Openstatus www.openstatus.dev
at main 48 lines 1.9 kB view raw
1import * as React from "react"; 2 3import { cn } from "@/lib/utils"; 4import { Input } from "../ui/input"; 5 6export interface InputWithAddonsProps 7 extends React.InputHTMLAttributes<HTMLInputElement> { 8 leading?: React.ReactNode; 9 trailing?: React.ReactNode; 10} 11 12// "file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", 13// "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]", 14// "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", 15 16const InputWithAddons = React.forwardRef< 17 HTMLInputElement, 18 InputWithAddonsProps 19>(({ leading, trailing, className, ...props }, ref) => { 20 return ( 21 <div className={cn("flex rounded-md shadow-xs", className)}> 22 {leading ? ( 23 <span className="inline-flex items-center rounded-s-md border border-input bg-muted px-3 text-muted-foreground text-sm"> 24 {leading} 25 </span> 26 ) : null} 27 <Input 28 ref={ref} 29 className={cn("z-1 shadow-none", { 30 "-ms-px rounded-s-none": leading, 31 "-me-px rounded-e-none": trailing, 32 })} 33 placeholder="google.com" 34 type="text" 35 {...props} 36 /> 37 {trailing ? ( 38 <span className="inline-flex items-center rounded-e-md border border-input bg-muted px-3 text-muted-foreground text-sm"> 39 {trailing} 40 </span> 41 ) : null} 42 </div> 43 ); 44}); 45 46InputWithAddons.displayName = "InputWithAddons"; 47 48export { InputWithAddons };