@@ -14,7 +14,10 @@ export interface DataTableProps
14
14
extends PropsWithChildren ,
15
15
Omit < ComponentProps < "div" > , "ref" > {
16
16
bordered ?: boolean ;
17
+ /** Children to send to DataTableCaption */
17
18
caption ?: ReactNode ;
19
+ /** Props to send to DataTableCaption. Ensure this object is memoized. */
20
+ captionProps ?: Omit < DataTableCaptionProps , "children" > ;
18
21
/** The <th /> index from 0 to scroll to within <thead />'s first row */
19
22
centeredColumnIndex ?: number ;
20
23
/** @deprecated See centeredColumnIndex */
@@ -52,6 +55,7 @@ export interface DataTableProps
52
55
53
56
export const DataTableComponent : FC < DataTableProps > = ( {
54
57
caption : captionChildren ,
58
+ captionProps,
55
59
centeredColumnIndex,
56
60
centeredIndex : deprecatedCenteredColumnIndex ,
57
61
centeredRowIndex,
@@ -150,7 +154,7 @@ export const DataTableComponent: FC<DataTableProps> = ({
150
154
>
151
155
< THead columns = { columns } stickyColumns = { stickyColumns } />
152
156
< tbody
153
- className = { "group/body divide-y text-gray-500 dark:text-gray-200" }
157
+ className = { "group/body divide-y text-gray-800 dark:text-gray-200" }
154
158
>
155
159
{ loading
156
160
? new Array ( loadingRows ) . fill ( 0 ) . map ( ( _ , y ) => (
@@ -169,7 +173,13 @@ export const DataTableComponent: FC<DataTableProps> = ({
169
173
: children }
170
174
</ tbody >
171
175
{ captionChildren && (
172
- < caption className = "sticky left-4 w-fit *:justify-start" >
176
+ < caption
177
+ { ...captionProps }
178
+ className = { twMerge (
179
+ "sticky left-4 w-fit *:justify-start" ,
180
+ captionProps ?. className ,
181
+ ) }
182
+ >
173
183
< DataTable . Caption > { captionChildren } </ DataTable . Caption >
174
184
</ caption >
175
185
) }
@@ -280,26 +290,17 @@ const DataTableCell = forwardRef<HTMLTableCellElement, DataTableCellProps>(
280
290
) ;
281
291
DataTableCell . displayName = "DataTable.Cell" ;
282
292
283
- export type DataTableCaptionProps = {
284
- className ?: string ;
285
- children ?: ReactNode ;
286
- } ;
287
-
288
- export const DataTableCaption : FC < DataTableCaptionProps > = function ( {
289
- children,
290
- className,
291
- } ) {
292
- return (
293
- < span
294
- className = { twMerge (
295
- "mt-4 flex justify-center text-sm text-gray-500 dark:text-gray-400" ,
296
- className ,
297
- ) }
298
- >
299
- { children }
300
- </ span >
301
- ) ;
302
- } ;
293
+ export type DataTableCaptionProps = ComponentProps < "span" > ;
294
+ /** An inline component styled to look like a <caption />. Through DataTable it is embedded inside <caption /> */
295
+ export const DataTableCaption : FC < DataTableCaptionProps > = ( props ) => (
296
+ < span
297
+ { ...props }
298
+ className = { twMerge (
299
+ "mt-2 flex justify-center text-sm text-gray-600 dark:text-gray-400" ,
300
+ props . className ,
301
+ ) }
302
+ />
303
+ ) ;
303
304
304
305
const dataTableHeaderColorsClassNames = "bg-gray-100 dark:bg-gray-700" ;
305
306
0 commit comments