@tristan2828/ui-foundation 4.147.0 → 4.148.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/cell-patterns.md +99 -43
- package/dist/components/app/edit-in-place-scope.d.ts +5 -0
- package/dist/components/app/edit-in-place-scope.js +30 -0
- package/dist/components/app/editable-value.d.ts +3 -2
- package/dist/components/app/editable-value.js +6 -4
- package/dist/components/app/rich-text-editor.js +4 -2
- package/dist/components/app/rich-text-load.d.ts +11 -0
- package/dist/components/app/rich-text-load.js +16 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ than installing this by hand:
|
|
|
18
18
|
|
|
19
19
|
| Import | What |
|
|
20
20
|
|---|---|
|
|
21
|
-
| `@tristan2828/ui-foundation` | The composites and what goes with them: `AppShell`, `DataTable`, `EntityView` (with editing in place: `EditableValue`, `editInPlace`, `inPlace`), `EntityForm`, `FormDialog`, `RecordDialogRoute`, `Markdown`, `RichTextEditor
|
|
21
|
+
| `@tristan2828/ui-foundation` | The composites and what goes with them: `AppShell`, `DataTable`, `EntityView` (with editing in place: `EditableValue`, `editInPlace`, `inPlace`; `EditInPlaceScope` runs it on a page of the app's own), `EntityForm`, `FormDialog`, `RecordDialogRoute`, `Markdown`, `RichTextEditor` (and `preloadRichTextEditor`), `ErrorState`, `FoundationProviders`, `LoginRoute`, `RegisterRoute`; the hooks `useAuth`, `useTableUrlState`, `useRecordUpdate`; `createQueryClient`, `cn`; types `Page`, `AppError`, `QuerySpec`. The full list is the package's type declarations (`dist/index.d.ts`); what each part is for is in the app's `docs/foundation/` |
|
|
22
22
|
| `@tristan2828/ui-foundation/ui/<name>` | shadcn primitives: alert, badge, breadcrumb, button, calendar, card, checkbox, collapsible, combobox, dialog, dropdown-menu, empty, field, input, input-group, label, popover, progress, radio-group, select, separator, sheet, sidebar, skeleton, slider, sonner, spinner, switch, table, tabs, textarea, toggle, toggle-group, tooltip |
|
|
23
23
|
| `@tristan2828/ui-foundation/gateway` | `safeFetch`, `toAppError`, `networkError`, `proxyAuthError` — for an app's `src/api/gateway/` only |
|
|
24
24
|
| `@tristan2828/ui-foundation/mocks` | MSW: `authHandlers`, `environmentHandlers`, `clientErrorHandlers`, `pushHandlers`, `resetMockAuth`, `getMockCurrentUser`, `MOCK_USER`, `startMockWorker` (mock mode's boot), `exposeMswForE2E`, among others (`dist/mocks/index.d.ts`) |
|
|
@@ -3,48 +3,49 @@
|
|
|
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
|
|
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
|
-
- [
|
|
35
|
-
- [
|
|
36
|
-
- [
|
|
37
|
-
- [
|
|
38
|
-
- [
|
|
39
|
-
- [
|
|
40
|
-
- [
|
|
41
|
-
- [
|
|
42
|
-
- [
|
|
43
|
-
|
|
44
|
-
- [
|
|
45
|
-
|
|
46
|
-
- [
|
|
47
|
-
- [
|
|
6
|
+
- [The rules that apply to every cell](#the-rules-that-apply-to-every-cell) · lines 64–87
|
|
7
|
+
- [1. Plain text](#1-plain-text) · lines 89–138
|
|
8
|
+
- [2. Icon + label](#2-icon--label) · lines 140–163
|
|
9
|
+
- [3. Icon in a badge](#3-icon-in-a-badge) · lines 165–178
|
|
10
|
+
- [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines 180–256
|
|
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 205–256
|
|
12
|
+
- [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines 258–278
|
|
13
|
+
- [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 280–292
|
|
14
|
+
- [7. Link as an outline button](#7-link-as-an-outline-button) · lines 294–315
|
|
15
|
+
- [8. Date, relative](#8-date-relative) · lines 317–354
|
|
16
|
+
- [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 356–432
|
|
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 374–432
|
|
18
|
+
- [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 434–483
|
|
19
|
+
- [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 452–483
|
|
20
|
+
- [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 485–525
|
|
21
|
+
- [12. Boolean](#12-boolean) · lines 527–555
|
|
22
|
+
- [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 557–591
|
|
23
|
+
- [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 576–591
|
|
24
|
+
- [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 593–611
|
|
25
|
+
- [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 613–715
|
|
26
|
+
- [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 636–715
|
|
27
|
+
- [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 717–758
|
|
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–1627
|
|
30
|
+
- [Presets: one line per field](#presets-one-line-per-field) · lines 1227–1299
|
|
31
|
+
- [Several fields edited as one](#several-fields-edited-as-one) · lines 1301–1337
|
|
32
|
+
- [A link and its label](#a-link-and-its-label) · lines 1339–1363
|
|
33
|
+
- [A list of sub-items](#a-list-of-sub-items) · lines 1365–1498
|
|
34
|
+
- [On a page of the app's own: `EditInPlaceScope`](#on-a-page-of-the-apps-own-editinplacescope) · lines 1500–1544
|
|
35
|
+
- [In a table's rows](#in-a-tables-rows) · lines 1546–1620
|
|
36
|
+
- [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1622–1627
|
|
37
|
+
- [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1629–1695
|
|
38
|
+
- [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1697–1751
|
|
39
|
+
- [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1753–1835
|
|
40
|
+
- [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1837–1862
|
|
41
|
+
- [28. A list's rows: hover, lines, rows per page](#28-a-lists-rows-hover-lines-rows-per-page) · lines 1864–1897
|
|
42
|
+
- [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1899–1950
|
|
43
|
+
- [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1952–2026
|
|
44
|
+
- [Picking one on a form: `ColorField`](#picking-one-on-a-form-colorfield) · lines 1972–2026
|
|
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 2028–2240
|
|
46
|
+
- [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2189–2240
|
|
47
|
+
- [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2242–2276
|
|
48
|
+
- [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2278–2325
|
|
48
49
|
|
|
49
50
|
<!-- /index -->
|
|
50
51
|
|
|
@@ -840,6 +841,13 @@ header `StatusMark`), Price, Description (rich text edited where it's read,
|
|
|
840
841
|
`inline`) and Extra Categories, with the controls in `widget-fields.tsx`,
|
|
841
842
|
the same ones the form uses.
|
|
842
843
|
|
|
844
|
+
Something has to run the editing: one value open at a time, autosave,
|
|
845
|
+
the leave-page prompt. A record's view (`EntityView`) runs it for what's
|
|
846
|
+
on it, a table (`DataTable`) for its rows, and a page of the app's own
|
|
847
|
+
that is neither (a notes screen that is nothing but its text) wraps what
|
|
848
|
+
it edits in `EditInPlaceScope` ("On a page of the app's own" below).
|
|
849
|
+
`<EditableValue>` outside all three throws, naming them.
|
|
850
|
+
|
|
843
851
|
The rule behind every part of it: **nothing typed is ever lost.**
|
|
844
852
|
|
|
845
853
|
**No toast, but one.** An edit in place says what happened where it
|
|
@@ -1069,7 +1077,9 @@ to open, and it never closes. Ctrl/Cmd+Enter or Esc saves now and leaves
|
|
|
1069
1077
|
the caret where it is. It sits beside the one open value rather than
|
|
1070
1078
|
being it: opening another value leaves it alone. Don't give its control
|
|
1071
1079
|
`autoFocus`. The cost: at rest the page shows the editor, not the read
|
|
1072
|
-
view, and the editor loads on every visit
|
|
1080
|
+
view, and the editor loads on every visit (an app whose first screen is
|
|
1081
|
+
an editor starts that load as it starts: `preloadRichTextEditor()`, "On a
|
|
1082
|
+
page of the app's own" below). A click on a link in the
|
|
1073
1083
|
notes still opens it in a new tab; its words are edited from the
|
|
1074
1084
|
keyboard or by dragging over them, and Ctrl/Cmd+K edits its address. Use it where the notes are what the page is
|
|
1075
1085
|
for; elsewhere `autosave` alone keeps the read view at rest.
|
|
@@ -1487,6 +1497,52 @@ const files = editInPlace<Attachment>({
|
|
|
1487
1497
|
})
|
|
1488
1498
|
```
|
|
1489
1499
|
|
|
1500
|
+
### On a page of the app's own: `EditInPlaceScope`
|
|
1501
|
+
|
|
1502
|
+
A page that is neither a record's view nor a table, such as a notes app
|
|
1503
|
+
whose screen is nothing but the note, wraps what it edits in
|
|
1504
|
+
`<EditInPlaceScope>` and puts `<EditableValue>`s inside: the same rules
|
|
1505
|
+
as a view, the same "Saving…" and "Saved", refusals, Keep Mine or Show
|
|
1506
|
+
Saved, and leaving the page saves first. The page needs a data router
|
|
1507
|
+
(`createBrowserRouter`), as a view does: the leave-page prompt uses its
|
|
1508
|
+
blocker.
|
|
1509
|
+
|
|
1510
|
+
```tsx
|
|
1511
|
+
const body = editInPlace<string>({
|
|
1512
|
+
kind: 'long-text',
|
|
1513
|
+
inline: true,
|
|
1514
|
+
value: note.body,
|
|
1515
|
+
save: (body) => editField.mutateAsync({ body }),
|
|
1516
|
+
// The form's own control, spreading what it gets onto RichTextEditor
|
|
1517
|
+
// with inline={props.inline} toolbar="floating"
|
|
1518
|
+
control: (props) => <NoteBodyEditor … />,
|
|
1519
|
+
})
|
|
1520
|
+
|
|
1521
|
+
<EditInPlaceScope>
|
|
1522
|
+
<EditableValue label="Note" edit={body} />
|
|
1523
|
+
</EditInPlaceScope>
|
|
1524
|
+
```
|
|
1525
|
+
|
|
1526
|
+
- **One scope per page, around everything it edits**, not one per
|
|
1527
|
+
value. Each scope renders a leave guard, which takes the router's
|
|
1528
|
+
blocker, and a router holds one at a time. A page with an `EntityView`
|
|
1529
|
+
or a `DataTable` doesn't need one: they run their own.
|
|
1530
|
+
- **Several always-editable values in one scope** is what a notes app's
|
|
1531
|
+
tabs are: one pane per open note, all mounted, only the one in front
|
|
1532
|
+
shown (the others `hidden`), so each keeps its caret and undo. A
|
|
1533
|
+
hidden value still saves, and the one leave guard covers them all.
|
|
1534
|
+
- **A value that leaves the page mid-typing is still saved** (a tab
|
|
1535
|
+
closed, a pane unmounted): what was typed goes at once rather than
|
|
1536
|
+
after the pause.
|
|
1537
|
+
- **An app that opens on an editor** calls `preloadRichTextEditor()`
|
|
1538
|
+
as it starts (in `main.tsx`), so the editor's code is loading while
|
|
1539
|
+
the note is fetched, not after. It returns nothing, never throws, and
|
|
1540
|
+
is safe to call more than once; a failed load is the editor's to meet
|
|
1541
|
+
when one mounts.
|
|
1542
|
+
|
|
1543
|
+
The stories are `app/EditInPlaceScope` (one note, and two in one scope);
|
|
1544
|
+
`e2e/edit-in-place-scope.spec.ts` is the browser behaviour.
|
|
1545
|
+
|
|
1490
1546
|
### In a table's rows
|
|
1491
1547
|
|
|
1492
1548
|
For a **small entity edited in its table** (a name and a few fields,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Editing in place on a page of the app's own: one that isn't a record's
|
|
3
|
+
// view or a table. EntityView and DataTable each run it for what's inside
|
|
4
|
+
// them (one field open at a time, autosave, the leave-page prompt); a page
|
|
5
|
+
// built from other parts, such as a notes screen that is nothing but its
|
|
6
|
+
// text, wraps those parts in this and uses <EditableValue> inside, with
|
|
7
|
+
// the same rules (cell-patterns.md "Editable value").
|
|
8
|
+
//
|
|
9
|
+
// Everything inside one scope is one page's worth of editing: opening a
|
|
10
|
+
// value saves the open one first, and leaving the page (a link, Back,
|
|
11
|
+
// closing the tab, hiding it on a phone) saves what autosaves and asks
|
|
12
|
+
// about the rest.
|
|
13
|
+
//
|
|
14
|
+
// One scope per page, around everything editable on it, not one per
|
|
15
|
+
// value, and not on a page that has an EntityView or a DataTable (each
|
|
16
|
+
// runs its own). Every one of them renders a leave guard, which takes
|
|
17
|
+
// React Router's blocker, and the router holds one blocker at a time. A
|
|
18
|
+
// scope holds any number of always-editable values, such as a notes
|
|
19
|
+
// app's open tabs kept mounted with only the one in front shown.
|
|
20
|
+
import { useState, useSyncExternalStore } from 'react';
|
|
21
|
+
import { EditInPlaceContext } from './edit-in-place.js';
|
|
22
|
+
import { EditInPlaceStore } from './edit-in-place-store.js';
|
|
23
|
+
import { LeaveGuard } from './editable-value.js';
|
|
24
|
+
export function EditInPlaceScope({ children }) {
|
|
25
|
+
const [store] = useState(() => new EditInPlaceStore());
|
|
26
|
+
// The leave-page prompt only while a value is open (or one is always
|
|
27
|
+
// editable), so a page nobody's editing never blocks anything.
|
|
28
|
+
const editing = useSyncExternalStore(store.subscribe, () => store.editing, () => store.editing);
|
|
29
|
+
return (_jsxs(EditInPlaceContext.Provider, { value: store, children: [editing && _jsx(LeaveGuard, { store: store }), children] }));
|
|
30
|
+
}
|
|
@@ -42,8 +42,9 @@ export declare function EditableField({ label, edit, children, layout, look, cla
|
|
|
42
42
|
/**
|
|
43
43
|
* While a field holds something unsaved, leaving asks first: an in-app
|
|
44
44
|
* link or Back (React Router's blocker, so the app needs a data router),
|
|
45
|
-
* or closing the tab (`beforeunload`). Rendered by EntityView
|
|
46
|
-
* a field is being edited, so a view
|
|
45
|
+
* or closing the tab (`beforeunload`). Rendered by EntityView, DataTable
|
|
46
|
+
* and EditInPlaceScope only while a field is being edited, so a view
|
|
47
|
+
* nobody's editing never blocks anything.
|
|
47
48
|
*
|
|
48
49
|
* When everything unsaved autosaves, an in-app move saves it first and
|
|
49
50
|
* goes on once saved, asking only if that save fails. Closing the tab
|
|
@@ -2,7 +2,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
// A value on a record's view that turns into its form control where it's
|
|
3
3
|
// shown, and saves when you leave it (cell-patterns.md "Editable value").
|
|
4
4
|
// EntityView wraps every field, section and title marked `edit`; a header
|
|
5
|
-
// badge uses <EditableValue> itself
|
|
5
|
+
// badge uses <EditableValue> itself, and so does a page of the app's own
|
|
6
|
+
// inside an <EditInPlaceScope>. The rules are edit-in-place-store.ts.
|
|
6
7
|
//
|
|
7
8
|
// - Start: click the value (a link inside it still navigates), or tab to
|
|
8
9
|
// its edit button and press Enter. Hover and focus show it's editable.
|
|
@@ -156,7 +157,7 @@ function usePinnedStatus(field, enabled) {
|
|
|
156
157
|
function useStore() {
|
|
157
158
|
const store = useContext(EditInPlaceContext);
|
|
158
159
|
if (!store)
|
|
159
|
-
throw new Error('<EditableValue> works inside an <EntityView>, which
|
|
160
|
+
throw new Error('<EditableValue> works inside an <EntityView> or an <EditInPlaceScope>, which run editing in place.');
|
|
160
161
|
return store;
|
|
161
162
|
}
|
|
162
163
|
// Long text's "Keep Mine": both sides kept block by block (rebaseMarkdown).
|
|
@@ -458,8 +459,9 @@ const sameAsJson = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
|
458
459
|
/**
|
|
459
460
|
* While a field holds something unsaved, leaving asks first: an in-app
|
|
460
461
|
* link or Back (React Router's blocker, so the app needs a data router),
|
|
461
|
-
* or closing the tab (`beforeunload`). Rendered by EntityView
|
|
462
|
-
* a field is being edited, so a view
|
|
462
|
+
* or closing the tab (`beforeunload`). Rendered by EntityView, DataTable
|
|
463
|
+
* and EditInPlaceScope only while a field is being edited, so a view
|
|
464
|
+
* nobody's editing never blocks anything.
|
|
463
465
|
*
|
|
464
466
|
* When everything unsaved autosaves, an in-app move saves it first and
|
|
465
467
|
* goes on once saved, asking only if that save fails. Closing the tab
|
|
@@ -44,12 +44,14 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
44
44
|
// The editor (Milkdown) is loaded on first use, so a page that only reads
|
|
45
45
|
// Markdown never downloads it. Until it arrives the text shows as
|
|
46
46
|
// <Markdown> draws it, the field's size, so nothing moves when the editor
|
|
47
|
-
// takes its place; an empty one shows skeleton lines.
|
|
47
|
+
// takes its place; an empty one shows skeleton lines. An app that opens on
|
|
48
|
+
// an editor loads it ahead with `preloadRichTextEditor()`.
|
|
48
49
|
import { lazy, Suspense, useLayoutEffect, useRef, useState } from 'react';
|
|
49
50
|
import { cn } from 'cn';
|
|
50
51
|
import { Skeleton } from '../ui/skeleton.js';
|
|
51
52
|
import { Markdown } from './markdown.js';
|
|
52
|
-
|
|
53
|
+
import { loadRichTextEditor } from './rich-text-load.js';
|
|
54
|
+
const MilkdownEditor = lazy(loadRichTextEditor);
|
|
53
55
|
// When the editor opens again: each time `defaultValue` changes to
|
|
54
56
|
// Markdown it didn't report. Adjusted while rendering (React's "storing
|
|
55
57
|
// information from previous renders"), so the new text never shows a
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The editor's module, fetched once: later calls get the same one. */
|
|
2
|
+
export declare const loadRichTextEditor: () => Promise<typeof import("./milkdown-editor.js")>;
|
|
3
|
+
/**
|
|
4
|
+
* Starts loading the editor now, before one is on screen: an app whose
|
|
5
|
+
* first screen is an editor (a notes app that opens on a note) calls it as
|
|
6
|
+
* the app starts, so the editor is there when the note is, not a moment
|
|
7
|
+
* after it. Safe to call more than once, and anywhere: it never throws,
|
|
8
|
+
* and a failed load is swallowed here, so the page goes on; the editor
|
|
9
|
+
* meets the same failure when one mounts, as it would with no preload.
|
|
10
|
+
*/
|
|
11
|
+
export declare function preloadRichTextEditor(): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// The editor's own code (Milkdown), loaded apart from the page that shows
|
|
2
|
+
// it: RichTextEditor asks for it when it first mounts, and an app that
|
|
3
|
+
// opens on an editor asks ahead with `preloadRichTextEditor()`.
|
|
4
|
+
/** The editor's module, fetched once: later calls get the same one. */
|
|
5
|
+
export const loadRichTextEditor = () => import('./milkdown-editor.js');
|
|
6
|
+
/**
|
|
7
|
+
* Starts loading the editor now, before one is on screen: an app whose
|
|
8
|
+
* first screen is an editor (a notes app that opens on a note) calls it as
|
|
9
|
+
* the app starts, so the editor is there when the note is, not a moment
|
|
10
|
+
* after it. Safe to call more than once, and anywhere: it never throws,
|
|
11
|
+
* and a failed load is swallowed here, so the page goes on; the editor
|
|
12
|
+
* meets the same failure when one mounts, as it would with no preload.
|
|
13
|
+
*/
|
|
14
|
+
export function preloadRichTextEditor() {
|
|
15
|
+
void loadRichTextEditor().catch(() => { });
|
|
16
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -52,6 +52,7 @@ export { linkHost, linkHref, linkRule } from './lib/link-href.js';
|
|
|
52
52
|
export { TITLE_CASE_SMALL_WORDS, titleCase } from './lib/title-case.js';
|
|
53
53
|
export { DataEnvironmentBanner } from './components/app/data-environment-banner.js';
|
|
54
54
|
export { EditableValue, type EditableValueProps } from './components/app/editable-value.js';
|
|
55
|
+
export { EditInPlaceScope, type EditInPlaceScopeProps } from './components/app/edit-in-place-scope.js';
|
|
55
56
|
export { editRowClass, onEditRowClick, SAVED_FOR_MS } from './components/app/edit-row.js';
|
|
56
57
|
export { ErrorState } from './components/app/error-state.js';
|
|
57
58
|
export { InlineCreate, type InlineCreateProps } from './components/app/inline-create.js';
|
|
@@ -71,6 +72,7 @@ export { MultiReference } from './components/app/multi-reference.js';
|
|
|
71
72
|
export { ListEditor } from './components/app/list-editor.js';
|
|
72
73
|
export { PasswordInput } from './components/app/password-input.js';
|
|
73
74
|
export { RichTextEditor, type RichTextEditorProps } from './components/app/rich-text-editor.js';
|
|
75
|
+
export { preloadRichTextEditor } from './components/app/rich-text-load.js';
|
|
74
76
|
export { flushPendingEdits, hasPendingEdits } from './lib/pending-edits.js';
|
|
75
77
|
export { RouteErrorBoundary } from './components/app/route-error-boundary.js';
|
|
76
78
|
export { PillFilter, type PillFilterOption, type PillFilterProps } from './components/app/pill-filter.js';
|
package/dist/index.js
CHANGED
|
@@ -63,6 +63,7 @@ export { linkHost, linkHref, linkRule } from './lib/link-href.js';
|
|
|
63
63
|
export { TITLE_CASE_SMALL_WORDS, titleCase } from './lib/title-case.js';
|
|
64
64
|
export { DataEnvironmentBanner } from './components/app/data-environment-banner.js';
|
|
65
65
|
export { EditableValue } from './components/app/editable-value.js';
|
|
66
|
+
export { EditInPlaceScope } from './components/app/edit-in-place-scope.js';
|
|
66
67
|
export { editRowClass, onEditRowClick, SAVED_FOR_MS } from './components/app/edit-row.js';
|
|
67
68
|
export { ErrorState } from './components/app/error-state.js';
|
|
68
69
|
export { InlineCreate } from './components/app/inline-create.js';
|
|
@@ -80,6 +81,7 @@ export { MultiReference } from './components/app/multi-reference.js';
|
|
|
80
81
|
export { ListEditor } from './components/app/list-editor.js';
|
|
81
82
|
export { PasswordInput } from './components/app/password-input.js';
|
|
82
83
|
export { RichTextEditor } from './components/app/rich-text-editor.js';
|
|
84
|
+
export { preloadRichTextEditor } from './components/app/rich-text-load.js';
|
|
83
85
|
// Typing a RichTextEditor holds back until a pause, reported now: call it
|
|
84
86
|
// before reading a rich-text field's value to save it in your own form.
|
|
85
87
|
export { flushPendingEdits, hasPendingEdits } from './lib/pending-edits.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.148.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": {
|