"use client"; import React from "react"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Checkbox } from "@/components/ui/checkbox"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { TextInputConfig } from "./types"; import { AutoGenerationType, AutoGenerationConfig } from "@/types/screen"; import { AutoGenerationUtils } from "@/lib/utils/autoGeneration"; export interface TextInputConfigPanelProps { config: TextInputConfig; onChange: (config: Partial) => void; } /** * TextInput 설정 패널 * 컴포넌트의 설정값들을 편집할 수 있는 UI 제공 */ export const TextInputConfigPanel: React.FC = ({ config, onChange }) => { const handleChange = (key: keyof TextInputConfig, value: any) => { onChange({ [key]: value }); }; return (
text-input 설정
{/* 텍스트 관련 설정 */}
handleChange("placeholder", e.target.value)} />
handleChange("maxLength", parseInt(e.target.value) || undefined)} />
{/* 구분선 */}
고급 기능
{/* 숨김 기능 */}
handleChange("hidden", checked)} />
{/* 자동생성 기능 */}
{ const currentConfig = config.autoGeneration || { type: "none", enabled: false }; handleChange("autoGeneration", { ...currentConfig, enabled: checked as boolean, }); }} />
{/* 자동생성 타입 선택 */} {config.autoGeneration?.enabled && (
{/* 선택된 타입 설명 */} {config.autoGeneration?.type && config.autoGeneration.type !== "none" && (
{AutoGenerationUtils.getTypeDescription(config.autoGeneration.type)}
)}
)} {/* 자동생성 옵션 */} {config.autoGeneration?.enabled && config.autoGeneration?.type && ["random_string", "random_number", "sequence"].includes(config.autoGeneration.type) && (
{/* 길이 설정 (랜덤 문자열/숫자용) */} {["random_string", "random_number"].includes(config.autoGeneration.type) && (
{ const currentConfig = config.autoGeneration!; handleChange("autoGeneration", { ...currentConfig, options: { ...currentConfig.options, length: parseInt(e.target.value) || 8, }, }); }} />
)} {/* 접두사 */}
{ const currentConfig = config.autoGeneration!; handleChange("autoGeneration", { ...currentConfig, options: { ...currentConfig.options, prefix: e.target.value, }, }); }} />
{/* 접미사 */}
{ const currentConfig = config.autoGeneration!; handleChange("autoGeneration", { ...currentConfig, options: { ...currentConfig.options, suffix: e.target.value, }, }); }} />
{/* 미리보기 */}
{AutoGenerationUtils.generatePreviewValue(config.autoGeneration)}
)}
); };