@vitavision/ui 0.14.1 → 0.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -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
@@ -886,6 +952,10 @@ function ProgressBar({ fraction, label, "aria-label": ariaLabel, className }) {
886
952
  }
887
953
  //#endregion
888
954
  //#region src/components/ui/Field.tsx
955
+ /** The `side` row: a label column and the control, centred on one line. */
956
+ const SIDE_ROW = "grid min-w-0 grid-cols-[var(--field-label-w,8.5rem)_minmax(0,1fr)] items-center gap-x-3";
957
+ /** Lines the description and the error up under the control of a `side` row. */
958
+ const SIDE_UNDER = "ml-[calc(var(--field-label-w,8.5rem)+0.75rem)]";
889
959
  const FieldContext = createContext({
890
960
  describedBy: void 0,
891
961
  invalid: false
@@ -914,7 +984,7 @@ function useFieldDescription(own) {
914
984
  * pick them up; give it `aria-describedby` yourself. State is exposed as `data-invalid` and
915
985
  * `data-required`.
916
986
  */
917
- function Field({ label, description, error, required = false, annotation, as = "label", className, children }) {
987
+ function Field({ label, description, error, required = false, annotation, as = "label", layout = "top", className, children }) {
918
988
  const descriptionId = useId();
919
989
  const errorId = useId();
920
990
  const density = useDensity();
@@ -929,15 +999,30 @@ function Field({ label, description, error, required = false, annotation, as = "
929
999
  hasError
930
1000
  ]);
931
1001
  const gap = byDensity(density, "gap-1.5", "gap-1");
932
- const labelled = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("span", {
1002
+ const side = layout === "side";
1003
+ const labelText = /* @__PURE__ */ jsxs(Fragment$1, { children: [label, required && /* @__PURE__ */ jsx("span", {
1004
+ className: "ml-0.5 text-defect",
1005
+ title: "Required",
1006
+ children: "*"
1007
+ })] });
1008
+ const labelled = side ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("span", {
1009
+ className: "flex min-w-0 items-center gap-1.5",
1010
+ children: [/* @__PURE__ */ jsx("span", {
1011
+ className: cn("min-w-0 truncate font-medium text-fg", byDensity(density, "text-xs", "text-[11px]")),
1012
+ title: label,
1013
+ children: labelText
1014
+ }), annotation && /* @__PURE__ */ jsx("span", {
1015
+ className: "shrink-0 font-mono text-[11px] text-fg-subtle",
1016
+ children: annotation
1017
+ })]
1018
+ }), /* @__PURE__ */ jsx(FieldContext, {
1019
+ value: control,
1020
+ children
1021
+ })] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("span", {
933
1022
  className: "flex items-baseline gap-2",
934
- children: [/* @__PURE__ */ jsxs("span", {
1023
+ children: [/* @__PURE__ */ jsx("span", {
935
1024
  className: cn("font-medium text-fg", byDensity(density, "text-xs", "text-[11px]")),
936
- children: [label, required && /* @__PURE__ */ jsx("span", {
937
- className: "ml-0.5 text-defect",
938
- title: "Required",
939
- children: "*"
940
- })]
1025
+ children: labelText
941
1026
  }), annotation && /* @__PURE__ */ jsx("span", {
942
1027
  className: "ml-auto font-mono text-[11px] text-fg-subtle",
943
1028
  children: annotation
@@ -946,8 +1031,11 @@ function Field({ label, description, error, required = false, annotation, as = "
946
1031
  value: control,
947
1032
  children
948
1033
  })] });
1034
+ const rowClasses = side ? SIDE_ROW : cn("flex min-w-0 flex-col", gap);
1035
+ const under = side ? SIDE_UNDER : void 0;
949
1036
  return /* @__PURE__ */ jsxs("div", {
950
- className: cn("flex min-w-0 flex-col", gap, className),
1037
+ className: cn("flex min-w-0 flex-col", side ? "gap-0.5" : gap, className),
1038
+ "data-layout": side ? "side" : void 0,
951
1039
  "data-invalid": hasError ? "" : void 0,
952
1040
  "data-required": required ? "" : void 0,
953
1041
  ...as === "group" ? {
@@ -957,18 +1045,21 @@ function Field({ label, description, error, required = false, annotation, as = "
957
1045
  } : {},
958
1046
  children: [
959
1047
  as === "label" ? /* @__PURE__ */ jsx("label", {
960
- className: cn("flex min-w-0 flex-col", gap),
1048
+ className: rowClasses,
1049
+ children: labelled
1050
+ }) : side ? /* @__PURE__ */ jsx("div", {
1051
+ className: rowClasses,
961
1052
  children: labelled
962
1053
  }) : labelled,
963
1054
  description && /* @__PURE__ */ jsx("span", {
964
1055
  id: descriptionId,
965
- className: "text-xs leading-snug text-fg-muted",
1056
+ className: cn("text-xs leading-snug text-fg-muted", under),
966
1057
  children: description
967
1058
  }),
968
1059
  hasError && /* @__PURE__ */ jsx("span", {
969
1060
  id: errorId,
970
1061
  role: "alert",
971
- className: "text-xs leading-snug text-defect",
1062
+ className: cn("text-xs leading-snug text-defect", under),
972
1063
  children: error
973
1064
  })
974
1065
  ]
@@ -1100,6 +1191,141 @@ function HighlightedText({ text, spans = [], labels, className, ...rest }) {
1100
1191
  });
1101
1192
  }
1102
1193
  //#endregion
1194
+ //#region src/components/ui/IconButton.tsx
1195
+ /** The square box of each size: `sm` 28 px, `md` 32 px — the heights of `Button`. */
1196
+ const BOX_CLASSES = {
1197
+ sm: "size-7 p-0 [&>svg]:size-4",
1198
+ md: "size-8 p-0 [&>svg]:size-4"
1199
+ };
1200
+ /** What the tooltip shows: the label, an optional hint line, an optional key cap. */
1201
+ function TipContent({ label, hint, shortcut }) {
1202
+ return /* @__PURE__ */ jsxs("span", {
1203
+ className: "flex items-center gap-2",
1204
+ children: [/* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsx("span", {
1205
+ className: "font-medium",
1206
+ children: label
1207
+ }), hint !== void 0 && /* @__PURE__ */ jsx("span", {
1208
+ className: "block text-fg-muted",
1209
+ children: hint
1210
+ })] }), shortcut && /* @__PURE__ */ jsx(Kbd, { children: shortcut })]
1211
+ });
1212
+ }
1213
+ /**
1214
+ * An icon-only button. `label` is its accessible name *and* its tooltip, so it is required;
1215
+ * `shortcut` adds a key cap to the tooltip and `aria-keyshortcuts`. `pressed` makes it a
1216
+ * toggle (`aria-pressed`, `data-state="on"` / `"off"`).
1217
+ *
1218
+ * Needs a `TooltipProvider` above it. Takes every `<button>` prop, `ref` included. A
1219
+ * disabled button shows no tooltip (browsers send it no pointer events), so say why in the
1220
+ * surrounding UI when the reason is not obvious.
1221
+ */
1222
+ function IconButton({ label, icon, hint, shortcut, pressed, variant = "ghost", size, type = "button", className, ...rest }) {
1223
+ const density = useDensity();
1224
+ const resolved = size ?? byDensity(density, "md", "sm");
1225
+ return /* @__PURE__ */ jsx(Tooltip, {
1226
+ content: /* @__PURE__ */ jsx(TipContent, {
1227
+ label,
1228
+ hint,
1229
+ shortcut
1230
+ }),
1231
+ children: /* @__PURE__ */ jsx("button", {
1232
+ ...rest,
1233
+ type,
1234
+ "aria-label": label,
1235
+ "aria-keyshortcuts": shortcut,
1236
+ "aria-pressed": pressed,
1237
+ "data-variant": variant,
1238
+ "data-state": pressed === void 0 ? void 0 : pressed ? "on" : "off",
1239
+ className: buttonClasses({
1240
+ variant,
1241
+ size: resolved,
1242
+ className: cn(BOX_CLASSES[resolved], pressed && variant === "ghost" && "bg-signal/15 text-signal hover:bg-signal/20 hover:text-signal", className)
1243
+ }),
1244
+ children: /* @__PURE__ */ jsx("span", {
1245
+ "aria-hidden": true,
1246
+ className: "contents",
1247
+ children: icon
1248
+ })
1249
+ })
1250
+ });
1251
+ }
1252
+ /**
1253
+ * A strip of icon toggles — a tool picker, a view-mode switch, text-style toggles — each
1254
+ * named by its tooltip. `type="single"` (the default) keeps exactly the chosen item
1255
+ * pressed; `type="multiple"` lets each toggle on its own. Controlled with `value` or
1256
+ * uncontrolled with `defaultValue`.
1257
+ *
1258
+ * Each item is a button with `aria-pressed` inside a `role="group"`. One item is a tab stop
1259
+ * (the pressed one, else the first); Arrow keys, Home and End move focus along the strip.
1260
+ * Needs a `TooltipProvider` above it.
1261
+ */
1262
+ function IconToggleGroup(props) {
1263
+ const { items, size, disabled = false, className, "aria-label": ariaLabel } = props;
1264
+ const multiple = props.type === "multiple";
1265
+ const density = useDensity();
1266
+ const resolved = size ?? byDensity(density, "md", "sm");
1267
+ const [internal, setInternal] = useControllable(props.value, props.defaultValue);
1268
+ const selected = toArray(internal);
1269
+ const stripRef = useRef(null);
1270
+ const toggle = (value) => {
1271
+ if (props.type === "multiple") {
1272
+ const next = selected.includes(value) ? selected.filter((v) => v !== value) : [...selected, value];
1273
+ setInternal(next);
1274
+ props.onValueChange?.(next);
1275
+ } else {
1276
+ if (selected.includes(value)) return;
1277
+ setInternal(value);
1278
+ props.onValueChange?.(value);
1279
+ }
1280
+ };
1281
+ const enabled = items.filter((item) => !item.disabled && !disabled);
1282
+ const stop = enabled.find((item) => selected.includes(item.value)) ?? enabled[0];
1283
+ const onKeyDown = (event) => {
1284
+ if (![
1285
+ "ArrowRight",
1286
+ "ArrowDown",
1287
+ "ArrowLeft",
1288
+ "ArrowUp",
1289
+ "Home",
1290
+ "End"
1291
+ ].includes(event.key)) return;
1292
+ const buttons = Array.from(stripRef.current?.querySelectorAll("button:not(:disabled)") ?? []);
1293
+ const at = buttons.indexOf(document.activeElement);
1294
+ if (at < 0 || buttons.length === 0) return;
1295
+ event.preventDefault();
1296
+ buttons[event.key === "Home" ? 0 : event.key === "End" ? buttons.length - 1 : (at + (event.key === "ArrowRight" || event.key === "ArrowDown" ? 1 : -1) + buttons.length) % buttons.length]?.focus();
1297
+ };
1298
+ return /* @__PURE__ */ jsx("div", {
1299
+ ref: stripRef,
1300
+ role: "group",
1301
+ "aria-label": ariaLabel,
1302
+ "data-type": multiple ? "multiple" : "single",
1303
+ "data-disabled": disabled ? "" : void 0,
1304
+ onKeyDown,
1305
+ className: cn("inline-flex shrink-0 items-center gap-0.5 rounded-control border border-line-strong bg-raised p-0.5", className),
1306
+ children: items.map((item) => /* @__PURE__ */ jsx(IconButton, {
1307
+ label: item.label,
1308
+ icon: item.icon,
1309
+ shortcut: item.shortcut,
1310
+ size: resolved,
1311
+ pressed: selected.includes(item.value),
1312
+ disabled: disabled || item.disabled,
1313
+ tabIndex: stop?.value === item.value ? 0 : -1,
1314
+ onClick: () => toggle(item.value),
1315
+ className: cn("rounded-[0.3rem]", selected.includes(item.value) && "bg-surface text-signal shadow-sm")
1316
+ }, item.value))
1317
+ });
1318
+ }
1319
+ function toArray(value) {
1320
+ if (value === void 0 || value === "") return [];
1321
+ return typeof value === "string" ? [value] : value;
1322
+ }
1323
+ /** Minimal controlled/uncontrolled state: `value` wins when given. */
1324
+ function useControllable(value, defaultValue) {
1325
+ const [state, setState] = useState(defaultValue);
1326
+ return [value !== void 0 ? value : state, setState];
1327
+ }
1328
+ //#endregion
1103
1329
  //#region src/components/ui/numberText.ts
1104
1330
  /**
1105
1331
  * A number at a fixed number of decimals, without a negative zero (`-0.000` reads as a sign
@@ -2060,6 +2286,33 @@ function Slider({ value, onValueChange, onValueCommit, min = 0, max = 1, step =
2060
2286
  });
2061
2287
  }
2062
2288
  //#endregion
2289
+ //#region src/components/ui/tableGroups.ts
2290
+ /**
2291
+ * The cells of the group header row.
2292
+ *
2293
+ * Adjacent columns with the same `group` label are one cell; a column with no group, and
2294
+ * adjacent such columns, are one empty cell. The same label twice with another between
2295
+ * them is two groups.
2296
+ *
2297
+ * @param columns - The columns, in order.
2298
+ * @returns The cells, left to right, spanning every column; `null` when no column has a group, so no row is drawn.
2299
+ */
2300
+ function columnGroups(columns) {
2301
+ if (!columns.some((column) => column.group)) return null;
2302
+ const cells = [];
2303
+ columns.forEach((column, start) => {
2304
+ const label = column.group || null;
2305
+ const last = cells.at(-1);
2306
+ if (last && last.label === label) last.span += 1;
2307
+ else cells.push({
2308
+ label,
2309
+ span: 1,
2310
+ start
2311
+ });
2312
+ });
2313
+ return cells;
2314
+ }
2315
+ //#endregion
2063
2316
  //#region src/components/ui/tableSort.ts
2064
2317
  /** Strings by a fixed English collation that reads digit runs as numbers: "frame 9" before "frame 10". */
2065
2318
  const collator = new Intl.Collator("en", { numeric: true });
@@ -2201,6 +2454,18 @@ function navigate(key, position, rowCount, page) {
2201
2454
  //#region src/components/ui/Table.tsx
2202
2455
  /** Rows per screen before a windowed table has measured itself (a server render, the first paint). */
2203
2456
  const INITIAL_ROWS = 20;
2457
+ /**
2458
+ * A pinned cell sticks to the left edge of the scroll area on `surface`, with a rule on its
2459
+ * right edge so a cell scrolling under it reads as under it.
2460
+ */
2461
+ const pinned = "sticky left-0 z-[2] bg-surface shadow-[inset_-1px_0_0_var(--line)]";
2462
+ /**
2463
+ * A pinned body cell: it must be opaque, so a row's hover and active tint is painted on the
2464
+ * cell itself, mixed over `surface`, to match what the row's other cells show through.
2465
+ */
2466
+ function pinnedCell(clickable, active) {
2467
+ 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%)]");
2468
+ }
2204
2469
  /** The header icon for a sort state: the direction when sorted, both arrows when only sortable. */
2205
2470
  const SORT_ICONS = {
2206
2471
  ascending: ArrowUp,
@@ -2227,7 +2492,7 @@ const SORT_ICONS = {
2227
2492
  * With `windowed` the table scrolls itself (vertically, under a sticky header), renders only the
2228
2493
  * rows in view, and uses a fixed layout: give columns a `width` where the content needs it.
2229
2494
  */
2230
- function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, className, onRowClick, isRowActive, onRowHover, sort: controlledSort, defaultSort = null, onSortChange, manualSort = false, windowed, selectionFollowsFocus = false }) {
2495
+ 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 }) {
2231
2496
  const density = useDensity();
2232
2497
  const [ownSort, setOwnSort] = useState(defaultSort);
2233
2498
  const controlled = controlledSort !== void 0;
@@ -2246,12 +2511,16 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
2246
2511
  const rowHeight = windowed?.rowHeight ?? 0;
2247
2512
  const scrollRef = useRef(null);
2248
2513
  const headRef = useRef(null);
2514
+ const groupRowRef = useRef(null);
2515
+ const groups = useMemo(() => columnGroups(columns), [columns]);
2516
+ const headerRows = groups ? 2 : 1;
2249
2517
  const bodyRef = useRef(null);
2250
2518
  const pendingFocus = useRef(null);
2251
2519
  const [scrollTop, setScrollTop] = useState(0);
2252
2520
  const [measured, setMeasured] = useState(null);
2253
2521
  const viewportHeight = measured?.viewport ?? windowed?.height ?? INITIAL_ROWS * rowHeight;
2254
2522
  const headerHeight = measured?.header ?? 0;
2523
+ const groupRowHeight = measured?.groupRow ?? 0;
2255
2524
  const range = windowed ? rowWindow({
2256
2525
  rowCount: order.length,
2257
2526
  rowHeight,
@@ -2274,9 +2543,10 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
2274
2543
  if (!scroller.isConnected) return;
2275
2544
  const next = {
2276
2545
  viewport: scroller.clientHeight,
2277
- header: headRef.current?.offsetHeight ?? 0
2546
+ header: headRef.current?.offsetHeight ?? 0,
2547
+ groupRow: groupRowRef.current?.offsetHeight ?? 0
2278
2548
  };
2279
- setMeasured((last) => last?.viewport === next.viewport && last.header === next.header ? last : next);
2549
+ setMeasured((last) => last?.viewport === next.viewport && last.header === next.header && last.groupRow === next.groupRow ? last : next);
2280
2550
  };
2281
2551
  measure();
2282
2552
  setScrollTop(scroller.scrollTop);
@@ -2349,20 +2619,45 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
2349
2619
  "aria-label": caption ?? "Table"
2350
2620
  } : {},
2351
2621
  children: /* @__PURE__ */ jsxs("table", {
2352
- className: cn("w-full text-left", byDensity(density, "text-sm", "text-[11px]")),
2622
+ className: cn("w-full text-left", pinFirstColumn && "min-w-max", byDensity(density, "text-sm", "text-[11px]")),
2353
2623
  style: windowed ? { tableLayout: "fixed" } : void 0,
2354
- "aria-rowcount": windowed ? order.length + 1 : void 0,
2624
+ "aria-rowcount": windowed ? order.length + headerRows : void 0,
2355
2625
  children: [
2356
2626
  caption && /* @__PURE__ */ jsx("caption", {
2357
2627
  className: "sr-only",
2358
2628
  children: caption
2359
2629
  }),
2360
- /* @__PURE__ */ jsx("thead", {
2630
+ /* @__PURE__ */ jsxs("thead", {
2361
2631
  ref: headRef,
2362
- children: /* @__PURE__ */ jsx("tr", {
2363
- className: "border-b border-line",
2632
+ children: [groups && /* @__PURE__ */ jsx("tr", {
2633
+ ref: groupRowRef,
2364
2634
  "aria-rowindex": windowed ? 1 : void 0,
2365
- children: columns.map((column) => {
2635
+ children: groups.map((cell) => cell.label === null ? /* @__PURE__ */ jsx("td", {
2636
+ colSpan: cell.span,
2637
+ className: cn(windowed && "bg-surface", pinFirstColumn && cell.start === 0 && cell.span === 1 && pinned),
2638
+ style: windowed ? {
2639
+ position: "sticky",
2640
+ top: 0,
2641
+ zIndex: pinFirstColumn && cell.start === 0 ? 3 : 1
2642
+ } : void 0
2643
+ }, `gap-${cell.start}`) : /* @__PURE__ */ jsx("th", {
2644
+ scope: "colgroup",
2645
+ colSpan: cell.span,
2646
+ 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),
2647
+ style: windowed ? {
2648
+ position: "sticky",
2649
+ top: 0,
2650
+ zIndex: pinFirstColumn && cell.start === 0 ? 3 : 1
2651
+ } : void 0,
2652
+ children: /* @__PURE__ */ jsx("span", {
2653
+ className: cn("block border-b border-line pb-1 text-left", byDensity(density, "pb-1", "pb-0.5")),
2654
+ children: cell.label
2655
+ })
2656
+ }, `group-${cell.start}`))
2657
+ }), /* @__PURE__ */ jsx("tr", {
2658
+ className: "border-b border-line",
2659
+ "aria-rowindex": windowed ? headerRows : void 0,
2660
+ children: columns.map((column, columnIndex) => {
2366
2661
  const sortable = isSortable(column);
2367
2662
  const direction = sortable && sort?.key === column.key ? sort.direction : void 0;
2368
2663
  const SortIcon = SORT_ICONS[direction ?? "none"];
@@ -2370,13 +2665,13 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
2370
2665
  scope: "col",
2371
2666
  style: windowed ? {
2372
2667
  position: "sticky",
2373
- top: 0,
2374
- zIndex: 1,
2668
+ top: groupRowHeight,
2669
+ zIndex: pinFirstColumn && columnIndex === 0 ? 3 : 1,
2375
2670
  ...column.width ? { width: column.width } : {}
2376
2671
  } : column.width ? { width: column.width } : void 0,
2377
2672
  "aria-sort": direction,
2378
2673
  "data-sort": sortable ? direction ?? "none" : void 0,
2379
- 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)]"),
2674
+ 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"),
2380
2675
  children: sortable ? /* @__PURE__ */ jsxs("button", {
2381
2676
  type: "button",
2382
2677
  onClick: () => changeSort(column),
@@ -2388,7 +2683,7 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
2388
2683
  }) : column.header
2389
2684
  }, column.key);
2390
2685
  })
2391
- })
2686
+ })]
2392
2687
  }),
2393
2688
  /* @__PURE__ */ jsxs("tbody", {
2394
2689
  ref: bodyRef,
@@ -2400,10 +2695,10 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
2400
2695
  const position = range.start + offset;
2401
2696
  return /* @__PURE__ */ jsx("tr", {
2402
2697
  "data-position": position,
2403
- "aria-rowindex": windowed ? position + 2 : void 0,
2698
+ "aria-rowindex": windowed ? position + 1 + headerRows : void 0,
2404
2699
  style: windowed ? { height: rowHeight } : void 0,
2405
2700
  "data-state": active ? "active" : void 0,
2406
- className: cn(!windowed && "border-b border-line/60 last:border-0", onRowClick && "cursor-pointer hover:bg-raised", active && "bg-signal/10"),
2701
+ className: cn("group/row", !windowed && "border-b border-line/60 last:border-0", onRowClick && "cursor-pointer hover:bg-raised", active && "bg-signal/10"),
2407
2702
  tabIndex: onRowClick ? 0 : void 0,
2408
2703
  "aria-current": active ? true : void 0,
2409
2704
  onClick: onRowClick ? (event) => onRowClick(row, index, event) : void 0,
@@ -2415,8 +2710,8 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
2415
2710
  } : void 0,
2416
2711
  onPointerEnter: onRowHover ? () => onRowHover(row, index) : void 0,
2417
2712
  onPointerLeave: onRowHover ? () => onRowHover(null, null) : void 0,
2418
- children: columns.map((column) => /* @__PURE__ */ jsx("td", {
2419
- 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)]"),
2713
+ children: columns.map((column, columnIndex) => /* @__PURE__ */ jsx("td", {
2714
+ 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)]"),
2420
2715
  style: windowed ? {
2421
2716
  whiteSpace: "nowrap",
2422
2717
  overflow: "hidden",
@@ -2887,6 +3182,6 @@ function Tabs({ items, active, onSelect, label, idPrefix, className }) {
2887
3182
  });
2888
3183
  }
2889
3184
  //#endregion
2890
- 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, ShortcutList, 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 };
3185
+ export { Badge, Breakdown, Button, ButtonLink, Callout, Checkbox, ConfirmDialog, CountRun, DEFAULT_THEME_STORAGE_KEY, DeltaCell, DensityProvider, Dialog, DialogClose, Disclosure, DropdownMenu, Empty, ErrorBox, Field, HighlightedText, IconButton, IconToggleGroup, 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 };
2891
3186
 
2892
3187
  //# sourceMappingURL=index.js.map