import type { FinalSchemas, GetSchemaFromName, GetSchemaNames, RecordType, } from "@hatchifyjs/rest-client" import type { PartialSchema } from "@hatchifyjs/core" import type { DataValue, DataValueComponent, HeaderProps, HeaderValueComponent, } from "../../presentation/interfaces.js" import { HatchifyColumn } from "../../hooks/index.js" export type RenderData< TSchemas extends Record, TSchemaName extends GetSchemaNames, > = ({ record, }: { record: RecordType< TSchemas, GetSchemaFromName, false, true > }) => JSX.Element export type RenderHeader = (headerArgs: HeaderProps) => JSX.Element export type RenderDataValue< TSchemas extends Record, TSchemaName extends GetSchemaNames, > = ({ value, record, }: // control { value: DataValue // @TODO HATCH-417 - DataValue should be replaced with type of the field for this column // @TODO HATCH-417 - `control` for this column's field should be forwarded here record: RecordType< TSchemas, GetSchemaFromName, false, true > }) => JSX.Element // @TODO HATCH-459 - https://bitovi.atlassian.net/browse/HATCH-459 - renderDataValue and DataValueComponent should be required, but only one can be provided // @TODO HATCH-459 - https://bitovi.atlassian.net/browse/HATCH-459 - renderHeaderValue, HeaderValueComponent, and label should all be optional, but only one can be provided export type ExtraColumnProps< TSchemas extends Record, TSchemaName extends GetSchemaNames, > = { allSchemas: FinalSchemas schemaName: string sortable?: boolean prepend?: boolean label?: string field?: never } & { renderDataValue?: RenderData DataValueComponent?: DataValueComponent renderHeaderValue?: RenderHeader HeaderValueComponent?: HeaderValueComponent } // @TODO HATCH-459 - https://bitovi.atlassian.net/browse/HATCH-459 - renderDataValue and DataValueComponent should be optional, but only one can be provided // @TODO HATCH-459 - https://bitovi.atlassian.net/browse/HATCH-459 - renderHeaderValue, HeaderValueComponent, and label should all be optional, but only one can be provided export type ReplaceColumnProps< TSchemas extends Record, TSchemaName extends GetSchemaNames, > = { allSchemas: FinalSchemas schemaName: TSchemaName sortable?: boolean prepend?: never label?: string field: | keyof GetSchemaFromName["attributes"] | keyof GetSchemaFromName["relationships"] | "id" } & { renderDataValue?: RenderDataValue DataValueComponent?: DataValueComponent renderHeaderValue?: RenderHeader HeaderValueComponent?: HeaderValueComponent } export function HatchifyColumn< const TSchemas extends Record, const TSchemaName extends GetSchemaNames, >( props: | ExtraColumnProps | ReplaceColumnProps, ): null { return null } HatchifyColumn.displayName = "Column"