@stasho/ds 0.7.0 → 0.7.1
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
CHANGED
|
@@ -8,6 +8,12 @@ type SortDirection = "asc" | "desc";
|
|
|
8
8
|
|
|
9
9
|
export type Column<T> = {
|
|
10
10
|
header: string;
|
|
11
|
+
/**
|
|
12
|
+
* Stable React key for the column. Defaults to `header`. Set this when two
|
|
13
|
+
* columns share a header (e.g. multiple header-less icon/action columns,
|
|
14
|
+
* where `header` is `""`) so cell keys don't collide.
|
|
15
|
+
*/
|
|
16
|
+
id?: string;
|
|
11
17
|
accessor: (row: T) => ReactNode;
|
|
12
18
|
sortable?: boolean;
|
|
13
19
|
sortValue?: (row: T) => string | number;
|
|
@@ -163,7 +169,7 @@ export function Table<T>({
|
|
|
163
169
|
<tr className="bg-muted/50">
|
|
164
170
|
{columns.map((col, i) => (
|
|
165
171
|
<th
|
|
166
|
-
key={col.header}
|
|
172
|
+
key={col.id ?? col.header}
|
|
167
173
|
className={cn(
|
|
168
174
|
"px-4 py-3 font-mono font-normal uppercase tracking-widest text-[11px] text-muted-foreground",
|
|
169
175
|
alignClass[col.align ?? "left"],
|
|
@@ -241,7 +247,7 @@ export function Table<T>({
|
|
|
241
247
|
>
|
|
242
248
|
{columns.map((col) => (
|
|
243
249
|
<td
|
|
244
|
-
key={col.header}
|
|
250
|
+
key={col.id ?? col.header}
|
|
245
251
|
className={cn(
|
|
246
252
|
"px-4 py-3 text-sm",
|
|
247
253
|
alignClass[col.align ?? "left"],
|