@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
@@ -10,11 +10,8 @@ import type { Meta, StoryObj } from '@storybook/vue3-vite';
10
10
  declare const meta: Meta<typeof CkCitation>;
11
11
  export default meta;
12
12
  type Story = StoryObj<typeof meta>;
13
- /**
14
- * A single marker in its default (amber) state. Hover the chip (or focus it and
15
- * press Enter) to reveal the source card.
16
- */
17
13
  export declare const Default: Story;
14
+ export declare const States: Story;
18
15
  /**
19
16
  * The selected (teal) state — set `selected` when the citation's source is the
20
17
  * one currently open/highlighted, so the active marker stands out.
@@ -1 +1 @@
1
- {"version":3,"file":"CkCitation.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkCitation/CkCitation.stories.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAK3D;;;;;;GAMG;AACH,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,UAAU,CA2BjC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC;;;GAGG;AACH,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC;AAEjC;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,KAEtB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,KAqB1B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,KAE7B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,KAEzB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,KAK1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,KAE7B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,KAsBzB,CAAC"}
1
+ {"version":3,"file":"CkCitation.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkCitation/CkCitation.stories.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAE1C,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAK3D;;;;;;GAMG;AACH,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,UAAU,CA2BjC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AA6BnC,eAAO,MAAM,OAAO,EAAE,KAErB,CAAC;AAoBF,eAAO,MAAM,MAAM,EAAE,KAoCpB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,KAEtB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,KAqB1B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,KAE7B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,KAEzB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,KAK1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,KAE7B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,KAsBzB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"CkCitation.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkCitation/CkCitation.vue"],"names":[],"mappings":"AA0JA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AA+R/C,QAAA,MAAM,YAAY;;;;;;;;;;6EAIhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"CkCitation.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkCitation/CkCitation.vue"],"names":[],"mappings":"AA8JA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAiS/C,QAAA,MAAM,YAAY;;;;;;;;;;6EAIhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -27,6 +27,11 @@ export interface CkCitationSource {
27
27
  * non-paginated sources.
28
28
  */
29
29
  locationLabel?: string;
30
+ /**
31
+ * Name of the collection the source belongs to, shown in the card footer
32
+ * before the location. Omit when the source has no collection.
33
+ */
34
+ collectionName?: string;
30
35
  /**
31
36
  * Source URL for the card's external-link action. Activating it emits
32
37
  * `open-source`. Omit to hide the action.
@@ -52,7 +57,7 @@ export interface CkCitationProps extends CkCitationSource {
52
57
  /**
53
58
  * Marks the citation as selected/active (e.g. the source it points to is
54
59
  * currently open or highlighted). Renders the marker in its selected (teal)
55
- * state instead of the default amber.
60
+ * state instead of the default neutral one.
56
61
  * @default false
57
62
  */
58
63
  selected?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkCitation/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACvD;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,CAAC,CAAC,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkCitation/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACvD;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,CAAC,CAAC,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC"}
@@ -22,10 +22,21 @@ export declare const Default: Story;
22
22
  */
23
23
  export declare const WithoutLink: Story;
24
24
  /**
25
- * No `locationLabel` — the footer is hidden. Use for non-paginated sources
26
- * such as a plain web page or a whole-document citation.
25
+ * No `locationLabel` — the footer keeps just the collection. Use for
26
+ * non-paginated sources such as a plain web page.
27
27
  */
28
28
  export declare const WithoutLocation: Story;
