@tristan2828/ui-foundation 4.97.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/docs/add-an-entity.md +66 -50
- package/conventions/docs/cell-patterns.md +41 -34
- package/conventions/docs/design-language.md +124 -68
- package/conventions/docs/entity-plan-template.md +15 -21
- package/dist/components/app/entity-view.d.ts +29 -11
- package/dist/components/app/entity-view.js +103 -26
- package/dist/components/app/key-stats.d.ts +3 -1
- package/dist/components/app/key-stats.js +2 -2
- 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/status-mark.d.ts +17 -0
- package/dist/components/app/status-mark.js +12 -0
- package/dist/components/ui/field.d.ts +3 -2
- package/dist/components/ui/field.js +13 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lib/field-rows.d.ts +3 -1
- package/dist/lib/field-rows.js +24 -6
- package/dist/lib/status-kinds.d.ts +10 -0
- package/dist/lib/status-kinds.js +33 -0
- package/package.json +1 -1
- package/styles/index.css +9 -0
|
@@ -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
|
|
@@ -140,10 +147,14 @@ function FieldList({ fields, place }) {
|
|
|
140
147
|
const shown = emptyCount === 0 || open ? fields : fields.filter((field) => !isEmptyValue(fieldValue(field)));
|
|
141
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());
|
|
@@ -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
|
}
|
|
@@ -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
|
}) }));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
1
2
|
import { type Location } from 'react-router';
|
|
2
3
|
/**
|
|
3
4
|
* Where a record dialog was opened from: the list's address, and how many
|
|
@@ -29,6 +30,14 @@ export type RecordDialogContextValue = {
|
|
|
29
30
|
titleId: string;
|
|
30
31
|
/** Closes the dialog: back to the list, as Back does. */
|
|
31
32
|
close: () => void;
|
|
33
|
+
/**
|
|
34
|
+
* `card`: a small card dialog (RecordDialogRoute `look="card"`, 8A).
|
|
35
|
+
* EntityView draws the record's title smaller, its sections as plain
|
|
36
|
+
* rows with no cards, and `controls` on the title's line.
|
|
37
|
+
*/
|
|
38
|
+
look?: 'record' | 'card';
|
|
39
|
+
/** The card dialog's own controls (Open full page, Close), for EntityView's title line. */
|
|
40
|
+
controls?: ReactNode;
|
|
32
41
|
};
|
|
33
42
|
export declare const RecordDialogContext: import("react").Context<RecordDialogContextValue | null>;
|
|
34
43
|
/**
|
|
@@ -10,6 +10,13 @@ export type RecordDialogRouteProps = {
|
|
|
10
10
|
label: string;
|
|
11
11
|
/** Extra classes on the dialog's popup. It's 1,120px (`size="record"`) by default. */
|
|
12
12
|
className?: string;
|
|
13
|
+
/**
|
|
14
|
+
* `record` (the default): 1,120px, a bar with Open full page and Close
|
|
15
|
+
* above the record. `card`: a small 420px card for a tiny record (a few
|
|
16
|
+
* fields, no notes), a bottom sheet on a phone, its controls on the
|
|
17
|
+
* title's line and its facts as plain rows.
|
|
18
|
+
*/
|
|
19
|
+
look?: 'record' | 'card';
|
|
13
20
|
/**
|
|
14
21
|
* False: the record has no full page, only this dialog (DataTable's
|
|
15
22
|
* `opens` kind `dialog-only`). No Open full page, and its address opened
|
|
@@ -34,7 +41,7 @@ export type RecordDialogRouteProps = {
|
|
|
34
41
|
*/
|
|
35
42
|
newPath?: string;
|
|
36
43
|
};
|
|
37
|
-
export declare function RecordDialogRoute({ list, label, className, fullPage, listPath: listAt, newPath: newAt, }: RecordDialogRouteProps): import("react").JSX.Element | null;
|
|
44
|
+
export declare function RecordDialogRoute({ list, label, className, look, fullPage, listPath: listAt, newPath: newAt, }: RecordDialogRouteProps): import("react").JSX.Element | null;
|
|
38
45
|
export type RecordLinkProps = Omit<ComponentProps<typeof Link>, 'state'>;
|
|
39
46
|
/**
|
|
40
47
|
* A link to a record that opens it over the current list (a board's card,
|
|
@@ -63,6 +63,13 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
63
63
|
// an EntityView with `layout="rail"` keeps its rail beside the main
|
|
64
64
|
// column, as on its page; a narrower screen stacks them.
|
|
65
65
|
//
|
|
66
|
+
// A tiny record (4.98, record standard 8A: a few fields and no notes)
|
|
67
|
+
// opens as a small card instead, `look="card"`: a 420px dialog (a bottom
|
|
68
|
+
// sheet on a phone, DialogContent `size="confirm"`) with no bar. The
|
|
69
|
+
// record's title, its actions (Delete as an icon), Open full page (an
|
|
70
|
+
// icon, when it has a page) and Close share one line, and its facts are
|
|
71
|
+
// plain rows under it, with no cards.
|
|
72
|
+
//
|
|
66
73
|
// Inside, the record's route renders as it always does. EntityView sees
|
|
67
74
|
// the dialog (useRecordDialog): its heading names the dialog, its back link
|
|
68
75
|
// gives way to the dialog's own bar, and not found's way out closes the
|
|
@@ -77,7 +84,7 @@ import { escapePassedThrough } from './escape-passthrough.js';
|
|
|
77
84
|
import { backgroundOf, NewRecordDialogContext, recordDialogState, RecordDialogContext, } from './record-dialog-context.js';
|
|
78
85
|
// Two paths are the same address, give or take a trailing slash.
|
|
79
86
|
const samePath = (a, b) => a.replace(/\/+$/, '') === b.replace(/\/+$/, '');
|
|
80
|
-
export function RecordDialogRoute({ list, label, className, fullPage = true, listPath: listAt, newPath: newAt, }) {
|
|
87
|
+
export function RecordDialogRoute({ list, label, className, look = 'record', fullPage = true, listPath: listAt, newPath: newAt, }) {
|
|
81
88
|
const location = useLocation();
|
|
82
89
|
const navigationType = useNavigationType();
|
|
83
90
|
const navigate = useNavigate();
|
|
@@ -119,7 +126,16 @@ export function RecordDialogRoute({ list, label, className, fullPage = true, lis
|
|
|
119
126
|
else
|
|
120
127
|
void navigate(-depth);
|
|
121
128
|
}, [navigate, location.key, depth, pathname, search, hash]);
|
|
122
|
-
const
|
|
129
|
+
const card = look === 'card';
|
|
130
|
+
// The card's controls sit on the record's title line (EntityView), so
|
|
131
|
+
// they're built here, where the address and the dialog are.
|
|
132
|
+
const { pathname: atPath, search: atSearch, hash: atHash } = location;
|
|
133
|
+
const dialog = useMemo(() => ({
|
|
134
|
+
titleId,
|
|
135
|
+
close,
|
|
136
|
+
look,
|
|
137
|
+
controls: card ? (_jsxs(_Fragment, { children: [fullPage && (_jsx(Link, { to: { pathname: atPath, search: atSearch, hash: atHash }, replace: true, "aria-label": "Open Full Page", title: "Open Full Page", className: buttonVariants({ variant: 'ghost', size: 'icon-sm' }), children: _jsx(Maximize2Icon, { "aria-hidden": "true" }) })), _jsxs(DialogClose, { render: _jsx(Button, { variant: "ghost", size: "icon-sm" }), children: [_jsx(XIcon, { "aria-hidden": "true" }), _jsx("span", { className: "sr-only", children: "Close" })] })] })) : undefined,
|
|
138
|
+
}), [titleId, close, look, card, fullPage, atPath, atSearch, atHash]);
|
|
123
139
|
// After the save: the new record over the same list, in this entry.
|
|
124
140
|
const created = useMemo(() => ({
|
|
125
141
|
close,
|
|
@@ -145,7 +161,7 @@ export function RecordDialogRoute({ list, label, className, fullPage = true, lis
|
|
|
145
161
|
return;
|
|
146
162
|
}
|
|
147
163
|
close();
|
|
148
|
-
}, children: _jsxs(DialogContent, { showCloseButton: false, "aria-labelledby": titleId, "aria-label": label, "data-slot": "record-dialog", size:
|
|
164
|
+
}, children: _jsxs(DialogContent, { showCloseButton: false, "aria-labelledby": titleId, "aria-label": label, "data-slot": "record-dialog", size: card ? 'confirm' : 'record', "data-look": look, className: cn('gap-0 overflow-hidden p-0 data-closed:hidden', card && 'flex max-h-[calc(100dvh-2rem)] flex-col', className), children: [!card && (_jsxs("div", { className: cn('flex items-center gap-2 border-b px-2 py-2', fullPage ? 'justify-between' : 'justify-end'), children: [fullPage && (_jsxs(Link, { to: { pathname: location.pathname, search: location.search, hash: location.hash }, replace: true, className: buttonVariants({ variant: 'ghost', size: 'sm' }), children: [_jsx(Maximize2Icon, { "aria-hidden": "true" }), "Open Full Page"] })), _jsxs(DialogClose, { render: _jsx(Button, { variant: "ghost", size: "icon-sm" }), children: [_jsx(XIcon, { "aria-hidden": "true" }), _jsx("span", { className: "sr-only", children: "Close" })] })] })), _jsx("div", { "data-slot": "record-dialog-body", className: cn('min-h-0 overflow-y-auto', card ? 'p-4 pb-[calc(1rem+env(safe-area-inset-bottom))] md:p-5' : 'p-4 sm:p-6'), children: _jsx(RecordDialogContext.Provider, { value: dialog, children: open && outlet }) })] }) })] }));
|
|
149
165
|
}
|
|
150
166
|
/**
|
|
151
167
|
* A link to a record that opens it over the current list (a board's card,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { type StatusKind } from '../../lib/status-kinds.js';
|
|
3
|
+
import type { IconComponent } from './icon-component.js';
|
|
4
|
+
export type StatusMarkProps = {
|
|
5
|
+
kind: StatusKind;
|
|
6
|
+
/** The status's own word ("As needed"). Defaults to the kind's (STATUS_KIND_LABELS). */
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
/** This place's own icon, in place of the kind's. */
|
|
9
|
+
icon?: IconComponent;
|
|
10
|
+
className?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* A status as its kind's icon and colour with its word: a `<span>`, so it
|
|
14
|
+
* goes wherever a badge did (a cell, EntityView's `badges`, an
|
|
15
|
+
* OptionSelect's `render`). The icon is decorative; the word says it.
|
|
16
|
+
*/
|
|
17
|
+
export declare function StatusMark({ kind, children, icon, className }: StatusMarkProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from 'cn';
|
|
3
|
+
import { STATUS_KIND_ICONS, STATUS_KIND_LABELS, STATUS_KIND_TONES, } from '../../lib/status-kinds.js';
|
|
4
|
+
/**
|
|
5
|
+
* A status as its kind's icon and colour with its word: a `<span>`, so it
|
|
6
|
+
* goes wherever a badge did (a cell, EntityView's `badges`, an
|
|
7
|
+
* OptionSelect's `render`). The icon is decorative; the word says it.
|
|
8
|
+
*/
|
|
9
|
+
export function StatusMark({ kind, children, icon, className }) {
|
|
10
|
+
const Icon = icon ?? STATUS_KIND_ICONS[kind];
|
|
11
|
+
return (_jsxs("span", { "data-slot": "status-mark", "data-kind": kind, className: cn('inline-flex min-w-0 items-center gap-1.5 type-label whitespace-nowrap', STATUS_KIND_TONES[kind], className), children: [_jsx(Icon, { "aria-hidden": "true", className: "size-3.5 shrink-0" }), _jsx("span", { className: "min-w-0 truncate", children: children ?? STATUS_KIND_LABELS[kind] })] }));
|
|
12
|
+
}
|
|
@@ -21,8 +21,9 @@ declare function Field({ className, orientation, size, solo, kind, ...props }: R
|
|
|
21
21
|
solo?: boolean;
|
|
22
22
|
/**
|
|
23
23
|
* A date or a number: two of a kind stay side by side on a phone.
|
|
24
|
-
*
|
|
25
|
-
*
|
|
24
|
+
* `choice`: two to a row, side by side on a phone while both fit.
|
|
25
|
+
* Found by itself for a date or number `<input>`, DateField (which
|
|
26
|
+
* marks itself, 4.88) and ChoiceButtons; say it for a control of your own.
|
|
26
27
|
*/
|
|
27
28
|
kind?: FieldKind;
|
|
28
29
|
}): import("react").JSX.Element;
|
|
@@ -11,7 +11,9 @@ import { fieldRows } from "../../lib/field-rows.js";
|
|
|
11
11
|
// (`<Field size="s" | "m" | "l">`) share a row, up to three, each as
|
|
12
12
|
// wide as its size; `<Field solo>` keeps a short one alone
|
|
13
13
|
// (lib/field-rows.ts has the rule). Below 48rem each takes its own row
|
|
14
|
-
// but two dates or two numbers.
|
|
14
|
+
// but two dates or two numbers. A choice (a Field holding ChoiceButtons,
|
|
15
|
+
// 4.98) shares a row only with another choice, and two choices stay side
|
|
16
|
+
// by side on a phone while both fit. The rows are worked out from the DOM, so
|
|
15
17
|
// a Field inside the app's own component still counts.
|
|
16
18
|
// - Compact: 14px between fields and 32px controls (40px under 48rem or
|
|
17
19
|
// on a touch screen), from `--control-height`, which FieldGroup sets
|
|
@@ -30,10 +32,14 @@ function FieldLegend({ className, variant = "legend", ...props }) {
|
|
|
30
32
|
// DateField marks its own box (`data-kind="date"`, 4.88).
|
|
31
33
|
const DATE_CONTROL = "input[type=date], [data-kind=date]";
|
|
32
34
|
const NUMBER_CONTROL = "input[type=number], input[inputmode=numeric], input[inputmode=decimal]";
|
|
35
|
+
// A row of choice buttons (ChoiceButtons, 4.98): two to a row (9C).
|
|
36
|
+
const CHOICE_CONTROL = "[data-slot=choice-buttons]";
|
|
33
37
|
function kindOf(field) {
|
|
34
38
|
const said = field.dataset.kind;
|
|
35
|
-
if (said === "date" || said === "number")
|
|
39
|
+
if (said === "date" || said === "number" || said === "choice")
|
|
36
40
|
return said;
|
|
41
|
+
if (field.querySelector(CHOICE_CONTROL))
|
|
42
|
+
return "choice";
|
|
37
43
|
if (field.querySelector(DATE_CONTROL))
|
|
38
44
|
return "date";
|
|
39
45
|
if (field.querySelector(NUMBER_CONTROL))
|
|
@@ -60,6 +66,7 @@ function layOut(group) {
|
|
|
60
66
|
child.style.removeProperty("--field-gaps");
|
|
61
67
|
delete child.dataset.fieldRow;
|
|
62
68
|
delete child.dataset.phonePair;
|
|
69
|
+
delete child.dataset.phoneFit;
|
|
63
70
|
return;
|
|
64
71
|
}
|
|
65
72
|
child.style.setProperty("--field-share", String(place.share));
|
|
@@ -69,6 +76,10 @@ function layOut(group) {
|
|
|
69
76
|
child.dataset.phonePair = "";
|
|
70
77
|
else
|
|
71
78
|
delete child.dataset.phonePair;
|
|
79
|
+
if (place.phoneFit)
|
|
80
|
+
child.dataset.phoneFit = "";
|
|
81
|
+
else
|
|
82
|
+
delete child.dataset.phoneFit;
|
|
72
83
|
});
|
|
73
84
|
}
|
|
74
85
|
function FieldGroup({ className, ref, ...props }) {
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export { ChoiceButtons, type ChoiceButtonsOption, type ChoiceButtonsProps } from
|
|
|
22
22
|
export { ReferenceCombobox, type ReferenceComboboxProps, type ReferenceRecord } from './components/app/reference-combobox.js';
|
|
23
23
|
export { fieldRows, type FieldKind, type FieldRowItem, type FieldRowPlace, type FieldSize } from './lib/field-rows.js';
|
|
24
24
|
export { KeyStats, type KeyStat, type KeyStatsProps } from './components/app/key-stats.js';
|
|
25
|
+
export { StatusMark, type StatusMarkProps } from './components/app/status-mark.js';
|
|
26
|
+
export { STATUS_KINDS, STATUS_KIND_ICONS, STATUS_KIND_LABELS, STATUS_KIND_TONES, type StatusKind, } from './lib/status-kinds.js';
|
|
25
27
|
export { EmptyText, type EmptyTextProps } from './components/app/empty-value.js';
|
|
26
28
|
export { isEmptyValue } from './lib/empty-value.js';
|
|
27
29
|
export { IconAction, type IconActionProps } from './components/app/icon-action.js';
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,8 @@ export { ChoiceButtons } from './components/app/choice-buttons.js';
|
|
|
26
26
|
export { ReferenceCombobox } from './components/app/reference-combobox.js';
|
|
27
27
|
export { fieldRows } from './lib/field-rows.js';
|
|
28
28
|
export { KeyStats } from './components/app/key-stats.js';
|
|
29
|
+
export { StatusMark } from './components/app/status-mark.js';
|
|
30
|
+
export { STATUS_KINDS, STATUS_KIND_ICONS, STATUS_KIND_LABELS, STATUS_KIND_TONES, } from './lib/status-kinds.js';
|
|
29
31
|
// The record's empty value (4.96): a muted dash read as "Not set", for an
|
|
30
32
|
// app's own strips, summary lines and cells.
|
|
31
33
|
export { EmptyText } from './components/app/empty-value.js';
|
package/dist/lib/field-rows.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type FieldSize = 's' | 'm' | 'l' | 'full';
|
|
2
|
-
export type FieldKind = 'date' | 'number';
|
|
2
|
+
export type FieldKind = 'date' | 'number' | 'choice';
|
|
3
3
|
export type FieldRowItem = {
|
|
4
4
|
size: FieldSize;
|
|
5
5
|
solo?: boolean;
|
|
@@ -12,6 +12,8 @@ export type FieldRowPlace = {
|
|
|
12
12
|
gaps: number;
|
|
13
13
|
/** Stays beside its partner on a phone: two dates or two numbers. */
|
|
14
14
|
phonePair: boolean;
|
|
15
|
+
/** Beside its partner on a phone while both fit, else a row of its own: two choices. */
|
|
16
|
+
phoneFit: boolean;
|
|
15
17
|
};
|
|
16
18
|
/** The most fields one row holds. */
|
|
17
19
|
export declare const FIELDS_PER_ROW = 3;
|
package/dist/lib/field-rows.js
CHANGED
|
@@ -11,23 +11,38 @@
|
|
|
11
11
|
// Below 48rem every field takes its own row, except two dates or two
|
|
12
12
|
// numbers next to each other in a row, which stay side by side
|
|
13
13
|
// (`phonePair`).
|
|
14
|
+
//
|
|
15
|
+
// A choice (4.98, record standard 9C: a Field holding ChoiceButtons, found
|
|
16
|
+
// by itself) shares its row only with another choice, two to a row, so a
|
|
17
|
+
// group of buttons has room to stay joined: three choices are two on a row
|
|
18
|
+
// and the third on the next, and a choice beside a date starts a row of
|
|
19
|
+
// its own. Two choices side by side stay that way on a phone
|
|
20
|
+
// while both fit, and go one per row when they don't (`phoneFit`, a width
|
|
21
|
+
// the browser works out from the buttons, styles/index.css).
|
|
14
22
|
const PARTS = { s: 1, m: 1.4, l: 2.6 };
|
|
15
23
|
/** The most fields one row holds. */
|
|
16
24
|
export const FIELDS_PER_ROW = 3;
|
|
17
25
|
export function fieldRows(items) {
|
|
18
|
-
const places = items.map(() => ({ share: null, gaps: 0, phonePair: false }));
|
|
26
|
+
const places = items.map(() => ({ share: null, gaps: 0, phonePair: false, phoneFit: false }));
|
|
19
27
|
let row = [];
|
|
20
28
|
const close = () => {
|
|
21
29
|
if (row.length > 1) {
|
|
22
|
-
|
|
30
|
+
// Two choices split the row evenly, whatever their sizes say.
|
|
31
|
+
const choices = row.every((at) => items[at].kind === 'choice');
|
|
32
|
+
const parts = row.map((at) => (choices ? 1 : PARTS[items[at].size]));
|
|
23
33
|
const total = parts.reduce((sum, part) => sum + part, 0);
|
|
24
34
|
row.forEach((at, index) => {
|
|
25
|
-
places[at] = { share: parts[index] / total, gaps: row.length - 1, phonePair: false };
|
|
35
|
+
places[at] = { share: parts[index] / total, gaps: row.length - 1, phonePair: false, phoneFit: false };
|
|
26
36
|
});
|
|
27
37
|
for (let index = 0; index + 1 < row.length; index++) {
|
|
28
38
|
const a = items[row[index]].kind;
|
|
29
39
|
const b = items[row[index + 1]].kind;
|
|
30
|
-
if (a
|
|
40
|
+
if (a === 'choice' && b === 'choice') {
|
|
41
|
+
places[row[index]].phoneFit = true;
|
|
42
|
+
places[row[index + 1]].phoneFit = true;
|
|
43
|
+
index++;
|
|
44
|
+
}
|
|
45
|
+
else if (a && a === b && !places[row[index]].phonePair) {
|
|
31
46
|
places[row[index]].phonePair = true;
|
|
32
47
|
places[row[index + 1]].phonePair = true;
|
|
33
48
|
index++;
|
|
@@ -43,8 +58,11 @@ export function fieldRows(items) {
|
|
|
43
58
|
return;
|
|
44
59
|
}
|
|
45
60
|
const hasLong = row.some((index) => items[index].size === 'l');
|
|
46
|
-
const
|
|
47
|
-
|
|
61
|
+
const isChoice = item.kind === 'choice';
|
|
62
|
+
// Choices share a row with each other only, two at a time.
|
|
63
|
+
const mixes = row.length > 0 && row.some((index) => (items[index].kind === 'choice') !== isChoice);
|
|
64
|
+
const full = row.length >= (hasLong || item.size === 'l' || isChoice ? 2 : FIELDS_PER_ROW);
|
|
65
|
+
if (full || mixes || (item.size === 'l' && hasLong))
|
|
48
66
|
close();
|
|
49
67
|
row.push(at);
|
|
50
68
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IconComponent } from '../components/app/icon-component.js';
|
|
2
|
+
export type StatusKind = 'active' | 'planned' | 'paused' | 'done' | 'ended' | 'attention';
|
|
3
|
+
/** Every kind, in the order a legend lists them. */
|
|
4
|
+
export declare const STATUS_KINDS: readonly StatusKind[];
|
|
5
|
+
/** Each kind's icon: the one place to change them. */
|
|
6
|
+
export declare const STATUS_KIND_ICONS: Record<StatusKind, IconComponent>;
|
|
7
|
+
/** Each kind's word, when the status has none of its own (a legend). */
|
|
8
|
+
export declare const STATUS_KIND_LABELS: Record<StatusKind, string>;
|
|
9
|
+
/** Each kind's colour, for the icon and the word: *-text tokens and the muted foreground only. */
|
|
10
|
+
export declare const STATUS_KIND_TONES: Record<StatusKind, string>;
|