@tristan2828/ui-foundation 4.104.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.
@@ -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;
@@ -151,9 +163,13 @@ export type EntityViewProps = {
151
163
  * A row of the record's key numbers (`<KeyStats>`) under the header and
152
164
  * its notice, across the page at every width: in the rail layout above
153
165
  * both columns, so on a phone it comes before the rail and the main
154
- * column.
166
+ * column. Left out in a small card dialog (RecordDialogRoute
167
+ * `look="card"`, 4.105): a tiny record's facts are its few rows, so
168
+ * `cardStrip` keeps it there.
155
169
  */
156
170
  strip?: ReactNode;
171
+ /** Show `strip` in a small card dialog too (4.105); off by default. */
172
+ cardStrip?: boolean;
157
173
  sections: EntityViewSection[];
158
174
  /**
159
175
  * Below every section (both columns in the rail layout), in small muted
@@ -204,6 +220,18 @@ export type EntityViewProps = {
204
220
  printLook?: 'icon' | 'words';
205
221
  /** The rail's landmark name (its `<aside>`). Defaults to the title + " details". */
206
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;
207
235
  /**
208
236
  * In the `rail` layout, a rail section's fields: each label to the left
209
237
  * of its value (`beside`, the default since 4.81), falling back to
@@ -245,4 +273,4 @@ export type EntityViewProps = {
245
273
  trail?: readonly PageCrumb[];
246
274
  };
247
275
  };
248
- export declare function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, sections, footer, layout, detailsTab, tabCounts, tabsStickyTop, mobileOrder, railLabel, railFields, emptyFields, emptyText, printLabel, printLook, isLoading, error, onRetry, back, }: EntityViewProps): import("react").JSX.Element;
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;
@@ -74,7 +74,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
74
74
  // switch. With no `tab` on any section, nothing changes.
75
75
  //
76
76
  // The tab bar (4.101, record standard 3B): bigger underline tabs (16px
77
- // semibold, 14px on a phone), a 3px primary line under the open one, each
77
+ // semibold, 14px on a phone), a 3px primary line under the open one and
78
+ // its name in the theme colour (`text-primary-text`, 4.105), each
78
79
  // tab's count beside its name (`tabCounts`; none for zero). The bar sticks
79
80
  // to the top of whatever scrolls (the page, or a record dialog's body) as
80
81
  // the record scrolls under it, `tabsStickyTop` below the top, and once
@@ -117,6 +118,7 @@ import { FIELD_LABEL, FIELD_ROW, FIELD_ROW_BASE, FIELD_VALUE } from './field-row
117
118
  import { PageTrail } from './page-trail.js';
118
119
  import { usePageTrail } from './page-trail-context.js';
119
120
  import { entityViewTabSlug } from '../../lib/entity-view-tab.js';
121
+ import { factsAsFields, useWideParent } from './entity-view-facts.js';
120
122
  // The view's empty text and whether fields cards fold their empty ones,
121
123
  // for every section without threading them through each layout.
122
124
  const EmptyContext = createContext({ text: EMPTY_DASH, fold: false });
@@ -156,10 +158,10 @@ function FieldList({ fields, place }) {
156
158
  const shown = emptyCount === 0 || open ? fields : fields.filter((field) => !isEmptyValue(fieldValue(field)));
157
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') })] }))] }));
158
160
  }
159
- function ViewSection({ section, inRail = false, railFields = 'beside', bare, }) {
161
+ function ViewSection({ section, inRail = false, railFields = 'beside', bare, factsRail = false, }) {
160
162
  const headingId = useId();
161
163
  const empty = useContext(EmptyContext);
162
- 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 })) }));
163
165
  if (bare) {
164
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] }));
165
167
  }
@@ -183,6 +185,18 @@ const RAIL_LAYOUT = {
183
185
  // is never stuck below the fold.
184
186
  sticky: '@4xl/view:data-[fits]:sticky @4xl/view:data-[fits]:top-6',
185
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
+ }
186
200
  function SkeletonCard({ rows, stacked }) {
187
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))) })] }));
188
202
  }
@@ -314,7 +328,7 @@ function MainTabs({ tabs, label, railFields = 'beside', title, counts, stickyTop
314
328
  // padding, so the bar sits at the body's own top edge there.
315
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) => {
316
330
  const count = countOf(tab);
317
- return (_jsxs(TabsTrigger, { value: tab.slug, className: "h-11 flex-none gap-1.5 px-2.5 text-sm font-semibold text-muted-foreground group-data-horizontal/tabs:after:bottom-0 group-data-horizontal/tabs:after:h-[3px] after:bg-primary data-active:text-foreground md:px-4 md:text-base dark:text-muted-foreground dark:data-active:text-foreground", children: [tab.name, count > 0 && (_jsx("span", { "data-slot": "entity-view-tab-count", className: "rounded-full bg-muted px-1.5 text-xs leading-[1.0625rem] font-medium tabular-nums text-foreground", children: count }))] }, tab.slug));
331
+ 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));
318
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)))] }));
319
333
  }
320
334
  // The `tabs` layout's sections (1A): the main column's untabbed sections,
@@ -341,7 +355,7 @@ function tabsLayout(sections, detailsTab) {
341
355
  tabs.push({ slug, name: detailsTab, sections: facts, side: [], details: true });
342
356
  return { above: main.filter((section) => section.tab === undefined), tabs, factsInColumn: false };
343
357
  }
344
- export function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, sections, footer, layout = 'tabs', detailsTab = 'Details', tabCounts, tabsStickyTop, mobileOrder = 'rail-first', railLabel, railFields = 'beside', emptyFields = 'show', emptyText = EMPTY_DASH, printLabel = 'Print Notes', printLook = 'icon', isLoading, error, onRetry, back, }) {
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, }) {
345
359
  // Editing in place: one store per view, and the leave-page prompt only
346
360
  // while a field is open (or one is always editable).
347
361
  const [store] = useState(() => new EditInPlaceStore());
@@ -354,6 +368,8 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
354
368
  // In the shell, the trail goes up in its bar; a dialog leaves the bar
355
369
  // to the list under it.
356
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');
357
373
  if (error?.kind === 'notfound') {
358
374
  // A record that doesn't exist and one that belongs to another user are
359
375
  // the same plain 404, so this never says which. Retrying can't help.
@@ -367,9 +383,9 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
367
383
  .filter((section) => section.print)
368
384
  .map((section) => ({
369
385
  title: section.title,
370
- ...('fields' in section
386
+ ...('fields' in section || 'facts' in section
371
387
  ? {
372
- fields: section.fields.map((field) => ({
388
+ fields: ('fields' in section ? section.fields : factsAsFields(section.facts)).map((field) => ({
373
389
  label: field.label,
374
390
  value: field.value !== undefined ? field.value : field.edit?.shown,
375
391
  })),
@@ -386,7 +402,8 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
386
402
  const card = dialog?.look === 'card';
387
403
  // Tabs: in the `tabs` layout the facts are a tab of their own (1A); in
388
404
  // the others a main section's `tab` (a rail one's is ignored).
389
- const shaped = layout === 'tabs' ? tabsLayout(sections, detailsTab) : null;
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;
390
407
  const tabs = shaped ? shaped.tabs : tabsOf(mainSections);
391
408
  const tabbed = (section) => section.placement !== 'rail' && section.tab !== undefined;
392
409
  const tabList = tabs.length > 0 && (_jsx(MainTabs, { tabs: tabs, label: tabsLabel, railFields: railFields, title: title, counts: tabCounts, stickyTop: tabsStickyTop }));
@@ -401,12 +418,16 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
401
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] }));
402
419
  }
403
420
  else if (shaped) {
404
- body = (_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] }));
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);
405
424
  }
406
425
  else {
407
426
  body = (_jsxs(_Fragment, { children: [sections
408
427
  .filter((section) => !tabbed(section))
409
428
  .map((section) => (_jsx(ViewSection, { section: section }, section.title))), tabList] }));
410
429
  }
411
- return (_jsx(EditInPlaceContext.Provider, { value: store, children: _jsx(EmptyContext.Provider, { value: { text: emptyText, fold: emptyFields === 'fold' }, children: _jsxs("div", { className: layout === 'rail' && !card ? RAIL_LAYOUT.page : cn('flex max-w-4xl flex-col', card ? 'gap-4' : 'gap-6'), "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 && _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 }))] }) }) }));
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 }))] }) }) }));
412
433
  }
@@ -2,6 +2,7 @@ export declare const FIELD_ROW: {
2
2
  page: string;
3
3
  rail: string;
4
4
  railBeside: string;
5
+ facts: string;
5
6
  };
6
7
  /** A row's own spacing, before its place's grid. */
7
8
  export declare const FIELD_ROW_BASE = "flex flex-col gap-1 py-3 first:pt-0 last:pb-0";
@@ -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';
@@ -41,6 +41,6 @@ export function ListHeader({ title, count, links = [], newAction, more = [], del
41
41
  const outLink = links.length === 1 ? links[0] : undefined;
42
42
  const menuLinks = links.length > 1 ? links : [];
43
43
  const hasMenu = menuLinks.length > 0 || more.length > 0 || deleted !== undefined;
44
- return (_jsxs("div", { "data-slot": "list-header", className: cn('flex flex-col', className), children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-4 gap-y-2", children: [_jsxs("h1", { className: "flex items-baseline gap-2 type-page-title text-foreground", children: [title, count !== undefined && (_jsxs("span", { className: "type-body font-normal tabular-nums text-muted-foreground", children: [_jsx("span", { className: "sr-only", children: ", " }), count] }))] }), siblings.length > 1 && _jsx(SiblingSwitch, { siblings: siblings, label: siblingsLabel ?? `${title} Lists` }), _jsxs("div", { className: "ml-auto flex flex-wrap items-center gap-2", children: [outLink && (_jsxs(Button, { size: "sm", variant: "outline", nativeButton: false, render: _jsx(Link, { to: outLink.to }), children: [outLink.icon && _jsx(outLink.icon, { "aria-hidden": "true" }), outLink.label] })), hasMenu && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsx(Button, { size: "icon-sm", variant: "outline", "aria-label": `More for ${title}`, "data-slot": "list-header-more" }), children: _jsx(EllipsisIcon, { "aria-hidden": "true" }) }), _jsxs(DropdownMenuContent, { align: "end", children: [menuLinks.map((link) => (_jsxs(DropdownMenuItem, { render: _jsx(Link, { to: link.to }), children: [link.icon && _jsx(link.icon, { "aria-hidden": "true" }), link.label] }, link.label))), more.map((action) => (_jsxs(DropdownMenuItem, { onClick: action.onSelect, children: [action.icon && _jsx(action.icon, { "aria-hidden": "true" }), action.label] }, action.label))), deleted && (menuLinks.length > 0 || more.length > 0) && _jsx(DropdownMenuSeparator, {}), deleted && (_jsxs(DropdownMenuCheckboxItem, { closeOnClick: true, checked: deleted.shown, onCheckedChange: deleted.onShownChange, children: [_jsx(Trash2Icon, { "aria-hidden": "true" }), "Show Deleted"] }))] })] })), newAction &&
44
+ return (_jsxs("div", { "data-slot": "list-header", className: cn('flex flex-col', className), children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-4 gap-y-2", children: [_jsxs("h1", { className: "flex items-baseline gap-2 type-page-title text-foreground", children: [title, count !== undefined && (_jsxs("span", { className: "type-body font-normal tabular-nums text-muted-foreground", children: [_jsx("span", { className: "sr-only", children: ", " }), count] }))] }), siblings.length > 1 && _jsx(SiblingSwitch, { siblings: siblings, label: siblingsLabel ?? `${title} Lists` }), _jsxs("div", { className: "ml-auto flex flex-wrap items-center gap-2", children: [outLink && (_jsxs(Button, { size: "sm", variant: "outline", nativeButton: false, render: _jsx(Link, { to: outLink.to }), children: [outLink.icon && _jsx(outLink.icon, { "aria-hidden": "true" }), outLink.label] })), hasMenu && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsx(Button, { size: "icon-sm", variant: "outline", "aria-label": `More for ${title}`, "data-slot": "list-header-more" }), children: _jsx(EllipsisIcon, { "aria-hidden": "true" }) }), _jsxs(DropdownMenuContent, { align: "end", className: "w-max max-w-(--available-width) whitespace-nowrap", children: [menuLinks.map((link) => (_jsxs(DropdownMenuItem, { render: _jsx(Link, { to: link.to }), children: [link.icon && _jsx(link.icon, { "aria-hidden": "true" }), link.label] }, link.label))), more.map((action) => (_jsxs(DropdownMenuItem, { onClick: action.onSelect, children: [action.icon && _jsx(action.icon, { "aria-hidden": "true" }), action.label] }, action.label))), deleted && (menuLinks.length > 0 || more.length > 0) && _jsx(DropdownMenuSeparator, {}), deleted && (_jsxs(DropdownMenuCheckboxItem, { closeOnClick: true, checked: deleted.shown, onCheckedChange: deleted.onShownChange, children: [_jsx(Trash2Icon, { "aria-hidden": "true" }), "Show Deleted"] }))] })] })), newAction &&
45
45
  (newAction.to !== undefined ? (_jsxs(Button, { size: "sm", nativeButton: false, render: _jsx(Link, { to: newAction.to }), children: [_jsx(PlusIcon, { "aria-hidden": "true" }), newAction.label] })) : (_jsxs(Button, { size: "sm", onClick: newAction.onClick, children: [_jsx(PlusIcon, { "aria-hidden": "true" }), newAction.label] })))] })] }), _jsx("div", { role: "status", "data-slot": "list-header-notice", className: "not-empty:mt-3", children: deleted?.shown && (_jsxs(Notice, { tone: "info", icon: Trash2Icon, action: _jsx(Button, { size: "sm", variant: "outline", onClick: () => deleted.onShownChange(false), children: "Back to the List" }), children: ["Showing deleted ", deleted.noun ?? 'records', "."] })) })] }));
