bolt-table 0.1.18 → 0.1.19
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/dist/index.d.mts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +24 -8
- package/dist/index.mjs +24 -8
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -232,6 +232,10 @@ interface BoltTableProps<T extends DataRecord = DataRecord> {
|
|
|
232
232
|
readonly layoutLoading?: boolean;
|
|
233
233
|
/** Custom React node to render when the table has no data and is not loading. */
|
|
234
234
|
readonly emptyRenderer?: React$1.ReactNode;
|
|
235
|
+
/** Returns a CSS class name for a given row based on its record and index. Useful for Tailwind or any CSS class-based conditional row styling. */
|
|
236
|
+
readonly rowClassName?: (record: T, index: number) => string;
|
|
237
|
+
/** Returns inline CSS styles for a given row based on its record and index. Useful for dynamic per-row styling. */
|
|
238
|
+
readonly rowStyle?: (record: T, index: number) => React$1.CSSProperties;
|
|
235
239
|
}
|
|
236
240
|
interface ClassNamesTypes {
|
|
237
241
|
/** Applied to all non-pinned column header cells. */
|
|
@@ -277,7 +281,7 @@ interface StylesTypes {
|
|
|
277
281
|
/** CSS color string for pinned column cells and headers background. */
|
|
278
282
|
pinnedBg?: string;
|
|
279
283
|
}
|
|
280
|
-
declare function BoltTable<T extends DataRecord = DataRecord>({ columns: initialColumns, data, rowHeight, expandedRowHeight, maxExpandedRowHeight, accentColor, className, classNames, styles, gripIcon, hideGripIcon, icons, pagination, onPaginationChange, onColumnResize, onColumnOrderChange, onColumnPin, onColumnHide, rowSelection, rowPinning, onRowPin, expandable, rowKey, onEndReached, onEndReachedThreshold, isLoading, onSortChange, onFilterChange, columnContextMenuItems, autoHeight, layoutLoading, emptyRenderer, }: BoltTableProps<T>): react_jsx_runtime.JSX.Element;
|
|
284
|
+
declare function BoltTable<T extends DataRecord = DataRecord>({ columns: initialColumns, data, rowHeight, expandedRowHeight, maxExpandedRowHeight, accentColor, className, classNames, styles, gripIcon, hideGripIcon, icons, pagination, onPaginationChange, onColumnResize, onColumnOrderChange, onColumnPin, onColumnHide, rowSelection, rowPinning, onRowPin, expandable, rowKey, onEndReached, onEndReachedThreshold, isLoading, onSortChange, onFilterChange, columnContextMenuItems, autoHeight, layoutLoading, emptyRenderer, rowClassName, rowStyle, }: BoltTableProps<T>): react_jsx_runtime.JSX.Element;
|
|
281
285
|
|
|
282
286
|
interface DraggableHeaderProps {
|
|
283
287
|
/** Column definition for this header cell. */
|
|
@@ -381,7 +385,11 @@ interface TableBodyProps {
|
|
|
381
385
|
gridTemplateColumns?: string;
|
|
382
386
|
/** Height of the column header row in pixels */
|
|
383
387
|
headerHeight?: number;
|
|
388
|
+
/** Returns a CSS class name for a given row based on its record and index */
|
|
389
|
+
rowClassName?: (record: DataRecord, index: number) => string;
|
|
390
|
+
/** Returns inline CSS styles for a given row based on its record and index */
|
|
391
|
+
rowStyle?: (record: DataRecord, index: number) => React$1.CSSProperties;
|
|
384
392
|
}
|
|
385
393
|
declare const TableBody: React$1.FC<TableBodyProps>;
|
|
386
394
|
|
|
387
|
-
export { BoltTable, type BoltTableIcons, type CellContextMenuItem, type ColumnContextMenuItem, type ColumnType, type DataRecord, DraggableHeader, type ExpandableConfig, type PaginationType, ResizeOverlay, type RowPinningConfig, type RowSelectionConfig, type SortDirection, TableBody };
|
|
395
|
+
export { BoltTable, type BoltTableIcons, type CellContextMenuItem, type ClassNamesTypes, type ColumnContextMenuItem, type ColumnType, type DataRecord, DraggableHeader, type ExpandableConfig, type PaginationType, ResizeOverlay, type RowPinningConfig, type RowSelectionConfig, type SortDirection, type StylesTypes, TableBody };
|
package/dist/index.d.ts
CHANGED
|
@@ -232,6 +232,10 @@ interface BoltTableProps<T extends DataRecord = DataRecord> {
|
|
|
232
232
|
readonly layoutLoading?: boolean;
|
|
233
233
|
/** Custom React node to render when the table has no data and is not loading. */
|
|
234
234
|
readonly emptyRenderer?: React$1.ReactNode;
|
|
235
|
+
/** Returns a CSS class name for a given row based on its record and index. Useful for Tailwind or any CSS class-based conditional row styling. */
|
|
236
|
+
readonly rowClassName?: (record: T, index: number) => string;
|
|
237
|
+
/** Returns inline CSS styles for a given row based on its record and index. Useful for dynamic per-row styling. */
|
|
238
|
+
readonly rowStyle?: (record: T, index: number) => React$1.CSSProperties;
|
|
235
239
|
}
|
|
236
240
|
interface ClassNamesTypes {
|
|
237
241
|
/** Applied to all non-pinned column header cells. */
|
|
@@ -277,7 +281,7 @@ interface StylesTypes {
|
|
|
277
281
|
/** CSS color string for pinned column cells and headers background. */
|
|
278
282
|
pinnedBg?: string;
|
|
279
283
|
}
|
|
280
|
-
declare function BoltTable<T extends DataRecord = DataRecord>({ columns: initialColumns, data, rowHeight, expandedRowHeight, maxExpandedRowHeight, accentColor, className, classNames, styles, gripIcon, hideGripIcon, icons, pagination, onPaginationChange, onColumnResize, onColumnOrderChange, onColumnPin, onColumnHide, rowSelection, rowPinning, onRowPin, expandable, rowKey, onEndReached, onEndReachedThreshold, isLoading, onSortChange, onFilterChange, columnContextMenuItems, autoHeight, layoutLoading, emptyRenderer, }: BoltTableProps<T>): react_jsx_runtime.JSX.Element;
|
|
284
|
+
declare function BoltTable<T extends DataRecord = DataRecord>({ columns: initialColumns, data, rowHeight, expandedRowHeight, maxExpandedRowHeight, accentColor, className, classNames, styles, gripIcon, hideGripIcon, icons, pagination, onPaginationChange, onColumnResize, onColumnOrderChange, onColumnPin, onColumnHide, rowSelection, rowPinning, onRowPin, expandable, rowKey, onEndReached, onEndReachedThreshold, isLoading, onSortChange, onFilterChange, columnContextMenuItems, autoHeight, layoutLoading, emptyRenderer, rowClassName, rowStyle, }: BoltTableProps<T>): react_jsx_runtime.JSX.Element;
|
|
281
285
|
|
|
282
286
|
interface DraggableHeaderProps {
|
|
283
287
|
/** Column definition for this header cell. */
|
|
@@ -381,7 +385,11 @@ interface TableBodyProps {
|
|
|
381
385
|
gridTemplateColumns?: string;
|
|
382
386
|
/** Height of the column header row in pixels */
|
|
383
387
|
headerHeight?: number;
|
|
388
|
+
/** Returns a CSS class name for a given row based on its record and index */
|
|
389
|
+
rowClassName?: (record: DataRecord, index: number) => string;
|
|
390
|
+
/** Returns inline CSS styles for a given row based on its record and index */
|
|
391
|
+
rowStyle?: (record: DataRecord, index: number) => React$1.CSSProperties;
|
|
384
392
|
}
|
|
385
393
|
declare const TableBody: React$1.FC<TableBodyProps>;
|
|
386
394
|
|
|
387
|
-
export { BoltTable, type BoltTableIcons, type CellContextMenuItem, type ColumnContextMenuItem, type ColumnType, type DataRecord, DraggableHeader, type ExpandableConfig, type PaginationType, ResizeOverlay, type RowPinningConfig, type RowSelectionConfig, type SortDirection, TableBody };
|
|
395
|
+
export { BoltTable, type BoltTableIcons, type CellContextMenuItem, type ClassNamesTypes, type ColumnContextMenuItem, type ColumnType, type DataRecord, DraggableHeader, type ExpandableConfig, type PaginationType, ResizeOverlay, type RowPinningConfig, type RowSelectionConfig, type SortDirection, type StylesTypes, TableBody };
|
package/dist/index.js
CHANGED
|
@@ -1085,7 +1085,9 @@ var TableBody = ({
|
|
|
1085
1085
|
pinnedTopData = [],
|
|
1086
1086
|
pinnedBottomData = [],
|
|
1087
1087
|
gridTemplateColumns,
|
|
1088
|
-
headerHeight = 36
|
|
1088
|
+
headerHeight = 36,
|
|
1089
|
+
rowClassName,
|
|
1090
|
+
rowStyle
|
|
1089
1091
|
}) => {
|
|
1090
1092
|
const virtualItems = rowVirtualizer.getVirtualItems();
|
|
1091
1093
|
const totalSize = rowVirtualizer.getTotalSize();
|
|
@@ -1137,6 +1139,8 @@ var TableBody = ({
|
|
|
1137
1139
|
const cellValue = row[col.dataIndex];
|
|
1138
1140
|
const isRowShimmer = isLoading || rowKey.startsWith("__shimmer_");
|
|
1139
1141
|
const recordFingerprint = hasRender && !isRowShimmer ? JSON.stringify(row) : void 0;
|
|
1142
|
+
const rowCls = rowClassName ? rowClassName(row, virtualRow.index) : "";
|
|
1143
|
+
const rowSty = rowStyle ? rowStyle(row, virtualRow.index) : void 0;
|
|
1140
1144
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1141
1145
|
"div",
|
|
1142
1146
|
{
|
|
@@ -1144,12 +1148,14 @@ var TableBody = ({
|
|
|
1144
1148
|
"data-column-key": col.key,
|
|
1145
1149
|
"data-bt-cell": "",
|
|
1146
1150
|
"data-selected": isSelected || void 0,
|
|
1151
|
+
className: rowCls || void 0,
|
|
1147
1152
|
style: {
|
|
1148
1153
|
position: "absolute",
|
|
1149
1154
|
top: `${virtualRow.start}px`,
|
|
1150
1155
|
left: 0,
|
|
1151
1156
|
right: 0,
|
|
1152
|
-
height: `${virtualRow.size}px
|
|
1157
|
+
height: `${virtualRow.size}px`,
|
|
1158
|
+
...rowSty
|
|
1153
1159
|
},
|
|
1154
1160
|
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1155
1161
|
"div",
|
|
@@ -1271,15 +1277,18 @@ var TableBody = ({
|
|
|
1271
1277
|
const rk = getRowKey ? getRowKey(row, rowIdx) : String(rowIdx);
|
|
1272
1278
|
const isSelected = selectedKeySet.has(rk);
|
|
1273
1279
|
const isExpanded = resolvedExpandedKeys?.has(rk) ?? false;
|
|
1280
|
+
const rowCls = rowClassName ? rowClassName(row, rowIdx) : "";
|
|
1281
|
+
const rowSty = rowStyle ? rowStyle(row, rowIdx) : void 0;
|
|
1274
1282
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1275
1283
|
"div",
|
|
1276
1284
|
{
|
|
1277
|
-
className: classNames?.pinnedRow ?? "",
|
|
1285
|
+
className: `${classNames?.pinnedRow ?? ""} ${rowCls}`.trim() || void 0,
|
|
1278
1286
|
style: {
|
|
1279
1287
|
display: "grid",
|
|
1280
1288
|
gridTemplateColumns: gridTemplateColumns ?? "",
|
|
1281
1289
|
minWidth: totalTableWidth ? `${totalTableWidth}px` : void 0,
|
|
1282
|
-
...styles?.pinnedRow
|
|
1290
|
+
...styles?.pinnedRow,
|
|
1291
|
+
...rowSty
|
|
1283
1292
|
},
|
|
1284
1293
|
children: orderedColumns.map((col) => {
|
|
1285
1294
|
const cellValue = row[col.dataIndex];
|
|
@@ -1376,15 +1385,18 @@ var TableBody = ({
|
|
|
1376
1385
|
const rk = getRowKey ? getRowKey(row, rowIdx) : String(rowIdx);
|
|
1377
1386
|
const isSelected = selectedKeySet.has(rk);
|
|
1378
1387
|
const isExpanded = resolvedExpandedKeys?.has(rk) ?? false;
|
|
1388
|
+
const rowCls = rowClassName ? rowClassName(row, rowIdx) : "";
|
|
1389
|
+
const rowSty = rowStyle ? rowStyle(row, rowIdx) : void 0;
|
|
1379
1390
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1380
1391
|
"div",
|
|
1381
1392
|
{
|
|
1382
|
-
className: classNames?.pinnedRow ?? "",
|
|
1393
|
+
className: `${classNames?.pinnedRow ?? ""} ${rowCls}`.trim() || void 0,
|
|
1383
1394
|
style: {
|
|
1384
1395
|
display: "grid",
|
|
1385
1396
|
gridTemplateColumns: gridTemplateColumns ?? "",
|
|
1386
1397
|
minWidth: totalTableWidth ? `${totalTableWidth}px` : void 0,
|
|
1387
|
-
...styles?.pinnedRow
|
|
1398
|
+
...styles?.pinnedRow,
|
|
1399
|
+
...rowSty
|
|
1388
1400
|
},
|
|
1389
1401
|
children: orderedColumns.map((col) => {
|
|
1390
1402
|
const cellValue = row[col.dataIndex];
|
|
@@ -1502,7 +1514,9 @@ function BoltTable({
|
|
|
1502
1514
|
columnContextMenuItems,
|
|
1503
1515
|
autoHeight = true,
|
|
1504
1516
|
layoutLoading,
|
|
1505
|
-
emptyRenderer
|
|
1517
|
+
emptyRenderer,
|
|
1518
|
+
rowClassName,
|
|
1519
|
+
rowStyle
|
|
1506
1520
|
}) {
|
|
1507
1521
|
const [columns, setColumns] = (0, import_react4.useState)(initialColumns);
|
|
1508
1522
|
const [columnOrder, setColumnOrder] = (0, import_react4.useState)(
|
|
@@ -2719,7 +2733,9 @@ function BoltTable({
|
|
|
2719
2733
|
pinnedTopData: pinnedTopRows,
|
|
2720
2734
|
pinnedBottomData: pinnedBottomRows,
|
|
2721
2735
|
gridTemplateColumns,
|
|
2722
|
-
headerHeight: HEADER_HEIGHT
|
|
2736
|
+
headerHeight: HEADER_HEIGHT,
|
|
2737
|
+
rowClassName,
|
|
2738
|
+
rowStyle
|
|
2723
2739
|
}
|
|
2724
2740
|
)
|
|
2725
2741
|
]
|
package/dist/index.mjs
CHANGED
|
@@ -1051,7 +1051,9 @@ var TableBody = ({
|
|
|
1051
1051
|
pinnedTopData = [],
|
|
1052
1052
|
pinnedBottomData = [],
|
|
1053
1053
|
gridTemplateColumns,
|
|
1054
|
-
headerHeight = 36
|
|
1054
|
+
headerHeight = 36,
|
|
1055
|
+
rowClassName,
|
|
1056
|
+
rowStyle
|
|
1055
1057
|
}) => {
|
|
1056
1058
|
const virtualItems = rowVirtualizer.getVirtualItems();
|
|
1057
1059
|
const totalSize = rowVirtualizer.getTotalSize();
|
|
@@ -1103,6 +1105,8 @@ var TableBody = ({
|
|
|
1103
1105
|
const cellValue = row[col.dataIndex];
|
|
1104
1106
|
const isRowShimmer = isLoading || rowKey.startsWith("__shimmer_");
|
|
1105
1107
|
const recordFingerprint = hasRender && !isRowShimmer ? JSON.stringify(row) : void 0;
|
|
1108
|
+
const rowCls = rowClassName ? rowClassName(row, virtualRow.index) : "";
|
|
1109
|
+
const rowSty = rowStyle ? rowStyle(row, virtualRow.index) : void 0;
|
|
1106
1110
|
return /* @__PURE__ */ jsx4(
|
|
1107
1111
|
"div",
|
|
1108
1112
|
{
|
|
@@ -1110,12 +1114,14 @@ var TableBody = ({
|
|
|
1110
1114
|
"data-column-key": col.key,
|
|
1111
1115
|
"data-bt-cell": "",
|
|
1112
1116
|
"data-selected": isSelected || void 0,
|
|
1117
|
+
className: rowCls || void 0,
|
|
1113
1118
|
style: {
|
|
1114
1119
|
position: "absolute",
|
|
1115
1120
|
top: `${virtualRow.start}px`,
|
|
1116
1121
|
left: 0,
|
|
1117
1122
|
right: 0,
|
|
1118
|
-
height: `${virtualRow.size}px
|
|
1123
|
+
height: `${virtualRow.size}px`,
|
|
1124
|
+
...rowSty
|
|
1119
1125
|
},
|
|
1120
1126
|
children: /* @__PURE__ */ jsx4(
|
|
1121
1127
|
"div",
|
|
@@ -1237,15 +1243,18 @@ var TableBody = ({
|
|
|
1237
1243
|
const rk = getRowKey ? getRowKey(row, rowIdx) : String(rowIdx);
|
|
1238
1244
|
const isSelected = selectedKeySet.has(rk);
|
|
1239
1245
|
const isExpanded = resolvedExpandedKeys?.has(rk) ?? false;
|
|
1246
|
+
const rowCls = rowClassName ? rowClassName(row, rowIdx) : "";
|
|
1247
|
+
const rowSty = rowStyle ? rowStyle(row, rowIdx) : void 0;
|
|
1240
1248
|
return /* @__PURE__ */ jsx4(
|
|
1241
1249
|
"div",
|
|
1242
1250
|
{
|
|
1243
|
-
className: classNames?.pinnedRow ?? "",
|
|
1251
|
+
className: `${classNames?.pinnedRow ?? ""} ${rowCls}`.trim() || void 0,
|
|
1244
1252
|
style: {
|
|
1245
1253
|
display: "grid",
|
|
1246
1254
|
gridTemplateColumns: gridTemplateColumns ?? "",
|
|
1247
1255
|
minWidth: totalTableWidth ? `${totalTableWidth}px` : void 0,
|
|
1248
|
-
...styles?.pinnedRow
|
|
1256
|
+
...styles?.pinnedRow,
|
|
1257
|
+
...rowSty
|
|
1249
1258
|
},
|
|
1250
1259
|
children: orderedColumns.map((col) => {
|
|
1251
1260
|
const cellValue = row[col.dataIndex];
|
|
@@ -1342,15 +1351,18 @@ var TableBody = ({
|
|
|
1342
1351
|
const rk = getRowKey ? getRowKey(row, rowIdx) : String(rowIdx);
|
|
1343
1352
|
const isSelected = selectedKeySet.has(rk);
|
|
1344
1353
|
const isExpanded = resolvedExpandedKeys?.has(rk) ?? false;
|
|
1354
|
+
const rowCls = rowClassName ? rowClassName(row, rowIdx) : "";
|
|
1355
|
+
const rowSty = rowStyle ? rowStyle(row, rowIdx) : void 0;
|
|
1345
1356
|
return /* @__PURE__ */ jsx4(
|
|
1346
1357
|
"div",
|
|
1347
1358
|
{
|
|
1348
|
-
className: classNames?.pinnedRow ?? "",
|
|
1359
|
+
className: `${classNames?.pinnedRow ?? ""} ${rowCls}`.trim() || void 0,
|
|
1349
1360
|
style: {
|
|
1350
1361
|
display: "grid",
|
|
1351
1362
|
gridTemplateColumns: gridTemplateColumns ?? "",
|
|
1352
1363
|
minWidth: totalTableWidth ? `${totalTableWidth}px` : void 0,
|
|
1353
|
-
...styles?.pinnedRow
|
|
1364
|
+
...styles?.pinnedRow,
|
|
1365
|
+
...rowSty
|
|
1354
1366
|
},
|
|
1355
1367
|
children: orderedColumns.map((col) => {
|
|
1356
1368
|
const cellValue = row[col.dataIndex];
|
|
@@ -1468,7 +1480,9 @@ function BoltTable({
|
|
|
1468
1480
|
columnContextMenuItems,
|
|
1469
1481
|
autoHeight = true,
|
|
1470
1482
|
layoutLoading,
|
|
1471
|
-
emptyRenderer
|
|
1483
|
+
emptyRenderer,
|
|
1484
|
+
rowClassName,
|
|
1485
|
+
rowStyle
|
|
1472
1486
|
}) {
|
|
1473
1487
|
const [columns, setColumns] = useState2(initialColumns);
|
|
1474
1488
|
const [columnOrder, setColumnOrder] = useState2(
|
|
@@ -2685,7 +2699,9 @@ function BoltTable({
|
|
|
2685
2699
|
pinnedTopData: pinnedTopRows,
|
|
2686
2700
|
pinnedBottomData: pinnedBottomRows,
|
|
2687
2701
|
gridTemplateColumns,
|
|
2688
|
-
headerHeight: HEADER_HEIGHT
|
|
2702
|
+
headerHeight: HEADER_HEIGHT,
|
|
2703
|
+
rowClassName,
|
|
2704
|
+
rowStyle
|
|
2689
2705
|
}
|
|
2690
2706
|
)
|
|
2691
2707
|
]
|
package/package.json
CHANGED