| 43 | ); |
| 44 | |
| 45 | function InputGroupAddon({ |
| 46 | className, |
| 47 | align = "inline-start", |
| 48 | ...props |
| 49 | }: React.ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>) { |
| 50 | return ( |
| 51 | <div |
| 52 | className={cn(inputGroupAddonVariants({ align }), className)} |
| 53 | data-align={align} |
| 54 | data-slot="input-group-addon" |
| 55 | onMouseDown={(e) => { |
| 56 | const target = e.target as HTMLElement; |
| 57 | const isInteractive = target.closest("button, a"); |
| 58 | if (isInteractive) return; |
| 59 | e.preventDefault(); |
| 60 | const parent = e.currentTarget.parentElement; |
| 61 | const input = parent?.querySelector< |
| 62 | HTMLInputElement | HTMLTextAreaElement |
| 63 | >("input, textarea"); |
| 64 | if (input && !parent?.querySelector("input:focus, textarea:focus")) { |
| 65 | input.focus(); |
| 66 | } |
| 67 | }} |
| 68 | {...props} |
| 69 | /> |
| 70 | ); |
| 71 | } |
| 72 | |
| 73 | function InputGroupText({ className, ...props }: React.ComponentProps<"span">) { |
| 74 | return ( |