46
46
  }
@@ -8,6 +8,17 @@ export type TableView<F extends string, M extends string> = {
8
8
  label?: string;
9
9
  filters?: Partial<Record<F, string>>;
10
10
  multiFilters?: Partial<Record<M, string[]>>;
11
+ /**
12
+ * The part of the view the filter bar has no control for (4.105): a
13
+ * computed rule the server applies, such as `{ overdue: 'true' }`. It's
14
+ * in the URL like a filter and counts toward the view being on, but the
15
+ * reader can't see or change it, so it lasts only while the view does:
16
+ * the first filter the reader changes clears it (filterChanges), and
17
+ * the rows are then what the bar shows. Put everything a control can
18
+ * show in `filters` and `multiFilters`, so the bar says why rows are
19
+ * hidden.
20
+ */
21
+ rule?: Partial<Record<F, string>>;
11
22
  sort?: Sort;
12
23
  /**
13
24
  * The ids of the columns this view shows, for DataTable's
@@ -25,6 +36,23 @@ export type TableView<F extends string, M extends string> = {
25
36
  };
26
37
  export declare function serializeSort(next: Sort): string | null;
27
38
  export declare function applyUrlChanges(previous: URLSearchParams, changes: UrlChanges): URLSearchParams;
28
- export declare function viewToUrlChanges<F extends string, M extends string>(filterNames: readonly F[], multiFilterNames: readonly M[], view: TableView<F, M>): UrlChanges;
39
+ export declare function viewToUrlChanges<F extends string, M extends string>(filterNames: readonly F[], multiFilterNames: readonly M[], view: TableView<F, M>, asDefault?: boolean): UrlChanges;
40
+ /**
41
+ * The query parameter that says "no view, no filters" on a list with a
42
+ * `defaultView` (4.105): `?view=none`. Without it a list's plain address
43
+ * is its default view, so clearing the last filter by hand writes it, or
44
+ * the default view's filters would come straight back.
45
+ */
46
+ export declare const NO_VIEW_PARAM = "view";
47
+ /** Every filter that some view's `rule` sets: the ones no control shows. */
48
+ export declare function ruleFilterNames<F extends string, M extends string>(views: Readonly<Record<string, TableView<F, M>>>): F[];
49
+ export type FilterState<F extends string, M extends string> = {
50
+ filters: Record<F, string>;
51
+ multiFilters: Record<M, string[]>;
52
+ /** The URL names no filter, so these are the default view's (useTableUrlState's `defaultView`). */
53
+ atDefault: boolean;
54
+ };
55
+ export declare function readFilterState<F extends string, M extends string>(params: URLSearchParams, filterNames: readonly F[], multiFilterNames: readonly M[], defaultView?: TableView<F, M>): FilterState<F, M>;
56
+ export declare function filterChanges<F extends string, M extends string>(state: FilterState<F, M>, changes: Readonly<Record<string, string | string[] | undefined>>, ruleNames: readonly F[], hasDefault: boolean): UrlChanges;
29
57
  export declare function activeViewOf<F extends string, M extends string, V extends string>(views: Readonly<Record<V, TableView<F, M>>>, filters: Readonly<Record<F, string>>, multiFilters: Readonly<Record<M, readonly string[]>>): V | null;
30
58
  export {};
@@ -22,17 +22,86 @@ export function applyUrlChanges(previous, changes) {
22
22
  // are set, and any the view doesn't name are cleared. Merging over the
23
23
  // current state instead would let a leftover filter silently show something
24
24
  // other than the view. Decided with the developer on 2026-09-28.
25
- export function viewToUrlChanges(filterNames, multiFilterNames, view) {
25
+ //
26
+ // The view the list opens on (`asDefault`, useTableUrlState's
27
+ // `defaultView`) is written as no filters at all, so the list's plain
28
+ // address is that view (readFilterState fills its filters back in).
29
+ export function viewToUrlChanges(filterNames, multiFilterNames, view, asDefault = false) {
30
+ const own = asDefault ? {} : viewFilters(view);
26
31
  return {
27
- ...Object.fromEntries(filterNames.map((name) => [name, view.filters?.[name] ?? ''])),
28
- ...Object.fromEntries(multiFilterNames.map((name) => [name, view.multiFilters?.[name] ?? []])),
32
+ // First, so a list's own filter of that name (one with no default view) wins.
33
+ [NO_VIEW_PARAM]: null,
34
+ ...Object.fromEntries(filterNames.map((name) => [name, own[name] ?? ''])),
35
+ ...Object.fromEntries(multiFilterNames.map((name) => [name, asDefault ? [] : (view.multiFilters?.[name] ?? [])])),
29
36
  sort: view.sort ? serializeSort(view.sort) : null,
30
37
  ...(view.group === undefined ? {} : { group: view.group || null }),
31
38
  page: null,
32
39
  };
33
40
  }
34
- // Which of `views` the current filters are: the first whose filters and
35
- // multi filters equal the URL's exactly (multi filters in any order), or
41
+ // A view's single-value filters with its rule: everything it sets.
42
+ function viewFilters(view) {
43
+ return { ...view.filters, ...view.rule };
44
+ }
45
+ /**
46
+ * The query parameter that says "no view, no filters" on a list with a
47
+ * `defaultView` (4.105): `?view=none`. Without it a list's plain address
48
+ * is its default view, so clearing the last filter by hand writes it, or
49
+ * the default view's filters would come straight back.
50
+ */
51
+ export const NO_VIEW_PARAM = 'view';
52
+ /** Every filter that some view's `rule` sets: the ones no control shows. */
53
+ export function ruleFilterNames(views) {
54
+ const names = new Set();
55
+ for (const view of Object.values(views))
56
+ for (const name of Object.keys(view.rule ?? {}))
57
+ names.add(name);
58
+ return [...names];
59
+ }
60
+ // The filters the bar shows and the query uses: the URL's, or, at a
61
+ // list's plain address (no filter and no `?view=none`), its default
62
+ // view's. So the default view's controls show what it means, the same as
63
+ // any other view's.
64
+ export function readFilterState(params, filterNames, multiFilterNames, defaultView) {
65
+ const named = filterNames.some((name) => Boolean(params.get(name))) || multiFilterNames.some((name) => params.getAll(name).length > 0);
66
+ const atDefault = defaultView !== undefined && !named && params.get(NO_VIEW_PARAM) !== 'none';
67
+ const own = atDefault ? viewFilters(defaultView) : {};
68
+ return {
69
+ filters: Object.fromEntries(filterNames.map((name) => [name, atDefault ? (own[name] ?? '') : (params.get(name) ?? '')])),
70
+ multiFilters: Object.fromEntries(multiFilterNames.map((name) => [
71
+ name,
72
+ atDefault ? [...(defaultView.multiFilters?.[name] ?? [])] : params.getAll(name),
73
+ ])),
74
+ atDefault,
75
+ };
76
+ }
77
+ // The URL changes for the reader changing filters by hand (setFilter,
78
+ // setFilters, setMultiFilter), 4.105:
79
+ // - every filter they didn't touch keeps the value the bar shows, even at
80
+ // the plain address where those come from the default view, so their
81
+ // change is the only change;
82
+ // - a view's `rule` is cleared, since no control shows it and the view it
83
+ // belonged to is no longer what's on;
84
+ // - with a `defaultView`, a result with no filter at all is written
85
+ // `?view=none`, so it stays empty instead of turning back into the
86
+ // default view.
87
+ // The page returns to 1. Which view is on follows from the result
88
+ // (activeViewOf): one whose filters it equals, often none.
89
+ export function filterChanges(state, changes, ruleNames, hasDefault) {
90
+ const next = {
91
+ ...(state.atDefault ? { ...state.filters, ...state.multiFilters } : {}),
92
+ ...Object.fromEntries(ruleNames.map((name) => [name, ''])),
93
+ };
94
+ for (const [name, value] of Object.entries(changes))
95
+ if (value !== undefined)
96
+ next[name] = value;
97
+ const result = { ...state.filters, ...state.multiFilters, ...next };
98
+ const empty = Object.values(result).every((value) => (Array.isArray(value) ? value.length === 0 : !value));
99
+ // The marker only on a list with a default view: without one, `view`
100
+ // may be a filter of the list's own, and is left alone.
101
+ return { ...next, ...(hasDefault ? { [NO_VIEW_PARAM]: empty ? 'none' : null } : {}), page: null };
102
+ }
103
+ // Which of `views` the current filters are: the first whose filters (with
104
+ // its `rule`) and multi filters equal the URL's exactly (multi filters in any order), or
36
105
  // null. A view is active only while it is still "this combination and
37
106
  // nothing else", so adding or changing any filter returns the table to its
38
107
  // default columns: a view's columns are chosen for the records its filters
@@ -41,7 +110,7 @@ export function viewToUrlChanges(filterNames, multiFilterNames, view) {
41
110
  // the developer on 2026-10-05.
42
111
  export function activeViewOf(views, filters, multiFilters) {
43
112
  const sameItems = (a, b) => a.length === b.length && [...a].sort().every((item, index) => item === [...b].sort()[index]);
44
- const matches = (view) => Object.keys(filters).every((name) => filters[name] === (view.filters?.[name] ?? '')) &&
113
+ const matches = (view) => Object.keys(filters).every((name) => filters[name] === (viewFilters(view)[name] ?? '')) &&
45
114
  Object.keys(multiFilters).every((name) => sameItems(multiFilters[name], view.multiFilters?.[name] ?? []));
46
115
  return Object.keys(views).find((id) => matches(views[id])) ?? null;
47
116
  }
@@ -21,7 +21,17 @@ export type TableUrlStateOptions = {
21
21
  */
22
22
  pageSizeStorageKey?: string;
23
23
  };
24
- export declare function useTableUrlState<F extends string, M extends string = never, V extends string = never>(filterNames: readonly F[], multiFilterNames?: readonly M[], views?: Readonly<Record<V, TableView<NoInfer<F>, NoInfer<M>>>>, { groupStorageKey, pageSizes, defaultPageSize, pageSizeStorageKey, }?: TableUrlStateOptions): {
24
+ /** useTableUrlState's options, with the view the list opens on. */
25
+ export type TableUrlStateViewOptions<V extends string> = TableUrlStateOptions & {
26
+ /**
27
+ * The view the list opens on (4.105): at the list's plain address its
28
+ * filters fill the bar and its pill is pressed. Write that view's whole
29
+ * meaning in its filters (`{ status: ['active', 'paused'] }`, not `{}`
30
+ * with the server's default doing the rest), so the bar shows it.
31
+ */
32
+ defaultView?: V;
33
+ };
34
+ export declare function useTableUrlState<F extends string, M extends string = never, V extends string = never>(filterNames: readonly F[], multiFilterNames?: readonly M[], views?: Readonly<Record<V, TableView<NoInfer<F>, NoInfer<M>>>>, { groupStorageKey, pageSizes, defaultPageSize, pageSizeStorageKey, defaultView, }?: TableUrlStateViewOptions<NoInfer<V>>): {
25
35
  page: number;
26
36
  sorting: SortingState;
27
37
  filters: Record<F, string>;
@@ -37,7 +47,7 @@ export declare function useTableUrlState<F extends string, M extends string = ne
37
47
  setFilter: (name: F, value: string) => void;
38
48
  setFilters: (changes: Partial<Record<F, string>> & Partial<Record<M, string[]>>) => void;
39
49
  setMultiFilter: (name: M, values: string[]) => void;
40
- applyView: (view: TableView<F, M>) => void;
50
+ applyView: (view: TableView<F, M>, id?: string) => void;
41
51
  };
42
52
  /** The rows per page: the URL's if it's one of the choices, then the remembered one, then the default. */
43
53
  export declare function resolvePageSize(pageSizes: readonly number[], fromUrl: string | null, remembered: string | null, defaultPageSize: number): number;
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useSyncExternalStore } from 'react';
2
2
  import { useSearchParams } from 'react-router';
3
- import { activeViewOf, applyUrlChanges, serializeSort, viewToUrlChanges, } from './table-url-changes.js';
3
+ import { activeViewOf, applyUrlChanges, filterChanges, readFilterState, ruleFilterNames, serializeSort, viewToUrlChanges, } from './table-url-changes.js';
4
4
  import { browserStore } from './use-table-layout.js';
5
5
  const DEFAULT_PAGE_SIZES = [25, 50, 100];
6
6
  // A table's page, sort and filters, kept in the URL query string
@@ -18,6 +18,18 @@ const DEFAULT_PAGE_SIZES = [25, 50, 100];
18
18
  // counts as active); pass that view's `columns` to DataTable. A view is
19
19
  // pressed with applyView().
20
20
  //
21
+ // Views fill the filters (4.105). A view's `filters` and `multiFilters` are
22
+ // what the bar's controls show while it's on, so the bar says why rows are
23
+ // hidden; write each view's whole meaning there. `defaultView` names the
24
+ // view the list opens on: at the list's plain address (no filter in the
25
+ // URL) `filters` and `multiFilters` are that view's and it's the active
26
+ // one, and pressing it goes back to the plain address. Changing a filter
27
+ // by hand keeps every other filter the bar shows (the default view's
28
+ // too), clears any view's `rule` (what no control shows), and the pills
29
+ // follow: the view the result equals, usually none. Clearing every
30
+ // filter by hand on a list with a default view writes `?view=none`, so
31
+ // the list stays unfiltered.
32
+ //
21
33
  // `pageSize` is the rows per page, for the query and DataTable: `?size=` in
22
34
  // the URL, then the one remembered under `pageSizeStorageKey`, then
23
35
  // `defaultPageSize`; `setPageSize` (DataTable's `onPageSizeChange`) picks
@@ -30,7 +42,7 @@ const DEFAULT_PAGE_SIZES = [25, 50, 100];
30
42
  // names a `group` sets it when pressed.
31
43
  //
32
44
  // Every setter is one update(), and must stay one: see setFilters.
33
- export function useTableUrlState(filterNames, multiFilterNames = [], views = {}, { groupStorageKey, pageSizes = DEFAULT_PAGE_SIZES, defaultPageSize = 50, pageSizeStorageKey, } = {}) {
45
+ export function useTableUrlState(filterNames, multiFilterNames = [], views = {}, { groupStorageKey, pageSizes = DEFAULT_PAGE_SIZES, defaultPageSize = 50, pageSizeStorageKey, defaultView, } = {}) {
34
46
  const [params, setParams] = useSearchParams();
35
47
  const rememberedPageSize = useRemembered(pageSizeStorageKey);
36
48
  const pageSize = resolvePageSize(pageSizes, params.get('size'), rememberedPageSize, defaultPageSize);
@@ -43,9 +55,13 @@ export function useTableUrlState(filterNames, multiFilterNames = [], views = {},
43
55
  const page = Math.max(1, Math.floor(Number(params.get('page'))) || 1);
44
56
  const [sortField, sortDir] = (params.get('sort') ?? '').split(':');
45
57
  const sorting = sortField ? [{ id: sortField, desc: sortDir === 'desc' }] : [];
46
- const filters = Object.fromEntries(filterNames.map((name) => [name, params.get(name) ?? '']));
47
- const multiFilters = Object.fromEntries(multiFilterNames.map((name) => [name, params.getAll(name)]));
58
+ const fallback = defaultView === undefined ? undefined : views[defaultView];
59
+ const state = readFilterState(params, filterNames, multiFilterNames, fallback);
60
+ const { filters, multiFilters } = state;
48
61
  const activeView = activeViewOf(views, filters, multiFilters);
62
+ const ruleNames = ruleFilterNames(views);
63
+ // The reader changing filters by hand: see filterChanges.
64
+ const changeFilters = (changes) => update(filterChanges(state, changes, ruleNames, fallback !== undefined));
49
65
  function update(changes) {
50
66
  setParams((previous) => applyUrlChanges(previous, changes), { replace: true });
51
67
  }
@@ -69,21 +85,26 @@ export function useTableUrlState(filterNames, multiFilterNames = [], views = {},
69
85
  },
70
86
  setPage: (next) => update({ page: next > 1 ? String(next) : null }),
71
87
  setSorting: (next) => update({ sort: serializeSort(next), page: null }),
72
- setFilter: (name, value) => update({ [name]: value, page: null }),
88
+ setFilter: (name, value) => changeFilters({ [name]: value }),
73
89
  // Several filters in one call — for any user action that changes more
74
90
  // than one (both ends of a date range, "clear filters"). Two setters in
75
91
  // the same tick lose all but the last: react-router hands each
76
92
  // setSearchParams updater the params from the last render, not the
77
93
  // ones the previous updater produced. Single-value filters take a
78
94
  // string ('' clears), multi-value ones a list ([] clears).
79
- setFilters: (changes) => update({ ...changes, page: null }),
80
- setMultiFilter: (name, values) => update({ [name]: values, page: null }),
95
+ setFilters: (changes) => changeFilters(changes),
96
+ setMultiFilter: (name, values) => changeFilters({ [name]: values }),
81
97
  // Replaces the whole filter + sort state at once — a saved view. See
82
98
  // viewToUrlChanges() for why anything the view doesn't set is cleared.
83
- applyView: (view) => {
99
+ // The default view (by `id`, as DataTable's onViewChange passes it, or
100
+ // the same object) goes back to the list's plain address. `{}` is
101
+ // "no filters": the plain address too, so the default view on a list
102
+ // that has one.
103
+ applyView: (view, id) => {
84
104
  if (view.group !== undefined)
85
105
  rememberGrouping(view.group);
86
- update(viewToUrlChanges(filterNames, multiFilterNames, view));
106
+ const asDefault = fallback !== undefined && (id === defaultView || view === fallback);
107
+ update(viewToUrlChanges(filterNames, multiFilterNames, view, asDefault));
87
108
  },
88
109
  };
89
110
  }
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';
@@ -112,7 +113,7 @@ export type { AuthContextValue, AuthStatus, AuthUser, SignInResult } from './aut
112
113
  export type { AppError, Page, QuerySpec } from './api/contracts.js';
113
114
  export type { ErrorReportingOptions } from './error-reporting/reporter.js';
114
115
  export { createQueryClient } from './api/query-client.js';
115
- export { useTableUrlState, type TableUrlStateOptions } from './hooks/use-table-url-state.js';
116
+ export { useTableUrlState, type TableUrlStateOptions, type TableUrlStateViewOptions } from './hooks/use-table-url-state.js';
116
117
  export { useTableLayout, type TableLayoutOptions } from './hooks/use-table-layout.js';
117
118
  export { useWidgetLayout, createWidgetLayoutStore, mergeWidgetLayout, type SavedWidgetLayout, type WidgetLayout, type WidgetLayoutOptions, type WidgetLayoutStore, } from './hooks/use-widget-layout.js';
118
119
  export type { TableView, UrlChanges } from './hooks/table-url-changes.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.104.0",
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": {
package/styles/index.css CHANGED
@@ -60,6 +60,7 @@
60
60
  --color-info-foreground: var(--info-foreground);
61
61
  --color-info-text: var(--info-text);
62
62
  --color-link: var(--link);
63
+ --color-primary-text: var(--primary-text);
63
64
  --color-card-header: var(--card-header);
64
65
  --color-highlight-amber: var(--highlight-amber);
65
66
  --color-highlight-yellow: var(--highlight-yellow);
@@ -492,6 +493,7 @@
492
493
  --warning-text: var(--amber-800);
493
494
  --info-text: var(--blue-800);
494
495
  --link: var(--blue-700);
496
+ --primary-text: var(--gray-950);
495
497
  --highlight-amber: oklch(0.9 0.1 75);
496
498
  --highlight-yellow: oklch(0.94 0.13 100);
497
499
  --highlight-green: oklch(0.9 0.1 150);
package/styles/theme.css CHANGED
@@ -645,6 +645,10 @@
645
645
  /* A link in written text: coloured as well as underlined, so it reads
646
646
  as a link at a glance (on white: 5.59). */
647
647
  --link: var(--blue-700);
648
+ /* The theme colour as text (4.105): what's picked or open, such as the
649
+ open tab's name and a picked choice, in the primary's own colour where
650
+ it reads as text. Here it's the primary (near-black, 17.7 on white). */
651
+ --primary-text: var(--primary);
648
652
  /* Highlighted words in written text (the notes editor's highlight, four
649
653
  colours): a wash behind words that keep --foreground. Light washes,
650
654
  text on each measures 11 or more. */
@@ -957,6 +961,7 @@
957
961
  --warning-text: var(--amber-400);
958
962
  --info-text: var(--blue-400);
959
963
  --link: var(--blue-400); /* on near-black: 8.90 */
964
+ --primary-text: var(--primary); /* near-white on near-black */
960
965
  /* Highlighted words: deep washes, --foreground on each measures 7 or more. */
961
966
  --highlight-amber: oklch(0.42 0.09 75);
962
967
  --highlight-yellow: oklch(0.44 0.09 100);
@@ -1182,6 +1187,7 @@
1182
1187
  --success-text: var(--palette-success);
1183
1188
  --warning-text: var(--palette-warning);
1184
1189
  --link: var(--palette-indigo-cyan-accent-light);
1190
+ --primary-text: var(--palette-indigo-cyan-accent-light);
1185
1191
  --heading-bar: var(--palette-indigo-cyan-accent-light);
1186
1192
  --rule: var(--palette-indigo-cyan-strong-border);
1187
1193
  --table-highlight-muted-foreground: var(--palette-indigo-cyan-dim);
@@ -1223,6 +1229,7 @@
1223
1229
  --success-text: var(--palette-success);
1224
1230
  --warning-text: var(--palette-warning);
1225
1231
  --link: var(--palette-indigo-rose-accent-light);
1232
+ --primary-text: var(--palette-indigo-rose-accent-light);
1226
1233
  --heading-bar: var(--palette-indigo-rose-accent-light);
1227
1234
  --rule: var(--palette-indigo-rose-strong-border);
1228
1235
  --table-highlight-muted-foreground: var(--palette-indigo-rose-dim);
@@ -1264,6 +1271,7 @@
1264
1271
  --success-text: var(--palette-success);
1265
1272
  --warning-text: var(--palette-warning);
1266
1273
  --link: var(--palette-graphite-periwinkle-accent-light);
1274
+ --primary-text: var(--palette-graphite-periwinkle-accent-light);
1267
1275
  --heading-bar: var(--palette-graphite-periwinkle-accent-light);
1268
1276
  --rule: var(--palette-graphite-periwinkle-strong-border);
1269
1277
  --table-highlight-muted-foreground: var(--palette-graphite-periwinkle-dim);
@@ -1305,6 +1313,7 @@
1305
1313
  --success-text: var(--palette-success);
1306
1314
  --warning-text: var(--palette-warning);
1307
1315
  --link: var(--palette-violet-accent-light);
1316
+ --primary-text: var(--palette-violet-accent-light);
1308
1317
  --heading-bar: var(--palette-violet-accent-light);
1309
1318
  --rule: var(--palette-violet-strong-border);
1310
1319
  --table-highlight-muted-foreground: var(--palette-violet-dim);
@@ -1359,6 +1368,7 @@
1359
1368
  --warning-text: var(--palette-palm-lcd-warning);
1360
1369
  --info-text: var(--palette-palm-lcd-info);
1361
1370
  --link: var(--palette-palm-lcd-link);
1371
+ --primary-text: var(--palette-palm-lcd-accent);
1362
1372
  --heading-bar: var(--palette-palm-lcd-link);
1363
1373
  --rule: var(--palette-palm-lcd-border);
1364
1374
  --heading-band: var(--palette-palm-lcd-band);