|
1 | 1 | import classNames from 'classnames'; |
| 2 | +import { getComponentFromProp, getOptionProps } from '../_util/props-util'; |
2 | 3 | import Input from './Input'; |
3 | 4 | import Icon from '../icon'; |
4 | 5 | import inputProps from './inputProps'; |
@@ -57,19 +58,33 @@ export default { |
57 | 58 | }, |
58 | 59 | }, |
59 | 60 | render() { |
60 | | - const { prefixCls, inputPrefixCls, size, suffix, visibilityToggle, ...restProps } = this.$props; |
| 61 | + const { prefixCls, inputPrefixCls, size, suffix, visibilityToggle, ...restProps } = getOptionProps(this); |
61 | 62 | const suffixIcon = visibilityToggle && this.getIcon(); |
62 | 63 | const inputClassName = classNames(prefixCls, { |
63 | 64 | [`${prefixCls}-${size}`]: !!size, |
64 | 65 | }); |
| 66 | + const inputProps = { |
| 67 | + props: { |
| 68 | + ...restProps, |
| 69 | + prefixCls: inputPrefixCls, |
| 70 | + size, |
| 71 | + suffix: suffixIcon, |
| 72 | + prefix: getComponentFromProp(this, 'prefix'), |
| 73 | + addonAfter: getComponentFromProp(this, 'addonAfter'), |
| 74 | + addonBefore: getComponentFromProp(this, 'addonBefore'), |
| 75 | + }, |
| 76 | + attrs: { |
| 77 | + ...this.$attrs, |
| 78 | + type: this.visible ? 'text' : 'password', |
| 79 | + }, |
| 80 | + class: inputClassName, |
| 81 | + on: { |
| 82 | + ...this.$listeners, |
| 83 | + }, |
| 84 | + }; |
65 | 85 | return ( |
66 | 86 | <Input |
67 | | - {...restProps} |
68 | | - type={this.visible ? 'text' : 'password'} |
69 | | - size={size} |
70 | | - class={inputClassName} |
71 | | - prefixCls={inputPrefixCls} |
72 | | - suffix={suffixIcon} |
| 87 | + {...inputProps} |
73 | 88 | /> |
74 | 89 | ); |
75 | 90 | }, |
|
0 commit comments