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

37 lines
1.1 KiB
Vue
Raw Normal View History

2020-10-16 14:24:14 +08:00
import { defineComponent, inject } from 'vue';
2019-09-11 18:11:48 +08:00
import PropTypes from '../_util/vue-types';
2020-07-30 18:41:38 +08:00
import { getSlot } from '../_util/props-util';
import { defaultConfigProvider } from '../config-provider';
2020-10-16 14:24:14 +08:00
import { tuple } from '../_util/type';
2019-04-07 17:19:18 +08:00
2020-10-16 14:24:14 +08:00
export default defineComponent({
2018-04-08 21:17:20 +08:00
name: 'AInputGroup',
2017-12-06 18:54:20 +08:00
props: {
2019-09-11 18:11:48 +08:00
prefixCls: PropTypes.string,
2020-10-16 14:24:14 +08:00
size: PropTypes.oneOf(tuple('small', 'large', 'default')),
compact: PropTypes.looseBool,
2017-12-06 18:54:20 +08:00
},
2020-06-27 14:02:30 +08:00
setup() {
return {
configProvider: inject('configProvider', defaultConfigProvider),
2020-06-27 14:02:30 +08:00
};
2019-04-07 17:19:18 +08:00
},
2017-12-06 18:54:20 +08:00
computed: {
2019-01-12 11:33:27 +08:00
classes() {
2020-10-16 14:24:14 +08:00
const { prefixCls: customizePrefixCls, size, compact = false, configProvider } = this as any;
const getPrefixCls = configProvider.getPrefixCls;
2019-04-07 17:19:18 +08:00
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
render() {
2020-07-30 18:41:38 +08:00
return <span class={this.classes}>{getSlot(this)}</span>;
2018-03-19 09:43:31 +08:00
},
2020-10-16 14:24:14 +08:00
});