@tristan2828/ui-foundation 4.111.0 → 4.112.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,18 +15,18 @@
15
15
  - Step 8: Add Playwright specs for all three screens · lines 755–832
16
16
  - Step 9: Register the nav entry and route names · lines 833–847
17
17
  - Step 10: `npm run verify`. · lines 848–850
18
- - [How a list opens a record](#how-a-list-opens-a-record) · lines 852–1257
19
- - [The record view](#the-record-view) · lines 1005–1102
20
- - [Forms](#forms) · lines 1104–1174
21
- - [Dialogs](#dialogs) · lines 1176–1207
22
- - [Toasts and feedback](#toasts-and-feedback) · lines 1209–1257
23
- - [What not to copy](#what-not-to-copy) · lines 1259–1291
24
- - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1293–1310
25
- - [Deleting](#deleting) · lines 1312–1343
26
- - [Fields only a script writes](#fields-only-a-script-writes) · lines 1345–1366
27
- - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1368–1377
28
- - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1380–1422
29
- - [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1424–1460
18
+ - [How a list opens a record](#how-a-list-opens-a-record) · lines 852–1261
19
+ - [The record view](#the-record-view) · lines 1005–1106
20
+ - [Forms](#forms) · lines 1108–1178
21
+ - [Dialogs](#dialogs) · lines 1180–1211
22
+ - [Toasts and feedback](#toasts-and-feedback) · lines 1213–1261
23
+ - [What not to copy](#what-not-to-copy) · lines 1263–1295
24
+ - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1297–1314
25
+ - [Deleting](#deleting) · lines 1316–1347
26
+ - [Fields only a script writes](#fields-only-a-script-writes) · lines 1349–1370
27
+ - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1372–1381
28
+ - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1384–1426
29
+ - [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1428–1464
30
30
 
31
31
  <!-- /index -->
32
32
 
@@ -1051,7 +1051,11 @@ A record uses the parts it has, in this order:
1051
1051
  dialog), so the page doesn't end 900px in. The strip stays above it at
1052
1052
  full width, and the rail starts level with the first content under the
1053
1053
  strip: the open tab's first section (beside the tab's content, not its
1054
- bar), or the first card when cards come before the tabs (4.108). Only short values go in it,
1054
+ bar), or the first card when cards come before the tabs (4.108). Beside
1055
+ the rail the record's cards fill the column up to it, as wide as the
1056
+ tab bar (Details too, which elsewhere keeps a 42rem reading width), and
1057
+ their rows keep a compact 10rem label so the values get the rest
1058
+ (4.112). Only short values go in it,
1055
1059
  and the API holds to that: a rail section is `facts`, not `fields`,
1056
1060
  each fact one of a few kinds, never free markup:
1057
1061
 
@@ -123,6 +123,10 @@ import { factsAsFields, useWideParent } from './entity-view-facts.js';
123
123
  // The view's empty text and whether fields cards fold their empty ones,
124
124
  // for every section without threading them through each layout.
125
125
  const EmptyContext = createContext({ text: EMPTY_DASH, fold: false });
126
+ // Whether the facts rail is drawn (4.112): the record's column then fills
127
+ // the room up to the rail (Details' reading-width cap off), and its fields
128
+ // rows keep a compact label (`FIELD_ROW.wide`) so the values get the rest.
129
+ const BesideFactsRailContext = createContext(false);
126
130
  // The record's trail (#R2): the crumbs above it, then its own title
127
131
  // once it has loaded; the list's crumb is the last until then.
128
132
  function recordTrail(back, title) {
@@ -159,10 +163,20 @@ function FieldList({ fields, place }) {
159
163
  const shown = emptyCount === 0 || open ? fields : fields.filter((field) => !isEmptyValue(fieldValue(field)));
160
164
  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') })] }))] }));
161
165
  }
162
- function ViewSection({ section, inRail = false, railFields = 'beside', bare, factsRail = false, }) {
166
+ function ViewSection({ section, inRail = false, railFields = 'beside', bare, factsRail = false, side = false, }) {
163
167
  const headingId = useId();
164
168
  const empty = useContext(EmptyContext);
165
- 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 })) }));
169
+ const besideFactsRail = useContext(BesideFactsRailContext);
170
+ const place = factsRail
171
+ ? 'facts'
172
+ : besideFactsRail && !side && bare === undefined
173
+ ? 'wide'
174
+ : !inRail
175
+ ? 'page'
176
+ : railFields === 'beside'
177
+ ? 'railBeside'
178
+ : 'rail';
179
+ const body = 'fields' in section || 'facts' in section ? (_jsx(FieldList, { fields: 'fields' in section ? section.fields : factsAsFields(section.facts), place: place })) : 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 })) }));
166
180
  if (bare) {
167
181
  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] }));
168
182
  }
@@ -275,14 +289,17 @@ const TAB_SIDE = {
275
289
  side: 'flex min-w-0 flex-col gap-6',
276
290
  };
277
291
  function TabBody({ tab, railFields }) {
292
+ const besideFactsRail = useContext(BesideFactsRailContext);
278
293
  if (tab.details) {
279
- // The facts on their own: a reading width, never the whole page.
280
- return (_jsx("div", { "data-slot": "entity-view-details", className: "flex w-full max-w-2xl min-w-0 flex-col gap-6", children: tab.sections.map((section) => (_jsx(ViewSection, { section: section, inRail: true, railFields: railFields }, section.title))) }));
294
+ // The facts on their own: a reading width, never the whole page. Beside
295
+ // the facts rail the column is already that (the page's own cap), so
296
+ // they fill it up to the rail, level with the tab bar (4.112).
297
+ return (_jsx("div", { "data-slot": "entity-view-details", className: cn('flex w-full min-w-0 flex-col gap-6', !besideFactsRail && 'max-w-2xl'), children: tab.sections.map((section) => (_jsx(ViewSection, { section: section, inRail: true, railFields: railFields }, section.title))) }));
281
298
  }
282
299
  const main = tab.sections.map((section) => _jsx(ViewSection, { section: section }, section.title));
283
300
  if (tab.side.length === 0)
284
301
  return main;
285
- return (_jsxs("div", { className: TAB_SIDE.columns, children: [_jsx("div", { className: TAB_SIDE.main, children: main }), _jsx("aside", { "aria-label": `${tab.name} Facts`, "data-slot": "entity-view-tab-side", className: TAB_SIDE.side, children: tab.side.map((section) => (_jsx(ViewSection, { section: section, inRail: true, railFields: railFields }, section.title))) })] }));
302
+ return (_jsxs("div", { className: TAB_SIDE.columns, children: [_jsx("div", { className: TAB_SIDE.main, children: main }), _jsx("aside", { "aria-label": `${tab.name} Facts`, "data-slot": "entity-view-tab-side", className: TAB_SIDE.side, children: tab.side.map((section) => (_jsx(ViewSection, { section: section, inRail: true, railFields: railFields, side: true }, section.title))) })] }));
286
303
  }
287
304
  // The tab list, under the sections with no tab, and every tab's sections
288
305
  // (hidden but mounted unless selected). The selected tab is the address's,
@@ -441,7 +458,7 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
441
458
  .filter((section) => !tabbed(section))
442
459
  .map((section) => (_jsx(ViewSection, { section: section }, section.title))), tabList] }));
