@dimaan/ui 0.0.30 → 0.0.31
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.cjs +202 -161
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +202 -161
- package/dist/index.js.map +1 -1
- package/dist/preset.css +23 -5
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -386,8 +386,9 @@ interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
|
386
386
|
variant?: BadgeVariant;
|
|
387
387
|
size?: BadgeSize;
|
|
388
388
|
/**
|
|
389
|
-
* Visual tone. `'
|
|
390
|
-
*
|
|
389
|
+
* Visual tone. `'soft'` (default) is a calmer, modern tinted fill — great for
|
|
390
|
+
* status columns and category labels; `'solid'` is a full-color fill for
|
|
391
|
+
* stronger emphasis.
|
|
391
392
|
*/
|
|
392
393
|
tone?: BadgeTone;
|
|
393
394
|
/** Render a small dot before the label (useful for online/status indicators). */
|
|
@@ -1568,6 +1569,15 @@ interface TableProps<T> {
|
|
|
1568
1569
|
striped?: boolean;
|
|
1569
1570
|
/** Optional row click handler. */
|
|
1570
1571
|
onRowClick?: (row: T, rowIndex: number) => void;
|
|
1572
|
+
/**
|
|
1573
|
+
* Optional per-row accent colour. When it returns a colour string, Table draws a
|
|
1574
|
+
* thin rounded bar at the row's leading (inline-start) edge — e.g. to colour-code
|
|
1575
|
+
* rows by category/department. Return `undefined` for no accent. Off by default,
|
|
1576
|
+
* so existing consumers are unaffected.
|
|
1577
|
+
*
|
|
1578
|
+
* @example getRowAccent={(row) => DEPARTMENT_COLOR[row.department]}
|
|
1579
|
+
*/
|
|
1580
|
+
getRowAccent?: (row: T, index: number) => string | undefined;
|
|
1571
1581
|
/** Optional ref to the underlying <table> element. */
|
|
1572
1582
|
tableRef?: Ref<HTMLTableElement>;
|
|
1573
1583
|
'aria-label'?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -386,8 +386,9 @@ interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
|
386
386
|
variant?: BadgeVariant;
|
|
387
387
|
size?: BadgeSize;
|
|
388
388
|
/**
|
|
389
|
-
* Visual tone. `'
|
|
390
|
-
*
|
|
389
|
+
* Visual tone. `'soft'` (default) is a calmer, modern tinted fill — great for
|
|
390
|
+
* status columns and category labels; `'solid'` is a full-color fill for
|
|
391
|
+
* stronger emphasis.
|
|
391
392
|
*/
|
|
392
393
|
tone?: BadgeTone;
|
|
393
394
|
/** Render a small dot before the label (useful for online/status indicators). */
|
|
@@ -1568,6 +1569,15 @@ interface TableProps<T> {
|
|
|
1568
1569
|
striped?: boolean;
|
|
1569
1570
|
/** Optional row click handler. */
|
|
1570
1571
|
onRowClick?: (row: T, rowIndex: number) => void;
|
|
1572
|
+
/**
|
|
1573
|
+
* Optional per-row accent colour. When it returns a colour string, Table draws a
|
|
1574
|
+
* thin rounded bar at the row's leading (inline-start) edge — e.g. to colour-code
|
|
1575
|
+
* rows by category/department. Return `undefined` for no accent. Off by default,
|
|
1576
|
+
* so existing consumers are unaffected.
|
|
1577
|
+
*
|
|
1578
|
+
* @example getRowAccent={(row) => DEPARTMENT_COLOR[row.department]}
|
|
1579
|
+
*/
|
|
1580
|
+
getRowAccent?: (row: T, index: number) => string | undefined;
|
|
1571
1581
|
/** Optional ref to the underlying <table> element. */
|
|
1572
1582
|
tableRef?: Ref<HTMLTableElement>;
|
|
1573
1583
|
'aria-label'?: string;
|
package/dist/index.js
CHANGED
|
@@ -877,7 +877,7 @@ var badgeDotSizeClass = {
|
|
|
877
877
|
md: "size-2"
|
|
878
878
|
};
|
|
879
879
|
var badgeBaseClass = "inline-flex shrink-0 items-center rounded-full border font-medium leading-none whitespace-nowrap select-none transition-colors";
|
|
880
|
-
var Badge = forwardRef(function Badge2({ variant = "default", size = "md", tone = "
|
|
880
|
+
var Badge = forwardRef(function Badge2({ variant = "default", size = "md", tone = "soft", dot = false, className, children, ...props }, ref) {
|
|
881
881
|
const variantClass = tone === "soft" ? badgeSoftVariantClass[variant] : badgeVariantClass[variant];
|
|
882
882
|
return /* @__PURE__ */ jsxs(
|
|
883
883
|
"span",
|
|
@@ -2293,9 +2293,9 @@ function Pagination({
|
|
|
2293
2293
|
children: isRtl ? /* @__PURE__ */ jsx(ChevronRight, { "aria-hidden": "true", className: "size-3.5" }) : /* @__PURE__ */ jsx(ChevronLeft, { "aria-hidden": "true", className: "size-3.5" })
|
|
2294
2294
|
}
|
|
2295
2295
|
),
|
|
2296
|
-
/* @__PURE__ */
|
|
2297
|
-
|
|
2298
|
-
"
|
|
2296
|
+
/* @__PURE__ */ jsx("span", { className: "inline-flex min-w-7 items-center justify-center rounded-lg bg-gradient-table px-2.5 py-0.5 text-xs font-semibold text-white", children: pageIndex + 1 }),
|
|
2297
|
+
/* @__PURE__ */ jsxs("span", { className: "px-0.5 text-muted-foreground", children: [
|
|
2298
|
+
"/ ",
|
|
2299
2299
|
pageCount
|
|
2300
2300
|
] }),
|
|
2301
2301
|
/* @__PURE__ */ jsx(
|
|
@@ -2320,7 +2320,7 @@ function Toolbar({ count, onClear, renderLabel, clearLabel, children }) {
|
|
|
2320
2320
|
{
|
|
2321
2321
|
role: "toolbar",
|
|
2322
2322
|
"aria-label": "Bulk actions",
|
|
2323
|
-
className: "flex flex-wrap items-center gap-3 rounded-
|
|
2323
|
+
className: "flex flex-wrap items-center gap-3 rounded-xl border border-border bg-muted/50 px-3.5 py-2.5 text-sm shadow-[var(--shadow-xs)]",
|
|
2324
2324
|
children: [
|
|
2325
2325
|
/* @__PURE__ */ jsx("span", { className: "font-medium text-foreground", children: renderLabel ? renderLabel(count) : `${count} selected` }),
|
|
2326
2326
|
/* @__PURE__ */ jsxs("div", { className: "ms-auto flex flex-wrap items-center gap-2", children: [
|
|
@@ -2336,18 +2336,18 @@ function Toolbar({ count, onClear, renderLabel, clearLabel, children }) {
|
|
|
2336
2336
|
var tableSizeClass = {
|
|
2337
2337
|
sm: {
|
|
2338
2338
|
row: "",
|
|
2339
|
-
cell: "px-3 py-
|
|
2340
|
-
head: "whitespace-nowrap px-3 py-
|
|
2339
|
+
cell: "px-3 py-2 text-xs tabular-nums",
|
|
2340
|
+
head: "whitespace-nowrap px-3 py-3 text-[11px] font-semibold uppercase tracking-wider"
|
|
2341
2341
|
},
|
|
2342
2342
|
md: {
|
|
2343
2343
|
row: "",
|
|
2344
|
-
cell: "px-4 py-
|
|
2345
|
-
head: "whitespace-nowrap px-4 py-
|
|
2344
|
+
cell: "px-4 py-3.5 text-sm tabular-nums",
|
|
2345
|
+
head: "whitespace-nowrap px-4 py-4 text-xs font-semibold uppercase tracking-wider"
|
|
2346
2346
|
},
|
|
2347
2347
|
lg: {
|
|
2348
2348
|
row: "",
|
|
2349
|
-
cell: "px-
|
|
2350
|
-
head: "whitespace-nowrap px-
|
|
2349
|
+
cell: "px-6 py-4 text-sm tabular-nums",
|
|
2350
|
+
head: "whitespace-nowrap px-6 py-5 text-[13px] font-semibold uppercase tracking-wider"
|
|
2351
2351
|
}
|
|
2352
2352
|
};
|
|
2353
2353
|
var tableBaseClass = "w-full caption-bottom border-collapse";
|
|
@@ -2404,6 +2404,7 @@ function Table(props) {
|
|
|
2404
2404
|
maxHeight,
|
|
2405
2405
|
striped = false,
|
|
2406
2406
|
onRowClick,
|
|
2407
|
+
getRowAccent,
|
|
2407
2408
|
tableRef,
|
|
2408
2409
|
pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS,
|
|
2409
2410
|
showPagination,
|
|
@@ -2475,166 +2476,198 @@ function Table(props) {
|
|
|
2475
2476
|
children: bulkActions(selectedRowsInData)
|
|
2476
2477
|
}
|
|
2477
2478
|
),
|
|
2478
|
-
/* @__PURE__ */
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
"
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
"bg-card text-muted-foreground shadow-[inset_0_-1px_0_var(--color-border)]",
|
|
2505
|
-
maxHeight !== void 0 && "sticky top-0 z-10"
|
|
2506
|
-
),
|
|
2507
|
-
children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
2508
|
-
enableRowSelection ? /* @__PURE__ */ jsx("th", { scope: "col", className: cn("w-10", sizeClasses.head), children: /* @__PURE__ */ jsx(
|
|
2509
|
-
Checkbox,
|
|
2510
|
-
{
|
|
2511
|
-
"aria-label": "Select all rows on this page",
|
|
2512
|
-
checked: allOnPageSelected,
|
|
2513
|
-
indeterminate: someOnPageSelected,
|
|
2514
|
-
disabled: selectableRowIds.length === 0,
|
|
2515
|
-
onCheckedChange: toggleHeader
|
|
2516
|
-
}
|
|
2517
|
-
) }) : null,
|
|
2518
|
-
columns.map((column) => {
|
|
2519
|
-
const isSorted = effectiveSort.columnId === column.id;
|
|
2520
|
-
const ariaSort = isSorted ? effectiveSort.direction === "asc" ? "ascending" : "descending" : "none";
|
|
2521
|
-
return /* @__PURE__ */ jsx(
|
|
2522
|
-
"th",
|
|
2523
|
-
{
|
|
2524
|
-
scope: "col",
|
|
2525
|
-
"aria-sort": column.sortable ? ariaSort : void 0,
|
|
2526
|
-
className: cn(
|
|
2527
|
-
sizeClasses.head,
|
|
2528
|
-
alignClass[column.align ?? "start"],
|
|
2529
|
-
column.className
|
|
2530
|
-
),
|
|
2531
|
-
children: column.sortable ? /* @__PURE__ */ jsxs(
|
|
2532
|
-
"button",
|
|
2533
|
-
{
|
|
2534
|
-
type: "button",
|
|
2535
|
-
onClick: () => handleSortClick(column.id),
|
|
2536
|
-
className: "inline-flex items-center gap-1.5 font-inherit uppercase tracking-inherit text-inherit hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",
|
|
2537
|
-
"aria-label": sortAriaLabel(column, effectiveSort),
|
|
2538
|
-
children: [
|
|
2539
|
-
/* @__PURE__ */ jsx("span", { children: renderHeader(column.header) }),
|
|
2540
|
-
/* @__PURE__ */ jsx(
|
|
2541
|
-
SortIndicator,
|
|
2542
|
-
{
|
|
2543
|
-
active: isSorted,
|
|
2544
|
-
direction: isSorted ? effectiveSort.direction : null
|
|
2545
|
-
}
|
|
2546
|
-
)
|
|
2547
|
-
]
|
|
2548
|
-
}
|
|
2549
|
-
) : renderHeader(column.header)
|
|
2550
|
-
},
|
|
2551
|
-
column.id
|
|
2552
|
-
);
|
|
2553
|
-
})
|
|
2554
|
-
] })
|
|
2555
|
-
}
|
|
2556
|
-
),
|
|
2557
|
-
/* @__PURE__ */ jsx("tbody", { children: loading ? /* @__PURE__ */ jsx(
|
|
2558
|
-
SkeletonRows,
|
|
2559
|
-
{
|
|
2560
|
-
rowCount: skeletonCount,
|
|
2561
|
-
columnCount: totalColumnCount,
|
|
2562
|
-
cellClassName: sizeClasses.cell
|
|
2563
|
-
}
|
|
2564
|
-
) : data.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
|
|
2565
|
-
"td",
|
|
2566
|
-
{
|
|
2567
|
-
colSpan: totalColumnCount,
|
|
2568
|
-
className: cn(sizeClasses.cell, "py-10 text-center text-muted-foreground"),
|
|
2569
|
-
children: emptyState ?? "No data"
|
|
2570
|
-
}
|
|
2571
|
-
) }) : data.map((row, rowIndex) => {
|
|
2572
|
-
const id = getRowId(row, rowIndex);
|
|
2573
|
-
const isSelected = selected.has(id);
|
|
2574
|
-
const rowSelectable = isRowSelectable ? isRowSelectable(row) : true;
|
|
2575
|
-
return /* @__PURE__ */ jsxs(
|
|
2576
|
-
"tr",
|
|
2479
|
+
/* @__PURE__ */ jsxs("div", { className: "relative overflow-hidden rounded-xl border border-border bg-card shadow-[var(--shadow-card)]", children: [
|
|
2480
|
+
/* @__PURE__ */ jsx(
|
|
2481
|
+
"span",
|
|
2482
|
+
{
|
|
2483
|
+
"aria-hidden": "true",
|
|
2484
|
+
"data-testid": "table-accent",
|
|
2485
|
+
className: "pointer-events-none absolute inset-x-0 top-0 z-20 h-[3px] bg-gradient-table"
|
|
2486
|
+
}
|
|
2487
|
+
),
|
|
2488
|
+
/* @__PURE__ */ jsx(
|
|
2489
|
+
"div",
|
|
2490
|
+
{
|
|
2491
|
+
className: cn("overflow-x-auto", maxHeight !== void 0 && "overflow-y-auto"),
|
|
2492
|
+
style: maxHeight !== void 0 ? { maxHeight } : void 0,
|
|
2493
|
+
children: /* @__PURE__ */ jsxs(
|
|
2494
|
+
"table",
|
|
2495
|
+
{
|
|
2496
|
+
ref: tableRef,
|
|
2497
|
+
"aria-label": ariaLabel,
|
|
2498
|
+
"aria-labelledby": ariaLabelledBy,
|
|
2499
|
+
"aria-rowcount": totalRowCount,
|
|
2500
|
+
className: cn(tableBaseClass, "text-sm text-foreground", tableClassName),
|
|
2501
|
+
children: [
|
|
2502
|
+
caption ? /* @__PURE__ */ jsx("caption", { className: "sr-only", children: caption }) : null,
|
|
2503
|
+
/* @__PURE__ */ jsx(
|
|
2504
|
+
"thead",
|
|
2577
2505
|
{
|
|
2578
|
-
"data-selected": isSelected ? "true" : void 0,
|
|
2579
|
-
"aria-selected": enableRowSelection ? isSelected : void 0,
|
|
2580
2506
|
className: cn(
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2507
|
+
// Clean opaque header (so a sticky header fully hides the rows
|
|
2508
|
+
// scrolling underneath it) with a hairline bottom rule drawn via an
|
|
2509
|
+
// inset shadow — it stays attached to the sticky header instead of
|
|
2510
|
+
// collapsing into the first row's border.
|
|
2511
|
+
// Opaque header background so a sticky header fully hides the rows
|
|
2512
|
+
// scrolling underneath it (a translucent tint would let them bleed through).
|
|
2513
|
+
"bg-muted text-muted-foreground shadow-[inset_0_-1px_0_var(--color-border)]",
|
|
2514
|
+
maxHeight !== void 0 && "sticky top-0 z-10"
|
|
2586
2515
|
),
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
enableRowSelection ? /* @__PURE__ */ jsx("td", { className: cn(sizeClasses.cell, "w-10"), children: /* @__PURE__ */ jsx(
|
|
2516
|
+
children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
2517
|
+
enableRowSelection ? /* @__PURE__ */ jsx("th", { scope: "col", className: cn("w-10", sizeClasses.head), children: /* @__PURE__ */ jsx(
|
|
2590
2518
|
Checkbox,
|
|
2591
2519
|
{
|
|
2592
|
-
"aria-label":
|
|
2593
|
-
checked:
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2520
|
+
"aria-label": "Select all rows on this page",
|
|
2521
|
+
checked: allOnPageSelected,
|
|
2522
|
+
indeterminate: someOnPageSelected,
|
|
2523
|
+
disabled: selectableRowIds.length === 0,
|
|
2524
|
+
onCheckedChange: toggleHeader
|
|
2597
2525
|
}
|
|
2598
2526
|
) }) : null,
|
|
2599
|
-
columns.map((column) =>
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2527
|
+
columns.map((column) => {
|
|
2528
|
+
const isSorted = effectiveSort.columnId === column.id;
|
|
2529
|
+
const ariaSort = isSorted ? effectiveSort.direction === "asc" ? "ascending" : "descending" : "none";
|
|
2530
|
+
return /* @__PURE__ */ jsx(
|
|
2531
|
+
"th",
|
|
2532
|
+
{
|
|
2533
|
+
scope: "col",
|
|
2534
|
+
"aria-sort": column.sortable ? ariaSort : void 0,
|
|
2535
|
+
className: cn(
|
|
2536
|
+
sizeClasses.head,
|
|
2537
|
+
alignClass[column.align ?? "start"],
|
|
2538
|
+
column.className,
|
|
2539
|
+
isSorted && "text-primary"
|
|
2540
|
+
),
|
|
2541
|
+
children: column.sortable ? /* @__PURE__ */ jsxs(
|
|
2542
|
+
"button",
|
|
2543
|
+
{
|
|
2544
|
+
type: "button",
|
|
2545
|
+
onClick: () => handleSortClick(column.id),
|
|
2546
|
+
className: "inline-flex items-center gap-1.5 font-inherit uppercase tracking-inherit text-inherit hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",
|
|
2547
|
+
"aria-label": sortAriaLabel(column, effectiveSort),
|
|
2548
|
+
children: [
|
|
2549
|
+
/* @__PURE__ */ jsx("span", { children: renderHeader(column.header) }),
|
|
2550
|
+
/* @__PURE__ */ jsx(
|
|
2551
|
+
SortIndicator,
|
|
2552
|
+
{
|
|
2553
|
+
active: isSorted,
|
|
2554
|
+
direction: isSorted ? effectiveSort.direction : null
|
|
2555
|
+
}
|
|
2556
|
+
)
|
|
2557
|
+
]
|
|
2558
|
+
}
|
|
2559
|
+
) : renderHeader(column.header)
|
|
2560
|
+
},
|
|
2561
|
+
column.id
|
|
2562
|
+
);
|
|
2563
|
+
})
|
|
2564
|
+
] })
|
|
2565
|
+
}
|
|
2566
|
+
),
|
|
2567
|
+
/* @__PURE__ */ jsx("tbody", { children: loading ? /* @__PURE__ */ jsx(
|
|
2568
|
+
SkeletonRows,
|
|
2569
|
+
{
|
|
2570
|
+
rowCount: skeletonCount,
|
|
2571
|
+
columnCount: totalColumnCount,
|
|
2572
|
+
cellClassName: sizeClasses.cell
|
|
2573
|
+
}
|
|
2574
|
+
) : data.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
|
|
2575
|
+
"td",
|
|
2576
|
+
{
|
|
2577
|
+
colSpan: totalColumnCount,
|
|
2578
|
+
className: cn(sizeClasses.cell, "py-10 text-center text-muted-foreground"),
|
|
2579
|
+
children: emptyState ?? "No data"
|
|
2580
|
+
}
|
|
2581
|
+
) }) : data.map((row, rowIndex) => {
|
|
2582
|
+
const id = getRowId(row, rowIndex);
|
|
2583
|
+
const isSelected = selected.has(id);
|
|
2584
|
+
const rowSelectable = isRowSelectable ? isRowSelectable(row) : true;
|
|
2585
|
+
const accent = getRowAccent?.(row, rowIndex);
|
|
2586
|
+
return /* @__PURE__ */ jsxs(
|
|
2587
|
+
"tr",
|
|
2588
|
+
{
|
|
2589
|
+
"data-selected": isSelected ? "true" : void 0,
|
|
2590
|
+
"aria-selected": enableRowSelection ? isSelected : void 0,
|
|
2591
|
+
className: cn(
|
|
2592
|
+
"border-b border-border/60 last:border-b-0 transition-colors",
|
|
2593
|
+
"hover:bg-muted/60",
|
|
2594
|
+
striped && rowIndex % 2 === 1 && "bg-muted/20",
|
|
2595
|
+
isSelected && selectedRowClass,
|
|
2596
|
+
onRowClick && "cursor-pointer"
|
|
2597
|
+
),
|
|
2598
|
+
onClick: onRowClick ? () => onRowClick(row, rowIndex) : void 0,
|
|
2599
|
+
children: [
|
|
2600
|
+
enableRowSelection ? /* @__PURE__ */ jsxs("td", { className: cn(sizeClasses.cell, "relative w-10"), children: [
|
|
2601
|
+
accent ? /* @__PURE__ */ jsx(RowAccent, { color: accent }) : null,
|
|
2602
|
+
/* @__PURE__ */ jsx(
|
|
2603
|
+
Checkbox,
|
|
2604
|
+
{
|
|
2605
|
+
"aria-label": `Select row ${rowIndex + 1}`,
|
|
2606
|
+
checked: isSelected,
|
|
2607
|
+
disabled: !rowSelectable,
|
|
2608
|
+
onCheckedChange: (next) => toggleRow(id, next),
|
|
2609
|
+
onClick: stopRowClickPropagation
|
|
2610
|
+
}
|
|
2611
|
+
)
|
|
2612
|
+
] }) : null,
|
|
2613
|
+
columns.map((column, colIndex) => {
|
|
2614
|
+
const isFirst = colIndex === 0 && !enableRowSelection;
|
|
2615
|
+
return /* @__PURE__ */ jsxs(
|
|
2616
|
+
"td",
|
|
2617
|
+
{
|
|
2618
|
+
className: cn(
|
|
2619
|
+
sizeClasses.cell,
|
|
2620
|
+
alignClass[column.align ?? "start"],
|
|
2621
|
+
column.className,
|
|
2622
|
+
isFirst && "relative"
|
|
2623
|
+
),
|
|
2624
|
+
children: [
|
|
2625
|
+
isFirst && accent ? /* @__PURE__ */ jsx(RowAccent, { color: accent }) : null,
|
|
2626
|
+
renderCell(column, row, rowIndex)
|
|
2627
|
+
]
|
|
2628
|
+
},
|
|
2629
|
+
column.id
|
|
2630
|
+
);
|
|
2631
|
+
})
|
|
2632
|
+
]
|
|
2633
|
+
},
|
|
2634
|
+
id
|
|
2635
|
+
);
|
|
2636
|
+
}) })
|
|
2637
|
+
]
|
|
2638
|
+
}
|
|
2639
|
+
)
|
|
2640
|
+
}
|
|
2641
|
+
),
|
|
2642
|
+
paginationVisible ? /* @__PURE__ */ jsx("div", { className: "border-t border-border px-4 py-3", children: /* @__PURE__ */ jsx(
|
|
2643
|
+
Pagination,
|
|
2644
|
+
{
|
|
2645
|
+
pageIndex,
|
|
2646
|
+
pageSize,
|
|
2647
|
+
pageCount,
|
|
2648
|
+
totalRowCount,
|
|
2649
|
+
pageSizeOptions,
|
|
2650
|
+
onChange: handlePaginationChange,
|
|
2651
|
+
labels
|
|
2652
|
+
}
|
|
2653
|
+
) }) : null
|
|
2654
|
+
] })
|
|
2633
2655
|
] });
|
|
2634
2656
|
}
|
|
2635
2657
|
function renderHeader(header) {
|
|
2636
2658
|
return typeof header === "function" ? header() : header;
|
|
2637
2659
|
}
|
|
2660
|
+
function RowAccent({ color }) {
|
|
2661
|
+
return /* @__PURE__ */ jsx(
|
|
2662
|
+
"span",
|
|
2663
|
+
{
|
|
2664
|
+
"aria-hidden": "true",
|
|
2665
|
+
"data-testid": "row-accent",
|
|
2666
|
+
className: "pointer-events-none absolute inset-y-1 start-0 w-[3px] rounded-full",
|
|
2667
|
+
style: { background: color }
|
|
2668
|
+
}
|
|
2669
|
+
);
|
|
2670
|
+
}
|
|
2638
2671
|
function renderCell(column, row, rowIndex) {
|
|
2639
2672
|
if (column.render) return column.render(row, rowIndex);
|
|
2640
2673
|
if (column.accessor !== void 0) {
|
|
@@ -2659,10 +2692,18 @@ function stopRowClickPropagation(event) {
|
|
|
2659
2692
|
function SkeletonRows({ rowCount, columnCount, cellClassName }) {
|
|
2660
2693
|
const rowKeys = Array.from({ length: Math.max(0, rowCount) }, (_, i) => `skeleton-row-${i}`);
|
|
2661
2694
|
const colKeys = Array.from({ length: Math.max(1, columnCount) }, (_, i) => `skeleton-col-${i}`);
|
|
2662
|
-
return /* @__PURE__ */ jsx(Fragment, { children: rowKeys.map((rowKey) => /* @__PURE__ */ jsx(
|
|
2695
|
+
return /* @__PURE__ */ jsx(Fragment, { children: rowKeys.map((rowKey) => /* @__PURE__ */ jsx(
|
|
2696
|
+
"tr",
|
|
2697
|
+
{
|
|
2698
|
+
className: "border-b border-border/60 last:border-b-0",
|
|
2699
|
+
"data-testid": "table-skeleton-row",
|
|
2700
|
+
children: colKeys.map((colKey) => /* @__PURE__ */ jsx("td", { className: cellClassName, children: /* @__PURE__ */ jsx("span", { className: "block h-3 w-full animate-pulse rounded bg-muted" }) }, `${rowKey}-${colKey}`))
|
|
2701
|
+
},
|
|
2702
|
+
rowKey
|
|
2703
|
+
)) });
|
|
2663
2704
|
}
|
|
2664
2705
|
function SortIndicator({ active, direction }) {
|
|
2665
|
-
const className = cn("size-3.5 shrink-0", active ? "text-
|
|
2706
|
+
const className = cn("size-3.5 shrink-0", active ? "text-primary" : "text-muted-foreground");
|
|
2666
2707
|
if (!active) return /* @__PURE__ */ jsx(ChevronsUpDown, { "aria-hidden": "true", className });
|
|
2667
2708
|
return direction === "asc" ? /* @__PURE__ */ jsx(ChevronUp, { "aria-hidden": "true", className }) : /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": "true", className });
|
|
2668
2709
|
}
|