strata-react 0.1.15 → 0.1.16

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
@@ -121,6 +121,7 @@ function KilnRoom() {
121
121
  | Status and figures | `Status`, `Metric`, `MetricStrip`, `Meter`, `crossedThreshold`, `CompositionBar` | A status is always a word; figures have no icons or sparklines; `Meter` is a `meter` named for what it measures, with its reading in words ("72% used"), threshold notches, and a `Status` word once a threshold is crossed (each threshold must name its state); `CompositionBar` is a stacked bar over a table naming every part, its amount and share, and names the remainder (`total` needs `restLabel`) |
122
122
  | Data | `DataView`, `Load<T>`, `Stale`, `StaleNotice`, `EmptyState`, `Skeleton`, `Thumbnail`, `ThumbnailSkeleton`, `DataTable`, `TableSkeleton`, `VirtualList`, `InfiniteList`, `LineChart` | `DataView` requires skeleton and empty, and keeps data on screen under a `StaleNotice` (why, how old, Try again) when a refresh fails; `Thumbnail` is a remote image in a box of fixed `aspect`, with a skeleton while it loads, the required `missing` words when it fails or `src` is null, required `alt`, and a request only once it nears the screen (`eager` for the first few); tables and lists virtualise from 100 rows; `InfiniteList` loads the next page on approach, with a skeleton for it, a Try again row when it fails and a Show more button for the keyboard; charts label values directly |
123
123
  | Selection | `useSelection`, `BulkBar`, `SelectableGrid`, `DataTable`'s `selection` (`RowSelection<T>`) | Opt-in checkbox column with "Select all shown" that respects `isSelectable`; Shift-click or Shift+Space chooses or clears the run from the last row clicked, in the order shown; `initial` (keys or a test on the row) chooses a row the first time it appears, so it applies to data that loads later; the selection drops rows that are gone; `BulkBar` announces the count politely; `SelectableGrid` is the same selection as a grid of pictures (`renderImage`), each tile one labelled target, virtualised from 100 tiles |
124
+ | Expansion | `Disclosure`, `useExpanded`, `DataTable`'s `expansion` (`RowExpansion<T>`) | Show more of one row in place. The toggle is a button with `aria-expanded`; the body is mounted only while open, so a request inside it runs on first open (unlike `<details>`, which mounts every closed body); `useExpanded({ param })` shares the open keys across a list or table and keeps them in the URL; a table's detail row spans the data columns and is measured when virtualised |
124
125
  | Data loading | `StrataQueryProvider`, `createQueryClient`, `useLoad`, `useInfiniteLoad`, `toLoad`, `staleOf`, `fetchJson`, `HttpError` | TanStack Query in, `Load<T>` out; a refetch that fails after a good read stays `ready` with `stale` set, never an error panel; `useInfiniteLoad` works out the cursor itself (after the last item held), merges pages by key and can `dismiss` an item at once |
125
126
  | Page and navigation | `AppShell`, `SideNav`, `Breadcrumb`, `Tabs`, `PageHeader`, `LinkCard`, `LinkCardList` | React Router; tab and sort state in the URL; a `LinkCard` is one link named by its title, described by its text and `Status` marks, with the whole card as the target (`to` a route, `href` elsewhere, marked with an arrow) |
126
127
  | Keyboard | `useHotkeys`, `KeysLegend`, `Shortcut`, `useActiveItem`, `ActiveList`, `isTypingTarget` | For queues worked from the keyboard; one shortcut list drives the handler and the legend; keys never fire while typing; answering moves focus to the next item |
@@ -22,6 +22,18 @@ export type RowSelection<T> = {
22
22
  /** Rows that cannot be chosen get a disabled checkbox and are left out of select-all. Default: every row. */
23
23
  isSelectable?: (row: T) => boolean;
24
24
  };
25
+ /** Row expansion for a `DataTable`: the open row keys, how to change them, how to name each toggle, and the detail to show. */
26
+ export type RowExpansion<T> = {
27
+ /** Keys (from `rowKey`) of the open rows. */
28
+ expanded: ReadonlySet<string>;
29
+ onChange: (next: Set<string>) => void;
30
+ /** Names the row's toggle by what it shows: "Pieces in firing 412". Its state is `aria-expanded`, so the name stays the same open or closed. */
31
+ rowLabel: (row: T) => string;
32
+ /** The row's detail, mounted only while it is open. Return an element whose component makes any request, so the request runs on open. */
33
+ detail: (row: T) => React.ReactNode;
34
+ /** Rows with nothing to show get no toggle. Default: every row. */
35
+ isExpandable?: (row: T) => boolean;
36
+ };
25
37
  export type Sort = {
26
38
  key: string;
27
39
  dir: "ascending" | "descending";
@@ -41,6 +53,8 @@ export type DataTableProps<T> = {
41
53
  maxHeight?: number;
42
54
  /** Adds a checkbox column and "Select all shown". Use only where a `BulkBar` acts on the selection. */
43
55
  selection?: RowSelection<T>;
56
+ /** Adds a toggle per row that opens a detail row under it. Spread `useExpanded()` in with a `rowLabel` and `detail`. */
57
+ expansion?: RowExpansion<T>;
44
58
  className?: string;
45
59
  };
46
60
  /** Reads a sort from its URL form (`pieces.desc`). */
@@ -0,0 +1,47 @@
1
+ import * as React from "react";
2
+ /** Open and closed disclosure state: controlled with `open` and `onOpenChange`, or uncontrolled from `defaultOpen`. */
3
+ export type DisclosureOpenProps = {
4
+ open: boolean;
5
+ onOpenChange: (open: boolean) => void;
6
+ defaultOpen?: never;
7
+ } | {
8
+ open?: never;
9
+ onOpenChange?: (open: boolean) => void;
10
+ defaultOpen?: boolean;
11
+ };
12
+ export type DisclosureProps = DisclosureOpenProps & {
13
+ /** The always-visible line, and the button's accessible name: text and marks, no controls. */
14
+ summary: React.ReactNode;
15
+ /** Mounted only while open, so a request inside runs when the person opens it. */
16
+ children: React.ReactNode;
17
+ /** Controls for the row (a `RowAction`), beside the summary and outside its button. */
18
+ actions?: React.ReactNode;
19
+ className?: string;
20
+ };
21
+ /** Shows more of one thing in place: a button with `aria-expanded` around `summary`, and a body mounted only while open (so a request inside it runs on first open). Controlled with `open`/`onOpenChange` or `useExpanded`, or uncontrolled with `defaultOpen`. */
22
+ export declare function Disclosure({ summary, children, actions, open, defaultOpen, onOpenChange, className }: DisclosureProps): React.JSX.Element;
23
+ /** The disclosure chevron: points right when closed, down when open. Shared with `DataTable`'s row toggle. */
24
+ export declare function Chevron({ open, className }: {
25
+ open: boolean;
26
+ className?: string;
27
+ }): React.JSX.Element;
28
+ /** Which of many disclosures are open, by key: spread into `DataTable`'s `expansion`, or read with `isOpen`/`setOpen` for a list of `Disclosure`s. */
29
+ export type Expanded = {
30
+ /** Keys of the open items. */
31
+ expanded: ReadonlySet<string>;
32
+ /** Replaces the open set. `DataTable` calls this. */
33
+ onChange: (next: Set<string>) => void;
34
+ isOpen: (key: string) => boolean;
35
+ setOpen: (key: string, open: boolean) => void;
36
+ collapseAll: () => void;
37
+ };
38
+ export type ExpandedOptions = {
39
+ /** Keep the open keys in this URL search parameter (`?open=a&open=b`), so an opened row can be linked and survives a reload. Needs a React Router context. */
40
+ param?: string;
41
+ /** Keys open at first. Ignored with `param`: there the URL says what is open, so a link that opens a row carries it. */
42
+ initial?: Iterable<string>;
43
+ /** Opening one closes the others (an accordion). Default false: people compare two rows. */
44
+ single?: boolean;
45
+ };
46
+ /** Shared open state for the disclosures of one list or table, optionally kept in the URL (`param`). */
47
+ export declare function useExpanded(options?: ExpandedOptions): Expanded;
package/dist/index.d.ts CHANGED
@@ -19,7 +19,8 @@ export { CompositionBar, type CompositionBarProps, type CompositionPart } from '
19
19
  export { LinkCard, LinkCardList, type LinkCardProps } from './components/link-card';
20
20
  export { DataView, EmptyState, Skeleton, StaleNotice, type Load, type Stale } from './components/data-view';
21
21
  export { Thumbnail, ThumbnailSkeleton, type ThumbnailProps, type AspectRatio } from './components/thumbnail';
22
- export { DataTable, TableSkeleton, parseSort, serialiseSort, type Column, type Sort, type DataTableProps, type RowSelection, } from './components/data-table';
22
+ export { DataTable, TableSkeleton, parseSort, serialiseSort, type Column, type Sort, type DataTableProps, type RowSelection, type RowExpansion, } from './components/data-table';
23
+ export { Disclosure, useExpanded, type DisclosureProps, type DisclosureOpenProps, type Expanded, type ExpandedOptions } from './components/disclosure';
23
24
  export { BulkBar, useSelection, type InitialSelection } from './components/selection';
24
25
  export { SelectableGrid, type SelectableGridProps, type TileAspect, type TileSize, } from './components/selectable-grid';
25
26
  export { VirtualList } from './components/virtual-list';
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import * as React from "react";
3
3
  import { Slot } from "@radix-ui/react-slot";
4
4
  import { cva } from "class-variance-authority";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
- import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Check, CircleAlert, History, ImageOff, LoaderCircle, RotateCcw, X } from "lucide-react";
6
+ import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Check, ChevronRight, CircleAlert, History, ImageOff, LoaderCircle, RotateCcw, X } from "lucide-react";
7
7
  import { Link, NavLink, useSearchParams } from "react-router";
