search.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { resolveDirective as _resolveDirective, createVNode as _createVNode } from "vue";
  2. import initDefaultProps from '../_util/props-util/initDefaultProps';
  3. import SearchOutlined from "@ant-design/icons-vue/es/icons/SearchOutlined";
  4. import Input from '../input';
  5. import { defineComponent } from 'vue';
  6. export var transferSearchProps = {
  7. prefixCls: String,
  8. placeholder: String,
  9. value: String,
  10. handleClear: Function,
  11. disabled: {
  12. type: Boolean,
  13. default: undefined
  14. },
  15. onChange: Function
  16. };
  17. export default defineComponent({
  18. compatConfig: {
  19. MODE: 3
  20. },
  21. name: 'Search',
  22. inheritAttrs: false,
  23. props: initDefaultProps(transferSearchProps, {
  24. placeholder: ''
  25. }),
  26. emits: ['change'],
  27. setup: function setup(props, _ref) {
  28. var emit = _ref.emit;
  29. var handleChange = function handleChange(e) {
  30. emit('change', e);
  31. if (e.target.value === '') {
  32. var _props$handleClear;
  33. (_props$handleClear = props.handleClear) === null || _props$handleClear === void 0 ? void 0 : _props$handleClear.call(props);
  34. }
  35. };
  36. return function () {
  37. var placeholder = props.placeholder,
  38. value = props.value,
  39. prefixCls = props.prefixCls,
  40. disabled = props.disabled;
  41. return _createVNode(Input, {
  42. "placeholder": placeholder,
  43. "class": prefixCls,
  44. "value": value,
  45. "onChange": handleChange,
  46. "disabled": disabled,
  47. "allowClear": true
  48. }, {
  49. prefix: function prefix() {
  50. return _createVNode(SearchOutlined, null, null);
  51. }
  52. });
  53. };
  54. }
  55. });