2026-04-18 18:51:53 +00:00
|
|
|
import * as React from "react";
|
|
|
|
|
|
2026-08-11 00:00:22 +08:00
|
|
|
import { formControlFocusClassName } from "@/components/ui/form-control";
|
2026-04-18 18:51:53 +00:00
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
|
|
2026-10-11 04:30:43 +08:00
|
|
|
type InputProps = React.InputHTMLAttributes<HTMLInputElement> & {
|
|
|
|
|
variant?: "default" | "search";
|
|
|
|
|
};
|
2026-04-18 18:51:53 +00:00
|
|
|
|
|
|
|
|
const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
2026-10-11 04:30:43 +08:00
|
|
|
({ className, type, variant = "default", ...props }, ref) => {
|
2026-04-18 18:51:53 +00:00
|
|
|
return (
|
|
|
|
|
<input
|
|
|
|
|
type={type}
|
|
|
|
|
className={cn(
|
2026-10-20 16:33:05 +08:00
|
|
|
"touch-text-input flex h-10 w-full rounded-full border border-input bg-background px-3 py-2 text-ui-body file:border-0 file:bg-transparent file:text-control-label placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
2026-10-11 04:30:43 +08:00
|
|
|
variant === "search" || type === "search"
|
|
|
|
|
? "focus:outline-none" : formControlFocusClassName,
|
2026-04-18 18:51:53 +00:00
|
|
|
className,
|
|
|
|
|
)}
|
|
|
|
|
ref={ref}
|
|
|
|
|
{...props}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
Input.displayName = "Input";
|
|
|
|
|
|
2026-10-11 04:30:43 +08:00
|
|
|
const SearchInput = React.forwardRef<HTMLInputElement, Omit<InputProps, "variant">>(
|
|
|
|
|
(props, ref) => <Input {...props} ref={ref} variant="search" />,
|
|
|
|
|
);
|
|
|
|
|
SearchInput.displayName = "SearchInput";
|
|
|
|
|
|
|
|
|
|
export { Input, SearchInput };
|