import * as _vue from "vue";
import PropTypes from '../_util/vue-types';
import { initDefaultProps, getOptionProps } from '../_util/props-util';
import CloseCircleFilled from '@ant-design/icons-vue/CloseCircleFilled';
import SearchOutlined from '@ant-design/icons-vue/SearchOutlined';
import Input from '../input';
export var TransferSearchProps = {
  prefixCls: PropTypes.string,
  placeholder: PropTypes.string,
  value: PropTypes.any,
  handleClear: PropTypes.func,
  disabled: PropTypes.bool,
  onChange: PropTypes.func
};
export default {
  name: 'Search',
  inheritAttrs: false,
  props: initDefaultProps(TransferSearchProps, {
    placeholder: ''
  }),
  methods: {
    handleChange: function handleChange(e) {
      this.$emit('change', e);
    },
    handleClear2: function handleClear2(e) {
      e.preventDefault();
      var _this$$props = this.$props,
          handleClear = _this$$props.handleClear,
          disabled = _this$$props.disabled;

      if (!disabled && handleClear) {
        handleClear(e);
      }
    }
  },
  render: function render() {
    var _getOptionProps = getOptionProps(this),
        placeholder = _getOptionProps.placeholder,
        value = _getOptionProps.value,
        prefixCls = _getOptionProps.prefixCls,
        disabled = _getOptionProps.disabled;

    var icon = value && value.length > 0 ? _vue.createVNode("a", {
      "href": "#",
      "class": "".concat(prefixCls, "-action"),
      "onClick": this.handleClear2
    }, [_vue.createVNode(CloseCircleFilled, null, null)]) : _vue.createVNode("span", {
      "class": "".concat(prefixCls, "-action")
    }, [_vue.createVNode(SearchOutlined, null, null)]);
    return _vue.createVNode("div", null, [_vue.createVNode(Input, {
      "placeholder": placeholder,
      "class": prefixCls,
      "value": value,
      "onChange": this.handleChange,
      "disabled": disabled
    }, null), icon]);
  }
};