@whity/ui 0.0.0-stage → 0.5.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 +107 -3
- package/package.json +192 -6
- package/src/access-denied.stories.tsx +179 -0
- package/src/access-denied.tsx +305 -0
- package/src/action-proposal.tsx +302 -0
- package/src/actor-chip.tsx +71 -0
- package/src/agent-activity.tsx +163 -0
- package/src/agent-collaboration.stories.tsx +156 -0
- package/src/agent-run-status.tsx +196 -0
- package/src/alert-dialog.stories.tsx +45 -0
- package/src/alert-dialog.tsx +147 -0
- package/src/alert.stories.tsx +91 -0
- package/src/alert.tsx +89 -0
- package/src/app-sidebar.stories.tsx +195 -0
- package/src/app-sidebar.tsx +500 -0
- package/src/approval-queue.tsx +108 -0
- package/src/audience-group-picker.stories.tsx +198 -0
- package/src/audience-group-picker.tsx +362 -0
- package/src/audience-people-picker.stories.tsx +102 -0
- package/src/audience-people-picker.tsx +279 -0
- package/src/avatar.tsx +83 -0
- package/src/badge.stories.tsx +105 -0
- package/src/badge.tsx +68 -0
- package/src/beta-warning.stories.tsx +79 -0
- package/src/beta-warning.tsx +189 -0
- package/src/bilingual-input.stories.tsx +82 -0
- package/src/bilingual-input.tsx +183 -0
- package/src/breadcrumb.stories.tsx +51 -0
- package/src/breadcrumb.tsx +90 -0
- package/src/button.stories.tsx +87 -0
- package/src/button.tsx +118 -0
- package/src/card.stories.tsx +423 -0
- package/src/card.tsx +180 -0
- package/src/chart.stories.tsx +66 -0
- package/src/chart.tsx +228 -0
- package/src/checkbox.stories.tsx +62 -0
- package/src/checkbox.tsx +54 -0
- package/src/collapsible.stories.tsx +48 -0
- package/src/collapsible.tsx +34 -0
- package/src/color-card.stories.tsx +61 -0
- package/src/color-card.tsx +270 -0
- package/src/color-picker.stories.tsx +65 -0
- package/src/color-picker.tsx +425 -0
- package/src/command-palette.tsx +306 -0
- package/src/copy-block.stories.tsx +38 -0
- package/src/copy-block.tsx +85 -0
- package/src/data-table.stories.tsx +200 -0
- package/src/data-table.tsx +1106 -0
- package/src/date-picker.stories.tsx +61 -0
- package/src/date-picker.tsx +422 -0
- package/src/design-cards.stories.tsx +458 -0
- package/src/dialog.stories.tsx +48 -0
- package/src/dialog.tsx +166 -0
- package/src/documents/barcode-svg.stories.tsx +72 -0
- package/src/documents/barcode-svg.tsx +79 -0
- package/src/dropdown-menu.stories.tsx +77 -0
- package/src/dropdown-menu.tsx +271 -0
- package/src/editor/behaviour.ts +279 -0
- package/src/editor/block-ids.ts +44 -0
- package/src/editor/block-list.tsx +101 -0
- package/src/editor/block-toolbar.tsx +477 -0
- package/src/editor/bubble.tsx +93 -0
- package/src/editor/catalogue.ts +103 -0
- package/src/editor/collab-rail.tsx +746 -0
- package/src/editor/collab.stories.tsx +207 -0
- package/src/editor/collab.ts +87 -0
- package/src/editor/contract.ts +408 -0
- package/src/editor/convert.ts +362 -0
- package/src/editor/doc-editor.stories.tsx +98 -0
- package/src/editor/doc-editor.tsx +1287 -0
- package/src/editor/editor.css +536 -0
- package/src/editor/extensions.ts +86 -0
- package/src/editor/field-picker.tsx +107 -0
- package/src/editor/fields.ts +100 -0
- package/src/editor/gutter.tsx +367 -0
- package/src/editor/index.ts +22 -0
- package/src/editor/label-sheet.tsx +289 -0
- package/src/editor/labels.ts +310 -0
- package/src/editor/link-tools.tsx +141 -0
- package/src/editor/node-views.tsx +450 -0
- package/src/editor/page-view.tsx +353 -0
- package/src/editor/publish-check.tsx +182 -0
- package/src/editor/rich-blocks.stories.tsx +146 -0
- package/src/editor/sample.ts +40 -0
- package/src/editor/schema-rich.ts +150 -0
- package/src/editor/schema.ts +315 -0
- package/src/editor/services.tsx +127 -0
- package/src/editor/slash.ts +64 -0
- package/src/editor/suggesting.ts +372 -0
- package/src/editor/suggestions.ts +763 -0
- package/src/editor/table-keys.ts +66 -0
- package/src/editor/templates.stories.tsx +324 -0
- package/src/editor/toolbar.tsx +358 -0
- package/src/empty-state.stories.tsx +51 -0
- package/src/empty-state.tsx +100 -0
- package/src/empty-state.usage-notes.md +30 -0
- package/src/form.stories.tsx +112 -0
- package/src/form.tsx +176 -0
- package/src/globals.css +20 -0
- package/src/icon-button.tsx +85 -0
- package/src/icon-map.ts +244 -0
- package/src/icon.tsx +41 -0
- package/src/index.ts +67 -0
- package/src/input.stories.tsx +157 -0
- package/src/input.tsx +759 -0
- package/src/locked-screen.stories.tsx +29 -0
- package/src/locked-screen.tsx +61 -0
- package/src/mark.tsx +62 -0
- package/src/math-text.stories.tsx +33 -0
- package/src/math-text.tsx +43 -0
- package/src/menu-bar.stories.tsx +198 -0
- package/src/menu-bar.tsx +373 -0
- package/src/money/currency.ts +230 -0
- package/src/page-header.stories.tsx +95 -0
- package/src/page-header.tsx +122 -0
- package/src/page-shell.stories.tsx +42 -0
- package/src/page-shell.tsx +32 -0
- package/src/pagination.stories.tsx +45 -0
- package/src/pagination.tsx +98 -0
- package/src/plugin-card.stories.tsx +180 -0
- package/src/plugin-card.tsx +848 -0
- package/src/popover.stories.tsx +48 -0
- package/src/popover.tsx +55 -0
- package/src/radio-group.stories.tsx +26 -0
- package/src/radio-group.tsx +44 -0
- package/src/route-flow/editor.tsx +1014 -0
- package/src/route-flow/model.ts +716 -0
- package/src/scope-grant.tsx +139 -0
- package/src/screen-too-small.stories.tsx +61 -0
- package/src/screen-too-small.tsx +104 -0
- package/src/select.stories.tsx +44 -0
- package/src/select.tsx +197 -0
- package/src/separator.stories.tsx +34 -0
- package/src/separator.tsx +34 -0
- package/src/sheet.stories.tsx +49 -0
- package/src/sheet.tsx +168 -0
- package/src/skeleton.stories.tsx +28 -0
- package/src/skeleton.tsx +19 -0
- package/src/slider.stories.tsx +78 -0
- package/src/slider.tsx +300 -0
- package/src/spinner.stories.tsx +33 -0
- package/src/spinner.tsx +55 -0
- package/src/switch.stories.tsx +42 -0
- package/src/switch.tsx +41 -0
- package/src/switcher.stories.tsx +111 -0
- package/src/switcher.tsx +131 -0
- package/src/table.stories.tsx +48 -0
- package/src/table.tsx +121 -0
- package/src/tabs.stories.tsx +74 -0
- package/src/tabs.tsx +90 -0
- package/src/tag-input.stories.tsx +67 -0
- package/src/tag-input.tsx +117 -0
- package/src/tenant-logo.tsx +63 -0
- package/src/tenant-switcher.stories.tsx +38 -0
- package/src/tenant-switcher.tsx +164 -0
- package/src/textarea.stories.tsx +27 -0
- package/src/textarea.tsx +18 -0
- package/src/theme-mode.ts +52 -0
- package/src/time-picker.stories.tsx +62 -0
- package/src/time-picker.tsx +615 -0
- package/src/toggle-group.tsx +138 -0
- package/src/tooltip.stories.tsx +43 -0
- package/src/tooltip.tsx +73 -0
- package/src/top-nav.stories.tsx +58 -0
- package/src/top-nav.tsx +324 -0
- package/src/undo-bar.tsx +107 -0
- package/src/utils.ts +45 -0
- package/src/view-toggle.stories.tsx +84 -0
- package/src/view-toggle.tsx +110 -0
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite"
|
|
2
|
+
import * as React from "react"
|
|
3
|
+
|
|
4
|
+
import { ActorChip } from "./actor-chip"
|
|
5
|
+
import { AgentRunStatus } from "./agent-run-status"
|
|
6
|
+
import { Avatar } from "./avatar"
|
|
7
|
+
import { Badge } from "./badge"
|
|
8
|
+
import { Button } from "./button"
|
|
9
|
+
import { Checkbox } from "./checkbox"
|
|
10
|
+
import {
|
|
11
|
+
Dialog,
|
|
12
|
+
DialogContent,
|
|
13
|
+
DialogDescription,
|
|
14
|
+
DialogFooter,
|
|
15
|
+
DialogHeader,
|
|
16
|
+
DialogTitle,
|
|
17
|
+
} from "./dialog"
|
|
18
|
+
import {
|
|
19
|
+
DropdownMenu,
|
|
20
|
+
DropdownMenuContent,
|
|
21
|
+
DropdownMenuItem,
|
|
22
|
+
DropdownMenuSeparator,
|
|
23
|
+
DropdownMenuShortcut,
|
|
24
|
+
DropdownMenuTrigger,
|
|
25
|
+
} from "./dropdown-menu"
|
|
26
|
+
import { Icon, iconNames } from "./icon"
|
|
27
|
+
import { IconButton } from "./icon-button"
|
|
28
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./popover"
|
|
29
|
+
import { RadioGroup, RadioGroupItem } from "./radio-group"
|
|
30
|
+
import { ToggleGroup } from "./toggle-group"
|
|
31
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip"
|
|
32
|
+
import { DocEditor } from "./editor/doc-editor"
|
|
33
|
+
import { SAMPLE_DOCUMENT } from "./editor/sample"
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* One story per design card (docs/design/components/<Name>), with the card's
|
|
37
|
+
* own content, rendered at the card's size from docs/design/cards.html. The
|
|
38
|
+
* screenshot check (scripts/design-cards-compare.mjs) renders these in light
|
|
39
|
+
* and dark and compares them with docs/design/screenshots/<Name>-<theme>.png.
|
|
40
|
+
* `parameters.designCard` names the card and its height; every card is 960 wide.
|
|
41
|
+
*/
|
|
42
|
+
const meta = {
|
|
43
|
+
title: "Design cards",
|
|
44
|
+
parameters: { layout: "fullscreen" },
|
|
45
|
+
} satisfies Meta
|
|
46
|
+
|
|
47
|
+
export default meta
|
|
48
|
+
type Story = StoryObj<typeof meta>
|
|
49
|
+
|
|
50
|
+
const card = (name: string, height: number) => ({ designCard: { name, width: 960, height } })
|
|
51
|
+
|
|
52
|
+
/** `.wy-stage`: a wrapping row, 12px apart, 16px by 24px of padding. */
|
|
53
|
+
function Stage({ className, ...props }: React.ComponentProps<"div">) {
|
|
54
|
+
return <div className={`flex flex-wrap items-center gap-3 px-6 py-4 ${className ?? ""}`} {...props} />
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The card page's own `#root` padding, for cards that put a stage inside it. */
|
|
58
|
+
function Root({ children }: { children: React.ReactNode }) {
|
|
59
|
+
return <div className="px-6 py-4">{children}</div>
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function Cap({ children }: { children: React.ReactNode }) {
|
|
63
|
+
return <p className="m-0 mb-1.5 text-xs text-muted-foreground">{children}</p>
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const ButtonCard: Story = {
|
|
67
|
+
name: "Button",
|
|
68
|
+
parameters: card("Button", 126),
|
|
69
|
+
render: () => (
|
|
70
|
+
<Stage>
|
|
71
|
+
<Button icon="send">Send invoice</Button>
|
|
72
|
+
<Button variant="outline">Save draft</Button>
|
|
73
|
+
<Button variant="secondary">Duplicate</Button>
|
|
74
|
+
<Button variant="ghost">Cancel</Button>
|
|
75
|
+
<Button variant="destructive" icon="delete">
|
|
76
|
+
Delete tenant
|
|
77
|
+
</Button>
|
|
78
|
+
<Button variant="link">View history</Button>
|
|
79
|
+
<Button size="sm" loading>
|
|
80
|
+
Saving
|
|
81
|
+
</Button>
|
|
82
|
+
<Button size="lg">Create workspace</Button>
|
|
83
|
+
</Stage>
|
|
84
|
+
),
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export const IconButtonCard: Story = {
|
|
88
|
+
name: "IconButton",
|
|
89
|
+
parameters: card("IconButton", 72),
|
|
90
|
+
render: () => (
|
|
91
|
+
<Stage>
|
|
92
|
+
<IconButton icon="edit" label="Edit" />
|
|
93
|
+
<IconButton icon="more" label="More actions" variant="outline" />
|
|
94
|
+
<IconButton icon="delete" label="Delete" variant="ghost" />
|
|
95
|
+
<IconButton icon="close" label="Close" />
|
|
96
|
+
</Stage>
|
|
97
|
+
),
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export const TooltipCard: Story = {
|
|
101
|
+
name: "Tooltip",
|
|
102
|
+
parameters: card("Tooltip", 130),
|
|
103
|
+
render: () => (
|
|
104
|
+
<Root>
|
|
105
|
+
<Stage className="gap-5 pt-11">
|
|
106
|
+
<Tooltip open>
|
|
107
|
+
<TooltipTrigger asChild>
|
|
108
|
+
<Button variant="outline" icon="download">
|
|
109
|
+
Download
|
|
110
|
+
</Button>
|
|
111
|
+
</TooltipTrigger>
|
|
112
|
+
<TooltipContent>Download as PDF</TooltipContent>
|
|
113
|
+
</Tooltip>
|
|
114
|
+
<Tooltip open>
|
|
115
|
+
<TooltipTrigger asChild>
|
|
116
|
+
<span className="inline-flex">
|
|
117
|
+
<IconButton icon="search" label="Search" tooltip={false} />
|
|
118
|
+
</span>
|
|
119
|
+
</TooltipTrigger>
|
|
120
|
+
<TooltipContent>
|
|
121
|
+
Search <kbd>⌘K</kbd>
|
|
122
|
+
</TooltipContent>
|
|
123
|
+
</Tooltip>
|
|
124
|
+
<IconButton icon="notification" label="Notifications" />
|
|
125
|
+
<IconButton icon="help" label="Help" />
|
|
126
|
+
<IconButton icon="more" label="More actions" variant="outline" />
|
|
127
|
+
<IconButton icon="edit" label="Edit" size="sm" />
|
|
128
|
+
</Stage>
|
|
129
|
+
</Root>
|
|
130
|
+
),
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export const MenuCard: Story = {
|
|
134
|
+
name: "Menu",
|
|
135
|
+
parameters: card("Menu", 430),
|
|
136
|
+
render: () => (
|
|
137
|
+
<Root>
|
|
138
|
+
<Stage className="min-h-[360px] items-start gap-[220px]">
|
|
139
|
+
<div>
|
|
140
|
+
<Cap>Menu</Cap>
|
|
141
|
+
<DropdownMenu open modal={false}>
|
|
142
|
+
<DropdownMenuTrigger asChild>
|
|
143
|
+
<Button variant="outline" iconEnd="chevron-down" aria-label="Invoice actions">
|
|
144
|
+
Actions
|
|
145
|
+
</Button>
|
|
146
|
+
</DropdownMenuTrigger>
|
|
147
|
+
<DropdownMenuContent align="start">
|
|
148
|
+
<DropdownMenuItem>
|
|
149
|
+
<Icon name="edit" /> Edit <DropdownMenuShortcut>E</DropdownMenuShortcut>
|
|
150
|
+
</DropdownMenuItem>
|
|
151
|
+
<DropdownMenuItem>
|
|
152
|
+
<Icon name="copy" /> Duplicate
|
|
153
|
+
</DropdownMenuItem>
|
|
154
|
+
<DropdownMenuItem>
|
|
155
|
+
<Icon name="download" /> Download PDF <DropdownMenuShortcut>⌘D</DropdownMenuShortcut>
|
|
156
|
+
</DropdownMenuItem>
|
|
157
|
+
<DropdownMenuItem>
|
|
158
|
+
<Icon name="send" />
|
|
159
|
+
<span className="grid gap-px">
|
|
160
|
+
Send a reminder
|
|
161
|
+
<span className="text-xs text-muted-foreground">Last sent 3 days ago</span>
|
|
162
|
+
</span>
|
|
163
|
+
</DropdownMenuItem>
|
|
164
|
+
<DropdownMenuSeparator />
|
|
165
|
+
<DropdownMenuItem variant="destructive">
|
|
166
|
+
<Icon name="delete" /> Void invoice
|
|
167
|
+
</DropdownMenuItem>
|
|
168
|
+
<DropdownMenuItem disabled>
|
|
169
|
+
<Icon name="delete" />
|
|
170
|
+
<span className="grid gap-px">
|
|
171
|
+
Delete
|
|
172
|
+
<span className="text-xs text-muted-foreground">Issued invoices can’t be deleted</span>
|
|
173
|
+
</span>
|
|
174
|
+
</DropdownMenuItem>
|
|
175
|
+
</DropdownMenuContent>
|
|
176
|
+
</DropdownMenu>
|
|
177
|
+
</div>
|
|
178
|
+
<div>
|
|
179
|
+
<Cap>Popover</Cap>
|
|
180
|
+
<Popover open modal={false}>
|
|
181
|
+
<PopoverTrigger asChild>
|
|
182
|
+
<Button variant="outline" icon="filter">
|
|
183
|
+
Filter
|
|
184
|
+
</Button>
|
|
185
|
+
</PopoverTrigger>
|
|
186
|
+
<PopoverContent align="start">
|
|
187
|
+
<div className="font-semibold">Filter invoices</div>
|
|
188
|
+
<div className="font-medium">Payment</div>
|
|
189
|
+
<RadioGroup defaultValue="overdue" aria-label="Payment" className="grid gap-2">
|
|
190
|
+
{[
|
|
191
|
+
["all", "All"],
|
|
192
|
+
["unpaid", "Unpaid"],
|
|
193
|
+
["overdue", "Overdue"],
|
|
194
|
+
].map(([value, label]) => (
|
|
195
|
+
<label key={value} className="flex items-center gap-2">
|
|
196
|
+
<RadioGroupItem value={value} /> {label}
|
|
197
|
+
</label>
|
|
198
|
+
))}
|
|
199
|
+
</RadioGroup>
|
|
200
|
+
<label className="flex items-center gap-2">
|
|
201
|
+
<Checkbox defaultChecked /> Only invoices sent by agents
|
|
202
|
+
</label>
|
|
203
|
+
<div className="flex justify-end gap-2">
|
|
204
|
+
<Button variant="ghost" size="sm">
|
|
205
|
+
Clear
|
|
206
|
+
</Button>
|
|
207
|
+
<Button size="sm">Apply</Button>
|
|
208
|
+
</div>
|
|
209
|
+
</PopoverContent>
|
|
210
|
+
</Popover>
|
|
211
|
+
</div>
|
|
212
|
+
</Stage>
|
|
213
|
+
</Root>
|
|
214
|
+
),
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export const ToggleGroupCard: Story = {
|
|
218
|
+
name: "ToggleGroup",
|
|
219
|
+
parameters: card("ToggleGroup", 230),
|
|
220
|
+
render: () => (
|
|
221
|
+
<div className="grid grid-cols-[repeat(auto-fit,minmax(280px,1fr))] items-start gap-x-8 gap-y-6 px-6 py-4">
|
|
222
|
+
<div className="grid content-start gap-3">
|
|
223
|
+
<Cap>One at a time: the view</Cap>
|
|
224
|
+
<ToggleGroup
|
|
225
|
+
label="View"
|
|
226
|
+
defaultValue="list"
|
|
227
|
+
required
|
|
228
|
+
options={[
|
|
229
|
+
{ value: "list", label: "List", icon: "form" },
|
|
230
|
+
{ value: "board", label: "Board", icon: "dashboard" },
|
|
231
|
+
{ value: "calendar", label: "Calendar", icon: "calendar" },
|
|
232
|
+
]}
|
|
233
|
+
/>
|
|
234
|
+
<Cap>Icons only, with tooltips</Cap>
|
|
235
|
+
<ToggleGroup
|
|
236
|
+
label="Show"
|
|
237
|
+
size="sm"
|
|
238
|
+
defaultValue="list"
|
|
239
|
+
required
|
|
240
|
+
options={[
|
|
241
|
+
{ value: "list", label: "List", icon: "form", iconOnly: true },
|
|
242
|
+
{ value: "board", label: "Board", icon: "dashboard", iconOnly: true },
|
|
243
|
+
{ value: "chart", label: "Chart", icon: "chart", iconOnly: true },
|
|
244
|
+
]}
|
|
245
|
+
/>
|
|
246
|
+
</div>
|
|
247
|
+
<div className="grid content-start gap-3">
|
|
248
|
+
<Cap>Any number: filters</Cap>
|
|
249
|
+
<ToggleGroup
|
|
250
|
+
label="Status"
|
|
251
|
+
type="multiple"
|
|
252
|
+
defaultValue={["unpaid", "overdue"]}
|
|
253
|
+
options={[
|
|
254
|
+
{ value: "paid", label: "Paid" },
|
|
255
|
+
{ value: "unpaid", label: "Unpaid" },
|
|
256
|
+
{ value: "overdue", label: "Overdue" },
|
|
257
|
+
{ value: "draft", label: "Draft", disabled: true },
|
|
258
|
+
]}
|
|
259
|
+
/>
|
|
260
|
+
<Cap>بالعربية</Cap>
|
|
261
|
+
<div dir="rtl" lang="ar" className="font-arabic">
|
|
262
|
+
<ToggleGroup
|
|
263
|
+
label="العرض"
|
|
264
|
+
defaultValue="list"
|
|
265
|
+
required
|
|
266
|
+
options={[
|
|
267
|
+
{ value: "list", label: "قائمة", icon: "form" },
|
|
268
|
+
{ value: "board", label: "لوحة", icon: "dashboard" },
|
|
269
|
+
{ value: "calendar", label: "تقويم", icon: "calendar" },
|
|
270
|
+
]}
|
|
271
|
+
/>
|
|
272
|
+
</div>
|
|
273
|
+
</div>
|
|
274
|
+
</div>
|
|
275
|
+
),
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export const DialogCard: Story = {
|
|
279
|
+
name: "Dialog",
|
|
280
|
+
parameters: card("Dialog", 384),
|
|
281
|
+
render: () => (
|
|
282
|
+
<Dialog open>
|
|
283
|
+
<DialogContent showCloseButton>
|
|
284
|
+
<DialogHeader>
|
|
285
|
+
<DialogTitle>Revoke this credential?</DialogTitle>
|
|
286
|
+
<DialogDescription>
|
|
287
|
+
Billing assistant will stop working at once. Anything it already did stays in the activity log.
|
|
288
|
+
</DialogDescription>
|
|
289
|
+
</DialogHeader>
|
|
290
|
+
<DialogFooter>
|
|
291
|
+
<Button variant="ghost">Cancel</Button>
|
|
292
|
+
<Button variant="destructive">Revoke credential</Button>
|
|
293
|
+
</DialogFooter>
|
|
294
|
+
</DialogContent>
|
|
295
|
+
</Dialog>
|
|
296
|
+
),
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export const AvatarCard: Story = {
|
|
300
|
+
name: "Avatar",
|
|
301
|
+
parameters: card("Avatar", 140),
|
|
302
|
+
render: () => (
|
|
303
|
+
<Root>
|
|
304
|
+
<Stage className="items-end gap-7">
|
|
305
|
+
<div className="grid justify-items-center gap-1.5">
|
|
306
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
307
|
+
<Avatar name="Rana Haddad" size={40} status="online" />
|
|
308
|
+
<Avatar name="Omar Saleh" size={32} />
|
|
309
|
+
<Avatar name="Lina" size={24} />
|
|
310
|
+
</div>
|
|
311
|
+
<Cap>People: initials</Cap>
|
|
312
|
+
</div>
|
|
313
|
+
<div className="grid justify-items-center gap-1.5">
|
|
314
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
315
|
+
<Avatar name="Billing assistant" kind="agent" size={40} />
|
|
316
|
+
<Avatar name="HR assistant" kind="agent" size={32} />
|
|
317
|
+
<Avatar name="Reports assistant" kind="agent" size={24} />
|
|
318
|
+
</div>
|
|
319
|
+
<Cap>Agents: the robot face, tinted</Cap>
|
|
320
|
+
</div>
|
|
321
|
+
<div className="grid justify-items-center gap-1.5">
|
|
322
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
323
|
+
<Avatar name="Whity" kind="system" size={40} />
|
|
324
|
+
<Avatar name="Whity" kind="system" size={32} />
|
|
325
|
+
</div>
|
|
326
|
+
<Cap>The system: the mark</Cap>
|
|
327
|
+
</div>
|
|
328
|
+
<div className="grid gap-1.5">
|
|
329
|
+
<ActorChip name="Whity" kind="system" />
|
|
330
|
+
<Cap>Actor chip, system</Cap>
|
|
331
|
+
</div>
|
|
332
|
+
</Stage>
|
|
333
|
+
</Root>
|
|
334
|
+
),
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export const ActorChipCard: Story = {
|
|
338
|
+
name: "ActorChip",
|
|
339
|
+
parameters: card("ActorChip", 64),
|
|
340
|
+
render: () => (
|
|
341
|
+
<Stage>
|
|
342
|
+
<ActorChip kind="person" name="Rana Haddad" />
|
|
343
|
+
<ActorChip kind="agent" name="Billing assistant" onBehalfOf="Rana" />
|
|
344
|
+
<ActorChip kind="agent" name="Front desk" />
|
|
345
|
+
</Stage>
|
|
346
|
+
),
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export const BadgeCard: Story = {
|
|
350
|
+
name: "Badge",
|
|
351
|
+
parameters: card("Badge", 64),
|
|
352
|
+
render: () => (
|
|
353
|
+
<Stage>
|
|
354
|
+
<Badge>[plan name]</Badge>
|
|
355
|
+
<Badge variant="secondary">Draft</Badge>
|
|
356
|
+
<Badge variant="outline">12 seats</Badge>
|
|
357
|
+
<Badge variant="success" icon="check">
|
|
358
|
+
Active
|
|
359
|
+
</Badge>
|
|
360
|
+
<Badge variant="info">Syncing</Badge>
|
|
361
|
+
<Badge variant="warning">Trial ends in 3 days</Badge>
|
|
362
|
+
<Badge variant="destructive">Failed</Badge>
|
|
363
|
+
</Stage>
|
|
364
|
+
),
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export const AgentRunStatusCard: Story = {
|
|
368
|
+
name: "AgentRunStatus",
|
|
369
|
+
parameters: card("AgentRunStatus", 520),
|
|
370
|
+
render: () => (
|
|
371
|
+
<div className="grid gap-5 px-6 py-4">
|
|
372
|
+
<div className="grid grid-cols-2 items-start gap-4">
|
|
373
|
+
<AgentRunStatus
|
|
374
|
+
status="running"
|
|
375
|
+
agent="Billing assistant"
|
|
376
|
+
onBehalfOf="Rana"
|
|
377
|
+
title="Reading 48 open invoices"
|
|
378
|
+
progress={{ done: 31, total: 48 }}
|
|
379
|
+
time="Started 1 min ago"
|
|
380
|
+
onStop={() => {}}
|
|
381
|
+
/>
|
|
382
|
+
<AgentRunStatus
|
|
383
|
+
status="waiting"
|
|
384
|
+
agent="Billing assistant"
|
|
385
|
+
onBehalfOf="Rana"
|
|
386
|
+
title="Send payment reminders to 12 customers"
|
|
387
|
+
detail="Waiting since 14:02 · uses invoice:remind"
|
|
388
|
+
time="Asked 3 min ago"
|
|
389
|
+
onReview={() => {}}
|
|
390
|
+
/>
|
|
391
|
+
<AgentRunStatus
|
|
392
|
+
status="done"
|
|
393
|
+
agent="Front desk"
|
|
394
|
+
onBehalfOf="Omar"
|
|
395
|
+
title="Booked 3 deliveries for tomorrow"
|
|
396
|
+
detail="Example Clinic, Example Hotel and Example School"
|
|
397
|
+
time="Finished 14:20 · took 40 s"
|
|
398
|
+
/>
|
|
399
|
+
<AgentRunStatus
|
|
400
|
+
status="failed"
|
|
401
|
+
agent="HR assistant"
|
|
402
|
+
onBehalfOf="Lina"
|
|
403
|
+
title="Couldn’t prepare October payslips"
|
|
404
|
+
next="Two employees have no bank account. Add them in People, then try again."
|
|
405
|
+
time="Stopped 13:55"
|
|
406
|
+
onRetry={() => {}}
|
|
407
|
+
/>
|
|
408
|
+
</div>
|
|
409
|
+
<div className="grid content-start gap-3">
|
|
410
|
+
<Cap>Compact, in the top bar</Cap>
|
|
411
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
412
|
+
<AgentRunStatus compact status="running" agent="Billing assistant" title="Reading 48 invoices" />
|
|
413
|
+
<AgentRunStatus compact status="done" agent="Front desk" title="Booked 3 deliveries" />
|
|
414
|
+
<AgentRunStatus compact status="failed" agent="HR assistant" title="Payslips stopped" />
|
|
415
|
+
</div>
|
|
416
|
+
</div>
|
|
417
|
+
</div>
|
|
418
|
+
),
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
export const IconCard: Story = {
|
|
422
|
+
name: "Icon",
|
|
423
|
+
parameters: card("Icon", 940),
|
|
424
|
+
render: () => (
|
|
425
|
+
<div className="grid grid-cols-[repeat(auto-fill,minmax(96px,1fr))] gap-1 px-5 py-3">
|
|
426
|
+
{iconNames.map((name) => (
|
|
427
|
+
<div key={name} className="grid justify-items-center gap-1.5 rounded-[8px] px-1 py-2.5">
|
|
428
|
+
<Icon name={name} size={20} />
|
|
429
|
+
<span className="font-mono text-xs text-muted-foreground">{name}</span>
|
|
430
|
+
</div>
|
|
431
|
+
))}
|
|
432
|
+
</div>
|
|
433
|
+
),
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/* ------------------------------------------------- Document editor (M2) */
|
|
437
|
+
|
|
438
|
+
function EditorCard() {
|
|
439
|
+
const [doc, setDoc] = React.useState(SAMPLE_DOCUMENT)
|
|
440
|
+
return (
|
|
441
|
+
<div style={{ height: 820 }}>
|
|
442
|
+
<DocEditor
|
|
443
|
+
document={doc}
|
|
444
|
+
onChange={setDoc}
|
|
445
|
+
canEdit
|
|
446
|
+
back={{ label: "Back to notes", onClick: () => {} }}
|
|
447
|
+
path="Notes · Billing"
|
|
448
|
+
save={{ state: "saved", at: "14:02" }}
|
|
449
|
+
/>
|
|
450
|
+
</div>
|
|
451
|
+
)
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export const EditorShellCard: Story = {
|
|
455
|
+
name: "EditorShell",
|
|
456
|
+
parameters: { designCard: { name: "EditorShell", width: 1280, height: 820 } },
|
|
457
|
+
render: () => <EditorCard />,
|
|
458
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite"
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Dialog,
|
|
5
|
+
DialogTrigger,
|
|
6
|
+
DialogContent,
|
|
7
|
+
DialogHeader,
|
|
8
|
+
DialogFooter,
|
|
9
|
+
DialogTitle,
|
|
10
|
+
DialogDescription,
|
|
11
|
+
DialogClose,
|
|
12
|
+
} from "./dialog"
|
|
13
|
+
import { Button } from "./button"
|
|
14
|
+
import { Input } from "./input"
|
|
15
|
+
|
|
16
|
+
const meta = {
|
|
17
|
+
title: "Overlays/Dialog",
|
|
18
|
+
component: Dialog,
|
|
19
|
+
tags: ["autodocs"],
|
|
20
|
+
} satisfies Meta<typeof Dialog>
|
|
21
|
+
|
|
22
|
+
export default meta
|
|
23
|
+
type Story = StoryObj<typeof meta>
|
|
24
|
+
|
|
25
|
+
export const Default: Story = {
|
|
26
|
+
render: () => (
|
|
27
|
+
<Dialog>
|
|
28
|
+
<DialogTrigger asChild>
|
|
29
|
+
<Button>Rename tenant</Button>
|
|
30
|
+
</DialogTrigger>
|
|
31
|
+
<DialogContent className="sm:max-w-md">
|
|
32
|
+
<DialogHeader>
|
|
33
|
+
<DialogTitle>Rename tenant</DialogTitle>
|
|
34
|
+
<DialogDescription>
|
|
35
|
+
This changes the display name only. The tenant ID stays the same.
|
|
36
|
+
</DialogDescription>
|
|
37
|
+
</DialogHeader>
|
|
38
|
+
<Input defaultValue="Acme Tenant" />
|
|
39
|
+
<DialogFooter>
|
|
40
|
+
<DialogClose asChild>
|
|
41
|
+
<Button variant="outline">Cancel</Button>
|
|
42
|
+
</DialogClose>
|
|
43
|
+
<Button>Save</Button>
|
|
44
|
+
</DialogFooter>
|
|
45
|
+
</DialogContent>
|
|
46
|
+
</Dialog>
|
|
47
|
+
),
|
|
48
|
+
}
|
package/src/dialog.tsx
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Dialog as DialogPrimitive } from "radix-ui"
|
|
5
|
+
|
|
6
|
+
import { cn, useIsDarkMode } from "./utils"
|
|
7
|
+
import { Button } from "./button"
|
|
8
|
+
import { IconX } from "@tabler/icons-react"
|
|
9
|
+
|
|
10
|
+
function Dialog({
|
|
11
|
+
...props
|
|
12
|
+
}: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
|
13
|
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function DialogTrigger({
|
|
17
|
+
...props
|
|
18
|
+
}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
|
19
|
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function DialogPortal({
|
|
23
|
+
...props
|
|
24
|
+
}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
|
25
|
+
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function DialogClose({
|
|
29
|
+
...props
|
|
30
|
+
}: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
|
31
|
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function DialogOverlay({
|
|
35
|
+
className,
|
|
36
|
+
...props
|
|
37
|
+
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
|
38
|
+
return (
|
|
39
|
+
<DialogPrimitive.Overlay
|
|
40
|
+
data-slot="dialog-overlay"
|
|
41
|
+
className={cn(
|
|
42
|
+
"fixed inset-0 isolate z-50 bg-overlay data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
|
|
43
|
+
className
|
|
44
|
+
)}
|
|
45
|
+
{...props}
|
|
46
|
+
/>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function DialogContent({
|
|
51
|
+
className,
|
|
52
|
+
children,
|
|
53
|
+
showCloseButton = true,
|
|
54
|
+
closeLabel = "Close",
|
|
55
|
+
...props
|
|
56
|
+
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
57
|
+
showCloseButton?: boolean
|
|
58
|
+
/** Accessible name for the corner close button (visually hidden). */
|
|
59
|
+
closeLabel?: string
|
|
60
|
+
}) {
|
|
61
|
+
const isDark = useIsDarkMode()
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<DialogPortal>
|
|
65
|
+
<DialogOverlay />
|
|
66
|
+
<DialogPrimitive.Content
|
|
67
|
+
data-slot="dialog-content"
|
|
68
|
+
className={cn(
|
|
69
|
+
isDark && "dark",
|
|
70
|
+
"fixed top-1/2 start-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 rtl:translate-x-1/2 -translate-y-1/2 gap-3 rounded-dialog bg-popover p-6 text-sm text-popover-foreground shadow-float outline-none sm:max-w-[488px] data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
71
|
+
className
|
|
72
|
+
)}
|
|
73
|
+
{...props}
|
|
74
|
+
>
|
|
75
|
+
{children}
|
|
76
|
+
{showCloseButton && (
|
|
77
|
+
<DialogPrimitive.Close data-slot="dialog-close" asChild>
|
|
78
|
+
<Button
|
|
79
|
+
variant="ghost"
|
|
80
|
+
className="absolute top-[22px] end-5"
|
|
81
|
+
size="icon-sm"
|
|
82
|
+
>
|
|
83
|
+
<IconX />
|
|
84
|
+
<span className="sr-only">{closeLabel}</span>
|
|
85
|
+
</Button>
|
|
86
|
+
</DialogPrimitive.Close>
|
|
87
|
+
)}
|
|
88
|
+
</DialogPrimitive.Content>
|
|
89
|
+
</DialogPortal>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
94
|
+
return (
|
|
95
|
+
<div
|
|
96
|
+
data-slot="dialog-header"
|
|
97
|
+
className={cn("flex flex-col gap-3", className)}
|
|
98
|
+
{...props}
|
|
99
|
+
/>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function DialogFooter({
|
|
104
|
+
className,
|
|
105
|
+
showCloseButton = false,
|
|
106
|
+
closeLabel = "Close",
|
|
107
|
+
...props
|
|
108
|
+
}: React.ComponentProps<"div"> & {
|
|
109
|
+
showCloseButton?: boolean
|
|
110
|
+
/** Text of the footer's close button. */
|
|
111
|
+
closeLabel?: string
|
|
112
|
+
}) {
|
|
113
|
+
return (
|
|
114
|
+
<div
|
|
115
|
+
data-slot="dialog-footer"
|
|
116
|
+
className={cn("flex flex-col-reverse gap-2 pt-2 sm:flex-row sm:justify-end", className)}
|
|
117
|
+
{...props}
|
|
118
|
+
>
|
|
119
|
+
{showCloseButton && (
|
|
120
|
+
<DialogPrimitive.Close asChild>
|
|
121
|
+
<Button variant="outline">{closeLabel}</Button>
|
|
122
|
+
</DialogPrimitive.Close>
|
|
123
|
+
)}
|
|
124
|
+
{props.children}
|
|
125
|
+
</div>
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function DialogTitle({
|
|
130
|
+
className,
|
|
131
|
+
...props
|
|
132
|
+
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
|
133
|
+
return (
|
|
134
|
+
<DialogPrimitive.Title
|
|
135
|
+
data-slot="dialog-title"
|
|
136
|
+
className={cn("pe-8 text-lg leading-snug font-semibold", className)}
|
|
137
|
+
{...props}
|
|
138
|
+
/>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function DialogDescription({
|
|
143
|
+
className,
|
|
144
|
+
...props
|
|
145
|
+
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
|
146
|
+
return (
|
|
147
|
+
<DialogPrimitive.Description
|
|
148
|
+
data-slot="dialog-description"
|
|
149
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
150
|
+
{...props}
|
|
151
|
+
/>
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export {
|
|
156
|
+
Dialog,
|
|
157
|
+
DialogClose,
|
|
158
|
+
DialogContent,
|
|
159
|
+
DialogDescription,
|
|
160
|
+
DialogFooter,
|
|
161
|
+
DialogHeader,
|
|
162
|
+
DialogOverlay,
|
|
163
|
+
DialogPortal,
|
|
164
|
+
DialogTitle,
|
|
165
|
+
DialogTrigger,
|
|
166
|
+
}
|