@whity/ui 0.0.0-stage → 1.0.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 +106 -2
- package/package.json +219 -4
- package/src/access-denied.stories.tsx +179 -0
- package/src/access-denied.tsx +305 -0
- package/src/action-proposal.tsx +338 -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 +604 -0
- package/src/approval-queue.tsx +109 -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-pattern.ts +138 -0
- package/src/avatar.tsx +125 -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 +188 -0
- package/src/board.tsx +216 -0
- package/src/breadcrumb.stories.tsx +51 -0
- package/src/breadcrumb.tsx +90 -0
- package/src/built-on-whity.tsx +52 -0
- package/src/button.stories.tsx +87 -0
- package/src/button.tsx +123 -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/column-matcher.tsx +84 -0
- package/src/command-palette.tsx +398 -0
- package/src/confirm-action.tsx +98 -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 +1686 -0
- package/src/date-picker.stories.tsx +61 -0
- package/src/date-picker.tsx +456 -0
- package/src/design-cards.stories.tsx +551 -0
- package/src/dialog.stories.tsx +48 -0
- package/src/dialog.tsx +179 -0
- package/src/display-preferences.tsx +50 -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/agent-panel.tsx +222 -0
- package/src/editor/agents.stories.tsx +81 -0
- package/src/editor/agents.ts +55 -0
- package/src/editor/behaviour.ts +279 -0
- package/src/editor/block-ids.ts +44 -0
- package/src/editor/block-list.tsx +104 -0
- package/src/editor/block-toolbar.tsx +490 -0
- package/src/editor/bubble.tsx +119 -0
- package/src/editor/catalogue.ts +169 -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 +476 -0
- package/src/editor/convert.ts +414 -0
- package/src/editor/doc-editor.stories.tsx +98 -0
- package/src/editor/doc-editor.tsx +1492 -0
- package/src/editor/editor.css +636 -0
- package/src/editor/extensions.ts +86 -0
- package/src/editor/field-bar.tsx +154 -0
- package/src/editor/field-picker.tsx +109 -0
- package/src/editor/fields.ts +100 -0
- package/src/editor/gutter.tsx +443 -0
- package/src/editor/index.ts +23 -0
- package/src/editor/label-sheet.tsx +289 -0
- package/src/editor/labels.ts +394 -0
- package/src/editor/link-tools.tsx +141 -0
- package/src/editor/node-views.tsx +461 -0
- package/src/editor/page-view.tsx +372 -0
- package/src/editor/phone.tsx +310 -0
- package/src/editor/plugin-block-view.tsx +230 -0
- package/src/editor/plugin-blocks.stories.tsx +96 -0
- package/src/editor/plugin-blocks.ts +52 -0
- package/src/editor/publish-check.tsx +201 -0
- package/src/editor/rich-blocks.stories.tsx +146 -0
- package/src/editor/sample.ts +40 -0
- package/src/editor/save-block-dialog.tsx +141 -0
- package/src/editor/saved-block-view.tsx +205 -0
- package/src/editor/saved-blocks.stories.tsx +105 -0
- package/src/editor/saved-parts.ts +192 -0
- package/src/editor/schema-rich.ts +156 -0
- package/src/editor/schema.ts +368 -0
- package/src/editor/services.tsx +205 -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 +364 -0
- package/src/empty-state.stories.tsx +51 -0
- package/src/empty-state.tsx +126 -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 +335 -0
- package/src/icon.tsx +41 -0
- package/src/index.ts +90 -0
- package/src/input.stories.tsx +157 -0
- package/src/input.tsx +768 -0
- package/src/kpi-strip.tsx +47 -0
- package/src/localized-text.ts +76 -0
- package/src/locked-screen.stories.tsx +29 -0
- package/src/locked-screen.tsx +75 -0
- package/src/lockup.tsx +42 -0
- package/src/lottie.tsx +441 -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/message-thread.tsx +181 -0
- package/src/money/currency.ts +244 -0
- package/src/money/money-input.tsx +131 -0
- package/src/money/money.tsx +33 -0
- package/src/open-on-computer.tsx +150 -0
- package/src/otp-input.tsx +161 -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/page-states.tsx +277 -0
- package/src/pagination.stories.tsx +45 -0
- package/src/pagination.tsx +98 -0
- package/src/paper-sheet.stories.tsx +88 -0
- package/src/paper-sheet.tsx +85 -0
- package/src/phone-tab-bar.tsx +152 -0
- package/src/plugin-card.stories.tsx +208 -0
- package/src/plugin-card.tsx +931 -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 +1087 -0
- package/src/route-flow/model.ts +771 -0
- package/src/save-bar.tsx +94 -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/search-field.tsx +65 -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/stepper.tsx +85 -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/system-state.tsx +55 -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-grid.tsx +163 -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,364 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import type { Editor } from "@tiptap/core"
|
|
5
|
+
import { useEditorState } from "@tiptap/react"
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
DropdownMenu,
|
|
9
|
+
DropdownMenuContent,
|
|
10
|
+
DropdownMenuItem,
|
|
11
|
+
DropdownMenuShortcut,
|
|
12
|
+
DropdownMenuTrigger,
|
|
13
|
+
} from "../dropdown-menu"
|
|
14
|
+
import { Icon } from "../icon"
|
|
15
|
+
import { IconButton } from "../icon-button"
|
|
16
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../popover"
|
|
17
|
+
import { ToggleGroup } from "../toggle-group"
|
|
18
|
+
import { cn } from "../utils"
|
|
19
|
+
import { CATALOGUE, applyItem, currentItem } from "./catalogue"
|
|
20
|
+
import { turnInto } from "./behaviour"
|
|
21
|
+
import { FieldPicker, flatFields } from "./field-picker"
|
|
22
|
+
import { filterFields, type FieldDef, type FieldGroup } from "./fields"
|
|
23
|
+
import { fill, type EditorLabels } from "./labels"
|
|
24
|
+
|
|
25
|
+
/** E.7: the page view's zoom steps; "fit" fits the page to the canvas width. */
|
|
26
|
+
export type PageZoom = "fit" | 50 | 75 | 100 | 125
|
|
27
|
+
export const ZOOM_STEPS: PageZoom[] = ["fit", 50, 75, 100, 125]
|
|
28
|
+
export type EditorView = "continuous" | "page"
|
|
29
|
+
|
|
30
|
+
/** Inserts a merge field at the caret as one character, followed by a space. */
|
|
31
|
+
export function insertField(editor: Editor, field: FieldDef) {
|
|
32
|
+
editor
|
|
33
|
+
.chain()
|
|
34
|
+
.focus()
|
|
35
|
+
.insertContent([
|
|
36
|
+
{ type: "field", attrs: { path: field.path, label: field.label, required: field.required ? true : null } },
|
|
37
|
+
{ type: "text", text: " " },
|
|
38
|
+
])
|
|
39
|
+
.run()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const STYLE_IDS = ["text", "h1", "h2", "h3"]
|
|
43
|
+
const STYLE_SHORTCUTS: Record<string, string> = { text: "⌘⌥0", h1: "⌘⌥1", h2: "⌘⌥2", h3: "⌘⌥3" }
|
|
44
|
+
|
|
45
|
+
function Sep() {
|
|
46
|
+
return <span aria-hidden="true" className="mx-1.5 h-5 w-px shrink-0 bg-border" />
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** A text dropdown in the bar: "Normal text ▾", "Insert ▾" (`.wy-edx__drop`). */
|
|
50
|
+
const BarDrop = React.forwardRef<HTMLButtonElement, React.ComponentProps<"button">>(function BarDrop(
|
|
51
|
+
{ className, children, ...props },
|
|
52
|
+
ref
|
|
53
|
+
) {
|
|
54
|
+
return (
|
|
55
|
+
<button
|
|
56
|
+
ref={ref}
|
|
57
|
+
type="button"
|
|
58
|
+
className={cn(
|
|
59
|
+
"inline-flex h-7 shrink-0 cursor-pointer items-center gap-1 rounded-control-sm border-0 bg-transparent ps-2 pe-1.5 text-[0.8125rem] whitespace-nowrap text-foreground hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-40",
|
|
60
|
+
className
|
|
61
|
+
)}
|
|
62
|
+
{...props}
|
|
63
|
+
>
|
|
64
|
+
{children}
|
|
65
|
+
<Icon name="chevron-down" size={14} className="text-muted-foreground" />
|
|
66
|
+
</button>
|
|
67
|
+
)
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
/** Field ▾ (EditorInline): the field picker with its own search box. */
|
|
71
|
+
function FieldMenu({
|
|
72
|
+
editor,
|
|
73
|
+
groups,
|
|
74
|
+
labels,
|
|
75
|
+
disabled,
|
|
76
|
+
onCreate,
|
|
77
|
+
}: {
|
|
78
|
+
editor: Editor
|
|
79
|
+
groups: FieldGroup[]
|
|
80
|
+
labels: EditorLabels
|
|
81
|
+
disabled: boolean
|
|
82
|
+
/** A template's own field named `label`, added to the document (editor M4b). */
|
|
83
|
+
onCreate?: (label: string) => FieldDef
|
|
84
|
+
}) {
|
|
85
|
+
const [open, setOpen] = React.useState(false)
|
|
86
|
+
const [query, setQuery] = React.useState("")
|
|
87
|
+
const [active, setActive] = React.useState(0)
|
|
88
|
+
const shown = React.useMemo(() => filterFields(groups, query), [groups, query])
|
|
89
|
+
const flat = flatFields(shown)
|
|
90
|
+
React.useEffect(() => setActive(0), [query, open])
|
|
91
|
+
const pick = (field: FieldDef) => {
|
|
92
|
+
setOpen(false)
|
|
93
|
+
setQuery("")
|
|
94
|
+
insertField(editor, field)
|
|
95
|
+
}
|
|
96
|
+
const name = query.trim()
|
|
97
|
+
const exists = flatFields(groups).some((f) => f.label.toLowerCase() === name.toLowerCase())
|
|
98
|
+
const create = onCreate && name && !exists ? () => pick(onCreate(name)) : undefined
|
|
99
|
+
return (
|
|
100
|
+
<Popover open={open} onOpenChange={setOpen}>
|
|
101
|
+
<PopoverTrigger asChild>
|
|
102
|
+
<BarDrop disabled={disabled}>
|
|
103
|
+
<Icon name="field" size={14} />
|
|
104
|
+
{labels.field}
|
|
105
|
+
</BarDrop>
|
|
106
|
+
</PopoverTrigger>
|
|
107
|
+
<PopoverContent align="start" className="w-auto border-0 bg-transparent p-0 shadow-none" onCloseAutoFocus={(e) => e.preventDefault()}>
|
|
108
|
+
<FieldPicker
|
|
109
|
+
id="wy-fieldmenu"
|
|
110
|
+
groups={shown}
|
|
111
|
+
active={Math.min(active, Math.max(0, flat.length - 1))}
|
|
112
|
+
onActive={setActive}
|
|
113
|
+
onPick={pick}
|
|
114
|
+
labels={labels}
|
|
115
|
+
search={
|
|
116
|
+
<label className="flex items-center gap-1.5 border-b border-border px-2 pb-1.5 pt-1 text-muted-foreground">
|
|
117
|
+
<Icon name="search" size={14} />
|
|
118
|
+
<input
|
|
119
|
+
autoFocus
|
|
120
|
+
value={query}
|
|
121
|
+
onChange={(e) => setQuery(e.target.value)}
|
|
122
|
+
onKeyDown={(e) => {
|
|
123
|
+
const n = flat.length || 1
|
|
124
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
125
|
+
e.preventDefault()
|
|
126
|
+
setActive((i) => (i + (e.key === "ArrowDown" ? 1 : n - 1)) % n)
|
|
127
|
+
} else if (e.key === "Enter" && flat[active]) {
|
|
128
|
+
e.preventDefault()
|
|
129
|
+
pick(flat[active])
|
|
130
|
+
} else if (e.key === "Enter" && create) {
|
|
131
|
+
e.preventDefault()
|
|
132
|
+
create()
|
|
133
|
+
}
|
|
134
|
+
}}
|
|
135
|
+
placeholder={labels.fieldSearch}
|
|
136
|
+
aria-label={labels.fieldSearch}
|
|
137
|
+
aria-controls="wy-fieldmenu"
|
|
138
|
+
aria-activedescendant={flat.length ? `wy-fieldmenu-${active}` : undefined}
|
|
139
|
+
className="h-7 min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground"
|
|
140
|
+
/>
|
|
141
|
+
</label>
|
|
142
|
+
}
|
|
143
|
+
footer={
|
|
144
|
+
onCreate && (
|
|
145
|
+
<div className="border-t border-border pt-1">
|
|
146
|
+
{create ? (
|
|
147
|
+
<button
|
|
148
|
+
type="button"
|
|
149
|
+
onClick={create}
|
|
150
|
+
className="flex w-full items-center gap-1.5 rounded-control px-2 py-1.5 text-start text-sm hover:bg-accent"
|
|
151
|
+
>
|
|
152
|
+
<Icon name="plus" size={14} />
|
|
153
|
+
<span className="min-w-0 truncate" dir="auto">
|
|
154
|
+
{fill(labels.fieldNew, { name })}
|
|
155
|
+
</span>
|
|
156
|
+
</button>
|
|
157
|
+
) : (
|
|
158
|
+
<p className="m-0 px-2 py-1.5 text-xs text-muted-foreground">{labels.fieldNewHint}</p>
|
|
159
|
+
)}
|
|
160
|
+
</div>
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
/>
|
|
164
|
+
</PopoverContent>
|
|
165
|
+
</Popover>
|
|
166
|
+
)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The fixed formatting toolbar, in Google Docs order (E.5, EditorShell):
|
|
171
|
+
* undo and redo · style · bold, italic, underline, strikethrough · link,
|
|
172
|
+
* highlight · lists · Insert ▾ · Field ▾ · zoom, view, outline. Every icon
|
|
173
|
+
* button has a tooltip with its shortcut; pressed states use the tint. Under
|
|
174
|
+
* 768px it scrolls sideways.
|
|
175
|
+
*/
|
|
176
|
+
function EditorToolbar({
|
|
177
|
+
editor,
|
|
178
|
+
labels,
|
|
179
|
+
editable,
|
|
180
|
+
outline,
|
|
181
|
+
onOutline,
|
|
182
|
+
onLink,
|
|
183
|
+
fields,
|
|
184
|
+
view,
|
|
185
|
+
onView,
|
|
186
|
+
zoom,
|
|
187
|
+
onZoom,
|
|
188
|
+
sheet,
|
|
189
|
+
onCreateField,
|
|
190
|
+
onComment,
|
|
191
|
+
onAskAgent,
|
|
192
|
+
}: {
|
|
193
|
+
editor: Editor
|
|
194
|
+
labels: EditorLabels
|
|
195
|
+
editable: boolean
|
|
196
|
+
outline: boolean
|
|
197
|
+
onOutline: () => void
|
|
198
|
+
onLink: () => void
|
|
199
|
+
/** The template's fields; Field ▾ shows only when there are some. */
|
|
200
|
+
fields?: FieldGroup[]
|
|
201
|
+
view?: EditorView
|
|
202
|
+
/** Omitted when the document can't switch (label sheets are page view only, E.43). */
|
|
203
|
+
onView?: (view: EditorView) => void
|
|
204
|
+
zoom?: PageZoom
|
|
205
|
+
onZoom?: (zoom: PageZoom) => void
|
|
206
|
+
/** Label sheets: the sheet setup, beside the zoom (E.43). */
|
|
207
|
+
sheet?: React.ReactNode
|
|
208
|
+
/** A template's own field, made from Field ▾. */
|
|
209
|
+
onCreateField?: (label: string) => FieldDef
|
|
210
|
+
/** M5: comment on the selection (⌥⌘M); offered with comment permission, editable or not. */
|
|
211
|
+
onComment?: () => void
|
|
212
|
+
/** M6: open the Ask an agent sheet (EditorAgents). */
|
|
213
|
+
onAskAgent?: () => void
|
|
214
|
+
}) {
|
|
215
|
+
const s = useEditorState({
|
|
216
|
+
editor,
|
|
217
|
+
selector: ({ editor: e }) => ({
|
|
218
|
+
bold: e.isActive("bold"),
|
|
219
|
+
italic: e.isActive("italic"),
|
|
220
|
+
underline: e.isActive("underline"),
|
|
221
|
+
strike: e.isActive("strike"),
|
|
222
|
+
link: e.isActive("link"),
|
|
223
|
+
highlight: e.isActive("highlight"),
|
|
224
|
+
canUndo: e.can().undo(),
|
|
225
|
+
canRedo: e.can().redo(),
|
|
226
|
+
item: currentItem(e)?.id ?? "text",
|
|
227
|
+
empty: e.state.selection.empty,
|
|
228
|
+
}),
|
|
229
|
+
})
|
|
230
|
+
const mark = (name: string) => () => editor.chain().focus().toggleMark(name).run()
|
|
231
|
+
const list = (id: string) => () => {
|
|
232
|
+
const item = CATALOGUE.find((i) => i.id === id)!
|
|
233
|
+
if (s.item === id) turnInto(editor, "paragraph")
|
|
234
|
+
else turnInto(editor, item.node.type, item.node.attrs)
|
|
235
|
+
}
|
|
236
|
+
const styleItem = CATALOGUE.find((i) => i.id === (STYLE_IDS.includes(s.item) ? s.item : "text"))!
|
|
237
|
+
const tb = (icon: React.ComponentProps<typeof IconButton>["icon"], label: string, pressed: boolean, onClick: () => void, shortcut?: string) => (
|
|
238
|
+
<IconButton
|
|
239
|
+
icon={icon}
|
|
240
|
+
label={label}
|
|
241
|
+
size="sm"
|
|
242
|
+
tooltip="bottom"
|
|
243
|
+
shortcut={shortcut}
|
|
244
|
+
pressed={pressed}
|
|
245
|
+
disabled={!editable}
|
|
246
|
+
onMouseDown={(e) => e.preventDefault()}
|
|
247
|
+
onClick={onClick}
|
|
248
|
+
/>
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
return (
|
|
252
|
+
<div
|
|
253
|
+
role="toolbar"
|
|
254
|
+
aria-label={labels.formatting}
|
|
255
|
+
data-slot="editor-toolbar"
|
|
256
|
+
className="flex h-11 items-center gap-0.5 overflow-x-auto border-b border-border bg-card px-3 [scrollbar-width:none]"
|
|
257
|
+
>
|
|
258
|
+
<IconButton icon="undo" label={labels.undo} size="sm" tooltip="bottom" shortcut="⌘Z" disabled={!editable || !s.canUndo} onMouseDown={(e) => e.preventDefault()} onClick={() => editor.chain().focus().undo().run()} />
|
|
259
|
+
<IconButton icon="redo" label={labels.redo} size="sm" tooltip="bottom" shortcut="⇧⌘Z" disabled={!editable || !s.canRedo} onMouseDown={(e) => e.preventDefault()} onClick={() => editor.chain().focus().redo().run()} />
|
|
260
|
+
<Sep />
|
|
261
|
+
<DropdownMenu modal={false}>
|
|
262
|
+
<DropdownMenuTrigger asChild>
|
|
263
|
+
<BarDrop aria-label={labels.styleMenu} disabled={!editable} className="min-w-28 justify-between">
|
|
264
|
+
{styleItem.id === "text" ? labels.normalText : labels[styleItem.label]}
|
|
265
|
+
</BarDrop>
|
|
266
|
+
</DropdownMenuTrigger>
|
|
267
|
+
<DropdownMenuContent align="start" onCloseAutoFocus={(e) => { e.preventDefault(); editor.commands.focus() }}>
|
|
268
|
+
{STYLE_IDS.map((id) => {
|
|
269
|
+
const item = CATALOGUE.find((i) => i.id === id)!
|
|
270
|
+
return (
|
|
271
|
+
<DropdownMenuItem key={id} onSelect={() => turnInto(editor, item.node.type, item.node.attrs)} className={cn(s.item === id && "bg-primary-tint text-primary-tint-foreground")}>
|
|
272
|
+
<Icon name={item.icon} /> {id === "text" ? labels.normalText : labels[item.label]}
|
|
273
|
+
<DropdownMenuShortcut>{STYLE_SHORTCUTS[id]}</DropdownMenuShortcut>
|
|
274
|
+
</DropdownMenuItem>
|
|
275
|
+
)
|
|
276
|
+
})}
|
|
277
|
+
</DropdownMenuContent>
|
|
278
|
+
</DropdownMenu>
|
|
279
|
+
<Sep />
|
|
280
|
+
{tb("bold", labels.bold, s.bold, mark("bold"), "⌘B")}
|
|
281
|
+
{tb("italic", labels.italic, s.italic, mark("italic"), "⌘I")}
|
|
282
|
+
{tb("underline", labels.underline, s.underline, mark("underline"), "⌘U")}
|
|
283
|
+
{tb("strike", labels.strike, s.strike, mark("strike"), "⇧⌘X")}
|
|
284
|
+
<Sep />
|
|
285
|
+
{tb("link", labels.link, s.link, onLink, "⌘K")}
|
|
286
|
+
{tb("highlight", labels.highlight, s.highlight, mark("highlight"))}
|
|
287
|
+
<Sep />
|
|
288
|
+
{tb("list-bullet", labels.blockBullet, s.item === "bullet", list("bullet"), "⇧⌘8")}
|
|
289
|
+
{tb("list-numbered", labels.blockNumber, s.item === "number", list("number"), "⇧⌘7")}
|
|
290
|
+
{tb("list-todo", labels.blockChecklist, s.item === "checklist", list("checklist"), "⇧⌘9")}
|
|
291
|
+
<Sep />
|
|
292
|
+
<DropdownMenu modal={false}>
|
|
293
|
+
<DropdownMenuTrigger asChild>
|
|
294
|
+
<BarDrop disabled={!editable}>
|
|
295
|
+
<Icon name="plus" size={14} />
|
|
296
|
+
{labels.insert}
|
|
297
|
+
</BarDrop>
|
|
298
|
+
</DropdownMenuTrigger>
|
|
299
|
+
<DropdownMenuContent align="start" onCloseAutoFocus={(e) => { e.preventDefault(); editor.commands.focus() }}>
|
|
300
|
+
{CATALOGUE.map((item) => (
|
|
301
|
+
<DropdownMenuItem key={item.id} onSelect={() => applyItem(editor, item)}>
|
|
302
|
+
<Icon name={item.icon} /> {labels[item.label]}
|
|
303
|
+
{item.markdown && <DropdownMenuShortcut>{item.markdown}</DropdownMenuShortcut>}
|
|
304
|
+
</DropdownMenuItem>
|
|
305
|
+
))}
|
|
306
|
+
</DropdownMenuContent>
|
|
307
|
+
</DropdownMenu>
|
|
308
|
+
{fields && (fields.length > 0 || onCreateField) && (
|
|
309
|
+
<FieldMenu editor={editor} groups={fields} labels={labels} disabled={!editable} onCreate={onCreateField} />
|
|
310
|
+
)}
|
|
311
|
+
{onComment && (
|
|
312
|
+
<IconButton
|
|
313
|
+
icon="comment-add"
|
|
314
|
+
label={labels.comment}
|
|
315
|
+
size="sm"
|
|
316
|
+
tooltip="bottom"
|
|
317
|
+
shortcut="⌥⌘M"
|
|
318
|
+
disabled={s.empty}
|
|
319
|
+
onMouseDown={(e) => e.preventDefault()}
|
|
320
|
+
onClick={onComment}
|
|
321
|
+
/>
|
|
322
|
+
)}
|
|
323
|
+
{onAskAgent && (
|
|
324
|
+
<IconButton icon="robot" label={labels.agentAsk} size="sm" tooltip="bottom" onClick={onAskAgent} />
|
|
325
|
+
)}
|
|
326
|
+
<span className="min-w-2 flex-1" />
|
|
327
|
+
{sheet}
|
|
328
|
+
{view === "page" && onZoom && (
|
|
329
|
+
<DropdownMenu modal={false}>
|
|
330
|
+
<DropdownMenuTrigger asChild>
|
|
331
|
+
<BarDrop aria-label={labels.zoom}>{zoomLabel(zoom ?? "fit", labels)}</BarDrop>
|
|
332
|
+
</DropdownMenuTrigger>
|
|
333
|
+
<DropdownMenuContent align="end">
|
|
334
|
+
{ZOOM_STEPS.map((step) => (
|
|
335
|
+
<DropdownMenuItem key={String(step)} onSelect={() => onZoom(step)} className={cn(step === (zoom ?? "fit") && "bg-primary-tint text-primary-tint-foreground")}>
|
|
336
|
+
{zoomLabel(step, labels)}
|
|
337
|
+
</DropdownMenuItem>
|
|
338
|
+
))}
|
|
339
|
+
</DropdownMenuContent>
|
|
340
|
+
</DropdownMenu>
|
|
341
|
+
)}
|
|
342
|
+
{view && onView && (
|
|
343
|
+
<ToggleGroup
|
|
344
|
+
size="sm"
|
|
345
|
+
label={labels.view}
|
|
346
|
+
required
|
|
347
|
+
value={view}
|
|
348
|
+
onChange={(v) => v && onView(v as EditorView)}
|
|
349
|
+
options={[
|
|
350
|
+
{ value: "continuous", label: labels.viewContinuous, icon: "continuous", iconOnly: true },
|
|
351
|
+
{ value: "page", label: labels.viewPage, icon: "page", iconOnly: true },
|
|
352
|
+
]}
|
|
353
|
+
/>
|
|
354
|
+
)}
|
|
355
|
+
<IconButton icon="outline" label={labels.outline} size="sm" tooltip="bottom" pressed={outline} onClick={onOutline} />
|
|
356
|
+
</div>
|
|
357
|
+
)
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function zoomLabel(zoom: PageZoom, labels: EditorLabels): string {
|
|
361
|
+
return zoom === "fit" ? labels.zoomFit : fill(labels.zoomPercent, { n: zoom })
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export { EditorToolbar }
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite"
|
|
2
|
+
import { IconPlus, IconRefresh } from "@tabler/icons-react"
|
|
3
|
+
|
|
4
|
+
import { EmptyState, ErrorState } from "./empty-state"
|
|
5
|
+
import { Button } from "./button"
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
title: "Primitives/EmptyState",
|
|
9
|
+
component: EmptyState,
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
argTypes: {
|
|
12
|
+
variant: { control: "select", options: ["empty", "error"] },
|
|
13
|
+
},
|
|
14
|
+
} satisfies Meta<typeof EmptyState>
|
|
15
|
+
|
|
16
|
+
export default meta
|
|
17
|
+
type Story = StoryObj<typeof meta>
|
|
18
|
+
|
|
19
|
+
export const Default: Story = {
|
|
20
|
+
args: {
|
|
21
|
+
title: "No tenants yet",
|
|
22
|
+
description: "Create your first tenant to get started.",
|
|
23
|
+
},
|
|
24
|
+
render: (args) => <EmptyState {...args} className="max-w-sm" />,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const WithAction: Story = {
|
|
28
|
+
args: {
|
|
29
|
+
title: "No roles found",
|
|
30
|
+
description: "Roles you create will show up here.",
|
|
31
|
+
action: (
|
|
32
|
+
<Button size="sm" variant="outline">
|
|
33
|
+
<IconPlus /> Create role
|
|
34
|
+
</Button>
|
|
35
|
+
),
|
|
36
|
+
},
|
|
37
|
+
render: (args) => <EmptyState {...args} className="max-w-sm" />,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const Error: Story = {
|
|
41
|
+
args: {
|
|
42
|
+
title: "Couldn't load audit logs",
|
|
43
|
+
description: "The request failed. Check your connection and try again.",
|
|
44
|
+
action: (
|
|
45
|
+
<Button size="sm" variant="outline">
|
|
46
|
+
<IconRefresh /> Retry
|
|
47
|
+
</Button>
|
|
48
|
+
),
|
|
49
|
+
},
|
|
50
|
+
render: (args) => <ErrorState {...args} className="max-w-sm" />,
|
|
51
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
|
+
import { IconInbox, IconAlertTriangle } from "@tabler/icons-react"
|
|
4
|
+
|
|
5
|
+
import { Lottie, type MomentName } from "./lottie"
|
|
6
|
+
import { cn } from "./utils"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Shared shape for EmptyState ("nothing here yet") and ErrorState ("something
|
|
10
|
+
* went wrong") — the two states share every prop; only the tone/default icon
|
|
11
|
+
* and the announced ARIA role differ. Kept as one variant-driven component so
|
|
12
|
+
* the two never drift apart visually.
|
|
13
|
+
*
|
|
14
|
+
* PLATFORM NOTE: `icon` and `action` are optional slot overrides (web-only —
|
|
15
|
+
* arbitrary React nodes cannot cross to a future Flutter/Dart port). Every
|
|
16
|
+
* OTHER prop (`variant`, `title`, `description`) is a plain string/enum, so a
|
|
17
|
+
* Flutter implementation can mirror the same contract and supply its own
|
|
18
|
+
* platform-appropriate default icon/action per variant.
|
|
19
|
+
*/
|
|
20
|
+
const emptyStateVariants = cva(
|
|
21
|
+
"flex flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-border p-8 text-center",
|
|
22
|
+
{
|
|
23
|
+
variants: {
|
|
24
|
+
variant: {
|
|
25
|
+
empty: "text-muted-foreground",
|
|
26
|
+
error: "border-destructive/30 text-destructive",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
defaultVariants: {
|
|
30
|
+
variant: "empty",
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
export interface EmptyStateProps
|
|
36
|
+
extends Omit<React.ComponentProps<"div">, "title">,
|
|
37
|
+
VariantProps<typeof emptyStateVariants> {
|
|
38
|
+
/** Slot override for the icon; falls back to a sensible per-variant default. */
|
|
39
|
+
icon?: React.ReactNode
|
|
40
|
+
title: string
|
|
41
|
+
description?: string
|
|
42
|
+
/** Slot for a retry/create/etc. control — typically a <Button>. */
|
|
43
|
+
action?: React.ReactNode
|
|
44
|
+
/**
|
|
45
|
+
* A Lottie moment in place of the icon (LT.4): `empty-*` the first time a list
|
|
46
|
+
* is empty, `no-results` after a search, `all-caught-up` when nothing waits.
|
|
47
|
+
* One scene at most on a screen; the icon shows until it is ready.
|
|
48
|
+
*/
|
|
49
|
+
moment?: MomentName
|
|
50
|
+
/** Play the moment once a session under this key (empty lists), then show it still. */
|
|
51
|
+
once?: string
|
|
52
|
+
/** Play the moment once ever on this device (first-run scenes such as `agents-propose`). */
|
|
53
|
+
onceEver?: string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function EmptyState({
|
|
57
|
+
className,
|
|
58
|
+
variant,
|
|
59
|
+
icon,
|
|
60
|
+
title,
|
|
61
|
+
description,
|
|
62
|
+
action,
|
|
63
|
+
moment,
|
|
64
|
+
once,
|
|
65
|
+
onceEver,
|
|
66
|
+
...props
|
|
67
|
+
}: EmptyStateProps) {
|
|
68
|
+
const resolvedVariant = variant ?? "empty"
|
|
69
|
+
const defaultIcon =
|
|
70
|
+
resolvedVariant === "error" ? <IconAlertTriangle /> : <IconInbox />
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<div
|
|
74
|
+
data-slot="empty-state"
|
|
75
|
+
// Errors interrupt (assertive); an empty list is just informational
|
|
76
|
+
// (polite) — matches the same distinction Alert/ErrorState conventions
|
|
77
|
+
// draw elsewhere in this package.
|
|
78
|
+
role={resolvedVariant === "error" ? "alert" : "status"}
|
|
79
|
+
className={cn(emptyStateVariants({ variant }), className)}
|
|
80
|
+
{...props}
|
|
81
|
+
>
|
|
82
|
+
{moment ? (
|
|
83
|
+
<Lottie
|
|
84
|
+
name={moment}
|
|
85
|
+
once={once}
|
|
86
|
+
onceEver={onceEver}
|
|
87
|
+
className="h-[120px] w-[160px]"
|
|
88
|
+
fallback={
|
|
89
|
+
<span className="text-muted-foreground [&>svg]:size-8 [&>svg]:stroke-1">{icon ?? defaultIcon}</span>
|
|
90
|
+
}
|
|
91
|
+
/>
|
|
92
|
+
) : (
|
|
93
|
+
<div
|
|
94
|
+
data-slot="empty-state-icon"
|
|
95
|
+
aria-hidden="true"
|
|
96
|
+
className="text-muted-foreground [&>svg]:size-8 [&>svg]:stroke-1"
|
|
97
|
+
>
|
|
98
|
+
{icon ?? defaultIcon}
|
|
99
|
+
</div>
|
|
100
|
+
)}
|
|
101
|
+
<div data-slot="empty-state-title" className="text-sm font-medium text-foreground">
|
|
102
|
+
{title}
|
|
103
|
+
</div>
|
|
104
|
+
{description ? (
|
|
105
|
+
<div
|
|
106
|
+
data-slot="empty-state-description"
|
|
107
|
+
className="max-w-sm text-xs/relaxed text-muted-foreground text-balance"
|
|
108
|
+
>
|
|
109
|
+
{description}
|
|
110
|
+
</div>
|
|
111
|
+
) : null}
|
|
112
|
+
{action ? (
|
|
113
|
+
<div data-slot="empty-state-action" className="mt-2">
|
|
114
|
+
{action}
|
|
115
|
+
</div>
|
|
116
|
+
) : null}
|
|
117
|
+
</div>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** ErrorState is EmptyState pinned to variant="error" — same contract, error tone. */
|
|
122
|
+
function ErrorState(props: Omit<EmptyStateProps, "variant">) {
|
|
123
|
+
return <EmptyState {...props} variant="error" />
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export { EmptyState, ErrorState, emptyStateVariants }
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# EmptyState / ErrorState — usage notes (for the gallery/showcase task)
|
|
2
|
+
|
|
3
|
+
Import: `import { EmptyState, ErrorState } from '@whity/ui/empty-state'` (or the root barrel).
|
|
4
|
+
|
|
5
|
+
`ErrorState` is `EmptyState` pinned to `variant="error"` — identical props minus `variant`.
|
|
6
|
+
|
|
7
|
+
## Props
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Notes |
|
|
10
|
+
|---|---|---|---|
|
|
11
|
+
| `variant` | `'empty' \| 'error'` | no (default `'empty'`) | Not settable on `ErrorState` (always `'error'`). Drives tone + default icon + ARIA role. |
|
|
12
|
+
| `icon` | `React.ReactNode` | no | Slot override. Falls back to `IconInbox` (empty) / `IconAlertTriangle` (error) from `@tabler/icons-react`. Web-only slot — see platform note below. |
|
|
13
|
+
| `title` | `string` | **yes** | |
|
|
14
|
+
| `description` | `string` | no | |
|
|
15
|
+
| `action` | `React.ReactNode` | no | Typically a `<Button>` (e.g. "Retry" / "Create X"). |
|
|
16
|
+
| ...rest | `React.ComponentProps<'div'>` | no | Spread onto the root element (e.g. `className`). |
|
|
17
|
+
|
|
18
|
+
## Accessibility
|
|
19
|
+
|
|
20
|
+
- `EmptyState` renders `role="status"` (polite announcement — informational).
|
|
21
|
+
- `ErrorState` renders `role="alert"` (assertive announcement — interrupts, matching real error semantics).
|
|
22
|
+
- Verified via a real axe-core scan in `web/__tests__/empty-state.a11y.test.tsx` (0 violations across default, error, and with-action renders).
|
|
23
|
+
|
|
24
|
+
## Platform note (Flutter-forward design)
|
|
25
|
+
|
|
26
|
+
`variant`, `title`, and `description` are plain string/enum props — directly mirrorable by a future Flutter/Dart component. `icon` and `action` are React-node slots and are **web-only**; a Flutter implementation should supply its own platform-appropriate default icon/action per `variant` rather than trying to accept an arbitrary widget through the same prop name.
|
|
27
|
+
|
|
28
|
+
## Gallery / Storybook
|
|
29
|
+
|
|
30
|
+
Story file: `packages/ui/src/empty-state.stories.tsx` — `Default`, `WithAction`, `Error` stories under `Primitives/EmptyState`.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite"
|
|
2
|
+
import { fn } from "storybook/test"
|
|
3
|
+
import { useForm } from "react-hook-form"
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Form,
|
|
7
|
+
FormField,
|
|
8
|
+
FormItem,
|
|
9
|
+
FormLabel,
|
|
10
|
+
FormControl,
|
|
11
|
+
FormDescription,
|
|
12
|
+
FormMessage,
|
|
13
|
+
} from "./form"
|
|
14
|
+
import { Input } from "./input"
|
|
15
|
+
import { Button } from "./button"
|
|
16
|
+
|
|
17
|
+
type Values = { name: string; email: string }
|
|
18
|
+
|
|
19
|
+
interface TenantFormProps {
|
|
20
|
+
/** Seeds the fields — the shape a real screen would hydrate from the API. */
|
|
21
|
+
defaultValues?: Values
|
|
22
|
+
/** Label of the submit button. */
|
|
23
|
+
submitLabel?: string
|
|
24
|
+
/** Fired with the validated values once the form submits cleanly. */
|
|
25
|
+
onSubmit?: (values: Values) => void
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A representative form assembled from this module's primitives. `Form` is
|
|
30
|
+
* react-hook-form's `FormProvider`, whose props are a live `useForm()` return
|
|
31
|
+
* value — it can only be produced by a hook at render time, never by static
|
|
32
|
+
* story args — so the stories document the composition through this wrapper
|
|
33
|
+
* instead of the provider itself.
|
|
34
|
+
*/
|
|
35
|
+
function TenantForm({
|
|
36
|
+
defaultValues = { name: "", email: "" },
|
|
37
|
+
submitLabel = "Create tenant",
|
|
38
|
+
onSubmit = () => {},
|
|
39
|
+
}: TenantFormProps) {
|
|
40
|
+
const form = useForm<Values>({ defaultValues, mode: "onTouched" })
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Form {...form}>
|
|
44
|
+
<form onSubmit={form.handleSubmit(onSubmit)} className="flex w-80 flex-col gap-4">
|
|
45
|
+
<FormField
|
|
46
|
+
control={form.control}
|
|
47
|
+
name="name"
|
|
48
|
+
rules={{ required: "Name is required" }}
|
|
49
|
+
render={({ field }) => (
|
|
50
|
+
<FormItem>
|
|
51
|
+
<FormLabel>Tenant name</FormLabel>
|
|
52
|
+
<FormControl>
|
|
53
|
+
<Input placeholder="Acme" {...field} />
|
|
54
|
+
</FormControl>
|
|
55
|
+
<FormDescription>Shown across the dashboard.</FormDescription>
|
|
56
|
+
<FormMessage />
|
|
57
|
+
</FormItem>
|
|
58
|
+
)}
|
|
59
|
+
/>
|
|
60
|
+
<FormField
|
|
61
|
+
control={form.control}
|
|
62
|
+
name="email"
|
|
63
|
+
rules={{
|
|
64
|
+
required: "Email is required",
|
|
65
|
+
pattern: { value: /^[^@]+@[^@]+$/, message: "Enter a valid email" },
|
|
66
|
+
}}
|
|
67
|
+
render={({ field }) => (
|
|
68
|
+
<FormItem>
|
|
69
|
+
<FormLabel>Admin email</FormLabel>
|
|
70
|
+
<FormControl>
|
|
71
|
+
<Input type="email" placeholder="admin@acme.com" {...field} />
|
|
72
|
+
</FormControl>
|
|
73
|
+
<FormMessage />
|
|
74
|
+
</FormItem>
|
|
75
|
+
)}
|
|
76
|
+
/>
|
|
77
|
+
<Button type="submit">{submitLabel}</Button>
|
|
78
|
+
</form>
|
|
79
|
+
</Form>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const meta = {
|
|
84
|
+
title: "Primitives/Form",
|
|
85
|
+
component: TenantForm,
|
|
86
|
+
tags: ["autodocs"],
|
|
87
|
+
parameters: {
|
|
88
|
+
layout: "padded",
|
|
89
|
+
docs: {
|
|
90
|
+
description: {
|
|
91
|
+
component:
|
|
92
|
+
"`Form`, `FormField`, `FormItem`, `FormLabel`, `FormControl`, `FormDescription` and `FormMessage` are the react-hook-form bindings shipped by this package. The stories exercise them through a representative tenant-creation form.",
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
args: {
|
|
97
|
+
onSubmit: fn(),
|
|
98
|
+
},
|
|
99
|
+
} satisfies Meta<typeof TenantForm>
|
|
100
|
+
|
|
101
|
+
export default meta
|
|
102
|
+
type Story = StoryObj<typeof meta>
|
|
103
|
+
|
|
104
|
+
export const Default: Story = {}
|
|
105
|
+
|
|
106
|
+
/** Prefilled the way an edit screen hydrates the form from an existing record. */
|
|
107
|
+
export const Prefilled: Story = {
|
|
108
|
+
args: {
|
|
109
|
+
defaultValues: { name: "Acme Inc.", email: "admin@acme.com" },
|
|
110
|
+
submitLabel: "Save changes",
|
|
111
|
+
},
|
|
112
|
+
}
|