import {ReactNode} from "react";
import {FieldsProps} from "../Fields";
import {RowOptions} from "./cards/Fields/RowOptions";

export enum FieldType {
    Tab = 'tab',
    MultiSelect = 'multi-select',
    Select = "select",
    Number = 'number',
    None = 'none',
    Button = 'button',
    BooleanButton = 'boolean-button',
    BooleanTab = 'boolean-tab',
    DualBooleanTab = 'dual-boolean-tab',
    Custom = "custom",
    Text = 'text',
    MultiLineText = 'multi-line-text',
    Date = 'date',
    Time = 'time',
    Columns = 'row',
    Grid = 'grid',
}

export type FieldItem<P extends object = {}, Options extends object = any> = {
    id: string,
    title?: string,
    description?: string,
    renderType: FieldType | ((options: Options) => FieldType | false) | false,
    columns?: FieldRow // when field type is columns
    fieldProps?: P | ((options: Options, onUpdate: FieldsProps['onUpdate'], state: Record<any, any>) => P),
    fieldOptions?: Record<string, any>,
    wrap?: (fieldToRender: ReactNode) => ReactNode,
    settingValue?: (value: any) => any;
}
export type FieldRow = (FieldItem| RowOptions)[] | false;
export type FieldsMap = FieldRow[];