@tristan2828/ui-foundation 4.76.0 → 4.78.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.
@@ -4,25 +4,25 @@
4
4
  ## Index
5
5
 
6
6
  - [The reference files](#the-reference-files) · lines 41–63
7
- - [Before anything: the entity plan](#before-anything-the-entity-plan) · lines 65–782
7
+ - [Before anything: the entity plan](#before-anything-the-entity-plan) · lines 65–802
8
8
  - Step 1: Add `<Entity>` to `openapi.yaml` · lines 107–114
9
9
  - Step 2: `npm run gen:api` · lines 115–116
10
10
  - Step 3: Add gateway tests in `tests/gateway/<entity>.test.ts`, derived from the spec · lines 117–128
11
11
  - Step 4: Add MSW handlers in `src/mocks/<entity>.ts` · lines 129–138
12
12
  - Step 5: Add a gateway module in `src/api/gateway/<entity>.ts` · lines 139–143
13
- - Step 6: Copy the reference files, one for one, not just the two screens · lines 144–669
14
- - Step 7: Register routes · lines 670–685
15
- - Step 8: Add Playwright specs for all three screens · lines 686–764
16
- - Step 9: Register the nav entry and route names · lines 765–779
17
- - Step 10: `npm run verify`. · lines 780–782
18
- - [How a list opens a record](#how-a-list-opens-a-record) · lines 784–933
19
- - [The record view](#the-record-view) · lines 897–933
20
- - [What not to copy](#what-not-to-copy) · lines 935–961
21
- - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 963–980
22
- - [Deleting](#deleting) · lines 982–1011
23
- - [Fields only a script writes](#fields-only-a-script-writes) · lines 1013–1034
24
- - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1036–1045
25
- - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1048–1087
13
+ - Step 6: Copy the reference files, one for one, not just the two screens · lines 144–689
14
+ - Step 7: Register routes · lines 690–705
15
+ - Step 8: Add Playwright specs for all three screens · lines 706–784
16
+ - Step 9: Register the nav entry and route names · lines 785–799
17
+ - Step 10: `npm run verify`. · lines 800–802
18
+ - [How a list opens a record](#how-a-list-opens-a-record) · lines 804–953
19
+ - [The record view](#the-record-view) · lines 917–953
20
+ - [What not to copy](#what-not-to-copy) · lines 955–981
21
+ - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 983–1000
22
+ - [Deleting](#deleting) · lines 1002–1031
23
+ - [Fields only a script writes](#fields-only-a-script-writes) · lines 1033–1054
24
+ - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1056–1065
25
+ - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1068–1107
26
26
 
27
27
  <!-- /index -->
28
28
 
@@ -225,6 +225,26 @@ is a filled-in example while the Widgets demo is still here).
225
225
  Select is (the fixtures' `app/DateField` EditInPlace). The backend column
226
226
  is a SQL `date` (`datetime.date` in the model).
227
227
 
228
+ **A `month-day`** (a day that comes round every year, with no year:
229
+ when a season starts, a yearly deadline) is `type: string` with
230
+ `pattern: '^(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$'` in
231
+ `openapi.yaml`, so the wire, the generated type and the form all hold
232
+ `'MM-DD'` (`'03-14'`), and `''` on the form for an optional one not set
233
+ (sent as `null`). It sorts as text in calendar order. On the form it's
234
+ the foundation's `MonthDayField` in a `Controller` (`clearable` when
235
+ optional); the schema is the string with
236
+ `.refine((v) => v === '' || isMonthDay(v), 'Pick a month and day')`
237
+ (`isMonthDay`: February 29 is a day, February 30 isn't), `min(1, …)`
238
+ too when required. The table and the view show `formatMonthDay(value)`
239
+ ("Mar 14"), the not-set label when empty. Editing in place is
240
+ `inPlace.monthDay({ value, save })` (cell pattern 18, "Presets"). The
241
+ backend column is `varchar(5)` (`str` in the model) and the router
242
+ refuses a day the month can't have as a 422 on the field (the pattern
243
+ alone lets `02-30` through). Values typed before as free text are
244
+ rewritten to `'MM-DD'` by a migration; one it can't read stays as
245
+ written, and the field shows it as written with nothing picked, refused
246
+ until a day is picked.
247
+
228
248
  **An image on a record** (a photo of it) is the stored file's id on the
229
249
  wire (`string`, nullable), and on the form the foundation's
230
250
  `ImageField` in a `Controller` (`z.string().nullable()`): `value` and
@@ -4,41 +4,41 @@
4
4
  ## Index
5
5
 
6
6
  - [The rules that apply to every cell](#the-rules-that-apply-to-every-cell) · lines 70–89
7
- - [1. Plain text](#1-plain-text) · lines 91–98
8
- - [2. Icon + label](#2-icon--label) · lines 100–123
9
- - [3. Icon in a badge](#3-icon-in-a-badge) · lines 125–138
10
- - [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines 140–217
11
- - [Several values: the icons side by side, every name in one tooltip](#several-values-the-icons-side-by-side-every-name-in-one-tooltip) · lines 165–217
12
- - [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines 219–232
13
- - [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 234–246
14
- - [7. Link as an outline button](#7-link-as-an-outline-button) · lines 248–269
15
- - [8. Date, relative](#8-date-relative) · lines 271–308
16
- - [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 310–358
17
- - [Two variants the package draws: a step bar and a star](#two-variants-the-package-draws-a-step-bar-and-a-star) · lines 328–358
18
- - [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 360–410
19
- - [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 378–410
20
- - [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 412–452
21
- - [12. Boolean](#12-boolean) · lines 454–484
22
- - [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 486–522
23
- - [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 506–522
24
- - [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 524–541
25
- - [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 543–652
26
- - [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 569–652
27
- - [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 654–689
28
- - [17. Quick action on the view](#17-quick-action-on-the-view) · lines 691–764
29
- - [18. Editable value](#18-editable-value) · lines 766–1401
30
- - [Presets: one line per field](#presets-one-line-per-field) · lines 1051–1107
31
- - [Several fields edited as one](#several-fields-edited-as-one) · lines 1109–1141
32
- - [A link and its label](#a-link-and-its-label) · lines 1143–1167
33
- - [A list of sub-items](#a-list-of-sub-items) · lines 1169–1302
34
- - [In a table's rows](#in-a-tables-rows) · lines 1304–1389
35
- - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1391–1401
36
- - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1403–1469
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–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
7
+ - [1. Plain text](#1-plain-text) · lines 91–127
8
+ - [2. Icon + label](#2-icon--label) · lines 129–152
9
+ - [3. Icon in a badge](#3-icon-in-a-badge) · lines 154–167
10
+ - [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines 169–246
11
+ - [Several values: the icons side by side, every name in one tooltip](#several-values-the-icons-side-by-side-every-name-in-one-tooltip) · lines 194–246
12
+ - [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines 248–261
13
+ - [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 263–275
14
+ - [7. Link as an outline button](#7-link-as-an-outline-button) · lines 277–298
15
+ - [8. Date, relative](#8-date-relative) · lines 300–337
16
+ - [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 339–387
17
+ - [Two variants the package draws: a step bar and a star](#two-variants-the-package-draws-a-step-bar-and-a-star) · lines 357–387
18
+ - [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 389–439
19
+ - [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 407–439
20
+ - [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 441–481
21
+ - [12. Boolean](#12-boolean) · lines 483–513
22
+ - [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 515–551
23
+ - [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 535–551
24
+ - [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 553–570
25
+ - [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 572–681
26
+ - [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 598–681
27
+ - [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 683–718
28
+ - [17. Quick action on the view](#17-quick-action-on-the-view) · lines 720–793
29
+ - [18. Editable value](#18-editable-value) · lines 795–1436
30
+ - [Presets: one line per field](#presets-one-line-per-field) · lines 1080–1138
31
+ - [Several fields edited as one](#several-fields-edited-as-one) · lines 1140–1176
32
+ - [A link and its label](#a-link-and-its-label) · lines 1178–1202
33
+ - [A list of sub-items](#a-list-of-sub-items) · lines 1204–1337
34
+ - [In a table's rows](#in-a-tables-rows) · lines 1339–1424
35
+ - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1426–1436
36
+ - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1438–1504
37
+ - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1506–1570
38
+ - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1572–1670
39
+ - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1672–1700
40
+ - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1702–1778
41
+ - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1780–1803
42
42
 
43
43
  <!-- /index -->
44
44
 
@@ -97,6 +97,35 @@ otherwise have to make themselves.
97
97
  Always offer a plain-text option when exploring a column — in practice it
98
98
  gets picked about as often as the visual ones.
99
99
 
100
+ **Markdown in a one-line value.** A short field the app lets people write
101
+ Markdown in (a summary, a status note, a title with a link) shows in a
102
+ cell, a card's line or a caption with `<Markdown inline>`, not the block
103
+ `<Markdown>`:
104
+
105
+ ```tsx
106
+ <span className="text-muted-foreground">
107
+ <Markdown inline>{row.original.summary}</Markdown>
108
+ </span>
109
+ ```
110
+
111
+ - Bold, italic, code and links keep their marks; every other mark shows
112
+ as its words (a strikethrough or a highlight as plain words).
113
+ - It's a `<span>` in the font and colour of where it sits, with no block
114
+ margins, so the row stays as tall as a plain-text one. Code is the mono
115
+ face alone, with no wash, so it can't add height or fail contrast on a
116
+ muted cell.
117
+ - Blocks written in it still read on one line: paragraphs joined with a
118
+ space; a list's items with " · " (numbered ones with their numbers, a
119
+ done task with ✓, one to do with ☐); a table's rows as `Header: value`
120
+ pairs (`Size: S, Price: $4 · Size: L, Price: $6`); a heading, quote or
121
+ rule as " · "; a callout led by its kind ("Warning: …"); an image as its
122
+ alt text.
123
+ - A link opens in a new tab, and its click and Enter stay its own: they
124
+ never reach the row or the card it sits in, even a card of the app's
125
+ own with an `onClick`.
126
+ - It's for one line. Long text is notes, the block `<Markdown>` on the
127
+ record's view.
128
+
100
129
  ## 2. Icon + label
101
130
 
102
131
  A single-value enum where a glyph speeds up scanning but the word still
@@ -1065,6 +1094,7 @@ fields: [
1065
1094
  { label: 'Hours', edit: inPlace.number({ value: project.hours, min: 0, max: 200, unit: 'h', save: (hours) => save({ hours }) }) },
1066
1095
  { label: 'Budget', edit: inPlace.money({ value: project.budget, save: (budget) => save({ budget }) }) },
1067
1096
  { label: 'Due', edit: inPlace.date({ value: project.due, required: true, save: (due) => save({ due }) }) },
1097
+ { label: 'Renews on', edit: inPlace.monthDay({ value: project.renewsOn, save: (renewsOn) => save({ renewsOn }) }) },
1068
1098
  { label: 'Priority', edit: inPlace.select({ value: project.priority, options: PRIORITY_OPTIONS,
1069
1099
  render: (priority, label) => <Badge variant={PRIORITY_BADGE[priority]}>{label}</Badge>,
1070
1100
  save: (priority) => save({ priority }) }) },
@@ -1087,12 +1117,13 @@ fields: [
1087
1117
  | `number` | `1,234 h` (`unit`) | a number; blank is `null` | not a number, under `min`, over `max`, a fraction with `integer` |
1088
1118
  | `money` | `$1,234.56` (`currency`, `locale`) | the API's decimal string, two places (`"1234.50"`), built from the digits, never a float; `$` and commas typed are fine | a third decimal, words, under `min` (0 by default), over `max` |
1089
1119
  | `date` | `Sep 2, 2026` | `'YYYY-MM-DD'`; Clear is `null` | Clear when `required` |
1120
+ | `monthDay` | `Mar 14` (`format`, `locale`); a stored value that isn't a day, as written | `'MM-DD'`, no year; February 29 is a day; Clear is `null` | Clear when `required`, a day the month can't have ("February has 29 days") |
1090
1121
  | `select` | the option's label, or its `render` (a badge) | the option's value; "Not set" is `null` | "Not set" isn't offered when `required` |
1091
1122
  | `reference` | the record's `label` (the view's lookup by id) | the picked record's id | "Not set" isn't offered when `required` |
1092
1123
 
1093
1124
  - **They save the way their kind does** (the table above): `text`,
1094
- `number` and `money` on Enter or leaving them, `date`, `select` and
1095
- `reference` on the pick (the list opens with the field).
1125
+ `number` and `money` on Enter or leaving them, `date`, `monthDay`,
1126
+ `select` and `reference` on the pick (the list opens with the field).
1096
1127
  `required: true` types the save without `null`.
1097
1128
  - **`reference` searches through the app.** The package knows no
1098
1129
  endpoint: `search(text)` is the app's (its gateway's search by name,
@@ -1128,6 +1159,10 @@ value and save in one PATCH: `inPlace.fields`.
1128
1159
  table above, with its own `label`), side by side under a small caption
1129
1160
  of its label, and stacked when the row is narrow. At rest the parts
1130
1161
  read joined by " · " ("Small · Low"), or as `shown`.
1162
+ - **A yearly range** is two `monthDay` parts (`{ kind: 'monthDay',
1163
+ label: 'From' }`, `'By'`). The package sets no rule across them: a
1164
+ range can run over New Year (Nov 1 to Feb 28), so "by after from" is
1165
+ the app's `rule` if it holds for its data.
1131
1166
  - **Nothing saves until they agree.** Picking a part doesn't save it:
1132
1167
  the pair saves on leaving it or Ctrl/Cmd+Enter (and on Enter too when
1133
1168
  every part is typed into: numbers, money, text). Esc gives up both.
@@ -1596,6 +1631,23 @@ const { page, filters, setFilter, setPage } = useTableUrlState(['kind'])
1596
1631
  it. An ancestor of your own with `overflow` set (a card with
1597
1632
  `overflow-hidden`, say) takes the place of the page: leave it off such a
1598
1633
  table's ancestors.
1634
+ - **`stickyTop`**, with `stickyGroupHeadings`, for a page that pins a bar
1635
+ of its own to the top (a page header, a filter bar): how far down the
1636
+ header and headings pin, so they sit under the bar and never behind it.
1637
+ Any CSS length, resolved at the table, so a variable the page sets per
1638
+ breakpoint gives a phone its own offset:
1639
+
1640
+ ```tsx
1641
+ <main className="[--page-bar:3.5rem] md:[--page-bar:3rem]">
1642
+ <div className="sticky top-0 z-40 h-(--page-bar) bg-background">…</div>
1643
+ <DataTable stickyGroupHeadings stickyTop="var(--page-bar)" … />
1644
+ </main>
1645
+ ```
1646
+
1647
+ When the columns are wider than their box, the box is that much shorter
1648
+ than the screen instead, so once the page is scrolled to it, it fits
1649
+ under the bar and its header pins at its own top. Focus moved to a row
1650
+ clears the bar too. Give the bar a `z-index` above the table's (`z-40`).
1599
1651
  - **`header={false}`** for a list-like table whose columns explain
1600
1652
  themselves (a thumbnail with a title block, then actions). The header
1601
1653
  row takes no room but stays in the table, so the columns keep their
@@ -3,33 +3,34 @@
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 42–109
7
- - [Glow](#glow) · lines 111–129
8
- - [Semantic tones](#semantic-tones) · lines 131–159
9
- - [The three badge styles](#the-three-badge-styles) · lines 161–178
10
- - [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 180–209
11
- - [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 211–224
12
- - [Logos and brand marks](#logos-and-brand-marks) · lines 226–270
13
- - [Categorical colour](#categorical-colour) · lines 272–342
14
- - [Heat scale](#heat-scale) · lines 344–405
15
- - [A stored colour](#a-stored-colour) · lines 407–455
16
- - [Shapes and sizes](#shapes-and-sizes) · lines 457–478
17
- - [Typography](#typography) · lines 480–586
18
- - [Written text (notes)](#written-text-notes) · lines 514–586
19
- - [Density](#density) · lines 588–674
20
- - [Rows on this device](#rows-on-this-device) · lines 647–674
21
- - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 676–790
22
- - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 792–869
23
- - [Notices](#notices) · lines 871–899
24
- - [A value over time](#a-value-over-time) · lines 901–987
25
- - [Several values over time](#several-values-over-time) · lines 950–987
26
- - [A list as a board](#a-list-as-a-board) · lines 989–1040
27
- - [A list as cards](#a-list-as-cards) · lines 1042–1088
28
- - [Key numbers on a record](#key-numbers-on-a-record) · lines 1090–1112
29
- - [A record's tabs, mark and rail](#a-records-tabs-mark-and-rail) · lines 1114–1158
30
- - [Picking at random](#picking-at-random) · lines 1160–1191
31
- - [Filling in what's missing](#filling-in-whats-missing) · lines 1193–1260
32
- - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1262–1287
6
+ - [Palettes](#palettes) · lines 43–110
7
+ - [Glow](#glow) · lines 112–130
8
+ - [Semantic tones](#semantic-tones) · lines 132–160
9
+ - [The three badge styles](#the-three-badge-styles) · lines 162–179
10
+ - [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 181–210
11
+ - [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 212–225
12
+ - [Logos and brand marks](#logos-and-brand-marks) · lines 227–271
13
+ - [Categorical colour](#categorical-colour) · lines 273–343
14
+ - [Heat scale](#heat-scale) · lines 345–406
15
+ - [Depth ramps](#depth-ramps) · lines 408–486
16
+ - [A stored colour](#a-stored-colour) · lines 488–536
17
+ - [Shapes and sizes](#shapes-and-sizes) · lines 538–559
18
+ - [Typography](#typography) · lines 561–671
19
+ - [Written text (notes)](#written-text-notes) · lines 595–671
20
+ - [Density](#density) · lines 673–759
21
+ - [Rows on this device](#rows-on-this-device) · lines 732–759
22
+ - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 761–875
23
+ - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 877–954
24
+ - [Notices](#notices) · lines 956–984
25
+ - [A value over time](#a-value-over-time) · lines 986–1072
26
+ - [Several values over time](#several-values-over-time) · lines 1035–1072
27
+ - [A list as a board](#a-list-as-a-board) · lines 1074–1125
28
+ - [A list as cards](#a-list-as-cards) · lines 1127–1173
29
+ - [Key numbers on a record](#key-numbers-on-a-record) · lines 1175–1197
30
+ - [A record's tabs, mark and rail](#a-records-tabs-mark-and-rail) · lines 1199–1243
31
+ - [Picking at random](#picking-at-random) · lines 1245–1276
32
+ - [Filling in what's missing](#filling-in-whats-missing) · lines 1278–1345
33
+ - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1347–1372
33
34
 
34
35
  <!-- /index -->
35
36
 
@@ -404,6 +405,86 @@ step against every palette's card and raised surface. `SideBySide` shows
404
405
  both themes at once, under normal vision and simulated deuteranopia and
405
406
  protanopia.
406
407
 
408
+ ## Depth ramps
409
+
410
+ For **depth within one category**: the levels of one kind of thing, where
411
+ the category stays the same and only how deep, how specific or how far
412
+ in changes. A category's subcategories in a chart (Food, then Groceries,
413
+ then Produce), nesting levels of one tree, a stacked bar of one
414
+ category's parts. Every categorical slot has five steps, shallow to deep,
415
+ `--category-N-depth-1` through `--category-N-depth-5`, given by Tailwind
416
+ as `fill-category-N-depth-M` (a shape), `bg-category-N-depth-M` (a cell)
417
+ and `text-category-N-depth-M-foreground` (text on that cell).
418
+
419
+ **Which to use:**
420
+
421
+ | The values are | Use |
422
+ |---|---|
423
+ | different from each other, in no order | the slot itself, `text-category-N` (a glyph's tint) |
424
+ | one category's levels, shallow to deep | its depth ramp, `bg-category-N-depth-M` |
425
+ | amounts in an order, with no category | the heat scale, `bg-heat-M` |
426
+ | good or bad | a tone |
427
+
428
+ - **One ramp per category, its slot's.** A record whose category is slot 3
429
+ draws its levels from slot 3's ramp, so the depth reads as "more of the
430
+ same thing". Two categories side by side each keep their own ramp. A
431
+ ramp's hue stays within about 20° of its slot's, so a step never reads
432
+ as another slot, but steps of two neighbouring slots' ramps can come
433
+ close (orange and brown, blue and navy): tell categories apart by their
434
+ slot's own glyph and name, not by a ramp step alone.
435
+ - **Depth, not amount.** A ramp says "a level of this", never "more of
436
+ this is worse". A count or a total over many categories is the heat
437
+ scale; a status is a tone.
438
+ - **Opaque, at full strength.** Each step clears 3:1 against the card and
439
+ the page in light, dark and every palette (3.03:1 at the least, light
440
+ on `--muted`), so a shape stands out with no outline. An opacity
441
+ modifier (`bg-category-3-depth-2/50`) gives that up.
442
+ - **Text on a fill takes its own foreground.** Which text colour is right
443
+ depends on the step and the theme: pair the two as below. It measures
444
+ 4.55:1 at the least.
445
+ - **Neighbours are closer than the heat scale's, so keep a boundary.**
446
+ Neighbouring steps are at least ΔE 17.7 apart in light and 13.9 in
447
+ dark (blue's; every slot but blue and navy 17.4 or more), and 10.3
448
+ under simulated deuteranopia and protanopia. Five steps of one hue that
449
+ each clear 3:1 on the card only have so much lightness to share, dark's
450
+ band most of all. A `stroke-card` or a 1px gap between shapes, as a
451
+ stacked bar's segments have, makes each boundary easy to see.
452
+ - **The order holds without hue.** Each step is darker than the one before
453
+ it in both themes, so a ramp also reads in greyscale. In the dark
454
+ themes step 1 is near white and step 5 the slot's deepest, still 3:1
455
+ on the card.
456
+ - **Never colour alone.** Name the level too, in the cell, a tooltip or
457
+ a legend, and give a shape holding one a name for screen readers.
458
+ - **Five steps, not more.** Deeper nesting than five shares step 5, or
459
+ starts again with a label saying so; don't interpolate between steps.
460
+
461
+ An app maps a slot's levels to whole class names, as the heat scale's
462
+ steps are mapped: Tailwind only generates classes it finds written out.
463
+
464
+ ```tsx
465
+ // Slot 3's ramp, shallow to deep.
466
+ const GREEN_DEPTH = [
467
+ { fill: 'fill-category-3-depth-1', cell: 'bg-category-3-depth-1 text-category-3-depth-1-foreground' },
468
+ { fill: 'fill-category-3-depth-2', cell: 'bg-category-3-depth-2 text-category-3-depth-2-foreground' },
469
+ { fill: 'fill-category-3-depth-3', cell: 'bg-category-3-depth-3 text-category-3-depth-3-foreground' },
470
+ { fill: 'fill-category-3-depth-4', cell: 'bg-category-3-depth-4 text-category-3-depth-4-foreground' },
471
+ { fill: 'fill-category-3-depth-5', cell: 'bg-category-3-depth-5 text-category-3-depth-5-foreground' },
472
+ ] as const
473
+
474
+ <rect className={`${GREEN_DEPTH[level - 1].fill} stroke-card`} />
475
+ <td className={GREEN_DEPTH[level - 1].cell}>{name}</td>
476
+ ```
477
+
478
+ The package's fixtures render every ramp (`patterns/DepthRamps`). Its
479
+ Default story runs through axe and the token check in light and dark, axe
480
+ in every palette too, and a check that measures every step of every
481
+ slot, as a fill and as a cell, against the page and a card in each.
482
+ `tests/depth-ramps.test.ts` holds the distance between neighbours (17 in
483
+ light, 13.5 in dark, 10 with deuteranopia and protanopia), the order of
484
+ lightness, text on every fill and every step against every palette's card
485
+ and raised surface. `SideBySide` shows both themes at once, under normal
486
+ vision and simulated deuteranopia and protanopia.
487
+
407
488
  ## A stored colour
408
489
 
409
490
  A colour the user stored as data (a paint's hex, a label's colour, a
@@ -513,6 +594,10 @@ height and weight together, from tokens in the package's `styles/theme.css`:
513
594
 
514
595
  ### Written text (notes)
515
596
 
597
+ A one-line value written as Markdown (a cell, a card's line) is
598
+ `<Markdown inline>` instead: no headings or blocks, the font and colour
599
+ of where it sits (cell-patterns.md, pattern 1).
600
+
516
601
  Long text written as Markdown (`<Markdown>` and `RichTextEditor`) has its
517
602
  own three heading roles, so `#`, `##` and `###` in a note never look
518
603
  alike. They're for headings inside the text only, never a screen's own
@@ -53,6 +53,8 @@ One or two sentences: what one record is, and who uses the screens.
53
53
  check).
54
54
  - *From the package, no Widget example:* `date` (a calendar day, no
55
55
  time: OpenAPI `format: date`; the foundation's `DateField`; say
56
+ whether it's optional), `month-day` (a day that comes round every
57
+ year, no year: `'MM-DD'`; the foundation's `MonthDayField`; say
56
58
  whether it's optional).
57
59
  - *Not supported yet:* a yes/no that can also be unset (three states),
58
60
  file, and anything else.
@@ -97,6 +97,16 @@ export type DataTableProps<TData extends Record<string, unknown>> = {
97
97
  * Ungrouped, it changes nothing.
98
98
  */
99
99
  stickyGroupHeadings?: boolean;
100
+ /**
101
+ * With `stickyGroupHeadings`: how far from the top of the screen the
102
+ * pinned header and headings sit, for a page with a bar of its own pinned
103
+ * to the top. Any CSS length (`'3.5rem'`, `'var(--page-bar-height)'`),
104
+ * resolved at the table, so a variable the page sets per breakpoint gives
105
+ * a phone and a desktop their own offset. When the columns are wider than
106
+ * their box, the box is that much shorter than the screen instead, so it
107
+ * fits below the bar. Without it, they sit at the very top (`0px`).
108
+ */
109
+ stickyTop?: string;
100
110
  /**
101
111
  * The fields the rows can be grouped by, picked in a Group menu at the
102
112
  * end of the toolbar: None (the default, the table as it is without
@@ -284,4 +294,4 @@ export type DataTableTotals = {
284
294
  */
285
295
  cells?: Partial<Record<string, ReactNode>>;
286
296
  };
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;
297
+ 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, stickyTop, 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;
@@ -188,18 +188,22 @@ const GROUP_HEADING_CLASS = 'h-auto bg-background pt-4 pb-1.5 align-bottom';
188
188
  // scroll sideways, so it's bounded to the screen and scrolls down too.
189
189
  // `isolate` keeps these z-indexes inside the table.
190
190
  const STICKY_PAGE_SCROLL_CLASS = 'isolate overflow-x-clip';
191
- const STICKY_OWN_SCROLL_CLASS = 'isolate max-h-dvh overflow-auto';
191
+ const STICKY_OWN_SCROLL_CLASS = 'isolate max-h-[calc(100dvh-var(--data-table-sticky-top))] overflow-auto';
192
192
  // Collapsed borders stay where the row was, so a stuck cell draws its rule
193
193
  // as an inset shadow and its row's border comes off. Above the pinned
194
194
  // columns (z-10): the column header over the headings over the rows. A
195
195
  // cell's sticky bounds are the whole table, not its group, so a heading isn't
196
196
  // pushed off by the next: the next slides over it, later in the DOM and opaque.
197
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}`;
198
+ //
199
+ // `stickyTop` moves both down by --data-table-pin-top: the app's offset on the
200
+ // page's scroll, none in a box of the table's own (that box's top is its own,
201
+ // and the box is shortened by the offset instead).
202
+ const STICKY_HEAD_CELL_CLASS = `sticky top-(--data-table-pin-top) z-30 bg-background ${STICKY_RULE_CLASS}`;
203
+ const STICKY_GROUP_HEADING_CLASS = `sticky top-[calc(var(--data-table-pin-top)+var(--data-table-head-height))] z-20 pt-2 ${STICKY_RULE_CLASS}`;
200
204
  // What focus scrolls to clears the stuck header and heading (3rem covers a
201
205
  // heading's height, large density included).
202
- const STICKY_FOCUS_CLASS = '[&_tbody_*]:scroll-mt-[calc(var(--data-table-head-height)+--spacing(12))]';
206
+ const STICKY_FOCUS_CLASS = '[&_tbody_*]:scroll-mt-[calc(var(--data-table-pin-top)+var(--data-table-head-height)+--spacing(12))]';
203
207
  // A grouping's heading (`groupings`) is a button that folds its rows: the
204
208
  // label, then the count, a chevron that turns when folded.
205
209
  const GROUP_TOGGLE_CLASS = '-mx-1 inline-flex items-baseline gap-2 rounded-sm px-1 outline-none hover:underline ' +
@@ -316,7 +320,7 @@ function useStickyHeadings(containerRef, enabled) {
316
320
  }, [containerRef, enabled]);
317
321
  return { scrollsSideways, headHeight };
318
322
  }
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', }) {
323
+ 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, stickyTop = '0px', header: showHeader = true, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel = 'Details', }) {
320
324
  // The switch's own state, for a table that doesn't pass `layout`.
321
325
  const [ownLayout, setOwnLayout] = useState('table');
322
326
  const requestedLayout = layoutProp ?? ownLayout;
@@ -593,7 +597,13 @@ export function DataTable({ columns, data, total, page, pageSize, onPageChange,
593
597
  return;
594
598
  event.preventDefault();
595
599
  closeDetail();
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,
600
+ }, 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), containerStyle: stickyGroups
601
+ ? {
602
+ '--data-table-head-height': `${headHeight}px`,
603
+ '--data-table-sticky-top': stickyTop,
604
+ '--data-table-pin-top': scrollsSideways ? '0px' : stickyTop,
605
+ }
606
+ : undefined,
597
607
  // With the sticky bar below as the visible scrollbar, hide the
598
608
  // container's own. It stays overflow-x-auto and fully
599
609
  // scrollable (wheel, trackpad, drag, and the sync effect); it
@@ -1,4 +1,5 @@
1
1
  import type { ReactNode } from 'react';
2
+ import { type MonthDay } from '../../lib/month-day.js';
2
3
  import { type PlainDate } from '../../lib/plain-date.js';
3
4
  import type { EditInPlace } from './edit-in-place.js';
4
5
  /** What the value saves as: with `required: true` never `null` (a blank is refused). */
@@ -58,6 +59,18 @@ export type InPlaceDateConfig<TRequired extends boolean = boolean> = {
58
59
  locale?: string;
59
60
  placeholder?: string;
60
61
  };
62
+ /**
63
+ * A month and day with no year, `'MM-DD'` (MonthDayField): something that
64
+ * comes round every year. Not `required`: Clear saves `null`. February 29
65
+ * is a day; a stored `'02-30'` is refused ("February has 29 days").
66
+ */
67
+ export type InPlaceMonthDayConfig<TRequired extends boolean = boolean> = {
68
+ required?: TRequired;
69
+ /** How the day reads. Defaults to `{ month: 'short', day: 'numeric' }` ("Mar 14"). */
70
+ format?: Pick<Intl.DateTimeFormatOptions, 'month' | 'day'>;
71
+ locale?: string;
72
+ placeholder?: string;
73
+ };
61
74
  /** One option of a select: its value and its words. */
62
75
  export type InPlaceOption<T> = {
63
76
  value: T;
@@ -121,6 +134,9 @@ export type InPlacePart = ({
121
134
  kind: 'date';
122
135
  label: string;
123
136
  } & InPlaceDateConfig) | ({
137
+ kind: 'monthDay';
138
+ label: string;
139
+ } & InPlaceMonthDayConfig) | ({
124
140
  kind: 'select';
125
141
  label: string;
126
142
  } & InPlaceSelectConfig<any>) | ({
@@ -163,6 +179,12 @@ export declare const inPlace: {
163
179
  money<R extends boolean = false>(options: Common<string | number | null | undefined, InPlaceSaved<string, R>> & InPlaceMoneyConfig<R>): EditInPlace;
164
180
  /** A plain day (`'YYYY-MM-DD'`) in DateField's calendar, which opens with the field; a pick saves. */
165
181
  date<R extends boolean = false>(options: Common<PlainDate | null | undefined, InPlaceSaved<PlainDate, R>> & InPlaceDateConfig<R>): EditInPlace;
182
+ /**
183
+ * A month and day with no year (`'MM-DD'`, every year's March 14) in
184
+ * MonthDayField's picker, which opens with the field; a pick saves.
185
+ * Reads as "Mar 14"; February 29 is a day, February 30 is refused.
186
+ */
187
+ monthDay<R extends boolean = false>(options: Common<MonthDay | null | undefined, InPlaceSaved<MonthDay, R>> & InPlaceMonthDayConfig<R>): EditInPlace;
166
188
  /** One of a fixed list; its list opens with the field and a pick saves. */
167
189
  select<T extends string | number, R extends boolean = false>(options: Common<T | null | undefined, InPlaceSaved<T, R>> & InPlaceSelectConfig<T, R>): EditInPlace;
168
190
  /** Another record, searched as you type through the app's `search`; a pick saves its id. */
@@ -3,8 +3,10 @@ import { Input } from '../ui/input.js';
3
3
  import { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText } from '../ui/input-group.js';
4
4
  import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select.js';
5
5
  import { linkHost, linkRule } from '../../lib/link-href.js';
6
+ import { formatMonthDay, monthDayProblem } from '../../lib/month-day.js';
6
7
  import { formatPlainDate } from '../../lib/plain-date.js';
7
8
  import { DateField } from './date-field.js';
9
+ import { MonthDayField } from './month-day-field.js';
8
10
  import { NONE, Parts, ReferencePicker } from './edit-in-place-controls.js';
9
11
  import { LinkOut } from './row-edit-cells.js';
10
12
  const REQUIRED = 'Required';
@@ -133,6 +135,29 @@ function dateKind(config) {
133
135
  : undefined, "aria-label": props.label, "aria-describedby": props.describedBy })),
134
136
  };
135
137
  }
138
+ function monthDayKind(config) {
139
+ return {
140
+ editKind: 'choice',
141
+ toDraft: (value) => value ?? '',
142
+ check: (draft) => {
143
+ if (draft === '')
144
+ return config.required ? { ok: false, message: REQUIRED } : { ok: true, value: null };
145
+ const problem = monthDayProblem(draft, config.locale);
146
+ return problem ? { ok: false, message: problem } : { ok: true, value: draft };
147
+ },
148
+ // A stored value that isn't a day of the year reads as written.
149
+ show: (value) => (value ? formatMonthDay(value, config.format, config.locale) || value : null),
150
+ control: (props, alone) => (_jsx(MonthDayField, { id: props.id, value: props.value,
151
+ // Alone, a pick saves and the picker opens with the field; closing
152
+ // it with nothing picked gives up (a pick has already saved by then).
153
+ onChange: alone ? (day) => props.commit(day) : props.onChange, clearable: !config.required, placeholder: config.placeholder, format: config.format, locale: config.locale, invalid: props.invalid, readOnly: props.disabled, defaultOpen: alone, modal: alone ? false : undefined, onOpenChange: alone
154
+ ? (open) => {
155
+ if (!open)
156
+ props.cancel();
157
+ }
158
+ : undefined, "aria-label": props.label, "aria-describedby": props.describedBy })),
159
+ };
160
+ }
136
161
  function selectKind(config) {
137
162
  const labelOf = (value) => config.options.find((option) => option.value === value)?.label ?? String(value);
138
163
  const shownOf = (value) => (config.render ? config.render(value, labelOf(value)) : labelOf(value));
@@ -198,6 +223,8 @@ function kindOf(part) {
198
223
  return moneyKind(part);
199
224
  case 'date':
200
225
  return dateKind(part);
226
+ case 'monthDay':
227
+ return monthDayKind(part);
201
228
  case 'select':
202
229
  return selectKind(part);
203
230
  case 'reference':
@@ -378,6 +405,14 @@ export const inPlace = {
378
405
  date(options) {
379
406
  return single(dateKind(options), { ...options, value: options.value || null });
380
407
  },
408
+ /**
409
+ * A month and day with no year (`'MM-DD'`, every year's March 14) in
410
+ * MonthDayField's picker, which opens with the field; a pick saves.
411
+ * Reads as "Mar 14"; February 29 is a day, February 30 is refused.
412
+ */
413
+ monthDay(options) {
414
+ return single(monthDayKind(options), { ...options, value: options.value || null });
415
+ },
381
416
  /** One of a fixed list; its list opens with the field and a pick saves. */
382
417
  select(options) {
383
418
  return single(selectKind(options), { ...options, value: options.value ?? null });
@@ -62,6 +62,18 @@ export type MarkdownProps = {
62
62
  * may nest to any depth: the package never asks whose page it is.
63
63
  */
64
64
  pageLink?: PageLinkResolver;
65
+ /**
66
+ * For a one-line value (a table cell, a card's line, a summary): a
67
+ * `<span>` of one run of words, in the font and colour of wherever it
68
+ * sits, with no block margins, so a row it's in keeps its height. Bold,
69
+ * italic, code and links keep their marks; every other mark is its
70
+ * words. A list, table or other block written in it still reads: a
71
+ * list's items joined with " · ", a table's rows as `Header: value`
72
+ * pairs. A link's click and Enter never reach the row or card it sits
73
+ * in. The headings, folding, tasks, table and page-link props don't
74
+ * apply. Default `false`.
75
+ */
76
+ inline?: boolean;
65
77
  className?: string;
66
78
  } & Omit<ComponentProps<'div'>, 'children'>;
67
- export declare function Markdown({ children, headingLevel, headingFrom, foldKey: foldKeyProp, foldable, onTasksChange: onTasksChangeProp, tableLook, pageLink, className, ...rest }: MarkdownProps): import("react").JSX.Element;
79
+ export declare function Markdown({ inline, ...props }: MarkdownProps): import("react").JSX.Element;