ERP-node/frontend/lib/registry/pop-components/pop-search/index.tsx

48 lines
1.8 KiB
TypeScript
Raw Normal View History

"use client";
import { PopComponentRegistry } from "../../PopComponentRegistry";
import { PopSearchComponent } from "./PopSearchComponent";
import { PopSearchConfigPanel } from "./PopSearchConfig";
import type { PopSearchConfig } from "./types";
import { DEFAULT_SEARCH_CONFIG } from "./types";
function PopSearchPreviewComponent({ config, label }: { config?: PopSearchConfig; label?: string }) {
const cfg = config || DEFAULT_SEARCH_CONFIG;
const displayLabel = cfg.labelText || label || cfg.fieldName || "검색";
return (
<div className="flex h-full w-full flex-col items-center justify-center gap-1 p-2">
<span className="text-[10px] font-medium text-muted-foreground">
{displayLabel}
</span>
<div className="flex h-6 w-full items-center rounded border border-dashed border-muted-foreground/30 px-2">
<span className="text-[9px] text-muted-foreground">
{cfg.placeholder || cfg.inputType}
</span>
</div>
</div>
);
}
PopComponentRegistry.registerComponent({
id: "pop-search",
name: "검색",
description: "조건 입력 (텍스트/날짜/선택/모달)",
category: "input",
icon: "Search",
component: PopSearchComponent,
configPanel: PopSearchConfigPanel,
preview: PopSearchPreviewComponent,
defaultProps: DEFAULT_SEARCH_CONFIG,
connectionMeta: {
sendable: [
{ key: "filter_value", label: "필터 값", type: "filter_value", category: "filter", description: "입력한 검색 조건을 다른 컴포넌트에 전달" },
],
receivable: [
{ key: "set_value", label: "값 설정", type: "filter_value", category: "filter", description: "외부에서 값을 받아 검색 필드에 세팅 (스캔, 모달 선택 등)" },
],
},
touchOptimized: true,
supportedDevices: ["mobile", "tablet"],
});