@tristan2828/ui-foundation 4.136.0 → 4.137.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 +7 -6
- package/bin/ui-foundation.mjs +1 -1
- package/conventions/agents/spec-tester.md +3 -3
- package/conventions/docs/add-an-entity.md +722 -714
- package/conventions/docs/cell-patterns.md +206 -378
- package/conventions/docs/column-options.md +6 -12
- package/conventions/docs/design-language.md +293 -515
- package/conventions/docs/entity-plan-template.md +9 -7
- package/conventions/docs/reminders.md +12 -17
- package/conventions/docs/timed-screens.md +17 -20
- package/dist/components/app/action-error.js +1 -1
- package/dist/components/app/action-hint.js +1 -1
- package/dist/components/app/app-shell-bottom-bar.js +4 -4
- package/dist/components/app/app-shell-nav.d.ts +1 -1
- package/dist/components/app/app-shell-nav.js +1 -1
- package/dist/components/app/app-shell.d.ts +1 -1
- package/dist/components/app/app-shell.js +9 -9
- package/dist/components/app/board.d.ts +13 -13
- package/dist/components/app/board.js +3 -3
- package/dist/components/app/choice-buttons.d.ts +1 -1
- package/dist/components/app/data-table-tools.d.ts +3 -3
- package/dist/components/app/data-table.d.ts +11 -13
- package/dist/components/app/data-table.js +5 -5
- package/dist/components/app/date-field.js +1 -1
- package/dist/components/app/delete-action.d.ts +1 -1
- package/dist/components/app/delete-action.js +4 -4
- package/dist/components/app/edit-caret.js +1 -1
- package/dist/components/app/edit-in-place-presets.d.ts +4 -4
- package/dist/components/app/edit-in-place-store.d.ts +3 -3
- package/dist/components/app/edit-in-place-store.js +7 -7
- package/dist/components/app/editable-list.js +2 -3
- package/dist/components/app/editable-value.d.ts +2 -2
- package/dist/components/app/editable-value.js +20 -20
- package/dist/components/app/entity-form.js +2 -2
- package/dist/components/app/entity-view-facts.d.ts +12 -12
- package/dist/components/app/entity-view-facts.js +1 -1
- package/dist/components/app/entity-view.d.ts +16 -16
- package/dist/components/app/entity-view.js +28 -33
- package/dist/components/app/equal-items.js +4 -4
- package/dist/components/app/fact-extras.js +5 -5
- package/dist/components/app/field-rows.js +5 -5
- package/dist/components/app/fill-in-queue.js +2 -3
- package/dist/components/app/filter-bar.d.ts +1 -1
- package/dist/components/app/filter-date.js +1 -1
- package/dist/components/app/filter-name.js +1 -1
- package/dist/components/app/form-dialog.js +2 -2
- package/dist/components/app/form-leave-guard.js +2 -2
- package/dist/components/app/form-section.js +1 -1
- package/dist/components/app/icon-action.d.ts +1 -1
- package/dist/components/app/icon-action.js +2 -2
- package/dist/components/app/image-field.js +0 -1
- package/dist/components/app/keep-pencil-room.js +1 -1
- package/dist/components/app/key-stats.d.ts +3 -3
- package/dist/components/app/line-chart.d.ts +1 -1
- package/dist/components/app/line-chart.js +3 -3
- package/dist/components/app/list-editor-rows.js +1 -1
- package/dist/components/app/list-editor.js +1 -1
- package/dist/components/app/list-header.d.ts +6 -6
- package/dist/components/app/list-header.js +8 -8
- package/dist/components/app/markdown.js +30 -37
- package/dist/components/app/milkdown-editor.js +37 -62
- package/dist/components/app/module-card.js +6 -7
- package/dist/components/app/month-calendar.d.ts +46 -0
- package/dist/components/app/month-calendar.js +160 -0
- package/dist/components/app/month-day-field.js +0 -1
- package/dist/components/app/multi-choice.d.ts +1 -1
- package/dist/components/app/multi-choice.js +3 -3
- package/dist/components/app/multi-line-chart.js +1 -1
- package/dist/components/app/multi-pick.js +9 -10
- package/dist/components/app/multi-reference.js +2 -2
- package/dist/components/app/notes-outline.js +0 -1
- package/dist/components/app/notify.js +2 -2
- package/dist/components/app/offline-notice.js +1 -1
- package/dist/components/app/option-icon.js +1 -1
- package/dist/components/app/option-select.d.ts +1 -1
- package/dist/components/app/overview-page.d.ts +2 -2
- package/dist/components/app/overview-page.js +1 -1
- package/dist/components/app/page-trail-context.js +1 -1
- package/dist/components/app/pill-filter.d.ts +2 -2
- package/dist/components/app/prose-look.js +1 -1
- package/dist/components/app/rating-input.js +1 -1
- package/dist/components/app/rating-score.js +1 -1
- package/dist/components/app/record-dialog.js +25 -40
- package/dist/components/app/recurrence-field.js +6 -6
- package/dist/components/app/reference-combobox.js +1 -2
- package/dist/components/app/rich-text-box-anchor.js +0 -1
- package/dist/components/app/rich-text-edges.js +2 -2
- package/dist/components/app/rich-text-editor.d.ts +2 -3
- package/dist/components/app/rich-text-editor.js +19 -32
- package/dist/components/app/rich-text-empty-paragraph.d.ts +6 -7
- package/dist/components/app/rich-text-empty-paragraph.js +6 -7
- package/dist/components/app/rich-text-floating-toolbar.js +0 -1
- package/dist/components/app/rich-text-formats.js +2 -2
- package/dist/components/app/rich-text-input-rules.js +1 -2
- package/dist/components/app/rich-text-keyboard-bar.js +6 -7
- package/dist/components/app/rich-text-node-views.js +1 -2
- package/dist/components/app/rich-text-shortcuts.js +8 -8
- package/dist/components/app/rich-text-slash-menu.js +22 -12
- package/dist/components/app/rich-text-slash.d.ts +2 -2
- package/dist/components/app/rich-text-slash.js +2 -2
- package/dist/components/app/rich-text-table-grips.d.ts +1 -1
- package/dist/components/app/rich-text-table-grips.js +1 -2
- package/dist/components/app/rich-text-tasks.d.ts +1 -1
- package/dist/components/app/rich-text-tasks.js +1 -1
- package/dist/components/app/rich-text-touch.js +1 -1
- package/dist/components/app/search-palette.js +1 -2
- package/dist/components/app/secondary-filters.js +2 -3
- package/dist/components/app/session-view.js +1 -1
- package/dist/components/app/stacked-area-chart.js +1 -1
- package/dist/components/app/step-track.d.ts +1 -1
- package/dist/components/app/step-track.js +3 -3
- package/dist/components/app/widget-card.js +26 -30
- package/dist/components/app/widget-layout-sheet.js +1 -1
- package/dist/components/ui/calendar.js +2 -2
- package/dist/components/ui/combobox.d.ts +1 -1
- package/dist/components/ui/combobox.js +2 -2
- package/dist/components/ui/field.d.ts +1 -1
- package/dist/components/ui/field.js +6 -6
- package/dist/components/ui/skeleton.js +1 -1
- package/dist/components/ui/sonner.js +1 -1
- package/dist/components/ui/tabs.js +1 -1
- package/dist/error-reporting/reporter.d.ts +1 -1
- package/dist/error-reporting/reporter.js +1 -1
- package/dist/hooks/table-url-changes.d.ts +2 -2
- package/dist/hooks/table-url-changes.js +5 -6
- package/dist/hooks/use-action.js +1 -1
- package/dist/hooks/use-record-update.js +1 -1
- package/dist/hooks/use-table-url-state.d.ts +1 -1
- package/dist/hooks/use-table-url-state.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -2
- package/dist/lib/audio-cues.js +2 -2
- package/dist/lib/connection.js +1 -1
- package/dist/lib/date-filter.js +1 -1
- package/dist/lib/entity-view-tab.js +1 -1
- package/dist/lib/field-rows.js +2 -2
- package/dist/lib/form-errors.d.ts +1 -1
- package/dist/lib/form-errors.js +1 -1
- package/dist/lib/keep-audio-alive.js +1 -1
- package/dist/lib/line-chart-layout.js +3 -3
- package/dist/lib/markdown-inline.js +0 -2
- package/dist/lib/markdown-merge.js +2 -2
- package/dist/lib/markdown-table-widths.js +1 -1
- package/dist/lib/markdown-table.js +1 -2
- package/dist/lib/markdown-toggle.js +1 -1
- package/dist/lib/page-leaving.js +1 -1
- package/dist/lib/recurrence-format.d.ts +2 -2
- package/dist/lib/recurrence-format.js +1 -1
- package/dist/lib/recurrence-phrase.d.ts +1 -1
- package/dist/lib/recurrence-phrase.js +2 -2
- package/dist/lib/recurrence.d.ts +1 -1
- package/dist/lib/recurrence.js +2 -2
- package/dist/lib/stale-chunk-reload.js +1 -1
- package/dist/lib/status-kinds.d.ts +1 -1
- package/dist/lib/status-kinds.js +2 -2
- package/dist/mocks/start-worker.js +2 -2
- package/dist/routes/login.js +1 -1
- package/dist/testing/index.d.ts +7 -4
- package/dist/testing/index.js +10 -13
- package/package.json +1 -1
- package/styles/index.css +3 -3
- package/styles/theme.css +14 -20
- package/vite/pwa.js +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ReactElement, type ReactNode } from 'react';
|
|
2
2
|
export type DeleteKind = 'soft' | 'hard';
|
|
3
|
-
/** The one field a confirm can ask
|
|
3
|
+
/** The one field a confirm can ask: an optional reason, in a textarea. */
|
|
4
4
|
export type DeleteReason = {
|
|
5
5
|
/** The field's label: "Why" unless set ("Why remove it?"). */
|
|
6
6
|
label?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// The one delete (
|
|
2
|
+
// The one delete (the dialogs and feedback standard D1): a record's
|
|
3
3
|
// Delete in its header and a row's delete in a table both use it.
|
|
4
4
|
//
|
|
5
5
|
// - The confirm asks "Delete <name>?" and says what happens, by `kind`:
|
|
@@ -14,14 +14,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
14
14
|
// - `verb` covers the other ways something leaves a list: `verb="Retire"`
|
|
15
15
|
// asks "Retire <name>?" on a "Retire" button and says "Retired <name>".
|
|
16
16
|
//
|
|
17
|
-
// - `reason`
|
|
17
|
+
// - `reason` puts one field between the sentence and the buttons, a
|
|
18
18
|
// "Why" box, optional: what's typed (trimmed, '' for nothing) is
|
|
19
19
|
// `onDelete`'s argument, and Try again sends it again. While something's
|
|
20
20
|
// typed, closing asks "Discard your changes?" first (the dialog
|
|
21
21
|
// standard's `dirty`). Width, words and the buttons stay as they are.
|
|
22
22
|
//
|
|
23
|
-
// The trigger is an icon (IconAction's Trash2, named "Delete <name>"
|
|
24
|
-
//
|
|
23
|
+
// The trigger is an icon (IconAction's Trash2, named "Delete <name>", its
|
|
24
|
+
// tooltip "Delete") unless `trigger` says
|
|
25
25
|
// otherwise: `"button"` for a "Delete" button in words, an element of the
|
|
26
26
|
// caller's, or `null` for none, opened with `open`/`onOpenChange` (a row's
|
|
27
27
|
// menu item).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Where the caret is in a block of text, kept across the control starting
|
|
2
2
|
// over (editable-value.tsx): a value saved elsewhere reloading under the
|
|
3
|
-
// caret
|
|
3
|
+
// caret, and a click-to-open note opening where it was clicked,
|
|
4
4
|
// the read view's text becoming the editor's.
|
|
5
5
|
//
|
|
6
6
|
// A spot is the innermost block holding the caret (a paragraph, a list
|
|
@@ -93,9 +93,9 @@ export type InPlaceRecurrenceConfig<TRequired extends boolean = boolean> = {
|
|
|
93
93
|
timeZone?: string;
|
|
94
94
|
/** The times a new repeat starts with. Defaults to 09:00. */
|
|
95
95
|
defaultTimes?: string[];
|
|
96
|
-
/** RecurrenceField's `times
|
|
96
|
+
/** RecurrenceField's `times`: false for a record whose times are its own fields; the value at rest says no times either. */
|
|
97
97
|
times?: boolean;
|
|
98
|
-
/** RecurrenceField's `weekStart
|
|
98
|
+
/** RecurrenceField's `weekStart`: `'SU'` for an app whose weeks start on Sunday. */
|
|
99
99
|
weekStart?: WeekdayCode;
|
|
100
100
|
/** Today, `'YYYY-MM-DD'`, and "now", for a fixed preview (tests). Default to the clock. */
|
|
101
101
|
today?: string;
|
|
@@ -104,7 +104,7 @@ export type InPlaceRecurrenceConfig<TRequired extends boolean = boolean> = {
|
|
|
104
104
|
};
|
|
105
105
|
/**
|
|
106
106
|
* One option of a select: its value and its words. `kind` and `icon`
|
|
107
|
-
*
|
|
107
|
+
* are ChoiceButtons': drawn by both looks.
|
|
108
108
|
*/
|
|
109
109
|
export type InPlaceOption<T> = ChoiceButtonsOption<T>;
|
|
110
110
|
/**
|
|
@@ -127,7 +127,7 @@ export type InPlaceSelectConfig<T extends string | number, TRequired extends boo
|
|
|
127
127
|
placeholder?: string;
|
|
128
128
|
};
|
|
129
129
|
/**
|
|
130
|
-
* A score out of a few, set by clicking a star (RatingInput
|
|
130
|
+
* A score out of a few, set by clicking a star (RatingInput). The
|
|
131
131
|
* stars are the value: shown at rest, with no click to open, a click on a
|
|
132
132
|
* star saving it at once. Pressing the set star again saves `null` (none)
|
|
133
133
|
* unless `required`; the arrow keys move and set it, saved a pause after
|
|
@@ -164,7 +164,7 @@ export declare class EditInPlaceStore {
|
|
|
164
164
|
private commitAutosaved;
|
|
165
165
|
private schedule;
|
|
166
166
|
/**
|
|
167
|
-
* The page is hidden (another tab, a phone's home screen
|
|
167
|
+
* The page is hidden (another tab, a phone's home screen): while it
|
|
168
168
|
* is, an autosave goes without the pause, and one waiting goes now.
|
|
169
169
|
*/
|
|
170
170
|
hurry(hidden: boolean): void;
|
|
@@ -188,11 +188,11 @@ export declare class EditInPlaceStore {
|
|
|
188
188
|
* elsewhere: another tab, a phone, an AI chat, the form. Call it whenever
|
|
189
189
|
* the value changes. An open autosaving field with nothing of its own unsaved or
|
|
190
190
|
* saving shows it, starting its control over (`revision`): true when it
|
|
191
|
-
* did, so the caret can be put back
|
|
191
|
+
* did, so the caret can be put back. One with unsaved typing gets a
|
|
192
192
|
* conflict (`conflict`, its message), and nothing saves until the person
|
|
193
193
|
* picks. The field's own save coming back, as sent or as the server
|
|
194
194
|
* normalised it (trimmed), is no change: the control keeps its text and
|
|
195
|
-
* its undo
|
|
195
|
+
* its undo.
|
|
196
196
|
*/
|
|
197
197
|
refresh(key: string): boolean;
|
|
198
198
|
/**
|
|
@@ -139,13 +139,13 @@ export class EditInPlaceStore {
|
|
|
139
139
|
}
|
|
140
140
|
return () => {
|
|
141
141
|
// A rich-text editor reports its typing a pause after it stops
|
|
142
|
-
// (src/lib/pending-edits.ts
|
|
142
|
+
// (src/lib/pending-edits.ts): asked for now, before this reads it.
|
|
143
143
|
flushPendingEdits();
|
|
144
144
|
const inFlight = this.autosaving.get(key);
|
|
145
145
|
const state = this.state(key);
|
|
146
146
|
const last = this.configs.get(key)?.();
|
|
147
147
|
// With a save in flight, what was typed since goes once it lands,
|
|
148
|
-
// from this draft and config: the field is gone by then
|
|
148
|
+
// from this draft and config: the field is gone by then.
|
|
149
149
|
if (inFlight) {
|
|
150
150
|
this.clearTimer(key);
|
|
151
151
|
if (state.status === 'open' && last)
|
|
@@ -239,7 +239,7 @@ export class EditInPlaceStore {
|
|
|
239
239
|
return false;
|
|
240
240
|
if (state.status === 'saving' || this.autosaving.has(key) || state.error !== null)
|
|
241
241
|
return true;
|
|
242
|
-
// A reported problem is unsaved at once, not only after the pause
|
|
242
|
+
// A reported problem is unsaved at once, not only after the pause.
|
|
243
243
|
if (state.problem !== null || state.conflict)
|
|
244
244
|
return true;
|
|
245
245
|
return !this.isEqual(key)(state.draft, state.initial);
|
|
@@ -390,7 +390,7 @@ export class EditInPlaceStore {
|
|
|
390
390
|
}, this.hurried ? 0 : this.autosaveDelay));
|
|
391
391
|
}
|
|
392
392
|
/**
|
|
393
|
-
* The page is hidden (another tab, a phone's home screen
|
|
393
|
+
* The page is hidden (another tab, a phone's home screen): while it
|
|
394
394
|
* is, an autosave goes without the pause, and one waiting goes now.
|
|
395
395
|
*/
|
|
396
396
|
hurry(hidden) {
|
|
@@ -418,7 +418,7 @@ export class EditInPlaceStore {
|
|
|
418
418
|
* sent is saved (or there was nothing to send).
|
|
419
419
|
*/
|
|
420
420
|
flush(key) {
|
|
421
|
-
// Typing an editor holds back is reported first
|
|
421
|
+
// Typing an editor holds back is reported first.
|
|
422
422
|
flushPendingEdits();
|
|
423
423
|
this.clearTimer(key);
|
|
424
424
|
const inFlight = this.autosaving.get(key);
|
|
@@ -506,11 +506,11 @@ export class EditInPlaceStore {
|
|
|
506
506
|
* elsewhere: another tab, a phone, an AI chat, the form. Call it whenever
|
|
507
507
|
* the value changes. An open autosaving field with nothing of its own unsaved or
|
|
508
508
|
* saving shows it, starting its control over (`revision`): true when it
|
|
509
|
-
* did, so the caret can be put back
|
|
509
|
+
* did, so the caret can be put back. One with unsaved typing gets a
|
|
510
510
|
* conflict (`conflict`, its message), and nothing saves until the person
|
|
511
511
|
* picks. The field's own save coming back, as sent or as the server
|
|
512
512
|
* normalised it (trimmed), is no change: the control keeps its text and
|
|
513
|
-
* its undo
|
|
513
|
+
* its undo.
|
|
514
514
|
*/
|
|
515
515
|
refresh(key) {
|
|
516
516
|
// Typing an editor holds back counts as unsaved (a conflict, not a reload).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// A list of sub-items edited in place on a record's view (cell-patterns.md
|
|
3
|
-
// "
|
|
3
|
+
// "A list of sub-items"): editInPlace's `list` kind, on a `content` section of
|
|
4
4
|
// EntityView. Built on ListEditor, so the rows and their buttons are the
|
|
5
5
|
// form's, with the same names ("Move item 2 up", "Remove item 2").
|
|
6
6
|
//
|
|
@@ -46,8 +46,7 @@ function locate(current, item, index) {
|
|
|
46
46
|
}
|
|
47
47
|
// The form's row, in place too: ListEditor lays `renderItem` out in a
|
|
48
48
|
// row, so its parts (a done box, then the text box) sit side by side
|
|
49
|
-
// there and here alike. One element (an app's own row) fills it
|
|
50
|
-
// filled the field's column before.
|
|
49
|
+
// there and here alike. One element (an app's own row) fills it.
|
|
51
50
|
function ItemRow({ children }) {
|
|
52
51
|
return _jsx("span", { className: "flex min-w-0 items-start gap-2 [&>:only-child]:flex-1", children: children });
|
|
53
52
|
}
|
|
@@ -17,10 +17,10 @@ export type EditableValueProps = {
|
|
|
17
17
|
*/
|
|
18
18
|
look?: 'value' | 'row';
|
|
19
19
|
/**
|
|
20
|
-
* Inline, the pencil's room is kept at rest,
|
|
20
|
+
* Inline, the pencil's room is kept at rest, so nothing
|
|
21
21
|
* moves on hover or focus: a table cell (row-edit-cells.tsx), whose
|
|
22
22
|
* column would otherwise widen, EntityView's title, which ends its line
|
|
23
|
-
* and can fill it, and every value inside a <KeyStats> (
|
|
23
|
+
* and can fill it, and every value inside a <KeyStats> (which
|
|
24
24
|
* sets it for them: a wrapping row moved the values after it along).
|
|
25
25
|
*/
|
|
26
26
|
keepPencilRoom?: boolean;
|
|
@@ -16,28 +16,28 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
16
16
|
// Ctrl/Cmd+Enter and Esc save what's left now and close it. On a note
|
|
17
17
|
// longer than the screen the line under it is pinned to the screen's
|
|
18
18
|
// bottom edge, so a refusal or a failed save is never off screen, and
|
|
19
|
-
// the first one also toasts
|
|
19
|
+
// the first one also toasts.
|
|
20
20
|
// - `long-text` without `autosave`: Esc on a changed draft asks
|
|
21
|
-
// ("Discard your changes?") rather than dropping it
|
|
21
|
+
// ("Discard your changes?") rather than dropping it.
|
|
22
22
|
// - Opening by a click puts the caret where the click was, not at the
|
|
23
|
-
// top, and the page doesn't move
|
|
23
|
+
// top, and the page doesn't move.
|
|
24
24
|
// - The saved value changing elsewhere shows at once when nothing here is
|
|
25
25
|
// unsaved, the caret keeping its block; under unsaved typing the line
|
|
26
|
-
// says so, with "Keep Mine" and "Show Saved"
|
|
26
|
+
// says so, with "Keep Mine" and "Show Saved".
|
|
27
27
|
// - `alwaysEditable`: the control is shown at rest, with no pencil and no
|
|
28
28
|
// click to open, and never closes. Ctrl/Cmd+Enter and Esc save now.
|
|
29
29
|
// - `inline`: always editable, and the control is told to look like the
|
|
30
30
|
// value it edits (`inline` among its props).
|
|
31
|
-
// - Always editable and a `choice` (
|
|
31
|
+
// - Always editable and a `choice` (`inPlace.rating`'s stars): a
|
|
32
32
|
// value on one line, so "Saving…" and "Saved" sit beside it, not on a
|
|
33
33
|
// line under it, and "Saved" goes after two seconds, as at rest.
|
|
34
|
-
// - Saved
|
|
34
|
+
// - Saved: once a save lands, "✓ Saved" shows beside the value
|
|
35
35
|
// for two seconds (`role="status"`).
|
|
36
|
-
// - `layout="inline"
|
|
36
|
+
// - `layout="inline"`: the pencil takes no room until hover or
|
|
37
37
|
// focus, so nothing gaps before what follows the value on its line.
|
|
38
|
-
// `keepPencilRoom` (and every value inside a KeyStats
|
|
38
|
+
// `keepPencilRoom` (and every value inside a KeyStats) keeps it
|
|
39
39
|
// at rest instead, so nothing moves on hover or focus.
|
|
40
|
-
// - `look="row"
|
|
40
|
+
// - `look="row"`: in a record's field list the row is
|
|
41
41
|
// the target (edit-row.ts): it wears the list's row hover and the pencil
|
|
42
42
|
// sits at its end; under 48rem or on a touch screen there's a chevron
|
|
43
43
|
// instead of the pencil. The control still opens in the row.
|
|
@@ -88,7 +88,7 @@ function Control({ render, ...props }) {
|
|
|
88
88
|
}
|
|
89
89
|
// While a field runs past the bottom of the screen, its status line (the
|
|
90
90
|
// save's state, a refusal) is pinned to the screen's bottom edge, under the
|
|
91
|
-
// field's left edge, so it's never off screen
|
|
91
|
+
// field's left edge, so it's never off screen. Not CSS sticky: a
|
|
92
92
|
// section's card clips its content (`overflow-hidden`), which stops sticky
|
|
93
93
|
// at the card. Returns where to pin it, or null while it shows in place.
|
|
94
94
|
//
|
|
@@ -211,7 +211,7 @@ export function EditableField({ label, edit, children, layout = 'block', look =
|
|
|
211
211
|
const refocus = useRef(false);
|
|
212
212
|
const blurTimer = useRef(undefined);
|
|
213
213
|
// Where the caret goes once the control shows or starts over: the spot
|
|
214
|
-
// clicked in the read view
|
|
214
|
+
// clicked in the read view, or the caret's own block.
|
|
215
215
|
const caretTarget = useRef(null);
|
|
216
216
|
const stopPlacing = useRef(() => { });
|
|
217
217
|
useEffect(() => () => stopPlacing.current(), []);
|
|
@@ -232,7 +232,7 @@ export function EditableField({ label, edit, children, layout = 'block', look =
|
|
|
232
232
|
useEffect(() => {
|
|
233
233
|
refresh();
|
|
234
234
|
}, [refresh, edit.value]);
|
|
235
|
-
// Always editable and one pick (stars): its line is beside it
|
|
235
|
+
// Always editable and one pick (stars): its line is beside it.
|
|
236
236
|
const beside = always && edit.kind === 'choice';
|
|
237
237
|
const autosaved = state.status !== 'closed' && state.autosave === 'saved';
|
|
238
238
|
const [savedGone, setSavedGone] = useState(false);
|
|
@@ -275,14 +275,14 @@ export function EditableField({ label, edit, children, layout = 'block', look =
|
|
|
275
275
|
}
|
|
276
276
|
wasOpen.current = isOpen;
|
|
277
277
|
}, [isOpen, always, placeCaretSoon]);
|
|
278
|
-
// Esc on a changed long text that doesn't autosave: asks first
|
|
278
|
+
// Esc on a changed long text that doesn't autosave: asks first.
|
|
279
279
|
const [askingDiscard, setAskingDiscard] = useState(false);
|
|
280
280
|
const asking = useRef(false);
|
|
281
281
|
useLayoutEffect(() => {
|
|
282
282
|
asking.current = askingDiscard;
|
|
283
283
|
});
|
|
284
284
|
// The first refusal or failed save of an autosaving field toasts too:
|
|
285
|
-
// its line may be far from where the person is looking
|
|
285
|
+
// its line may be far from where the person is looking. Once per
|
|
286
286
|
// run of failures; a save that lands starts the count again.
|
|
287
287
|
// A conflict (saved elsewhere) isn't a failed save: its toast says so.
|
|
288
288
|
const failure = state.status !== 'closed' ? state.error : null;
|
|
@@ -341,7 +341,7 @@ export function EditableField({ label, edit, children, layout = 'block', look =
|
|
|
341
341
|
const onShownClick = (event) => {
|
|
342
342
|
if (event.target.closest(INTERACTIVE))
|
|
343
343
|
return;
|
|
344
|
-
// Long text opens with the caret where it was clicked
|
|
344
|
+
// Long text opens with the caret where it was clicked.
|
|
345
345
|
if (edit.kind === 'long-text')
|
|
346
346
|
caretTarget.current = spotAtPoint(event.currentTarget, event.clientX, event.clientY);
|
|
347
347
|
start();
|
|
@@ -421,7 +421,7 @@ export function EditableField({ label, edit, children, layout = 'block', look =
|
|
|
421
421
|
// Inline, the cap is its column plus the 0.75rem the negative
|
|
422
422
|
// margins give back: a parent sized to its content (a title on
|
|
423
423
|
// its line) is sized to the margin box, 0.75rem under the box,
|
|
424
|
-
// and `max-w-full` then wrapped a short value mid-word
|
|
424
|
+
// and `max-w-full` then wrapped a short value mid-word.
|
|
425
425
|
layout === 'block' ? 'flex w-full' : cn('inline-flex align-top', row ? 'max-w-full' : 'max-w-[calc(100%+0.75rem)]'), className), children: [_jsxs("span", { className: cn('min-w-0 flex-1', !row &&
|
|
426
426
|
'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, {})) }) })] }));
|
|
427
427
|
}
|
|
@@ -436,11 +436,11 @@ export function EditableField({ label, edit, children, layout = 'block', look =
|
|
|
436
436
|
// Something to say: a save in flight, saved, or why it can't save.
|
|
437
437
|
const hasStatus = autosaving || open.autosave === 'saved' || lineError !== null;
|
|
438
438
|
const pin = hasStatus ? pinned : null;
|
|
439
|
-
// The saved value changed elsewhere under unsaved typing: the person picks
|
|
439
|
+
// The saved value changed elsewhere under unsaved typing: the person picks.
|
|
440
440
|
const conflictActions = 'conflict' in open && open.conflict && (_jsxs("span", { className: "mt-1 flex flex-wrap gap-2", children: [_jsx(Button, { type: "button", size: "xs", variant: "outline", onClick: () => void store.keepMine(key), children: "Keep Mine" }), _jsx(Button, { type: "button", size: "xs", variant: "ghost", onClick: () => store.takeSaved(key), children: "Show Saved" })] }));
|
|
441
441
|
return (_jsxs(_Fragment, { children: [_jsxs("span", { ref: container, "data-slot": "editable-value", "data-state": saving || autosaving ? 'saving' : open.error ? 'failed' : 'editing', onKeyDown: onKeyDown, onBlur: onBlur, onFocus: onFocus, className: cn('flex min-w-0', beside ? 'flex-row flex-wrap items-center gap-x-2 gap-y-1' : 'flex-col gap-1.5', layout === 'block' ? 'w-full' : 'w-fit max-w-full', className), children: [_jsx(Control, { render: edit.control, id: controlId, value: open.draft, onChange: (value) => store.change(key, value), commit: commit, cancel: cancel, disabled: saving, invalid: !saving && open.error !== null, label: label, describedBy: describedBy, onProblem: (problem) => store.report(key, problem), inline: Boolean(edit.inline), errors: saving ? undefined : fieldErrors }, open.revision ?? 0), _jsx("span", { id: describedBy, "data-slot": "editable-value-status", "data-pinned": pin ? '' : undefined,
|
|
442
442
|
// Pinned to the screen's bottom edge while the field runs past
|
|
443
|
-
// it, so the save's state and a refusal stay in view
|
|
443
|
+
// it, so the save's state and a refusal stay in view.
|
|
444
444
|
style: pin ? { left: pin.left, maxWidth: pin.width } : undefined, className: cn('type-body',
|
|
445
445
|
// Beside the value, a refusal takes the line under it.
|
|
446
446
|
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,7 +466,7 @@ const sameAsJson = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
|
466
466
|
export function LeaveGuard({ store }) {
|
|
467
467
|
const dirty = useSyncExternalStore(store.subscribe, () => store.dirty, () => store.dirty);
|
|
468
468
|
const savesOnLeave = useSyncExternalStore(store.subscribe, () => store.savesOnLeave, () => store.savesOnLeave);
|
|
469
|
-
// Typing a rich-text field holds back
|
|
469
|
+
// Typing a rich-text field holds back counts: the tab's prompt is
|
|
470
470
|
// set up from the first key, and a move reports it before it's judged.
|
|
471
471
|
const holding = useSyncExternalStore(subscribePendingEdits, hasPendingEdits, hasPendingEdits);
|
|
472
472
|
const blocker = useBlocker(({ currentLocation, nextLocation }) => {
|
|
@@ -503,7 +503,7 @@ export function LeaveGuard({ store }) {
|
|
|
503
503
|
if (!dirty && !holding)
|
|
504
504
|
return;
|
|
505
505
|
// Saves started as the page goes ask the browser to finish them
|
|
506
|
-
// (`keepalive`, lib/page-leaving.ts)
|
|
506
|
+
// (`keepalive`, lib/page-leaving.ts).
|
|
507
507
|
const saveAsLeaving = () => {
|
|
508
508
|
markPageLeaving();
|
|
509
509
|
void store.saveAll();
|
|
@@ -5,7 +5,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
// wiring; this component does not attempt to generate fields from a
|
|
6
6
|
// schema.
|
|
7
7
|
//
|
|
8
|
-
// The form standard
|
|
8
|
+
// The form standard is drawn here and in Field:
|
|
9
9
|
//
|
|
10
10
|
// - Fields are a FieldGroup, so short ones share a row (`Field size`),
|
|
11
11
|
// compact (32px controls, 14px between). `FormSection` groups them in
|
|
@@ -104,7 +104,7 @@ export function EntityForm({ title, onSubmit, isSubmitting, submitError, onRetry
|
|
|
104
104
|
const [attempt, setAttempt] = useState(0);
|
|
105
105
|
const submit = (event) => {
|
|
106
106
|
// A rich-text field reports its typing a pause after it stops: asked
|
|
107
|
-
// for now, so the submit reads the last of it
|
|
107
|
+
// for now, so the submit reads the last of it.
|
|
108
108
|
flushPendingEdits();
|
|
109
109
|
const done = onSubmit(event);
|
|
110
110
|
void Promise.resolve(done).then(() => setAttempt((count) => count + 1));
|
|
@@ -15,7 +15,7 @@ export type EntityViewFactValue =
|
|
|
15
15
|
kind: 'text';
|
|
16
16
|
text: string | number | null | undefined;
|
|
17
17
|
}
|
|
18
|
-
/** A few short labels (areas, tags) as badges, each with its icon if it has one
|
|
18
|
+
/** A few short labels (areas, tags) as badges, each with its icon if it has one. None is empty. */
|
|
19
19
|
| {
|
|
20
20
|
kind: 'badges';
|
|
21
21
|
items: readonly (string | EntityViewFactBadge)[];
|
|
@@ -44,7 +44,7 @@ export type EntityViewFactValue =
|
|
|
44
44
|
short: true;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
-
* Several items
|
|
47
|
+
* Several items: linked records, links out, or plain words, each
|
|
48
48
|
* marked by its kind's `icon` or a bullet (FactList), so long titles
|
|
49
49
|
* that wrap still read apart. An item with `to` links in the app, with
|
|
50
50
|
* `href` out of it (a new tab), with neither is its words. None is empty.
|
|
@@ -54,7 +54,7 @@ export type EntityViewFactValue =
|
|
|
54
54
|
items: readonly EntityViewFactListItem[];
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
|
-
* A rating
|
|
57
|
+
* A rating, drawn as the list's cells draw it: `stars` (the
|
|
58
58
|
* default) or `hearts` for a score out of `max` (RatingScore), `bar` for a
|
|
59
59
|
* quality level of `max` steps (StepBar). `value` is how many are
|
|
60
60
|
* filled; `null` is empty. Named "4 of 5" for a screen reader (with
|
|
@@ -68,7 +68,7 @@ export type EntityViewFactValue =
|
|
|
68
68
|
word?: string;
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
|
-
* A yes/no
|
|
71
|
+
* A yes/no, toggled in place by a switch named by the fact's
|
|
72
72
|
* label. `onCheckedChange` saves it: while a promise it returns is
|
|
73
73
|
* pending the switch shows the new state and is busy, and if it rejects
|
|
74
74
|
* the switch goes back. `on`/`off` are words after the switch ("Shared",
|
|
@@ -96,21 +96,21 @@ export type EntityViewFactListItem = {
|
|
|
96
96
|
/** Its kind's icon (the record standard's 4I); a bullet without one. */
|
|
97
97
|
icon?: IconComponent;
|
|
98
98
|
};
|
|
99
|
-
/** One item of a `badges` fact with an icon
|
|
99
|
+
/** One item of a `badges` fact with an icon: the icon before its label, in the muted tone. */
|
|
100
100
|
export type EntityViewFactBadge = {
|
|
101
101
|
label: string;
|
|
102
102
|
/** An icon component (a `LucideIcon`, an app's own mark) or a node drawn as it is. Decorative: the label says it. */
|
|
103
103
|
icon?: IconComponent | ReactNode;
|
|
104
104
|
/**
|
|
105
|
-
* The badge's tone
|
|
105
|
+
* The badge's tone, for a label that is a state ("Pinned",
|
|
106
106
|
* "Overdue"): the outline badge in that tone's text colour, its icon
|
|
107
107
|
* too. Neutral (the outline) unless set. The word still says it.
|
|
108
108
|
*/
|
|
109
109
|
tone?: EntityViewFactBadgeTone;
|
|
110
110
|
};
|
|
111
|
-
/** A badge item's tone
|
|
111
|
+
/** A badge item's tone: the design language's four, as outline badges. */
|
|
112
112
|
export type EntityViewFactBadgeTone = 'success' | 'warning' | 'info' | 'destructive';
|
|
113
|
-
/** A small button under a fact's value
|
|
113
|
+
/** A small button under a fact's value: "Close…" under a status that changes only through it. */
|
|
114
114
|
export type EntityViewFactAction = {
|
|
115
115
|
/** The button's words ("Close…"; an ellipsis when it opens a dialog). */
|
|
116
116
|
label: string;
|
|
@@ -133,19 +133,19 @@ export type EntityViewFact = EntityViewFactValue & {
|
|
|
133
133
|
/** Editable in place, as a field is (`inPlace.select`, `inPlace.date`); it's drawn by its kind at rest. */
|
|
134
134
|
edit?: EditInPlace;
|
|
135
135
|
/**
|
|
136
|
-
* The record's status
|
|
136
|
+
* The record's status: drawn first, at the top of the rail (or
|
|
137
137
|
* of Details), whatever its place in `facts` or its section's among the
|
|
138
138
|
* rail's. One per record; usually a `kind: 'status'` fact.
|
|
139
139
|
*/
|
|
140
140
|
recordStatus?: boolean;
|
|
141
141
|
/**
|
|
142
|
-
* A few words on the value
|
|
142
|
+
* A few words on the value, such as why it can't be edited here
|
|
143
143
|
* ("Changes when the record is closed"). An info button after the value
|
|
144
144
|
* shows it on hover and keyboard focus; a touch screen shows it as a
|
|
145
145
|
* line under the value instead. A screen reader reads it with the value.
|
|
146
146
|
*/
|
|
147
147
|
hint?: string;
|
|
148
|
-
/** A small button under the value
|
|
148
|
+
/** A small button under the value, drawn in the rail and in Details alike. */
|
|
149
149
|
action?: EntityViewFactAction;
|
|
150
150
|
};
|
|
151
151
|
/** A fact as the view draws it: `null` when empty. `label` names a control the fact draws (a switch). */
|
|
@@ -161,7 +161,7 @@ export declare function factsAsFields(facts: readonly EntityViewFact[]): {
|
|
|
161
161
|
recordStatus: boolean | undefined;
|
|
162
162
|
}[];
|
|
163
163
|
/**
|
|
164
|
-
* The sections with the one holding the status fact
|
|
164
|
+
* The sections with the one holding the status fact moved before
|
|
165
165
|
* the other sections that share its place (the rail, or a tab's
|
|
166
166
|
* side), so the status is the first fact there. Nothing else moves.
|
|
167
167
|
*/
|
|
@@ -82,7 +82,7 @@ function statusFirst(facts) {
|
|
|
82
82
|
return at <= 0 ? facts : [facts[at], ...facts.slice(0, at), ...facts.slice(at + 1)];
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
|
-
* The sections with the one holding the status fact
|
|
85
|
+
* The sections with the one holding the status fact moved before
|
|
86
86
|
* the other sections that share its place (the rail, or a tab's
|
|
87
87
|
* side), so the status is the first fact there. Nothing else moves.
|
|
88
88
|
*/
|
|
@@ -35,7 +35,7 @@ export type EntityViewSection = ({
|
|
|
35
35
|
/** The section's heading. */
|
|
36
36
|
title: string;
|
|
37
37
|
/**
|
|
38
|
-
* Short facts only (
|
|
38
|
+
* Short facts only (A1): each a typed kind (a status, short
|
|
39
39
|
* text, badges, a count, a link, a short-named record), never free
|
|
40
40
|
* markup. Placed `rail` with no `tab`, the section goes in the facts
|
|
41
41
|
* rail beside the tabs where the view has room (`factsRail`), else
|
|
@@ -87,10 +87,10 @@ export type EntityViewSection = ({
|
|
|
87
87
|
};
|
|
88
88
|
export type EntityViewPlacement = 'main' | 'rail';
|
|
89
89
|
/**
|
|
90
|
-
* `tabs` (the default
|
|
90
|
+
* `tabs` (the default): one column, at most max-w-4xl wide, the
|
|
91
91
|
* short facts (sections placed `rail`) in a Details tab after the record's
|
|
92
|
-
* other tabs. `column`: one column, `placement` ignored. `rail` (
|
|
93
|
-
*
|
|
92
|
+
* other tabs. `column`: one column, `placement` ignored. `rail` (legacy;
|
|
93
|
+
* consuming.md "4.98"): the content
|
|
94
94
|
* area's whole width, with the sections placed `rail` in a narrow column
|
|
95
95
|
* on the right (one column on a narrow screen, rail first).
|
|
96
96
|
*/
|
|
@@ -164,11 +164,11 @@ export type EntityViewProps = {
|
|
|
164
164
|
* its notice, across the page at every width: in the rail layout above
|
|
165
165
|
* both columns, so on a phone it comes before the rail and the main
|
|
166
166
|
* column. Left out in a small card dialog (RecordDialogRoute
|
|
167
|
-
* `look="card"
|
|
167
|
+
* `look="card"`): a tiny record's facts are its few rows, so
|
|
168
168
|
* `cardStrip` keeps it there.
|
|
169
169
|
*/
|
|
170
170
|
strip?: ReactNode;
|
|
171
|
-
/** Show `strip` in a small card dialog too
|
|
171
|
+
/** Show `strip` in a small card dialog too; off by default. */
|
|
172
172
|
cardStrip?: boolean;
|
|
173
173
|
sections: EntityViewSection[];
|
|
174
174
|
/**
|
|
@@ -178,11 +178,11 @@ export type EntityViewProps = {
|
|
|
178
178
|
*/
|
|
179
179
|
footer?: ReactNode;
|
|
180
180
|
/**
|
|
181
|
-
* `tabs` (the default
|
|
181
|
+
* `tabs` (the default): the sections placed `rail` are a
|
|
182
182
|
* Details tab after the other tabs (in the column where there's no other
|
|
183
183
|
* tab). `column`: one column, `placement` ignored. `rail`: the sections
|
|
184
|
-
* placed `rail` in a column on the right
|
|
185
|
-
*
|
|
184
|
+
* placed `rail` in a column on the right (legacy; drop it to move to
|
|
185
|
+
* `tabs`).
|
|
186
186
|
*/
|
|
187
187
|
layout?: EntityViewLayout;
|
|
188
188
|
/**
|
|
@@ -216,19 +216,19 @@ export type EntityViewProps = {
|
|
|
216
216
|
* to "Print notes".
|
|
217
217
|
*/
|
|
218
218
|
printLabel?: string;
|
|
219
|
-
/** Print notes as an icon (`icon`, the default
|
|
219
|
+
/** Print notes as an icon (`icon`, the default) or a button with its words (`words`). */
|
|
220
220
|
printLook?: 'icon' | 'words';
|
|
221
221
|
/** The rail's landmark name (its `<aside>`). Defaults to the title + " details". */
|
|
222
222
|
railLabel?: string;
|
|
223
223
|
/**
|
|
224
|
-
* The facts rail (
|
|
224
|
+
* The facts rail (record standard A1), in the `tabs` layout:
|
|
225
225
|
* where the view has room (60rem beside it: a laptop's page, a record
|
|
226
226
|
* dialog), the sections of short facts (`facts`, placed `rail`, no
|
|
227
227
|
* `tab`) go in a 300px column beside the record's body, and leave
|
|
228
228
|
* Details. The strip stays above, full width; the rail starts level with
|
|
229
229
|
* the first content under it (the open tab's first section, or the first
|
|
230
|
-
* card when cards come before the tabs
|
|
231
|
-
* nothing isn't drawn. Narrower (a phone), they're in Details
|
|
230
|
+
* card when cards come before the tabs). A Details tab left with
|
|
231
|
+
* nothing isn't drawn. Narrower (a phone), they're in Details. Sections with `fields` or
|
|
232
232
|
* `content` never go in it: a rail holds short values only.
|
|
233
233
|
*/
|
|
234
234
|
factsRail?: boolean;
|
|
@@ -236,7 +236,7 @@ export type EntityViewProps = {
|
|
|
236
236
|
factsRailLabel?: string;
|
|
237
237
|
/**
|
|
238
238
|
* In the `rail` layout, a rail section's fields: each label to the left
|
|
239
|
-
* of its value (`beside`, the default
|
|
239
|
+
* of its value (`beside`, the default), falling back to
|
|
240
240
|
* stacked where the rail is too narrow for both, or above it
|
|
241
241
|
* (`stacked`). Once the rail's sections stack full width on a narrower
|
|
242
242
|
* screen, labels sit beside values either way.
|
|
@@ -262,10 +262,10 @@ export type EntityViewProps = {
|
|
|
262
262
|
onRetry?: () => void;
|
|
263
263
|
/**
|
|
264
264
|
* The entity's list: a link above the title, and the not-found state's
|
|
265
|
-
* way out. With `trail
|
|
265
|
+
* way out. With `trail`, the crumbs above the record, from the top
|
|
266
266
|
* down ("Finance", "Accounts"), the record's title follows them as the
|
|
267
267
|
* page's own crumb and the trail takes the link's place: in AppShell's
|
|
268
|
-
* bar (`usePageTrail
|
|
268
|
+
* bar (`usePageTrail`), or, outside the shell, above the title
|
|
269
269
|
* (PageTrail). A record in a dialog shows neither: the dialog's bar
|
|
270
270
|
* is its way back.
|
|
271
271
|
*/
|