// 此类提供airTable,所有基础组件
import React from 'react';
import { SetFormatter, formatStr } from './_utils/setFormatter';
import { GetFormatter } from './_utils/getFormatter';
import {
    ApolloInput,
    ApolloCascader,
    ApolloCheck,
    ApolloDate,
    ApolloLink,
    ApolloMultipleSelect,
    ApolloNumber,
    ApolloPercentage,
    ApolloRate,
    ApolloSearch,
    ApolloSelect,
    ApolloInputSearch,
    ApolloTreeSelect,
    ApolloUpload,
    ApolloTextArea,
    ApolloDateRange,
    ApolloRegion,
    ApolloTextLink,
} from './edit';
import {
    ApolloInputDetail,
    ApolloCascaderDetail,
    ApolloCheckBoxDetail,
    ApolloDateDetail,
    ApolloLinkDetail,
    ApolloMultipleSelectDetail,
    ApolloNumberDetail,
    ApolloPercentageDetail,
    ApolloRateDetail,
    ApolloSearchDetail,
    ApolloSelectDetail,
    ApolloInputSearchDetail,
    ApolloTextAreaDetail,
    ApolloTreeSelectDetail,
    ApolloUploadDetail,
    ApolloDateRangeDetail,
    ApolloTextLinkDetail,
    ApolloRegionDetail,
} from './detail';
import CellContainer from './edit/container';

