1
1
import Cell from './Cell' ;
2
2
import { getSlot , getClass , getStyle } from '../_util/props-util' ;
3
- import type { FunctionalComponent , VNode } from 'vue' ;
3
+ import type { CSSProperties , FunctionalComponent , VNode } from 'vue' ;
4
4
import { inject , ref } from 'vue' ;
5
- import type { DescriptionsContextProp } from './index' ;
6
5
import { descriptionsContext } from './index' ;
7
6
8
7
interface CellConfig {
@@ -32,29 +31,29 @@ const Row: FunctionalComponent<RowProps> = props => {
32
31
showContent,
33
32
labelStyle : rootLabelStyle ,
34
33
contentStyle : rootContentStyle ,
35
- } : CellConfig & DescriptionsContextProp ,
34
+ } : CellConfig & { labelStyle ?: CSSProperties ; contentStyle ?: CSSProperties } ,
36
35
) => {
37
36
return items . map ( ( item , index ) => {
37
+ const itemProps = item . props || { } ;
38
38
const {
39
39
prefixCls : itemPrefixCls = prefixCls ,
40
40
span = 1 ,
41
- labelStyle,
42
- contentStyle,
41
+ labelStyle = itemProps [ 'label-style' ] ,
42
+ contentStyle = itemProps [ 'content-style' ] ,
43
43
label = ( item . children as any ) ?. label ?.( ) ,
44
- } = item . props || { } ;
44
+ } = itemProps ;
45
45
const children = getSlot ( item ) ;
46
46
const className = getClass ( item ) ;
47
47
const style = getStyle ( item ) ;
48
48
const { key } = item ;
49
-
50
49
if ( typeof component === 'string' ) {
51
50
return (
52
51
< Cell
53
52
key = { `${ type } -${ String ( key ) || index } ` }
54
53
class = { className }
55
54
style = { style }
56
- labelStyle = { { ...rootLabelStyle . value , ...labelStyle } }
57
- contentStyle = { { ...rootContentStyle . value , ...contentStyle } }
55
+ labelStyle = { { ...rootLabelStyle , ...labelStyle } }
56
+ contentStyle = { { ...rootContentStyle , ...contentStyle } }
58
57
span = { span }
59
58
colon = { colon }
60
59
component = { component }
@@ -70,7 +69,7 @@ const Row: FunctionalComponent<RowProps> = props => {
70
69
< Cell
71
70
key = { `label-${ String ( key ) || index } ` }
72
71
class = { className }
73
- style = { { ...rootLabelStyle . value , ...style , ...labelStyle } }
72
+ style = { { ...rootLabelStyle , ...style , ...labelStyle } }
74
73
span = { 1 }
75
74
colon = { colon }
76
75
component = { component [ 0 ] }
@@ -81,7 +80,7 @@ const Row: FunctionalComponent<RowProps> = props => {
81
80
< Cell
82
81
key = { `content-${ String ( key ) || index } ` }
83
82
class = { className }
84
- style = { { ...rootContentStyle . value , ...style , ...contentStyle } }
83
+ style = { { ...rootContentStyle , ...style , ...contentStyle } }
85
84
span = { span * 2 - 1 }
86
85
component = { component [ 1 ] }
87
86
itemPrefixCls = { itemPrefixCls }
@@ -105,17 +104,17 @@ const Row: FunctionalComponent<RowProps> = props => {
105
104
component : 'th' ,
106
105
type : 'label' ,
107
106
showLabel : true ,
108
- labelStyle,
109
- contentStyle,
107
+ labelStyle : labelStyle . value ,
108
+ contentStyle : contentStyle . value ,
110
109
} ) }
111
110
</ tr >
112
111
< tr key = { `content-${ index } ` } class = { `${ prefixCls } -row` } >
113
112
{ renderCells ( row , props , {
114
113
component : 'td' ,
115
114
type : 'content' ,
116
115
showContent : true ,
117
- labelStyle,
118
- contentStyle,
116
+ labelStyle : labelStyle . value ,
117
+ contentStyle : contentStyle . value ,
119
118
} ) }
120
119
</ tr >
121
120
</ >
@@ -129,8 +128,8 @@ const Row: FunctionalComponent<RowProps> = props => {
129
128
type : 'item' ,
130
129
showLabel : true ,
131
130
showContent : true ,
132
- labelStyle,
133
- contentStyle,
131
+ labelStyle : labelStyle . value ,
132
+ contentStyle : contentStyle . value ,
134
133
} ) }
135
134
</ tr >
136
135
) ;
0 commit comments