@tristan2828/ui-foundation 4.73.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
@@ -3,31 +3,32 @@
3
3
  <!-- index: written by `npm run docs:index` in the package from the headings below; never edit it by hand -->
4
4
  ## Index
5
5
 
6
- - [Palettes](#palettes) · lines 40–106
7
- - [Glow](#glow) · lines 108–126
8
- - [Semantic tones](#semantic-tones) · lines 128–156
9
- - [The three badge styles](#the-three-badge-styles) · lines 158–175
10
- - [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 177–206
11
- - [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 208–221
12
- - [Logos and brand marks](#logos-and-brand-marks) · lines 223–267
13
- - [Categorical colour](#categorical-colour) · lines 269–339
14
- - [A stored colour](#a-stored-colour) · lines 341–389
15
- - [Shapes and sizes](#shapes-and-sizes) · lines 391–412
16
- - [Typography](#typography) · lines 414–520
17
- - [Written text (notes)](#written-text-notes) · lines 448–520
18
- - [Density](#density) · lines 522–608
19
- - [Rows on this device](#rows-on-this-device) · lines 581–608
20
- - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 610–724
21
- - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 726–795
22
- - [Notices](#notices) · lines 797–825
23
- - [A value over time](#a-value-over-time) · lines 827–913
24
- - [Several values over time](#several-values-over-time) · lines 876–913
25
- - [A list as a board](#a-list-as-a-board) · lines 915–966
26
- - [A list as cards](#a-list-as-cards) · lines 968–1014
27
- - [Key numbers on a record](#key-numbers-on-a-record) · lines 1016–1038
28
- - [Picking at random](#picking-at-random) · lines 1040–1071
29
- - [Filling in what's missing](#filling-in-whats-missing) · lines 1073–1140
30
- - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1142–1167
6
+ - [Palettes](#palettes) · lines 41–108
7
+ - [Glow](#glow) · lines 110–128
8
+ - [Semantic tones](#semantic-tones) · lines 130–158
9
+ - [The three badge styles](#the-three-badge-styles) · lines 160–177
10
+ - [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 179–208
11
+ - [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 210–223
12
+ - [Logos and brand marks](#logos-and-brand-marks) · lines 225–269
13
+ - [Categorical colour](#categorical-colour) · lines 271–341
14
+ - [Heat scale](#heat-scale) · lines 343–404
15
+ - [A stored colour](#a-stored-colour) · lines 406–454
16
+ - [Shapes and sizes](#shapes-and-sizes) · lines 456–477
17
+ - [Typography](#typography) · lines 479–585
18
+ - [Written text (notes)](#written-text-notes) · lines 513–585
19
+ - [Density](#density) · lines 587–673
20
+ - [Rows on this device](#rows-on-this-device) · lines 646–673
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–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
31
32
 
32
33
  <!-- /index -->
33
34
 
@@ -95,7 +96,8 @@ wear it too. An installed app's colours follow it with
95
96
 
96
97
  The package's `e2e/fixtures-visual.spec.ts` runs every primitive,
97
98
  composite and tone story through axe in each palette, and measures every
98
- glyph and categorical slot against each palette's page and card.
99
+ glyph, categorical slot and heat step against each palette's page and
100
+ card.
99
101
 
100
102
  **An app's own axe specs** check its palettes instead of light and dark:
101
103
  `defineA11ySuite({ …, palettes: ['indigo-cyan'] })` (and
@@ -338,6 +340,69 @@ If you find yourself wanting a thirteenth, that is a sign the column should
338
340
  be showing a shape or a label rather than more colours: there is no more
339
341
  room that stays readable.
340
342
 
343
+ ## Heat scale
344
+
345
+ For values that have an **order**: how much, how often, how hot. A heat
346
+ map, a calendar shaded by activity, a grid of counts. Five steps from
347
+ cold to hot, `--heat-1` through `--heat-5`. Tailwind gives each one as
348
+ `fill-heat-1` (a shape), `bg-heat-1` (a cell) and `text-heat-1-foreground`
349
+ (text on that cell).
350
+
351
+ **Use it only for ordered values.** A value that's good or bad is a tone
352
+ (hot is not "bad" here, and red here says nothing about danger). A value
353
+ that's only different from its neighbours is a categorical slot: the scale
354
+ would claim one category is more than another. Beside tone badges, keep
355
+ heat out of the same column.
356
+
357
+ An app sorts its values into the five steps itself, on rules it writes
358
+ down (thresholds, or an even split of the range), and maps each to whole
359
+ class names:
360
+
361
+ ```tsx
362
+ const HEAT = [
363
+ { fill: 'fill-heat-1', cell: 'bg-heat-1 text-heat-1-foreground' },
364
+ { fill: 'fill-heat-2', cell: 'bg-heat-2 text-heat-2-foreground' },
365
+ { fill: 'fill-heat-3', cell: 'bg-heat-3 text-heat-3-foreground' },
366
+ { fill: 'fill-heat-4', cell: 'bg-heat-4 text-heat-4-foreground' },
367
+ { fill: 'fill-heat-5', cell: 'bg-heat-5 text-heat-5-foreground' },
368
+ ] as const
369
+
370
+ <path className={`${HEAT[step - 1].fill} stroke-card`} d={shape} />
371
+ <td className={HEAT[step - 1].cell}>{count}</td>
372
+ ```
373
+
374
+ - **Opaque, at full strength.** Each step clears 3:1 against the card and
375
+ the page in light, dark and every palette, so a shape stands out with
376
+ no outline. An opacity modifier (`bg-heat-3/50`) gives that up.
377
+ - **Text on a fill takes its own foreground.** Pair the two as above: the
378
+ right text colour depends on the step and the theme. `text-foreground`
379
+ or muted text on a fill fails. It measures 4.71:1 at the least.
380
+ - **Neighbours can touch.** Neighbouring steps are at least ΔE 17.8 apart
381
+ (the perceived difference) and 12.6 under simulated deuteranopia and
382
+ protanopia, the common red-green deficiencies. A thin `stroke-card`
383
+ between shapes still helps, since a boundary is easier to see than a
384
+ shade.
385
+ - **The order holds without hue.** Each step is darker than the one before
386
+ it in both themes, so the scale also reads in greyscale. Hot is always
387
+ the red end, which in the dark themes means it is the darker end too.
388
+ - **Never colour alone.** Show the value too, in the cell, a tooltip or
389
+ a legend of the steps. A shape holding a value needs a name for screen
390
+ readers.
391
+ - **Nothing to show is not step 1.** Step 1 is the coldest *value*. No data
392
+ stays `fill-muted` or an empty state, so "none" and "cold" don't look
393
+ alike.
394
+ - **Five steps, not more.** Past five, neighbours stop being readable as
395
+ different. Bin the values rather than interpolating between steps.
396
+
397
+ The package's fixtures render it (`patterns/HeatScale`). Its Default story
398
+ runs through axe and the token check in light and dark, axe in every
399
+ palette too, and a check that measures every step, as a fill and as a
400
+ cell, against the page and a card in each. `tests/heat-scale.test.ts`
401
+ holds the distance between neighbours, the order of lightness and every
402
+ step against every palette's card and raised surface. `SideBySide` shows
403
+ both themes at once, under normal vision and simulated deuteranopia and
404
+ protanopia.
405
+
341
406
  ## A stored colour
342
407
 
343
408
  A colour the user stored as data (a paint's hex, a label's colour, a
@@ -782,15 +847,23 @@ const { data, isLoading, error, refetch } = useProjectsSummaryQuery()
782
847
  hub's widgets should start on the first screen, or there are more
783
848
  places than six tiles: below the sidebar's breakpoint the strip is one
784
849
  row that scrolls sideways, a chip per place with its icon in its slot's
785
- colour, its name and its number (no note, no action). While the number
786
- 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
787
853
  a screen reader), with Retry left to the desktop card and the place's
788
854
  own page. The row scrolls inside itself and the page never does. A
789
855
  desktop shows the cards either way, so don't render your own row
790
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.
791
864
  - The fixtures' `app/ModuleCard` shows a hub with a strip and a widget,
792
865
  every state, both at `compact`, and both again as a row of chips (Row,
793
- 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
794
867
  themes and at `large`, measure the strip at a desktop and a phone
795
868
  width, and run axe on the chips at a phone's.
796
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.73.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": {
package/styles/index.css CHANGED
@@ -79,6 +79,16 @@
79
79
  --color-category-10: var(--category-10);
80
80
  --color-category-11: var(--category-11);
81
81
  --color-category-12: var(--category-12);
82
+ --color-heat-1: var(--heat-1);
83
+ --color-heat-1-foreground: var(--heat-1-foreground);
84
+ --color-heat-2: var(--heat-2);
85
+ --color-heat-2-foreground: var(--heat-2-foreground);
86
+ --color-heat-3: var(--heat-3);
87
+ --color-heat-3-foreground: var(--heat-3-foreground);
88
+ --color-heat-4: var(--heat-4);
89
+ --color-heat-4-foreground: var(--heat-4-foreground);
90
+ --color-heat-5: var(--heat-5);
91
+ --color-heat-5-foreground: var(--heat-5-foreground);
82
92
  --color-accent-foreground: var(--accent-foreground);
83
93
  --color-accent: var(--accent);
84
94
  --color-muted-foreground: var(--muted-foreground);
package/styles/theme.css CHANGED
@@ -110,6 +110,38 @@
110
110
  --category-11-400: oklch(0.823 0.163 119);
111
111
  --category-12-700: oklch(0.423 0.181 337); /* magenta */
112
112
  --category-12-400: oklch(0.648 0.232 337);
113
+ /*
114
+ * The heat scale (design-language.md "Heat scale"). Five steps from cold
115
+ * to hot, for values that have an order: a heat map, a calendar of how
116
+ * much. Not status (tones) and not categories (the slots above).
117
+ *
118
+ * Opaque fills, unlike the slots: each step has its own --heat-N-foreground
119
+ * for text on it. Lightness falls at every step in both themes, so the
120
+ * order survives in greyscale and for colour-blind readers, and hue runs
121
+ * blue, teal, gold, orange, red, so the cold half and the hot half never
122
+ * meet (blue against yellow survives red-green colour blindness).
123
+ *
124
+ * Measured from these values (tests/heat-scale.test.ts holds neighbours to
125
+ * ΔE 15, 10 under simulated deuteranopia and protanopia, and every step to
126
+ * 3:1 on every card):
127
+ * neighbours light ΔE 20.9 to 34.2, deuteranopia/protanopia 13.1 or more
128
+ * dark ΔE 17.8 to 34.6, deuteranopia/protanopia 12.6 or more
129
+ * on white 3.33 / 3.55 / 4.20 / 6.34 / 10.47 (3.06 at the least on --muted)
130
+ * on dark's card 11.5 / 8.60 / 7.39 / 5.52 / 4.46
131
+ * on palette cards 3.96 at the least (step 5, Graphite); 3.43 on its raised surface
132
+ * text on the fill 4.71 at the least: black on steps 1-3 in light, white
133
+ * on 4 and 5, black on every step in dark
134
+ */
135
+ --heat-1-700: oklch(0.645 0.13 262); /* blue */
136
+ --heat-1-400: oklch(0.85 0.08 240);
137
+ --heat-2-700: oklch(0.614 0.104 188); /* teal */
138
+ --heat-2-400: oklch(0.758 0.085 185);
139
+ --heat-3-700: oklch(0.584 0.114 97); /* gold */
140
+ --heat-3-400: oklch(0.725 0.148 98);
141
+ --heat-4-700: oklch(0.5 0.133 47); /* orange */
142
+ --heat-4-400: oklch(0.661 0.13 47);
143
+ --heat-5-700: oklch(0.388 0.15 20); /* red */
144
+ --heat-5-400: oklch(0.615 0.16 20); /* a purer red goes nearly black under protanopia */
113
145
  --blue-500: oklch(0.488 0.243 264.376);
114
146
 
115
147
  /*
@@ -349,6 +381,17 @@
349
381
  --category-10: var(--category-10-700);
350
382
  --category-11: var(--category-11-700);
351
383
  --category-12: var(--category-12-700);
384
+ /* The heat scale: an opaque fill, with its own text colour. */
385
+ --heat-1: var(--heat-1-700);
386
+ --heat-1-foreground: var(--black);
387
+ --heat-2: var(--heat-2-700);
388
+ --heat-2-foreground: var(--black);
389
+ --heat-3: var(--heat-3-700);
390
+ --heat-3-foreground: var(--black);
391
+ --heat-4: var(--heat-4-700);
392
+ --heat-4-foreground: var(--white);
393
+ --heat-5: var(--heat-5-700);
394
+ --heat-5-foreground: var(--white);
352
395
  /* The zebra stripe (table.tsx: bg-muted/40 on even rows) mixed onto the
353
396
  page, opaque: what a pinned table cell paints on an even row, so it
354
397
  matches the row without letting scrolled columns show through. Mixed
@@ -517,6 +560,17 @@
517
560
  --category-10: var(--category-10-400);
518
561
  --category-11: var(--category-11-400);
519
562
  --category-12: var(--category-12-400);
563
+ /* The heat scale: lighter steps to clear the dark surfaces, black text on all. */
564
+ --heat-1: var(--heat-1-400);
565
+ --heat-1-foreground: var(--black);
566
+ --heat-2: var(--heat-2-400);
567
+ --heat-2-foreground: var(--black);
568
+ --heat-3: var(--heat-3-400);
569
+ --heat-3-foreground: var(--black);
570
+ --heat-4: var(--heat-4-400);
571
+ --heat-4-foreground: var(--black);
572
+ --heat-5: var(--heat-5-400);
573
+ --heat-5-foreground: var(--black);
520
574
  --table-stripe: color-mix(in srgb, var(--muted) 40%, var(--background));
521
575
  --table-highlight: color-mix(in srgb, var(--info) 20%, var(--background));
522
576
  --table-highlight-muted-foreground: var(--gray-400); /* the usual muted: not var(--muted-foreground), which the row redefines from this */
@@ -547,7 +601,7 @@
547
601
  * the dark theme, so a block below always sits on top of .dark and sets
548
602
  * only what differs from it. The solid fills (--destructive, --success,
549
603
  * --warning, --info, each with white -foreground), --info-text, the
550
- * highlight washes and the categorical slots stay .dark's.
604
+ * highlight washes, the categorical slots and the heat scale stay .dark's.
551
605
  *
552
606
  * --ring is the accent (4.24 to 5.25 on the page), not the guide's
553
607
  * accent deep (2.30 to 2.91, under the 3:1 a focus ring needs).