@tristan2828/ui-foundation 4.105.0 → 4.106.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.
- package/conventions/docs/add-an-entity.md +41 -11
- package/conventions/docs/cell-patterns.md +22 -5
- package/conventions/docs/design-language.md +12 -10
- package/dist/components/app/data-table.d.ts +11 -1
- package/dist/components/app/data-table.js +6 -2
- package/dist/components/app/entity-view-facts.d.ts +69 -0
- package/dist/components/app/entity-view-facts.js +56 -0
- package/dist/components/app/entity-view.d.ts +25 -1
- package/dist/components/app/entity-view.js +28 -8
- package/dist/components/app/field-rows.d.ts +1 -0
- package/dist/components/app/field-rows.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -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–
|
|
19
|
-
- [The record view](#the-record-view) · lines 1002–
|
|
20
|
-
- [Forms](#forms) · lines
|
|
21
|
-
- [Dialogs](#dialogs) · lines
|
|
22
|
-
- [Toasts and feedback](#toasts-and-feedback) · lines
|
|
23
|
-
- [What not to copy](#what-not-to-copy) · lines
|
|
24
|
-
- [After a commit, in the backend](#after-a-commit-in-the-backend) · lines
|
|
25
|
-
- [Deleting](#deleting) · lines
|
|
26
|
-
- [Fields only a script writes](#fields-only-a-script-writes) · lines
|
|
27
|
-
- [Searching one part of the app](#searching-one-part-of-the-app) · lines
|
|
28
|
-
- [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines
|
|
18
|
+
- [How a list opens a record](#how-a-list-opens-a-record) · lines 849–1246
|
|
19
|
+
- [The record view](#the-record-view) · lines 1002–1096
|
|
20
|
+
- [Forms](#forms) · lines 1098–1163
|
|
21
|
+
- [Dialogs](#dialogs) · lines 1165–1196
|
|
22
|
+
- [Toasts and feedback](#toasts-and-feedback) · lines 1198–1246
|
|
23
|
+
- [What not to copy](#what-not-to-copy) · lines 1248–1280
|
|
24
|
+
- [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1282–1299
|
|
25
|
+
- [Deleting](#deleting) · lines 1301–1332
|
|
26
|
+
- [Fields only a script writes](#fields-only-a-script-writes) · lines 1334–1355
|
|
27
|
+
- [Searching one part of the app](#searching-one-part-of-the-app) · lines 1357–1366
|
|
28
|
+
- [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1369–1411
|
|
29
29
|
|
|
30
30
|
<!-- /index -->
|
|
31
31
|
|
|
@@ -1042,6 +1042,36 @@ A record uses the parts it has, in this order:
|
|
|
1042
1042
|
- **Facts beside their labels** (`railFields`, `beside` by default since
|
|
1043
1043
|
4.81), so the short facts read as a list of pairs rather than a column
|
|
1044
1044
|
of labels; keep labels to a word or two.
|
|
1045
|
+
- **The facts rail** (4.106, record standard A1): `factsRail` on the
|
|
1046
|
+
view puts the record's short facts in a 300px column beside the strip
|
|
1047
|
+
and the tabs where the view has room (60rem: a laptop's page, a record
|
|
1048
|
+
dialog), so the page doesn't end 900px in. Only short values go in it,
|
|
1049
|
+
and the API holds to that: a rail section is `facts`, not `fields`,
|
|
1050
|
+
each fact one of a few kinds, never free markup:
|
|
1051
|
+
|
|
1052
|
+
```tsx
|
|
1053
|
+
{ title: 'Facts', placement: 'rail', facts: [
|
|
1054
|
+
{ label: 'Status', kind: 'status', status: STATUS_KINDS[record.status], word: STATUS_LABELS[record.status] },
|
|
1055
|
+
{ label: 'By', kind: 'text', text: formatDay(record.due) },
|
|
1056
|
+
{ label: 'Areas', kind: 'badges', items: record.areas.map(areaLabel) },
|
|
1057
|
+
{ label: 'From', kind: 'record', name: provider.name, to: `/providers/${provider.id}`, short: true },
|
|
1058
|
+
{ label: 'Open Tasks', kind: 'count', count: record.openTasks, to: `/tasks?project=${record.id}` },
|
|
1059
|
+
{ label: 'Task', kind: 'link', href: task.url, name: task.name },
|
|
1060
|
+
] }
|
|
1061
|
+
```
|
|
1062
|
+
|
|
1063
|
+
- `text` is a date, a number or a person's name: one line, cut with
|
|
1064
|
+
its whole text on hover. `badges` are a few short labels.
|
|
1065
|
+
- A link to another record is `record`, and must say `short: true`:
|
|
1066
|
+
the app vouches its names are short (a person, a place). Records
|
|
1067
|
+
with long titles (a list of discussions, a log's entries) never go in
|
|
1068
|
+
the rail: they're a tab of their own, with its count.
|
|
1069
|
+
- Anything else (a sentence, a closing condition, notes) is a
|
|
1070
|
+
`fields` or `content` section: in Details, never the rail.
|
|
1071
|
+
- What's in the rail isn't repeated in Details. A Details tab left with
|
|
1072
|
+
nothing isn't drawn. On a phone (or a view under 60rem) the rail's
|
|
1073
|
+
sections are back in Details, as rows.
|
|
1074
|
+
- `edit` works on a fact as on a field; at rest it's drawn by its kind.
|
|
1045
1075
|
- **A tiny record** (4.98: a few fields and no notes, like a lookup's
|
|
1046
1076
|
row) opens as a small card: `RecordDialogRoute look="card"`, usually
|
|
1047
1077
|
with `fullPage={false}`. A 420px dialog (a sheet on a phone), its
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
- [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines 1811–1849
|
|
41
41
|
- [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1851–1927
|
|
42
42
|
- [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1929–1952
|
|
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 1954–
|
|
44
|
-
- [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2074–
|
|
45
|
-
- [26. A record's related list, capped](#26-a-records-related-list-capped) · lines
|
|
46
|
-
- [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines
|
|
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 1954–2129
|
|
44
|
+
- [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2074–2129
|
|
45
|
+
- [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2131–2167
|
|
46
|
+
- [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2169–2214
|
|
47
47
|
|
|
48
48
|
<!-- /index -->
|
|
49
49
|
|
|
@@ -2090,6 +2090,13 @@ The toolbar a list-page review picked (4.100): `look="framed"` on
|
|
|
2090
2090
|
<DataTable look="framed" views={VIEWS} columnsMenu={…} groupings={…} toolbar={<FilterBar … />} … />
|
|
2091
2091
|
```
|
|
2092
2092
|
|
|
2093
|
+
Since 4.106 (C3) the header goes in the table, as `pageHeader`, so the
|
|
2094
|
+
header row ends where the card does:
|
|
2095
|
+
|
|
2096
|
+
```tsx
|
|
2097
|
+
<DataTable look="framed" pageHeader={<ListHeader title="Exercises" … />} views={VIEWS} toolbar={…} … />
|
|
2098
|
+
```
|
|
2099
|
+
|
|
2093
2100
|
- **The card**: the toolbar in its top bar (search and Filters keep their
|
|
2094
2101
|
words), the rows, then the count and pager in its bottom bar. Saved
|
|
2095
2102
|
views sit above it, outside the bar. Loading, empty and error show
|
|
@@ -2097,6 +2104,14 @@ The toolbar a list-page review picked (4.100): `look="framed"` on
|
|
|
2097
2104
|
- **The tools end at the table's edge**: the card is as wide as `width`
|
|
2098
2105
|
makes the table, tools and pager with it, so nothing sits off at the
|
|
2099
2106
|
far right of a wide page. `width="full"` fills the area as before.
|
|
2107
|
+
- **So does the header** (4.106, C3), passed as `pageHeader`: the
|
|
2108
|
+
header (title, siblings, ⋯ and New), the views and the card are one
|
|
2109
|
+
box as wide as the table (CSS `fit-content` with the table's minimum
|
|
2110
|
+
and the page as its maximum; nothing is measured), so above a short
|
|
2111
|
+
table ⋯ and New sit over the card's right edge, and above a wide one
|
|
2112
|
+
where the page ends. A header wider than the table widens the card to
|
|
2113
|
+
match. `width="full"` and the phone's row list span the page as before.
|
|
2114
|
+
A ListHeader left outside the table spans the page, as before 4.106.
|
|
2100
2115
|
- **One settings button** in place of Columns and Group: the Columns
|
|
2101
2116
|
ticks, then Group By, in one menu. Its name says the grouping that's on
|
|
2102
2117
|
("Table Settings, Grouped by Status") and a dot marks it. Fold All
|
|
@@ -2109,7 +2124,9 @@ The toolbar a list-page review picked (4.100): `look="framed"` on
|
|
|
2109
2124
|
- The fixtures' `app/DataTable tools` Framed and `app/ListHeader`
|
|
2110
2125
|
Siblings stories hold it, under axe and the token check in both
|
|
2111
2126
|
themes; `e2e/data-table-framed.spec.ts` checks the edges, the menu
|
|
2112
|
-
from the mouse and the keyboard, the switch and the phone
|
|
2127
|
+
from the mouse and the keyboard, the switch and the phone, and
|
|
2128
|
+
`e2e/list-header-width.spec.ts` the header's edge at 1440 and 1920
|
|
2129
|
+
(`Header at the table edge` stories).
|
|
2113
2130
|
|
|
2114
2131
|
## 26. A record's related list, capped
|
|
2115
2132
|
|
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
- [A list as a board](#a-list-as-a-board) · lines 1236–1287
|
|
30
30
|
- [A list as cards](#a-list-as-cards) · lines 1289–1335
|
|
31
31
|
- [Key numbers on a record](#key-numbers-on-a-record) · lines 1337–1366
|
|
32
|
-
- [Parts of the page standards](#parts-of-the-page-standards) · lines 1368–
|
|
33
|
-
- [A few equal things](#a-few-equal-things) · lines
|
|
34
|
-
- [An overview page](#an-overview-page) · lines
|
|
35
|
-
- [A record's header and empty values](#a-records-header-and-empty-values) · lines
|
|
36
|
-
- [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines
|
|
37
|
-
- [Picking at random](#picking-at-random) · lines
|
|
38
|
-
- [Filling in what's missing](#filling-in-whats-missing) · lines
|
|
39
|
-
- [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines
|
|
40
|
-
- [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines
|
|
32
|
+
- [Parts of the page standards](#parts-of-the-page-standards) · lines 1368–1415
|
|
33
|
+
- [A few equal things](#a-few-equal-things) · lines 1417–1501
|
|
34
|
+
- [An overview page](#an-overview-page) · lines 1503–1566
|
|
35
|
+
- [A record's header and empty values](#a-records-header-and-empty-values) · lines 1567–1618
|
|
36
|
+
- [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1620–1688
|
|
37
|
+
- [Picking at random](#picking-at-random) · lines 1690–1721
|
|
38
|
+
- [Filling in what's missing](#filling-in-whats-missing) · lines 1723–1790
|
|
39
|
+
- [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1792–1817
|
|
40
|
+
- [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1819–1908
|
|
41
41
|
|
|
42
42
|
<!-- /index -->
|
|
43
43
|
|
|
@@ -1383,7 +1383,9 @@ into a table, a record or an overview.
|
|
|
1383
1383
|
`more` (the page's own actions). `deleted={{ shown, onShownChange }}` adds
|
|
1384
1384
|
"Show Deleted" as the menu's last item and, while it's on, an info
|
|
1385
1385
|
`Notice` with "Back to the List" in a `role="status"` region that is
|
|
1386
|
-
always there. It holds no state: the app keeps `shown`.
|
|
1386
|
+
always there. It holds no state: the app keeps `shown`. Passed as a
|
|
1387
|
+
framed DataTable's `pageHeader` (4.106, C3) it's as wide as the
|
|
1388
|
+
table, so ⋯ and New end on the card's right edge. The menu is as
|
|
1387
1389
|
wide as its longest item and never wraps one (4.105), as is a row's ⋯
|
|
1388
1390
|
menu.
|
|
1389
1391
|
- **`Timeline`: a record's dated history.** `items` newest first
|
|
@@ -278,6 +278,16 @@ export type DataTableProps<TData extends Record<string, unknown>, TView extends
|
|
|
278
278
|
onViewChange?: (view: TView, id: string) => void;
|
|
279
279
|
/** The pills' group name: "Views" unless set. */
|
|
280
280
|
viewsLabel?: string;
|
|
281
|
+
/**
|
|
282
|
+
* The list page's header (4.106, the list standard's C3): its
|
|
283
|
+
* `<ListHeader>`, drawn above the views. In the framed look with
|
|
284
|
+
* `width="content"` the header, the views and the card share one width,
|
|
285
|
+
* the table's, so the header's ⋯ and New end on the card's right edge
|
|
286
|
+
* above a short table instead of at the page's far edge. With
|
|
287
|
+
* `width="full"`, a table wider than the page, or the row list on a
|
|
288
|
+
* phone, it spans the page as before.
|
|
289
|
+
*/
|
|
290
|
+
pageHeader?: ReactNode;
|
|
281
291
|
/**
|
|
282
292
|
* A Columns menu at the end of the toolbar (L5): a tick for every column
|
|
283
293
|
* but the first (the name) and the row actions, remembered on this device
|
|
@@ -405,4 +415,4 @@ export type DataTableTotals = {
|
|
|
405
415
|
*/
|
|
406
416
|
cells?: Partial<Record<string, ReactNode>>;
|
|
407
417
|
};
|
|
408
|
-
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;
|
|
418
|
+
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, pageHeader, columnsMenu, rowActions, phoneRow, limit, viewAll, look, }: DataTableProps<TData, TView>): import("react").JSX.Element;
|
|
@@ -428,7 +428,7 @@ const ROW_ACTIONS_COLUMN = {
|
|
|
428
428
|
};
|
|
429
429
|
// The cell under the actions' column: as narrow as its button.
|
|
430
430
|
const ROW_ACTIONS_CELL_CLASS = 'w-px py-0';
|
|
431
|
-
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', }) {
|
|
431
|
+
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', pageHeader, columnsMenu, rowActions, phoneRow, limit, viewAll, look = 'plain', }) {
|
|
432
432
|
// The switch's own state, for a table that doesn't pass `layout`.
|
|
433
433
|
const [ownLayout, setOwnLayout] = useState('table');
|
|
434
434
|
const requestedLayout = layoutProp ?? ownLayout;
|
|
@@ -851,7 +851,11 @@ export function DataTable({ columns, data, total, page, pageSize, onPageChange,
|
|
|
851
851
|
const lastWidthStyle = fitsColumns && !isSuccessView && lastWidth !== null
|
|
852
852
|
? { '--data-table-last-width': `${lastWidth}px` }
|
|
853
853
|
: undefined;
|
|
854
|
-
|
|
854
|
+
// C3: with a header, the header, views and card are one box as wide as
|
|
855
|
+
// the table (the box fits its content, the card fills the box), so the
|
|
856
|
+
// header ends where the card does. CSS only: nothing is measured.
|
|
857
|
+
const sharedWidth = Boolean(pageHeader) && fitsColumns;
|
|
858
|
+
const content = framed ? (_jsxs("div", { ref: root, className: cn('flex flex-col gap-4', sharedWidth && CONTENT_WIDTH_CLASS), "data-width": width, "data-look": "framed", "data-shared-width": sharedWidth ? '' : undefined, "data-layout": layouts?.length ? currentLayout : undefined, children: [pageHeader, viewPills, _jsx(DetailFrame, { enabled: Boolean(detailPanel) && !cardLayout, aside: detailAside, children: _jsxs("div", { ref: body, "data-slot": "data-table-frame", className: cn(FRAME_CLASS, fitsColumns && !sharedWidth && 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: [pageHeader, 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] })) })] }));
|
|
855
859
|
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) => {
|
|
856
860
|
if (!open)
|
|
857
861
|
setSelection(null);
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { StatusKind } from '../../lib/status-kinds.js';
|
|
3
|
+
import type { EditInPlace } from './edit-in-place.js';
|
|
4
|
+
/** What a fact holds: one of the short kinds a rail can draw. */
|
|
5
|
+
export type EntityViewFactValue =
|
|
6
|
+
/** A status, drawn as its StatusMark; `word` is the status's own ("As needed"). */
|
|
7
|
+
{
|
|
8
|
+
kind: 'status';
|
|
9
|
+
status: StatusKind;
|
|
10
|
+
word?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Short text: a date, a number, a person's name. One line, cut with its whole text on hover. `null` is empty. */
|
|
13
|
+
| {
|
|
14
|
+
kind: 'text';
|
|
15
|
+
text: string | number | null | undefined;
|
|
16
|
+
}
|
|
17
|
+
/** A few short labels (areas, tags) as badges. None is empty. */
|
|
18
|
+
| {
|
|
19
|
+
kind: 'badges';
|
|
20
|
+
items: readonly string[];
|
|
21
|
+
}
|
|
22
|
+
/** A count, and where it links to, if anywhere (`/discussions?provider=3`). */
|
|
23
|
+
| {
|
|
24
|
+
kind: 'count';
|
|
25
|
+
count: number;
|
|
26
|
+
to?: string;
|
|
27
|
+
}
|
|
28
|
+
/** A link out of the app, its words `name`, opening in a new tab. */
|
|
29
|
+
| {
|
|
30
|
+
kind: 'link';
|
|
31
|
+
href: string;
|
|
32
|
+
name: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Another record, by a short `name` (a person's, a place's). `short: true`
|
|
36
|
+
* says the app knows its titles are short: a record whose titles run
|
|
37
|
+
* long (a discussion, a log entry) is a section in a tab instead.
|
|
38
|
+
*/
|
|
39
|
+
| {
|
|
40
|
+
kind: 'record';
|
|
41
|
+
name: string;
|
|
42
|
+
to: string;
|
|
43
|
+
short: true;
|
|
44
|
+
};
|
|
45
|
+
export type EntityViewFact = EntityViewFactValue & {
|
|
46
|
+
label: string;
|
|
47
|
+
/** What an empty value reads as, for this fact. Defaults to the view's `emptyText`. */
|
|
48
|
+
emptyLabel?: string;
|
|
49
|
+
/** Editable in place, as a field is (`inPlace.select`, `inPlace.date`); it's drawn by its kind at rest. */
|
|
50
|
+
edit?: EditInPlace;
|
|
51
|
+
};
|
|
52
|
+
/** A fact as the view draws it: `null` when empty. */
|
|
53
|
+
export declare function factValue(fact: EntityViewFactValue): ReactNode;
|
|
54
|
+
/** A facts section's facts as fields rows, for Details, the column and printing. */
|
|
55
|
+
export declare function factsAsFields(facts: readonly EntityViewFact[]): {
|
|
56
|
+
label: string;
|
|
57
|
+
value: ReactNode;
|
|
58
|
+
emptyLabel: string | undefined;
|
|
59
|
+
edit: EditInPlace | undefined;
|
|
60
|
+
}[];
|
|
61
|
+
/** The width the view needs for the facts rail beside its column: 60rem (the column ~40rem, a 300px rail, the gap). */
|
|
62
|
+
export declare const FACTS_RAIL_MIN_WIDTH = 960;
|
|
63
|
+
/**
|
|
64
|
+
* Whether the element's parent (the room the view has: the page's content
|
|
65
|
+
* area, or a dialog's body) is at least `min` px wide. A ResizeObserver
|
|
66
|
+
* measures it: its first report comes after layout and before paint, and
|
|
67
|
+
* then on every resize, so the rail and the Details tab never flash.
|
|
68
|
+
*/
|
|
69
|
+
export declare function useWideParent<T extends HTMLElement>(enabled: boolean, min?: number): readonly [import("react").Dispatch<import("react").SetStateAction<T | null>>, boolean];
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLayoutEffect, useState } from 'react';
|
|
3
|
+
import { Link } from 'react-router';
|
|
4
|
+
import { ExternalLinkIcon } from 'lucide-react';
|
|
5
|
+
import { cn } from 'cn';
|
|
6
|
+
import { Badge } from '../ui/badge.js';
|
|
7
|
+
import { StatusMark } from './status-mark.js';
|
|
8
|
+
const LINK_CLASS = 'rounded-sm font-medium text-link underline-offset-4 outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50';
|
|
9
|
+
/** A fact as the view draws it: `null` when empty. */
|
|
10
|
+
export function factValue(fact) {
|
|
11
|
+
switch (fact.kind) {
|
|
12
|
+
case 'status':
|
|
13
|
+
return _jsx(StatusMark, { kind: fact.status, children: fact.word });
|
|
14
|
+
case 'text': {
|
|
15
|
+
if (fact.text === null || fact.text === undefined || fact.text === '')
|
|
16
|
+
return null;
|
|
17
|
+
const text = String(fact.text);
|
|
18
|
+
return (_jsx("span", { "data-slot": "entity-view-fact-text", title: text, className: "inline-block max-w-full truncate align-bottom tabular-nums", children: text }));
|
|
19
|
+
}
|
|
20
|
+
case 'badges':
|
|
21
|
+
if (fact.items.length === 0)
|
|
22
|
+
return null;
|
|
23
|
+
return (_jsx("span", { className: "inline-flex max-w-full flex-wrap gap-1", children: fact.items.map((item) => (_jsx(Badge, { variant: "outline", className: "max-w-full truncate", children: item }, item))) }));
|
|
24
|
+
case 'count':
|
|
25
|
+
return fact.to ? (_jsx(Link, { to: fact.to, className: cn(LINK_CLASS, 'tabular-nums'), children: fact.count })) : (_jsx("span", { className: "tabular-nums", children: fact.count }));
|
|
26
|
+
case 'link':
|
|
27
|
+
return (_jsxs("a", { href: fact.href, target: "_blank", rel: "noreferrer", className: cn(LINK_CLASS, 'inline-flex max-w-full items-center gap-1'), children: [_jsx("span", { className: "truncate", children: fact.name }), _jsx(ExternalLinkIcon, { "aria-hidden": "true", className: "size-3.5 shrink-0" }), _jsx("span", { className: "sr-only", children: "(opens in a new tab)" })] }));
|
|
28
|
+
case 'record':
|
|
29
|
+
return (_jsx(Link, { to: fact.to, title: fact.name, className: cn(LINK_CLASS, 'inline-block max-w-full truncate align-bottom'), children: fact.name }));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** A facts section's facts as fields rows, for Details, the column and printing. */
|
|
33
|
+
export function factsAsFields(facts) {
|
|
34
|
+
return facts.map((fact) => ({ label: fact.label, value: factValue(fact), emptyLabel: fact.emptyLabel, edit: fact.edit }));
|
|
35
|
+
}
|
|
36
|
+
/** The width the view needs for the facts rail beside its column: 60rem (the column ~40rem, a 300px rail, the gap). */
|
|
37
|
+
export const FACTS_RAIL_MIN_WIDTH = 960;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the element's parent (the room the view has: the page's content
|
|
40
|
+
* area, or a dialog's body) is at least `min` px wide. A ResizeObserver
|
|
41
|
+
* measures it: its first report comes after layout and before paint, and
|
|
42
|
+
* then on every resize, so the rail and the Details tab never flash.
|
|
43
|
+
*/
|
|
44
|
+
export function useWideParent(enabled, min = FACTS_RAIL_MIN_WIDTH) {
|
|
45
|
+
const [node, setNode] = useState(null);
|
|
46
|
+
const [wide, setWide] = useState(false);
|
|
47
|
+
useLayoutEffect(() => {
|
|
48
|
+
const parent = node?.parentElement;
|
|
49
|
+
if (!enabled || !parent || typeof ResizeObserver === 'undefined')
|
|
50
|
+
return;
|
|
51
|
+
const observer = new ResizeObserver(() => setWide(parent.getBoundingClientRect().width >= min));
|
|
52
|
+
observer.observe(parent);
|
|
53
|
+
return () => observer.disconnect();
|
|
54
|
+
}, [node, enabled, min]);
|
|
55
|
+
return [setNode, enabled && wide];
|
|
56
|
+
}
|
|
@@ -2,6 +2,7 @@ import { type ReactNode } from 'react';
|
|
|
2
2
|
import type { AppError } from '../../api/contracts.js';
|
|
3
3
|
import { type EditInPlace, type EditInPlaceList } from './edit-in-place.js';
|
|
4
4
|
import { type PageCrumb } from './page-trail.js';
|
|
5
|
+
import { type EntityViewFact } from './entity-view-facts.js';
|
|
5
6
|
export type EntityViewField = {
|
|
6
7
|
label: string;
|
|
7
8
|
/**
|
|
@@ -30,6 +31,17 @@ export type EntityViewSection = ({
|
|
|
30
31
|
/** The section's heading (an <h2>). Unique on the page. */
|
|
31
32
|
title: string;
|
|
32
33
|
fields: EntityViewField[];
|
|
34
|
+
} | {
|
|
35
|
+
/** The section's heading. */
|
|
36
|
+
title: string;
|
|
37
|
+
/**
|
|
38
|
+
* Short facts only (4.106, A1): each a typed kind (a status, short
|
|
39
|
+
* text, badges, a count, a link, a short-named record), never free
|
|
40
|
+
* markup. Placed `rail` with no `tab`, the section goes in the facts
|
|
41
|
+
* rail beside the tabs where the view has room (`factsRail`), else
|
|
42
|
+
* in Details, as rows like `fields`.
|
|
43
|
+
*/
|
|
44
|
+
facts: EntityViewFact[];
|
|
33
45
|
} | {
|
|
34
46
|
title: string;
|
|
35
47
|
content: ReactNode;
|
|
@@ -208,6 +220,18 @@ export type EntityViewProps = {
|
|
|
208
220
|
printLook?: 'icon' | 'words';
|
|
209
221
|
/** The rail's landmark name (its `<aside>`). Defaults to the title + " details". */
|
|
210
222
|
railLabel?: string;
|
|
223
|
+
/**
|
|
224
|
+
* The facts rail (4.106, record standard A1), in the `tabs` layout:
|
|
225
|
+
* where the view has room (60rem beside it: a laptop's page, a record
|
|
226
|
+
* dialog), the sections of short facts (`facts`, placed `rail`, no
|
|
227
|
+
* `tab`) go in a 300px column beside the strip and the tabs, and leave
|
|
228
|
+
* Details; a Details tab left with nothing isn't drawn. Narrower (a
|
|
229
|
+
* phone), they're in Details as before. Sections with `fields` or
|
|
230
|
+
* `content` never go in it: a rail holds short values only.
|
|
231
|
+
*/
|
|
232
|
+
factsRail?: boolean;
|
|
233
|
+
/** The facts rail's landmark name (its `<aside>`). Defaults to the title + " facts". */
|
|
234
|
+
factsRailLabel?: string;
|
|
211
235
|
/**
|
|
212
236
|
* In the `rail` layout, a rail section's fields: each label to the left
|
|
213
237
|
* of its value (`beside`, the default since 4.81), falling back to
|
|
@@ -249,4 +273,4 @@ export type EntityViewProps = {
|
|
|
249
273
|
trail?: readonly PageCrumb[];
|
|
250
274
|
};
|
|
251
275
|
};
|
|
252
|
-
export declare function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, cardStrip, sections, footer, layout, detailsTab, tabCounts, tabsStickyTop, mobileOrder, railLabel, railFields, emptyFields, emptyText, printLabel, printLook, isLoading, error, onRetry, back, }: EntityViewProps): import("react").JSX.Element;
|
|
276
|
+
export declare function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, cardStrip, sections, footer, layout, detailsTab, tabCounts, tabsStickyTop, mobileOrder, railLabel, factsRail, factsRailLabel, railFields, emptyFields, emptyText, printLabel, printLook, isLoading, error, onRetry, back, }: EntityViewProps): import("react").JSX.Element;
|
|
@@ -118,6 +118,7 @@ import { FIELD_LABEL, FIELD_ROW, FIELD_ROW_BASE, FIELD_VALUE } from './field-row
|
|
|
118
118
|
import { PageTrail } from './page-trail.js';
|
|
119
119
|
import { usePageTrail } from './page-trail-context.js';
|
|
120
120
|
import { entityViewTabSlug } from '../../lib/entity-view-tab.js';
|
|
121
|
+
import { factsAsFields, useWideParent } from './entity-view-facts.js';
|
|
121
122
|
// The view's empty text and whether fields cards fold their empty ones,
|
|
122
123
|
// for every section without threading them through each layout.
|
|
123
124
|
const EmptyContext = createContext({ text: EMPTY_DASH, fold: false });
|
|
@@ -157,10 +158,10 @@ function FieldList({ fields, place }) {
|
|
|
157
158
|
const shown = emptyCount === 0 || open ? fields : fields.filter((field) => !isEmptyValue(fieldValue(field)));
|
|
158
159
|
return (_jsxs("div", { className: "flex flex-col gap-3", children: [shown.length > 0 && (_jsx("dl", { id: listId, className: "@container/fields flex flex-col divide-y divide-border", children: shown.map((field) => (_jsx(FieldRow, { field: field, place: place }, field.label))) })), emptyCount > 0 && (_jsxs("button", { type: "button", "data-slot": "entity-view-empty-toggle", "aria-expanded": open, "aria-controls": shown.length > 0 ? listId : undefined, onClick: () => setOpen((was) => !was), className: "inline-flex w-fit items-center gap-1 rounded-sm type-label text-muted-foreground underline underline-offset-3 outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 pointer-coarse:min-h-11", children: [open ? 'Hide Empty' : `${emptyCount} Empty`, _jsx(ChevronDownIcon, { "aria-hidden": "true", className: cn('size-3.5 transition-transform', open && 'rotate-180') })] }))] }));
|
|
159
160
|
}
|
|
160
|
-
function ViewSection({ section, inRail = false, railFields = 'beside', bare, }) {
|
|
161
|
+
function ViewSection({ section, inRail = false, railFields = 'beside', bare, factsRail = false, }) {
|
|
161
162
|
const headingId = useId();
|
|
162
163
|
const empty = useContext(EmptyContext);
|
|
163
|
-
const body = 'fields' in section ? (_jsx(FieldList, { fields: section.fields, place: !inRail ? 'page' : railFields === 'beside' ? 'railBeside' : 'rail' })) : 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 ?? empty.text })] })) : (_jsx("div", { className: "min-w-0 type-body break-words text-foreground", children: section.edit ? (_jsx(EditableValue, { label: section.title, edit: section.edit, children: _jsx(OrEmpty, { value: section.content, emptyLabel: section.emptyLabel }) })) : (_jsx(OrEmpty, { value: section.content, emptyLabel: section.emptyLabel })) }));
|
|
164
|
+
const body = 'fields' in section || 'facts' in section ? (_jsx(FieldList, { fields: 'fields' in section ? section.fields : factsAsFields(section.facts), place: factsRail ? 'facts' : !inRail ? 'page' : railFields === 'beside' ? 'railBeside' : 'rail' })) : 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 ?? empty.text })] })) : (_jsx("div", { className: "min-w-0 type-body break-words text-foreground", children: section.edit ? (_jsx(EditableValue, { label: section.title, edit: section.edit, children: _jsx(OrEmpty, { value: section.content, emptyLabel: section.emptyLabel }) })) : (_jsx(OrEmpty, { value: section.content, emptyLabel: section.emptyLabel })) }));
|
|
164
165
|
if (bare) {
|
|
165
166
|
return (_jsxs("section", { "aria-labelledby": headingId, "data-slot": "entity-view-bare-section", className: "flex flex-col gap-2", children: [_jsx("h2", { id: headingId, className: bare === 'hidden' ? 'sr-only' : 'type-label text-muted-foreground', children: section.title }), body] }));
|
|
166
167
|
}
|
|
@@ -184,6 +185,18 @@ const RAIL_LAYOUT = {
|
|
|
184
185
|
// is never stuck below the fold.
|
|
185
186
|
sticky: '@4xl/view:data-[fits]:sticky @4xl/view:data-[fits]:top-6',
|
|
186
187
|
};
|
|
188
|
+
// The facts rail (A1): the record's column at its usual reading width
|
|
189
|
+
// (max-w-4xl) and a 300px rail beside it, top-aligned with the strip.
|
|
190
|
+
const FACTS_RAIL = {
|
|
191
|
+
page: 'max-w-[calc(var(--container-4xl)+var(--spacing)*6+300px)]',
|
|
192
|
+
columns: 'grid grid-cols-[minmax(0,1fr)_300px] items-start gap-6',
|
|
193
|
+
main: 'flex min-w-0 flex-col gap-6',
|
|
194
|
+
rail: 'flex min-w-0 flex-col gap-6',
|
|
195
|
+
};
|
|
196
|
+
/** A section of short facts placed `rail` with no tab: the facts rail's, where it's drawn. */
|
|
197
|
+
function isRailFacts(section) {
|
|
198
|
+
return 'facts' in section && section.placement === 'rail' && section.tab === undefined;
|
|
199
|
+
}
|
|
187
200
|
function SkeletonCard({ rows, stacked }) {
|
|
188
201
|
return (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(Skeleton, { className: "h-5 w-32" }) }), _jsx(CardContent, { className: "flex flex-col gap-4", children: Array.from({ length: rows }, (_, row) => (_jsxs("div", { className: cn('flex flex-col gap-1', !stacked && 'sm:flex-row sm:gap-6'), children: [_jsx(Skeleton, { className: "h-5 w-32" }), _jsx(Skeleton, { className: cn('h-5', stacked ? 'w-full' : 'flex-1') })] }, row))) })] }));
|
|
189
202
|
}
|
|
@@ -342,7 +355,7 @@ function tabsLayout(sections, detailsTab) {
|
|
|
342
355
|
tabs.push({ slug, name: detailsTab, sections: facts, side: [], details: true });
|
|
343
356
|
return { above: main.filter((section) => section.tab === undefined), tabs, factsInColumn: false };
|
|
344
357
|
}
|
|
345
|
-
export function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, cardStrip = false, 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, }) {
|
|
358
|
+
export function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, cardStrip = false, sections, footer, layout = 'tabs', detailsTab = 'Details', tabCounts, tabsStickyTop, mobileOrder = 'rail-first', railLabel, factsRail = false, factsRailLabel, railFields = 'beside', emptyFields = 'show', emptyText = EMPTY_DASH, printLabel = 'Print Notes', printLook = 'icon', isLoading, error, onRetry, back, }) {
|
|
346
359
|
// Editing in place: one store per view, and the leave-page prompt only
|
|
347
360
|
// while a field is open (or one is always editable).
|
|
348
361
|
const [store] = useState(() => new EditInPlaceStore());
|
|
@@ -355,6 +368,8 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
|
|
|
355
368
|
// In the shell, the trail goes up in its bar; a dialog leaves the bar
|
|
356
369
|
// to the list under it.
|
|
357
370
|
const inShell = usePageTrail(dialog ? null : trail);
|
|
371
|
+
// The facts rail (A1): only in the tabs layout, never in a card dialog.
|
|
372
|
+
const [setRoot, wide] = useWideParent(factsRail && layout === 'tabs' && dialog?.look !== 'card');
|
|
358
373
|
if (error?.kind === 'notfound') {
|
|
359
374
|
// A record that doesn't exist and one that belongs to another user are
|
|
360
375
|
// the same plain 404, so this never says which. Retrying can't help.
|
|
@@ -368,9 +383,9 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
|
|
|
368
383
|
.filter((section) => section.print)
|
|
369
384
|
.map((section) => ({
|
|
370
385
|
title: section.title,
|
|
371
|
-
...('fields' in section
|
|
386
|
+
...('fields' in section || 'facts' in section
|
|
372
387
|
? {
|
|
373
|
-
fields: section.fields.map((field) => ({
|
|
388
|
+
fields: ('fields' in section ? section.fields : factsAsFields(section.facts)).map((field) => ({
|
|
374
389
|
label: field.label,
|
|
375
390
|
value: field.value !== undefined ? field.value : field.edit?.shown,
|
|
376
391
|
})),
|
|
@@ -387,7 +402,8 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
|
|
|
387
402
|
const card = dialog?.look === 'card';
|
|
388
403
|
// Tabs: in the `tabs` layout the facts are a tab of their own (1A); in
|
|
389
404
|
// the others a main section's `tab` (a rail one's is ignored).
|
|
390
|
-
const
|
|
405
|
+
const railFacts = wide && !card ? sections.filter(isRailFacts) : [];
|
|
406
|
+
const shaped = layout === 'tabs' ? tabsLayout(railFacts.length > 0 ? sections.filter((section) => !isRailFacts(section)) : sections, detailsTab) : null;
|
|
391
407
|
const tabs = shaped ? shaped.tabs : tabsOf(mainSections);
|
|
392
408
|
const tabbed = (section) => section.placement !== 'rail' && section.tab !== undefined;
|
|
393
409
|
const tabList = tabs.length > 0 && (_jsx(MainTabs, { tabs: tabs, label: tabsLabel, railFields: railFields, title: title, counts: tabCounts, stickyTop: tabsStickyTop }));
|
|
@@ -402,12 +418,16 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
|
|
|
402
418
|
body = (_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] }));
|
|
403
419
|
}
|
|
404
420
|
else if (shaped) {
|
|
405
|
-
|
|
421
|
+
const column = (_jsxs(_Fragment, { children: [shaped.above.map((section) => section.placement === 'rail' ? (_jsx(ViewSection, { section: section, inRail: true, railFields: railFields }, section.title)) : (_jsx(ViewSection, { section: section }, section.title))), tabList] }));
|
|
422
|
+
body =
|
|
423
|
+
railFacts.length > 0 ? (_jsxs("div", { "data-slot": "entity-view-with-facts", className: FACTS_RAIL.columns, children: [_jsxs("div", { className: FACTS_RAIL.main, children: [strip && _jsx("div", { "data-slot": "entity-view-strip", children: strip }), column] }), _jsx("aside", { "aria-label": factsRailLabel ?? `${title ?? 'Record'} facts`, "data-slot": "entity-view-facts-rail", className: FACTS_RAIL.rail, children: railFacts.map((section) => (_jsx(ViewSection, { section: section, inRail: true, factsRail: true }, section.title))) })] })) : (column);
|
|
406
424
|
}
|
|
407
425
|
else {
|
|
408
426
|
body = (_jsxs(_Fragment, { children: [sections
|
|
409
427
|
.filter((section) => !tabbed(section))
|
|
410
428
|
.map((section) => (_jsx(ViewSection, { section: section }, section.title))), tabList] }));
|
|
411
429
|
}
|
|
412
|
-
return (_jsx(EditInPlaceContext.Provider, { value: store, children: _jsx(EmptyContext.Provider, { value: { text: emptyText, fold: emptyFields === 'fold' }, children: _jsxs("div", {
|
|
430
|
+
return (_jsx(EditInPlaceContext.Provider, { value: store, children: _jsx(EmptyContext.Provider, { value: { text: emptyText, fold: emptyFields === 'fold' }, children: _jsxs("div", { ref: setRoot, className: layout === 'rail' && !card
|
|
431
|
+
? RAIL_LAYOUT.page
|
|
432
|
+
: cn('flex flex-col', railFacts.length > 0 ? FACTS_RAIL.page : 'max-w-4xl', card ? 'gap-4' : 'gap-6'), "data-facts-rail": railFacts.length > 0 ? '' : undefined, "data-state": "success", "data-layout": layout, "data-look": card ? 'card' : undefined, children: [editing && _jsx(LeaveGuard, { store: store }), !dialog && !trail && _jsx(BackLink, { back: back }), !dialog && trail && !inShell && _jsx(PageTrail, { crumbs: trail }), _jsxs("header", { className: card ? 'flex items-start justify-between gap-3' : 'flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between', children: [_jsxs("div", { className: cn('flex min-w-0 flex-1 items-start gap-3', !card && '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: [_jsxs("div", { "data-slot": "entity-view-title-line", className: "flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2", children: [_jsx("h1", { id: dialog?.titleId, className: cn('min-w-0 max-w-full break-words text-foreground', card ? 'type-section-title' : 'type-page-title'), children: titleEdit ? (_jsx(EditableField, { label: titleEdit.label, edit: titleEdit, layout: "inline", keepPencilRoom: true, children: title })) : (title) }), badges && (_jsx("div", { "data-slot": "entity-view-badges", className: "flex flex-wrap items-center gap-1.5", children: badges }))] }), subtitle && (_jsx("div", { "data-slot": "entity-view-subtitle", className: "type-body break-words text-muted-foreground", children: subtitle }))] })] }), card ? (_jsxs("div", { "data-slot": "entity-view-card-controls", className: "flex shrink-0 items-center gap-1", children: [printButton, actions, dialog?.controls] })) : ((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 && (!card || cardStrip) && railFacts.length === 0 && _jsx("div", { "data-slot": "entity-view-strip", children: strip }), body, footer && (_jsx("footer", { "data-slot": "entity-view-footer", className: "type-caption text-muted-foreground", children: footer }))] }) }) }));
|
|
413
433
|
}
|
|
@@ -18,6 +18,9 @@ export const FIELD_ROW = {
|
|
|
18
18
|
page: 'sm:@sm/fields:grid sm:@sm/fields:grid-cols-[minmax(--spacing(32),--spacing(48))_minmax(0,1fr)] sm:@sm/fields:gap-6',
|
|
19
19
|
rail: '@lg/fields:grid @lg/fields:grid-cols-[minmax(--spacing(32),--spacing(48))_1fr] @lg/fields:gap-6',
|
|
20
20
|
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',
|
|
21
|
+
// The facts rail (4.106, A1): a 300px card, so side by side from a
|
|
22
|
+
// 16rem list, the label column a little narrower again.
|
|
23
|
+
facts: '@3xs/fields:grid @3xs/fields:grid-cols-[--spacing(24)_minmax(0,1fr)] @3xs/fields:items-baseline @3xs/fields:gap-3 @3xs/fields:py-2.5',
|
|
21
24
|
};
|
|
22
25
|
/** A row's own spacing, before its place's grid. */
|
|
23
26
|
export const FIELD_ROW_BASE = 'flex flex-col gap-1 py-3 first:pt-0 last:pb-0';
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export { EmptyText, type EmptyTextProps } from './components/app/empty-value.js'
|
|
|
28
28
|
export { isEmptyValue } from './lib/empty-value.js';
|
|
29
29
|
export { IconAction, type IconActionProps } from './components/app/icon-action.js';
|
|
30
30
|
export { EntityView, type EntityViewEmptyFields, type EntityViewField, type EntityViewLayout, type EntityViewMobileOrder, type EntityViewPlacement, type EntityViewProps, type EntityViewRailFields, type EntityViewSection, } from './components/app/entity-view.js';
|
|
31
|
+
export { type EntityViewFact, type EntityViewFactValue } from './components/app/entity-view-facts.js';
|
|
31
32
|
export { entityViewTabSlug } from './lib/entity-view-tab.js';
|
|
32
33
|
export { usePrinting } from './components/app/print-context.js';
|
|
33
34
|
export { RecordDialogRoute, RecordLink, type RecordDialogRouteProps, type RecordLinkProps, } from './components/app/record-dialog.js';
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,7 @@ export { EmptyText } from './components/app/empty-value.js';
|
|
|
34
34
|
export { isEmptyValue } from './lib/empty-value.js';
|
|
35
35
|
export { IconAction } from './components/app/icon-action.js';
|
|
36
36
|
export { EntityView, } from './components/app/entity-view.js';
|
|
37
|
+
export {} from './components/app/entity-view-facts.js';
|
|
37
38
|
export { entityViewTabSlug } from './lib/entity-view-tab.js';
|
|
38
39
|
export { usePrinting } from './components/app/print-context.js';
|
|
39
40
|
export { RecordDialogRoute, RecordLink, } from './components/app/record-dialog.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.106.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": {
|