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.
54 lines
1.3 KiB
54 lines
1.3 KiB
4 years ago
|
import { defineComponent, inject } from 'vue';
|
||
5 years ago
|
import { filterEmpty, getSlot } from '../_util/props-util';
|
||
5 years ago
|
import PropTypes from '../_util/vue-types';
|
||
4 years ago
|
import { defaultConfigProvider } from '../config-provider';
|
||
4 years ago
|
import { tuple } from '../_util/type';
|
||
6 years ago
|
|
||
7 years ago
|
const ButtonGroupProps = {
|
||
5 years ago
|
prefixCls: PropTypes.string,
|
||
4 years ago
|
size: PropTypes.oneOf(tuple('small', 'large', 'default')),
|
||
6 years ago
|
};
|
||
|
export { ButtonGroupProps };
|
||
4 years ago
|
export default defineComponent({
|
||
7 years ago
|
name: 'AButtonGroup',
|
||
7 years ago
|
props: ButtonGroupProps,
|
||
5 years ago
|
setup() {
|
||
4 years ago
|
const configProvider = inject('configProvider', defaultConfigProvider);
|
||
5 years ago
|
return {
|
||
|
configProvider,
|
||
|
};
|
||
6 years ago
|
},
|
||
6 years ago
|
data() {
|
||
7 years ago
|
return {
|
||
|
sizeMap: {
|
||
|
large: 'lg',
|
||
|
small: 'sm',
|
||
|
},
|
||
6 years ago
|
};
|
||
7 years ago
|
},
|
||
6 years ago
|
render() {
|
||
5 years ago
|
const { prefixCls: customizePrefixCls, size } = this;
|
||
5 years ago
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
||
6 years ago
|
const prefixCls = getPrefixCls('btn-group', customizePrefixCls);
|
||
|
|
||
|
// large => lg
|
||
|
// small => sm
|
||
|
let sizeCls = '';
|
||
|
switch (size) {
|
||
|
case 'large':
|
||
|
sizeCls = 'lg';
|
||
|
break;
|
||
|
case 'small':
|
||
|
sizeCls = 'sm';
|
||
5 years ago
|
break;
|
||
6 years ago
|
default:
|
||
|
break;
|
||
|
}
|
||
|
const classes = {
|
||
|
[`${prefixCls}`]: true,
|
||
|
[`${prefixCls}-${sizeCls}`]: sizeCls,
|
||
|
};
|
||
5 years ago
|
return <div class={classes}>{filterEmpty(getSlot(this))}</div>;
|
||
7 years ago
|
},
|
||
4 years ago
|
});
|