The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { Field as FieldPrimitive } from "@base-ui/react/field"; |
| 2 | import { mergeProps } from "@base-ui/react/merge-props"; |
| 3 | import type * as React from "react"; |
| 4 | |
| 5 | import { cn } from "~/lib/utils"; |
| 6 | |
| 7 | type TextareaProps = React.ComponentProps<"textarea"> & { |
| 8 | size?: "sm" | "default" | "lg" | number; |
| 9 | unstyled?: boolean; |
| 10 | }; |
| 11 | |
| 12 | function Textarea({ |
| 13 | className, |
| 14 | size = "default", |
| 15 | unstyled = false, |
| 16 | rows, |
| 17 | ...props |
| 18 | }: TextareaProps) { |
| 19 | return ( |
| 20 | <span |
| 21 | className={ |
| 22 | cn( |
| 23 | !unstyled && |
| 24 | "relative inline-flex w-full rounded-lg border border-input bg-background not-dark:bg-clip-padding text-base text-foreground shadow-xs/5 ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] has-focus-visible:has-aria-invalid:border-destructive/64 has-focus-visible:has-aria-invalid:ring-destructive/16 has-aria-invalid:border-destructive/36 has-focus-visible:border-ring has-disabled:opacity-64 has-[:disabled,:focus-visible,[aria-invalid]]:shadow-none has-focus-visible:ring-[3px] has-focus-visible:ring-inset not-has-disabled:has-not-focus-visible:not-has-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] sm:text-sm dark:bg-input/32 dark:has-aria-invalid:ring-destructive/24 dark:not-has-disabled:has-not-focus-visible:not-has-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/6%)]", |
| 25 | className, |
| 26 | ) || undefined |
| 27 | } |
| 28 | data-size={size} |
| 29 | data-slot="textarea-control" |
| 30 | > |
| 31 | <FieldPrimitive.Control |
| 32 | render={(defaultProps) => ( |
| 33 | <textarea |
| 34 | className={cn( |
| 35 | "field-sizing-content max-h-64 w-full rounded-[inherit] px-[calc(--spacing(3)-1px)] py-[calc(--spacing(1.5)-1px)] outline-none wrap-anywhere", |
| 36 | rows === undefined && "min-h-17.5 max-sm:min-h-20.5", |
| 37 | size === "sm" && "px-[calc(--spacing(2.5)-1px)] py-[calc(--spacing(1)-1px)]", |
| 38 | size === "sm" && rows === undefined && "min-h-16.5 max-sm:min-h-19.5", |
| 39 | size === "lg" && "py-[calc(--spacing(2)-1px)]", |
| 40 | size === "lg" && rows === undefined && "min-h-18.5 max-sm:min-h-21.5", |
| 41 | )} |
| 42 | // field-sizing: content ignores `rows`, so an explicit row count sets the minimum height. |
| 43 | style={ |
| 44 | rows === undefined |
| 45 | ? undefined |
| 46 | : { |
| 47 | minHeight: `calc(${rows}lh + 2 * (var(--spacing) * ${size === "sm" ? 1 : size === "lg" ? 2 : 1.5} - 1px))`, |
| 48 | } |
| 49 | } |
| 50 | data-slot="textarea" |
| 51 | rows={rows} |
| 52 | {...mergeProps(defaultProps, props)} |
| 53 | /> |
| 54 | )} |
| 55 | /> |
| 56 | </span> |
| 57 | ); |
| 58 | } |
| 59 | |
| 60 | export { Textarea, type TextareaProps }; |