"use client"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Button } from "@/components/ui/button"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { Calculator } from "lucide-react"; import { useReportDesigner } from "@/contexts/ReportDesignerContext"; import type { ComponentConfig } from "@/types/report"; interface Props { component: ComponentConfig; /** 우측 패널: "style" | 모달: "data" | 미전달: 전체 표시 (하위 호환) */ section?: "style" | "data"; } export function CalculationProperties({ component, section }: Props) { const { updateComponent, queries, getQueryResult } = useReportDesigner(); const showStyle = !section || section === "style"; const showData = !section || section === "data"; return ( <> {/* 표시 설정 — 우측 패널(section="style")에서 표시 */} {showStyle && (
표시 설정
{/* 라벨 너비 */}
updateComponent(component.id, { labelWidth: Number(e.target.value) })} min={60} max={200} className="h-9" />
{/* 숫자 포맷 */}
{/* 통화 접미사 */} {component.numberFormat === "currency" && (
updateComponent(component.id, { currencySuffix: e.target.value })} placeholder="원" className="h-9" />
)} {/* 폰트 크기 설정 */}
updateComponent(component.id, { labelFontSize: Number(e.target.value) })} min={10} max={20} className="h-9" />
updateComponent(component.id, { valueFontSize: Number(e.target.value) })} min={10} max={20} className="h-9" />
updateComponent(component.id, { resultFontSize: Number(e.target.value) })} min={12} max={24} className="h-9" />
{/* 색상 설정 */}
updateComponent(component.id, { labelColor: e.target.value })} className="h-9 w-full cursor-pointer p-1" />
updateComponent(component.id, { valueColor: e.target.value })} className="h-9 w-full cursor-pointer p-1" />
updateComponent(component.id, { resultColor: e.target.value })} className="h-9 w-full cursor-pointer p-1" />
)} {/* 계산 항목 — 모달(section="data")에서 표시 */} {showData && (
계산 항목
{/* 결과 라벨 */}
updateComponent(component.id, { resultLabel: e.target.value })} placeholder="합계 금액" className="h-9" />
{/* 쿼리 선택 (데이터 바인딩용) */}
{/* 계산 항목 목록 관리 */}
{/* 항목 리스트 — 개별 항목 카드(rounded border bg-white p-2)는 유지 */}
{(component.calcItems || []).map((item, index: number) => (
항목 {index + 1}
{ const currentItems = [...(component.calcItems || [])]; currentItems[index] = { ...currentItems[index], label: e.target.value }; updateComponent(component.id, { calcItems: currentItems }); }} className="h-6 text-xs" placeholder="항목명" />
{index > 0 && (
)}
{component.queryId ? (
) : (
{ const currentItems = [...(component.calcItems || [])]; currentItems[index] = { ...currentItems[index], value: Number(e.target.value), }; updateComponent(component.id, { calcItems: currentItems }); }} className="h-6 text-xs" placeholder="0" />
)}
))}
)} ); }