2026-01-30 10:51:33 +09:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
import React from "react";
|
|
|
|
|
import { AutoRegisteringComponentRenderer } from "../../AutoRegisteringComponentRenderer";
|
|
|
|
|
import { V2InputDefinition } from "./index";
|
|
|
|
|
import { V2Input } from "@/components/v2/V2Input";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* V2Input 렌더러
|
|
|
|
|
* 자동 등록 시스템을 사용하여 컴포넌트를 레지스트리에 등록
|
|
|
|
|
*/
|
|
|
|
|
export class V2InputRenderer extends AutoRegisteringComponentRenderer {
|
|
|
|
|
static componentDefinition = V2InputDefinition;
|
|
|
|
|
|
|
|
|
|
render(): React.ReactElement {
|
|
|
|
|
const { component, formData, onFormDataChange, isDesignMode, isSelected, isInteractive, ...restProps } = this.props;
|
|
|
|
|
|
|
|
|
|
// 컴포넌트 설정 추출
|
|
|
|
|
const config = component.componentConfig || component.config || {};
|
|
|
|
|
const columnName = component.columnName;
|
|
|
|
|
const tableName = component.tableName || this.props.tableName;
|
|
|
|
|
|
|
|
|
|
// formData에서 현재 값 가져오기
|
|
|
|
|
const currentValue = formData?.[columnName] ?? component.value ?? "";
|
|
|
|
|
|
|
|
|
|
// 값 변경 핸들러
|
|
|
|
|
const handleChange = (value: any) => {
|
|
|
|
|
if (isInteractive && onFormDataChange && columnName) {
|
|
|
|
|
onFormDataChange(columnName, value);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2026-02-03 11:02:13 +09:00
|
|
|
// 라벨: style.labelText 우선, 없으면 component.label 사용
|
2026-02-04 18:01:20 +09:00
|
|
|
// 🔧 style.labelDisplay를 먼저 체크 (속성 패널에서 style 객체로 업데이트하므로)
|
2026-02-03 11:02:13 +09:00
|
|
|
const style = component.style || {};
|
2026-02-04 18:01:20 +09:00
|
|
|
const labelDisplay = style.labelDisplay ?? (component as any).labelDisplay;
|
|
|
|
|
// labelDisplay: true → 라벨 표시, false → 숨김, undefined → 기존 동작 유지(숨김)
|
|
|
|
|
const effectiveLabel = labelDisplay === true ? (style.labelText || component.label) : undefined;
|
2026-02-03 11:02:13 +09:00
|
|
|
|
2026-01-30 10:51:33 +09:00
|
|
|
return (
|
|
|
|
|
<V2Input
|
|
|
|
|
id={component.id}
|
2026-02-03 11:02:13 +09:00
|
|
|
label={effectiveLabel}
|
2026-01-30 10:51:33 +09:00
|
|
|
required={component.required}
|
|
|
|
|
readonly={config.readonly || component.readonly}
|
|
|
|
|
disabled={config.disabled || component.disabled}
|
|
|
|
|
value={currentValue}
|
|
|
|
|
onChange={handleChange}
|
2026-02-03 11:02:13 +09:00
|
|
|
onFormDataChange={onFormDataChange}
|
2026-01-30 10:51:33 +09:00
|
|
|
config={{
|
|
|
|
|
type: config.inputType || config.webType || "text",
|
|
|
|
|
inputType: config.inputType || config.webType || "text",
|
|
|
|
|
placeholder: config.placeholder,
|
|
|
|
|
format: config.format,
|
|
|
|
|
min: config.min,
|
|
|
|
|
max: config.max,
|
|
|
|
|
step: config.step,
|
|
|
|
|
rows: config.rows,
|
|
|
|
|
autoGeneration: config.autoGeneration || component.autoGeneration,
|
|
|
|
|
}}
|
|
|
|
|
style={component.style}
|
|
|
|
|
size={component.size}
|
|
|
|
|
formData={formData}
|
|
|
|
|
columnName={columnName}
|
|
|
|
|
tableName={tableName}
|
|
|
|
|
autoGeneration={config.autoGeneration || component.autoGeneration}
|
|
|
|
|
originalData={(this.props as any).originalData}
|
|
|
|
|
{...restProps}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 자동 등록 실행
|
|
|
|
|
V2InputRenderer.registerSelf();
|
|
|
|
|
|
|
|
|
|
// Hot Reload 지원 (개발 모드)
|
|
|
|
|
if (process.env.NODE_ENV === "development") {
|
|
|
|
|
V2InputRenderer.enableHotReload();
|
|
|
|
|
}
|