@tristan2828/ui-foundation 4.96.0 → 4.98.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/conventions/AGENTS.md +1 -1
- package/conventions/docs/add-an-entity.md +92 -64
- package/conventions/docs/cell-patterns.md +64 -54
- package/conventions/docs/design-language.md +168 -76
- package/conventions/docs/entity-plan-template.md +15 -21
- package/conventions/docs/reminders.md +2 -2
- package/conventions/docs/timed-screens.md +1 -1
- package/dist/components/app/action-error.js +1 -1
- package/dist/components/app/allow-reminders.js +1 -1
- package/dist/components/app/app-shell.js +4 -4
- package/dist/components/app/board.js +1 -1
- package/dist/components/app/choice-buttons.js +6 -1
- package/dist/components/app/data-table-tools.js +2 -2
- package/dist/components/app/data-table.js +4 -4
- package/dist/components/app/date-field.js +1 -1
- package/dist/components/app/emoji-field-data.js +7 -7
- package/dist/components/app/entity-form.js +1 -1
- package/dist/components/app/entity-view.d.ts +29 -11
- package/dist/components/app/entity-view.js +106 -29
- package/dist/components/app/error-state.js +1 -1
- package/dist/components/app/field-rows.js +6 -3
- package/dist/components/app/fill-in-queue.js +2 -2
- package/dist/components/app/filter-bar.js +1 -1
- package/dist/components/app/form-dialog.js +1 -1
- package/dist/components/app/form-section.d.ts +1 -1
- package/dist/components/app/image-field.js +3 -2
- package/dist/components/app/key-stats.d.ts +3 -1
- package/dist/components/app/key-stats.js +2 -2
- package/dist/components/app/list-header.js +2 -2
- package/dist/components/app/milkdown-editor.js +4 -4
- package/dist/components/app/month-day-field.js +3 -3
- package/dist/components/app/multi-pick.js +1 -1
- package/dist/components/app/needs-you.js +1 -1
- package/dist/components/app/notes-outline.js +1 -1
- package/dist/components/app/password-input.js +1 -1
- package/dist/components/app/record-dialog-context.d.ts +9 -0
- package/dist/components/app/record-dialog.d.ts +8 -1
- package/dist/components/app/record-dialog.js +19 -3
- package/dist/components/app/rich-text-format-items.js +6 -6
- package/dist/components/app/rich-text-highlight-menu.js +1 -1
- package/dist/components/app/rich-text-table-grips.js +16 -16
- package/dist/components/app/rich-text-toolbar.js +2 -2
- package/dist/components/app/rich-text-widgets.js +2 -2
- package/dist/components/app/secondary-filters.js +2 -2
- package/dist/components/app/session-view.js +1 -1
- package/dist/components/app/status-mark.d.ts +17 -0
- package/dist/components/app/status-mark.js +12 -0
- package/dist/components/app/timeline.js +1 -1
- package/dist/components/app/widget-layout-sheet.js +1 -1
- package/dist/components/ui/combobox.js +1 -1
- package/dist/components/ui/dialog.js +1 -1
- package/dist/components/ui/field.d.ts +3 -2
- package/dist/components/ui/field.js +13 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/lib/field-rows.d.ts +3 -1
- package/dist/lib/field-rows.js +24 -6
- package/dist/lib/group-by-day.js +2 -2
- package/dist/lib/status-kinds.d.ts +10 -0
- package/dist/lib/status-kinds.js +33 -0
- package/dist/lib/title-case.d.ts +13 -0
- package/dist/lib/title-case.js +66 -0
- package/dist/routes/login.js +4 -4
- package/dist/routes/register.js +1 -1
- package/package.json +1 -1
- package/styles/index.css +9 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const EMOJI_GROUPS = [
|
|
2
2
|
{
|
|
3
|
-
label: 'Morning and
|
|
3
|
+
label: 'Morning and Sleep',
|
|
4
4
|
emojis: [
|
|
5
5
|
{ emoji: '☀️', name: 'Sun', keywords: 'morning day bright' },
|
|
6
6
|
{ emoji: '🌅', name: 'Sunrise', keywords: 'morning dawn' },
|
|
@@ -13,7 +13,7 @@ export const EMOJI_GROUPS = [
|
|
|
13
13
|
],
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
|
-
label: 'Body and
|
|
16
|
+
label: 'Body and Health',
|
|
17
17
|
emojis: [
|
|
18
18
|
{ emoji: '🧘', name: 'Person in lotus position', keywords: 'yoga meditate breathe calm' },
|
|
19
19
|
{ emoji: '🏃', name: 'Person running', keywords: 'run exercise workout cardio' },
|
|
@@ -45,7 +45,7 @@ export const EMOJI_GROUPS = [
|
|
|
45
45
|
],
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
|
-
label: 'Food and
|
|
48
|
+
label: 'Food and Drink',
|
|
49
49
|
emojis: [
|
|
50
50
|
{ emoji: '🍳', name: 'Cooking', keywords: 'breakfast egg pan' },
|
|
51
51
|
{ emoji: '🥣', name: 'Bowl with spoon', keywords: 'cereal oatmeal breakfast' },
|
|
@@ -61,7 +61,7 @@ export const EMOJI_GROUPS = [
|
|
|
61
61
|
],
|
|
62
62
|
},
|
|
63
63
|
{
|
|
64
|
-
label: 'Home and
|
|
64
|
+
label: 'Home and Chores',
|
|
65
65
|
emojis: [
|
|
66
66
|
{ emoji: '🏠', name: 'House', keywords: 'home' },
|
|
67
67
|
{ emoji: '🧹', name: 'Broom', keywords: 'sweep clean chores' },
|
|
@@ -80,7 +80,7 @@ export const EMOJI_GROUPS = [
|
|
|
80
80
|
],
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
|
-
label: 'Work and
|
|
83
|
+
label: 'Work and Learning',
|
|
84
84
|
emojis: [
|
|
85
85
|
{ emoji: '💻', name: 'Laptop', keywords: 'computer work code' },
|
|
86
86
|
{ emoji: '📧', name: 'Email', keywords: 'mail inbox' },
|
|
@@ -99,7 +99,7 @@ export const EMOJI_GROUPS = [
|
|
|
99
99
|
],
|
|
100
100
|
},
|
|
101
101
|
{
|
|
102
|
-
label: 'Play and
|
|
102
|
+
label: 'Play and Music',
|
|
103
103
|
emojis: [
|
|
104
104
|
{ emoji: '🎵', name: 'Musical note', keywords: 'music song' },
|
|
105
105
|
{ emoji: '🎧', name: 'Headphones', keywords: 'music podcast listen' },
|
|
@@ -114,7 +114,7 @@ export const EMOJI_GROUPS = [
|
|
|
114
114
|
],
|
|
115
115
|
},
|
|
116
116
|
{
|
|
117
|
-
label: 'Outside and
|
|
117
|
+
label: 'Outside and Travel',
|
|
118
118
|
emojis: [
|
|
119
119
|
{ emoji: '🚶', name: 'Person walking', keywords: 'walk steps' },
|
|
120
120
|
{ emoji: '🥾', name: 'Hiking boot', keywords: 'hike trail' },
|
|
@@ -121,7 +121,7 @@ export function EntityForm({ title, onSubmit, isSubmitting, submitError, onRetry
|
|
|
121
121
|
}
|
|
122
122
|
onCancel();
|
|
123
123
|
};
|
|
124
|
-
return (_jsxs("form", { ref: form, onSubmit: submit, noValidate: true, "data-slot": "entity-form", className: "flex max-w-xl flex-col gap-6", children: [_jsx("h1", { className: "type-page-title text-foreground", children: title }), _jsx(FieldGroup, { children: children }), _jsxs("div", { ref: bar, "data-slot": "entity-form-bar", className: "sticky z-10 -mt-3 flex flex-col gap-3 border-t border-border bg-background pt-3", children: [_jsx("div", { role: "status", className: "empty:hidden", children: submitError && (_jsx(Notice, { tone: "destructive", action: _jsx(Button, { type: "button", size: "sm", variant: "outline", disabled: isSubmitting, onClick: () => (onRetry ? onRetry() : form.current?.requestSubmit()), children: "Try
|
|
124
|
+
return (_jsxs("form", { ref: form, onSubmit: submit, noValidate: true, "data-slot": "entity-form", className: "flex max-w-xl flex-col gap-6", children: [_jsx("h1", { className: "type-page-title text-foreground", children: title }), _jsx(FieldGroup, { children: children }), _jsxs("div", { ref: bar, "data-slot": "entity-form-bar", className: "sticky z-10 -mt-3 flex flex-col gap-3 border-t border-border bg-background pt-3", children: [_jsx("div", { role: "status", className: "empty:hidden", children: submitError && (_jsx(Notice, { tone: "destructive", action: _jsx(Button, { type: "button", size: "sm", variant: "outline", disabled: isSubmitting, onClick: () => (onRetry ? onRetry() : form.current?.requestSubmit()), children: "Try Again" }), children: submitError.message })) }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [danger, _jsx("p", { role: "status", "data-slot": "entity-form-to-fix", className: "mr-auto type-label text-destructive-text empty:hidden", children: toFix > 0 ? `${toFix} to fix` : '' }), _jsxs("div", { className: "ml-auto flex gap-2 max-md:w-full max-md:[&>*]:flex-1", children: [_jsx(Button, { type: "button", variant: "outline", onClick: cancel, disabled: isSubmitting, children: "Cancel" }), _jsxs(Button, { type: "submit", disabled: isSubmitting, children: [isSubmitting && _jsx(Spinner, { className: "size-4" }), submitLabel] })] })] })] }), dirty !== undefined && _jsx(FormLeaveGuard, { dirty: dirty, letThrough: () => leaving.current || submitting.current }), _jsx(DiscardChangesDialog, { open: askingCancel, onKeepEditing: () => setAskingCancel(false), onDiscard: () => {
|
|
125
125
|
setAskingCancel(false);
|
|
126
126
|
leaving.current = true;
|
|
127
127
|
onCancel();
|
|
@@ -44,9 +44,12 @@ export type EntityViewSection = ({
|
|
|
44
44
|
edit?: EditInPlace | EditInPlaceList;
|
|
45
45
|
}) & {
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
47
|
+
* `rail` for the short facts (a summary, label/value fields, a few
|
|
48
|
+
* links), `main` (the default) for long text and long lists. In the
|
|
49
|
+
* `tabs` layout (the default) a `rail` section with no `tab` goes in the
|
|
50
|
+
* Details tab, and one with a `tab` in a narrow box beside that tab's
|
|
51
|
+
* sections (short facts only, never free text). In the `rail` layout it
|
|
52
|
+
* goes in the column on the right. The `column` layout ignores it.
|
|
50
53
|
*/
|
|
51
54
|
placement?: EntityViewPlacement;
|
|
52
55
|
/**
|
|
@@ -61,8 +64,9 @@ export type EntityViewSection = ({
|
|
|
61
64
|
answerSpace?: boolean;
|
|
62
65
|
};
|
|
63
66
|
/**
|
|
64
|
-
* The tab the section goes under, by name ("Steps", "Used in")
|
|
65
|
-
*
|
|
67
|
+
* The tab the section goes under, by name ("Steps", "Used in"). In the
|
|
68
|
+
* `tabs` layout a `rail` section with a tab sits beside the tab's own
|
|
69
|
+
* sections; in the others a `rail` one ignores it. Any main section with a tab
|
|
66
70
|
* adds a tab list to the main column, one tab per name in the order the
|
|
67
71
|
* sections first give it; sections without one stay above the list. The
|
|
68
72
|
* selected tab is in the address, `?tab=<slug of the name>`.
|
|
@@ -71,11 +75,14 @@ export type EntityViewSection = ({
|
|
|
71
75
|
};
|
|
72
76
|
export type EntityViewPlacement = 'main' | 'rail';
|
|
73
77
|
/**
|
|
74
|
-
* `
|
|
75
|
-
*
|
|
76
|
-
*
|
|
78
|
+
* `tabs` (the default since 4.98): one column, at most max-w-4xl wide, the
|
|
79
|
+
* short facts (sections placed `rail`) in a Details tab after the record's
|
|
80
|
+
* other tabs. `column`: one column, `placement` ignored. `rail` (before
|
|
81
|
+
* 4.98's record standard; move off it, consuming.md "4.98"): the content
|
|
82
|
+
* area's whole width, with the sections placed `rail` in a narrow column
|
|
83
|
+
* on the right (one column on a narrow screen, rail first).
|
|
77
84
|
*/
|
|
78
|
-
export type EntityViewLayout = 'column' | 'rail';
|
|
85
|
+
export type EntityViewLayout = 'tabs' | 'column' | 'rail';
|
|
79
86
|
/**
|
|
80
87
|
* Which column comes first where the rail layout is one column (a phone,
|
|
81
88
|
* or a narrow content area): `rail-first` (the default) or `main-first`.
|
|
@@ -154,8 +161,19 @@ export type EntityViewProps = {
|
|
|
154
161
|
* (`<SourceCredit>`), when its source's terms ask for a credit.
|
|
155
162
|
*/
|
|
156
163
|
footer?: ReactNode;
|
|
157
|
-
/**
|
|
164
|
+
/**
|
|
165
|
+
* `tabs` (the default since 4.98): the sections placed `rail` are a
|
|
166
|
+
* Details tab after the other tabs (in the column where there's no other
|
|
167
|
+
* tab). `column`: one column, `placement` ignored. `rail`: the sections
|
|
168
|
+
* placed `rail` in a column on the right, the shape before 4.98's record
|
|
169
|
+
* standard (no right rail); drop it to move to `tabs`.
|
|
170
|
+
*/
|
|
158
171
|
layout?: EntityViewLayout;
|
|
172
|
+
/**
|
|
173
|
+
* The `tabs` layout's facts tab: its name ("Details" by default). A
|
|
174
|
+
* section of the record's own with this tab joins it.
|
|
175
|
+
*/
|
|
176
|
+
detailsTab?: string;
|
|
159
177
|
/**
|
|
160
178
|
* In the `rail` layout, where its columns stack (a phone): the rail
|
|
161
179
|
* before the main column (`rail-first`, the default), or the main column
|
|
@@ -215,4 +233,4 @@ export type EntityViewProps = {
|
|
|
215
233
|
trail?: readonly PageCrumb[];
|
|
216
234
|
};
|
|
217
235
|
};
|
|
218
|
-
export declare function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, sections, footer, layout, mobileOrder, railLabel, railFields, emptyFields, emptyText, printLabel, printLook, isLoading, error, onRetry, back, }: EntityViewProps): import("react").JSX.Element;
|
|
236
|
+
export declare function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, sections, footer, layout, detailsTab, mobileOrder, railLabel, railFields, emptyFields, emptyText, printLabel, printLook, isLoading, error, onRetry, back, }: EntityViewProps): import("react").JSX.Element;
|
|
@@ -45,8 +45,15 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
45
45
|
// button, which prints those sections alone under the title and
|
|
46
46
|
// subtitle, with no rail, shell or buttons, on light paper.
|
|
47
47
|
//
|
|
48
|
-
//
|
|
49
|
-
// at max-w-4xl
|
|
48
|
+
// Three layouts. `tabs` (the default since 4.98, record standard 1A):
|
|
49
|
+
// every section in one column capped at max-w-4xl, with no right rail. The
|
|
50
|
+
// short facts (sections placed `rail` with no `tab`) are the record's last
|
|
51
|
+
// tab, Details (`detailsTab`), beside its other tabs; a record with no other
|
|
52
|
+
// tab shows them in the column, in their place. A section placed `rail`
|
|
53
|
+
// *with* a `tab` is a narrow box beside that tab's sections (on a phone,
|
|
54
|
+
// under them): short facts only, never free text. `column`: one column,
|
|
55
|
+
// `placement` ignored, as before 4.98. `rail` (kept for apps not yet
|
|
56
|
+
// moved; consuming.md "4.98"): the page takes the
|
|
50
57
|
// content area's whole width, sections placed `rail` go in a narrow column
|
|
51
58
|
// on the right that stays in view while the main column scrolls (an issue
|
|
52
59
|
// tracker's shape), and the rest fill the main column. Below the width two
|
|
@@ -132,18 +139,22 @@ function FieldRow({ field, place }) {
|
|
|
132
139
|
// places (the card's order kept) and then reads "Hide empty". Whether a
|
|
133
140
|
// field is empty is read on every render, so one filled elsewhere joins
|
|
134
141
|
// the card at once.
|
|
135
|
-
function FieldList({ fields,
|
|
142
|
+
function FieldList({ fields, place }) {
|
|
136
143
|
const empty = useContext(EmptyContext);
|
|
137
144
|
const [open, setOpen] = useState(false);
|
|
138
145
|
const listId = useId();
|
|
139
146
|
const emptyCount = empty.fold ? fields.filter((field) => isEmptyValue(fieldValue(field))).length : 0;
|
|
140
147
|
const shown = emptyCount === 0 || open ? fields : fields.filter((field) => !isEmptyValue(fieldValue(field)));
|
|
141
|
-
return (_jsxs("div", { className: "flex flex-col gap-3", children: [shown.length > 0 && (_jsx("dl", { id: listId, className:
|
|
148
|
+
return (_jsxs("div", { className: "flex flex-col gap-3", children: [shown.length > 0 && (_jsx("dl", { id: listId, className: "@container/fields flex flex-col divide-y divide-border", children: shown.map((field) => (_jsx(FieldRow, { field: field, place: place }, field.label))) })), emptyCount > 0 && (_jsxs("button", { type: "button", "data-slot": "entity-view-empty-toggle", "aria-expanded": open, "aria-controls": shown.length > 0 ? listId : undefined, onClick: () => setOpen((was) => !was), className: "inline-flex w-fit items-center gap-1 rounded-sm type-label text-muted-foreground underline underline-offset-3 outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 pointer-coarse:min-h-11", children: [open ? 'Hide Empty' : `${emptyCount} Empty`, _jsx(ChevronDownIcon, { "aria-hidden": "true", className: cn('size-3.5 transition-transform', open && 'rotate-180') })] }))] }));
|
|
142
149
|
}
|
|
143
|
-
function ViewSection({ section, inRail = false, railFields = 'beside', }) {
|
|
150
|
+
function ViewSection({ section, inRail = false, railFields = 'beside', bare, }) {
|
|
144
151
|
const headingId = useId();
|
|
145
152
|
const empty = useContext(EmptyContext);
|
|
146
|
-
|
|
153
|
+
const body = 'fields' in section ? (_jsx(FieldList, { fields: section.fields, place: !inRail ? 'page' : railFields === 'beside' ? 'railBeside' : 'rail' })) : section.edit?.kind === 'list' ? (_jsxs("div", { className: "flex min-w-0 flex-col gap-2 type-body break-words text-foreground", children: [!isEmptyValue(section.content) && section.content, _jsx(EditableList, { label: section.title, edit: section.edit, emptyLabel: section.emptyLabel ?? empty.text })] })) : (_jsx("div", { className: "min-w-0 type-body break-words text-foreground", children: section.edit ? (_jsx(EditableValue, { label: section.title, edit: section.edit, children: _jsx(OrEmpty, { value: section.content, emptyLabel: section.emptyLabel }) })) : (_jsx(OrEmpty, { value: section.content, emptyLabel: section.emptyLabel })) }));
|
|
154
|
+
if (bare) {
|
|
155
|
+
return (_jsxs("section", { "aria-labelledby": headingId, "data-slot": "entity-view-bare-section", className: "flex flex-col gap-2", children: [_jsx("h2", { id: headingId, className: bare === 'hidden' ? 'sr-only' : 'type-label text-muted-foreground', children: section.title }), body] }));
|
|
156
|
+
}
|
|
157
|
+
return (_jsx("section", { "aria-labelledby": headingId, children: _jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx("h2", { id: headingId, className: "type-section-title text-foreground", children: section.title }) }), _jsx(CardContent, { children: body })] }) }));
|
|
147
158
|
}
|
|
148
159
|
// The rail layout's columns. The view is a container, so the switch to
|
|
149
160
|
// two columns follows the width the page actually has (the sidebar open
|
|
@@ -204,27 +215,50 @@ function Rail({ label, sections, fields, }) {
|
|
|
204
215
|
return (_jsx("aside", { ref: ref, "aria-label": label, "data-fits": fits ? '' : undefined, className: cn(RAIL_LAYOUT.rail, RAIL_LAYOUT.sticky, 'flex min-w-0 flex-col gap-6'), children: sections.map((section) => (_jsx(ViewSection, { section: section, inRail: true, railFields: fields }, section.title))) }));
|
|
205
216
|
}
|
|
206
217
|
const TAB_PARAM = 'tab';
|
|
207
|
-
// The
|
|
208
|
-
//
|
|
209
|
-
|
|
218
|
+
// The tabs, in the order the sections first name them. Two names with one
|
|
219
|
+
// slug ("Notes", "notes") are one tab, under the first. `side` sections
|
|
220
|
+
// (placed `rail` in the `tabs` layout) go beside their tab's own.
|
|
221
|
+
function tabsOf(sections, side = []) {
|
|
210
222
|
const tabs = [];
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
223
|
+
const tabFor = (name) => {
|
|
224
|
+
const slug = entityViewTabSlug(name);
|
|
225
|
+
let tab = tabs.find((each) => each.slug === slug);
|
|
226
|
+
if (!tab) {
|
|
227
|
+
tab = { slug, name, sections: [], side: [] };
|
|
228
|
+
tabs.push(tab);
|
|
229
|
+
}
|
|
230
|
+
return tab;
|
|
231
|
+
};
|
|
232
|
+
for (const section of sections)
|
|
233
|
+
if (section.tab !== undefined)
|
|
234
|
+
tabFor(section.tab).sections.push(section);
|
|
235
|
+
for (const section of side)
|
|
236
|
+
if (section.tab !== undefined)
|
|
237
|
+
tabFor(section.tab).side.push(section);
|
|
221
238
|
return tabs;
|
|
222
239
|
}
|
|
240
|
+
// A tab with short facts beside its sections: two columns once the tab is
|
|
241
|
+
// 42rem wide (the side ~18rem), the facts under the sections below that.
|
|
242
|
+
const TAB_SIDE = {
|
|
243
|
+
columns: 'flex min-w-0 flex-col gap-6 @2xl/tab:grid @2xl/tab:grid-cols-[minmax(0,1fr)_--spacing(72)] @2xl/tab:items-start',
|
|
244
|
+
main: 'flex min-w-0 flex-col gap-6',
|
|
245
|
+
side: 'flex min-w-0 flex-col gap-6',
|
|
246
|
+
};
|
|
247
|
+
function TabBody({ tab, railFields }) {
|
|
248
|
+
if (tab.details) {
|
|
249
|
+
// The facts on their own: a reading width, never the whole page.
|
|
250
|
+
return (_jsx("div", { "data-slot": "entity-view-details", className: "flex w-full max-w-2xl min-w-0 flex-col gap-6", children: tab.sections.map((section) => (_jsx(ViewSection, { section: section, inRail: true, railFields: railFields }, section.title))) }));
|
|
251
|
+
}
|
|
252
|
+
const main = tab.sections.map((section) => _jsx(ViewSection, { section: section }, section.title));
|
|
253
|
+
if (tab.side.length === 0)
|
|
254
|
+
return main;
|
|
255
|
+
return (_jsxs("div", { className: TAB_SIDE.columns, children: [_jsx("div", { className: TAB_SIDE.main, children: main }), _jsx("aside", { "aria-label": `${tab.name} Facts`, "data-slot": "entity-view-tab-side", className: TAB_SIDE.side, children: tab.side.map((section) => (_jsx(ViewSection, { section: section, inRail: true, railFields: railFields }, section.title))) })] }));
|
|
256
|
+
}
|
|
223
257
|
// The tab list, under the sections with no tab, and every tab's sections
|
|
224
258
|
// (hidden but mounted unless selected). The selected tab is the address's,
|
|
225
259
|
// changed in place: the entry replaced, its state kept (a record over its
|
|
226
260
|
// list stays the dialog), the scroll where it was.
|
|
227
|
-
function MainTabs({ tabs, label }) {
|
|
261
|
+
function MainTabs({ tabs, label, railFields = 'beside', }) {
|
|
228
262
|
const location = useLocation();
|
|
229
263
|
const navigate = useNavigate();
|
|
230
264
|
const asked = new URLSearchParams(location.search).get(TAB_PARAM);
|
|
@@ -238,9 +272,33 @@ function MainTabs({ tabs, label }) {
|
|
|
238
272
|
const search = params.toString();
|
|
239
273
|
void navigate({ pathname: location.pathname, search: search ? `?${search}` : '', hash: location.hash }, { replace: true, state: location.state, preventScrollReset: true });
|
|
240
274
|
};
|
|
241
|
-
return (_jsxs(Tabs, { value: selected, onValueChange: (value) => select(String(value)), "data-slot": "entity-view-tabs", className: "min-w-0 gap-6", children: [_jsx(TabsList, { variant: "line", activateOnFocus: true, "aria-label": label, className: "h-auto w-full max-w-full justify-start gap-1 overflow-x-auto overflow-y-hidden border-b border-border p-0 [scrollbar-width:thin]", children: tabs.map((tab) => (_jsx(TabsTrigger, { value: tab.slug, className: "h-9 flex-none px-3 text-muted-foreground group-data-horizontal/tabs:after:bottom-0 pointer-coarse:h-11 dark:text-muted-foreground", children: tab.name }, tab.slug))) }), tabs.map((tab) => (_jsx(TabsContent, { value: tab.slug, keepMounted: true, className: "flex min-w-0 flex-col gap-6 [font-size:inherit]", children:
|
|
275
|
+
return (_jsxs(Tabs, { value: selected, onValueChange: (value) => select(String(value)), "data-slot": "entity-view-tabs", className: "min-w-0 gap-6", children: [_jsx(TabsList, { variant: "line", activateOnFocus: true, "aria-label": label, className: "h-auto w-full max-w-full justify-start gap-1 overflow-x-auto overflow-y-hidden border-b border-border p-0 [scrollbar-width:thin]", children: tabs.map((tab) => (_jsx(TabsTrigger, { value: tab.slug, className: "h-9 flex-none px-3 text-muted-foreground group-data-horizontal/tabs:after:bottom-0 pointer-coarse:h-11 dark:text-muted-foreground", children: tab.name }, tab.slug))) }), tabs.map((tab) => (_jsx(TabsContent, { value: tab.slug, keepMounted: true, className: "@container/tab flex min-w-0 flex-col gap-6 [font-size:inherit]", children: _jsx(TabBody, { tab: tab, railFields: railFields }) }, tab.slug)))] }));
|
|
242
276
|
}
|
|
243
|
-
|
|
277
|
+
// The `tabs` layout's sections (1A): the main column's untabbed sections,
|
|
278
|
+
// then the tab list, with the facts (placed `rail`, no tab) as the last
|
|
279
|
+
// tab, or in the column in their place when there's no other tab.
|
|
280
|
+
function tabsLayout(sections, detailsTab) {
|
|
281
|
+
const isFacts = (section) => section.placement === 'rail' && section.tab === undefined;
|
|
282
|
+
const side = sections.filter((section) => section.placement === 'rail' && section.tab !== undefined);
|
|
283
|
+
const main = sections.filter((section) => section.placement !== 'rail');
|
|
284
|
+
const facts = sections.filter(isFacts);
|
|
285
|
+
const tabs = tabsOf(main, side);
|
|
286
|
+
if (tabs.length === 0 || facts.length === 0) {
|
|
287
|
+
return { above: sections.filter((section) => section.tab === undefined), tabs, factsInColumn: true };
|
|
288
|
+
}
|
|
289
|
+
const slug = entityViewTabSlug(detailsTab);
|
|
290
|
+
const own = tabs.find((tab) => tab.slug === slug);
|
|
291
|
+
if (own) {
|
|
292
|
+
// The record's own tab of that name: the facts join it, drawn as its
|
|
293
|
+
// own facts tab only if it held nothing else.
|
|
294
|
+
own.details = own.sections.length === 0 && own.side.length === 0;
|
|
295
|
+
own.sections.push(...facts);
|
|
296
|
+
}
|
|
297
|
+
else
|
|
298
|
+
tabs.push({ slug, name: detailsTab, sections: facts, side: [], details: true });
|
|
299
|
+
return { above: main.filter((section) => section.tab === undefined), tabs, factsInColumn: false };
|
|
300
|
+
}
|
|
301
|
+
export function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, sections, footer, layout = 'tabs', detailsTab = 'Details', mobileOrder = 'rail-first', railLabel, railFields = 'beside', emptyFields = 'show', emptyText = EMPTY_DASH, printLabel = 'Print Notes', printLook = 'icon', isLoading, error, onRetry, back, }) {
|
|
244
302
|
// Editing in place: one store per view, and the leave-page prompt only
|
|
245
303
|
// while a field is open (or one is always editable).
|
|
246
304
|
const [store] = useState(() => new EditInPlaceStore());
|
|
@@ -256,7 +314,7 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
|
|
|
256
314
|
if (error?.kind === 'notfound') {
|
|
257
315
|
// A record that doesn't exist and one that belongs to another user are
|
|
258
316
|
// the same plain 404, so this never says which. Retrying can't help.
|
|
259
|
-
return (_jsxs(Empty, { "data-state": "notfound", children: [_jsxs(EmptyHeader, { children: [_jsx(EmptyMedia, { variant: "icon", children: _jsx(SearchXIcon, {}) }), _jsx(EmptyTitle, { children: "Not found" }), _jsx(EmptyDescription, { children: error.message })] }), _jsx(EmptyContent, { children: dialog ? (_jsxs(Button, { size: "sm", variant: "outline", onClick: dialog.close, children: ["Back
|
|
317
|
+
return (_jsxs(Empty, { "data-state": "notfound", children: [_jsxs(EmptyHeader, { children: [_jsx(EmptyMedia, { variant: "icon", children: _jsx(SearchXIcon, {}) }), _jsx(EmptyTitle, { children: "Not found" }), _jsx(EmptyDescription, { children: error.message })] }), _jsx(EmptyContent, { children: dialog ? (_jsxs(Button, { size: "sm", variant: "outline", onClick: dialog.close, children: ["Back To ", back.label] })) : (_jsxs(Button, { size: "sm", variant: "outline", nativeButton: false, render: _jsx(Link, { to: back.to }), children: ["Back To ", back.label] })) })] }));
|
|
260
318
|
}
|
|
261
319
|
if (error)
|
|
262
320
|
return _jsx(ErrorState, { error: error, onRetry: onRetry });
|
|
@@ -279,14 +337,33 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
|
|
|
279
337
|
const printButton = printSections.length > 0 && (_jsx(PrintNotes, { label: printLabel, look: printLook, title: title, subtitle: subtitle, sections: printSections }));
|
|
280
338
|
const railSections = sections.filter((section) => section.placement === 'rail');
|
|
281
339
|
const mainSections = sections.filter((section) => section.placement !== 'rail');
|
|
282
|
-
|
|
283
|
-
|
|
340
|
+
const tabsLabel = `${title ?? 'Record'} sections`;
|
|
341
|
+
// A tiny record in a small card dialog (8A): the facts as plain rows,
|
|
342
|
+
// the dialog's own controls on the title's line.
|
|
343
|
+
const card = dialog?.look === 'card';
|
|
344
|
+
// Tabs: in the `tabs` layout the facts are a tab of their own (1A); in
|
|
345
|
+
// the others a main section's `tab` (a rail one's is ignored).
|
|
346
|
+
const shaped = layout === 'tabs' ? tabsLayout(sections, detailsTab) : null;
|
|
347
|
+
const tabs = shaped ? shaped.tabs : tabsOf(mainSections);
|
|
284
348
|
const tabbed = (section) => section.placement !== 'rail' && section.tab !== undefined;
|
|
285
|
-
const tabList = tabs.length > 0 && _jsx(MainTabs, { tabs: tabs, label:
|
|
349
|
+
const tabList = tabs.length > 0 && _jsx(MainTabs, { tabs: tabs, label: tabsLabel, railFields: railFields });
|
|
286
350
|
const main = (_jsxs("div", { className: cn(RAIL_LAYOUT.main, railSections.length === 0 && RAIL_LAYOUT.mainAlone), children: [mainSections
|
|
287
351
|
.filter((section) => !tabbed(section))
|
|
288
352
|
.map((section) => (_jsx(ViewSection, { section: section }, section.title))), tabList] }));
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
353
|
+
let body;
|
|
354
|
+
if (card) {
|
|
355
|
+
body = (_jsx("div", { "data-slot": "entity-view-card-sections", className: "flex flex-col gap-5", children: sections.map((section) => (_jsx(ViewSection, { section: section, inRail: true, railFields: railFields, bare: sections.length === 1 ? 'hidden' : 'label' }, section.title))) }));
|
|
356
|
+
}
|
|
357
|
+
else if (layout === 'rail') {
|
|
358
|
+
body = (_jsxs("div", { className: RAIL_LAYOUT.columns, children: [mobileOrder === 'main-first' && main, railSections.length > 0 && (_jsx(Rail, { label: railLabel ?? `${title ?? 'Record'} details`, sections: railSections, fields: railFields })), mobileOrder === 'rail-first' && main] }));
|
|
359
|
+
}
|
|
360
|
+
else if (shaped) {
|
|
361
|
+
body = (_jsxs(_Fragment, { children: [shaped.above.map((section) => section.placement === 'rail' ? (_jsx(ViewSection, { section: section, inRail: true, railFields: railFields }, section.title)) : (_jsx(ViewSection, { section: section }, section.title))), tabList] }));
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
body = (_jsxs(_Fragment, { children: [sections
|
|
365
|
+
.filter((section) => !tabbed(section))
|
|
366
|
+
.map((section) => (_jsx(ViewSection, { section: section }, section.title))), tabList] }));
|
|
367
|
+
}
|
|
368
|
+
return (_jsx(EditInPlaceContext.Provider, { value: store, children: _jsx(EmptyContext.Provider, { value: { text: emptyText, fold: emptyFields === 'fold' }, children: _jsxs("div", { className: layout === 'rail' && !card ? RAIL_LAYOUT.page : cn('flex max-w-4xl flex-col', card ? 'gap-4' : 'gap-6'), "data-state": "success", "data-layout": layout, "data-look": card ? 'card' : undefined, children: [editing && _jsx(LeaveGuard, { store: store }), !dialog && !trail && _jsx(BackLink, { back: back }), !dialog && trail && !inShell && _jsx(PageTrail, { crumbs: trail }), _jsxs("header", { className: card ? 'flex items-start justify-between gap-3' : 'flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between', children: [_jsxs("div", { className: cn('flex min-w-0 flex-1 items-start gap-3', !card && 'sm:min-w-64 sm:gap-4'), children: [leading && (_jsx("div", { "data-slot": "entity-view-leading", className: "flex shrink-0 items-center", children: leading })), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-2", children: [_jsxs("div", { "data-slot": "entity-view-title-line", className: "flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2", children: [_jsx("h1", { id: dialog?.titleId, className: cn('min-w-0 max-w-full break-words text-foreground', card ? 'type-section-title' : 'type-page-title'), children: titleEdit ? (_jsx(EditableValue, { label: titleEdit.label, edit: titleEdit, layout: "inline", children: title })) : (title) }), badges && (_jsx("div", { "data-slot": "entity-view-badges", className: "flex flex-wrap items-center gap-1.5", children: badges }))] }), subtitle && (_jsx("div", { "data-slot": "entity-view-subtitle", className: "type-body break-words text-muted-foreground", children: subtitle }))] })] }), card ? (_jsxs("div", { "data-slot": "entity-view-card-controls", className: "flex shrink-0 items-center gap-1", children: [printButton, actions, dialog?.controls] })) : ((actions || printButton) && (_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-2 sm:justify-end", children: [printButton, actions] })))] }), _jsx("div", { role: "status", "data-slot": "entity-view-notice", className: "empty:hidden", children: notice }), strip && _jsx("div", { "data-slot": "entity-view-strip", children: strip }), body, footer && (_jsx("footer", { "data-slot": "entity-view-footer", className: "type-caption text-muted-foreground", children: footer }))] }) }) }));
|
|
292
369
|
}
|
|
@@ -23,5 +23,5 @@ const TITLE_BY_KIND = {
|
|
|
23
23
|
};
|
|
24
24
|
export function ErrorState({ error, onRetry, size = 'default', className, }) {
|
|
25
25
|
const compact = size === 'compact';
|
|
26
|
-
return (_jsxs(Empty, { className: cn(compact && 'gap-3 p-4', className), "data-state": "error", "data-size": size, children: [_jsxs(EmptyHeader, { className: cn(compact && 'gap-1'), children: [compact ? (_jsxs(EmptyTitle, { className: "flex items-center gap-1.5", children: [_jsx(AlertCircleIcon, { "aria-hidden": "true", className: "size-4 shrink-0 text-destructive-text" }), TITLE_BY_KIND[error.kind]] })) : (_jsxs(_Fragment, { children: [_jsx(EmptyMedia, { variant: "icon", children: _jsx(AlertCircleIcon, { className: "text-destructive" }) }), _jsx(EmptyTitle, { children: TITLE_BY_KIND[error.kind] })] })), _jsx(EmptyDescription, { children: error.message })] }), onRetry && (_jsx(EmptyContent, { children: _jsx(Button, { size: "sm", variant: "outline", onClick: onRetry, children: "Try
|
|
26
|
+
return (_jsxs(Empty, { className: cn(compact && 'gap-3 p-4', className), "data-state": "error", "data-size": size, children: [_jsxs(EmptyHeader, { className: cn(compact && 'gap-1'), children: [compact ? (_jsxs(EmptyTitle, { className: "flex items-center gap-1.5", children: [_jsx(AlertCircleIcon, { "aria-hidden": "true", className: "size-4 shrink-0 text-destructive-text" }), TITLE_BY_KIND[error.kind]] })) : (_jsxs(_Fragment, { children: [_jsx(EmptyMedia, { variant: "icon", children: _jsx(AlertCircleIcon, { className: "text-destructive" }) }), _jsx(EmptyTitle, { children: TITLE_BY_KIND[error.kind] })] })), _jsx(EmptyDescription, { children: error.message })] }), onRetry && (_jsx(EmptyContent, { children: _jsx(Button, { size: "sm", variant: "outline", onClick: onRetry, children: "Try Again" }) }))] }));
|
|
27
27
|
}
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
// EqualItems (record standard R10), so a fact reads the same wherever a
|
|
3
3
|
// record shows it.
|
|
4
4
|
//
|
|
5
|
-
// Label beside value from `sm` up
|
|
6
|
-
//
|
|
5
|
+
// Label beside value from `sm` up, once the list itself is 24rem wide;
|
|
6
|
+
// below either (a phone, or a narrow box on a wide screen: a panel, a
|
|
7
|
+
// dialog's column) the label sits above its value, so nothing is squeezed
|
|
8
|
+
// into a narrow second column (4.97: a value column squeezed to nothing
|
|
9
|
+
// cut off an editor's controls, ChoiceButtons' among them). In
|
|
7
10
|
// the rail the list's own width decides instead (a container query on the
|
|
8
11
|
// <dl>): label above value in the narrow rail, beside it once the rail's
|
|
9
12
|
// sections stack full width under the header.
|
|
@@ -12,7 +15,7 @@
|
|
|
12
15
|
// inside), with a narrower label column, and stacked below that. Each
|
|
13
16
|
// container query needs an `@container/fields` on the <dl>.
|
|
14
17
|
export const FIELD_ROW = {
|
|
15
|
-
page: 'sm:grid sm:grid-cols-[minmax(--spacing(32),--spacing(48))
|
|
18
|
+
page: 'sm:@sm/fields:grid sm:@sm/fields:grid-cols-[minmax(--spacing(32),--spacing(48))_minmax(0,1fr)] sm:@sm/fields:gap-6',
|
|
16
19
|
rail: '@lg/fields:grid @lg/fields:grid-cols-[minmax(--spacing(32),--spacing(48))_1fr] @lg/fields:gap-6',
|
|
17
20
|
railBeside: '@2xs/fields:grid @2xs/fields:grid-cols-[minmax(--spacing(24),--spacing(28))_minmax(0,1fr)] @2xs/fields:items-baseline @2xs/fields:gap-4 @2xs/fields:py-2.5 @lg/fields:grid-cols-[minmax(--spacing(32),--spacing(48))_1fr] @lg/fields:gap-6',
|
|
18
21
|
};
|
|
@@ -73,7 +73,7 @@ function ownsEnter(element) {
|
|
|
73
73
|
return true;
|
|
74
74
|
return (element.closest('button, a[href], summary, [role=button], [role=link], [role=combobox], [role=listbox], [role=option], [role=menu], [role=menuitem], [role=menuitemradio], [role=menuitemcheckbox], [role=switch], [role=checkbox], [role=radio], [role=tab]') !== null);
|
|
75
75
|
}
|
|
76
|
-
export function FillInQueue({ items, getKey, renderItem, onSave, canSave = true, onSkip, progress, groups, getGroup, saveLabel = 'Save and
|
|
76
|
+
export function FillInQueue({ items, getKey, renderItem, onSave, canSave = true, onSkip, progress, groups, getGroup, saveLabel = 'Save and Next', skipLabel = 'Skip', loading = false, error, onRetry, empty = 'Nothing left to fill in', index: indexProp, onIndexChange, className, }) {
|
|
77
77
|
const keys = items.map(getKey);
|
|
78
78
|
const [held, setHeld] = useState(() => ({
|
|
79
79
|
key: indexProp !== undefined ? (keys[indexProp] ?? null) : null,
|
|
@@ -189,7 +189,7 @@ export function FillInQueue({ items, getKey, renderItem, onSave, canSave = true,
|
|
|
189
189
|
const counted = groups?.filter((group) => group.progress !== undefined) ?? [];
|
|
190
190
|
const progressBar = (progress || counted.length > 1) && (_jsxs("div", { className: "flex flex-col gap-1.5", children: [progress && _jsx(ProgressLine, { progress: progress }), counted.length > 1 && (_jsx("ul", { className: "flex flex-wrap gap-x-4 gap-y-1 type-caption text-muted-foreground tabular-nums", "data-slot": "fill-in-queue-groups", children: counted.map((group) => (_jsxs("li", { children: [group.label, " ", group.progress?.done, " of ", group.progress?.total] }, group.id))) }))] }));
|
|
191
191
|
if (error !== undefined && error !== null && error !== false) {
|
|
192
|
-
return (_jsx("div", { "data-slot": "fill-in-queue", "data-state": "error", className: className, children: isAppError(error) ? (_jsx(ErrorState, { error: error, onRetry: onRetry })) : (_jsxs(Empty, { "data-state": "error", children: [_jsxs(EmptyHeader, { children: [_jsx(EmptyTitle, { children: "Something went wrong" }), _jsx(EmptyDescription, { children: error })] }), onRetry && (_jsx(Button, { size: "sm", variant: "outline", onClick: onRetry, children: "Try
|
|
192
|
+
return (_jsx("div", { "data-slot": "fill-in-queue", "data-state": "error", className: className, children: isAppError(error) ? (_jsx(ErrorState, { error: error, onRetry: onRetry })) : (_jsxs(Empty, { "data-state": "error", children: [_jsxs(EmptyHeader, { children: [_jsx(EmptyTitle, { children: "Something went wrong" }), _jsx(EmptyDescription, { children: error })] }), onRetry && (_jsx(Button, { size: "sm", variant: "outline", onClick: onRetry, children: "Try Again" }))] })) }));
|
|
193
193
|
}
|
|
194
194
|
if (loading) {
|
|
195
195
|
return (_jsxs("div", { "data-slot": "fill-in-queue", "data-state": "loading", "aria-busy": "true", className: cn('flex flex-col gap-6', className), children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Skeleton, { className: "h-2 w-full" }), _jsx(Skeleton, { className: "h-4 w-40" })] }), _jsxs("div", { className: "mx-auto flex w-full max-w-[40rem] flex-col gap-4", children: [_jsx(Skeleton, { className: "h-6 w-2/3" }), _jsx(Skeleton, { className: "h-4 w-1/2" }), _jsx(Skeleton, { className: "h-9 w-full" }), _jsx(Skeleton, { className: "h-9 w-full" })] })] }));
|
|
@@ -21,7 +21,7 @@ const ANY = '__any__';
|
|
|
21
21
|
* "Status: Active" with a value, so the toolbar needs no captions.
|
|
22
22
|
*/
|
|
23
23
|
export function FilterSelect({ label, options, value, onValueChange, anyLabel, className }) {
|
|
24
|
-
const any = anyLabel ?? `Any ${label
|
|
24
|
+
const any = anyLabel ?? `Any ${label}`;
|
|
25
25
|
const picked = options.find((option) => option.value === value);
|
|
26
26
|
const shown = picked ? `${label}: ${picked.label}` : any;
|
|
27
27
|
return (_jsxs(Select, { value: picked ? picked.value : ANY, onValueChange: (next) => onValueChange(next === ANY || next === null ? '' : String(next)), children: [_jsx(SelectTrigger, { "aria-label": shown, "data-slot": "filter-select", "data-active": picked ? true : undefined, className: className, children: _jsx(SelectValue, { children: () => shown }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: ANY, children: any }), options.map((option) => (_jsx(SelectItem, { value: option.value, children: option.label }, option.value)))] })] }));
|
|
@@ -50,5 +50,5 @@ export function FormDialog({ title, description, open, onOpenChange, onSubmit, i
|
|
|
50
50
|
leaving.current = true;
|
|
51
51
|
route?.close();
|
|
52
52
|
}
|
|
53
|
-
}, children: [_jsxs(DialogContent, { size: "form", dirty: dirty, "data-slot": "form-dialog", className: cn('gap-0 p-0', className), children: [_jsxs("div", { "data-slot": "form-dialog-header", className: "flex flex-col gap-1 px-4 pt-4 pb-2 pr-12 md:px-6 md:pt-5 md:pr-14", children: [_jsx(DialogTitle, { className: "type-section-title", children: title }), description && _jsx(DialogDescription, { children: description })] }), _jsxs("form", { ref: form, id: formId, onSubmit: onSubmit, noValidate: true, className: "flex min-h-0 flex-1 flex-col", children: [_jsx("div", { "data-slot": "form-dialog-body", className: "min-h-0 flex-1 overflow-y-auto px-4 py-4 md:px-6", children: _jsx(FieldGroup, { children: children }) }), _jsxs("div", { "data-slot": "form-dialog-bar", className: "flex flex-col gap-3 border-t px-4 py-3 pb-[calc(0.75rem+env(safe-area-inset-bottom))] md:px-6 md:pb-3", children: [_jsx("div", { role: "status", className: "empty:hidden", children: submitError && (_jsx(Notice, { tone: "destructive", action: _jsx(Button, { type: "button", size: "sm", variant: "outline", disabled: isSubmitting, onClick: () => (onRetry ? onRetry() : form.current?.requestSubmit()), children: "Try
|
|
53
|
+
}, children: [_jsxs(DialogContent, { size: "form", dirty: dirty, "data-slot": "form-dialog", className: cn('gap-0 p-0', className), children: [_jsxs("div", { "data-slot": "form-dialog-header", className: "flex flex-col gap-1 px-4 pt-4 pb-2 pr-12 md:px-6 md:pt-5 md:pr-14", children: [_jsx(DialogTitle, { className: "type-section-title", children: title }), description && _jsx(DialogDescription, { children: description })] }), _jsxs("form", { ref: form, id: formId, onSubmit: onSubmit, noValidate: true, className: "flex min-h-0 flex-1 flex-col", children: [_jsx("div", { "data-slot": "form-dialog-body", className: "min-h-0 flex-1 overflow-y-auto px-4 py-4 md:px-6", children: _jsx(FieldGroup, { children: children }) }), _jsxs("div", { "data-slot": "form-dialog-bar", className: "flex flex-col gap-3 border-t px-4 py-3 pb-[calc(0.75rem+env(safe-area-inset-bottom))] md:px-6 md:pb-3", children: [_jsx("div", { role: "status", className: "empty:hidden", children: submitError && (_jsx(Notice, { tone: "destructive", action: _jsx(Button, { type: "button", size: "sm", variant: "outline", disabled: isSubmitting, onClick: () => (onRetry ? onRetry() : form.current?.requestSubmit()), children: "Try Again" }), children: submitError.message })) }), _jsxs("div", { className: "flex justify-end gap-2 max-md:[&>*]:h-10 max-md:[&>*]:flex-1", children: [_jsx(DialogClose, { render: _jsx(Button, { type: "button", variant: "outline", disabled: isSubmitting }), children: "Cancel" }), _jsxs(Button, { type: "submit", disabled: isSubmitting, children: [isSubmitting && _jsx(Spinner, { className: "size-4" }), submitLabel] })] })] })] })] }), route && open === undefined && (_jsx(FormLeaveGuard, { dirty: dirty, letThrough: () => leaving.current || submitting.current }))] }));
|
|
54
54
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
export type FormSectionProps = {
|
|
3
|
-
/** What the group is ("Reading", "Details"):
|
|
3
|
+
/** What the group is ("Reading", "Details"): Title Case, a word or two (design-language.md "Words on screen"). */
|
|
4
4
|
title: string;
|
|
5
5
|
/** The group's fields. */
|
|
6
6
|
children: ReactNode;
|
|
@@ -18,6 +18,7 @@ import { cn } from 'cn';
|
|
|
18
18
|
import { Button } from '../ui/button.js';
|
|
19
19
|
import { Spinner } from '../ui/spinner.js';
|
|
20
20
|
import { acceptAttribute, DEFAULT_IMAGE_TYPES, imageRefusal, uploadFailure } from '../../lib/image-file.js';
|
|
21
|
+
import { titleCase } from '../../lib/title-case.js';
|
|
21
22
|
export function ImageField({ id, value, thumbUrl, onChange, upload, accept = DEFAULT_IMAGE_TYPES, maxSize, noun = 'photo', alt, invalid = false, readOnly = false, onBusyChange, className, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, }) {
|
|
22
23
|
const ids = useId();
|
|
23
24
|
const errorId = `${ids}-error`;
|
|
@@ -91,10 +92,10 @@ export function ImageField({ id, value, thumbUrl, onChange, upload, accept = DEF
|
|
|
91
92
|
input.current?.click();
|
|
92
93
|
};
|
|
93
94
|
const describedBy = [ariaDescribedBy, problem ? errorId : undefined].filter(Boolean).join(' ') || undefined;
|
|
94
|
-
const mainLabel = busy ? `Uploading ${noun}…` : value !== null ? `Replace ${noun}` : `Add ${noun}`;
|
|
95
|
+
const mainLabel = busy ? `Uploading ${noun}…` : value !== null ? `Replace ${titleCase(noun)}` : `Add ${titleCase(noun)}`;
|
|
95
96
|
return (_jsxs("div", { "data-slot": "image-field", role: "group", "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-busy": busy || undefined, className: cn('flex flex-col gap-2', className), children: [_jsxs("div", { className: "flex items-center gap-3", children: [value !== null ? (_jsxs("div", { className: "relative size-24 shrink-0 overflow-hidden rounded-lg border border-border bg-muted", children: [shown ? (_jsx("img", { src: shown, alt: alt ?? `Current ${noun}`, className: "size-full object-cover", onError: () => setBroken(shown) })) : (_jsx("div", { role: "img", "aria-label": alt ?? `Current ${noun}`, className: "flex size-full items-center justify-center text-muted-foreground", children: _jsx(ImageIcon, { "aria-hidden": "true", className: "size-6" }) })), busy && (_jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-background/70", children: _jsx(Spinner, { "aria-hidden": "true", className: "size-5 text-foreground" }) }))] })) : (_jsx("div", { "aria-hidden": "true", onClick: open, className: cn('flex size-24 shrink-0 items-center justify-center rounded-lg border-2 border-dashed border-input text-muted-foreground', !busy && !readOnly && 'cursor-pointer hover:bg-muted'), children: busy ? _jsx(Spinner, { className: "size-5" }) : _jsx(ImagePlusIcon, { className: "size-6" }) })), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsxs(Button, { ref: main, id: id, type: "button", variant: "outline", size: "sm", "aria-label": mainLabel, "aria-describedby": describedBy, "aria-invalid": invalid || undefined, disabled: busy || readOnly,
|
|
96
97
|
// Keeps focus through an upload, so it's where it was after.
|
|
97
|
-
focusableWhenDisabled: true, onClick: open, children: [busy ? (_jsx(Spinner, { "aria-hidden": "true" })) : value !== null ? (_jsx(RefreshCwIcon, { "aria-hidden": "true" })) : (_jsx(ImagePlusIcon, { "aria-hidden": "true" })), busy ? 'Uploading…' : value !== null ? 'Replace' : `Add ${noun}`] }), value !== null && (_jsxs(Button, { type: "button", variant: "ghost", size: "sm", "aria-label": `Remove ${noun}`, disabled: busy || readOnly, onClick: remove, children: [_jsx(XIcon, { "aria-hidden": "true" }), "Remove"] }))] })] }), problem && (_jsx("p", { id: errorId, role: "alert", "data-slot": "image-field-error", className: "type-caption text-destructive-text", children: problem })), _jsx("span", { role: "status", className: "sr-only", children: status }), _jsx("input", { ref: input, type: "file", accept: acceptAttribute(accept), hidden: true, tabIndex: -1, onChange: (event) => {
|
|
98
|
+
focusableWhenDisabled: true, onClick: open, children: [busy ? (_jsx(Spinner, { "aria-hidden": "true" })) : value !== null ? (_jsx(RefreshCwIcon, { "aria-hidden": "true" })) : (_jsx(ImagePlusIcon, { "aria-hidden": "true" })), busy ? 'Uploading…' : value !== null ? 'Replace' : `Add ${titleCase(noun)}`] }), value !== null && (_jsxs(Button, { type: "button", variant: "ghost", size: "sm", "aria-label": `Remove ${noun}`, disabled: busy || readOnly, onClick: remove, children: [_jsx(XIcon, { "aria-hidden": "true" }), "Remove"] }))] })] }), problem && (_jsx("p", { id: errorId, role: "alert", "data-slot": "image-field-error", className: "type-caption text-destructive-text", children: problem })), _jsx("span", { role: "status", className: "sr-only", children: status }), _jsx("input", { ref: input, type: "file", accept: acceptAttribute(accept), hidden: true, tabIndex: -1, onChange: (event) => {
|
|
98
99
|
const file = event.target.files?.[0];
|
|
99
100
|
// Cleared, so picking the same file again still counts.
|
|
100
101
|
event.target.value = '';
|
|
@@ -12,6 +12,8 @@ export type KeyStatsProps = {
|
|
|
12
12
|
stats: readonly KeyStat[];
|
|
13
13
|
/** What an empty value reads as. Defaults to a dash, read as "Not set". */
|
|
14
14
|
emptyLabel?: string;
|
|
15
|
+
/** `content` (the default since 4.98): as wide as its numbers. `full`: across the page. */
|
|
16
|
+
width?: 'content' | 'full';
|
|
15
17
|
className?: string;
|
|
16
18
|
};
|
|
17
|
-
export declare function KeyStats({ stats, emptyLabel, className }: KeyStatsProps): import("react").JSX.Element;
|
|
19
|
+
export declare function KeyStats({ stats, emptyLabel, width, className }: KeyStatsProps): import("react").JSX.Element;
|
|
@@ -3,8 +3,8 @@ import { cn } from 'cn';
|
|
|
3
3
|
import { EmptyText } from './empty-value.js';
|
|
4
4
|
import { EMPTY_DASH } from '../../lib/empty-value.js';
|
|
5
5
|
const isEmpty = (value) => value === null || value === undefined || value === false || value === '';
|
|
6
|
-
export function KeyStats({ stats, emptyLabel = EMPTY_DASH, className }) {
|
|
7
|
-
return (_jsx("dl", { "data-slot": "key-stats", className: cn('flex flex-wrap gap-x-8 gap-y-3 rounded-lg border border-border bg-card px-4 py-3 text-card-foreground', className), children: stats.map((stat) => {
|
|
6
|
+
export function KeyStats({ stats, emptyLabel = EMPTY_DASH, width = 'content', className }) {
|
|
7
|
+
return (_jsx("dl", { "data-slot": "key-stats", "data-width": width, className: cn('flex flex-wrap gap-x-8 gap-y-3 rounded-lg border border-border bg-card px-4 py-3 text-card-foreground', width === 'content' && 'w-fit max-w-full', className), children: stats.map((stat) => {
|
|
8
8
|
const Icon = stat.icon;
|
|
9
9
|
return (_jsxs("div", { className: "flex min-w-0 flex-col gap-0.5", children: [_jsxs("dt", { className: cn('type-caption text-muted-foreground', Icon && 'inline-flex items-center gap-1'), children: [Icon && _jsx(Icon, { "aria-hidden": "true", className: "size-3.25 shrink-0" }), stat.label] }), _jsx("dd", { className: "type-section-title tabular-nums break-words text-foreground", children: isEmpty(stat.value) ? _jsx(EmptyText, { text: emptyLabel, className: "type-body text-muted-foreground" }) : stat.value }), stat.hint && _jsx("dd", { className: "type-caption text-muted-foreground", children: stat.hint })] }, stat.label));
|
|
10
10
|
}) }));
|
|
@@ -22,6 +22,6 @@ export function ListHeader({ title, count, links = [], newAction, more = [], del
|
|
|
22
22
|
const outLink = links.length === 1 ? links[0] : undefined;
|
|
23
23
|
const menuLinks = links.length > 1 ? links : [];
|
|
24
24
|
const hasMenu = menuLinks.length > 0 || more.length > 0 || deleted !== undefined;
|
|
25
|
-
return (_jsxs("div", { "data-slot": "list-header", className: cn('flex flex-col', className), children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-4 gap-y-2", children: [_jsxs("h1", { className: "flex items-baseline gap-2 type-page-title text-foreground", children: [title, count !== undefined && (_jsxs("span", { className: "type-body font-normal tabular-nums text-muted-foreground", children: [_jsx("span", { className: "sr-only", children: ", " }), count] }))] }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [outLink && (_jsxs(Button, { size: "sm", variant: "outline", nativeButton: false, render: _jsx(Link, { to: outLink.to }), children: [outLink.icon && _jsx(outLink.icon, { "aria-hidden": "true" }), outLink.label] })), hasMenu && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsx(Button, { size: "icon-sm", variant: "outline", "aria-label": `More for ${title}`, "data-slot": "list-header-more" }), children: _jsx(EllipsisIcon, { "aria-hidden": "true" }) }), _jsxs(DropdownMenuContent, { align: "end", children: [menuLinks.map((link) => (_jsxs(DropdownMenuItem, { render: _jsx(Link, { to: link.to }), children: [link.icon && _jsx(link.icon, { "aria-hidden": "true" }), link.label] }, link.label))), more.map((action) => (_jsxs(DropdownMenuItem, { onClick: action.onSelect, children: [action.icon && _jsx(action.icon, { "aria-hidden": "true" }), action.label] }, action.label))), deleted && (menuLinks.length > 0 || more.length > 0) && _jsx(DropdownMenuSeparator, {}), deleted && (_jsxs(DropdownMenuCheckboxItem, { closeOnClick: true, checked: deleted.shown, onCheckedChange: deleted.onShownChange, children: [_jsx(Trash2Icon, { "aria-hidden": "true" }), "Show
|
|
26
|
-
(newAction.to !== undefined ? (_jsxs(Button, { size: "sm", nativeButton: false, render: _jsx(Link, { to: newAction.to }), children: [_jsx(PlusIcon, { "aria-hidden": "true" }), newAction.label] })) : (_jsxs(Button, { size: "sm", onClick: newAction.onClick, children: [_jsx(PlusIcon, { "aria-hidden": "true" }), newAction.label] })))] })] }), _jsx("div", { role: "status", "data-slot": "list-header-notice", className: "not-empty:mt-3", children: deleted?.shown && (_jsxs(Notice, { tone: "info", icon: Trash2Icon, action: _jsx(Button, { size: "sm", variant: "outline", onClick: () => deleted.onShownChange(false), children: "Back to the
|
|
25
|
+
return (_jsxs("div", { "data-slot": "list-header", className: cn('flex flex-col', className), children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-4 gap-y-2", children: [_jsxs("h1", { className: "flex items-baseline gap-2 type-page-title text-foreground", children: [title, count !== undefined && (_jsxs("span", { className: "type-body font-normal tabular-nums text-muted-foreground", children: [_jsx("span", { className: "sr-only", children: ", " }), count] }))] }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [outLink && (_jsxs(Button, { size: "sm", variant: "outline", nativeButton: false, render: _jsx(Link, { to: outLink.to }), children: [outLink.icon && _jsx(outLink.icon, { "aria-hidden": "true" }), outLink.label] })), hasMenu && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsx(Button, { size: "icon-sm", variant: "outline", "aria-label": `More for ${title}`, "data-slot": "list-header-more" }), children: _jsx(EllipsisIcon, { "aria-hidden": "true" }) }), _jsxs(DropdownMenuContent, { align: "end", children: [menuLinks.map((link) => (_jsxs(DropdownMenuItem, { render: _jsx(Link, { to: link.to }), children: [link.icon && _jsx(link.icon, { "aria-hidden": "true" }), link.label] }, link.label))), more.map((action) => (_jsxs(DropdownMenuItem, { onClick: action.onSelect, children: [action.icon && _jsx(action.icon, { "aria-hidden": "true" }), action.label] }, action.label))), deleted && (menuLinks.length > 0 || more.length > 0) && _jsx(DropdownMenuSeparator, {}), deleted && (_jsxs(DropdownMenuCheckboxItem, { closeOnClick: true, checked: deleted.shown, onCheckedChange: deleted.onShownChange, children: [_jsx(Trash2Icon, { "aria-hidden": "true" }), "Show Deleted"] }))] })] })), newAction &&
|
|
26
|
+
(newAction.to !== undefined ? (_jsxs(Button, { size: "sm", nativeButton: false, render: _jsx(Link, { to: newAction.to }), children: [_jsx(PlusIcon, { "aria-hidden": "true" }), newAction.label] })) : (_jsxs(Button, { size: "sm", onClick: newAction.onClick, children: [_jsx(PlusIcon, { "aria-hidden": "true" }), newAction.label] })))] })] }), _jsx("div", { role: "status", "data-slot": "list-header-notice", className: "not-empty:mt-3", children: deleted?.shown && (_jsxs(Notice, { tone: "info", icon: Trash2Icon, action: _jsx(Button, { size: "sm", variant: "outline", onClick: () => deleted.onShownChange(false), children: "Back to the List" }), children: ["Showing deleted ", deleted.noun ?? 'records', "."] })) })] }));
|
|
27
27
|
}
|
|
@@ -1324,10 +1324,10 @@ function LinkForm({ box, onApply }) {
|
|
|
1324
1324
|
apply();
|
|
1325
1325
|
}
|
|
1326
1326
|
};
|
|
1327
|
-
return (_jsxs(PopoverContent, { anchor: box.anchor, align: "start", "aria-label": box.href ? 'Edit
|
|
1327
|
+
return (_jsxs(PopoverContent, { anchor: box.anchor, align: "start", "aria-label": box.href ? 'Edit Link' : 'Add Link', initialFocus: inputRef, finalFocus: false, className: "w-80", onKeyDown: onKeyDown, children: [_jsxs(Field, { "data-invalid": error ? true : undefined, children: [_jsx(FieldLabel, { htmlFor: inputId, children: "Link Address" }), _jsx(Input, { ref: inputRef, id: inputId, value: typed, placeholder: "https://", autoComplete: "off", "aria-invalid": error ? true : undefined, "aria-describedby": error ? errorId : undefined, onChange: (event) => {
|
|
1328
1328
|
setTyped(event.target.value);
|
|
1329
1329
|
setError(null);
|
|
1330
|
-
} }), error && _jsx(FieldError, { id: errorId, children: error })] }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { size: "sm", onClick: apply, children: "Apply" }), box.href && (_jsx(Button, { size: "sm", variant: "outline", onClick: () => onApply(''), children: "Remove
|
|
1330
|
+
} }), error && _jsx(FieldError, { id: errorId, children: error })] }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { size: "sm", onClick: apply, children: "Apply" }), box.href && (_jsx(Button, { size: "sm", variant: "outline", onClick: () => onApply(''), children: "Remove Link" }))] })] }));
|
|
1331
1331
|
}
|
|
1332
1332
|
// The new page's title box: the title (the selected words to start with),
|
|
1333
1333
|
// and Create page. While the app makes the page it waits, its controls
|
|
@@ -1362,8 +1362,8 @@ function PageForm({ box, busy, onCreate }) {
|
|
|
1362
1362
|
create();
|
|
1363
1363
|
}
|
|
1364
1364
|
};
|
|
1365
|
-
return (_jsxs(PopoverContent, { anchor: box.anchor, align: "start", "aria-label": "New
|
|
1365
|
+
return (_jsxs(PopoverContent, { anchor: box.anchor, align: "start", "aria-label": "New Page", initialFocus: inputRef, finalFocus: false, className: "w-80", "data-rich-text-menu": "", "data-slot": "page-form", onKeyDown: onKeyDown, children: [_jsxs(Field, { "data-invalid": error ? true : undefined, children: [_jsx(FieldLabel, { htmlFor: inputId, children: "Page Title" }), _jsx(Input, { ref: inputRef, id: inputId, value: typed, autoComplete: "off", readOnly: busy, "aria-invalid": error ? true : undefined, "aria-describedby": error ? errorId : undefined, onChange: (event) => {
|
|
1366
1366
|
setTyped(event.target.value);
|
|
1367
1367
|
setError(null);
|
|
1368
|
-
} }), error && _jsx(FieldError, { id: errorId, children: error })] }), _jsx("div", { className: "flex gap-2", children: _jsx(Button, { size: "sm", onClick: create, disabled: busy, children: busy ? 'Creating…' : 'Create
|
|
1368
|
+
} }), error && _jsx(FieldError, { id: errorId, children: error })] }), _jsx("div", { className: "flex gap-2", children: _jsx(Button, { size: "sm", onClick: create, disabled: busy, children: busy ? 'Creating…' : 'Create Page' }) })] }));
|
|
1369
1369
|
}
|