@tristan2828/ui-foundation 4.125.0 → 4.127.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.
- package/README.md +1 -1
- package/conventions/docs/add-an-entity.md +140 -35
- package/conventions/docs/cell-patterns.md +144 -56
- package/conventions/docs/design-language.md +45 -13
- package/dist/api/contracts.d.ts +8 -1
- package/dist/api/gateway/errors.js +4 -0
- package/dist/api/schema.d.ts +9 -0
- package/dist/api/transport/index.js +10 -1
- package/dist/components/app/data-table-tools.d.ts +12 -0
- package/dist/components/app/data-table-tools.js +2 -2
- package/dist/components/app/data-table.d.ts +2 -1
- package/dist/components/app/data-table.js +1 -1
- package/dist/components/app/edit-caret.d.ts +25 -0
- package/dist/components/app/edit-caret.js +118 -0
- package/dist/components/app/edit-in-place-presets.d.ts +51 -1
- package/dist/components/app/edit-in-place-presets.js +30 -0
- package/dist/components/app/edit-in-place-store.d.ts +70 -4
- package/dist/components/app/edit-in-place-store.js +219 -21
- package/dist/components/app/edit-in-place.d.ts +11 -0
- package/dist/components/app/editable-value.js +202 -25
- package/dist/components/app/entity-form.js +4 -0
- package/dist/components/app/entity-view.js +5 -1
- package/dist/components/app/equal-items.d.ts +32 -6
- package/dist/components/app/equal-items.js +59 -8
- package/dist/components/app/error-state.js +1 -0
- package/dist/components/app/form-leave-guard.js +7 -1
- package/dist/components/app/milkdown-editor.d.ts +1 -0
- package/dist/components/app/milkdown-editor.js +226 -64
- package/dist/components/app/pill-filter.d.ts +16 -0
- package/dist/components/app/pill-filter.js +22 -1
- package/dist/components/app/prose-look.d.ts +1 -1
- package/dist/components/app/prose-look.js +3 -1
- package/dist/components/app/rating-input.d.ts +22 -0
- package/dist/components/app/rating-input.js +65 -0
- package/dist/components/app/rating-score.d.ts +2 -1
- package/dist/components/app/rating-score.js +2 -6
- package/dist/components/app/rich-text-autolink.d.ts +6 -0
- package/dist/components/app/rich-text-autolink.js +79 -0
- package/dist/components/app/rich-text-edges.d.ts +8 -0
- package/dist/components/app/rich-text-edges.js +144 -0
- package/dist/components/app/rich-text-editor.d.ts +19 -4
- package/dist/components/app/rich-text-editor.js +19 -6
- package/dist/components/app/rich-text-empty-paragraph.d.ts +14 -6
- package/dist/components/app/rich-text-empty-paragraph.js +19 -8
- package/dist/components/app/rich-text-formats.js +88 -15
- package/dist/components/app/rich-text-full-screen.d.ts +2 -0
- package/dist/components/app/rich-text-full-screen.js +78 -0
- package/dist/components/app/rich-text-highlight-menu.d.ts +3 -1
- package/dist/components/app/rich-text-highlight-menu.js +3 -2
- package/dist/components/app/rich-text-input-rules.d.ts +7 -0
- package/dist/components/app/rich-text-input-rules.js +83 -0
- package/dist/components/app/rich-text-keyboard-bar.d.ts +24 -0
- package/dist/components/app/rich-text-keyboard-bar.js +215 -0
- package/dist/components/app/rich-text-node-views.js +2 -1
- package/dist/components/app/rich-text-paste.d.ts +43 -0
- package/dist/components/app/rich-text-paste.js +355 -0
- package/dist/components/app/rich-text-shortcuts.d.ts +5 -1
- package/dist/components/app/rich-text-shortcuts.js +132 -2
- package/dist/components/app/rich-text-slash-menu.js +47 -9
- package/dist/components/app/rich-text-slash.d.ts +7 -0
- package/dist/components/app/rich-text-slash.js +27 -14
- package/dist/components/app/rich-text-table-grips.d.ts +8 -6
- package/dist/components/app/rich-text-table-grips.js +11 -12
- package/dist/components/app/rich-text-tasks.d.ts +8 -0
- package/dist/components/app/rich-text-tasks.js +20 -0
- package/dist/components/app/rich-text-toolbar.d.ts +5 -1
- package/dist/components/app/rich-text-toolbar.js +14 -6
- package/dist/components/app/rich-text-tools-bar.d.ts +3 -1
- package/dist/components/app/rich-text-tools-bar.js +2 -2
- package/dist/components/app/rich-text-touch.d.ts +2 -0
- package/dist/components/app/rich-text-touch.js +18 -0
- package/dist/components/app/rich-text-widgets.js +1 -1
- package/dist/hooks/table-url-changes.d.ts +4 -0
- package/dist/hooks/table-url-changes.js +13 -0
- package/dist/hooks/use-record-update.d.ts +13 -1
- package/dist/hooks/use-record-update.js +17 -3
- package/dist/hooks/use-table-url-state.js +14 -8
- package/dist/index.d.ts +5 -2
- package/dist/index.js +8 -0
- package/dist/lib/markdown-merge.d.ts +38 -0
- package/dist/lib/markdown-merge.js +202 -17
- package/dist/lib/page-leaving.d.ts +8 -0
- package/dist/lib/page-leaving.js +30 -0
- package/dist/lib/pending-edits.d.ts +14 -0
- package/dist/lib/pending-edits.js +51 -0
- package/dist/lib/rating-glyphs.d.ts +3 -0
- package/dist/lib/rating-glyphs.js +7 -0
- package/dist/mocks/e2e-hooks.js +10 -0
- package/dist/mocks/override.d.ts +8 -0
- package/dist/testing/index.d.ts +40 -2
- package/dist/testing/index.js +101 -7
- package/openapi/foundation.yaml +12 -0
- package/package.json +1 -1
- package/styles/index.css +7 -0
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ than installing this by hand:
|
|
|
22
22
|
| `@tristan2828/ui-foundation/ui/<name>` | shadcn primitives: badge, button, calendar, card, checkbox, combobox, dialog, empty, field, input, input-group, label, popover, select, separator, sheet, sidebar, skeleton, sonner, spinner, switch, table, textarea, tooltip |
|
|
23
23
|
| `@tristan2828/ui-foundation/gateway` | `safeFetch`, `toAppError`, `networkError` — for an app's `src/api/gateway/` only |
|
|
24
24
|
| `@tristan2828/ui-foundation/mocks` | MSW: `authHandlers`, `environmentHandlers`, `resetMockAuth`, `getMockCurrentUser`, `MOCK_USER`, `startMockWorker` (mock mode's boot), `exposeMswForE2E` |
|
|
25
|
-
| `@tristan2828/ui-foundation/testing` | Playwright: `test` and `expect` (a page whose `goto()`/`reload()` wait for the app's boot; `withBootWait` for a page of your own), `defineA11ySuite`, `defineMockModeBannerSuite`, `defineDataEnvironmentBannerSuite`, `forceMswOverride`, `forceLoggedOut`, `waitForMswReady`, `expectDataViewsLoaded` |
|
|
25
|
+
| `@tristan2828/ui-foundation/testing` | Playwright: `test` and `expect` (a page whose `goto()`/`reload()` let its `/api/` requests settle, then wait for the app's boot; `withBootWait` for a page of your own), `defineA11ySuite`, `defineMockModeBannerSuite`, `defineDataEnvironmentBannerSuite`, `forceMswOverride` (`{ hold: true }` for a loading state, then `release()`), `releaseMswOverride`, `forceLoggedOut`, `waitForMswReady`, `expectDataViewsLoaded` |
|
|
26
26
|
| `@tristan2828/ui-foundation/eslint` | the lint rules, as a flat config: `export default [...uiFoundation()]` |
|
|
27
27
|
| `@tristan2828/ui-foundation/styles.css` | tokens and base styles, after `@import "tailwindcss";` |
|
|
28
28
|
| `@tristan2828/ui-foundation/openapi.yaml` | the part of an app's API contract the package calls: `/auth/*`, `/environment` (optional) and the error bodies |
|
|
@@ -3,30 +3,31 @@
|
|
|
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 reference files](#the-reference-files) · lines
|
|
7
|
-
- [Before anything: the entity plan](#before-anything-the-entity-plan) · lines
|
|
8
|
-
- Step 1: Add `<Entity>` to `openapi.yaml` · lines
|
|
9
|
-
- Step 2: `npm run gen:api` · lines
|
|
10
|
-
- Step 3: Add gateway tests in `tests/gateway/<entity>.test.ts`, derived from the spec · lines
|
|
11
|
-
- Step 4: Add MSW handlers in `src/mocks/<entity>.ts` · lines
|
|
12
|
-
- Step 5: Add a gateway module in `src/api/gateway/<entity>.ts` · lines
|
|
13
|
-
- Step 6: Copy the reference files, one for one, not just the two screens · lines
|
|
14
|
-
- Step 7: Register routes · lines
|
|
15
|
-
- Step 8: Add Playwright specs for all three screens · lines
|
|
16
|
-
- Step 9: Register the nav entry and route names · lines
|
|
17
|
-
- Step 10: `npm run verify`. · lines
|
|
18
|
-
- [How a list opens a record](#how-a-list-opens-a-record) · lines
|
|
19
|
-
- [The record view](#the-record-view) · lines
|
|
20
|
-
- [Forms](#forms) · lines
|
|
21
|
-
- [Dialogs](#dialogs) · lines
|
|
22
|
-
- [Toasts and feedback](#toasts-and-feedback) · lines
|
|
23
|
-
- [What not to copy](#what-not-to-copy) · lines
|
|
24
|
-
- [After a commit, in the backend](#after-a-commit-in-the-backend) · lines
|
|
25
|
-
- [
|
|
26
|
-
- [
|
|
27
|
-
- [
|
|
28
|
-
- [
|
|
29
|
-
- [
|
|
6
|
+
- [The reference files](#the-reference-files) · lines 46–68
|
|
7
|
+
- [Before anything: the entity plan](#before-anything-the-entity-plan) · lines 70–881
|
|
8
|
+
- Step 1: Add `<Entity>` to `openapi.yaml` · lines 112–119
|
|
9
|
+
- Step 2: `npm run gen:api` · lines 120–121
|
|
10
|
+
- Step 3: Add gateway tests in `tests/gateway/<entity>.test.ts`, derived from the spec · lines 122–133
|
|
11
|
+
- Step 4: Add MSW handlers in `src/mocks/<entity>.ts` · lines 134–143
|
|
12
|
+
- Step 5: Add a gateway module in `src/api/gateway/<entity>.ts` · lines 144–150
|
|
13
|
+
- Step 6: Copy the reference files, one for one, not just the two screens · lines 151–759
|
|
14
|
+
- Step 7: Register routes · lines 760–775
|
|
15
|
+
- Step 8: Add Playwright specs for all three screens · lines 776–863
|
|
16
|
+
- Step 9: Register the nav entry and route names · lines 864–878
|
|
17
|
+
- Step 10: `npm run verify`. · lines 879–881
|
|
18
|
+
- [How a list opens a record](#how-a-list-opens-a-record) · lines 883–1385
|
|
19
|
+
- [The record view](#the-record-view) · lines 1036–1215
|
|
20
|
+
- [Forms](#forms) · lines 1217–1299
|
|
21
|
+
- [Dialogs](#dialogs) · lines 1301–1332
|
|
22
|
+
- [Toasts and feedback](#toasts-and-feedback) · lines 1334–1385
|
|
23
|
+
- [What not to copy](#what-not-to-copy) · lines 1387–1422
|
|
24
|
+
- [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1424–1441
|
|
25
|
+
- [Saves that don't overwrite](#saves-that-dont-overwrite) · lines 1443–1489
|
|
26
|
+
- [Deleting](#deleting) · lines 1491–1522
|
|
27
|
+
- [Fields only a script writes](#fields-only-a-script-writes) · lines 1524–1545
|
|
28
|
+
- [Searching one part of the app](#searching-one-part-of-the-app) · lines 1547–1556
|
|
29
|
+
- [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1559–1601
|
|
30
|
+
- [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1603–1639
|
|
30
31
|
|
|
31
32
|
<!-- /index -->
|
|
32
33
|
|
|
@@ -425,7 +426,14 @@ is a filled-in example while the Widgets demo is still here).
|
|
|
425
426
|
the Markdown long text's `RichTextEditor` (on the form whether or
|
|
426
427
|
not it edits in place), given a `placeholder` and `maxLength` (the
|
|
427
428
|
schema's limit, one constant both read, like Widget's
|
|
428
|
-
`DESCRIPTION_MAX_LENGTH`)
|
|
429
|
+
`DESCRIPTION_MAX_LENGTH`) and an `onProblem` prop it passes on. **On
|
|
430
|
+
the form, bind `onProblem`** as `widget-form.tsx`'s
|
|
431
|
+
`onDescriptionProblem` does: the message becomes the field's error
|
|
432
|
+
(`setError`, type `refused`) and submit is refused while it stands.
|
|
433
|
+
An edit the editor can't save without rewriting text nobody touched
|
|
434
|
+
never reaches `onChange`, so a form without it would send the last
|
|
435
|
+
text that could be saved and say it worked. (An editor given no
|
|
436
|
+
`onProblem` says it inside the field itself.) Every other field's control stays inline in
|
|
429
437
|
the form, as `widget-form.tsx`'s Category, Tags and Available From
|
|
430
438
|
do. No `Edit in place` line and no Markdown long text: no fields
|
|
431
439
|
file.
|
|
@@ -641,7 +649,11 @@ is a filled-in example while the Widgets demo is still here).
|
|
|
641
649
|
`useEditWidgetField`: the single-field save with `optimistic: false,
|
|
642
650
|
toastOnError: false`). `kind` follows the control: `text` (one line;
|
|
643
651
|
a number or integer too), `long-text` (Markdown, `RichTextEditor`
|
|
644
|
-
with `
|
|
652
|
+
with `onProblem={props.onProblem}`; notes are `inline: true` by
|
|
653
|
+
default, the control passing `inline={props.inline}` and
|
|
654
|
+
`toolbar="floating"` (on the form too: "Forms" below) with no
|
|
655
|
+
`autoFocus`, as Widget's Description does; a short one opened by a click is
|
|
656
|
+
`autosave: true` with `autoFocus`), `choice` (a
|
|
645
657
|
select or a single reference: its list opens with the field,
|
|
646
658
|
`defaultOpen`, non-modal, `onChange={(v) => props.commit(v)}`,
|
|
647
659
|
`onOpenChange={(open) => !open && props.cancel()}`; a yes/no switch
|
|
@@ -768,7 +780,10 @@ is a filled-in example while the Widgets demo is still here).
|
|
|
768
780
|
`e2e/widgets-table.spec.ts`/`e2e/widget-form.spec.ts`/
|
|
769
781
|
`e2e/widget-view.spec.ts` for the pattern. Import `test` and
|
|
770
782
|
`expect` from there too, not from `@playwright/test`: its page's
|
|
771
|
-
`goto()` and `reload()`
|
|
783
|
+
`goto()` and `reload()` first wait for the page's `/api/` requests to
|
|
784
|
+
settle (150 ms with none in flight, at most 3 s, never a failure), so a
|
|
785
|
+
save's follow-up refresh isn't sent past the mocks by the page as it
|
|
786
|
+
unloads; then they return once the app has rendered (after MSW's
|
|
772
787
|
start), and load once more if the server refused one of its files,
|
|
773
788
|
so a spec's first expect never meets an empty page. The view's states are
|
|
774
789
|
loading, not found (a 404: "Not found", the way back, no retry), error
|
|
@@ -806,6 +821,13 @@ is a filled-in example while the Widgets demo is still here).
|
|
|
806
821
|
section placed `details`, that test checks its labels sit beside
|
|
807
822
|
their values, and another on a wide screen that there's no rail (copy
|
|
808
823
|
`wide screens: …` in `e2e/widget-view.spec.ts`).
|
|
824
|
+
**A loading test holds the answer, never delays it:**
|
|
825
|
+
`forceMswOverride(page, override, { hold: true })` returns a
|
|
826
|
+
`release()`; assert the skeleton, `await release()`, then assert the
|
|
827
|
+
data, so the test waits on nothing but its own steps. A `delayMs` can
|
|
828
|
+
run out before the page first renders under load, and the skeleton is
|
|
829
|
+
never seen. Copy `loading: …` in `e2e/widgets-table.spec.ts`; keep
|
|
830
|
+
`delayMs` for a test about time itself.
|
|
809
831
|
States forced via a first-load init script (loading, load-time error)
|
|
810
832
|
need `page.addInitScript` before navigation; states forced after the
|
|
811
833
|
page is already up (a mutation's error response) can use a
|
|
@@ -1120,18 +1142,38 @@ A record uses the parts it has, in this order:
|
|
|
1120
1142
|
component or a node) before the label, in the muted tone. With
|
|
1121
1143
|
`tone` (4.123: `success`, `warning`, `info`, `destructive`) a label
|
|
1122
1144
|
that is a state ("Pinned", "Overdue") is the outline badge in that
|
|
1123
|
-
tone, its icon too; the word still says it.
|
|
1145
|
+
tone, its icon too; the word still says it. A flag that's set reads
|
|
1146
|
+
at a glance this way, edited in place as any badges fact (its `edit`
|
|
1147
|
+
picks the flags; at rest each is drawn in its tone), and the tone
|
|
1148
|
+
comes along where the rail folds into Details on a phone. Untoned
|
|
1149
|
+
items are the plain outline. Give each state its tone from the design
|
|
1150
|
+
language's badge tones, never a colour of the app's own:
|
|
1151
|
+
|
|
1152
|
+
```tsx
|
|
1153
|
+
const FLAG_BADGE = { blocked: { label: 'Blocked', tone: 'destructive' }, needsYou: { label: 'Needs you', tone: 'warning' } } as const
|
|
1154
|
+
{ label: 'Flags', kind: 'badges', items: record.flags.map((flag) => FLAG_BADGE[flag]), emptyLabel: 'None',
|
|
1155
|
+
edit: editInPlace({ kind: 'multi', value: record.flags, save: (flags) => save({ flags }), control: (props) => <MultiPick options={FLAGS} value={props.value} onValueChange={props.onChange} aria-label={props.label} aria-describedby={props.describedBy} /> }) },
|
|
1156
|
+
```
|
|
1124
1157
|
- **A rating** (4.117) is `kind: 'rating'`, drawn as the list's cells
|
|
1125
1158
|
draw it, never as "4 of 5" text: stars (the default) or hearts for a
|
|
1126
1159
|
score out of `max` (5), the step bar for a quality level. `null` is
|
|
1127
|
-
empty (its `emptyLabel`).
|
|
1160
|
+
empty (its `emptyLabel`). A score the person gives (my rating) is
|
|
1161
|
+
edited in place with **`inPlace.rating`** (4.127): the stars are then
|
|
1162
|
+
the value, a click on one saves it, a second press on the set one
|
|
1163
|
+
saves `null`, and an empty one shows five empty stars to click rather
|
|
1164
|
+
than its `emptyLabel`. A score that isn't the person's to set (a
|
|
1165
|
+
critics' average) stays read-only:
|
|
1128
1166
|
|
|
1129
1167
|
```tsx
|
|
1130
|
-
{ label: 'My Rating', kind: 'rating',
|
|
1131
|
-
edit: inPlace.
|
|
1132
|
-
|
|
1168
|
+
{ label: 'My Rating', kind: 'rating', value: record.rating,
|
|
1169
|
+
edit: inPlace.rating({ value: record.rating, save: (rating) => save({ rating }) }) },
|
|
1170
|
+
{ label: 'Loved', kind: 'rating', look: 'hearts', value: record.loved,
|
|
1171
|
+
edit: inPlace.rating({ value: record.loved, glyph: 'heart', save: (loved) => save({ loved }) }) },
|
|
1133
1172
|
{ label: 'Quality', kind: 'rating', look: 'bar', value: QUALITY[record.quality].value, word: QUALITY[record.quality].word },
|
|
1134
1173
|
```
|
|
1174
|
+
|
|
1175
|
+
A quality level drawn as the step bar is an enum, not a score: edit
|
|
1176
|
+
it with `inPlace.select` over its levels.
|
|
1135
1177
|
- **A yes/no** (4.120) is `kind: 'switch'`, a switch toggled where it
|
|
1136
1178
|
is, named by the label, never a two-choice select. Return the save's
|
|
1137
1179
|
promise: the switch shows the new state while it runs and goes back
|
|
@@ -1159,8 +1201,10 @@ A record uses the parts it has, in this order:
|
|
|
1159
1201
|
handful of options) are one `EqualItems` (4.93) in a section, one look
|
|
1160
1202
|
per set: `cards` for little to say about each, `table` for things
|
|
1161
1203
|
compared on the same values, `featured` when one is current or best,
|
|
1162
|
-
`panels` when each has several details (
|
|
1163
|
-
|
|
1204
|
+
`panels` when each has several details, `stepper` (4.127) for a
|
|
1205
|
+
sequence with a current step whose items are looked at one at a time
|
|
1206
|
+
(numbered steps picking the one panel shown; design-language.md "A few
|
|
1207
|
+
equal things"). Never hand-made cards, a grid or a stepper of their own. An item
|
|
1164
1208
|
edited or removed on its own carries its editor as `content` and its
|
|
1165
1209
|
Edit and Remove as `actions` (4.94), `wide` while the editor is open;
|
|
1166
1210
|
never an editor put in a field's value.
|
|
@@ -1194,6 +1238,17 @@ shape (4.85):
|
|
|
1194
1238
|
a status choice gives each option its `kind`, so its icons are
|
|
1195
1239
|
`StatusMark`'s in their colours (below).
|
|
1196
1240
|
- **Order:** required first, the status next, long text last.
|
|
1241
|
+
- **Notes** (a Markdown long text: notes, a description, a body) are a
|
|
1242
|
+
`RichTextEditor` with `toolbar="floating"` on the form as in place
|
|
1243
|
+
(4.127): no bar above the text, the formats over selected words, every
|
|
1244
|
+
block in the slash menu ("/"), and Image, Full Screen and (on a narrow
|
|
1245
|
+
or touch screen) Indent and Outdent on the small "Editor tools" strip
|
|
1246
|
+
while it has focus. On a phone the row pinned to the keyboard carries
|
|
1247
|
+
them, Image included, at 40px. Give it the app's `upload` (the one
|
|
1248
|
+
`ImageField` takes) for the Image button and for pasted and dropped
|
|
1249
|
+
pictures, which go in as ``; a refused or failed picture says
|
|
1250
|
+
why in a toast. Without `upload` there's no Image button, and a picture
|
|
1251
|
+
can't go in at all.
|
|
1197
1252
|
- **Required:** `<FieldLabel required>` (an asterisk, and `aria-required`
|
|
1198
1253
|
on the control it names). Nothing on an optional field: never
|
|
1199
1254
|
"(optional)".
|
|
@@ -1354,7 +1409,9 @@ sight.** What happened where the person is looking says so there.
|
|
|
1354
1409
|
opens on with `defaultView`, and put what no control can show (a
|
|
1355
1410
|
computed "overdue") in the view's `rule` (cell-patterns.md "Saved views
|
|
1356
1411
|
are pills"). The default view's `sort` is its plain address's too
|
|
1357
|
-
(4.123): pressing it writes no `?sort=`, and the rows keep that order.
|
|
1412
|
+
(4.123): pressing it writes no `?sort=`, and the rows keep that order. A view the plan says
|
|
1413
|
+
shows a count gets `count` from the app's own query, passed to
|
|
1414
|
+
`DataTable`'s `views` (cell-patterns.md "A view can carry a count").
|
|
1358
1415
|
- `src/api/gateway/widgets.ts`, `src/mocks/data.ts`, `src/mocks/handlers.ts`
|
|
1359
1416
|
are demo-domain content — write the entity's own versions rather than
|
|
1360
1417
|
adapting these by find-and-replace.
|
|
@@ -1383,6 +1440,54 @@ asyncio is a `MissingGreenlet` and a 500.
|
|
|
1383
1440
|
a `User(...)` in for `get_current_user` in an override: a detached user
|
|
1384
1441
|
never expires, so the test passes and the route fails live.
|
|
1385
1442
|
|
|
1443
|
+
## Saves that don't overwrite
|
|
1444
|
+
|
|
1445
|
+
A record edited in more than one place (a laptop tab, a phone, an AI chat
|
|
1446
|
+
through MCP) needs a version, or the last save wins: a phone left open on
|
|
1447
|
+
a note, typed into after the laptop changed it, replaces the laptop's
|
|
1448
|
+
work. The fix is optimistic concurrency, the same for every entity:
|
|
1449
|
+
|
|
1450
|
+
- **The record carries its version: `updatedAt`** (`updated_at`, a
|
|
1451
|
+
`timestamptz` every write sets with `foundation_backend.versions.touch()`,
|
|
1452
|
+
never null, commented in its migration). Not a counter or an ETag: most
|
|
1453
|
+
tables already have one, a person or an AI reading the row knows what it
|
|
1454
|
+
means, and it rides in the JSON body, where an MCP tool call can send it
|
|
1455
|
+
back too (an `If-Match` header can't reach a chat). It's compared for
|
|
1456
|
+
equality, never ordered, so clocks don't matter.
|
|
1457
|
+
- **An update may send the version it was built on: `baseUpdatedAt`**, an
|
|
1458
|
+
optional field of `<Entity>Update` that isn't a column. The router locks
|
|
1459
|
+
the row, calls `check_version(record.updated_at, base)` before changing
|
|
1460
|
+
anything, and sets `updated_at = touch()`. A version that's no longer the
|
|
1461
|
+
record's is a **409** (`ConflictError`, `VersionConflict`): nothing is
|
|
1462
|
+
written. No version sent: no check, so older clients and scripts keep
|
|
1463
|
+
working. `responses=VERSIONED_UPDATE_RESPONSES` documents it, and the
|
|
1464
|
+
PATCH in `openapi.yaml` lists `"409": ConflictError`.
|
|
1465
|
+
- **The client sends it with every single-field save:** `useRecordUpdate`'s
|
|
1466
|
+
`withVersion: (update, record) => ({ ...update, baseUpdatedAt:
|
|
1467
|
+
record.updatedAt })`. The record it gets is the latest the server
|
|
1468
|
+
returned (a burst of saves chains through each answer's version), so a
|
|
1469
|
+
save never conflicts with the tab's own. The gateway needs no change:
|
|
1470
|
+
`toAppError` makes the 409 an `AppError` of kind `conflict`, and
|
|
1471
|
+
`useRecordUpdate` refetches the record.
|
|
1472
|
+
- **What the person sees.** A quick action's toast gives the 409's reason,
|
|
1473
|
+
and the refetch shows what the other writer saved. A field edited in
|
|
1474
|
+
place asks: "This changed elsewhere", with **Keep Mine** and **Show
|
|
1475
|
+
Saved**, and nothing saves until a pick. Long text's Keep Mine keeps
|
|
1476
|
+
both, block by block (`rebaseMarkdown`); when both changed the same
|
|
1477
|
+
paragraph it says so, and only a second Keep Mine replaces theirs. Any
|
|
1478
|
+
other field's Keep Mine saves what's typed over theirs. An `editInPlace`
|
|
1479
|
+
takes its own `rebase`, or `rebase: false`.
|
|
1480
|
+
- **A chat** gets the same check through the entity's `McpEntity.update`:
|
|
1481
|
+
the `update` tool tells it to send the `updatedAt` it read as
|
|
1482
|
+
`baseUpdatedAt`, and a 409 comes back as a refusal that says to fetch
|
|
1483
|
+
the record again. `edit_text` is safe without it (its `old` text must
|
|
1484
|
+
still be there).
|
|
1485
|
+
- **Copy:** `template/backend/app/routers/widgets.py` (`update_widget`),
|
|
1486
|
+
migration `0017_widget_updated_at.py`, `WidgetOut.updated_at` and
|
|
1487
|
+
`WidgetUpdate.base_updated_at` in `app/schemas.py`, the PATCH mock in
|
|
1488
|
+
`src/mocks/handlers.ts`, `withVersion` in `use-widgets.ts`, and the
|
|
1489
|
+
"two writers" specs in `e2e/widget-edit-in-place.spec.ts`.
|
|
1490
|
+
|
|
1386
1491
|
## Deleting
|
|
1387
1492
|
|
|
1388
1493
|
The plan's "Deleting" line says which of three. The Widget reference is the
|
|
@@ -13,38 +13,38 @@
|
|
|
13
13
|
- [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 299–311
|
|
14
14
|
- [7. Link as an outline button](#7-link-as-an-outline-button) · lines 313–334
|
|
15
15
|
- [8. Date, relative](#8-date-relative) · lines 336–373
|
|
16
|
-
- [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 375–
|
|
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–
|
|
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
|
-
- [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines
|
|
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
|
|
16
|
+
- [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 375–453
|
|
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–453
|
|
18
|
+
- [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 455–505
|
|
19
|
+
- [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 473–505
|
|
20
|
+
- [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 507–547
|
|
21
|
+
- [12. Boolean](#12-boolean) · lines 549–579
|
|
22
|
+
- [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 581–617
|
|
23
|
+
- [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 601–617
|
|
24
|
+
- [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 619–636
|
|
25
|
+
- [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 638–747
|
|
26
|
+
- [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 664–747
|
|
27
|
+
- [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 749–795
|
|
28
|
+
- [17. Quick action on the view](#17-quick-action-on-the-view) · lines 797–870
|
|
29
|
+
- [18. Editable value](#18-editable-value) · lines 872–1628
|
|
30
|
+
- [Presets: one line per field](#presets-one-line-per-field) · lines 1257–1328
|
|
31
|
+
- [Several fields edited as one](#several-fields-edited-as-one) · lines 1330–1366
|
|
32
|
+
- [A link and its label](#a-link-and-its-label) · lines 1368–1392
|
|
33
|
+
- [A list of sub-items](#a-list-of-sub-items) · lines 1394–1527
|
|
34
|
+
- [In a table's rows](#in-a-tables-rows) · lines 1529–1614
|
|
35
|
+
- [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1616–1628
|
|
36
|
+
- [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1630–1696
|
|
37
|
+
- [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1698–1762
|
|
38
|
+
- [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1764–1862
|
|
39
|
+
- [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1864–1893
|
|
40
|
+
- [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines 1895–1933
|
|
41
|
+
- [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1935–2011
|
|
42
|
+
- [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 2013–2099
|
|
43
|
+
- [Picking one on a form: `ColorField`](#picking-one-on-a-form-colorfield) · lines 2038–2099
|
|
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 2101–2342
|
|
45
|
+
- [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2271–2342
|
|
46
|
+
- [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2344–2380
|
|
47
|
+
- [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2382–2431
|
|
48
48
|
|
|
49
49
|
<!-- /index -->
|
|
50
50
|
|
|
@@ -430,6 +430,25 @@ themes. Each is one image to a screen reader, named in words.
|
|
|
430
430
|
{row.rating === null ? <Muted>Not rated</Muted> : <RatingScore value={row.rating} glyph="heart" />}
|
|
431
431
|
```
|
|
432
432
|
|
|
433
|
+
- **`RatingInput`, the same score set by a click** (4.127): RatingScore's
|
|
434
|
+
glyphs and tokens as a radio group named by `label`, one radio per
|
|
435
|
+
star ("2 of 5"). A click (or Space) sets a star, a click on the set one
|
|
436
|
+
clears it to `null`, the arrow keys move and set it, a mouse's hover
|
|
437
|
+
previews it. 24px targets on a laptop, 44px on a touch screen.
|
|
438
|
+
`onChange(value, source)`: `source` is `'pointer'` or `'keyboard'`.
|
|
439
|
+
On a form it's the field's control; on a record or in a row it's
|
|
440
|
+
`inPlace.rating` ("Presets" below), so a cell sets its row's score where
|
|
441
|
+
it's drawn:
|
|
442
|
+
|
|
443
|
+
```tsx
|
|
444
|
+
<RatingInput label="Taste" value={value} onChange={(next) => setValue(next)} />
|
|
445
|
+
// A table's cell: inside DataTable, which runs editing in place.
|
|
446
|
+
cell: ({ row }) => (
|
|
447
|
+
<EditableValue layout="inline" label={`Rating of ${row.original.name}`}
|
|
448
|
+
edit={inPlace.rating({ value: row.original.rating, save: (rating) => save(row.original.id, { rating }) })} />
|
|
449
|
+
),
|
|
450
|
+
```
|
|
451
|
+
|
|
433
452
|
- All three draw in `foreground`. Tone one only as pattern 5 would (a `*-text`
|
|
434
453
|
class in `className`), never by band alone.
|
|
435
454
|
|
|
@@ -856,17 +875,21 @@ A value on the record's view that turns into **the form's own control**
|
|
|
856
875
|
where it's shown, and saves when you leave it: a title, a status, a
|
|
857
876
|
price, notes, a list of linked records. Widget's view is the reference
|
|
858
877
|
(`src/routes/widgets/widget-view.tsx`): Name (the title), Status (its
|
|
859
|
-
header badge), Price, Description (rich text
|
|
860
|
-
Categories, with the controls in `widget-fields.tsx`,
|
|
861
|
-
form uses.
|
|
878
|
+
header badge), Price, Description (rich text edited where it's read,
|
|
879
|
+
`inline`) and Extra Categories, with the controls in `widget-fields.tsx`,
|
|
880
|
+
the same ones the form uses.
|
|
862
881
|
|
|
863
882
|
The rule behind every part of it: **nothing typed is ever lost.**
|
|
864
883
|
|
|
865
|
-
**No toast,
|
|
884
|
+
**No toast, but one.** An edit in place says what happened where it
|
|
866
885
|
happened: "Saving…" and "Saved" beside the value, a refusal's reason
|
|
867
886
|
under it. A toast after one would repeat what the person just watched
|
|
868
887
|
(add-an-entity.md "Toasts and feedback": a toast is for what happened
|
|
869
|
-
out of sight).
|
|
888
|
+
out of sight). The one exception is notes that save themselves
|
|
889
|
+
(`autosave`, `alwaysEditable`, `inline`): the first refusal or failed
|
|
890
|
+
save of a run also toasts ("Couldn't save Description", the reason
|
|
891
|
+
under it), since the person is typing, not watching the line, and on a
|
|
892
|
+
long note the line can be a screen away.
|
|
870
893
|
|
|
871
894
|
**Which values.** Only those the plan's "View screen" names under `Edit
|
|
872
895
|
in place`; read-only is the default, and a value not named renders
|
|
@@ -920,7 +943,7 @@ Save button, no Undo:
|
|
|
920
943
|
| Kind (`editInPlace({ kind })`) | Saves on | Esc |
|
|
921
944
|
|---|---|---|
|
|
922
945
|
| `text`: one line | Enter, or leaving it | puts the saved value back |
|
|
923
|
-
| `long-text`: notes, rich text for Markdown | Ctrl/Cmd+Enter, or leaving it (Enter is a new line); with `autosave`, also a pause in typing |
|
|
946
|
+
| `long-text`: notes, rich text for Markdown | Ctrl/Cmd+Enter, or leaving it (Enter is a new line); with `autosave`, also a pause in typing | a changed draft asks "Discard your changes?" first (unchanged closes); with `autosave`, saves what's left and closes |
|
|
924
947
|
| `choice`: a select, a switch, a single reference | the pick (its list opens with the field, non-modal) | closes the list with nothing picked: gives up |
|
|
925
948
|
| `multi`: a multi reference | leaving it, or Ctrl/Cmd+Enter (Enter picks) | closes the list first; Esc again gives up |
|
|
926
949
|
| `multi` over a small set (`MultiPick`) | each click, on its own | closes it: every pick is already saved |
|
|
@@ -1035,19 +1058,50 @@ nobody has to click away to save notes. Opt in per field:
|
|
|
1035
1058
|
is by then, so saves never cross and the latest always wins.
|
|
1036
1059
|
- Under the text, a quiet line in the muted caption tone
|
|
1037
1060
|
(`role="status"`): "Saving…" with a spinner while a save is in flight,
|
|
1038
|
-
"Saved" with a check once nothing typed is waiting.
|
|
1061
|
+
"Saved" with a check once nothing typed is waiting. **On a note longer
|
|
1062
|
+
than the screen the line is pinned to the screen's bottom edge** while
|
|
1063
|
+
the note runs past it, so the save's state and a refusal are never off
|
|
1064
|
+
screen.
|
|
1039
1065
|
- **Refused:** exactly what was typed stays, with the reason under it, as
|
|
1040
|
-
above
|
|
1041
|
-
re-sent on its own.
|
|
1066
|
+
above, and the first refusal of a run toasts. Typing again retries
|
|
1067
|
+
after the pause; a refused draft is never re-sent on its own.
|
|
1068
|
+
- **Saved elsewhere** (another tab, a phone, an AI chat; the record's
|
|
1069
|
+
query refetches): with nothing typed waiting, the note shows the new
|
|
1070
|
+
text at once, even with the caret in it, which keeps its paragraph.
|
|
1071
|
+
Under unsaved typing nothing saves over it: the line says it "changed
|
|
1072
|
+
elsewhere", with **Keep Mine** and **Show Saved** (drop what's typed).
|
|
1073
|
+
Keep Mine keeps both, block by block: what's typed is laid onto the
|
|
1074
|
+
other writer's text and the editor shows the result as it saves; when
|
|
1075
|
+
both changed the same paragraph it says so, and a second Keep Mine
|
|
1076
|
+
replaces theirs. A save the server refuses because another writer saved
|
|
1077
|
+
first (a 409, the record's version check: add-an-entity.md "Saves that
|
|
1078
|
+
don't overwrite") asks the same way, never a plain failure to retry.
|
|
1079
|
+
The server sending back what it was sent, even trimmed, is not a
|
|
1080
|
+
change: the editor keeps its undo.
|
|
1081
|
+
- **Leaving mid-save:** a field that leaves the view while a save is in
|
|
1082
|
+
flight (a session ending, a parent that stops showing it) still sends
|
|
1083
|
+
what was typed after that save started.
|
|
1042
1084
|
- **Esc saves what's left and closes.** Nothing reverts: what was saved a
|
|
1043
1085
|
second ago stays saved, so "give up" would only drop the last second.
|
|
1044
1086
|
- Rich text that can't save without rewriting what the person didn't edit
|
|
1045
|
-
(`RichTextEditor`'s `onProblem`) saves nothing;
|
|
1046
|
-
|
|
1087
|
+
(`RichTextEditor`'s `onProblem`) saves nothing; it counts as unsaved at
|
|
1088
|
+
once (leaving asks straight away), its message shows after the pause,
|
|
1089
|
+
and the next good edit saves.
|
|
1047
1090
|
- **Leaving the page** with a save still to come saves it first and goes
|
|
1048
1091
|
on; "Discard your changes?" shows only if that save is refused. Closing
|
|
1049
1092
|
the tab can't wait: it starts the save and the browser asks. Hiding the
|
|
1050
|
-
page (another tab, a phone's home screen) saves
|
|
1093
|
+
page (another tab, a phone's home screen) saves at once, with no pause.
|
|
1094
|
+
A save started as the page goes is sent with `keepalive` when its body
|
|
1095
|
+
fits (about 30 KB of JSON), so the browser finishes it after the page
|
|
1096
|
+
is gone; a longer note's save goes as an ordinary request.
|
|
1097
|
+
|
|
1098
|
+
**Notes are edited where they're read by default (`inline: true`)** (the
|
|
1099
|
+
developer, 2026-11-17): a record's notes, a description, any long text
|
|
1100
|
+
the page is for. `alwaysEditable` (the boxed editor at rest) and
|
|
1101
|
+
`autosave` alone (the read view at rest, a click opens the editor) are
|
|
1102
|
+
for where that doesn't fit, such as a short summary beside other values.
|
|
1103
|
+
Opening one by a click puts the caret where the click was, and the page
|
|
1104
|
+
doesn't move.
|
|
1051
1105
|
|
|
1052
1106
|
**Always editable (`alwaysEditable: true`, implies `autosave`)**: the
|
|
1053
1107
|
notes are the editor itself, shown at rest, with no pencil and no click
|
|
@@ -1071,7 +1125,8 @@ but drops the bar above the text. An empty one shows the editor's
|
|
|
1071
1125
|
`placeholder` (say "or type / for blocks" in it), not the view's "Not
|
|
1072
1126
|
set". It saves like any always-editable value (a pause after typing,
|
|
1073
1127
|
leaving the page saves first) and is otherwise the same: on the form the
|
|
1074
|
-
control is the boxed editor with
|
|
1128
|
+
control is the boxed editor, with the floating toolbar too (4.127,
|
|
1129
|
+
[add-an-entity.md "Forms"](add-an-entity.md#forms)).
|
|
1075
1130
|
|
|
1076
1131
|
```tsx
|
|
1077
1132
|
notes: editInPlace({
|
|
@@ -1087,13 +1142,13 @@ notes: editInPlace({
|
|
|
1087
1142
|
```
|
|
1088
1143
|
|
|
1089
1144
|
```tsx
|
|
1090
|
-
|
|
1145
|
+
summary: editInPlace({
|
|
1091
1146
|
kind: 'long-text',
|
|
1092
|
-
autosave: true, //
|
|
1093
|
-
value: widget.
|
|
1094
|
-
schema: widgetFormSchema.shape.
|
|
1095
|
-
save: (
|
|
1096
|
-
control: (props) => <
|
|
1147
|
+
autosave: true, // not notes: a click opens it (autoFocus on the control)
|
|
1148
|
+
value: widget.summary,
|
|
1149
|
+
schema: widgetFormSchema.shape.summary,
|
|
1150
|
+
save: (summary) => editField.mutateAsync({ summary }),
|
|
1151
|
+
control: (props) => <WidgetSummaryEditor {...} />,
|
|
1097
1152
|
}),
|
|
1098
1153
|
```
|
|
1099
1154
|
|
|
@@ -1132,7 +1187,14 @@ const price = editInPlace({
|
|
|
1132
1187
|
(a count shows from 80% of it, in the destructive text tone once over).
|
|
1133
1188
|
Its keys: Ctrl/Cmd+K adds or edits a link (web and email addresses
|
|
1134
1189
|
only), Ctrl/Cmd+Shift+Enter ticks the task item the caret is in, and
|
|
1135
|
-
Markdown pasted as plain text arrives formatted.
|
|
1190
|
+
Markdown pasted as plain text arrives formatted. A web or email address
|
|
1191
|
+
typed (on a space or Enter) or pasted becomes a link, and one pasted
|
|
1192
|
+
over selected words links them; pasted lines stay lines, Word's and
|
|
1193
|
+
Notion's lists and to-dos arrive as lists and task items. An edit it
|
|
1194
|
+
can't save without rewriting text nobody touched is never saved: on a
|
|
1195
|
+
form, bind its `onProblem` to the field's error and refuse submit while
|
|
1196
|
+
it stands (add-an-entity.md, `widget-form.tsx`); with no `onProblem` it
|
|
1197
|
+
says so inside the field. Notion's block keys
|
|
1136
1198
|
work: Ctrl+Shift+1 to 3 for headings, +4 tasks, +5 bullets, +6 numbers,
|
|
1137
1199
|
+8 a code block, +0 back to text (Cmd+Option on a Mac), and
|
|
1138
1200
|
Ctrl/Cmd+Shift+S strikes through. Ctrl/Cmd+Enter stays the save, in a
|
|
@@ -1162,8 +1224,14 @@ const price = editInPlace({
|
|
|
1162
1224
|
button fills the window with the field (Esc leaves; nothing is lost or
|
|
1163
1225
|
saved by it), and on a touch screen or under 768px it carries Indent
|
|
1164
1226
|
and Outdent for list items, where there is no Tab. A field with only the
|
|
1165
|
-
floating toolbar (`inline` notes
|
|
1166
|
-
tools" strip over its corner while it has focus
|
|
1227
|
+
floating toolbar (`inline` notes, and notes on a form) gets the same
|
|
1228
|
+
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` (4.127). On a touch screen the
|
|
1230
|
+
toolbar is instead one row pinned to the top of the keyboard while the
|
|
1231
|
+
field has focus (Aa for every format, in the keyboard's place; the list
|
|
1232
|
+
buttons, Insert, Image (with `upload`) and Undo; with words selected, their formats first, and
|
|
1233
|
+
no floating bar under the system's Copy bar), and the checkbox, the
|
|
1234
|
+
table grips, the fold button and the callout icon take a 40px tap. A new checklist item
|
|
1167
1235
|
shows a "To-do" placeholder and the caret until you type. `[] ` (or
|
|
1168
1236
|
`[x] `) at a line's start makes it a checklist item, a bulleted item
|
|
1169
1237
|
too; Enter in one makes the next, its box unticked, and Enter in an
|
|
@@ -1173,7 +1241,8 @@ const price = editInPlace({
|
|
|
1173
1241
|
the floating one and the slash menu without the bar above (an `inline`
|
|
1174
1242
|
field's look). Images in the text (``) show; give it the
|
|
1175
1243
|
app's `upload` (the same one `ImageField` takes) and an image pasted,
|
|
1176
|
-
dropped or picked with
|
|
1244
|
+
dropped or picked with an Image button (the fixed toolbar's, the tools
|
|
1245
|
+
strip's, the phone's row) is uploaded and goes
|
|
1177
1246
|
in as ``, a placeholder showing meanwhile (never saved), a
|
|
1178
1247
|
refusal or failure in a toast. No `upload`, no file handling at all.
|
|
1179
1248
|
- **The save is the single-field save** (`useRecordUpdate` with
|
|
@@ -1207,6 +1276,7 @@ fields: [
|
|
|
1207
1276
|
{ label: 'Priority', edit: inPlace.select({ value: project.priority, options: PRIORITY_OPTIONS,
|
|
1208
1277
|
render: (priority, label) => <Badge variant={PRIORITY_BADGE[priority]}>{label}</Badge>,
|
|
1209
1278
|
save: (priority) => save({ priority }) }) },
|
|
1279
|
+
{ label: 'My Rating', edit: inPlace.rating({ value: project.rating, save: (rating) => save({ rating }) }) },
|
|
1210
1280
|
{ label: 'Category', edit: inPlace.reference({ value: project.categoryId, label: categoryName,
|
|
1211
1281
|
search: (text) => searchCategories(text), onCreate: (name) => openNewCategory(name),
|
|
1212
1282
|
save: (categoryId) => save({ categoryId }) }) },
|
|
@@ -1230,12 +1300,14 @@ fields: [
|
|
|
1230
1300
|
| `monthDay` | `Mar 14` (`format`, `locale`); a stored value that isn't a day, as written | `'MM-DD'`, no year; February 29 is a day; Clear is `null` | Clear when `required`, a day the month can't have ("February has 29 days") |
|
|
1231
1301
|
| `select` | the option's label, or its `render` (a badge) | the option's value; "Not set" is `null` | "Not set" isn't offered when `required` |
|
|
1232
1302
|
| `choice` | as `select` | as `select`, drawn as ChoiceButtons (two to four short options); pressing the picked one again is `null` | as `select` |
|
|
1303
|
+
| `rating` | `RatingScore` (`max`, `glyph`); always the stars (`RatingInput`), with no click to open | the star's number, at once on a click; an arrow's a pause after the last; pressing the set star again is `null` | clearing when `required` (the press does nothing) |
|
|
1233
1304
|
| `reference` | the record's `label` (the view's lookup by id) | the picked record's id | "Not set" isn't offered when `required` |
|
|
1234
1305
|
|
|
1235
1306
|
- **They save the way their kind does** (the table above): `text`,
|
|
1236
1307
|
`number`, `money` and a typed `date` on Enter or leaving them, a day
|
|
1237
1308
|
picked in the date's calendar, `monthDay`, `select`, `choice` and
|
|
1238
|
-
`reference` on the pick (a list opens with the field)
|
|
1309
|
+
`reference` on the pick (a list opens with the field), `rating` on a
|
|
1310
|
+
click of a star (it's always open: the stars are the value).
|
|
1239
1311
|
`required: true` types the save without `null`.
|
|
1240
1312
|
- **`reference` searches through the app.** The package knows no
|
|
1241
1313
|
endpoint: `search(text)` is the app's (its gateway's search by name,
|
|
@@ -2079,6 +2151,22 @@ const { filters, multiFilters, setFilter, setFilters, setMultiFilter, activeView
|
|
|
2079
2151
|
once the filters move off every view. Under 48rem they stay on one line
|
|
2080
2152
|
that scrolls sideways. Replaces a hand-written row of view buttons; a
|
|
2081
2153
|
Deleted view goes in ListHeader's ⋯ menu as Show Deleted instead.
|
|
2154
|
+
- **A view can carry a count** (4.127): `count` on the view you pass
|
|
2155
|
+
`DataTable`, shown after its label as "Needs a Look · 3" and read as
|
|
2156
|
+
"Needs a Look, 3". The app counts with its own query (the list's
|
|
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
|
|
2161
|
+
In), not All. Give the view the key from the first render, `undefined`
|
|
2162
|
+
while the query loads: a view with the key keeps room for a two-digit
|
|
2163
|
+
count, so no pill moves when it arrives, on a phone's scrolling row
|
|
2164
|
+
too.
|
|
2165
|
+
|
|
2166
|
+
```tsx
|
|
2167
|
+
const { data: needsLook } = useNewsSourcesQuery({ ...VIEWS.look.filters, pageSize: 1 })
|
|
2168
|
+
<DataTable views={{ ...VIEWS, look: { ...VIEWS.look, count: needsLook?.total } }} … />
|
|
2169
|
+
```
|
|
2082
2170
|
- **Views fill the filters** (4.105), so the bar always says why rows are
|
|
2083
2171
|
hidden:
|
|
2084
2172
|
- A view's `filters` and `multiFilters` are what the bar's controls
|