@tristan2828/ui-foundation 4.93.0 → 4.94.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 +19 -13
- package/conventions/docs/cell-patterns.md +21 -17
- package/conventions/docs/design-language.md +65 -24
- package/dist/components/app/editable-value.js +6 -1
- package/dist/components/app/entity-view.js +1 -1
- package/dist/components/app/equal-items.d.ts +21 -3
- package/dist/components/app/equal-items.js +41 -12
- package/package.json +1 -1
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
- Step 8: Add Playwright specs for all three screens · lines 736–814
|
|
16
16
|
- Step 9: Register the nav entry and route names · lines 815–829
|
|
17
17
|
- Step 10: `npm run verify`. · lines 830–832
|
|
18
|
-
- [How a list opens a record](#how-a-list-opens-a-record) · lines 834–
|
|
19
|
-
- [The record view](#the-record-view) · lines 983–
|
|
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 834–1153
|
|
19
|
+
- [The record view](#the-record-view) · lines 983–1031
|
|
20
|
+
- [Forms](#forms) · lines 1033–1085
|
|
21
|
+
- [Dialogs](#dialogs) · lines 1087–1112
|
|
22
|
+
- [Toasts and feedback](#toasts-and-feedback) · lines 1114–1153
|
|
23
|
+
- [What not to copy](#what-not-to-copy) · lines 1155–1181
|
|
24
|
+
- [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1183–1200
|
|
25
|
+
- [Deleting](#deleting) · lines 1202–1233
|
|
26
|
+
- [Fields only a script writes](#fields-only-a-script-writes) · lines 1235–1256
|
|
27
|
+
- [Searching one part of the app](#searching-one-part-of-the-app) · lines 1258–1267
|
|
28
|
+
- [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1270–1312
|
|
29
29
|
|
|
30
30
|
<!-- /index -->
|
|
31
31
|
|
|
@@ -1020,7 +1020,10 @@ view reaches them all. A record uses the parts it has, in this order:
|
|
|
1020
1020
|
per set: `cards` for little to say about each, `table` for things
|
|
1021
1021
|
compared on the same values, `featured` when one is current or best,
|
|
1022
1022
|
`panels` when each has several details (design-language.md "A few
|
|
1023
|
-
equal things"). Never hand-made cards or a grid of their own.
|
|
1023
|
+
equal things"). Never hand-made cards or a grid of their own. An item
|
|
1024
|
+
edited or removed on its own carries its editor as `content` and its
|
|
1025
|
+
Edit and Remove as `actions` (4.94), `wide` while the editor is open;
|
|
1026
|
+
never an editor put in a field's value.
|
|
1024
1027
|
- **A big record's own parts** (a drawing, a player, a checklist of
|
|
1025
1028
|
documents) are sections in the view, not a screen of their own.
|
|
1026
1029
|
|
|
@@ -1279,7 +1282,10 @@ Four more things an app sets for AI chats (4.71), each in
|
|
|
1279
1282
|
must be found exactly once (missing, or found twice, is a refusal that
|
|
1280
1283
|
says so and saves nothing), or `append` adds text on a new line at the
|
|
1281
1284
|
end. It saves and logs as `update` does, so a long note isn't sent back
|
|
1282
|
-
whole to change a line.
|
|
1285
|
+
whole to change a line. A table's widths comment (design-language.md
|
|
1286
|
+
"Written text (notes)") is hidden from every read answer and kept
|
|
1287
|
+
in what's stored, so an edit never drops it (4.94); `search` leaves
|
|
1288
|
+
out a record whose only match is inside it. Each must be a text field of `update_schema`
|
|
1283
1289
|
and not `script_only`; the backend refuses to start otherwise.
|
|
1284
1290
|
- **The server's instructions** a chat gets when it connects:
|
|
1285
1291
|
`register_entities(ENTITIES, instructions="…")` (or
|
|
@@ -26,22 +26,22 @@
|
|
|
26
26
|
- [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 618–701
|
|
27
27
|
- [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 703–738
|
|
28
28
|
- [17. Quick action on the view](#17-quick-action-on-the-view) · lines 740–813
|
|
29
|
-
- [18. Editable value](#18-editable-value) · lines 815–
|
|
30
|
-
- [Presets: one line per field](#presets-one-line-per-field) · lines
|
|
31
|
-
- [Several fields edited as one](#several-fields-edited-as-one) · lines
|
|
32
|
-
- [A link and its label](#a-link-and-its-label) · lines
|
|
33
|
-
- [A list of sub-items](#a-list-of-sub-items) · lines
|
|
34
|
-
- [In a table's rows](#in-a-tables-rows) · lines
|
|
35
|
-
- [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines
|
|
36
|
-
- [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines
|
|
37
|
-
- [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines
|
|
38
|
-
- [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines
|
|
39
|
-
- [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines
|
|
40
|
-
- [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines
|
|
41
|
-
- [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines
|
|
42
|
-
- [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · 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
|
|
44
|
-
- [26. A record's related list, capped](#26-a-records-related-list-capped) · lines
|
|
29
|
+
- [18. Editable value](#18-editable-value) · lines 815–1493
|
|
30
|
+
- [Presets: one line per field](#presets-one-line-per-field) · lines 1125–1193
|
|
31
|
+
- [Several fields edited as one](#several-fields-edited-as-one) · lines 1195–1231
|
|
32
|
+
- [A link and its label](#a-link-and-its-label) · lines 1233–1257
|
|
33
|
+
- [A list of sub-items](#a-list-of-sub-items) · lines 1259–1392
|
|
34
|
+
- [In a table's rows](#in-a-tables-rows) · lines 1394–1479
|
|
35
|
+
- [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1481–1493
|
|
36
|
+
- [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1495–1561
|
|
37
|
+
- [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1563–1627
|
|
38
|
+
- [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1629–1727
|
|
39
|
+
- [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1729–1758
|
|
40
|
+
- [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines 1760–1798
|
|
41
|
+
- [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1800–1876
|
|
42
|
+
- [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1878–1901
|
|
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 1903–1989
|
|
44
|
+
- [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 1991–2027
|
|
45
45
|
|
|
46
46
|
<!-- /index -->
|
|
47
47
|
|
|
@@ -849,7 +849,11 @@ on that tint, since muted on `bg-muted` is under 4.5:1; the package does
|
|
|
849
849
|
it, so an app just uses `text-muted-foreground` as anywhere else. On a
|
|
850
850
|
touch screen the pencil always shows. A click anywhere on the value opens it, except on a
|
|
851
851
|
link inside it (a reference to a record with a view, a link in the
|
|
852
|
-
notes), which still navigates.
|
|
852
|
+
notes), which still navigates. The tint reaches 0.375rem past the value
|
|
853
|
+
on each side without moving it, and never wraps it: a short title or
|
|
854
|
+
badge edited in place (`layout="inline"`) stays on one line, and a long
|
|
855
|
+
one wraps between words within its column (4.94; before, a title like
|
|
856
|
+
"Dr. Example" broke over two lines).
|
|
853
857
|
|
|
854
858
|
**In a field list, the row is the target** (4.88, `look="row"`, which
|
|
855
859
|
EntityView's field rows use). The row wears the list's row hover, the
|
|
@@ -15,27 +15,27 @@
|
|
|
15
15
|
- [Depth ramps](#depth-ramps) · lines 454–539
|
|
16
16
|
- [A stored colour](#a-stored-colour) · lines 541–589
|
|
17
17
|
- [Shapes and sizes](#shapes-and-sizes) · lines 591–612
|
|
18
|
-
- [Typography](#typography) · lines 614–
|
|
19
|
-
- [Written text (notes)](#written-text-notes) · lines 648–
|
|
20
|
-
- [Density](#density) · lines
|
|
21
|
-
- [Rows on this device](#rows-on-this-device) · lines
|
|
22
|
-
- [Widget cards (hub pages)](#widget-cards-hub-pages) · lines
|
|
23
|
-
- [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines
|
|
24
|
-
- [Notices](#notices) · lines
|
|
25
|
-
- [A value over time](#a-value-over-time) · lines
|
|
26
|
-
- [Several values over time](#several-values-over-time) · lines
|
|
27
|
-
- [A list as a board](#a-list-as-a-board) · lines
|
|
28
|
-
- [A list as cards](#a-list-as-cards) · lines
|
|
29
|
-
- [Key numbers on a record](#key-numbers-on-a-record) · lines
|
|
30
|
-
- [Parts of the page standards](#parts-of-the-page-standards) · lines
|
|
31
|
-
- [A few equal things](#a-few-equal-things) · lines
|
|
32
|
-
- [An overview page](#an-overview-page) · lines
|
|
33
|
-
- [A record's header and empty values](#a-records-header-and-empty-values) · lines
|
|
34
|
-
- [A record's tabs, mark and rail](#a-records-tabs-mark-and-rail) · lines
|
|
35
|
-
- [Picking at random](#picking-at-random) · lines
|
|
36
|
-
- [Filling in what's missing](#filling-in-whats-missing) · lines
|
|
37
|
-
- [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines
|
|
38
|
-
- [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines
|
|
18
|
+
- [Typography](#typography) · lines 614–736
|
|
19
|
+
- [Written text (notes)](#written-text-notes) · lines 648–736
|
|
20
|
+
- [Density](#density) · lines 738–831
|
|
21
|
+
- [Rows on this device](#rows-on-this-device) · lines 804–831
|
|
22
|
+
- [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 833–947
|
|
23
|
+
- [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 949–1026
|
|
24
|
+
- [Notices](#notices) · lines 1028–1056
|
|
25
|
+
- [A value over time](#a-value-over-time) · lines 1058–1144
|
|
26
|
+
- [Several values over time](#several-values-over-time) · lines 1107–1144
|
|
27
|
+
- [A list as a board](#a-list-as-a-board) · lines 1146–1197
|
|
28
|
+
- [A list as cards](#a-list-as-cards) · lines 1199–1245
|
|
29
|
+
- [Key numbers on a record](#key-numbers-on-a-record) · lines 1247–1276
|
|
30
|
+
- [Parts of the page standards](#parts-of-the-page-standards) · lines 1278–1321
|
|
31
|
+
- [A few equal things](#a-few-equal-things) · lines 1323–1407
|
|
32
|
+
- [An overview page](#an-overview-page) · lines 1409–1472
|
|
33
|
+
- [A record's header and empty values](#a-records-header-and-empty-values) · lines 1473–1511
|
|
34
|
+
- [A record's tabs, mark and rail](#a-records-tabs-mark-and-rail) · lines 1513–1558
|
|
35
|
+
- [Picking at random](#picking-at-random) · lines 1560–1591
|
|
36
|
+
- [Filling in what's missing](#filling-in-whats-missing) · lines 1593–1660
|
|
37
|
+
- [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1662–1687
|
|
38
|
+
- [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1689–1762
|
|
39
39
|
|
|
40
40
|
<!-- /index -->
|
|
41
41
|
|
|
@@ -686,7 +686,9 @@ least), a column's menu has Narrower, Wider, Fit to content and Fit all
|
|
|
686
686
|
columns, and a double-click on the edge fits it again. The width is kept
|
|
687
687
|
in the Markdown as a comment after the table, naming its columns
|
|
688
688
|
(`<!-- table widths: Item=140, Cost=72 -->`), which `<Markdown>` and the
|
|
689
|
-
editor read and never show
|
|
689
|
+
editor read and never show; nor do the backend's MCP read tools (4.94:
|
|
690
|
+
`fetch`, `list`, `search`, and `update`'s answer), while `edit_text` and
|
|
691
|
+
`update` keep it in what's stored. A column named nowhere fits its words. A
|
|
690
692
|
phone ignores the widths and can't set them; on paper they scale to the
|
|
691
693
|
page.
|
|
692
694
|
|
|
@@ -1361,9 +1363,48 @@ one look per set; a fifth is asked for first.
|
|
|
1361
1363
|
reader (the list's name, the table's caption); titles are `h3` under a
|
|
1362
1364
|
section's `h2` (`headingLevel`).
|
|
1363
1365
|
|
|
1366
|
+
**An item's own content and actions** (4.94). When an item holds more
|
|
1367
|
+
than label/value rows (an editor of several fields, a note, a chart), it
|
|
1368
|
+
carries them itself, never as a field's value, where the label/value grid
|
|
1369
|
+
squeezes them into its narrow value column:
|
|
1370
|
+
|
|
1371
|
+
```tsx
|
|
1372
|
+
items={stores.map((store) => ({
|
|
1373
|
+
id: store.id,
|
|
1374
|
+
title: store.name,
|
|
1375
|
+
fields: editing === store.id ? undefined : [{ label: 'Price', value: store.price }],
|
|
1376
|
+
content: editing === store.id && <StoreEditor store={store} onDone={stopEditing} />,
|
|
1377
|
+
wide: editing === store.id,
|
|
1378
|
+
actions: (
|
|
1379
|
+
<>
|
|
1380
|
+
<IconAction icon={PencilIcon} label={`Edit ${store.name}`} size="sm" variant="ghost" onClick={() => edit(store.id)} />
|
|
1381
|
+
<IconAction icon={Trash2Icon} label={`Remove ${store.name}`} tone="destructive" size="sm" variant="ghost" onClick={() => remove(store.id)} />
|
|
1382
|
+
</>
|
|
1383
|
+
),
|
|
1384
|
+
}))}
|
|
1385
|
+
```
|
|
1386
|
+
|
|
1387
|
+
- **`content`** goes under the item's fields at the item's full width (in
|
|
1388
|
+
`table`, a row of its own under the item's, as wide as the table's box
|
|
1389
|
+
and held in view while a phone scrolls the table sideways). An item with
|
|
1390
|
+
content and no fields reads no "No details".
|
|
1391
|
+
- **`actions`** are the item's own buttons, at the end of its title line;
|
|
1392
|
+
in `featured` beside the toggle, never inside its button; in `table` a
|
|
1393
|
+
last column, named `actionsColumn` ("Actions") for a screen reader. Icon
|
|
1394
|
+
actions (`IconAction`, a tooltip and a name each) named for the item
|
|
1395
|
+
("Edit Corner Hardware"), as the record standard's header draws them.
|
|
1396
|
+
A Remove that loses data asks first, as any delete does
|
|
1397
|
+
(add-an-entity.md "Deleting").
|
|
1398
|
+
- **`wide`** gives the item the whole row of `cards` or `panels`, for
|
|
1399
|
+
content that needs it: set it while the item's editor is open. The
|
|
1400
|
+
items keep their order; the others wrap around it.
|
|
1401
|
+
- **Editing one item swaps its fields for its editor** (the content), then
|
|
1402
|
+
back on Save or Cancel. The set's other items stay as they are.
|
|
1403
|
+
|
|
1364
1404
|
Measured with axe, the token check and the glyph check in both themes and
|
|
1365
|
-
every palette (fixtures `app/EqualItems
|
|
1366
|
-
phone's width in
|
|
1405
|
+
every palette (fixtures `app/EqualItems`, "Content and actions" among
|
|
1406
|
+
them), and from the keyboard and at a phone's width in
|
|
1407
|
+
`e2e/equal-items.spec.ts`.
|
|
1367
1408
|
|
|
1368
1409
|
## An overview page
|
|
1369
1410
|
|
|
@@ -237,7 +237,12 @@ export function EditableField({ label, edit, children, layout = 'block', look =
|
|
|
237
237
|
const row = look === 'row';
|
|
238
238
|
return (_jsxs("span", { "data-slot": "editable-value", "data-look": look, onClick: onShownClick, className: cn('group/editable relative cursor-text items-start gap-1',
|
|
239
239
|
// A row: the row (editRowClass) wears the hover, not the value.
|
|
240
|
-
!row && '-mx-1.5 rounded-md px-1.5 transition-colors hover:bg-muted has-[[data-edit]:focus-visible]:bg-muted',
|
|
240
|
+
!row && '-mx-1.5 rounded-md px-1.5 transition-colors hover:bg-muted has-[[data-edit]:focus-visible]:bg-muted',
|
|
241
|
+
// Inline, the cap is its column plus the 0.75rem the negative
|
|
242
|
+
// margins give back: a parent sized to its content (a title on
|
|
243
|
+
// its line) is sized to the margin box, 0.75rem under the box,
|
|
244
|
+
// and `max-w-full` then wrapped a short value mid-word (4.94).
|
|
245
|
+
layout === 'block' ? 'flex w-full' : cn('inline-flex align-top', row ? 'max-w-full' : 'max-w-[calc(100%+0.75rem)]'), className), children: [_jsxs("span", { className: cn('min-w-0 flex-1', !row &&
|
|
241
246
|
'group-hover/editable:[&_.text-muted-foreground]:text-foreground group-has-[[data-edit]:focus-visible]/editable:[&_.text-muted-foreground]:text-foreground'), children: [children !== undefined ? children : edit.shown, _jsx("span", { role: "status", "data-slot": "editable-value-saved", className: "ml-2 inline-flex items-center gap-1 align-baseline type-caption text-success-text empty:hidden", children: justSaved && (_jsxs(_Fragment, { children: [_jsx(CheckIcon, { "aria-hidden": "true", className: "size-3.5" }), "Saved"] })) })] }), _jsx(Button, { ref: editButton, "data-edit": "", type: "button", variant: "ghost", size: "icon-xs", "aria-label": `Edit ${label}`, onClick: start, className: cn('shrink-0 text-muted-foreground opacity-0 focus-visible:opacity-100 pointer-coarse:opacity-100', row ? 'group-hover/edit-row:opacity-100 hover:bg-transparent max-md:opacity-100' : 'group-hover/editable:opacity-100'), children: row ? (_jsxs(_Fragment, { children: [_jsx(PencilIcon, { className: "max-md:hidden pointer-coarse:hidden" }), _jsx(ChevronRightIcon, { className: "hidden max-md:block pointer-coarse:block" })] })) : (_jsx(PencilIcon, {})) })] }));
|
|
242
247
|
}
|
|
243
248
|
// Always editable, before the store has it (the first render): the saved value.
|
|
@@ -286,7 +286,7 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
|
|
|
286
286
|
const main = (_jsxs("div", { className: cn(RAIL_LAYOUT.main, railSections.length === 0 && RAIL_LAYOUT.mainAlone), children: [mainSections
|
|
287
287
|
.filter((section) => !tabbed(section))
|
|
288
288
|
.map((section) => (_jsx(ViewSection, { section: section }, section.title))), tabList] }));
|
|
289
|
-
return (_jsx(EditInPlaceContext.Provider, { value: store, children: _jsx(EmptyContext.Provider, { value: { text: emptyText, fold: emptyFields === 'fold' }, children: _jsxs("div", { className: layout === 'rail' ? RAIL_LAYOUT.page : 'flex max-w-4xl flex-col gap-6', "data-state": "success", "data-layout": layout, children: [editing && _jsx(LeaveGuard, { store: store }), !dialog && !trail && _jsx(BackLink, { back: back }), !dialog && trail && !inShell && _jsx(PageTrail, { crumbs: trail }), _jsxs("header", { className: "flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between", children: [_jsxs("div", { className: "flex min-w-0 flex-1 items-start gap-3 sm:min-w-64 sm:gap-4", children: [leading && (_jsx("div", { "data-slot": "entity-view-leading", className: "flex shrink-0 items-center", children: leading })), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-2", children: [_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: "min-w-0 max-w-full type-page-title break-words text-foreground", children: titleEdit ? (_jsx(EditableValue, { label: titleEdit.label, edit: titleEdit, layout: "inline",
|
|
289
|
+
return (_jsx(EditInPlaceContext.Provider, { value: store, children: _jsx(EmptyContext.Provider, { value: { text: emptyText, fold: emptyFields === 'fold' }, children: _jsxs("div", { className: layout === 'rail' ? RAIL_LAYOUT.page : 'flex max-w-4xl flex-col gap-6', "data-state": "success", "data-layout": layout, children: [editing && _jsx(LeaveGuard, { store: store }), !dialog && !trail && _jsx(BackLink, { back: back }), !dialog && trail && !inShell && _jsx(PageTrail, { crumbs: trail }), _jsxs("header", { className: "flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between", children: [_jsxs("div", { className: "flex min-w-0 flex-1 items-start gap-3 sm:min-w-64 sm:gap-4", children: [leading && (_jsx("div", { "data-slot": "entity-view-leading", className: "flex shrink-0 items-center", children: leading })), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-2", children: [_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: "min-w-0 max-w-full type-page-title break-words text-foreground", children: titleEdit ? (_jsx(EditableValue, { label: titleEdit.label, edit: titleEdit, layout: "inline", 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 }))] })] }), (actions || printButton) && (_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-2 sm:justify-end", children: [printButton, actions] }))] }), _jsx("div", { role: "status", "data-slot": "entity-view-notice", className: "empty:hidden", children: notice }), strip && _jsx("div", { "data-slot": "entity-view-strip", children: strip }), layout === 'rail' ? (_jsxs("div", { className: RAIL_LAYOUT.columns, children: [mobileOrder === 'main-first' && main, railSections.length > 0 && (_jsx(Rail, { label: railLabel ?? `${title ?? 'Record'} details`, sections: railSections, fields: railFields })), mobileOrder === 'rail-first' && main] })) : (_jsxs(_Fragment, { children: [sections
|
|
290
290
|
.filter((section) => !tabbed(section))
|
|
291
291
|
.map((section) => (_jsx(ViewSection, { section: section }, section.title))), tabList] })), footer && (_jsx("footer", { "data-slot": "entity-view-footer", className: "type-caption text-muted-foreground", children: footer }))] }) }) }));
|
|
292
292
|
}
|
|
@@ -28,8 +28,22 @@ export type EqualItem = {
|
|
|
28
28
|
title: string;
|
|
29
29
|
/** A small status, as a badge: words alone are a neutral one. */
|
|
30
30
|
state?: string | EqualItemState;
|
|
31
|
-
/** Its details, in order. None reads as `noFieldsText`. */
|
|
31
|
+
/** Its details, in order. None (and no `content`) reads as `noFieldsText`. */
|
|
32
32
|
fields?: readonly EqualItemField[];
|
|
33
|
+
/**
|
|
34
|
+
* Anything of the app's, under the fields at the item's full width (an
|
|
35
|
+
* editor of several fields, a note): never squeezed into the label/value
|
|
36
|
+
* grid. In the `table` look, a row of its own under the item's.
|
|
37
|
+
*/
|
|
38
|
+
content?: ReactNode;
|
|
39
|
+
/**
|
|
40
|
+
* The item's own buttons (Edit, Remove), small and named for the item
|
|
41
|
+
* ("Edit Phase 2"): at the end of its title line, beside a featured
|
|
42
|
+
* toggle's button (never inside it), or the `table` look's last column.
|
|
43
|
+
*/
|
|
44
|
+
actions?: ReactNode;
|
|
45
|
+
/** The whole row in the `cards` and `panels` looks (an editor open in it). */
|
|
46
|
+
wide?: boolean;
|
|
33
47
|
};
|
|
34
48
|
export type EqualItemsProps = {
|
|
35
49
|
items: readonly EqualItem[];
|
|
@@ -53,6 +67,8 @@ export type EqualItemsProps = {
|
|
|
53
67
|
titleColumn?: string;
|
|
54
68
|
/** For `look="table"`: the state column's heading. Defaults to "Status". */
|
|
55
69
|
stateColumn?: string;
|
|
70
|
+
/** For `look="table"`: the actions column's heading, for screen readers. Defaults to "Actions". */
|
|
71
|
+
actionsColumn?: string;
|
|
56
72
|
/** What no items says. Defaults to "Nothing yet". */
|
|
57
73
|
emptyText?: string;
|
|
58
74
|
/** What an item with no fields says. Defaults to "No details". */
|
|
@@ -79,6 +95,8 @@ export type EqualItemsProps = {
|
|
|
79
95
|
* `cards` for a few things with little to say about each, `table` for
|
|
80
96
|
* things compared on the same values, `featured` when one is current or
|
|
81
97
|
* best, `panels` when each has several details and must read as separate
|
|
82
|
-
* (design-language.md "A few equal things").
|
|
98
|
+
* (design-language.md "A few equal things"). An item's own `content` (an
|
|
99
|
+
* editor) goes under its fields at full width, its `actions` (Edit, Remove)
|
|
100
|
+
* at its title line's end; `wide` gives it the whole row of cards or panels.
|
|
83
101
|
*/
|
|
84
|
-
export declare function EqualItems({ items, look, featuredId, defaultOpenIds, label, headingLevel, titleColumn, stateColumn, emptyText, noFieldsText, className, }: EqualItemsProps): import("react").JSX.Element;
|
|
102
|
+
export declare function EqualItems({ items, look, featuredId, defaultOpenIds, label, headingLevel, titleColumn, stateColumn, actionsColumn, emptyText, noFieldsText, className, }: EqualItemsProps): 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 few equal things in a record (record page standard R10): the phases of
|
|
3
3
|
// a plan, the stores a price is compared at, a handful of options. One data
|
|
4
4
|
// shape, four looks, each the record picks for what it shows:
|
|
@@ -22,7 +22,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
22
22
|
// value is the record's dash, read as "Not set". It owns its empty states:
|
|
23
23
|
// no items reads `emptyText` ("Nothing yet"), an item with no fields
|
|
24
24
|
// `noFieldsText` ("No details").
|
|
25
|
-
|
|
25
|
+
//
|
|
26
|
+
// An item can carry its own parts too (4.94): `content`, anything of the
|
|
27
|
+
// app's (an editor of several fields, a note, a chart), drawn under its
|
|
28
|
+
// fields at the item's full width, never in the label/value grid; and
|
|
29
|
+
// `actions`, its own buttons (Edit, Remove), at the end of its title line,
|
|
30
|
+
// or the table's last column. `wide` gives an item the whole row in
|
|
31
|
+
// `cards` and `panels`, for content that needs it (an editor open).
|
|
32
|
+
import { Fragment, useState } from 'react';
|
|
26
33
|
import { ChevronDownIcon } from 'lucide-react';
|
|
27
34
|
import { cn } from 'cn';
|
|
28
35
|
import { Badge } from '../ui/badge.js';
|
|
@@ -62,31 +69,51 @@ function Fields({ fields, noFieldsText, rows, }) {
|
|
|
62
69
|
}
|
|
63
70
|
return (_jsx("dl", { "data-slot": "equal-item-fields", className: "@container/fields flex flex-col divide-y divide-border", children: fields.map((field, index) => (_jsxs("div", { className: cn(FIELD_ROW_BASE, rows === 'beside' && FIELD_ROW.railBeside), children: [_jsx("dt", { className: FIELD_LABEL, children: field.label }), _jsx("dd", { className: FIELD_VALUE, children: _jsx(Value, { value: field.value }) })] }, `${field.label}-${index}`))) }));
|
|
64
71
|
}
|
|
72
|
+
const hasPart = (part) => part !== undefined && part !== null && part !== false;
|
|
73
|
+
function Actions({ actions, className }) {
|
|
74
|
+
if (!hasPart(actions))
|
|
75
|
+
return null;
|
|
76
|
+
return (_jsx("div", { "data-slot": "equal-item-actions", className: cn('flex shrink-0 flex-wrap items-center justify-end gap-1', className), children: actions }));
|
|
77
|
+
}
|
|
78
|
+
// The title and its state, then the item's actions at the line's end.
|
|
65
79
|
function Title({ item, level, className }) {
|
|
66
80
|
const Heading = `h${level}`;
|
|
67
|
-
|
|
81
|
+
const withActions = hasPart(item.actions);
|
|
82
|
+
const heading = (_jsxs("div", { className: cn('flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1', withActions ? 'flex-1' : className), children: [_jsx(Heading, { className: "min-w-0 type-body font-semibold break-words text-foreground", children: item.title }), _jsx(StateBadge, { state: item.state })] }));
|
|
83
|
+
if (!withActions)
|
|
84
|
+
return heading;
|
|
85
|
+
return (_jsxs("div", { className: cn('flex min-w-0 items-start gap-2', className), children: [heading, _jsx(Actions, { actions: item.actions, className: "-my-1" })] }));
|
|
86
|
+
}
|
|
87
|
+
// An item's body: its fields, then its own content at full width. Content
|
|
88
|
+
// alone needs no fields, and reads no "No details".
|
|
89
|
+
function Body({ item, noFieldsText, rows, }) {
|
|
90
|
+
if (!hasPart(item.content))
|
|
91
|
+
return _jsx(Fields, { fields: item.fields, noFieldsText: noFieldsText, rows: rows });
|
|
92
|
+
return (_jsxs(_Fragment, { children: [item.fields && item.fields.length > 0 && _jsx(Fields, { fields: item.fields, noFieldsText: noFieldsText, rows: rows }), _jsx("div", { "data-slot": "equal-item-content", className: "min-w-0", children: item.content })] }));
|
|
68
93
|
}
|
|
69
94
|
function Cards({ items, label, level, noFieldsText }) {
|
|
70
|
-
return (_jsx("ul", { "aria-label": label, className: "grid grid-cols-[repeat(auto-fill,minmax(min(100%,14rem),1fr))] gap-3", children: items.map((item) => (_jsxs("li", { "data-slot": "equal-item", className:
|
|
95
|
+
return (_jsx("ul", { "aria-label": label, className: "grid grid-cols-[repeat(auto-fill,minmax(min(100%,14rem),1fr))] gap-3", children: items.map((item) => (_jsxs("li", { "data-slot": "equal-item", "data-wide": item.wide ? '' : undefined, className: cn('flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-card p-4 text-card-foreground', item.wide && 'col-span-full'), children: [_jsx(Title, { item: item, level: level }), _jsx(Body, { item: item, noFieldsText: noFieldsText, rows: "compact" })] }, item.id))) }));
|
|
71
96
|
}
|
|
72
97
|
function Panels({ items, label, level, noFieldsText }) {
|
|
73
|
-
return (_jsx("ul", { "aria-label": label, className: "grid grid-cols-1 gap-3 sm:grid-cols-[repeat(auto-fit,minmax(14rem,1fr))]", children: items.map((item) => (_jsxs("li", { "data-slot": "equal-item", className:
|
|
98
|
+
return (_jsx("ul", { "aria-label": label, className: "grid grid-cols-1 gap-3 sm:grid-cols-[repeat(auto-fit,minmax(14rem,1fr))]", children: items.map((item) => (_jsxs("li", { "data-slot": "equal-item", "data-wide": item.wide ? '' : undefined, className: cn('flex min-w-0 flex-col overflow-hidden rounded-lg border border-border bg-card text-card-foreground', item.wide && 'col-span-full'), children: [_jsx(Title, { item: item, level: level, className: "border-b border-border bg-muted/40 px-4 py-3" }), _jsx("div", { className: "flex flex-col gap-3 px-4 py-3", children: _jsx(Body, { item: item, noFieldsText: noFieldsText, rows: "stacked" }) })] }, item.id))) }));
|
|
74
99
|
}
|
|
75
100
|
// One column per field label, in the order the items first give them; an
|
|
76
101
|
// item without one reads as a dash there. The title is each row's header.
|
|
77
|
-
function ItemsTable({ items, label, titleColumn, stateColumn, }) {
|
|
102
|
+
function ItemsTable({ items, label, titleColumn, stateColumn, actionsColumn, }) {
|
|
78
103
|
const columns = [];
|
|
79
104
|
for (const item of items)
|
|
80
105
|
for (const field of item.fields ?? [])
|
|
81
106
|
if (!columns.includes(field.label))
|
|
82
107
|
columns.push(field.label);
|
|
83
108
|
const hasState = items.some((item) => stateOf(item.state));
|
|
84
|
-
|
|
109
|
+
const hasActions = items.some((item) => hasPart(item.actions));
|
|
110
|
+
const span = 1 + (hasState ? 1 : 0) + columns.length + (hasActions ? 1 : 0);
|
|
111
|
+
return (_jsx("div", { "data-slot": "equal-items-table", className: "@container/equal-table rounded-lg border border-border bg-card text-card-foreground", children: _jsxs(Table, { children: [_jsx("caption", { className: "sr-only", children: label }), _jsx(TableHeader, { children: _jsxs(TableRow, { className: "hover:bg-transparent", children: [_jsx(TableHead, { scope: "col", className: "type-label text-muted-foreground", children: titleColumn }), hasState && (_jsx(TableHead, { scope: "col", className: "type-label text-muted-foreground", children: stateColumn })), columns.map((column) => (_jsx(TableHead, { scope: "col", className: "type-label text-muted-foreground", children: column }, column))), hasActions && (_jsx(TableHead, { scope: "col", children: _jsx("span", { className: "sr-only", children: actionsColumn }) }))] }) }), _jsx(TableBody, { className: "[&_tr:nth-child(even)]:bg-transparent", children: items.map((item) => (_jsxs(Fragment, { children: [_jsxs(TableRow, { "data-slot": "equal-item", className: cn(hasPart(item.content) && 'border-b-0'), children: [_jsx(TableHead, { scope: "row", className: "h-auto min-w-28 py-(--table-cell-py) font-semibold sm:min-w-40 break-words whitespace-normal", children: item.title }), hasState && (_jsx(TableCell, { children: stateOf(item.state) ? _jsx(StateBadge, { state: item.state }) : _jsx(EmptyText, { text: EMPTY_DASH }) })), columns.map((column) => (_jsx(TableCell, { className: "type-body tabular-nums", children: _jsx(Value, { value: item.fields?.find((field) => field.label === column)?.value }) }, column))), hasActions && (_jsx(TableCell, { className: "w-0 py-1", children: _jsx(Actions, { actions: item.actions, className: "flex-nowrap" }) }))] }), hasPart(item.content) && (_jsx(TableRow, { "data-slot": "equal-item-content-row", className: "hover:bg-transparent", children: _jsx(TableCell, { colSpan: span, className: "pt-0 whitespace-normal", children: _jsx("div", { "data-slot": "equal-item-content", className: "sticky left-(--table-cell-px) w-[calc(100cqw-var(--table-cell-px)*2)] min-w-0", children: item.content }) }) }))] }, item.id))) })] }) }));
|
|
85
112
|
}
|
|
86
113
|
function Featured({ items, label, level, noFieldsText, featuredId, defaultOpenIds, }) {
|
|
87
114
|
const featured = items.find((item) => item.id === featuredId) ?? items[0];
|
|
88
115
|
const rest = items.filter((item) => item !== featured);
|
|
89
|
-
return (_jsxs("div", { role: "group", "aria-label": label, className: "flex flex-col gap-3", children: [_jsxs("section", { "data-slot": "equal-item", "data-featured": "", "aria-label": featured.title, className: "flex min-w-0 flex-col gap-3 rounded-lg border border-primary bg-card p-4 text-card-foreground", children: [_jsx(Title, { item: featured, level: level }), _jsx(
|
|
116
|
+
return (_jsxs("div", { role: "group", "aria-label": label, className: "flex flex-col gap-3", children: [_jsxs("section", { "data-slot": "equal-item", "data-featured": "", "aria-label": featured.title, className: "flex min-w-0 flex-col gap-3 rounded-lg border border-primary bg-card p-4 text-card-foreground", children: [_jsx(Title, { item: featured, level: level }), _jsx(Body, { item: featured, noFieldsText: noFieldsText, rows: "beside" })] }), rest.length > 0 && (_jsx("ul", { className: "flex flex-col divide-y divide-border rounded-lg border border-border bg-card text-card-foreground", children: rest.map((item) => (_jsx(FeaturedToggle, { item: item, level: level, noFieldsText: noFieldsText, defaultOpen: defaultOpenIds?.includes(item.id) ?? false }, item.id))) }))] }));
|
|
90
117
|
}
|
|
91
118
|
// A heading holding its button (the disclosure pattern): Enter and Space
|
|
92
119
|
// open and close it, Tab moves on to the next, and the button says
|
|
@@ -94,7 +121,7 @@ function Featured({ items, label, level, noFieldsText, featuredId, defaultOpenId
|
|
|
94
121
|
function FeaturedToggle({ item, level, noFieldsText, defaultOpen, }) {
|
|
95
122
|
const [open, setOpen] = useState(defaultOpen);
|
|
96
123
|
const Heading = `h${level}`;
|
|
97
|
-
return (_jsx("li", { "data-slot": "equal-item", children: _jsxs(Collapsible, { open: open, onOpenChange: setOpen, children: [_jsx(Heading, { className: "m-0", children: _jsxs(CollapsibleTrigger, { "data-slot": "equal-item-toggle", className: "flex min-h-11 w-full items-center gap-2 px-4 py-2 text-left outline-none hover:bg-muted/50 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:ring-inset", children: [_jsx(ChevronDownIcon, { "aria-hidden": "true", className: cn('size-4 shrink-0 text-muted-foreground transition-transform', !open && '-rotate-90') }), _jsxs("span", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1", children: [_jsx("span", { className: "min-w-0 type-body font-semibold break-words text-foreground", children: item.title }), _jsx(StateBadge, { state: item.state })] })] }) }), _jsx(CollapsibleContent, { className: "px-4 pt-1 pb-4 pl-10", children: _jsx(
|
|
124
|
+
return (_jsx("li", { "data-slot": "equal-item", children: _jsxs(Collapsible, { open: open, onOpenChange: setOpen, children: [_jsxs("div", { className: "flex min-w-0 items-center", children: [_jsx(Heading, { className: "m-0 min-w-0 flex-1", children: _jsxs(CollapsibleTrigger, { "data-slot": "equal-item-toggle", className: "flex min-h-11 w-full items-center gap-2 px-4 py-2 text-left outline-none hover:bg-muted/50 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:ring-inset", children: [_jsx(ChevronDownIcon, { "aria-hidden": "true", className: cn('size-4 shrink-0 text-muted-foreground transition-transform', !open && '-rotate-90') }), _jsxs("span", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1", children: [_jsx("span", { className: "min-w-0 type-body font-semibold break-words text-foreground", children: item.title }), _jsx(StateBadge, { state: item.state })] })] }) }), _jsx(Actions, { actions: item.actions, className: "pr-4" })] }), _jsx(CollapsibleContent, { className: "flex flex-col gap-3 px-4 pt-1 pb-4 pl-10", children: _jsx(Body, { item: item, noFieldsText: noFieldsText, rows: "beside" }) })] }) }));
|
|
98
125
|
}
|
|
99
126
|
/**
|
|
100
127
|
* A few equal, related things inside a record view (record page standard
|
|
@@ -116,12 +143,14 @@ function FeaturedToggle({ item, level, noFieldsText, defaultOpen, }) {
|
|
|
116
143
|
* `cards` for a few things with little to say about each, `table` for
|
|
117
144
|
* things compared on the same values, `featured` when one is current or
|
|
118
145
|
* best, `panels` when each has several details and must read as separate
|
|
119
|
-
* (design-language.md "A few equal things").
|
|
146
|
+
* (design-language.md "A few equal things"). An item's own `content` (an
|
|
147
|
+
* editor) goes under its fields at full width, its `actions` (Edit, Remove)
|
|
148
|
+
* at its title line's end; `wide` gives it the whole row of cards or panels.
|
|
120
149
|
*/
|
|
121
|
-
export function EqualItems({ items, look = 'cards', featuredId, defaultOpenIds, label, headingLevel = 3, titleColumn = 'Name', stateColumn = 'Status', emptyText = 'Nothing yet', noFieldsText = 'No details', className, }) {
|
|
150
|
+
export function EqualItems({ items, look = 'cards', featuredId, defaultOpenIds, label, headingLevel = 3, titleColumn = 'Name', stateColumn = 'Status', actionsColumn = 'Actions', emptyText = 'Nothing yet', noFieldsText = 'No details', className, }) {
|
|
122
151
|
if (items.length === 0) {
|
|
123
152
|
return (_jsx("p", { "data-slot": "equal-items", "data-look": look, "data-state": "empty", className: cn('type-body text-muted-foreground', className), children: emptyText }));
|
|
124
153
|
}
|
|
125
154
|
const shared = { items, label, level: headingLevel, noFieldsText };
|
|
126
|
-
return (_jsx("div", { "data-slot": "equal-items", "data-look": look, className: cn('min-w-0', className), children: look === 'table' ? (_jsx(ItemsTable, { items: items, label: label, titleColumn: titleColumn, stateColumn: stateColumn })) : look === 'featured' ? (_jsx(Featured, { ...shared, featuredId: featuredId, defaultOpenIds: defaultOpenIds })) : look === 'panels' ? (_jsx(Panels, { ...shared })) : (_jsx(Cards, { ...shared })) }));
|
|
155
|
+
return (_jsx("div", { "data-slot": "equal-items", "data-look": look, className: cn('min-w-0', className), children: look === 'table' ? (_jsx(ItemsTable, { items: items, label: label, titleColumn: titleColumn, stateColumn: stateColumn, actionsColumn: actionsColumn })) : look === 'featured' ? (_jsx(Featured, { ...shared, featuredId: featuredId, defaultOpenIds: defaultOpenIds })) : look === 'panels' ? (_jsx(Panels, { ...shared })) : (_jsx(Cards, { ...shared })) }));
|
|
127
156
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.94.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": {
|