@tristan2828/ui-foundation 4.122.0 → 4.124.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.
Files changed (35) hide show
  1. package/conventions/docs/add-an-entity.md +25 -16
  2. package/conventions/docs/cell-patterns.md +112 -42
  3. package/conventions/docs/design-language.md +48 -25
  4. package/dist/components/app/color-field.d.ts +22 -0
  5. package/dist/components/app/color-field.js +84 -0
  6. package/dist/components/app/data-table.d.ts +10 -1
  7. package/dist/components/app/data-table.js +3 -3
  8. package/dist/components/app/delete-action.js +3 -2
  9. package/dist/components/app/entity-view-facts.d.ts +8 -0
  10. package/dist/components/app/entity-view-facts.js +10 -4
  11. package/dist/components/app/filter-bar.d.ts +7 -1
  12. package/dist/components/app/filter-bar.js +3 -2
  13. package/dist/components/app/filter-date.js +2 -1
  14. package/dist/components/app/filter-name.d.ts +1 -0
  15. package/dist/components/app/filter-name.js +11 -0
  16. package/dist/components/app/icon-action.d.ts +8 -2
  17. package/dist/components/app/icon-action.js +20 -3
  18. package/dist/components/app/list-header.d.ts +2 -0
  19. package/dist/components/app/list-header.js +1 -1
  20. package/dist/components/app/milkdown-editor.js +19 -3
  21. package/dist/components/app/rich-text-editor.d.ts +2 -1
  22. package/dist/components/app/rich-text-editor.js +8 -4
  23. package/dist/components/app/rich-text-slash.d.ts +9 -3
  24. package/dist/components/app/rich-text-slash.js +17 -4
  25. package/dist/components/ui/field.js +4 -2
  26. package/dist/components/ui/radio-group.d.ts +5 -0
  27. package/dist/components/ui/radio-group.js +11 -0
  28. package/dist/hooks/table-url-changes.js +2 -1
  29. package/dist/hooks/use-table-url-state.js +15 -4
  30. package/dist/index.d.ts +3 -1
  31. package/dist/index.js +2 -0
  32. package/dist/lib/color-choices.d.ts +31 -0
  33. package/dist/lib/color-choices.js +57 -0
  34. package/openapi/foundation.yaml +1 -1
  35. package/package.json +1 -1
@@ -15,18 +15,18 @@
15
15
  - Step 8: Add Playwright specs for all three screens · lines 760–837
16
16
  - Step 9: Register the nav entry and route names · lines 838–852
17
17
  - Step 10: `npm run verify`. · lines 853–855
