"use client"; import React from "react"; import { ComponentRendererProps } from "@/types/component"; import { TextInputConfig } from "./types"; export interface TextInputComponentProps extends ComponentRendererProps { config?: TextInputConfig; } /** * TextInput 컴포넌트 * text-input 컴포넌트입니다 */ export const TextInputComponent: React.FC = ({ component, isDesignMode = false, isSelected = false, isInteractive = false, onClick, onDragStart, onDragEnd, config, className, style, formData, onFormDataChange, ...props }) => { // 컴포넌트 설정 const componentConfig = { ...config, ...component.config, } as TextInputConfig; console.log("🔧 텍스트 입력 컴포넌트 설정:", { config, componentConfig, component: component, }); // 스타일 계산 (위치는 RealtimePreviewDynamic에서 처리하므로 제외) const componentStyle: React.CSSProperties = { width: "100%", height: "100%", ...component.style, ...style, }; // 디자인 모드 스타일 if (isDesignMode) { componentStyle.border = "1px dashed #cbd5e1"; componentStyle.borderColor = isSelected ? "#3b82f6" : "#cbd5e1"; } // 이벤트 핸들러 const handleClick = (e: React.MouseEvent) => { e.stopPropagation(); onClick?.(); }; // DOM에 전달하면 안 되는 React-specific props 필터링 const { selectedScreen, onZoneComponentDrop, onZoneClick, componentConfig: _componentConfig, component: _component, isSelected: _isSelected, onClick: _onClick, onDragStart: _onDragStart, onDragEnd: _onDragEnd, size: _size, position: _position, style: _style, screenId: _screenId, tableName: _tableName, onRefresh: _onRefresh, onClose: _onClose, ...domProps } = props; return (
{/* 라벨 렌더링 */} {component.label && ( )} { const newValue = e.target.value; console.log(`🎯 TextInputComponent onChange 호출:`, { componentId: component.id, columnName: component.columnName, newValue, isInteractive, hasOnFormDataChange: !!onFormDataChange, hasOnChange: !!props.onChange, }); // isInteractive 모드에서는 formData 업데이트 if (isInteractive && onFormDataChange && component.columnName) { console.log(`📤 TextInputComponent -> onFormDataChange 호출: ${component.columnName} = "${newValue}"`); console.log(`🔍 onFormDataChange 함수 정보:`, { functionName: onFormDataChange.name, functionString: onFormDataChange.toString().substring(0, 200), }); onFormDataChange(component.columnName, newValue); } else { console.log(`❌ TextInputComponent onFormDataChange 조건 미충족:`, { isInteractive, hasOnFormDataChange: !!onFormDataChange, hasColumnName: !!component.columnName, }); } // 기존 onChange 핸들러도 호출 if (props.onChange) { console.log(`📤 TextInputComponent -> props.onChange 호출: "${newValue}"`); props.onChange(newValue); } }} />
); }; /** * TextInput 래퍼 컴포넌트 * 추가적인 로직이나 상태 관리가 필요한 경우 사용 */ export const TextInputWrapper: React.FC = (props) => { return ; };