2025-09-12 16:47:02 +09:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
import React from "react";
|
|
|
|
|
import { ComponentRendererProps } from "@/types/component";
|
|
|
|
|
import { TestInputConfig } from "./types";
|
|
|
|
|
|
|
|
|
|
export interface TestInputComponentProps extends ComponentRendererProps {
|
|
|
|
|
config?: TestInputConfig;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* TestInput 컴포넌트
|
|
|
|
|
* 테스트용 입력 컴포넌트
|
|
|
|
|
*/
|
|
|
|
|
export const TestInputComponent: React.FC<TestInputComponentProps> = ({
|
|
|
|
|
component,
|
|
|
|
|
isDesignMode = false,
|
|
|
|
|
isSelected = false,
|
|
|
|
|
isInteractive = false,
|
|
|
|
|
onClick,
|
|
|
|
|
onDragStart,
|
|
|
|
|
onDragEnd,
|
|
|
|
|
config,
|
|
|
|
|
className,
|
|
|
|
|
style,
|
|
|
|
|
formData,
|
|
|
|
|
onFormDataChange,
|
|
|
|
|
screenId,
|
|
|
|
|
...props
|
|
|
|
|
}) => {
|
|
|
|
|
// 컴포넌트 설정
|
|
|
|
|
const componentConfig = {
|
|
|
|
|
...config,
|
|
|
|
|
...component.config,
|
|
|
|
|
} as TestInputConfig;
|
|
|
|
|
|
|
|
|
|
// 스타일 계산 (위치는 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,
|
|
|
|
|
...domProps
|
|
|
|
|
} = props;
|
|
|
|
|
|
2025-09-22 14:13:05 +09:00
|
|
|
return (
|
2025-09-12 16:47:02 +09:00
|
|
|
<div style={componentStyle} className={className} {...domProps}>
|
|
|
|
|
{/* 라벨 렌더링 */}
|
2025-09-22 14:13:05 +09:00
|
|
|
{component.label && component.style?.labelDisplay !== false && (
|
2025-09-12 16:47:02 +09:00
|
|
|
<label
|
|
|
|
|
style={{
|
|
|
|
|
position: "absolute",
|
|
|
|
|
top: "-25px",
|
|
|
|
|
left: "0px",
|
|
|
|
|
fontSize: component.style?.labelFontSize || "14px",
|
|
|
|
|
color: component.style?.labelColor || "#374151",
|
|
|
|
|
fontWeight: "500",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{component.label}
|
|
|
|
|
{component.required && <span style={{ color: "#ef4444" }}>*</span>}
|
|
|
|
|
</label>
|
|
|
|
|
)}
|
2025-09-22 14:13:05 +09:00
|
|
|
|
2025-09-12 16:47:02 +09:00
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
value={component.value || ""}
|
|
|
|
|
placeholder={componentConfig.placeholder || ""}
|
|
|
|
|
disabled={componentConfig.disabled || false}
|
|
|
|
|
required={componentConfig.required || false}
|
|
|
|
|
readOnly={componentConfig.readonly || false}
|
|
|
|
|
style={{
|
|
|
|
|
width: "100%",
|
|
|
|
|
height: "100%",
|
|
|
|
|
border: "1px solid #d1d5db",
|
|
|
|
|
borderRadius: "4px",
|
|
|
|
|
padding: "8px 12px",
|
|
|
|
|
fontSize: "14px",
|
|
|
|
|
outline: "none",
|
|
|
|
|
}}
|
|
|
|
|
onClick={handleClick}
|
|
|
|
|
onDragStart={onDragStart}
|
|
|
|
|
onDragEnd={onDragEnd}
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
if (domProps.onChange) {
|
|
|
|
|
domProps.onChange(e.target.value);
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* TestInput 래퍼 컴포넌트
|
|
|
|
|
* 추가적인 로직이나 상태 관리가 필요한 경우 사용
|
|
|
|
|
*/
|
|
|
|
|
export const TestInputWrapper: React.FC<TestInputComponentProps> = (props) => {
|
|
|
|
|
return <TestInputComponent {...props} />;
|
|
|
|
|
};
|