@vitavision/ui 0.14.0 → 0.14.2

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/README.md CHANGED
@@ -130,9 +130,9 @@ deprecated) · `Breakdown`, `breakdownText` (counts by verdict as one thin stack
130
130
  `unit` written in the field; number-valued with `onValueChange`), `Textarea` (optionally growing
131
131
  with its content between `minRows` and `maxRows`) · `HighlightedText`, `findSpans` (a string
132
132
  with its placeholders, tags and terms marked, never parsed as HTML) · `VectorInput`,
133
- `PoseInput` · `Kbd` · `Listbox` (single choice among options that render their own content) ·
133
+ `PoseInput` · `Kbd`, `ShortcutList` (a screen's keyboard shortcuts as titled groups, for a `?` help dialog) · `Listbox` (single choice among options that render their own content) ·
134
134
  `PageHeader`, `Panel`, `ReadoutStrip`, `Section` · `Popover`, `PopoverClose` ·
135
- `SegmentedControl` · `Select` · `Slider` · `Table` (with `windowed` for thousands of rows, and `selectionFollowsFocus` for keyboard selection) ·
135
+ `SegmentedControl` · `Select` · `Slider` · `Table` (with `windowed` for thousands of rows, `selectionFollowsFocus` for keyboard selection, a column's `group` for a header row that spans columns, and `pinFirstColumn`) · `DeltaCell` (a number with its signed difference and a strength tint, for a numeric `Table` cell) ·
136
136
  `Checkbox`, `Switch` · `ToggleChip` · `Toaster`, `toast()` (notifications from anywhere; mount one `<Toaster />` near the root) ·
137
137
  `InfoHint`, `Tooltip`, `TooltipProvider` ·
138
138
  `ThemeToggle` · plus `cn`, `focusRing`, `focusRingInset`, and `formatNumber` / `parseNumber`
package/dist/index.d.ts CHANGED
@@ -293,6 +293,52 @@ export declare function ButtonLink({ variant, size, icon, asChild, className, ch
293
293
  asChild?: boolean | undefined;
294
294
  }): import("react").JSX.Element;
295
295
  //#endregion
296
+ //#region src/components/ui/DeltaCell.d.ts
297
+ /** How strongly a `DeltaCell` is highlighted. */
298
+ type DeltaStrength = "none" | "low" | "medium" | "high";
299
+ /**
300
+ * The strength a normalised magnitude is shown at.
301
+ *
302
+ * @param magnitude - Where the change falls on the caller's scale, `0` (no change) to `1` (the
303
+ * largest worth showing). Clamped. `undefined`, `null` and `NaN` give `none`.
304
+ * @returns `none` below 0.1, `low` below 0.4, `medium` below 0.7, else `high`.
305
+ */
306
+ export declare function deltaStrength(magnitude: number | null | undefined): DeltaStrength;
307
+ /** Props of `DeltaCell`. */
308
+ interface DeltaCellProps {
309
+ /** The number. A missing or non-finite one shows an em dash. */
310
+ value: number | null | undefined;
311
+ /** Its signed difference from the reference, in the value's own units. Missing or non-finite shows no difference. */
312
+ delta?: number | null | undefined;
313
+ /**
314
+ * How much the difference matters, normalised to `[0, 1]` by the caller: `0.25` is a quarter
315
+ * of the largest difference worth showing. Steps into a tint (see `deltaStrength`); leave it
316
+ * out for no tint.
317
+ */
318
+ magnitude?: number | null | undefined;
319
+ /** The tint: the accent (`signal`, the default) or a neutral grey. Never a verdict colour. */
320
+ tone?: "signal" | "neutral" | undefined;
321
+ /** Formats the value. Defaults to at most 4 significant figures, without trailing zeros. */
322
+ format?: ((value: number) => string) | undefined;
323
+ /** Formats the difference's size, without its sign. Defaults to `format`. */
324
+ deltaFormat?: ((delta: number) => string) | undefined;
325
+ /** The unit, written after the value. */
326
+ unit?: string | undefined;
327
+ /** What the difference is from, for assistive technology: "from default". Defaults to "change". */
328
+ deltaLabel?: string | undefined;
329
+ /** Merged onto the cell with `cn`. */
330
+ className?: string | undefined;
331
+ }
332
+ /**
333
+ * A value with its signed difference and a strength tint, for a numeric `Table` cell.
334
+ *
335
+ * The difference is written with an explicit sign (`+0.012`, `−0.4`; a zero has none) in muted
336
+ * text beside the value, and is announced as "change +0.012" or with `deltaLabel`. The tint
337
+ * carries `data-strength` (`none`, `low`, `medium`, `high`); it is never the only cue, since the
338
+ * difference is also text. Right-aligned and in mono when it sits in a `numeric` column.
339
+ */
340
+ export declare function DeltaCell({ value, delta, magnitude, tone, format, deltaFormat, unit, deltaLabel, className }: DeltaCellProps): import("react").JSX.Element;
341
+ //#endregion
296
342
  //#region src/components/ui/Density.d.ts
297
343
  /**
298
344
  * How much room the chrome takes: `comfortable` (the default, for a page you read through)
@@ -1128,6 +1174,39 @@ export declare function Select({ value, onValueChange, options, placeholder, uns
1128
1174
  className?: string | undefined;
1129
1175
  }): import("react").JSX.Element;
1130
1176
  //#endregion
1177
+ //#region src/components/ui/ShortcutList.d.ts
1178
+ /** One command and the keys that run it. */
1179
+ interface Shortcut {
1180
+ /**
1181
+ * The keys, as the keyboard labels them: each entry is one key or chord (`J`, `⇧ click`,
1182
+ * `⌘K`), and several distinct entries are alternatives (`["J", "↓"]` reads "J or ↓").
1183
+ */
1184
+ keys: readonly string[];
1185
+ /** What it does, as a short phrase ("Next tile"), unique within its group. */
1186
+ description: string;
1187
+ }
1188
+ /** A titled group of shortcuts ("Navigation", "Flags"). */
1189
+ interface ShortcutGroup {
1190
+ /** The group's heading, unique within the list. */
1191
+ title: string;
1192
+ /** Its shortcuts, in the order they should read. */
1193
+ shortcuts: readonly Shortcut[];
1194
+ }
1195
+ /** Props of `ShortcutList`. */
1196
+ type ShortcutListProps = Omit<ComponentProps<"div">, "children"> & {
1197
+ /** The groups, in the order they should read. Empty groups are left out. */
1198
+ groups: readonly ShortcutGroup[];
1199
+ };
1200
+ /**
1201
+ * The keyboard shortcuts of a screen as titled groups: each row a command's keys, as `Kbd`
1202
+ * caps, beside what it does. Groups flow into two columns where there is room.
1203
+ *
1204
+ * It only lists: binding the keys is the app's. Put it in a `Dialog` for a `?` help, or in a
1205
+ * panel. Each group is a `<section>` labelled by its heading, and its rows are a description
1206
+ * list, so a screen reader announces "J or ↓, Next tile".
1207
+ */
1208
+ export declare function ShortcutList({ groups, className, ...rest }: ShortcutListProps): import("react").JSX.Element;
1209
+ //#endregion
1131
1210
  //#region src/components/ui/Slider.d.ts
1132
1211
  /**
1133
1212
  * A continuous value, with its number rendered beside the track.
@@ -1200,6 +1279,12 @@ type Column<Row> = {
1200
1279
  numeric?: boolean;
1201
1280
  /** A CSS width for the column, e.g. `"6rem"`. */
1202
1281
  width?: string;
1282
+ /**
1283
+ * The label of the header group the column belongs to. Adjacent columns with the same label
1284
+ * are headed by one cell that spans them, in a row above the column headers; columns with no
1285
+ * group get an empty cell there. Any column with a `group` makes the row appear.
1286
+ */
1287
+ group?: string | undefined;
1203
1288
  /** The cell's content for a row. */
1204
1289
  cell: (row: Row) => ReactNode;
1205
1290
  /**
@@ -1266,7 +1351,7 @@ interface TableWindowing {
1266
1351
  * With `windowed` the table scrolls itself (vertically, under a sticky header), renders only the
1267
1352
  * rows in view, and uses a fixed layout: give columns a `width` where the content needs it.
1268
1353
  */
1269
- export declare function Table<Row>({ columns, rows, rowKey, empty, caption, className, onRowClick, isRowActive, onRowHover, sort: controlledSort, defaultSort, onSortChange, manualSort, windowed, selectionFollowsFocus }: {
1354
+ export declare function Table<Row>({ columns, rows, rowKey, empty, caption, className, onRowClick, isRowActive, onRowHover, sort: controlledSort, defaultSort, onSortChange, manualSort, windowed, selectionFollowsFocus, pinFirstColumn }: {
1270
1355
  /** The columns, in order. */
1271
1356
  columns: Column<Row>[];
1272
1357
  /** The rows, in their own order: the order shown while the table is not sorted. */
@@ -1324,6 +1409,13 @@ export declare function Table<Row>({ columns, rows, rowKey, empty, caption, clas
1324
1409
  * choose one. Needs `onRowClick`.
1325
1410
  */
1326
1411
  selectionFollowsFocus?: boolean | undefined;
1412
+ /**
1413
+ * Keep the first column in view while the others scroll sideways, for a table wider than its
1414
+ * container; the table is then as wide as its content (`min-w-max`) rather than squeezed to fit.
1415
+ * The column is drawn on `surface`, the panel colour, with a rule on its right edge;
1416
+ * give it a `width`. Put the table on a `Panel` or another `surface`.
1417
+ */
1418
+ pinFirstColumn?: boolean | undefined;
1327
1419
  }): import("react").JSX.Element;
1328
1420
  //#endregion
1329
1421
  //#region src/components/ui/Textarea.d.ts
@@ -1659,5 +1751,5 @@ export declare function Tabs<Id extends string>({ items, active, onSelect, label
1659
1751
  className?: string | undefined;
1660
1752
  }): import("react").JSX.Element;
1661
1753
  //#endregion
1662
- export type { BackLink, BreakdownProps, BreakdownSegment, BreakdownTextOptions, BreakdownTone, ButtonSize, ButtonVariant, CalloutTone, Column, Density, DropdownMenuProps, HighlightKind, HighlightRule, HighlightSpan, HighlightedTextProps, ListboxOption, ListboxOptionState, ListboxProps, MeasureTone, MenuCheckboxItemProps, MenuItemProps, NumberInputProps, PopoverProps, PoseInputProps, PoseValue, ProgressProps, Quaternion, ReadoutItem, RotationView, SelectOption, SortDirection, TabItem, TableSort, TableWindowing, TextareaProps, ThemeChoice, ToastOptions, ToastRecord, ToastStore, ToastTone, ToasterProps, Tone, Vec3, VectorInputProps };
1754
+ export type { BackLink, BreakdownProps, BreakdownSegment, BreakdownTextOptions, BreakdownTone, ButtonSize, ButtonVariant, CalloutTone, Column, DeltaCellProps, DeltaStrength, Density, DropdownMenuProps, HighlightKind, HighlightRule, HighlightSpan, HighlightedTextProps, ListboxOption, ListboxOptionState, ListboxProps, MeasureTone, MenuCheckboxItemProps, MenuItemProps, NumberInputProps, PopoverProps, PoseInputProps, PoseValue, ProgressProps, Quaternion, ReadoutItem, RotationView, SelectOption, Shortcut, ShortcutGroup, ShortcutListProps, SortDirection, TabItem, TableSort, TableWindowing, TextareaProps, ThemeChoice, ToastOptions, ToastRecord, ToastStore, ToastTone, ToasterProps, Tone, Vec3, VectorInputProps };
1663
1755
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { AlertTriangle, ArrowDown, ArrowUp, ArrowUpDown, Check, CheckCircle2, ChevronDown, ChevronRight, CircleCheck, CircleX, HelpCircle, Info, Loader2, Minus, Moon, Sun, SunMoon, TriangleAlert, X, XCircle } from "lucide-react";
2
- import { createContext, isValidElement, use, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
2
+ import { Fragment, createContext, isValidElement, use, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
3
3
  import * as RadixTooltip from "@radix-ui/react-tooltip";
4
4
  import { clsx } from "clsx";
5
5
  import { twMerge } from "tailwind-merge";
6
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
7
  import { Slot, Slottable } from "@radix-ui/react-slot";
8
8
  import * as RadixDialog from "@radix-ui/react-dialog";
9
9
  import * as RadixMenu from "@radix-ui/react-dropdown-menu";
@@ -532,6 +532,72 @@ function ButtonLink({ variant = "secondary", size, icon, asChild = false, classN
532
532
  });
533
533
  }
534
534
  //#endregion
535
+ //#region src/components/ui/DeltaCell.tsx
536
+ /**
537
+ * The strength a normalised magnitude is shown at.
538
+ *
539
+ * @param magnitude - Where the change falls on the caller's scale, `0` (no change) to `1` (the
540
+ * largest worth showing). Clamped. `undefined`, `null` and `NaN` give `none`.
541
+ * @returns `none` below 0.1, `low` below 0.4, `medium` below 0.7, else `high`.
542
+ */
543
+ function deltaStrength(magnitude) {
544
+ if (magnitude === null || magnitude === void 0 || Number.isNaN(magnitude)) return "none";
545
+ const m = Math.min(1, Math.max(0, magnitude));
546
+ if (m < .1) return "none";
547
+ if (m < .4) return "low";
548
+ if (m < .7) return "medium";
549
+ return "high";
550
+ }
551
+ const TINT = {
552
+ signal: {
553
+ none: "",
554
+ low: "bg-signal/8",
555
+ medium: "bg-signal/16",
556
+ high: "bg-signal/26"
557
+ },
558
+ neutral: {
559
+ none: "",
560
+ low: "bg-fg/6",
561
+ medium: "bg-fg/12",
562
+ high: "bg-fg/20"
563
+ }
564
+ };
565
+ const defaultFormat = (value) => String(Number(value.toPrecision(4)));
566
+ /**
567
+ * A value with its signed difference and a strength tint, for a numeric `Table` cell.
568
+ *
569
+ * The difference is written with an explicit sign (`+0.012`, `−0.4`; a zero has none) in muted
570
+ * text beside the value, and is announced as "change +0.012" or with `deltaLabel`. The tint
571
+ * carries `data-strength` (`none`, `low`, `medium`, `high`); it is never the only cue, since the
572
+ * difference is also text. Right-aligned and in mono when it sits in a `numeric` column.
573
+ */
574
+ function DeltaCell({ value, delta, magnitude, tone = "signal", format = defaultFormat, deltaFormat, unit, deltaLabel = "change", className }) {
575
+ const present = typeof value === "number" && Number.isFinite(value);
576
+ const hasDelta = typeof delta === "number" && Number.isFinite(delta);
577
+ const strength = deltaStrength(magnitude);
578
+ const sign = !hasDelta || delta === 0 ? "" : delta > 0 ? "+" : "−";
579
+ const size = hasDelta ? (deltaFormat ?? format)(Math.abs(delta)) : "";
580
+ return /* @__PURE__ */ jsxs("span", {
581
+ "data-delta-cell": "",
582
+ "data-strength": strength,
583
+ className: cn("inline-flex items-baseline justify-end gap-1.5 rounded-control px-1.5 py-0.5", TINT[tone][strength], className),
584
+ children: [/* @__PURE__ */ jsxs("span", { children: [present ? format(value) : "—", present && unit && /* @__PURE__ */ jsx("span", {
585
+ className: cn("ml-0.5", strength === "none" ? "text-fg-muted" : "text-fg"),
586
+ children: unit
587
+ })] }), hasDelta && /* @__PURE__ */ jsxs("span", {
588
+ className: cn("text-[0.85em]", strength === "none" ? "text-fg-muted" : "text-fg"),
589
+ children: [
590
+ /* @__PURE__ */ jsxs("span", {
591
+ className: "sr-only",
592
+ children: [deltaLabel, " "]
593
+ }),
594
+ sign,
595
+ size
596
+ ]
597
+ })]
598
+ });
599
+ }
600
+ //#endregion
535
601
  //#region src/components/ui/Dialog.tsx
536
602
  /**
537
603
  * Whether the body overflows its height cap, kept current as the dialog or its content
@@ -600,7 +666,7 @@ function ConfirmDialog({ open, onOpenChange, title, description, confirmLabel, o
600
666
  title,
601
667
  description,
602
668
  className,
603
- footer: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(RadixDialog.Close, {
669
+ footer: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(RadixDialog.Close, {
604
670
  asChild: true,
605
671
  children: /* @__PURE__ */ jsx(Button, {
606
672
  variant: "ghost",
@@ -929,7 +995,7 @@ function Field({ label, description, error, required = false, annotation, as = "
929
995
  hasError
930
996
  ]);
931
997
  const gap = byDensity(density, "gap-1.5", "gap-1");
932
- const labelled = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("span", {
998
+ const labelled = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("span", {
933
999
  className: "flex items-baseline gap-2",
934
1000
  children: [/* @__PURE__ */ jsxs("span", {
935
1001
  className: cn("font-medium text-fg", byDensity(density, "text-xs", "text-[11px]")),
@@ -1989,6 +2055,41 @@ function SelectItem({ value, label, note, disabled, muted = false }) {
1989
2055
  });
1990
2056
  }
1991
2057
  //#endregion
2058
+ //#region src/components/ui/ShortcutList.tsx
2059
+ /**
2060
+ * The keyboard shortcuts of a screen as titled groups: each row a command's keys, as `Kbd`
2061
+ * caps, beside what it does. Groups flow into two columns where there is room.
2062
+ *
2063
+ * It only lists: binding the keys is the app's. Put it in a `Dialog` for a `?` help, or in a
2064
+ * panel. Each group is a `<section>` labelled by its heading, and its rows are a description
2065
+ * list, so a screen reader announces "J or ↓, Next tile".
2066
+ */
2067
+ function ShortcutList({ groups, className, ...rest }) {
2068
+ const baseId = useId();
2069
+ return /* @__PURE__ */ jsx("div", {
2070
+ ...rest,
2071
+ className: cn("grid gap-x-8 gap-y-4 sm:grid-cols-2", className),
2072
+ children: groups.map((group, g) => group.shortcuts.length === 0 ? null : /* @__PURE__ */ jsxs("section", {
2073
+ "aria-labelledby": `${baseId}-${g}`,
2074
+ className: "min-w-0",
2075
+ children: [/* @__PURE__ */ jsx("h3", {
2076
+ id: `${baseId}-${g}`,
2077
+ className: "mb-1.5 text-[11px] font-semibold tracking-wider text-fg-muted uppercase",
2078
+ children: group.title
2079
+ }), /* @__PURE__ */ jsx("dl", {
2080
+ className: "grid grid-cols-[auto_1fr] items-baseline gap-x-3 gap-y-1 text-sm",
2081
+ children: group.shortcuts.map((shortcut) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("dt", {
2082
+ className: "flex flex-wrap items-center gap-1 text-xs text-fg-muted",
2083
+ children: shortcut.keys.map((key, k) => /* @__PURE__ */ jsxs(Fragment, { children: [k > 0 && /* @__PURE__ */ jsx("span", { children: "or" }), /* @__PURE__ */ jsx(Kbd, { children: key })] }, key))
2084
+ }), /* @__PURE__ */ jsx("dd", {
2085
+ className: "text-fg",
2086
+ children: shortcut.description
2087
+ })] }, shortcut.description))
2088
+ })]
2089
+ }, group.title))
2090
+ });
2091
+ }
2092
+ //#endregion
1992
2093
  //#region src/components/ui/Slider.tsx
1993
2094
  /**
1994
2095
  * A continuous value, with its number rendered beside the track.
@@ -2025,6 +2126,33 @@ function Slider({ value, onValueChange, onValueCommit, min = 0, max = 1, step =
2025
2126
  });
2026
2127
  }
2027
2128
  //#endregion
2129
+ //#region src/components/ui/tableGroups.ts
2130
+ /**
2131
+ * The cells of the group header row.
2132
+ *
2133
+ * Adjacent columns with the same `group` label are one cell; a column with no group, and
2134
+ * adjacent such columns, are one empty cell. The same label twice with another between
2135
+ * them is two groups.
2136
+ *
2137
+ * @param columns - The columns, in order.
2138
+ * @returns The cells, left to right, spanning every column; `null` when no column has a group, so no row is drawn.
2139
+ */
2140
+ function columnGroups(columns) {
2141
+ if (!columns.some((column) => column.group)) return null;
2142
+ const cells = [];
2143
+ columns.forEach((column, start) => {
2144
+ const label = column.group || null;
2145
+ const last = cells.at(-1);
2146
+ if (last && last.label === label) last.span += 1;
2147
+ else cells.push({
2148
+ label,
2149
+ span: 1,
2150
+ start
2151
+ });
2152
+ });
2153
+ return cells;
2154
+ }
2155
+ //#endregion
2028
2156
  //#region src/components/ui/tableSort.ts
2029
2157
  /** Strings by a fixed English collation that reads digit runs as numbers: "frame 9" before "frame 10". */
2030
2158
  const collator = new Intl.Collator("en", { numeric: true });
@@ -2166,6 +2294,18 @@ function navigate(key, position, rowCount, page) {
2166
2294
  //#region src/components/ui/Table.tsx
2167
2295
  /** Rows per screen before a windowed table has measured itself (a server render, the first paint). */
2168
2296
  const INITIAL_ROWS = 20;
2297
+ /**
2298
+ * A pinned cell sticks to the left edge of the scroll area on `surface`, with a rule on its
2299
+ * right edge so a cell scrolling under it reads as under it.
2300
+ */
2301
+ const pinned = "sticky left-0 z-[2] bg-surface shadow-[inset_-1px_0_0_var(--line)]";
2302
+ /**
2303
+ * A pinned body cell: it must be opaque, so a row's hover and active tint is painted on the
2304
+ * cell itself, mixed over `surface`, to match what the row's other cells show through.
2305
+ */
2306
+ function pinnedCell(clickable, active) {
2307
+ return cn("sticky left-0 z-[1] bg-surface shadow-[inset_-1px_0_0_var(--line)]", clickable && "group-hover/row:bg-raised", active && "bg-[color-mix(in_oklab,var(--surface),var(--signal)_10%)] group-hover/row:bg-[color-mix(in_oklab,var(--raised),var(--signal)_10%)]");
2308
+ }
2169
2309
  /** The header icon for a sort state: the direction when sorted, both arrows when only sortable. */
2170
2310
  const SORT_ICONS = {
2171
2311
  ascending: ArrowUp,
@@ -2192,7 +2332,7 @@ const SORT_ICONS = {
2192
2332
  * With `windowed` the table scrolls itself (vertically, under a sticky header), renders only the
2193
2333
  * rows in view, and uses a fixed layout: give columns a `width` where the content needs it.
2194
2334
  */
2195
- function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, className, onRowClick, isRowActive, onRowHover, sort: controlledSort, defaultSort = null, onSortChange, manualSort = false, windowed, selectionFollowsFocus = false }) {
2335
+ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, className, onRowClick, isRowActive, onRowHover, sort: controlledSort, defaultSort = null, onSortChange, manualSort = false, windowed, selectionFollowsFocus = false, pinFirstColumn = false }) {
2196
2336
  const density = useDensity();
2197
2337
  const [ownSort, setOwnSort] = useState(defaultSort);
2198
2338
  const controlled = controlledSort !== void 0;
@@ -2211,12 +2351,16 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
2211
2351
  const rowHeight = windowed?.rowHeight ?? 0;
2212
2352
  const scrollRef = useRef(null);
2213
2353
  const headRef = useRef(null);
2354
+ const groupRowRef = useRef(null);
2355
+ const groups = useMemo(() => columnGroups(columns), [columns]);
2356
+ const headerRows = groups ? 2 : 1;
2214
2357
  const bodyRef = useRef(null);
2215
2358
  const pendingFocus = useRef(null);
2216
2359
  const [scrollTop, setScrollTop] = useState(0);
2217
2360
  const [measured, setMeasured] = useState(null);
2218
2361
  const viewportHeight = measured?.viewport ?? windowed?.height ?? INITIAL_ROWS * rowHeight;
2219
2362
  const headerHeight = measured?.header ?? 0;
2363
+ const groupRowHeight = measured?.groupRow ?? 0;
2220
2364
  const range = windowed ? rowWindow({
2221
2365
  rowCount: order.length,
2222
2366
  rowHeight,
@@ -2239,9 +2383,10 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
2239
2383
  if (!scroller.isConnected) return;
2240
2384
  const next = {
2241
2385
  viewport: scroller.clientHeight,
2242
- header: headRef.current?.offsetHeight ?? 0
2386
+ header: headRef.current?.offsetHeight ?? 0,
2387
+ groupRow: groupRowRef.current?.offsetHeight ?? 0
2243
2388
  };
2244
- setMeasured((last) => last?.viewport === next.viewport && last.header === next.header ? last : next);
2389
+ setMeasured((last) => last?.viewport === next.viewport && last.header === next.header && last.groupRow === next.groupRow ? last : next);
2245
2390
  };
2246
2391
  measure();
2247
2392
  setScrollTop(scroller.scrollTop);
@@ -2314,20 +2459,45 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
2314
2459
  "aria-label": caption ?? "Table"
2315
2460
  } : {},
2316
2461
  children: /* @__PURE__ */ jsxs("table", {
2317
- className: cn("w-full text-left", byDensity(density, "text-sm", "text-[11px]")),
2462
+ className: cn("w-full text-left", pinFirstColumn && "min-w-max", byDensity(density, "text-sm", "text-[11px]")),
2318
2463
  style: windowed ? { tableLayout: "fixed" } : void 0,
2319
- "aria-rowcount": windowed ? order.length + 1 : void 0,
2464
+ "aria-rowcount": windowed ? order.length + headerRows : void 0,
2320
2465
  children: [
2321
2466
  caption && /* @__PURE__ */ jsx("caption", {
2322
2467
  className: "sr-only",
2323
2468
  children: caption
2324
2469
  }),
2325
- /* @__PURE__ */ jsx("thead", {
2470
+ /* @__PURE__ */ jsxs("thead", {
2326
2471
  ref: headRef,
2327
- children: /* @__PURE__ */ jsx("tr", {
2328
- className: "border-b border-line",
2472
+ children: [groups && /* @__PURE__ */ jsx("tr", {
2473
+ ref: groupRowRef,
2329
2474
  "aria-rowindex": windowed ? 1 : void 0,
2330
- children: columns.map((column) => {
2475
+ children: groups.map((cell) => cell.label === null ? /* @__PURE__ */ jsx("td", {
2476
+ colSpan: cell.span,
2477
+ className: cn(windowed && "bg-surface", pinFirstColumn && cell.start === 0 && cell.span === 1 && pinned),
2478
+ style: windowed ? {
2479
+ position: "sticky",
2480
+ top: 0,
2481
+ zIndex: pinFirstColumn && cell.start === 0 ? 3 : 1
2482
+ } : void 0
2483
+ }, `gap-${cell.start}`) : /* @__PURE__ */ jsx("th", {
2484
+ scope: "colgroup",
2485
+ colSpan: cell.span,
2486
+ className: cn("font-medium text-fg-muted", byDensity(density, "pb-1 text-xs", "pb-0.5 text-[10px]"), cell.start + cell.span === columns.length ? "pr-0" : byDensity(density, "pr-3", "pr-2"), windowed && "bg-surface", pinFirstColumn && cell.start === 0 && cell.span === 1 && pinned),
2487
+ style: windowed ? {
2488
+ position: "sticky",
2489
+ top: 0,
2490
+ zIndex: pinFirstColumn && cell.start === 0 ? 3 : 1
2491
+ } : void 0,
2492
+ children: /* @__PURE__ */ jsx("span", {
2493
+ className: cn("block border-b border-line pb-1 text-left", byDensity(density, "pb-1", "pb-0.5")),
2494
+ children: cell.label
2495
+ })
2496
+ }, `group-${cell.start}`))
2497
+ }), /* @__PURE__ */ jsx("tr", {
2498
+ className: "border-b border-line",
2499
+ "aria-rowindex": windowed ? headerRows : void 0,
2500
+ children: columns.map((column, columnIndex) => {
2331
2501
  const sortable = isSortable(column);
2332
2502
  const direction = sortable && sort?.key === column.key ? sort.direction : void 0;
2333
2503
  const SortIcon = SORT_ICONS[direction ?? "none"];
@@ -2335,13 +2505,13 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
2335
2505
  scope: "col",
2336
2506
  style: windowed ? {
2337
2507
  position: "sticky",
2338
- top: 0,
2339
- zIndex: 1,
2508
+ top: groupRowHeight,
2509
+ zIndex: pinFirstColumn && columnIndex === 0 ? 3 : 1,
2340
2510
  ...column.width ? { width: column.width } : {}
2341
2511
  } : column.width ? { width: column.width } : void 0,
2342
2512
  "aria-sort": direction,
2343
2513
  "data-sort": sortable ? direction ?? "none" : void 0,
2344
- className: cn("font-medium text-fg-muted last:pr-0", byDensity(density, "pb-2 pr-3 text-xs", "pb-1 pr-2 text-[10px]"), column.numeric && "text-right", windowed && "bg-surface shadow-[inset_0_-1px_0_var(--line)]"),
2514
+ className: cn("font-medium text-fg-muted last:pr-0", byDensity(density, "pb-2 pr-3 text-xs", "pb-1 pr-2 text-[10px]"), column.numeric && "text-right", windowed && "bg-surface shadow-[inset_0_-1px_0_var(--line)]", pinFirstColumn && columnIndex === 0 && pinned, pinFirstColumn && columnIndex === 0 && !windowed && "bg-surface"),
2345
2515
  children: sortable ? /* @__PURE__ */ jsxs("button", {
2346
2516
  type: "button",
2347
2517
  onClick: () => changeSort(column),
@@ -2353,7 +2523,7 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
2353
2523
  }) : column.header
2354
2524
  }, column.key);
2355
2525
  })
2356
- })
2526
+ })]
2357
2527
  }),
2358
2528
  /* @__PURE__ */ jsxs("tbody", {
2359
2529
  ref: bodyRef,
@@ -2365,10 +2535,10 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
2365
2535
  const position = range.start + offset;
2366
2536
  return /* @__PURE__ */ jsx("tr", {
2367
2537
  "data-position": position,
2368
- "aria-rowindex": windowed ? position + 2 : void 0,
2538
+ "aria-rowindex": windowed ? position + 1 + headerRows : void 0,
2369
2539
  style: windowed ? { height: rowHeight } : void 0,
2370
2540
  "data-state": active ? "active" : void 0,
2371
- className: cn(!windowed && "border-b border-line/60 last:border-0", onRowClick && "cursor-pointer hover:bg-raised", active && "bg-signal/10"),
2541
+ className: cn("group/row", !windowed && "border-b border-line/60 last:border-0", onRowClick && "cursor-pointer hover:bg-raised", active && "bg-signal/10"),
2372
2542
  tabIndex: onRowClick ? 0 : void 0,
2373
2543
  "aria-current": active ? true : void 0,
2374
2544
  onClick: onRowClick ? (event) => onRowClick(row, index, event) : void 0,
@@ -2380,8 +2550,8 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
2380
2550
  } : void 0,
2381
2551
  onPointerEnter: onRowHover ? () => onRowHover(row, index) : void 0,
2382
2552
  onPointerLeave: onRowHover ? () => onRowHover(null, null) : void 0,
2383
- children: columns.map((column) => /* @__PURE__ */ jsx("td", {
2384
- className: cn("align-middle text-fg last:pr-0", byDensity(density, "py-2 pr-3", "py-0.5 pr-2"), column.numeric && "text-right font-mono tabular-nums", windowed && "shadow-[inset_0_-1px_0_color-mix(in_oklab,var(--line)_60%,transparent)]"),
2553
+ children: columns.map((column, columnIndex) => /* @__PURE__ */ jsx("td", {
2554
+ className: cn("align-middle text-fg last:pr-0", pinFirstColumn && columnIndex === 0 && pinnedCell(Boolean(onRowClick), active), byDensity(density, "py-2 pr-3", "py-0.5 pr-2"), column.numeric && "text-right font-mono tabular-nums", windowed && "shadow-[inset_0_-1px_0_color-mix(in_oklab,var(--line)_60%,transparent)]"),
2385
2555
  style: windowed ? {
2386
2556
  whiteSpace: "nowrap",
2387
2557
  overflow: "hidden",
@@ -2852,6 +3022,6 @@ function Tabs({ items, active, onSelect, label, idPrefix, className }) {
2852
3022
  });
2853
3023
  }
2854
3024
  //#endregion
2855
- export { Badge, Breakdown, Button, ButtonLink, Callout, Checkbox, ConfirmDialog, CountRun, DEFAULT_THEME_STORAGE_KEY, DensityProvider, Dialog, DialogClose, Disclosure, DropdownMenu, Empty, ErrorBox, Field, HighlightedText, InfoHint, Input, Kbd, Listbox, MenuCheckboxItem, MenuItem, MenuLabel, MenuSeparator, NumberInput, PageHeader, Panel, Popover, PopoverClose, PoseInput, Progress, ProgressBar, ReadoutStrip, Section, SegmentedControl, Select, Skeleton, SkeletonRows, Slider, StatusDot, Switch, Table, Tabs, Textarea, ThemeToggle, Toaster, ToggleChip, Tooltip, TooltipProvider, VectorInput, breakdownText, buttonClasses, byDensity, cn, controlClasses, createToastStore, defaultToastStore, findSpans, focusRing, focusRingInset, formatNumber, initTheme, inputClasses, parseNumber, progressText, readThemeChoice, resolveTheme, setThemeChoice, sortRows, toast, toneColor, useControlHeight, useDensity };
3025
+ export { Badge, Breakdown, Button, ButtonLink, Callout, Checkbox, ConfirmDialog, CountRun, DEFAULT_THEME_STORAGE_KEY, DeltaCell, DensityProvider, Dialog, DialogClose, Disclosure, DropdownMenu, Empty, ErrorBox, Field, HighlightedText, InfoHint, Input, Kbd, Listbox, MenuCheckboxItem, MenuItem, MenuLabel, MenuSeparator, NumberInput, PageHeader, Panel, Popover, PopoverClose, PoseInput, Progress, ProgressBar, ReadoutStrip, Section, SegmentedControl, Select, ShortcutList, Skeleton, SkeletonRows, Slider, StatusDot, Switch, Table, Tabs, Textarea, ThemeToggle, Toaster, ToggleChip, Tooltip, TooltipProvider, VectorInput, breakdownText, buttonClasses, byDensity, cn, controlClasses, createToastStore, defaultToastStore, deltaStrength, findSpans, focusRing, focusRingInset, formatNumber, initTheme, inputClasses, parseNumber, progressText, readThemeChoice, resolveTheme, setThemeChoice, sortRows, toast, toneColor, useControlHeight, useDensity };
2856
3026
 
2857
3027
  //# sourceMappingURL=index.js.map