"use client"; import React, { useState, useEffect } from "react"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Switch } from "@/components/ui/switch"; import { Textarea } from "@/components/ui/textarea"; import { Slider } from "@/components/ui/slider"; import { AlignLeft } from "lucide-react"; import { WebTypeConfigPanelProps } from "@/lib/registry/types"; import { WidgetComponent, TextareaTypeConfig } from "@/types/screen"; export const TextareaConfigPanel: React.FC = ({ component, onUpdateComponent, onUpdateProperty, }) => { const widget = component as WidgetComponent; const config = (widget.webTypeConfig as TextareaTypeConfig) || {}; // 로컬 상태 const [localConfig, setLocalConfig] = useState({ rows: config.rows || 4, cols: config.cols || undefined, minLength: config.minLength || undefined, maxLength: config.maxLength || undefined, placeholder: config.placeholder || "", defaultValue: config.defaultValue || "", required: config.required || false, readonly: config.readonly || false, resizable: config.resizable !== false, // 기본값 true autoHeight: config.autoHeight || false, showCharCount: config.showCharCount || false, wrap: config.wrap || "soft", }); // 컴포넌트 변경 시 로컬 상태 동기화 useEffect(() => { const currentConfig = (widget.webTypeConfig as TextareaTypeConfig) || {}; setLocalConfig({ rows: currentConfig.rows || 4, cols: currentConfig.cols || undefined, minLength: currentConfig.minLength || undefined, maxLength: currentConfig.maxLength || undefined, placeholder: currentConfig.placeholder || "", defaultValue: currentConfig.defaultValue || "", required: currentConfig.required || false, readonly: currentConfig.readonly || false, resizable: currentConfig.resizable !== false, autoHeight: currentConfig.autoHeight || false, showCharCount: currentConfig.showCharCount || false, wrap: currentConfig.wrap || "soft", }); }, [widget.webTypeConfig]); // 설정 업데이트 핸들러 const updateConfig = (field: keyof TextareaTypeConfig, value: any) => { const newConfig = { ...localConfig, [field]: value }; setLocalConfig(newConfig); onUpdateProperty("webTypeConfig", newConfig); }; // 현재 문자 수 계산 const currentCharCount = (localConfig.defaultValue || "").length; const isOverLimit = localConfig.maxLength ? currentCharCount > localConfig.maxLength : false; return ( 텍스트영역 설정 여러 줄 텍스트 입력 영역의 세부 설정을 관리합니다. {/* 기본 설정 */}

기본 설정

updateConfig("placeholder", e.target.value)} placeholder="내용을 입력하세요" className="text-xs" />