2025-09-23 10:40:21 +09:00
|
|
|
/**
|
|
|
|
|
* 입력 타입 정의 (테이블 타입 관리 개선)
|
|
|
|
|
* 기존 웹 타입을 8개 핵심 입력 타입으로 단순화
|
|
|
|
|
*
|
|
|
|
|
* 주의: 이 파일을 수정할 때는 반드시 백엔드 타입도 함께 업데이트 해야 합니다.
|
|
|
|
|
*/
|
|
|
|
|
|
2025-11-05 15:23:57 +09:00
|
|
|
// 9개 핵심 입력 타입
|
2025-09-23 10:40:21 +09:00
|
|
|
export type InputType =
|
|
|
|
|
| "text" // 텍스트
|
|
|
|
|
| "number" // 숫자
|
|
|
|
|
| "date" // 날짜
|
|
|
|
|
| "code" // 코드
|
|
|
|
|
| "entity" // 엔티티
|
2025-11-05 15:23:57 +09:00
|
|
|
| "category" // 카테고리
|
2025-09-23 10:40:21 +09:00
|
|
|
| "select" // 선택박스
|
|
|
|
|
| "checkbox" // 체크박스
|
|
|
|
|
| "radio"; // 라디오버튼
|
|
|
|
|
|
|
|
|
|
// 입력 타입 옵션 정의
|
|
|
|
|
export interface InputTypeOption {
|
|
|
|
|
value: InputType;
|
|
|
|
|
label: string;
|
|
|
|
|
description: string;
|
|
|
|
|
category: InputTypeCategory;
|
|
|
|
|
icon?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 입력 타입 카테고리
|
|
|
|
|
export type InputTypeCategory =
|
|
|
|
|
| "basic" // 기본 입력 (text, number, date)
|
|
|
|
|
| "reference" // 참조 입력 (code, entity)
|
|
|
|
|
| "selection"; // 선택 입력 (select, checkbox, radio)
|
|
|
|
|
|
|
|
|
|
// 입력 타입 옵션 목록
|
|
|
|
|
export const INPUT_TYPE_OPTIONS: InputTypeOption[] = [
|
|
|
|
|
{
|
|
|
|
|
value: "text",
|
|
|
|
|
label: "텍스트",
|
|
|
|
|
description: "일반 텍스트 입력",
|
|
|
|
|
category: "basic",
|
|
|
|
|
icon: "Type",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: "number",
|
|
|
|
|
label: "숫자",
|
|
|
|
|
description: "숫자 입력 (정수/소수)",
|
|
|
|
|
category: "basic",
|
|
|
|
|
icon: "Hash",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: "date",
|
|
|
|
|
label: "날짜",
|
|
|
|
|
description: "날짜 선택",
|
|
|
|
|
category: "basic",
|
|
|
|
|
icon: "Calendar",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: "code",
|
|
|
|
|
label: "코드",
|
|
|
|
|
description: "공통코드 참조",
|
|
|
|
|
category: "reference",
|
|
|
|
|
icon: "Code",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: "entity",
|
|
|
|
|
label: "엔티티",
|
|
|
|
|
description: "다른 테이블 참조",
|
|
|
|
|
category: "reference",
|
|
|
|
|
icon: "Database",
|
|
|
|
|
},
|
2025-11-05 15:23:57 +09:00
|
|
|
{
|
|
|
|
|
value: "category",
|
|
|
|
|
label: "카테고리",
|
|
|
|
|
description: "메뉴별 카테고리 값 선택",
|
|
|
|
|
category: "reference",
|
|
|
|
|
icon: "FolderTree",
|
|
|
|
|
},
|
2025-09-23 10:40:21 +09:00
|
|
|
{
|
|
|
|
|
value: "select",
|
|
|
|
|
label: "선택박스",
|
|
|
|
|
description: "드롭다운 선택",
|
|
|
|
|
category: "selection",
|
|
|
|
|
icon: "ChevronDown",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: "checkbox",
|
|
|
|
|
label: "체크박스",
|
|
|
|
|
description: "체크박스 입력",
|
|
|
|
|
category: "selection",
|
|
|
|
|
icon: "CheckSquare",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: "radio",
|
|
|
|
|
label: "라디오버튼",
|
|
|
|
|
description: "단일 선택",
|
|
|
|
|
category: "selection",
|
|
|
|
|
icon: "Circle",
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// 카테고리별 입력 타입 그룹화
|
|
|
|
|
export const INPUT_TYPE_GROUPS = {
|
|
|
|
|
basic: INPUT_TYPE_OPTIONS.filter((option) => option.category === "basic"),
|
|
|
|
|
reference: INPUT_TYPE_OPTIONS.filter((option) => option.category === "reference"),
|
|
|
|
|
selection: INPUT_TYPE_OPTIONS.filter((option) => option.category === "selection"),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 입력 타입 검증 함수
|
|
|
|
|
export const isValidInputType = (inputType: string): inputType is InputType => {
|
|
|
|
|
return INPUT_TYPE_OPTIONS.some((option) => option.value === inputType);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 입력 타입 정보 조회
|
|
|
|
|
export const getInputTypeInfo = (inputType: InputType): InputTypeOption | undefined => {
|
|
|
|
|
return INPUT_TYPE_OPTIONS.find((option) => option.value === inputType);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 입력 타입별 기본 설정
|
|
|
|
|
export const INPUT_TYPE_DEFAULT_CONFIGS: Record<InputType, Record<string, any>> = {
|
|
|
|
|
text: {
|
|
|
|
|
maxLength: 500,
|
|
|
|
|
placeholder: "텍스트를 입력하세요",
|
|
|
|
|
},
|
|
|
|
|
number: {
|
|
|
|
|
min: 0,
|
|
|
|
|
step: 1,
|
|
|
|
|
placeholder: "숫자를 입력하세요",
|
|
|
|
|
},
|
|
|
|
|
date: {
|
|
|
|
|
format: "YYYY-MM-DD",
|
|
|
|
|
placeholder: "날짜를 선택하세요",
|
|
|
|
|
},
|
|
|
|
|
code: {
|
|
|
|
|
placeholder: "코드를 선택하세요",
|
|
|
|
|
searchable: true,
|
|
|
|
|
},
|
|
|
|
|
entity: {
|
|
|
|
|
placeholder: "항목을 선택하세요",
|
|
|
|
|
searchable: true,
|
|
|
|
|
},
|
2025-11-05 15:23:57 +09:00
|
|
|
category: {
|
|
|
|
|
placeholder: "카테고리를 선택하세요",
|
|
|
|
|
searchable: true,
|
|
|
|
|
},
|
2025-09-23 10:40:21 +09:00
|
|
|
select: {
|
|
|
|
|
placeholder: "선택하세요",
|
|
|
|
|
searchable: false,
|
|
|
|
|
},
|
|
|
|
|
checkbox: {
|
|
|
|
|
defaultChecked: false,
|
|
|
|
|
trueValue: "Y",
|
|
|
|
|
falseValue: "N",
|
|
|
|
|
},
|
|
|
|
|
radio: {
|
|
|
|
|
inline: false,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 레거시 웹 타입 → 입력 타입 매핑
|
|
|
|
|
export const WEB_TYPE_TO_INPUT_TYPE: Record<string, InputType> = {
|
|
|
|
|
// 텍스트 관련
|
|
|
|
|
text: "text",
|
|
|
|
|
textarea: "text",
|
|
|
|
|
email: "text",
|
|
|
|
|
tel: "text",
|
|
|
|
|
url: "text",
|
|
|
|
|
password: "text",
|
|
|
|
|
|
|
|
|
|
// 숫자 관련
|
|
|
|
|
number: "number",
|
|
|
|
|
decimal: "number",
|
|
|
|
|
|
|
|
|
|
// 날짜 관련
|
|
|
|
|
date: "date",
|
|
|
|
|
datetime: "date",
|
|
|
|
|
time: "date",
|
|
|
|
|
|
|
|
|
|
// 선택 관련
|
|
|
|
|
select: "select",
|
|
|
|
|
dropdown: "select",
|
|
|
|
|
checkbox: "checkbox",
|
|
|
|
|
boolean: "checkbox",
|
|
|
|
|
radio: "radio",
|
|
|
|
|
|
|
|
|
|
// 참조 관련
|
|
|
|
|
code: "code",
|
|
|
|
|
entity: "entity",
|
2025-11-05 15:23:57 +09:00
|
|
|
category: "category",
|
2025-09-23 10:40:21 +09:00
|
|
|
|
|
|
|
|
// 기타 (기본값: text)
|
|
|
|
|
file: "text",
|
|
|
|
|
button: "text",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 입력 타입 → 웹 타입 역매핑 (화면관리 시스템 호환용)
|
|
|
|
|
export const INPUT_TYPE_TO_WEB_TYPE: Record<InputType, string> = {
|
|
|
|
|
text: "text",
|
|
|
|
|
number: "number",
|
|
|
|
|
date: "date",
|
|
|
|
|
code: "code",
|
|
|
|
|
entity: "entity",
|
2025-11-05 15:23:57 +09:00
|
|
|
category: "category",
|
2025-09-23 10:40:21 +09:00
|
|
|
select: "select",
|
|
|
|
|
checkbox: "checkbox",
|
|
|
|
|
radio: "radio",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 입력 타입 변환 함수
|
|
|
|
|
export const convertWebTypeToInputType = (webType: string): InputType => {
|
|
|
|
|
return WEB_TYPE_TO_INPUT_TYPE[webType] || "text";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 입력 타입별 검증 규칙
|
|
|
|
|
export const INPUT_TYPE_VALIDATION_RULES: Record<InputType, Record<string, any>> = {
|
|
|
|
|
text: {
|
|
|
|
|
type: "string",
|
|
|
|
|
trim: true,
|
|
|
|
|
maxLength: 500,
|
|
|
|
|
},
|
|
|
|
|
number: {
|
|
|
|
|
type: "number",
|
|
|
|
|
allowFloat: true,
|
|
|
|
|
},
|
|
|
|
|
date: {
|
|
|
|
|
type: "date",
|
|
|
|
|
format: "YYYY-MM-DD",
|
|
|
|
|
},
|
|
|
|
|
code: {
|
|
|
|
|
type: "string",
|
|
|
|
|
required: false,
|
|
|
|
|
},
|
|
|
|
|
entity: {
|
|
|
|
|
type: "string",
|
|
|
|
|
required: false,
|
|
|
|
|
},
|
2025-11-05 15:23:57 +09:00
|
|
|
category: {
|
|
|
|
|
type: "string",
|
|
|
|
|
required: false,
|
|
|
|
|
},
|
2025-09-23 10:40:21 +09:00
|
|
|
select: {
|
|
|
|
|
type: "string",
|
|
|
|
|
options: true,
|
|
|
|
|
},
|
|
|
|
|
checkbox: {
|
|
|
|
|
type: "boolean",
|
|
|
|
|
values: ["Y", "N"],
|
|
|
|
|
},
|
|
|
|
|
radio: {
|
|
|
|
|
type: "string",
|
|
|
|
|
options: true,
|
|
|
|
|
},
|
|
|
|
|
};
|