@tristan2828/ui-foundation 4.74.0 → 4.75.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.
@@ -35,10 +35,10 @@
35
35
  - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1391–1401
36
36
  - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1403–1469
37
37
  - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1471–1535
38
- - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1537–1605
39
- - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1607–1635
40
- - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1637–1713
41
- - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1715–1738
38
+ - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1537–1618
39
+ - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1620–1648
40
+ - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1650–1726
41
+ - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1728–1751
42
42
 
43
43
  <!-- /index -->
44
44
 
@@ -1583,6 +1583,19 @@ const { page, filters, setFilter, setPage } = useTableUrlState(['kind'])
1583
1583
  in the group's own `<tbody>`), so a screen reader names a cell's group
1584
1584
  as it names its column. It stays in view while a wide table scrolls
1585
1585
  sideways.
1586
+ - **`stickyGroupHeadings`** pins the headings while their groups scroll,
1587
+ for a list long enough that "which day is this?" gets lost: each
1588
+ heading sticks below the column header, which is pinned with it (with
1589
+ `header={false}`, at the very top), until the next group's slides
1590
+ over it. It works under `groupBy` and a grouping alike, and does nothing
1591
+ to a table that isn't grouped or to a card layout. When the columns fit
1592
+ (a feed, most lists on a phone) they stick to the page's own scroll.
1593
+ When they're wider than the screen the table has to scroll sideways, and
1594
+ a box that scrolls sideways is what sticky cells stick to, so the table
1595
+ becomes a box no taller than the screen and scrolls both ways inside
1596
+ it. An ancestor of your own with `overflow` set (a card with
1597
+ `overflow-hidden`, say) takes the place of the page: leave it off such a
1598
+ table's ancestors.
1586
1599
  - **`header={false}`** for a list-like table whose columns explain
1587
1600
  themselves (a thumbnail with a title block, then actions). The header
1588
1601
  row takes no room but stays in the table, so the columns keep their
