@aleph-alpha/chat-kit 5.12.0 → 5.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 (31) hide show
  1. package/dist/{CkHistory.vue_vue_type_script_setup_true_lang-CImSzLYs.js → CkHistory.vue_vue_type_script_setup_true_lang-BNcJURkq.js} +105 -20
  2. package/dist/chat-kit.css +2 -2
  3. package/dist/components/base/CkCitation/CkCitation.stories.d.ts +1 -4
  4. package/dist/components/base/CkCitation/CkCitation.stories.d.ts.map +1 -1
  5. package/dist/components/base/CkCitation/CkCitation.vue.d.ts.map +1 -1
  6. package/dist/components/base/CkCitation/types.d.ts +6 -1
  7. package/dist/components/base/CkCitation/types.d.ts.map +1 -1
  8. package/dist/components/base/CkCitationCard/CkCitationCard.stories.d.ts +13 -2
  9. package/dist/components/base/CkCitationCard/CkCitationCard.stories.d.ts.map +1 -1
  10. package/dist/components/base/CkCitationCard/CkCitationCard.vue.d.ts +1 -0
  11. package/dist/components/base/CkCitationCard/CkCitationCard.vue.d.ts.map +1 -1
  12. package/dist/components/base/CkCitationCard/types.d.ts +6 -1
  13. package/dist/components/base/CkCitationCard/types.d.ts.map +1 -1
  14. package/dist/components/base/CkCitationLabel/CkCitationLabel.vue.d.ts.map +1 -1
  15. package/dist/components/index.js +1 -1
  16. package/dist/composables/useIsTruncated.d.ts +22 -0
  17. package/dist/composables/useIsTruncated.d.ts.map +1 -0
  18. package/dist/index.js +1 -1
  19. package/package.json +3 -3
  20. package/src/components/base/CkCitation/CkCitation.spec.ts +3 -3
  21. package/src/components/base/CkCitation/CkCitation.stories.ts +85 -3
  22. package/src/components/base/CkCitation/CkCitation.vue +5 -1
  23. package/src/components/base/CkCitation/types.ts +6 -1
  24. package/src/components/base/CkCitationCard/CkCitationCard.spec.ts +37 -0
  25. package/src/components/base/CkCitationCard/CkCitationCard.stories.ts +30 -3
  26. package/src/components/base/CkCitationCard/CkCitationCard.vue +53 -11
  27. package/src/components/base/CkCitationCard/types.ts +6 -1
  28. package/src/components/base/CkCitationLabel/CkCitationLabel.spec.ts +3 -3
  29. package/src/components/base/CkCitationLabel/CkCitationLabel.vue +6 -5
  30. package/src/components/base/CkFeedbackDialog/CkFeedbackDialog.spec.ts +1 -1
  31. package/src/composables/useIsTruncated.ts +82 -0
