export interface DataValue {
    label: string;
    value: string;
}

interface DataWithShortcut extends DataValue {
    label: string;
    value: string;
    shortcut?: string;
}

export interface FormDetails {
    id: number;
    name?: string;
    version?: number;
    components?: SingleFormProps;
    deploymentName?: string;
}

export interface ValidationProps {
    customMessage?: string;
    pattern?: RegExp;
    required?: boolean;
    minLength?: number;
    maxLength?: number;
    min?: number;
    max?: number;
}

export interface FieldProps {
    defaultValue?: string | boolean | unknown[];
    description?: string;
    disableOnInvalid?: boolean;
    disabled?: boolean;
    input?: boolean;
    key?: string;
    label?: string;
    multiple?: boolean;
    placeholder?: string;
    type?:
        | 'textfield'
        | 'checkbox'
        | 'selectboxes'
        | 'number'
        | 'email'
        | 'phoneNumber'
        | 'datetime'
        | 'textarea'
        | 'button'
        | 'select'
        | 'radio'
        | 'panel'
        | 'url'
        | 'currency'
        | 'password'
        | 'file';
    validate?: ValidationProps;
    validateOn?: 'change' | 'blur';

    data?: {
        values: DataValue[];
    };
    widget?: unknown;
    inputMask?: string;
    action?: 'next' | 'save' | 'callback' | 'triggerProcess';
    enableTime?: boolean;
    variableValue?: unknown;
    values?: DataWithShortcut[];
    components?: FieldProps[];
    mask?: boolean;
    currency?: string;
    spellcheck?: boolean;
    storage?: string;
    webcam?: boolean;
    fileTypes?: DataValue[];
}

export interface SingleFormProps {
    display?: string;
    components?: FieldProps | [];
}

export interface SingleForm {
    id: number;
    name: string;
    version: number;
    components: SingleFormProps;
}

export interface RenderedForm {
    fieldLabel: string;
    stateName: 'id' | 'name' | 'version' | 'deploymentName';
    inputType?: string;
    controlId: string;
    required?: boolean;
    disabled?: boolean;
}

export interface ButtonAction {
    label: string;
    value: string;
}
