@swisper.ai/web-chat-ui 0.1.0 → 0.2.1
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/README.md +2 -5
- package/dist/components/chat-card/chat-card.stories.d.ts.map +1 -1
- package/dist/components/chat-card-container/chat-card-container.stories.d.ts.map +1 -1
- package/dist/components/rich-text-field/rich-text-field.stories.d.ts.map +1 -1
- package/dist/components/rich-text-field/utils.d.ts +36 -36
- package/dist/index.css +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +1566 -1810
- package/dist/index.es.js.map +1 -1
- package/package.json +4 -4
- package/src/components/chat-card/chat-card.json +6 -6
- package/src/components/chat-card/chat-card.stories.tsx +6 -14
- package/src/components/chat-card/components/chat-card-body.tsx +1 -1
- package/src/components/chat-card-container/chat-card-container.json +6 -6
- package/src/components/chat-card-container/chat-card-container.stories.tsx +10 -18
- package/src/components/chat-container/chat-container.json +1 -1
- package/src/components/chat-list/chat-list-items.tsx +3 -3
- package/src/components/rich-text-field/rich-text-field.stories.tsx +3 -1
- package/src/index.ts +0 -1
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts +0 -97
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts.map +0 -1
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts +0 -52
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts.map +0 -1
- package/dist/layouts/chat-card-list-layout/index.d.ts +0 -3
- package/dist/layouts/chat-card-list-layout/index.d.ts.map +0 -1
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.d.ts +0 -89
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.d.ts.map +0 -1
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.d.ts +0 -44
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.d.ts.map +0 -1
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts +0 -62
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts.map +0 -1
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.d.ts +0 -81
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.d.ts.map +0 -1
- package/dist/layouts/chat-card-three-column-layout/index.d.ts +0 -5
- package/dist/layouts/chat-card-three-column-layout/index.d.ts.map +0 -1
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts +0 -37
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts.map +0 -1
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.d.ts +0 -12
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.d.ts.map +0 -1
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts +0 -40
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts.map +0 -1
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.d.ts +0 -35
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.d.ts.map +0 -1
- package/dist/layouts/chat-card-two-column-layout/index.d.ts +0 -4
- package/dist/layouts/chat-card-two-column-layout/index.d.ts.map +0 -1
- package/dist/layouts/index.d.ts +0 -4
- package/dist/layouts/index.d.ts.map +0 -1
- package/src/layouts/chat-card-list-layout/__stories__/fixtures.ts +0 -112
- package/src/layouts/chat-card-list-layout/__stories__/result-card.tsx +0 -36
- package/src/layouts/chat-card-list-layout/__stories__/types.ts +0 -31
- package/src/layouts/chat-card-list-layout/__tests__/chat-card-list-layout.spec.tsx +0 -204
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.json +0 -129
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.stories.tsx +0 -422
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.tsx +0 -254
- package/src/layouts/chat-card-list-layout/index.ts +0 -11
- package/src/layouts/chat-card-three-column-layout/__stories__/fixtures.ts +0 -117
- package/src/layouts/chat-card-three-column-layout/__stories__/resizable-chat-window.tsx +0 -18
- package/src/layouts/chat-card-three-column-layout/__stories__/stay-details.tsx +0 -85
- package/src/layouts/chat-card-three-column-layout/__stories__/stay-list.tsx +0 -47
- package/src/layouts/chat-card-three-column-layout/__stories__/stay-map.tsx +0 -44
- package/src/layouts/chat-card-three-column-layout/__stories__/stay-rooms.tsx +0 -61
- package/src/layouts/chat-card-three-column-layout/__stories__/types.ts +0 -35
- package/src/layouts/chat-card-three-column-layout/__tests__/chat-card-three-column-layout.sizing.test.ts +0 -71
- package/src/layouts/chat-card-three-column-layout/__tests__/chat-card-three-column-layout.spec.tsx +0 -327
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.json +0 -153
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.ts +0 -76
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.tsx +0 -658
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.tsx +0 -293
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.ts +0 -146
- package/src/layouts/chat-card-three-column-layout/index.ts +0 -24
- package/src/layouts/chat-card-two-column-layout/__stories__/connection-itinerary.tsx +0 -51
- package/src/layouts/chat-card-two-column-layout/__stories__/fixtures.ts +0 -83
- package/src/layouts/chat-card-two-column-layout/__stories__/route-map.tsx +0 -24
- package/src/layouts/chat-card-two-column-layout/__stories__/types.ts +0 -15
- package/src/layouts/chat-card-two-column-layout/__tests__/chat-card-two-column-layout.spec.tsx +0 -109
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.json +0 -109
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.ts +0 -21
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.tsx +0 -439
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.tsx +0 -141
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.ts +0 -65
- package/src/layouts/chat-card-two-column-layout/index.ts +0 -17
- package/src/layouts/index.ts +0 -3
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { Slot } from '@radix-ui/react-slot';
|
|
2
|
-
import { createContext, forwardRef, useContext } from 'react';
|
|
3
|
-
import type { ComponentProps, ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
import { cn } from '@swisper.ai/web-core';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
chatCardTwoColumnLayoutAsideVariants,
|
|
9
|
-
chatCardTwoColumnLayoutGridVariants,
|
|
10
|
-
chatCardTwoColumnLayoutMainVariants,
|
|
11
|
-
chatCardTwoColumnLayoutVariants,
|
|
12
|
-
} from './chat-card-two-column-layout.variants';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Carries nothing but "inside the layout". The panes' container queries only match inside
|
|
16
|
-
* the root's named container, so a pane outside it would stay stacked forever without any
|
|
17
|
-
* error. The check turns that into one.
|
|
18
|
-
*/
|
|
19
|
-
const ChatCardTwoColumnLayoutContext = createContext(false);
|
|
20
|
-
|
|
21
|
-
function useChatCardTwoColumnLayoutContext(part: string) {
|
|
22
|
-
if (!useContext(ChatCardTwoColumnLayoutContext)) {
|
|
23
|
-
throw new Error(
|
|
24
|
-
`[web-chat-ui] "${part}" must be used within a ChatCardTwoColumnLayout. ` +
|
|
25
|
-
'Its columns come from the layout’s container query, so render it as a child of ' +
|
|
26
|
-
'the ChatCardTwoColumnLayout element, not as a sibling of it.',
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface ChatCardTwoColumnLayoutProps extends ComponentProps<'div'> {
|
|
32
|
-
children: ReactNode;
|
|
33
|
-
/**
|
|
34
|
-
* Classes for the grid the root renders around its children, merged after its defaults, e.g.
|
|
35
|
-
* `gap-8` for a tighter gutter. Keep the column and row templates: the panes rely on them.
|
|
36
|
-
*/
|
|
37
|
-
gridClassName?: string;
|
|
38
|
-
asChild?: boolean;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* A two-pane card body: Aside (a 336px column) beside Main (flexible), stacked as Aside over
|
|
43
|
-
* Main when the layout is narrower than 744px.
|
|
44
|
-
*
|
|
45
|
-
* The switch is a container query on the layout's **own width**, not a viewport breakpoint,
|
|
46
|
-
* because the card is sized by the chat window, not the viewport. Nothing floats, so unlike
|
|
47
|
-
* the three-column layout there is no measuring and no render prop.
|
|
48
|
-
*
|
|
49
|
-
* The root is the query container and renders the grid inside itself: an element cannot
|
|
50
|
-
* query its own width. `className` goes on the root, so a height set there reaches the grid.
|
|
51
|
-
* Height is not set here, because it belongs to the content, so pass it in `className`.
|
|
52
|
-
* `gridClassName` reaches the grid itself.
|
|
53
|
-
*/
|
|
54
|
-
export const ChatCardTwoColumnLayout = forwardRef<HTMLDivElement, ChatCardTwoColumnLayoutProps>(
|
|
55
|
-
function ChatCardTwoColumnLayout(
|
|
56
|
-
{ children, className, gridClassName, asChild = false, ...rest },
|
|
57
|
-
ref,
|
|
58
|
-
) {
|
|
59
|
-
const Component = asChild ? Slot : 'div';
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<ChatCardTwoColumnLayoutContext.Provider value>
|
|
63
|
-
<Component
|
|
64
|
-
ref={ref}
|
|
65
|
-
data-testid="chat-card-two-column-layout"
|
|
66
|
-
data-slot="chat-card-two-column-layout"
|
|
67
|
-
className={cn(chatCardTwoColumnLayoutVariants(), className)}
|
|
68
|
-
{...rest}
|
|
69
|
-
>
|
|
70
|
-
<div
|
|
71
|
-
data-testid="chat-card-two-column-layout-grid"
|
|
72
|
-
data-slot="chat-card-two-column-layout-grid"
|
|
73
|
-
className={cn(chatCardTwoColumnLayoutGridVariants(), gridClassName)}
|
|
74
|
-
>
|
|
75
|
-
{children}
|
|
76
|
-
</div>
|
|
77
|
-
</Component>
|
|
78
|
-
</ChatCardTwoColumnLayoutContext.Provider>
|
|
79
|
-
);
|
|
80
|
-
},
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
ChatCardTwoColumnLayout.displayName = 'ChatCardTwoColumnLayout';
|
|
84
|
-
|
|
85
|
-
export interface ChatCardTwoColumnLayoutAsideProps extends ComponentProps<'aside'> {
|
|
86
|
-
children: ReactNode;
|
|
87
|
-
asChild?: boolean;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/** Column 1 (336px) when the layout is at least 744px wide; the first row below that. */
|
|
91
|
-
export const ChatCardTwoColumnLayoutAside = forwardRef<
|
|
92
|
-
HTMLElement,
|
|
93
|
-
ChatCardTwoColumnLayoutAsideProps
|
|
94
|
-
>(function ChatCardTwoColumnLayoutAside({ children, className, asChild = false, ...rest }, ref) {
|
|
95
|
-
useChatCardTwoColumnLayoutContext('ChatCardTwoColumnLayoutAside');
|
|
96
|
-
|
|
97
|
-
const Component = asChild ? Slot : 'aside';
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
<Component
|
|
101
|
-
ref={ref}
|
|
102
|
-
data-testid="chat-card-two-column-layout-aside"
|
|
103
|
-
data-slot="chat-card-two-column-layout-aside"
|
|
104
|
-
className={cn(chatCardTwoColumnLayoutAsideVariants(), className)}
|
|
105
|
-
{...rest}
|
|
106
|
-
>
|
|
107
|
-
{children}
|
|
108
|
-
</Component>
|
|
109
|
-
);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
ChatCardTwoColumnLayoutAside.displayName = 'ChatCardTwoColumnLayoutAside';
|
|
113
|
-
|
|
114
|
-
export interface ChatCardTwoColumnLayoutMainProps extends ComponentProps<'main'> {
|
|
115
|
-
children: ReactNode;
|
|
116
|
-
asChild?: boolean;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/** The flexible track: column 2 side by side, the second row (taking the rest) stacked. */
|
|
120
|
-
export const ChatCardTwoColumnLayoutMain = forwardRef<
|
|
121
|
-
HTMLElement,
|
|
122
|
-
ChatCardTwoColumnLayoutMainProps
|
|
123
|
-
>(function ChatCardTwoColumnLayoutMain({ children, className, asChild = false, ...rest }, ref) {
|
|
124
|
-
useChatCardTwoColumnLayoutContext('ChatCardTwoColumnLayoutMain');
|
|
125
|
-
|
|
126
|
-
const Component = asChild ? Slot : 'main';
|
|
127
|
-
|
|
128
|
-
return (
|
|
129
|
-
<Component
|
|
130
|
-
ref={ref}
|
|
131
|
-
data-testid="chat-card-two-column-layout-main"
|
|
132
|
-
data-slot="chat-card-two-column-layout-main"
|
|
133
|
-
className={cn(chatCardTwoColumnLayoutMainVariants(), className)}
|
|
134
|
-
{...rest}
|
|
135
|
-
>
|
|
136
|
-
{children}
|
|
137
|
-
</Component>
|
|
138
|
-
);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
ChatCardTwoColumnLayoutMain.displayName = 'ChatCardTwoColumnLayoutMain';
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { cva } from 'class-variance-authority';
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* The layout switches on a container query against its own width, not on viewport
|
|
5
|
-
* breakpoints: the card is sized by the chat window, and a sidebar or split view makes the
|
|
6
|
-
* viewport claim room the card doesn't have. `336px` and `744px` are `ASIDE_WIDTH` and
|
|
7
|
-
* `TWO_COLUMN_MIN_WIDTH` from `chat-card-two-column-layout.sizing.ts`, written out because
|
|
8
|
-
* Tailwind cannot read a constant. Change both together.
|
|
9
|
-
*
|
|
10
|
-
* The container is named so a two-column layout nested in another container still queries
|
|
11
|
-
* its own root, not the nearest ancestor.
|
|
12
|
-
*
|
|
13
|
-
* Class strings are written out in full because Tailwind finds classes by scanning source;
|
|
14
|
-
* a class assembled from a constant is never generated.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Root: the query container, nothing else. An element cannot match a container query
|
|
19
|
-
* against its own width, so the grid lives one level down, in `…GridVariants`.
|
|
20
|
-
*/
|
|
21
|
-
export const chatCardTwoColumnLayoutVariants = cva(['@container/chat-card-two-column-layout']);
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The grid, rendered by the root around its children.
|
|
25
|
-
*
|
|
26
|
-
* Stacked, the rows are `auto 1fr`, so with a height on the root Main takes whatever Aside
|
|
27
|
-
* leaves. Side by side there is one `1fr` row; the stacked template would otherwise leave an
|
|
28
|
-
* empty `1fr` second row taking the height.
|
|
29
|
-
*/
|
|
30
|
-
export const chatCardTwoColumnLayoutGridVariants = cva([
|
|
31
|
-
'grid h-full gap-16',
|
|
32
|
-
'grid-cols-[minmax(0,1fr)] grid-rows-[auto_1fr]',
|
|
33
|
-
'@[744px]/chat-card-two-column-layout:grid-cols-[336px_minmax(0,1fr)] @[744px]/chat-card-two-column-layout:grid-rows-[minmax(0,1fr)]',
|
|
34
|
-
]);
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Row 1 when stacked, column 1 when side by side. In the column, `min-h-0` + `overflow-hidden`
|
|
38
|
-
* keep a long list inside the row. Without them the grid item grows to its content and the
|
|
39
|
-
* card gets taller instead of scrolling.
|
|
40
|
-
*/
|
|
41
|
-
export const chatCardTwoColumnLayoutAsideVariants = cva([
|
|
42
|
-
'min-w-0 min-h-0',
|
|
43
|
-
'@[744px]/chat-card-two-column-layout:h-full @[744px]/chat-card-two-column-layout:overflow-hidden',
|
|
44
|
-
]);
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* The flexible track. `min-w-0` because a grid item's minimum width is its content by
|
|
48
|
-
* default: a map or a wide table would push the track past the card. `relative` so the
|
|
49
|
-
* consumer can anchor their own overlays to Main.
|
|
50
|
-
*/
|
|
51
|
-
export const chatCardTwoColumnLayoutMainVariants = cva(['relative min-w-0 min-h-0 h-full']);
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Width recipe for the `ChatCard` that wraps the layout. The same recipe, for the same
|
|
55
|
-
* reason, as `chatCardThreeColumnLayoutCardVariants`: a grid of `1fr` tracks has no intrinsic
|
|
56
|
-
* width, so inside a shrink-to-fit message the card would collapse to nothing. It takes the
|
|
57
|
-
* whole chat window instead, and the layout decides whether two columns fit.
|
|
58
|
-
*
|
|
59
|
-
* Gated on `data-state=open` so a collapsed card goes back to header width.
|
|
60
|
-
*/
|
|
61
|
-
export const chatCardTwoColumnLayoutCardVariants = cva([
|
|
62
|
-
'data-[state=open]:w-full data-[state=open]:mx-0',
|
|
63
|
-
// `100%` fallback, like every other read of the variable, for a card outside `ChatContainer`
|
|
64
|
-
'data-[state=open]:min-w-[min(1130px,calc(var(--chat-window-width,100%)-var(--spacing-message)*2))]',
|
|
65
|
-
]);
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
ChatCardTwoColumnLayout,
|
|
3
|
-
ChatCardTwoColumnLayoutAside,
|
|
4
|
-
ChatCardTwoColumnLayoutMain,
|
|
5
|
-
} from './chat-card-two-column-layout';
|
|
6
|
-
export type {
|
|
7
|
-
ChatCardTwoColumnLayoutProps,
|
|
8
|
-
ChatCardTwoColumnLayoutAsideProps,
|
|
9
|
-
ChatCardTwoColumnLayoutMainProps,
|
|
10
|
-
} from './chat-card-two-column-layout';
|
|
11
|
-
export {
|
|
12
|
-
chatCardTwoColumnLayoutVariants,
|
|
13
|
-
chatCardTwoColumnLayoutGridVariants,
|
|
14
|
-
chatCardTwoColumnLayoutAsideVariants,
|
|
15
|
-
chatCardTwoColumnLayoutMainVariants,
|
|
16
|
-
chatCardTwoColumnLayoutCardVariants,
|
|
17
|
-
} from './chat-card-two-column-layout.variants';
|
package/src/layouts/index.ts
DELETED