@tristan2828/ui-foundation 4.136.1 → 4.137.1
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.
- package/README.md +7 -6
- package/bin/ui-foundation.mjs +1 -1
- package/conventions/agents/skills/new-entity/SKILL.md +5 -2
- package/conventions/agents/spec-tester.md +3 -3
- package/conventions/docs/add-an-entity.md +722 -714
- package/conventions/docs/cell-patterns.md +206 -378
- package/conventions/docs/column-options.md +6 -12
- package/conventions/docs/design-language.md +294 -516
- package/conventions/docs/entity-plan-template.md +9 -7
- package/conventions/docs/reminders.md +12 -17
- package/conventions/docs/timed-screens.md +17 -20
- package/dist/components/app/action-error.js +1 -1
- package/dist/components/app/action-hint.js +1 -1
- package/dist/components/app/app-shell-bottom-bar.js +4 -4
- package/dist/components/app/app-shell-nav.d.ts +1 -1
- package/dist/components/app/app-shell-nav.js +1 -1
- package/dist/components/app/app-shell.d.ts +1 -1
- package/dist/components/app/app-shell.js +9 -9
- package/dist/components/app/board.d.ts +13 -13
- package/dist/components/app/board.js +3 -3
- package/dist/components/app/choice-buttons.d.ts +1 -1
- package/dist/components/app/data-table-tools.d.ts +3 -3
- package/dist/components/app/data-table.d.ts +11 -13
- package/dist/components/app/data-table.js +5 -5
- package/dist/components/app/date-field.js +1 -1
- package/dist/components/app/delete-action.d.ts +1 -1
- package/dist/components/app/delete-action.js +4 -4
- package/dist/components/app/edit-caret.js +1 -1
- package/dist/components/app/edit-in-place-presets.d.ts +4 -4
- package/dist/components/app/edit-in-place-store.d.ts +3 -3
- package/dist/components/app/edit-in-place-store.js +7 -7
- package/dist/components/app/editable-list.js +2 -3
- package/dist/components/app/editable-value.d.ts +2 -2
- package/dist/components/app/editable-value.js +20 -20
- package/dist/components/app/entity-form.js +2 -2
- package/dist/components/app/entity-view-facts.d.ts +12 -12
- package/dist/components/app/entity-view-facts.js +1 -1
- package/dist/components/app/entity-view.d.ts +16 -16
- package/dist/components/app/entity-view.js +28 -33
- package/dist/components/app/equal-items.js +4 -4
- package/dist/components/app/fact-extras.js +5 -5
- package/dist/components/app/field-rows.js +5 -5
- package/dist/components/app/fill-in-queue.js +2 -3
- package/dist/components/app/filter-bar.d.ts +1 -1
- package/dist/components/app/filter-date.js +1 -1
- package/dist/components/app/filter-name.js +1 -1
- package/dist/components/app/form-dialog.js +2 -2
- package/dist/components/app/form-leave-guard.js +2 -2
- package/dist/components/app/form-section.js +1 -1
- package/dist/components/app/icon-action.d.ts +1 -1
- package/dist/components/app/icon-action.js +2 -2
- package/dist/components/app/image-field.js +0 -1
- package/dist/components/app/keep-pencil-room.js +1 -1
- package/dist/components/app/key-stats.d.ts +3 -3
- package/dist/components/app/line-chart.d.ts +1 -1
- package/dist/components/app/line-chart.js +4 -4
- package/dist/components/app/list-editor-rows.js +1 -1
- package/dist/components/app/list-editor.js +1 -1
- package/dist/components/app/list-header.d.ts +6 -6
- package/dist/components/app/list-header.js +8 -8
- package/dist/components/app/markdown.js +30 -37
- package/dist/components/app/milkdown-editor.js +37 -62
- package/dist/components/app/module-card.js +6 -7
- package/dist/components/app/month-calendar.d.ts +46 -0
- package/dist/components/app/month-calendar.js +160 -0
- package/dist/components/app/month-day-field.js +0 -1
- package/dist/components/app/multi-choice.d.ts +1 -1
- package/dist/components/app/multi-choice.js +3 -3
- package/dist/components/app/multi-line-chart.js +5 -5
- package/dist/components/app/multi-pick.js +9 -10
- package/dist/components/app/multi-reference.js +2 -2
- package/dist/components/app/notes-outline.js +0 -1
- package/dist/components/app/notify.js +2 -2
- package/dist/components/app/offline-notice.js +1 -1
- package/dist/components/app/option-icon.js +1 -1
- package/dist/components/app/option-select.d.ts +1 -1
- package/dist/components/app/overview-page.d.ts +2 -2
- package/dist/components/app/overview-page.js +1 -1
- package/dist/components/app/page-trail-context.js +1 -1
- package/dist/components/app/pill-filter.d.ts +2 -2
- package/dist/components/app/prose-look.js +1 -1
- package/dist/components/app/quick-add-input.js +1 -1
- package/dist/components/app/rating-input.js +1 -1
- package/dist/components/app/rating-score.js +1 -1
- package/dist/components/app/record-dialog.js +25 -40
- package/dist/components/app/recurrence-field.js +6 -6
- package/dist/components/app/reference-combobox.js +1 -2
- package/dist/components/app/rich-text-box-anchor.js +0 -1
- package/dist/components/app/rich-text-edges.js +2 -2
- package/dist/components/app/rich-text-editor.d.ts +2 -3
- package/dist/components/app/rich-text-editor.js +19 -32
- package/dist/components/app/rich-text-empty-paragraph.d.ts +6 -7
- package/dist/components/app/rich-text-empty-paragraph.js +6 -7
- package/dist/components/app/rich-text-floating-toolbar.js +0 -1
- package/dist/components/app/rich-text-formats.js +2 -2
- package/dist/components/app/rich-text-input-rules.js +1 -2
- package/dist/components/app/rich-text-keyboard-bar.js +6 -7
- package/dist/components/app/rich-text-node-views.js +1 -2
- package/dist/components/app/rich-text-shortcuts.js +8 -8
- package/dist/components/app/rich-text-slash-menu.js +4 -6
- package/dist/components/app/rich-text-slash.d.ts +2 -2
- package/dist/components/app/rich-text-slash.js +2 -2
- package/dist/components/app/rich-text-table-grips.d.ts +1 -1
- package/dist/components/app/rich-text-table-grips.js +1 -2
- package/dist/components/app/rich-text-tasks.d.ts +1 -1
- package/dist/components/app/rich-text-tasks.js +1 -1
- package/dist/components/app/rich-text-touch.js +1 -1
- package/dist/components/app/search-palette.js +1 -2
- package/dist/components/app/secondary-filters.js +2 -3
- package/dist/components/app/session-view.js +1 -1
- package/dist/components/app/stacked-area-chart.js +1 -1
- package/dist/components/app/step-track.d.ts +1 -1
- package/dist/components/app/step-track.js +3 -3
- package/dist/components/app/widget-card.js +26 -30
- package/dist/components/app/widget-layout-sheet.js +1 -1
- package/dist/components/ui/calendar.js +2 -2
- package/dist/components/ui/combobox.d.ts +1 -1
- package/dist/components/ui/combobox.js +2 -2
- package/dist/components/ui/field.d.ts +1 -1
- package/dist/components/ui/field.js +6 -6
- package/dist/components/ui/skeleton.js +1 -1
- package/dist/components/ui/sonner.js +1 -1
- package/dist/components/ui/tabs.js +1 -1
- package/dist/error-reporting/reporter.d.ts +1 -1
- package/dist/error-reporting/reporter.js +1 -1
- package/dist/hooks/table-url-changes.d.ts +2 -2
- package/dist/hooks/table-url-changes.js +5 -6
- package/dist/hooks/use-action.js +1 -1
- package/dist/hooks/use-record-update.js +1 -1
- package/dist/hooks/use-table-url-state.d.ts +1 -1
- package/dist/hooks/use-table-url-state.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -2
- package/dist/lib/audio-cues.js +2 -2
- package/dist/lib/connection.js +1 -1
- package/dist/lib/date-filter.js +1 -1
- package/dist/lib/entity-view-tab.js +1 -1
- package/dist/lib/field-rows.js +2 -2
- package/dist/lib/form-errors.d.ts +1 -1
- package/dist/lib/form-errors.js +1 -1
- package/dist/lib/keep-audio-alive.js +1 -1
- package/dist/lib/line-chart-layout.js +4 -4
- package/dist/lib/markdown-inline.js +0 -2
- package/dist/lib/markdown-merge.js +2 -2
- package/dist/lib/markdown-table-widths.js +1 -1
- package/dist/lib/markdown-table.js +1 -2
- package/dist/lib/markdown-toggle.js +1 -1
- package/dist/lib/page-leaving.js +1 -1
- package/dist/lib/recurrence-format.d.ts +2 -2
- package/dist/lib/recurrence-format.js +1 -1
- package/dist/lib/recurrence-phrase.d.ts +1 -1
- package/dist/lib/recurrence-phrase.js +2 -2
- package/dist/lib/recurrence.d.ts +1 -1
- package/dist/lib/recurrence.js +2 -2
- package/dist/lib/stale-chunk-reload.js +1 -1
- package/dist/lib/status-kinds.d.ts +1 -1
- package/dist/lib/status-kinds.js +2 -2
- package/dist/mocks/start-worker.js +2 -2
- package/dist/routes/login.js +1 -1
- package/dist/testing/index.d.ts +7 -4
- package/dist/testing/index.js +10 -13
- package/package.json +2 -2
- package/styles/index.css +4 -4
- package/styles/theme.css +14 -20
- package/vite/pwa.js +1 -1
|
@@ -3,48 +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
|
|
7
|
-
- [1. Plain text](#1-plain-text) · lines
|
|
8
|
-
- [2. Icon + label](#2-icon--label) · lines
|
|
9
|
-
- [3. Icon in a badge](#3-icon-in-a-badge) · lines
|
|
10
|
-
- [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines
|
|
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
|
|
12
|
-
- [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines 277
|
|
13
|
-
- [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines
|
|
14
|
-
- [7. Link as an outline button](#7-link-as-an-outline-button) · lines
|
|
15
|
-
- [8. Date, relative](#8-date-relative) · lines
|
|
16
|
-
- [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines
|
|
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
|
|
18
|
-
- [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines
|
|
19
|
-
- [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines
|
|
20
|
-
- [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines
|
|
21
|
-
- [12. Boolean](#12-boolean) · lines
|
|
22
|
-
- [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines
|
|
23
|
-
- [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines
|
|
24
|
-
- [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines
|
|
25
|
-
- [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines
|
|
26
|
-
- [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines
|
|
27
|
-
- [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines
|
|
28
|
-
- [17. Quick action on the view](#17-quick-action-on-the-view) · lines
|
|
29
|
-
- [18. Editable value](#18-editable-value) · lines
|
|
30
|
-
- [Presets: one line per field](#presets-one-line-per-field) · lines
|
|
31
|
-
- [Several fields edited as one](#several-fields-edited-as-one) · lines
|
|
32
|
-
- [A link and its label](#a-link-and-its-label) · lines
|
|
33
|
-
- [A list of sub-items](#a-list-of-sub-items) · lines
|
|
34
|
-
- [In a table's rows](#in-a-tables-rows) · lines
|
|
35
|
-
- [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines
|
|
36
|
-
- [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines
|
|
37
|
-
- [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines
|
|
38
|
-
- [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines
|
|
39
|
-
- [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines
|
|
40
|
-
- [
|
|
41
|
-
- [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines
|
|
42
|
-
- [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines
|
|
43
|
-
- [Picking one on a form: `ColorField`](#picking-one-on-a-form-colorfield) · lines
|
|
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
|
|
45
|
-
- [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines
|
|
46
|
-
- [26. A record's related list, capped](#26-a-records-related-list-capped) · lines
|
|
47
|
-
- [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines
|
|
6
|
+
- [The rules that apply to every cell](#the-rules-that-apply-to-every-cell) · lines 63–86
|
|
7
|
+
- [1. Plain text](#1-plain-text) · lines 88–137
|
|
8
|
+
- [2. Icon + label](#2-icon--label) · lines 139–162
|
|
9
|
+
- [3. Icon in a badge](#3-icon-in-a-badge) · lines 164–177
|
|
10
|
+
- [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines 179–255
|
|
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 204–255
|
|
12
|
+
- [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines 257–277
|
|
13
|
+
- [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 279–291
|
|
14
|
+
- [7. Link as an outline button](#7-link-as-an-outline-button) · lines 293–314
|
|
15
|
+
- [8. Date, relative](#8-date-relative) · lines 316–353
|
|
16
|
+
- [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 355–431
|
|
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 373–431
|
|
18
|
+
- [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 433–482
|
|
19
|
+
- [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 451–482
|
|
20
|
+
- [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 484–524
|
|
21
|
+
- [12. Boolean](#12-boolean) · lines 526–554
|
|
22
|
+
- [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 556–590
|
|
23
|
+
- [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 575–590
|
|
24
|
+
- [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 592–610
|
|
25
|
+
- [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 612–714
|
|
26
|
+
- [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 635–714
|
|
27
|
+
- [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 716–757
|
|
28
|
+
- [17. Quick action on the view](#17-quick-action-on-the-view) · lines 759–831
|
|
29
|
+
- [18. Editable value](#18-editable-value) · lines 833–1571
|
|
30
|
+
- [Presets: one line per field](#presets-one-line-per-field) · lines 1217–1289
|
|
31
|
+
- [Several fields edited as one](#several-fields-edited-as-one) · lines 1291–1327
|
|
32
|
+
- [A link and its label](#a-link-and-its-label) · lines 1329–1353
|
|
33
|
+
- [A list of sub-items](#a-list-of-sub-items) · lines 1355–1488
|
|
34
|
+
- [In a table's rows](#in-a-tables-rows) · lines 1490–1564
|
|
35
|
+
- [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1566–1571
|
|
36
|
+
- [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1573–1639
|
|
37
|
+
- [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1641–1695
|
|
38
|
+
- [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1697–1779
|
|
39
|
+
- [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1781–1806
|
|
40
|
+
- [28. A list's rows: hover, lines, rows per page](#28-a-lists-rows-hover-lines-rows-per-page) · lines 1808–1841
|
|
41
|
+
- [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1843–1894
|
|
42
|
+
- [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1896–1970
|
|
43
|
+
- [Picking one on a form: `ColorField`](#picking-one-on-a-form-colorfield) · lines 1916–1970
|
|
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 1972–2183
|
|
45
|
+
- [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2132–2183
|
|
46
|
+
- [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2185–2219
|
|
47
|
+
- [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2221–2268
|
|
48
48
|
|
|
49
49
|
<!-- /index -->
|
|
50
50
|
|
|
@@ -53,30 +53,17 @@ first attempt gets wrong — **not components**: the lookup maps are always
|
|
|
53
53
|
per-entity, and only the shape is reusable. Copy the markup into your
|
|
54
54
|
`<entity>-columns.tsx`.
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
20 (count linking to the related records) and 22 (a highlighted row),
|
|
63
|
-
the multi-value variant of 4, the step bar and star in 9, the dependency
|
|
64
|
-
list in 10, the ring in 13 and the pressed icon in 15 were each built
|
|
65
|
-
for a real app's screen first; the package's fixtures renders
|
|
66
|
-
them (`app/StageCircle`, `app/CountLink`, `patterns/CellPatterns`,
|
|
67
|
-
`patterns/Scales`, `app/DataTable`), and
|
|
68
|
-
its checks pin their accessibility and contrast in both themes. The
|
|
69
|
-
other patterns from 11 on are marked **Unproven**: written ahead of a
|
|
70
|
-
real column, so no app has tested them on real data yet. Prefer a proven
|
|
71
|
-
pattern when one fits. When you use an unproven one, say so in the
|
|
72
|
-
entity's plan, and raise what you learned for the foundation, so the
|
|
73
|
-
entry can lose its label. A pattern that proves generic is worth raising
|
|
74
|
-
too, so it ships here for every app.
|
|
56
|
+
A pattern marked **Unproven** was written ahead of a real column, so no
|
|
57
|
+
app has tested it on real data yet. Prefer a proven pattern when one
|
|
58
|
+
fits. When you use an unproven one, say so in the entity's plan, and
|
|
59
|
+
raise what you learned for the foundation, so the entry can lose its
|
|
60
|
+
label. A pattern that proves generic is worth raising too, so it ships
|
|
61
|
+
here for every app.
|
|
75
62
|
|
|
76
63
|
## The rules that apply to every cell
|
|
77
64
|
|
|
78
65
|
- **An empty value renders an em dash**, never a blank cell: a blank reads
|
|
79
|
-
as a rendering bug. Draw it with the package's `EmptyText
|
|
66
|
+
as a rendering bug. Draw it with the package's `EmptyText`, the
|
|
80
67
|
record's own dash, read by a screen reader as "Not set" (`label` for
|
|
81
68
|
other words): `const emptyCell = <EmptyText />` once per columns file,
|
|
82
69
|
used everywhere. Never a hand-written dash. The one exception is a value whose "nothing" state
|
|
@@ -104,8 +91,8 @@ The default, and it wins more often than it looks like it should. Reach for
|
|
|
104
91
|
something else only when the extra ink buys a decision the reader would
|
|
105
92
|
otherwise have to make themselves.
|
|
106
93
|
|
|
107
|
-
Always offer a plain-text option when exploring a column
|
|
108
|
-
|
|
94
|
+
Always offer a plain-text option when exploring a column
|
|
95
|
+
([`column-options.md`](column-options.md)).
|
|
109
96
|
|
|
110
97
|
**Markdown in a one-line value.** A short field the app lets people write
|
|
111
98
|
Markdown in (a summary, a status note, a title with a link) shows in a
|
|
@@ -144,16 +131,10 @@ can't make the whole table thousands of pixels wide:
|
|
|
144
131
|
{ id: 'notes', header: 'Notes', meta: { clip: true }, cell: ({ row }) => row.original.notes }
|
|
145
132
|
```
|
|
146
133
|
|
|
147
|
-
- One line, cut at `meta.maxWidth` (`'24rem'` unless set, and never over
|
|
148
|
-
60% of the table's area, so a phone keeps room for the name) with an
|
|
149
|
-
ellipsis.
|
|
150
|
-
- The whole text shows in a tooltip on hover and on focus: a cell that's
|
|
151
|
-
actually cut takes a tab stop, one that fits takes none. A screen reader
|
|
152
|
-
reads the whole text either way, and the record shows it too.
|
|
153
134
|
- `meta.maxWidth` alone caps the column and lets its text wrap, for a
|
|
154
135
|
value worth reading whole in the row.
|
|
155
136
|
- The title column (the first) is cut this way already, with no `meta`
|
|
156
|
-
(pattern 16
|
|
137
|
+
(pattern 16).
|
|
157
138
|
|
|
158
139
|
## 2. Icon + label
|
|
159
140
|
|
|
@@ -223,8 +204,7 @@ narrow.
|
|
|
223
204
|
### Several values: the icons side by side, every name in one tooltip
|
|
224
205
|
|
|
225
206
|
A multi value (several categories on one record) where each value has
|
|
226
|
-
its own icon and colour slot, and the column is narrow.
|
|
227
|
-
fixtures render it (`patterns/CellPatterns`, "Icons with one tooltip").
|
|
207
|
+
its own icon and colour slot, and the column is narrow.
|
|
228
208
|
|
|
229
209
|
```tsx
|
|
230
210
|
// values: the row's categories, `undefined` for one still loading.
|
|
@@ -280,7 +260,7 @@ A many-valued enum that collapses to good / neutral / bad. **The grouping
|
|
|
280
260
|
is the decision, not the style** — see
|
|
281
261
|
[`design-language.md`](design-language.md#mapping-an-enum-to-tones).
|
|
282
262
|
|
|
283
|
-
**A record's status** is not this pattern
|
|
263
|
+
**A record's status** is not this pattern: it's a
|
|
284
264
|
`StatusMark` (an icon, a colour and the word, one of six kinds; see
|
|
285
265
|
[`design-language.md` "Status marks"](design-language.md#status-marks)),
|
|
286
266
|
`<StatusMark kind={STATUS_KIND[status]}>{STATUS_LABELS[status]}</StatusMark>`
|
|
@@ -392,9 +372,7 @@ own state.
|
|
|
392
372
|
|
|
393
373
|
### Three variants the package draws: a step bar, a star and a score
|
|
394
374
|
|
|
395
|
-
|
|
396
|
-
the page and on a card, measured by axe and the glyph check in both
|
|
397
|
-
themes. Each is one image to a screen reader, named in words.
|
|
375
|
+
Each is one image to a screen reader, named in words.
|
|
398
376
|
|
|
399
377
|
- **`StepBar`, an ordered enum of a few bands** (best to worst): a short
|
|
400
378
|
bar of steps, the first `value` filled in `foreground`, the rest the
|
|
@@ -419,7 +397,7 @@ themes. Each is one image to a screen reader, named in words.
|
|
|
419
397
|
<RatingStar value={OWNED[o].value /* 'full' | 'half' | 'empty' */} word={OWNED[o].word} />
|
|
420
398
|
```
|
|
421
399
|
|
|
422
|
-
- **`RatingScore`, a score out of a few
|
|
400
|
+
- **`RatingScore`, a score out of a few**: `max` stars (the
|
|
423
401
|
default) or hearts (`glyph="heart"`), the first `value` filled in
|
|
424
402
|
`foreground`, the rest outlines in `muted-foreground` (which clears 3:1,
|
|
425
403
|
so an empty glyph is still seen). Named "4 of 5";
|
|
@@ -427,10 +405,10 @@ themes. Each is one image to a screen reader, named in words.
|
|
|
427
405
|
rail's `rating` fact draws it too.
|
|
428
406
|
|
|
429
407
|
```tsx
|
|
430
|
-
{row.rating === null ? <
|
|
408
|
+
{row.rating === null ? <span className="text-muted-foreground">Not rated</span> : <RatingScore value={row.rating} glyph="heart" />}
|
|
431
409
|
```
|
|
432
410
|
|
|
433
|
-
- **`RatingInput`, the same score set by a click
|
|
411
|
+
- **`RatingInput`, the same score set by a click**: RatingScore's
|
|
434
412
|
glyphs and tokens as a radio group named by `label`, one radio per
|
|
435
413
|
star ("2 of 5"). A click (or Space) sets a star, a click on the set one
|
|
436
414
|
clears it to `null`, the arrow keys move and set it, a mouse's hover
|
|
@@ -449,7 +427,7 @@ themes. Each is one image to a screen reader, named in words.
|
|
|
449
427
|
),
|
|
450
428
|
```
|
|
451
429
|
|
|
452
|
-
- All
|
|
430
|
+
- All of them draw in `foreground`. Tone one only as pattern 5 would (a `*-text`
|
|
453
431
|
class in `className`), never by band alone.
|
|
454
432
|
|
|
455
433
|
## 10. Summary in the cell, detail in a popover
|
|
@@ -474,8 +452,7 @@ A one-to-many value (`★ 4.7 (3)` opening a per-person breakdown).
|
|
|
474
452
|
|
|
475
453
|
The records a row waits on (parts it needs, a date that has to pass,
|
|
476
454
|
other records that have to finish), summarised in the cell, listed in
|
|
477
|
-
the popover.
|
|
478
|
-
(`patterns/CellPatterns`, "Dependency list").
|
|
455
|
+
the popover.
|
|
479
456
|
|
|
480
457
|
- **The cell: a computed summary.** "Ready" when nothing holds the row,
|
|
481
458
|
else the count of what does ("1 hold", "2 holds"). Compute it where the
|
|
@@ -548,9 +525,7 @@ const priceFormatter = new Intl.NumberFormat(undefined, { style: 'currency', cur
|
|
|
548
525
|
|
|
549
526
|
## 12. Boolean
|
|
550
527
|
|
|
551
|
-
A yes/no field.
|
|
552
|
-
is the reference; its value is never null, so it drops the `emptyCell`
|
|
553
|
-
branch below.
|
|
528
|
+
A yes/no field.
|
|
554
529
|
|
|
555
530
|
```tsx
|
|
556
531
|
cell: ({ getValue }) => {
|
|
@@ -582,9 +557,8 @@ cell: ({ getValue }) => {
|
|
|
582
557
|
|
|
583
558
|
A percentage, or a count out of a total (`7 of 12 done`).
|
|
584
559
|
|
|
585
|
-
- The package
|
|
586
|
-
|
|
587
|
-
checking its dependencies against `deps-allowlist.json`).
|
|
560
|
+
- The package ships `progress`: import it from
|
|
561
|
+
`@tristan2828/ui-foundation/ui/progress`.
|
|
588
562
|
- **Always print the number** beside the bar (`72%`, `7 / 12`). The bar
|
|
589
563
|
shows roughly how far; the number says exactly.
|
|
590
564
|
- Fix the bar's width (`w-24`) so bars compare down the column. A bar that
|
|
@@ -602,8 +576,7 @@ A percentage, or a count out of a total (`7 of 12 done`).
|
|
|
602
576
|
|
|
603
577
|
Done out of total (a checklist, how far through an ordered list, the
|
|
604
578
|
steps of a process) as a small ring filling clockwise beside the count
|
|
605
|
-
("4/6").
|
|
606
|
-
ships it, so this needs no `progress` install.
|
|
579
|
+
("4/6"). The package ships it.
|
|
607
580
|
|
|
608
581
|
```tsx
|
|
609
582
|
<ProgressRing done={row.original.doneCount} total={row.original.itemCount} />
|
|
@@ -620,8 +593,9 @@ ships it, so this needs no `progress` install.
|
|
|
620
593
|
|
|
621
594
|
A person: an assignee or an owner.
|
|
622
595
|
|
|
623
|
-
- The package doesn't ship `avatar`. Install shadcn's
|
|
624
|
-
|
|
596
|
+
- The package doesn't ship `avatar`. Install shadcn's into
|
|
597
|
+
`src/components/ui/` (`npx shadcn@<tools.shadcn> add avatar`, after
|
|
598
|
+
checking its dependencies against `deps-allowlist.json`).
|
|
625
599
|
- **Always render the fallback** (initials). Images fail, load slowly, or
|
|
626
600
|
aren't set, and the cell must still look intentional.
|
|
627
601
|
- The image is decorative (`alt=""`) because the name is right beside
|
|
@@ -645,15 +619,12 @@ now", "happened"). Widget's In Stock column is the reference
|
|
|
645
619
|
reads as "select this row".
|
|
646
620
|
- **It saves on its own:** a PATCH of that one field, not the form,
|
|
647
621
|
through the foundation's `useRecordUpdate` (Widget's
|
|
648
|
-
`useSaveWidgetField`)
|
|
649
|
-
the
|
|
650
|
-
|
|
651
|
-
- **Saving blocks nothing.** The switch stays usable (a second flip waits
|
|
652
|
-
for the first and builds on it), and a "Saving" spinner shows beside it
|
|
653
|
-
in a slot that's always there, so the cell never changes width.
|
|
622
|
+
`useSaveWidgetField`), and saving blocks nothing. Pattern 17 has the
|
|
623
|
+
rules (the value at once, a refusal put back with a toast, the "Saving"
|
|
624
|
+
slot that's always there); they're the same in a row.
|
|
654
625
|
- **Keep the word beside it** (pattern 12), `aria-hidden` since the switch
|
|
655
626
|
announces its own state. Give the switch a row-specific name
|
|
656
|
-
(`In
|
|
627
|
+
(`In Stock: ${row.original.name}`).
|
|
657
628
|
- Its own component in its own file, rendered from the column's `cell`,
|
|
658
629
|
so the hook lives in a component and the columns stay stable
|
|
659
630
|
([`add-an-entity.md`](add-an-entity.md) "Keep column definitions
|
|
@@ -666,8 +637,7 @@ now", "happened"). Widget's In Stock column is the reference
|
|
|
666
637
|
A yes/no that belongs to another value rather than having a column of
|
|
667
638
|
its own: a "focus" flag that only exists while the status is "doing", a
|
|
668
639
|
"pinned" mark on an open item. It's a small icon button inside the owning
|
|
669
|
-
value's cell, beside its word.
|
|
670
|
-
(`patterns/CellPatterns`, "Pressed icon in a cell").
|
|
640
|
+
value's cell, beside its word.
|
|
671
641
|
|
|
672
642
|
**Pick it over the Switch** when the yes/no only means something while
|
|
673
643
|
another value allows it, or when a Switch and its words would crowd that
|
|
@@ -719,8 +689,7 @@ export function FocusToggle({ item }: { item: Item }) {
|
|
|
719
689
|
faintest step that still clears WCAG's 3:1 non-text minimum in light
|
|
720
690
|
mode (3.2:1; dark is 5.2:1). `/70` measures 2.7:1, and a control a
|
|
721
691
|
reader can't see fails them. Hover lifts it to full
|
|
722
|
-
`muted-foreground`. axe doesn't measure icons
|
|
723
|
-
fixtures glyph check does.
|
|
692
|
+
`muted-foreground`. axe doesn't measure icons.
|
|
724
693
|
- **Tone: `destructive-text`, read as "flagged", not "error".** A flag
|
|
725
694
|
claims attention ahead of the rest of the row, and the destructive
|
|
726
695
|
tone is the one with that pull. The other tones are taken where it
|
|
@@ -731,12 +700,10 @@ export function FocusToggle({ item }: { item: Item }) {
|
|
|
731
700
|
broken) and because no word beside it says error. If a flag is common,
|
|
732
701
|
or does mean "something's wrong", it's an enum with a verdict
|
|
733
702
|
(pattern 5) instead.
|
|
734
|
-
- **It saves on its own, through `useRecordUpdate`**, like the Switch
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
both; add nothing.
|
|
738
|
-
- **The "Saving" slot is always there**, after the toggle, so nothing
|
|
739
|
-
moves while it saves, and nothing is disabled.
|
|
703
|
+
- **It saves on its own, through `useRecordUpdate`**, like the Switch
|
|
704
|
+
(pattern 17's rules): a refusal (a cap the server enforces) puts it
|
|
705
|
+
back with the toast, and the "Saving" slot after the toggle is always
|
|
706
|
+
there. The hook does both; add nothing.
|
|
740
707
|
- **Only rendered while the owning value allows it.** When the status
|
|
741
708
|
moves on, the toggle goes; what the server does with the flag then (it
|
|
742
709
|
clears it, or keeps it for next time) is the plan's rule, and shows
|
|
@@ -782,17 +749,12 @@ cell: ({ row }) => (
|
|
|
782
749
|
- **Cost:** none to speak of. Specs that match the title as a cell still
|
|
783
750
|
work (`getByRole('cell', { name })` reads the link's text); ones that
|
|
784
751
|
opened the form from a row button go through the view's Edit instead.
|
|
785
|
-
- **DataTable caps the title column
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
the title column first and write no clip of your own (`truncate`,
|
|
792
|
-
`max-w-*`) around it. `meta: { wrap: true }` wraps it at the cap
|
|
793
|
-
instead, for a title worth reading whole in the row;
|
|
794
|
-
`meta: { maxWidth: 'none' }` lifts the cap. Its own `meta.clip` or
|
|
795
|
-
`meta.maxWidth` works as on any column (cut, or wrapped, at that width).
|
|
752
|
+
- **DataTable caps the title column.** The first column is the title
|
|
753
|
+
column, cut to one line at 24rem with an ellipsis, its whole text in a
|
|
754
|
+
tooltip. Put the title column first and write no clip of your own
|
|
755
|
+
(`truncate`, `max-w-*`) around it. `meta: { wrap: true }` wraps it at
|
|
756
|
+
the cap instead, for a title worth reading whole in the row;
|
|
757
|
+
`meta: { maxWidth: 'none' }` lifts the cap.
|
|
796
758
|
|
|
797
759
|
## 17. Quick action on the view
|
|
798
760
|
|
|
@@ -808,20 +770,19 @@ place`, pattern 18); everything else renders as its table cell does, and
|
|
|
808
770
|
changes through Edit. A quick action is for a value people change often
|
|
809
771
|
and can change back as easily: never anything destructive. Anything you
|
|
810
772
|
type or pick from a list (text, a status) edits in place instead
|
|
811
|
-
(pattern 18)
|
|
812
|
-
3.13.
|
|
773
|
+
(pattern 18).
|
|
813
774
|
|
|
814
775
|
| The plan's field | The control | Accessible name |
|
|
815
776
|
|---|---|---|
|
|
816
|
-
| `yes/no`, in the header or a field row | A `Switch` (`size="sm"`) with the value in words beside it, `aria-hidden` (pattern 15) | The field's label: `In
|
|
777
|
+
| `yes/no`, in the header or a field row | A `Switch` (`size="sm"`) with the value in words beside it, `aria-hidden` (pattern 15) | The field's label: `In Stock` |
|
|
817
778
|
| A `yes/no` that belongs to another value (pattern 15's variant), beside that value in the header | The same pressed icon `Toggle` as in the table's cell | The field's label: `Focus` |
|
|
818
|
-
| A sub-record list's `yes/no` item field | Each item a `Checkbox`
|
|
779
|
+
| A sub-record list's `yes/no` item field | Each item a `Checkbox` beside the item's text; the text isn't part of the box (a click on it edits the item in place, pattern 18) | `Done: <item text>` (the box's `aria-label`) |
|
|
819
780
|
|
|
820
781
|
```tsx
|
|
821
782
|
const save = useSaveWidgetField(widget.id) // one per control
|
|
822
783
|
|
|
823
784
|
// A value: send the field.
|
|
824
|
-
<Switch size="sm" checked={widget.inStock} aria-label="In
|
|
785
|
+
<Switch size="sm" checked={widget.inStock} aria-label="In Stock"
|
|
825
786
|
onCheckedChange={(inStock) => save.mutate({ inStock })} />
|
|
826
787
|
|
|
827
788
|
// A list item: send the whole list, built from the latest record.
|
|
@@ -875,7 +836,7 @@ A value on the record's view that turns into **the form's own control**
|
|
|
875
836
|
where it's shown, and saves when you leave it: a title, a status, a
|
|
876
837
|
price, notes, a list of linked records. Widget's view is the reference
|
|
877
838
|
(`src/routes/widgets/widget-view.tsx`): Name (the title), Status (its
|
|
878
|
-
header
|
|
839
|
+
header `StatusMark`), Price, Description (rich text edited where it's read,
|
|
879
840
|
`inline`) and Extra Categories, with the controls in `widget-fields.tsx`,
|
|
880
841
|
the same ones the form uses.
|
|
881
842
|
|
|
@@ -913,9 +874,8 @@ link inside it (a reference to a record with a view, a link in the
|
|
|
913
874
|
notes), which still navigates. The tint reaches 0.375rem past the value
|
|
914
875
|
on each side without moving it, and never wraps it: a short title or
|
|
915
876
|
badge edited in place (`layout="inline"`) stays on one line, and a long
|
|
916
|
-
one wraps between words within its column
|
|
917
|
-
|
|
918
|
-
Inline, the pencil takes no room at rest (4.102): a value in a summary
|
|
877
|
+
one wraps between words within its column.
|
|
878
|
+
Inline, the pencil takes no room at rest: a value in a summary
|
|
919
879
|
line ("Harbor Office · Tuesdays") is followed by its separator a space
|
|
920
880
|
after it, not a pencil's width. The pencil keeps its 24px box out of the
|
|
921
881
|
flow, hidden just past the value over the separator, so it's still a
|
|
@@ -926,7 +886,7 @@ screen keeps the room open. `DataTable`'s cells keep the room at rest
|
|
|
926
886
|
(a column never widens on hover), and so does `EntityView`'s title,
|
|
927
887
|
which ends its line and can fill it. An app needs no override for this.
|
|
928
888
|
|
|
929
|
-
**In a field list, the row is the target** (
|
|
889
|
+
**In a field list, the row is the target** (`look="row"`, which
|
|
930
890
|
EntityView's field rows use). The row wears the list's row hover, the
|
|
931
891
|
`--table-hover` tint and the 3px `--primary` bar at its start, as a
|
|
932
892
|
DataTable row does, with its label readable on it and the pencil at its
|
|
@@ -960,7 +920,7 @@ dozen labels, a short tag list) uses `MultiPick` instead, on the form
|
|
|
960
920
|
and in place: every option a toggle chip with its icon or colour where
|
|
961
921
|
the app draws one (`icon`), the picked ones pressed with a check, and a
|
|
962
922
|
filter box above them, not in front of them. The chips wrap at every
|
|
963
|
-
width
|
|
923
|
+
width; past 30 options (`limit`) it shows the picked ones and the
|
|
964
924
|
first 30, then "Show All N", and a filter searches them all. The options
|
|
965
925
|
can be the app's list of records (its query's rows as `{ id, label }`,
|
|
966
926
|
`loading` meanwhile), so links to a few dozen other records use it too.
|
|
@@ -987,7 +947,7 @@ Larger sets, or ones that grow with the data, keep `MultiReference`
|
|
|
987
947
|
- **Keyboard:** opening puts the caret in the filter box; Down goes to
|
|
988
948
|
the chips, Left/Right (Home/End) move along them, Space or Enter
|
|
989
949
|
toggles one, Up goes back to the box.
|
|
990
|
-
- **Create "<typed>"** (
|
|
950
|
+
- **Create "<typed>"** (`onCreate`): when what's typed names no
|
|
991
951
|
option (ignoring case), a Create "<typed>" button shows under the
|
|
992
952
|
chips; Enter in the box does the same when nothing matches, and Down
|
|
993
953
|
reaches it when there are no chips. It calls `onCreate(name)`, which
|
|
@@ -1007,21 +967,21 @@ Larger sets, or ones that grow with the data, keep `MultiReference`
|
|
|
1007
967
|
form's whole-set save, never called in place.
|
|
1008
968
|
|
|
1009
969
|
```tsx
|
|
1010
|
-
const editField =
|
|
970
|
+
const editField = useEditTaskField(task.id) // optimistic: false, toastOnError: false
|
|
1011
971
|
labels: editInPlace({
|
|
1012
972
|
kind: 'multi',
|
|
1013
|
-
value:
|
|
973
|
+
value: task.labelIds,
|
|
1014
974
|
isEqual: sameIds,
|
|
1015
975
|
save: (labelIds) => editField.mutateAsync({ labelIds }),
|
|
1016
976
|
control: (props) => (
|
|
1017
|
-
<
|
|
977
|
+
<TaskLabelsPicker id={props.id} value={task.labelIds}
|
|
1018
978
|
onPick={(id, picked) => editField.mutateAsync((current) => ({
|
|
1019
979
|
labelIds: [...current.labelIds.filter((other) => other !== id), ...(picked ? [id] : [])],
|
|
1020
980
|
}))}
|
|
1021
981
|
aria-label={props.label} aria-describedby={props.describedBy} />
|
|
1022
982
|
),
|
|
1023
983
|
}),
|
|
1024
|
-
//
|
|
984
|
+
// TaskLabelsPicker: <MultiPick options={labels.map((l) => ({ id: l.id, label: l.name,
|
|
1025
985
|
// icon: <TagIcon className={LABEL_COLOUR[l.slot]} /> }))} value onPick aria-label aria-describedby />
|
|
1026
986
|
// On the form, the same control with onValueChange={field.onChange} instead of onPick.
|
|
1027
987
|
```
|
|
@@ -1035,7 +995,7 @@ open.
|
|
|
1035
995
|
**Saving: still open, read-only, and says so.** Under the control,
|
|
1036
996
|
"Saving…" with a spinner (`role="status"`) until the server agrees, then
|
|
1037
997
|
it closes on the saved value, with "✓ Saved" beside it for two seconds
|
|
1038
|
-
(
|
|
998
|
+
(`role="status"`). **Not optimistic**: the value only shows as
|
|
1039
999
|
saved once it is, and the view shows the record the server returned (a
|
|
1040
1000
|
side effect included). The rest of the page stays usable.
|
|
1041
1001
|
|
|
@@ -1095,8 +1055,8 @@ nobody has to click away to save notes. Opt in per field:
|
|
|
1095
1055
|
fits (about 30 KB of JSON), so the browser finishes it after the page
|
|
1096
1056
|
is gone; a longer note's save goes as an ordinary request.
|
|
1097
1057
|
|
|
1098
|
-
**Notes are edited where they're read by default (`inline: true`)
|
|
1099
|
-
|
|
1058
|
+
**Notes are edited where they're read by default (`inline: true`)**: a
|
|
1059
|
+
record's notes, a description, any long text
|
|
1100
1060
|
the page is for. `alwaysEditable` (the boxed editor at rest) and
|
|
1101
1061
|
`autosave` alone (the read view at rest, a click opens the editor) are
|
|
1102
1062
|
for where that doesn't fit, such as a short summary beside other values.
|
|
@@ -1110,7 +1070,7 @@ the caret where it is. It sits beside the one open value rather than
|
|
|
1110
1070
|
being it: opening another value leaves it alone. Don't give its control
|
|
1111
1071
|
`autoFocus`. The cost: at rest the page shows the editor, not the read
|
|
1112
1072
|
view, and the editor loads on every visit. A click on a link in the
|
|
1113
|
-
notes still opens it in a new tab
|
|
1073
|
+
notes still opens it in a new tab; its words are edited from the
|
|
1114
1074
|
keyboard or by dragging over them, and Ctrl/Cmd+K edits its address. Use it where the notes are what the page is
|
|
1115
1075
|
for; elsewhere `autosave` alone keeps the read view at rest.
|
|
1116
1076
|
|
|
@@ -1125,19 +1085,19 @@ but drops the bar above the text. An empty one shows the editor's
|
|
|
1125
1085
|
`placeholder` (say "or type / for blocks" in it), not the view's "Not
|
|
1126
1086
|
set". It saves like any always-editable value (a pause after typing,
|
|
1127
1087
|
leaving the page saves first) and is otherwise the same: on the form the
|
|
1128
|
-
control is the boxed editor, with the floating toolbar too
|
|
1129
|
-
[add-an-entity.md "Forms"](add-an-entity.md#forms)).
|
|
1088
|
+
control is the boxed editor, with the floating toolbar too
|
|
1089
|
+
([add-an-entity.md "Forms"](add-an-entity.md#forms)).
|
|
1130
1090
|
|
|
1131
1091
|
```tsx
|
|
1132
|
-
|
|
1092
|
+
description: editInPlace({
|
|
1133
1093
|
kind: 'long-text',
|
|
1134
1094
|
inline: true,
|
|
1135
|
-
value: widget.
|
|
1136
|
-
schema: widgetFormSchema.shape.
|
|
1137
|
-
save: (
|
|
1095
|
+
value: widget.description,
|
|
1096
|
+
schema: widgetFormSchema.shape.description,
|
|
1097
|
+
save: (description) => editField.mutateAsync({ description }),
|
|
1138
1098
|
// The form's own control, spreading what it gets onto RichTextEditor:
|
|
1139
1099
|
// inline={props.inline} toolbar={props.inline ? 'floating' : true}
|
|
1140
|
-
control: (props) => <
|
|
1100
|
+
control: (props) => <WidgetDescriptionEditor … />,
|
|
1141
1101
|
}),
|
|
1142
1102
|
```
|
|
1143
1103
|
|
|
@@ -1145,10 +1105,10 @@ notes: editInPlace({
|
|
|
1145
1105
|
summary: editInPlace({
|
|
1146
1106
|
kind: 'long-text',
|
|
1147
1107
|
autosave: true, // not notes: a click opens it (autoFocus on the control)
|
|
1148
|
-
value:
|
|
1149
|
-
schema:
|
|
1108
|
+
value: project.summary,
|
|
1109
|
+
schema: projectFormSchema.shape.summary,
|
|
1150
1110
|
save: (summary) => editField.mutateAsync({ summary }),
|
|
1151
|
-
control: (props) => <
|
|
1111
|
+
control: (props) => <ProjectSummaryEditor … />,
|
|
1152
1112
|
}),
|
|
1153
1113
|
```
|
|
1154
1114
|
|
|
@@ -1172,7 +1132,7 @@ const price = editInPlace({
|
|
|
1172
1132
|
})
|
|
1173
1133
|
// A field: { label: 'Price', value: <…as the table shows it…>, edit: price }
|
|
1174
1134
|
// The title: <EntityView titleEdit={{ label: 'Name', ...name }} />
|
|
1175
|
-
//
|
|
1135
|
+
// The status: <EditableValue label="Status" edit={status} layout="inline"><StatusMark …>…</StatusMark></EditableValue>
|
|
1176
1136
|
```
|
|
1177
1137
|
|
|
1178
1138
|
- **One control per field, shared with the form** (`<entity>-fields.tsx`):
|
|
@@ -1226,7 +1186,7 @@ const price = editInPlace({
|
|
|
1226
1186
|
and Outdent for list items, where there is no Tab. A field with only the
|
|
1227
1187
|
floating toolbar (`inline` notes, and notes on a form) gets the same
|
|
1228
1188
|
two in a small "Editor tools" strip over its corner while it has focus,
|
|
1229
|
-
with the Image button too when the editor has `upload
|
|
1189
|
+
with the Image button too when the editor has `upload`. On a touch screen the
|
|
1230
1190
|
toolbar is instead one row pinned to the top of the keyboard while the
|
|
1231
1191
|
field has focus (Aa for every format, in the keyboard's place; the list
|
|
1232
1192
|
buttons, Insert, Image (with `upload`) and Undo; with words selected, their formats first, and
|
|
@@ -1309,6 +1269,7 @@ fields: [
|
|
|
1309
1269
|
`reference` on the pick (a list opens with the field), `rating` on a
|
|
1310
1270
|
click of a star (it's always open: the stars are the value).
|
|
1311
1271
|
`required: true` types the save without `null`.
|
|
1272
|
+
- **`inPlace.recurrence`** (how something repeats) is in reminders.md.
|
|
1312
1273
|
- **`reference` searches through the app.** The package knows no
|
|
1313
1274
|
endpoint: `search(text)` is the app's (its gateway's search by name,
|
|
1314
1275
|
`''` when the list opens), called a pause after typing stops; a
|
|
@@ -1535,22 +1496,13 @@ row`), every editable cell is an editable value, exactly as on a view.
|
|
|
1535
1496
|
one is open, "Saving…" and a refusal in the cell. There's no pencil
|
|
1536
1497
|
column and no edit route.
|
|
1537
1498
|
|
|
1538
|
-
- **A cell is one of the package's three row-edit cells
|
|
1499
|
+
- **A cell is one of the package's three row-edit cells** (`NameCell`
|
|
1500
|
+
for a one-line name, `ChoiceCell` for a pick from a list, `LinkCell`
|
|
1501
|
+
for a link, checked as `inPlace.link`'s is), or an
|
|
1539
1502
|
`<EditableValue label="<Column> of <name>" layout="inline"
|
|
1540
1503
|
edit={editInPlace({ ... })}>` for anything else. The label names the
|
|
1541
1504
|
column and the row, so its pencil reads "Edit Colour of Work" and its
|
|
1542
1505
|
control "Colour of Work".
|
|
1543
|
-
- **`NameCell`**: one line; Enter saves, the form's rule (`schema`)
|
|
1544
|
-
runs first, a taken name's 422 shows in the cell. `children` is how
|
|
1545
|
-
the name shows at rest (an icon beside it).
|
|
1546
|
-
- **`ChoiceCell<T>`** (`options`, `render`): the list opens with the
|
|
1547
|
-
cell, non-modal; a pick saves, closing it with no pick gives up.
|
|
1548
|
-
`render` draws a value at rest, on the trigger and in the list.
|
|
1549
|
-
- **`LinkCell`** (`linkText`, `emptyLabel`, `save(link | null)`): a
|
|
1550
|
-
link opening in a new tab (said to screen readers), or the not-set
|
|
1551
|
-
label; edited as one line. A bare `example.com` gains `https://`,
|
|
1552
|
-
another scheme (`javascript:`) is refused in the cell, and a blank
|
|
1553
|
-
box saves `null`. Clicking the link follows it; the pencil edits.
|
|
1554
1506
|
- **A cell is a component** (`<Entity><Field>Cell`) that calls
|
|
1555
1507
|
`useEdit<Entity>Field(row.id)` for its save, the view's single-field
|
|
1556
1508
|
save, and renders the package's cell with it. A hook can't be called
|
|
@@ -1609,31 +1561,21 @@ const CATEGORY_COLUMNS: LegacyColumnDef<Category, unknown>[] = [
|
|
|
1609
1561
|
create={(name) => createCategory.mutateAsync({ name, colour: 'blue', icon: 'house' })} />} … />
|
|
1610
1562
|
```
|
|
1611
1563
|
|
|
1612
|
-
The
|
|
1613
|
-
"Edit in the rows" (`data-table.fixtures.tsx`); the template has no small
|
|
1614
|
-
entity yet.
|
|
1564
|
+
The template has no small entity yet.
|
|
1615
1565
|
|
|
1616
1566
|
### A table of a few short columns: `width="content"`
|
|
1617
1567
|
|
|
1618
1568
|
On a wide screen a table of a few short columns (a name, a colour, a
|
|
1619
1569
|
count, its delete) spread across the page puts the row's actions far
|
|
1620
|
-
from its name. `width="content"`, the default
|
|
1621
|
-
|
|
1622
|
-
every width, never under 36rem (or the whole width, when that's less),
|
|
1623
|
-
with empty space at the right; the toolbar keeps the whole width, so its
|
|
1624
|
-
controls sit in the same place on every list. A table wider than its
|
|
1625
|
-
area scrolls sideways inside it. While it's loading, empty or failed
|
|
1626
|
-
after a load, it keeps the width it last had, so paging and filtering
|
|
1627
|
-
don't move it; only the first load can. `width="full"` takes the whole
|
|
1628
|
-
width, the look before 4.83; a card layout always does.
|
|
1570
|
+
from its name. `width="content"`, the default, sizes the table and its
|
|
1571
|
+
pagination to its columns; `width="full"` takes the whole width.
|
|
1629
1572
|
|
|
1630
1573
|
## 19. Stage circle for an ordered status
|
|
1631
1574
|
|
|
1632
1575
|
A status that's an ordered lifecycle (each record moves through the same
|
|
1633
1576
|
stages, in the same order, toward one that means *done*), with one or
|
|
1634
1577
|
more exit states off the side. A small circle beside the word fills as
|
|
1635
|
-
the record moves on. The package ships it: `StageCircle
|
|
1636
|
-
every stage and tone in its fixtures (`app/StageCircle`).
|
|
1578
|
+
the record moves on. The package ships it: `StageCircle`.
|
|
1637
1579
|
|
|
1638
1580
|
| Stage (`stage`) | Drawn as | Say it for |
|
|
1639
1581
|
|---|---|---|
|
|
@@ -1674,7 +1616,7 @@ cell: ({ getValue }) => {
|
|
|
1674
1616
|
- **Tone it like pattern 5:** the stage in progress is `info` ("notice
|
|
1675
1617
|
this"), complete is `success`, and the rest stay `muted` (the default).
|
|
1676
1618
|
The tones are the `*-text` shades, so the circle clears 3:1 on the page
|
|
1677
|
-
in both themes
|
|
1619
|
+
in both themes. An exit is
|
|
1678
1620
|
muted: dropped is an end, not a failure. Give it `destructive` only if
|
|
1679
1621
|
the exit really is bad news (failed, rejected).
|
|
1680
1622
|
- **Map the stages in order**, the first `0`, the final `'complete'`, the
|
|
@@ -1688,7 +1630,8 @@ cell: ({ getValue }) => {
|
|
|
1688
1630
|
Widget's Status is the second kind: `draft` → `active` → `archived` is
|
|
1689
1631
|
an order in time, but `archived` is retirement, not completion, and its
|
|
1690
1632
|
good state is the middle one. A tick on `archived` would say "done"
|
|
1691
|
-
where nothing was finished, so it
|
|
1633
|
+
where nothing was finished, so it isn't a stage circle (the demo draws
|
|
1634
|
+
it as a `StatusMark`).
|
|
1692
1635
|
- **On the record's view** it's the same markup in the header, beside the
|
|
1693
1636
|
title; editing the status in place (pattern 18) wraps it in
|
|
1694
1637
|
`<EditableValue>` like a badge.
|
|
@@ -1700,8 +1643,7 @@ cell: ({ getValue }) => {
|
|
|
1700
1643
|
A count of the records in another table that point at this row (open
|
|
1701
1644
|
Tasks per Project, items per Tag), which opens that table already filtered
|
|
1702
1645
|
to them. The count is a `computed` integer (the entity plan's type).
|
|
1703
|
-
The package ships it: `CountLink
|
|
1704
|
-
(`app/CountLink`).
|
|
1646
|
+
The package ships it: `CountLink`.
|
|
1705
1647
|
|
|
1706
1648
|
```tsx
|
|
1707
1649
|
import { CountLink } from '@tristan2828/ui-foundation'
|
|
@@ -1718,20 +1660,11 @@ cell: ({ row }) => {
|
|
|
1718
1660
|
}
|
|
1719
1661
|
```
|
|
1720
1662
|
|
|
1721
|
-
What the component decides, so a cell doesn't have to:
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
not `text-link`: `--link` is for links in written text, and a column of
|
|
1727
|
-
blue numbers pulls the eye from every other column.
|
|
1728
|
-
- **Zero is a plain `0`**, not a link (a link to an empty list is a dead
|
|
1729
|
-
end) and not an em dash: zero is a value (pattern 11). Same
|
|
1730
|
-
`tabular-nums`, so it lines up with the links.
|
|
1731
|
-
- **The accessible name is the count, then `label`**: `3 open tasks in
|
|
1732
|
-
Kitchen remodel`. Every row's link text is just a number, so `3` alone
|
|
1733
|
-
isn't distinct, and starting with it keeps the link findable by what
|
|
1734
|
-
it shows (speech input, `getByRole('link', { name: /^3 / })`).
|
|
1663
|
+
What the component decides, so a cell doesn't have to: underlined at
|
|
1664
|
+
rest, in foreground (not `text-link`); zero a plain `0`, not a link and
|
|
1665
|
+
not an em dash (zero is a value, pattern 11); and an accessible name
|
|
1666
|
+
that is the count, then `label` (`3 open tasks in Kitchen remodel`), so
|
|
1667
|
+
the link is found by what it shows (`getByRole('link', { name: /^3 / })`).
|
|
1735
1668
|
|
|
1736
1669
|
What the cell decides:
|
|
1737
1670
|
|
|
@@ -1769,9 +1702,6 @@ months), each heading with a count and a summary ("4 · 1 h 12 m"). The
|
|
|
1769
1702
|
same screens usually want one quick filter as pills above the rows (All /
|
|
1770
1703
|
Video / Audio / Text, one pressed at a time) rather than a dropdown: there
|
|
1771
1704
|
are few values, and switching between them is the main thing people do.
|
|
1772
|
-
Raised for an app's feed (issue #135); the package's fixtures renders it
|
|
1773
|
-
(`app/DataTable` "Grouped" and "Grouped no matches"), with axe in both
|
|
1774
|
-
themes.
|
|
1775
1705
|
|
|
1776
1706
|
```tsx
|
|
1777
1707
|
import { byDay, DataTable, PillFilter } from '@tristan2828/ui-foundation'
|
|
@@ -1811,23 +1741,14 @@ const { page, filters, setFilter, setPage } = useTableUrlState(['kind'])
|
|
|
1811
1741
|
as it names its column. It stays in view while a wide table scrolls
|
|
1812
1742
|
sideways.
|
|
1813
1743
|
- **`stickyGroupHeadings`** pins the headings while their groups scroll,
|
|
1814
|
-
for a list long enough that "which day is this?" gets lost
|
|
1815
|
-
|
|
1816
|
-
`header={false}`, at the very top), until the next group's slides
|
|
1817
|
-
over it. It works under `groupBy` and a grouping alike, and does nothing
|
|
1818
|
-
to a table that isn't grouped or to a card layout. When the columns fit
|
|
1819
|
-
(a feed, most lists on a phone) they stick to the page's own scroll.
|
|
1820
|
-
When they're wider than the screen the table has to scroll sideways, and
|
|
1821
|
-
a box that scrolls sideways is what sticky cells stick to, so the table
|
|
1822
|
-
becomes a box no taller than the screen and scrolls both ways inside
|
|
1823
|
-
it. An ancestor of your own with `overflow` set (a card with
|
|
1744
|
+
for a list long enough that "which day is this?" gets lost. An
|
|
1745
|
+
ancestor of your own with `overflow` set (a card with
|
|
1824
1746
|
`overflow-hidden`, say) takes the place of the page: leave it off such a
|
|
1825
1747
|
table's ancestors.
|
|
1826
1748
|
- **`stickyTop`**, with `stickyGroupHeadings`, for a page that pins a bar
|
|
1827
1749
|
of its own to the top (a page header, a filter bar): how far down the
|
|
1828
1750
|
header and headings pin, so they sit under the bar and never behind it.
|
|
1829
|
-
|
|
1830
|
-
breakpoint gives a phone its own offset:
|
|
1751
|
+
A variable the page sets per breakpoint gives a phone its own offset:
|
|
1831
1752
|
|
|
1832
1753
|
```tsx
|
|
1833
1754
|
<main className="[--page-bar:3.5rem] md:[--page-bar:3rem]">
|
|
@@ -1836,16 +1757,12 @@ const { page, filters, setFilter, setPage } = useTableUrlState(['kind'])
|
|
|
1836
1757
|
</main>
|
|
1837
1758
|
```
|
|
1838
1759
|
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
under the bar and its header pins at its own top. Focus moved to a row
|
|
1842
|
-
clears the bar too. Give the bar a `z-index` above the table's (`z-40`).
|
|
1760
|
+
Focus moved to a row clears the bar too. Give the bar a `z-index`
|
|
1761
|
+
above the table's (`z-40`).
|
|
1843
1762
|
- **`header={false}`** for a list-like table whose columns explain
|
|
1844
|
-
themselves (a thumbnail with a title block, then actions)
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
Fewer, wider columns read as a list: put the thumbnail inside the
|
|
1848
|
-
title's cell rather than a column of its own.
|
|
1763
|
+
themselves (a thumbnail with a title block, then actions); sorting, if
|
|
1764
|
+
any, moves to the toolbar. Fewer, wider columns read as a list: put the
|
|
1765
|
+
thumbnail inside the title's cell rather than a column of its own.
|
|
1849
1766
|
- **`PillFilter` is a filter like the others**: its value is in the URL
|
|
1850
1767
|
(`useTableUrlState`, '' for All) and `setFilter` sets it, so it returns
|
|
1851
1768
|
to page 1 and survives a refresh, back and forward. Pressing the
|
|
@@ -1873,7 +1790,7 @@ current one. `DataTable`'s `highlightRow` returns true for it.
|
|
|
1873
1790
|
- **A wash of info on every cell**, over a stripe (`striped`) and the
|
|
1874
1791
|
pinned columns' opaque backgrounds (`--table-highlight`, pre-mixed onto
|
|
1875
1792
|
the page), and a bar in `info-text` at the row's start, so it reads
|
|
1876
|
-
without colour too. The pointer's hover (pattern
|
|
1793
|
+
without colour too. The pointer's hover (pattern 28) leaves it as it
|
|
1877
1794
|
is, so "next up" never reads as the hovered row. Still **say why in the row** (a "Next up" word or badge):
|
|
1878
1795
|
the wash says "look here", not what it is.
|
|
1879
1796
|
- **Muted text inside it is darkened for you.** `muted-foreground`
|
|
@@ -1887,15 +1804,11 @@ current one. `DataTable`'s `highlightRow` returns true for it.
|
|
|
1887
1804
|
`opacity-50` (or `text-foreground/60`) drops their text under 4.5:1 the
|
|
1888
1805
|
same way. Render their text in `text-muted-foreground`, which is
|
|
1889
1806
|
measured, and keep the word that says done.
|
|
1890
|
-
- The fixtures' `app/DataTable` Highlighted story has two highlighted rows
|
|
1891
|
-
(one striped), pinned columns and muted text inside them, under axe and
|
|
1892
|
-
the token check in both themes; `e2e/data-table.spec.ts` checks every
|
|
1893
|
-
cell wears the wash.
|
|
1894
1807
|
|
|
1895
|
-
##
|
|
1808
|
+
## 28. A list's rows: hover, lines, rows per page
|
|
1896
1809
|
|
|
1897
|
-
What every `DataTable` does by default
|
|
1898
|
-
|
|
1810
|
+
What every `DataTable` does by default, and the two choices it leaves
|
|
1811
|
+
an app.
|
|
1899
1812
|
|
|
1900
1813
|
- **The row under the pointer** lights whole: every cell, pinned ones
|
|
1901
1814
|
included, in `--table-hover` (the muted fill, solid), with a 3px bar in
|
|
@@ -1908,7 +1821,7 @@ standard), and the two choices it leaves an app.
|
|
|
1908
1821
|
their own look.
|
|
1909
1822
|
- **No zebra stripes:** rows are told apart by the line under each.
|
|
1910
1823
|
`striped` brings the stripes back for an app that wants them. Tables in
|
|
1911
|
-
notes keep theirs
|
|
1824
|
+
notes keep theirs.
|
|
1912
1825
|
- **Rows per Page:** a menu in the pagination bar, from
|
|
1913
1826
|
`useTableUrlState`, which keeps the pick in the URL (`?size=`) and on
|
|
1914
1827
|
this device:
|
|
@@ -1925,12 +1838,7 @@ const query = useRecipes({ page, pageSize, ... })
|
|
|
1925
1838
|
A pick returns to page 1. A size in the URL or storage that isn't one
|
|
1926
1839
|
of `pageSizes` is ignored, so `?size=100000` can't ask the server for
|
|
1927
1840
|
everything. Without `pageSizes` and `onPageSizeChange` the bar has no
|
|
1928
|
-
menu
|
|
1929
|
-
- The fixtures' `app/DataTable` ListLook, ListLookInRows and
|
|
1930
|
-
ListLookStriped stories hold all of it (with a `meta.clip` Notes
|
|
1931
|
-
column, pattern 1), under axe and the token check in both themes;
|
|
1932
|
-
`e2e/data-table.spec.ts` "list look" checks the hover on every cell,
|
|
1933
|
-
the cursors, the stripes, the tooltip, the widths and the menu.
|
|
1841
|
+
menu.
|
|
1934
1842
|
|
|
1935
1843
|
## 23. A Group menu, and a record read beside the list
|
|
1936
1844
|
|
|
@@ -1939,9 +1847,7 @@ columns: **grouped by one of its choice fields**, picked by the reader
|
|
|
1939
1847
|
(by status to see what's moving, by area to plan a trip round the
|
|
1940
1848
|
house), and **one record at a time without leaving the list**, its notes
|
|
1941
1849
|
and key facts in a panel beside the rows. `DataTable`'s `groupings` and
|
|
1942
|
-
`detailPanel`
|
|
1943
|
-
package's fixtures render it (`app/DataTable grouping`), with axe in
|
|
1944
|
-
both themes and its specs in a real browser.
|
|
1850
|
+
`detailPanel` do both.
|
|
1945
1851
|
|
|
1946
1852
|
```tsx
|
|
1947
1853
|
const GROUPINGS: DataTableGrouping<Task>[] = [ // module level
|
|
@@ -1963,43 +1869,20 @@ const { grouping, setGrouping, ...table } = useTableUrlState(FILTERS, MULTI, VIE
|
|
|
1963
1869
|
… />
|
|
1964
1870
|
```
|
|
1965
1871
|
|
|
1966
|
-
- **None is the default**, and the table is exactly as it was until a
|
|
1967
|
-
grouping is picked. The Group menu sits at the end of the toolbar
|
|
1968
|
-
(before a layout switch): None, then each grouping. While grouped a
|
|
1969
|
-
Fold All button joins it, and the menu says which ("Group: Status").
|
|
1970
1872
|
- **Only choice fields**: each group is one of the field's options, in
|
|
1971
1873
|
the options' order (the order the form lists them), so give the same
|
|
1972
|
-
options list the column and the form use. A
|
|
1973
|
-
array) shows the row under each of its values; a row with none goes
|
|
1974
|
-
last, under `emptyLabel` ("Not set" unless set). A yes/no field is two
|
|
1874
|
+
options list the column and the form use. A yes/no field is two
|
|
1975
1875
|
options, worded as headings ("Can do now", "Not yet").
|
|
1976
1876
|
- **The grouped column is hidden** while grouped (its value is the
|
|
1977
1877
|
heading), so a grouping's `id` is its column's id.
|
|
1978
|
-
- **
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
- **
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
for None) to turn one on when pressed; a view that names none keeps
|
|
1986
|
-
the grouping that's on. Grouping doesn't change which rows are shown,
|
|
1987
|
-
so it keeps the page and doesn't count toward the active view.
|
|
1988
|
-
- **It groups the page's rows**: paging pages rows, not groups, so a
|
|
1989
|
-
list that groups wants a page size that holds it (a working list of a
|
|
1990
|
-
few dozen), and a summary that must count a whole group across pages
|
|
1991
|
-
comes from the API. A grouping, while on, takes the place of
|
|
1878
|
+
- **Remembered like the layout**: `useTableUrlState`'s `grouping`
|
|
1879
|
+
(`?group=`, then `groupStorageKey`). A saved view can name a `group`.
|
|
1880
|
+
Grouping doesn't change which rows are shown, so it keeps the page and
|
|
1881
|
+
doesn't count toward the active view.
|
|
1882
|
+
- **It groups the page's rows**: paging pages rows, not groups (pattern
|
|
1883
|
+
21), so a list that groups wants a page size that holds it (a working
|
|
1884
|
+
list of a few dozen). A grouping, while on, takes the place of
|
|
1992
1885
|
`groupBy`'s headings.
|
|
1993
|
-
- **The detail panel** opens on a click on a row, or Enter on it (its
|
|
1994
|
-
title link included: a plain click picks the row, a modified one still
|
|
1995
|
-
opens the link in a new tab, and the panel's own "Open page" link
|
|
1996
|
-
leaves). A control in a cell (a button, a switch, an editable value)
|
|
1997
|
-
stays the control's. The picked row is marked (`aria-selected`, the
|
|
1998
|
-
muted fill and a bar in `--primary` at its start); ↑ and ↓ move the pick
|
|
1999
|
-
while the list has focus, and Escape or Close closes it, focus back on
|
|
2000
|
-
the row. On a wide screen (64rem and up) the panel sits beside the
|
|
2001
|
-
table and stays in view as the page scrolls; below that it is a
|
|
2002
|
-
bottom sheet.
|
|
2003
1886
|
- **The panel is the app's**: a heading-sized title, a few badges, a
|
|
2004
1887
|
short notes preview (a few lines of the record's notes, not the whole
|
|
2005
1888
|
editor), and an "Open page" link (a `<Link>` in `text-link`, so it's
|
|
@@ -2024,20 +1907,15 @@ import { ColorSwatch } from '@tristan2828/ui-foundation'
|
|
|
2024
1907
|
```
|
|
2025
1908
|
|
|
2026
1909
|
- **The label is required**: the colour's name, else the value (the hex),
|
|
2027
|
-
else "No colour".
|
|
2028
|
-
- **A missing or invalid value** draws the empty swatch
|
|
2029
|
-
|
|
1910
|
+
else "No colour".
|
|
1911
|
+
- **A missing or invalid value** draws the empty swatch. Validate on the
|
|
1912
|
+
form with `storedColor`.
|
|
2030
1913
|
- **In a badge** (a label shown as a tag): `size="sm"` inside the
|
|
2031
1914
|
`Badge`, which sizes it like the badge's icons (pattern 3).
|
|
2032
|
-
- **A colour picked from a few** is a categorical slot, a tinted glyph
|
|
2033
|
-
(design-language.md "Categorical colour"), not a stored hex.
|
|
2034
|
-
|
|
2035
|
-
The package's fixture `app/ColorSwatch` "In a table" renders it; its
|
|
2036
|
-
checks measure the ring at 3:1 in both themes and every palette.
|
|
2037
1915
|
|
|
2038
1916
|
### Picking one on a form: `ColorField`
|
|
2039
1917
|
|
|
2040
|
-
The same colour on the record's form
|
|
1918
|
+
The same colour on the record's form: a grid of named swatches
|
|
2041
1919
|
and **Custom**, which opens the browser's own colour picker. One control
|
|
2042
1920
|
for a react-hook-form `Controller`, like `DateField`.
|
|
2043
1921
|
|
|
@@ -2091,25 +1969,17 @@ import { ColorField, storedColor } from '@tristan2828/ui-foundation'
|
|
|
2091
1969
|
change. Swap the `Input` for `ColorField` in the same `Controller`;
|
|
2092
1970
|
values already stored that aren't in the set show as Custom.
|
|
2093
1971
|
|
|
2094
|
-
The package's fixture `app/ColorField` renders it on a card (a named
|
|
2095
|
-
colour, a Custom hex, a required one left empty, an app's own list, a
|
|
2096
|
-
refused value); its checks run axe, the token check, each swatch's ring
|
|
2097
|
-
and the picker's edge at 3:1, and each default fill against the card, in
|
|
2098
|
-
both themes and every palette. `e2e/color-field.spec.ts` drives the
|
|
2099
|
-
pointer, the keyboard and Custom.
|
|
2100
|
-
|
|
2101
1972
|
## 25. A list's tools: views, filters, columns, row actions, a phone's rows
|
|
2102
1973
|
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
is a prop or a part; leave it out and the list is as before.
|
|
1974
|
+
What sits above a list's rows, at the end of each row, and what a phone
|
|
1975
|
+
gets instead of the table. Each is a prop or a part.
|
|
2106
1976
|
|
|
2107
1977
|
```tsx
|
|
2108
1978
|
import { DataTable, FilterBar, FilterSelect, MultiChoice } from '@tristan2828/ui-foundation'
|
|
2109
1979
|
|
|
2110
1980
|
const VIEWS = {
|
|
2111
1981
|
current: { label: 'Current', filters: { status: 'active' } },
|
|
2112
|
-
review: { label: 'To
|
|
1982
|
+
review: { label: 'To Review', filters: { status: 'watch' }, columns: ['name', 'status', 'notes'] },
|
|
2113
1983
|
all: { label: 'All' },
|
|
2114
1984
|
}
|
|
2115
1985
|
const { filters, multiFilters, setFilter, setFilters, setMultiFilter, activeView, applyView, ... } =
|
|
@@ -2124,7 +1994,7 @@ const { filters, multiFilters, setFilter, setFilters, setMultiFilter, activeView
|
|
|
2124
1994
|
]}
|
|
2125
1995
|
phoneRow={{
|
|
2126
1996
|
title: (plant) => plant.name,
|
|
2127
|
-
status: (plant) => <
|
|
1997
|
+
status: (plant) => <StatusMark kind={STATUS_KIND[plant.status]}>{STATUS_LABELS[plant.status]}</StatusMark>,
|
|
2128
1998
|
facts: (plant) => [plant.light, `Watered ${plant.watered}`],
|
|
2129
1999
|
}}
|
|
2130
2000
|
toolbar={
|
|
@@ -2146,28 +2016,22 @@ const { filters, multiFilters, setFilter, setFilters, setMultiFilter, activeView
|
|
|
2146
2016
|
… />
|
|
2147
2017
|
```
|
|
2148
2018
|
|
|
2149
|
-
- **Saved views are pills** above the toolbar
|
|
2150
|
-
views, each with its `label`, in order.
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
`total` under that view's filters, or a count endpoint); the table
|
|
2158
|
-
computes nothing. null, undefined and 0 show no count, as the
|
|
2159
|
-
sidebar's counts and a record's tab counts don't, and past 99 it reads
|
|
2160
|
-
"99+". Count only views that ask you to act (Needs a Look, To Fill
|
|
2019
|
+
- **Saved views are pills** above the toolbar: useTableUrlState's
|
|
2020
|
+
views, each with its `label`, in order. Replaces a hand-written row of
|
|
2021
|
+
view buttons; a Deleted view goes in ListHeader's ⋯ menu as Show
|
|
2022
|
+
Deleted instead.
|
|
2023
|
+
- **A view can carry a count**: `count` on the view you pass
|
|
2024
|
+
`DataTable`. The app counts with its own query (the list's `total`
|
|
2025
|
+
under that view's filters, or a count endpoint); the table computes
|
|
2026
|
+
nothing. Count only views that ask you to act (Needs a Look, To Fill
|
|
2161
2027
|
In), not All. Give the view the key from the first render, `undefined`
|
|
2162
|
-
while the query loads
|
|
2163
|
-
count, so no pill moves when it arrives, on a phone's scrolling row
|
|
2164
|
-
too.
|
|
2028
|
+
while the query loads, so no pill moves when it arrives.
|
|
2165
2029
|
|
|
2166
2030
|
```tsx
|
|
2167
2031
|
const { data: needsLook } = useNewsSourcesQuery({ ...VIEWS.look.filters, pageSize: 1 })
|
|
2168
2032
|
<DataTable views={{ ...VIEWS, look: { ...VIEWS.look, count: needsLook?.total } }} … />
|
|
2169
2033
|
```
|
|
2170
|
-
- **Views fill the filters
|
|
2034
|
+
- **Views fill the filters**, so the bar always says why rows are
|
|
2171
2035
|
hidden:
|
|
2172
2036
|
- A view's `filters` and `multiFilters` are what the bar's controls
|
|
2173
2037
|
show while it's on: write its whole meaning there. A "Current" view
|
|
@@ -2196,22 +2060,22 @@ const { filters, multiFilters, setFilter, setFilters, setMultiFilter, activeView
|
|
|
2196
2060
|
}
|
|
2197
2061
|
const table = useTableUrlState(['search', 'overdue'], ['status'], VIEWS, { defaultView: 'current' })
|
|
2198
2062
|
```
|
|
2199
|
-
- **The column header row**
|
|
2063
|
+
- **The column header row** wears the muted fill on every cell,
|
|
2200
2064
|
pinned and stuck ones too, in the plain and framed looks, so the names
|
|
2201
2065
|
read apart from the rows; its words stay `--foreground`.
|
|
2202
|
-
- **The filters
|
|
2066
|
+
- **The filters**: `FilterBar` holds search, the two filters used
|
|
2203
2067
|
most (`primary`), and the rest behind Filters (`secondary`, with their
|
|
2204
2068
|
chips, as `SecondaryFilters` draws them). No captions over controls:
|
|
2205
2069
|
each names itself. `FilterSelect` says "Any status" while off and
|
|
2206
|
-
"Status: Active" on, and is named by its label first
|
|
2070
|
+
"Status: Active" on, and is named by its label first: "Status"
|
|
2207
2071
|
while it shows "Any status", "Status: Active", "Status: All reminders"
|
|
2208
2072
|
for an `anyLabel` that doesn't say the label (`FilterDate` the same), so
|
|
2209
2073
|
a test finds it by `getByRole('combobox', { name: /^Status/ })`.
|
|
2210
|
-
`search.onKeyDown`
|
|
2074
|
+
`search.onKeyDown` gives the search box's keys to the app
|
|
2211
2075
|
first: Enter on "#12" opening record 12, `preventDefault()` keeping the
|
|
2212
2076
|
key from the box. `MultiChoice`'s `label` makes it "Rooms: Hall +1"
|
|
2213
2077
|
instead of a chip per pick. Given `OptionSelect`'s options
|
|
2214
|
-
(`{ value, label, kind?, icon? }
|
|
2078
|
+
(`{ value, label, kind?, icon? }`) in place of bare values,
|
|
2215
2079
|
`MultiChoice` draws each option's icon as OptionSelect does: in the
|
|
2216
2080
|
list, on each chip, and before the summary's first pick ("Status: ●
|
|
2217
2081
|
Active +1"), so a status filter that takes several keeps its icons.
|
|
@@ -2219,7 +2083,7 @@ const { filters, multiFilters, setFilter, setFilters, setMultiFilter, activeView
|
|
|
2219
2083
|
ones too, is in Filters' bottom sheet, so pass
|
|
2220
2084
|
`primaryActive` (their chips) and an `onClearAll` that clears them all
|
|
2221
2085
|
in one `setFilters` call.
|
|
2222
|
-
- **A date filter**
|
|
2086
|
+
- **A date filter** is `FilterDate`: "Any due date" while off,
|
|
2223
2087
|
"Due: Before today" on, with the presets Before today, Today and From
|
|
2224
2088
|
today (`presets` picks which) and Between dates, a From and a To day
|
|
2225
2089
|
beside it. Its value is one string in the URL (`before-today`,
|
|
@@ -2247,40 +2111,28 @@ const { filters, multiFilters, setFilter, setFilters, setMultiFilter, activeView
|
|
|
2247
2111
|
onClear={() => setFilter('due', '')}
|
|
2248
2112
|
/>
|
|
2249
2113
|
```
|
|
2250
|
-
- **The Columns menu** (
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
view's columns show and the ticks can't change. A column whose `header`
|
|
2256
|
-
isn't a string names itself in the menu with `meta.label`. It isn't
|
|
2257
|
-
shown with the phone's row list.
|
|
2258
|
-
- **Row actions** (L9) take a column of their own, pinned to the right
|
|
2114
|
+
- **The Columns menu** (`columnsMenu`) sits at the end of the toolbar,
|
|
2115
|
+
its ticks remembered on this device under `storageKey`; a column added
|
|
2116
|
+
later shows. A column whose `header` isn't a string names itself in the
|
|
2117
|
+
menu with `meta.label`. It isn't shown with the phone's row list.
|
|
2118
|
+
- **Row actions** take a column of their own, pinned to the right
|
|
2259
2119
|
edge with its header for screen readers only. One action is its icon,
|
|
2260
2120
|
its label the tooltip and accessible name; two or more are a ⋯ menu.
|
|
2261
2121
|
A click on them never opens the row. Return `[]` for a row with none.
|
|
2262
2122
|
Drop a hand-made Actions column and `pinLastColumn` when moving to it.
|
|
2263
|
-
- **A phone gets a row list** (
|
|
2123
|
+
- **A phone gets a row list** (`phoneRow`) under 48rem: the `title`, the
|
|
2264
2124
|
`status` at the line's end and one muted line of the `facts` that matter
|
|
2265
|
-
(two, usually)
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
link, in a 44px-wide column: the tick that completes a to-do from its
|
|
2272
|
-
row. Its clicks never open the record, so it carries its own label
|
|
2273
|
-
(`Complete <title>`), as the table's tick column does.
|
|
2274
|
-
- The fixtures' `app/DataTable tools` ListTools, ListToolsFiltered,
|
|
2275
|
-
OneRowAction and PhoneRowLead stories hold all of it, under axe and the token check in
|
|
2276
|
-
both themes; `e2e/data-table-tools.spec.ts` checks the pills, the stored
|
|
2277
|
-
pick and a view's columns winning, the ⋯ menu, the 44px rows, the
|
|
2278
|
-
phone's line and sheet.
|
|
2125
|
+
(two, usually). `title` is plain text (the row is already the link). A
|
|
2126
|
+
card layout, when picked, wins.
|
|
2127
|
+
- **`lead`** puts one control at the row's start, outside the link: the
|
|
2128
|
+
tick that completes a to-do from its row. Its clicks never open the
|
|
2129
|
+
record, so it carries its own label (`Complete <title>`), as the
|
|
2130
|
+
table's tick column does.
|
|
2279
2131
|
|
|
2280
2132
|
### The framed look, and sibling lists beside the title
|
|
2281
2133
|
|
|
2282
|
-
|
|
2283
|
-
|
|
2134
|
+
`look="framed"` on `DataTable`, and `siblings` on `ListHeader`. Both are
|
|
2135
|
+
opt-in.
|
|
2284
2136
|
|
|
2285
2137
|
```tsx
|
|
2286
2138
|
<ListHeader
|
|
@@ -2288,7 +2140,7 @@ The toolbar a list-page review picked (4.100): `look="framed"` on
|
|
|
2288
2140
|
siblings={[
|
|
2289
2141
|
{ label: 'Exercises', to: '/training/exercises', count: 5 },
|
|
2290
2142
|
{ label: 'Targets', to: '/training/targets', count: 9 },
|
|
2291
|
-
{ label: 'Weak
|
|
2143
|
+
{ label: 'Weak Spots', to: '/training/weak-spots', count: 4 },
|
|
2292
2144
|
]}
|
|
2293
2145
|
deleted={{ shown, onShownChange: setShown, noun: 'exercises' }}
|
|
2294
2146
|
newAction={{ label: 'New Exercise', to: '/training/exercises/new' }}
|
|
@@ -2296,34 +2148,23 @@ The toolbar a list-page review picked (4.100): `look="framed"` on
|
|
|
2296
2148
|
<DataTable look="framed" views={VIEWS} columnsMenu={…} groupings={…} toolbar={<FilterBar … />} … />
|
|
2297
2149
|
```
|
|
2298
2150
|
|
|
2299
|
-
|
|
2300
|
-
|
|
2151
|
+
The header goes in the table, as `pageHeader`, so the header row ends
|
|
2152
|
+
where the card does:
|
|
2301
2153
|
|
|
2302
2154
|
```tsx
|
|
2303
2155
|
<DataTable look="framed" pageHeader={<ListHeader title="Exercises" … />} views={VIEWS} toolbar={…} … />
|
|
2304
2156
|
```
|
|
2305
2157
|
|
|
2306
|
-
- **The card
|
|
2307
|
-
|
|
2308
|
-
views sit above it
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
and the page as its maximum; nothing is measured), so above a short
|
|
2317
|
-
table ⋯ and New sit over the card's right edge, and above a wide one
|
|
2318
|
-
where the page ends. A header wider than the table widens the card to
|
|
2319
|
-
match. `width="full"` and the phone's row list span the page as before.
|
|
2320
|
-
A ListHeader left outside the table spans the page, as before 4.106.
|
|
2321
|
-
- **One settings button** in place of Columns and Group: the Columns
|
|
2322
|
-
ticks, then Group By, in one menu. Its name says the grouping that's on
|
|
2323
|
-
("Table Settings, Grouped by Status") and a dot marks it. Fold All
|
|
2324
|
-
stays a button of its own while grouped. On a phone it holds Group By
|
|
2325
|
-
alone.
|
|
2326
|
-
- **One more button beside New** (`secondaryAction`, 4.117), in the
|
|
2158
|
+
- **The card** holds the toolbar, the rows and the pager, as wide as
|
|
2159
|
+
`width` makes the table, so nothing sits off at the far right of a wide
|
|
2160
|
+
page. Saved views sit above it.
|
|
2161
|
+
- **So does the header**, passed as `pageHeader`: the header, the views
|
|
2162
|
+
and the card are one box as wide as the table. A ListHeader left
|
|
2163
|
+
outside the table spans the page.
|
|
2164
|
+
- **One settings button** in place of Columns and Group. Its name says
|
|
2165
|
+
the grouping that's on ("Table Settings, Grouped by Status"). Fold All
|
|
2166
|
+
stays a button of its own while grouped.
|
|
2167
|
+
- **One more button beside New** (`secondaryAction`), in the
|
|
2327
2168
|
header in or out of the table: a list's second most common action, as
|
|
2328
2169
|
an outline button just before New, which stays the primary.
|
|
2329
2170
|
|
|
@@ -2335,26 +2176,17 @@ header row ends where the card does:
|
|
|
2335
2176
|
|
|
2336
2177
|
One at most: a third action goes in ⋯ (`more`). On a phone it's ⋯'s
|
|
2337
2178
|
first item, so the row keeps the title, ⋯ and New; ⋯ shows on a phone
|
|
2338
|
-
for it alone when nothing else is in the menu.
|
|
2339
|
-
`app/ListHeader` Secondary action story, and
|
|
2340
|
-
`e2e/list-header-secondary.spec.ts` (its place, the fold, axe in both
|
|
2341
|
-
themes at both widths).
|
|
2179
|
+
for it alone when nothing else is in the menu.
|
|
2342
2180
|
- **Siblings** are the page's peers, a switch of links beside the title,
|
|
2343
2181
|
the current one marked (`aria-current="page"`); they don't go in ⋯,
|
|
2344
2182
|
which keeps what's left. Two or more; on a phone the switch has its own
|
|
2345
2183
|
line. Pass `current` when the siblings differ only by query string.
|
|
2346
|
-
- The fixtures' `app/DataTable tools` Framed and `app/ListHeader`
|
|
2347
|
-
Siblings stories hold it, under axe and the token check in both
|
|
2348
|
-
themes; `e2e/data-table-framed.spec.ts` checks the edges, the menu
|
|
2349
|
-
from the mouse and the keyboard, the switch and the phone, and
|
|
2350
|
-
`e2e/list-header-width.spec.ts` the header's edge at 1440 and 1920
|
|
2351
|
-
(`Header at the table edge` stories).
|
|
2352
2184
|
|
|
2353
2185
|
## 26. A record's related list, capped
|
|
2354
2186
|
|
|
2355
2187
|
A list of records related to this one, in a section of its view (a
|
|
2356
2188
|
provider's visits, a project's tasks): the ten newest, then View All N to
|
|
2357
|
-
the whole list filtered to this record
|
|
2189
|
+
the whole list filtered to this record, so a long list doesn't push
|
|
2358
2190
|
the rest of the record away. With tabs (EntityView's), each such list
|
|
2359
2191
|
counts as a group.
|
|
2360
2192
|
|
|
@@ -2385,8 +2217,6 @@ const visits = useVisits({ provider: provider.id, sort: 'date:desc', page: 1, pa
|
|
|
2385
2217
|
- **`opens` is required**, as on any list. Everything else a DataTable
|
|
2386
2218
|
takes for its rows (`rowActions`, `phoneRow`, `highlightRow`) works.
|
|
2387
2219
|
- On a DataTable of your own, `limit` and `viewAll` do the same.
|
|
2388
|
-
- The fixture `app/DataTable tools` Related draws a capped list and a
|
|
2389
|
-
short one with no link; the spec follows View All.
|
|
2390
2220
|
|
|
2391
2221
|
## 27. A repeat and its next time
|
|
2392
2222
|
|
|
@@ -2436,5 +2266,3 @@ import { formatOccurrence, formatRecurrence, nextOccurrence, EmptyText } from '@
|
|
|
2436
2266
|
done, use the server's `next_at` if it sends one; `nextOccurrence`
|
|
2437
2267
|
counts from the schedule's start.
|
|
2438
2268
|
- **Sorting by Next** is the server's (`next_at`), not the cell's text.
|
|
2439
|
-
- The fixture `app/RecurrenceField` List cells draws both on six chores;
|
|
2440
|
-
its spec reads each cell.
|