@@ -1,5 +1,5 @@
1
- import { defineComponent, openBlock, createBlock, unref, createElementBlock, createElementVNode, normalizeClass, renderSlot, createCommentVNode, mergeProps, withCtx, computed, createVNode, toDisplayString, resolveDynamicComponent, createTextVNode, ref, onBeforeUnmount, useSlots, onMounted, nextTick, onUnmounted, watch, Fragment, renderList, normalizeStyle, Transition, createStaticVNode, Teleport, withModifiers, toValue, h, toRefs, useId, useAttrs, useTemplateRef, onUpdated, createSlots, normalizeProps, guardReactiveProps, Comment, Text } from "vue";
2
- import { UiIcon, UiButton, UiFileType, UiPopover, UiPopoverTrigger, UiPopoverContent, UiTooltip, formatFileSize, UiDialog, UiDialogContent, UiDialogDescription, UiFieldLabel, UiToggleGroup, UiToggleGroupItem, UiField, UiTextarea, UiFileItem, UiProgress, Primitive, UiFloatActions, UiFloatActionItems, UiCodeBlock, UiAvatar, UiAvatarImage, UiSpinner, UiAvatarFallback, UiSidebarPopoverMenu, UiSidebarPopoverMenuItem } from "@aleph-alpha/ui-library";
1
+ import { defineComponent, openBlock, createBlock, unref, createElementBlock, createElementVNode, normalizeClass, renderSlot, createCommentVNode, mergeProps, withCtx, ref, watch, onScopeDispose, computed, useTemplateRef, createVNode, toDisplayString, resolveDynamicComponent, onBeforeUnmount, useSlots, onMounted, nextTick, onUnmounted, Fragment, renderList, normalizeStyle, Transition, createStaticVNode, Teleport, withModifiers, toValue, h, toRefs, useId, createTextVNode, useAttrs, onUpdated, createSlots, normalizeProps, guardReactiveProps, Comment, Text } from "vue";
2
+ import { UiIcon, UiButton, UiFileType, UiTooltip, UiPopover, UiPopoverTrigger, UiPopoverContent, formatFileSize, UiDialog, UiDialogContent, UiDialogDescription, UiFieldLabel, UiToggleGroup, UiToggleGroupItem, UiField, UiTextarea, UiFileItem, UiProgress, Primitive, UiFloatActions, UiFloatActionItems, UiCodeBlock, UiAvatar, UiAvatarImage, UiSpinner, UiAvatarFallback, UiSidebarPopoverMenu, UiSidebarPopoverMenuItem } from "@aleph-alpha/ui-library";
3
3
  import { u as useChatKitLabels, d as defaultChatKitLabels, r as remarkCitations, b as useMarkdownParser } from "./useChatKitLabels-CMOr3Kjq.js";
4
4
  const MINUTE = 60;
5
5
  const HOUR = 60 * MINUTE;
@@ -181,13 +181,59 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
181
181
  };
182
182
  }
183
183
  });
184
+ const measurers = /* @__PURE__ */ new WeakMap();
185
+ let sharedObserver;
186
+ function getSharedObserver() {
187
+ if (typeof ResizeObserver === "undefined") return void 0;
188
+ sharedObserver ??= new ResizeObserver((entries) => {
189
+ for (const entry of entries) measurers.get(entry.target)?.();
190
+ });
191
+ return sharedObserver;
192
+ }
193
+ function watchElement(el, measure) {
194
+ measurers.set(el, measure);
195
+ getSharedObserver()?.observe(el);
196
+ }
197
+ function unwatchElement(el) {
198
+ measurers.delete(el);
199
+ getSharedObserver()?.unobserve(el);
200
+ }
201
+ function useIsTruncated(elementRef, watchSource) {
202
+ const isTruncated = ref(false);
203
+ function measure() {
204
+ const el = elementRef.value;
205
+ isTruncated.value = el ? el.scrollWidth - el.clientWidth >= 1 : false;
206
+ }
207
+ if (watchSource) watch(watchSource, measure, { flush: "post" });
208
+ watch(
209
+ elementRef,
210
+ (el, previous) => {
211
+ if (previous) unwatchElement(previous);
212
+ if (el) watchElement(el, measure);
213
+ measure();
214
+ },
215
+ { immediate: true, flush: "post" }
216
+ );
217
+ onScopeDispose(() => {
218
+ if (elementRef.value) unwatchElement(elementRef.value);
219
+ });
220
+ return isTruncated;
221
+ }
184
222
  const _hoisted_1$d = { class: "ck-citation-card flex w-[22.5rem] max-w-[90vw] flex-col gap-2 rounded-md bg-background-surface-floating px-6 pb-6 pt-4 shadow-md" };
