@tristan2828/ui-foundation 4.99.0 → 4.101.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,17 +15,17 @@
15
15
  - Step 8: Add Playwright specs for all three screens · lines 752–829
16
16
  - Step 9: Register the nav entry and route names · lines 830–844
17
17
  - Step 10: `npm run verify`. · lines 845–847
18
- - [How a list opens a record](#how-a-list-opens-a-record) · lines 849–1206
19
- - [The record view](#the-record-view) · lines 1002–1063
20
- - [Forms](#forms) · lines 1065–1123
21
- - [Dialogs](#dialogs) · lines 1125–1156
22
- - [Toasts and feedback](#toasts-and-feedback) · lines 1158–1206
23
- - [What not to copy](#what-not-to-copy) · lines 1208–1234
24
- - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1236–1253
25
- - [Deleting](#deleting) · lines 1255–1286
26
- - [Fields only a script writes](#fields-only-a-script-writes) · lines 1288–1309
27
- - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1311–1320
28
- - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1323–1365
18
+ - [How a list opens a record](#how-a-list-opens-a-record) · lines 849–1208
19
+ - [The record view](#the-record-view) · lines 1002–1065
20
+ - [Forms](#forms) · lines 1067–1125
21
+ - [Dialogs](#dialogs) · lines 1127–1158
22
+ - [Toasts and feedback](#toasts-and-feedback) · lines 1160–1208
23
+ - [What not to copy](#what-not-to-copy) · lines 1210–1236
24
+ - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1238–1255
25
+ - [Deleting](#deleting) · lines 1257–1288
26
+ - [Fields only a script writes](#fields-only-a-script-writes) · lines 1290–1311
27
+ - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1313–1322
28
+ - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1325–1367
29
29
 
30
30
  <!-- /index -->
31
31
 
@@ -1033,7 +1033,9 @@ A record uses the parts it has, in this order:
1033
1033
  - **Tabs** (4.76), for a main column with **three or more groups of
1034
1034
  long content** (the steps, where it's used, the reasoning): a `tab` on
1035
1035
  each main section groups them under a tab list, the selected one in
1036
- `?tab=`. Fewer groups stay one scroll, folded by headings. A record's
1036
+ `?tab=`. Give each tab that holds records its count (`tabCounts={{
1037
+ Updates: updates.length }}`); the bar sticks as the record scrolls,
1038
+ with the record's name above it (4.101). Fewer groups stay one scroll, folded by headings. A record's
1037
1039
  Notes stay outside the tabs, above them, unless they are one tab's
1038
1040
  content; the strip never goes in a tab, and the facts are a tab of
1039
1041
  their own (Details, `detailsTab` to name it otherwise).
@@ -3,46 +3,47 @@
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
- - [The rules that apply to every cell](#the-rules-that-apply-to-every-cell) · lines 74–97
7
- - [1. Plain text](#1-plain-text) · lines 99–152
8
- - [2. Icon + label](#2-icon--label) · lines 154–177
9
- - [3. Icon in a badge](#3-icon-in-a-badge) · lines 179–192
10
- - [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines 194–271
11
- - [Several values: the icons side by side, every name in one tooltip](#several-values-the-icons-side-by-side-every-name-in-one-tooltip) · lines 219–271
12
- - [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines 273–293
13
- - [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 295–307
14
- - [7. Link as an outline button](#7-link-as-an-outline-button) · lines 309–330
15
- - [8. Date, relative](#8-date-relative) · lines 332–369
16
- - [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 371–419
17
- - [Two variants the package draws: a step bar and a star](#two-variants-the-package-draws-a-step-bar-and-a-star) · lines 389–419
18
- - [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 421–471
19
- - [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 439–471
20
- - [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 473–513
21
- - [12. Boolean](#12-boolean) · lines 515–545
22
- - [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 547–583
23
- - [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 567–583
24
- - [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 585–602
25
- - [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 604–713
26
- - [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 630–713
27
- - [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 715–750
28
- - [17. Quick action on the view](#17-quick-action-on-the-view) · lines 752–825
29
- - [18. Editable value](#18-editable-value) · lines 827–1505
30
- - [Presets: one line per field](#presets-one-line-per-field) · lines 1137–1205
31
- - [Several fields edited as one](#several-fields-edited-as-one) · lines 1207–1243
32
- - [A link and its label](#a-link-and-its-label) · lines 1245–1269
33
- - [A list of sub-items](#a-list-of-sub-items) · lines 1271–1404
34
- - [In a table's rows](#in-a-tables-rows) · lines 1406–1491
35
- - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1493–1505
36
- - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1507–1573
37
- - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1575–1639
38
- - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1641–1739
39
- - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1741–1770
40
- - [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines 1772–1810
41
- - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1812–1888
42
- - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1890–1913
43
- - [25. A list's tools: views, filters, columns, row actions, a phone's rows](#25-a-lists-tools-views-filters-columns-row-actions-a-phones-rows) · lines 1915–2001
44
- - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2003–2039
45
- - [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2041–2086
6
+ - [The rules that apply to every cell](#the-rules-that-apply-to-every-cell) · lines 75–98
7
+ - [1. Plain text](#1-plain-text) · lines 100–153
8
+ - [2. Icon + label](#2-icon--label) · lines 155–178
9
+ - [3. Icon in a badge](#3-icon-in-a-badge) · lines 180–193
10
+ - [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines 195–272
11
+ - [Several values: the icons side by side, every name in one tooltip](#several-values-the-icons-side-by-side-every-name-in-one-tooltip) · lines 220–272
12
+ - [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines 274–294
13
+ - [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 296–308
14
+ - [7. Link as an outline button](#7-link-as-an-outline-button) · lines 310–331
15
+ - [8. Date, relative](#8-date-relative) · lines 333–370
16
+ - [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 372–420
17
+ - [Two variants the package draws: a step bar and a star](#two-variants-the-package-draws-a-step-bar-and-a-star) · lines 390–420
18
+ - [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 422–472
19
+ - [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 440–472
20
+ - [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 474–514
21
+ - [12. Boolean](#12-boolean) · lines 516–546
22
+ - [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 548–584
23
+ - [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 568–584
24
+ - [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 586–603
25
+ - [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 605–714
26
+ - [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 631–714
27
+ - [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 716–751
28
+ - [17. Quick action on the view](#17-quick-action-on-the-view) · lines 753–826
29
+ - [18. Editable value](#18-editable-value) · lines 828–1506
30
+ - [Presets: one line per field](#presets-one-line-per-field) · lines 1138–1206
31
+ - [Several fields edited as one](#several-fields-edited-as-one) · lines 1208–1244
32
+ - [A link and its label](#a-link-and-its-label) · lines 1246–1270
33
+ - [A list of sub-items](#a-list-of-sub-items) · lines 1272–1405
34
+ - [In a table's rows](#in-a-tables-rows) · lines 1407–1492
35
+ - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1494–1506
36
+ - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1508–1574
37
+ - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1576–1640
38
+ - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1642–1740
39
+ - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1742–1771
40
+ - [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines 1773–1811
41
+ - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1813–1889
42
+ - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1891–1914
43
+ - [25. A list's tools: views, filters, columns, row actions, a phone's rows](#25-a-lists-tools-views-filters-columns-row-actions-a-phones-rows) · lines 1916–2042
44
+ - [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2004–2042
45
+ - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2044–2080
46
+ - [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2082–2127
46
47
 
47
48
  <!-- /index -->
48
49
 
@@ -2000,6 +2001,46 @@ const { filters, multiFilters, setFilter, setFilters, setMultiFilter, activeView
2000
2001
  pick and a view's columns winning, the ⋯ menu, the 44px rows, the
2001
2002
  phone's line and sheet.
2002
2003
 
2004
+ ### The framed look, and sibling lists beside the title
2005
+
2006
+ The toolbar a list-page review picked (4.100): `look="framed"` on
2007
+ `DataTable`, and `siblings` on `ListHeader`. Both are opt-in.
2008
+
2009
+ ```tsx
2010
+ <ListHeader
2011
+ title="Exercises" count={total}
2012
+ siblings={[
2013
+ { label: 'Exercises', to: '/training/exercises', count: 5 },
2014
+ { label: 'Targets', to: '/training/targets', count: 9 },
2015
+ { label: 'Weak spots', to: '/training/weak-spots', count: 4 },
2016
+ ]}
2017
+ deleted={{ shown, onShownChange: setShown, noun: 'exercises' }}
2018
+ newAction={{ label: 'New Exercise', to: '/training/exercises/new' }}
2019
+ />
2020
+ <DataTable look="framed" views={VIEWS} columnsMenu={…} groupings={…} toolbar={<FilterBar … />} … />
2021
+ ```
2022
+
2023
+ - **The card**: the toolbar in its top bar (search and Filters keep their
2024
+ words), the rows, then the count and pager in its bottom bar. Saved
2025
+ views sit above it, outside the bar. Loading, empty and error show
2026
+ inside it.
2027
+ - **The tools end at the table's edge**: the card is as wide as `width`
2028
+ makes the table, tools and pager with it, so nothing sits off at the
2029
+ far right of a wide page. `width="full"` fills the area as before.
2030
+ - **One settings button** in place of Columns and Group: the Columns
2031
+ ticks, then Group By, in one menu. Its name says the grouping that's on
2032
+ ("Table Settings, Grouped by Status") and a dot marks it. Fold All
2033
+ stays a button of its own while grouped. On a phone it holds Group By
2034
+ alone.
2035
+ - **Siblings** are the page's peers, a switch of links beside the title,
2036
+ the current one marked (`aria-current="page"`); they don't go in ⋯,
2037
+ which keeps what's left. Two or more; on a phone the switch has its own
2038
+ line. Pass `current` when the siblings differ only by query string.
2039
+ - The fixtures' `app/DataTable tools` Framed and `app/ListHeader`
2040
+ Siblings stories hold it, under axe and the token check in both
2041
+ themes; `e2e/data-table-framed.spec.ts` checks the edges, the menu
2042
+ from the mouse and the keyboard, the switch and the phone.
2043
+
2003
2044
  ## 26. A record's related list, capped
2004
2045
 
2005
2046
  A list of records related to this one, in a section of its view (a
@@ -33,11 +33,11 @@
33
33
  - [A few equal things](#a-few-equal-things) · lines 1401–1485
34
34
  - [An overview page](#an-overview-page) · lines 1487–1550
35
35
  - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1551–1602
36
- - [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1604–1663
37
- - [Picking at random](#picking-at-random) · lines 1665–1696
38
- - [Filling in what's missing](#filling-in-whats-missing) · lines 1698–1765
39
- - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1767–1792
40
- - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1794–1883
36
+ - [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1604–1671
37
+ - [Picking at random](#picking-at-random) · lines 1673–1704
38
+ - [Filling in what's missing](#filling-in-whats-missing) · lines 1706–1773
39
+ - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1775–1800
40
+ - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1802–1891
41
41
 
42
42
  <!-- /index -->
43
43
 
@@ -1622,10 +1622,18 @@ its short facts the last tab, Details. A mark goes left of the title.
1622
1622
 
1623
1623
  - **Tabs** (`tab` on a section): a line tab list under the strip and any
1624
1624
  sections with no tab, one tab per name in the order the sections first
1625
- give it. The selected tab has foreground text and a 2px underline, the
1626
- others muted text; the list's own bottom border runs the column's
1627
- width. On a phone each tab is 44px tall, and a list wider than the
1628
- column scrolls sideways on its own, never the page. Arrow keys move
1625
+ give it. The look is the record standard's 3B (4.101): 44px tabs in
1626
+ 16px semibold (14px under 48rem), the selected one in foreground text
1627
+ with a 3px primary line under it, the others muted; the list's own
1628
+ bottom border runs the column's width. A tab's count (`tabCounts`, by
1629
+ name: the records it holds) sits beside its name in a small muted
1630
+ pill; a tab with none shows no count. A list wider than the column
1631
+ scrolls sideways on its own, never the page.
1632
+ - **The tab bar sticks** (4.101) to the top of whatever scrolls (the
1633
+ page, or a record dialog's body) while the record scrolls under it,
1634
+ and once stuck shows the record's name above the tabs, so you always
1635
+ see which record and which other tabs there are. A page with a bar of
1636
+ its own pinned to the top passes `tabsStickyTop` (any CSS length). Arrow keys move
1629
1637
  between tabs and select (Home, End), and Tab goes on into the panel.
1630
1638
  The address holds the selected tab (`?tab=used-in`,
1631
1639
  `entityViewTabSlug`), replaced rather than pushed, so Back leaves the
@@ -30,7 +30,7 @@ export type DataTableColumnsMenu = {
30
30
  /** The button's text: "Columns" unless set. */
31
31
  label?: string;
32
32
  };
33
- export declare function ColumnsMenu({ columns, visible, fixed, pick, onPickChange, setByView, label, }: {
33
+ type ColumnsMenuProps = {
34
34
  /** Every column the menu can tick, in order, with its name. */
35
35
  columns: readonly {
36
36
  id: string;
@@ -44,6 +44,9 @@ export declare function ColumnsMenu({ columns, visible, fixed, pick, onPickChang
44
44
  onPickChange: (pick: ColumnsPick | null) => void;
45
45
  /** A view on that sets its own columns: the ticks show them and can't change. */
46
46
  setByView: boolean;
47
+ };
48
+ export declare function ColumnsMenuItems({ columns, visible, fixed, pick, onPickChange, setByView }: ColumnsMenuProps): import("react").JSX.Element;
49
+ export declare function ColumnsMenu({ label, ...props }: ColumnsMenuProps & {
47
50
  label?: string;
48
51
  }): import("react").JSX.Element;
49
52
  /** One of a row's actions (DataTable `rowActions`). */
@@ -96,3 +99,4 @@ export declare function ViewAllLink({ viewAll, total, navigator }: {
96
99
  total: number;
97
100
  navigator?: Navigator;
98
101
  }): import("react").JSX.Element;
102
+ export {};
@@ -14,9 +14,14 @@ export function ViewPills({ views, value, onValueChange, label, }) {
14
14
  // No view's id matches '' (filters set by hand), so none is pressed.
15
15
  value: value ?? '', onValueChange: onValueChange, className: "max-md:w-max max-md:flex-nowrap" }) }));
16
16
  }
17
- export function ColumnsMenu({ columns, visible, fixed, pick, onPickChange, setByView, label = 'Columns', }) {
17
+ // The menu's items alone: the Columns menu's, and the framed look's
18
+ // settings menu's first group (data-table.tsx's TableSettingsMenu).
19
+ export function ColumnsMenuItems({ columns, visible, fixed, pick, onPickChange, setByView }) {
18
20
  const ids = [...fixed, ...columns.map((column) => column.id)];
19
- return (_jsxs(DropdownMenu, { children: [_jsxs(DropdownMenuTrigger, { render: _jsx(Button, { variant: "outline", size: "sm", "data-slot": "data-table-columns-menu" }), children: [_jsx(Columns3Icon, { "aria-hidden": "true" }), label] }), _jsxs(DropdownMenuContent, { align: "end", className: "w-52", children: [_jsxs(DropdownMenuGroup, { children: [_jsx(DropdownMenuLabel, { children: setByView ? 'Set by This View' : 'Show Columns' }), columns.map((column) => (_jsx(DropdownMenuCheckboxItem, { checked: visible.includes(column.id), disabled: setByView, onCheckedChange: (checked) => onPickChange(togglePick(ids, visible, column.id, checked, pick)), children: column.label }, column.id)))] }), pick && !setByView ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsx(DropdownMenuItem, { onClick: () => onPickChange(null), children: "Reset to the List's Columns" })] })) : null] })] }));
21
+ return (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuGroup, { children: [_jsx(DropdownMenuLabel, { children: setByView ? 'Set by This View' : 'Show Columns' }), columns.map((column) => (_jsx(DropdownMenuCheckboxItem, { checked: visible.includes(column.id), disabled: setByView, onCheckedChange: (checked) => onPickChange(togglePick(ids, visible, column.id, checked, pick)), children: column.label }, column.id)))] }), pick && !setByView ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsx(DropdownMenuItem, { onClick: () => onPickChange(null), children: "Reset to the List's Columns" })] })) : null] }));
22
+ }
23
+ export function ColumnsMenu({ label = 'Columns', ...props }) {
24
+ return (_jsxs(DropdownMenu, { children: [_jsxs(DropdownMenuTrigger, { render: _jsx(Button, { variant: "outline", size: "sm", "data-slot": "data-table-columns-menu" }), children: [_jsx(Columns3Icon, { "aria-hidden": "true" }), label] }), _jsx(DropdownMenuContent, { align: "end", className: "w-52", children: _jsx(ColumnsMenuItems, { ...props }) })] }));
20
25
  }
21
26
  export function RowActions({ actions, rowLabel }) {
22
27
  if (actions.length === 0)
@@ -305,7 +305,22 @@ export type DataTableProps<TData extends Record<string, unknown>, TView extends
305
305
  * when there are more than the rows shown.
306
306
  */
307
307
  viewAll?: DataTableViewAll;
308
+ /**
309
+ * How the list is drawn around its rows (4.100). `plain` (the default):
310
+ * the toolbar above the whole width, the Columns and Group menus as
311
+ * buttons at its end, the pagination under the rows. `framed`: the
312
+ * list is a card with a border, as wide as the table under `width`'s
313
+ * rules, so its tools end at the table's own edge and nothing sits off
314
+ * at the far right of a wide page. The card's top bar holds the toolbar
315
+ * (search and Filters keep their words), Fold All while grouped, one
316
+ * settings button holding the Columns ticks and Group By, and the layout
317
+ * switch; its bottom bar holds the count and the pager. Saved views stay
318
+ * above the card, outside its bar. Every other prop works the same way.
319
+ */
320
+ look?: DataTableLook;
308
321
  };
322
+ /** How DataTable draws the list around its rows (`look`). */
323
+ export type DataTableLook = 'plain' | 'framed';
309
324
  /** A field DataTable's rows can be grouped by (`groupings`). */
310
325
  export type DataTableGrouping<TData> = {
311
326
  /**
@@ -380,4 +395,4 @@ export type DataTableTotals = {
380
395
  */
381
396
  cells?: Partial<Record<string, ReactNode>>;
382
397
  };
383
- export declare function DataTable<TData extends Record<string, unknown>, TView extends DataTableView = DataTableView>({ columns, data, total, page, pageSize, onPageChange, pageSizes, onPageSizeChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width, striped, groupBy, groupSummary, stickyGroupHeadings, stickyTop, header: showHeader, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel, views, activeView, onViewChange, viewsLabel, columnsMenu, rowActions, phoneRow, limit, viewAll, }: DataTableProps<TData, TView>): import("react").JSX.Element;
398
+ export declare function DataTable<TData extends Record<string, unknown>, TView extends DataTableView = DataTableView>({ columns, data, total, page, pageSize, onPageChange, pageSizes, onPageSizeChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width, striped, groupBy, groupSummary, stickyGroupHeadings, stickyTop, header: showHeader, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel, views, activeView, onViewChange, viewsLabel, columnsMenu, rowActions, phoneRow, limit, viewAll, look, }: DataTableProps<TData, TView>): import("react").JSX.Element;
@@ -15,10 +15,10 @@ import { UNSAFE_LocationContext as LocationContext, UNSAFE_NavigationContext as
15
15
  import { flexRender } from '@tanstack/react-table';
16
16
  import { cn } from 'cn';
17
17
  import { getCoreRowModel, useLegacyTable } from '@tanstack/react-table/legacy';
18
- import { ArrowDownIcon, ArrowUpIcon, ArrowUpDownIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ListTreeIcon, TableIcon, XIcon, } from 'lucide-react';
18
+ import { ArrowDownIcon, ArrowUpIcon, ArrowUpDownIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ListTreeIcon, Settings2Icon, TableIcon, XIcon, } from 'lucide-react';
19
19
  import { ErrorState } from './error-state.js';
20
20
  import { Button } from '../ui/button.js';
21
- import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger, } from '../ui/dropdown-menu.js';
21
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger, } from '../ui/dropdown-menu.js';
22
22
  import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from '../ui/empty.js';
23
23
  import { Sheet, SheetContent, SheetHeader, SheetTitle } from '../ui/sheet.js';
24
24
  import { Skeleton } from '../ui/skeleton.js';
@@ -28,8 +28,9 @@ import { EditInPlaceContext } from './edit-in-place.js';
28
28
  import { EditInPlaceStore } from './edit-in-place-store.js';
29
29
  import { LeaveGuard } from './editable-value.js';
30
30
  import { recordDialogState } from './record-dialog-context.js';
31
+ import { IconAction } from './icon-action.js';
31
32
  import { groupByValues, groupRuns } from './table-groups.js';
32
- import { ColumnsMenu, PHONE_LIST_CLASS, PhoneRow, PhoneRowsSkeleton, RowActions, ViewAllLink, ViewPills, } from './data-table-tools.js';
33
+ import { ColumnsMenu, ColumnsMenuItems, PHONE_LIST_CLASS, PhoneRow, PhoneRowsSkeleton, RowActions, ViewAllLink, ViewPills, } from './data-table-tools.js';
33
34
  import { ROW_ACTIONS_COLUMN_ID, visibleFromPick } from './table-columns.js';
34
35
  import { useColumnsPick } from '../../hooks/use-columns-pick.js';
35
36
  import { useIsPhone } from '../../hooks/use-is-phone.js';
@@ -95,10 +96,38 @@ function LayoutSwitch({ options, value, onValueChange, }) {
95
96
  // a pick. Base UI's radio group needs a value for None, so it's this
96
97
  // stand-in, never '' (the grouping's own word for None).
97
98
  const NO_GROUPING = '__none__';
98
- function GroupMenu({ groupings, value, onValueChange, }) {
99
+ // The Group menu's items alone: its own menu's, and the framed look's
100
+ // settings menu's second group.
101
+ function GroupMenuItems({ groupings, value, onValueChange }) {
99
102
  const current = groupings.find((grouping) => grouping.id === value);
100
- return (_jsxs(DropdownMenu, { children: [_jsxs(DropdownMenuTrigger, { render: _jsx(Button, { variant: "outline", size: "sm", "data-slot": "data-table-group-menu" }), children: [_jsx(ListTreeIcon, { "aria-hidden": "true" }), current ? `Group: ${current.label}` : 'Group'] }), _jsx(DropdownMenuContent, { align: "end", className: "w-48", children: _jsxs(DropdownMenuGroup, { children: [_jsx(DropdownMenuLabel, { children: "Group By" }), _jsxs(DropdownMenuRadioGroup, { value: current?.id ?? NO_GROUPING, onValueChange: (next) => onValueChange(next === NO_GROUPING ? '' : String(next)), children: [_jsx(DropdownMenuRadioItem, { value: NO_GROUPING, closeOnClick: true, children: "None" }), groupings.map((grouping) => (_jsx(DropdownMenuRadioItem, { value: grouping.id, closeOnClick: true, children: grouping.label }, grouping.id)))] })] }) })] }));
103
+ return (_jsxs(DropdownMenuGroup, { children: [_jsx(DropdownMenuLabel, { children: "Group By" }), _jsxs(DropdownMenuRadioGroup, { value: current?.id ?? NO_GROUPING, onValueChange: (next) => onValueChange(next === NO_GROUPING ? '' : String(next)), children: [_jsx(DropdownMenuRadioItem, { value: NO_GROUPING, closeOnClick: true, children: "None" }), groupings.map((grouping) => (_jsx(DropdownMenuRadioItem, { value: grouping.id, closeOnClick: true, children: grouping.label }, grouping.id)))] })] }));
101
104
  }
105
+ function GroupMenu(props) {
106
+ const current = props.groupings.find((grouping) => grouping.id === props.value);
107
+ return (_jsxs(DropdownMenu, { children: [_jsxs(DropdownMenuTrigger, { render: _jsx(Button, { variant: "outline", size: "sm", "data-slot": "data-table-group-menu" }), children: [_jsx(ListTreeIcon, { "aria-hidden": "true" }), current ? `Group: ${current.label}` : 'Group'] }), _jsx(DropdownMenuContent, { align: "end", className: "w-48", children: _jsx(GroupMenuItems, { ...props }) })] }));
108
+ }
109
+ // The framed look's one settings button (`look="framed"`): the Columns
110
+ // ticks, then Group By, in one menu, in place of the two buttons with
111
+ // words. Its name says what's set that the bar no longer shows ("Table
112
+ // Settings, Grouped by Status"), and a dot on it says so to the eye.
113
+ function TableSettingsMenu({ columns, grouping, changed, }) {
114
+ const current = grouping?.groupings.find((each) => each.id === grouping.value);
115
+ const label = current ? `Table Settings, Grouped by ${current.label}` : 'Table Settings';
116
+ return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsx(IconAction, { icon: Settings2Icon, label: label, size: "sm", "data-tool": "table-settings", "data-set": current || changed ? true : undefined, className: SETTINGS_DOT_CLASS }) }), _jsxs(DropdownMenuContent, { align: "end", className: "w-56", children: [columns ? _jsx(ColumnsMenuItems, { ...columns }) : null, columns && grouping ? _jsx(DropdownMenuSeparator, {}) : null, grouping ? _jsx(GroupMenuItems, { ...grouping }) : null] })] }));
117
+ }
118
+ // The dot on the settings button while something in it is set: the
119
+ // primary colour, ringed in the button's own background so it reads on
120
+ // either theme. Decoration: the button's name says it in words.
121
+ const SETTINGS_DOT_CLASS = 'relative data-set:after:absolute data-set:after:top-0.5 data-set:after:right-0.5 data-set:after:size-2 ' +
122
+ 'data-set:after:rounded-full data-set:after:bg-primary data-set:after:ring-2 data-set:after:ring-background ' +
123
+ "data-set:after:content-['']";
124
+ // `look="framed"`: the card around the list, and its two bars. The card
125
+ // clips (never hides) its overflow, so the rounded corners hold and sticky
126
+ // headings still stick to the page.
127
+ const FRAME_CLASS = 'flex flex-col overflow-clip rounded-lg border border-border bg-background';
128
+ // The phone's row list inside the card: the card is its border.
129
+ const FRAMED_PHONE_ROWS_CLASS = '[&_[data-slot=data-table-phone-rows]_ul]:rounded-none [&_[data-slot=data-table-phone-rows]_ul]:border-0';
130
+ const FRAME_BAR_CLASS = 'flex flex-wrap items-center gap-x-4 gap-y-2 bg-card px-3 py-2.5 text-card-foreground max-md:gap-x-2';
102
131
  // The rows-per-page menu in the pagination bar (`pageSizes`): a radio list
103
132
  // that closes on a pick. The button says the size in words of its own
104
133
  // ("50 rows", as the list page standard drew it), and the menu says
@@ -383,7 +412,7 @@ const ROW_ACTIONS_COLUMN = {
383
412
  };
384
413
  // The cell under the actions' column: as narrow as its button.
385
414
  const ROW_ACTIONS_CELL_CLASS = 'w-px py-0';
386
- export function DataTable({ columns, data, total, page, pageSize, onPageChange, pageSizes, onPageSizeChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width = 'content', striped = false, groupBy, groupSummary, stickyGroupHeadings = false, stickyTop = '0px', header: showHeader = true, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel = 'Details', views, activeView = null, onViewChange, viewsLabel = 'Views', columnsMenu, rowActions, phoneRow, limit, viewAll, }) {
415
+ export function DataTable({ columns, data, total, page, pageSize, onPageChange, pageSizes, onPageSizeChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width = 'content', striped = false, groupBy, groupSummary, stickyGroupHeadings = false, stickyTop = '0px', header: showHeader = true, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel = 'Details', views, activeView = null, onViewChange, viewsLabel = 'Views', columnsMenu, rowActions, phoneRow, limit, viewAll, look = 'plain', }) {
387
416
  // The switch's own state, for a table that doesn't pass `layout`.
388
417
  const [ownLayout, setOwnLayout] = useState('table');
389
418
  const requestedLayout = layoutProp ?? ownLayout;
@@ -707,67 +736,99 @@ export function DataTable({ columns, data, total, page, pageSize, onPageChange,
707
736
  const viewAllTotal = viewAll?.total ?? total;
708
737
  // The row list a phone gets has no columns to pick.
709
738
  const showColumnsMenu = Boolean(columnsMenu) && !showPhoneRows;
710
- const content = (_jsxs("div", { ref: root, className: "flex flex-col gap-4", "data-width": width, "data-layout": layouts?.length ? currentLayout : undefined, children: [viewEntries.length > 0 ? (_jsx(ViewPills, { label: viewsLabel, views: viewEntries.map(([id, view]) => ({ id, label: view.label ?? id })), value: activeView, onValueChange: (id) => {
711
- const view = views?.[id];
712
- if (view)
713
- onViewChange?.(view, id);
714
- } })) : null, layouts?.length || groupings?.length || showColumnsMenu ? (_jsxs("div", { className: "flex flex-wrap items-end gap-x-4 gap-y-2", children: [_jsx("div", { className: "min-w-0 flex-1 basis-72", children: toolbar }), showColumnsMenu ? (_jsx(ColumnsMenu, { label: columnsMenu?.label, columns: menuColumns, visible: shownColumns ?? leafIds, fixed: fixedColumns, pick: columnsPick, onPickChange: setColumnsPick, setByView: viewColumns !== undefined })) : null, groupings?.length ? (_jsxs("div", { className: "flex items-center gap-2", children: [activeGrouping && (_jsx(Button, { variant: "ghost", size: "sm", "data-slot": "data-table-fold-all", disabled: !runs?.length, onClick: foldAll, children: allFolded ? 'Unfold All' : 'Fold All' })), _jsx(GroupMenu, { groupings: groupings, value: activeGrouping?.id ?? '', onValueChange: setGrouping })] })) : null, layouts?.length ? (_jsx(LayoutSwitch, { options: [
715
- { id: 'table', label: tableLayout?.label ?? 'Table', icon: tableLayout?.icon ?? TableIcon },
716
- ...layouts,
717
- ], value: currentLayout, onValueChange: setLayout })) : null] })) : (toolbar), _jsx("div", { ref: body, "data-slot": "data-table-body", className: cn('flex flex-col gap-4', fitsColumns && CONTENT_WIDTH_CLASS), style: fitsColumns && !isSuccessView && lastWidth !== null
718
- ? { '--data-table-last-width': `${lastWidth}px` }
719
- : undefined, children: error ? (_jsx(ErrorState, { error: error, onRetry: onRetry })) : isLoading || isPastLastPage ? (cardLayout ? (_jsx(CardsSkeleton, { layout: cardLayout })) : showPhoneRows ? (_jsx(PhoneRowsSkeleton, {})) : (_jsx(TableSkeleton, { columnCount: table.getVisibleLeafColumns().length }))) : isEmpty ? (_jsxs(Empty, { "data-state": "empty", children: [_jsxs(EmptyHeader, { children: [_jsx(EmptyTitle, { children: emptyTitle }), emptyDescription && _jsx(EmptyDescription, { children: emptyDescription })] }), emptyAction] })) : (_jsxs(DetailFrame, { enabled: Boolean(detailPanel) && !cardLayout, aside: selectedRow && detailPanel && isWide ? (_jsxs("aside", { "aria-label": detailLabel, "data-slot": "data-table-detail", className: DETAIL_ASIDE_CLASS, onKeyDown: (event) => {
720
- const target = event.target;
721
- if (event.key !== 'Escape' || event.defaultPrevented || target.closest(TYPING_SELECTOR))
722
- return;
723
- event.preventDefault();
724
- closeDetail();
725
- }, 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 })) : showPhoneRows ? (_jsx("div", { "data-state": "success", "data-slot": "data-table-phone-rows", className: "flex flex-col gap-4", children: runs
726
- ? runs.map((run, runIndex) => {
727
- const isFolded = folded.has(run.key);
728
- return (_jsxs("section", { "data-slot": "table-group", "data-folded": isFolded || undefined, className: "flex flex-col gap-2", children: [_jsxs("h2", { "data-slot": "table-group-heading", className: "flex items-baseline gap-2 px-1", 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 }) }))] }), !isFolded && phoneList(run.rows)] }, `${runIndex}:${run.key}`));
729
- })
730
- : phoneList(rows) })) : (_jsxs(Table, { "data-state": "success", containerRef: containerRef, onKeyDown: rowsOpen ? onListKeyDown : undefined, className: cn(stickyGroups && STICKY_FOCUS_CLASS), containerStyle: stickyGroups
731
- ? {
732
- '--data-table-head-height': `${headHeight}px`,
733
- '--data-table-sticky-top': stickyTop,
734
- '--data-table-pin-top': scrollsSideways ? '0px' : stickyTop,
735
- }
736
- : undefined,
737
- // With the sticky bar below as the visible scrollbar, hide the
738
- // container's own. It stays overflow-x-auto and fully
739
- // scrollable (wheel, trackpad, drag, and the sync effect); it
740
- // just no longer draws a bar directly under the last row.
741
- containerClassName: cn(
742
- // A size container has no width of its own to give, so
743
- // `width="content"` couldn't fit the table: there the
744
- // pinned column's `cqw` measures the table's area
745
- // (`@container/data-table`) instead.
746
- pinFirstColumn && width !== 'content' && '@container', pinFirstColumn && '[scrollbar-width:none] [&::-webkit-scrollbar]:hidden', 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) => {
747
- const canSort = header.column.getCanSort();
748
- const sortDirection = header.column.getIsSorted();
749
- // Hidden, a header is its name only: a sort button no
750
- // one can see would still take focus.
751
- const content = header.isPlaceholder ? null : canSort && showHeader ? (_jsxs("button", { type: "button", className: cn('flex items-center gap-1 text-foreground', header.column.columnDef.meta?.align === 'center' && 'w-full justify-center',
752
- // The arrow on the label's left, so the label's
753
- // right edge lines up with the numbers under it.
754
- 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()));
755
- return (_jsx(TableHead, { className: cn(!showHeader && HIDDEN_HEAD_CLASS, pinFirstColumn && index === 0 && PINNED_COLUMN_CLASS, pinLast &&
756
- index === headerGroup.headers.length - 1 &&
757
- PINNED_LAST_COLUMN_CLASS, stickyGroups && showHeader && STICKY_HEAD_CELL_CLASS, alignClass(header.column.columnDef.meta?.align)), "aria-sort": !canSort
758
- ? undefined
759
- : sortDirection === 'asc'
760
- ? 'ascending'
761
- : sortDirection === 'desc'
762
- ? 'descending'
763
- : '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));
764
- }) }, headerGroup.id))) }), runs ? (runs.map((run, runIndex) => {
765
- const isFolded = folded.has(run.key);
766
- return (_jsxs(TableBody, { "data-slot": "table-group", "data-folded": isFolded || undefined, className: cn(!striped && UNSTRIPED_BODY_CLASS), 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}`));
767
- })) : (_jsx(TableBody, { className: cn(!striped && UNSTRIPED_BODY_CLASS), 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) => {
768
- const className = cn(pinFirstColumn && index === 0 && PINNED_TOTALS_LABEL_CLASS, pinLast && index === visibleColumnCount - 1 && PINNED_LAST_COLUMN_CLASS, alignClass(column.columnDef.meta?.align));
769
- 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));
770
- }) }) }))] })), pinFirstColumn && isOverflowing && !cardLayout && !showPhoneRows && (_jsx("div", { ref: barRef, "aria-hidden": "true", tabIndex: -1, "data-slot": "bottom-scrollbar", className: "sticky bottom-0 z-20 h-4 overflow-x-auto border-t border-border bg-background", children: _jsx("div", { style: { width: scrollWidth, height: 1 } }) })), viewAll && limit !== undefined && viewAllTotal > rows.length ? (_jsx(ViewAllLink, { viewAll: viewAll, total: viewAllTotal, navigator: navigation?.navigator })) : null, limit === undefined && (_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-4 gap-y-2", "data-slot": "data-table-pagination", children: [_jsxs("p", { className: "type-body text-muted-foreground", children: [total === 0 ? 0 : (page - 1) * pageSize + 1, '–', Math.min(page * pageSize, total), " of ", total] }), _jsxs("div", { className: "flex items-center gap-2", children: [pageSizes && pageSizes.length > 1 && onPageSizeChange ? (_jsx(PageSizeMenu, { pageSizes: pageSizes, value: pageSize, onValueChange: onPageSizeChange })) : null, _jsx(Button, { variant: "outline", size: "icon-sm", "aria-label": "Previous Page", disabled: page <= 1, onClick: () => onPageChange(page - 1), children: _jsx(ChevronLeftIcon, {}) }), _jsxs("span", { className: "type-body text-muted-foreground", children: ["Page ", page, " of ", pageCount] }), _jsx(Button, { variant: "outline", size: "icon-sm", "aria-label": "Next Page", disabled: page >= pageCount, onClick: () => onPageChange(page + 1), children: _jsx(ChevronRightIcon, {}) })] })] }))] })) })] }));
739
+ // The pieces, placed as `look` says: plain, or a framed card.
740
+ const framed = look === 'framed';
741
+ const viewPills = (_jsx(_Fragment, { children: viewEntries.length > 0 ? (_jsx(ViewPills, { label: viewsLabel, views: viewEntries.map(([id, view]) => ({ id, label: view.label ?? id })), value: activeView, onValueChange: (id) => {
742
+ const view = views?.[id];
743
+ if (view)
744
+ onViewChange?.(view, id);
745
+ } })) : null }));
746
+ const foldAllButton = activeGrouping ? (_jsx(Button, { variant: "ghost", size: "sm", "data-slot": "data-table-fold-all", disabled: !runs?.length, onClick: foldAll, children: allFolded ? 'Unfold All' : 'Fold All' })) : null;
747
+ const columnsItems = showColumnsMenu
748
+ ? {
749
+ columns: menuColumns,
750
+ visible: shownColumns ?? leafIds,
751
+ fixed: fixedColumns,
752
+ pick: columnsPick,
753
+ onPickChange: setColumnsPick,
754
+ setByView: viewColumns !== undefined,
755
+ }
756
+ : undefined;
757
+ const layoutSwitch = layouts?.length ? (_jsx(LayoutSwitch, { options: [
758
+ { id: 'table', label: tableLayout?.label ?? 'Table', icon: tableLayout?.icon ?? TableIcon },
759
+ ...layouts,
760
+ ], value: currentLayout, onValueChange: setLayout })) : null;
761
+ const hasTools = Boolean(layouts?.length || groupings?.length || showColumnsMenu);
762
+ // `plain`: the toolbar, then the Columns and Group menus as buttons.
763
+ const plainToolbar = hasTools ? (_jsxs("div", { className: "flex flex-wrap items-end gap-x-4 gap-y-2", children: [_jsx("div", { className: "min-w-0 flex-1 basis-72", children: toolbar }), columnsItems ? _jsx(ColumnsMenu, { label: columnsMenu?.label, ...columnsItems }) : null, groupings?.length ? (_jsxs("div", { className: "flex items-center gap-2", children: [foldAllButton, _jsx(GroupMenu, { groupings: groupings, value: activeGrouping?.id ?? '', onValueChange: setGrouping })] })) : null, layoutSwitch] })) : (toolbar);
764
+ // `framed`: the card's top bar, one settings button in place of the two
765
+ // menus. Left out when there's nothing to put in it.
766
+ const framedToolbar = toolbar || hasTools ? (_jsxs("div", { "data-slot": "data-table-top-bar", className: cn(FRAME_BAR_CLASS, 'border-b border-border'), children: [_jsx("div", { className: "min-w-0 flex-1 basis-72 max-md:basis-0", children: toolbar }), hasTools ? (_jsxs("div", { className: "flex items-center gap-2", children: [foldAllButton, columnsItems || groupings?.length ? (_jsx(TableSettingsMenu, { columns: columnsItems, grouping: groupings?.length
767
+ ? { groupings, value: activeGrouping?.id ?? '', onValueChange: setGrouping }
768
+ : undefined, changed: Boolean(columnsItems && (columnsPick || viewColumns !== undefined)) })) : null, layoutSwitch] })) : null] })) : null;
769
+ // Loading, empty or failed: in place of the rows.
770
+ const stateView = error ? (_jsx(ErrorState, { error: error, onRetry: onRetry })) : isLoading || isPastLastPage ? (cardLayout ? (_jsx(CardsSkeleton, { layout: cardLayout })) : showPhoneRows ? (_jsx(PhoneRowsSkeleton, {})) : (_jsx(TableSkeleton, { columnCount: table.getVisibleLeafColumns().length }))) : isEmpty ? (_jsxs(Empty, { "data-state": "empty", children: [_jsxs(EmptyHeader, { children: [_jsx(EmptyTitle, { children: emptyTitle }), emptyDescription && _jsx(EmptyDescription, { children: emptyDescription })] }), emptyAction] })) : null;
771
+ const detailAside = !isSuccessView
772
+ ? null
773
+ : (selectedRow && detailPanel && isWide ? (_jsxs("aside", { "aria-label": detailLabel, "data-slot": "data-table-detail", className: DETAIL_ASIDE_CLASS, onKeyDown: (event) => {
774
+ const target = event.target;
775
+ if (event.key !== 'Escape' || event.defaultPrevented || target.closest(TYPING_SELECTOR))
776
+ return;
777
+ event.preventDefault();
778
+ closeDetail();
779
+ }, 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);
780
+ const rowsView = (_jsxs(_Fragment, { children: [cardLayout ? (_jsx(Cards, { layout: cardLayout, runs: runs, rows: rows, folded: folded, onToggleFold: toggleFold, groupSummary: groupSummary, groupIcons: groupIcons, onCardClick: onCardClick })) : showPhoneRows ? (_jsx("div", { "data-state": "success", "data-slot": "data-table-phone-rows", className: "flex flex-col gap-4", children: runs
781
+ ? runs.map((run, runIndex) => {
782
+ const isFolded = folded.has(run.key);
783
+ return (_jsxs("section", { "data-slot": "table-group", "data-folded": isFolded || undefined, className: "flex flex-col gap-2", children: [_jsxs("h2", { "data-slot": "table-group-heading", className: "flex items-baseline gap-2 px-1", 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 }) }))] }), !isFolded && phoneList(run.rows)] }, `${runIndex}:${run.key}`));
784
+ })
785
+ : phoneList(rows) })) : (_jsxs(Table, { "data-state": "success", containerRef: containerRef, onKeyDown: rowsOpen ? onListKeyDown : undefined, className: cn(stickyGroups && STICKY_FOCUS_CLASS), containerStyle: stickyGroups
786
+ ? {
787
+ '--data-table-head-height': `${headHeight}px`,
788
+ '--data-table-sticky-top': stickyTop,
789
+ '--data-table-pin-top': scrollsSideways ? '0px' : stickyTop,
790
+ }
791
+ : undefined,
792
+ // With the sticky bar below as the visible scrollbar, hide the
793
+ // container's own. It stays overflow-x-auto and fully
794
+ // scrollable (wheel, trackpad, drag, and the sync effect); it
795
+ // just no longer draws a bar directly under the last row.
796
+ containerClassName: cn(
797
+ // A size container has no width of its own to give, so
798
+ // `width="content"` couldn't fit the table: there the
799
+ // pinned column's `cqw` measures the table's area
800
+ // (`@container/data-table`) instead.
801
+ pinFirstColumn && width !== 'content' && '@container', pinFirstColumn && '[scrollbar-width:none] [&::-webkit-scrollbar]:hidden', 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) => {
802
+ const canSort = header.column.getCanSort();
803
+ const sortDirection = header.column.getIsSorted();
804
+ // Hidden, a header is its name only: a sort button no
805
+ // one can see would still take focus.
806
+ const content = header.isPlaceholder ? null : canSort && showHeader ? (_jsxs("button", { type: "button", className: cn('flex items-center gap-1 text-foreground', header.column.columnDef.meta?.align === 'center' && 'w-full justify-center',
807
+ // The arrow on the label's left, so the label's
808
+ // right edge lines up with the numbers under it.
809
+ 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()));
810
+ return (_jsx(TableHead, { className: cn(!showHeader && HIDDEN_HEAD_CLASS, pinFirstColumn && index === 0 && PINNED_COLUMN_CLASS, pinLast &&
811
+ index === headerGroup.headers.length - 1 &&
812
+ PINNED_LAST_COLUMN_CLASS, stickyGroups && showHeader && STICKY_HEAD_CELL_CLASS, alignClass(header.column.columnDef.meta?.align)), "aria-sort": !canSort
813
+ ? undefined
814
+ : sortDirection === 'asc'
815
+ ? 'ascending'
816
+ : sortDirection === 'desc'
817
+ ? 'descending'
818
+ : '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));
819
+ }) }, headerGroup.id))) }), runs ? (runs.map((run, runIndex) => {
820
+ const isFolded = folded.has(run.key);
821
+ return (_jsxs(TableBody, { "data-slot": "table-group", "data-folded": isFolded || undefined, className: cn(!striped && UNSTRIPED_BODY_CLASS), 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}`));
822
+ })) : (_jsx(TableBody, { className: cn(!striped && UNSTRIPED_BODY_CLASS), 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) => {
823
+ const className = cn(pinFirstColumn && index === 0 && PINNED_TOTALS_LABEL_CLASS, pinLast && index === visibleColumnCount - 1 && PINNED_LAST_COLUMN_CLASS, alignClass(column.columnDef.meta?.align));
824
+ 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));
825
+ }) }) }))] })), pinFirstColumn && isOverflowing && !cardLayout && !showPhoneRows && (_jsx("div", { ref: barRef, "aria-hidden": "true", tabIndex: -1, "data-slot": "bottom-scrollbar", className: "sticky bottom-0 z-20 h-4 overflow-x-auto border-t border-border bg-background", children: _jsx("div", { style: { width: scrollWidth, height: 1 } }) })), viewAll && limit !== undefined && viewAllTotal > rows.length ? (_jsx(ViewAllLink, { viewAll: viewAll, total: viewAllTotal, navigator: navigation?.navigator })) : null] }));
826
+ const pagination = limit === undefined ? (_jsxs("div", { className: cn('flex flex-wrap items-center justify-between gap-x-4 gap-y-2', framed && [FRAME_BAR_CLASS, 'border-t border-border py-2']), "data-slot": "data-table-pagination", children: [_jsxs("p", { className: "type-body text-muted-foreground", children: [total === 0 ? 0 : (page - 1) * pageSize + 1, '–', Math.min(page * pageSize, total), " of ", total] }), _jsxs("div", { className: "flex items-center gap-2", children: [pageSizes && pageSizes.length > 1 && onPageSizeChange ? (_jsx(PageSizeMenu, { pageSizes: pageSizes, value: pageSize, onValueChange: onPageSizeChange })) : null, _jsx(Button, { variant: "outline", size: "icon-sm", "aria-label": "Previous Page", disabled: page <= 1, onClick: () => onPageChange(page - 1), children: _jsx(ChevronLeftIcon, {}) }), _jsxs("span", { className: "type-body text-muted-foreground", children: ["Page ", page, " of ", pageCount] }), _jsx(Button, { variant: "outline", size: "icon-sm", "aria-label": "Next Page", disabled: page >= pageCount, onClick: () => onPageChange(page + 1), children: _jsx(ChevronRightIcon, {}) })] })] })) : null;
827
+ // `width="content"`'s last width, kept while another state shows.
828
+ const lastWidthStyle = fitsColumns && !isSuccessView && lastWidth !== null
829
+ ? { '--data-table-last-width': `${lastWidth}px` }
830
+ : undefined;
831
+ const content = framed ? (_jsxs("div", { ref: root, className: "flex flex-col gap-4", "data-width": width, "data-look": "framed", "data-layout": layouts?.length ? currentLayout : undefined, children: [viewPills, _jsx(DetailFrame, { enabled: Boolean(detailPanel) && !cardLayout, aside: detailAside, children: _jsxs("div", { ref: body, "data-slot": "data-table-frame", className: cn(FRAME_CLASS, fitsColumns && CONTENT_WIDTH_CLASS), style: lastWidthStyle, children: [framedToolbar, _jsx("div", { "data-slot": "data-table-body", className: cn('flex flex-col gap-4', (stateView || cardLayout) && 'p-3', showPhoneRows && !stateView && FRAMED_PHONE_ROWS_CLASS), children: stateView ?? rowsView }), stateView ? null : pagination] }) })] })) : (_jsxs("div", { ref: root, className: "flex flex-col gap-4", "data-width": width, "data-layout": layouts?.length ? currentLayout : undefined, children: [viewPills, plainToolbar, _jsx("div", { ref: body, "data-slot": "data-table-body", className: cn('flex flex-col gap-4', fitsColumns && CONTENT_WIDTH_CLASS), style: lastWidthStyle, children: stateView ?? (_jsxs(DetailFrame, { enabled: Boolean(detailPanel) && !cardLayout, aside: detailAside, children: [rowsView, pagination] })) })] }));
771
832
  return (_jsx(EditInPlaceContext.Provider, { value: store, children: _jsxs(RowActionsContext.Provider, { value: rowActions, children: [editing && _jsx(LeaveGuard, { store: store }), width === 'content' ? _jsx("div", { className: "@container/data-table", children: content }) : content, detailPanel && (_jsx(Sheet, { open: Boolean(selectedRow) && !isWide && isSuccessView && !cardLayout, onOpenChange: (open) => {
772
833
  if (!open)
773
834
  setSelection(null);
@@ -174,6 +174,18 @@ export type EntityViewProps = {
174
174
  * section of the record's own with this tab joins it.
175
175
  */
176
176
  detailsTab?: string;
177
+ /**
178
+ * Each tab's count, by its name (`{ Updates: 2, Linked: 1 }`): the
179
+ * records it holds, shown beside the name. A tab left out, or at 0,
180
+ * shows none.
181
+ */
182
+ tabCounts?: Readonly<Record<string, number>>;
183
+ /**
184
+ * How far from the top the tab bar sticks, for a page with a bar of its
185
+ * own pinned to the top: any CSS length (`'3.5rem'`,
186
+ * `'var(--page-bar-height)'`). Defaults to `0px`.
187
+ */
188
+ tabsStickyTop?: string;
177
189
  /**
178
190
  * In the `rail` layout, where its columns stack (a phone): the rail
179
191
  * before the main column (`rail-first`, the default), or the main column
@@ -233,4 +245,4 @@ export type EntityViewProps = {
233
245
  trail?: readonly PageCrumb[];
234
246
  };
235
247
  };
236
- export declare function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, sections, footer, layout, detailsTab, mobileOrder, railLabel, railFields, emptyFields, emptyText, printLabel, printLook, isLoading, error, onRetry, back, }: EntityViewProps): import("react").JSX.Element;
248
+ export declare function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, sections, footer, layout, detailsTab, tabCounts, tabsStickyTop, mobileOrder, railLabel, railFields, emptyFields, emptyText, printLabel, printLook, isLoading, error, onRetry, back, }: EntityViewProps): import("react").JSX.Element;
@@ -73,6 +73,15 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
73
73
  // sections stay mounted, hidden, so a field open in place survives a
74
74
  // switch. With no `tab` on any section, nothing changes.
75
75
  //
76
+ // The tab bar (4.101, record standard 3B): bigger underline tabs (16px
77
+ // semibold, 14px on a phone), a 3px primary line under the open one, each
78
+ // tab's count beside its name (`tabCounts`; none for zero). The bar sticks
79
+ // to the top of whatever scrolls (the page, or a record dialog's body) as
80
+ // the record scrolls under it, `tabsStickyTop` below the top, and once
81
+ // stuck it shows the record's name above the tabs, so the other tabs and
82
+ // the record you're on stay in view. Stuck is measured (a marker just
83
+ // above the bar, compared on every scroll), never guessed from the width.
84
+ //
76
85
  // `leading`, left of the title: the record's mark or avatar, with the
77
86
  // title, subtitle and badges beside it at every width. A rail field's
78
87
  // label sits to the left of its value (`railFields`, `beside` by default
@@ -258,7 +267,35 @@ function TabBody({ tab, railFields }) {
258
267
  // (hidden but mounted unless selected). The selected tab is the address's,
259
268
  // changed in place: the entry replaced, its state kept (a record over its
260
269
  // list stays the dialog), the scroll where it was.
261
- function MainTabs({ tabs, label, railFields = 'beside', }) {
270
+ // Whether the tab bar is stuck: the marker just above it has scrolled
271
+ // above the bar's top. Read on every scroll anywhere (a capture listener:
272
+ // the page's or a dialog body's) and on resize.
273
+ function useStuck() {
274
+ const [marker, setMarker] = useState(null);
275
+ const [bar, setBar] = useState(null);
276
+ const [stuck, setStuck] = useState(false);
277
+ useEffect(() => {
278
+ if (!marker || !bar)
279
+ return;
280
+ const measure = () => setStuck(marker.getBoundingClientRect().top < bar.getBoundingClientRect().top - 1);
281
+ measure();
282
+ window.addEventListener('scroll', measure, { capture: true, passive: true });
283
+ window.addEventListener('resize', measure);
284
+ return () => {
285
+ window.removeEventListener('scroll', measure, { capture: true });
286
+ window.removeEventListener('resize', measure);
287
+ };
288
+ }, [marker, bar]);
289
+ return { setMarker, setBar, stuck };
290
+ }
291
+ function MainTabs({ tabs, label, railFields = 'beside', title, counts, stickyTop, }) {
292
+ const { setMarker, setBar, stuck } = useStuck();
293
+ const countOf = (tab) => {
294
+ if (!counts)
295
+ return 0;
296
+ const key = Object.keys(counts).find((name) => entityViewTabSlug(name) === tab.slug);
297
+ return key ? counts[key] ?? 0 : 0;
298
+ };
262
299
  const location = useLocation();
263
300
  const navigate = useNavigate();
264
301
  const asked = new URLSearchParams(location.search).get(TAB_PARAM);
@@ -272,7 +309,13 @@ function MainTabs({ tabs, label, railFields = 'beside', }) {
272
309
  const search = params.toString();
273
310
  void navigate({ pathname: location.pathname, search: search ? `?${search}` : '', hash: location.hash }, { replace: true, state: location.state, preventScrollReset: true });
274
311
  };
275
- 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: "@container/tab flex min-w-0 flex-col gap-6 [font-size:inherit]", children: _jsx(TabBody, { tab: tab, railFields: railFields }) }, tab.slug)))] }));
312
+ return (_jsxs(Tabs, { value: selected, onValueChange: (value) => select(String(value)), "data-slot": "entity-view-tabs", className: "min-w-0 gap-6", children: [_jsx("div", { ref: setMarker, "aria-hidden": "true", "data-slot": "entity-view-tabs-marker", className: "h-px -mb-6" }), _jsxs("div", { ref: setBar, "data-slot": "entity-view-tab-bar", "data-stuck": stuck ? '' : undefined,
313
+ // A record dialog's body sets --entity-view-sticky-top to minus its
314
+ // padding, so the bar sits at the body's own top edge there.
315
+ style: { top: stickyTop ?? 'var(--entity-view-sticky-top, 0px)' }, className: "sticky z-10 -mx-1 flex min-w-0 flex-col gap-1 bg-background px-1 pt-0 data-[stuck]:pt-2 data-[stuck]:shadow-[0_8px_12px_-10px_var(--color-foreground)]", children: [stuck && title && (_jsx("p", { "data-slot": "entity-view-tab-bar-title", "aria-hidden": "true", className: "truncate type-label font-semibold text-foreground", children: title })), _jsx(TabsList, { variant: "line", activateOnFocus: true, "aria-label": label, className: "h-auto w-full max-w-full justify-start gap-0 overflow-x-auto overflow-y-hidden border-b border-border p-0 md:gap-1 [scrollbar-width:thin]", children: tabs.map((tab) => {
316
+ const count = countOf(tab);
317
+ return (_jsxs(TabsTrigger, { value: tab.slug, className: "h-11 flex-none gap-1.5 px-2.5 text-sm font-semibold text-muted-foreground group-data-horizontal/tabs:after:bottom-0 group-data-horizontal/tabs:after:h-[3px] after:bg-primary data-active:text-foreground md:px-4 md:text-base dark:text-muted-foreground dark:data-active:text-foreground", children: [tab.name, count > 0 && (_jsx("span", { "data-slot": "entity-view-tab-count", className: "rounded-full bg-muted px-1.5 text-xs leading-[1.0625rem] font-medium tabular-nums text-foreground", children: count }))] }, tab.slug));
318
+ }) })] }), tabs.map((tab) => (_jsx(TabsContent, { value: tab.slug, keepMounted: true, className: "@container/tab flex min-w-0 flex-col gap-6 [font-size:inherit]", children: _jsx(TabBody, { tab: tab, railFields: railFields }) }, tab.slug)))] }));
276
319
  }
277
320
  // The `tabs` layout's sections (1A): the main column's untabbed sections,
278
321
  // then the tab list, with the facts (placed `rail`, no tab) as the last
@@ -298,7 +341,7 @@ function tabsLayout(sections, detailsTab) {
298
341
  tabs.push({ slug, name: detailsTab, sections: facts, side: [], details: true });
299
342
  return { above: main.filter((section) => section.tab === undefined), tabs, factsInColumn: false };
300
343
  }
301
- export function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, sections, footer, layout = 'tabs', detailsTab = 'Details', mobileOrder = 'rail-first', railLabel, railFields = 'beside', emptyFields = 'show', emptyText = EMPTY_DASH, printLabel = 'Print Notes', printLook = 'icon', isLoading, error, onRetry, back, }) {
344
+ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, sections, footer, layout = 'tabs', detailsTab = 'Details', tabCounts, tabsStickyTop, mobileOrder = 'rail-first', railLabel, railFields = 'beside', emptyFields = 'show', emptyText = EMPTY_DASH, printLabel = 'Print Notes', printLook = 'icon', isLoading, error, onRetry, back, }) {
302
345
  // Editing in place: one store per view, and the leave-page prompt only
303
346
  // while a field is open (or one is always editable).
304
347
  const [store] = useState(() => new EditInPlaceStore());
@@ -346,7 +389,7 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
346
389
  const shaped = layout === 'tabs' ? tabsLayout(sections, detailsTab) : null;
347
390
  const tabs = shaped ? shaped.tabs : tabsOf(mainSections);
348
391
  const tabbed = (section) => section.placement !== 'rail' && section.tab !== undefined;
349
- const tabList = tabs.length > 0 && _jsx(MainTabs, { tabs: tabs, label: tabsLabel, railFields: railFields });
392
+ const tabList = tabs.length > 0 && (_jsx(MainTabs, { tabs: tabs, label: tabsLabel, railFields: railFields, title: title, counts: tabCounts, stickyTop: tabsStickyTop }));
350
393
  const main = (_jsxs("div", { className: cn(RAIL_LAYOUT.main, railSections.length === 0 && RAIL_LAYOUT.mainAlone), children: [mainSections
351
394
  .filter((section) => !tabbed(section))
352
395
  .map((section) => (_jsx(ViewSection, { section: section }, section.title))), tabList] }));
@@ -10,6 +10,19 @@ export type ListHeaderAction = {
10
10
  onSelect: () => void;
11
11
  icon?: IconComponent;
12
12
  };
13
+ /** One list in the `siblings` switch. */
14
+ export type ListHeaderSibling = {
15
+ label: string;
16
+ to: To;
17
+ /** How many records it holds, after its label. */
18
+ count?: number;
19
+ /**
20
+ * Whether it's the list showing. Left out, it's the one whose path is
21
+ * the page's (react-router's NavLink, `end`), so set it for siblings
22
+ * told apart by their query string.
23
+ */
24
+ current?: boolean;
25
+ };
13
26
  export type ListHeaderProps = {
14
27
  /** The list's name: the page's h1. */
15
28
  title: string;
@@ -39,6 +52,13 @@ export type ListHeaderProps = {
39
52
  onShownChange: (shown: boolean) => void;
40
53
  noun?: string;
41
54
  };
55
+ /**
56
+ * Lists that are this one's peers (4.100): a switch beside the title,
57
+ * this list among them. Two or more; fewer draws nothing.
58
+ */
59
+ siblings?: readonly ListHeaderSibling[];
60
+ /** The switch's landmark name: "<title> Lists" unless set. */
61
+ siblingsLabel?: string;
42
62
  className?: string;
43
63
  };
44
- export declare function ListHeader({ title, count, links, newAction, more, deleted, className }: ListHeaderProps): import("react").JSX.Element;
64
+ export declare function ListHeader({ title, count, links, newAction, more, deleted, siblings, siblingsLabel, className, }: ListHeaderProps): import("react").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  // A list page's header (list standard L12): the title with its count,
3
3
  // the New button alone beside it, and everything else behind one ⋯ menu.
4
4
  // The related screens (Board, Change log) stay out as buttons while
@@ -11,17 +11,36 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  // Holds no state: the app keeps `shown` (usually a URL filter). `links`
12
12
  // are routes, `more` are the app's own actions. The ⋯ button has an
13
13
  // accessible name and is left out when the menu would be empty.
14
+ //
15
+ // `siblings` (4.100) is a switch beside the title between lists that are
16
+ // one thing seen three ways (Exercises / Targets / Weak spots): links in a
17
+ // segmented row, the one on marked as the current page. They're the
18
+ // page's own peers, so they aren't in ⋯, which keeps only what's left
19
+ // (Show deleted). On a phone the switch takes its own line under the
20
+ // title and scrolls sideways if it must.
14
21
  import { EllipsisIcon, PlusIcon, Trash2Icon } from 'lucide-react';
15
- import { Link } from 'react-router';
22
+ import { Link, NavLink } from 'react-router';
16
23
  import { cn } from 'cn';
17
24
  import { Notice } from './notice.js';
18
25
  import { Button } from '../ui/button.js';
19
26
  import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from '../ui/dropdown-menu.js';
20
- export function ListHeader({ title, count, links = [], newAction, more = [], deleted, className }) {
27
+ // The switch: one bordered row, the current list filled. Each link is
28
+ // 32px tall (40 on a phone), its focus ring inside the row.
29
+ const SIBLING_CLASS = 'inline-flex min-h-8 shrink-0 items-center gap-1.5 border-r border-border px-3 type-body whitespace-nowrap ' +
30
+ 'text-muted-foreground outline-none last:border-r-0 hover:bg-muted hover:text-foreground ' +
31
+ 'focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:ring-inset max-md:min-h-10 ' +
32
+ 'aria-[current=page]:bg-muted aria-[current=page]:font-medium aria-[current=page]:text-foreground';
33
+ function SiblingSwitch({ siblings, label }) {
34
+ return (_jsx("nav", { "aria-label": label, "data-slot": "list-header-siblings", className: "max-w-full max-md:order-last max-md:basis-full max-md:overflow-x-auto", children: _jsx("div", { className: "inline-flex overflow-hidden rounded-md border border-border", children: siblings.map((sibling) => {
35
+ const inner = (_jsxs(_Fragment, { children: [sibling.label, sibling.count !== undefined && (_jsxs("span", { className: "tabular-nums", children: [_jsx("span", { className: "sr-only", children: ", " }), sibling.count] }))] }));
36
+ return sibling.current === undefined ? (_jsx(NavLink, { to: sibling.to, end: true, className: SIBLING_CLASS, children: inner }, sibling.label)) : (_jsx(Link, { to: sibling.to, "aria-current": sibling.current ? 'page' : undefined, className: SIBLING_CLASS, children: inner }, sibling.label));
37
+ }) }) }));
38
+ }
39
+ export function ListHeader({ title, count, links = [], newAction, more = [], deleted, siblings = [], siblingsLabel, className, }) {
21
40
  // One link is a button of its own; two or more go in the menu.
22
41
  const outLink = links.length === 1 ? links[0] : undefined;
23
42
  const menuLinks = links.length > 1 ? links : [];
24
43
  const hasMenu = menuLinks.length > 0 || more.length > 0 || deleted !== undefined;
25
- return (_jsxs("div", { "data-slot": "list-header", className: cn('flex flex-col', className), children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-4 gap-y-2", children: [_jsxs("h1", { className: "flex items-baseline gap-2 type-page-title text-foreground", children: [title, count !== undefined && (_jsxs("span", { className: "type-body font-normal tabular-nums text-muted-foreground", children: [_jsx("span", { className: "sr-only", children: ", " }), count] }))] }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [outLink && (_jsxs(Button, { size: "sm", variant: "outline", nativeButton: false, render: _jsx(Link, { to: outLink.to }), children: [outLink.icon && _jsx(outLink.icon, { "aria-hidden": "true" }), outLink.label] })), hasMenu && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsx(Button, { size: "icon-sm", variant: "outline", "aria-label": `More for ${title}`, "data-slot": "list-header-more" }), children: _jsx(EllipsisIcon, { "aria-hidden": "true" }) }), _jsxs(DropdownMenuContent, { align: "end", children: [menuLinks.map((link) => (_jsxs(DropdownMenuItem, { render: _jsx(Link, { to: link.to }), children: [link.icon && _jsx(link.icon, { "aria-hidden": "true" }), link.label] }, link.label))), more.map((action) => (_jsxs(DropdownMenuItem, { onClick: action.onSelect, children: [action.icon && _jsx(action.icon, { "aria-hidden": "true" }), action.label] }, action.label))), deleted && (menuLinks.length > 0 || more.length > 0) && _jsx(DropdownMenuSeparator, {}), deleted && (_jsxs(DropdownMenuCheckboxItem, { closeOnClick: true, checked: deleted.shown, onCheckedChange: deleted.onShownChange, children: [_jsx(Trash2Icon, { "aria-hidden": "true" }), "Show Deleted"] }))] })] })), newAction &&
44
+ return (_jsxs("div", { "data-slot": "list-header", className: cn('flex flex-col', className), children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-4 gap-y-2", children: [_jsxs("h1", { className: "flex items-baseline gap-2 type-page-title text-foreground", children: [title, count !== undefined && (_jsxs("span", { className: "type-body font-normal tabular-nums text-muted-foreground", children: [_jsx("span", { className: "sr-only", children: ", " }), count] }))] }), siblings.length > 1 && _jsx(SiblingSwitch, { siblings: siblings, label: siblingsLabel ?? `${title} Lists` }), _jsxs("div", { className: "ml-auto flex flex-wrap items-center gap-2", children: [outLink && (_jsxs(Button, { size: "sm", variant: "outline", nativeButton: false, render: _jsx(Link, { to: outLink.to }), children: [outLink.icon && _jsx(outLink.icon, { "aria-hidden": "true" }), outLink.label] })), hasMenu && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsx(Button, { size: "icon-sm", variant: "outline", "aria-label": `More for ${title}`, "data-slot": "list-header-more" }), children: _jsx(EllipsisIcon, { "aria-hidden": "true" }) }), _jsxs(DropdownMenuContent, { align: "end", children: [menuLinks.map((link) => (_jsxs(DropdownMenuItem, { render: _jsx(Link, { to: link.to }), children: [link.icon && _jsx(link.icon, { "aria-hidden": "true" }), link.label] }, link.label))), more.map((action) => (_jsxs(DropdownMenuItem, { onClick: action.onSelect, children: [action.icon && _jsx(action.icon, { "aria-hidden": "true" }), action.label] }, action.label))), deleted && (menuLinks.length > 0 || more.length > 0) && _jsx(DropdownMenuSeparator, {}), deleted && (_jsxs(DropdownMenuCheckboxItem, { closeOnClick: true, checked: deleted.shown, onCheckedChange: deleted.onShownChange, children: [_jsx(Trash2Icon, { "aria-hidden": "true" }), "Show Deleted"] }))] })] })), newAction &&
26
45
  (newAction.to !== undefined ? (_jsxs(Button, { size: "sm", nativeButton: false, render: _jsx(Link, { to: newAction.to }), children: [_jsx(PlusIcon, { "aria-hidden": "true" }), newAction.label] })) : (_jsxs(Button, { size: "sm", onClick: newAction.onClick, children: [_jsx(PlusIcon, { "aria-hidden": "true" }), newAction.label] })))] })] }), _jsx("div", { role: "status", "data-slot": "list-header-notice", className: "not-empty:mt-3", children: deleted?.shown && (_jsxs(Notice, { tone: "info", icon: Trash2Icon, action: _jsx(Button, { size: "sm", variant: "outline", onClick: () => deleted.onShownChange(false), children: "Back to the List" }), children: ["Showing deleted ", deleted.noun ?? 'records', "."] })) })] }));
27
46
  }
@@ -161,7 +161,12 @@ export function RecordDialogRoute({ list, label, className, look = 'record', ful
161
161
  return;
162
162
  }
163
163
  close();
164
- }, children: _jsxs(DialogContent, { showCloseButton: false, "aria-labelledby": titleId, "aria-label": label, "data-slot": "record-dialog", size: card ? 'confirm' : 'record', "data-look": look, className: cn('gap-0 overflow-hidden p-0 data-closed:hidden', card && 'flex max-h-[calc(100dvh-2rem)] flex-col', className), children: [!card && (_jsxs("div", { className: cn('flex items-center gap-2 border-b px-2 py-2', fullPage ? 'justify-between' : 'justify-end'), children: [fullPage && (_jsxs(Link, { to: { pathname: location.pathname, search: location.search, hash: location.hash }, replace: true, className: buttonVariants({ variant: 'ghost', size: 'sm' }), children: [_jsx(Maximize2Icon, { "aria-hidden": "true" }), "Open Full Page"] })), _jsxs(DialogClose, { render: _jsx(Button, { variant: "ghost", size: "icon-sm" }), children: [_jsx(XIcon, { "aria-hidden": "true" }), _jsx("span", { className: "sr-only", children: "Close" })] })] })), _jsx("div", { "data-slot": "record-dialog-body", className: cn('min-h-0 overflow-y-auto', card ? 'p-4 pb-[calc(1rem+env(safe-area-inset-bottom))] md:p-5' : 'p-4 sm:p-6'), children: _jsx(RecordDialogContext.Provider, { value: dialog, children: open && outlet }) })] }) })] }));
164
+ }, children: _jsxs(DialogContent, { showCloseButton: false, "aria-labelledby": titleId, "aria-label": label, "data-slot": "record-dialog", size: card ? 'confirm' : 'record', "data-look": look, className: cn('gap-0 overflow-hidden p-0 data-closed:hidden', card && 'flex max-h-[calc(100dvh-2rem)] flex-col', className), children: [!card && (_jsxs("div", { className: cn('flex items-center gap-2 border-b px-2 py-2', fullPage ? 'justify-between' : 'justify-end'), children: [fullPage && (_jsxs(Link, { to: { pathname: location.pathname, search: location.search, hash: location.hash }, replace: true, className: buttonVariants({ variant: 'ghost', size: 'sm' }), children: [_jsx(Maximize2Icon, { "aria-hidden": "true" }), "Open Full Page"] })), _jsxs(DialogClose, { render: _jsx(Button, { variant: "ghost", size: "icon-sm" }), children: [_jsx(XIcon, { "aria-hidden": "true" }), _jsx("span", { className: "sr-only", children: "Close" })] })] })), _jsx("div", { "data-slot": "record-dialog-body", className: cn('min-h-0 overflow-y-auto',
165
+ // A record's tab bar sticks to the body's top edge, not inside
166
+ // its padding (4.101): minus the padding, for EntityView.
167
+ card
168
+ ? 'p-4 pb-[calc(1rem+env(safe-area-inset-bottom))] [--entity-view-sticky-top:-1rem] md:p-5 md:[--entity-view-sticky-top:-1.25rem]'
169
+ : 'p-4 [--entity-view-sticky-top:-1rem] sm:p-6 sm:[--entity-view-sticky-top:-1.5rem]'), children: _jsx(RecordDialogContext.Provider, { value: dialog, children: open && outlet }) })] }) })] }));
165
170
  }
166
171
  /**
167
172
  * A link to a record that opens it over the current list (a board's card,
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ export { Artwork, ArtworkTag, ArtworkToggle, type ArtworkAspect, type ArtworkPro
9
9
  export { ColorSwatch, type ColorSwatchProps } from './components/app/color-swatch.js';
10
10
  export { storedColor } from './lib/stored-color.js';
11
11
  export { CountLink, type CountLinkProps } from './components/app/count-link.js';
12
- export { DataTable, type DataTableCardLayout, type DataTableOpens, type DataTableOpensKind, type DataTableGrouping, type DataTableProps, type DataTableTotals, type DataTableWidth, type SortingState, } from './components/app/data-table.js';
12
+ export { DataTable, type DataTableCardLayout, type DataTableOpens, type DataTableOpensKind, type DataTableGrouping, type DataTableLook, type DataTableProps, type DataTableTotals, type DataTableWidth, type SortingState, } from './components/app/data-table.js';
13
13
  export { type DataTableColumnsMenu, type DataTablePhoneRow, type DataTableRowAction, type DataTableView, type DataTableViewAll, } from './components/app/data-table-tools.js';
14
14
  export { RelatedTable, type RelatedTableProps } from './components/app/related-table.js';
15
15
  export { type RowGroup } from './components/app/table-groups.js';
@@ -74,7 +74,7 @@ export { AllowReminders, type AllowRemindersProps } from './components/app/allow
74
74
  export { StageCircle, type StageCircleProps, type StageCircleStage, type StageCircleTone, } from './components/app/stage-circle.js';
75
75
  export { Notice, type NoticeProps, type NoticeTone } from './components/app/notice.js';
76
76
  export { ValueList, type ValueListItem, type ValueListProps } from './components/app/value-list.js';
77
- export { ListHeader, type ListHeaderAction, type ListHeaderLink, type ListHeaderProps, } from './components/app/list-header.js';
77
+ export { ListHeader, type ListHeaderAction, type ListHeaderLink, type ListHeaderProps, type ListHeaderSibling, } from './components/app/list-header.js';
78
78
  export { Timeline, type TimelineItem, type TimelineProps } from './components/app/timeline.js';
79
79
  export { EqualItems, type EqualItem, type EqualItemField, type EqualItemState, type EqualItemTone, type EqualItemsLook, type EqualItemsProps, } from './components/app/equal-items.js';
80
80
  export { NeedsYou, type NeedsYouItem, type NeedsYouProps, type NeedsYouTone } from './components/app/needs-you.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "4.99.0",
3
+ "version": "4.101.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": {