react-live-data-table 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/ReactDataTable.jsx +40 -27
package/package.json
CHANGED
package/src/ReactDataTable.jsx
CHANGED
@@ -16,8 +16,10 @@ function ReactDataTable({
|
|
16
16
|
emptyText,
|
17
17
|
rowHeights = 40,
|
18
18
|
headerProps = {},
|
19
|
-
selected={},
|
20
|
-
showSelectAllCheckbox=true
|
19
|
+
selected = {},
|
20
|
+
showSelectAllCheckbox = true,
|
21
|
+
rowStyle = {},
|
22
|
+
rowClassName = ""
|
21
23
|
}) {
|
22
24
|
const tableContainerRef = React.useRef(null);
|
23
25
|
const [data, setData] = React.useState({ pages: [], meta: { totalPages: 1 } });
|
@@ -205,7 +207,7 @@ function ReactDataTable({
|
|
205
207
|
const enhancedColumns = showCheckbox ? [checkboxColumn, ...columns] : columns;
|
206
208
|
|
207
209
|
return (
|
208
|
-
<div className="bg-white relative w-full">
|
210
|
+
<div className="bg-white relative w-full react-live-data-table" >
|
209
211
|
{loading && (
|
210
212
|
<div className="absolute inset-0 bg-white/50 z-20 flex items-center justify-center">
|
211
213
|
<svg
|
@@ -260,10 +262,12 @@ function ReactDataTable({
|
|
260
262
|
style={{ ...headerProps.style }}
|
261
263
|
>
|
262
264
|
<tr>
|
263
|
-
{enhancedColumns.map(column => (
|
265
|
+
{enhancedColumns.map((column, columnIndex) => (
|
264
266
|
<th
|
265
267
|
key={column.accessorKey || column.id}
|
266
|
-
className=
|
268
|
+
className={`text-left font-normal h-[40px] border-b border-t border-solid border-[#e4e3e2] ${
|
269
|
+
columnIndex < enhancedColumns.length - 1 ? 'border-r' : ''
|
270
|
+
}`}
|
267
271
|
style={{
|
268
272
|
width: column.size,
|
269
273
|
minWidth: column.minWidth,
|
@@ -277,28 +281,37 @@ function ReactDataTable({
|
|
277
281
|
</thead>
|
278
282
|
<tbody>
|
279
283
|
{flatData.length > 0 ? (
|
280
|
-
flatData.map((row, index) =>
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
284
|
+
flatData.map((row, index) => {
|
285
|
+
const isLastRow = index === flatData.length - 1;
|
286
|
+
return (
|
287
|
+
<tr
|
288
|
+
key={row.id}
|
289
|
+
className={`border-t ${isLastRow ? 'border-b' : ''} border-gray-200 hover:bg-[#dee1f2] ${selectedRows[row.id] ? 'bg-[#dee1f2]' : ''} ${rowClassName}`}
|
290
|
+
style={{
|
291
|
+
height: `${rowHeights}px`,
|
292
|
+
...rowStyle,
|
293
|
+
...(typeof rowStyle === 'function' ? rowStyle(row, index) : {})
|
294
|
+
}}
|
295
|
+
onClick={() => handleRowClick(row, index, flatData)}
|
296
|
+
>
|
297
|
+
{enhancedColumns.map((column, cellIndex) => (
|
298
|
+
<td
|
299
|
+
key={column.accessorKey || column.id}
|
300
|
+
className={`text-left font-normal ${
|
301
|
+
cellIndex < enhancedColumns.length-1 ? 'border-r' : ''
|
302
|
+
} ${column?.cellProps?.className || ''}`}
|
303
|
+
style={{
|
304
|
+
minWidth: `${column.minWidth}px`,
|
305
|
+
textAlign: column?.textAlign,
|
306
|
+
...column?.cellProps?.style,
|
307
|
+
}}
|
308
|
+
>
|
309
|
+
{typeof column.cell === 'function' ? column.cell({ row }) : null}
|
310
|
+
</td>
|
311
|
+
))}
|
312
|
+
</tr>
|
313
|
+
);
|
314
|
+
})
|
302
315
|
) : (
|
303
316
|
<tr>
|
304
317
|
<td colSpan={enhancedColumns.length} className="text-center py-4">
|