import * as React from "react"; import { cn } from "@/lib/utils"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; /** * ColorPicker — WealthX Design System * * Popover-based color picker with preset swatches and a hex input field. * Designed for tenant white-label brand color configuration. * * Figma: https://www.figma.com/design/9V9F0NGVsif8LGmEhVjOcT/Design-System---shadcn */ // --------------------------------------------------------------------------- // Preset palettes // --------------------------------------------------------------------------- export const COLOR_PICKER_PRESETS = [ // Blues "#1E40AF", "#2563EB", "#3B82F6", "#60A5FA", // Purples "#7C3AED", "#8B5CF6", "#A78BFA", "#C4B5FD", // Greens "#15803D", "#16A34A", "#22C55E", "#4ADE80", // Reds "#B91C1C", "#DC2626", "#EF4444", "#F87171", // Oranges "#C2410C", "#EA580C", "#F97316", "#FB923C", // Teals "#0F766E", "#0D9488", "#14B8A6", "#2DD4BF", // Neutrals "#111827", "#374151", "#6B7280", "#D1D5DB", ]; // --------------------------------------------------------------------------- // Utility // --------------------------------------------------------------------------- /** Returns true if the string is a valid 6-digit or 3-digit hex color. */ function isValidHex(value: string): boolean { return /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(value); } /** Ensures value always has a leading `#`. */ function normalizeHex(value: string): string { const stripped = value.replace(/^#/, ""); return `#${stripped}`; } // --------------------------------------------------------------------------- // ColorSwatch // --------------------------------------------------------------------------- interface ColorSwatchProps { color: string; selected?: boolean; size?: "sm" | "md"; onClick?: (color: string) => void; className?: string; } function ColorSwatch({ color, selected, size = "md", onClick, className, }: ColorSwatchProps) { return (