@tristan2828/ui-foundation 4.136.1 → 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 +4 -6
- package/dist/components/app/rich-text-slash.d.ts +2 -2
- package/dist/components/app/rich-text-slash.js +2 -2
- package/dist/components/app/rich-text-table-grips.d.ts +1 -1
- package/dist/components/app/rich-text-table-grips.js +1 -2
- package/dist/components/app/rich-text-tasks.d.ts +1 -1
- package/dist/components/app/rich-text-tasks.js +1 -1
- package/dist/components/app/rich-text-touch.js +1 -1
- package/dist/components/app/search-palette.js +1 -2
- package/dist/components/app/secondary-filters.js +2 -3
- package/dist/components/app/session-view.js +1 -1
- package/dist/components/app/stacked-area-chart.js +1 -1
- package/dist/components/app/step-track.d.ts +1 -1
- package/dist/components/app/step-track.js +3 -3
- package/dist/components/app/widget-card.js +26 -30
- package/dist/components/app/widget-layout-sheet.js +1 -1
- package/dist/components/ui/calendar.js +2 -2
- package/dist/components/ui/combobox.d.ts +1 -1
- package/dist/components/ui/combobox.js +2 -2
- package/dist/components/ui/field.d.ts +1 -1
- package/dist/components/ui/field.js +6 -6
- package/dist/components/ui/skeleton.js +1 -1
- package/dist/components/ui/sonner.js +1 -1
- package/dist/components/ui/tabs.js +1 -1
- package/dist/error-reporting/reporter.d.ts +1 -1
- package/dist/error-reporting/reporter.js +1 -1
- package/dist/hooks/table-url-changes.d.ts +2 -2
- package/dist/hooks/table-url-changes.js +5 -6
- package/dist/hooks/use-action.js +1 -1
- package/dist/hooks/use-record-update.js +1 -1
- package/dist/hooks/use-table-url-state.d.ts +1 -1
- package/dist/hooks/use-table-url-state.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -2
- package/dist/lib/audio-cues.js +2 -2
- package/dist/lib/connection.js +1 -1
- package/dist/lib/date-filter.js +1 -1
- package/dist/lib/entity-view-tab.js +1 -1
- package/dist/lib/field-rows.js +2 -2
- package/dist/lib/form-errors.d.ts +1 -1
- package/dist/lib/form-errors.js +1 -1
- package/dist/lib/keep-audio-alive.js +1 -1
- package/dist/lib/line-chart-layout.js +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
|
@@ -6,7 +6,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
6
6
|
// docs/ARCHITECTURE.md "Decisions".
|
|
7
7
|
//
|
|
8
8
|
// What this file (the wiring) and the rich-text-* files beside it add to
|
|
9
|
-
// Milkdown's own presets:
|
|
9
|
+
// Milkdown's own presets; each feature's detail is in its own file:
|
|
10
10
|
// - Saves go through mergeMarkdown: an untouched document, and every block
|
|
11
11
|
// the person didn't change, saves back as originally written.
|
|
12
12
|
// - No HTML in, ever. The preset's "preserve empty line" plugin is left
|
|
@@ -20,70 +20,48 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
20
20
|
// outline, as it does <Markdown>'s; only the element moves, never the
|
|
21
21
|
// level the Markdown is saved with (a node view draws it, from the
|
|
22
22
|
// node's own level: rich-text-heading-view.ts). They look like
|
|
23
|
-
// <Markdown>'s (prose-look.ts).
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
// -
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
// (rich-text-table-grips.tsx); right-click or Shift+F10 in a cell opens
|
|
34
|
-
// the cell's. A column's right edge drags to a width (double-click:
|
|
35
|
-
// back to fit its words), and the menus hold Narrower, Wider and Fit to
|
|
36
|
-
// content; none of that on a phone, which fits columns to their words.
|
|
37
|
-
// Tab in the last cell adds a row and Enter goes down a
|
|
38
|
-
// column (rich-text-table.ts). Colours and a header column are kept as
|
|
39
|
-
// Markdown writes them (src/lib/markdown-table.ts).
|
|
40
|
-
// - Edited blocks are written in the document's own bullet and rule marks.
|
|
23
|
+
// <Markdown>'s (prose-look.ts).
|
|
24
|
+
// - Callouts (src/lib/markdown-callout.ts), highlighted words
|
|
25
|
+
// (src/lib/markdown-highlight.ts), toggle headings
|
|
26
|
+
// (rich-text-toggle-heading.ts), task items (rich-text-tasks.ts), page
|
|
27
|
+
// links (rich-text-page-links.ts) and tables (rich-text-table.ts,
|
|
28
|
+
// rich-text-table-grips.tsx, rich-text-node-views.ts) are nodes and
|
|
29
|
+
// plugins of their own, drawn as <Markdown> draws them. None of the
|
|
30
|
+
// table's menus or grips show on a phone, which fits columns to their
|
|
31
|
+
// words. Edited blocks are written in the document's own bullet and rule
|
|
32
|
+
// marks.
|
|
41
33
|
// - Markdown pasted as plain text arrives formatted (still no HTML), and a
|
|
42
|
-
// copy out of the editor is Markdown. A paste
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
// or an image as `data:` (rich-text-paste.ts, rich-text-autolink.ts).
|
|
34
|
+
// copy out of the editor is Markdown. A paste can't bring in a link that
|
|
35
|
+
// runs code or an image as `data:` (rich-text-paste.ts,
|
|
36
|
+
// rich-text-autolink.ts).
|
|
46
37
|
// - An edit the merge refuses is never saved quietly: the field is marked
|
|
47
38
|
// invalid, and says why in itself when the app gives no `onProblem`
|
|
48
39
|
// (with one, the app shows it: a form's field error, editing in
|
|
49
40
|
// place's line).
|
|
50
41
|
// - Full screen holds focus: the page behind it is inert until it ends
|
|
51
42
|
// (rich-text-full-screen.ts).
|
|
52
|
-
// - A click on a link opens it in a new tab, as the read view's links do
|
|
53
|
-
//
|
|
54
|
-
// (
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
// length as it nears `maxLength`.
|
|
63
|
-
// - A fixed toolbar above the text (rich-text-toolbar.tsx), and a
|
|
64
|
-
// floating one over selected words (rich-text-floating-toolbar.tsx),
|
|
65
|
-
// unless `toolbar={false}`; `toolbar="floating"` leaves out the fixed
|
|
66
|
-
// one. Alt+F10 reaches the floating one when it shows, else the fixed one.
|
|
67
|
-
// - A slash menu (rich-text-slash.ts, rich-text-slash-menu.tsx): "/" at a
|
|
68
|
-
// line's start lists the blocks it can become, also unless
|
|
69
|
-
// `toolbar={false}`.
|
|
43
|
+
// - A click on a link opens it in a new tab, as the read view's links do
|
|
44
|
+
// (followLink, rich-text-links.ts). Ctrl/Cmd+K adds or edits a link
|
|
45
|
+
// (rich-text-link-box.tsx: web and email addresses only).
|
|
46
|
+
// Ctrl/Cmd+Enter stays the field's save, in a table too. The editing
|
|
47
|
+
// keys are in rich-text-shortcuts.ts.
|
|
48
|
+
// - A fixed toolbar above the text (rich-text-toolbar.tsx) and a floating
|
|
49
|
+
// one over selected words (rich-text-floating-toolbar.tsx), unless
|
|
50
|
+
// `toolbar={false}`; `toolbar="floating"` leaves out the fixed one.
|
|
51
|
+
// Alt+F10 reaches the floating one when it shows, else the fixed one.
|
|
52
|
+
// The slash menu (rich-text-slash.ts) goes with them.
|
|
70
53
|
// - `inline`: the field drawn as the text it edits (no border, no box),
|
|
71
54
|
// for notes that are always editable where they're read.
|
|
72
|
-
// - Images
|
|
73
|
-
//
|
|
74
|
-
// Image button (the fixed toolbar's, the tools strip's with
|
|
75
|
-
// `toolbar="floating"`, the phone's row) is uploaded through it and goes in as ``
|
|
55
|
+
// - Images show at most the field's width. With `upload`, an image pasted,
|
|
56
|
+
// dropped or picked is uploaded through it and goes in as ``
|
|
76
57
|
// (rich-text-image-upload.ts); a refusal or a failed upload is a toast.
|
|
77
|
-
// - Toggle headings (`## Safety {toggle="true"}`, rich-text-toggle-heading.ts):
|
|
78
|
-
// a heading's `toggle` attribute, typed as `>## `, picked from the slash
|
|
79
|
-
// menu or the toolbar. A plain heading is the default.
|
|
80
58
|
// - `foldKey`: the text folds by its toggle headings, as <Markdown> does
|
|
81
59
|
// (rich-text-fold.ts), remembered on this device and shared with
|
|
82
60
|
// NotesOutline; the document never changes.
|
|
83
|
-
// - `pageLink`: links the app marks as its pages drawn as page links
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
//
|
|
61
|
+
// - `pageLink`: links the app marks as its pages drawn as page links,
|
|
62
|
+
// opened in this tab; `onCreatePage`: "/page" and Turn into page make
|
|
63
|
+
// one through the app and link it (a title box, rich-text-page-box.tsx).
|
|
64
|
+
// The Markdown stays a plain link.
|
|
87
65
|
import { useEffect, useId, useRef, useState } from 'react';
|
|
88
66
|
import { createPortal } from 'react-dom';
|
|
89
67
|
import { useInRouterContext, useNavigate } from 'react-router';
|
|
@@ -256,9 +234,8 @@ const imageTitles = $remark('imageTitles', () => () => (tree) => emptyImageTitle
|
|
|
256
234
|
// What the field says when the merge refuses an edit (markdown-merge.ts):
|
|
257
235
|
// to the app's `onProblem`, and in the field itself.
|
|
258
236
|
// How long typing has to stop before the edit is turned back into
|
|
259
|
-
// Markdown (mergeMarkdown) and reported through onChange
|
|
237
|
+
// Markdown (mergeMarkdown) and reported through onChange.
|
|
260
238
|
export const MERGE_PAUSE_MS = 300;
|
|
261
|
-
// Every format a toolbar can show as on.
|
|
262
239
|
const SHOWN_FORMATS = [
|
|
263
240
|
...new Set([...FORMAT_GROUPS.flat(), ...TOGGLE_HEADING_VARIANTS, ...CALLOUT_VARIANTS, ...HIGHLIGHT_VARIANTS].map((item) => item.id)),
|
|
264
241
|
];
|
|
@@ -266,7 +243,7 @@ const SHOWN_FORMATS = [
|
|
|
266
243
|
// formats on, the selection (where only when there is one: a caret's
|
|
267
244
|
// place matters to nothing drawn but the slash menu and a table's grips),
|
|
268
245
|
// the slash menu's query, a table's caret cell and the uploads. A key
|
|
269
|
-
// that doesn't change it re-renders nothing
|
|
246
|
+
// that doesn't change it re-renders nothing.
|
|
270
247
|
function shownKey(state) {
|
|
271
248
|
const { selection } = state;
|
|
272
249
|
const parts = [selection.empty ? 'caret' : `${selection.from}-${selection.to}`];
|
|
@@ -327,7 +304,7 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
327
304
|
const [focused, setFocused] = useState(false);
|
|
328
305
|
const [selecting, setSelectingState] = useState(false);
|
|
329
306
|
// Set only when it changes: a key sets it false, and React would draw
|
|
330
|
-
// the whole editor again for the first key after a click
|
|
307
|
+
// the whole editor again for the first key after a click.
|
|
331
308
|
const selectingRef = useRef(false);
|
|
332
309
|
const setSelecting = (next) => {
|
|
333
310
|
if (selectingRef.current === next)
|
|
@@ -377,7 +354,6 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
377
354
|
}, [fullScreen]);
|
|
378
355
|
// The page behind full screen is inert meanwhile (rich-text-full-screen.ts).
|
|
379
356
|
useHoldFocus(field, fullScreen);
|
|
380
|
-
// The toolbar's Image button opens this file picker.
|
|
381
357
|
const imageInputRef = useRef(null);
|
|
382
358
|
// The fixed bar above the text, and the menus over it (the floating
|
|
383
359
|
// toolbar and the slash menu), which `'floating'` keeps on their own.
|
|
@@ -442,10 +418,9 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
442
418
|
const textTop = headingFrom === 'text' ? textTopHeading(original) : 1;
|
|
443
419
|
let baseline = null;
|
|
444
420
|
let cancelled = false;
|
|
445
|
-
// The last shownKey React drew.
|
|
446
421
|
let shown = '';
|
|
447
422
|
// The merge runs a pause after typing stops (MERGE_PAUSE_MS), not on
|
|
448
|
-
// every key: its cost grows with the note
|
|
423
|
+
// every key: its cost grows with the note. Anything about to read
|
|
449
424
|
// the value first asks for it (flushPendingEdits, src/lib/pending-edits.ts),
|
|
450
425
|
// and leaving the text, Esc, Ctrl/Cmd+Enter, hiding the page and
|
|
451
426
|
// unmounting report it at once.
|
|
@@ -658,7 +633,7 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
658
633
|
return false;
|
|
659
634
|
},
|
|
660
635
|
// Moving to the floating toolbar keeps it showing.
|
|
661
|
-
// Leaving the text reports what was typed
|
|
636
|
+
// Leaving the text reports what was typed.
|
|
662
637
|
blur: (_view, event) => {
|
|
663
638
|
emit();
|
|
664
639
|
if (!inFloating(event.relatedTarget))
|
|
@@ -685,7 +660,7 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
685
660
|
handleKeyDown: (view, event) => {
|
|
686
661
|
setSelecting(false);
|
|
687
662
|
// Esc and Ctrl/Cmd+Enter are the field's (save, close): what
|
|
688
|
-
// was typed is reported before they reach it
|
|
663
|
+
// was typed is reported before they reach it.
|
|
689
664
|
if (event.key === 'Escape' || (event.key === 'Enter' && (event.metaKey || event.ctrlKey)))
|
|
690
665
|
emit();
|
|
691
666
|
// Alt+F10: to the floating toolbar when it shows, else the
|
|
@@ -934,7 +909,7 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
934
909
|
// The toolbar's Image button: the file picker, then each file picked
|
|
935
910
|
// uploaded in place of the selection, and focus back in the text.
|
|
936
911
|
const pickImages = () => imageInputRef.current?.click();
|
|
937
|
-
// The slash menu's Image
|
|
912
|
+
// The slash menu's Image: the "/…" goes, then the file picker;
|
|
938
913
|
// the images go in at the caret, where the "/" was.
|
|
939
914
|
// A tick later: Chrome opens no picker for a click made inside the
|
|
940
915
|
// editor's own keydown (Enter on the item); the key's activation lasts.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// A place on a hub page
|
|
2
|
+
// A place on a hub page: one of the app's modules, or a site
|
|
3
3
|
// outside it, as a small card in a strip across the top of the page.
|
|
4
4
|
//
|
|
5
5
|
// - The band: the place's icon, tinted with its categorical slot, and its
|
|
@@ -26,12 +26,11 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
26
26
|
// the sidebar's breakpoint (md) instead, so a hub's widgets start on the
|
|
27
27
|
// first screen: each place's icon in its slot's colour, its name and its
|
|
28
28
|
// number, a skeleton while that loads and a dash when it fails (Retry is
|
|
29
|
-
// the card's
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
// cut off at a fixed width, so a long note can't crowd the row.
|
|
29
|
+
// the card's). Each ModuleCard renders its chip beside its card, one shown
|
|
30
|
+
// at each width. The row scrolls inside itself and is `relative`, so a
|
|
31
|
+
// chip's sr-only text (absolutely placed) scrolls with it instead of
|
|
32
|
+
// widening the page. `noteOnChip` adds the note after the number, cut off
|
|
33
|
+
// at a fixed width so a long note can't crowd the row.
|
|
35
34
|
import { Children, createContext, useContext, useId } from 'react';
|
|
36
35
|
import { Link } from 'react-router';
|
|
37
36
|
import { AlertCircleIcon, ExternalLinkIcon } from 'lucide-react';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type To } from 'react-router';
|
|
3
|
+
import type { AppError } from '../../api/contracts.js';
|
|
4
|
+
import { type PlainDate } from '../../lib/plain-date.js';
|
|
5
|
+
export type MonthCalendarTone = 'neutral' | 'info' | 'success' | 'warning' | 'destructive';
|
|
6
|
+
/** One thing on a day. */
|
|
7
|
+
export type MonthCalendarItem = {
|
|
8
|
+
id: string | number;
|
|
9
|
+
/** Its day, `'YYYY-MM-DD'`. */
|
|
10
|
+
day: PlainDate;
|
|
11
|
+
title: string;
|
|
12
|
+
/** `'HH:MM'`, or none for all day. */
|
|
13
|
+
time?: string | null;
|
|
14
|
+
/** Its dot and mark (design-language.md "Semantic tones"). Defaults to `info`. */
|
|
15
|
+
tone?: MonthCalendarTone;
|
|
16
|
+
/** Where its row in the day's list goes. */
|
|
17
|
+
to?: To;
|
|
18
|
+
/** A word after the time in the day's list ("Visit"). */
|
|
19
|
+
detail?: string;
|
|
20
|
+
};
|
|
21
|
+
export type MonthCalendarProps = {
|
|
22
|
+
/** The month's name for a screen reader is added to this ("Events"). */
|
|
23
|
+
label: string;
|
|
24
|
+
items?: MonthCalendarItem[];
|
|
25
|
+
/** Today, `'YYYY-MM-DD'` in the app's zone (todayIn). */
|
|
26
|
+
today: PlainDate;
|
|
27
|
+
/** The picked day, when the app holds it. */
|
|
28
|
+
selected?: PlainDate;
|
|
29
|
+
/** A day picked by click, Enter or the arrows; the app says what that does. */
|
|
30
|
+
onSelect?: (day: PlainDate) => void;
|
|
31
|
+
/** The month shown, `'YYYY-MM'`, when the app holds it. Defaults to the picked day's. */
|
|
32
|
+
month?: string;
|
|
33
|
+
onMonthChange?: (month: string) => void;
|
|
34
|
+
/** The app's actions for the picked day, beside its heading (an Add button). */
|
|
35
|
+
dayActions?: (day: PlainDate) => ReactNode;
|
|
36
|
+
/** The first day of the week. Defaults to Monday. */
|
|
37
|
+
weekStart?: 'MO' | 'SU';
|
|
38
|
+
isLoading?: boolean;
|
|
39
|
+
error?: AppError | null;
|
|
40
|
+
onRetry?: () => void;
|
|
41
|
+
/** Over the days when the month has nothing. Defaults to "Nothing this month". */
|
|
42
|
+
emptyText?: ReactNode;
|
|
43
|
+
locale?: string;
|
|
44
|
+
className?: string;
|
|
45
|
+
};
|
|
46
|
+
export declare function MonthCalendar({ label, items, today, selected, onSelect, month, onMonthChange, dayActions, weekStart, isLoading, error, onRetry, emptyText, locale, className, }: MonthCalendarProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// A month of days holding the app's items: events,
|
|
3
|
+
// visits, anything with a day. On a laptop each day shows its items by
|
|
4
|
+
// title, two to a day and the rest folded to a count; on a phone each day
|
|
5
|
+
// shows a dot per item in its tone. The picked day's items are listed
|
|
6
|
+
// under the month, each a link, with the app's own actions for that day
|
|
7
|
+
// beside its heading (Add, say). Not a date picker: that's `Calendar`.
|
|
8
|
+
//
|
|
9
|
+
// The month is a grid (role="grid", a table): one tab stop on the picked
|
|
10
|
+
// day, the arrows move it a day or a week, Home and End to the week's
|
|
11
|
+
// ends, Page Up and Page Down a month, Enter or a click picks it. Moving
|
|
12
|
+
// past the month's edge turns the page. Every day is a plain day
|
|
13
|
+
// (`'YYYY-MM-DD'`), never an instant, so no zone shifts one.
|
|
14
|
+
//
|
|
15
|
+
// Four states: loading (the month's frame with placeholders), error
|
|
16
|
+
// (ErrorState in place of the days, the arrows still there), empty
|
|
17
|
+
// ("Nothing this month" over the days) and success.
|
|
18
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
19
|
+
import { ChevronLeftIcon, ChevronRightIcon } from 'lucide-react';
|
|
20
|
+
import { Link } from 'react-router';
|
|
21
|
+
import { cn } from 'cn';
|
|
22
|
+
import { Button } from '../ui/button.js';
|
|
23
|
+
import { Skeleton } from '../ui/skeleton.js';
|
|
24
|
+
import { formatPlainDate, localToPlainDate } from '../../lib/plain-date.js';
|
|
25
|
+
import { ErrorState } from './error-state.js';
|
|
26
|
+
const TONE_DOT = {
|
|
27
|
+
neutral: 'bg-muted-foreground',
|
|
28
|
+
info: 'bg-info',
|
|
29
|
+
success: 'bg-success',
|
|
30
|
+
warning: 'bg-warning',
|
|
31
|
+
destructive: 'bg-destructive',
|
|
32
|
+
};
|
|
33
|
+
const pad = (value) => String(value).padStart(2, '0');
|
|
34
|
+
const monthOf = (day) => day.slice(0, 7);
|
|
35
|
+
function parts(day) {
|
|
36
|
+
const [year, month, date] = day.split('-').map(Number);
|
|
37
|
+
return [year, month, date];
|
|
38
|
+
}
|
|
39
|
+
function shift(day, days) {
|
|
40
|
+
const [year, month, date] = parts(day);
|
|
41
|
+
return localToPlainDate(new Date(year, month - 1, date + days));
|
|
42
|
+
}
|
|
43
|
+
function shiftMonth(month, by) {
|
|
44
|
+
const [year, number] = month.split('-').map(Number);
|
|
45
|
+
const next = new Date(year, number - 1 + by, 1);
|
|
46
|
+
return `${next.getFullYear()}-${pad(next.getMonth() + 1)}`;
|
|
47
|
+
}
|
|
48
|
+
/** The same day in another month, or that month's last day. */
|
|
49
|
+
function sameDayIn(day, month) {
|
|
50
|
+
const [year, number] = month.split('-').map(Number);
|
|
51
|
+
const last = new Date(year, number, 0).getDate();
|
|
52
|
+
return `${month}-${pad(Math.min(parts(day)[2], last))}`;
|
|
53
|
+
}
|
|
54
|
+
function clock(time, locale) {
|
|
55
|
+
const [hour, minute] = time.split(':').map(Number);
|
|
56
|
+
return new Intl.DateTimeFormat(locale, { hour: 'numeric', minute: '2-digit', timeZone: 'UTC' }).format(Date.UTC(2001, 0, 1, hour, minute));
|
|
57
|
+
}
|
|
58
|
+
/** Monday 0 … Sunday 6. */
|
|
59
|
+
function weekdayIndex(day) {
|
|
60
|
+
const [year, month, date] = parts(day);
|
|
61
|
+
return (new Date(Date.UTC(year, month - 1, date)).getUTCDay() + 6) % 7;
|
|
62
|
+
}
|
|
63
|
+
const byTime = (a, b) => (a.time ?? '').localeCompare(b.time ?? '');
|
|
64
|
+
export function MonthCalendar({ label, items = [], today, selected, onSelect, month, onMonthChange, dayActions, weekStart = 'MO', isLoading, error, onRetry, emptyText = 'Nothing this month', locale, className, }) {
|
|
65
|
+
const [ownSelected, setOwnSelected] = useState(selected ?? today);
|
|
66
|
+
const picked = selected ?? ownSelected;
|
|
67
|
+
const [ownMonth, setOwnMonth] = useState(month ?? monthOf(picked));
|
|
68
|
+
const shown = month ?? ownMonth;
|
|
69
|
+
const gridRef = useRef(null);
|
|
70
|
+
const focusAfter = useRef(false);
|
|
71
|
+
const byDay = useMemo(() => {
|
|
72
|
+
const map = new Map();
|
|
73
|
+
for (const item of items)
|
|
74
|
+
map.set(item.day, [...(map.get(item.day) ?? []), item]);
|
|
75
|
+
for (const list of map.values())
|
|
76
|
+
list.sort(byTime);
|
|
77
|
+
return map;
|
|
78
|
+
}, [items]);
|
|
79
|
+
function showMonth(next) {
|
|
80
|
+
if (month === undefined)
|
|
81
|
+
setOwnMonth(next);
|
|
82
|
+
onMonthChange?.(next);
|
|
83
|
+
}
|
|
84
|
+
function pick(day, focus = false) {
|
|
85
|
+
if (selected === undefined)
|
|
86
|
+
setOwnSelected(day);
|
|
87
|
+
onSelect?.(day);
|
|
88
|
+
if (monthOf(day) !== shown)
|
|
89
|
+
showMonth(monthOf(day));
|
|
90
|
+
focusAfter.current = focus;
|
|
91
|
+
}
|
|
92
|
+
// After a key moves the pick, the focus follows it (into the new month too).
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (!focusAfter.current)
|
|
95
|
+
return;
|
|
96
|
+
focusAfter.current = false;
|
|
97
|
+
gridRef.current?.querySelector(`[data-day="${picked}"]`)?.focus();
|
|
98
|
+
});
|
|
99
|
+
const firstDay = `${shown}-01`;
|
|
100
|
+
const [year, monthNumber] = shown.split('-').map(Number);
|
|
101
|
+
const daysIn = new Date(year, monthNumber, 0).getDate();
|
|
102
|
+
const startIndex = weekStart === 'SU' ? 6 : 0;
|
|
103
|
+
const lead = (weekdayIndex(firstDay) - startIndex + 7) % 7;
|
|
104
|
+
const weeks = [];
|
|
105
|
+
for (let cell = 0; cell < Math.ceil((lead + daysIn) / 7) * 7; cell++) {
|
|
106
|
+
const date = cell - lead + 1;
|
|
107
|
+
if (cell % 7 === 0)
|
|
108
|
+
weeks.push([]);
|
|
109
|
+
weeks[weeks.length - 1].push(date >= 1 && date <= daysIn ? `${shown}-${pad(date)}` : null);
|
|
110
|
+
}
|
|
111
|
+
const weekdayNames = Array.from({ length: 7 }, (_, i) => {
|
|
112
|
+
// 2024-01-01 was a Monday.
|
|
113
|
+
const at = Date.UTC(2024, 0, 1 + ((i + startIndex) % 7));
|
|
114
|
+
return {
|
|
115
|
+
short: new Intl.DateTimeFormat(locale, { weekday: 'short', timeZone: 'UTC' }).format(at),
|
|
116
|
+
narrow: new Intl.DateTimeFormat(locale, { weekday: 'narrow', timeZone: 'UTC' }).format(at),
|
|
117
|
+
long: new Intl.DateTimeFormat(locale, { weekday: 'long', timeZone: 'UTC' }).format(at),
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
const monthName = formatPlainDate(firstDay, { month: 'long', year: 'numeric' }, locale);
|
|
121
|
+
const monthHasItems = items.some((item) => monthOf(item.day) === shown);
|
|
122
|
+
// The pick the grid's tab stop sits on: in this month, or its first day.
|
|
123
|
+
const stop = monthOf(picked) === shown ? picked : firstDay;
|
|
124
|
+
function onKeyDown(event, day) {
|
|
125
|
+
const index = (weekdayIndex(day) - startIndex + 7) % 7;
|
|
126
|
+
const moves = {
|
|
127
|
+
ArrowLeft: () => shift(day, -1),
|
|
128
|
+
ArrowRight: () => shift(day, 1),
|
|
129
|
+
ArrowUp: () => shift(day, -7),
|
|
130
|
+
ArrowDown: () => shift(day, 7),
|
|
131
|
+
Home: () => shift(day, -index),
|
|
132
|
+
End: () => shift(day, 6 - index),
|
|
133
|
+
PageUp: () => sameDayIn(day, shiftMonth(monthOf(day), -1)),
|
|
134
|
+
PageDown: () => sameDayIn(day, shiftMonth(monthOf(day), 1)),
|
|
135
|
+
};
|
|
136
|
+
if (moves[event.key]) {
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
pick(moves[event.key](), true);
|
|
139
|
+
}
|
|
140
|
+
else if (event.key === 'Enter' || event.key === ' ') {
|
|
141
|
+
event.preventDefault();
|
|
142
|
+
pick(day, true);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const dayLabel = (day) => formatPlainDate(day, { weekday: 'long', month: 'long', day: 'numeric' }, locale);
|
|
146
|
+
const pickedItems = byDay.get(picked) ?? [];
|
|
147
|
+
return (_jsxs("div", { "data-slot": "month-calendar", className: cn('flex min-w-0 flex-col gap-3', className), children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("h2", { className: "mr-auto type-body font-semibold text-foreground", "aria-live": "polite", children: monthName }), _jsx(Button, { variant: "outline", size: "icon-sm", "aria-label": "Previous month", onClick: () => showMonth(shiftMonth(shown, -1)), children: _jsx(ChevronLeftIcon, { "aria-hidden": "true" }) }), _jsx(Button, { variant: "outline", size: "sm", onClick: () => pick(today), children: "Today" }), _jsx(Button, { variant: "outline", size: "icon-sm", "aria-label": "Next month", onClick: () => showMonth(shiftMonth(shown, 1)), children: _jsx(ChevronRightIcon, { "aria-hidden": "true" }) })] }), error ? (_jsx(ErrorState, { error: error, onRetry: onRetry })) : (_jsxs(_Fragment, { children: [!isLoading && !monthHasItems && (_jsx("p", { "data-slot": "month-calendar-empty", className: "text-sm text-muted-foreground", children: emptyText })), _jsxs("table", { ref: gridRef, role: "grid", "aria-label": `${label}, ${monthName}`, "aria-busy": isLoading || undefined, className: "w-full table-fixed border-separate border-spacing-0 overflow-hidden rounded-md border-t border-l border-border", children: [_jsx("thead", { children: _jsx("tr", { children: weekdayNames.map((name) => (_jsxs("th", { scope: "col", abbr: name.long, className: "border-r border-b border-border bg-muted/40 px-1 py-1 text-left text-xs font-medium text-muted-foreground uppercase max-md:text-center", children: [_jsx("span", { className: "sr-only", children: name.long }), _jsx("span", { className: "max-md:hidden", "aria-hidden": "true", children: name.short }), _jsx("span", { className: "md:hidden", "aria-hidden": "true", children: name.narrow })] }, name.long))) }) }), _jsx("tbody", { children: weeks.map((week, row) => (_jsx("tr", { children: week.map((day, column) => {
|
|
148
|
+
if (!day)
|
|
149
|
+
return _jsx("td", { className: "border-r border-b border-border bg-muted/20" }, column);
|
|
150
|
+
const list = byDay.get(day) ?? [];
|
|
151
|
+
const isToday = day === today;
|
|
152
|
+
const isPicked = day === picked;
|
|
153
|
+
const count = list.length;
|
|
154
|
+
return (_jsxs("td", { "data-day": day, "aria-selected": isPicked, "aria-current": isToday ? 'date' : undefined, tabIndex: day === stop ? 0 : -1, onClick: () => pick(day), onKeyDown: (event) => onKeyDown(event, day), className: cn('h-11 cursor-pointer border-r border-b border-border bg-card p-1 align-top outline-none md:h-20', 'hover:bg-muted/40 focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:ring-inset', isPicked && 'shadow-[inset_0_0_0_2px_var(--color-ring)]'), children: [_jsxs("span", { className: "sr-only", children: [`${dayLabel(day)}${isToday ? ', today' : ''}, ${count === 0 ? 'nothing' : count === 1 ? '1 item' : `${count} items`}`, count > 0 && `: ${list.map((item) => item.title).join(', ')}`] }), _jsxs("div", { className: "flex flex-col max-md:items-center", "aria-hidden": "true", children: [_jsx("span", { className: cn('w-fit rounded px-1 text-xs tabular-nums', isToday ? 'bg-primary font-semibold text-primary-foreground' : 'text-muted-foreground'), children: Number(day.slice(8)) }), isLoading ? (_jsx(Skeleton, { className: "mt-1 h-3 w-3/4 max-md:hidden" })) : (_jsxs(_Fragment, { children: [_jsxs("ul", { className: "mt-0.5 flex min-w-0 flex-col gap-0.5 max-md:hidden", children: [list.slice(0, 2).map((item) => (_jsxs("li", { className: "flex min-w-0 items-center gap-1 text-xs text-foreground", children: [_jsx("span", { className: cn('size-1.5 shrink-0 rounded-full', TONE_DOT[item.tone ?? 'info']) }), _jsx("span", { className: "truncate", children: item.title })] }, item.id))), count > 2 && _jsxs("li", { className: "pl-2.5 text-xs text-muted-foreground", children: ["+", count - 2, " more"] })] }), count > 0 && (_jsx("span", { className: "mt-1 flex justify-center gap-0.5 md:hidden", children: list.slice(0, 4).map((item) => (_jsx("span", { className: cn('size-1.5 rounded-full', TONE_DOT[item.tone ?? 'info']) }, item.id))) }))] }))] })] }, day));
|
|
155
|
+
}) }, row))) })] }), _jsxs("div", { role: "group", "aria-label": `${dayLabel(picked)}${picked === today ? ', today' : ''}`, "data-slot": "month-calendar-day", className: "flex flex-col gap-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsxs("h3", { className: cn('mr-auto text-sm font-semibold', picked === today ? 'text-link' : 'text-foreground'), children: [dayLabel(picked), picked === today && ' · Today'] }), dayActions?.(picked)] }), isLoading ? (_jsxs("div", { className: "flex flex-col gap-2 py-1", children: [_jsx(Skeleton, { className: "h-4 w-2/3" }), _jsx(Skeleton, { className: "h-4 w-1/2" })] })) : pickedItems.length === 0 ? (_jsx("p", { className: "border-t border-border py-1.5 text-sm text-muted-foreground", children: "Nothing that day." })) : (_jsx("ul", { className: "flex flex-col", children: pickedItems.map((item) => {
|
|
156
|
+
const when = [item.time ? clock(item.time, locale) : 'All day', item.detail].filter(Boolean).join(' · ');
|
|
157
|
+
const body = (_jsxs(_Fragment, { children: [_jsx("span", { className: cn('size-2 shrink-0 rounded-full', TONE_DOT[item.tone ?? 'info']), "aria-hidden": "true" }), _jsx("span", { className: "min-w-0 flex-1 truncate", children: item.title }), _jsx("span", { className: "shrink-0 text-xs text-muted-foreground", children: when })] }));
|
|
158
|
+
return (_jsx("li", { className: "border-t border-border", children: item.to ? (_jsx(Link, { to: item.to, className: "flex min-h-10 items-center gap-2 py-1.5 text-sm text-foreground outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50", children: body })) : (_jsx("div", { className: "flex min-h-10 items-center gap-2 py-1.5 text-sm text-foreground", children: body })) }, item.id));
|
|
159
|
+
}) }))] })] }))] }));
|
|
160
|
+
}
|
|
@@ -44,7 +44,6 @@ function moveInGrid(key, at, count, columns) {
|
|
|
44
44
|
return null;
|
|
45
45
|
return Math.min(Math.max(next, 0), count - 1);
|
|
46
46
|
}
|
|
47
|
-
// The month after (or before) one, round the year.
|
|
48
47
|
const nextMonth = (month, by) => ((month - 1 + by + 12) % 12) + 1;
|
|
49
48
|
export function MonthDayField({ id, value, onChange, placeholder = 'Pick a day', clearable = false, invalid = false, readOnly = false, defaultOpen = false, modal, onOpenChange, format, locale, className, ...aria }) {
|
|
50
49
|
const [open, setOpen] = useState(defaultOpen && !readOnly);
|
|
@@ -4,7 +4,7 @@ import type { OptionSelectOption } from './option-select.js';
|
|
|
4
4
|
export type MultiChoiceOption<T extends string> = OptionSelectOption<T>;
|
|
5
5
|
export type MultiChoiceProps<T extends string> = {
|
|
6
6
|
/**
|
|
7
|
-
* Every allowed option, in display order: bare values, or
|
|
7
|
+
* Every allowed option, in display order: bare values, or
|
|
8
8
|
* OptionSelect's `{ value, label, kind?, icon? }`, whose `label` names it
|
|
9
9
|
* and whose `kind` or `icon` is drawn before the words, as OptionSelect
|
|
10
10
|
* draws it.
|
|
@@ -11,10 +11,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
// typed-text match all use the label, and the value is what's emitted.
|
|
12
12
|
//
|
|
13
13
|
// A toolbar filter's summary ("Status: Active +1", `label`) keeps the
|
|
14
|
-
// control one line high however narrow it is
|
|
14
|
+
// control one line high however narrow it is: it truncates, and
|
|
15
15
|
// the text box beside it takes no room until it's focused.
|
|
16
16
|
//
|
|
17
|
-
// An option can carry a status kind or an icon
|
|
17
|
+
// An option can carry a status kind or an icon, as OptionSelect's
|
|
18
18
|
// and ChoiceButtons' do, drawn by the same OptionIcon: pass the options as
|
|
19
19
|
// `{ value, label, kind?, icon? }` (OptionSelectOption) in place of bare
|
|
20
20
|
// values. The icon goes before the words on the option in the list, on its
|
|
@@ -49,7 +49,7 @@ export function MultiChoice({ options, value, onValueChange, getLabel, id, place
|
|
|
49
49
|
const summarised = label !== undefined && value.length > 0;
|
|
50
50
|
return (_jsxs(Combobox, { multiple: true, autoHighlight: true, items: values, value: value, onValueChange: (next, details) => {
|
|
51
51
|
// Base UI empties the value on Escape while the list is closed, so
|
|
52
|
-
// a second Escape after a pick wiped every chip
|
|
52
|
+
// a second Escape after a pick wiped every chip. Escape
|
|
53
53
|
// never removes picks here: a chip's remove button, Backspace or
|
|
54
54
|
// unpicking in the list does. Let the key go on, so a dialog or an
|
|
55
55
|
// edit in place gets its own Escape.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
// Several values over time on one plot
|
|
2
|
+
// Several values over time on one plot: a net worth beside its
|
|
3
3
|
// assets and debts, or a balance's history beside low, middle and high
|
|
4
4
|
// projections. LineChart's sibling, plain SVG the same way: each series is
|
|
5
5
|
// its own <svg> drawing in currentColor in a text tone, so the package's
|
|
@@ -22,15 +22,15 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
22
22
|
// - Keyboard: the filter box first; Down goes to the chips, Left/Right
|
|
23
23
|
// (Home/End) move along them, Up goes back to the box, and Space or
|
|
24
24
|
// Enter toggles a chip.
|
|
25
|
-
// - Every multi-pick
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
// - `onCreate
|
|
32
|
-
//
|
|
33
|
-
//
|
|
25
|
+
// - Every multi-pick: the chips wrap at every width, under the filter box
|
|
26
|
+
// (the form standard). Past `limit` options (30) it shows the picked ones
|
|
27
|
+
// and the first 30, then "Show all N"; a filter searches them all. The
|
|
28
|
+
// options can be the app's list of records (its query's rows as
|
|
29
|
+
// `{ id, label }`, `loading` while it loads), so a link to several other
|
|
30
|
+
// records uses it too.
|
|
31
|
+
// - `onCreate`: when what's typed names no option, Create "<typed>" shows
|
|
32
|
+
// under the chips (Enter in the box does the same when nothing matches;
|
|
33
|
+
// Down reaches it when there are no chips). It calls the app's
|
|
34
34
|
// `onCreate(name)`: its small create form with the name filled in, or a
|
|
35
35
|
// save straight away. While that's out the button reads Creating
|
|
36
36
|
// "<typed>"… (`aria-busy`), the box can't change, and an edit in place
|
|
@@ -104,7 +104,6 @@ export function MultiPick({ options, value, onValueChange, onPick, 'aria-label':
|
|
|
104
104
|
next.set(option, { ...entry, inFlight });
|
|
105
105
|
return next;
|
|
106
106
|
});
|
|
107
|
-
// Edited in place: one pick saved on its own.
|
|
108
107
|
const savePick = (option, picked, save) => {
|
|
109
108
|
setRefused((current) => without(current, option.id));
|
|
110
109
|
setPending((current) => new Map(current).set(option.id, { picked, inFlight: (current.get(option.id)?.inFlight ?? 0) + 1 }));
|
|
@@ -17,7 +17,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
17
17
|
// results, its first still highlighted. `searching` says so: Enter
|
|
18
18
|
// waits rather than picking from the old list (where it could even
|
|
19
19
|
// remove a pick: the highlighted item may be one already picked).
|
|
20
|
-
// - `onCreate
|
|
20
|
+
// - `onCreate`: Create "<typed>" as the list's last item when
|
|
21
21
|
// what's typed names no option; the app's create form resolves with the
|
|
22
22
|
// new record, which joins the picks (its name kept here until the app's
|
|
23
23
|
// lookup has it).
|
|
@@ -59,7 +59,7 @@ export function MultiReference({ options, value, onValueChange, getLabel, onSear
|
|
|
59
59
|
// with Object.is, so the items must have the value's own shape.
|
|
60
60
|
items: items, value: value, onValueChange: (next, details) => {
|
|
61
61
|
// Base UI empties the value on Escape while the list is closed, so
|
|
62
|
-
// a second Escape after a pick wiped every chip
|
|
62
|
+
// a second Escape after a pick wiped every chip. Escape
|
|
63
63
|
// never removes picks here: a chip's remove button, Backspace or
|
|
64
64
|
// unpicking in the list does. Let the key go on, so a dialog or an
|
|
65
65
|
// edit in place gets its own Escape.
|
|
@@ -17,7 +17,6 @@ import { Button } from '../ui/button.js';
|
|
|
17
17
|
import { useFolds } from '../../hooks/fold-store.js';
|
|
18
18
|
import { usePrefersReducedMotion } from '../../hooks/use-prefers-reduced-motion.js';
|
|
19
19
|
import { allFoldable, markdownFoldPlan, openTo } from '../../lib/markdown-fold.js';
|
|
20
|
-
// Each level's indent, from the highest listed.
|
|
21
20
|
const INDENT = ['pl-2', 'pl-6', 'pl-10', 'pl-14', 'pl-18', 'pl-22'];
|
|
22
21
|
// The element showing the heading `id` in the text under `foldKey`.
|
|
23
22
|
function headingElement(foldKey, id) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
// The words and the lifetimes of the app's toasts (
|
|
2
|
+
// The words and the lifetimes of the app's toasts (the dialogs and
|
|
3
3
|
// feedback standard D5, D6). A toast is for what happened out of sight: a
|
|
4
4
|
// delete (with Undo), a record made somewhere else, a job that finished
|
|
5
5
|
// after the page was left. Never after an edit in place, which shows its
|
|
6
|
-
// own "Saved" (cell-patterns.md, add-an-entity.md "
|
|
6
|
+
// own "Saved" (cell-patterns.md, add-an-entity.md "Toasts and feedback").
|
|
7
7
|
//
|
|
8
8
|
// - `notify.done("Deleted", "The Long Walk", { undo })`: "Deleted The Long
|
|
9
9
|
// Walk", the verb first, the same way everywhere, for 4 seconds. With
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// "You're offline" across the top of the app (
|
|
2
|
+
// "You're offline" across the top of the app (the dialogs and
|
|
3
3
|
// feedback standard D9), while the server can't be reached: the browser
|
|
4
4
|
// says it's offline, or a request got no answer at all. Gone as soon as
|
|
5
5
|
// the browser is back online or any request gets an answer. AppShell
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
// An option's icon, shared by ChoiceButtons and OptionSelect
|
|
2
|
+
// An option's icon, shared by ChoiceButtons and OptionSelect: a
|
|
3
3
|
// status kind's icon in its colour (StatusMark's, lib/status-kinds.ts), or
|
|
4
4
|
// the option's own icon, uncoloured without a kind. Decorative: the
|
|
5
5
|
// option's word says it.
|
|
@@ -4,7 +4,7 @@ import type { IconComponent } from './icon-component.js';
|
|
|
4
4
|
export type OptionSelectOption<T> = {
|
|
5
5
|
value: T;
|
|
6
6
|
label: string;
|
|
7
|
-
/** A status kind
|
|
7
|
+
/** A status kind: its icon, in its colour, before the words, as StatusMark and ChoiceButtons draw it. */
|
|
8
8
|
kind?: StatusKind;
|
|
9
9
|
/** An icon before the words; with `kind`, in place of the kind's. Uncoloured without a `kind`. */
|
|
10
10
|
icon?: IconComponent;
|
|
@@ -27,7 +27,7 @@ export type OverviewPart = {
|
|
|
27
27
|
error?: AppError | null;
|
|
28
28
|
onRetry?: () => void;
|
|
29
29
|
};
|
|
30
|
-
/** A page outside the app
|
|
30
|
+
/** A page outside the app, in the overview's Links section. */
|
|
31
31
|
export type OverviewLink = {
|
|
32
32
|
label: string;
|
|
33
33
|
/** The page's address: opened in a new tab. */
|
|
@@ -45,7 +45,7 @@ export type OverviewPageProps = {
|
|
|
45
45
|
stats?: ReactNode;
|
|
46
46
|
/** Controls at the title's end. */
|
|
47
47
|
actions?: ReactNode;
|
|
48
|
-
/** Pages outside the app
|
|
48
|
+
/** Pages outside the app: one section after the parts, each opening in a new tab. */
|
|
49
49
|
links?: readonly OverviewLink[];
|
|
50
50
|
/** The links section's heading. Defaults to "Links". */
|
|
51
51
|
linksTitle?: string;
|
|
@@ -19,7 +19,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
19
19
|
// `onRetry` in the card), and `empty` (a part with nothing yet: "Nothing
|
|
20
20
|
// yet" in the tile, PartEmpty with its one way to start in the card).
|
|
21
21
|
//
|
|
22
|
-
// `links`
|
|
22
|
+
// `links` are a short list of pages outside the app (the
|
|
23
23
|
// module's account page, a supplier's site): one section after the parts,
|
|
24
24
|
// titled `linksTitle` ("Links"), each link its label with its icon if it
|
|
25
25
|
// has one and the external-link mark, opening in a new tab. In a row of
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// The trail in AppShell's bar
|
|
1
|
+
// The trail in AppShell's bar: a page names where it is with
|
|
2
2
|
// `usePageTrail`, and the shell draws it between the menu button and the
|
|
3
3
|
// search box. Pages that set none get their nav entry's (navTrail).
|
|
4
4
|
import { createContext, useContext, useLayoutEffect } from 'react';
|