search.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 const 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(props, _ref) {
  28. let {
  29. emit
  30. } = _ref;
  31. const handleChange = e => {
  32. var _a;
  33. emit('change', e);
  34. if (e.target.value === '') {
  35. (_a = props.handleClear) === null || _a === void 0 ? void 0 : _a.call(props);
  36. }
  37. };
  38. return () => {
  39. const {
  40. placeholder,
  41. value,
  42. prefixCls,
  43. disabled
  44. } = props;
  45. return _createVNode(Input, {
  46. "placeholder": placeholder,
  47. "class": prefixCls,
  48. "value": value,
  49. "onChange": handleChange,
  50. "disabled": disabled,
  51. "allowClear": true
  52. }, {
  53. prefix: () => _createVNode(SearchOutlined, null, null)
  54. });
  55. };
  56. }
  57. });