@aleph-alpha/chat-kit 3.0.0 → 3.1.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-CwH5M5WD.js → CkInput.vue_vue_type_script_setup_true_lang-DKzc21Yp.js} +37 -14
- package/dist/components/base/CkAgentMessage/CkAgentMessage.vue.d.ts.map +1 -1
- package/dist/components/base/CkConversationLayout/CkConversationLayout.vue.d.ts.map +1 -1
- package/dist/components/base/CkMarkdownRenderer/CkMarkdownRenderer.vue.d.ts.map +1 -1
- package/dist/components/base/CkMarkdownRenderer/defaultMarkdownClasses.d.ts.map +1 -1
- package/dist/components/base/CkModelSelector/CkModelSelector.vue.d.ts.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/handlers/index.js +1 -1
- package/dist/handlers/useChatKitLabels.d.ts +6 -0
- package/dist/handlers/useChatKitLabels.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/{useChatKitLabels-ZutacPad.js → useChatKitLabels-CLsWWwgG.js} +1 -0
- package/package.json +1 -1
- package/src/components/base/CkAgentMessage/CkAgentMessage.vue +2 -2
- package/src/components/base/CkConversationLayout/CkConversationLayout.vue +3 -2
- package/src/components/base/CkMarkdownRenderer/CkMarkdownRenderer.vue +36 -4
- package/src/components/base/CkMarkdownRenderer/defaultMarkdownClasses.ts +2 -1
- package/src/components/base/CkModelSelector/CkModelSelector.vue +8 -3
- package/src/handlers/useChatKitLabels.ts +7 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent, openBlock, createBlock, unref, createElementBlock, createElementVNode, renderSlot, createCommentVNode, ref, onMounted, nextTick, onUnmounted, watch, Fragment, renderList, normalizeStyle, mergeProps, withCtx, createVNode, Transition, toDisplayString, createStaticVNode, computed, onBeforeUnmount, Teleport, withModifiers, normalizeClass, toRefs, h, useId, createTextVNode, useAttrs, useSlots, resolveDynamicComponent, useTemplateRef, onUpdated, createSlots, normalizeProps, guardReactiveProps } from "vue";
|
|
2
2
|
import { UiIcon, UiButton, UiTooltip, formatFileSize, UiDialog, UiDialogContent, UiDialogDescription, UiFieldLabel, UiToggleGroup, UiToggleGroupItem, UiField, UiTextarea, UiFileItem, UiPopover, UiPopoverTrigger, UiFileType, UiProgress, UiPopoverContent, Primitive, UiAvatar, UiAvatarImage, UiSpinner, UiAvatarFallback, UiSidebarPopoverMenu, UiSidebarPopoverMenuItem } from "@aleph-alpha/ui-library";
|
|
3
|
-
import { u as useChatKitLabels, d as defaultChatKitLabels, a as useMarkdownParser } from "./useChatKitLabels-
|
|
3
|
+
import { u as useChatKitLabels, d as defaultChatKitLabels, a as useMarkdownParser } from "./useChatKitLabels-CLsWWwgG.js";
|
|
4
4
|
const MINUTE = 60;
|
|
5
5
|
const HOUR = 60 * MINUTE;
|
|
6
6
|
const DAY = 24 * HOUR;
|
|
@@ -66,7 +66,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
|
-
const _hoisted_1$c = { class: "flex w-full flex-col gap-6 pb-6" };
|
|
69
|
+
const _hoisted_1$c = { class: "flex w-full min-w-0 flex-col gap-6 pb-6" };
|
|
70
70
|
const _hoisted_2$8 = {
|
|
71
71
|
key: 0,
|
|
72
72
|
class: "flex items-start gap-3"
|
|
@@ -81,7 +81,7 @@ const _hoisted_4$6 = {
|
|
|
81
81
|
"data-testid": "ck-agent-message-header",
|
|
82
82
|
class: "body-14-regular text-content-on-surface-muted min-w-0 flex-1 [word-break:break-word]"
|
|
83
83
|
};
|
|
84
|
-
const _hoisted_5$4 = { class: "text-content-on-surface-primary text-base leading-7" };
|
|
84
|
+
const _hoisted_5$4 = { class: "text-content-on-surface-primary min-w-0 text-base leading-7" };
|
|
85
85
|
const _hoisted_6$3 = {
|
|
86
86
|
key: 1,
|
|
87
87
|
class: "flex items-center gap-4"
|
|
@@ -113,11 +113,11 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
113
113
|
const _hoisted_1$b = ["data-message-row"];
|
|
114
114
|
const _hoisted_2$7 = {
|
|
115
115
|
key: 0,
|
|
116
|
-
class: "flex justify-end"
|
|
116
|
+
class: "flex min-w-0 justify-end"
|
|
117
117
|
};
|
|
118
118
|
const _hoisted_3$6 = {
|
|
119
119
|
key: 1,
|
|
120
|
-
class: "flex justify-start"
|
|
120
|
+
class: "flex min-w-0 justify-start"
|
|
121
121
|
};
|
|
122
122
|
const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
123
123
|
...{ name: "CkConversationLayout" },
|
|
@@ -257,7 +257,8 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
|
257
257
|
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.messages, (message) => {
|
|
258
258
|
return openBlock(), createElementBlock("div", {
|
|
259
259
|
key: message.id,
|
|
260
|
-
"data-message-row": message.role
|
|
260
|
+
"data-message-row": message.role,
|
|
261
|
+
class: "min-w-0"
|
|
261
262
|
}, [
|
|
262
263
|
message.role === "user" ? (openBlock(), createElementBlock("div", _hoisted_2$7, [
|
|
263
264
|
renderSlot(_ctx.$slots, "user-message", { message })
|
|
@@ -742,13 +743,14 @@ const CkFeedbackButton = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["__scopeId",
|
|
|
742
743
|
const defaultMarkdownClasses = {
|
|
743
744
|
p: "my-1 leading-7",
|
|
744
745
|
a: "underline underline-offset-4",
|
|
746
|
+
img: "max-w-full h-auto",
|
|
745
747
|
h1: "mt-4 mb-2 text-2xl font-bold",
|
|
746
748
|
h2: "mt-3 mb-2 text-xl font-semibold",
|
|
747
749
|
h3: "mt-3 mb-1 text-lg font-semibold",
|
|
748
750
|
ul: "my-1 ml-6 list-disc",
|
|
749
751
|
ol: "my-1 ml-6 list-decimal",
|
|
750
752
|
li: "my-0.5",
|
|
751
|
-
pre: "my-2 overflow-x-auto rounded-lg p-4",
|
|
753
|
+
pre: "my-2 max-w-full overflow-x-auto rounded-lg p-4",
|
|
752
754
|
code: "rounded px-1.5 py-0.5",
|
|
753
755
|
blockquote: "my-2 border-l-2 pl-4 italic",
|
|
754
756
|
table: "my-2 w-full border-collapse",
|
|
@@ -756,7 +758,8 @@ const defaultMarkdownClasses = {
|
|
|
756
758
|
td: "border p-2",
|
|
757
759
|
hr: "my-4"
|
|
758
760
|
};
|
|
759
|
-
|
|
761
|
+
const TABLE_WRAPPER_CLASS = "max-w-full overflow-x-auto";
|
|
762
|
+
function domToVNode(node, slots, classes, tableLabel) {
|
|
760
763
|
if (node.nodeType === Node.TEXT_NODE) return node.textContent;
|
|
761
764
|
if (node.nodeType !== Node.ELEMENT_NODE) return null;
|
|
762
765
|
const el = node;
|
|
@@ -768,7 +771,7 @@ function domToVNode(node, slots, classes) {
|
|
|
768
771
|
return slots["code-block"]({ code, language });
|
|
769
772
|
}
|
|
770
773
|
}
|
|
771
|
-
const children = Array.from(node.childNodes).map((child) => domToVNode(child, slots, classes)).filter((c) => c != null);
|
|
774
|
+
const children = Array.from(node.childNodes).map((child) => domToVNode(child, slots, classes, tableLabel)).filter((c) => c != null);
|
|
772
775
|
const attrs = {};
|
|
773
776
|
for (const attr of el.attributes) {
|
|
774
777
|
attrs[attr.name] = attr.value;
|
|
@@ -778,7 +781,20 @@ function domToVNode(node, slots, classes) {
|
|
|
778
781
|
if (customClass) {
|
|
779
782
|
attrs.class = attrs.class ? `${attrs.class} ${customClass}` : customClass;
|
|
780
783
|
}
|
|
781
|
-
|
|
784
|
+
const vnode = h(tag, attrs, children);
|
|
785
|
+
if (tag === "table") {
|
|
786
|
+
return h(
|
|
787
|
+
"div",
|
|
788
|
+
{
|
|
789
|
+
class: TABLE_WRAPPER_CLASS,
|
|
790
|
+
tabindex: "0",
|
|
791
|
+
role: "region",
|
|
792
|
+
"aria-label": tableLabel
|
|
793
|
+
},
|
|
794
|
+
[vnode]
|
|
795
|
+
);
|
|
796
|
+
}
|
|
797
|
+
return vnode;
|
|
782
798
|
}
|
|
783
799
|
const _sfc_main$f = defineComponent({
|
|
784
800
|
name: "CkMarkdownRenderer",
|
|
@@ -793,6 +809,7 @@ const _sfc_main$f = defineComponent({
|
|
|
793
809
|
setup(props, { slots }) {
|
|
794
810
|
const { content, plugins } = toRefs(props);
|
|
795
811
|
const { html } = useMarkdownParser(content, plugins);
|
|
812
|
+
const labels = useChatKitLabels();
|
|
796
813
|
const parsedNodes = computed(() => {
|
|
797
814
|
const raw = html.value;
|
|
798
815
|
if (!raw) return [];
|
|
@@ -805,8 +822,13 @@ const _sfc_main$f = defineComponent({
|
|
|
805
822
|
}));
|
|
806
823
|
return () => {
|
|
807
824
|
const elementClasses = mergedClasses.value;
|
|
808
|
-
const
|
|
809
|
-
|
|
825
|
+
const tableLabel = labels.value.markdownTableLabel ?? defaultChatKitLabels.markdownTableLabel;
|
|
826
|
+
const children = parsedNodes.value.map((node) => domToVNode(node, slots, elementClasses, tableLabel)).filter((c) => c != null);
|
|
827
|
+
return h(
|
|
828
|
+
"div",
|
|
829
|
+
{ class: "markdown-renderer min-w-0 break-words" },
|
|
830
|
+
children
|
|
831
|
+
);
|
|
810
832
|
};
|
|
811
833
|
}
|
|
812
834
|
});
|
|
@@ -1596,7 +1618,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
1596
1618
|
}
|
|
1597
1619
|
});
|
|
1598
1620
|
const _hoisted_1$3 = ["disabled", "aria-expanded", "aria-label"];
|
|
1599
|
-
const _hoisted_2$2 = { class: "max-w-[10rem] truncate" };
|
|
1621
|
+
const _hoisted_2$2 = { class: "min-w-0 max-w-[10rem] truncate" };
|
|
1600
1622
|
const _hoisted_3$1 = ["aria-label"];
|
|
1601
1623
|
const _hoisted_4$1 = ["aria-selected", "onClick"];
|
|
1602
1624
|
const _hoisted_5 = { class: "min-w-0 flex-1 truncate" };
|
|
@@ -1644,7 +1666,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
1644
1666
|
default: withCtx(() => [
|
|
1645
1667
|
createElementVNode("button", {
|
|
1646
1668
|
type: "button",
|
|
1647
|
-
class: "ck-model-selector__trigger inline-flex h-9
|
|
1669
|
+
class: "ck-model-selector__trigger inline-flex h-9 min-w-0 items-center gap-1 rounded-3xl px-3 label-14-medium text-content-on-surface-primary outline-none transition-colors hover:bg-background-surface-muted focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
|
|
1648
1670
|
disabled: __props.disabled,
|
|
1649
1671
|
"aria-haspopup": "listbox",
|
|
1650
1672
|
"aria-expanded": open.value,
|
|
@@ -1654,6 +1676,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
1654
1676
|
createVNode(unref(UiIcon), {
|
|
1655
1677
|
name: "chevron-down",
|
|
1656
1678
|
size: 16,
|
|
1679
|
+
class: "shrink-0",
|
|
1657
1680
|
"aria-hidden": "true"
|
|
1658
1681
|
})
|
|
1659
1682
|
], 8, _hoisted_1$3)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CkAgentMessage.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkAgentMessage/CkAgentMessage.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CkAgentMessage.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkAgentMessage/CkAgentMessage.vue"],"names":[],"mappings":"AA0GA,QAAA,IAAI,OAAO,IAAU,EAAE,OAAO,IAAU,EAAE,OAAO,IAAU,EAAE,OAAO,IAAW,CAAE;AACjF,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GACzC;IAAE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GAC3C;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GAC5C;IAAE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAK9C,QAAA,MAAM,UAAU,+QACd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CkConversationLayout.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkConversationLayout/CkConversationLayout.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CkConversationLayout.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkConversationLayout/CkConversationLayout.vue"],"names":[],"mappings":"AAoNA,QAAA,MAAM,YAAY,GAAK,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAC5D,aAAa,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,EAC9D,YAAY,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,EAC3G,gBAAgB,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,EAClE;WA6PO,OAAO,KAAK,EAAE,WAAW,GAAG,mBAAmB;kBAzP3C,CAAC,EAAE;MAyP2D,GAAG,CAAC,OAAO,UAAU,SAAS;QAAE,oBAAoB,EAAE,MAAM,CAAC,CAAA;KAAE,GAAG,CAAC,GAAG,EAAE,CAAC;YAC1I,CAAC,OAAO,EAAE,EAAE,KAAK,IAAI;WACtB,GAAG;;wBAtPO,CAAC,KAAK,EAAE;YAAE,OAAO,EAAE,CAAC,CAAA;SAAE,KAAK,IAAI;yBAC9B,CAAC,KAAK,EAAE;YAAE,OAAO,EAAE,CAAC,CAAA;SAAE,KAAK,IAAI;;UAuP3C,EAAE;EAEL,KACQ,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAI,CAAC;wBACvD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,CAAC,GAAG,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CkMarkdownRenderer.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkMarkdownRenderer/CkMarkdownRenderer.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CkMarkdownRenderer.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkMarkdownRenderer/CkMarkdownRenderer.vue"],"names":[],"mappings":"AA4HA,OAAO,EAKL,KAAK,QAAQ,EAEb,KAAK,KAAK,EACX,MAAM,KAAK,CAAC;AACb,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAM7C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;wBA6DnC,OAAO,YAAY;AAAxC,wBAAyC;AAQzC,QAAA,MAAM,YAAY;;;;;;cAKI,QAAQ,CAAC,wBAAwB,CAAC;;;;cAG1B,QAAQ,CAAC,aAAa,CAAC;;;;;;;;;;;cAH/B,QAAQ,CAAC,wBAAwB,CAAC;;;;cAG1B,QAAQ,CAAC,aAAa,CAAC;;;;;;4EAkCnD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultMarkdownClasses.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkMarkdownRenderer/defaultMarkdownClasses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD,eAAO,MAAM,sBAAsB,EAAE,
|
|
1
|
+
{"version":3,"file":"defaultMarkdownClasses.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkMarkdownRenderer/defaultMarkdownClasses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD,eAAO,MAAM,sBAAsB,EAAE,wBAiBpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CkModelSelector.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkModelSelector/CkModelSelector.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CkModelSelector.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkModelSelector/CkModelSelector.vue"],"names":[],"mappings":"AAiIA,OAAO,KAAK,EAAwB,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAiR1E,QAAA,MAAM,YAAY;;;;;;;;;;;6EAIhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
package/dist/components/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _, a, b, C, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u } from "../CkInput.vue_vue_type_script_setup_true_lang-
|
|
1
|
+
import { _, a, b, C, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u } from "../CkInput.vue_vue_type_script_setup_true_lang-DKzc21Yp.js";
|
|
2
2
|
export {
|
|
3
3
|
_ as CkAgentMessage,
|
|
4
4
|
a as CkConversation,
|
package/dist/handlers/index.js
CHANGED
|
@@ -73,6 +73,12 @@ export type ChatKitLabels = {
|
|
|
73
73
|
modelSelectorListAriaLabel?: string;
|
|
74
74
|
/** Trigger text shown by `CkModelSelector` when no model is selected. */
|
|
75
75
|
modelSelectorPlaceholder?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Accessible label for the horizontally scrollable wrapper around markdown
|
|
78
|
+
* tables in `CkMarkdownRenderer` (the wrapper is focusable so keyboard users
|
|
79
|
+
* can scroll wide tables). Falls back to `defaultChatKitLabels` when omitted.
|
|
80
|
+
*/
|
|
81
|
+
markdownTableLabel?: string;
|
|
76
82
|
/** Fallback title used by `CkHistory` when a conversation has no `title`. */
|
|
77
83
|
historyItemUntitled: string;
|
|
78
84
|
/** Accessible name for the trailing kebab trigger on each `CkHistory` row. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChatKitLabels.d.ts","sourceRoot":"","sources":["../../src/handlers/useChatKitLabels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAG1D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,0CAA0C;IAC1C,cAAc,EAAE,MAAM,CAAC;IACvB,4CAA4C;IAC5C,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gDAAgD;IAChD,gBAAgB,EAAE,MAAM,CAAC;IACzB,sFAAsF;IACtF,iBAAiB,EAAE,MAAM,CAAC;IAC1B,4FAA4F;IAC5F,uBAAuB,EAAE,MAAM,CAAC;IAChC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+DAA+D;IAC/D,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,+DAA+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CAAC;IAC5B,8EAA8E;IAC9E,0BAA0B,EAAE,MAAM,CAAC;IACnC,uEAAuE;IACvE,qBAAqB,EAAE,MAAM,CAAC;IAC9B,yEAAyE;IACzE,uBAAuB,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,yEAAyE;AACzE,eAAO,MAAM,oBAAoB,EAAE,aA+BlC,CAAC;AAEF,4CAA4C;AAC5C,eAAO,MAAM,eAAe,EAAE,YAAY,CAAC,WAAW,CAAC,aAAa,CAAC,CAC1C,CAAC;AAE5B,KAAK,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAE5C,yFAAyF;AACzF,KAAK,cAAc,GACf,GAAG,CAAC,aAAa,CAAC,GAClB,WAAW,CAAC,aAAa,CAAC,GAC1B,CAAC,MAAM,aAAa,CAAC,CAAC;AAE1B;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAKjE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,IAAI,WAAW,CAAC,aAAa,CAAC,CAK7D"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { u } from "./useMessageHandler-CMdy-lm0.js";
|
|
2
|
-
import { C, d, p, u as u2, a } from "./useChatKitLabels-
|
|
2
|
+
import { C, d, p, u as u2, a } from "./useChatKitLabels-CLsWWwgG.js";
|
|
3
3
|
import { S, c, d as d2, a as a2, u as u3, b, e, f } from "./index-THzZwfMU.js";
|
|
4
|
-
import { _, a as a3, b as b2, C as C2, c as c2, d as d3, e as e2, f as f2, g, h, i, j, k, l, m, n, o, p as p2, q, r, s, t, u as u4, v } from "./CkInput.vue_vue_type_script_setup_true_lang-
|
|
4
|
+
import { _, a as a3, b as b2, C as C2, c as c2, d as d3, e as e2, f as f2, g, h, i, j, k, l, m, n, o, p as p2, q, r, s, t, u as u4, v } from "./CkInput.vue_vue_type_script_setup_true_lang-DKzc21Yp.js";
|
|
5
5
|
export {
|
|
6
6
|
C as CHAT_KIT_LABELS,
|
|
7
7
|
_ as CkAgentMessage,
|
|
@@ -12722,6 +12722,7 @@ const defaultChatKitLabels = {
|
|
|
12722
12722
|
modelSelectorAriaLabel: "Select model",
|
|
12723
12723
|
modelSelectorListAriaLabel: "Models",
|
|
12724
12724
|
modelSelectorPlaceholder: "Select model",
|
|
12725
|
+
markdownTableLabel: "Table",
|
|
12725
12726
|
historyItemUntitled: "Untitled conversation",
|
|
12726
12727
|
historyItemActionAriaLabel: "Conversation options",
|
|
12727
12728
|
historyItemEditAction: "Edit",
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ defineOptions({ name: 'CkAgentMessage' });
|
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<template>
|
|
6
|
-
<div class="flex w-full flex-col gap-6 pb-6">
|
|
6
|
+
<div class="flex w-full min-w-0 flex-col gap-6 pb-6">
|
|
7
7
|
<div v-if="$slots.icon || $slots.header" class="flex items-start gap-3">
|
|
8
8
|
<div
|
|
9
9
|
v-if="$slots.icon"
|
|
@@ -21,7 +21,7 @@ defineOptions({ name: 'CkAgentMessage' });
|
|
|
21
21
|
</span>
|
|
22
22
|
</div>
|
|
23
23
|
|
|
24
|
-
<div class="text-content-on-surface-primary text-base leading-7">
|
|
24
|
+
<div class="text-content-on-surface-primary min-w-0 text-base leading-7">
|
|
25
25
|
<slot />
|
|
26
26
|
</div>
|
|
27
27
|
|
|
@@ -188,11 +188,12 @@ watch(
|
|
|
188
188
|
v-for="message in messages"
|
|
189
189
|
:key="message.id"
|
|
190
190
|
:data-message-row="message.role"
|
|
191
|
+
class="min-w-0"
|
|
191
192
|
>
|
|
192
|
-
<div v-if="message.role === 'user'" class="flex justify-end">
|
|
193
|
+
<div v-if="message.role === 'user'" class="flex min-w-0 justify-end">
|
|
193
194
|
<slot name="user-message" :message="message" />
|
|
194
195
|
</div>
|
|
195
|
-
<div v-else class="flex justify-start">
|
|
196
|
+
<div v-else class="flex min-w-0 justify-start">
|
|
196
197
|
<slot name="agent-message" :message="message" />
|
|
197
198
|
</div>
|
|
198
199
|
</div>
|
|
@@ -10,13 +10,22 @@ import {
|
|
|
10
10
|
} from 'vue';
|
|
11
11
|
import type { PluggableList } from 'unified';
|
|
12
12
|
import { useMarkdownParser } from '../../../handlers/useMarkdownParser';
|
|
13
|
+
import {
|
|
14
|
+
defaultChatKitLabels,
|
|
15
|
+
useChatKitLabels,
|
|
16
|
+
} from '../../../handlers/useChatKitLabels';
|
|
13
17
|
import type { CkMarkdownElementClasses } from './types';
|
|
14
18
|
import { defaultMarkdownClasses } from './defaultMarkdownClasses';
|
|
15
19
|
|
|
20
|
+
// Tables are wrapped in a horizontally scrollable container so wide content
|
|
21
|
+
// never forces the whole message column wider on narrow viewports.
|
|
22
|
+
const TABLE_WRAPPER_CLASS = 'max-w-full overflow-x-auto';
|
|
23
|
+
|
|
16
24
|
function domToVNode(
|
|
17
25
|
node: Node,
|
|
18
26
|
slots: Slots,
|
|
19
27
|
classes: CkMarkdownElementClasses,
|
|
28
|
+
tableLabel: string,
|
|
20
29
|
): VNode | string | null {
|
|
21
30
|
if (node.nodeType === Node.TEXT_NODE) return node.textContent;
|
|
22
31
|
if (node.nodeType !== Node.ELEMENT_NODE) return null;
|
|
@@ -34,7 +43,7 @@ function domToVNode(
|
|
|
34
43
|
}
|
|
35
44
|
|
|
36
45
|
const children = Array.from(node.childNodes)
|
|
37
|
-
.map((child) => domToVNode(child, slots, classes))
|
|
46
|
+
.map((child) => domToVNode(child, slots, classes, tableLabel))
|
|
38
47
|
.filter((c): c is VNode | string => c != null);
|
|
39
48
|
|
|
40
49
|
const attrs: Record<string, string> = {};
|
|
@@ -48,7 +57,22 @@ function domToVNode(
|
|
|
48
57
|
attrs.class = attrs.class ? `${attrs.class} ${customClass}` : customClass;
|
|
49
58
|
}
|
|
50
59
|
|
|
51
|
-
|
|
60
|
+
const vnode = h(tag, attrs, children);
|
|
61
|
+
|
|
62
|
+
if (tag === 'table') {
|
|
63
|
+
return h(
|
|
64
|
+
'div',
|
|
65
|
+
{
|
|
66
|
+
class: TABLE_WRAPPER_CLASS,
|
|
67
|
+
tabindex: '0',
|
|
68
|
+
role: 'region',
|
|
69
|
+
'aria-label': tableLabel,
|
|
70
|
+
},
|
|
71
|
+
[vnode],
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return vnode;
|
|
52
76
|
}
|
|
53
77
|
|
|
54
78
|
export default defineComponent({
|
|
@@ -64,6 +88,7 @@ export default defineComponent({
|
|
|
64
88
|
setup(props, { slots }) {
|
|
65
89
|
const { content, plugins } = toRefs(props);
|
|
66
90
|
const { html } = useMarkdownParser(content, plugins);
|
|
91
|
+
const labels = useChatKitLabels();
|
|
67
92
|
|
|
68
93
|
const parsedNodes = computed(() => {
|
|
69
94
|
const raw = html.value;
|
|
@@ -79,10 +104,17 @@ export default defineComponent({
|
|
|
79
104
|
|
|
80
105
|
return () => {
|
|
81
106
|
const elementClasses = mergedClasses.value;
|
|
107
|
+
const tableLabel =
|
|
108
|
+
labels.value.markdownTableLabel ??
|
|
109
|
+
defaultChatKitLabels.markdownTableLabel!;
|
|
82
110
|
const children = parsedNodes.value
|
|
83
|
-
.map((node) => domToVNode(node, slots, elementClasses))
|
|
111
|
+
.map((node) => domToVNode(node, slots, elementClasses, tableLabel))
|
|
84
112
|
.filter((c): c is VNode | string => c != null);
|
|
85
|
-
return h(
|
|
113
|
+
return h(
|
|
114
|
+
'div',
|
|
115
|
+
{ class: 'markdown-renderer min-w-0 break-words' },
|
|
116
|
+
children,
|
|
117
|
+
);
|
|
86
118
|
};
|
|
87
119
|
},
|
|
88
120
|
});
|
|
@@ -3,13 +3,14 @@ import type { CkMarkdownElementClasses } from './types';
|
|
|
3
3
|
export const defaultMarkdownClasses: CkMarkdownElementClasses = {
|
|
4
4
|
p: 'my-1 leading-7',
|
|
5
5
|
a: 'underline underline-offset-4',
|
|
6
|
+
img: 'max-w-full h-auto',
|
|
6
7
|
h1: 'mt-4 mb-2 text-2xl font-bold',
|
|
7
8
|
h2: 'mt-3 mb-2 text-xl font-semibold',
|
|
8
9
|
h3: 'mt-3 mb-1 text-lg font-semibold',
|
|
9
10
|
ul: 'my-1 ml-6 list-disc',
|
|
10
11
|
ol: 'my-1 ml-6 list-decimal',
|
|
11
12
|
li: 'my-0.5',
|
|
12
|
-
pre: 'my-2 overflow-x-auto rounded-lg p-4',
|
|
13
|
+
pre: 'my-2 max-w-full overflow-x-auto rounded-lg p-4',
|
|
13
14
|
code: 'rounded px-1.5 py-0.5',
|
|
14
15
|
blockquote: 'my-2 border-l-2 pl-4 italic',
|
|
15
16
|
table: 'my-2 w-full border-collapse',
|
|
@@ -63,14 +63,19 @@ function select(id: string) {
|
|
|
63
63
|
<UiPopoverTrigger as-child>
|
|
64
64
|
<button
|
|
65
65
|
type="button"
|
|
66
|
-
class="ck-model-selector__trigger inline-flex h-9
|
|
66
|
+
class="ck-model-selector__trigger inline-flex h-9 min-w-0 items-center gap-1 rounded-3xl px-3 label-14-medium text-content-on-surface-primary outline-none transition-colors hover:bg-background-surface-muted focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"
|
|
67
67
|
:disabled="disabled"
|
|
68
68
|
aria-haspopup="listbox"
|
|
69
69
|
:aria-expanded="open"
|
|
70
70
|
:aria-label="triggerAriaLabel"
|
|
71
71
|
>
|
|
72
|
-
<span class="max-w-[10rem] truncate">{{ selectedLabel }}</span>
|
|
73
|
-
<UiIcon
|
|
72
|
+
<span class="min-w-0 max-w-[10rem] truncate">{{ selectedLabel }}</span>
|
|
73
|
+
<UiIcon
|
|
74
|
+
name="chevron-down"
|
|
75
|
+
:size="16"
|
|
76
|
+
class="shrink-0"
|
|
77
|
+
aria-hidden="true"
|
|
78
|
+
/>
|
|
74
79
|
</button>
|
|
75
80
|
</UiPopoverTrigger>
|
|
76
81
|
<UiPopoverContent
|
|
@@ -75,6 +75,12 @@ export type ChatKitLabels = {
|
|
|
75
75
|
modelSelectorListAriaLabel?: string;
|
|
76
76
|
/** Trigger text shown by `CkModelSelector` when no model is selected. */
|
|
77
77
|
modelSelectorPlaceholder?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Accessible label for the horizontally scrollable wrapper around markdown
|
|
80
|
+
* tables in `CkMarkdownRenderer` (the wrapper is focusable so keyboard users
|
|
81
|
+
* can scroll wide tables). Falls back to `defaultChatKitLabels` when omitted.
|
|
82
|
+
*/
|
|
83
|
+
markdownTableLabel?: string;
|
|
78
84
|
/** Fallback title used by `CkHistory` when a conversation has no `title`. */
|
|
79
85
|
historyItemUntitled: string;
|
|
80
86
|
/** Accessible name for the trailing kebab trigger on each `CkHistory` row. */
|
|
@@ -116,6 +122,7 @@ export const defaultChatKitLabels: ChatKitLabels = {
|
|
|
116
122
|
modelSelectorAriaLabel: 'Select model',
|
|
117
123
|
modelSelectorListAriaLabel: 'Models',
|
|
118
124
|
modelSelectorPlaceholder: 'Select model',
|
|
125
|
+
markdownTableLabel: 'Table',
|
|
119
126
|
historyItemUntitled: 'Untitled conversation',
|
|
120
127
|
historyItemActionAriaLabel: 'Conversation options',
|
|
121
128
|
historyItemEditAction: 'Edit',
|