8
8
  import { flexRender, getCoreRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
9
9
  import { useVirtualizer } from "@tanstack/react-virtual";
@@ -815,6 +815,90 @@ function ThumbnailSkeleton({ aspect = 1, className }) {
815
815
  children: /* @__PURE__ */ jsx(Skeleton, { className: "absolute inset-0" })
816
816
  });
817
817
  }
818
+ // src/components/disclosure.tsx
819
+ /** Shows more of one thing in place: a button with `aria-expanded` around `summary`, and a body mounted only while open (so a request inside it runs on first open). Controlled with `open`/`onOpenChange` or `useExpanded`, or uncontrolled with `defaultOpen`. */
820
+ function Disclosure({ summary, children, actions, open, defaultOpen = false, onOpenChange, className }) {
821
+ const [own, setOwn] = React.useState(defaultOpen);
822
+ const isOpen = open ?? own;
823
+ const bodyId = React.useId();
824
+ const toggle = () => {
825
+ if (open === void 0) setOwn(!isOpen);
826
+ onOpenChange?.(!isOpen);
827
+ };
828
+ return /* @__PURE__ */ jsxs("div", {
829
+ className: cn("min-w-0", className),
830
+ children: [/* @__PURE__ */ jsxs("div", {
831
+ className: "flex items-center gap-3",
832
+ children: [/* @__PURE__ */ jsxs("button", {
833
+ type: "button",
834
+ "aria-expanded": isOpen,
835
+ "aria-controls": isOpen ? bodyId : void 0,
836
+ onClick: toggle,
837
+ className: "-mx-1 flex min-h-(--control-h-sm) min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-control px-1 text-left hover:bg-muted",
838
+ children: [/* @__PURE__ */ jsx(Chevron, { open: isOpen }), /* @__PURE__ */ jsx("span", {
839
+ className: "min-w-0 flex-1",
840
+ children: summary
841
+ })]
842
+ }), actions && /* @__PURE__ */ jsx("div", {
843
+ className: "flex shrink-0 items-center gap-2",
844
+ children: actions
845
+ })]
846
+ }), isOpen && /* @__PURE__ */ jsx("div", {
847
+ id: bodyId,
848
+ className: "pt-2 pb-3 pl-6",
849
+ children
850
+ })]
851
+ });
852
+ }
853
+ /** The disclosure chevron: points right when closed, down when open. Shared with `DataTable`'s row toggle. */
854
+ function Chevron({ open, className }) {
855
+ return /* @__PURE__ */ jsx(ChevronRight, {
856
+ "aria-hidden": true,
857
+ className: cn("size-4 shrink-0 text-muted-foreground", open && "rotate-90", className)
858
+ });
859
+ }
860
+ /** Shared open state for the disclosures of one list or table, optionally kept in the URL (`param`). */
861
+ function useExpanded(options = {}) {
862
+ return options.param ? useUrlExpanded(options.param, options) : useLocalExpanded(options);
863
+ }
864
+ function api(expanded, set, single) {
865
+ return {
866
+ expanded,
867
+ onChange: (next) => {
868
+ const opened = single ? [...next].filter((k) => !expanded.has(k)) : [];
869
+ set(opened.length ? /* @__PURE__ */ new Set([opened[opened.length - 1]]) : next);
870
+ },
871
+ isOpen: (key) => expanded.has(key),
872
+ setOpen: (key, open) => {
873
+ const next = single ? /* @__PURE__ */ new Set() : new Set(expanded);
874
+ if (open) next.add(key);
875
+ else next.delete(key);
876
+ set(next);
877
+ },
878
+ collapseAll: () => set(/* @__PURE__ */ new Set())
879
+ };
880
+ }
881
+ function useLocalExpanded({ initial = [], single }) {
882
+ const [expanded, setExpanded] = React.useState(() => new Set(initial));
883
+ return React.useMemo(() => api(expanded, setExpanded, single), [expanded, single]);
884
+ }
885
+ function useUrlExpanded(param, { single }) {
886
+ const [params, setParams] = useSearchParams();
887
+ const fromUrl = params.getAll(param);
888
+ const joined = fromUrl.join("\0");
889
+ const expanded = React.useMemo(() => new Set(fromUrl), [joined]);
890
+ const set = React.useCallback((next) => setParams((p) => {
891
+ const out = new URLSearchParams(p);
892
+ out.delete(param);
893
+ for (const k of next) out.append(param, k);
894
+ return out;
895
+ }, { replace: true }), [param, setParams]);
896
+ return React.useMemo(() => api(expanded, set, single), [
897
+ expanded,
898
+ set,
899
+ single
900
+ ]);
901
+ }
818
902
  // src/components/selection.tsx
