'use client'; // ============================================================================= // Bộ thành phần giao diện dùng chung (Tailwind v4) // ============================================================================= import React, { createContext, useCallback, useContext, useEffect, useId, useRef, useState } from 'react'; import { createPortal } from 'react-dom'; import { AlertTriangle, CheckCircle2, Info, Loader2, X, XCircle } from 'lucide-react'; export function cn(...classes: (string | false | null | undefined)[]) { return classes.filter(Boolean).join(' '); } // ----------------------------------------------------------------------------- // Bố cục // ----------------------------------------------------------------------------- export function Card({ title, icon, actions, children, className, bodyClassName, }: { title?: React.ReactNode; icon?: React.ReactNode; actions?: React.ReactNode; children: React.ReactNode; className?: string; bodyClassName?: string; }) { return (
{(title || actions) && (

{icon} {title}

{actions &&
{actions}
}
)}
{children}
); } export function PageHeader({ title, description, actions }: { title: string; description?: string; actions?: React.ReactNode }) { return (

{title}

{description &&

{description}

}
{actions &&
{actions}
}
); } // ----------------------------------------------------------------------------- // Nút // ----------------------------------------------------------------------------- type ButtonVariant = 'primary' | 'secondary' | 'danger' | 'ghost' | 'success'; const buttonStyles: Record = { primary: 'bg-blue-600 text-white hover:bg-blue-700 shadow-xs', secondary: 'bg-white text-slate-700 border border-slate-300 hover:bg-slate-50', danger: 'bg-rose-600 text-white hover:bg-rose-700 shadow-xs', ghost: 'text-slate-600 hover:bg-slate-100', success: 'bg-emerald-600 text-white hover:bg-emerald-700 shadow-xs', }; export function Button({ variant = 'secondary', size = 'md', loading, icon, className, children, disabled, type = 'button', ...rest }: React.ButtonHTMLAttributes & { variant?: ButtonVariant; size?: 'sm' | 'md'; loading?: boolean; icon?: React.ReactNode; }) { return ( ); } export function IconButton({ label, className, children, tone = 'default', ...rest }: React.ButtonHTMLAttributes & { label: string; tone?: 'default' | 'danger' }) { return ( ); } // ----------------------------------------------------------------------------- // Ô nhập liệu // ----------------------------------------------------------------------------- const inputBase = 'w-full rounded-lg border border-slate-300 bg-white px-2.5 py-2 sm:py-1.5 text-base sm:text-sm text-slate-900 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-500 disabled:bg-slate-50 disabled:text-slate-500'; export function Field({ label, hint, error, children, className, htmlFor, }: { label?: React.ReactNode; hint?: React.ReactNode; error?: string | null; children: React.ReactNode; className?: string; htmlFor?: string; }) { return (
{label && ( )} {children} {error ?

{error}

: hint ?

{hint}

: null}
); } export const TextInput = React.forwardRef>(function TextInput( { className, ...rest }, ref ) { return ; }); export function Textarea({ className, ...rest }: React.TextareaHTMLAttributes) { return