1
1
import type { VNodeTypes , PropType , VNode , ExtractPropTypes , CSSProperties } from 'vue' ;
2
2
import { isVNode , defineComponent , renderSlot } from 'vue' ;
3
3
import Tabs from '../tabs' ;
4
- import Row from '../row' ;
5
- import Col from '../col' ;
6
4
import PropTypes from '../_util/vue-types' ;
7
5
import { flattenChildren , isEmptyElement , filterEmptyWithUndefined } from '../_util/props-util' ;
8
6
import type { SizeType } from '../config-provider' ;
9
7
import isPlainObject from 'lodash-es/isPlainObject' ;
10
8
import useConfigInject from '../config-provider/hooks/useConfigInject' ;
11
9
import devWarning from '../vc-util/devWarning' ;
10
+ import useStyle from './style' ;
11
+ import Skeleton from '../skeleton' ;
12
12
export interface CardTabListType {
13
13
key : string ;
14
14
tab : any ;
@@ -51,10 +51,12 @@ export type CardProps = Partial<ExtractPropTypes<ReturnType<typeof cardProps>>>;
51
51
const Card = defineComponent ( {
52
52
compatConfig : { MODE : 3 } ,
53
53
name : 'ACard' ,
54
+ inheritAttrs : false ,
54
55
props : cardProps ( ) ,
55
56
slots : [ 'title' , 'extra' , 'tabBarExtraContent' , 'actions' , 'cover' , 'customTab' ] ,
56
- setup ( props , { slots } ) {
57
+ setup ( props , { slots, attrs } ) {
57
58
const { prefixCls, direction, size } = useConfigInject ( 'card' , props ) ;
59
+ const [ wrapSSR , hashId ] = useStyle ( prefixCls ) ;
58
60
const getAction = ( actions : VNodeTypes [ ] ) => {
59
61
const actionList = actions . map ( ( action , index ) =>
60
62
( isVNode ( action ) && ! isEmptyElement ( action ) ) || ! isVNode ( action ) ? (
@@ -99,6 +101,7 @@ const Card = defineComponent({
99
101
const pre = prefixCls . value ;
100
102
const classString = {
101
103
[ `${ pre } ` ] : true ,
104
+ [ hashId . value ] : true ,
102
105
[ `${ pre } -loading` ] : loading ,
103
106
[ `${ pre } -bordered` ] : bordered ,
104
107
[ `${ pre } -hoverable` ] : ! ! hoverable ,
@@ -108,34 +111,10 @@ const Card = defineComponent({
108
111
[ `${ pre } -type-${ type } ` ] : ! ! type ,
109
112
[ `${ pre } -rtl` ] : direction . value === 'rtl' ,
110
113
} ;
111
-
112
- const loadingBlockStyle =
113
- bodyStyle . padding === 0 || bodyStyle . padding === '0px' ? { padding : '24px' } : undefined ;
114
-
115
- const block = < div class = { `${ pre } -loading-block` } /> ;
116
114
const loadingBlock = (
117
- < div class = { `${ pre } -loading-content` } style = { loadingBlockStyle } >
118
- < Row gutter = { 8 } >
119
- < Col span = { 22 } > { block } </ Col >
120
- </ Row >
121
- < Row gutter = { 8 } >
122
- < Col span = { 8 } > { block } </ Col >
123
- < Col span = { 15 } > { block } </ Col >
124
- </ Row >
125
- < Row gutter = { 8 } >
126
- < Col span = { 6 } > { block } </ Col >
127
- < Col span = { 18 } > { block } </ Col >
128
- </ Row >
129
- < Row gutter = { 8 } >
130
- < Col span = { 13 } > { block } </ Col >
131
- < Col span = { 9 } > { block } </ Col >
132
- </ Row >
133
- < Row gutter = { 8 } >
134
- < Col span = { 4 } > { block } </ Col >
135
- < Col span = { 3 } > { block } </ Col >
136
- < Col span = { 16 } > { block } </ Col >
137
- </ Row >
138
- </ div >
115
+ < Skeleton loading active paragraph = { { rows : 4 } } title = { false } >
116
+ { children }
117
+ </ Skeleton >
139
118
) ;
140
119
141
120
const hasActiveTabKey = activeTabKey !== undefined ;
@@ -190,13 +169,13 @@ const Card = defineComponent({
190
169
const actionDom =
191
170
actions && actions . length ? < ul class = { `${ pre } -actions` } > { getAction ( actions ) } </ ul > : null ;
192
171
193
- return (
194
- < div class = { classString } ref = "cardContainerRef" >
172
+ return wrapSSR (
173
+ < div ref = "cardContainerRef" { ... attrs } class = { [ classString , attrs . class ] } >
195
174
{ head }
196
175
{ coverDom }
197
176
{ children && children . length ? body : null }
198
177
{ actionDom }
199
- </ div >
178
+ </ div > ,
200
179
) ;
201
180
} ;
202
181
} ,
0 commit comments