2019-09-11 10:11:48 +00:00
|
|
|
import PropTypes from '../_util/vue-types';
|
2019-01-12 03:33:27 +00:00
|
|
|
import { filterEmpty } from '../_util/props-util';
|
2019-04-07 09:19:18 +00:00
|
|
|
import { ConfigConsumerProps } from '../config-provider';
|
|
|
|
|
2017-12-06 10:54:20 +00:00
|
|
|
export default {
|
2018-04-08 13:17:20 +00:00
|
|
|
name: 'AInputGroup',
|
2017-12-06 10:54:20 +00:00
|
|
|
props: {
|
2019-09-11 10:11:48 +00:00
|
|
|
prefixCls: PropTypes.string,
|
2017-12-06 10:54:20 +00:00
|
|
|
size: {
|
2019-01-12 03:33:27 +00:00
|
|
|
validator(value) {
|
|
|
|
return ['small', 'large', 'default'].includes(value);
|
2017-12-06 10:54:20 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
compact: Boolean,
|
|
|
|
},
|
2019-04-07 09:19:18 +00:00
|
|
|
inject: {
|
2019-09-11 14:35:25 +00:00
|
|
|
configProvider: { default: () => ConfigConsumerProps },
|
2019-04-07 09:19:18 +00:00
|
|
|
},
|
2017-12-06 10:54:20 +00:00
|
|
|
computed: {
|
2019-01-12 03:33:27 +00:00
|
|
|
classes() {
|
2019-04-07 09:19:18 +00:00
|
|
|
const { prefixCls: customizePrefixCls, size, compact = false } = this;
|
2019-09-11 14:35:25 +00:00
|
|
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
2019-04-07 09:19:18 +00:00
|
|
|
const prefixCls = getPrefixCls('input-group', customizePrefixCls);
|
|
|
|
|
2017-12-06 10:54:20 +00:00
|
|
|
return {
|
|
|
|
[`${prefixCls}`]: true,
|
|
|
|
[`${prefixCls}-lg`]: size === 'large',
|
|
|
|
[`${prefixCls}-sm`]: size === 'small',
|
|
|
|
[`${prefixCls}-compact`]: compact,
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2017-12-06 10:54:20 +00:00
|
|
|
},
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
methods: {},
|
|
|
|
render() {
|
|
|
|
const { $listeners } = this;
|
2018-03-19 01:43:31 +00:00
|
|
|
return (
|
2019-01-12 03:33:27 +00:00
|
|
|
<span class={this.classes} {...{ on: $listeners }}>
|
2018-03-20 11:06:04 +00:00
|
|
|
{filterEmpty(this.$slots.default)}
|
2018-03-19 01:43:31 +00:00
|
|
|
</span>
|
2019-01-12 03:33:27 +00:00
|
|
|
);
|
2018-03-19 01:43:31 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|