@swisper.ai/web-chat-ui 0.1.0 → 0.2.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 (83) hide show
  1. package/README.md +2 -5
  2. package/dist/components/chat-card/chat-card.stories.d.ts.map +1 -1
  3. package/dist/components/chat-card-container/chat-card-container.stories.d.ts.map +1 -1
  4. package/dist/components/rich-text-field/rich-text-field.stories.d.ts.map +1 -1
  5. package/dist/components/rich-text-field/utils.d.ts +36 -36
  6. package/dist/index.css +1 -1
  7. package/dist/index.d.ts +0 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.es.js +1566 -1810
  10. package/dist/index.es.js.map +1 -1
  11. package/package.json +4 -4
  12. package/src/components/chat-card/chat-card.json +6 -6
  13. package/src/components/chat-card/chat-card.stories.tsx +6 -14
  14. package/src/components/chat-card/components/chat-card-body.tsx +1 -1
  15. package/src/components/chat-card-container/chat-card-container.json +6 -6
  16. package/src/components/chat-card-container/chat-card-container.stories.tsx +10 -18
  17. package/src/components/chat-container/chat-container.json +1 -1
  18. package/src/components/chat-list/chat-list-items.tsx +3 -3
  19. package/src/components/rich-text-field/rich-text-field.stories.tsx +3 -1
  20. package/src/index.ts +0 -1
  21. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts +0 -97
  22. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts.map +0 -1
  23. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts +0 -52
  24. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts.map +0 -1
  25. package/dist/layouts/chat-card-list-layout/index.d.ts +0 -3
  26. package/dist/layouts/chat-card-list-layout/index.d.ts.map +0 -1
  27. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.d.ts +0 -89
  28. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.d.ts.map +0 -1
  29. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.d.ts +0 -44
  30. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.d.ts.map +0 -1
  31. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts +0 -62
  32. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts.map +0 -1
  33. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.d.ts +0 -81
  34. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.d.ts.map +0 -1
  35. package/dist/layouts/chat-card-three-column-layout/index.d.ts +0 -5
  36. package/dist/layouts/chat-card-three-column-layout/index.d.ts.map +0 -1
  37. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts +0 -37
  38. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts.map +0 -1
  39. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.d.ts +0 -12
  40. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.d.ts.map +0 -1
  41. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts +0 -40
  42. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts.map +0 -1
  43. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.d.ts +0 -35
  44. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.d.ts.map +0 -1
  45. package/dist/layouts/chat-card-two-column-layout/index.d.ts +0 -4
  46. package/dist/layouts/chat-card-two-column-layout/index.d.ts.map +0 -1
  47. package/dist/layouts/index.d.ts +0 -4
  48. package/dist/layouts/index.d.ts.map +0 -1
  49. package/src/layouts/chat-card-list-layout/__stories__/fixtures.ts +0 -112
  50. package/src/layouts/chat-card-list-layout/__stories__/result-card.tsx +0 -36
  51. package/src/layouts/chat-card-list-layout/__stories__/types.ts +0 -31
  52. package/src/layouts/chat-card-list-layout/__tests__/chat-card-list-layout.spec.tsx +0 -204
  53. package/src/layouts/chat-card-list-layout/chat-card-list-layout.json +0 -129
  54. package/src/layouts/chat-card-list-layout/chat-card-list-layout.stories.tsx +0 -422
  55. package/src/layouts/chat-card-list-layout/chat-card-list-layout.tsx +0 -254
  56. package/src/layouts/chat-card-list-layout/index.ts +0 -11
  57. package/src/layouts/chat-card-three-column-layout/__stories__/fixtures.ts +0 -117
  58. package/src/layouts/chat-card-three-column-layout/__stories__/resizable-chat-window.tsx +0 -18
  59. package/src/layouts/chat-card-three-column-layout/__stories__/stay-details.tsx +0 -85
  60. package/src/layouts/chat-card-three-column-layout/__stories__/stay-list.tsx +0 -47
  61. package/src/layouts/chat-card-three-column-layout/__stories__/stay-map.tsx +0 -44
  62. package/src/layouts/chat-card-three-column-layout/__stories__/stay-rooms.tsx +0 -61
  63. package/src/layouts/chat-card-three-column-layout/__stories__/types.ts +0 -35
  64. package/src/layouts/chat-card-three-column-layout/__tests__/chat-card-three-column-layout.sizing.test.ts +0 -71
  65. package/src/layouts/chat-card-three-column-layout/__tests__/chat-card-three-column-layout.spec.tsx +0 -327
  66. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.json +0 -153
  67. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.ts +0 -76
  68. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.tsx +0 -658
  69. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.tsx +0 -293
  70. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.ts +0 -146
  71. package/src/layouts/chat-card-three-column-layout/index.ts +0 -24
  72. package/src/layouts/chat-card-two-column-layout/__stories__/connection-itinerary.tsx +0 -51
  73. package/src/layouts/chat-card-two-column-layout/__stories__/fixtures.ts +0 -83
  74. package/src/layouts/chat-card-two-column-layout/__stories__/route-map.tsx +0 -24
  75. package/src/layouts/chat-card-two-column-layout/__stories__/types.ts +0 -15
  76. package/src/layouts/chat-card-two-column-layout/__tests__/chat-card-two-column-layout.spec.tsx +0 -109
  77. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.json +0 -109
  78. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.ts +0 -21
  79. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.tsx +0 -439
  80. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.tsx +0 -141
  81. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.ts +0 -65
  82. package/src/layouts/chat-card-two-column-layout/index.ts +0 -17
  83. package/src/layouts/index.ts +0 -3
