import { IconSearch } from "@tabler/icons-react"; import { createElement, type CSSProperties, type KeyboardEvent, type MouseEvent as ReactMouseEvent, type ReactNode, type Ref, } from "react"; import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar.js"; import { Badge } from "../ui/badge.js"; import { ButtonBase } from "../ui/button.js"; import { Card } from "../ui/card.js"; import { Checkbox as DefaultCheckboxPrimitive } from "../ui/checkbox.js"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "../ui/dialog.js"; import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, } from "../ui/dropdown-menu.js"; import { Input } from "../ui/input.js"; import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover.js"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "../ui/select.js"; import { Skeleton as DefaultSkeletonPrimitive } from "../ui/skeleton.js"; import { Spinner as DefaultSpinnerPrimitive } from "../ui/spinner.js"; import { Switch as DefaultSwitchPrimitive } from "../ui/switch.js"; import { Tabs as DefaultTabsPrimitive, TabsContent, TabsList, TabsTrigger, } from "../ui/tabs.js"; import { Textarea } from "../ui/textarea.js"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "../ui/tooltip.js"; import { cn } from "../utils.js"; import type { DesignSystemComponents, MenuItem } from "./types.js"; function buttonVariant( intent: "primary" | "neutral" | "danger" = "neutral", emphasis: "solid" | "outline" | "ghost" = "solid", ) { if (emphasis === "ghost") return "ghost" as const; if (emphasis === "outline") return "outline" as const; if (intent === "primary") return "default" as const; if (intent === "danger") return "destructive" as const; return "secondary" as const; } function buttonSize(size: "compact" | "default" | "large" = "default") { if (size === "compact") return "sm" as const; if (size === "large") return "lg" as const; return "default" as const; } const DefaultActionButton: DesignSystemComponents["ActionButton"] = ({ children, intent, emphasis, size, pending, disabled, type = "button", leadingIcon, trailingIcon, onPress, elementRef, ...props }) => ( onPress?.(event)} > {pending ? ); const DefaultIconButton: DesignSystemComponents["IconButton"] = ({ label, icon, intent, emphasis = "ghost", size, pending, disabled, type = "button", onPress, elementRef, className, ...props }) => ( onPress?.(event)} aria-label={label} data-size={size} > {pending ? ); function FieldShell({ label, description, errorMessage, className, style, children, }: { label?: ReactNode; description?: ReactNode; errorMessage?: ReactNode; className?: string; style?: CSSProperties; children: ReactNode; }) { return ( ); } const DefaultTextField: DesignSystemComponents["TextField"] = ({ value, onChange, label, description, errorMessage, invalid, inputRef, leadingContent, trailingContent, className, style, onBlur, onFocus, onKeyDown, ...props }) => (
{leadingContent} onChange(event.currentTarget.value)} onBlur={onBlur} onFocus={onFocus} onKeyDown={onKeyDown} /> {trailingContent}
); const DefaultTextArea: DesignSystemComponents["TextArea"] = ({ value, onChange, label, description, errorMessage, invalid, textAreaRef, className, style, onBlur, onFocus, onKeyDown, ...props }) => (