[agent-pipeline] pipe-20260311122226-4dkx round-3
This commit is contained in:
parent
b2d3c6c688
commit
a36bcceef3
|
|
@ -2,16 +2,78 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* V2Group 설정 패널
|
* V2Group 설정 패널
|
||||||
* 통합 그룹 컴포넌트의 세부 설정을 관리합니다.
|
* 토스식 단계별 UX: 그룹 타입 카드 선택 -> 타입별 설정 -> 고급 설정(접힘)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from "react";
|
import React, { useState } from "react";
|
||||||
import { Label } from "@/components/ui/label";
|
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
import {
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from "@/components/ui/select";
|
||||||
|
import { Switch } from "@/components/ui/switch";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Plus, Trash2 } from "lucide-react";
|
import {
|
||||||
|
Collapsible,
|
||||||
|
CollapsibleContent,
|
||||||
|
CollapsibleTrigger,
|
||||||
|
} from "@/components/ui/collapsible";
|
||||||
|
import {
|
||||||
|
LayoutList,
|
||||||
|
Rows3,
|
||||||
|
ChevronsDownUp,
|
||||||
|
SquareStack,
|
||||||
|
AppWindow,
|
||||||
|
FileInput,
|
||||||
|
Settings,
|
||||||
|
ChevronDown,
|
||||||
|
Plus,
|
||||||
|
Trash2,
|
||||||
|
} from "lucide-react";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
// ─── 그룹 타입 카드 정의 ───
|
||||||
|
const GROUP_TYPE_CARDS = [
|
||||||
|
{
|
||||||
|
value: "section",
|
||||||
|
icon: LayoutList,
|
||||||
|
title: "섹션",
|
||||||
|
description: "기본 영역 구분이에요",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "tabs",
|
||||||
|
icon: Rows3,
|
||||||
|
title: "탭",
|
||||||
|
description: "탭으로 내용을 나눠요",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "accordion",
|
||||||
|
icon: ChevronsDownUp,
|
||||||
|
title: "아코디언",
|
||||||
|
description: "접었다 펼 수 있어요",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "card",
|
||||||
|
icon: SquareStack,
|
||||||
|
title: "카드 섹션",
|
||||||
|
description: "카드 형태로 묶어요",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "modal",
|
||||||
|
icon: AppWindow,
|
||||||
|
title: "모달",
|
||||||
|
description: "팝업으로 표시해요",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "form-modal",
|
||||||
|
icon: FileInput,
|
||||||
|
title: "폼 모달",
|
||||||
|
description: "입력 폼 팝업이에요",
|
||||||
|
},
|
||||||
|
] as const;
|
||||||
|
|
||||||
interface V2GroupConfigPanelProps {
|
interface V2GroupConfigPanelProps {
|
||||||
config: Record<string, any>;
|
config: Record<string, any>;
|
||||||
|
|
@ -22,10 +84,17 @@ export const V2GroupConfigPanel: React.FC<V2GroupConfigPanelProps> = ({
|
||||||
config,
|
config,
|
||||||
onChange,
|
onChange,
|
||||||
}) => {
|
}) => {
|
||||||
|
const [advancedOpen, setAdvancedOpen] = useState(false);
|
||||||
|
|
||||||
const updateConfig = (field: string, value: any) => {
|
const updateConfig = (field: string, value: any) => {
|
||||||
onChange({ ...config, [field]: value });
|
onChange({ ...config, [field]: value });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const currentGroupType = config.groupType || config.type || "section";
|
||||||
|
const isSectionType = currentGroupType === "section" || currentGroupType === "accordion";
|
||||||
|
const isModalType = currentGroupType === "modal" || currentGroupType === "form-modal";
|
||||||
|
const isTabsType = currentGroupType === "tabs";
|
||||||
|
|
||||||
const tabs = config.tabs || [];
|
const tabs = config.tabs || [];
|
||||||
|
|
||||||
const addTab = () => {
|
const addTab = () => {
|
||||||
|
|
@ -45,138 +114,165 @@ export const V2GroupConfigPanel: React.FC<V2GroupConfigPanelProps> = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-1">
|
<div className="space-y-4">
|
||||||
{/* GROUP TYPE 섹션 */}
|
{/* ─── 1단계: 그룹 타입 선택 (카드) ─── */}
|
||||||
<div className="border-b border-border/50 pb-3 mb-3">
|
<div className="space-y-2">
|
||||||
<h4 className="text-[10px] font-semibold uppercase tracking-wider text-muted-foreground py-2">GROUP TYPE</h4>
|
<p className="text-sm font-medium">어떤 방식으로 영역을 구성하나요?</p>
|
||||||
<div className="flex items-center justify-between py-1.5">
|
<div className="grid grid-cols-3 gap-2">
|
||||||
<span className="text-xs text-muted-foreground">그룹 타입</span>
|
{GROUP_TYPE_CARDS.map((card) => {
|
||||||
<div className="w-[140px]">
|
const Icon = card.icon;
|
||||||
<Select
|
const isSelected = currentGroupType === card.value;
|
||||||
value={config.groupType || config.type || "section"}
|
return (
|
||||||
onValueChange={(value) => updateConfig("groupType", value)}
|
<button
|
||||||
>
|
key={card.value}
|
||||||
<SelectTrigger className="h-7 text-xs">
|
type="button"
|
||||||
<SelectValue placeholder="타입 선택" />
|
onClick={() => updateConfig("groupType", card.value)}
|
||||||
</SelectTrigger>
|
className={cn(
|
||||||
<SelectContent>
|
"flex flex-col items-center justify-center rounded-lg border p-3 text-center transition-all min-h-[80px]",
|
||||||
<SelectItem value="section">섹션</SelectItem>
|
isSelected
|
||||||
<SelectItem value="tabs">탭</SelectItem>
|
? "border-primary bg-primary/5 ring-1 ring-primary/20"
|
||||||
<SelectItem value="accordion">아코디언</SelectItem>
|
: "border-border hover:border-primary/50 hover:bg-muted/50",
|
||||||
<SelectItem value="card">카드 섹션</SelectItem>
|
)}
|
||||||
<SelectItem value="modal">모달</SelectItem>
|
>
|
||||||
<SelectItem value="form-modal">폼 모달</SelectItem>
|
<Icon className="h-5 w-5 mb-1.5 text-primary" />
|
||||||
</SelectContent>
|
<span className="text-xs font-medium leading-tight">
|
||||||
</Select>
|
{card.title}
|
||||||
</div>
|
</span>
|
||||||
|
<span className="text-[10px] text-muted-foreground leading-tight mt-0.5">
|
||||||
|
{card.description}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* TITLE 섹션 */}
|
{/* ─── 2단계: 기본 설정 ─── */}
|
||||||
<div className="border-b border-border/50 pb-3 mb-3">
|
<div className="rounded-lg border bg-muted/30 p-4 space-y-3">
|
||||||
<h4 className="text-[10px] font-semibold uppercase tracking-wider text-muted-foreground py-2">TITLE</h4>
|
<span className="text-sm font-medium">기본 설정</span>
|
||||||
|
|
||||||
<div className="flex items-center justify-between py-1.5">
|
<div className="flex items-center justify-between py-1.5">
|
||||||
<span className="text-xs text-muted-foreground">제목</span>
|
<span className="text-xs text-muted-foreground">제목</span>
|
||||||
<div className="w-[140px]">
|
<Input
|
||||||
<Input
|
value={config.title || ""}
|
||||||
value={config.title || ""}
|
onChange={(e) => updateConfig("title", e.target.value)}
|
||||||
onChange={(e) => updateConfig("title", e.target.value)}
|
placeholder="그룹 제목"
|
||||||
placeholder="그룹 제목"
|
className="h-8 w-[180px] text-sm"
|
||||||
className="h-7 text-xs"
|
/>
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* TABS 섹션 - 탭 타입일 때만 */}
|
{/* ─── 3단계: 타입별 설정 ─── */}
|
||||||
{config.groupType === "tabs" && (
|
|
||||||
<div className="border-b border-border/50 pb-3 mb-3">
|
{/* 탭 타입: 탭 목록 관리 */}
|
||||||
<div className="flex items-center justify-between py-2">
|
{isTabsType && (
|
||||||
<h4 className="text-[10px] font-semibold uppercase tracking-wider text-muted-foreground">TABS</h4>
|
<div className="rounded-lg border bg-muted/30 p-4 space-y-3">
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Rows3 className="h-4 w-4 text-primary" />
|
||||||
|
<span className="text-sm font-medium">탭 목록</span>
|
||||||
|
</div>
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
variant="ghost"
|
variant="outline"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={addTab}
|
onClick={addTab}
|
||||||
className="h-6 px-2 text-xs"
|
className="h-7 px-2 text-xs"
|
||||||
>
|
>
|
||||||
<Plus className="h-3 w-3 mr-1" />
|
<Plus className="mr-1 h-3 w-3" />
|
||||||
추가
|
추가
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1.5 max-h-40 overflow-y-auto">
|
|
||||||
{tabs.map((tab: any, index: number) => (
|
{tabs.length > 0 ? (
|
||||||
<div key={index} className="flex items-center gap-1.5">
|
<div className="max-h-40 space-y-1.5 overflow-y-auto">
|
||||||
<Input
|
{tabs.map((tab: any, index: number) => (
|
||||||
value={tab.id || ""}
|
<div key={index} className="flex items-center gap-1.5">
|
||||||
onChange={(e) => updateTab(index, "id", e.target.value)}
|
<Input
|
||||||
placeholder="ID"
|
value={tab.id || ""}
|
||||||
className="h-7 text-xs flex-1"
|
onChange={(e) => updateTab(index, "id", e.target.value)}
|
||||||
/>
|
placeholder="ID"
|
||||||
<Input
|
className="h-8 flex-1 text-sm"
|
||||||
value={tab.label || ""}
|
/>
|
||||||
onChange={(e) => updateTab(index, "label", e.target.value)}
|
<Input
|
||||||
placeholder="라벨"
|
value={tab.label || ""}
|
||||||
className="h-7 text-xs flex-1"
|
onChange={(e) => updateTab(index, "label", e.target.value)}
|
||||||
/>
|
placeholder="라벨"
|
||||||
<Button
|
className="h-8 flex-1 text-sm"
|
||||||
type="button"
|
/>
|
||||||
variant="ghost"
|
<Button
|
||||||
size="sm"
|
type="button"
|
||||||
onClick={() => removeTab(index)}
|
variant="ghost"
|
||||||
className="h-7 w-7 p-0 text-destructive"
|
size="icon"
|
||||||
>
|
onClick={() => removeTab(index)}
|
||||||
<Trash2 className="h-3 w-3" />
|
className="text-destructive h-8 w-8 shrink-0"
|
||||||
</Button>
|
>
|
||||||
</div>
|
<Trash2 className="h-4 w-4" />
|
||||||
))}
|
</Button>
|
||||||
{tabs.length === 0 && (
|
</div>
|
||||||
<p className="text-xs text-muted-foreground text-center py-2">
|
))}
|
||||||
탭을 추가해주세요
|
</div>
|
||||||
</p>
|
) : (
|
||||||
)}
|
<div className="text-center py-6 text-muted-foreground">
|
||||||
</div>
|
<Rows3 className="mx-auto mb-2 h-8 w-8 opacity-30" />
|
||||||
|
<p className="text-sm">아직 탭이 없어요</p>
|
||||||
|
<p className="text-xs mt-0.5">위의 추가 버튼으로 탭을 만들어보세요</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* SECTION OPTIONS 섹션 - 섹션/아코디언일 때 */}
|
{/* 섹션/아코디언 타입: 접기/펴기 옵션 */}
|
||||||
{(config.groupType === "section" || config.groupType === "accordion" || !config.groupType) && (
|
{isSectionType && (
|
||||||
<div className="border-b border-border/50 pb-3 mb-3">
|
<div className="space-y-2">
|
||||||
<h4 className="text-[10px] font-semibold uppercase tracking-wider text-muted-foreground py-2">SECTION OPTIONS</h4>
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<div>
|
||||||
<div className="flex items-center justify-between py-1.5">
|
<p className="text-sm">접기/펴기</p>
|
||||||
<span className="text-xs text-muted-foreground">접기/펴기 가능</span>
|
<p className="text-[11px] text-muted-foreground">
|
||||||
<Checkbox
|
사용자가 섹션을 접었다 펼 수 있어요
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
checked={config.collapsible || false}
|
checked={config.collapsible || false}
|
||||||
onCheckedChange={(checked) => updateConfig("collapsible", checked)}
|
onCheckedChange={(checked) => updateConfig("collapsible", checked)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{config.collapsible && (
|
{config.collapsible && (
|
||||||
<div className="flex items-center justify-between py-1.5">
|
<div className="ml-4 border-l-2 border-primary/20 pl-3">
|
||||||
<span className="text-xs text-muted-foreground">기본으로 펼침</span>
|
<div className="flex items-center justify-between py-1">
|
||||||
<Checkbox
|
<div>
|
||||||
checked={config.defaultOpen !== false}
|
<p className="text-sm">기본으로 펼침</p>
|
||||||
onCheckedChange={(checked) => updateConfig("defaultOpen", checked)}
|
<p className="text-[11px] text-muted-foreground">
|
||||||
/>
|
처음에 펼쳐진 상태로 보여줘요
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
|
checked={config.defaultOpen !== false}
|
||||||
|
onCheckedChange={(checked) => updateConfig("defaultOpen", checked)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* MODAL OPTIONS 섹션 - 모달/폼모달일 때 */}
|
{/* 모달/폼모달 타입: 모달 옵션 */}
|
||||||
{(config.groupType === "modal" || config.groupType === "form-modal") && (
|
{isModalType && (
|
||||||
<div className="border-b border-border/50 pb-3 mb-3">
|
<div className="space-y-3">
|
||||||
<h4 className="text-[10px] font-semibold uppercase tracking-wider text-muted-foreground py-2">MODAL OPTIONS</h4>
|
<div className="rounded-lg border bg-muted/30 p-4 space-y-3">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<AppWindow className="h-4 w-4 text-primary" />
|
||||||
|
<span className="text-sm font-medium">모달 설정</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center justify-between py-1.5">
|
<div className="flex items-center justify-between py-1.5">
|
||||||
<span className="text-xs text-muted-foreground">모달 크기</span>
|
<span className="text-xs text-muted-foreground">모달 크기</span>
|
||||||
<div className="w-[140px]">
|
|
||||||
<Select
|
<Select
|
||||||
value={config.modalSize || "md"}
|
value={config.modalSize || "md"}
|
||||||
onValueChange={(value) => updateConfig("modalSize", value)}
|
onValueChange={(value) => updateConfig("modalSize", value)}
|
||||||
>
|
>
|
||||||
<SelectTrigger className="h-7 text-xs">
|
<SelectTrigger className="h-8 w-[180px] text-sm">
|
||||||
<SelectValue />
|
<SelectValue />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
|
|
@ -190,17 +286,27 @@ export const V2GroupConfigPanel: React.FC<V2GroupConfigPanelProps> = ({
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center justify-between py-1.5">
|
<div className="flex items-center justify-between py-1">
|
||||||
<span className="text-xs text-muted-foreground">닫기 버튼 표시</span>
|
<div>
|
||||||
<Checkbox
|
<p className="text-sm">닫기 버튼</p>
|
||||||
|
<p className="text-[11px] text-muted-foreground">
|
||||||
|
모달 우측 상단에 X 버튼이 표시돼요
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
checked={config.closeable !== false}
|
checked={config.closeable !== false}
|
||||||
onCheckedChange={(checked) => updateConfig("closeable", checked)}
|
onCheckedChange={(checked) => updateConfig("closeable", checked)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center justify-between py-1.5">
|
<div className="flex items-center justify-between py-1">
|
||||||
<span className="text-xs text-muted-foreground">배경 클릭으로 닫기</span>
|
<div>
|
||||||
<Checkbox
|
<p className="text-sm">배경 클릭 닫기</p>
|
||||||
|
<p className="text-[11px] text-muted-foreground">
|
||||||
|
모달 바깥을 클릭하면 닫혀요
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
checked={config.backdrop !== false}
|
checked={config.backdrop !== false}
|
||||||
onCheckedChange={(checked) => updateConfig("backdrop", checked)}
|
onCheckedChange={(checked) => updateConfig("backdrop", checked)}
|
||||||
/>
|
/>
|
||||||
|
|
@ -208,17 +314,42 @@ export const V2GroupConfigPanel: React.FC<V2GroupConfigPanelProps> = ({
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* DISPLAY 섹션 */}
|
{/* ─── 4단계: 고급 설정 (기본 접혀있음) ─── */}
|
||||||
<div className="border-b border-border/50 pb-3 mb-3">
|
<Collapsible open={advancedOpen} onOpenChange={setAdvancedOpen}>
|
||||||
<h4 className="text-[10px] font-semibold uppercase tracking-wider text-muted-foreground py-2">DISPLAY</h4>
|
<CollapsibleTrigger asChild>
|
||||||
<div className="flex items-center justify-between py-1.5">
|
<button
|
||||||
<span className="text-xs text-muted-foreground">헤더 표시</span>
|
type="button"
|
||||||
<Checkbox
|
className="flex w-full items-center justify-between rounded-lg border bg-muted/30 px-4 py-2.5 text-left transition-colors hover:bg-muted/50"
|
||||||
checked={config.showHeader !== false}
|
>
|
||||||
onCheckedChange={(checked) => updateConfig("showHeader", checked)}
|
<div className="flex items-center gap-2">
|
||||||
/>
|
<Settings className="h-4 w-4 text-muted-foreground" />
|
||||||
</div>
|
<span className="text-sm font-medium">고급 설정</span>
|
||||||
</div>
|
</div>
|
||||||
|
<ChevronDown
|
||||||
|
className={cn(
|
||||||
|
"h-4 w-4 text-muted-foreground transition-transform duration-200",
|
||||||
|
advancedOpen && "rotate-180",
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
</CollapsibleTrigger>
|
||||||
|
<CollapsibleContent>
|
||||||
|
<div className="rounded-b-lg border border-t-0 p-4 space-y-3">
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<div>
|
||||||
|
<p className="text-sm">헤더 표시</p>
|
||||||
|
<p className="text-[11px] text-muted-foreground">
|
||||||
|
그룹 상단에 제목 영역이 표시돼요
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
|
checked={config.showHeader !== false}
|
||||||
|
onCheckedChange={(checked) => updateConfig("showHeader", checked)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CollapsibleContent>
|
||||||
|
</Collapsible>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue