37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import * as React from 'react';
|
|
import { cn } from '@/lib/utils';
|
|
|
|
/**
|
|
* 标准 shadcn/ui Input 组件
|
|
* 遵循 shadcn/ui 规范:纯 input 元素 + data-slot + cn 工具
|
|
*
|
|
* 若需 label/error 属性,请使用 LabeledInput 组件
|
|
*/
|
|
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<'input'>>(
|
|
({ className, type, ...props }, ref) => {
|
|
return (
|
|
<input
|
|
type={type}
|
|
data-slot="input"
|
|
ref={ref}
|
|
className={cn(
|
|
'file:text-foreground placeholder:text-text-placeholder selection:bg-brand selection:text-white',
|
|
'flex h-11 w-full min-w-0 rounded-md border border-border-primary bg-bg-primary px-3 py-1 text-base',
|
|
'transition-all duration-fast outline-none',
|
|
'file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium',
|
|
'disabled:cursor-not-allowed disabled:opacity-50',
|
|
'md:text-sm',
|
|
'focus-visible:border-brand focus-visible:ring-2 focus-visible:ring-brand/30',
|
|
'hover:border-border-secondary',
|
|
'touch-manipulation',
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|
|
);
|
|
Input.displayName = 'Input';
|
|
|
|
export { Input };
|