@tristan2828/ui-foundation 4.74.0 → 4.76.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,14 +15,14 @@
15
15
  - Step 8: Add Playwright specs for all three screens · lines 686–764
16
16
  - Step 9: Register the nav entry and route names · lines 765–779
17
17
  - Step 10: `npm run verify`. · lines 780–782
18
- - [How a list opens a record](#how-a-list-opens-a-record) · lines 784–922
19
- - [The record view](#the-record-view) · lines 897–922
20
- - [What not to copy](#what-not-to-copy) · lines 924–950
21
- - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 952–969
22
- - [Deleting](#deleting) · lines 971–1000
23
- - [Fields only a script writes](#fields-only-a-script-writes) · lines 1002–1023
24
- - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1025–1034
25
- - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1037–1076
18
+ - [How a list opens a record](#how-a-list-opens-a-record) · lines 784–933
19
+ - [The record view](#the-record-view) · lines 897–933
20
+ - [What not to copy](#what-not-to-copy) · lines 935–961
21
+ - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 963–980
22
+ - [Deleting](#deleting) · lines 982–1011
23
+ - [Fields only a script writes](#fields-only-a-script-writes) · lines 1013–1034
24
+ - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1036–1045
25
+ - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1048–1087
26
26
 
27
27
  <!-- /index -->
28
28
 
@@ -903,7 +903,9 @@ view reaches them all. A record uses the parts it has, in this order:
903
903
  - **Header**: the title, edited in place (`titleEdit`); under it a
904
904
  one-line summary field, edited in place (`subtitle`: a goal, a
905
905
  description); beside it the status as a quick action (a picker saved
906
- at once) and other status-like fields as badges, edited in place.
906
+ at once) and other status-like fields as badges, edited in place. A
907
+ record with a face or a mark of its own (a person's avatar, a
908
+ service's logo, a cover) puts it left of all that (`leading`, 4.76).
907
909
  `actions` holds Delete (soft, with Undo) and the record's own commands
908
910
  (Run, Print), never Edit.
909
911
  - **Strip**: the record's key numbers and ratings (`strip`, a
@@ -915,6 +917,15 @@ view reaches them all. A record uses the parts it has, in this order:
915
917
  Outline for a long one and Print notes (`print`). Without long text,
916
918
  one column. Every value edited in place (`edit`), a sub-item list
917
919
  included (`editInPlace({ kind: 'list' })`).
920
+ - **Tabs** (4.76), for a main column with **three or more groups of
921
+ long content** (the steps, where it's used, the reasoning): a `tab` on
922
+ each main section groups them under a tab list, the selected one in
923
+ `?tab=`. Fewer groups stay one scroll, folded by headings. A record's
924
+ Notes stay outside the tabs, above them, unless they are one tab's
925
+ content; the rail and the strip never go in a tab.
926
+ - **Rail fields beside their labels** (`railFields="beside"`, 4.76) for
927
+ a rail of many short facts, so it reads as a list of pairs rather than
928
+ a column of labels; keep labels to a word or two.
918
929
  - **A big record's own parts** (a drawing, a player, a checklist of
919
930
  documents) are sections in the view, not a screen of their own.
920
931
 
@@ -35,10 +35,10 @@
35
35
  - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1391–1401
36
36
  - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1403–1469
37
37
  - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1471–1535
38
- - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1537–1605
39
- - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1607–1635
40
- - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1637–1713
41
- - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1715–1738
38
+ - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1537–1618
39
+ - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1620–1648
40
+ - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1650–1726
41
+ - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1728–1751
42
42
 
43
43
  <!-- /index -->
44
44
 
@@ -1583,6 +1583,19 @@ const { page, filters, setFilter, setPage } = useTableUrlState(['kind'])
1583
1583
  in the group's own `<tbody>`), so a screen reader names a cell's group
1584
1584
  as it names its column. It stays in view while a wide table scrolls
1585
1585
  sideways.
1586
+ - **`stickyGroupHeadings`** pins the headings while their groups scroll,
1587
+ for a list long enough that "which day is this?" gets lost: each
1588
+ heading sticks below the column header, which is pinned with it (with
1589
+ `header={false}`, at the very top), until the next group's slides
1590
+ over it. It works under `groupBy` and a grouping alike, and does nothing
1591
+ to a table that isn't grouped or to a card layout. When the columns fit
1592
+ (a feed, most lists on a phone) they stick to the page's own scroll.
1593
+ When they're wider than the screen the table has to scroll sideways, and
1594
+ a box that scrolls sideways is what sticky cells stick to, so the table
1595
+ becomes a box no taller than the screen and scrolls both ways inside
1596
+ it. An ancestor of your own with `overflow` set (a card with
1597
+ `overflow-hidden`, say) takes the place of the page: leave it off such a
1598
+ table's ancestors.
1586
1599
  - **`header={false}`** for a list-like table whose columns explain
1587
1600
  themselves (a thumbnail with a title block, then actions). The header
1588
1601
  row takes no room but stays in the table, so the columns keep their
@@ -3,32 +3,33 @@
3
3
  <!-- index: written by `npm run docs:index` in the package from the headings below; never edit it by hand -->
4
4
  ## Index
5
5
 
6
- - [Palettes](#palettes) · lines 41–108
7
- - [Glow](#glow) · lines 110–128
8
- - [Semantic tones](#semantic-tones) · lines 130–158
9
- - [The three badge styles](#the-three-badge-styles) · lines 160–177
10
- - [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 179–208
11
- - [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 210–223
12
- - [Logos and brand marks](#logos-and-brand-marks) · lines 225–269
13
- - [Categorical colour](#categorical-colour) · lines 271–341
14
- - [Heat scale](#heat-scale) · lines 343–404
15
- - [A stored colour](#a-stored-colour) · lines 406–454
16
- - [Shapes and sizes](#shapes-and-sizes) · lines 456–477
17
- - [Typography](#typography) · lines 479–585
18
- - [Written text (notes)](#written-text-notes) · lines 513–585
19
- - [Density](#density) · lines 587–673
20
- - [Rows on this device](#rows-on-this-device) · lines 646–673
21
- - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 675–789
22
- - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 791–860
23
- - [Notices](#notices) · lines 862–890
24
- - [A value over time](#a-value-over-time) · lines 892–978
25
- - [Several values over time](#several-values-over-time) · lines 941–978
26
- - [A list as a board](#a-list-as-a-board) · lines 980–1031
27
- - [A list as cards](#a-list-as-cards) · lines 1033–1079
28
- - [Key numbers on a record](#key-numbers-on-a-record) · lines 1081–1103
29
- - [Picking at random](#picking-at-random) · lines 1105–1136
30
- - [Filling in what's missing](#filling-in-whats-missing) · lines 1138–1205
31
- - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1207–1232
6
+ - [Palettes](#palettes) · lines 42–109
7
+ - [Glow](#glow) · lines 111–129
8
+ - [Semantic tones](#semantic-tones) · lines 131–159
9
+ - [The three badge styles](#the-three-badge-styles) · lines 161–178
10
+ - [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 180–209
11
+ - [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 211–224
12
+ - [Logos and brand marks](#logos-and-brand-marks) · lines 226–270
13
+ - [Categorical colour](#categorical-colour) · lines 272–342
14
+ - [Heat scale](#heat-scale) · lines 344–405
15
+ - [A stored colour](#a-stored-colour) · lines 407–455
16
+ - [Shapes and sizes](#shapes-and-sizes) · lines 457–478
17
+ - [Typography](#typography) · lines 480–586
18
+ - [Written text (notes)](#written-text-notes) · lines 514–586
19
+ - [Density](#density) · lines 588–674
20
+ - [Rows on this device](#rows-on-this-device) · lines 647–674
21
+ - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 676–790
22
+ - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 792–869
23
+ - [Notices](#notices) · lines 871–899
24
+ - [A value over time](#a-value-over-time) · lines 901–987
25
+ - [Several values over time](#several-values-over-time) · lines 950–987
26
+ - [A list as a board](#a-list-as-a-board) · lines 989–1040
27
+ - [A list as cards](#a-list-as-cards) · lines 1042–1088
28
+ - [Key numbers on a record](#key-numbers-on-a-record) · lines 1090–1112
29
+ - [A record's tabs, mark and rail](#a-records-tabs-mark-and-rail) · lines 1114–1158
30
+ - [Picking at random](#picking-at-random) · lines 1160–1191
31
+ - [Filling in what's missing](#filling-in-whats-missing) · lines 1193–1260
32
+ - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1262–1287
32
33
 
33
34
  <!-- /index -->
34
35
 
@@ -847,15 +848,23 @@ const { data, isLoading, error, refetch } = useProjectsSummaryQuery()
847
848
  hub's widgets should start on the first screen, or there are more
848
849
  places than six tiles: below the sidebar's breakpoint the strip is one
849
850
  row that scrolls sideways, a chip per place with its icon in its slot's
850
- colour, its name and its number (no note, no action). While the number
851
- loads, a small skeleton; on an error, a muted dash ("Couldn't load" to
851
+ colour, its name and its number (no action, and no note unless the card
852
+ sets `noteOnChip`). While the number loads, a small skeleton; on an
853
+ error, a muted dash ("Couldn't load" to
852
854
  a screen reader), with Retry left to the desktop card and the place's
853
855
  own page. The row scrolls inside itself and the page never does. A
854
856
  desktop shows the cards either way, so don't render your own row
855
857
  beside a strip hidden on a phone.
858
+ - **`noteOnChip`** puts a card's `note` on its chip, after the number,
859
+ for a word or two the number means little without ("5 new"). A rule of
860
+ the card, so a strip can show it on the chips that need it. It stays on
861
+ the chip's one line in caption type, cut off with an ellipsis past 96px
862
+ (the whole note is still read out), so every chip keeps its height and
863
+ a long note can't take over the row. It stays while the number loads,
864
+ so the chip doesn't change width, and goes on an error, as on the card.
856
865
  - The fixtures' `app/ModuleCard` shows a hub with a strip and a widget,
857
866
  every state, both at `compact`, and both again as a row of chips (Row,
858
- Row states); its checks run axe and the token and glyph checks in both
867
+ Row states, Row notes); its checks run axe and the token and glyph checks in both
859
868
  themes and at `large`, measure the strip at a desktop and a phone
860
869
  width, and run axe on the chips at a phone's.
861
870
 
@@ -1102,6 +1111,52 @@ row under the header, across the page at every width.
1102
1111
  - **`subtitle`** is the line under the title: what the record is for,
1103
1112
  in muted body type, editable in place like any value.
1104
1113
 
1114
+ ## A record's tabs, mark and rail
1115
+
1116
+ Three opt-ins on `EntityView` (4.76), each for a record that needs it;
1117
+ a record without them is as it was.
1118
+
1119
+ ```tsx
1120
+ <EntityView
1121
+ layout="rail"
1122
+ mobileOrder="main-first"
1123
+ leading={<img src={photo} alt="" className="size-12 rounded-full object-cover" />}
1124
+ railFields="beside"
1125
+ sections={[
1126
+ { title: 'Summary', placement: 'rail', fields },
1127
+ { title: 'Notes', content: <Markdown>{notes}</Markdown> },
1128
+ { title: 'Steps', tab: 'Steps', content: steps },
1129
+ { title: 'Where it applies', tab: 'Used in', content: uses },
1130
+ { title: 'Why this order', tab: 'Reasoning', content: reasoning },
1131
+ ]}
1132
+ … />
1133
+ ```
1134
+
1135
+ - **Tabs** (`tab` on a main section): a line tab list at the top of
1136
+ the main column, under the strip and any sections with no tab, one
1137
+ tab per name in the order the sections first give it. The selected
1138
+ tab has foreground text and a 2px underline, the others muted text;
1139
+ the list's own bottom border runs the column's width. On a phone each
1140
+ tab is 44px tall, and a list wider than the column scrolls sideways on
1141
+ its own, never the page. Arrow keys move between tabs and select
1142
+ (Home, End), and Tab goes on into the panel. The address holds the
1143
+ selected tab (`?tab=used-in`, `entityViewTabSlug`), replaced rather
1144
+ than pushed, so Back leaves the record, not the tab. Every tab's
1145
+ sections stay mounted, so a value open in place survives a switch.
1146
+ Short tab names, one or two words; no counts or icons in them yet.
1147
+ - **A mark or avatar** (`leading`): left of the title, top-aligned,
1148
+ with the title, subtitle and badges beside it at every width. 40 to
1149
+ 64px (`size-10` to `size-16`): an avatar round (`rounded-full`), a
1150
+ mark or cover in a rounded square (`rounded-lg`). Decorative, since
1151
+ the title names the record (`alt=""`, `aria-hidden`); initials in
1152
+ foreground on `bg-muted`, an icon in muted foreground on the card
1153
+ with its border. "Logos and brand marks" above holds for a logo here.
1154
+ - **Rail fields beside** (`railFields="beside"`): the label in a 6 to
1155
+ 7rem column left of its value, baseline-aligned, rows a little tighter
1156
+ than stacked. Where the rail's list is under 18rem (a phone narrower
1157
+ than ~350px) it stacks as before, and once the rail stacks full width
1158
+ the label column widens to the page's.
1159
+
1105
1160
  ## Picking at random
1106
1161
 
1107
1162
  `SpinWheel` (4.42) picks one of a few candidates by chance, for "what do
@@ -87,6 +87,16 @@ export type DataTableProps<TData extends Record<string, unknown>> = {
87
87
  * a grouping's alike. `group` says which group it is.
88
88
  */
89
89
  groupSummary?: (rows: TData[], group: RowGroup) => ReactNode;
90
+ /**
91
+ * While rows are grouped (`groupBy` or a grouping), pins each heading
92
+ * below the column header while its group scrolls past, and pins the
93
+ * column header above it. When the columns fit, they stick to whatever
94
+ * scrolls the page. When they don't, the table scrolls both ways inside
95
+ * a box no taller than the screen, and they stick to that. The table
96
+ * layout's alone: a card layout's headings scroll with their cards.
97
+ * Ungrouped, it changes nothing.
98
+ */
99
+ stickyGroupHeadings?: boolean;
90
100
  /**
91
101
  * The fields the rows can be grouped by, picked in a Group menu at the
92
102
  * end of the toolbar: None (the default, the table as it is without
@@ -274,4 +284,4 @@ export type DataTableTotals = {
274
284
  */
275
285
  cells?: Partial<Record<string, ReactNode>>;
276
286
  };
277
- export declare function DataTable<TData extends Record<string, unknown>>({ columns, data, total, page, pageSize, onPageChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width, groupBy, groupSummary, header: showHeader, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel, }: DataTableProps<TData>): import("react").JSX.Element;
287
+ export declare function DataTable<TData extends Record<string, unknown>>({ columns, data, total, page, pageSize, onPageChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width, groupBy, groupSummary, stickyGroupHeadings, header: showHeader, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel, }: DataTableProps<TData>): import("react").JSX.Element;
@@ -181,6 +181,25 @@ const HIDDEN_HEAD_CLASS = 'h-0 p-0';
181
181
  const ALIGN_CLASS = { center: 'text-center', right: 'text-right' };
182
182
  const alignClass = (align) => align && ALIGN_CLASS[align];
183
183
  const GROUP_HEADING_CLASS = 'h-auto bg-background pt-4 pb-1.5 align-bottom';
184
+ // `stickyGroupHeadings`. An `overflow-x-auto` box scrolls on both axes as far
185
+ // as `position: sticky` is concerned, so a cell inside it sticks to that box
186
+ // and never to the page. When the columns fit, the box only clips, which
187
+ // leaves the page's scroll to stick to. When they don't, the box has to
188
+ // scroll sideways, so it's bounded to the screen and scrolls down too.
189
+ // `isolate` keeps these z-indexes inside the table.
190
+ const STICKY_PAGE_SCROLL_CLASS = 'isolate overflow-x-clip';
191
+ const STICKY_OWN_SCROLL_CLASS = 'isolate max-h-dvh overflow-auto';
192
+ // Collapsed borders stay where the row was, so a stuck cell draws its rule
193
+ // as an inset shadow and its row's border comes off. Above the pinned
194
+ // columns (z-10): the column header over the headings over the rows. A
195
+ // cell's sticky bounds are the whole table, not its group, so a heading isn't
196
+ // pushed off by the next: the next slides over it, later in the DOM and opaque.
197
+ const STICKY_RULE_CLASS = 'shadow-[inset_0_-1px_0_0_var(--border)]';
198
+ const STICKY_HEAD_CELL_CLASS = `sticky top-0 z-30 bg-background ${STICKY_RULE_CLASS}`;
199
+ const STICKY_GROUP_HEADING_CLASS = `sticky top-(--data-table-head-height) z-20 pt-2 ${STICKY_RULE_CLASS}`;
200
+ // What focus scrolls to clears the stuck header and heading (3rem covers a
201
+ // heading's height, large density included).
202
+ const STICKY_FOCUS_CLASS = '[&_tbody_*]:scroll-mt-[calc(var(--data-table-head-height)+--spacing(12))]';
184
203
  // A grouping's heading (`groupings`) is a button that folds its rows: the
185
204
  // label, then the count, a chevron that turns when folded.
186
205
  const GROUP_TOGGLE_CLASS = '-mx-1 inline-flex items-baseline gap-2 rounded-sm px-1 outline-none hover:underline ' +
@@ -270,7 +289,34 @@ function useBottomScrollbar(containerRef, isSuccessView) {
270
289
  }, [containerRef, isSuccessView, isOverflowing]);
271
290
  return { barRef, isOverflowing, scrollWidth };
272
291
  }
273
- export function DataTable({ columns, data, total, page, pageSize, onPageChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width = 'full', groupBy, groupSummary, header: showHeader = true, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel = 'Details', }) {
292
+ // `stickyGroupHeadings`: whether the columns are wider than their box, which
293
+ // picks what the headings stick to, and the column header's measured height,
294
+ // which is where they stick (a header can wrap, or be hidden, so it isn't
295
+ // always --table-head-height). A layout effect, so the first paint is right.
296
+ // The table's width, not the box's scrollWidth: it reads the same in either
297
+ // mode, and a scrollbar the bounded box draws can't flip the answer back.
298
+ function useStickyHeadings(containerRef, enabled) {
299
+ const [scrollsSideways, setScrollsSideways] = useState(false);
300
+ const [headHeight, setHeadHeight] = useState(0);
301
+ useLayoutEffect(() => {
302
+ const container = containerRef.current;
303
+ const contentTable = container?.querySelector('table');
304
+ const head = contentTable?.querySelector('thead');
305
+ if (!enabled || !container || !contentTable || !head)
306
+ return;
307
+ const measure = () => {
308
+ setScrollsSideways(contentTable.getBoundingClientRect().width > container.getBoundingClientRect().width + 0.5);
309
+ setHeadHeight(head.getBoundingClientRect().height);
310
+ };
311
+ measure();
312
+ const resizeObserver = new ResizeObserver(measure);
313
+ resizeObserver.observe(container);
314
+ resizeObserver.observe(contentTable);
315
+ return () => resizeObserver.disconnect();
316
+ }, [containerRef, enabled]);
317
+ return { scrollsSideways, headHeight };
318
+ }
319
+ export function DataTable({ columns, data, total, page, pageSize, onPageChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width = 'full', groupBy, groupSummary, stickyGroupHeadings = false, header: showHeader = true, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel = 'Details', }) {
274
320
  // The switch's own state, for a table that doesn't pass `layout`.
275
321
  const [ownLayout, setOwnLayout] = useState('table');
276
322
  const requestedLayout = layoutProp ?? ownLayout;
@@ -400,6 +446,8 @@ export function DataTable({ columns, data, total, page, pageSize, onPageChange,
400
446
  : groupBy
401
447
  ? groupRuns(rows, (row) => groupBy(row.original)).map((run) => ({ ...run, foldable: false }))
402
448
  : null;
449
+ const stickyGroups = stickyGroupHeadings && runs !== null && !cardLayout;
450
+ const { scrollsSideways, headHeight } = useStickyHeadings(containerRef, stickyGroups && isSuccessView);
403
451
  const allFolded = runs !== null && runs.length > 0 && runs.every((run) => folded.has(run.key));
404
452
  const toggleFold = (key) => {
405
453
  if (!activeGrouping)
@@ -545,7 +593,7 @@ export function DataTable({ columns, data, total, page, pageSize, onPageChange,
545
593
  return;
546
594
  event.preventDefault();
547
595
  closeDetail();
548
- }, children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("h2", { className: "type-label text-muted-foreground", children: detailLabel }), _jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": "Close", onClick: closeDetail, children: _jsx(XIcon, { "aria-hidden": "true" }) })] }), detailPanel(selectedRow.original)] })) : null, children: [cardLayout ? (_jsx(Cards, { layout: cardLayout, runs: runs, rows: rows, folded: folded, onToggleFold: toggleFold, groupSummary: groupSummary, groupIcons: groupIcons, onCardClick: onCardClick })) : (_jsxs(Table, { "data-state": "success", containerRef: containerRef, onKeyDown: rowsOpen ? onListKeyDown : undefined,
596
+ }, children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("h2", { className: "type-label text-muted-foreground", children: detailLabel }), _jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": "Close", onClick: closeDetail, children: _jsx(XIcon, { "aria-hidden": "true" }) })] }), detailPanel(selectedRow.original)] })) : null, children: [cardLayout ? (_jsx(Cards, { layout: cardLayout, runs: runs, rows: rows, folded: folded, onToggleFold: toggleFold, groupSummary: groupSummary, groupIcons: groupIcons, onCardClick: onCardClick })) : (_jsxs(Table, { "data-state": "success", containerRef: containerRef, onKeyDown: rowsOpen ? onListKeyDown : undefined, className: cn(stickyGroups && STICKY_FOCUS_CLASS), style: stickyGroups ? { '--data-table-head-height': `${headHeight}px` } : undefined,
549
597
  // With the sticky bar below as the visible scrollbar, hide the
550
598
  // container's own. It stays overflow-x-auto and fully
551
599
  // scrollable (wheel, trackpad, drag, and the sync effect); it
@@ -556,7 +604,7 @@ export function DataTable({ columns, data, total, page, pageSize, onPageChange,
556
604
  // `width="content"` couldn't fit the table. Its query only
557
605
  // serves a phone-width rule, and an 80rem table area never
558
606
  // is one.
559
- width === 'content' && '@7xl/data-table:[container-type:normal]'), children: [_jsx(TableHeader, { className: cn(!showHeader && '[&_tr]:border-0'), children: table.getHeaderGroups().map((headerGroup) => (_jsx(TableRow, { children: headerGroup.headers.map((header, index) => {
607
+ width === 'content' && '@7xl/data-table:[container-type:normal]', stickyGroups && (scrollsSideways ? STICKY_OWN_SCROLL_CLASS : STICKY_PAGE_SCROLL_CLASS)), children: [_jsx(TableHeader, { className: cn((!showHeader || stickyGroups) && '[&_tr]:border-0'), children: table.getHeaderGroups().map((headerGroup) => (_jsx(TableRow, { children: headerGroup.headers.map((header, index) => {
560
608
  const canSort = header.column.getCanSort();
561
609
  const sortDirection = header.column.getIsSorted();
562
610
  // Hidden, a header is its name only: a sort button no
@@ -567,7 +615,7 @@ export function DataTable({ columns, data, total, page, pageSize, onPageChange,
567
615
  header.column.columnDef.meta?.align === 'right' && 'ml-auto flex-row-reverse'), onClick: header.column.getToggleSortingHandler(), children: [flexRender(header.column.columnDef.header, header.getContext()), sortDirection === 'asc' ? (_jsx(ArrowUpIcon, { className: "size-3.5 text-muted-foreground" })) : sortDirection === 'desc' ? (_jsx(ArrowDownIcon, { className: "size-3.5 text-muted-foreground" })) : (_jsx(ArrowUpDownIcon, { className: "size-3.5 text-muted-foreground/50" }))] })) : (flexRender(header.column.columnDef.header, header.getContext()));
568
616
  return (_jsx(TableHead, { className: cn(!showHeader && HIDDEN_HEAD_CLASS, pinFirstColumn && index === 0 && PINNED_COLUMN_CLASS, pinLastColumn &&
569
617
  index === headerGroup.headers.length - 1 &&
570
- PINNED_LAST_COLUMN_CLASS, alignClass(header.column.columnDef.meta?.align)), "aria-sort": !canSort
618
+ PINNED_LAST_COLUMN_CLASS, stickyGroups && showHeader && STICKY_HEAD_CELL_CLASS, alignClass(header.column.columnDef.meta?.align)), "aria-sort": !canSort
571
619
  ? undefined
572
620
  : sortDirection === 'asc'
573
621
  ? 'ascending'
@@ -576,7 +624,7 @@ export function DataTable({ columns, data, total, page, pageSize, onPageChange,
576
624
  : 'none', children: !showHeader ? (_jsx("span", { className: "sr-only", children: content })) : pinFirstColumn && index === 0 ? (_jsx("div", { className: PINNED_FIRST_CONTENT_CLASS, children: content })) : (content) }, header.id));
577
625
  }) }, headerGroup.id))) }), runs ? (runs.map((run, runIndex) => {
578
626
  const isFolded = folded.has(run.key);
579
- return (_jsxs(TableBody, { "data-slot": "table-group", "data-folded": isFolded || undefined, children: [_jsx(TableRow, { "data-slot": "table-group-heading", className: "hover:bg-transparent has-aria-expanded:bg-transparent", children: _jsx(TableHead, { scope: "rowgroup", colSpan: visibleColumnCount, className: GROUP_HEADING_CLASS, children: _jsxs("span", { className: "sticky left-(--table-cell-px) inline-flex items-baseline gap-2", children: [_jsx(GroupLabel, { run: run, icon: groupIcons?.get(run.key), isFolded: isFolded, onToggle: () => toggleFold(run.key) }), groupSummary && (_jsx("span", { className: "type-caption text-muted-foreground tabular-nums", children: groupSummary(run.rows.map((row) => row.original), { key: run.key, label: run.label }) }))] }) }) }), _jsx("tr", { hidden: true, "aria-hidden": "true", "data-slot": "table-group-stripe-offset" }), !isFolded && run.rows.map((row) => renderRow(row, placeKey(run.key, row.id)))] }, `${runIndex}:${run.key}`));
627
+ return (_jsxs(TableBody, { "data-slot": "table-group", "data-folded": isFolded || undefined, children: [_jsx(TableRow, { "data-slot": "table-group-heading", className: cn('hover:bg-transparent has-aria-expanded:bg-transparent', stickyGroups && 'border-b-0'), children: _jsx(TableHead, { scope: "rowgroup", colSpan: visibleColumnCount, className: cn(GROUP_HEADING_CLASS, stickyGroups && STICKY_GROUP_HEADING_CLASS), children: _jsxs("span", { className: "sticky left-(--table-cell-px) inline-flex items-baseline gap-2", children: [_jsx(GroupLabel, { run: run, icon: groupIcons?.get(run.key), isFolded: isFolded, onToggle: () => toggleFold(run.key) }), groupSummary && (_jsx("span", { className: "type-caption text-muted-foreground tabular-nums", children: groupSummary(run.rows.map((row) => row.original), { key: run.key, label: run.label }) }))] }) }) }), _jsx("tr", { hidden: true, "aria-hidden": "true", "data-slot": "table-group-stripe-offset" }), !isFolded && run.rows.map((row) => renderRow(row, placeKey(run.key, row.id)))] }, `${runIndex}:${run.key}`));
580
628
  })) : (_jsx(TableBody, { children: rows.map((row) => renderRow(row)) })), totals && (_jsx(TableFooter, { className: TOTALS_FOOTER_CLASS, children: _jsx(TableRow, { "data-slot": "table-totals", className: "hover:bg-transparent", children: visibleLeafColumns.map((column, index) => {
581
629
  const className = cn(pinFirstColumn && index === 0 && PINNED_TOTALS_LABEL_CLASS, pinLastColumn && index === visibleColumnCount - 1 && PINNED_LAST_COLUMN_CLASS, alignClass(column.columnDef.meta?.align));
582
630
  return index === 0 ? (_jsx(TableHead, { scope: "row", className: cn(TOTALS_LABEL_CLASS, className), children: pinFirstColumn ? (_jsx("div", { className: PINNED_FIRST_CONTENT_CLASS, children: totals.label })) : (totals.label) }, column.id)) : (_jsx(TableCell, { className: className, children: totals.cells?.[column.id] }, column.id));
@@ -59,6 +59,14 @@ export type EntityViewSection = ({
59
59
  print?: boolean | {
60
60
  answerSpace?: boolean;
61
61
  };
62
+ /**
63
+ * The tab the section goes under, by name ("Steps", "Used in"): main
64
+ * sections only (a `rail` one ignores it). Any main section with a tab
65
+ * adds a tab list to the main column, one tab per name in the order the
66
+ * sections first give it; sections without one stay above the list. The
67
+ * selected tab is in the address, `?tab=<slug of the name>`.
68
+ */
69
+ tab?: string;
62
70
  };
63
71
  export type EntityViewPlacement = 'main' | 'rail';
64
72
  /**
@@ -72,6 +80,12 @@ export type EntityViewLayout = 'column' | 'rail';
72
80
  * or a narrow content area): `rail-first` (the default) or `main-first`.
73
81
  */
74
82
  export type EntityViewMobileOrder = 'rail-first' | 'main-first';
83
+ /**
84
+ * How a rail section's fields lay out: `stacked` (the default), each label
85
+ * above its value; `beside`, the label to the left of its value, stacked
86
+ * where the rail's list is narrower than 18rem (a small phone).
87
+ */
88
+ export type EntityViewRailFields = 'stacked' | 'beside';
75
89
  export type EntityViewProps = {
76
90
  /** The record's name or title, the page's <h1>, and the browser tab's once it loads (`documentTitle`). */
77
91
  title?: string;
@@ -86,6 +100,14 @@ export type EntityViewProps = {
86
100
  titleEdit?: EditInPlace & {
87
101
  label: string;
88
102
  };
103
+ /**
104
+ * Left of the title, top-aligned with it: the record's mark or avatar
105
+ * (an image, an icon, initials), at a size of the screen's own choosing
106
+ * (`size-10` to `size-16`). The title, subtitle and badges sit beside it
107
+ * at every width. Decorative unless it says something the title doesn't:
108
+ * give an image `alt=""`.
109
+ */
110
+ leading?: ReactNode;
89
111
  /**
90
112
  * A line under the title, in muted body type: what the record is for (a
91
113
  * goal, a one-line summary). Any markup, an `<EditableValue>` included,
@@ -134,6 +156,14 @@ export type EntityViewProps = {
134
156
  printLabel?: string;
135
157
  /** The rail's landmark name (its `<aside>`). Defaults to the title + " details". */
136
158
  railLabel?: string;
159
+ /**
160
+ * In the `rail` layout, a rail section's fields: each label above its
161
+ * value (`stacked`, the default), or to its left (`beside`), falling back
162
+ * to stacked where the rail is too narrow for both. Once the rail's
163
+ * sections stack full width on a narrower screen, labels sit beside
164
+ * values either way.
165
+ */
166
+ railFields?: EntityViewRailFields;
137
167
  isLoading: boolean;
138
168
  /** A `notfound` error (including another user's record) shows "Not found" and a way back, never a retry. */
139
169
  error?: AppError | null;
@@ -144,4 +174,4 @@ export type EntityViewProps = {
144
174
  label: string;
145
175
  };
146
176
  };
147
- export declare function EntityView({ title, documentTitle, titleEdit, subtitle, badges, actions, notice, strip, sections, footer, layout, mobileOrder, railLabel, printLabel, isLoading, error, onRetry, back, }: EntityViewProps): import("react").JSX.Element;
177
+ export declare function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, sections, footer, layout, mobileOrder, railLabel, railFields, printLabel, isLoading, error, onRetry, back, }: EntityViewProps): import("react").JSX.Element;
@@ -55,8 +55,24 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
55
55
  // it for: notes, a checklist). The DOM is in that order at every width, so
56
56
  // reading and tab order match the screen: beside each other, the columns'
57
57
  // places come from the grid, not the DOM.
58
+ //
59
+ // Tabs (4.76, #303): a main section with a `tab` goes under a tab list at
60
+ // the top of the main column, one tab per distinct name in the order the
61
+ // sections first give it, and only the selected tab's sections show. The
62
+ // rest of the main column stays above the list, and the rail always shows.
63
+ // The selected tab is `?tab=<slug>` (the history entry replaced, its state
64
+ // kept, so a record over its list stays the dialog); the first tab is the
65
+ // bare address, and an unknown slug reads as the first. Every tab's
66
+ // sections stay mounted, hidden, so a field open in place survives a
67
+ // switch. With no `tab` on any section, nothing changes.
68
+ //
69
+ // `leading`, left of the title: the record's mark or avatar, with the
70
+ // title, subtitle and badges beside it at every width. `railFields`
71
+ // `beside` puts a rail field's label to the left of its value, as in an
72
+ // issue tracker's sidebar, stacked again where the rail's list is too
73
+ // narrow for both.
58
74
  import { useEffect, useId, useState, useSyncExternalStore } from 'react';
59
- import { Link } from 'react-router';
75
+ import { Link, useLocation, useNavigate } from 'react-router';
60
76
  import { ArrowLeftIcon, SearchXIcon } from 'lucide-react';
61
77
  import { cn } from 'cn';
62
78
  import { ErrorState } from './error-state.js';
@@ -64,6 +80,7 @@ import { Button } from '../ui/button.js';
64
80
  import { Card, CardContent, CardHeader } from '../ui/card.js';
65
81
  import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, } from '../ui/empty.js';
66
82
  import { Skeleton } from '../ui/skeleton.js';
83
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs.js';
67
84
  import { useDocumentTitle } from '../../hooks/use-document-title.js';
68
85
  import { PrintNotes } from './entity-view-print.js';
69
86
  import { EditInPlaceContext } from './edit-in-place.js';
@@ -71,6 +88,7 @@ import { EditInPlaceStore } from './edit-in-place-store.js';
71
88
  import { EditableList } from './editable-list.js';
72
89
  import { EditableValue, LeaveGuard } from './editable-value.js';
73
90
  import { useRecordDialog } from './record-dialog-context.js';
91
+ import { entityViewTabSlug } from '../../lib/entity-view-tab.js';
74
92
  const DEFAULT_EMPTY_LABEL = 'Not set';
75
93
  function isEmptyValue(value) {
76
94
  return (value === null ||
@@ -90,18 +108,22 @@ function orEmptyLabel(value, emptyLabel) {
90
108
  // the rail the list's own width decides instead (a container query on the
91
109
  // <dl>): label above value in the narrow rail, beside it once the rail's
92
110
  // sections stack full width under the header.
111
+ // `railFields="beside"` (4.76) puts them side by side in the rail too,
112
+ // from an 18rem list (a rail card beside the main column is ~19rem
113
+ // inside), with a narrower label column, and stacked below that.
93
114
  const FIELD_ROW = {
94
115
  page: 'sm:grid sm:grid-cols-[minmax(--spacing(32),--spacing(48))_1fr] sm:gap-6',
95
116
  rail: '@lg/fields:grid @lg/fields:grid-cols-[minmax(--spacing(32),--spacing(48))_1fr] @lg/fields:gap-6',
117
+ railBeside: '@2xs/fields:grid @2xs/fields:grid-cols-[minmax(--spacing(24),--spacing(28))_minmax(0,1fr)] @2xs/fields:items-baseline @2xs/fields:gap-4 @2xs/fields:py-2.5 @lg/fields:grid-cols-[minmax(--spacing(32),--spacing(48))_1fr] @lg/fields:gap-6',
96
118
  };
97
- function FieldRow({ field, inRail }) {
119
+ function FieldRow({ field, place }) {
98
120
  // A preset shows its own value unless the screen gives one.
99
121
  const value = field.value !== undefined ? field.value : field.edit?.shown;
100
- return (_jsxs("div", { className: cn('flex flex-col gap-1 py-3 first:pt-0 last:pb-0', FIELD_ROW[inRail ? 'rail' : 'page']), children: [_jsx("dt", { className: "type-label text-muted-foreground", children: field.label }), _jsx("dd", { className: "min-w-0 type-body break-words text-foreground", children: field.edit ? (_jsx(EditableValue, { label: field.label, edit: field.edit, children: orEmptyLabel(value, field.emptyLabel) })) : (orEmptyLabel(value, field.emptyLabel)) })] }));
122
+ return (_jsxs("div", { className: cn('flex flex-col gap-1 py-3 first:pt-0 last:pb-0', FIELD_ROW[place]), children: [_jsx("dt", { className: "type-label text-muted-foreground", children: field.label }), _jsx("dd", { className: "min-w-0 type-body break-words text-foreground", children: field.edit ? (_jsx(EditableValue, { label: field.label, edit: field.edit, children: orEmptyLabel(value, field.emptyLabel) })) : (orEmptyLabel(value, field.emptyLabel)) })] }));
101
123
  }
102
- function ViewSection({ section, inRail = false }) {
124
+ function ViewSection({ section, inRail = false, railFields = 'stacked', }) {
103
125
  const headingId = useId();
104
- return (_jsx("section", { "aria-labelledby": headingId, children: _jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx("h2", { id: headingId, className: "type-section-title text-foreground", children: section.title }) }), _jsx(CardContent, { children: 'fields' in section ? (_jsx("dl", { className: cn('flex flex-col divide-y divide-border', inRail && '@container/fields'), children: section.fields.map((field) => (_jsx(FieldRow, { field: field, inRail: inRail }, field.label))) })) : section.edit?.kind === 'list' ? (_jsxs("div", { className: "flex min-w-0 flex-col gap-2 type-body break-words text-foreground", children: [!isEmptyValue(section.content) && section.content, _jsx(EditableList, { label: section.title, edit: section.edit, emptyLabel: section.emptyLabel ?? DEFAULT_EMPTY_LABEL })] })) : (_jsx("div", { className: "min-w-0 type-body break-words text-foreground", children: section.edit ? (_jsx(EditableValue, { label: section.title, edit: section.edit, children: orEmptyLabel(section.content, section.emptyLabel) })) : (orEmptyLabel(section.content, section.emptyLabel)) })) })] }) }));
126
+ return (_jsx("section", { "aria-labelledby": headingId, children: _jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx("h2", { id: headingId, className: "type-section-title text-foreground", children: section.title }) }), _jsx(CardContent, { children: 'fields' in section ? (_jsx("dl", { className: cn('flex flex-col divide-y divide-border', inRail && '@container/fields'), children: section.fields.map((field) => (_jsx(FieldRow, { field: field, place: !inRail ? 'page' : railFields === 'beside' ? 'railBeside' : 'rail' }, field.label))) })) : section.edit?.kind === 'list' ? (_jsxs("div", { className: "flex min-w-0 flex-col gap-2 type-body break-words text-foreground", children: [!isEmptyValue(section.content) && section.content, _jsx(EditableList, { label: section.title, edit: section.edit, emptyLabel: section.emptyLabel ?? DEFAULT_EMPTY_LABEL })] })) : (_jsx("div", { className: "min-w-0 type-body break-words text-foreground", children: section.edit ? (_jsx(EditableValue, { label: section.title, edit: section.edit, children: orEmptyLabel(section.content, section.emptyLabel) })) : (orEmptyLabel(section.content, section.emptyLabel)) })) })] }) }));
105
127
  }
106
128
  // The rail layout's columns. The view is a container, so the switch to
107
129
  // two columns follows the width the page actually has (the sidebar open
@@ -157,11 +179,48 @@ function useFitsWindow() {
157
179
  }, [element]);
158
180
  return [setElement, fits];
159
181
  }
160
- function Rail({ label, sections }) {
182
+ function Rail({ label, sections, fields, }) {
161
183
  const [ref, fits] = useFitsWindow();
162
- return (_jsx("aside", { ref: ref, "aria-label": label, "data-fits": fits ? '' : undefined, className: cn(RAIL_LAYOUT.rail, RAIL_LAYOUT.sticky, 'flex min-w-0 flex-col gap-6'), children: sections.map((section) => (_jsx(ViewSection, { section: section, inRail: true }, section.title))) }));
184
+ return (_jsx("aside", { ref: ref, "aria-label": label, "data-fits": fits ? '' : undefined, className: cn(RAIL_LAYOUT.rail, RAIL_LAYOUT.sticky, 'flex min-w-0 flex-col gap-6'), children: sections.map((section) => (_jsx(ViewSection, { section: section, inRail: true, railFields: fields }, section.title))) }));
185
+ }
186
+ const TAB_PARAM = 'tab';
187
+ // The main sections' tabs, in the order the sections first name them. Two
188
+ // names with one slug ("Notes", "notes") are one tab, under the first.
189
+ function tabsOf(sections) {
190
+ const tabs = [];
191
+ for (const section of sections) {
192
+ if (section.tab === undefined)
193
+ continue;
194
+ const slug = entityViewTabSlug(section.tab);
195
+ const tab = tabs.find((each) => each.slug === slug);
196
+ if (tab)
197
+ tab.sections.push(section);
198
+ else
199
+ tabs.push({ slug, name: section.tab, sections: [section] });
200
+ }
201
+ return tabs;
202
+ }
203
+ // The tab list, under the sections with no tab, and every tab's sections
204
+ // (hidden but mounted unless selected). The selected tab is the address's,
205
+ // changed in place: the entry replaced, its state kept (a record over its
206
+ // list stays the dialog), the scroll where it was.
207
+ function MainTabs({ tabs, label }) {
208
+ const location = useLocation();
209
+ const navigate = useNavigate();
210
+ const asked = new URLSearchParams(location.search).get(TAB_PARAM);
211
+ const selected = tabs.find((tab) => tab.slug === asked)?.slug ?? tabs[0].slug;
212
+ const select = (slug) => {
213
+ const params = new URLSearchParams(location.search);
214
+ if (slug === tabs[0].slug)
215
+ params.delete(TAB_PARAM);
216
+ else
217
+ params.set(TAB_PARAM, slug);
218
+ const search = params.toString();
219
+ void navigate({ pathname: location.pathname, search: search ? `?${search}` : '', hash: location.hash }, { replace: true, state: location.state, preventScrollReset: true });
220
+ };
221
+ return (_jsxs(Tabs, { value: selected, onValueChange: (value) => select(String(value)), "data-slot": "entity-view-tabs", className: "min-w-0 gap-6", children: [_jsx(TabsList, { variant: "line", activateOnFocus: true, "aria-label": label, className: "h-auto w-full max-w-full justify-start gap-1 overflow-x-auto overflow-y-hidden border-b border-border p-0 [scrollbar-width:thin]", children: tabs.map((tab) => (_jsx(TabsTrigger, { value: tab.slug, className: "h-9 flex-none px-3 text-muted-foreground group-data-horizontal/tabs:after:bottom-0 pointer-coarse:h-11 dark:text-muted-foreground", children: tab.name }, tab.slug))) }), tabs.map((tab) => (_jsx(TabsContent, { value: tab.slug, keepMounted: true, className: "flex min-w-0 flex-col gap-6 [font-size:inherit]", children: tab.sections.map((section) => (_jsx(ViewSection, { section: section }, section.title))) }, tab.slug)))] }));
163
222
  }
164
- export function EntityView({ title, documentTitle, titleEdit, subtitle, badges, actions, notice, strip, sections, footer, layout = 'column', mobileOrder = 'rail-first', railLabel, printLabel = 'Print notes', isLoading, error, onRetry, back, }) {
223
+ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, sections, footer, layout = 'column', mobileOrder = 'rail-first', railLabel, railFields = 'stacked', printLabel = 'Print notes', isLoading, error, onRetry, back, }) {
165
224
  // Editing in place: one store per view, and the leave-page prompt only
166
225
  // while a field is open (or one is always editable).
167
226
  const [store] = useState(() => new EditInPlaceStore());
@@ -196,6 +255,14 @@ export function EntityView({ title, documentTitle, titleEdit, subtitle, badges,
196
255
  const printButton = printSections.length > 0 && (_jsx(PrintNotes, { label: printLabel, title: title, subtitle: subtitle, sections: printSections }));
197
256
  const railSections = sections.filter((section) => section.placement === 'rail');
198
257
  const mainSections = sections.filter((section) => section.placement !== 'rail');
199
- const main = (_jsx("div", { className: cn(RAIL_LAYOUT.main, railSections.length === 0 && RAIL_LAYOUT.mainAlone), children: mainSections.map((section) => (_jsx(ViewSection, { section: section }, section.title))) }));
200
- return (_jsx(EditInPlaceContext.Provider, { value: store, children: _jsxs("div", { className: layout === 'rail' ? RAIL_LAYOUT.page : 'flex max-w-4xl flex-col gap-6', "data-state": "success", "data-layout": layout, children: [editing && _jsx(LeaveGuard, { store: store }), !dialog && _jsx(BackLink, { back: back }), _jsxs("header", { className: "flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between", children: [_jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-2 sm:min-w-64", children: [_jsx("h1", { id: dialog?.titleId, className: "type-page-title break-words text-foreground", children: titleEdit ? (_jsx(EditableValue, { label: titleEdit.label, edit: titleEdit, layout: "inline", className: "w-full", children: title })) : (title) }), subtitle && (_jsx("div", { "data-slot": "entity-view-subtitle", className: "type-body break-words text-muted-foreground", children: subtitle })), badges && _jsx("div", { className: "flex flex-wrap items-center gap-1.5", children: badges })] }), (actions || printButton) && (_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-2 sm:justify-end", children: [printButton, actions] }))] }), _jsx("div", { role: "status", "data-slot": "entity-view-notice", className: "empty:hidden", children: notice }), strip && _jsx("div", { "data-slot": "entity-view-strip", children: strip }), layout === 'rail' ? (_jsxs("div", { className: RAIL_LAYOUT.columns, children: [mobileOrder === 'main-first' && main, railSections.length > 0 && (_jsx(Rail, { label: railLabel ?? `${title ?? 'Record'} details`, sections: railSections })), mobileOrder === 'rail-first' && main] })) : (sections.map((section) => _jsx(ViewSection, { section: section }, section.title))), footer && (_jsx("footer", { "data-slot": "entity-view-footer", className: "type-caption text-muted-foreground", children: footer }))] }) }));
258
+ // Tabs: a main section's `tab` (a rail one's is ignored, in either layout).
259
+ const tabs = tabsOf(mainSections);
260
+ const tabbed = (section) => section.placement !== 'rail' && section.tab !== undefined;
261
+ const tabList = tabs.length > 0 && _jsx(MainTabs, { tabs: tabs, label: `${title ?? 'Record'} sections` });
262
+ const main = (_jsxs("div", { className: cn(RAIL_LAYOUT.main, railSections.length === 0 && RAIL_LAYOUT.mainAlone), children: [mainSections
263
+ .filter((section) => !tabbed(section))
264
+ .map((section) => (_jsx(ViewSection, { section: section }, section.title))), tabList] }));
265
+ return (_jsx(EditInPlaceContext.Provider, { value: store, children: _jsxs("div", { className: layout === 'rail' ? RAIL_LAYOUT.page : 'flex max-w-4xl flex-col gap-6', "data-state": "success", "data-layout": layout, children: [editing && _jsx(LeaveGuard, { store: store }), !dialog && _jsx(BackLink, { back: back }), _jsxs("header", { className: "flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between", children: [_jsxs("div", { className: "flex min-w-0 flex-1 items-start gap-3 sm:min-w-64 sm:gap-4", children: [leading && (_jsx("div", { "data-slot": "entity-view-leading", className: "flex shrink-0 items-center", children: leading })), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-2", children: [_jsx("h1", { id: dialog?.titleId, className: "type-page-title break-words text-foreground", children: titleEdit ? (_jsx(EditableValue, { label: titleEdit.label, edit: titleEdit, layout: "inline", className: "w-full", children: title })) : (title) }), subtitle && (_jsx("div", { "data-slot": "entity-view-subtitle", className: "type-body break-words text-muted-foreground", children: subtitle })), badges && _jsx("div", { className: "flex flex-wrap items-center gap-1.5", children: badges })] })] }), (actions || printButton) && (_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-2 sm:justify-end", children: [printButton, actions] }))] }), _jsx("div", { role: "status", "data-slot": "entity-view-notice", className: "empty:hidden", children: notice }), strip && _jsx("div", { "data-slot": "entity-view-strip", children: strip }), layout === 'rail' ? (_jsxs("div", { className: RAIL_LAYOUT.columns, children: [mobileOrder === 'main-first' && main, railSections.length > 0 && (_jsx(Rail, { label: railLabel ?? `${title ?? 'Record'} details`, sections: railSections, fields: railFields })), mobileOrder === 'rail-first' && main] })) : (_jsxs(_Fragment, { children: [sections
266
+ .filter((section) => !tabbed(section))
267
+ .map((section) => (_jsx(ViewSection, { section: section }, section.title))), tabList] })), footer && (_jsx("footer", { "data-slot": "entity-view-footer", className: "type-caption text-muted-foreground", children: footer }))] }) }));
201
268
  }
@@ -30,6 +30,13 @@ export type ModuleCardProps = ModuleCardPlace & {
30
30
  value?: number | string;
31
31
  /** A few words under the number: "open", "due today", "Opens its own app". */
32
32
  note?: string;
33
+ /**
34
+ * Shows `note` on the phone chip too, after the number (`ModuleStrip
35
+ * mobile="row"`): for a word or two the number means little without.
36
+ * One line, cut off with an ellipsis past 96px; gone on an error, as on
37
+ * the card.
38
+ */
39
+ noteOnChip?: boolean;
33
40
  /** One link at the foot of the card (hidden on a phone, where the tile is the link). */
34
41
  action?: ModuleCardLink;
35
42
  /** True while the number loads. */
@@ -40,7 +47,7 @@ export type ModuleCardProps = ModuleCardPlace & {
40
47
  };
41
48
  /** How a ModuleStrip shows its places on a phone: `tiles` (the default), or one sideways `row` of chips. */
42
49
  export type ModuleStripMobile = 'tiles' | 'row';
43
- export declare function ModuleCard({ title, icon: Icon, category, to, href, value, note, action, isLoading, error, onRetry, className, }: ModuleCardProps): import("react").JSX.Element;
50
+ export declare function ModuleCard({ title, icon: Icon, category, to, href, value, note, noteOnChip, action, isLoading, error, onRetry, className, }: ModuleCardProps): import("react").JSX.Element;
44
51
  export interface ModuleStripProps {
45
52
  /** Names the strip's navigation landmark: "Places". */
46
53
  'aria-label': string;
@@ -48,7 +55,7 @@ export interface ModuleStripProps {
48
55
  children: ReactNode;
49
56
  /**
50
57
  * On a phone: three columns of `tiles` (the default), or one `row` of
51
- * chips (icon, name, number) that scrolls sideways, below the sidebar's
58
+ * chips (icon, name, number, and the note with `noteOnChip`) that scrolls sideways, below the sidebar's
52
59
  * breakpoint. A desktop shows the cards either way.
53
60
  */
54
61
  mobile?: ModuleStripMobile;
@@ -30,6 +30,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
30
30
  // renders its chip beside its card, one shown at each width. The row
31
31
  // scrolls inside itself and is `relative`, so a chip's sr-only text
32
32
  // (absolutely placed) scrolls with it instead of widening the page.
33
+ // `noteOnChip` adds the note after the number, on the chip's one line and
34
+ // cut off at a fixed width, so a long note can't crowd the row.
33
35
  import { Children, createContext, useContext, useId } from 'react';
34
36
  import { Link } from 'react-router';
35
37
  import { AlertCircleIcon, ExternalLinkIcon } from 'lucide-react';
@@ -97,12 +99,12 @@ function ChipValue({ state, value }) {
97
99
  return null;
98
100
  return (_jsx("span", { "data-slot": "module-card-chip-value", className: "font-semibold tabular-nums", children: value }));
99
101
  }
100
- function ModuleChip({ title, icon: Icon, category, to, href, value, state, }) {
101
- const content = (_jsxs(_Fragment, { children: [_jsx(Icon, { "aria-hidden": "true", className: cn('size-4 shrink-0', category ? ICON_CLASS[category] : 'text-muted-foreground') }), title, _jsx(ChipValue, { state: state, value: value })] }));
102
+ function ModuleChip({ title, icon: Icon, category, to, href, value, note, state, }) {
103
+ const content = (_jsxs(_Fragment, { children: [_jsx(Icon, { "aria-hidden": "true", className: cn('size-4 shrink-0', category ? ICON_CLASS[category] : 'text-muted-foreground') }), title, _jsx(ChipValue, { state: state, value: value }), note && state !== 'error' && (_jsx("span", { "data-slot": "module-card-chip-note", title: note, className: "max-w-24 truncate type-caption text-muted-foreground", children: note }))] }));
102
104
  const chipProps = { 'data-slot': 'module-card-chip', 'data-state': state, className: cn(CHIP_CLASS, 'md:hidden') };
103
105
  return href !== undefined ? (_jsxs("a", { href: href, target: "_blank", rel: "noreferrer", ...chipProps, children: [content, _jsx(NewTabMark, {})] })) : (_jsx(Link, { to: to, ...chipProps, children: content }));
104
106
  }
105
- export function ModuleCard({ title, icon: Icon, category, to, href, value, note, action, isLoading = false, error, onRetry, className, }) {
107
+ export function ModuleCard({ title, icon: Icon, category, to, href, value, note, noteOnChip = false, action, isLoading = false, error, onRetry, className, }) {
106
108
  const titleId = useId();
107
109
  const bodyId = useId();
108
110
  const state = error ? 'error' : isLoading ? 'loading' : 'success';
@@ -117,7 +119,7 @@ export function ModuleCard({ title, icon: Icon, category, to, href, value, note,
117
119
  (action.href !== undefined ? (_jsxs("a", { href: action.href, target: "_blank", rel: "noreferrer", "aria-describedby": titleId, className: ACTION_CLASS, children: [_jsx("span", { className: "truncate", children: action.label }), _jsx(NewTabMark, {})] })) : (_jsx(Link, { to: action.to, "aria-describedby": titleId, className: ACTION_CLASS, children: _jsx("span", { className: "truncate", children: action.label }) })))] }));
118
120
  if (mobile === 'tiles')
119
121
  return card;
120
- return (_jsxs(_Fragment, { children: [card, _jsx(ModuleChip, { title: title, icon: Icon, category: category, to: to, href: href, value: value, state: state })] }));
122
+ return (_jsxs(_Fragment, { children: [card, _jsx(ModuleChip, { title: title, icon: Icon, category: category, to: to, href: href, value: value, note: noteOnChip ? note : undefined, state: state })] }));
121
123
  }
122
124
  // The list's columns: whole class names, so Tailwind generates them.
123
125
  const STRIP_LIST = {
@@ -0,0 +1,10 @@
1
+ import { Tabs as TabsPrimitive } from "@base-ui/react/tabs";
2
+ import { type VariantProps } from "class-variance-authority";
3
+ declare function Tabs({ className, orientation, ...props }: TabsPrimitive.Root.Props): import("react").JSX.Element;
4
+ declare const tabsListVariants: (props?: ({
5
+ variant?: "default" | "line" | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
+ declare function TabsList({ className, variant, ...props }: TabsPrimitive.List.Props & VariantProps<typeof tabsListVariants>): import("react").JSX.Element;
8
+ declare function TabsTrigger({ className, ...props }: TabsPrimitive.Tab.Props): import("react").JSX.Element;
9
+ declare function TabsContent({ className, ...props }: TabsPrimitive.Panel.Props): import("react").JSX.Element;
10
+ export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants };
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Tabs as TabsPrimitive } from "@base-ui/react/tabs";
3
+ import { cva } from "class-variance-authority";
4
+ import { cn } from "cn";
5
+ function Tabs({ className, orientation = "horizontal", ...props }) {
6
+ return (_jsx(TabsPrimitive.Root, { "data-slot": "tabs", "data-orientation": orientation, className: cn("group/tabs flex gap-2 data-horizontal:flex-col", className), ...props }));
7
+ }
8
+ const tabsListVariants = cva("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none", {
9
+ variants: {
10
+ variant: {
11
+ default: "bg-muted",
12
+ line: "gap-1 bg-transparent",
13
+ },
14
+ },
15
+ defaultVariants: {
16
+ variant: "default",
17
+ },
18
+ });
19
+ function TabsList({ className, variant = "default", ...props }) {
20
+ return (_jsx(TabsPrimitive.List, { "data-slot": "tabs-list", "data-variant": variant, className: cn(tabsListVariants({ variant }), className), ...props }));
21
+ }
22
+ function TabsTrigger({ className, ...props }) {
23
+ return (_jsx(TabsPrimitive.Tab, { "data-slot": "tabs-trigger", className: cn("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", "group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent", "data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground", "after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100", className), ...props }));
24
+ }
25
+ function TabsContent({ className, ...props }) {
26
+ return (_jsx(TabsPrimitive.Panel, { "data-slot": "tabs-content", className: cn("flex-1 text-sm outline-none", className), ...props }));
27
+ }
28
+ export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants };
package/dist/index.d.ts CHANGED
@@ -14,7 +14,8 @@ export { type RowGroup } from './components/app/table-groups.js';
14
14
  export { byDay, type ByDayOptions } from './lib/group-by-day.js';
15
15
  export { EntityForm, type EntityFormProps } from './components/app/entity-form.js';
16
16
  export { KeyStats, type KeyStat, type KeyStatsProps } from './components/app/key-stats.js';
17
- export { EntityView, type EntityViewField, type EntityViewLayout, type EntityViewMobileOrder, type EntityViewPlacement, type EntityViewProps, type EntityViewSection, } from './components/app/entity-view.js';
17
+ export { EntityView, type EntityViewField, type EntityViewLayout, type EntityViewMobileOrder, type EntityViewPlacement, type EntityViewProps, type EntityViewRailFields, type EntityViewSection, } from './components/app/entity-view.js';
18
+ export { entityViewTabSlug } from './lib/entity-view-tab.js';
18
19
  export { usePrinting } from './components/app/print-context.js';
19
20
  export { RecordDialogRoute, RecordLink, type RecordDialogRouteProps, type RecordLinkProps, } from './components/app/record-dialog.js';
20
21
  export { recordDialogState, useOpenRecord, useRecordDialog, type RecordDialogBackground, type RecordDialogContextValue, type RecordDialogState, } from './components/app/record-dialog-context.js';
package/dist/index.js CHANGED
@@ -19,6 +19,7 @@ export { byDay } from './lib/group-by-day.js';
19
19
  export { EntityForm } from './components/app/entity-form.js';
20
20
  export { KeyStats } from './components/app/key-stats.js';
21
21
  export { EntityView, } from './components/app/entity-view.js';
22
+ export { entityViewTabSlug } from './lib/entity-view-tab.js';
22
23
  export { usePrinting } from './components/app/print-context.js';
23
24
  export { RecordDialogRoute, RecordLink, } from './components/app/record-dialog.js';
24
25
  export { recordDialogState, useOpenRecord, useRecordDialog, } from './components/app/record-dialog-context.js';
@@ -0,0 +1,2 @@
1
+ /** A tab's name as it reads in the address: "Used in" is `used-in`. */
2
+ export declare function entityViewTabSlug(name: string): string;
@@ -0,0 +1,11 @@
1
+ // EntityView's tabs (4.76, #303): the selected tab is `?tab=<slug>`, so a
2
+ // screen can link straight to one (`/things/3?tab=${entityViewTabSlug('Used in')}`).
3
+ /** A tab's name as it reads in the address: "Used in" is `used-in`. */
4
+ export function entityViewTabSlug(name) {
5
+ return (name
6
+ .normalize('NFKD')
7
+ .replace(/[\u0300-\u036f]/g, '')
8
+ .toLowerCase()
9
+ .replace(/[^a-z0-9]+/g, '-')
10
+ .replace(/^-+|-+$/g, '') || 'tab');
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "4.74.0",
3
+ "version": "4.76.0",
4
4
  "description": "Shared UI foundation for contract-first, database-backed React apps: shadcn primitives, DataTable/EntityForm composites, auth, the gateway error seam, design tokens, lint rules and the AI playbook.",
5
5
  "license": "MIT",
6
6
  "repository": {