185
- const _hoisted_2$8 = { class: "flex items-center gap-2" };
186
- const _hoisted_3$7 = ["title"];
187
- const _hoisted_4$7 = { class: "line-clamp-6 break-words text-sm leading-5 text-content-on-surface-secondary" };
188
- const _hoisted_5$4 = {
223
+ const _hoisted_2$8 = { class: "flex min-w-0 items-center gap-3 py-0.5" };
224
+ const _hoisted_3$7 = { class: "line-clamp-6 break-words text-sm leading-5 text-content-on-surface-secondary" };
225
+ const _hoisted_4$7 = {
189
226
  key: 0,
190
- class: "text-sm leading-5 text-content-on-surface-muted"
227
+ class: "flex items-center gap-1.5 text-sm leading-5 text-content-on-surface-muted"
228
+ };
229
+ const _hoisted_5$4 = {
230
+ key: 1,
231
+ "aria-hidden": "true",
232
+ class: "shrink-0 text-border-input-strong"
233
+ };
234
+ const _hoisted_6$4 = {
235
+ key: 2,
236
+ class: "shrink-0"
191
237
  };
192
238
  const _sfc_main$p = /* @__PURE__ */ defineComponent({
193
239
  ...{
@@ -198,6 +244,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
198
244
  fileName: {},
199
245
  snippet: {},
200
246
  locationLabel: { default: void 0 },
247
+ collectionName: { default: void 0 },
201
248
  url: { default: void 0 },
202
249
  openSourceLabel: { default: void 0 }
203
250
  },
@@ -209,6 +256,13 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
209
256
  const openSourceAriaLabel = computed(
210
257
  () => props.openSourceLabel ?? labels.value.citationOpenSource ?? defaultChatKitLabels.citationOpenSource
211
258
  );
259
+ const fileNameRef = useTemplateRef("fileNameRef");
260
+ const collectionRef = useTemplateRef("collectionRef");
261
+ const isFileNameTruncated = useIsTruncated(fileNameRef, () => props.fileName);
262
+ const isCollectionTruncated = useIsTruncated(
263
+ collectionRef,
264
+ () => props.collectionName
265
+ );
212
266
  function handleOpen() {
213
267
  if (props.url) {
214
268
  emit("open-source", props.url);
@@ -221,10 +275,20 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
221
275
  filename: __props.fileName,
222
276
  class: "shrink-0"
223
277
  }, null, 8, ["filename"]),
224
- createElementVNode("p", {
225
- class: "min-w-0 truncate text-sm font-medium text-content-on-surface-primary",
226
- title: __props.fileName
227
- }, toDisplayString(__props.fileName), 9, _hoisted_3$7),
278
+ createVNode(unref(UiTooltip), {
279
+ content: __props.fileName,
280
+ disabled: !unref(isFileNameTruncated),
281
+ align: "start"
282
+ }, {
283
+ default: withCtx(() => [
284
+ createElementVNode("p", {
285
+ ref_key: "fileNameRef",
286
+ ref: fileNameRef,
287
+ class: "min-w-0 truncate text-sm font-medium leading-4 text-content-on-surface-primary"
288
+ }, toDisplayString(__props.fileName), 513)
289
+ ]),
290
+ _: 1
291
+ }, 8, ["content", "disabled"]),
228
292
  __props.url ? (openBlock(), createBlock(unref(UiButton), {
229
293
  key: 0,
230
294
  variant: "ghost",
@@ -243,8 +307,26 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
243
307
  _: 1
244
308
  }, 8, ["aria-label"])) : createCommentVNode("", true)
245
309
  ]),
246
- createElementVNode("p", _hoisted_4$7, toDisplayString(__props.snippet), 1),
247
- __props.locationLabel ? (openBlock(), createElementBlock("p", _hoisted_5$4, toDisplayString(__props.locationLabel), 1)) : createCommentVNode("", true)
310
+ createElementVNode("p", _hoisted_3$7, toDisplayString(__props.snippet), 1),
311
+ __props.collectionName || __props.locationLabel ? (openBlock(), createElementBlock("p", _hoisted_4$7, [
312
+ __props.collectionName ? (openBlock(), createBlock(unref(UiTooltip), {
313
+ key: 0,
314
+ content: __props.collectionName,
315
+ disabled: !unref(isCollectionTruncated),
316
+ align: "start"
317
+ }, {
318
+ default: withCtx(() => [
319
+ createElementVNode("span", {
320
+ ref_key: "collectionRef",
321
+ ref: collectionRef,
322
+ class: "min-w-0 truncate"
323
+ }, toDisplayString(__props.collectionName), 513)
324
+ ]),
325
+ _: 1
326
+ }, 8, ["content", "disabled"])) : createCommentVNode("", true),
327
+ __props.collectionName && __props.locationLabel ? (openBlock(), createElementBlock("span", _hoisted_5$4, " | ")) : createCommentVNode("", true),
328
+ __props.locationLabel ? (openBlock(), createElementBlock("span", _hoisted_6$4, toDisplayString(__props.locationLabel), 1)) : createCommentVNode("", true)
329
+ ])) : createCommentVNode("", true)
248
330
  ]);
