/* global React, Icon */ /* Primitives: Button, IconBtn, Chip, Badge, Pill, Tag, Avatar, Input, Textarea, Select, Toggle, Checkbox, Radio, Slider, FilePick, Tabs, Segmented, Accordion, Breadcrumb, Kbd, Spinner */ const { useState, useRef, useEffect, useId, useCallback } = React; /* ---------- Button ---------- */ function Button({ variant = "primary", size = "md", icon, iconRight, children, disabled, loading, fullWidth, onClick, type = "button", style, className = "", ...rest }) { const sz = { xs: { h: 28, px: 12, fs: 12 }, sm: { h: 32, px: 14, fs: 13 }, md: { h: "var(--d-btn-h)", px: "var(--d-btn-px)", fs: 14 }, lg: { h: 48, px: 24, fs: 15 } }[size]; const base = { height: sz.h, padding: `0 ${typeof sz.px === "number" ? sz.px + "px" : sz.px}`, fontSize: sz.fs, fontWeight: 500, fontFamily: "var(--sans)", borderRadius: 2, display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 8, cursor: disabled ? "not-allowed" : "pointer", border: "1px solid transparent", transition: "background 220ms ease, color 220ms ease, border-color 220ms ease, opacity 200ms", opacity: disabled ? 0.4 : 1, position: "relative", overflow: "hidden", whiteSpace: "nowrap", letterSpacing: "-0.005em", width: fullWidth ? "100%" : "auto" }; const variants = { primary: { background: "var(--brand-grad)", color: "white" }, ink: { background: "var(--ink)", color: "var(--bg)" }, secondary: { background: "transparent", color: "var(--ink)", border: "1px solid var(--ink)" }, ghost: { background: "transparent", color: "var(--ink)" }, quiet: { background: "var(--bg-2)", color: "var(--ink)" }, danger: { background: "transparent", color: "var(--neg)", border: "1px solid var(--neg)" } }; return ( ); } function IconBtn({ icon, size = 36, onClick, label, active, className = "", style }) { return ( ); } /* ---------- Spinner ---------- */ function Spinner({ size = 16, color = "currentColor" }) { return ( ); } /* ---------- Chip / Tag / Badge / Pill ---------- */ function Chip({ children, onRemove, active, icon, dot, onClick, size = "md" }) { const sizes = { sm: { h: 22, px: 8, fs: 11 }, md: { h: 28, px: 12, fs: 12 }, lg: { h: 32, px: 14, fs: 13 } }; const s = sizes[size]; return ( {dot && } {icon} {children} {onRemove && } ); } function Badge({ children, tone = "neutral", style }) { const tones = { neutral: { bg: "var(--bg-2)", color: "var(--ink)", border: "var(--line)" }, pos: { bg: "var(--pos-bg)", color: "var(--pos)", border: "transparent" }, neg: { bg: "var(--neg-bg)", color: "var(--neg)", border: "transparent" }, warn: { bg: "var(--warn-bg)", color: "var(--warn)", border: "transparent" }, info: { bg: "var(--info-bg)", color: "var(--info)", border: "transparent" }, grad: { bg: "transparent", color: "white", border: "transparent", grad: true }, ink: { bg: "var(--ink)", color: "var(--bg)", border: "var(--ink)" } }; const t = tones[tone]; return ( {children}); } function Pill({ children, tone = "neutral", dot }) { const tones = { neutral: { bg: "var(--bg-2)", color: "var(--ink-2)" }, pos: { bg: "var(--pos-bg)", color: "var(--pos)" }, neg: { bg: "var(--neg-bg)", color: "var(--neg)" }, warn: { bg: "var(--warn-bg)", color: "var(--warn)" }, info: { bg: "var(--info-bg)", color: "var(--info)" } }; const t = tones[tone]; const dotColor = { neutral: "var(--ink-3)", pos: "var(--pos)", neg: "var(--neg)", warn: "var(--warn)", info: "var(--info)" }[tone]; return ( {dot && } {children} ); } /* ---------- Avatar ---------- */ function Avatar({ name = "", size = 32, tint, ring, src }) { const initials = name.split(/\s+/).slice(0, 2).map((s) => s[0]).join("").toUpperCase(); const tints = ["var(--ph-pink)", "var(--ph-teal)", "var(--ph-magenta)", "var(--ph-orange)", "var(--ph-ink)"]; const idx = (name.charCodeAt(0) || 0) % tints.length; return ( {!src && initials}); } /* ---------- Inputs ---------- */ function Field({ label, hint, error, required, children, style }) { return ( ); } function Input({ icon, suffix, value, onChange, placeholder, type = "text", error, fullWidth = true, style, ...rest }) { return (
e.currentTarget.style.borderColor = "var(--ink)"} onBlur={(e) => e.currentTarget.style.borderColor = error ? "var(--neg)" : "var(--line)"}> {icon && {icon}} {suffix && {suffix}}
); } function Textarea({ value, onChange, placeholder, rows = 4, error, ...rest }) { return (