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.
53 lines
1.2 KiB
53 lines
1.2 KiB
import { filterEmpty } from '../_util/props-util';
|
|
import { ConfigConsumerProps } from '../config-provider';
|
|
|
|
const ButtonGroupProps = {
|
|
prefixCls: {
|
|
type: String,
|
|
},
|
|
size: {
|
|
validator(value) {
|
|
return ['small', 'large', 'default'].includes(value);
|
|
},
|
|
},
|
|
};
|
|
export { ButtonGroupProps };
|
|
export default {
|
|
name: 'AButtonGroup',
|
|
props: ButtonGroupProps,
|
|
inject: {
|
|
configProvider: { default: () => ({}) },
|
|
},
|
|
data() {
|
|
return {
|
|
sizeMap: {
|
|
large: 'lg',
|
|
small: 'sm',
|
|
},
|
|
};
|
|
},
|
|
render() {
|
|
const { prefixCls: customizePrefixCls, size, sizeMap, $slots } = this;
|
|
const getPrefixCls = this.configProvider.getPrefixCls || ConfigConsumerProps.getPrefixCls;
|
|
const prefixCls = getPrefixCls('btn-group', customizePrefixCls);
|
|
|
|
// large => lg
|
|
// small => sm
|
|
let sizeCls = '';
|
|
switch (size) {
|
|
case 'large':
|
|
sizeCls = 'lg';
|
|
break;
|
|
case 'small':
|
|
sizeCls = 'sm';
|
|
default:
|
|
break;
|
|
}
|
|
const classes = {
|
|
[`${prefixCls}`]: true,
|
|
[`${prefixCls}-${sizeCls}`]: sizeCls,
|
|
};
|
|
return <div class={classes}>{filterEmpty($slots.default)}</div>;
|
|
},
|
|
};
|