import { Component } from 'vue'
import { VComponent } from './component'

export const Richform: VComponent<RichformProps, RichformEventProps, RichformSlots>

export type SizeType = 'default' | 'large' | 'mini'

declare function AJValidate(schema: object, values: object, errors: object): boolean

export type FormType = {
    border?: boolean
    grid?: boolean
    labelSuffix?: string
    labelWidth?: string
    labelAlign?: string
    labelInline?: boolean
    size?: SizeType
    colors?: object
    actions?: Array<any>
    layout?: Array<any>
    widget?: boolean
    activeField?: boolean
}

export interface RichformConstructor { // extends RichformMethods 
    id: string
    props: RichformProps,
    friendSchema?: SchemaType,
    friendForm?: FormType,
    topActions?: any,
    buttomActions?: any,
    noReady?: boolean,
}

export interface RichformProps {
    values?: RichformProps.values,
    form?: RichformProps.form,
    schema?: RichformProps.schema,
    isDesign?: RichformProps.isDesign,
    showBtns?: RichformProps.showBtns,
    deepValues?: RichformProps.deepValues,
    isFriendValue?: RichformProps.isFriendValue,
    authorization?: RichformProps.authorization,
    item?: RichformPropsTypes.item,
    fieldErrors?: RichformPropsTypes.fieldErrors,
    language?: RichformPropsTypes.language,
    theme?: RichformPropsTypes.theme,
}

export namespace RichformPropsTypes {
    export type values = object
    export type form = FormType
    export type schema = SchemaType
    export type isDesign = boolean
    export type showBtns = boolean
    export type deepValues = boolean
    export type isFriendValue = boolean
    export type authorization = {
        key?: string
        value?: string
        codeKey?: string
        codeVal?: string
        baseUrl?: string
        msgkey?: string
        expireCode?: string,
    }
    export type item = object
    export type fieldErrors = object
    export type language = string
    export type theme = "dark" | "light" | ''
}

export interface RichformEventProps {

}

export interface RichformSlots {

}

export interface RichformMethods {
    globalValidate(schema: object, values: object, fieldErrors?: object): boolean,
    resetValues(): void
    validateForm(schema: object, values: object): boolean
    clickCanvas(event: Event): void
    clickFormPs(event: Event): void
    updateTheme(theme: any): void
}

export type SchemaType = {
    $schema?: string
    title?: string
    description?: string
    type?: string
    properties?: object
    errorMessage?: object
    if?: object
    then?: object
    else?: object
    required?: Array<any>
}

export type ButtonType = {
    name: string
    type: 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text'
    title: string
    icon: string
    tips: string
    right: boolean
    visible: boolean
    top: boolean
    size: SizeType
    nativeType?: 'button' | 'submit' | 'reset'
}

export interface RichformReactData {
    hideFields: object
    dependencies: object
    flatFields: object
    requireds: Array<any>
    context: ContextType
    regExpFields: object
    clickedField: any
    fieldErrors: any
}

export type ContextType = {
    loadDebounce: any,
    loadCompleted: boolean,
    deepValueKeys: Array<any>,
    uploadCount: number,
    uploadSuccess: number,
}

export type GroupType = {
    name: string
    title: string
    widget: string
}

export type CollapseType = {
    name: string
    title: string
    widget: string
    expand: boolean
    actions: Array<any>
    fields: Array<any>
    isClicked?: boolean
    style?: object
    activeDesign?: boolean
}

export type TabsType = {

}

export type WidgetsType = {
    button?: Component,
    cascader?: Component,
    checkbox?: Component,
    colorpicker?: Component,
    datetimepicker?: Component,
    draggablelist?: Component,
    expression?: Component,
    icon?: Component,
    input?: Component,
    inputnumber?: Component,
    ipinput?: Component,
    multiexp?: Component,
    radio?: Component,
    rate?: Component,
    select?: Component,
    slider?: Component,
    slot?: Component,
    switch?: Component,
    table?: Component,
    text?: Component,
    timepicker?: Component,
    transfer?: Component,
    tree?: Component,
    treeselect?: Component,
    upload?: Component,
    [key: string]: string | number;
}

export const Widgets: WidgetsType
