@tristan2828/ui-foundation 4.152.0 → 4.153.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.
|
@@ -26,26 +26,26 @@
|
|
|
26
26
|
- [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 636–715
|
|
27
27
|
- [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 717–758
|
|
28
28
|
- [17. Quick action on the view](#17-quick-action-on-the-view) · lines 760–832
|
|
29
|
-
- [18. Editable value](#18-editable-value) · lines 834–
|
|
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
|
-
- [On a page of the app's own: `EditInPlaceScope`](#on-a-page-of-the-apps-own-editinplacescope) · lines
|
|
35
|
-
- [In a table's rows](#in-a-tables-rows) · lines
|
|
36
|
-
- [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines
|
|
37
|
-
- [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines
|
|
38
|
-
- [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines
|
|
39
|
-
- [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines
|
|
40
|
-
- [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines
|
|
41
|
-
- [28. A list's rows: hover, lines, rows per page](#28-a-lists-rows-hover-lines-rows-per-page) · lines
|
|
42
|
-
- [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines
|
|
43
|
-
- [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines
|
|
44
|
-
- [Picking one on a form: `ColorField`](#picking-one-on-a-form-colorfield) · lines
|
|
45
|
-
- [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
|
|
46
|
-
- [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines
|
|
47
|
-
- [26. A record's related list, capped](#26-a-records-related-list-capped) · lines
|
|
48
|
-
- [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines
|
|
29
|
+
- [18. Editable value](#18-editable-value) · lines 834–1667
|
|
30
|
+
- [Presets: one line per field](#presets-one-line-per-field) · lines 1237–1309
|
|
31
|
+
- [Several fields edited as one](#several-fields-edited-as-one) · lines 1311–1347
|
|
32
|
+
- [A link and its label](#a-link-and-its-label) · lines 1349–1373
|
|
33
|
+
- [A list of sub-items](#a-list-of-sub-items) · lines 1375–1508
|
|
34
|
+
- [On a page of the app's own: `EditInPlaceScope`](#on-a-page-of-the-apps-own-editinplacescope) · lines 1510–1584
|
|
35
|
+
- [In a table's rows](#in-a-tables-rows) · lines 1586–1660
|
|
36
|
+
- [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1662–1667
|
|
37
|
+
- [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1669–1735
|
|
38
|
+
- [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1737–1791
|
|
39
|
+
- [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1793–1875
|
|
40
|
+
- [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1877–1902
|
|
41
|
+
- [28. A list's rows: hover, lines, rows per page](#28-a-lists-rows-hover-lines-rows-per-page) · lines 1904–1937
|
|
42
|
+
- [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1939–1990
|
|
43
|
+
- [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1992–2066
|
|
44
|
+
- [Picking one on a form: `ColorField`](#picking-one-on-a-form-colorfield) · lines 2012–2066
|
|
45
|
+
- [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 2068–2280
|
|
46
|
+
- [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2229–2280
|
|
47
|
+
- [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2282–2316
|
|
48
|
+
- [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2318–2365
|
|
49
49
|
|
|
50
50
|
<!-- /index -->
|
|
51
51
|
|
|
@@ -1027,8 +1027,11 @@ nobody has to click away to save notes. Opt in per field:
|
|
|
1027
1027
|
the next save waits for the one in flight and sends whatever the text
|
|
1028
1028
|
is by then, so saves never cross and the latest always wins.
|
|
1029
1029
|
- Under the text, a quiet line in the muted caption tone
|
|
1030
|
-
(`role="status"
|
|
1031
|
-
"Saved" with a check once nothing typed is waiting.
|
|
1030
|
+
(`role="status"`, named "Save Status"): "Saving…" with a spinner while a save is in flight,
|
|
1031
|
+
"Saved" with a check once nothing typed is waiting. An editor with
|
|
1032
|
+
`upload` has a live region of its own beside it, named "Uploads", so a
|
|
1033
|
+
test finds the save line by its name:
|
|
1034
|
+
`field.getByRole('status', { name: 'Save Status' })`. **On a note longer
|
|
1032
1035
|
than the screen the line is pinned to the screen's bottom edge** while
|
|
1033
1036
|
the note runs past it, so the save's state and a refusal are never off
|
|
1034
1037
|
screen.
|
|
@@ -1219,7 +1222,8 @@ const price = editInPlace({
|
|
|
1219
1222
|
app's `upload` (the same one `ImageField` takes) and an image pasted,
|
|
1220
1223
|
dropped or picked with an Image button (the fixed toolbar's, the tools
|
|
1221
1224
|
strip's, the phone's row) is uploaded and goes
|
|
1222
|
-
in as ``, a placeholder showing meanwhile (never saved
|
|
1225
|
+
in as ``, a placeholder showing meanwhile (never saved, and
|
|
1226
|
+
read out from a live region named "Uploads"), a
|
|
1223
1227
|
refusal or failure in a toast. No `upload`, no file handling at all.
|
|
1224
1228
|
- **The save is the single-field save** (`useRecordUpdate` with
|
|
1225
1229
|
`optimistic: false, toastOnError: false`, the entity's
|
|
@@ -1560,8 +1564,10 @@ const body = editInPlace<string>({
|
|
|
1560
1564
|
closed, a pane unmounted): what was typed goes at once rather than
|
|
1561
1565
|
after the pause, and a value whose save had been refused tries once
|
|
1562
1566
|
more. If that save fails, nothing on screen holds the text any more,
|
|
1563
|
-
so a toast says "
|
|
1564
|
-
|
|
1567
|
+
so a toast says "*Label* wasn't saved and is no longer on the page"
|
|
1568
|
+
(not a refusal's "Couldn't save *label*", which can still be retried
|
|
1569
|
+
where it is) with the reason, and stays until dismissed, with
|
|
1570
|
+
**Copy Text** to put what was typed on the clipboard.
|
|
1565
1571
|
`onLostEdit`, given `{ label, value, reason }` (`LostEdit`), is for the
|
|
1566
1572
|
app to do more, such as reopen the note's tab. A record's view and a
|
|
1567
1573
|
table toast the same way.
|
|
@@ -35,6 +35,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
35
35
|
// line under it, and "Saved" goes after two seconds, as at rest.
|
|
36
36
|
// - Saved: once a save lands, "✓ Saved" shows beside the value
|
|
37
37
|
// for two seconds (`role="status"`).
|
|
38
|
+
// - Each of its live regions ("Saving…", "Saved") is named "Save Status",
|
|
39
|
+
// so a test finds it by name beside the editor's own ("Uploads").
|
|
38
40
|
// - `layout="inline"`: the pencil takes no room until hover or
|
|
39
41
|
// focus, so nothing gaps before what follows the value on its line.
|
|
40
42
|
// `keepPencilRoom` (and every value inside a KeyStats) keeps it
|
|
@@ -60,6 +62,8 @@ import { EditInPlaceContext } from './edit-in-place.js';
|
|
|
60
62
|
import { SAVED_FOR_MS } from './edit-row.js';
|
|
61
63
|
import { escapePassedThrough } from './escape-passthrough.js';
|
|
62
64
|
import { KeepPencilRoomContext } from './keep-pencil-room.js';
|
|
65
|
+
// The save line's accessible name, on every live region it uses.
|
|
66
|
+
const SAVE_STATUS = 'Save Status';
|
|
63
67
|
// What a click on the shown value must leave alone: links navigate,
|
|
64
68
|
// buttons and boxes do their own thing (a list item's done box ticks it).
|
|
65
69
|
const INTERACTIVE = 'a[href], button, input, select, textarea, label, [role="button"], [role="link"], [role="checkbox"], [role="switch"]';
|
|
@@ -439,7 +443,7 @@ export function EditableField({ label, edit, children, layout = 'block', look =
|
|
|
439
443
|
// grow with --spacing, and a fixed 0.75rem left the record's
|
|
440
444
|
// title 3-5px short of its one line (4.145).
|
|
441
445
|
layout === 'block' ? 'flex w-full' : cn('inline-flex align-top', row ? 'max-w-full' : 'max-w-[calc(100%+var(--spacing)*3)]'), className), children: [_jsxs("span", { className: cn('min-w-0 flex-1', !row &&
|
|
442
|
-
'group-hover/editable:[&_.text-muted-foreground]:text-foreground group-has-[[data-edit]:focus-visible]/editable:[&_.text-muted-foreground]:text-foreground'), children: [children !== undefined ? children : edit.shown, _jsx("span", { role: "status", "data-slot": "editable-value-saved", className: "ml-2 inline-flex items-center gap-1 align-baseline type-caption text-success-text empty:hidden", children: justSaved && (_jsxs(_Fragment, { children: [_jsx(CheckIcon, { "aria-hidden": "true", className: "size-3.5" }), "Saved"] })) })] }), _jsx(InlinePencilRoom, { inline: inlineValue, children: _jsx(Button, { ref: editButton, "data-edit": "", type: "button", variant: "ghost", size: "icon-xs", "aria-label": `Edit ${label}`, onClick: start, className: cn('shrink-0 text-muted-foreground opacity-0 focus-visible:opacity-100 pointer-coarse:opacity-100', row ? 'group-hover/edit-row:opacity-100 hover:bg-transparent max-md:opacity-100' : 'group-hover/editable:opacity-100', inlineValue && 'absolute top-0 left-1 z-10'), children: row ? (_jsxs(_Fragment, { children: [_jsx(PencilIcon, { className: "max-md:hidden pointer-coarse:hidden" }), _jsx(ChevronRightIcon, { className: "hidden max-md:block pointer-coarse:block" })] })) : (_jsx(PencilIcon, {})) }) })] }));
|
|
446
|
+
'group-hover/editable:[&_.text-muted-foreground]:text-foreground group-has-[[data-edit]:focus-visible]/editable:[&_.text-muted-foreground]:text-foreground'), children: [children !== undefined ? children : edit.shown, _jsx("span", { role: "status", "aria-label": SAVE_STATUS, "data-slot": "editable-value-saved", className: "ml-2 inline-flex items-center gap-1 align-baseline type-caption text-success-text empty:hidden", children: justSaved && (_jsxs(_Fragment, { children: [_jsx(CheckIcon, { "aria-hidden": "true", className: "size-3.5" }), "Saved"] })) })] }), _jsx(InlinePencilRoom, { inline: inlineValue, children: _jsx(Button, { ref: editButton, "data-edit": "", type: "button", variant: "ghost", size: "icon-xs", "aria-label": `Edit ${label}`, onClick: start, className: cn('shrink-0 text-muted-foreground opacity-0 focus-visible:opacity-100 pointer-coarse:opacity-100', row ? 'group-hover/edit-row:opacity-100 hover:bg-transparent max-md:opacity-100' : 'group-hover/editable:opacity-100', inlineValue && 'absolute top-0 left-1 z-10'), children: row ? (_jsxs(_Fragment, { children: [_jsx(PencilIcon, { className: "max-md:hidden pointer-coarse:hidden" }), _jsx(ChevronRightIcon, { className: "hidden max-md:block pointer-coarse:block" })] })) : (_jsx(PencilIcon, {})) }) })] }));
|
|
443
447
|
}
|
|
444
448
|
// Always editable, before the store has it (the first render): the saved value.
|
|
445
449
|
const open = state.status === 'closed' ? { status: 'open', draft: edit.value, error: null, autosave: undefined, revision: 0 } : state;
|
|
@@ -459,9 +463,9 @@ export function EditableField({ label, edit, children, layout = 'block', look =
|
|
|
459
463
|
// it, so the save's state and a refusal stay in view.
|
|
460
464
|
style: pin ? { left: pin.left, maxWidth: pin.width } : undefined, className: cn('type-body',
|
|
461
465
|
// Beside the value, a refusal takes the line under it.
|
|
462
|
-
beside && (lineError ? 'basis-full' : 'flex items-center'), pin && 'fixed bottom-3 z-30 w-fit rounded-md border border-border bg-popover px-2 py-1 text-popover-foreground shadow-md'), children: autosave ? (_jsxs(_Fragment, { children: [lineError && _jsx(FieldError, { className: "type-caption", children: lineError }), conflictActions, _jsx("span", { role: "status", className: "inline-flex items-center gap-1.5 type-caption text-muted-foreground", children: autosaving ? (_jsxs(_Fragment, { children: [_jsx(Spinner, { "aria-hidden": "true", className: "size-3.5" }), _jsx("span", { className: cn(beside && 'sr-only'), children: "Saving\u2026" })] })) : (open.autosave === 'saved' &&
|
|
466
|
+
beside && (lineError ? 'basis-full' : 'flex items-center'), pin && 'fixed bottom-3 z-30 w-fit rounded-md border border-border bg-popover px-2 py-1 text-popover-foreground shadow-md'), children: autosave ? (_jsxs(_Fragment, { children: [lineError && _jsx(FieldError, { className: "type-caption", children: lineError }), conflictActions, _jsx("span", { role: "status", "aria-label": SAVE_STATUS, className: "inline-flex items-center gap-1.5 type-caption text-muted-foreground", children: autosaving ? (_jsxs(_Fragment, { children: [_jsx(Spinner, { "aria-hidden": "true", className: "size-3.5" }), _jsx("span", { className: cn(beside && 'sr-only'), children: "Saving\u2026" })] })) : (open.autosave === 'saved' &&
|
|
463
467
|
!open.error &&
|
|
464
|
-
!(beside && savedGone) && (_jsxs(_Fragment, { children: [_jsx(CheckIcon, { "aria-hidden": "true", className: cn('size-3.5', beside && 'text-success-text') }), _jsx("span", { className: cn(beside && 'sr-only'), children: "Saved" })] }))) })] })) : saving ? (_jsxs("span", { role: "status", className: "inline-flex items-center gap-1.5 type-caption text-muted-foreground", children: [_jsx(Spinner, { "aria-hidden": "true", className: "size-3.5" }), "Saving\u2026"] })) : (_jsxs(_Fragment, { children: [lineError && _jsx(FieldError, { className: "type-caption", children: lineError }), conflictActions] })) })] }), _jsx(DiscardChangesDialog, { open: askingDiscard, "data-leave-guard": "", onKeepEditing: () => setAskingDiscard(false), onDiscard: () => {
|
|
468
|
+
!(beside && savedGone) && (_jsxs(_Fragment, { children: [_jsx(CheckIcon, { "aria-hidden": "true", className: cn('size-3.5', beside && 'text-success-text') }), _jsx("span", { className: cn(beside && 'sr-only'), children: "Saved" })] }))) })] })) : saving ? (_jsxs("span", { role: "status", "aria-label": SAVE_STATUS, className: "inline-flex items-center gap-1.5 type-caption text-muted-foreground", children: [_jsx(Spinner, { "aria-hidden": "true", className: "size-3.5" }), "Saving\u2026"] })) : (_jsxs(_Fragment, { children: [lineError && _jsx(FieldError, { className: "type-caption", children: lineError }), conflictActions] })) })] }), _jsx(DiscardChangesDialog, { open: askingDiscard, "data-leave-guard": "", onKeepEditing: () => setAskingDiscard(false), onDiscard: () => {
|
|
465
469
|
setAskingDiscard(false);
|
|
466
470
|
refocus.current = true;
|
|
467
471
|
cancel();
|
|
@@ -9,8 +9,10 @@ import { toast } from 'sonner';
|
|
|
9
9
|
*/
|
|
10
10
|
export function toastLostEdit({ label, value, reason }) {
|
|
11
11
|
const text = typeof value === 'string' && value.trim() !== '' ? value : null;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
// Its own title, not a refusal's "Couldn't save <label>": that one is
|
|
13
|
+
// still on the page to retry, this one only Copy Text can get back.
|
|
14
|
+
const id = toast.error(`${label} wasn't saved and is no longer on the page`, {
|
|
15
|
+
description: text ? `${reason} Copy what you typed to keep it.` : reason,
|
|
14
16
|
duration: Infinity,
|
|
15
17
|
action: text
|
|
16
18
|
? {
|
|
@@ -55,6 +55,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
55
55
|
// - Images show at most the field's width. With `upload`, an image pasted,
|
|
56
56
|
// dropped or picked is uploaded through it and goes in as ``
|
|
57
57
|
// (rich-text-image-upload.ts); a refusal or a failed upload is a toast.
|
|
58
|
+
// What's uploading is read from a live region named "Uploads"
|
|
59
|
+
// (`role="status"`, empty while nothing uploads).
|
|
58
60
|
// - `foldKey`: the text folds by its toggle headings, as <Markdown> does
|
|
59
61
|
// (rich-text-fold.ts), remembered on this device and shared with
|
|
60
62
|
// NotesOutline; the document never changes.
|
|
@@ -1333,7 +1335,7 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
1333
1335
|
const next = event.relatedTarget;
|
|
1334
1336
|
if (!editorView.dom.contains(next) && !inFloating(next))
|
|
1335
1337
|
setFocused(false);
|
|
1336
|
-
} }))] }), upload && (_jsx("p", { role: "status", className: "sr-only", children: uploading > 0 ? `Uploading ${uploading === 1 ? 'an image' : `${uploading} images`}…` : '' })), showCount && (_jsx("p", { id: counterId, "data-slot": "rich-text-editor-count", className: cn('text-right type-caption tabular-nums', length > maxLength ? 'text-destructive-text' : 'text-muted-foreground'), children: length > maxLength
|
|
1338
|
+
} }))] }), upload && (_jsx("p", { role: "status", "aria-label": "Uploads", className: "sr-only", children: uploading > 0 ? `Uploading ${uploading === 1 ? 'an image' : `${uploading} images`}…` : '' })), showCount && (_jsx("p", { id: counterId, "data-slot": "rich-text-editor-count", className: cn('text-right type-caption tabular-nums', length > maxLength ? 'text-destructive-text' : 'text-muted-foreground'), children: length > maxLength
|
|
1337
1339
|
? `${(length - maxLength).toLocaleString()} characters over the limit of ${maxLength.toLocaleString()}`
|
|
1338
1340
|
: `${length.toLocaleString()} of ${maxLength.toLocaleString()} characters` })), inRouter && _jsx(NavigateBridge, { targetRef: navigateRef }), _jsx(Popover, { open: pageBox !== null, onOpenChange: (open) => !open && !pageBusy && closePage(), children: pageBox && _jsx(PageForm, { box: pageBox, busy: pageBusy, onCreate: createPage }) }), _jsx(Popover, { open: linkBox !== null, onOpenChange: (open) => !open && closeLink(), children: linkBox && (_jsx(LinkForm, { box: linkBox, onApply: (href) => {
|
|
1339
1341
|
const editor = editorRef.current;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.153.0",
|
|
4
4
|
"description": "Shared UI foundation for contract-first, database-backed React apps: shadcn primitives, DataTable/EntityForm composites, auth, the gateway error seam, design tokens, lint rules and the AI playbook.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|