"use client";

import { createComponentDefinition } from "../../utils/createComponentDefinition";
import { ComponentCategory } from "@/types/component";
import { ModalRepeaterTableComponent } from "./ModalRepeaterTableComponent";
import { ModalRepeaterTableConfigPanel } from "./ModalRepeaterTableConfigPanel";

/**
 * ModalRepeaterTable 컴포넌트 정의
 * 모달 검색 + 동적 테이블 (반복기)
 */
export const ModalRepeaterTableDefinition = createComponentDefinition({
  id: "modal-repeater-table",
  name: "모달 반복 테이블",
  nameEng: "Modal Repeater Table",
  description: "모달에서 항목을 검색하여 동적으로 추가/편집할 수 있는 테이블 (수주 품목 등)",
  category: ComponentCategory.DATA,
  webType: "table",
  component: ModalRepeaterTableComponent,
  defaultConfig: {
    sourceTable: "item_info",
    sourceColumns: ["item_code", "item_name", "size", "unit_price"],
    sourceSearchFields: ["item_code", "item_name"],
    modalTitle: "항목 검색 및 선택",
    modalButtonText: "항목 검색",
    multiSelect: true,
    columns: [],
    uniqueField: "item_code",
  },
  defaultSize: { width: 800, height: 400 },
  configPanel: ModalRepeaterTableConfigPanel,
  icon: "Table",
  tags: ["테이블", "반복", "동적", "모달", "수주", "품목"],
  version: "1.0.0",
  author: "개발팀",
});

// 타입 내보내기
export type {
  ModalRepeaterTableProps,
  RepeaterColumnConfig,
  CalculationRule,
  ItemSelectionModalProps,
} from "./types";

// 컴포넌트 내보내기
export { ModalRepeaterTableComponent } from "./ModalRepeaterTableComponent";
export { ModalRepeaterTableRenderer } from "./ModalRepeaterTableRenderer";
export { ItemSelectionModal } from "./ItemSelectionModal";
export { RepeaterTable } from "./RepeaterTable";
export { useCalculation } from "./useCalculation";

