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

79 lines
3.2 KiB
TypeScript
Raw Normal View History

"use client";
/**
* pop-card-list (V2)
*
* import하면 side-effect로 PopComponentRegistry에
*/
import { PopComponentRegistry } from "../../PopComponentRegistry";
import { PopCardListComponent } from "./PopCardListComponent";
import { PopCardListConfigPanel } from "./PopCardListConfig";
import { PopCardListPreviewComponent } from "./PopCardListPreview";
import type { PopCardListConfig } from "../types";
import { DEFAULT_CARD_IMAGE } from "../types";
const defaultConfig: PopCardListConfig = {
// 데이터 소스 (테이블 단위)
dataSource: {
tableName: "",
},
// 카드 템플릿
cardTemplate: {
header: {
codeField: undefined,
titleField: undefined,
},
image: {
enabled: true,
imageColumn: undefined,
defaultImage: DEFAULT_CARD_IMAGE,
},
body: {
fields: [],
},
},
// 스크롤 방향
scrollDirection: "vertical",
cardSize: "medium",
// 그리드 배치 (가로 x 세로)
gridColumns: 3,
gridRows: 2,
// 담기 버튼 기본 설정
cartAction: {
saveMode: "cart",
label: "담기",
cancelLabel: "취소",
},
};
// 레지스트리 등록
PopComponentRegistry.registerComponent({
id: "pop-card-list",
name: "카드 목록",
description: "테이블 데이터를 카드 형태로 표시 (헤더 + 이미지 + 필드 목록)",
category: "display",
icon: "LayoutGrid",
component: PopCardListComponent,
configPanel: PopCardListConfigPanel,
preview: PopCardListPreviewComponent,
defaultProps: defaultConfig,
connectionMeta: {
sendable: [
{ key: "selected_row", label: "선택된 행", type: "selected_row", category: "data", description: "사용자가 선택한 카드의 행 데이터를 전달" },
{ key: "cart_updated", label: "장바구니 상태", type: "event", category: "event", description: "장바구니 변경 시 count/isDirty 전달" },
{ key: "cart_save_completed", label: "저장 완료", type: "event", category: "event", description: "장바구니 DB 저장 완료 후 결과 전달" },
{ key: "selected_items", label: "선택된 항목", type: "event", category: "event", description: "장바구니 모드에서 체크박스로 선택된 항목 배열" },
{ key: "collected_data", label: "수집 응답", type: "event", category: "event", description: "데이터 수집 요청에 대한 응답 (선택 항목 + 매핑)" },
],
receivable: [
{ key: "filter_condition", label: "필터 조건", type: "filter_value", category: "filter", description: "외부 컴포넌트에서 받은 필터 조건으로 카드 목록 필터링" },
{ key: "cart_save_trigger", label: "저장 요청", type: "event", category: "event", description: "장바구니 DB 일괄 저장 트리거 (버튼에서 수신)" },
{ key: "confirm_trigger", label: "확정 트리거", type: "event", category: "event", description: "입고 확정 시 수정된 수량 일괄 반영 + 선택 항목 전달" },
{ key: "collect_data", label: "수집 요청", type: "event", category: "event", description: "버튼에서 데이터+매핑 수집 요청 수신" },
],
},
touchOptimized: true,
supportedDevices: ["mobile", "tablet"],
});