@@ -20,22 +20,25 @@ import {
20
20
ButtonLink ,
21
21
ButtonLinkProps ,
22
22
BodyProps ,
23
+ LabelProps ,
23
24
} from ".." ;
24
25
import { useBentoConfig } from "../BentoConfigContext" ;
26
+ import { mergeProps } from "@react-aria/utils" ;
25
27
26
28
export function ButtonCell ( {
27
29
value : buttonProps ,
28
30
column : { align } ,
29
- options : { size } ,
31
+ options,
30
32
} : CellProps < { } , Omit < ButtonProps , "size" > > & {
31
33
options : Partial < Pick < ButtonProps , "size" > > ;
32
34
} ) {
33
35
const config = useBentoConfig ( ) . table ;
36
+ const { size } = mergeProps ( config . defaultCellOptions . buttonCell , options ) ;
34
37
const padding = config . padding . buttonCell ?? config . padding . defaultCell ;
35
38
return (
36
39
< Inset spaceX = { padding . paddingX } spaceY = { padding . paddingY } >
37
40
< Inline space = { 0 } align = { align } alignY = "center" >
38
- < Button size = { size ?? "medium" } { ...buttonProps } />
41
+ < Button size = { size } { ...buttonProps } />
39
42
</ Inline >
40
43
</ Inset >
41
44
) ;
@@ -44,16 +47,17 @@ export function ButtonCell({
44
47
export function ButtonLinkCell ( {
45
48
value : buttonProps ,
46
49
column : { align } ,
47
- options : { size } ,
50
+ options,
48
51
} : CellProps < { } , Omit < ButtonLinkProps , "size" > > & {
49
52
options : Partial < Pick < ButtonLinkProps , "size" > > ;
50
53
} ) {
51
54
const config = useBentoConfig ( ) . table ;
55
+ const { size } = mergeProps ( config . defaultCellOptions . buttonLinkCell , options ) ;
52
56
const padding = config . padding . buttonLinkCell ?? config . padding . defaultCell ;
53
57
return (
54
58
< Inset spaceX = { padding . paddingX } spaceY = { padding . paddingY } >
55
59
< Inline space = { 0 } align = { align } >
56
- < ButtonLink size = { size ?? "medium" } { ...buttonProps } />
60
+ < ButtonLink size = { size } { ...buttonProps } />
57
61
</ Inline >
58
62
</ Inset >
59
63
) ;
@@ -62,15 +66,16 @@ export function ButtonLinkCell({
62
66
export function TextCell ( {
63
67
value,
64
68
column : { align } ,
65
- options : { size , weight , color } ,
69
+ options,
66
70
} : CellProps < { } , LocalizedString > & {
67
71
options : Partial < Pick < BodyProps , "size" | "weight" | "color" > > ;
68
72
} ) {
69
73
const config = useBentoConfig ( ) . table ;
70
74
const padding = config . padding . textCell ?? config . padding . defaultCell ;
75
+ const { size, weight, color } = mergeProps ( config . defaultCellOptions . textCell , options ) ;
71
76
return (
72
77
< Box { ...padding } textAlign = { align } >
73
- < Body size = { size ?? "medium" } weight = { weight } color = { color } >
78
+ < Body size = { size } weight = { weight } color = { color } >
74
79
{ value }
75
80
</ Body >
76
81
</ Box >
@@ -80,7 +85,7 @@ export function TextCell({
80
85
export function TextWithIconCell ( {
81
86
value : { icon, iconPosition, text, tooltipContent } ,
82
87
column : { align } ,
83
- options : { size , weight , color , iconSize , iconColor } ,
88
+ options,
84
89
} : CellProps <
85
90
{ } ,
86
91
{
@@ -96,8 +101,12 @@ export function TextWithIconCell({
96
101
} ;
97
102
} ) {
98
103
const config = useBentoConfig ( ) . table ;
104
+ const { size, weight, color, iconSize, iconColor } = mergeProps (
105
+ config . defaultCellOptions . textWithIconCell ,
106
+ options
107
+ ) ;
99
108
const padding = config . padding . textWithIconCell ?? config . padding . defaultCell ;
100
- const icon_ = icon && icon ( { size : iconSize ?? 12 , color : iconColor } ) ;
109
+ const icon_ = icon && icon ( { size : iconSize , color : iconColor } ) ;
101
110
102
111
return (
103
112
< Inset spaceX = { padding . paddingX } spaceY = { padding . paddingY } >
@@ -115,7 +124,7 @@ export function TextWithIconCell({
115
124
) : (
116
125
icon_
117
126
) }
118
- < Body size = { size ?? "medium" } weight = { weight } color = { color } >
127
+ < Body size = { size } weight = { weight } color = { color } >
119
128
{ text }
120
129
</ Body >
121
130
</ Inline >
@@ -135,28 +144,38 @@ export function ChipCell({ value: chipProps, column: { align } }: CellProps<{},
135
144
) ;
136
145
}
137
146
138
- export function LabelCell ( { value, column : { align } } : CellProps < { } , LocalizedString > ) {
147
+ export function LabelCell ( {
148
+ value,
149
+ column : { align } ,
150
+ options,
151
+ } : CellProps < { } , LocalizedString > & {
152
+ options : Partial < Pick < LabelProps , "size" | "color" > > ;
153
+ } ) {
139
154
const config = useBentoConfig ( ) . table ;
140
155
const padding = config . padding . labelCell ?? config . padding . defaultCell ;
156
+ const { size, color } = mergeProps ( config . defaultCellOptions . labelCell , options ) ;
141
157
return (
142
158
< Box { ...padding } textAlign = { align } >
143
- < Label size = "large" > { value } </ Label >
159
+ < Label size = { size } color = { color } >
160
+ { value }
161
+ </ Label >
144
162
</ Box >
145
163
) ;
146
164
}
147
165
148
166
export function LinkCell ( {
149
167
value,
150
168
column : { align } ,
151
- options : { size , weight } ,
169
+ options,
152
170
} : CellProps < { } , ComponentProps < typeof Link > > & {
153
171
options : Partial < Pick < BodyProps , "size" | "weight" > > ;
154
172
} ) {
155
173
const config = useBentoConfig ( ) . table ;
156
174
const padding = config . padding . linkCell ?? config . padding . defaultCell ;
175
+ const { size, weight } = mergeProps ( config . defaultCellOptions . linkCell , options ) ;
157
176
return (
158
177
< Box { ...padding } textAlign = { align } >
159
- < Body size = { size ?? "medium" } weight = { weight } >
178
+ < Body size = { size } weight = { weight } >
160
179
< Link { ...value } />
161
180
</ Body >
162
181
</ Box >
@@ -166,37 +185,35 @@ export function LinkCell({
166
185
export function IconCell ( {
167
186
value,
168
187
column : { align } ,
169
- options : { size , color } ,
188
+ options,
170
189
} : CellProps < { } , { icon : ( props : IconProps ) => JSX . Element ; label : LocalizedString } > & {
171
190
options : Partial < Pick < IconProps , "size" | "color" > > ;
172
191
} ) {
173
192
const config = useBentoConfig ( ) . table ;
193
+ const { size, color } = mergeProps ( config . defaultCellOptions . iconCell , options ) ;
174
194
const padding = config . padding . iconCell ?? config . padding . defaultCell ;
175
195
return (
176
196
< Box { ...padding } textAlign = { align } aria-label = { value . label } >
177
- { value . icon ( { size : size ?? 16 , color : color ?? "default" } ) }
197
+ { value . icon ( { size, color } ) }
178
198
</ Box >
179
199
) ;
180
200
}
181
201
182
202
export function IconButtonCell ( {
183
203
value : iconButtonProps ,
184
204
column : { align } ,
185
- options : { size , hierarchy , kind } ,
205
+ options,
186
206
} : CellProps < { } , Omit < IconButtonProps , "size" | "kind" | "hierarchy" > > & {
187
207
options : Partial < Pick < IconButtonProps , "size" | "kind" | "hierarchy" > > ;
188
208
} ) {
189
209
const config = useBentoConfig ( ) . table ;
210
+ const { size, hierarchy, kind } = mergeProps ( config . defaultCellOptions . iconButtonCell , options ) ;
190
211
const padding = config . padding . iconButtonCell ?? config . padding . defaultCell ;
212
+
191
213
return (
192
214
< Inset spaceX = { padding . paddingX } spaceY = { padding . paddingY } >
193
215
< Inline space = { 0 } align = { align } alignY = "center" >
194
- < IconButton
195
- kind = { kind ?? "transparent" }
196
- hierarchy = { hierarchy ?? "primary" }
197
- size = { size ?? 16 }
198
- { ...iconButtonProps }
199
- />
216
+ < IconButton kind = { kind } hierarchy = { hierarchy } size = { size } { ...iconButtonProps } />
200
217
</ Inline >
201
218
</ Inset >
202
219
) ;
0 commit comments