You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/components/auto-complete/InputElement.jsx

56 lines
1.4 KiB

import PropTypes from '../_util/vue-types';
import { cloneElement } from '../_util/vnode';
import { getOptionProps } from '../_util/props-util';
function chaining(...fns) {
return function(...args) {
// eslint-disable-line
// eslint-disable-line
for (let i = 0; i < fns.length; i++) {
if (fns[i] && typeof fns[i] === 'function') {
fns[i].apply(this, args);
}
}
};
}
export default {
name: 'InputElement',
7 years ago
props: {
value: PropTypes.any,
disabled: PropTypes.bool,
},
methods: {
focus() {
const ele = this.$refs.ele;
ele.focus ? ele.focus() : this.$el.focus();
},
blur() {
const ele = this.$refs.ele;
ele.blur ? ele.blur() : this.$el.blur();
},
},
render() {
const { $slots = {}, $listeners = {}, $attrs = {} } = this;
const props = getOptionProps(this);
const value = props.value === undefined ? '' : props.value;
const children = $slots.default[0];
const { componentOptions = {} } = $slots.default[0];
const { listeners = {} } = componentOptions;
const newEvent = { ...listeners };
for (const [eventName, event] of Object.entries($listeners)) {
newEvent[eventName] = chaining(event, listeners[eventName]);
}
return cloneElement(children, {
domProps: {
7 years ago
value,
},
props,
on: newEvent,
7 years ago
attrs: { ...$attrs, value },
ref: 'ele',
});
},
};