import { BaseHeader } from "./type/BaseHeader"; import type { BaseHeaderDefine } from "../list-grid/layout-map/api"; import { CheckHeader } from "./type/CheckHeader"; import { Header } from "./type/Header"; import type { HeaderTypeOption } from "../ts-types"; import { MultilineTextHeader } from "./type/MultilineTextHeader"; import { SortHeader } from "./type/SortHeader"; const TYPES = { // eslint-disable-next-line @typescript-eslint/no-explicit-any DEFAULT: new Header(), // eslint-disable-next-line @typescript-eslint/no-explicit-any SORT: new SortHeader(), // eslint-disable-next-line @typescript-eslint/no-explicit-any CHECK: new CheckHeader(), // eslint-disable-next-line @typescript-eslint/no-explicit-any MULTILINETEXT: new MultilineTextHeader(), }; export { BaseHeader, Header, SortHeader, CheckHeader, MultilineTextHeader }; export function of( headerType: HeaderTypeOption | BaseHeader | null | undefined ): BaseHeader { if (!headerType) { return TYPES.DEFAULT; } else if (typeof headerType === "string") { const key = headerType.toUpperCase() as keyof typeof TYPES; return TYPES[key] || of(null); } else { return headerType; } } export function ofCell(headerCell: BaseHeaderDefine): BaseHeader { if (headerCell.sort) { return TYPES.SORT; } return of(headerCell.headerType); }