@majapisoftwares/ui 6.3.0 → 6.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/AGENTS.md +27 -27
- package/README.md +79 -79
- package/THIRD_PARTY_NOTICES.md +39 -39
- package/components.json +25 -25
- package/docs/MIGRATION-0.2.md +20 -20
- package/docs/MIGRATION-6.0.md +33 -33
- package/docs/NEXT-STARTER-VALIDATION.md +14 -14
- package/docs/STANDARDS.md +65 -51
- package/docs/VALIDATION.md +11 -11
- package/docs/VERSIONING.md +32 -28
- package/docs/validation/preference-titles.md +22 -22
- package/package.json +91 -89
- package/scripts/check-standards.mjs +41 -41
- package/src/components/ui/accordion.tsx +82 -82
- package/src/components/ui/alert-dialog.tsx +187 -187
- package/src/components/ui/alert.tsx +77 -77
- package/src/components/ui/attachment.tsx +209 -0
- package/src/components/ui/avatar.tsx +108 -108
- package/src/components/ui/badge.tsx +55 -55
- package/src/components/ui/breadcrumb.tsx +125 -125
- package/src/components/ui/bubble.tsx +129 -0
- package/src/components/ui/button-group.tsx +89 -89
- package/src/components/ui/button.tsx +59 -59
- package/src/components/ui/card.tsx +101 -101
- package/src/components/ui/checkbox.tsx +27 -27
- package/src/components/ui/collapsible.tsx +21 -21
- package/src/components/ui/context-menu.tsx +271 -271
- package/src/components/ui/dialog.tsx +161 -161
- package/src/components/ui/dropdown-menu.tsx +271 -271
- package/src/components/ui/empty.tsx +105 -105
- package/src/components/ui/field.tsx +238 -238
- package/src/components/ui/hover-card.tsx +50 -50
- package/src/components/ui/input-group.tsx +155 -155
- package/src/components/ui/input.tsx +21 -21
- package/src/components/ui/item.tsx +203 -0
- package/src/components/ui/kbd.tsx +28 -28
- package/src/components/ui/label.tsx +19 -19
- package/src/components/ui/message-scroller.tsx +166 -0
- package/src/components/ui/message.tsx +93 -0
- package/src/components/ui/orb.css +1002 -1002
- package/src/components/ui/orb.tsx +752 -752
- package/src/components/ui/popover.tsx +89 -89
- package/src/components/ui/progress.tsx +82 -82
- package/src/components/ui/radio-group.tsx +37 -37
- package/src/components/ui/scroll-area.tsx +54 -54
- package/src/components/ui/select.tsx +204 -204
- package/src/components/ui/separator.tsx +24 -24
- package/src/components/ui/sheet.tsx +139 -139
- package/src/components/ui/sidebar.tsx +1048 -1048
- package/src/components/ui/skeleton.tsx +15 -15
- package/src/components/ui/slider.tsx +53 -53
- package/src/components/ui/sonner.tsx +44 -44
- package/src/components/ui/spinner.tsx +32 -32
- package/src/components/ui/switch.tsx +31 -31
- package/src/components/ui/table.tsx +121 -121
- package/src/components/ui/tabs.tsx +81 -81
- package/src/components/ui/textarea.tsx +19 -19
- package/src/components/ui/toggle-group.tsx +89 -89
- package/src/components/ui/toggle.tsx +44 -44
- package/src/components/ui/tooltip.tsx +65 -65
- package/src/components/ui/trace.tsx +163 -0
- package/src/hooks/use-mobile.ts +20 -20
- package/src/hooks/use-streamed-text.ts +64 -0
- package/src/lib/i18n.tsx +151 -109
- package/src/lib/utils.ts +1 -1
- package/src/patterns/app-shell.tsx +237 -237
- package/src/patterns/chat-markdown.tsx +72 -0
- package/src/patterns/chat-trace.tsx +200 -0
- package/src/patterns/chat.tsx +317 -0
- package/src/patterns/data-table.tsx +2492 -2492
- package/src/patterns/filter-tabs.tsx +53 -53
- package/src/patterns/majapi-logo.tsx +32 -32
- package/src/patterns/page-header.tsx +62 -62
- package/src/patterns/prompt-input.tsx +374 -0
- package/src/patterns/status-badge.tsx +24 -24
- package/src/patterns/user-menu.tsx +218 -218
- package/src/patterns/workspace-switcher.tsx +176 -176
- package/src/styles.css +170 -165
- package/src/templates/admin-dashboard.tsx +44 -44
- package/src/templates/auth-layout.tsx +30 -30
- package/src/templates/signup-form.tsx +177 -177
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
useEffect,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
|
+
type ClipboardEvent,
|
|
8
|
+
type DragEvent,
|
|
9
|
+
type FormEvent,
|
|
10
|
+
type KeyboardEvent,
|
|
11
|
+
type ReactNode,
|
|
12
|
+
} from "react";
|
|
13
|
+
import { ArrowUpIcon, FileIcon, PlusIcon, SquareIcon, XIcon } from "lucide-react";
|
|
14
|
+
import { cn } from "../lib/utils";
|
|
15
|
+
import { useUiMessages } from "../lib/i18n";
|
|
16
|
+
import {
|
|
17
|
+
InputGroup,
|
|
18
|
+
InputGroupAddon,
|
|
19
|
+
InputGroupButton,
|
|
20
|
+
InputGroupTextarea,
|
|
21
|
+
} from "../components/ui/input-group";
|
|
22
|
+
import {
|
|
23
|
+
Attachment,
|
|
24
|
+
AttachmentAction,
|
|
25
|
+
AttachmentActions,
|
|
26
|
+
AttachmentContent,
|
|
27
|
+
AttachmentDescription,
|
|
28
|
+
AttachmentGroup,
|
|
29
|
+
AttachmentMedia,
|
|
30
|
+
AttachmentTitle,
|
|
31
|
+
} from "../components/ui/attachment";
|
|
32
|
+
import { Input } from "../components/ui/input";
|
|
33
|
+
import { Spinner } from "../components/ui/spinner";
|
|
34
|
+
|
|
35
|
+
/** Lifecycle of the current turn, as in the AI SDK's `useChat().status`. */
|
|
36
|
+
export type ChatStatus = "ready" | "submitted" | "streaming" | "error";
|
|
37
|
+
|
|
38
|
+
export interface PromptInputMessage {
|
|
39
|
+
text: string;
|
|
40
|
+
files: File[];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface PromptInputProps {
|
|
44
|
+
/**
|
|
45
|
+
* Receives the trimmed text and attached files. The field clears right
|
|
46
|
+
* away; when the returned promise rejects, text and files come back.
|
|
47
|
+
*/
|
|
48
|
+
onSubmit: (message: PromptInputMessage) => void | Promise<void>;
|
|
49
|
+
value?: string;
|
|
50
|
+
defaultValue?: string;
|
|
51
|
+
onValueChange?: (value: string) => void;
|
|
52
|
+
/** While submitted/streaming, Enter does not send and the button stops. */
|
|
53
|
+
status?: ChatStatus;
|
|
54
|
+
onStop?: () => void;
|
|
55
|
+
/**
|
|
56
|
+
* Lets the person send while a reply is in progress, e.g. to steer a
|
|
57
|
+
* running agent. With text the button sends; with an empty field it stops.
|
|
58
|
+
*/
|
|
59
|
+
sendWhileBusy?: boolean;
|
|
60
|
+
placeholder?: string;
|
|
61
|
+
disabled?: boolean;
|
|
62
|
+
autoFocus?: boolean;
|
|
63
|
+
/** Enables the attach button, paste and drop of files. */
|
|
64
|
+
attachments?: boolean;
|
|
65
|
+
/** File input accept list, e.g. "image/*,.pdf". */
|
|
66
|
+
accept?: string;
|
|
67
|
+
maxFiles?: number;
|
|
68
|
+
/** Extra controls in the bottom bar, before the send button (e.g. a model menu). */
|
|
69
|
+
actions?: ReactNode;
|
|
70
|
+
className?: string;
|
|
71
|
+
"aria-label"?: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
interface PendingFile {
|
|
75
|
+
id: string;
|
|
76
|
+
file: File;
|
|
77
|
+
previewUrl?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function matchesAccept(file: File, accept?: string) {
|
|
81
|
+
if (!accept) return true;
|
|
82
|
+
const name = file.name.toLowerCase();
|
|
83
|
+
const type = file.type.toLowerCase();
|
|
84
|
+
return accept.split(",").some((raw) => {
|
|
85
|
+
const rule = raw.trim().toLowerCase();
|
|
86
|
+
if (!rule) return false;
|
|
87
|
+
if (rule.startsWith(".")) return name.endsWith(rule);
|
|
88
|
+
if (rule.endsWith("/*")) return type.startsWith(rule.slice(0, -1));
|
|
89
|
+
return type === rule;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function toPendingFile(file: File): PendingFile {
|
|
94
|
+
return {
|
|
95
|
+
id: crypto.randomUUID(),
|
|
96
|
+
file,
|
|
97
|
+
previewUrl: file.type.startsWith("image/")
|
|
98
|
+
? URL.createObjectURL(file)
|
|
99
|
+
: undefined,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function formatBytes(bytes: number) {
|
|
104
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
105
|
+
if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;
|
|
106
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function clipboardFiles(data: DataTransfer) {
|
|
110
|
+
if (data.files.length > 0) return Array.from(data.files);
|
|
111
|
+
return Array.from(data.items).flatMap((item) => {
|
|
112
|
+
const file = item.kind === "file" ? item.getAsFile() : null;
|
|
113
|
+
return file ? [file] : [];
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Chat composer on InputGroup (shadcn AI Elements Prompt Input) with Numa's
|
|
119
|
+
* behaviour: Enter sends and Shift+Enter breaks the line, files can be
|
|
120
|
+
* attached, pasted or dropped, focus stays in the field after sending, a
|
|
121
|
+
* failed send restores the draft and, with `sendWhileBusy`, messages can be
|
|
122
|
+
* sent while the agent works.
|
|
123
|
+
*/
|
|
124
|
+
export function PromptInput({
|
|
125
|
+
onSubmit,
|
|
126
|
+
value,
|
|
127
|
+
defaultValue = "",
|
|
128
|
+
onValueChange,
|
|
129
|
+
status = "ready",
|
|
130
|
+
onStop,
|
|
131
|
+
sendWhileBusy = false,
|
|
132
|
+
placeholder,
|
|
133
|
+
disabled = false,
|
|
134
|
+
autoFocus = false,
|
|
135
|
+
attachments = false,
|
|
136
|
+
accept,
|
|
137
|
+
maxFiles,
|
|
138
|
+
actions,
|
|
139
|
+
className,
|
|
140
|
+
"aria-label": ariaLabel,
|
|
141
|
+
}: PromptInputProps) {
|
|
142
|
+
const messages = useUiMessages();
|
|
143
|
+
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
|
144
|
+
const fileInputRef = useRef<HTMLInputElement>(null);
|
|
145
|
+
const [innerValue, setInnerValue] = useState(defaultValue);
|
|
146
|
+
const [files, setFiles] = useState<PendingFile[]>([]);
|
|
147
|
+
const [dragging, setDragging] = useState(false);
|
|
148
|
+
const filesRef = useRef(files);
|
|
149
|
+
const text = value ?? innerValue;
|
|
150
|
+
const busy = status === "submitted" || status === "streaming";
|
|
151
|
+
const hasContent = text.trim().length > 0 || files.length > 0;
|
|
152
|
+
const canSend = !disabled && (!busy || sendWhileBusy) && hasContent;
|
|
153
|
+
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
filesRef.current = files;
|
|
156
|
+
}, [files]);
|
|
157
|
+
|
|
158
|
+
// Release previews that are still attached when the composer unmounts.
|
|
159
|
+
useEffect(
|
|
160
|
+
() => () => {
|
|
161
|
+
for (const item of filesRef.current)
|
|
162
|
+
if (item.previewUrl) URL.revokeObjectURL(item.previewUrl);
|
|
163
|
+
},
|
|
164
|
+
[],
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
const setText = (next: string) => {
|
|
168
|
+
if (value === undefined) setInnerValue(next);
|
|
169
|
+
onValueChange?.(next);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const addFiles = (incoming: File[]) => {
|
|
173
|
+
if (!attachments || disabled) return;
|
|
174
|
+
const accepted = incoming.filter((file) => matchesAccept(file, accept));
|
|
175
|
+
if (accepted.length === 0) return;
|
|
176
|
+
setFiles((current) => {
|
|
177
|
+
const room = maxFiles === undefined ? accepted.length : maxFiles - current.length;
|
|
178
|
+
return [...current, ...accepted.slice(0, Math.max(0, room)).map(toPendingFile)];
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const removeFile = (id: string) => {
|
|
183
|
+
setFiles((current) => {
|
|
184
|
+
const removed = current.find((item) => item.id === id);
|
|
185
|
+
if (removed?.previewUrl) URL.revokeObjectURL(removed.previewUrl);
|
|
186
|
+
return current.filter((item) => item.id !== id);
|
|
187
|
+
});
|
|
188
|
+
textareaRef.current?.focus();
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const submit = (event?: FormEvent<HTMLFormElement>) => {
|
|
192
|
+
event?.preventDefault();
|
|
193
|
+
if (!canSend) return;
|
|
194
|
+
const draft = text;
|
|
195
|
+
const sent = files;
|
|
196
|
+
setText("");
|
|
197
|
+
setFiles([]);
|
|
198
|
+
const release = () => {
|
|
199
|
+
for (const item of sent)
|
|
200
|
+
if (item.previewUrl) URL.revokeObjectURL(item.previewUrl);
|
|
201
|
+
};
|
|
202
|
+
const result = onSubmit({
|
|
203
|
+
text: draft.trim(),
|
|
204
|
+
files: sent.map((item) => item.file),
|
|
205
|
+
});
|
|
206
|
+
if (!(result instanceof Promise)) {
|
|
207
|
+
release();
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
result.then(release, () => {
|
|
211
|
+
// Restore unless the person already started a new draft.
|
|
212
|
+
if (value === undefined) setInnerValue((current) => current || draft);
|
|
213
|
+
else if (!textareaRef.current?.value) onValueChange?.(draft);
|
|
214
|
+
setFiles((current) => (current.length > 0 ? current : sent));
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
const handleKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {
|
|
219
|
+
if (event.key !== "Enter" || event.shiftKey || event.nativeEvent.isComposing)
|
|
220
|
+
return;
|
|
221
|
+
event.preventDefault();
|
|
222
|
+
if (canSend) event.currentTarget.form?.requestSubmit();
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const handlePaste = (event: ClipboardEvent<HTMLTextAreaElement>) => {
|
|
226
|
+
if (!attachments) return;
|
|
227
|
+
const pasted = clipboardFiles(event.clipboardData);
|
|
228
|
+
if (pasted.length === 0) return;
|
|
229
|
+
event.preventDefault();
|
|
230
|
+
addFiles(pasted);
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
const hasFiles = (event: DragEvent) =>
|
|
234
|
+
attachments && !disabled && event.dataTransfer.types.includes("Files");
|
|
235
|
+
|
|
236
|
+
// With sendWhileBusy, a draft turns the stop button back into send.
|
|
237
|
+
const stopping =
|
|
238
|
+
busy && onStop !== undefined && !(sendWhileBusy && hasContent);
|
|
239
|
+
const waiting = busy && !stopping && !canSend;
|
|
240
|
+
const sendLabel = stopping ? messages.stop : messages.send;
|
|
241
|
+
// Keeps focus (and the mobile keyboard) in the field while pressing buttons.
|
|
242
|
+
const keepFocus = (event: { preventDefault: () => void }) =>
|
|
243
|
+
event.preventDefault();
|
|
244
|
+
|
|
245
|
+
return (
|
|
246
|
+
<form
|
|
247
|
+
className={cn("w-full", className)}
|
|
248
|
+
onSubmit={submit}
|
|
249
|
+
onDragOver={(event) => {
|
|
250
|
+
if (!hasFiles(event)) return;
|
|
251
|
+
event.preventDefault();
|
|
252
|
+
setDragging(true);
|
|
253
|
+
}}
|
|
254
|
+
onDragLeave={(event) => {
|
|
255
|
+
if (!event.currentTarget.contains(event.relatedTarget as Node | null))
|
|
256
|
+
setDragging(false);
|
|
257
|
+
}}
|
|
258
|
+
onDrop={(event) => {
|
|
259
|
+
if (!hasFiles(event)) return;
|
|
260
|
+
event.preventDefault();
|
|
261
|
+
setDragging(false);
|
|
262
|
+
addFiles(Array.from(event.dataTransfer.files));
|
|
263
|
+
}}
|
|
264
|
+
>
|
|
265
|
+
<InputGroup
|
|
266
|
+
data-disabled={disabled || undefined}
|
|
267
|
+
data-dragging={dragging || undefined}
|
|
268
|
+
className="data-dragging:border-ring data-dragging:ring-3 data-dragging:ring-ring/30"
|
|
269
|
+
>
|
|
270
|
+
{files.length > 0 ? (
|
|
271
|
+
<InputGroupAddon align="block-start" className="cursor-default">
|
|
272
|
+
<AttachmentGroup aria-label={messages.attachments} className="w-full">
|
|
273
|
+
{files.map((item) => (
|
|
274
|
+
<Attachment key={item.id} size="sm">
|
|
275
|
+
<AttachmentMedia variant={item.previewUrl ? "image" : "icon"}>
|
|
276
|
+
{item.previewUrl ? (
|
|
277
|
+
<img src={item.previewUrl} alt="" />
|
|
278
|
+
) : (
|
|
279
|
+
<FileIcon />
|
|
280
|
+
)}
|
|
281
|
+
</AttachmentMedia>
|
|
282
|
+
<AttachmentContent>
|
|
283
|
+
<AttachmentTitle>{item.file.name}</AttachmentTitle>
|
|
284
|
+
<AttachmentDescription>
|
|
285
|
+
{formatBytes(item.file.size)}
|
|
286
|
+
</AttachmentDescription>
|
|
287
|
+
</AttachmentContent>
|
|
288
|
+
<AttachmentActions>
|
|
289
|
+
<AttachmentAction
|
|
290
|
+
aria-label={messages.removeAttachment(item.file.name)}
|
|
291
|
+
onClick={() => removeFile(item.id)}
|
|
292
|
+
>
|
|
293
|
+
<XIcon />
|
|
294
|
+
</AttachmentAction>
|
|
295
|
+
</AttachmentActions>
|
|
296
|
+
</Attachment>
|
|
297
|
+
))}
|
|
298
|
+
</AttachmentGroup>
|
|
299
|
+
</InputGroupAddon>
|
|
300
|
+
) : null}
|
|
301
|
+
<InputGroupTextarea
|
|
302
|
+
ref={textareaRef}
|
|
303
|
+
value={text}
|
|
304
|
+
onChange={(event) => setText(event.target.value)}
|
|
305
|
+
onKeyDown={handleKeyDown}
|
|
306
|
+
onPaste={handlePaste}
|
|
307
|
+
placeholder={placeholder ?? messages.promptPlaceholder}
|
|
308
|
+
aria-label={ariaLabel ?? messages.prompt}
|
|
309
|
+
disabled={disabled}
|
|
310
|
+
autoFocus={autoFocus}
|
|
311
|
+
rows={1}
|
|
312
|
+
className="max-h-48 min-h-12 px-4 pt-3.5"
|
|
313
|
+
/>
|
|
314
|
+
<InputGroupAddon
|
|
315
|
+
align="block-end"
|
|
316
|
+
className="cursor-text"
|
|
317
|
+
onClick={(event) => {
|
|
318
|
+
if (!(event.target as HTMLElement).closest("button"))
|
|
319
|
+
textareaRef.current?.focus();
|
|
320
|
+
}}
|
|
321
|
+
>
|
|
322
|
+
{attachments ? (
|
|
323
|
+
<>
|
|
324
|
+
<Input
|
|
325
|
+
ref={fileInputRef}
|
|
326
|
+
type="file"
|
|
327
|
+
multiple
|
|
328
|
+
accept={accept}
|
|
329
|
+
disabled={disabled}
|
|
330
|
+
hidden
|
|
331
|
+
onChange={(event) => {
|
|
332
|
+
addFiles(Array.from(event.target.files ?? []));
|
|
333
|
+
event.target.value = "";
|
|
334
|
+
}}
|
|
335
|
+
/>
|
|
336
|
+
<InputGroupButton
|
|
337
|
+
size="icon-sm"
|
|
338
|
+
variant="outline"
|
|
339
|
+
className="size-11 rounded-full md:size-8"
|
|
340
|
+
aria-label={messages.attachFiles}
|
|
341
|
+
disabled={disabled}
|
|
342
|
+
onMouseDown={keepFocus}
|
|
343
|
+
onClick={() => fileInputRef.current?.click()}
|
|
344
|
+
>
|
|
345
|
+
<PlusIcon />
|
|
346
|
+
</InputGroupButton>
|
|
347
|
+
</>
|
|
348
|
+
) : null}
|
|
349
|
+
<div className="ml-auto flex min-w-0 items-center gap-2">
|
|
350
|
+
{actions}
|
|
351
|
+
<InputGroupButton
|
|
352
|
+
type={stopping ? "button" : "submit"}
|
|
353
|
+
size="icon-sm"
|
|
354
|
+
variant="default"
|
|
355
|
+
className="size-11 rounded-full md:size-8"
|
|
356
|
+
aria-label={sendLabel}
|
|
357
|
+
disabled={stopping ? false : !canSend}
|
|
358
|
+
onMouseDown={keepFocus}
|
|
359
|
+
onClick={stopping ? onStop : undefined}
|
|
360
|
+
>
|
|
361
|
+
{stopping ? (
|
|
362
|
+
<SquareIcon className="fill-current" />
|
|
363
|
+
) : waiting ? (
|
|
364
|
+
<Spinner />
|
|
365
|
+
) : (
|
|
366
|
+
<ArrowUpIcon />
|
|
367
|
+
)}
|
|
368
|
+
</InputGroupButton>
|
|
369
|
+
</div>
|
|
370
|
+
</InputGroupAddon>
|
|
371
|
+
</InputGroup>
|
|
372
|
+
</form>
|
|
373
|
+
);
|
|
374
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
import { Badge } from "../components/ui/badge";
|
|
3
|
-
export function StatusBadge({
|
|
4
|
-
children,
|
|
5
|
-
tone = "neutral",
|
|
6
|
-
}: {
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
tone?: "neutral" | "success" | "warning" | "danger";
|
|
9
|
-
}) {
|
|
10
|
-
return (
|
|
11
|
-
<Badge
|
|
12
|
-
variant={
|
|
13
|
-
tone === "danger"
|
|
14
|
-
? "destructive"
|
|
15
|
-
: tone === "neutral"
|
|
16
|
-
? "outline"
|
|
17
|
-
: tone
|
|
18
|
-
}
|
|
19
|
-
>
|
|
20
|
-
<span className="size-1.5 rounded-full bg-current" aria-hidden="true" />
|
|
21
|
-
{children}
|
|
22
|
-
</Badge>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { Badge } from "../components/ui/badge";
|
|
3
|
+
export function StatusBadge({
|
|
4
|
+
children,
|
|
5
|
+
tone = "neutral",
|
|
6
|
+
}: {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
tone?: "neutral" | "success" | "warning" | "danger";
|
|
9
|
+
}) {
|
|
10
|
+
return (
|
|
11
|
+
<Badge
|
|
12
|
+
variant={
|
|
13
|
+
tone === "danger"
|
|
14
|
+
? "destructive"
|
|
15
|
+
: tone === "neutral"
|
|
16
|
+
? "outline"
|
|
17
|
+
: tone
|
|
18
|
+
}
|
|
19
|
+
>
|
|
20
|
+
<span className="size-1.5 rounded-full bg-current" aria-hidden="true" />
|
|
21
|
+
{children}
|
|
22
|
+
</Badge>
|
|
23
|
+
);
|
|
24
|
+
}
|