export const config: any = {
    1: {
        name: '单行文本',
        editComp: ApolloInput,
        cellComp: ApolloInput,
        setFormatter: SetFormatter.INPUT,
        getFormatter: GetFormatter.INPUT,
        componentAttr: {
            placeholder: 'please enter',
        },
        detailComp: ApolloInputDetail,
        icon: 'iconziduan-danhangwenben',
    },
    // 2: {
    //     name: '超链接',
    //     editComp: ApolloLink,
    //     cellComp: CellContainer(ApolloLink),
    //     getFormatter: GetFormatter.LINK,
    //     setFormatter: SetFormatter.LINK,
    //     detailComp: ApolloLinkDetail,
    //     icon: 'iconziduan-chaolianjie',
    // },
    2: {
        name: '超链接',
        editComp: ApolloTextLink,
        cellComp: ApolloTextLink,
        getFormatter: GetFormatter.TEXTLINK,
        setFormatter: SetFormatter.TEXTLINK,
        componentAttr: {
            autoSize: { minRows: 3 },
        },
        detailComp: ApolloTextLinkDetail,
        icon: 'iconziduan-chaolianjie',
    },
    3: {
        name: '多行文本',
        editComp: ApolloTextArea,
        cellComp: ApolloTextArea,
        getFormatter: GetFormatter.TEXTAREA,
        setFormatter: SetFormatter.TEXTAREA,
        componentAttr: {
            autoSize: { minRows: 3 },
        },
        detailComp: ApolloTextAreaDetail,
        icon: 'iconziduan-duohangwenben',
    },
    4: {
        name: '附件上传',
        editComp: ApolloUpload,
        cellComp: ApolloUpload,
        setFormatter: SetFormatter.UPLOAD,
        getFormatter: GetFormatter.UPLOAD,
        detailComp: ApolloUploadDetail,
        icon: 'iconziduan-fujian',
    },
    5: {
        name: '复选',
        editComp: ApolloCheck,
        cellComp: ApolloCheck,
        getFormatter: GetFormatter.CHECKBOX,
        setFormatter: SetFormatter.CHECKBOX,
        componentAttr: {},
        detailComp: ApolloCheckBoxDetail,
        icon: 'iconziduan-fuxuan',
    },
    6: {
        name: '下拉单选',
        editComp: ApolloSelect,
        cellComp: ApolloSelect,
        componentAttr: {
            labelInValue: true,
            allowClear: true,
        },
        getFormatter: GetFormatter.SELECT,
        setFormatter: SetFormatter.SELECT,
        detailComp: ApolloSelectDetail,
        icon: 'iconziduan-xiala',
    },
    7: {
        name: '下拉多选',
        editComp: ApolloMultipleSelect,
        cellComp: ApolloMultipleSelect,
        componentAttr: {
            labelInValue: true,
            mode: 'multiple',
        },
        getFormatter: GetFormatter.MULTIPLE_SELECT,
        setFormatter: SetFormatter.MULTIPLE_SELECT,
        detailComp: ApolloMultipleSelectDetail,
        icon: 'iconziduan-xialaduoxuan',
    },
    8: {
        name: '评级',
        editComp: ApolloRate,
        cellComp: ApolloRate,
        componentAttr: {
            allowClear: true,
        },
        getFormatter: GetFormatter.RATE,
        setFormatter: SetFormatter.RATE,
        detailComp: ApolloRateDetail,
        icon: 'iconziduan-pingji',
    },
    9: {
        name: '数字输入',
        editComp: ApolloNumber,
        cellComp: ApolloNumber,
        componentAttr: {
            precision: 2,
        },
        setFormatter: SetFormatter.NUMBER,
        getFormatter: GetFormatter.NUMBER,
        detailComp: ApolloNumberDetail,
        icon: 'iconziduan-shuzi',
    },
    10: {
        name: '百分比',
        editComp: ApolloPercentage,
        cellComp: ApolloPercentage,
        setFormatter: SetFormatter.PERCENTAGE,
        getFormatter: GetFormatter.PERCENTAGE,
        componentAttr: {
            precision: 2,
        },
        detailComp: ApolloPercentageDetail,
        icon: 'iconziduan-baifenbi',
    },
    11: {
        name: '日期',
        editComp: ApolloDate,
        cellComp: ApolloDate,
        componentAttr: {
            format: formatStr,
            showTime: true,
        },
        getFormatter: GetFormatter.DATE,
        setFormatter: SetFormatter.DATE,
        detailComp: ApolloDateDetail,
        icon: 'iconziduan-riqi',
    },
    12: {
        name: '引用',
        editComp: ApolloLink,
        cellComp: CellContainer(ApolloLink),
        getFormatter: GetFormatter.LINK,
        setFormatter: SetFormatter.LINK,
        detailComp: ApolloLinkDetail,
        icon: 'iconziduan-yinyong',
    },
    13: {
        name: '模糊搜索',
        editComp: ApolloSearch,
        cellComp: ApolloSearch,
        getFormatter: GetFormatter.SEARCH,
        setFormatter: SetFormatter.SEARCH,
        componentAttr: {
            allowClear: true,
        },
        detailComp: ApolloSearchDetail,
        icon: 'iconziduan-lianxiangduoxuan',
    },
    14: {
        name: '树组件',
        editComp: ApolloTreeSelect,
        cellComp: CellContainer(ApolloTreeSelect),
        getFormatter: GetFormatter.TREE_SELECT,
        setFormatter: SetFormatter.TREE_SELECT,
        componentAttr: {
            allowClear: true,
        },
        detailComp: ApolloTreeSelectDetail,
        icon: 'iconziduan-ren',
    },
    15: {
        name: '文本选择',
        editComp: ApolloInputSearch,
        cellComp: ApolloInputSearch,
        getFormatter: GetFormatter.TEXT_SELECT,
        setFormatter: SetFormatter.TEXT_SELECT,
        componentAttr: {
            allowClear: true,
        },
        detailComp: ApolloInputSearchDetail,
        icon: 'iconziduan-lianxiangdanxuan',
    },
    17: {
        name: '级联选择',
        editComp: ApolloCascader,
        cellComp: CellContainer(ApolloCascader),
        getFormatter: GetFormatter.CASCADER,
        setFormatter: SetFormatter.CASCADER,
        componentAttr: {
            allowClear: true,
        },
        detailComp: ApolloCascaderDetail,
        icon: 'iconziduan-lianxiangdanxuan',
    },
    20: {
        name: '期间',
        editComp: ApolloDateRange,
        cellComp: ApolloDateRange,
        componentAttr: {
            format: formatStr,
            showTime: true,
        },
        getFormatter: GetFormatter.DATERANGE,
        setFormatter: SetFormatter.DATERANGE,
        detailComp: ApolloDateRangeDetail,
        icon: 'iconziduan-riqi',
    },
    22: {
        name: '地区选择控件',
        editComp: ApolloRegion,
        detailComp: ApolloRegionDetail,
        setFormatter: SetFormatter.REGION,
        // getFormatter: GetFormatter.REGION,
        icon: 'iconziduan-lianxiangdanxuan',
    },
    26: {
        name: '视频上传',
        editComp: ApolloUpload,
        cellComp: ApolloUpload,
        setFormatter: SetFormatter.UPLOAD,
        getFormatter: GetFormatter.UPLOAD,
        detailComp: ApolloUploadDetail,
        icon: 'iconziduan-fujian',
    },
};