819
903
  function reconcile(prev, rows, keys, initial) {
820
904
  const present = new Set(keys);
@@ -1002,7 +1086,8 @@ function UrlSortedTable(props) {
1002
1086
  sortState: useUrlSort(props.sortParam, props.initialSort)
1003
1087
  });
1004
1088
  }
1005
- function Table({ caption, columns, rows, rowKey, sortState: [sort, setSort], virtualizeFrom = 100, maxHeight = 480, selection, className }) {
1089
+ function Table({ caption, columns, rows, rowKey, sortState: [sort, setSort], virtualizeFrom = 100, maxHeight = 480, selection, expansion, className }) {
1090
+ const baseId = React.useId();
1006
1091
  const defs = React.useMemo(() => columns.map((c) => ({
1007
1092
  id: c.key,
1008
1093
  accessorFn: (row) => row,
@@ -1035,14 +1120,29 @@ function Table({ caption, columns, rows, rowKey, sortState: [sort, setSort], vir
1035
1120
  dir: sort?.key === key && sort.dir === "ascending" ? "descending" : "ascending"
1036
1121
  });
1037
1122
  const modelRows = table.getRowModel().rows;
1123
+ const canExpand = (row) => expansion?.isExpandable?.(row) ?? true;
1124
+ const lines = React.useMemo(() => expansion ? modelRows.flatMap((row) => expansion.expanded.has(row.id) && canExpand(row.original) ? [{
1125
+ row,
1126
+ detail: false
1127
+ }, {
1128
+ row,
1129
+ detail: true
1130
+ }] : [{
1131
+ row,
1132
+ detail: false
1133
+ }]) : modelRows.map((row) => ({
1134
+ row,
1135
+ detail: false
1136
+ })), [modelRows, expansion]);
1038
1137
  const select = useSelectRows(React.useMemo(() => modelRows.map((r) => r.original), [modelRows]), rowKey, selection);
1039
1138
  const selectAll = selection ? select.all : void 0;
1040
1139
  const virtual = modelRows.length >= virtualizeFrom;
1041
1140
  const scroller = React.useRef(null);
1042
1141
  const virtualizer = useVirtualizer({
1043
- count: virtual ? modelRows.length : 0,
1142
+ count: virtual ? lines.length : 0,
1044
1143
  getScrollElement: () => scroller.current,
1045
- estimateSize: () => 41,
1144
+ estimateSize: (i) => lines[i]?.detail ? 160 : 41,
1145
+ getItemKey: (i) => lines[i] ? `${lines[i].row.id}${lines[i].detail ? "\0detail" : ""}` : i,
1046
1146
  overscan: 8,
1047
1147
  initialRect: {
1048
1148
  width: 0,
@@ -1052,7 +1152,14 @@ function Table({ caption, columns, rows, rowKey, sortState: [sort, setSort], vir
1052
1152
  const items = virtual ? virtualizer.getVirtualItems() : [];
1053
1153
  const padTop = items.length ? items[0].start : 0;
1054
1154
  const padBottom = items.length ? virtualizer.getTotalSize() - items[items.length - 1].end : 0;
1055
- const visible = virtual ? items.map((i) => modelRows[i.index]) : modelRows;
1155
+ const visible = virtual ? items.map((i) => ({
1156
+ ...lines[i.index],
1157
+ index: i.index
1158
+ })) : lines.map((l, index) => ({
1159
+ ...l,
1160
+ index
1161
+ }));
1162
+ const lead = (selection ? 1 : 0) + (expansion ? 1 : 0);
1056
1163
  return /* @__PURE__ */ jsx("div", {
1057
1164
  ref: scroller,
1058
1165
  role: "region",
@@ -1062,7 +1169,7 @@ function Table({ caption, columns, rows, rowKey, sortState: [sort, setSort], vir
1062
1169
  style: virtual ? { maxHeight } : void 0,
1063
1170
  children: /* @__PURE__ */ jsxs("table", {
1064
1171
  className: "w-full border-collapse type-body-sm",
1065
- "aria-rowcount": virtual ? modelRows.length + 1 : void 0,
1172
+ "aria-rowcount": virtual ? lines.length + 1 : void 0,
1066
1173
  children: [
1067
1174
  /* @__PURE__ */ jsx("caption", {
1068
1175
  className: "sr-only",
@@ -1070,69 +1177,115 @@ function Table({ caption, columns, rows, rowKey, sortState: [sort, setSort], vir
1070
1177
  }),
1071
1178
  /* @__PURE__ */ jsx("thead", {
1072
1179
  className: cn(virtual && "sticky top-0 z-10 bg-background"),
1073
- children: table.getHeaderGroups().map((group) => /* @__PURE__ */ jsxs("tr", { children: [selectAll && /* @__PURE__ */ jsx("th", {
1074
- scope: "col",
1075
- className: "w-8 py-2 pr-2 text-left align-bottom",
1076
- children: /* @__PURE__ */ jsx(Checkbox, {
1077
- className: "-my-1",
1078
- label: "Select all shown",
1079
- hideLabel: true,
1080
- checked: selectAll.checked,
1081
- disabled: selectAll.disabled,
1082
- onCheckedChange: selectAll.toggle
1083
- })
1084
- }), group.headers.map((header) => {
1085
- const meta = header.column.columnDef.meta;
1086
- const active = sort?.key === header.id && header.column.getCanSort() ? sort.dir : void 0;
1087
- const Icon = active === "ascending" ? ArrowUp : active === "descending" ? ArrowDown : ArrowUpDown;
1088
- const rendered = flexRender(header.column.columnDef.header, header.getContext());
1089
- const label = meta?.hideHeader ? /* @__PURE__ */ jsx("span", {
1090
- className: "sr-only",
1091
- children: rendered
1092
- }) : rendered;
1093
- return /* @__PURE__ */ jsx("th", {
1180
+ children: table.getHeaderGroups().map((group) => /* @__PURE__ */ jsxs("tr", { children: [
1181
+ selectAll && /* @__PURE__ */ jsx("th", {
1094
1182
  scope: "col",
1095
- "aria-sort": active,
1096
- className: cn("py-2 pr-4 text-left align-bottom type-caption text-muted-foreground last:pr-0", meta?.numeric && "text-right"),
1097
- children: header.column.getCanSort() ? /* @__PURE__ */ jsxs("button", {
1098
- type: "button",
1099
- onClick: () => toggle(header.id),
1100
- className: cn("-mx-1 inline-flex cursor-pointer items-center gap-1 rounded-control px-1 transition-state hover:text-foreground", meta?.numeric && "flex-row-reverse", active && "text-foreground"),
1101
- children: [label, /* @__PURE__ */ jsx(Icon, {
1102
- "aria-hidden": true,
1103
- className: cn("size-3.5", !active && "opacity-50")
1104
- })]
1105
- }) : label
1106
- }, header.id);
1107
- })] }, group.id))
1183
+ className: "w-8 py-2 pr-2 text-left align-bottom",
1184
+ children: /* @__PURE__ */ jsx(Checkbox, {
1185
+ className: "-my-1",
1186
+ label: "Select all shown",
1187
+ hideLabel: true,
1188
+ checked: selectAll.checked,
1189
+ disabled: selectAll.disabled,
1190
+ onCheckedChange: selectAll.toggle
1191
+ })
1192
+ }),
1193
+ expansion && /* @__PURE__ */ jsx("th", {
1194
+ scope: "col",
1195
+ className: "w-10 py-2 pr-2",
1196
+ children: /* @__PURE__ */ jsx("span", {
1197
+ className: "sr-only",
1198
+ children: "Details"
1199
+ })
1200
+ }),
1201
+ group.headers.map((header) => {
1202
+ const meta = header.column.columnDef.meta;
1203
+ const active = sort?.key === header.id && header.column.getCanSort() ? sort.dir : void 0;
1204
+ const Icon = active === "ascending" ? ArrowUp : active === "descending" ? ArrowDown : ArrowUpDown;
1205
+ const rendered = flexRender(header.column.columnDef.header, header.getContext());
1206
+ const label = meta?.hideHeader ? /* @__PURE__ */ jsx("span", {
1207
+ className: "sr-only",
1208
+ children: rendered
1209
+ }) : rendered;
1210
+ return /* @__PURE__ */ jsx("th", {
1211
+ scope: "col",
1212
+ "aria-sort": active,
1213
+ className: cn("py-2 pr-4 text-left align-bottom type-caption text-muted-foreground last:pr-0", meta?.numeric && "text-right"),
1214
+ children: header.column.getCanSort() ? /* @__PURE__ */ jsxs("button", {
1215
+ type: "button",
1216
+ onClick: () => toggle(header.id),
1217
+ className: cn("-mx-1 inline-flex cursor-pointer items-center gap-1 rounded-control px-1 transition-state hover:text-foreground", meta?.numeric && "flex-row-reverse", active && "text-foreground"),
1218
+ children: [label, /* @__PURE__ */ jsx(Icon, {
1219
+ "aria-hidden": true,
1220
+ className: cn("size-3.5", !active && "opacity-50")
1221
+ })]
1222
+ }) : label
1223
+ }, header.id);
1224
+ })
1225
+ ] }, group.id))
1108
1226
  }),
1109
1227
  /* @__PURE__ */ jsxs("tbody", { children: [
1110
1228
  padTop > 0 && /* @__PURE__ */ jsx("tr", {
1111
1229
  "aria-hidden": true,
1112
1230
  style: { height: padTop }
1113
1231
  }),
1114
- visible.map((row, i) => {
1232
+ visible.map(({ row, detail, index }) => {
1115
1233
  const chosen = selection?.selected.has(row.id) ?? false;
1234
+ const detailId = `${baseId}-detail-${row.id}`;
1235
+ if (detail && expansion) return /* @__PURE__ */ jsxs("tr", {
1236
+ ref: virtual ? virtualizer.measureElement : void 0,
1237
+ "data-index": index,
1238
+ className: cn(chosen && "bg-surface-sunken"),
1239
+ "aria-rowindex": virtual ? index + 2 : void 0,
1240
+ children: [lead > 0 && /* @__PURE__ */ jsx("td", { colSpan: lead }), /* @__PURE__ */ jsx("td", {
1241
+ id: detailId,
1242
+ colSpan: columns.length,
1243
+ className: "pt-0.5 pb-4 align-top",
1244
+ children: expansion.detail(row.original)
1245
+ })]
1246
+ }, `${row.id}-detail`);
1247
+ const open = expansion?.expanded.has(row.id) ?? false;
1116
1248
  return /* @__PURE__ */ jsxs("tr", {
1117
1249
  className: cn("border-t border-border", chosen && "bg-surface-sunken"),
1118
- "aria-rowindex": virtual ? (items[i]?.index ?? 0) + 2 : void 0,
1119
- children: [selection && /* @__PURE__ */ jsx("td", {
1120
- className: "w-8 py-2.5 pr-2 align-middle",
1121
- children: /* @__PURE__ */ jsx(Checkbox, {
1122
- className: "-my-0.5",
1123
- label: `Select ${selection.rowLabel(row.original)}`,
1124
- hideLabel: true,
1125
- checked: chosen,
1126
- disabled: !(selection.isSelectable?.(row.original) ?? true),
1127
- onCheckedChange: (on, gesture) => select.toggle(row.id, on, gesture)
1250
+ "aria-rowindex": virtual ? index + 2 : void 0,
1251
+ children: [
1252
+ selection && /* @__PURE__ */ jsx("td", {
1253
+ className: "w-8 py-2.5 pr-2 align-middle",
1254
+ children: /* @__PURE__ */ jsx(Checkbox, {
1255
+ className: "-my-0.5",
1256
+ label: `Select ${selection.rowLabel(row.original)}`,
1257
+ hideLabel: true,
1258
+ checked: chosen,
1259
+ disabled: !(selection.isSelectable?.(row.original) ?? true),
1260
+ onCheckedChange: (on, gesture) => select.toggle(row.id, on, gesture)
1261
+ })
1262
+ }),
1263
+ expansion && /* @__PURE__ */ jsx("td", {
1264
+ className: "w-10 py-2.5 pr-2 align-middle",
1265
+ children: canExpand(row.original) && /* @__PURE__ */ jsx("button", {
1266
+ type: "button",
1267
+ "aria-expanded": open,
1268
+ "aria-controls": open ? detailId : void 0,
1269
+ "aria-label": expansion.rowLabel(row.original),
1270
+ title: expansion.rowLabel(row.original),
1271
+ onClick: () => {
1272
+ const next = new Set(expansion.expanded);
1273
+ if (open) next.delete(row.id);
1274
+ else next.add(row.id);
1275
+ expansion.onChange(next);
1276
+ },
1277
+ className: "-my-1.5 grid size-(--control-h-sm) cursor-pointer place-items-center rounded-control hover:bg-muted",
1278
+ children: /* @__PURE__ */ jsx(Chevron, { open })
1279
+ })
1280
+ }),
1281
+ row.getVisibleCells().map((cell) => {
1282
+ const meta = cell.column.columnDef.meta;
1283
+ return /* @__PURE__ */ jsx("td", {
1284
+ className: cn("py-2.5 pr-4 align-middle last:pr-0", meta?.numeric && "text-right tabular-nums", meta?.truncate && "max-w-48 truncate", meta?.className),
1285
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
1286
+ }, cell.id);
1128
1287
  })
1129
- }), row.getVisibleCells().map((cell) => {
1130
- const meta = cell.column.columnDef.meta;
1131
- return /* @__PURE__ */ jsx("td", {
1132
- className: cn("py-2.5 pr-4 align-middle last:pr-0", meta?.numeric && "text-right tabular-nums", meta?.truncate && "max-w-48 truncate", meta?.className),
1133
- children: flexRender(cell.column.columnDef.cell, cell.getContext())
1134
- }, cell.id);
1135
- })]
1288
+ ]
1136
1289
  }, row.id);
1137
1290
  }),
1138
1291
  padBottom > 0 && /* @__PURE__ */ jsx("tr", {
@@ -2462,6 +2615,6 @@ function nextAfter(pages, items, itemKey, hidden) {
2462
2615
  if (held.length === 0 || pages.length > 1 && !lastPageAddedAny) return last;
2463
2616
  return held[held.length - 1];
2464
2617
  }
2465
- export { ActiveList, AppShell, AsyncButton, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGroup, ColorSchemeChoice, CompositionBar, DataTable, DataView, Done, EmptyState, Field, HttpError, IconButton, InfiniteList, Input, KeysLegend, LineChart, LinkCard, LinkCardList, Meter, Metric, MetricStrip, NBSP, NativeSelect, PageHeader, RowAction, SelectableGrid, SideNav, Skeleton, StaleNotice, Status, StrataQueryProvider, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, UndoBar, VirtualList, buttonVariants, cn, colorSchemeScript, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, fetchJson, format, isTypingTarget, parseSort, serialiseSort, staleOf, toDate, toLoad, typeSteps, useActiveItem, useAsyncAction, useColorScheme, useHotkeys, useInfiniteLoad, useLoad, useSelection, useSystemColorScheme, useUndoable };
2618
+ export { ActiveList, AppShell, AsyncButton, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGroup, ColorSchemeChoice, CompositionBar, DataTable, DataView, Disclosure, Done, EmptyState, Field, HttpError, IconButton, InfiniteList, Input, KeysLegend, LineChart, LinkCard, LinkCardList, Meter, Metric, MetricStrip, NBSP, NativeSelect, PageHeader, RowAction, SelectableGrid, SideNav, Skeleton, StaleNotice, Status, StrataQueryProvider, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, UndoBar, VirtualList, buttonVariants, cn, colorSchemeScript, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, fetchJson, format, isTypingTarget, parseSort, serialiseSort, staleOf, toDate, toLoad, typeSteps, useActiveItem, useAsyncAction, useColorScheme, useExpanded, useHotkeys, useInfiniteLoad, useLoad, useSelection, useSystemColorScheme, useUndoable };
2466
2619
 
2467
2620
  //# sourceMappingURL=index.js.map