@vitavision/ui 0.14.1 → 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 +1 -1
- package/dist/index.d.ts +61 -2
- package/dist/index.js +153 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ui/DeltaCell.tsx +109 -0
- package/src/components/ui/Table.tsx +103 -10
- package/src/components/ui/index.ts +1 -0
- package/src/components/ui/tableGroups.ts +36 -0
package/README.md
CHANGED
|
@@ -132,7 +132,7 @@ with its content between `minRows` and `maxRows`) · `HighlightedText`, `findSpa
|
|
|
132
132
|
with its placeholders, tags and terms marked, never parsed as HTML) · `VectorInput`,
|
|
133
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,
|
|
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)
|
|
@@ -1233,6 +1279,12 @@ type Column<Row> = {
|
|
|
1233
1279
|
numeric?: boolean;
|
|
1234
1280
|
/** A CSS width for the column, e.g. `"6rem"`. */
|
|
1235
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;
|
|
1236
1288
|
/** The cell's content for a row. */
|
|
1237
1289
|
cell: (row: Row) => ReactNode;
|
|
1238
1290
|
/**
|
|
@@ -1299,7 +1351,7 @@ interface TableWindowing {
|
|
|
1299
1351
|
* With `windowed` the table scrolls itself (vertically, under a sticky header), renders only the
|
|
1300
1352
|
* rows in view, and uses a fixed layout: give columns a `width` where the content needs it.
|
|
1301
1353
|
*/
|
|
1302
|
-
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 }: {
|
|
1303
1355
|
/** The columns, in order. */
|
|
1304
1356
|
columns: Column<Row>[];
|
|
1305
1357
|
/** The rows, in their own order: the order shown while the table is not sorted. */
|
|
@@ -1357,6 +1409,13 @@ export declare function Table<Row>({ columns, rows, rowKey, empty, caption, clas
|
|
|
1357
1409
|
* choose one. Needs `onRowClick`.
|
|
1358
1410
|
*/
|
|
1359
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;
|
|
1360
1419
|
}): import("react").JSX.Element;
|
|
1361
1420
|
//#endregion
|
|
1362
1421
|
//#region src/components/ui/Textarea.d.ts
|
|
@@ -1692,5 +1751,5 @@ export declare function Tabs<Id extends string>({ items, active, onSelect, label
|
|
|
1692
1751
|
className?: string | undefined;
|
|
1693
1752
|
}): import("react").JSX.Element;
|
|
1694
1753
|
//#endregion
|
|
1695
|
-
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, Shortcut, ShortcutGroup, ShortcutListProps, 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 };
|
|
1696
1755
|
//# sourceMappingURL=index.d.ts.map
|
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
|
|
@@ -2060,6 +2126,33 @@ function Slider({ value, onValueChange, onValueCommit, min = 0, max = 1, step =
|
|
|
2060
2126
|
});
|
|
2061
2127
|
}
|
|
2062
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
|
|
2063
2156
|
//#region src/components/ui/tableSort.ts
|
|
2064
2157
|
/** Strings by a fixed English collation that reads digit runs as numbers: "frame 9" before "frame 10". */
|
|
2065
2158
|
const collator = new Intl.Collator("en", { numeric: true });
|
|
@@ -2201,6 +2294,18 @@ function navigate(key, position, rowCount, page) {
|
|
|
2201
2294
|
//#region src/components/ui/Table.tsx
|
|
2202
2295
|
/** Rows per screen before a windowed table has measured itself (a server render, the first paint). */
|
|
2203
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
|
+
}
|
|
2204
2309
|
/** The header icon for a sort state: the direction when sorted, both arrows when only sortable. */
|
|
2205
2310
|
const SORT_ICONS = {
|
|
2206
2311
|
ascending: ArrowUp,
|
|
@@ -2227,7 +2332,7 @@ const SORT_ICONS = {
|
|
|
2227
2332
|
* With `windowed` the table scrolls itself (vertically, under a sticky header), renders only the
|
|
2228
2333
|
* rows in view, and uses a fixed layout: give columns a `width` where the content needs it.
|
|
2229
2334
|
*/
|
|
2230
|
-
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 }) {
|
|
2231
2336
|
const density = useDensity();
|
|
2232
2337
|
const [ownSort, setOwnSort] = useState(defaultSort);
|
|
2233
2338
|
const controlled = controlledSort !== void 0;
|
|
@@ -2246,12 +2351,16 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
|
|
|
2246
2351
|
const rowHeight = windowed?.rowHeight ?? 0;
|
|
2247
2352
|
const scrollRef = useRef(null);
|
|
2248
2353
|
const headRef = useRef(null);
|
|
2354
|
+
const groupRowRef = useRef(null);
|
|
2355
|
+
const groups = useMemo(() => columnGroups(columns), [columns]);
|
|
2356
|
+
const headerRows = groups ? 2 : 1;
|
|
2249
2357
|
const bodyRef = useRef(null);
|
|
2250
2358
|
const pendingFocus = useRef(null);
|
|
2251
2359
|
const [scrollTop, setScrollTop] = useState(0);
|
|
2252
2360
|
const [measured, setMeasured] = useState(null);
|
|
2253
2361
|
const viewportHeight = measured?.viewport ?? windowed?.height ?? INITIAL_ROWS * rowHeight;
|
|
2254
2362
|
const headerHeight = measured?.header ?? 0;
|
|
2363
|
+
const groupRowHeight = measured?.groupRow ?? 0;
|
|
2255
2364
|
const range = windowed ? rowWindow({
|
|
2256
2365
|
rowCount: order.length,
|
|
2257
2366
|
rowHeight,
|
|
@@ -2274,9 +2383,10 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
|
|
|
2274
2383
|
if (!scroller.isConnected) return;
|
|
2275
2384
|
const next = {
|
|
2276
2385
|
viewport: scroller.clientHeight,
|
|
2277
|
-
header: headRef.current?.offsetHeight ?? 0
|
|
2386
|
+
header: headRef.current?.offsetHeight ?? 0,
|
|
2387
|
+
groupRow: groupRowRef.current?.offsetHeight ?? 0
|
|
2278
2388
|
};
|
|
2279
|
-
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);
|
|
2280
2390
|
};
|
|
2281
2391
|
measure();
|
|
2282
2392
|
setScrollTop(scroller.scrollTop);
|
|
@@ -2349,20 +2459,45 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
|
|
|
2349
2459
|
"aria-label": caption ?? "Table"
|
|
2350
2460
|
} : {},
|
|
2351
2461
|
children: /* @__PURE__ */ jsxs("table", {
|
|
2352
|
-
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]")),
|
|
2353
2463
|
style: windowed ? { tableLayout: "fixed" } : void 0,
|
|
2354
|
-
"aria-rowcount": windowed ? order.length +
|
|
2464
|
+
"aria-rowcount": windowed ? order.length + headerRows : void 0,
|
|
2355
2465
|
children: [
|
|
2356
2466
|
caption && /* @__PURE__ */ jsx("caption", {
|
|
2357
2467
|
className: "sr-only",
|
|
2358
2468
|
children: caption
|
|
2359
2469
|
}),
|
|
2360
|
-
/* @__PURE__ */
|
|
2470
|
+
/* @__PURE__ */ jsxs("thead", {
|
|
2361
2471
|
ref: headRef,
|
|
2362
|
-
children: /* @__PURE__ */ jsx("tr", {
|
|
2363
|
-
|
|
2472
|
+
children: [groups && /* @__PURE__ */ jsx("tr", {
|
|
2473
|
+
ref: groupRowRef,
|
|
2364
2474
|
"aria-rowindex": windowed ? 1 : void 0,
|
|
2365
|
-
children:
|
|
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) => {
|
|
2366
2501
|
const sortable = isSortable(column);
|
|
2367
2502
|
const direction = sortable && sort?.key === column.key ? sort.direction : void 0;
|
|
2368
2503
|
const SortIcon = SORT_ICONS[direction ?? "none"];
|
|
@@ -2370,13 +2505,13 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
|
|
|
2370
2505
|
scope: "col",
|
|
2371
2506
|
style: windowed ? {
|
|
2372
2507
|
position: "sticky",
|
|
2373
|
-
top:
|
|
2374
|
-
zIndex: 1,
|
|
2508
|
+
top: groupRowHeight,
|
|
2509
|
+
zIndex: pinFirstColumn && columnIndex === 0 ? 3 : 1,
|
|
2375
2510
|
...column.width ? { width: column.width } : {}
|
|
2376
2511
|
} : column.width ? { width: column.width } : void 0,
|
|
2377
2512
|
"aria-sort": direction,
|
|
2378
2513
|
"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)]"),
|
|
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"),
|
|
2380
2515
|
children: sortable ? /* @__PURE__ */ jsxs("button", {
|
|
2381
2516
|
type: "button",
|
|
2382
2517
|
onClick: () => changeSort(column),
|
|
@@ -2388,7 +2523,7 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
|
|
|
2388
2523
|
}) : column.header
|
|
2389
2524
|
}, column.key);
|
|
2390
2525
|
})
|
|
2391
|
-
})
|
|
2526
|
+
})]
|
|
2392
2527
|
}),
|
|
2393
2528
|
/* @__PURE__ */ jsxs("tbody", {
|
|
2394
2529
|
ref: bodyRef,
|
|
@@ -2400,10 +2535,10 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
|
|
|
2400
2535
|
const position = range.start + offset;
|
|
2401
2536
|
return /* @__PURE__ */ jsx("tr", {
|
|
2402
2537
|
"data-position": position,
|
|
2403
|
-
"aria-rowindex": windowed ? position +
|
|
2538
|
+
"aria-rowindex": windowed ? position + 1 + headerRows : void 0,
|
|
2404
2539
|
style: windowed ? { height: rowHeight } : void 0,
|
|
2405
2540
|
"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"),
|
|
2541
|
+
className: cn("group/row", !windowed && "border-b border-line/60 last:border-0", onRowClick && "cursor-pointer hover:bg-raised", active && "bg-signal/10"),
|
|
2407
2542
|
tabIndex: onRowClick ? 0 : void 0,
|
|
2408
2543
|
"aria-current": active ? true : void 0,
|
|
2409
2544
|
onClick: onRowClick ? (event) => onRowClick(row, index, event) : void 0,
|
|
@@ -2415,8 +2550,8 @@ function Table({ columns, rows, rowKey, empty = "Nothing here.", caption, classN
|
|
|
2415
2550
|
} : void 0,
|
|
2416
2551
|
onPointerEnter: onRowHover ? () => onRowHover(row, index) : void 0,
|
|
2417
2552
|
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)]"),
|
|
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)]"),
|
|
2420
2555
|
style: windowed ? {
|
|
2421
2556
|
whiteSpace: "nowrap",
|
|
2422
2557
|
overflow: "hidden",
|
|
@@ -2887,6 +3022,6 @@ function Tabs({ items, active, onSelect, label, idPrefix, className }) {
|
|
|
2887
3022
|
});
|
|
2888
3023
|
}
|
|
2889
3024
|
//#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 };
|
|
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 };
|
|
2891
3026
|
|
|
2892
3027
|
//# sourceMappingURL=index.js.map
|