29
+ /**
30
+ * No `collectionName` — the footer keeps just the location, and the separator
31
+ * goes with it. Use for sources that don't come from a collection.
32
+ */
33
+ export declare const WithoutCollection: Story;
34
+ /**
35
+ * A collection name longer than the card is wide. The name truncates and the
36
+ * location stays on the same line — the page a citation points at is the more
37
+ * useful half, so it must not be pushed out or wrapped away.
38
+ */
39
+ export declare const LongCollectionName: Story;
29
40
  /**
30
41
  * Minimal: title + excerpt only (no link, no location). The leanest source a
31
42
  * card can describe.
@@ -1 +1 @@
1
- {"version":3,"file":"CkCitationCard.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkCitationCard/CkCitationCard.stories.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAK3D;;;;;;;GAOG;AACH,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,cAAc,CAuBrC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAqBnC;;;GAGG;AACH,eAAO,MAAM,OAAO,EAAE,KAErB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,KAEzB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,KAE7B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAEhC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAE,KAK1B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,EAAE,KAIzB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,KAuB9B,CAAC"}
1
+ {"version":3,"file":"CkCitationCard.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkCitationCard/CkCitationCard.stories.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAK3D;;;;;;;GAOG;AACH,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,cAAc,CAyBrC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAqBnC;;;GAGG;AACH,eAAO,MAAM,OAAO,EAAE,KAErB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,KAEzB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,KAE7B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,KAE/B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAMhC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAMhC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAE,KAK1B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,EAAE,KAIzB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,KAuB9B,CAAC"}
@@ -5,6 +5,7 @@ declare const __VLS_export: import("vue").DefineComponent<CkCitationCardProps, {
5
5
  "onOpen-source"?: ((url: string) => any) | undefined;
6
6
  }>, {
7
7
  locationLabel: string;
8
+ collectionName: string;
8
9
  url: string;
9
10
  openSourceLabel: string;
10
11
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -1 +1 @@
1
- {"version":3,"file":"CkCitationCard.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkCitationCard/CkCitationCard.vue"],"names":[],"mappings":"AAuFA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AA4KnD,QAAA,MAAM,YAAY;;;;;;;;6EAIhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"CkCitationCard.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkCitationCard/CkCitationCard.vue"],"names":[],"mappings":"AAuIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AA+PnD,QAAA,MAAM,YAAY;;;;;;;;;6EAIhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -25,9 +25,14 @@ export interface CkCitationCardProps {
25
25
  /**
26
26
  * Location label shown in the footer, e.g. `"Page 3"`. Pass a fully
27
27
  * formatted, localized string — the component does no number formatting.
28
- * Omit for non-paginated sources to hide the footer.
28
+ * Omit for non-paginated sources.
29
29
  */
30
30
  locationLabel?: string;
31
+ /**
32
+ * Name of the collection the source belongs to, shown in the footer before
33
+ * the location. Omit when the source has no collection.
34
+ */
35
+ collectionName?: string;
31
36
  /**
32
37
  * When set, the external-link action is shown in the header. Activating it
33
38
  * emits `open-source` with this value; the host opens it (it may be an
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkCitationCard/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,CAAC,CAAC,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkCitationCard/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,CAAC,CAAC,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC"}
@@ -1 +1 @@
1
- {"version":3,"file":"CkCitationLabel.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkCitationLabel/CkCitationLabel.vue"],"names":[],"mappings":"AA6EA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AA6GpD,QAAA,MAAM,YAAY;;;;6EAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"CkCitationLabel.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkCitationLabel/CkCitationLabel.vue"],"names":[],"mappings":"AA8EA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAiHpD,QAAA,MAAM,YAAY;;;;6EAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -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, v, w, x, y, z, A } from "../CkHistory.vue_vue_type_script_setup_true_lang-CImSzLYs.js";
1
+ import { _, a, b, c, C, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A } from "../CkHistory.vue_vue_type_script_setup_true_lang-BNcJURkq.js";
2
2
  export {
3
3
  _ as CkAgentMessage,
4
4
  a as CkAgentMessageHeader,
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Local copy of ui-library's internal probe of the same name. chat-kit's
3
+ * supported ui-library range (^5.3.0) does not export it, and it is too small
4
+ * to justify widening that package's public API. Drop this file once the range
5
+ * moves up to a version that exports it.
6
+ */
7
+ import { type Ref, type ShallowRef } from 'vue';
8
+ /** An element ref as produced by `useTemplateRef`. */
9
+ type ElementRef = Readonly<ShallowRef<HTMLElement | null>>;
10
+ /**
11
+ * Whether an element's text is currently clipped by `text-overflow: ellipsis`.
12
+ *
13
+ * Re-measures when the element resizes and whenever `watchSource` changes, so
14
+ * it stays correct as the container narrows or the text is swapped out. Use it
15
+ * to show a tooltip only for names that are actually cut off.
16
+ * @param elementRef - The element whose text may be clipped
17
+ * @param watchSource - Value to re-measure on, e.g. the rendered text
18
+ * @returns Reactive truncation state
19
+ */
20
+ export declare function useIsTruncated(elementRef: ElementRef, watchSource?: () => unknown): Ref<boolean>;
21
+ export {};
22
+ //# sourceMappingURL=useIsTruncated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIsTruncated.d.ts","sourceRoot":"","sources":["../../src/composables/useIsTruncated.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAA8B,KAAK,GAAG,EAAE,KAAK,UAAU,EAAE,MAAM,KAAK,CAAC;AAE5E,sDAAsD;AACtD,KAAK,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC;AA6B3D;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,UAAU,EACtB,WAAW,CAAC,EAAE,MAAM,OAAO,GAC1B,GAAG,CAAC,OAAO,CAAC,CA6Bd"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { u } from "./useMessageHandler-Tellov3w.js";
2
2
  import { C, d, p, u as u2, b } from "./useChatKitLabels-CMOr3Kjq.js";
