<template>
  <div class="uif-form-item-icon">
    <u-icon scene="action" :type="input.actionIcon || input.availableIcon" :disabled="!isAvailable(input)"
            :title="input.actionIconTitle || input.availableIconTitle" @click="handleIconClick"></u-icon>
  </div>
</template>

<script>
import UIcon from '@uif/hq/lib/components/icon'

export default {
  components: {UIcon},
  props: {
    input: {
      type: Object,
      default () {
        return {}
      }
    }
  },
  data () {
    return {
    }
  },
  computed: {

  },
  created () {
  },
  mounted () {
  },
  methods: {
    handleIconClick (event) {
      this.$emit('icon-click', this.input, event)
    },
    isAvailable (input) {
      if (input.vailableIcon || input.items) {
        return true
      } else if (input.isIconAvailable instanceof Function) {
        return input.isIconAvailable(this.input)
      }
      return input.value
    }
  }
}
</script>
