1
- import { defineComponent , shallowRef } from 'vue' ;
1
+ import { computed , defineComponent } from 'vue' ;
2
2
import type { CSSProperties } from 'vue' ;
3
3
import { useConfigContextInject } from '../config-provider/context' ;
4
4
import useConfigInject from '../config-provider/hooks/useConfigInject' ;
5
5
import useStyle from './style' ;
6
- import classNames from '../_util/classNames' ;
7
6
import { isPresetSize } from '../_util/gapSize' ;
8
7
import omit from '../_util/omit' ;
9
8
import { withInstall } from '../_util/type' ;
@@ -19,26 +18,20 @@ const AFlex = defineComponent({
19
18
const { flex : ctxFlex , direction : ctxDirection } = useConfigContextInject ( ) ;
20
19
const { prefixCls } = useConfigInject ( 'flex' , props ) ;
21
20
const [ wrapSSR , hashId ] = useStyle ( prefixCls ) ;
22
- const flexRef = shallowRef ( ) ;
23
-
21
+ const mergedCls = computed ( ( ) => [
22
+ prefixCls . value ,
23
+ hashId . value ,
24
+ createFlexClassNames ( prefixCls . value , props ) ,
25
+ {
26
+ [ `${ prefixCls . value } -rtl` ] : ctxDirection . value === 'rtl' ,
27
+ [ `${ prefixCls . value } -gap-${ props . gap } ` ] : isPresetSize ( props . gap ) ,
28
+ [ `${ prefixCls . value } -vertical` ] : props . vertical ?? ctxFlex ?. value . vertical ,
29
+ } ,
30
+ ] ) ;
24
31
return ( ) => {
25
- const { flex, gap, vertical = false , component : Component = 'div' , ...othersProps } = props ;
26
-
27
- const mergedVertical = vertical ?? ctxFlex ?. value . vertical ;
28
-
29
- const mergedCls = classNames (
30
- attrs . class ,
31
- prefixCls . value ,
32
- hashId . value ,
33
- createFlexClassNames ( prefixCls . value , props ) ,
34
- {
35
- [ `${ prefixCls . value } -rtl` ] : ctxDirection . value === 'rtl' ,
36
- [ `${ prefixCls . value } -gap-${ gap } ` ] : isPresetSize ( gap ) ,
37
- [ `${ prefixCls . value } -vertical` ] : mergedVertical ,
38
- } ,
39
- ) ;
32
+ const { flex, gap, component : Component = 'div' , ...othersProps } = props ;
40
33
41
- const mergedStyle = { ... ( attrs . style as CSSProperties ) } ;
34
+ const mergedStyle : CSSProperties = { } ;
42
35
43
36
if ( flex ) {
44
37
mergedStyle . flex = flex ;
@@ -50,10 +43,9 @@ const AFlex = defineComponent({
50
43
51
44
return wrapSSR (
52
45
< Component
53
- ref = { flexRef . value }
54
- class = { mergedCls }
55
- style = { mergedStyle }
56
- { ...omit ( othersProps , [ 'justify' , 'wrap' , 'align' ] ) }
46
+ class = { [ attrs . class , mergedCls . value ] }
47
+ style = { [ attrs . style as CSSProperties , mergedStyle ] }
48
+ { ...omit ( othersProps , [ 'justify' , 'wrap' , 'align' , 'vertical' ] ) }
57
49
>
58
50
{ slots . default ?.( ) }
59
51
</ Component > ,
0 commit comments