91 lines
3.6 KiB
TypeScript
91 lines
3.6 KiB
TypeScript
|
|
"use client";
|
||
|
|
|
||
|
|
import React from "react";
|
||
|
|
import { Label } from "@/components/ui/label";
|
||
|
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||
|
|
import { Slider } from "@/components/ui/slider";
|
||
|
|
import { Switch } from "@/components/ui/switch";
|
||
|
|
import { SplitPanelLayoutConfig } from "../types";
|
||
|
|
|
||
|
|
export interface CommonConfigTabProps {
|
||
|
|
config: SplitPanelLayoutConfig;
|
||
|
|
onChange?: (key: string, value: any) => void;
|
||
|
|
updateConfig: (updates: Partial<SplitPanelLayoutConfig>) => void;
|
||
|
|
updateRightPanel: (updates: Partial<SplitPanelLayoutConfig["rightPanel"]>) => void;
|
||
|
|
}
|
||
|
|
|
||
|
|
export const CommonConfigTab: React.FC<CommonConfigTabProps> = ({
|
||
|
|
config,
|
||
|
|
updateConfig,
|
||
|
|
updateRightPanel,
|
||
|
|
}) => {
|
||
|
|
const relationshipType = config.rightPanel?.relation?.type || "detail";
|
||
|
|
|
||
|
|
return (
|
||
|
|
<div className="space-y-6">
|
||
|
|
{/* 관계 타입 선택 */}
|
||
|
|
<div className="space-y-3 rounded-lg border border-border/50 bg-muted/40 p-4">
|
||
|
|
<h3 className="border-l-2 border-l-primary/40 pl-2 text-sm font-semibold">우측 패널 표시 방식</h3>
|
||
|
|
<p className="text-muted-foreground text-xs">좌측 항목 선택 시 우측에 어떤 형태로 데이터를 보여줄지 설정합니다</p>
|
||
|
|
<Select
|
||
|
|
value={relationshipType}
|
||
|
|
onValueChange={(value: "join" | "detail") => {
|
||
|
|
updateRightPanel({
|
||
|
|
relation: { ...config.rightPanel?.relation, type: value },
|
||
|
|
});
|
||
|
|
}}
|
||
|
|
>
|
||
|
|
<SelectTrigger className="h-10 bg-white">
|
||
|
|
<SelectValue placeholder="표시 방식 선택">
|
||
|
|
{relationshipType === "detail" ? "선택 시 표시" : "연관 목록"}
|
||
|
|
</SelectValue>
|
||
|
|
</SelectTrigger>
|
||
|
|
<SelectContent>
|
||
|
|
<SelectItem value="detail">
|
||
|
|
<div className="flex flex-col py-1">
|
||
|
|
<span className="text-sm font-medium">선택 시 표시</span>
|
||
|
|
<span className="text-xs text-gray-500">좌측 선택 시에만 우측 데이터 표시 / 미선택 시 빈 화면</span>
|
||
|
|
</div>
|
||
|
|
</SelectItem>
|
||
|
|
<SelectItem value="join">
|
||
|
|
<div className="flex flex-col py-1">
|
||
|
|
<span className="text-sm font-medium">연관 목록</span>
|
||
|
|
<span className="text-xs text-gray-500">미선택 시 전체 표시 / 좌측 선택 시 필터링</span>
|
||
|
|
</div>
|
||
|
|
</SelectItem>
|
||
|
|
</SelectContent>
|
||
|
|
</Select>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
{/* 레이아웃 설정 */}
|
||
|
|
<div className="space-y-4 rounded-lg border border-border/50 bg-muted/40 p-4">
|
||
|
|
<h3 className="border-l-2 border-l-primary/40 pl-2 text-sm font-semibold">레이아웃</h3>
|
||
|
|
<div className="space-y-2">
|
||
|
|
<Label>좌측 패널 너비: {config.splitRatio || 30}%</Label>
|
||
|
|
<Slider
|
||
|
|
value={[config.splitRatio || 30]}
|
||
|
|
onValueChange={(value) => updateConfig({ splitRatio: value[0] })}
|
||
|
|
min={20}
|
||
|
|
max={80}
|
||
|
|
step={5}
|
||
|
|
/>
|
||
|
|
</div>
|
||
|
|
<div className="flex items-center justify-between">
|
||
|
|
<Label>크기 조절 가능</Label>
|
||
|
|
<Switch
|
||
|
|
checked={config.resizable ?? true}
|
||
|
|
onCheckedChange={(checked) => updateConfig({ resizable: checked })}
|
||
|
|
/>
|
||
|
|
</div>
|
||
|
|
<div className="flex items-center justify-between">
|
||
|
|
<Label>자동 데이터 로드</Label>
|
||
|
|
<Switch
|
||
|
|
checked={config.autoLoad ?? true}
|
||
|
|
onCheckedChange={(checked) => updateConfig({ autoLoad: checked })}
|
||
|
|
/>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
};
|