@@ -10,6 +10,8 @@ type ScalarDict = {
10
10
[ key : string ] : Scalar
11
11
}
12
12
13
+ export type CellProps = React . PropsWithChildren < { column : number } >
14
+
13
15
export type TableProps < T extends ScalarDict > = {
14
16
/**
15
17
* List of values (rows).
@@ -30,7 +32,7 @@ export type TableProps<T extends ScalarDict> = {
30
32
/**
31
33
* Component used to render a cell in the table.
32
34
*/
33
- cell : ( props : React . PropsWithChildren < { } > ) => JSX . Element
35
+ cell : ( props : CellProps ) => JSX . Element
34
36
/**
35
37
* Component used to render the skeleton of the table.
36
38
*/
@@ -233,7 +235,7 @@ type RowConfig = {
233
235
/**
234
236
* Component used to render cells.
235
237
*/
236
- cell : ( props : React . PropsWithChildren < { } > ) => JSX . Element
238
+ cell : ( props : CellProps ) => JSX . Element
237
239
/**
238
240
* Tells the padding of each cell.
239
241
*/
@@ -295,15 +297,15 @@ function row<T extends ScalarDict>(
295
297
} ,
296
298
297
299
// Values.
298
- props . columns . map ( ( column ) => {
300
+ props . columns . map ( ( column , colI ) => {
299
301
// content
300
302
const value = props . data [ column . column ]
301
303
302
304
if ( value == undefined || value == null ) {
303
305
const key = `${ props . key } -empty-${ column . key } `
304
306
305
307
return (
306
- < config . cell key = { key } >
308
+ < config . cell key = { key } column = { colI } >
307
309
{ skeleton . line . repeat ( column . width ) }
308
310
</ config . cell >
309
311
)
@@ -316,7 +318,7 @@ function row<T extends ScalarDict>(
316
318
317
319
return (
318
320
/* prettier-ignore */
319
- < config . cell key = { key } >
321
+ < config . cell key = { key } column = { colI } >
320
322
{ `${ skeleton . line . repeat ( ml ) } ${ String ( value ) } ${ skeleton . line . repeat ( mr ) } ` }
321
323
</ config . cell >
322
324
)
@@ -343,7 +345,7 @@ export function Header(props: React.PropsWithChildren<{}>) {
343
345
/**
344
346
* Renders a cell in the table.
345
347
*/
346
- export function Cell ( props : React . PropsWithChildren < { } > ) {
348
+ export function Cell ( props : CellProps ) {
347
349
return < Text > { props . children } </ Text >
348
350
}
349
351
0 commit comments