45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
'use client';
|
|
|
|
import { Input } from '@/components/ui/input';
|
|
import type { FieldConfig } from '@/types/invyone-component';
|
|
|
|
interface TextareaFieldProps {
|
|
field: FieldConfig;
|
|
value: any;
|
|
onChange: (value: any) => void;
|
|
mode: 'form' | 'search';
|
|
disabled?: boolean;
|
|
error?: string;
|
|
}
|
|
|
|
export function TextareaField({ field, value, onChange, mode, disabled, error }: TextareaFieldProps) {
|
|
if (mode === 'search') {
|
|
// 검색: 일반 텍스트 입력 (부분 일치)
|
|
return (
|
|
<Input
|
|
type="text"
|
|
value={value ?? ''}
|
|
onChange={(e) => onChange(e.target.value || undefined)}
|
|
placeholder={field.placeholder ?? field.label}
|
|
disabled={disabled}
|
|
className={`h-7 text-xs ${error ? 'border-destructive' : ''}`}
|
|
/>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<textarea
|
|
value={value ?? ''}
|
|
onChange={(e) => onChange(e.target.value)}
|
|
placeholder={field.placeholder ?? field.label}
|
|
disabled={disabled}
|
|
rows={3}
|
|
className={`flex w-full rounded-md border bg-transparent px-3 py-2 text-xs
|
|
placeholder:text-muted-foreground
|
|
focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]
|
|
disabled:cursor-not-allowed disabled:opacity-50 outline-none
|
|
${error ? 'border-destructive' : 'border-input'}`}
|
|
/>
|
|
);
|
|
}
|