import TyComponent from '../common/component'

TyComponent({
  /**
   * 组件的属性列表
   */
  properties: {

    name: {
      type: String
    },
    label: {
      type: String
    },
    shape: {
      type: String,
      value: 'square'
    },
    value: {
      type: [String, Number]
    },
    background: {
      type: String,
      value: '#f5f5f5'
    },
    showAction: {
      type: Boolean,
      value: false
    },
    actionText: {
      type: Boolean,
      value: '取消'
    },
    focus: {
      type: Boolean,
      value: false
    },
    error: {
      type: Boolean,
      value: false
    },
    disabled: {
      type: Boolean,
      value: false
    },
    readonly: {
      type: Boolean,
      value: false
    },
    clearable: {
      type: Boolean,
      value: true
    },
    maxlength: {
      type: Number,
      value: -1
    },
    useActionSlot: {
      type: Boolean,
      value: false
    },
    placeholder: {
      type: String
    },
    placeholderStyle: {
      type: String
    },
    inputAlign: {
      type: String,
      value: 'left'
    },
    useLeftIconSlot: {
      type: Boolean,
      value: false
    },
    useRightIconSlot: {
      type: Boolean,
      value: false
    },
    leftIcon: {
      type: String,
      value: 'search'
    },
    rightIcon: {
      type: String
    },
    customClass: {
      type: String
    },
    fieldClass: {
      type: String
    },
    inputClass: {
      type: String
    },
    cancelClass: {
      type: String
    }

  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    handleSearch({detail}) {
      this.triggerEvent('search', detail)
    },
    handleChange({detail}) {
      this.triggerEvent('change', detail)
    },
    handleCancel({detail}) {
      this.triggerEvent('cancel', detail)
    },
    handleFocus({detail}) {
      this.triggerEvent('focus', detail)
    },
    handleBlur({detail}) {
      this.triggerEvent('blur', detail)
    },
    handleClear({detail}) {
      this.triggerEvent('clear', detail)
    },
  }
})
