const instalcePublic = {
    name: {
        type: String,
    },
    disabled: {
        type: [Boolean],
    },
    modelValue: {
        required: false,
        default: '',
    },
    placeholder: {
        require: false,
        default: '请输入',
    },
}

export const colorPropsDesc = {
    ...instalcePublic,
    width: {
        type: String,
        default: '100px',
    },
    height: {
        type: String,
        default: '34px',
    },
}

export const filePropsDesc = {
    ...instalcePublic,
    placeholder: {
        require: false,
        default: '请选择',
    },
    othPlaceholder: {
        require: false,
        default: '',
    },
    accept: {
        type: String,
    },
    scale: {
        type: String,
    },
    multiple: {
        type: Boolean,
    },
    preview: {
        type: Boolean,
    },
    maxSize: {
        type: Number,
    },
    maxLen: {
        type: Number,
    },
}

export const switchPropsDesc = {
    ...instalcePublic,
    width: {
        type: [Number, String],
    },
    height: {
        type: [Number, String],
    },
}

export const checkboxPropsDesc = {
    ...switchPropsDesc,
    label: {
        type: String,
        required: false,
    },
}

export const radioPropsDesc = {
    ...checkboxPropsDesc,
    icon: {
        type: String,
    },
    tip: {
        type: String,
    },
}

export const textPropsDesc = {
    ...instalcePublic,
    maxlength: {
        type: [String, Number],
    },
    placeholder: {
        type: String,
        default: '请输入',
    },
    readonly: {
        type: Boolean,
        default: false,
    },
    other: {
        type: Object,
        default: () => ({}),
    },
    right: {
        type: Boolean,
    },
}

export const textEmitsDesc = ['update:modelValue', 'focus', 'blur', 'click', 'keydown']

export const textareaPropsDesc = {
    ...textPropsDesc,
    rich: {
        type: Boolean,
    },
}

export const richtextPropsDesc = {
    ...textareaPropsDesc,
    onUpdatePos: Function,
}

export const selectPropsDesc = {
    ...textPropsDesc,
    stopEl: {
        type: String,
        require: false,
    },
    floatingClass: {
        type: String,
        require: false,
    },
    showOptions: {
        type: Boolean,
        require: false,
    },
    placeholder: { ...textPropsDesc.placeholder, default: '请选择' },
    unplaceholder: { ...textPropsDesc.placeholder, default: '暂无选项' },
    options: {
        type: Array,
        default: () => [],
    },
    dire: {
        type: String,
        default: 'bottom',
    },
}

export const searchPropsDesc = {
    ...selectPropsDesc,
    unplaceholder: { ...textPropsDesc.placeholder, default: '无搜索结果' },
}

export const numberPropsDesc = {
    ...textPropsDesc,
    inInput: {
        type: Boolean,
        default: true,
    },
    ctrl: {
        type: Boolean,
        default: true,
    },
    step: {
        type: Number,
        require: true,
        default: 1,
    },
    min: {
        type: [Number, String],
        require: false,
    },
    max: {
        type: [Number, String],
        require: false,
    },
    limit: {
        type: Number,
        default: 0,
    },
    inch: {
        type: [Boolean, String],
        default: false,
    },
}

export const rangePropsDesc = {
    ...numberPropsDesc,
    min: { ...numberPropsDesc.min, require: true },
    min: { ...numberPropsDesc.min, require: true },
}

const summary = {
    ...checkboxPropsDesc,
    ...radioPropsDesc,
    ...selectPropsDesc,
    ...textPropsDesc,
    ...rangePropsDesc,
    ...numberPropsDesc,
    ...switchPropsDesc,
    ...textareaPropsDesc,
    ...filePropsDesc,
    ...searchPropsDesc,
    ...richtextPropsDesc,
    ...colorPropsDesc,
}
for (let key in summary) {
    summary[key] = {
        ...summary[key],
        default: undefined,
    }
}

export const inputEmitDesc = {
    text: textEmitsDesc,
}

export const inputPropsDesc = {
    ...summary,
    type: {
        type: String,
        required: true,
        default: 'text',
    },
    width: {
        type: [Number, String],
    },
    height: {
        type: [Number, String],
    },
    require: {
        type: Boolean,
    },
    error: {
        type: String,
    },
    disabled: {
        type: Boolean,
    },
}
