@@ -18,13 +18,14 @@ import LoadingIcon from './LoadingIcon';
18
18
19
19
import type { ButtonType } from './buttonTypes' ;
20
20
import type { VNode , Ref } from 'vue' ;
21
+ import { GroupSizeContext } from './button-group' ;
21
22
22
23
type Loading = boolean | number ;
23
24
24
25
const rxTwoCNChar = / ^ [ \u4e00 - \u9fa5 ] { 2 } $ / ;
25
26
const isTwoCNChar = rxTwoCNChar . test . bind ( rxTwoCNChar ) ;
26
27
27
- function isUnborderedButtonType ( type : ButtonType | undefined ) {
28
+ function isUnBorderedButtonType ( type : ButtonType | undefined ) {
28
29
return type === 'text' || type === 'link' ;
29
30
}
30
31
export { buttonProps } ;
@@ -37,7 +38,7 @@ export default defineComponent({
37
38
// emits: ['click', 'mousedown'],
38
39
setup ( props , { slots, attrs, emit } ) {
39
40
const { prefixCls, autoInsertSpaceInButton, direction, size } = useConfigInject ( 'btn' , props ) ;
40
-
41
+ const { size : groupSize } = GroupSizeContext . useInject ( ) ;
41
42
const buttonNodeRef = ref < HTMLElement > ( null ) ;
42
43
const delayTimeoutRef = ref ( undefined ) ;
43
44
let isNeedInserted = false ;
@@ -76,7 +77,7 @@ export default defineComponent({
76
77
const pre = prefixCls . value ;
77
78
78
79
const sizeClassNameMap = { large : 'lg' , small : 'sm' , middle : undefined } ;
79
- const sizeFullname = size . value ;
80
+ const sizeFullname = groupSize ?. value || size . value ;
80
81
const sizeCls = sizeFullname ? sizeClassNameMap [ sizeFullname ] || '' : '' ;
81
82
82
83
return {
@@ -85,7 +86,7 @@ export default defineComponent({
85
86
[ `${ pre } -${ shape } ` ] : shape !== 'default' && shape ,
86
87
[ `${ pre } -${ sizeCls } ` ] : sizeCls ,
87
88
[ `${ pre } -loading` ] : innerLoading . value ,
88
- [ `${ pre } -background-ghost` ] : ghost && ! isUnborderedButtonType ( type ) ,
89
+ [ `${ pre } -background-ghost` ] : ghost && ! isUnBorderedButtonType ( type ) ,
89
90
[ `${ pre } -two-chinese-chars` ] : hasTwoCNChar . value && autoInsertSpace . value ,
90
91
[ `${ pre } -block` ] : block ,
91
92
[ `${ pre } -dangerous` ] : ! ! danger ,
@@ -132,7 +133,7 @@ export default defineComponent({
132
133
133
134
watchEffect ( ( ) => {
134
135
devWarning (
135
- ! ( props . ghost && isUnborderedButtonType ( props . type ) ) ,
136
+ ! ( props . ghost && isUnBorderedButtonType ( props . type ) ) ,
136
137
'Button' ,
137
138
"`link` or `text` button can't be a `ghost` button." ,
138
139
) ;
@@ -149,7 +150,7 @@ export default defineComponent({
149
150
const { icon = slots . icon ?.( ) } = props ;
150
151
const children = flattenChildren ( slots . default ?.( ) ) ;
151
152
152
- isNeedInserted = children . length === 1 && ! icon && ! isUnborderedButtonType ( props . type ) ;
153
+ isNeedInserted = children . length === 1 && ! icon && ! isUnBorderedButtonType ( props . type ) ;
153
154
154
155
const { type, htmlType, disabled, href, title, target, onMousedown } = props ;
155
156
@@ -202,7 +203,7 @@ export default defineComponent({
202
203
</ button >
203
204
) ;
204
205
205
- if ( isUnborderedButtonType ( type ) ) {
206
+ if ( isUnBorderedButtonType ( type ) ) {
206
207
return buttonNode ;
207
208
}
208
209
0 commit comments