3
3
  import { S, c, d as d2, f, u as u3, a, b as b2, e } from "./index-Dn4ctxk8.js";
4
- import { _, a as a2, b as b3, 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, w, x, y, z, A, B } from "./CkHistory.vue_vue_type_script_setup_true_lang-CImSzLYs.js";
4
+ import { _, a as a2, b as b3, 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, w, x, y, z, A, B } from "./CkHistory.vue_vue_type_script_setup_true_lang-BNcJURkq.js";
5
5
  export {
6
6
  C as CHAT_KIT_LABELS,
7
7
  _ as CkAgentMessage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aleph-alpha/chat-kit",
3
- "version": "5.12.0",
3
+ "version": "5.13.0",
4
4
  "description": "Chat kit package for building chat interfaces with Vue",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -67,7 +67,6 @@
67
67
  "vue": "^3.5.27"
68
68
  },
69
69
  "dependencies": {
70
- "@aleph-alpha/ui-library": "^5.3.0",
71
70
  "dompurify": "^3.3.2",
72
71
  "katex": "^0.17.0",
73
72
  "mdast-util-find-and-replace": "^3.0.2",
@@ -77,7 +76,8 @@
77
76
  "remark-math": "^6.0.0",
78
77
  "remark-parse": "^11.0.0",
79
78
  "remark-rehype": "^11.1.2",
80
- "unified": "^11.0.5"
79
+ "unified": "^11.0.5",
80
+ "@aleph-alpha/ui-library": "5.10.0"
81
81
  },
