BaseInput.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
  2. import { createVNode as _createVNode } from "vue";
  3. import { defineComponent, ref, withDirectives } from 'vue';
  4. import antInput from './antInputDirective';
  5. import PropTypes from './vue-types';
  6. var BaseInput = defineComponent({
  7. compatConfig: {
  8. MODE: 3
  9. },
  10. props: {
  11. value: PropTypes.string.def('')
  12. },
  13. emits: ['change', 'input'],
  14. setup: function setup(_p, _ref) {
  15. var emit = _ref.emit;
  16. var inputRef = ref(null);
  17. var handleChange = function handleChange(e) {
  18. var composing = e.target.composing;
  19. if (e.isComposing || composing) {
  20. emit('input', e);
  21. } else {
  22. emit('input', e);
  23. emit('change', e);
  24. }
  25. };
  26. return {
  27. inputRef: inputRef,
  28. focus: function focus() {
  29. if (inputRef.value) {
  30. inputRef.value.focus();
  31. }
  32. },
  33. blur: function blur() {
  34. if (inputRef.value) {
  35. inputRef.value.blur();
  36. }
  37. },
  38. handleChange: handleChange
  39. };
  40. },
  41. render: function render() {
  42. return withDirectives(_createVNode("input", _objectSpread(_objectSpread(_objectSpread({}, this.$props), this.$attrs), {}, {
  43. "onInput": this.handleChange,
  44. "onChange": this.handleChange,
  45. "ref": "inputRef"
  46. }), null), [[antInput]]);
  47. }
  48. });
  49. export default BaseInput;