@swisper.ai/web-chat-ui 0.0.9 → 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.
- package/README.md +2 -5
- package/dist/components/chat-card/chat-card.stories.d.ts.map +1 -1
- package/dist/components/chat-card/components/chat-card-header.d.ts.map +1 -1
- package/dist/components/chat-card-container/chat-card-container.stories.d.ts.map +1 -1
- package/dist/components/chat-thinking-process/chat-thinking-process.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 +38 -38
- 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 +1571 -1813
- package/dist/index.es.js.map +1 -1
- package/package.json +5 -5
- 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/components/chat-card-header.tsx +3 -7
- 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-thinking-process/chat-thinking-process.tsx +4 -12
- package/src/components/rich-text-area/__tests__/rich-text-area.spec.tsx +12 -2
- 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 -84
- 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 -45
- 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 -50
- 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 -73
- package/src/layouts/chat-card-three-column-layout/__tests__/chat-card-three-column-layout.spec.tsx +0 -282
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.json +0 -147
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.ts +0 -78
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.tsx +0 -694
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.tsx +0 -291
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.ts +0 -135
- 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,117 +0,0 @@
|
|
|
1
|
-
import type { RoomRate, Stay } from './types';
|
|
2
|
-
|
|
3
|
-
// The first result of the search: the one a single-property card shows.
|
|
4
|
-
export const FEATURED_STAY: Stay = {
|
|
5
|
-
id: 'limmatblick',
|
|
6
|
-
name: 'Hotel Limmatblick',
|
|
7
|
-
area: 'Altstadt · 0.4 km from Zurich HB',
|
|
8
|
-
pricePerNight: 'CHF 240',
|
|
9
|
-
total: 'CHF 720',
|
|
10
|
-
nights: 3,
|
|
11
|
-
description:
|
|
12
|
-
'A riverside townhouse with 42 rooms, a breakfast room over the Limmat and the old town at the door.',
|
|
13
|
-
amenities: ['Free Wi-Fi', 'Breakfast', 'Air conditioning', 'Lift'],
|
|
14
|
-
checkIn: '15:00',
|
|
15
|
-
checkOut: '11:00',
|
|
16
|
-
room: 'Double room · 1 queen bed · breakfast included',
|
|
17
|
-
cancellation: 'Free cancellation until 10 Nov',
|
|
18
|
-
pin: { left: 46, top: 38 },
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// Results of one search: a name that runs long, a rate that can't be refunded, and a property
|
|
22
|
-
// without a map location, which gets a row but no pin.
|
|
23
|
-
export const STAYS: Stay[] = [
|
|
24
|
-
FEATURED_STAY,
|
|
25
|
-
{
|
|
26
|
-
id: 'goldener-anker',
|
|
27
|
-
name: 'Pension Zum Goldenen Anker am Lindenhof, Altstadt Suites and Apartments',
|
|
28
|
-
area: 'Lindenhof · 0.7 km from Zurich HB',
|
|
29
|
-
pricePerNight: 'CHF 189',
|
|
30
|
-
total: 'CHF 567',
|
|
31
|
-
nights: 3,
|
|
32
|
-
description: 'Six apartments above a courtyard, each with a kitchenette and a washing machine.',
|
|
33
|
-
amenities: ['Kitchenette', 'Free Wi-Fi', 'Washing machine'],
|
|
34
|
-
checkIn: '16:00',
|
|
35
|
-
checkOut: '10:00',
|
|
36
|
-
room: 'Studio apartment · 1 double bed',
|
|
37
|
-
cancellation: 'Non-refundable',
|
|
38
|
-
pin: { left: 34, top: 52 },
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
id: 'seefeld-garden',
|
|
42
|
-
name: 'Seefeld Garden Hotel',
|
|
43
|
-
area: 'Seefeld · 2.1 km from Zurich HB',
|
|
44
|
-
pricePerNight: 'CHF 275',
|
|
45
|
-
total: 'CHF 825',
|
|
46
|
-
nights: 3,
|
|
47
|
-
description: 'A garden hotel two streets from the lake, with a sauna and bicycles to borrow.',
|
|
48
|
-
amenities: ['Sauna', 'Breakfast', 'Bicycles', 'Free Wi-Fi', 'Garden'],
|
|
49
|
-
checkIn: '15:00',
|
|
50
|
-
checkOut: '12:00',
|
|
51
|
-
room: 'Superior double · 1 king bed · breakfast included',
|
|
52
|
-
cancellation: 'Free cancellation until 11 Nov',
|
|
53
|
-
pin: { left: 68, top: 70 },
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
id: 'wiedikon-loft',
|
|
57
|
-
name: 'Wiedikon Loft House',
|
|
58
|
-
area: 'Wiedikon · 2.8 km from Zurich HB',
|
|
59
|
-
pricePerNight: 'CHF 162',
|
|
60
|
-
total: 'CHF 486',
|
|
61
|
-
nights: 3,
|
|
62
|
-
description:
|
|
63
|
-
'Self check-in lofts in a converted print shop, ten minutes by tram from the centre.',
|
|
64
|
-
amenities: ['Self check-in', 'Free Wi-Fi'],
|
|
65
|
-
checkIn: '15:00',
|
|
66
|
-
checkOut: '11:00',
|
|
67
|
-
room: 'Loft · 2 single beds',
|
|
68
|
-
cancellation: 'Free cancellation until 8 Nov',
|
|
69
|
-
pin: { left: 18, top: 66 },
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
id: 'uetliberg',
|
|
73
|
-
name: 'Gasthaus Uetliblick',
|
|
74
|
-
area: 'Uetliberg · 6.4 km from Zurich HB',
|
|
75
|
-
pricePerNight: 'CHF 205',
|
|
76
|
-
total: 'CHF 615',
|
|
77
|
-
nights: 3,
|
|
78
|
-
description: 'A hilltop guesthouse above the city, reached by the S10 and a ten-minute walk.',
|
|
79
|
-
amenities: ['Restaurant', 'Terrace', 'Breakfast'],
|
|
80
|
-
checkIn: '14:00',
|
|
81
|
-
checkOut: '11:00',
|
|
82
|
-
room: 'Twin room · 2 single beds · breakfast included',
|
|
83
|
-
cancellation: 'Free cancellation until 9 Nov',
|
|
84
|
-
pin: null,
|
|
85
|
-
},
|
|
86
|
-
];
|
|
87
|
-
|
|
88
|
-
// The rates of the featured stay, cheapest first; the suite does not say how many are left.
|
|
89
|
-
export const ROOM_RATES: RoomRate[] = [
|
|
90
|
-
{
|
|
91
|
-
id: 'rate_01',
|
|
92
|
-
room: 'Double room',
|
|
93
|
-
bedding: '1 queen bed · breakfast included',
|
|
94
|
-
cancellation: 'Free cancellation until 10 Nov',
|
|
95
|
-
pricePerNight: 'CHF 240',
|
|
96
|
-
total: 'CHF 720',
|
|
97
|
-
roomsLeft: 3,
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
id: 'rate_02',
|
|
101
|
-
room: 'Double room with river view',
|
|
102
|
-
bedding: '1 queen bed · breakfast included',
|
|
103
|
-
cancellation: 'Non-refundable',
|
|
104
|
-
pricePerNight: 'CHF 262',
|
|
105
|
-
total: 'CHF 786',
|
|
106
|
-
roomsLeft: 1,
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
id: 'rate_03',
|
|
110
|
-
room: 'Junior suite',
|
|
111
|
-
bedding: '1 king bed and 1 sofa bed · breakfast included',
|
|
112
|
-
cancellation: 'Free cancellation until 10 Nov',
|
|
113
|
-
pricePerNight: 'CHF 318',
|
|
114
|
-
total: 'CHF 954',
|
|
115
|
-
roomsLeft: null,
|
|
116
|
-
},
|
|
117
|
-
];
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
export interface ResizableChatWindowProps {
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/** A dashed box that starts 900px wide and resizes from its right edge, standing in for a chat window. */
|
|
8
|
-
export function ResizableChatWindow({ children }: ResizableChatWindowProps) {
|
|
9
|
-
return (
|
|
10
|
-
<div
|
|
11
|
-
role="group"
|
|
12
|
-
aria-label="Resizable chat window"
|
|
13
|
-
className="w-225 max-w-full min-w-90 resize-x overflow-auto border border-dashed border-card-border-base"
|
|
14
|
-
>
|
|
15
|
-
{children}
|
|
16
|
-
</div>
|
|
17
|
-
);
|
|
18
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { CloseIcon } from '@swisper.ai/icons';
|
|
2
|
-
import { Button, Chip, IconButton, ScrollArea, Typography } from '@swisper.ai/ui';
|
|
3
|
-
import { cn } from '@swisper.ai/web-core';
|
|
4
|
-
|
|
5
|
-
import type { Stay } from './types';
|
|
6
|
-
|
|
7
|
-
export interface StayDetailsProps {
|
|
8
|
-
stay: Stay;
|
|
9
|
-
/** Whether the Details pane floats over the map; the surface then lifts off it with a shadow. */
|
|
10
|
-
isFloating?: boolean;
|
|
11
|
-
/** Leave out on a card about one property, where there is no list to go back to. */
|
|
12
|
-
onClose?: () => void;
|
|
13
|
-
onCheckRooms?: () => void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** What the Details pane shows for the open property. The pane is transparent, so this draws the surface. */
|
|
17
|
-
export function StayDetails({ stay, isFloating = false, onClose, onCheckRooms }: StayDetailsProps) {
|
|
18
|
-
return (
|
|
19
|
-
<div
|
|
20
|
-
className={cn(
|
|
21
|
-
'flex h-full min-h-0 flex-col gap-12 rounded-10 border border-card-border-base bg-card-background-base p-12',
|
|
22
|
-
isFloating && 'shadow-md',
|
|
23
|
-
)}
|
|
24
|
-
>
|
|
25
|
-
<div className="flex items-center gap-8">
|
|
26
|
-
<Typography variant="body-medium" fontWeight="semibold" asChild>
|
|
27
|
-
<h3 className="line-clamp-1 min-w-0 flex-1" title={stay.name}>
|
|
28
|
-
{stay.name}
|
|
29
|
-
</h3>
|
|
30
|
-
</Typography>
|
|
31
|
-
{onClose && (
|
|
32
|
-
<IconButton variant="tertiary" size="sm" aria-label="Close details" onClick={onClose}>
|
|
33
|
-
<CloseIcon />
|
|
34
|
-
</IconButton>
|
|
35
|
-
)}
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
<ScrollArea className="min-h-0 flex-1">
|
|
39
|
-
<div className="flex flex-col gap-12">
|
|
40
|
-
<Typography variant="body-small-low" className="text-text-secondary">
|
|
41
|
-
{stay.description}
|
|
42
|
-
</Typography>
|
|
43
|
-
|
|
44
|
-
<ul aria-label="Amenities" className="flex flex-wrap gap-4">
|
|
45
|
-
{stay.amenities.map((amenity) => (
|
|
46
|
-
<li key={amenity}>
|
|
47
|
-
<Chip variant="outlined" size="2xs">
|
|
48
|
-
{amenity}
|
|
49
|
-
</Chip>
|
|
50
|
-
</li>
|
|
51
|
-
))}
|
|
52
|
-
</ul>
|
|
53
|
-
|
|
54
|
-
<Typography variant="caption-md" className="text-text-tertiary">
|
|
55
|
-
Check-in {stay.checkIn} · Check-out {stay.checkOut}
|
|
56
|
-
</Typography>
|
|
57
|
-
|
|
58
|
-
<div className="flex flex-col gap-4">
|
|
59
|
-
<Typography variant="caption-md" className="text-text-secondary">
|
|
60
|
-
From
|
|
61
|
-
</Typography>
|
|
62
|
-
<Typography variant="body-medium" fontWeight="semibold">
|
|
63
|
-
{stay.pricePerNight} avg / night
|
|
64
|
-
</Typography>
|
|
65
|
-
<Typography variant="caption-md" className="text-text-secondary">
|
|
66
|
-
{stay.total} total · {stay.nights} nights
|
|
67
|
-
</Typography>
|
|
68
|
-
<Typography variant="caption-md" className="text-text-secondary">
|
|
69
|
-
{stay.room}
|
|
70
|
-
</Typography>
|
|
71
|
-
<Typography variant="caption-md" className="text-text-secondary">
|
|
72
|
-
{stay.cancellation}
|
|
73
|
-
</Typography>
|
|
74
|
-
</div>
|
|
75
|
-
</div>
|
|
76
|
-
</ScrollArea>
|
|
77
|
-
|
|
78
|
-
{onCheckRooms && (
|
|
79
|
-
<Button variant="secondary" size="md" onClick={onCheckRooms}>
|
|
80
|
-
Check other rooms
|
|
81
|
-
</Button>
|
|
82
|
-
)}
|
|
83
|
-
</div>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { ScrollArea, Typography } from '@swisper.ai/ui';
|
|
2
|
-
import { cn } from '@swisper.ai/web-core';
|
|
3
|
-
|
|
4
|
-
import type { Stay } from './types';
|
|
5
|
-
|
|
6
|
-
export interface StayListProps {
|
|
7
|
-
stays: Stay[];
|
|
8
|
-
/** Whether the List pane floats: a swipe strip over the map, not a scrolling column. */
|
|
9
|
-
isFloating: boolean;
|
|
10
|
-
selectedId: string | null;
|
|
11
|
-
onOpen: (stayId: string) => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/** The search results: a scrolling column of rows, or a horizontal swipe strip when the pane floats. */
|
|
15
|
-
export function StayList({ stays, isFloating, selectedId, onOpen }: StayListProps) {
|
|
16
|
-
const list = (
|
|
17
|
-
<ul className={cn('flex gap-8', isFloating ? 'overflow-x-auto p-12' : 'flex-col')}>
|
|
18
|
-
{stays.map((stay) => (
|
|
19
|
-
<li key={stay.id} className={cn(isFloating && 'w-60 shrink-0')}>
|
|
20
|
-
<button
|
|
21
|
-
type="button"
|
|
22
|
-
aria-pressed={stay.id === selectedId}
|
|
23
|
-
onClick={() => onOpen(stay.id)}
|
|
24
|
-
className="flex w-full flex-col gap-2 rounded-10 border border-card-border-base bg-card-background-base p-12 text-left hover:bg-card-background-lvl-2 focus-visible:ring-2 focus-visible:ring-primary-focus-visible focus-visible:outline-none aria-pressed:border-primary-main"
|
|
25
|
-
>
|
|
26
|
-
<Typography
|
|
27
|
-
variant="body-small-high"
|
|
28
|
-
fontWeight="medium"
|
|
29
|
-
className="line-clamp-1"
|
|
30
|
-
asChild
|
|
31
|
-
>
|
|
32
|
-
<span>{stay.name}</span>
|
|
33
|
-
</Typography>
|
|
34
|
-
<Typography variant="caption-md" className="line-clamp-1 text-text-secondary" asChild>
|
|
35
|
-
<span>{stay.pin ? stay.area : `${stay.area} · Not on the map`}</span>
|
|
36
|
-
</Typography>
|
|
37
|
-
<Typography variant="caption-md" className="text-text-secondary" asChild>
|
|
38
|
-
<span>
|
|
39
|
-
{stay.pricePerNight} avg / night · {stay.total} total
|
|
40
|
-
</span>
|
|
41
|
-
</Typography>
|
|
42
|
-
</button>
|
|
43
|
-
</li>
|
|
44
|
-
))}
|
|
45
|
-
</ul>
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
// The strip scrolls sideways by itself; only the column needs a scroll area to stay in its row.
|
|
49
|
-
return isFloating ? list : <ScrollArea className="h-full">{list}</ScrollArea>;
|
|
50
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Button, Typography } from '@swisper.ai/ui';
|
|
2
|
-
|
|
3
|
-
import type { Stay } from './types';
|
|
4
|
-
|
|
5
|
-
export interface StayMapProps {
|
|
6
|
-
stays: Stay[];
|
|
7
|
-
selectedId: string | null;
|
|
8
|
-
onOpen: (stayId: string) => void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/** Stands in for the map: one price pin per property that has a location, and a note for the rest. */
|
|
12
|
-
export function StayMap({ stays, selectedId, onOpen }: StayMapProps) {
|
|
13
|
-
const unpinnedCount = stays.filter((stay) => stay.pin === null).length;
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<div className="relative h-full w-full overflow-hidden rounded-10 bg-card-background-lvl-2">
|
|
17
|
-
{stays.map(
|
|
18
|
-
(stay) =>
|
|
19
|
-
stay.pin && (
|
|
20
|
-
<Button
|
|
21
|
-
key={stay.id}
|
|
22
|
-
size="sm"
|
|
23
|
-
variant={stay.id === selectedId ? 'primary' : 'secondary'}
|
|
24
|
-
aria-label={`${stay.name}, ${stay.pricePerNight} avg / night`}
|
|
25
|
-
className="absolute"
|
|
26
|
-
style={{ left: `${stay.pin.left}%`, top: `${stay.pin.top}%` }}
|
|
27
|
-
onClick={() => onOpen(stay.id)}
|
|
28
|
-
>
|
|
29
|
-
{stay.pricePerNight}
|
|
30
|
-
</Button>
|
|
31
|
-
),
|
|
32
|
-
)}
|
|
33
|
-
|
|
34
|
-
{unpinnedCount > 0 && (
|
|
35
|
-
<Typography
|
|
36
|
-
variant="caption-md"
|
|
37
|
-
className="absolute top-10 left-10 rounded-10 bg-global-bg/90 px-10 py-4 text-text-secondary"
|
|
38
|
-
>
|
|
39
|
-
{unpinnedCount} of these {unpinnedCount === 1 ? 'has' : 'have'} no map location
|
|
40
|
-
</Typography>
|
|
41
|
-
)}
|
|
42
|
-
</div>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Button, ScrollArea, Typography } from '@swisper.ai/ui';
|
|
2
|
-
|
|
3
|
-
import type { RoomRate, Stay } from './types';
|
|
4
|
-
|
|
5
|
-
export interface StayRoomsProps {
|
|
6
|
-
stay: Stay;
|
|
7
|
-
rates: RoomRate[];
|
|
8
|
-
onBack: () => void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/** The view the Panel holds: every rate of the open property, and the control that closes the Panel. */
|
|
12
|
-
export function StayRooms({ stay, rates, onBack }: StayRoomsProps) {
|
|
13
|
-
return (
|
|
14
|
-
<div className="flex h-full min-h-0 flex-col gap-12 rounded-10 border border-card-border-base bg-card-background-base p-12 shadow-md">
|
|
15
|
-
<div className="flex items-center justify-between gap-12">
|
|
16
|
-
<Typography variant="body-medium" fontWeight="semibold" asChild>
|
|
17
|
-
<h3 className="line-clamp-1 min-w-0">Rooms at {stay.name}</h3>
|
|
18
|
-
</Typography>
|
|
19
|
-
<Button variant="tertiary" size="sm" className="shrink-0" onClick={onBack}>
|
|
20
|
-
Back to the property
|
|
21
|
-
</Button>
|
|
22
|
-
</div>
|
|
23
|
-
|
|
24
|
-
<ScrollArea className="min-h-0 flex-1">
|
|
25
|
-
<ul className="flex flex-col gap-8">
|
|
26
|
-
{rates.map((rate) => (
|
|
27
|
-
<li
|
|
28
|
-
key={rate.id}
|
|
29
|
-
className="flex items-start justify-between gap-12 rounded-10 border border-card-border-base p-12"
|
|
30
|
-
>
|
|
31
|
-
<div className="flex min-w-0 flex-col gap-2">
|
|
32
|
-
<Typography variant="body-small-high" fontWeight="medium">
|
|
33
|
-
{rate.room}
|
|
34
|
-
</Typography>
|
|
35
|
-
<Typography variant="caption-md" className="text-text-secondary">
|
|
36
|
-
{rate.bedding}
|
|
37
|
-
</Typography>
|
|
38
|
-
<Typography variant="caption-md" className="text-text-secondary">
|
|
39
|
-
{rate.cancellation}
|
|
40
|
-
</Typography>
|
|
41
|
-
</div>
|
|
42
|
-
<div className="flex shrink-0 flex-col items-end gap-2">
|
|
43
|
-
<Typography variant="body-small-high" fontWeight="semibold">
|
|
44
|
-
{rate.pricePerNight} avg / night
|
|
45
|
-
</Typography>
|
|
46
|
-
<Typography variant="caption-md" className="text-text-secondary">
|
|
47
|
-
{rate.total} total
|
|
48
|
-
</Typography>
|
|
49
|
-
{rate.roomsLeft !== null && (
|
|
50
|
-
<Typography variant="caption-md" className="text-text-tertiary">
|
|
51
|
-
{rate.roomsLeft} left
|
|
52
|
-
</Typography>
|
|
53
|
-
)}
|
|
54
|
-
</div>
|
|
55
|
-
</li>
|
|
56
|
-
))}
|
|
57
|
-
</ul>
|
|
58
|
-
</ScrollArea>
|
|
59
|
-
</div>
|
|
60
|
-
);
|
|
61
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/** Where a stay's price pin sits on the map stand-in, in percent of the map's box. */
|
|
2
|
-
export interface StayPin {
|
|
3
|
-
left: number;
|
|
4
|
-
top: number;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/** One property of an accommodation search, trimmed to what the list, the map and Details render. */
|
|
8
|
-
export interface Stay {
|
|
9
|
-
id: string;
|
|
10
|
-
name: string;
|
|
11
|
-
area: string;
|
|
12
|
-
pricePerNight: string;
|
|
13
|
-
total: string;
|
|
14
|
-
nights: number;
|
|
15
|
-
description: string;
|
|
16
|
-
amenities: string[];
|
|
17
|
-
checkIn: string;
|
|
18
|
-
checkOut: string;
|
|
19
|
-
room: string;
|
|
20
|
-
cancellation: string;
|
|
21
|
-
/** `null` when the property has no map location, so it gets a row but no pin. */
|
|
22
|
-
pin: StayPin | null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** One bookable rate of a property, as the rooms view lists it. */
|
|
26
|
-
export interface RoomRate {
|
|
27
|
-
id: string;
|
|
28
|
-
room: string;
|
|
29
|
-
bedding: string;
|
|
30
|
-
cancellation: string;
|
|
31
|
-
pricePerNight: string;
|
|
32
|
-
total: string;
|
|
33
|
-
/** `null` when the supplier does not say how many are left. */
|
|
34
|
-
roomsLeft: number | null;
|
|
35
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { resolveLayout } from '../chat-card-three-column-layout.sizing';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* The thresholds are the whole feature: every pane decision, in CSS and in the render
|
|
7
|
-
* props, comes from this function. Each boundary is tested at its exact pixel and one
|
|
8
|
-
* below, so an off-by-one (a `>` for a `>=`, a forgotten gap) shows up here instead of as
|
|
9
|
-
* a pane that floats with room to spare.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
describe('size tiers', () => {
|
|
13
|
-
// md from 640; lg = 290 list + 8 gap + 400 min Main; xl = 2 × 358 + 2 × 8 + 400
|
|
14
|
-
test.each([
|
|
15
|
-
[639, 'sm'],
|
|
16
|
-
[640, 'md'],
|
|
17
|
-
[697, 'md'],
|
|
18
|
-
[698, 'lg'],
|
|
19
|
-
[1131, 'lg'],
|
|
20
|
-
[1132, 'xl'],
|
|
21
|
-
])('at %ipx the layout is %s', (width, expected) => {
|
|
22
|
-
expect(resolveLayout(width, 'responsive').size).toBe(expected);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
describe('with responsive placement', () => {
|
|
27
|
-
test.each([
|
|
28
|
-
[500, { isListFloating: true, isDetailsFloating: true, isDetailsSheet: true }],
|
|
29
|
-
[660, { isListFloating: true, isDetailsFloating: true, isDetailsSheet: false }],
|
|
30
|
-
[800, { isListFloating: false, isDetailsFloating: true, isDetailsSheet: false }],
|
|
31
|
-
[1200, { isListFloating: false, isDetailsFloating: false, isDetailsSheet: false }],
|
|
32
|
-
])('at %ipx resolves %o', (width, expected) => {
|
|
33
|
-
expect(resolveLayout(width, 'responsive')).toMatchObject(expected);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// The bug that motivated measuring the layout: Details only got its column at a 1366px
|
|
37
|
-
// viewport, so a card with 1200px of room still floated it.
|
|
38
|
-
test('gives details its column once the layout has room, whatever the viewport', () => {
|
|
39
|
-
expect(resolveLayout(1200, 'responsive').isDetailsFloating).toBe(false);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe('with floating placement', () => {
|
|
44
|
-
// The tiers still apply to List; only Details is kept off its column.
|
|
45
|
-
test.each([
|
|
46
|
-
[500, 'sm', true],
|
|
47
|
-
[800, 'lg', false],
|
|
48
|
-
[1920, 'xl', false],
|
|
49
|
-
])('at %ipx is %s with list floating: %s, and details floats', (width, size, isListFloating) => {
|
|
50
|
-
expect(resolveLayout(width, 'floating')).toMatchObject({
|
|
51
|
-
size,
|
|
52
|
-
isListFloating,
|
|
53
|
-
isDetailsFloating: true,
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe('before the layout is measured', () => {
|
|
59
|
-
// SSR and the first client render have no width; the wide form is the safer guess
|
|
60
|
-
// because SSR HTML is mostly seen on desktops.
|
|
61
|
-
test('resolves to xl', () => {
|
|
62
|
-
expect(resolveLayout('unset', 'responsive')).toEqual({
|
|
63
|
-
size: 'xl',
|
|
64
|
-
isListFloating: false,
|
|
65
|
-
isDetailsFloating: false,
|
|
66
|
-
isDetailsSheet: false,
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test('still floats details with floating placement', () => {
|
|
71
|
-
expect(resolveLayout('unset', 'floating').isDetailsFloating).toBe(true);
|
|
72
|
-
});
|
|
73
|
-
});
|