@@ -19,16 +19,16 @@
19
19
  - [Density](#density) · lines 587–673
20
20
  - [Rows on this device](#rows-on-this-device) · lines 646–673
21
21
  - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 675–789
22
- - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 791–860
23
- - [Notices](#notices) · lines 862–890
24
- - [A value over time](#a-value-over-time) · lines 892–978
25
- - [Several values over time](#several-values-over-time) · lines 941–978
26
- - [A list as a board](#a-list-as-a-board) · lines 980–1031
27
- - [A list as cards](#a-list-as-cards) · lines 1033–1079
28
- - [Key numbers on a record](#key-numbers-on-a-record) · lines 1081–1103
29
- - [Picking at random](#picking-at-random) · lines 1105–1136
30
- - [Filling in what's missing](#filling-in-whats-missing) · lines 1138–1205
31
- - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1207–1232
22
+ - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 791–868
23
+ - [Notices](#notices) · lines 870–898
24
+ - [A value over time](#a-value-over-time) · lines 900–986
25
+ - [Several values over time](#several-values-over-time) · lines 949–986
26
+ - [A list as a board](#a-list-as-a-board) · lines 988–1039
27
+ - [A list as cards](#a-list-as-cards) · lines 1041–1087
28
+ - [Key numbers on a record](#key-numbers-on-a-record) · lines 1089–1111
29
+ - [Picking at random](#picking-at-random) · lines 1113–1144
30
+ - [Filling in what's missing](#filling-in-whats-missing) · lines 1146–1213
31
+ - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1215–1240
32
32
 
33
33
  <!-- /index -->
34
34
 
@@ -847,15 +847,23 @@ const { data, isLoading, error, refetch } = useProjectsSummaryQuery()
847
847
  hub's widgets should start on the first screen, or there are more
848
848
  places than six tiles: below the sidebar's breakpoint the strip is one
849
849
  row that scrolls sideways, a chip per place with its icon in its slot's
850
- colour, its name and its number (no note, no action). While the number
851
- loads, a small skeleton; on an error, a muted dash ("Couldn't load" to
850
+ colour, its name and its number (no action, and no note unless the card
851
+ sets `noteOnChip`). While the number loads, a small skeleton; on an
852
+ error, a muted dash ("Couldn't load" to
852
853
  a screen reader), with Retry left to the desktop card and the place's
853
854
  own page. The row scrolls inside itself and the page never does. A
854
855
  desktop shows the cards either way, so don't render your own row
855
856
  beside a strip hidden on a phone.
857
+ - **`noteOnChip`** puts a card's `note` on its chip, after the number,
858
+ for a word or two the number means little without ("5 new"). A rule of
859
+ the card, so a strip can show it on the chips that need it. It stays on
860
+ the chip's one line in caption type, cut off with an ellipsis past 96px
861
+ (the whole note is still read out), so every chip keeps its height and
862
+ a long note can't take over the row. It stays while the number loads,
863
+ so the chip doesn't change width, and goes on an error, as on the card.
856
864
  - The fixtures' `app/ModuleCard` shows a hub with a strip and a widget,
857
865
  every state, both at `compact`, and both again as a row of chips (Row,
858
- Row states); its checks run axe and the token and glyph checks in both
866
+ Row states, Row notes); its checks run axe and the token and glyph checks in both
859
867
  themes and at `large`, measure the strip at a desktop and a phone
860
868
  width, and run axe on the chips at a phone's.
861
869
 
@@ -87,6 +87,16 @@ export type DataTableProps<TData extends Record<string, unknown>> = {
87
87
  * a grouping's alike. `group` says which group it is.
88
88
  */
89
89
  groupSummary?: (rows: TData[], group: RowGroup) => ReactNode;
90
+ /**
91
+ * While rows are grouped (`groupBy` or a grouping), pins each heading
92
+ * below the column header while its group scrolls past, and pins the
93
+ * column header above it. When the columns fit, they stick to whatever
94
+ * scrolls the page. When they don't, the table scrolls both ways inside
95
+ * a box no taller than the screen, and they stick to that. The table
96
+ * layout's alone: a card layout's headings scroll with their cards.
97
+ * Ungrouped, it changes nothing.
98
+ */
99
+ stickyGroupHeadings?: boolean;
90
100
  /**
91
101
  * The fields the rows can be grouped by, picked in a Group menu at the
92
102
  * end of the toolbar: None (the default, the table as it is without
@@ -274,4 +284,4 @@ export type DataTableTotals = {
274
284
  */
275
285
  cells?: Partial<Record<string, ReactNode>>;
276
286
  };
277
- export declare function DataTable<TData extends Record<string, unknown>>({ columns, data, total, page, pageSize, onPageChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width, groupBy, groupSummary, header: showHeader, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel, }: DataTableProps<TData>): import("react").JSX.Element;
287
+ export declare function DataTable<TData extends Record<string, unknown>>({ columns, data, total, page, pageSize, onPageChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width, groupBy, groupSummary, stickyGroupHeadings, header: showHeader, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel, }: DataTableProps<TData>): import("react").JSX.Element;
@@ -181,6 +181,25 @@ const HIDDEN_HEAD_CLASS = 'h-0 p-0';
181
181
  const ALIGN_CLASS = { center: 'text-center', right: 'text-right' };
182
182
  const alignClass = (align) => align && ALIGN_CLASS[align];
183
183
  const GROUP_HEADING_CLASS = 'h-auto bg-background pt-4 pb-1.5 align-bottom';
184
+ // `stickyGroupHeadings`. An `overflow-x-auto` box scrolls on both axes as far
185
+ // as `position: sticky` is concerned, so a cell inside it sticks to that box
186
+ // and never to the page. When the columns fit, the box only clips, which
187
+ // leaves the page's scroll to stick to. When they don't, the box has to
188
+ // scroll sideways, so it's bounded to the screen and scrolls down too.
189
+ // `isolate` keeps these z-indexes inside the table.
190
+ const STICKY_PAGE_SCROLL_CLASS = 'isolate overflow-x-clip';
191
+ const STICKY_OWN_SCROLL_CLASS = 'isolate max-h-dvh overflow-auto';
192
+ // Collapsed borders stay where the row was, so a stuck cell draws its rule
193
+ // as an inset shadow and its row's border comes off. Above the pinned
194
+ // columns (z-10): the column header over the headings over the rows. A
195
+ // cell's sticky bounds are the whole table, not its group, so a heading isn't
196
+ // pushed off by the next: the next slides over it, later in the DOM and opaque.
197
+ const STICKY_RULE_CLASS = 'shadow-[inset_0_-1px_0_0_var(--border)]';
198
+ const STICKY_HEAD_CELL_CLASS = `sticky top-0 z-30 bg-background ${STICKY_RULE_CLASS}`;
199
+ const STICKY_GROUP_HEADING_CLASS = `sticky top-(--data-table-head-height) z-20 pt-2 ${STICKY_RULE_CLASS}`;
200
+ // What focus scrolls to clears the stuck header and heading (3rem covers a
201
+ // heading's height, large density included).
202
+ const STICKY_FOCUS_CLASS = '[&_tbody_*]:scroll-mt-[calc(var(--data-table-head-height)+--spacing(12))]';
184
203
  // A grouping's heading (`groupings`) is a button that folds its rows: the
185
204
  // label, then the count, a chevron that turns when folded.
186
205
  const GROUP_TOGGLE_CLASS = '-mx-1 inline-flex items-baseline gap-2 rounded-sm px-1 outline-none hover:underline ' +
@@ -270,7 +289,34 @@ function useBottomScrollbar(containerRef, isSuccessView) {
270
289
  }, [containerRef, isSuccessView, isOverflowing]);
271
290
  return { barRef, isOverflowing, scrollWidth };
272
291
  }
273
- export function DataTable({ columns, data, total, page, pageSize, onPageChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width = 'full', groupBy, groupSummary, header: showHeader = true, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel = 'Details', }) {
292
+ // `stickyGroupHeadings`: whether the columns are wider than their box, which
293
+ // picks what the headings stick to, and the column header's measured height,
294
+ // which is where they stick (a header can wrap, or be hidden, so it isn't
295
+ // always --table-head-height). A layout effect, so the first paint is right.
296
+ // The table's width, not the box's scrollWidth: it reads the same in either
297
+ // mode, and a scrollbar the bounded box draws can't flip the answer back.
298
+ function useStickyHeadings(containerRef, enabled) {
299
+ const [scrollsSideways, setScrollsSideways] = useState(false);
300
+ const [headHeight, setHeadHeight] = useState(0);
301
+ useLayoutEffect(() => {
302
+ const container = containerRef.current;
303
+ const contentTable = container?.querySelector('table');
304
+ const head = contentTable?.querySelector('thead');
305
+ if (!enabled || !container || !contentTable || !head)
306
+ return;
307
+ const measure = () => {
308
+ setScrollsSideways(contentTable.getBoundingClientRect().width > container.getBoundingClientRect().width + 0.5);
309
+ setHeadHeight(head.getBoundingClientRect().height);
310
+ };
311
+ measure();
312
+ const resizeObserver = new ResizeObserver(measure);
313
+ resizeObserver.observe(container);
314
+ resizeObserver.observe(contentTable);
315
+ return () => resizeObserver.disconnect();
316
+ }, [containerRef, enabled]);
317
+ return { scrollsSideways, headHeight };
318
+ }
319
+ export function DataTable({ columns, data, total, page, pageSize, onPageChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width = 'full', groupBy, groupSummary, stickyGroupHeadings = false, header: showHeader = true, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel = 'Details', }) {
274
320
  // The switch's own state, for a table that doesn't pass `layout`.
275
321
  const [ownLayout, setOwnLayout] = useState('table');
276
322
  const requestedLayout = layoutProp ?? ownLayout;
@@ -400,6 +446,8 @@ export function DataTable({ columns, data, total, page, pageSize, onPageChange,
400
446
  : groupBy
401
447
  ? groupRuns(rows, (row) => groupBy(row.original)).map((run) => ({ ...run, foldable: false }))
402
448
  : null;
449
+ const stickyGroups = stickyGroupHeadings && runs !== null && !cardLayout;
450
+ const { scrollsSideways, headHeight } = useStickyHeadings(containerRef, stickyGroups && isSuccessView);
403
451
  const allFolded = runs !== null && runs.length > 0 && runs.every((run) => folded.has(run.key));
404
452
  const toggleFold = (key) => {
405
453
  if (!activeGrouping)
@@ -545,7 +593,7 @@ export function DataTable({ columns, data, total, page, pageSize, onPageChange,
545
593
  return;
546
594
  event.preventDefault();
547
595
  closeDetail();
548
- }, children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("h2", { className: "type-label text-muted-foreground", children: detailLabel }), _jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": "Close", onClick: closeDetail, children: _jsx(XIcon, { "aria-hidden": "true" }) })] }), detailPanel(selectedRow.original)] })) : null, children: [cardLayout ? (_jsx(Cards, { layout: cardLayout, runs: runs, rows: rows, folded: folded, onToggleFold: toggleFold, groupSummary: groupSummary, groupIcons: groupIcons, onCardClick: onCardClick })) : (_jsxs(Table, { "data-state": "success", containerRef: containerRef, onKeyDown: rowsOpen ? onListKeyDown : undefined,
596
+ }, children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("h2", { className: "type-label text-muted-foreground", children: detailLabel }), _jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": "Close", onClick: closeDetail, children: _jsx(XIcon, { "aria-hidden": "true" }) })] }), detailPanel(selectedRow.original)] })) : null, children: [cardLayout ? (_jsx(Cards, { layout: cardLayout, runs: runs, rows: rows, folded: folded, onToggleFold: toggleFold, groupSummary: groupSummary, groupIcons: groupIcons, onCardClick: onCardClick })) : (_jsxs(Table, { "data-state": "success", containerRef: containerRef, onKeyDown: rowsOpen ? onListKeyDown : undefined, className: cn(stickyGroups && STICKY_FOCUS_CLASS), style: stickyGroups ? { '--data-table-head-height': `${headHeight}px` } : undefined,
549
597
  // With the sticky bar below as the visible scrollbar, hide the
550
598
  // container's own. It stays overflow-x-auto and fully
551
599
  // scrollable (wheel, trackpad, drag, and the sync effect); it
@@ -556,7 +604,7 @@ export function DataTable({ columns, data, total, page, pageSize, onPageChange,
556
604
  // `width="content"` couldn't fit the table. Its query only
557
605
  // serves a phone-width rule, and an 80rem table area never
558
606
  // is one.
559
- width === 'content' && '@7xl/data-table:[container-type:normal]'), children: [_jsx(TableHeader, { className: cn(!showHeader && '[&_tr]:border-0'), children: table.getHeaderGroups().map((headerGroup) => (_jsx(TableRow, { children: headerGroup.headers.map((header, index) => {
607
+ width === 'content' && '@7xl/data-table:[container-type:normal]', stickyGroups && (scrollsSideways ? STICKY_OWN_SCROLL_CLASS : STICKY_PAGE_SCROLL_CLASS)), children: [_jsx(TableHeader, { className: cn((!showHeader || stickyGroups) && '[&_tr]:border-0'), children: table.getHeaderGroups().map((headerGroup) => (_jsx(TableRow, { children: headerGroup.headers.map((header, index) => {
560
608
  const canSort = header.column.getCanSort();
561
609
  const sortDirection = header.column.getIsSorted();
562
610
  // Hidden, a header is its name only: a sort button no
@@ -567,7 +615,7 @@ export function DataTable({ columns, data, total, page, pageSize, onPageChange,
567
615
  header.column.columnDef.meta?.align === 'right' && 'ml-auto flex-row-reverse'), onClick: header.column.getToggleSortingHandler(), children: [flexRender(header.column.columnDef.header, header.getContext()), sortDirection === 'asc' ? (_jsx(ArrowUpIcon, { className: "size-3.5 text-muted-foreground" })) : sortDirection === 'desc' ? (_jsx(ArrowDownIcon, { className: "size-3.5 text-muted-foreground" })) : (_jsx(ArrowUpDownIcon, { className: "size-3.5 text-muted-foreground/50" }))] })) : (flexRender(header.column.columnDef.header, header.getContext()));
568
616
  return (_jsx(TableHead, { className: cn(!showHeader && HIDDEN_HEAD_CLASS, pinFirstColumn && index === 0 && PINNED_COLUMN_CLASS, pinLastColumn &&
569
617
  index === headerGroup.headers.length - 1 &&
570
- PINNED_LAST_COLUMN_CLASS, alignClass(header.column.columnDef.meta?.align)), "aria-sort": !canSort
618
+ PINNED_LAST_COLUMN_CLASS, stickyGroups && showHeader && STICKY_HEAD_CELL_CLASS, alignClass(header.column.columnDef.meta?.align)), "aria-sort": !canSort
571
619
  ? undefined
572
620
  : sortDirection === 'asc'
573
621
  ? 'ascending'
@@ -576,7 +624,7 @@ export function DataTable({ columns, data, total, page, pageSize, onPageChange,
576
624
  : 'none', children: !showHeader ? (_jsx("span", { className: "sr-only", children: content })) : pinFirstColumn && index === 0 ? (_jsx("div", { className: PINNED_FIRST_CONTENT_CLASS, children: content })) : (content) }, header.id));
577
625
  }) }, headerGroup.id))) }), runs ? (runs.map((run, runIndex) => {
578
626
  const isFolded = folded.has(run.key);
579
- return (_jsxs(TableBody, { "data-slot": "table-group", "data-folded": isFolded || undefined, children: [_jsx(TableRow, { "data-slot": "table-group-heading", className: "hover:bg-transparent has-aria-expanded:bg-transparent", children: _jsx(TableHead, { scope: "rowgroup", colSpan: visibleColumnCount, className: GROUP_HEADING_CLASS, children: _jsxs("span", { className: "sticky left-(--table-cell-px) inline-flex items-baseline gap-2", children: [_jsx(GroupLabel, { run: run, icon: groupIcons?.get(run.key), isFolded: isFolded, onToggle: () => toggleFold(run.key) }), groupSummary && (_jsx("span", { className: "type-caption text-muted-foreground tabular-nums", children: groupSummary(run.rows.map((row) => row.original), { key: run.key, label: run.label }) }))] }) }) }), _jsx("tr", { hidden: true, "aria-hidden": "true", "data-slot": "table-group-stripe-offset" }), !isFolded && run.rows.map((row) => renderRow(row, placeKey(run.key, row.id)))] }, `${runIndex}:${run.key}`));
627
+ return (_jsxs(TableBody, { "data-slot": "table-group", "data-folded": isFolded || undefined, children: [_jsx(TableRow, { "data-slot": "table-group-heading", className: cn('hover:bg-transparent has-aria-expanded:bg-transparent', stickyGroups && 'border-b-0'), children: _jsx(TableHead, { scope: "rowgroup", colSpan: visibleColumnCount, className: cn(GROUP_HEADING_CLASS, stickyGroups && STICKY_GROUP_HEADING_CLASS), children: _jsxs("span", { className: "sticky left-(--table-cell-px) inline-flex items-baseline gap-2", children: [_jsx(GroupLabel, { run: run, icon: groupIcons?.get(run.key), isFolded: isFolded, onToggle: () => toggleFold(run.key) }), groupSummary && (_jsx("span", { className: "type-caption text-muted-foreground tabular-nums", children: groupSummary(run.rows.map((row) => row.original), { key: run.key, label: run.label }) }))] }) }) }), _jsx("tr", { hidden: true, "aria-hidden": "true", "data-slot": "table-group-stripe-offset" }), !isFolded && run.rows.map((row) => renderRow(row, placeKey(run.key, row.id)))] }, `${runIndex}:${run.key}`));
580
628
  })) : (_jsx(TableBody, { children: rows.map((row) => renderRow(row)) })), totals && (_jsx(TableFooter, { className: TOTALS_FOOTER_CLASS, children: _jsx(TableRow, { "data-slot": "table-totals", className: "hover:bg-transparent", children: visibleLeafColumns.map((column, index) => {
581
629
  const className = cn(pinFirstColumn && index === 0 && PINNED_TOTALS_LABEL_CLASS, pinLastColumn && index === visibleColumnCount - 1 && PINNED_LAST_COLUMN_CLASS, alignClass(column.columnDef.meta?.align));
582
630
  return index === 0 ? (_jsx(TableHead, { scope: "row", className: cn(TOTALS_LABEL_CLASS, className), children: pinFirstColumn ? (_jsx("div", { className: PINNED_FIRST_CONTENT_CLASS, children: totals.label })) : (totals.label) }, column.id)) : (_jsx(TableCell, { className: className, children: totals.cells?.[column.id] }, column.id));
@@ -30,6 +30,13 @@ export type ModuleCardProps = ModuleCardPlace & {
30
30
  value?: number | string;
31
31
  /** A few words under the number: "open", "due today", "Opens its own app". */
32
32
  note?: string;
33
+ /**
34
+ * Shows `note` on the phone chip too, after the number (`ModuleStrip
35
+ * mobile="row"`): for a word or two the number means little without.
36
+ * One line, cut off with an ellipsis past 96px; gone on an error, as on
37
+ * the card.
38
+ */
39
+ noteOnChip?: boolean;
33
40
  /** One link at the foot of the card (hidden on a phone, where the tile is the link). */
34
41
  action?: ModuleCardLink;
35
42
  /** True while the number loads. */
@@ -40,7 +47,7 @@ export type ModuleCardProps = ModuleCardPlace & {
40
47
  };
41
48
  /** How a ModuleStrip shows its places on a phone: `tiles` (the default), or one sideways `row` of chips. */
42
49
  export type ModuleStripMobile = 'tiles' | 'row';
43
- export declare function ModuleCard({ title, icon: Icon, category, to, href, value, note, action, isLoading, error, onRetry, className, }: ModuleCardProps): import("react").JSX.Element;
50
+ export declare function ModuleCard({ title, icon: Icon, category, to, href, value, note, noteOnChip, action, isLoading, error, onRetry, className, }: ModuleCardProps): import("react").JSX.Element;
44
51
  export interface ModuleStripProps {
45
52
  /** Names the strip's navigation landmark: "Places". */
46
53
  'aria-label': string;
@@ -48,7 +55,7 @@ export interface ModuleStripProps {
48
55
  children: ReactNode;
49
56
  /**
50
57
  * On a phone: three columns of `tiles` (the default), or one `row` of
51
- * chips (icon, name, number) that scrolls sideways, below the sidebar's
58
+ * chips (icon, name, number, and the note with `noteOnChip`) that scrolls sideways, below the sidebar's
52
59
  * breakpoint. A desktop shows the cards either way.
53
60
  */
54
61
  mobile?: ModuleStripMobile;
@@ -30,6 +30,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
30
30
  // renders its chip beside its card, one shown at each width. The row
31
31
  // scrolls inside itself and is `relative`, so a chip's sr-only text
32
32
  // (absolutely placed) scrolls with it instead of widening the page.
33
+ // `noteOnChip` adds the note after the number, on the chip's one line and
34
+ // cut off at a fixed width, so a long note can't crowd the row.
33
35
  import { Children, createContext, useContext, useId } from 'react';
34
36
  import { Link } from 'react-router';
35
37
  import { AlertCircleIcon, ExternalLinkIcon } from 'lucide-react';
@@ -97,12 +99,12 @@ function ChipValue({ state, value }) {
97
99
  return null;
98
100
  return (_jsx("span", { "data-slot": "module-card-chip-value", className: "font-semibold tabular-nums", children: value }));
99
101
  }
100
- function ModuleChip({ title, icon: Icon, category, to, href, value, state, }) {
101
- const content = (_jsxs(_Fragment, { children: [_jsx(Icon, { "aria-hidden": "true", className: cn('size-4 shrink-0', category ? ICON_CLASS[category] : 'text-muted-foreground') }), title, _jsx(ChipValue, { state: state, value: value })] }));
102
+ function ModuleChip({ title, icon: Icon, category, to, href, value, note, state, }) {
103
+ const content = (_jsxs(_Fragment, { children: [_jsx(Icon, { "aria-hidden": "true", className: cn('size-4 shrink-0', category ? ICON_CLASS[category] : 'text-muted-foreground') }), title, _jsx(ChipValue, { state: state, value: value }), note && state !== 'error' && (_jsx("span", { "data-slot": "module-card-chip-note", title: note, className: "max-w-24 truncate type-caption text-muted-foreground", children: note }))] }));
102
104
  const chipProps = { 'data-slot': 'module-card-chip', 'data-state': state, className: cn(CHIP_CLASS, 'md:hidden') };
103
105
  return href !== undefined ? (_jsxs("a", { href: href, target: "_blank", rel: "noreferrer", ...chipProps, children: [content, _jsx(NewTabMark, {})] })) : (_jsx(Link, { to: to, ...chipProps, children: content }));
104
106
  }
105
- export function ModuleCard({ title, icon: Icon, category, to, href, value, note, action, isLoading = false, error, onRetry, className, }) {
107
+ export function ModuleCard({ title, icon: Icon, category, to, href, value, note, noteOnChip = false, action, isLoading = false, error, onRetry, className, }) {
106
108
  const titleId = useId();
107
109
  const bodyId = useId();
108
110
  const state = error ? 'error' : isLoading ? 'loading' : 'success';
@@ -117,7 +119,7 @@ export function ModuleCard({ title, icon: Icon, category, to, href, value, note,
117
119
  (action.href !== undefined ? (_jsxs("a", { href: action.href, target: "_blank", rel: "noreferrer", "aria-describedby": titleId, className: ACTION_CLASS, children: [_jsx("span", { className: "truncate", children: action.label }), _jsx(NewTabMark, {})] })) : (_jsx(Link, { to: action.to, "aria-describedby": titleId, className: ACTION_CLASS, children: _jsx("span", { className: "truncate", children: action.label }) })))] }));
118
120
  if (mobile === 'tiles')
119
121
  return card;
120
- return (_jsxs(_Fragment, { children: [card, _jsx(ModuleChip, { title: title, icon: Icon, category: category, to: to, href: href, value: value, state: state })] }));
122
+ return (_jsxs(_Fragment, { children: [card, _jsx(ModuleChip, { title: title, icon: Icon, category: category, to: to, href: href, value: value, note: noteOnChip ? note : undefined, state: state })] }));
121
123
  }
122
124
  // The list's columns: whole class names, so Tailwind generates them.
123
125
  const STRIP_LIST = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "4.74.0",
3
+ "version": "4.75.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": {