ant-design-vue/components/input/Group.jsx

44 lines
1.1 KiB
Vue
Raw Normal View History

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