82
82
  "devDependencies": {
83
83
  "@storybook/addon-a11y": "10.2.17",
@@ -72,11 +72,11 @@ describe('CkCitation', () => {
72
72
  expect(marker).toHaveAttribute('aria-expanded', 'false');
73
73
  });
74
74
 
75
- it('renders the default (amber) marker state by default', () => {
75
+ it('renders the default (neutral) marker state by default', () => {
76
76
  render(CkCitation, { props: base });
77
77
 
78
78
  const marker = screen.getByRole('button', { name: 'Source 1' });
79
- expect(marker.className).toContain('bg-background-accent-yellow');
79
+ expect(marker.className).toContain('bg-background-surface-citation');
80
80
  expect(marker.className).not.toContain('bg-background-accent-soft');
81
81
  });
82
82
 
@@ -85,6 +85,6 @@ describe('CkCitation', () => {
85
85
 
86
86
  const marker = screen.getByRole('button', { name: 'Source 1' });
87
87
  expect(marker.className).toContain('bg-background-accent-soft');
88
- expect(marker.className).not.toContain('bg-background-accent-yellow');
88
+ expect(marker.className).not.toContain('bg-background-surface-citation');
89
89
  });
90
90
  });
@@ -1,4 +1,5 @@
1
1
  import CkCitation from './CkCitation.vue';
2
+ import { CkCitationLabel } from '../CkCitationLabel';
2
3
  import type { Meta, StoryObj } from '@storybook/vue3-vite';
3
4
 
4
5
  const SNIPPET =
@@ -44,10 +45,91 @@ export default meta;
44
45
  type Story = StoryObj<typeof meta>;
45
46
 
46
47
  /**
47
- * A single marker in its default (amber) state. Hover the chip (or focus it and
48
- * press Enter) to reveal the source card.
48
+ * A single marker in its default (neutral) state. Hover the chip (or focus it
49
+ * and press Enter) to reveal the source card.
49
50
  */
50
- export const Default: Story = {};
51
+ const defaultTemplateSource = `<script setup lang="ts">
52
+ import { CkCitation } from '@aleph-alpha/chat-kit';
53
+
54
+ function openSource(url: string) {
55
+ // The source URL is often auth-proxied, so the host opens it.
56
+ window.open(url, '_blank', 'noopener');
57
+ }
58
+ </script>
59
+
60
+ <template>
61
+ <p>
62
+ Departments with tailored training adopted the tools faster.<CkCitation
63
+ :index="1"
64
+ file-name="Q2_Business_Plan.pdf"
65
+ snippet="Lorem ipsum dolor sit amet consectetur…"
66
+ location-label="Page 3"
67
+ collection-name="Collection name"
68
+ url="/api/v1/search-stores/ss_abc/files/file_123/public-urls"
69
+ @open-source="openSource"
70
+ />
71
+ </p>
72
+ </template>`;
73
+
74
+ export const Default: Story = {
75
+ parameters: { docs: { source: { code: defaultTemplateSource } } },
76
+ };
77
+
78
+ /**
79
+ * The four marker states side by side, as specified in the design: default,
80
+ * hover, focus and selected. Hover and focus are live — mouse over the second
81
+ * chip or tab to the third to see them.
82
+ */
83
+ const statesTemplateSource = `<script setup lang="ts">
84
+ import { CkCitationLabel } from '@aleph-alpha/chat-kit';
85
+ </script>
86
+
87
+ <template>
88
+ <!-- \`hover-layer-active\` pins the hover overlay open; focus is a real
89
+ :focus-visible, so it only shows when the chip is focused. -->
90
+ <CkCitationLabel as="button" :index="1" />
91
+ <CkCitationLabel as="button" :index="1" class="hover-layer-active" />
92
+ <CkCitationLabel as="button" :index="1" />
93
+ <CkCitationLabel as="button" :index="1" selected />
94
+ </template>`;
95
+
96
+ export const States: Story = {
97
+ parameters: { docs: { source: { code: statesTemplateSource } } },
98
+ render: (args) => ({
99
+ components: { CkCitationLabel },
100
+ setup() {
101
+ return { args };
102
+ },
103
+ // `CkCitationLabel` renders the chip on its own, so each state can be shown
104
+ // at rest. Hover is forced with `hover-layer-active` (the class ui-library
105
+ // uses to pin its overlay open); focus is real, applied by the play
106
+ // function below, because `:focus-visible` cannot be faked with a class.
107
+ template: `
108
+ <div style="display: flex; align-items: flex-start; gap: 32px;">
109
+ <div style="display: grid; justify-items: center; gap: 8px;">
110
+ <CkCitationLabel v-bind="args" :index="1" as="button" />
111
+ <small style="font-size: 11px; opacity: 0.6;">default</small>
112
+ </div>
113
+ <div style="display: grid; justify-items: center; gap: 8px;">
114
+ <CkCitationLabel v-bind="args" :index="1" as="button" class="hover-layer-active" />
115
+ <small style="font-size: 11px; opacity: 0.6;">hover</small>
116
+ </div>
117
+ <div style="display: grid; justify-items: center; gap: 8px;">
118
+ <CkCitationLabel v-bind="args" :index="1" as="button" data-focus-demo />
119
+ <small style="font-size: 11px; opacity: 0.6;">focus</small>
120
+ </div>
121
+ <div style="display: grid; justify-items: center; gap: 8px;">
122
+ <CkCitationLabel v-bind="args" :index="1" as="button" selected />
123
+ <small style="font-size: 11px; opacity: 0.6;">selected</small>
124
+ </div>
125
+ </div>
126
+ `,
127
+ }),
128
+ play: async ({ canvasElement }) => {
129
+ // A real focus, so the ring is the one keyboard users actually get.
130
+ canvasElement.querySelector<HTMLElement>('[data-focus-demo]')?.focus();
131
+ },
132
+ };
51
133
 
52
134
  /**
53
135
  * The selected (teal) state — set `selected` when the citation's source is the
@@ -109,10 +109,13 @@ onBeforeUnmount(() => {
109
109
  <template>
110
110
  <UiPopover v-model:open="open">
111
111
  <UiPopoverTrigger as-child>
112
+ <!-- An open card is itself a selection: the chip the user is reading
113
+ about shows the selected state, so it stands out from its neighbours
114
+ while the card is up. -->
112
115
  <CkCitationLabel
113
116
  as="button"
114
117
  :index="index"
115
- :selected="selected"
118
+ :selected="selected || open"
116
119
  :aria-label="ariaLabel"
117
120
  @keydown="onTriggerKeydown"
118
121
  @mouseenter="onPointerEnter"
@@ -134,6 +137,7 @@ onBeforeUnmount(() => {
134
137
  :file-name="fileName"
135
138
  :snippet="snippet"
136
139
  :location-label="locationLabel"
140
+ :collection-name="collectionName"
137
141
  :url="url"
138
142
  :open-source-label="openSourceLabel"
139
143
  @open-source="(u: string) => emit('open-source', u)"
@@ -27,6 +27,11 @@ export interface CkCitationSource {
27
27
  * non-paginated sources.
28
28
  */
29
29
  locationLabel?: string;
30
+ /**
31
+ * Name of the collection the source belongs to, shown in the card footer
32
+ * before the location. Omit when the source has no collection.
33
+ */
34
+ collectionName?: string;
30
35
  /**
31
36
  * Source URL for the card's external-link action. Activating it emits
32
37
  * `open-source`. Omit to hide the action.
@@ -53,7 +58,7 @@ export interface CkCitationProps extends CkCitationSource {
53
58
  /**
54
59
  * Marks the citation as selected/active (e.g. the source it points to is
55
60
  * currently open or highlighted). Renders the marker in its selected (teal)
56
- * state instead of the default amber.
61
+ * state instead of the default neutral one.
57
62
  * @default false
58
63
  */
59
64
  selected?: boolean;
@@ -69,6 +69,43 @@ describe('CkCitationCard', () => {
69
69
  expect(screen.getByText(snippet).className).toContain('line-clamp-6');
70
70
  });
71
71
 
72
+ it('shows the collection name before the location in the footer', () => {
73
+ render(CkCitationCard, {
74
+ props: { ...base, collectionName: 'EU AI Act', locationLabel: 'Page 3' },
75
+ });
76
+
77
+ const footer = screen.getByText('EU AI Act').closest('p');
78
+ expect(footer).toHaveTextContent('EU AI Act | Page 3');
79
+ });
80
+
81
+ it('drops the separator when only one footer part is present', () => {
82
+ render(CkCitationCard, { props: { ...base, collectionName: 'EU AI Act' } });
83
+
84
+ expect(screen.getByText('EU AI Act').closest('p')).not.toHaveTextContent(
85
+ '|',
86
+ );
87
+ });
88
+
89
+ it('hides the footer entirely with neither a collection nor a location', () => {
90
+ render(CkCitationCard, { props: base });
91
+
92
+ expect(screen.queryByText('Page 3')).not.toBeInTheDocument();
93
+ expect(screen.queryByText('|')).not.toBeInTheDocument();
94
+ });
95
+
96
+ it('keeps the location intact when the collection name is too long', () => {
97
+ const collectionName =
98
+ 'Public Sector Knowledge Base — European Union Regulatory Corpus 2026';
99
+ render(CkCitationCard, {
100
+ props: { ...base, collectionName, locationLabel: 'Page 3' },
101
+ });
102
+
103
+ // jsdom has no layout, so the guarantee is asserted through the classes
104
+ // that produce it: the name is the only part allowed to give way.
105
+ expect(screen.getByText(collectionName).className).toContain('truncate');
106
+ expect(screen.getByText('Page 3').className).toContain('shrink-0');
107
+ });
108
+
72
109
  it('uses the injected citationOpenSource label via provideChatKitLabels', () => {
73
110
  const Wrapper = defineComponent({
74
111
  setup() {
@@ -20,6 +20,7 @@ const meta: Meta<typeof CkCitationCard> = {
20
20
  fileName: { control: 'text' },
21
21
  snippet: { control: 'text' },
22
22
  locationLabel: { control: 'text' },
23
+ collectionName: { control: 'text' },
23
24
  url: { control: 'text' },
24
25
  openSourceLabel: { control: 'text' },
25
26
  },
@@ -27,6 +28,7 @@ const meta: Meta<typeof CkCitationCard> = {
27
28
  fileName: 'Q2_Business_Plan.pdf',
28
29
  snippet: LOREM,
29
30
  locationLabel: 'Page 3',
31
+ collectionName: 'Collection name',
30
32
  url: '/api/v1/search-stores/ss_abc/files/file_123/public-urls',
31
33
  },
32
34
  decorators: [
@@ -76,19 +78,44 @@ export const WithoutLink: Story = {
76
78
  };
77
79
 
78
80
  /**
79
- * No `locationLabel` — the footer is hidden. Use for non-paginated sources
80
- * such as a plain web page or a whole-document citation.
81
+ * No `locationLabel` — the footer keeps just the collection. Use for
82
+ * non-paginated sources such as a plain web page.
81
83
  */
82
84
  export const WithoutLocation: Story = {
83
85
  args: { locationLabel: undefined },
84
86
  };
85
87
 
88
+ /**
89
+ * No `collectionName` — the footer keeps just the location, and the separator
90
+ * goes with it. Use for sources that don't come from a collection.
91
+ */
92
+ export const WithoutCollection: Story = {
93
+ args: { collectionName: undefined },
94
+ };
95
+
96
+ /**
97
+ * A collection name longer than the card is wide. The name truncates and the
98
+ * location stays on the same line — the page a citation points at is the more
99
+ * useful half, so it must not be pushed out or wrapped away.
100
+ */
101
+ export const LongCollectionName: Story = {
102
+ args: {
103
+ collectionName:
104
+ 'Public Sector Knowledge Base — European Union Regulatory Corpus 2026',
105
+ locationLabel: 'Page 3',
106
+ },
107
+ };
108
+
86
109
  /**
87
110
  * Minimal: title + excerpt only (no link, no location). The leanest source a
88
111
  * card can describe.
89
112
  */
90
113
  export const MinimalSnippetOnly: Story = {
91
- args: { url: undefined, locationLabel: undefined },
114
+ args: {
115
+ url: undefined,
116
+ locationLabel: undefined,
117
+ collectionName: undefined,
118
+ },
92
119
  };
93
120
 
94
121
  /**
@@ -1,6 +1,12 @@
1
1
  <script setup lang="ts">
2
- import { computed } from 'vue';
3
- import { UiFileType, UiButton, UiIcon } from '@aleph-alpha/ui-library';
2
+ import { computed, useTemplateRef } from 'vue';
3
+ import {
4
+ UiFileType,
5
+ UiButton,
6
+ UiIcon,
7
+ UiTooltip,
8
+ } from '@aleph-alpha/ui-library';
9
+ import { useIsTruncated } from '../../../composables/useIsTruncated';
4
10
  import {
5
11
  defaultChatKitLabels,
6
12
  useChatKitLabels,
@@ -13,6 +19,7 @@ defineOptions({
13
19
 
14
20
  const props = withDefaults(defineProps<CkCitationCardProps>(), {
15
21
  locationLabel: undefined,
22
+ collectionName: undefined,
16
23
  url: undefined,
17
24
  openSourceLabel: undefined,
18
25
  });
@@ -31,6 +38,16 @@ const openSourceAriaLabel = computed(
31
38
  defaultChatKitLabels.citationOpenSource!,
32
39
  );
33
40
 
41
+ // Both labels are clipped to the card width, so each gets the same tooltip
42
+ // treatment as a file row: revealed only when the text is actually cut off.
43
+ const fileNameRef = useTemplateRef<HTMLElement>('fileNameRef');
44
+ const collectionRef = useTemplateRef<HTMLElement>('collectionRef');
45
+ const isFileNameTruncated = useIsTruncated(fileNameRef, () => props.fileName);
46
+ const isCollectionTruncated = useIsTruncated(
47
+ collectionRef,
48
+ () => props.collectionName,
49
+ );
50
+
34
51
  function handleOpen(): void {
35
52
  if (props.url) {
36
53
  emit('open-source', props.url);
@@ -42,14 +59,20 @@ function handleOpen(): void {
42
59
  <div
43
60
  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"
44
61
  >
45
- <div class="flex items-center gap-2">
62
+ <div class="flex min-w-0 items-center gap-3 py-0.5">
46
63
  <UiFileType :filename="fileName" class="shrink-0" />
47
- <p
48
- class="min-w-0 truncate text-sm font-medium text-content-on-surface-primary"
49
- :title="fileName"
64
+ <UiTooltip
65
+ :content="fileName"
66
+ :disabled="!isFileNameTruncated"
67
+ align="start"
50
68
  >
51
- {{ fileName }}
52
- </p>
69
+ <p
70
+ ref="fileNameRef"
71
+ class="min-w-0 truncate text-sm font-medium leading-4 text-content-on-surface-primary"
72
+ >
73
+ {{ fileName }}
74
+ </p>
75
+ </UiTooltip>
53
76
  <UiButton
54
77
  v-if="url"
55
78
  variant="ghost"
@@ -68,11 +91,30 @@ function handleOpen(): void {
68
91
  {{ snippet }}
69
92
  </p>
70
93
 
94
+ <!-- The location is the more useful half, so the collection name is the
95
+ part that gives way when the two don't fit on one line. -->
71
96
  <p
72
- v-if="locationLabel"
73
- class="text-sm leading-5 text-content-on-surface-muted"
97
+ v-if="collectionName || locationLabel"
98
+ class="flex items-center gap-1.5 text-sm leading-5 text-content-on-surface-muted"
74
99
  >
75
- {{ locationLabel }}
100
+ <UiTooltip
101
+ v-if="collectionName"
102
+ :content="collectionName"
103
+ :disabled="!isCollectionTruncated"
104
+ align="start"
105
+ >
106
+ <span ref="collectionRef" class="min-w-0 truncate">
107
+ {{ collectionName }}
108
+ </span>
109
+ </UiTooltip>
110
+ <span
111
+ v-if="collectionName && locationLabel"
112
+ aria-hidden="true"
113
+ class="shrink-0 text-border-input-strong"
114
+ >
115
+ |
116
+ </span>
117
+ <span v-if="locationLabel" class="shrink-0">{{ locationLabel }}</span>
76
118
  </p>
77
119
  </div>
78
120
  </template>
@@ -25,9 +25,14 @@ export interface CkCitationCardProps {
25
25
  /**
26
26
  * Location label shown in the footer, e.g. `"Page 3"`. Pass a fully
27
27
  * formatted, localized string — the component does no number formatting.
28
- * Omit for non-paginated sources to hide the footer.
28
+ * Omit for non-paginated sources.
29
29
  */
30
30
  locationLabel?: string;
31
+ /**
32
+ * Name of the collection the source belongs to, shown in the footer before
33
+ * the location. Omit when the source has no collection.
34
+ */
35
+ collectionName?: string;
31
36
  /**
32
37
  * When set, the external-link action is shown in the header. Activating it
33
38
  * emits `open-source` with this value; the host opens it (it may be an
@@ -53,11 +53,11 @@ describe('CkCitationLabel', () => {
53
53
  ).toBeInTheDocument();
54
54
  });
55
55
 
56
- it('renders the default (amber) state by default', () => {
56
+ it('renders the default (neutral) state by default', () => {
57
57
  const { container } = render(CkCitationLabel, { props: { index: 1 } });
58
58
 
59
59
  const marker = container.querySelector('.ck-citation')!;
60
- expect(marker.className).toContain('bg-background-accent-yellow');
60
+ expect(marker.className).toContain('bg-background-surface-citation');
61
61
  expect(marker.className).not.toContain('bg-background-accent-soft');
62
62
  });
63
63
 
@@ -68,6 +68,6 @@ describe('CkCitationLabel', () => {
68
68
 
69
69
  const marker = container.querySelector('.ck-citation')!;
70
70
  expect(marker.className).toContain('bg-background-accent-soft');
71
- expect(marker.className).not.toContain('bg-background-accent-yellow');
71
+ expect(marker.className).not.toContain('bg-background-surface-citation');
72
72
  });
73
73
  });
@@ -46,17 +46,18 @@ const resolvedAriaLabel = computed(
46
46
  :role="isButton ? undefined : 'img'"
47
47
  :aria-label="resolvedAriaLabel"
48
48
  :class="[
49
- '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',
49
+ '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',
50
50
  // The static chip is part of the prose: it must stay selectable so the
51
51
  // number survives a copy of the surrounding text. A control shouldn't
52
52
  // start a text selection on click, so button mode keeps `select-none`.
53
- isButton ? 'select-none' : '',
53
+ // Only the control gets the hover layer; a static chip has no hover state.
54
+ isButton ? 'select-none hover-layer hover-layer-default' : '',
54
55
  selected
55
- ? 'bg-background-accent-soft text-black'
56
- : 'bg-background-accent-yellow text-background-status-warning',
56
+ ? 'bg-background-accent-soft text-content-on-accent-soft'
57
+ : 'bg-background-surface-citation text-content-on-surface-primary',
57
58
  ]"
58
59
  >
59
- {{ index }}
60
+ <span>{{ index }}</span>
60
61
  </component>
61
62
  </template>
62
63