ERP-node/frontend/types/grid-system.ts

108 lines
2.3 KiB
TypeScript
Raw Normal View History

2025-10-13 18:28:03 +09:00
/**
* 🎨
*
* (Row) 12
*/
import { ColumnSpanPreset, GapPreset } from "@/lib/constants/columnSpans";
import { ComponentData } from "./screen-management";
/**
*
*/
export interface LayoutRow {
id: string;
rowIndex: number;
height: "auto" | "fixed" | "min" | "max";
minHeight?: number;
maxHeight?: number;
fixedHeight?: number;
gap: GapPreset;
padding: GapPreset;
backgroundColor?: string;
alignment: "start" | "center" | "end" | "stretch" | "baseline";
verticalAlignment: "top" | "middle" | "bottom" | "stretch";
components: RowComponent[];
}
/**
*
*/
export interface RowComponent {
id: string;
componentId: string; // 실제 ComponentData의 ID
columnSpan: ColumnSpanPreset;
columnStart?: number; // 명시적 시작 위치 (선택)
order?: number; // 정렬 순서
offset?: ColumnSpanPreset; // 왼쪽 여백
}
/**
*
*/
export interface GridLayout {
screenId: number;
rows: LayoutRow[];
components: Map<string, ComponentData>; // 컴포넌트 저장소
globalSettings: GridGlobalSettings;
}
/**
*
*/
export interface GridGlobalSettings {
containerMaxWidth?: "full" | "7xl" | "6xl" | "5xl" | "4xl";
containerPadding: GapPreset;
}
/**
*
*/
export interface CreateRowOptions {
height?: "auto" | "fixed";
fixedHeight?: number;
gap?: GapPreset;
padding?: GapPreset;
alignment?: "start" | "center" | "end" | "stretch";
}
/**
*
*/
export interface PlaceComponentOptions {
columnSpan: ColumnSpanPreset;
columnStart?: number;
rowIndex: number;
}
/**
*
*/
export type UpdateRowOptions = Partial<Omit<LayoutRow, "id" | "rowIndex" | "components">>;
/**
*
*/
export interface GridDragState {
isDragging: boolean;
draggedComponentId?: string;
targetRowId?: string;
targetColumnIndex?: number;
previewPosition?: {
rowIndex: number;
columnStart: number;
columnSpan: ColumnSpanPreset;
};
}
/**
*
*/
export interface GridGuideOptions {
showGrid: boolean;
showColumnLines: boolean;
showRowBorders: boolean;
gridColor?: string;
gridOpacity?: number;
}