1- import { defineComponent , shallowRef } from 'vue' ;
1+ import { computed , defineComponent } from 'vue' ;
22import type { CSSProperties } from 'vue' ;
33import { useConfigContextInject } from '../config-provider/context' ;
44import useConfigInject from '../config-provider/hooks/useConfigInject' ;
55import useStyle from './style' ;
6- import classNames from '../_util/classNames' ;
76import { isPresetSize } from '../_util/gapSize' ;
87import omit from '../_util/omit' ;
98import { withInstall } from '../_util/type' ;
@@ -19,26 +18,20 @@ const AFlex = defineComponent({
1918 const { flex : ctxFlex , direction : ctxDirection } = useConfigContextInject ( ) ;
2019 const { prefixCls } = useConfigInject ( 'flex' , props ) ;
2120 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+ ] ) ;
2431 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 ;
4033
41- const mergedStyle = { ... ( attrs . style as CSSProperties ) } ;
34+ const mergedStyle : CSSProperties = { } ;
4235
4336 if ( flex ) {
4437 mergedStyle . flex = flex ;
@@ -50,10 +43,9 @@ const AFlex = defineComponent({
5043
5144 return wrapSSR (
5245 < 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' ] ) }
5749 >
5850 { slots . default ?.( ) }
5951 </ Component > ,
0 commit comments