@tristan2828/ui-foundation 4.107.0 → 4.108.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–1249
19
- - [The record view](#the-record-view) · lines 1005–1099
20
- - [Forms](#forms) · lines 1101–1166
21
- - [Dialogs](#dialogs) · lines 1168–1199
22
- - [Toasts and feedback](#toasts-and-feedback) · lines 1201–1249
23
- - [What not to copy](#what-not-to-copy) · lines 1251–1283
24
- - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1285–1302
25
- - [Deleting](#deleting) · lines 1304–1335
26
- - [Fields only a script writes](#fields-only-a-script-writes) · lines 1337–1358
27
- - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1360–1369
28
- - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1372–1414
29
- - [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1416–1452
18
+ - [How a list opens a record](#how-a-list-opens-a-record) · lines 852–1252
19
+ - [The record view](#the-record-view) · lines 1005–1102
20
+ - [Forms](#forms) · lines 1104–1169
21
+ - [Dialogs](#dialogs) · lines 1171–1202
22
+ - [Toasts and feedback](#toasts-and-feedback) · lines 1204–1252
23
+ - [What not to copy](#what-not-to-copy) · lines 1254–1286
24
+ - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1288–1305
25
+ - [Deleting](#deleting) · lines 1307–1338
26
+ - [Fields only a script writes](#fields-only-a-script-writes) · lines 1340–1361
27
+ - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1363–1372
28
+ - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1375–1417
29
+ - [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1419–1455
30
30
 
31
31
  <!-- /index -->
32
32
 
@@ -1046,9 +1046,12 @@ A record uses the parts it has, in this order:
1046
1046
  4.81), so the short facts read as a list of pairs rather than a column
1047
1047
  of labels; keep labels to a word or two.
1048
1048
  - **The facts rail** (4.106, record standard A1): `factsRail` on the
1049
- view puts the record's short facts in a 300px column beside the strip
1050
- and the tabs where the view has room (60rem: a laptop's page, a record
1051
- dialog), so the page doesn't end 900px in. Only short values go in it,
1049
+ view puts the record's short facts in a 300px column beside the
1050
+ record's body where the view has room (60rem: a laptop's page, a record
1051
+ dialog), so the page doesn't end 900px in. The strip stays above it at
1052
+ full width, and the rail starts level with the first content under the
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,
1052
1055
  and the API holds to that: a rail section is `facts`, not `fields`,
1053
1056
  each fact one of a few kinds, never free markup:
1054
1057
 
@@ -224,9 +224,11 @@ export type EntityViewProps = {
224
224
  * The facts rail (4.106, record standard A1), in the `tabs` layout:
225
225
  * where the view has room (60rem beside it: a laptop's page, a record
226
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
227
+ * `tab`) go in a 300px column beside the record's body, and leave
228
+ * Details. The strip stays above, full width; the rail starts level with
229
+ * the first content under it (the open tab's first section, or the first
230
+ * card when cards come before the tabs; 4.108). A Details tab left with
231
+ * nothing isn't drawn. Narrower (a phone), they're in Details as before. Sections with `fields` or
230
232
  * `content` never go in it: a rail holds short values only.
231
233
  */
232
234
  factsRail?: boolean;
@@ -186,12 +186,18 @@ const RAIL_LAYOUT = {
186
186
  sticky: '@4xl/view:data-[fits]:sticky @4xl/view:data-[fits]:top-6',
187
187
  };
188
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.
189
+ // (max-w-4xl) and a 300px rail beside it. The strip stays above both, at
190
+ // full width; the rail starts level with the first content under it: the
191
+ // first section of the open tab (beside the tab's content, never its bar),
192
+ // or the first card when the record's first content isn't the tabs (4.108).
190
193
  const FACTS_RAIL = {
191
194
  page: 'max-w-[calc(var(--container-4xl)+var(--spacing)*6+300px)]',
192
195
  columns: 'grid grid-cols-[minmax(0,1fr)_300px] items-start gap-6',
193
196
  main: 'flex min-w-0 flex-col gap-6',
194
- rail: 'flex min-w-0 flex-col gap-6',
197
+ rail: 'col-start-2 row-start-1 flex min-w-0 flex-col gap-6',
198
+ // The tab bar over the column only: the rail's 300px and the gap (the
199
+ // bar's own -mx-1 bleed kept on its left).
200
+ barBeside: 'mr-[calc(300px+var(--spacing)*5)]',
195
201
  };
196
202
  /** A section of short facts placed `rail` with no tab: the facts rail's, where it's drawn. */
197
203
  function isRailFacts(section) {
@@ -302,7 +308,7 @@ function useStuck() {
302
308
  }, [marker, bar]);
303
309
  return { setMarker, setBar, stuck };
304
310
  }
305
- function MainTabs({ tabs, label, railFields = 'beside', title, counts, stickyTop, }) {
311
+ function MainTabs({ tabs, label, railFields = 'beside', title, counts, stickyTop, aside, }) {
306
312
  const { setMarker, setBar, stuck } = useStuck();
307
313
  const countOf = (tab) => {
308
314
  if (!counts)
@@ -323,13 +329,16 @@ function MainTabs({ tabs, label, railFields = 'beside', title, counts, stickyTop
323
329
  const search = params.toString();
324
330
  void navigate({ pathname: location.pathname, search: search ? `?${search}` : '', hash: location.hash }, { replace: true, state: location.state, preventScrollReset: true });
325
331
  };
332
+ // Kept mounted, the closed tabs are hidden (no box), so beside the rail
333
+ // only the open one takes the first column.
334
+ const panels = tabs.map((tab) => (_jsx(TabsContent, { value: tab.slug, keepMounted: true, className: cn('@container/tab flex min-w-0 flex-col gap-6 [font-size:inherit]', aside !== undefined && 'col-start-1 row-start-1'), children: _jsx(TabBody, { tab: tab, railFields: railFields }) }, tab.slug)));
326
335
  return (_jsxs(Tabs, { value: selected, onValueChange: (value) => select(String(value)), "data-slot": "entity-view-tabs", className: "min-w-0 gap-6", children: [_jsx("div", { ref: setMarker, "aria-hidden": "true", "data-slot": "entity-view-tabs-marker", className: "h-px -mb-6" }), _jsxs("div", { ref: setBar, "data-slot": "entity-view-tab-bar", "data-stuck": stuck ? '' : undefined,
327
336
  // A record dialog's body sets --entity-view-sticky-top to minus its
328
337
  // padding, so the bar sits at the body's own top edge there.
329
- style: { top: stickyTop ?? 'var(--entity-view-sticky-top, 0px)' }, className: "sticky z-10 -mx-1 flex min-w-0 flex-col gap-1 bg-background px-1 pt-0 data-[stuck]:pt-2 data-[stuck]:shadow-[0_8px_12px_-10px_var(--color-foreground)]", children: [stuck && title && (_jsx("p", { "data-slot": "entity-view-tab-bar-title", "aria-hidden": "true", className: "truncate type-label font-semibold text-foreground", children: title })), _jsx(TabsList, { variant: "line", activateOnFocus: true, "aria-label": label, className: "h-auto w-full max-w-full justify-start gap-0 overflow-x-auto overflow-y-hidden border-b border-border p-0 md:gap-1 [scrollbar-width:thin]", children: tabs.map((tab) => {
338
+ style: { top: stickyTop ?? 'var(--entity-view-sticky-top, 0px)' }, className: cn('sticky z-10 -mx-1 flex min-w-0 flex-col gap-1 bg-background px-1 pt-0 data-[stuck]:pt-2 data-[stuck]:shadow-[0_8px_12px_-10px_var(--color-foreground)]', aside !== undefined && FACTS_RAIL.barBeside), children: [stuck && title && (_jsx("p", { "data-slot": "entity-view-tab-bar-title", "aria-hidden": "true", className: "truncate type-label font-semibold text-foreground", children: title })), _jsx(TabsList, { variant: "line", activateOnFocus: true, "aria-label": label, className: "h-auto w-full max-w-full justify-start gap-0 overflow-x-auto overflow-y-hidden border-b border-border p-0 md:gap-1 [scrollbar-width:thin]", children: tabs.map((tab) => {
330
339
  const count = countOf(tab);
331
340
  return (_jsxs(TabsTrigger, { value: tab.slug, className: "h-11 flex-none gap-1.5 px-2.5 text-sm font-semibold text-muted-foreground group-data-horizontal/tabs:after:bottom-0 group-data-horizontal/tabs:after:h-[3px] after:bg-primary data-active:text-primary-text md:px-4 md:text-base dark:text-muted-foreground dark:data-active:text-primary-text", children: [tab.name, count > 0 && (_jsx("span", { "data-slot": "entity-view-tab-count", className: "rounded-full bg-muted px-1.5 text-xs leading-[1.0625rem] font-medium tabular-nums text-foreground", children: count }))] }, tab.slug));
332
- }) })] }), tabs.map((tab) => (_jsx(TabsContent, { value: tab.slug, keepMounted: true, className: "@container/tab flex min-w-0 flex-col gap-6 [font-size:inherit]", children: _jsx(TabBody, { tab: tab, railFields: railFields }) }, tab.slug)))] }));
341
+ }) })] }), aside === undefined ? (panels) : (_jsxs("div", { "data-slot": "entity-view-with-facts", className: FACTS_RAIL.columns, children: [panels, aside] }))] }));
333
342
  }
334
343
  // The `tabs` layout's sections (1A): the main column's untabbed sections,
335
344
  // then the tab list, with the facts (placed `rail`, no tab) as the last
@@ -406,7 +415,11 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
406
415
  const shaped = layout === 'tabs' ? tabsLayout(railFacts.length > 0 ? sections.filter((section) => !isRailFacts(section)) : sections, detailsTab) : null;
407
416
  const tabs = shaped ? shaped.tabs : tabsOf(mainSections);
408
417
  const tabbed = (section) => section.placement !== 'rail' && section.tab !== undefined;
409
- const tabList = tabs.length > 0 && (_jsx(MainTabs, { tabs: tabs, label: tabsLabel, railFields: railFields, title: title, counts: tabCounts, stickyTop: tabsStickyTop }));
418
+ const factsAside = railFacts.length > 0 && (_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))) }));
419
+ // The record's first content under the strip is the tab bar: the rail
420
+ // goes in the tabs, beside the open tab's content.
421
+ const factsInTabs = factsAside !== false && shaped !== null && shaped.above.length === 0 && tabs.length > 0;
422
+ const tabList = tabs.length > 0 && (_jsx(MainTabs, { tabs: tabs, label: tabsLabel, railFields: railFields, title: title, counts: tabCounts, stickyTop: tabsStickyTop, aside: factsInTabs ? factsAside : undefined }));
410
423
  const main = (_jsxs("div", { className: cn(RAIL_LAYOUT.main, railSections.length === 0 && RAIL_LAYOUT.mainAlone), children: [mainSections
411
424
  .filter((section) => !tabbed(section))
412
425
  .map((section) => (_jsx(ViewSection, { section: section }, section.title))), tabList] }));
@@ -420,7 +433,7 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
420
433
  else if (shaped) {
421
434
  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
435
  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);
436
+ factsAside !== false && !factsInTabs ? (_jsxs("div", { "data-slot": "entity-view-with-facts", className: FACTS_RAIL.columns, children: [_jsx("div", { className: cn(FACTS_RAIL.main, 'col-start-1 row-start-1'), children: column }), factsAside] })) : (column);
424
437
  }
425
438
  else {
426
439
  body = (_jsxs(_Fragment, { children: [sections
@@ -429,5 +442,5 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
429
442
  }
430
443
  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
444
  ? 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 }))] }) }) }));
445
+ : 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 }))] }) }) }));
433
446
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "4.107.0",
3
+ "version": "4.108.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": {