18
- - [How a list opens a record](#how-a-list-opens-a-record) · lines 857–1318
19
- - [The record view](#the-record-view) · lines 1010–1163
20
- - [Forms](#forms) · lines 1165–1235
21
- - [Dialogs](#dialogs) · lines 1237–1268
22
- - [Toasts and feedback](#toasts-and-feedback) · lines 1270–1318
23
- - [What not to copy](#what-not-to-copy) · lines 1320–1352
24
- - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1354–1371
25
- - [Deleting](#deleting) · lines 1373–1404
26
- - [Fields only a script writes](#fields-only-a-script-writes) · lines 1406–1427
27
- - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1429–1438
28
- - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1441–1483
29
- - [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1485–1521
18
+ - [How a list opens a record](#how-a-list-opens-a-record) · lines 857–1326
19
+ - [The record view](#the-record-view) · lines 1010–1167
20
+ - [Forms](#forms) · lines 1169–1240
21
+ - [Dialogs](#dialogs) · lines 1242–1273
22
+ - [Toasts and feedback](#toasts-and-feedback) · lines 1275–1326
23
+ - [What not to copy](#what-not-to-copy) · lines 1328–1361
24
+ - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1363–1380
25
+ - [Deleting](#deleting) · lines 1382–1413
26
+ - [Fields only a script writes](#fields-only-a-script-writes) · lines 1415–1436
27
+ - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1438–1447
28
+ - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1450–1492
29
+ - [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1494–1530
30
30
 
31
31
  <!-- /index -->
32
32
 
@@ -1071,6 +1071,7 @@ A record uses the parts it has, in this order:
1071
1071
  { label: 'Status', kind: 'status', status: STATUS_KINDS[record.status], word: STATUS_LABELS[record.status] },
1072
1072
  { label: 'By', kind: 'text', text: formatDay(record.due) },
1073
1073
  { label: 'Areas', kind: 'badges', items: record.areas.map(areaLabel) },
1074
+ { label: 'Flags', kind: 'badges', items: [{ label: 'Pinned', icon: PinIcon, tone: 'info' }] },
1074
1075
  { label: 'From', kind: 'record', name: provider.name, to: `/providers/${provider.id}`, short: true },
1075
1076
  { label: 'Open Tasks', kind: 'count', count: record.openTasks, to: `/tasks?project=${record.id}` },
1076
1077
  { label: 'Task', kind: 'link', href: task.url, name: task.name },
@@ -1112,7 +1113,10 @@ A record uses the parts it has, in this order:
1112
1113
  hover and keyboard focus, and a line under the value on a touch
1113
1114
  screen. Both are drawn in Details too, where the rail folds.
1114
1115
  - A `badges` item may be `{ label, icon }` (4.115): the icon (a
1115
- component or a node) before the label, in the muted tone.
1116
+ component or a node) before the label, in the muted tone. With
1117
+ `tone` (4.123: `success`, `warning`, `info`, `destructive`) a label
1118
+ that is a state ("Pinned", "Overdue") is the outline badge in that
1119
+ tone, its icon too; the word still says it.
1116
1120
  - **A rating** (4.117) is `kind: 'rating'`, drawn as the list's cells
1117
1121
  draw it, never as "4 of 5" text: stars (the default) or hearts for a
1118
1122
  score out of `max` (5), the step bar for a quality level. `null` is
@@ -1178,7 +1182,8 @@ shape (4.85):
1178
1182
  short one alone where a pairing would read wrong. Under 48rem every
1179
1183
  field takes its own row but two dates or two numbers (`DateField` says
1180
1184
  so itself; a date picker of your own with `kind="date"`). A choice
1181
- (`ChoiceButtons`, found by itself, 4.98) shares a row only with another
1185
+ (`ChoiceButtons`, found by itself, 4.98, or a `ToggleGroup` that is the
1186
+ field's own control, 4.123) shares a row only with another
1182
1187
  choice, two to a row; on a phone two stay side by side while both
1183
1188
  groups fit, and go one per row when they don't. Never a hand-made
1184
1189
  `sm:grid-cols-2` row. The picked option is in the theme colour (4.105);
@@ -1293,7 +1298,10 @@ sight.** What happened where the person is looking says so there.
1293
1298
  the same component (`size="sm"`), or `trigger={null}` with
1294
1299
  `open`/`onOpenChange`, opened by a `DataTable` `rowActions` entry's
1295
1300
  `onSelect` (a row's ⋯ menu). `verb="Retire"` for a retire.
1296
- Never a delete without a confirm, never a hand-written dialog.
1301
+ Never a delete without a confirm, never a hand-written dialog. Its icon
1302
+ is named "Delete <name>" (4.123), so several on one page (a record's,
1303
+ each of its rows') are told apart; its tooltip says "Delete". A test
1304
+ finds one by `getByRole('button', { name: 'Delete The Long Walk' })`.
1297
1305
  - **A delete that asks a reason: `DeleteAction reason`** (4.96). One
1298
1306
  optional field between the sentence and the buttons, a "Why" box:
1299
1307
  `reason={{ label: 'Why remove it?', hint: 'Kept with its history.' }}`
@@ -1341,7 +1349,8 @@ sight.** What happened where the person is looking says so there.
1341
1349
  `{}` with the server's default doing the rest), name the one the list
1342
1350
  opens on with `defaultView`, and put what no control can show (a
1343
1351
  computed "overdue") in the view's `rule` (cell-patterns.md "Saved views
1344
- are pills").
1352
+ are pills"). The default view's `sort` is its plain address's too
1353
+ (4.123): pressing it writes no `?sort=`, and the rows keep that order.
1345
1354
  - `src/api/gateway/widgets.ts`, `src/mocks/data.ts`, `src/mocks/handlers.ts`
1346
1355
  are demo-domain content — write the entity's own versions rather than
1347
1356
  adapting these by find-and-replace.
@@ -3,47 +3,48 @@
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
- - [The rules that apply to every cell](#the-rules-that-apply-to-every-cell) · lines 75–98
7
- - [1. Plain text](#1-plain-text) · lines 100–155
8
- - [2. Icon + label](#2-icon--label) · lines 157–180
9
- - [3. Icon in a badge](#3-icon-in-a-badge) · lines 182–195
10
- - [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines 197–274
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 222–274
12
- - [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines 276–296
13
- - [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 298–310
14
- - [7. Link as an outline button](#7-link-as-an-outline-button) · lines 312–333
15
- - [8. Date, relative](#8-date-relative) · lines 335–372
16
- - [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 374–433
17
- - [Three variants the package draws: a step bar, a star and a score](#three-variants-the-package-draws-a-step-bar-a-star-and-a-score) · lines 392–433
18
- - [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 435–485
19
- - [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 453–485
20
- - [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 487–527
21
- - [12. Boolean](#12-boolean) · lines 529–559
22
- - [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 561–597
23
- - [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 581–597
24
- - [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 599–616
25
- - [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 618–727
26
- - [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 644–727
27
- - [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 729–775
28
- - [17. Quick action on the view](#17-quick-action-on-the-view) · lines 777–850
29
- - [18. Editable value](#18-editable-value) · lines 852–1555
30
- - [Presets: one line per field](#presets-one-line-per-field) · lines 1187–1255
31
- - [Several fields edited as one](#several-fields-edited-as-one) · lines 1257–1293
32
- - [A link and its label](#a-link-and-its-label) · lines 1295–1319
33
- - [A list of sub-items](#a-list-of-sub-items) · lines 1321–1454
34
- - [In a table's rows](#in-a-tables-rows) · lines 1456–1541
35
- - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1543–1555
36
- - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1557–1623
37
- - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1625–1689
38
- - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1691–1789
39
- - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1791–1820
40
- - [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines 1822–1860
41
- - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1862–1938
42
- - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1940–1963
43
- - [25. A list's tools: views, filters, columns, row actions, a phone's rows](#25-a-lists-tools-views-filters-columns-row-actions-a-phones-rows) · lines 1965–2184
44
- - [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2113–2184
45
- - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2186–2222
46
- - [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2224–2273
6
+ - [The rules that apply to every cell](#the-rules-that-apply-to-every-cell) · lines 76–99
7
+ - [1. Plain text](#1-plain-text) · lines 101–156
8
+ - [2. Icon + label](#2-icon--label) · lines 158–181
9
+ - [3. Icon in a badge](#3-icon-in-a-badge) · lines 183–196
10
+ - [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines 198–275
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 223–275
12
+ - [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines 277–297
13
+ - [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 299–311
14
+ - [7. Link as an outline button](#7-link-as-an-outline-button) · lines 313–334
15
+ - [8. Date, relative](#8-date-relative) · lines 336–373
16
+ - [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 375–434
17
+ - [Three variants the package draws: a step bar, a star and a score](#three-variants-the-package-draws-a-step-bar-a-star-and-a-score) · lines 393–434
18
+ - [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 436–486
19
+ - [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 454–486
20
+ - [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 488–528
21
+ - [12. Boolean](#12-boolean) · lines 530–560
22
+ - [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 562–598
23
+ - [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 582–598
24
+ - [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 600–617
25
+ - [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 619–728
26
+ - [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 645–728
27
+ - [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 730–776
28
+ - [17. Quick action on the view](#17-quick-action-on-the-view) · lines 778–851
29
+ - [18. Editable value](#18-editable-value) · lines 853–1556
30
+ - [Presets: one line per field](#presets-one-line-per-field) · lines 1188–1256
31
+ - [Several fields edited as one](#several-fields-edited-as-one) · lines 1258–1294
32
+ - [A link and its label](#a-link-and-its-label) · lines 1296–1320
33
+ - [A list of sub-items](#a-list-of-sub-items) · lines 1322–1455
34
+ - [In a table's rows](#in-a-tables-rows) · lines 1457–1542
35
+ - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1544–1556
36
+ - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1558–1624
37
+ - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1626–1690
38
+ - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1692–1790
39
+ - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1792–1821
40
+ - [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines 1823–1861
41
+ - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1863–1939
42
+ - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1941–2027
43
+ - [Picking one on a form: `ColorField`](#picking-one-on-a-form-colorfield) · lines 1966–2027
44
+ - [25. A list's tools: views, filters, columns, row actions, a phone's rows](#25-a-lists-tools-views-filters-columns-row-actions-a-phones-rows) · lines 2029–2254
45
+ - [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2183–2254
46
+ - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2256–2292
47
+ - [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2294–2343
47
48
 
48
49
  <!-- /index -->
49
50
 
@@ -1962,6 +1963,69 @@ import { ColorSwatch } from '@tristan2828/ui-foundation'
1962
1963
  The package's fixture `app/ColorSwatch` "In a table" renders it; its
1963
1964
  checks measure the ring at 3:1 in both themes and every palette.
1964
1965
 
1966
+ ### Picking one on a form: `ColorField`
1967
+
1968
+ The same colour on the record's form (4.124): a grid of named swatches
1969
+ and **Custom**, which opens the browser's own colour picker. One control
1970
+ for a react-hook-form `Controller`, like `DateField`.
1971
+
1972
+ ```tsx
1973
+ import { ColorField, storedColor } from '@tristan2828/ui-foundation'
1974
+
1975
+ <Field data-invalid={!!errors.color || undefined}>
1976
+ <FieldLabel id="label-color-label" htmlFor="label-color">Colour</FieldLabel>
1977
+ <Controller
1978
+ control={form.control}
1979
+ name="color"
1980
+ rules={{ validate: (value) => !value || !!storedColor(value) || 'Pick a colour' }}
1981
+ render={({ field, fieldState }) => (
1982
+ <ColorField
1983
+ id="label-color"
1984
+ aria-labelledby="label-color-label"
1985
+ value={field.value}
1986
+ onChange={field.onChange}
1987
+ onBlur={field.onBlur}
1988
+ invalid={fieldState.invalid}
1989
+ />
1990
+ )}
1991
+ />
1992
+ <FieldError errors={[errors.color]} />
1993
+ </Field>
1994
+ ```
1995
+
1996
+ - **It's one radio group.** One tab stop; the arrow keys move and pick;
1997
+ Tab goes on to Custom's picker, then out. Each swatch's name is its
1998
+ radio's label, written beside it (the word carries it, as above). The
1999
+ picked one shows its radio's dot and a primary border, not only its
2000
+ colour.
2001
+ - **Name the group with `aria-labelledby`** (the `FieldLabel`'s `id`): a
2002
+ label's `htmlFor` can't name a group. Still pass `id` and `htmlFor`, so
2003
+ `<FieldLabel required>` marks the group `aria-required`.
2004
+ - **The value out is always `storedColor`'s form** (`#c0392b`). A value in
2005
+ is compared in full, so `C0392B` or `#FFF` still shows as its named
2006
+ colour. One that's none of the named colours (a hex typed in the old
2007
+ text box) shows **Custom** picked, its hex beside it, and stays as it
2008
+ is until someone picks. A value that isn't a colour shows nothing
2009
+ picked.
2010
+ - **Custom by pointer opens the picker; by keyboard it only picks**, and
2011
+ the picker is the next tab stop. Picking Custom keeps the current
2012
+ colour until a colour is chosen in the picker.
2013
+ - **The default set** is `COLOR_CHOICES`: twelve named hues at a middle
2014
+ lightness that read on a card in light, dark and every palette (3:1,
2015
+ 2.3:1 on Palm LCD's mid panel). An app with its own names passes
2016
+ `colors={[{ name: 'Hale Navy', color: '#434c56' }, ...]}`; each name is
2017
+ shown, so make them words a person would say.
2018
+ - **Replacing a text box and a swatch preview**: the stored values don't
2019
+ change. Swap the `Input` for `ColorField` in the same `Controller`;
2020
+ values already stored that aren't in the set show as Custom.
2021
+
2022
+ The package's fixture `app/ColorField` renders it on a card (a named
2023
+ colour, a Custom hex, a required one left empty, an app's own list, a
2024
+ refused value); its checks run axe, the token check, each swatch's ring
2025
+ and the picker's edge at 3:1, and each default fill against the card, in
2026
+ both themes and every palette. `e2e/color-field.spec.ts` drives the
2027
+ pointer, the keyboard and Custom.
2028
+
1965
2029
  ## 25. A list's tools: views, filters, columns, row actions, a phone's rows
1966
2030
 
1967
2031
  The rest of the list page standard (4.86): what sits above a list's rows,
@@ -2051,7 +2115,13 @@ const { filters, multiFilters, setFilter, setFilters, setMultiFilter, activeView
2051
2115
  most (`primary`), and the rest behind Filters (`secondary`, with their
2052
2116
  chips, as `SecondaryFilters` draws them). No captions over controls:
2053
2117
  each names itself. `FilterSelect` says "Any status" while off and
2054
- "Status: Active" on; `MultiChoice`'s `label` makes it "Rooms: Hall +1"
2118
+ "Status: Active" on, and is named by its label first (4.123): "Status"
2119
+ while it shows "Any status", "Status: Active", "Status: All reminders"
2120
+ for an `anyLabel` that doesn't say the label (`FilterDate` the same), so
2121
+ a test finds it by `getByRole('combobox', { name: /^Status/ })`.
2122
+ `search.onKeyDown` (4.123) gives the search box's keys to the app
2123
+ first: Enter on "#12" opening record 12, `preventDefault()` keeping the
2124
+ key from the box. `MultiChoice`'s `label` makes it "Rooms: Hall +1"
2055
2125
  instead of a chip per pick. Below 48rem search and Filters share a line
2056
2126
  and every filter, primary ones too, is in Filters' bottom sheet, so pass
2057
2127
  `primaryActive` (their chips) and an `onClearAll` that clears them all
@@ -14,30 +14,30 @@
14
14
  - [Categorical colour](#categorical-colour) · lines 370–440
15
15
  - [Heat scale](#heat-scale) · lines 442–503
16
16
  - [Depth ramps](#depth-ramps) · lines 505–590
17
- - [A stored colour](#a-stored-colour) · lines 592–640
18
- - [Shapes and sizes](#shapes-and-sizes) · lines 642–663
19
- - [Typography](#typography) · lines 665–836
20
- - [Words on screen: Title Case and sentence case](#words-on-screen-title-case-and-sentence-case) · lines 699–732
21
- - [Written text (notes)](#written-text-notes) · lines 734–836
22
- - [Density](#density) · lines 838–931
23
- - [Rows on this device](#rows-on-this-device) · lines 904–931
24
- - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 933–1047
25
- - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 1049–1126
26
- - [Notices](#notices) · lines 1128–1156
27
- - [A value over time](#a-value-over-time) · lines 1158–1244
28
- - [Several values over time](#several-values-over-time) · lines 1207–1244
29
- - [A list as a board](#a-list-as-a-board) · lines 1246–1297
30
- - [A list as cards](#a-list-as-cards) · lines 1299–1345
31
- - [Key numbers on a record](#key-numbers-on-a-record) · lines 1347–1383
32
- - [Parts of the page standards](#parts-of-the-page-standards) · lines 1385–1446
33
- - [A few equal things](#a-few-equal-things) · lines 1448–1532
34
- - [An overview page](#an-overview-page) · lines 1534–1605
35
- - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1606–1664
36
- - [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1666–1790
37
- - [Picking at random](#picking-at-random) · lines 1792–1823
38
- - [Filling in what's missing](#filling-in-whats-missing) · lines 1825–1892
39
- - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1894–1919
40
- - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1921–2017
17
+ - [A stored colour](#a-stored-colour) · lines 592–649
18
+ - [Shapes and sizes](#shapes-and-sizes) · lines 651–672
19
+ - [Typography](#typography) · lines 674–845
20
+ - [Words on screen: Title Case and sentence case](#words-on-screen-title-case-and-sentence-case) · lines 708–741
21
+ - [Written text (notes)](#written-text-notes) · lines 743–845
22
+ - [Density](#density) · lines 847–940
23
+ - [Rows on this device](#rows-on-this-device) · lines 913–940
24
+ - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 942–1056
25
+ - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 1058–1135
26
+ - [Notices](#notices) · lines 1137–1165
27
+ - [A value over time](#a-value-over-time) · lines 1167–1253
28
+ - [Several values over time](#several-values-over-time) · lines 1216–1253
29
+ - [A list as a board](#a-list-as-a-board) · lines 1255–1306
30
+ - [A list as cards](#a-list-as-cards) · lines 1308–1354
31
+ - [Key numbers on a record](#key-numbers-on-a-record) · lines 1356–1392
32
+ - [Parts of the page standards](#parts-of-the-page-standards) · lines 1394–1464
33
+ - [A few equal things](#a-few-equal-things) · lines 1466–1550
34
+ - [An overview page](#an-overview-page) · lines 1552–1623
35
+ - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1624–1687
36
+ - [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1689–1813
37
+ - [Picking at random](#picking-at-random) · lines 1815–1846
38
+ - [Filling in what's missing](#filling-in-whats-missing) · lines 1848–1915
39
+ - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1917–1942
40
+ - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1944–2040
41
41
 
42
42
  <!-- /index -->
43
43
 
@@ -639,6 +639,15 @@ palette side by side), with axe, the token check and the ring's ratio
639
639
  measured in light, dark and every palette. Cell pattern 24 is it in a
640
640
  column.
641
641
 
642
+ **Picking one on a form is `ColorField`** (4.124): the same swatches,
643
+ each beside its name, as one radio group, and Custom for the browser's
644
+ own picker. Its default twelve (`COLOR_CHOICES`) sit at a middle
645
+ lightness, so each fill clears 3:1 against a card in light, dark and the
646
+ dark palettes, and 2.3:1 on Palm LCD, whose mid-light panel no middle
647
+ colour clears 3:1 on (the ring shows the edge there). The picked one is
648
+ marked by its radio's dot and a primary border, never by its colour
649
+ alone. Cell pattern 24 has its markup.
650
+
642
651
  ## Shapes and sizes
643
652
 
644
653
  The shared style guide's, the same in every app with or without a
@@ -1418,6 +1427,15 @@ into a table, a record or an overview.
1418
1427
  list that needs it ("Each search runs against the catalog once a
1419
1428
  day."). It wraps in the header's width and never widens a framed
1420
1429
  table's shared width; on a phone it's under the title and its buttons.
1430
+ A `more` item that can't be used now (4.123, `disabled: true`: an
1431
+ import already running) stays in ⋯, greyed, never hidden.
1432
+ - **A bar between the header and the list** (`DataTable pageBar`, 4.123):
1433
+ something about the whole page that belongs above its rows, such as a
1434
+ deals bar, "Allow Reminders" or a budget's totals. It's drawn under
1435
+ `pageHeader` and above the views, in the same box, so C3 holds: the
1436
+ header, the bar and the card share the table's width, and the bar
1437
+ wraps in it rather than widening it. Never a bar put between a
1438
+ separate `ListHeader` and the table, which loses the shared width.
1421
1439
  One sentence: anything longer belongs in a help page.
1422
1440
  - **`Timeline`: a record's dated history.** `items` newest first
1423
1441
  (`{ id, date, dateTime?, kind?, body, edit? }`): dates in a tabular
@@ -1634,7 +1652,12 @@ data on each its own.
1634
1652
  done), then the universal ones as `IconAction`s: Print Notes
1635
1653
  (`printer`, EntityView's own) and Delete (`trash-2`, the destructive
1636
1654
  tone). Each is a square outline button at the header's 36px with its
1637
- words as both its tooltip and its accessible name. Icon alone is for
1655
+ words as both its tooltip and its accessible name. An `IconAction`
1656
+ that goes somewhere (Open Site, Print to a page) takes the link as
1657
+ `render` (4.123, `render={<Link to="/print" />}` or `render={<a href=…
1658
+ target="_blank" />}`) and is drawn as that link. `accessibleName` says
1659
+ more than the tooltip where several are on one page: `DeleteAction`'s
1660
+ icon is named "Delete <name>" (4.123), its tooltip still "Delete". Icon alone is for
1638
1661
  the universal actions only (Delete, Print Notes, Copy link, Pin, Open
1639
1662
  site, Restore, Open Full Page, Close, More); everything else keeps its
1640
1663
  word. `printLook="words"` keeps Print Notes as a button with its words.
@@ -0,0 +1,22 @@
1
+ import { type ColorChoice } from '../../lib/color-choices.js';
2
+ export type ColorFieldProps = {
3
+ /** The radio group's id, for the field's `<FieldLabel htmlFor>` (its `required` marks the group). */
4
+ id?: string;
5
+ /** The stored colour: a hex, with or without `#`, in 3, 4, 6 or 8 digits. Missing or invalid picks nothing. */
6
+ value: string | null | undefined;
7
+ /** Called with the picked colour in `storedColor`'s form (`#c0392b`). */
8
+ onChange: (value: string) => void;
9
+ /** Called when focus leaves the whole field (react-hook-form's `onBlur`). */
10
+ onBlur?: () => void;
11
+ /** The named colours offered, in order. Defaults to `COLOR_CHOICES`, twelve that read on a card everywhere. */
12
+ colors?: readonly ColorChoice[];
13
+ /** The value was refused: `aria-invalid` on the group and a destructive outline. */
14
+ invalid?: boolean;
15
+ disabled?: boolean;
16
+ className?: string;
17
+ /** Name the group: the FieldLabel's id (a label's `htmlFor` can't name a group). */
18
+ 'aria-labelledby'?: string;
19
+ 'aria-label'?: string;
20
+ 'aria-describedby'?: string;
21
+ };
22
+ export declare function ColorField({ id, value, onChange, onBlur, colors, invalid, disabled, className, ...aria }: ColorFieldProps): import("react").JSX.Element;
@@ -0,0 +1,84 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // A stored colour on a form (a label's colour, a calendar's): a grid of
3
+ // named swatches and Custom, one radio group, for a react-hook-form
4
+ // `Controller` like DateField. The value is a hex string, always
5
+ // `storedColor`'s form (`#c0392b`), and the design language's "A stored
6
+ // colour" is the why of the swatches themselves (ColorSwatch).
7
+ //
8
+ // - One radio group (shadcn's RadioGroup on Base UI): one tab stop, the
9
+ // arrow keys move and pick, Space picks. Each choice is a radio with its
10
+ // ColorSwatch, and the swatch's name is the radio's label, written out:
11
+ // the colour is never the only way to tell. The picked one shows its
12
+ // radio's dot and a primary border, so it's marked by more than its
13
+ // colour; the focused one wears the focus ring.
14
+ // - Custom is the last choice. Clicking it opens the browser's own colour
15
+ // picker (`<input type="color">`, beside it, which is also a button of
16
+ // its own); reaching it by the keyboard only picks it, and Tab goes on to
17
+ // the picker. The chosen hex is written beside it.
18
+ // - A value that's none of the named colours (a hex typed elsewhere,
19
+ // uppercase or 3-digit included) shows Custom picked, with its hex.
20
+ // Colours compare in full (`#FFF` is `#ffffff`), so a named colour stored
21
+ // another way still shows as its name. A value that isn't a colour
22
+ // (missing, empty, a typo) shows nothing picked.
23
+ // - The swatch fills are data (ColorSwatch's inline style); everything
24
+ // around them is semantic tokens.
25
+ import { useRef, useState } from 'react';
26
+ import { cn } from 'cn';
27
+ import { RadioGroup, RadioGroupItem } from '../ui/radio-group.js';
28
+ import { choiceIndex, COLOR_CHOICES, pickerHex } from '../../lib/color-choices.js';
29
+ import { storedColor } from '../../lib/stored-color.js';
30
+ import { ColorSwatch } from './color-swatch.js';
31
+ const CUSTOM = 'custom';
32
+ // A choice's box: the radio and its swatch, a primary border when picked
33
+ // (the dot says it too), the focus ring on the one the keyboard is on.
34
+ const CHOICE = cn('flex h-(--control-height,--spacing(8)) min-w-0 cursor-pointer items-center gap-2 rounded-md border border-transparent px-2 type-body text-foreground', 'hover:bg-muted has-data-checked:border-primary has-data-checked:bg-primary/12', 'has-[:focus-visible]:border-ring has-[:focus-visible]:ring-3 has-[:focus-visible]:ring-ring/50', 'has-data-disabled:cursor-not-allowed has-data-disabled:opacity-50');
35
+ export function ColorField({ id, value, onChange, onBlur, colors = COLOR_CHOICES, invalid = false, disabled = false, className, ...aria }) {
36
+ const picker = useRef(null);
37
+ // Custom picked by the person while the value is still a named colour:
38
+ // it stays picked until they pick a named one.
39
+ const [customPicked, setCustomPicked] = useState(false);
40
+ const index = choiceIndex(value, colors);
41
+ const hex = storedColor(value);
42
+ const picked = customPicked || (index === -1 && hex) ? CUSTOM : index === -1 ? null : String(index);
43
+ const choose = (next) => {
44
+ if (next === CUSTOM) {
45
+ setCustomPicked(true);
46
+ return;
47
+ }
48
+ const choice = colors[Number(next)];
49
+ const color = storedColor(choice?.color);
50
+ if (!color)
51
+ return;
52
+ setCustomPicked(false);
53
+ if (color !== hex)
54
+ onChange(color);
55
+ };
56
+ // A pointer's click on Custom (its radio or its word) opens the picker;
57
+ // a label's forwarded click and the keyboard's (`detail` 0) don't.
58
+ const openPicker = (event) => {
59
+ if (disabled || event.detail === 0)
60
+ return;
61
+ const input = picker.current;
62
+ if (!input)
63
+ return;
64
+ try {
65
+ input.showPicker();
66
+ }
67
+ catch {
68
+ input.click();
69
+ }
70
+ };
71
+ const leave = (event) => {
72
+ if (!event.currentTarget.contains(event.relatedTarget))
73
+ onBlur?.();
74
+ };
75
+ return (_jsx("div", { "data-slot": "color-field", className: cn('min-w-0', className), onBlur: leave, children: _jsxs(RadioGroup, { id: id, value: picked, onValueChange: choose, disabled: disabled, "aria-invalid": invalid || undefined, className: cn('grid grid-cols-[repeat(auto-fill,minmax(7.5rem,1fr))] gap-1 rounded-md', invalid && 'ring-3 ring-destructive/20 dark:ring-destructive/40'), ...aria, children: [colors.map((choice, at) => (_jsxs("label", { "data-slot": "color-field-choice", className: CHOICE, children: [_jsx(RadioGroupItem, { value: String(at), "aria-invalid": invalid || undefined }), _jsx(ColorSwatch, { color: choice.color, label: choice.name })] }, `${choice.name}-${at}`))), _jsxs("div", { "data-slot": "color-field-custom", className: "col-span-full flex min-w-0 flex-wrap items-center gap-2", children: [_jsxs("label", { className: cn(CHOICE, 'w-fit'), onClick: openPicker, children: [_jsx(RadioGroupItem, { value: CUSTOM, "aria-invalid": invalid || undefined }), "Custom"] }), _jsx("input", { ref: picker, type: "color", "data-slot": "color-field-picker", "aria-label": "Custom colour", value: pickerHex(value), disabled: disabled, onChange: (event) => {
76
+ const color = storedColor(event.target.value);
77
+ if (!color)
78
+ return;
79
+ setCustomPicked(true);
80
+ onChange(color);
81
+ },
82
+ // The radio group's arrow keys are for its radios, not this button.
83
+ onKeyDown: (event) => event.stopPropagation(), className: cn('box-border size-(--control-height,--spacing(8)) shrink-0 cursor-pointer rounded-md border border-muted-foreground bg-transparent p-0.5 outline-none', 'focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50', '[&::-webkit-color-swatch-wrapper]:p-0 [&::-webkit-color-swatch]:rounded-sm [&::-webkit-color-swatch]:border-0 [&::-moz-color-swatch]:rounded-sm [&::-moz-color-swatch]:border-0') }), picked === CUSTOM && hex && (_jsx("span", { "data-slot": "color-field-hex", className: "type-body text-muted-foreground tabular-nums", children: hex }))] })] }) }));
84
+ }
@@ -288,6 +288,15 @@ export type DataTableProps<TData extends Record<string, unknown>, TView extends
288
288
  * phone, it spans the page as before.
289
289
  */
290
290
  pageHeader?: ReactNode;
291
+ /**
292
+ * A bar between the page header and the list (4.123): something about
293
+ * the whole page that belongs above its rows, such as a deals bar, an
294
+ * "Allow reminders" notice or a budget's totals. Drawn under
295
+ * `pageHeader` and above the views, so C3 holds: the header, the bar and
296
+ * the card are still one box as wide as the table, and the bar never
297
+ * widens it (it wraps in that width instead).
298
+ */
299
+ pageBar?: ReactNode;
291
300
  /**
292
301
  * A Columns menu at the end of the toolbar (L5): a tick for every column
293
302
  * but the first (the name) and the row actions, remembered on this device
@@ -415,4 +424,4 @@ export type DataTableTotals = {
415
424
  */
416
425
  cells?: Partial<Record<string, ReactNode>>;
417
426
  };
418
- export declare function DataTable<TData extends Record<string, unknown>, TView extends DataTableView = DataTableView>({ columns, data, total, page, pageSize, onPageChange, pageSizes, onPageSizeChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width, striped, groupBy, groupSummary, stickyGroupHeadings, stickyTop, header: showHeader, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel, views, activeView, onViewChange, viewsLabel, pageHeader, columnsMenu, rowActions, phoneRow, limit, viewAll, look, }: DataTableProps<TData, TView>): import("react").JSX.Element;
427
+ export declare function DataTable<TData extends Record<string, unknown>, TView extends DataTableView = DataTableView>({ columns, data, total, page, pageSize, onPageChange, pageSizes, onPageSizeChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width, striped, groupBy, groupSummary, stickyGroupHeadings, stickyTop, header: showHeader, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel, views, activeView, onViewChange, viewsLabel, pageHeader, pageBar, columnsMenu, rowActions, phoneRow, limit, viewAll, look, }: DataTableProps<TData, TView>): import("react").JSX.Element;
@@ -428,7 +428,7 @@ const ROW_ACTIONS_COLUMN = {
428
428
  };
429
429
  // The cell under the actions' column: as narrow as its button.
430
430
  const ROW_ACTIONS_CELL_CLASS = 'w-px py-0';
431
- export function DataTable({ columns, data, total, page, pageSize, onPageChange, pageSizes, onPageSizeChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width = 'content', striped = false, 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', views, activeView = null, onViewChange, viewsLabel = 'Views', pageHeader, columnsMenu, rowActions, phoneRow, limit, viewAll, look = 'plain', }) {
431
+ export function DataTable({ columns, data, total, page, pageSize, onPageChange, pageSizes, onPageSizeChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width = 'content', striped = false, 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', views, activeView = null, onViewChange, viewsLabel = 'Views', pageHeader, pageBar, columnsMenu, rowActions, phoneRow, limit, viewAll, look = 'plain', }) {
432
432
  // The switch's own state, for a table that doesn't pass `layout`.
433
433
  const [ownLayout, setOwnLayout] = useState('table');
434
434
  const requestedLayout = layoutProp ?? ownLayout;
@@ -854,8 +854,8 @@ export function DataTable({ columns, data, total, page, pageSize, onPageChange,
854
854
  // C3: with a header, the header, views and card are one box as wide as
855
855
  // the table (the box fits its content, the card fills the box), so the
856
856
  // header ends where the card does. CSS only: nothing is measured.
857
- const sharedWidth = Boolean(pageHeader) && fitsColumns;
858
- const content = framed ? (_jsxs("div", { ref: root, className: cn('flex flex-col gap-4', sharedWidth && CONTENT_WIDTH_CLASS), "data-width": width, "data-look": "framed", "data-shared-width": sharedWidth ? '' : undefined, "data-layout": layouts?.length ? currentLayout : undefined, children: [pageHeader, viewPills, _jsx(DetailFrame, { enabled: Boolean(detailPanel) && !cardLayout, aside: detailAside, children: _jsxs("div", { ref: body, "data-slot": "data-table-frame", className: cn(FRAME_CLASS, fitsColumns && !sharedWidth && CONTENT_WIDTH_CLASS), style: lastWidthStyle, children: [framedToolbar, _jsx("div", { "data-slot": "data-table-body", className: cn('flex flex-col gap-4', (stateView || cardLayout) && 'p-3', showPhoneRows && !stateView && FRAMED_PHONE_ROWS_CLASS), children: stateView ?? rowsView }), stateView ? null : pagination] }) })] })) : (_jsxs("div", { ref: root, className: "flex flex-col gap-4", "data-width": width, "data-layout": layouts?.length ? currentLayout : undefined, children: [pageHeader, viewPills, plainToolbar, _jsx("div", { ref: body, "data-slot": "data-table-body", className: cn('flex flex-col gap-4', fitsColumns && CONTENT_WIDTH_CLASS), style: lastWidthStyle, children: stateView ?? (_jsxs(DetailFrame, { enabled: Boolean(detailPanel) && !cardLayout, aside: detailAside, children: [rowsView, pagination] })) })] }));
857
+ const sharedWidth = Boolean(pageHeader || pageBar) && fitsColumns;
858
+ const content = framed ? (_jsxs("div", { ref: root, className: cn('flex flex-col gap-4', sharedWidth && CONTENT_WIDTH_CLASS), "data-width": width, "data-look": "framed", "data-shared-width": sharedWidth ? '' : undefined, "data-layout": layouts?.length ? currentLayout : undefined, children: [pageHeader, pageBar && (_jsx("div", { "data-slot": "data-table-page-bar", className: "min-w-0 contain-inline-size", children: pageBar })), viewPills, _jsx(DetailFrame, { enabled: Boolean(detailPanel) && !cardLayout, aside: detailAside, children: _jsxs("div", { ref: body, "data-slot": "data-table-frame", className: cn(FRAME_CLASS, fitsColumns && !sharedWidth && CONTENT_WIDTH_CLASS), style: lastWidthStyle, children: [framedToolbar, _jsx("div", { "data-slot": "data-table-body", className: cn('flex flex-col gap-4', (stateView || cardLayout) && 'p-3', showPhoneRows && !stateView && FRAMED_PHONE_ROWS_CLASS), children: stateView ?? rowsView }), stateView ? null : pagination] }) })] })) : (_jsxs("div", { ref: root, className: "flex flex-col gap-4", "data-width": width, "data-layout": layouts?.length ? currentLayout : undefined, children: [pageHeader, pageBar && (_jsx("div", { "data-slot": "data-table-page-bar", className: "min-w-0 contain-inline-size", children: pageBar })), viewPills, plainToolbar, _jsx("div", { ref: body, "data-slot": "data-table-body", className: cn('flex flex-col gap-4', fitsColumns && CONTENT_WIDTH_CLASS), style: lastWidthStyle, children: stateView ?? (_jsxs(DetailFrame, { enabled: Boolean(detailPanel) && !cardLayout, aside: detailAside, children: [rowsView, pagination] })) })] }));
859
859
  return (_jsx(EditInPlaceContext.Provider, { value: store, children: _jsxs(RowActionsContext.Provider, { value: rowActions, children: [editing && _jsx(LeaveGuard, { store: store }), width === 'content' ? _jsx("div", { className: "@container/data-table", children: content }) : content, detailPanel && (_jsx(Sheet, { open: Boolean(selectedRow) && !isWide && isSuccessView && !cardLayout, onOpenChange: (open) => {
860
860
  if (!open)
861
861
  setSelection(null);
@@ -20,7 +20,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
20
  // typed, closing asks "Discard your changes?" first (the dialog
21
21
  // standard's `dirty`). Width, words and the buttons stay as they are.
22
22
  //
23
- // The trigger is an icon (IconAction's Trash2) unless `trigger` says
23
+ // The trigger is an icon (IconAction's Trash2, named "Delete <name>" since
24
+ // 4.123, its tooltip "Delete") unless `trigger` says
24
25
  // otherwise: `"button"` for a "Delete" button in words, an element of the
25
26
  // caller's, or `null` for none, opened with `open`/`onOpenChange` (a row's
26
27
  // menu item).
@@ -74,5 +75,5 @@ export function DeleteAction({ name, kind, onDelete, onRestore, onDeleted, verb
74
75
  if (!next)
75
76
  remove.reset();
76
77
  setOpen(next);
77
- }, children: [trigger === 'icon' && (_jsx(DialogTrigger, { render: _jsx(IconAction, { icon: Trash2Icon, label: verb, tone: "destructive", size: size }) })), trigger === 'button' && (_jsx(DialogTrigger, { render: _jsx(Button, { variant: "outline", size: size === 'sm' ? 'sm' : 'default' }), children: verb })), trigger && typeof trigger === 'object' && _jsx(DialogTrigger, { render: trigger }), _jsxs(DialogContent, { size: "confirm", dirty: reason !== undefined && typed.trim() !== '' && !remove.pending, "data-slot": "delete-action", "data-kind": kind, children: [_jsxs(DialogHeader, { children: [_jsxs(DialogTitle, { children: [verb, " ", name, "?"] }), _jsx(DialogDescription, { children: description ?? SAYS[kind] })] }), reason && (_jsxs(Field, { "data-slot": "delete-action-reason", children: [_jsx(FieldLabel, { htmlFor: reasonId, children: reason.label ?? 'Why' }), _jsx(Textarea, { id: reasonId, value: typed, placeholder: reason.placeholder, disabled: remove.pending, onChange: (event) => setTyped(event.target.value) }), reason.hint && _jsx(FieldDescription, { children: reason.hint })] })), _jsx(ActionError, { action: { ...remove, retry: confirm } }), _jsxs(DialogFooter, { children: [_jsx(DialogClose, { render: _jsx(Button, { variant: "outline", disabled: remove.pending }), children: "Cancel" }), _jsxs(Button, { variant: "destructive", disabled: remove.pending, onClick: () => void confirm(), children: [remove.pending && _jsx(Spinner, { className: "size-4" }), verb] })] })] })] }));
78
+ }, children: [trigger === 'icon' && (_jsx(DialogTrigger, { render: _jsx(IconAction, { icon: Trash2Icon, label: verb, accessibleName: `${verb} ${name}`, tone: "destructive", size: size }) })), trigger === 'button' && (_jsx(DialogTrigger, { render: _jsx(Button, { variant: "outline", size: size === 'sm' ? 'sm' : 'default' }), children: verb })), trigger && typeof trigger === 'object' && _jsx(DialogTrigger, { render: trigger }), _jsxs(DialogContent, { size: "confirm", dirty: reason !== undefined && typed.trim() !== '' && !remove.pending, "data-slot": "delete-action", "data-kind": kind, children: [_jsxs(DialogHeader, { children: [_jsxs(DialogTitle, { children: [verb, " ", name, "?"] }), _jsx(DialogDescription, { children: description ?? SAYS[kind] })] }), reason && (_jsxs(Field, { "data-slot": "delete-action-reason", children: [_jsx(FieldLabel, { htmlFor: reasonId, children: reason.label ?? 'Why' }), _jsx(Textarea, { id: reasonId, value: typed, placeholder: reason.placeholder, disabled: remove.pending, onChange: (event) => setTyped(event.target.value) }), reason.hint && _jsx(FieldDescription, { children: reason.hint })] })), _jsx(ActionError, { action: { ...remove, retry: confirm } }), _jsxs(DialogFooter, { children: [_jsx(DialogClose, { render: _jsx(Button, { variant: "outline", disabled: remove.pending }), children: "Cancel" }), _jsxs(Button, { variant: "destructive", disabled: remove.pending, onClick: () => void confirm(), children: [remove.pending && _jsx(Spinner, { className: "size-4" }), verb] })] })] })] }));
78
79
  }
@@ -101,7 +101,15 @@ export type EntityViewFactBadge = {
101
101
  label: string;
102
102
  /** An icon component (a `LucideIcon`, an app's own mark) or a node drawn as it is. Decorative: the label says it. */
103
103
  icon?: IconComponent | ReactNode;
104
+ /**
105
+ * The badge's tone (4.123), for a label that is a state ("Pinned",
106
+ * "Overdue"): the outline badge in that tone's text colour, its icon
107
+ * too. Neutral (the outline) unless set. The word still says it.
108
+ */
109
+ tone?: EntityViewFactBadgeTone;
104
110
  };
111
+ /** A badge item's tone (4.123): the design language's four, as outline badges. */
112
+ export type EntityViewFactBadgeTone = 'success' | 'warning' | 'info' | 'destructive';
105
113
  /** A small button under a fact's value (4.115): "Close…" under a status that changes only through it. */
106
114
  export type EntityViewFactAction = {
107
115
  /** The button's words ("Close…"; an ellipsis when it opens a dialog). */
@@ -9,15 +9,21 @@ import { RatingScore } from './rating-score.js';
9
9
  import { StepBar } from './step-bar.js';
10
10
  import { StatusMark } from './status-mark.js';
11
11
  import { FactSwitch } from './fact-extras.js';
12
+ const BADGE_TONE = {
13
+ success: 'outline-success',
14
+ warning: 'outline-warning',
15
+ info: 'outline-info',
16
+ destructive: 'outline-destructive',
17
+ };
12
18
  const LINK_CLASS = 'rounded-sm font-medium text-link underline-offset-4 outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50';
13
19
  // A badge item's icon in the muted tone a list's item icons have
14
20
  // (FactList's marks): a component drawn at the badge's icon size, or the
15
21
  // app's own node as it is.
16
- function badgeIcon(icon) {
22
+ function badgeIcon(icon, toned = false) {
17
23
  // A component: a function, or a forwardRef or memo object (a LucideIcon); an element is a node.
18
24
  const isComponent = typeof icon === 'function' || (typeof icon === 'object' && icon !== null && !isValidElement(icon) && '$$typeof' in icon);
19
25
  const Icon = icon;
20
- return (_jsx("span", { "data-slot": "entity-view-fact-badge-icon", "aria-hidden": "true", "data-icon": "inline-start", className: "inline-flex shrink-0 text-muted-foreground", children: isComponent ? _jsx(Icon, { "aria-hidden": "true", className: "size-3" }) : icon }));
26
+ return (_jsx("span", { "data-slot": "entity-view-fact-badge-icon", "aria-hidden": "true", "data-icon": "inline-start", className: cn('inline-flex shrink-0', !toned && 'text-muted-foreground'), children: isComponent ? _jsx(Icon, { "aria-hidden": "true", className: "size-3" }) : icon }));
21
27
  }
22
28
  /** A fact as the view draws it: `null` when empty. `label` names a control the fact draws (a switch). */
23
29
  export function factValue(fact, label = '') {
@@ -36,8 +42,8 @@ export function factValue(fact, label = '') {
36
42
  if (fact.items.length === 0)
37
43
  return null;
38
44
  return (_jsx("span", { className: "inline-flex max-w-full flex-wrap gap-1", children: fact.items.map((item, index) => {
39
- const { label, icon } = typeof item === 'string' ? { label: item, icon: undefined } : item;
40
- return (_jsxs(Badge, { variant: "outline", className: "max-w-full", children: [icon !== undefined && icon !== null && badgeIcon(icon), _jsx("span", { className: "min-w-0 truncate", children: label })] }, `${index}:${label}`));
45
+ const { label, icon, tone } = typeof item === 'string' ? { label: item, icon: undefined, tone: undefined } : item;
46
+ return (_jsxs(Badge, { variant: tone ? BADGE_TONE[tone] : 'outline', "data-tone": tone, className: "max-w-full", children: [icon !== undefined && icon !== null && badgeIcon(icon, tone !== undefined), _jsx("span", { className: "min-w-0 truncate", children: label })] }, `${index}:${label}`));
41
47
  }) }));
42
48
  case 'count':
43
49
  return fact.to ? (_jsx(Link, { to: fact.to, className: cn(LINK_CLASS, 'tabular-nums'), children: fact.count })) : (_jsx("span", { className: "tabular-nums", children: fact.count }));