sliftutils 0.16.0 → 0.18.0
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/index.d.ts +1 -0
- package/package.json +1 -1
- package/render-utils/Table.d.ts +1 -0
- package/render-utils/Table.tsx +9 -5
package/index.d.ts
CHANGED
|
@@ -317,6 +317,7 @@ declare module "sliftutils/render-utils/Table" {
|
|
|
317
317
|
lineLimit?: number;
|
|
318
318
|
characterLimit?: number;
|
|
319
319
|
excludeEmptyColumns?: boolean;
|
|
320
|
+
getRowFields?: (row: RowT) => preact.JSX.HTMLAttributes<HTMLTableRowElement>;
|
|
320
321
|
}> {
|
|
321
322
|
state: {
|
|
322
323
|
limit: number;
|
package/package.json
CHANGED
package/render-utils/Table.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare class Table<RowT extends RowType> extends preact.Component<TableT
|
|
|
24
24
|
lineLimit?: number;
|
|
25
25
|
characterLimit?: number;
|
|
26
26
|
excludeEmptyColumns?: boolean;
|
|
27
|
+
getRowFields?: (row: RowT) => preact.JSX.HTMLAttributes<HTMLTableRowElement>;
|
|
27
28
|
}> {
|
|
28
29
|
state: {
|
|
29
30
|
limit: number;
|
package/render-utils/Table.tsx
CHANGED
|
@@ -32,6 +32,8 @@ export class Table<RowT extends RowType> extends preact.Component<TableType<RowT
|
|
|
32
32
|
characterLimit?: number;
|
|
33
33
|
|
|
34
34
|
excludeEmptyColumns?: boolean;
|
|
35
|
+
|
|
36
|
+
getRowFields?: (row: RowT) => preact.JSX.HTMLAttributes<HTMLTableRowElement>;
|
|
35
37
|
}> {
|
|
36
38
|
state = {
|
|
37
39
|
limit: this.props.initialLimit || 100,
|
|
@@ -63,9 +65,11 @@ export class Table<RowT extends RowType> extends preact.Component<TableType<RowT
|
|
|
63
65
|
<th className={css.pad2(8, 4) + cellClass}>{column?.title || toSpaceCase(columnName)}</th>
|
|
64
66
|
)}
|
|
65
67
|
</tr>
|
|
66
|
-
{rows.map((row, index) =>
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
{rows.map((row, index) => {
|
|
69
|
+
let rowFields = this.props.getRowFields?.(row) || {};
|
|
70
|
+
return <tr
|
|
71
|
+
{...rowFields}
|
|
72
|
+
className={rowFields.className + " " + (index % 2 === 1 && css.hsla(0, 0, 100, 0.25) || "")}
|
|
69
73
|
>
|
|
70
74
|
<td className={css.center}>{index + 1}</td>
|
|
71
75
|
{Object.entries(columns).filter(x => x[1] !== null).map(([columnName, column]: [string, ColumnType]) => {
|
|
@@ -114,8 +118,8 @@ export class Table<RowT extends RowType> extends preact.Component<TableType<RowT
|
|
|
114
118
|
{innerContent}
|
|
115
119
|
</td>;
|
|
116
120
|
})}
|
|
117
|
-
</tr
|
|
118
|
-
)
|
|
121
|
+
</tr>;
|
|
122
|
+
})}
|
|
119
123
|
{allRows.length > rows.length && <tr>
|
|
120
124
|
<td
|
|
121
125
|
colSpan={1 + Object.keys(columns).length}
|