@@ -1,81 +0,0 @@
1
- /**
2
- * Whether Details may take its own right column.
3
- *
4
- * - `responsive` — a column whenever the layout is wide enough for List, Details and a
5
- * usable Main side by side; floating over Main otherwise.
6
- * - `floating` — always over Main, for a pane that is secondary at every size.
7
- *
8
- * There is no "always a column": at widths where it would not fit, Main would be squeezed
9
- * below usefulness, which is exactly what the width check exists to prevent.
10
- */
11
- export type ChatCardThreeColumnLayoutDetailsPlacement = 'responsive' | 'floating';
12
- /**
13
- * `responsive` because it uses the room when it is there: `floating` would cover Main on
14
- * a card with space to spare.
15
- */
16
- export declare const DEFAULT_DETAILS_PLACEMENT: ChatCardThreeColumnLayoutDetailsPlacement;
17
- /**
18
- * Root grid.
19
- *
20
- * The third track needs both "Details fits" (`data-details-floating=false`, from the
21
- * width) and "Details is mounted" (`:has(> [data-slot=…-details])`). The second is CSS, not
22
- * a prop, because consumers mount Details conditionally and a `hasDetails` prop could
23
- * disagree with what is rendered.
24
- */
25
- export declare const chatCardThreeColumnLayoutVariants: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
26
- /**
27
- * Column 1 at `lg` and `xl`. Below that the grid has no `list` area, so the column classes
28
- * are keyed on the size: naming a missing area would add a stray track. `hideOnMobile`
29
- * hides the pane at those sizes, without unmounting it.
30
- *
31
- * In the column, `min-h-0` + `overflow-hidden` keep a long list inside the row. Without them
32
- * the grid item grows to its content and the card gets taller instead of scrolling.
33
- */
34
- export declare const chatCardThreeColumnLayoutListVariants: (props?: ({
35
- hideOnMobile?: boolean | null | undefined;
36
- } & import('class-variance-authority/types').ClassProp) | undefined) => string;
37
- /**
38
- * Column 2, the flexible `1fr` track. `min-w-0` because a grid item's minimum width is its
39
- * content by default: a map or a wide table would push the track past the card. `relative`
40
- * so the consumer can anchor their own overlays to Main.
41
- */
42
- export declare const chatCardThreeColumnLayoutMainVariants: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
43
- /**
44
- * Column 3, or floating over Main. Floating shares Main's grid area instead of being
45
- * `absolute`, so it is sized by the same track Main is.
46
- *
47
- * - pinned: the right edge of Main, at the same width the column would have, inset 12px
48
- * - sheet: on a narrow layout, a bottom sheet at a fixed 85% height, so the pane does not
49
- * change height as its content changes (the content scrolls instead)
50
- *
51
- * `z-20` keeps a floating Details above Main's own overlays. `min-w-0` + `max-w-full` stop
52
- * the fixed width from widening the `1fr` track past the card.
53
- */
54
- export declare const chatCardThreeColumnLayoutDetailsVariants: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
55
- /**
56
- * An overlay over everything but the List column, inset 12px, for a view that takes over the
57
- * card (all reviews, a filter form) while Main and Details stay mounted underneath.
58
- *
59
- * It spans columns in row 1 instead of being `absolute`, so it follows the grid template:
60
- * from column 2 to the last one when List is a column (`lg`, `xl`), all of them otherwise.
61
- * It never adds a track, so mounting it doesn't move Main. `z-30` keeps it above floating
62
- * Details (`z-20`).
63
- */
64
- export declare const chatCardThreeColumnLayoutPanelVariants: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
65
- /**
66
- * Width recipe for the `ChatCard` that wraps the layout.
67
- *
68
- * A grid of `1fr` tracks has no intrinsic width, so inside a shrink-to-fit message the card
69
- * would collapse to nothing. It takes the whole chat window instead, minus the message
70
- * gutter on both sides, up to 1432px (four 358px columns). The layout then decides which
71
- * panes fit in whatever width that gives it. `ChatContainer` sets both variables.
72
- *
73
- * One cap, not a ladder of viewport steps: a step like `lg:min-w-[1074px]` held the card
74
- * narrower than the chat window between breakpoints, and Details floated for no reason.
75
- *
76
- * Gated on `data-state=open`, which `ChatCard`'s `Collapsible` puts on the card element
77
- * itself: a collapsed card is only a header, and holding it at full width would leave a
78
- * wide empty bar in the thread. A non-collapsible card is always `open`.
79
- */
80
- export declare const chatCardThreeColumnLayoutCardVariants: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
81
- //# sourceMappingURL=chat-card-three-column-layout.variants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chat-card-three-column-layout.variants.d.ts","sourceRoot":"","sources":["../../../src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,MAAM,yCAAyC,GAAG,YAAY,GAAG,UAAU,CAAC;AAElF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,yCAAwD,CAAC;AAmBjG;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,oFAS5C,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,qCAAqC;;8EAiBjD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qCAAqC,oFAEhD,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wCAAwC,oFAMnD,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,sCAAsC,oFAIjD,CAAC;AAEH;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,qCAAqC,oFAIhD,CAAC"}
@@ -1,5 +0,0 @@
1
- export { ChatCardThreeColumnLayout, ChatCardThreeColumnLayoutList, ChatCardThreeColumnLayoutMain, ChatCardThreeColumnLayoutDetails, ChatCardThreeColumnLayoutPanel, } from './chat-card-three-column-layout';
2
- export type { ChatCardThreeColumnLayoutProps, ChatCardThreeColumnLayoutListProps, ChatCardThreeColumnLayoutMainProps, ChatCardThreeColumnLayoutDetailsProps, ChatCardThreeColumnLayoutPanelProps, ChatCardThreeColumnLayoutPaneChildren, } from './chat-card-three-column-layout';
3
- export { chatCardThreeColumnLayoutVariants, chatCardThreeColumnLayoutListVariants, chatCardThreeColumnLayoutMainVariants, chatCardThreeColumnLayoutDetailsVariants, chatCardThreeColumnLayoutPanelVariants, chatCardThreeColumnLayoutCardVariants, } from './chat-card-three-column-layout.variants';
4
- export type { ChatCardThreeColumnLayoutDetailsPlacement } from './chat-card-three-column-layout.variants';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/layouts/chat-card-three-column-layout/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,6BAA6B,EAC7B,6BAA6B,EAC7B,gCAAgC,EAChC,8BAA8B,GAC/B,MAAM,iCAAiC,CAAC;AACzC,YAAY,EACV,8BAA8B,EAC9B,kCAAkC,EAClC,kCAAkC,EAClC,qCAAqC,EACrC,mCAAmC,EACnC,qCAAqC,GACtC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,iCAAiC,EACjC,qCAAqC,EACrC,qCAAqC,EACrC,wCAAwC,EACxC,sCAAsC,EACtC,qCAAqC,GACtC,MAAM,0CAA0C,CAAC;AAClD,YAAY,EAAE,yCAAyC,EAAE,MAAM,0CAA0C,CAAC"}
@@ -1,37 +0,0 @@
1
- import { ComponentProps, ReactNode } from 'react';
2
- export interface ChatCardTwoColumnLayoutProps extends ComponentProps<'div'> {
3
- children: ReactNode;
4
- /**
5
- * Classes for the grid the root renders around its children, merged after its defaults, e.g.
6
- * `gap-8` for a tighter gutter. Keep the column and row templates: the panes rely on them.
7
- */
8
- gridClassName?: string;
9
- asChild?: boolean;
10
- }
11
- /**
12
- * A two-pane card body: Aside (a 336px column) beside Main (flexible), stacked as Aside over
13
- * Main when the layout is narrower than 744px.
14
- *
15
- * The switch is a container query on the layout's **own width**, not a viewport breakpoint,
16
- * because the card is sized by the chat window, not the viewport. Nothing floats, so unlike
17
- * the three-column layout there is no measuring and no render prop.
18
- *
19
- * The root is the query container and renders the grid inside itself: an element cannot
20
- * query its own width. `className` goes on the root, so a height set there reaches the grid.
21
- * Height is not set here, because it belongs to the content, so pass it in `className`.
22
- * `gridClassName` reaches the grid itself.
23
- */
24
- export declare const ChatCardTwoColumnLayout: import('react').ForwardRefExoticComponent<Omit<ChatCardTwoColumnLayoutProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
25
- export interface ChatCardTwoColumnLayoutAsideProps extends ComponentProps<'aside'> {
26
- children: ReactNode;
27
- asChild?: boolean;
28
- }
29
- /** Column 1 (336px) when the layout is at least 744px wide; the first row below that. */
30
- export declare const ChatCardTwoColumnLayoutAside: import('react').ForwardRefExoticComponent<Omit<ChatCardTwoColumnLayoutAsideProps, "ref"> & import('react').RefAttributes<HTMLElement>>;
31
- export interface ChatCardTwoColumnLayoutMainProps extends ComponentProps<'main'> {
32
- children: ReactNode;
33
- asChild?: boolean;
34
- }
35
- /** The flexible track: column 2 side by side, the second row (taking the rest) stacked. */
36
- export declare const ChatCardTwoColumnLayoutMain: import('react').ForwardRefExoticComponent<Omit<ChatCardTwoColumnLayoutMainProps, "ref"> & import('react').RefAttributes<HTMLElement>>;
37
- //# sourceMappingURL=chat-card-two-column-layout.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chat-card-two-column-layout.d.ts","sourceRoot":"","sources":["../../../src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AA4BvD,MAAM,WAAW,4BAA6B,SAAQ,cAAc,CAAC,KAAK,CAAC;IACzE,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,sIA2BnC,CAAC;AAIF,MAAM,WAAW,iCAAkC,SAAQ,cAAc,CAAC,OAAO,CAAC;IAChF,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,yFAAyF;AACzF,eAAO,MAAM,4BAA4B,wIAmBvC,CAAC;AAIH,MAAM,WAAW,gCAAiC,SAAQ,cAAc,CAAC,MAAM,CAAC;IAC9E,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,2FAA2F;AAC3F,eAAO,MAAM,2BAA2B,uIAmBtC,CAAC"}
@@ -1,12 +0,0 @@
1
- /** Aside's fixed column width once the layout is wide enough for two columns. */
2
- export declare const ASIDE_WIDTH = 336;
3
- /**
4
- * Narrowest Main may get beside the Aside column. The same 400px as the three-column
5
- * layout: below it a map or a chart shows too little to be worth sitting beside anything.
6
- */
7
- export declare const MIN_MAIN_WIDTH = 400;
8
- /** Must equal the `gap-[8px]` on the grid, or the threshold is off by that much. */
9
- export declare const GAP = 8;
10
- /** From this layout width, Aside and Main sit side by side; below it they stack. */
11
- export declare const TWO_COLUMN_MIN_WIDTH: number;
12
- //# sourceMappingURL=chat-card-two-column-layout.sizing.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chat-card-two-column-layout.sizing.d.ts","sourceRoot":"","sources":["../../../src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.ts"],"names":[],"mappings":"AAOA,iFAAiF;AACjF,eAAO,MAAM,WAAW,MAAM,CAAC;AAE/B;;;GAGG;AACH,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC,oFAAoF;AACpF,eAAO,MAAM,GAAG,IAAI,CAAC;AAErB,oFAAoF;AACpF,eAAO,MAAM,oBAAoB,QAAqC,CAAC"}
@@ -1,40 +0,0 @@
1
- import { Meta, StoryObj } from '@storybook/react-vite';
2
- import { ChatCardTwoColumnLayout, ChatCardTwoColumnLayoutProps } from './chat-card-two-column-layout';
3
- declare const meta: Meta<typeof ChatCardTwoColumnLayout>;
4
- export default meta;
5
- type Story = StoryObj<typeof ChatCardTwoColumnLayout>;
6
- /**
7
- * From 744px of layout width, Aside is a 336px column beside Main; below it, Aside stacks
8
- * above Main and Main takes the rest of the height. The threshold is the layout's own width,
9
- * not the viewport's.
10
- */
11
- export declare const Default: Story;
12
- /** A narrow card: Aside stacks above Main although the viewport is wide. */
13
- export declare const Stacked: Story;
14
- /**
15
- * Drag the dashed wrapper's right edge across 744px: the columns switch without the viewport
16
- * changing, which is the point.
17
- */
18
- export declare const ResizableContainer: Story;
19
- /** Checks that a 1000px card puts Aside in a 336px column beside Main, both at the root's height. */
20
- export declare const SideBySideColumns: Story;
21
- /** Checks that a 500px card stacks Aside over Main at one width, and Main takes the height Aside leaves. */
22
- export declare const StackedRows: Story;
23
- /** Checks that an itinerary longer than the card scrolls inside the Aside column instead of growing the card. */
24
- export declare const LongAsideScrolls: Story;
25
- /** Checks that `gridClassName` reaches the grid: `gap-8` halves the gutter between the columns. */
26
- export declare const GridClassNameGutter: Story;
27
- /** The layout in each place it's allowed: straight in a card's content, in a card body with a footer under it, and in a chat thread. */
28
- export declare const Examples: Story;
29
- interface ChatCardTwoColumnLayoutPlaygroundProps extends Omit<ChatCardTwoColumnLayoutProps, 'children'> {
30
- width: number;
31
- title: string;
32
- stepCount: number;
33
- hasScrollArea: boolean;
34
- asideClassName: string;
35
- mainClassName: string;
36
- }
37
- declare function ChatCardTwoColumnLayoutPlayground({ width, title, stepCount, hasScrollArea, asideClassName, mainClassName, ...rest }: ChatCardTwoColumnLayoutPlaygroundProps): import('react').JSX.Element;
38
- /** Both panes with the door-to-door itinerary, and the card width, the classes of every part and the Aside scroll on the Controls panel. */
39
- export declare const Playground: StoryObj<typeof ChatCardTwoColumnLayoutPlayground>;
40
- //# sourceMappingURL=chat-card-two-column-layout.stories.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chat-card-two-column-layout.stories.d.ts","sourceRoot":"","sources":["../../../src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AA0B5D,OAAO,EACL,uBAAuB,EAGxB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAGlF,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,uBAAuB,CA8B9C,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAsDtD;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,KAMrB,CAAC;AAEF,4EAA4E;AAC5E,eAAO,MAAM,OAAO,EAAE,KASrB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAShC,CAAC;AAOF,qGAAqG;AACrG,eAAO,MAAM,iBAAiB,EAAE,KAkC/B,CAAC;AAEF,4GAA4G;AAC5G,eAAO,MAAM,WAAW,EAAE,KAuBzB,CAAC;AAEF,iHAAiH;AACjH,eAAO,MAAM,gBAAgB,EAAE,KAoB9B,CAAC;AAEF,mGAAmG;AACnG,eAAO,MAAM,mBAAmB,EAAE,KAajC,CAAC;AAEF,wIAAwI;AACxI,eAAO,MAAM,QAAQ,EAAE,KAoEtB,CAAC;AAEF,UAAU,sCAAuC,SAAQ,IAAI,CAC3D,4BAA4B,EAC5B,UAAU,CACX;IACC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,iBAAS,iCAAiC,CAAC,EACzC,KAAK,EACL,KAAK,EACL,SAAS,EACT,aAAa,EACb,cAAc,EACd,aAAa,EACb,GAAG,IAAI,EACR,EAAE,sCAAsC,+BAsCxC;AAED,4IAA4I;AAC5I,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,OAAO,iCAAiC,CAsCzE,CAAC"}
@@ -1,35 +0,0 @@
1
- /**
2
- * Root: the query container, nothing else. An element cannot match a container query
3
- * against its own width, so the grid lives one level down, in `…GridVariants`.
4
- */
5
- export declare const chatCardTwoColumnLayoutVariants: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
6
- /**
7
- * The grid, rendered by the root around its children.
8
- *
9
- * Stacked, the rows are `auto 1fr`, so with a height on the root Main takes whatever Aside
10
- * leaves. Side by side there is one `1fr` row; the stacked template would otherwise leave an
11
- * empty `1fr` second row taking the height.
12
- */
13
- export declare const chatCardTwoColumnLayoutGridVariants: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
14
- /**
15
- * Row 1 when stacked, column 1 when side by side. In the column, `min-h-0` + `overflow-hidden`
16
- * keep a long list inside the row. Without them the grid item grows to its content and the
17
- * card gets taller instead of scrolling.
18
- */
19
- export declare const chatCardTwoColumnLayoutAsideVariants: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
20
- /**
21
- * The flexible track. `min-w-0` because a grid item's minimum width is its content by
22
- * default: a map or a wide table would push the track past the card. `relative` so the
23
- * consumer can anchor their own overlays to Main.
24
- */
25
- export declare const chatCardTwoColumnLayoutMainVariants: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
26
- /**
27
- * Width recipe for the `ChatCard` that wraps the layout. The same recipe, for the same
28
- * reason, as `chatCardThreeColumnLayoutCardVariants`: a grid of `1fr` tracks has no intrinsic
29
- * width, so inside a shrink-to-fit message the card would collapse to nothing. It takes the
30
- * whole chat window instead, and the layout decides whether two columns fit.
31
- *
32
- * Gated on `data-state=open` so a collapsed card goes back to header width.
33
- */
34
- export declare const chatCardTwoColumnLayoutCardVariants: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
35
- //# sourceMappingURL=chat-card-two-column-layout.variants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chat-card-two-column-layout.variants.d.ts","sourceRoot":"","sources":["../../../src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.ts"],"names":[],"mappings":"AAgBA;;;GAGG;AACH,eAAO,MAAM,+BAA+B,oFAAkD,CAAC;AAE/F;;;;;;GAMG;AACH,eAAO,MAAM,mCAAmC,oFAI9C,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,oCAAoC,oFAG/C,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,oFAA2C,CAAC;AAE5F;;;;;;;GAOG;AACH,eAAO,MAAM,mCAAmC,oFAI9C,CAAC"}
@@ -1,4 +0,0 @@
1
- export { ChatCardTwoColumnLayout, ChatCardTwoColumnLayoutAside, ChatCardTwoColumnLayoutMain, } from './chat-card-two-column-layout';
2
- export type { ChatCardTwoColumnLayoutProps, ChatCardTwoColumnLayoutAsideProps, ChatCardTwoColumnLayoutMainProps, } from './chat-card-two-column-layout';
3
- export { chatCardTwoColumnLayoutVariants, chatCardTwoColumnLayoutGridVariants, chatCardTwoColumnLayoutAsideVariants, chatCardTwoColumnLayoutMainVariants, chatCardTwoColumnLayoutCardVariants, } from './chat-card-two-column-layout.variants';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/layouts/chat-card-two-column-layout/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,+BAA+B,CAAC;AACvC,YAAY,EACV,4BAA4B,EAC5B,iCAAiC,EACjC,gCAAgC,GACjC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,+BAA+B,EAC/B,mCAAmC,EACnC,oCAAoC,EACpC,mCAAmC,EACnC,mCAAmC,GACpC,MAAM,wCAAwC,CAAC"}
@@ -1,4 +0,0 @@
1
- export * from './chat-card-list-layout';
2
- export * from './chat-card-three-column-layout';
3
- export * from './chat-card-two-column-layout';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/layouts/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC"}
@@ -1,112 +0,0 @@
1
- import type { CalendarEvent, EmailSummary, TrainConnection } from './types';
2
-
3
- // Shaped like the rows an inbox search returns: one long subject, one message without a text body.
4
- export const EMAILS: EmailSummary[] = [
5
- {
6
- id: 'email_01',
7
- subject: 'Agenda for the offsite on 14 November',
8
- from: 'mara.keller@company.com',
9
- date: 'Oct 27, 14:00',
10
- preview: 'Here is the draft agenda. Tell me by Friday if a session is missing.',
11
- },
12
- {
13
- id: 'email_02',
14
- subject: 'Invoice 2026-1043 is ready',
15
- from: 'billing@company.com',
16
- date: 'Oct 27, 09:12',
17
- preview: null,
18
- },
19
- {
20
- id: 'email_03',
21
- subject: 'Re: Re: Fwd: Updated seating plan for the quarterly review, with the room change',
22
- from: 'jonas.frei@company.com',
23
- date: 'Oct 26, 17:48',
24
- preview: 'The review moves to the large room on the third floor. Seats are as before.',
25
- },
26
- {
27
- id: 'email_04',
28
- subject: 'Your train ticket to Geneva',
29
- from: 'tickets@company.com',
30
- date: 'Oct 26, 08:03',
31
- preview: 'Your ticket for 28 October is attached. Show it together with your half-fare card.',
32
- },
33
- {
34
- id: 'email_05',
35
- subject: 'Feedback on the onboarding draft',
36
- from: 'lea.baumann@company.com',
37
- date: 'Oct 24, 16:20',
38
- preview: 'Two comments on the second section, the rest reads well.',
39
- },
40
- {
41
- id: 'email_06',
42
- subject: 'Lunch on Thursday?',
43
- from: 'noah.meier@company.com',
44
- date: 'Oct 24, 11:35',
45
- preview: 'The place by the river has a table at 12:15 if you are in.',
46
- },
47
- ];
48
-
49
- // Two events: fewer than the default limit of three.
50
- export const CALENDAR_EVENTS: CalendarEvent[] = [
51
- {
52
- id: 'event_01',
53
- title: 'Quarterly review',
54
- time: 'Tue, Oct 28, 10:00 to 11:30',
55
- location: 'Room Säntis, third floor',
56
- },
57
- {
58
- id: 'event_02',
59
- title: 'Call with the onboarding team',
60
- time: 'Tue, Oct 28, 14:00 to 14:30',
61
- location: null,
62
- },
63
- ];
64
-
65
- // Shaped like the connections a transport search returns; the third one has the long route.
66
- export const TRAIN_CONNECTIONS: TrainConnection[] = [
67
- {
68
- id: 'conn_01',
69
- line: 'IC 1',
70
- route: 'Zurich HB → Geneva Airport',
71
- departure: '08:02',
72
- arrival: '10:57',
73
- duration: '2h 55m',
74
- transfers: 0,
75
- },
76
- {
77
- id: 'conn_02',
78
- line: 'IR 15',
79
- route: 'Zurich HB → Geneva',
80
- departure: '08:32',
81
- arrival: '11:16',
82
- duration: '2h 44m',
83
- transfers: 0,
84
- },
85
- {
86
- id: 'conn_03',
87
- line: 'IC 5',
88
- route: 'Zurich HB → Geneva Airport via Biel/Bienne and Neuchâtel',
89
- departure: '09:03',
90
- arrival: '11:58',
91
- duration: '2h 55m',
92
- transfers: 1,
93
- },
94
- {
95
- id: 'conn_04',
96
- line: 'IC 1',
97
- route: 'Zurich HB → Geneva Airport',
98
- departure: '09:02',
99
- arrival: '11:57',
100
- duration: '2h 55m',
101
- transfers: 0,
102
- },
103
- {
104
- id: 'conn_05',
105
- line: 'IR 15',
106
- route: 'Zurich HB → Geneva',
107
- departure: '09:32',
108
- arrival: '12:16',
109
- duration: '2h 44m',
110
- transfers: 0,
111
- },
112
- ];
@@ -1,36 +0,0 @@
1
- import type { ReactNode } from 'react';
2
-
3
- import {
4
- ChatCard,
5
- ChatCardBody,
6
- ChatCardContent,
7
- ChatCardHeader,
8
- ChatCardHeaderContent,
9
- ChatCardSubTitle,
10
- ChatCardTitle,
11
- } from '../../../components/chat-card';
12
-
13
- export interface ResultCardProps {
14
- title: string;
15
- subTitle: string;
16
- children?: ReactNode;
17
- }
18
-
19
- /** One card of a result list: a title, a line under it and, when there is one, a body. */
20
- export function ResultCard({ title, subTitle, children }: ResultCardProps) {
21
- return (
22
- <ChatCard fullWidth>
23
- <ChatCardHeader>
24
- <ChatCardHeaderContent>
25
- <ChatCardTitle>{title}</ChatCardTitle>
26
- <ChatCardSubTitle>{subTitle}</ChatCardSubTitle>
27
- </ChatCardHeaderContent>
28
- </ChatCardHeader>
29
- {children ? (
30
- <ChatCardBody>
31
- <ChatCardContent>{children}</ChatCardContent>
32
- </ChatCardBody>
33
- ) : null}
34
- </ChatCard>
35
- );
36
- }
@@ -1,31 +0,0 @@
1
- /** An email as the list shows it: the header fields and a one-line preview. */
2
- export interface EmailSummary {
3
- id: string;
4
- subject: string;
5
- from: string;
6
- /** Pre-formatted the way the card header shows it. */
7
- date: string;
8
- /** `null` when the message has no text body, only attachments. */
9
- preview: string | null;
10
- }
11
-
12
- /** A calendar event as the list shows it. */
13
- export interface CalendarEvent {
14
- id: string;
15
- title: string;
16
- /** Pre-formatted the way the card header shows it. */
17
- time: string;
18
- /** `null` for an event without a room or an address. */
19
- location: string | null;
20
- }
21
-
22
- /** One connection of a transport search. */
23
- export interface TrainConnection {
24
- id: string;
25
- line: string;
26
- route: string;
27
- departure: string;
28
- arrival: string;
29
- duration: string;
30
- transfers: number;
31
- }
@@ -1,204 +0,0 @@
1
- import { cleanup, fireEvent, render, screen } from '@testing-library/react';
2
- import { afterEach, describe, expect, test, vi } from 'vitest';
3
-
4
- import {
5
- ChatCardListLayout,
6
- ChatCardListLayoutItems,
7
- ChatCardListLayoutShowMore,
8
- useChatCardListLayoutContext,
9
- } from '../chat-card-list-layout';
10
- import type { ChatCardListLayoutProps } from '../chat-card-list-layout';
11
-
12
- /**
13
- * What this file is about is the contract between the three parts: the slice one of them
14
- * computes, the count another one reads, and the one-way state the root holds between
15
- * them. `Button` and `Slot` have their own suites — nothing here asserts on appearance.
16
- */
17
-
18
- afterEach(() => {
19
- cleanup();
20
- vi.restoreAllMocks();
21
- });
22
-
23
- /** One list item. `data-item` exists only so a test can count what actually mounted. */
24
- function Item({ label }: { label: string }) {
25
- return <div data-item>{label}</div>;
26
- }
27
-
28
- function items(count: number) {
29
- return Array.from({ length: count }, (_, index) => <Item key={index} label={`Card ${index}`} />);
30
- }
31
-
32
- function renderLayout(count: number, props: Partial<ChatCardListLayoutProps> = {}) {
33
- return render(
34
- <ChatCardListLayout {...props}>
35
- <ChatCardListLayoutItems>{items(count)}</ChatCardListLayoutItems>
36
- <ChatCardListLayoutShowMore>Show more</ChatCardListLayoutShowMore>
37
- </ChatCardListLayout>,
38
- );
39
- }
40
-
41
- function mountedItems(container: HTMLElement) {
42
- return container.querySelectorAll('[data-item]').length;
43
- }
44
-
45
- function showMore() {
46
- return screen.queryByRole('button', { name: /show more/i });
47
- }
48
-
49
- describe('the collapsed list', () => {
50
- test('mounts only the visible slice', () => {
51
- const { container } = renderLayout(8, { visibleCount: 3 });
52
-
53
- expect(mountedItems(container)).toBe(3);
54
- });
55
-
56
- test('defaults to three visible items', () => {
57
- const { container } = renderLayout(8);
58
-
59
- expect(mountedItems(container)).toBe(3);
60
- });
61
-
62
- // The hidden cards are sliced out rather than hidden with CSS, so nothing that is not
63
- // yet revealed may be reachable in the DOM at all — no off-screen images, no stray tab
64
- // stops. Counting elements alone would miss text rendered by a hidden card.
65
- test('leaves no trace of the hidden items in the DOM', () => {
66
- const { container } = renderLayout(8, { visibleCount: 3 });
67
-
68
- expect(container.textContent).toContain('Card 2');
69
- expect(container.textContent).not.toContain('Card 3');
70
- });
71
-
72
- // A negative count reaches `Array.slice` as an offset from the end, which would render
73
- // the *last* n items instead of none.
74
- test('renders nothing when visibleCount is negative', () => {
75
- const { container } = renderLayout(8, { visibleCount: -2 });
76
-
77
- expect(mountedItems(container)).toBe(0);
78
- expect(showMore()).not.toBeNull();
79
- });
80
- });
81
-
82
- describe('the show more button', () => {
83
- test('reveals every item and then removes itself', () => {
84
- const { container } = renderLayout(8, { visibleCount: 3 });
85
-
86
- fireEvent.click(screen.getByRole('button', { name: /show more/i }));
87
-
88
- expect(mountedItems(container)).toBe(8);
89
- expect(showMore()).toBeNull();
90
- });
91
-
92
- // The button is a one-shot affordance, not a toggle: with nothing left to reveal it must
93
- // never have been rendered, rather than rendered and disabled.
94
- test('is absent when the list is shorter than the limit', () => {
95
- renderLayout(2, { visibleCount: 3 });
96
-
97
- expect(showMore()).toBeNull();
98
- });
99
-
100
- test('is absent when the list is exactly the limit', () => {
101
- renderLayout(3, { visibleCount: 3 });
102
-
103
- expect(showMore()).toBeNull();
104
- });
105
-
106
- test('is absent when the layout starts expanded', () => {
107
- const { container } = renderLayout(8, { visibleCount: 3, defaultExpanded: true });
108
-
109
- expect(mountedItems(container)).toBe(8);
110
- expect(showMore()).toBeNull();
111
- });
112
-
113
- test('runs the consumer onClick as well as expanding', () => {
114
- const onClick = vi.fn();
115
- const { container } = render(
116
- <ChatCardListLayout visibleCount={3}>
117
- <ChatCardListLayoutItems>{items(8)}</ChatCardListLayoutItems>
118
- <ChatCardListLayoutShowMore onClick={onClick}>Show more</ChatCardListLayoutShowMore>
119
- </ChatCardListLayout>,
120
- );
121
-
122
- fireEvent.click(screen.getByRole('button', { name: /show more/i }));
123
-
124
- expect(onClick).toHaveBeenCalledTimes(1);
125
- expect(mountedItems(container)).toBe(8);
126
- });
127
- });
128
-
129
- describe('controlled expansion', () => {
130
- test('reports the change but does not expand on its own', () => {
131
- const onExpandedChange = vi.fn();
132
- const { container } = renderLayout(8, {
133
- visibleCount: 3,
134
- expanded: false,
135
- onExpandedChange,
136
- });
137
-
138
- fireEvent.click(screen.getByRole('button', { name: /show more/i }));
139
-
140
- expect(onExpandedChange).toHaveBeenCalledWith(true);
141
- expect(mountedItems(container)).toBe(3);
142
- });
143
-
144
- test('follows the prop when the owner flips it', () => {
145
- const { container, rerender } = render(
146
- <ChatCardListLayout visibleCount={3} expanded={false}>
147
- <ChatCardListLayoutItems>{items(8)}</ChatCardListLayoutItems>
148
- <ChatCardListLayoutShowMore>Show more</ChatCardListLayoutShowMore>
149
- </ChatCardListLayout>,
150
- );
151
-
152
- rerender(
153
- <ChatCardListLayout visibleCount={3} expanded>
154
- <ChatCardListLayoutItems>{items(8)}</ChatCardListLayoutItems>
155
- <ChatCardListLayoutShowMore>Show more</ChatCardListLayoutShowMore>
156
- </ChatCardListLayout>,
157
- );
158
-
159
- expect(mountedItems(container)).toBe(8);
160
- expect(showMore()).toBeNull();
161
- });
162
-
163
- test('notifies the uncontrolled owner too', () => {
164
- const onExpandedChange = vi.fn();
165
- renderLayout(8, { visibleCount: 3, onExpandedChange });
166
-
167
- fireEvent.click(screen.getByRole('button', { name: /show more/i }));
168
-
169
- expect(onExpandedChange).toHaveBeenCalledWith(true);
170
- });
171
- });
172
-
173
- describe('useChatCardListLayoutContext', () => {
174
- test('publishes the hidden count to a custom trigger', () => {
175
- function CountLabel() {
176
- const { hiddenCount } = useChatCardListLayoutContext();
177
-
178
- return <span>{`${hiddenCount} hidden`}</span>;
179
- }
180
-
181
- render(
182
- <ChatCardListLayout visibleCount={3}>
183
- <ChatCardListLayoutItems>{items(8)}</ChatCardListLayoutItems>
184
- <CountLabel />
185
- </ChatCardListLayout>,
186
- );
187
-
188
- expect(screen.getByText('5 hidden')).not.toBeNull();
189
- });
190
-
191
- // The throw is the behaviour: a part rendered as a sibling of the layout instead of a
192
- // child would otherwise read `visibleCount` off `undefined` deep inside the render.
193
- test('throws when used outside a ChatCardListLayout', () => {
194
- vi.spyOn(console, 'error').mockImplementation(() => {});
195
-
196
- function Orphan() {
197
- useChatCardListLayoutContext();
198
-
199
- return null;
200
- }
201
-
202
- expect(() => render(<Orphan />)).toThrow(/\[web-chat-ui\]/);
203
- });
204
- });