@underpin/ui 0.0.0 → 2.1.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/LICENSE +21 -0
- package/README.md +44 -1
- package/components/autocomplete.d.ts +25 -0
- package/components/autocomplete.js +71 -0
- package/components/autocomplete.js.map +1 -0
- package/components/avatar.d.ts +5 -0
- package/components/avatar.js +26 -0
- package/components/avatar.js.map +1 -0
- package/components/badge.d.ts +36 -0
- package/components/badge.js +140 -0
- package/components/badge.js.map +1 -0
- package/components/bar-list.d.ts +133 -0
- package/components/bar-list.js +204 -0
- package/components/bar-list.js.map +1 -0
- package/components/breakdown-card.d.ts +30 -0
- package/components/breakdown-card.js +43 -0
- package/components/breakdown-card.js.map +1 -0
- package/components/bulk-action-bar.d.ts +21 -0
- package/components/bulk-action-bar.js +38 -0
- package/components/bulk-action-bar.js.map +1 -0
- package/components/button-group.d.ts +21 -0
- package/components/button-group.js +32 -0
- package/components/button-group.js.map +1 -0
- package/components/button.d.ts +39 -0
- package/components/button.js +145 -0
- package/components/button.js.map +1 -0
- package/components/calendar.d.ts +27 -0
- package/components/calendar.js +95 -0
- package/components/calendar.js.map +1 -0
- package/components/callout.d.ts +26 -0
- package/components/callout.js +71 -0
- package/components/callout.js.map +1 -0
- package/components/card.d.ts +55 -0
- package/components/card.js +96 -0
- package/components/card.js.map +1 -0
- package/components/chart.d.ts +32 -0
- package/components/chart.js +43 -0
- package/components/chart.js.map +1 -0
- package/components/checkbox.d.ts +15 -0
- package/components/checkbox.js +42 -0
- package/components/checkbox.js.map +1 -0
- package/components/code-block.d.ts +21 -0
- package/components/code-block.js +35 -0
- package/components/code-block.js.map +1 -0
- package/components/collapse.d.ts +14 -0
- package/components/collapse.js +25 -0
- package/components/collapse.js.map +1 -0
- package/components/combobox.d.ts +71 -0
- package/components/combobox.js +155 -0
- package/components/combobox.js.map +1 -0
- package/components/copy-button.d.ts +29 -0
- package/components/copy-button.js +100 -0
- package/components/copy-button.js.map +1 -0
- package/components/copy-input.d.ts +15 -0
- package/components/copy-input.js +51 -0
- package/components/copy-input.js.map +1 -0
- package/components/data-table.d.ts +120 -0
- package/components/data-table.js +336 -0
- package/components/data-table.js.map +1 -0
- package/components/date-picker-trigger.d.ts +12 -0
- package/components/date-picker-trigger.js +30 -0
- package/components/date-picker-trigger.js.map +1 -0
- package/components/date-picker.d.ts +36 -0
- package/components/date-picker.js +70 -0
- package/components/date-picker.js.map +1 -0
- package/components/detail-row.d.ts +51 -0
- package/components/detail-row.js +77 -0
- package/components/detail-row.js.map +1 -0
- package/components/dialog.d.ts +121 -0
- package/components/dialog.js +327 -0
- package/components/dialog.js.map +1 -0
- package/components/disabled-reason.d.ts +31 -0
- package/components/disabled-reason.js +67 -0
- package/components/disabled-reason.js.map +1 -0
- package/components/empty-state.d.ts +41 -0
- package/components/empty-state.js +84 -0
- package/components/empty-state.js.map +1 -0
- package/components/entity-avatar.d.ts +54 -0
- package/components/entity-avatar.js +68 -0
- package/components/entity-avatar.js.map +1 -0
- package/components/form-section.d.ts +22 -0
- package/components/form-section.js +38 -0
- package/components/form-section.js.map +1 -0
- package/components/form.d.ts +199 -0
- package/components/form.js +456 -0
- package/components/form.js.map +1 -0
- package/components/formatted-number.d.ts +21 -0
- package/components/formatted-number.js +13 -0
- package/components/formatted-number.js.map +1 -0
- package/components/heading.d.ts +23 -0
- package/components/heading.js +44 -0
- package/components/heading.js.map +1 -0
- package/components/icon-swap.d.ts +15 -0
- package/components/icon-swap.js +29 -0
- package/components/icon-swap.js.map +1 -0
- package/components/inline-action.d.ts +21 -0
- package/components/inline-action.js +36 -0
- package/components/inline-action.js.map +1 -0
- package/components/input.d.ts +51 -0
- package/components/input.js +52 -0
- package/components/input.js.map +1 -0
- package/components/kbd.d.ts +17 -0
- package/components/kbd.js +34 -0
- package/components/kbd.js.map +1 -0
- package/components/label.d.ts +10 -0
- package/components/label.js +20 -0
- package/components/label.js.map +1 -0
- package/components/menu.d.ts +77 -0
- package/components/menu.js +189 -0
- package/components/menu.js.map +1 -0
- package/components/nav-button.d.ts +34 -0
- package/components/nav-button.js +71 -0
- package/components/nav-button.js.map +1 -0
- package/components/nav.d.ts +39 -0
- package/components/nav.js +68 -0
- package/components/nav.js.map +1 -0
- package/components/number-input.d.ts +16 -0
- package/components/number-input.js +25 -0
- package/components/number-input.js.map +1 -0
- package/components/page.d.ts +14 -0
- package/components/page.js +23 -0
- package/components/page.js.map +1 -0
- package/components/pagination.d.ts +73 -0
- package/components/pagination.js +212 -0
- package/components/pagination.js.map +1 -0
- package/components/ping.d.ts +38 -0
- package/components/ping.js +50 -0
- package/components/ping.js.map +1 -0
- package/components/popover.d.ts +5 -0
- package/components/popover.js +25 -0
- package/components/popover.js.map +1 -0
- package/components/radio-group.d.ts +35 -0
- package/components/radio-group.js +81 -0
- package/components/radio-group.js.map +1 -0
- package/components/relative-time.d.ts +25 -0
- package/components/relative-time.js +51 -0
- package/components/relative-time.js.map +1 -0
- package/components/saved-mark.d.ts +15 -0
- package/components/saved-mark.js +45 -0
- package/components/saved-mark.js.map +1 -0
- package/components/search-input.d.ts +13 -0
- package/components/search-input.js +44 -0
- package/components/search-input.js.map +1 -0
- package/components/section-header.d.ts +83 -0
- package/components/section-header.js +170 -0
- package/components/section-header.js.map +1 -0
- package/components/segmented-control.d.ts +24 -0
- package/components/segmented-control.js +70 -0
- package/components/segmented-control.js.map +1 -0
- package/components/select.d.ts +28 -0
- package/components/select.js +129 -0
- package/components/select.js.map +1 -0
- package/components/shortcut-keys.d.ts +14 -0
- package/components/shortcut-keys.js +32 -0
- package/components/shortcut-keys.js.map +1 -0
- package/components/shortcuts-dialog.d.ts +10 -0
- package/components/shortcuts-dialog.js +92 -0
- package/components/shortcuts-dialog.js.map +1 -0
- package/components/skeleton.d.ts +8 -0
- package/components/skeleton.js +23 -0
- package/components/skeleton.js.map +1 -0
- package/components/sparkline.d.ts +25 -0
- package/components/sparkline.js +70 -0
- package/components/sparkline.js.map +1 -0
- package/components/stack.d.ts +21 -0
- package/components/stack.js +45 -0
- package/components/stack.js.map +1 -0
- package/components/stat-strip.d.ts +43 -0
- package/components/stat-strip.js +151 -0
- package/components/stat-strip.js.map +1 -0
- package/components/steps.d.ts +19 -0
- package/components/steps.js +25 -0
- package/components/steps.js.map +1 -0
- package/components/switch.d.ts +16 -0
- package/components/switch.js +29 -0
- package/components/switch.js.map +1 -0
- package/components/table-toolbar.d.ts +55 -0
- package/components/table-toolbar.js +119 -0
- package/components/table-toolbar.js.map +1 -0
- package/components/table.d.ts +276 -0
- package/components/table.js +572 -0
- package/components/table.js.map +1 -0
- package/components/tabs.d.ts +36 -0
- package/components/tabs.js +120 -0
- package/components/tabs.js.map +1 -0
- package/components/text-link.d.ts +16 -0
- package/components/text-link.js +32 -0
- package/components/text-link.js.map +1 -0
- package/components/textarea.d.ts +10 -0
- package/components/textarea.js +23 -0
- package/components/textarea.js.map +1 -0
- package/components/theme.d.ts +28 -0
- package/components/theme.js +158 -0
- package/components/theme.js.map +1 -0
- package/components/time-series-chart.d.ts +122 -0
- package/components/time-series-chart.js +722 -0
- package/components/time-series-chart.js.map +1 -0
- package/components/toaster.d.ts +3 -0
- package/components/toaster.js +44 -0
- package/components/toaster.js.map +1 -0
- package/components/tooltip.d.ts +64 -0
- package/components/tooltip.js +126 -0
- package/components/tooltip.js.map +1 -0
- package/components/view-picker.d.ts +20 -0
- package/components/view-picker.js +24 -0
- package/components/view-picker.js.map +1 -0
- package/fonts/inter-OFL.txt +93 -0
- package/fonts/inter-cyrillic-ext.woff2 +0 -0
- package/fonts/inter-cyrillic.woff2 +0 -0
- package/fonts/inter-greek-ext.woff2 +0 -0
- package/fonts/inter-greek.woff2 +0 -0
- package/fonts/inter-latin-ext.woff2 +0 -0
- package/fonts/inter-latin.woff2 +0 -0
- package/fonts/inter-vietnamese.woff2 +0 -0
- package/fonts.css +83 -0
- package/lib/animation.d.ts +14 -0
- package/lib/animation.js +20 -0
- package/lib/animation.js.map +1 -0
- package/lib/aria.d.ts +5 -0
- package/lib/aria.js +12 -0
- package/lib/aria.js.map +1 -0
- package/lib/chart-curve.d.ts +13 -0
- package/lib/chart-curve.js +79 -0
- package/lib/chart-curve.js.map +1 -0
- package/lib/classes.d.ts +134 -0
- package/lib/classes.js +152 -0
- package/lib/classes.js.map +1 -0
- package/lib/color.d.ts +25 -0
- package/lib/color.js +149 -0
- package/lib/color.js.map +1 -0
- package/lib/data-table-state.d.ts +87 -0
- package/lib/data-table-state.js +92 -0
- package/lib/data-table-state.js.map +1 -0
- package/lib/day.d.ts +9 -0
- package/lib/day.js +20 -0
- package/lib/day.js.map +1 -0
- package/lib/design-tokens.d.ts +56 -0
- package/lib/design-tokens.js +196 -0
- package/lib/design-tokens.js.map +1 -0
- package/lib/icon.d.ts +17 -0
- package/lib/icon.js +34 -0
- package/lib/icon.js.map +1 -0
- package/lib/icons.d.ts +29 -0
- package/lib/icons.js +34 -0
- package/lib/icons.js.map +1 -0
- package/lib/interactive.d.ts +21 -0
- package/lib/interactive.js +31 -0
- package/lib/interactive.js.map +1 -0
- package/lib/load-more.d.ts +14 -0
- package/lib/load-more.js +27 -0
- package/lib/load-more.js.map +1 -0
- package/lib/media.d.ts +58 -0
- package/lib/media.js +116 -0
- package/lib/media.js.map +1 -0
- package/lib/segmented.d.ts +57 -0
- package/lib/segmented.js +83 -0
- package/lib/segmented.js.map +1 -0
- package/lib/shortcuts.d.ts +94 -0
- package/lib/shortcuts.js +271 -0
- package/lib/shortcuts.js.map +1 -0
- package/lib/slot.d.ts +9 -0
- package/lib/slot.js +18 -0
- package/lib/slot.js.map +1 -0
- package/lib/time-series.d.ts +100 -0
- package/lib/time-series.js +144 -0
- package/lib/time-series.js.map +1 -0
- package/lib/tone.d.ts +6 -0
- package/lib/tone.js +0 -0
- package/lib/variants.d.ts +12 -0
- package/lib/variants.js +14 -0
- package/lib/variants.js.map +1 -0
- package/package.json +122 -3
- package/styles.css +630 -0
- package/tokens.d.ts +104 -0
- package/tokens.js +108 -0
- package/tokens.js.map +1 -0
- package/publish.log +0 -1
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { rowPressClasses } from "../lib/classes.js";
|
|
3
|
+
import { AlertIcon, ArrowDownIcon, ArrowUpIcon, FilterIcon } from "../lib/icons.js";
|
|
4
|
+
import { cn, variants } from "../lib/variants.js";
|
|
5
|
+
import { Checkbox } from "./checkbox.js";
|
|
6
|
+
import { CopyButton } from "./copy-button.js";
|
|
7
|
+
import { EmptyState } from "./empty-state.js";
|
|
8
|
+
import { Skeleton } from "./skeleton.js";
|
|
9
|
+
import { Sparkline } from "./sparkline.js";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
12
|
+
import { Children, createContext, use } from "react";
|
|
13
|
+
// src/components/table.tsx
|
|
14
|
+
const TableContext = createContext({
|
|
15
|
+
layout: "table",
|
|
16
|
+
columns: []
|
|
17
|
+
});
|
|
18
|
+
const TableColumnScopeContext = createContext({});
|
|
19
|
+
/**
|
|
20
|
+
* The classes that hide a cell of a column with a priority, on its head and on every cell, so
|
|
21
|
+
* the column drops out whole. `Table` drops its track from the grid at the same widths.
|
|
22
|
+
*/
|
|
23
|
+
const tableColumnPriorityClasses = {
|
|
24
|
+
medium: "@max-2xl:hidden",
|
|
25
|
+
low: "@max-4xl:hidden",
|
|
26
|
+
lowest: "@max-6xl:hidden"
|
|
27
|
+
};
|
|
28
|
+
function formatColumnTemplate(columns, hidden) {
|
|
29
|
+
return columns.filter((column) => !column.priority || !hidden.includes(column.priority)).map((column) => column.width).join(" ");
|
|
30
|
+
}
|
|
31
|
+
const ROW_GRID_CLASSES = "col-span-full grid grid-cols-subgrid";
|
|
32
|
+
const tableVariants = variants({
|
|
33
|
+
slots: {
|
|
34
|
+
container: "@container relative",
|
|
35
|
+
table: [
|
|
36
|
+
"grid w-full text-control text-ink",
|
|
37
|
+
"grid-cols-(--table-columns) @2xl:grid-cols-(--table-columns-md) @4xl:grid-cols-(--table-columns-lg) @6xl:grid-cols-(--table-columns-xl)",
|
|
38
|
+
"has-[>[data-sticky]]:[--table-header-height:--spacing(10)]"
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
variants: { variant: {
|
|
42
|
+
card: { container: "overflow-clip rounded-lg border bg-surface shadow-card" },
|
|
43
|
+
flush: {}
|
|
44
|
+
} },
|
|
45
|
+
defaultVariants: { variant: "card" }
|
|
46
|
+
});
|
|
47
|
+
const tableRowVariants = variants({
|
|
48
|
+
base: [
|
|
49
|
+
ROW_GRID_CLASSES,
|
|
50
|
+
"group/row relative items-center border-t border-edge-subtle",
|
|
51
|
+
"has-[[data-row-link]:not(:active)]:hover:bg-canvas has-[[data-row-link]:focus-visible:not(:active)]:bg-canvas",
|
|
52
|
+
rowPressClasses,
|
|
53
|
+
"data-selected:bg-fill-subtle data-selected:hover:bg-fill-subtle",
|
|
54
|
+
"*:has-[[data-row-link]]:z-1",
|
|
55
|
+
"data-inactive:*:not-data-[slot=actions]:not-data-[slot=checkbox]:not-data-[slot=mono]:opacity-50"
|
|
56
|
+
],
|
|
57
|
+
variants: { size: {
|
|
58
|
+
/** 32px, for a feed or a dense list. */
|
|
59
|
+
compact: "h-8",
|
|
60
|
+
/** 44px, a one-line row. */
|
|
61
|
+
default: "h-11",
|
|
62
|
+
/** 52px, for a two-line name cell. */
|
|
63
|
+
identity: "h-13"
|
|
64
|
+
} },
|
|
65
|
+
defaultVariants: { size: "default" }
|
|
66
|
+
});
|
|
67
|
+
const tableCellVariants = variants({
|
|
68
|
+
base: [
|
|
69
|
+
"flex min-w-0 items-center gap-2 px-2 first:pl-5 last:pr-5",
|
|
70
|
+
"@max-6xl:[&:not(:has(~:not([data-priority=lowest])))]:pr-5",
|
|
71
|
+
"@max-4xl:[&:not(:has(~:not([data-priority=low]):not([data-priority=lowest])))]:pr-5",
|
|
72
|
+
"@max-2xl:[&:not(:has(~:not([data-priority])))]:pr-5"
|
|
73
|
+
],
|
|
74
|
+
variants: {
|
|
75
|
+
align: {
|
|
76
|
+
start: "justify-start text-left",
|
|
77
|
+
end: "justify-end text-right"
|
|
78
|
+
},
|
|
79
|
+
priority: tableColumnPriorityClasses
|
|
80
|
+
},
|
|
81
|
+
defaultVariants: { align: "start" }
|
|
82
|
+
});
|
|
83
|
+
/** Varied widths for a skeleton row's first line, so a stack of them does not read as stripes. */
|
|
84
|
+
const SKELETON_NAME_WIDTHS = [
|
|
85
|
+
"w-36",
|
|
86
|
+
"w-28",
|
|
87
|
+
"w-40",
|
|
88
|
+
"w-32",
|
|
89
|
+
"w-24"
|
|
90
|
+
];
|
|
91
|
+
const MESSAGE_ICONS = {
|
|
92
|
+
filtered: /* @__PURE__ */ jsx(FilterIcon, {}),
|
|
93
|
+
error: /* @__PURE__ */ jsx(AlertIcon, {})
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* A table on a CSS grid. The root sets one grid template from `columns`, and the header and
|
|
97
|
+
* every row take it as a subgrid, so the columns line up however the rows are grouped. A row
|
|
98
|
+
* stays a positioned box, which a real table row is not in Safari, so a stretched link can
|
|
99
|
+
* fill it (`TableRowLink`). Columns with a `priority` drop out as the table's own box narrows.
|
|
100
|
+
* Set `--table-sticky-top` on it when a sticky header must clear a bar pinned above it.
|
|
101
|
+
*/
|
|
102
|
+
function Table({ columns, layout = "table", variant, footer, className, containerClassName, style, children, ...props }) {
|
|
103
|
+
const styles = tableVariants({ variant });
|
|
104
|
+
const template = {
|
|
105
|
+
"--table-columns": formatColumnTemplate(columns, [
|
|
106
|
+
"medium",
|
|
107
|
+
"low",
|
|
108
|
+
"lowest"
|
|
109
|
+
]),
|
|
110
|
+
"--table-columns-md": formatColumnTemplate(columns, ["low", "lowest"]),
|
|
111
|
+
"--table-columns-lg": formatColumnTemplate(columns, ["lowest"]),
|
|
112
|
+
"--table-columns-xl": formatColumnTemplate(columns, []),
|
|
113
|
+
...style
|
|
114
|
+
};
|
|
115
|
+
const Root = layout === "list" ? "div" : "table";
|
|
116
|
+
return /* @__PURE__ */ jsx(TableContext, {
|
|
117
|
+
value: {
|
|
118
|
+
layout,
|
|
119
|
+
columns
|
|
120
|
+
},
|
|
121
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
122
|
+
className: styles.container({ className: containerClassName }),
|
|
123
|
+
children: [/* @__PURE__ */ jsx(Root, {
|
|
124
|
+
role: layout === "list" ? "list" : "table",
|
|
125
|
+
className: styles.table({ className }),
|
|
126
|
+
style: template,
|
|
127
|
+
...props,
|
|
128
|
+
children
|
|
129
|
+
}), footer]
|
|
130
|
+
})
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* The row of column names: 40px, on the surface, with one line under it in the card's edge
|
|
135
|
+
* colour. The first row draws no line of its own, so the two never stack. A list has none, and
|
|
136
|
+
* renders nothing for one.
|
|
137
|
+
*/
|
|
138
|
+
function TableHeader({ sticky, className, children, ...props }) {
|
|
139
|
+
if (use(TableContext).layout === "list") return null;
|
|
140
|
+
return /* @__PURE__ */ jsx("thead", {
|
|
141
|
+
role: "rowgroup",
|
|
142
|
+
"data-sticky": sticky ? "" : void 0,
|
|
143
|
+
className: cn(ROW_GRID_CLASSES, "border-b bg-surface", sticky && "sticky top-(--table-sticky-top,0px) z-20", className),
|
|
144
|
+
...props,
|
|
145
|
+
children: /* @__PURE__ */ jsx("tr", {
|
|
146
|
+
role: "row",
|
|
147
|
+
className: cn(ROW_GRID_CLASSES, "h-10 items-center"),
|
|
148
|
+
children
|
|
149
|
+
})
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* The rows. A table cut into runs (days, workspaces) takes one body per run, each opening with
|
|
154
|
+
* its `TableGroupHeader`, so the heading sticks while its own rows are in view.
|
|
155
|
+
*/
|
|
156
|
+
function TableBody({ className, ...props }) {
|
|
157
|
+
const { layout } = use(TableContext);
|
|
158
|
+
return /* @__PURE__ */ jsx(layout === "list" ? "div" : "tbody", {
|
|
159
|
+
role: layout === "list" ? "presentation" : "rowgroup",
|
|
160
|
+
className: cn(ROW_GRID_CLASSES, "[&:first-of-type>:first-child]:border-t-0", className),
|
|
161
|
+
...props
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* One record. A row whose name is a `TableRowLink` opens it from anywhere on the row and takes
|
|
166
|
+
* the hover fill; a row without one keeps its background under the pointer.
|
|
167
|
+
*/
|
|
168
|
+
function TableRow({ size, selected, inactive, className, ...props }) {
|
|
169
|
+
const { layout } = use(TableContext);
|
|
170
|
+
return /* @__PURE__ */ jsx(layout === "list" ? "div" : "tr", {
|
|
171
|
+
role: layout === "list" ? "listitem" : "row",
|
|
172
|
+
"data-selected": selected ? "" : void 0,
|
|
173
|
+
"data-inactive": inactive ? "" : void 0,
|
|
174
|
+
className: tableRowVariants({
|
|
175
|
+
size,
|
|
176
|
+
className
|
|
177
|
+
}),
|
|
178
|
+
...props
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* A column name, in the control weight. A sortable column is a button, with the arrow of its
|
|
183
|
+
* order while the table is sorted by it; unsorted, it looks like any other name.
|
|
184
|
+
*/
|
|
185
|
+
function TableHead({ align, priority, sort, onSort, className, children, ...props }) {
|
|
186
|
+
const sorted = sort === "ascending" || sort === "descending";
|
|
187
|
+
const Arrow = sort === "ascending" ? ArrowUpIcon : ArrowDownIcon;
|
|
188
|
+
return /* @__PURE__ */ jsx("th", {
|
|
189
|
+
role: "columnheader",
|
|
190
|
+
scope: "col",
|
|
191
|
+
"data-priority": priority,
|
|
192
|
+
"aria-sort": sort,
|
|
193
|
+
className: tableCellVariants({
|
|
194
|
+
align,
|
|
195
|
+
priority,
|
|
196
|
+
className: cn("gap-1 font-medium text-control text-ink", className)
|
|
197
|
+
}),
|
|
198
|
+
...props,
|
|
199
|
+
children: onSort ? /* @__PURE__ */ jsxs("button", {
|
|
200
|
+
type: "button",
|
|
201
|
+
className: "inline-flex min-w-0 cursor-pointer items-center gap-1 rounded-xs hover:text-ink-secondary",
|
|
202
|
+
onClick: onSort,
|
|
203
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
204
|
+
className: "truncate",
|
|
205
|
+
children
|
|
206
|
+
}), sorted && /* @__PURE__ */ jsx(Arrow, { className: "size-3 shrink-0" })]
|
|
207
|
+
}) : children
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* One cell, the Text type: a line of ink that ends in an ellipsis. Every other cell type is
|
|
212
|
+
* built on it. Give it the `align` and `priority` of its column's head.
|
|
213
|
+
*/
|
|
214
|
+
function TableCell({ align, priority, className, children, ...props }) {
|
|
215
|
+
const { layout } = use(TableContext);
|
|
216
|
+
const scope = use(TableColumnScopeContext);
|
|
217
|
+
const columnPriority = priority ?? scope.priority;
|
|
218
|
+
const Cell = layout === "list" ? "div" : "td";
|
|
219
|
+
const text = typeof children === "string" || typeof children === "number";
|
|
220
|
+
return /* @__PURE__ */ jsx(Cell, {
|
|
221
|
+
role: layout === "list" ? void 0 : "cell",
|
|
222
|
+
"data-priority": columnPriority,
|
|
223
|
+
className: tableCellVariants({
|
|
224
|
+
align: align ?? scope.align,
|
|
225
|
+
priority: columnPriority,
|
|
226
|
+
className
|
|
227
|
+
}),
|
|
228
|
+
...props,
|
|
229
|
+
children: text ? /* @__PURE__ */ jsx("span", {
|
|
230
|
+
className: "truncate",
|
|
231
|
+
children
|
|
232
|
+
}) : children
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Hands the cells inside it their column's `align` and `priority`, for a cell rendered by code
|
|
237
|
+
* that knows nothing of its column (a `DataTable` column's `cell`). A cell's own props win.
|
|
238
|
+
*/
|
|
239
|
+
function TableColumnScope({ align, priority, children }) {
|
|
240
|
+
return /* @__PURE__ */ jsx(TableColumnScopeContext, {
|
|
241
|
+
value: {
|
|
242
|
+
align,
|
|
243
|
+
priority
|
|
244
|
+
},
|
|
245
|
+
children
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* The record's name as a link that covers the whole row: its box stretches over the row, and
|
|
250
|
+
* the focus ring is drawn round the row. The checkbox, the menu and any other link in the row
|
|
251
|
+
* sit above it (`relative z-10`, as the checkbox and actions cells do), so each keeps its own
|
|
252
|
+
* click. Pass `render` for a router's link.
|
|
253
|
+
*/
|
|
254
|
+
function TableRowLink({ render, className, ...props }) {
|
|
255
|
+
return useRender({
|
|
256
|
+
render,
|
|
257
|
+
defaultTagName: "a",
|
|
258
|
+
props: {
|
|
259
|
+
"data-row-link": "",
|
|
260
|
+
"data-press-target": "",
|
|
261
|
+
className: cn("truncate outline-none after:absolute after:inset-0", "focus-visible:after:outline-2 focus-visible:after:-outline-offset-2 focus-visible:after:outline-focus", className),
|
|
262
|
+
...props
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
/** The name column: the leading mark, the name in the control weight and a muted line. */
|
|
267
|
+
function TableIdentityCell({ leading, title, detail, extras, className, ...props }) {
|
|
268
|
+
return /* @__PURE__ */ jsxs(TableCell, {
|
|
269
|
+
className: cn("gap-3", className),
|
|
270
|
+
...props,
|
|
271
|
+
children: [leading && /* @__PURE__ */ jsx("span", {
|
|
272
|
+
className: "flex shrink-0",
|
|
273
|
+
children: leading
|
|
274
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
275
|
+
className: "flex min-w-0 flex-col gap-0.5",
|
|
276
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
277
|
+
className: "flex min-w-0 items-center gap-1.5",
|
|
278
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
279
|
+
className: "min-w-0 truncate font-medium",
|
|
280
|
+
children: title
|
|
281
|
+
}), extras && /* @__PURE__ */ jsx("span", {
|
|
282
|
+
className: "flex shrink-0 items-center gap-1.5",
|
|
283
|
+
children: extras
|
|
284
|
+
})]
|
|
285
|
+
}), detail && /* @__PURE__ */ jsx("span", {
|
|
286
|
+
className: "truncate text-ink-muted text-xs",
|
|
287
|
+
children: detail
|
|
288
|
+
})]
|
|
289
|
+
})]
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* A figure, Number or Money: end-aligned in tabular figures. The caller formats the value, a
|
|
294
|
+
* sum of money with its currency.
|
|
295
|
+
*/
|
|
296
|
+
function TableNumberCell({ align, className, ...props }) {
|
|
297
|
+
const scope = use(TableColumnScopeContext);
|
|
298
|
+
return /* @__PURE__ */ jsx(TableCell, {
|
|
299
|
+
align: align ?? scope.align ?? "end",
|
|
300
|
+
className: cn("tabular-nums", className),
|
|
301
|
+
...props
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
/** A date, muted: pass a `RelativeTime`, which keeps the exact moment for its tooltip. */
|
|
305
|
+
function TableDateCell({ className, ...props }) {
|
|
306
|
+
return /* @__PURE__ */ jsx(TableCell, {
|
|
307
|
+
className: cn("text-ink-muted tabular-nums", className),
|
|
308
|
+
...props
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
/** A status: pass one `Badge`. */
|
|
312
|
+
function TableBadgeCell(props) {
|
|
313
|
+
return /* @__PURE__ */ jsx(TableCell, { ...props });
|
|
314
|
+
}
|
|
315
|
+
/** Tags: the first two, then a count of the rest. */
|
|
316
|
+
function TableTagsCell({ tags, max = 2, className, ...props }) {
|
|
317
|
+
const rest = tags.length - max;
|
|
318
|
+
return /* @__PURE__ */ jsxs(TableCell, {
|
|
319
|
+
className: cn("gap-1", className),
|
|
320
|
+
...props,
|
|
321
|
+
children: [Children.toArray(tags.slice(0, max)), rest > 0 && /* @__PURE__ */ jsxs("span", {
|
|
322
|
+
className: "shrink-0 text-ink-muted text-xs tabular-nums",
|
|
323
|
+
children: ["+", rest]
|
|
324
|
+
})]
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
/** A trend: a `Sparkline` across the cell, 32px tall. */
|
|
328
|
+
function TableSparklineCell({ data, ...props }) {
|
|
329
|
+
return /* @__PURE__ */ jsx(TableCell, {
|
|
330
|
+
...props,
|
|
331
|
+
children: /* @__PURE__ */ jsx(Sparkline, {
|
|
332
|
+
data,
|
|
333
|
+
className: "h-8 w-full"
|
|
334
|
+
})
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
const METER_TONES = {
|
|
338
|
+
neutral: {
|
|
339
|
+
bar: "bg-ink",
|
|
340
|
+
ring: "stroke-ink"
|
|
341
|
+
},
|
|
342
|
+
brand: {
|
|
343
|
+
bar: "bg-brand",
|
|
344
|
+
ring: "stroke-brand"
|
|
345
|
+
},
|
|
346
|
+
warning: {
|
|
347
|
+
bar: "bg-warning",
|
|
348
|
+
ring: "stroke-warning"
|
|
349
|
+
},
|
|
350
|
+
danger: {
|
|
351
|
+
bar: "bg-danger",
|
|
352
|
+
ring: "stroke-danger"
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
/** The ring's radius in its 16px box, and the length of its circle. */
|
|
356
|
+
const RING_RADIUS = 6;
|
|
357
|
+
const RING_LENGTH = 2 * Math.PI * RING_RADIUS;
|
|
358
|
+
/** Usage against a limit: a bar or a ring, then the figure. It turns warning past 90%. */
|
|
359
|
+
function TableMeterCell({ value, max, label, tone, layout = "bar", className, ...props }) {
|
|
360
|
+
const share = max > 0 ? Math.min(value / max, 1) : 0;
|
|
361
|
+
const tones = METER_TONES[tone ?? (share > .9 ? "warning" : "neutral")];
|
|
362
|
+
const ring = layout === "ring";
|
|
363
|
+
return /* @__PURE__ */ jsxs(TableCell, {
|
|
364
|
+
className: cn(ring ? "gap-1.5" : "gap-2", className),
|
|
365
|
+
...props,
|
|
366
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
367
|
+
role: "meter",
|
|
368
|
+
"aria-valuenow": value,
|
|
369
|
+
"aria-valuemin": 0,
|
|
370
|
+
"aria-valuemax": max,
|
|
371
|
+
"aria-label": typeof label === "string" ? label : void 0,
|
|
372
|
+
className: cn("shrink-0", ring ? "flex size-3.5" : "h-1 w-12 overflow-hidden rounded-full bg-fill"),
|
|
373
|
+
children: ring ? /* @__PURE__ */ jsxs("svg", {
|
|
374
|
+
"aria-hidden": true,
|
|
375
|
+
viewBox: "0 0 16 16",
|
|
376
|
+
fill: "none",
|
|
377
|
+
className: "size-full -rotate-90",
|
|
378
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
379
|
+
cx: "8",
|
|
380
|
+
cy: "8",
|
|
381
|
+
r: RING_RADIUS,
|
|
382
|
+
strokeWidth: "2.5",
|
|
383
|
+
className: "stroke-fill-strong"
|
|
384
|
+
}), share > 0 && /* @__PURE__ */ jsx("circle", {
|
|
385
|
+
cx: "8",
|
|
386
|
+
cy: "8",
|
|
387
|
+
r: RING_RADIUS,
|
|
388
|
+
strokeWidth: "2.5",
|
|
389
|
+
strokeLinecap: "round",
|
|
390
|
+
strokeDasharray: `${share * RING_LENGTH} ${RING_LENGTH}`,
|
|
391
|
+
className: tones.ring
|
|
392
|
+
})]
|
|
393
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
394
|
+
className: cn("block h-full rounded-full", tones.bar),
|
|
395
|
+
style: { width: `${share * 100}%` }
|
|
396
|
+
})
|
|
397
|
+
}), label && /* @__PURE__ */ jsx("span", {
|
|
398
|
+
className: cn("truncate tabular-nums", !ring && "text-ink-muted text-xs"),
|
|
399
|
+
children: label
|
|
400
|
+
})]
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
/** A country: its flag and its name. */
|
|
404
|
+
function TableCountryCell({ flag, name, ...props }) {
|
|
405
|
+
return /* @__PURE__ */ jsxs(TableCell, {
|
|
406
|
+
...props,
|
|
407
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
408
|
+
className: "flex shrink-0",
|
|
409
|
+
children: flag
|
|
410
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
411
|
+
className: "truncate",
|
|
412
|
+
children: name
|
|
413
|
+
})]
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
/** A machine string (a key, an id) in mono, with a copy button that sits above the row link. */
|
|
417
|
+
function TableMonoCell({ value, copy, className, ...props }) {
|
|
418
|
+
return /* @__PURE__ */ jsxs(TableCell, {
|
|
419
|
+
"data-slot": "mono",
|
|
420
|
+
className: cn("gap-1", className),
|
|
421
|
+
...props,
|
|
422
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
423
|
+
className: "truncate font-mono text-ink-secondary text-xs in-data-inactive:opacity-50",
|
|
424
|
+
children: value
|
|
425
|
+
}), copy && /* @__PURE__ */ jsx(CopyButton, {
|
|
426
|
+
value,
|
|
427
|
+
variant: "ghost",
|
|
428
|
+
size: "xs",
|
|
429
|
+
className: "relative z-10 in-data-inactive:opacity-50"
|
|
430
|
+
})]
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
/** A person on one line: a 20px avatar and the name. */
|
|
434
|
+
function TablePersonCell({ avatar, name, ...props }) {
|
|
435
|
+
return /* @__PURE__ */ jsxs(TableCell, {
|
|
436
|
+
...props,
|
|
437
|
+
children: [avatar && /* @__PURE__ */ jsx("span", {
|
|
438
|
+
className: "flex shrink-0",
|
|
439
|
+
children: avatar
|
|
440
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
441
|
+
className: "truncate",
|
|
442
|
+
children: name
|
|
443
|
+
})]
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* The row's menu, end-aligned above the row link. It shows on hover, on keyboard focus, while
|
|
448
|
+
* open, and always on a touch screen, which has no hover to give.
|
|
449
|
+
*/
|
|
450
|
+
function TableActionsCell({ align, className, children, ...props }) {
|
|
451
|
+
const scope = use(TableColumnScopeContext);
|
|
452
|
+
return /* @__PURE__ */ jsx(TableCell, {
|
|
453
|
+
"data-slot": "actions",
|
|
454
|
+
align: align ?? scope.align ?? "end",
|
|
455
|
+
className,
|
|
456
|
+
...props,
|
|
457
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
458
|
+
className: cn("relative z-10 flex", "opacity-0 group-hover/row:opacity-100 focus-within:opacity-100 has-data-popup-open:opacity-100 pointer-coarse:opacity-100"),
|
|
459
|
+
children
|
|
460
|
+
})
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
/** Selects the row, or every row on the page in the header. */
|
|
464
|
+
function TableCheckboxCell({ label, header: headerProp, checked, indeterminate, disabled, onCheckedChange, className, ...props }) {
|
|
465
|
+
const { layout } = use(TableContext);
|
|
466
|
+
const header = headerProp && layout === "table";
|
|
467
|
+
const box = /* @__PURE__ */ jsx(Checkbox, {
|
|
468
|
+
"aria-label": label,
|
|
469
|
+
checked,
|
|
470
|
+
indeterminate,
|
|
471
|
+
disabled,
|
|
472
|
+
className: "relative z-10 in-data-inactive:opacity-50",
|
|
473
|
+
onCheckedChange
|
|
474
|
+
});
|
|
475
|
+
const classes = cn("pr-0 first:pl-4", className);
|
|
476
|
+
if (header) {
|
|
477
|
+
const { align, priority, ...headProps } = props;
|
|
478
|
+
return /* @__PURE__ */ jsx("th", {
|
|
479
|
+
role: "columnheader",
|
|
480
|
+
scope: "col",
|
|
481
|
+
"data-slot": "checkbox",
|
|
482
|
+
className: tableCellVariants({
|
|
483
|
+
align,
|
|
484
|
+
priority,
|
|
485
|
+
className: classes
|
|
486
|
+
}),
|
|
487
|
+
...headProps,
|
|
488
|
+
children: box
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
return /* @__PURE__ */ jsx(TableCell, {
|
|
492
|
+
"data-slot": "checkbox",
|
|
493
|
+
className: classes,
|
|
494
|
+
...props,
|
|
495
|
+
children: box
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* A heading row for the run of rows under it: a day of a feed, a workspace of a list. It sticks
|
|
500
|
+
* under the header while its own body is in view, and the next one pushes it out. Opaque, so the
|
|
501
|
+
* rows slide under it.
|
|
502
|
+
*/
|
|
503
|
+
function TableGroupHeader({ className, children, ...props }) {
|
|
504
|
+
const { layout } = use(TableContext);
|
|
505
|
+
const list = layout === "list";
|
|
506
|
+
const Row = list ? "div" : "tr";
|
|
507
|
+
const Heading = list ? "div" : "th";
|
|
508
|
+
return /* @__PURE__ */ jsx(Row, {
|
|
509
|
+
role: list ? "listitem" : "row",
|
|
510
|
+
className: cn(ROW_GRID_CLASSES, "sticky top-[calc(var(--table-sticky-top,0px)+var(--table-header-height,0px))] z-15", "h-7 border-t border-edge-subtle bg-fill-subtle", className),
|
|
511
|
+
...props,
|
|
512
|
+
children: /* @__PURE__ */ jsx(Heading, {
|
|
513
|
+
role: list ? "heading" : "rowheader",
|
|
514
|
+
"aria-level": list ? 3 : void 0,
|
|
515
|
+
scope: list ? void 0 : "rowgroup",
|
|
516
|
+
className: "col-span-full flex items-center px-5 text-left font-medium text-ink-secondary text-xs",
|
|
517
|
+
children
|
|
518
|
+
})
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* A loading row the size of the rows it stands in for, one stand-in per column of the table.
|
|
523
|
+
* Put five in the body on a first load; while a later page loads, keep the old rows and dim them.
|
|
524
|
+
*/
|
|
525
|
+
function TableSkeletonRow({ size, index = 0 }) {
|
|
526
|
+
const { columns } = use(TableContext);
|
|
527
|
+
const nameWidth = SKELETON_NAME_WIDTHS[index % SKELETON_NAME_WIDTHS.length];
|
|
528
|
+
const nameColumn = columns.findIndex((column) => column.skeleton !== false);
|
|
529
|
+
return /* @__PURE__ */ jsx(TableRow, {
|
|
530
|
+
size,
|
|
531
|
+
"aria-hidden": true,
|
|
532
|
+
children: columns.map((column, position) => /* @__PURE__ */ jsx(TableCell, {
|
|
533
|
+
align: column.align,
|
|
534
|
+
priority: column.priority,
|
|
535
|
+
className: "gap-2",
|
|
536
|
+
children: column.skeleton === false ? null : position === nameColumn && size === "identity" ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Skeleton, { className: "size-7 shrink-0 rounded-md" }), /* @__PURE__ */ jsxs("span", {
|
|
537
|
+
className: "flex flex-col gap-1.5",
|
|
538
|
+
children: [/* @__PURE__ */ jsx(Skeleton, { className: cn("h-3", nameWidth) }), /* @__PURE__ */ jsx(Skeleton, { className: "h-2.5 w-24" })]
|
|
539
|
+
})] }) : /* @__PURE__ */ jsx(Skeleton, { className: cn("h-3", position === nameColumn ? nameWidth : "w-16") })
|
|
540
|
+
}, position))
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Stands in for the rows: the small empty state across every column, under the header, which
|
|
545
|
+
* keeps its line. Put it inside `TableBody`.
|
|
546
|
+
*/
|
|
547
|
+
function TableMessage({ kind, icon, title, description, action }) {
|
|
548
|
+
const { layout } = use(TableContext);
|
|
549
|
+
const list = layout === "list";
|
|
550
|
+
const Row = list ? "div" : "tr";
|
|
551
|
+
const Cell = list ? "div" : "td";
|
|
552
|
+
return /* @__PURE__ */ jsx(Row, {
|
|
553
|
+
role: list ? "listitem" : "row",
|
|
554
|
+
"data-kind": kind,
|
|
555
|
+
className: cn(ROW_GRID_CLASSES, "border-t border-edge-subtle"),
|
|
556
|
+
children: /* @__PURE__ */ jsx(Cell, {
|
|
557
|
+
role: list ? void 0 : "cell",
|
|
558
|
+
className: "col-span-full py-5",
|
|
559
|
+
children: /* @__PURE__ */ jsx(EmptyState, {
|
|
560
|
+
size: "sm",
|
|
561
|
+
role: kind === "error" ? "alert" : void 0,
|
|
562
|
+
icon: icon ?? (kind === "empty" ? void 0 : MESSAGE_ICONS[kind]),
|
|
563
|
+
title,
|
|
564
|
+
description,
|
|
565
|
+
action
|
|
566
|
+
})
|
|
567
|
+
})
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
export { Table, TableActionsCell, TableBadgeCell, TableBody, TableCell, TableCheckboxCell, TableColumnScope, TableCountryCell, TableDateCell, TableGroupHeader, TableHead, TableHeader, TableIdentityCell, TableMessage, TableMeterCell, TableMonoCell, TableNumberCell, TablePersonCell, TableRow, TableRowLink, TableSkeletonRow, TableSparklineCell, TableTagsCell, tableColumnPriorityClasses };
|
|
571
|
+
|
|
572
|
+
//# sourceMappingURL=table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.js","names":[],"sources":["../../src/components/table.tsx"],"sourcesContent":["\"use client\"\n\nimport { useRender } from \"@base-ui/react/use-render\"\nimport {\n Children,\n type ComponentProps,\n createContext,\n type CSSProperties,\n type ReactNode,\n use,\n} from \"react\"\nimport { rowPressClasses } from \"../lib/classes\"\nimport { AlertIcon, ArrowDownIcon, ArrowUpIcon, FilterIcon } from \"../lib/icons\"\nimport { cn, variants, type VariantProps } from \"../lib/variants\"\nimport { Checkbox } from \"./checkbox\"\nimport { CopyButton } from \"./copy-button\"\nimport { EmptyState } from \"./empty-state\"\nimport { Skeleton } from \"./skeleton\"\nimport { Sparkline } from \"./sparkline\"\n\n// The parts are table elements laid out as a CSS grid, so they carry their table roles\n// explicitly: a browser that sees `display: grid` on a `<table>` may stop exposing it as one.\n/* oxlint-disable jsx-a11y/no-redundant-roles */\n\n/**\n * Which columns give way as the table's box narrows: a `medium` column hides below the `@2xl`\n * container width (672px), a `low` one below `@4xl` (896px) and a `lowest` one below `@6xl`\n * (1152px), for a table with more columns than a laptop's content column holds. A column with\n * none always shows.\n */\nexport type TableColumnPriority = \"medium\" | \"low\" | \"lowest\"\n\nexport interface TableColumn {\n /** The column's grid track: `minmax(0,1fr)` for the name, a fixed `6rem` for a figure. */\n width: string\n priority?: TableColumnPriority\n /** Where a skeleton row puts its stand-in. */\n align?: \"start\" | \"end\"\n /** Whether a skeleton row draws a stand-in here. Off for a checkbox or actions column. */\n skeleton?: boolean\n}\n\ntype TableLayout = \"table\" | \"list\"\n\ninterface TableContextValue {\n layout: TableLayout\n columns: TableColumn[]\n}\n\nconst TableContext = createContext<TableContextValue>({ layout: \"table\", columns: [] })\n\ninterface TableColumnScopeValue {\n align?: \"start\" | \"end\"\n priority?: TableColumnPriority\n}\n\nconst TableColumnScopeContext = createContext<TableColumnScopeValue>({})\n\n/**\n * The classes that hide a cell of a column with a priority, on its head and on every cell, so\n * the column drops out whole. `Table` drops its track from the grid at the same widths.\n */\nexport const tableColumnPriorityClasses: Record<TableColumnPriority, string> = {\n medium: \"@max-2xl:hidden\",\n low: \"@max-4xl:hidden\",\n lowest: \"@max-6xl:hidden\",\n}\n\nfunction formatColumnTemplate(columns: TableColumn[], hidden: TableColumnPriority[]) {\n return columns\n .filter(column => !column.priority || !hidden.includes(column.priority))\n .map(column => column.width)\n .join(\" \")\n}\n\nconst ROW_GRID_CLASSES = \"col-span-full grid grid-cols-subgrid\"\n\nconst tableVariants = variants({\n slots: {\n container: \"@container relative\",\n table: [\n \"grid w-full text-control text-ink\",\n \"grid-cols-(--table-columns) @2xl:grid-cols-(--table-columns-md) @4xl:grid-cols-(--table-columns-lg) @6xl:grid-cols-(--table-columns-xl)\",\n // A sticky header pushes the sticky group headings down by its own height.\n \"has-[>[data-sticky]]:[--table-header-height:--spacing(10)]\",\n ],\n },\n\n variants: {\n variant: {\n // The card surface, its edge drawn by the wrapper so the rows' fills stay inside it.\n card: { container: \"overflow-clip rounded-lg border bg-surface shadow-card\" },\n // No surface, for a table inside another card or a dialog.\n flush: {},\n },\n },\n\n defaultVariants: {\n variant: \"card\",\n },\n})\n\nconst tableRowVariants = variants({\n base: [\n ROW_GRID_CLASSES,\n \"group/row relative items-center border-t border-edge-subtle\",\n // Only a row that opens something answers the pointer. The hover and focus fills leave out a\n // pressed link: they match with the same weight as the press fill and come later in the\n // stylesheet, so they would hide it.\n \"has-[[data-row-link]:not(:active)]:hover:bg-canvas has-[[data-row-link]:focus-visible:not(:active)]:bg-canvas\",\n rowPressClasses,\n \"data-selected:bg-fill-subtle data-selected:hover:bg-fill-subtle\",\n // The cell holding the row link sits on a layer above its neighbours. A faded cell is a\n // stacking context of its own, and a later one would otherwise paint over the link's box.\n // A grid item takes `z-index` without being positioned, so the link still fills the row.\n \"*:has-[[data-row-link]]:z-1\",\n // An archived or blocked record fades, all but its menu. A cell holding a control above the\n // row link (the checkbox, a copy button) fades its content instead: faded whole, it would be\n // a stacking context under the link's layer, and the control could not be clicked.\n \"data-inactive:*:not-data-[slot=actions]:not-data-[slot=checkbox]:not-data-[slot=mono]:opacity-50\",\n ],\n\n variants: {\n size: {\n /** 32px, for a feed or a dense list. */\n compact: \"h-8\",\n /** 44px, a one-line row. */\n default: \"h-11\",\n /** 52px, for a two-line name cell. */\n identity: \"h-13\",\n },\n },\n\n defaultVariants: {\n size: \"default\",\n },\n})\n\nconst tableCellVariants = variants({\n base: [\n \"flex min-w-0 items-center gap-2 px-2 first:pl-5 last:pr-5\",\n // The trailing inset goes to the last cell still shown: a hidden cell after it stays the\n // `:last-child`. Below 1152px that is a cell followed only by `lowest` ones, below 896px one\n // followed only by `low` and `lowest` ones, below 672px one followed only by cells with a\n // priority.\n \"@max-6xl:[&:not(:has(~:not([data-priority=lowest])))]:pr-5\",\n \"@max-4xl:[&:not(:has(~:not([data-priority=low]):not([data-priority=lowest])))]:pr-5\",\n \"@max-2xl:[&:not(:has(~:not([data-priority])))]:pr-5\",\n ],\n\n variants: {\n align: {\n start: \"justify-start text-left\",\n end: \"justify-end text-right\",\n },\n priority: tableColumnPriorityClasses,\n },\n\n defaultVariants: {\n align: \"start\",\n },\n})\n\ntype TableCellVariantProps = VariantProps<typeof tableCellVariants>\n\n/** Varied widths for a skeleton row's first line, so a stack of them does not read as stripes. */\nconst SKELETON_NAME_WIDTHS = [\"w-36\", \"w-28\", \"w-40\", \"w-32\", \"w-24\"]\n\nconst MESSAGE_ICONS = {\n filtered: <FilterIcon />,\n error: <AlertIcon />,\n}\n\nexport interface TableProps\n extends Omit<ComponentProps<\"table\">, \"children\">, VariantProps<typeof tableVariants> {\n /** Every column in order, the same list the head and the cells of each row follow. */\n columns: TableColumn[]\n /**\n * `list` draws the same rows with no column names, for a list of records (members, API keys):\n * the rows are list items rather than table rows.\n */\n layout?: TableLayout\n /** The band under the rows: `Pagination` or `PaginationInfinite`. */\n footer?: ReactNode\n /** Classes for the box around the table: the card, or the bare wrapper of a flush table. */\n containerClassName?: string\n children?: ReactNode\n}\n\n/**\n * A table on a CSS grid. The root sets one grid template from `columns`, and the header and\n * every row take it as a subgrid, so the columns line up however the rows are grouped. A row\n * stays a positioned box, which a real table row is not in Safari, so a stretched link can\n * fill it (`TableRowLink`). Columns with a `priority` drop out as the table's own box narrows.\n * Set `--table-sticky-top` on it when a sticky header must clear a bar pinned above it.\n */\nexport function Table({\n columns,\n layout = \"table\",\n variant,\n footer,\n className,\n containerClassName,\n style,\n children,\n ...props\n}: TableProps) {\n const styles = tableVariants({ variant })\n const template = {\n \"--table-columns\": formatColumnTemplate(columns, [\"medium\", \"low\", \"lowest\"]),\n \"--table-columns-md\": formatColumnTemplate(columns, [\"low\", \"lowest\"]),\n \"--table-columns-lg\": formatColumnTemplate(columns, [\"lowest\"]),\n \"--table-columns-xl\": formatColumnTemplate(columns, []),\n ...style,\n } as CSSProperties\n const Root = layout === \"list\" ? \"div\" : \"table\"\n\n return (\n <TableContext value={{ layout, columns }}>\n <div className={styles.container({ className: containerClassName })}>\n <Root\n role={layout === \"list\" ? \"list\" : \"table\"}\n className={styles.table({ className })}\n style={template}\n {...props}\n >\n {children}\n </Root>\n {footer}\n </div>\n </TableContext>\n )\n}\n\ninterface TableHeaderProps extends ComponentProps<\"thead\"> {\n /** Keeps the column names in view while the rows scroll under them. */\n sticky?: boolean\n}\n\n/**\n * The row of column names: 40px, on the surface, with one line under it in the card's edge\n * colour. The first row draws no line of its own, so the two never stack. A list has none, and\n * renders nothing for one.\n */\nexport function TableHeader({ sticky, className, children, ...props }: TableHeaderProps) {\n if (use(TableContext).layout === \"list\") return null\n\n return (\n <thead\n role=\"rowgroup\"\n data-sticky={sticky ? \"\" : undefined}\n className={cn(\n ROW_GRID_CLASSES,\n \"border-b bg-surface\",\n sticky && \"sticky top-(--table-sticky-top,0px) z-20\",\n className,\n )}\n {...props}\n >\n {/* The rule reads a header row as interactive; the role restores what `display: grid` drops. */}\n {/* oxlint-disable-next-line jsx-a11y/no-interactive-element-to-noninteractive-role */}\n <tr role=\"row\" className={cn(ROW_GRID_CLASSES, \"h-10 items-center\")}>\n {children}\n </tr>\n </thead>\n )\n}\n\n/**\n * The rows. A table cut into runs (days, workspaces) takes one body per run, each opening with\n * its `TableGroupHeader`, so the heading sticks while its own rows are in view.\n */\nexport function TableBody({ className, ...props }: ComponentProps<\"tbody\">) {\n const { layout } = use(TableContext)\n const Body = layout === \"list\" ? \"div\" : \"tbody\"\n\n return (\n <Body\n role={layout === \"list\" ? \"presentation\" : \"rowgroup\"}\n className={cn(\n ROW_GRID_CLASSES,\n // The first row of the table sits under the header's line, or the card's edge.\n \"[&:first-of-type>:first-child]:border-t-0\",\n className,\n )}\n {...props}\n />\n )\n}\n\nexport interface TableRowProps extends ComponentProps<\"tr\">, VariantProps<typeof tableRowVariants> {\n selected?: boolean\n /** Dims the row's cells, for a record that is archived or blocked. */\n inactive?: boolean\n}\n\n/**\n * One record. A row whose name is a `TableRowLink` opens it from anywhere on the row and takes\n * the hover fill; a row without one keeps its background under the pointer.\n */\nexport function TableRow({ size, selected, inactive, className, ...props }: TableRowProps) {\n const { layout } = use(TableContext)\n const Row = layout === \"list\" ? \"div\" : \"tr\"\n\n return (\n <Row\n role={layout === \"list\" ? \"listitem\" : \"row\"}\n data-selected={selected ? \"\" : undefined}\n data-inactive={inactive ? \"\" : undefined}\n className={tableRowVariants({ size, className })}\n {...props}\n />\n )\n}\n\nexport interface TableHeadProps extends Omit<ComponentProps<\"th\">, \"align\">, TableCellVariantProps {\n /** The order the table is in by this column. Left out for a column that does not sort. */\n sort?: \"ascending\" | \"descending\" | \"none\"\n /** Turns the name into a button that sorts by the column. */\n onSort?: () => void\n}\n\n/**\n * A column name, in the control weight. A sortable column is a button, with the arrow of its\n * order while the table is sorted by it; unsorted, it looks like any other name.\n */\nexport function TableHead({\n align,\n priority,\n sort,\n onSort,\n className,\n children,\n ...props\n}: TableHeadProps) {\n const sorted = sort === \"ascending\" || sort === \"descending\"\n const Arrow = sort === \"ascending\" ? ArrowUpIcon : ArrowDownIcon\n\n return (\n <th\n role=\"columnheader\"\n scope=\"col\"\n data-priority={priority}\n aria-sort={sort}\n className={tableCellVariants({\n align,\n priority,\n className: cn(\"gap-1 font-medium text-control text-ink\", className),\n })}\n {...props}\n >\n {onSort ? (\n <button\n type=\"button\"\n className=\"inline-flex min-w-0 cursor-pointer items-center gap-1 rounded-xs hover:text-ink-secondary\"\n onClick={onSort}\n >\n <span className=\"truncate\">{children}</span>\n {sorted && <Arrow className=\"size-3 shrink-0\" />}\n </button>\n ) : (\n children\n )}\n </th>\n )\n}\n\nexport interface TableCellProps\n extends Omit<ComponentProps<\"td\">, \"align\">, TableCellVariantProps {}\n\n/**\n * One cell, the Text type: a line of ink that ends in an ellipsis. Every other cell type is\n * built on it. Give it the `align` and `priority` of its column's head.\n */\nexport function TableCell({ align, priority, className, children, ...props }: TableCellProps) {\n const { layout } = use(TableContext)\n const scope = use(TableColumnScopeContext)\n const columnPriority = priority ?? scope.priority\n const Cell = layout === \"list\" ? \"div\" : \"td\"\n const text = typeof children === \"string\" || typeof children === \"number\"\n\n return (\n <Cell\n role={layout === \"list\" ? undefined : \"cell\"}\n data-priority={columnPriority}\n className={tableCellVariants({\n align: align ?? scope.align,\n priority: columnPriority,\n className,\n })}\n {...props}\n >\n {text ? <span className=\"truncate\">{children}</span> : children}\n </Cell>\n )\n}\n\ninterface TableColumnScopeProps extends TableColumnScopeValue {\n children?: ReactNode\n}\n\n/**\n * Hands the cells inside it their column's `align` and `priority`, for a cell rendered by code\n * that knows nothing of its column (a `DataTable` column's `cell`). A cell's own props win.\n */\nexport function TableColumnScope({ align, priority, children }: TableColumnScopeProps) {\n return <TableColumnScopeContext value={{ align, priority }}>{children}</TableColumnScopeContext>\n}\n\n/**\n * The record's name as a link that covers the whole row: its box stretches over the row, and\n * the focus ring is drawn round the row. The checkbox, the menu and any other link in the row\n * sit above it (`relative z-10`, as the checkbox and actions cells do), so each keeps its own\n * click. Pass `render` for a router's link.\n */\nexport function TableRowLink({ render, className, ...props }: useRender.ComponentProps<\"a\">) {\n return useRender({\n render,\n defaultTagName: \"a\",\n props: {\n \"data-row-link\": \"\",\n \"data-press-target\": \"\",\n className: cn(\n \"truncate outline-none after:absolute after:inset-0\",\n \"focus-visible:after:outline-2 focus-visible:after:-outline-offset-2 focus-visible:after:outline-focus\",\n className,\n ),\n ...props,\n },\n })\n}\n\ninterface TableIdentityCellProps extends Omit<TableCellProps, \"title\"> {\n /** A favicon, an avatar or a letter tile, sized 28px (`size-7`) by the caller. */\n leading?: ReactNode\n /** The record's name, usually a `TableRowLink`. */\n title: ReactNode\n /** One muted line under the name: a domain, an email. */\n detail?: ReactNode\n /** A flag or a badge after the name. */\n extras?: ReactNode\n}\n\n/** The name column: the leading mark, the name in the control weight and a muted line. */\nexport function TableIdentityCell({\n leading,\n title,\n detail,\n extras,\n className,\n ...props\n}: TableIdentityCellProps) {\n return (\n <TableCell className={cn(\"gap-3\", className)} {...props}>\n {leading && <span className=\"flex shrink-0\">{leading}</span>}\n <span className=\"flex min-w-0 flex-col gap-0.5\">\n <span className=\"flex min-w-0 items-center gap-1.5\">\n <span className=\"min-w-0 truncate font-medium\">{title}</span>\n {extras && <span className=\"flex shrink-0 items-center gap-1.5\">{extras}</span>}\n </span>\n {detail && <span className=\"truncate text-ink-muted text-xs\">{detail}</span>}\n </span>\n </TableCell>\n )\n}\n\n/**\n * A figure, Number or Money: end-aligned in tabular figures. The caller formats the value, a\n * sum of money with its currency.\n */\nexport function TableNumberCell({ align, className, ...props }: TableCellProps) {\n const scope = use(TableColumnScopeContext)\n\n return (\n <TableCell\n align={align ?? scope.align ?? \"end\"}\n className={cn(\"tabular-nums\", className)}\n {...props}\n />\n )\n}\n\n/** A date, muted: pass a `RelativeTime`, which keeps the exact moment for its tooltip. */\nexport function TableDateCell({ className, ...props }: TableCellProps) {\n return <TableCell className={cn(\"text-ink-muted tabular-nums\", className)} {...props} />\n}\n\n/** A status: pass one `Badge`. */\nexport function TableBadgeCell(props: TableCellProps) {\n return <TableCell {...props} />\n}\n\ninterface TableTagsCellProps extends Omit<TableCellProps, \"children\"> {\n /** One `Badge` per tag. */\n tags: ReactNode[]\n /** How many show before the rest fold into \"+N\". */\n max?: number\n}\n\n/** Tags: the first two, then a count of the rest. */\nexport function TableTagsCell({ tags, max = 2, className, ...props }: TableTagsCellProps) {\n const rest = tags.length - max\n\n return (\n <TableCell className={cn(\"gap-1\", className)} {...props}>\n {Children.toArray(tags.slice(0, max))}\n {rest > 0 && <span className=\"shrink-0 text-ink-muted text-xs tabular-nums\">+{rest}</span>}\n </TableCell>\n )\n}\n\ninterface TableSparklineCellProps extends Omit<TableCellProps, \"children\"> {\n data: number[]\n}\n\n/** A trend: a `Sparkline` across the cell, 32px tall. */\nexport function TableSparklineCell({ data, ...props }: TableSparklineCellProps) {\n return (\n <TableCell {...props}>\n <Sparkline data={data} className=\"h-8 w-full\" />\n </TableCell>\n )\n}\n\nconst METER_TONES = {\n neutral: { bar: \"bg-ink\", ring: \"stroke-ink\" },\n brand: { bar: \"bg-brand\", ring: \"stroke-brand\" },\n warning: { bar: \"bg-warning\", ring: \"stroke-warning\" },\n danger: { bar: \"bg-danger\", ring: \"stroke-danger\" },\n}\n\n/** The ring's radius in its 16px box, and the length of its circle. */\nconst RING_RADIUS = 6\nconst RING_LENGTH = 2 * Math.PI * RING_RADIUS\n\ninterface TableMeterCellProps extends Omit<TableCellProps, \"children\"> {\n value: number\n max: number\n /** The usage as text, formatted by the caller: \"8,240 of 10,000\". */\n label?: ReactNode\n /**\n * The meter's colour, for a meter whose state the app knows better than the share does (a\n * usage lock, a failed job). Left out, it is ink and turns warning past 90%.\n */\n tone?: keyof typeof METER_TONES\n /**\n * `bar` puts a 48px bar before a muted figure. `ring` puts a 14px ring before the figure in the\n * cell's own text, for a narrow column whose figure needs the room (\"35.5k of 657.2k rows\").\n */\n layout?: \"bar\" | \"ring\"\n}\n\n/** Usage against a limit: a bar or a ring, then the figure. It turns warning past 90%. */\nexport function TableMeterCell({\n value,\n max,\n label,\n tone,\n layout = \"bar\",\n className,\n ...props\n}: TableMeterCellProps) {\n const share = max > 0 ? Math.min(value / max, 1) : 0\n const tones = METER_TONES[tone ?? (share > 0.9 ? \"warning\" : \"neutral\")]\n const ring = layout === \"ring\"\n\n return (\n <TableCell className={cn(ring ? \"gap-1.5\" : \"gap-2\", className)} {...props}>\n <span\n // A native `<meter>` draws its own bar, which the theme's tokens cannot reach.\n // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role\n role=\"meter\"\n aria-valuenow={value}\n aria-valuemin={0}\n aria-valuemax={max}\n aria-label={typeof label === \"string\" ? label : undefined}\n className={cn(\n \"shrink-0\",\n ring ? \"flex size-3.5\" : \"h-1 w-12 overflow-hidden rounded-full bg-fill\",\n )}\n >\n {ring ? (\n <svg aria-hidden viewBox=\"0 0 16 16\" fill=\"none\" className=\"size-full -rotate-90\">\n <circle\n cx=\"8\"\n cy=\"8\"\n r={RING_RADIUS}\n strokeWidth=\"2.5\"\n className=\"stroke-fill-strong\"\n />\n {share > 0 && (\n <circle\n cx=\"8\"\n cy=\"8\"\n r={RING_RADIUS}\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeDasharray={`${share * RING_LENGTH} ${RING_LENGTH}`}\n className={tones.ring}\n />\n )}\n </svg>\n ) : (\n <span\n className={cn(\"block h-full rounded-full\", tones.bar)}\n style={{ width: `${share * 100}%` }}\n />\n )}\n </span>\n {label && (\n <span className={cn(\"truncate tabular-nums\", !ring && \"text-ink-muted text-xs\")}>\n {label}\n </span>\n )}\n </TableCell>\n )\n}\n\ninterface TableCountryCellProps extends Omit<TableCellProps, \"children\"> {\n /** The country's flag. */\n flag: ReactNode\n name: ReactNode\n}\n\n/** A country: its flag and its name. */\nexport function TableCountryCell({ flag, name, ...props }: TableCountryCellProps) {\n return (\n <TableCell {...props}>\n <span className=\"flex shrink-0\">{flag}</span>\n <span className=\"truncate\">{name}</span>\n </TableCell>\n )\n}\n\ninterface TableMonoCellProps extends Omit<TableCellProps, \"children\"> {\n value: string\n /** Adds a copy button after the value. */\n copy?: boolean\n}\n\n/** A machine string (a key, an id) in mono, with a copy button that sits above the row link. */\nexport function TableMonoCell({ value, copy, className, ...props }: TableMonoCellProps) {\n return (\n <TableCell data-slot=\"mono\" className={cn(\"gap-1\", className)} {...props}>\n <span className=\"truncate font-mono text-ink-secondary text-xs in-data-inactive:opacity-50\">\n {value}\n </span>\n {copy && (\n <CopyButton\n value={value}\n variant=\"ghost\"\n size=\"xs\"\n className=\"relative z-10 in-data-inactive:opacity-50\"\n />\n )}\n </TableCell>\n )\n}\n\ninterface TablePersonCellProps extends Omit<TableCellProps, \"children\"> {\n /** An avatar, sized 20px (`size-5`) by the caller. */\n avatar?: ReactNode\n name: ReactNode\n}\n\n/** A person on one line: a 20px avatar and the name. */\nexport function TablePersonCell({ avatar, name, ...props }: TablePersonCellProps) {\n return (\n <TableCell {...props}>\n {avatar && <span className=\"flex shrink-0\">{avatar}</span>}\n <span className=\"truncate\">{name}</span>\n </TableCell>\n )\n}\n\n/**\n * The row's menu, end-aligned above the row link. It shows on hover, on keyboard focus, while\n * open, and always on a touch screen, which has no hover to give.\n */\nexport function TableActionsCell({ align, className, children, ...props }: TableCellProps) {\n const scope = use(TableColumnScopeContext)\n\n return (\n <TableCell\n data-slot=\"actions\"\n align={align ?? scope.align ?? \"end\"}\n className={className}\n {...props}\n >\n <span\n className={cn(\n \"relative z-10 flex\",\n \"opacity-0 group-hover/row:opacity-100 focus-within:opacity-100 has-data-popup-open:opacity-100 pointer-coarse:opacity-100\",\n )}\n >\n {children}\n </span>\n </TableCell>\n )\n}\n\ninterface TableCheckboxCellProps\n extends\n Omit<TableCellProps, \"children\" | \"onChange\">,\n Pick<\n ComponentProps<typeof Checkbox>,\n \"checked\" | \"indeterminate\" | \"disabled\" | \"onCheckedChange\"\n > {\n /** Names the checkbox: \"Select openalternative.com\", \"Select all\". */\n label: string\n /** Renders a head cell for the header row: the select-all box. Ignored in a list. */\n header?: boolean\n}\n\n/** Selects the row, or every row on the page in the header. */\nexport function TableCheckboxCell({\n label,\n header: headerProp,\n checked,\n indeterminate,\n disabled,\n onCheckedChange,\n className,\n ...props\n}: TableCheckboxCellProps) {\n // A list has no header row, so a header box there renders as a plain cell.\n const { layout } = use(TableContext)\n const header = headerProp && layout === \"table\"\n const box = (\n <Checkbox\n aria-label={label}\n checked={checked}\n indeterminate={indeterminate}\n disabled={disabled}\n className=\"relative z-10 in-data-inactive:opacity-50\"\n onCheckedChange={onCheckedChange}\n />\n )\n const classes = cn(\"pr-0 first:pl-4\", className)\n\n if (header) {\n const { align, priority, ...headProps } = props\n return (\n <th\n role=\"columnheader\"\n scope=\"col\"\n data-slot=\"checkbox\"\n className={tableCellVariants({ align, priority, className: classes })}\n {...headProps}\n >\n {box}\n </th>\n )\n }\n\n return (\n <TableCell data-slot=\"checkbox\" className={classes} {...props}>\n {box}\n </TableCell>\n )\n}\n\ninterface TableGroupHeaderProps extends ComponentProps<\"tr\"> {}\n\n/**\n * A heading row for the run of rows under it: a day of a feed, a workspace of a list. It sticks\n * under the header while its own body is in view, and the next one pushes it out. Opaque, so the\n * rows slide under it.\n */\nexport function TableGroupHeader({ className, children, ...props }: TableGroupHeaderProps) {\n const { layout } = use(TableContext)\n const list = layout === \"list\"\n const Row = list ? \"div\" : \"tr\"\n const Heading = list ? \"div\" : \"th\"\n\n return (\n <Row\n role={list ? \"listitem\" : \"row\"}\n className={cn(\n ROW_GRID_CLASSES,\n // Above the controls of the rows sliding under it (`z-10`), below a sticky header (`z-20`).\n \"sticky top-[calc(var(--table-sticky-top,0px)+var(--table-header-height,0px))] z-15\",\n \"h-7 border-t border-edge-subtle bg-fill-subtle\",\n className,\n )}\n {...props}\n >\n <Heading\n role={list ? \"heading\" : \"rowheader\"}\n aria-level={list ? 3 : undefined}\n scope={list ? undefined : \"rowgroup\"}\n className=\"col-span-full flex items-center px-5 text-left font-medium text-ink-secondary text-xs\"\n >\n {children}\n </Heading>\n </Row>\n )\n}\n\ninterface TableSkeletonRowProps extends VariantProps<typeof tableRowVariants> {\n /** The row's place in the stack, which picks the width of its first line. */\n index?: number\n}\n\n/**\n * A loading row the size of the rows it stands in for, one stand-in per column of the table.\n * Put five in the body on a first load; while a later page loads, keep the old rows and dim them.\n */\nexport function TableSkeletonRow({ size, index = 0 }: TableSkeletonRowProps) {\n const { columns } = use(TableContext)\n const nameWidth = SKELETON_NAME_WIDTHS[index % SKELETON_NAME_WIDTHS.length]\n // The first column that draws a stand-in, past a leading checkbox.\n const nameColumn = columns.findIndex(column => column.skeleton !== false)\n\n return (\n <TableRow size={size} aria-hidden>\n {columns.map((column, position) => (\n <TableCell\n // oxlint-disable-next-line react/no-array-index-key\n key={position}\n align={column.align}\n priority={column.priority}\n className=\"gap-2\"\n >\n {column.skeleton === false ? null : position === nameColumn && size === \"identity\" ? (\n <>\n <Skeleton className=\"size-7 shrink-0 rounded-md\" />\n <span className=\"flex flex-col gap-1.5\">\n <Skeleton className={cn(\"h-3\", nameWidth)} />\n <Skeleton className=\"h-2.5 w-24\" />\n </span>\n </>\n ) : (\n <Skeleton className={cn(\"h-3\", position === nameColumn ? nameWidth : \"w-16\")} />\n )}\n </TableCell>\n ))}\n </TableRow>\n )\n}\n\ninterface TableMessageProps {\n /**\n * `empty`: nothing exists yet, with the create action. `filtered`: nothing matches, with a way\n * to clear the filters. `error`: the load failed, with a retry.\n */\n kind: \"empty\" | \"filtered\" | \"error\"\n /** Required for `empty`; `filtered` and `error` draw a filter and an alert by default. */\n icon?: ReactNode\n title: ReactNode\n description?: ReactNode\n action?: ReactNode\n}\n\n/**\n * Stands in for the rows: the small empty state across every column, under the header, which\n * keeps its line. Put it inside `TableBody`.\n */\nexport function TableMessage({ kind, icon, title, description, action }: TableMessageProps) {\n const { layout } = use(TableContext)\n const list = layout === \"list\"\n const Row = list ? \"div\" : \"tr\"\n const Cell = list ? \"div\" : \"td\"\n\n return (\n <Row\n role={list ? \"listitem\" : \"row\"}\n data-kind={kind}\n className={cn(ROW_GRID_CLASSES, \"border-t border-edge-subtle\")}\n >\n <Cell role={list ? undefined : \"cell\"} className=\"col-span-full py-5\">\n <EmptyState\n size=\"sm\"\n role={kind === \"error\" ? \"alert\" : undefined}\n icon={icon ?? (kind === \"empty\" ? undefined : MESSAGE_ICONS[kind])}\n title={title}\n description={description}\n action={action}\n />\n </Cell>\n </Row>\n )\n}\n"],"mappings":";;;;;;;;;;;;;AAiDA,MAAM,eAAe,cAAiC;CAAE,QAAQ;CAAS,SAAS,CAAC;AAAE,CAAC;AAOtF,MAAM,0BAA0B,cAAqC,CAAC,CAAC;;;;;AAMvE,MAAa,6BAAkE;CAC7E,QAAQ;CACR,KAAK;CACL,QAAQ;AACV;AAEA,SAAS,qBAAqB,SAAwB,QAA+B;CACnF,OAAO,QACJ,QAAO,WAAU,CAAC,OAAO,YAAY,CAAC,OAAO,SAAS,OAAO,QAAQ,CAAC,CAAC,CACvE,KAAI,WAAU,OAAO,KAAK,CAAC,CAC3B,KAAK,GAAG;AACb;AAEA,MAAM,mBAAmB;AAEzB,MAAM,gBAAgB,SAAS;CAC7B,OAAO;EACL,WAAW;EACX,OAAO;GACL;GACA;GAEA;EACF;CACF;CAEA,UAAU,EACR,SAAS;EAEP,MAAM,EAAE,WAAW,yDAAyD;EAE5E,OAAO,CAAC;CACV,EACF;CAEA,iBAAiB,EACf,SAAS,OACX;AACF,CAAC;AAED,MAAM,mBAAmB,SAAS;CAChC,MAAM;EACJ;EACA;EAIA;EACA;EACA;EAIA;EAIA;CACF;CAEA,UAAU,EACR,MAAM;;EAEJ,SAAS;;EAET,SAAS;;EAET,UAAU;CACZ,EACF;CAEA,iBAAiB,EACf,MAAM,UACR;AACF,CAAC;AAED,MAAM,oBAAoB,SAAS;CACjC,MAAM;EACJ;EAKA;EACA;EACA;CACF;CAEA,UAAU;EACR,OAAO;GACL,OAAO;GACP,KAAK;EACP;EACA,UAAU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