443
460
  }
444
- 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
445
- ? RAIL_LAYOUT.page
446
- : 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) && _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 }))] }) }) }));
461
+ return (_jsx(EditInPlaceContext.Provider, { value: store, children: _jsx(EmptyContext.Provider, { value: { text: emptyText, fold: emptyFields === 'fold' }, children: _jsx(BesideFactsRailContext.Provider, { value: railFacts.length > 0, children: _jsxs("div", { ref: setRoot, className: layout === 'rail' && !card
462
+ ? RAIL_LAYOUT.page
463
+ : 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) && _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 }))] }) }) }) }));
447
464
  }
@@ -3,6 +3,7 @@ export declare const FIELD_ROW: {
3
3
  rail: string;
4
4
  railBeside: string;
5
5
  facts: string;
6
+ wide: string;
6
7
  };
7
8
  /** A row's own spacing, before its place's grid. */
8
9
  export declare const FIELD_ROW_BASE = "flex flex-col gap-1 py-3 first:pt-0 last:pb-0";
@@ -21,6 +21,11 @@ export const FIELD_ROW = {
21
21
  // The facts rail (4.106, A1): a 300px card, so side by side from a
22
22
  // 16rem list, the label column a little narrower again.
23
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',
24
+ // Beside the facts rail (4.112): the cards fill the column up to the
25
+ // rail, so the label keeps a compact 10rem and the value takes the rest
26
+ // (a 12rem label, a third of a 36rem card, wrapped most values onto two
27
+ // lines). Stacked below `sm` or a 24rem list, as on the page.
28
+ wide: 'sm:@sm/fields:grid sm:@sm/fields:grid-cols-[--spacing(40)_minmax(0,1fr)] sm:@sm/fields:items-baseline sm:@sm/fields:gap-6',
24
29
  };
25
30
  /** A row's own spacing, before its place's grid. */
26
31
  export const FIELD_ROW_BASE = 'flex flex-col gap-1 py-3 first:pt-0 last:pb-0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "4.111.0",
3
+ "version": "4.112.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": {