249
331
  };
250
332
  }
@@ -273,16 +355,17 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
273
355
  role: isButton.value ? void 0 : "img",
274
356
  "aria-label": resolvedAriaLabel.value,
275
357
  class: normalizeClass([
276
- "ck-citation mx-px inline-flex h-5 min-w-5 items-center justify-center rounded-sm px-1 align-middle text-sm leading-4 tabular-nums transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
358
+ "ck-citation ui-focus-ring mx-px inline-flex h-5 min-w-5 items-center justify-center rounded-sm border border-transparent px-1 align-middle text-sm leading-4 tabular-nums transition-colors",
277
359
  // The static chip is part of the prose: it must stay selectable so the
278
360
  // number survives a copy of the surrounding text. A control shouldn't
279
361
  // start a text selection on click, so button mode keeps `select-none`.
280
- isButton.value ? "select-none" : "",
281
- __props.selected ? "bg-background-accent-soft text-black" : "bg-background-accent-yellow text-background-status-warning"
362
+ // Only the control gets the hover layer; a static chip has no hover state.
363
+ isButton.value ? "select-none hover-layer hover-layer-default" : "",
364
+ __props.selected ? "bg-background-accent-soft text-content-on-accent-soft" : "bg-background-surface-citation text-content-on-surface-primary"
282
365
  ])
283
366
  }, {
284
367
  default: withCtx(() => [
285
- createTextVNode(toDisplayString(__props.index), 1)
368
+ createElementVNode("span", null, toDisplayString(__props.index), 1)
286
369
  ]),
287
370
  _: 1
288
371
  }, 8, ["type", "role", "aria-label", "class"]);
@@ -296,7 +379,7 @@ const _export_sfc = (sfc, props) => {
296
379
  }
297
380
  return target;
298
381
  };
299
- const CkCitationLabel = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["__scopeId", "data-v-66d74063"]]);
382
+ const CkCitationLabel = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["__scopeId", "data-v-554678fe"]]);
300
383
  const CLOSE_DELAY_MS = 80;
301
384
  const _sfc_main$n = /* @__PURE__ */ defineComponent({
302
385
  ...{
@@ -311,6 +394,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
311
394
  fileName: {},
312
395
  snippet: {},
313
396
  locationLabel: { default: void 0 },
397
+ collectionName: {},
314
398
  url: { default: void 0 }
315
399
  },
316
400
  emits: ["open-source"],
@@ -372,7 +456,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
372
456
  createVNode(unref(CkCitationLabel), {
373
457
  as: "button",
374
458
  index: __props.index,
375
- selected: __props.selected,
459
+ selected: __props.selected || open.value,
376
460
  "aria-label": __props.ariaLabel,
377
461
  onKeydown: onTriggerKeydown,
378
462
  onMouseenter: onPointerEnter,
@@ -397,10 +481,11 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
397
481
  "file-name": __props.fileName,
398
482
  snippet: __props.snippet,
399
483
  "location-label": __props.locationLabel,
484
+ "collection-name": __props.collectionName,
400
485
  url: __props.url,
401
486
  "open-source-label": __props.openSourceLabel,
402
487
  onOpenSource: _cache[0] || (_cache[0] = (u) => emit("open-source", u))
403
- }, null, 8, ["file-name", "snippet", "location-label", "url", "open-source-label"])
488
+ }, null, 8, ["file-name", "snippet", "location-label", "collection-name", "url", "open-source-label"])
404
489
  ]),
405
490
  _: 1
406
491
  })