@mistriwork/kit 1.0.0-rc.15 → 1.0.0-rc.16

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.
@@ -49,10 +49,11 @@ interface ChartFigureProps {
49
49
  curve?: 'smooth' | 'straight';
50
50
  /** A donut's words for the figure in its middle. */
51
51
  total?: string;
52
- /** How a donut's slices and a bar chart's categories are arranged: 'answer' keeps the order they were asked in (the
52
+ /** How a donut's slices and a bar chart's categories are arranged: 'category' is the key's own order (its vocabulary,
53
+ else its values as a scale), 'answer' keeps the order they were asked in (the
53
54
  page's chart asked for the key's natural order, or a column's), 'value' is biggest first whatever the key's
54
55
  vocabulary. Absent, the key's vocabulary or scale, else biggest first. */
55
- arrange?: 'answer' | 'value';
56
+ arrange?: 'answer' | 'value' | 'category';
56
57
  /** A line with too few filled buckets to draw a line through keeps its shape and stands its points alone. */
57
58
  dots?: boolean;
58
59
  }
@@ -29,11 +29,13 @@ export function ChartFigure({ answer, shape, limit, target, height, say, label,
29
29
  const periods = (answer?.rows ?? []).every((row) => /^\d{4}(-\d{2}(-\d{2})?|-Q[1-4])?$/.test(String(row[columns[0]])));
30
30
  const answered = arrange === 'answer' && (donut || bars)
31
31
  ? (answer?.rows ?? []).slice(0, limit)
32
- : arrange === 'value' && (donut || (bars && !periods))
33
- ? orderDeclared(answer?.rows ?? [], columns[0], columns[1]).slice(0, limit)
34
- : donut || (bars && !periods) || (!stacked && !periods && columns.length < 3 && ((vocabulary?.length ?? 0) > 0 || Boolean(scale)))
35
- ? orderDeclared(answer?.rows ?? [], columns[0], columns[1], vocabulary, scale).slice(0, limit)
36
- : (answer?.rows ?? []);
32
+ : arrange === 'category' && (donut || (bars && !periods))
33
+ ? orderDeclared(answer?.rows ?? [], columns[0], columns[1], vocabulary, true).slice(0, limit)
34
+ : arrange === 'value' && (donut || (bars && !periods))
35
+ ? orderDeclared(answer?.rows ?? [], columns[0], columns[1]).slice(0, limit)
36
+ : donut || (bars && !periods) || (!stacked && !periods && columns.length < 3 && ((vocabulary?.length ?? 0) > 0 || Boolean(scale)))
37
+ ? orderDeclared(answer?.rows ?? [], columns[0], columns[1], vocabulary, scale).slice(0, limit)
38
+ : (answer?.rows ?? []);
37
39
  /* A line over a two-key answer is a line per value of the second key. */
38
40
  const multi = !stacked && !donut && !bars && columns.length >= 3;
39
41
  const rows = answered.map((r) => ({
@@ -1,3 +1,4 @@
1
- export declare function JsonView({ value }: {
1
+ export declare function JsonView({ value, bar }: {
2
2
  value: object;
3
+ bar?: boolean;
3
4
  }): import("react").JSX.Element;
@@ -16,10 +16,10 @@ import { useEffect, useState } from 'react';
16
16
  import { formatLocale } from '../locale.js';
17
17
  import { countLabel, isContainer, ITEM_PAGE, KEY_PAGE, layoutOf, MORE_STEP, OPEN_DEPTH, prettyJson, restOf, scalarOf, sizeOf, } from './jsonModel.js';
18
18
  import { say } from '../copy/record/components/JsonView.js';
19
- export function JsonView({ value }) {
19
+ export function JsonView({ value, bar = true }) {
20
20
  const [raw, setRaw] = useState(false);
21
21
  const locale = formatLocale();
22
- return (_jsxs("div", { className: "json-view", children: [_jsxs("div", { className: "json-bar", children: [_jsx("button", { type: "button", className: "json-tool", "aria-pressed": raw, onClick: () => setRaw(!raw), children: say('raw') }), _jsx(CopyButton, { value: value })] }), raw ? (_jsx("pre", { className: "json-raw", tabIndex: 0, "aria-label": say('rawJson'), children: prettyJson(value) })) : (_jsx(Node, { value: value, depth: 0, locale: locale }))] }));
22
+ return (_jsxs("div", { className: "json-view", children: [bar && (_jsxs("div", { className: "json-bar", children: [_jsx("button", { type: "button", className: "json-tool", "aria-pressed": raw, onClick: () => setRaw(!raw), children: say('raw') }), _jsx(CopyButton, { value: value })] })), raw ? (_jsx("pre", { className: "json-raw", tabIndex: 0, "aria-label": say('rawJson'), children: prettyJson(value) })) : (_jsx(Node, { value: value, depth: 0, locale: locale }))] }));
23
23
  }
24
24
  function CopyButton({ value }) {
25
25
  const [said, setSaid] = useState(null);
@@ -8,12 +8,13 @@
8
8
  * telehealth" on Noah's page); the columns its `show` names are the facts,
9
9
  * in that order, each dressed by its display rule, and nothing else the read
10
10
  * carried to name or open the row; "View lease" says so again at the foot.
11
+ * A card over a link table is named by, and opens, the far record its link row points at (`opens`).
11
12
  * With no such row the card says what that means, in the author's words
12
13
  * where there are some.
13
14
  */
14
15
  import type { ReactNode } from 'react';
15
16
  import { type TableMeta } from '@mistriwork/engine/shared/schema.js';
16
- export declare function CurrentCard({ table, caption, row, columns, show, labels, referenceLabels, record, title, noun, empty, }: {
17
+ export declare function CurrentCard({ table, caption, row, columns, show, labels, referenceLabels, record, opens, title, noun, empty, }: {
17
18
  table: TableMeta;
18
19
  /** The section's title: what the card is ("Current lease"). */
19
20
  caption?: string;
@@ -29,6 +30,14 @@ export declare function CurrentCard({ table, caption, row, columns, show, labels
29
30
  key: Record<string, unknown> | null;
30
31
  label: string;
31
32
  } | undefined;
33
+ /** The record the card opens in place of its own row, where that row is a link between two records. */
34
+ opens?: {
35
+ table: TableMeta;
36
+ column: string;
37
+ key: Record<string, unknown>;
38
+ label: string;
39
+ noun: string;
40
+ };
32
41
  /** The name the card is titled by, where it says less than the record's own (its parent's name left out);
33
42
  null where it is the page's own name, which the heading already says. */
34
43
  title?: string | null;
@@ -6,22 +6,26 @@ import { primaryKey } from '@mistriwork/engine/shared/schema.js';
6
6
  import { Value } from './Value.js';
7
7
  import { presentationColumns } from './columnPresentation.js';
8
8
  import { say } from '../copy/record/components/PageCurrent.js';
9
- export function CurrentCard({ table, caption, row, columns, show, labels, referenceLabels, record, title, noun, empty, }) {
9
+ export function CurrentCard({ table, caption, row, columns, show, labels, referenceLabels, record, opens, title, noun, empty, }) {
10
10
  const naming = labelPath(table);
11
11
  const keys = primaryKey(table);
12
12
  /* A card titled by a computed name still reads a column to name the row by
13
13
  where the App names none: that column is the title, not a fact the
14
14
  author asked for. */
15
- const asked = (show?.length ? show.filter((name) => columns.includes(name)) : columns).filter((name) => name !== naming && !keys.includes(name));
15
+ const asked = (show?.length ? show.filter((name) => columns.includes(name)) : columns).filter((name) => name !== naming && !keys.includes(name) && name !== opens?.column);
16
16
  const facts = asked.filter((name) => row && row[name] !== null && row[name] !== undefined && row[name] !== '');
17
17
  const metadata = presentationColumns(state.schema, table, facts);
18
+ /* What the card's name and its foot open: the far record of a link row, else the row itself. */
19
+ const target = opens
20
+ ? { table: opens.table, key: opens.key, label: opens.label, noun: opens.noun }
21
+ : record && { table, key: record.key, label: record.label, noun };
18
22
  const open = () => {
19
- if (record?.key)
20
- void openRecord(table.id, record.key, record.label);
23
+ if (target?.key)
24
+ void openRecord(target.table.id, target.key, target.label);
21
25
  };
22
- return (_jsxs("div", { className: "page-card page-current", children: [caption && _jsx("h2", { className: "page-card-caption", children: caption }), row && record ? (_jsxs(_Fragment, { children: [title !== null && (_jsx("p", { className: "page-card-title", children: record.key ? (_jsx("button", { type: "button", className: "ref-jump page-card-name", "data-opens": opensRecord(table.id, record.key), onClick: open, children: title ?? record.label })) : (_jsx("span", { children: title ?? record.label })) })), facts.length > 0 && (_jsx("dl", { className: "page-card-facts", children: facts.map((name) => {
26
+ return (_jsxs("div", { className: "page-card page-current", children: [caption && _jsx("h2", { className: "page-card-caption", children: caption }), row && record ? (_jsxs(_Fragment, { children: [title !== null && (_jsx("p", { className: "page-card-title", children: target?.key ? (_jsx("button", { type: "button", className: "ref-jump page-card-name", "data-opens": opensRecord(target.table.id, target.key), onClick: open, children: title ?? target.label })) : (_jsx("span", { children: title ?? target?.label })) })), facts.length > 0 && (_jsx("dl", { className: "page-card-facts", children: facts.map((name) => {
23
27
  const label = referenceLabels?.[name] ? row[referenceLabels[name]] : undefined;
24
28
  const col = metadata.get(name) ?? { name, type: 'TEXT', nullable: true, primaryKey: false };
25
29
  return (_jsxs("div", { className: "page-card-fact", children: [_jsx("dt", { children: labels?.[name] ?? columnLabel(table.id, name) ?? humanName(name) }), _jsx("dd", { children: _jsx(Value, { tableId: table.id, col: label == null ? col : { ...col, type: 'TEXT' }, value: label ?? row[name], compact: true }) })] }, name));
26
- }) })), record.key && (_jsx("p", { className: "page-card-foot", children: _jsx("button", { type: "button", className: "ref-jump page-card-more", "data-opens": opensRecord(table.id, record.key), onClick: open, children: say('common.view', { noun }) }) }))] })) : (_jsx("div", { className: "page-current-empty", children: empty }))] }));
30
+ }) })), target?.key && (_jsx("p", { className: "page-card-foot", children: _jsx("button", { type: "button", className: "ref-jump page-card-more", "data-opens": opensRecord(target.table.id, target.key), onClick: open, children: say('common.view', { noun: target.noun }) }) }))] })) : (_jsx("div", { className: "page-current-empty", children: empty }))] }));
27
31
  }
@@ -157,16 +157,19 @@ export function FieldsSection({ page, section, index, base, recordKey: key, fold
157
157
  const presentation = section.presentation ?? (section.region === 'aside' ? 'properties' : 'summary');
158
158
  const rail = presentation === 'properties';
159
159
  const filled = (path) => row[path] !== null && row[path] !== undefined && row[path] !== '';
160
+ /* A rail leaves out the values the record does not have, as a header's facts do, unless it says 'show'; any block can
161
+ ask. A field the reader may fill in place is not one of them: it is where the value is set. */
162
+ const hideEmpty = section.emptyMode === 'hide' || (rail && section.emptyMode !== 'show');
160
163
  /* A value as a line of facts or a card says it: a reference is the record
161
164
  it names, by its label where the section fetched one, never its key. */
162
165
  const said = (path, compact) => {
163
166
  const column = columnAt(path);
164
167
  const labelAt = refLabels.get(path);
165
- return column?.references ? (_jsx(RefJump, { references: column.references, value: row[path], label: labelAt ? row[labelAt] : undefined, table: base, column: path, row: row })) : (_jsx(Value, { col: column, value: row[path], tableId: base.id, compact: compact, row: row }));
168
+ return column?.references ? (_jsx(RefJump, { references: column.references, value: row[path], label: labelAt ? row[labelAt] : undefined, table: base, column: path, row: row })) : (_jsx(Value, { col: column, value: row[path], tableId: base.id, compact: compact, row: row, subtitled: true }));
166
169
  };
167
170
  /* A headline is the record offered: its figure, its facts and what to do next. */
168
171
  if (section.presentation === 'headline') {
169
- return (_jsx(SectionBox, { section: section, foldable: false, body: _jsx(PageHeadline, { tableId: base.id, row: row, paths: paths, column: columnAt, actions: section.actions ?? [], subfigure: section.subfigure, was: section.was, note: section.note }) }));
172
+ return (_jsx(SectionBox, { section: section, foldable: false, body: _jsx(PageHeadline, { tableId: base.id, row: row, paths: paths, column: columnAt, actions: section.actions ?? [], subfigure: section.subfigure, subtitle: section.subtitle, was: section.was, note: section.note }) }));
170
173
  }
171
174
  /* A facts line: the values alone, each after a dot, in the order named.
172
175
  An empty one is left out rather than said as a dash in the middle of a
@@ -216,6 +219,8 @@ export function FieldsSection({ page, section, index, base, recordKey: key, fold
216
219
  /* A group that follows a reference to nothing — "Converted to" on a lead
217
220
  that has not been — is one dash, not four labels over four dashes. */
218
221
  if (stem && shell().inApp() && paths.length && paths.every((p) => row[p] === null || row[p] === undefined)) {
222
+ if (hideEmpty)
223
+ return null;
219
224
  return (_jsx(SectionBox, { section: section, foldable: foldable, body: _jsx("p", { className: "page-group-empty", title: say('nothingHereEveryField'), children: "\u2014" }) }));
220
225
  }
221
226
  const bound = resourceOf(shell().app(), base.id)?.defined;
@@ -252,6 +257,9 @@ export function FieldsSection({ page, section, index, base, recordKey: key, fold
252
257
  recordActions.list.some((action) => !action.command && Object.keys(action.set).length === 1 && path in action.set)) {
253
258
  dd = (_jsx("dd", { className: "page-field-edit", children: _jsx(ActionPick, { tableId: base.id, recordKey: key, column: path, value: value, actions: recordActions, caption: columnLabel(base.id, path, stem) ?? path, onDone: onEdit, connection: connection }) }));
254
259
  }
260
+ else if (hideEmpty && !filled(path) && !adorned) {
261
+ return null;
262
+ }
255
263
  else if (value === null || value === undefined) {
256
264
  /* A text a section is only about, with nothing in it, is one muted line saying so, not a dash alone in the
257
265
  room of a paragraph. */
@@ -263,7 +271,7 @@ export function FieldsSection({ page, section, index, base, recordKey: key, fold
263
271
  dd = (_jsxs("dd", { children: [_jsx(RefJump, { references: column.references, value: value, label: labelAt ? row[labelAt] : undefined, table: base, column: path, row: row }), adorned] }));
264
272
  }
265
273
  else {
266
- dd = (_jsxs("dd", { children: [_jsx(Value, { col: column, value: value, tableId: base.id, row: row }), adorned] }));
274
+ dd = (_jsxs("dd", { children: [_jsx(Value, { col: column, value: value, tableId: base.id, row: row, subtitled: true }), adorned] }));
267
275
  }
268
276
  const shownAs = shared ? path.slice(shared.length) : path;
269
277
  const label = columnLabel(base.id, path, stem) ?? shownAs;
@@ -285,6 +293,9 @@ export function FieldsSection({ page, section, index, base, recordKey: key, fold
285
293
  const prose = lone && typeof value === 'string' && !column?.references;
286
294
  return (_jsxs("div", { className: `page-field${long ? ' page-field-wide' : ''}${prose ? ' page-field-prose' : ''}`, children: [_jsx("dt", { title: path, className: lone ? 'visually-hidden' : undefined, children: label }), dd] }, path));
287
295
  });
296
+ /* Nothing left to say: the block is not drawn, as a header with no facts is not. A writable block keeps its fields. */
297
+ if (hideEmpty && !fields.some(Boolean) && !section.workflow)
298
+ return null;
288
299
  const columns = typeof section.columns === 'number' ? section.columns : undefined;
289
300
  /* Both are lists of terms, so both are drawn as one: a property rail says
290
301
  caption beside value, the grid says them in columns. A grid of <dt>/<dd>
@@ -16,7 +16,7 @@ import { readRecordSource, shareRecordSource } from '../recordSource.js';
16
16
  import { pathEqualityFilter } from '../resourceRequests.js';
17
17
  import { canEditRow, pendingCount, sameRow, stagedVersion, subscribeStaged } from '../write.js';
18
18
  import { humanName } from '@mistriwork/engine/shared/model.js';
19
- import { factWord } from '@mistriwork/engine/shared/appCards.js';
19
+ import { factWord, HEADER_FACTS_SHOWN } from '@mistriwork/engine/shared/appCards.js';
20
20
  import { shell } from '../shellMode.js';
21
21
  import { isPinned, togglePinned } from '../pagemarks.js';
22
22
  import { Editable, PendingBar } from './Editable.js';
@@ -264,16 +264,17 @@ function useRecordHeader({ page, base, recordKey: key, header, onSectionLabel, o
264
264
  : undefined;
265
265
  const adornments = new Map(facts.map((path) => [path, adornedAt(path)]));
266
266
  const shown = facts.filter((path) => filled(path) || adornments.get(path));
267
+ const fact = (path) => {
268
+ const labels = section.factLabels;
269
+ const word = labels && Object.hasOwn(labels, path)
270
+ ? factWord(labels[path], row[path], columnDisplay(base.id, path))
271
+ : undefined;
272
+ const before = word !== undefined && labels[path].position === 'before';
273
+ return (_jsxs("li", { className: "page-fact", children: [word === undefined && (_jsxs("span", { className: "page-fact-caption", children: [captionOf(path), _jsx("span", { className: "visually-hidden", children: ": " })] })), before && _jsxs("span", { className: "page-fact-word", children: [word, " "] }), filled(path) && said(path), word !== undefined && !before && _jsxs("span", { className: "page-fact-word", children: [" ", word] }), adornments.get(path)] }, path));
274
+ };
267
275
  return {
268
276
  /* Its caption is heard, not seen: beside the name a chip is its own word. */
269
277
  status: status && filled(status) ? (_jsxs("span", { className: "page-head-status", children: [_jsxs("span", { className: "visually-hidden", children: [captionOf(status), ": "] }), said(status)] })) : null,
270
- facts: shown.length ? (_jsx("ul", { className: "page-facts page-head-facts", "aria-label": say('common.keyFacts'), children: shown.map((path) => {
271
- const labels = section.factLabels;
272
- const word = labels && Object.hasOwn(labels, path)
273
- ? factWord(labels[path], row[path], columnDisplay(base.id, path))
274
- : undefined;
275
- const before = word !== undefined && labels[path].position === 'before';
276
- return (_jsxs("li", { className: "page-fact", children: [word === undefined && (_jsxs("span", { className: "page-fact-caption", children: [captionOf(path), _jsx("span", { className: "visually-hidden", children: ": " })] })), before && _jsxs("span", { className: "page-fact-word", children: [word, " "] }), filled(path) && said(path), word !== undefined && !before && _jsxs("span", { className: "page-fact-word", children: [" ", word] }), adornments.get(path)] }, path));
277
- }) })) : null,
278
+ facts: shown.length ? (_jsxs(_Fragment, { children: [_jsx("ul", { className: "page-facts page-head-facts", "aria-label": say('common.keyFacts'), children: shown.slice(0, HEADER_FACTS_SHOWN).map(fact) }), shown.length > HEADER_FACTS_SHOWN && (_jsxs("details", { className: "page-head-more", children: [_jsx("summary", { children: say('common.more') }), _jsx("ul", { className: "page-facts page-head-facts", children: shown.slice(HEADER_FACTS_SHOWN).map(fact) })] }))] })) : null,
278
279
  };
279
280
  }
@@ -10,6 +10,8 @@ interface PageHeadlineProps {
10
10
  actions: ReadonlyArray<PageHeadlineAction>;
11
11
  /** A second figure under the first. */
12
12
  subfigure?: string;
13
+ /** A line of words under the figure, read from a column of the record (a frequency under an income). */
14
+ subtitle?: string;
13
15
  /** The figure's earlier value, struck through beside it when it is set and higher. */
14
16
  was?: string;
15
17
  /** Small print under the actions. */
@@ -19,5 +21,5 @@ interface PageHeadlineProps {
19
21
  export declare function prefilledFormLink(link: ViewLink, action: PageHeadlineAction, row: Record<string, unknown>): ViewLink;
20
22
  /** The earlier value is said only where it is a figure above the one in hand: a reduction, never a rise or a repeat. */
21
23
  export declare function wasShown(row: Record<string, unknown>, figure: string | undefined, was: string | undefined): boolean;
22
- export declare function PageHeadline({ tableId, row, paths, column, actions, subfigure, was, note }: PageHeadlineProps): import("react").JSX.Element;
24
+ export declare function PageHeadline({ tableId, row, paths, column, actions, subfigure, subtitle, was, note }: PageHeadlineProps): import("react").JSX.Element;
23
25
  export {};
@@ -59,7 +59,7 @@ export function wasShown(row, figure, was) {
59
59
  const [then, now] = [Number(row[was]), Number(row[figure])];
60
60
  return Number.isFinite(then) && Number.isFinite(now) && then > now;
61
61
  }
62
- export function PageHeadline({ tableId, row, paths, column, actions, subfigure, was, note }) {
62
+ export function PageHeadline({ tableId, row, paths, column, actions, subfigure, subtitle, was, note }) {
63
63
  useMessageLanguage();
64
64
  const caption = (path) => columnLabel(tableId, path) ?? humanName(path.split('.').pop() ?? path);
65
65
  const [figure, ...facts] = paths;
@@ -88,9 +88,10 @@ export function PageHeadline({ tableId, row, paths, column, actions, subfigure,
88
88
  });
89
89
  const [asking, setAsking] = useState(null);
90
90
  const second = subfigure !== undefined && hasValue(row[subfigure]);
91
+ const line = subtitle !== undefined && hasValue(row[subtitle]);
91
92
  const earlier = wasShown(row, figure, was);
92
93
  const shownFacts = facts.filter((path) => hasValue(row[path]));
93
- return (_jsxs("div", { className: "page-headline", children: [figure !== undefined && (_jsxs("p", { className: "page-headline-figure", children: [_jsxs("span", { className: "visually-hidden", children: [caption(figure), ": "] }), _jsx(Value, { col: column(figure), value: row[figure], tableId: tableId, compact: true, row: row }), earlier && (_jsxs(_Fragment, { children: [' ', _jsxs("s", { className: "page-headline-was", children: [_jsxs("span", { className: "visually-hidden", children: [caption(was), ": "] }), _jsx(Value, { col: column(was), value: row[was], tableId: tableId, compact: true })] })] }))] })), second && (_jsxs("p", { className: "page-headline-sub", children: [_jsx("span", { className: "page-headline-sub-caption", children: caption(subfigure) }), ' ', _jsx(Value, { col: column(subfigure), value: row[subfigure], tableId: tableId, compact: true })] })), links.some(Boolean) && (_jsx("div", { className: "page-headline-actions", children: links.map((entry, index) => !entry ? null : 'action' in entry && entry.action ? (TargetAction && (_jsx(TargetAction, { label: entry.action.label, to: entry.action.to, row: row, className: `page-headline-action is-${entry.kind}` }, index))) : (_jsx("a", { className: `page-headline-action is-${entry.kind}`, href: entry.link.href, onClick: entry.dialog
94
+ return (_jsxs("div", { className: "page-headline", children: [figure !== undefined && (_jsxs("p", { className: "page-headline-figure", children: [_jsxs("span", { className: "visually-hidden", children: [caption(figure), ": "] }), _jsx(Value, { col: column(figure), value: row[figure], tableId: tableId, compact: true, row: row, subtitled: true }), earlier && (_jsxs(_Fragment, { children: [' ', _jsxs("s", { className: "page-headline-was", children: [_jsxs("span", { className: "visually-hidden", children: [caption(was), ": "] }), _jsx(Value, { col: column(was), value: row[was], tableId: tableId, compact: true })] })] })), line && (_jsx("span", { className: "page-headline-subtitle", children: _jsx(Value, { col: column(subtitle), value: row[subtitle], tableId: tableId, compact: true }) }))] })), second && (_jsxs("p", { className: "page-headline-sub", children: [_jsx("span", { className: "page-headline-sub-caption", children: caption(subfigure) }), ' ', _jsx(Value, { col: column(subfigure), value: row[subfigure], tableId: tableId, compact: true })] })), links.some(Boolean) && (_jsx("div", { className: "page-headline-actions", children: links.map((entry, index) => !entry ? null : 'action' in entry && entry.action ? (TargetAction && (_jsx(TargetAction, { label: entry.action.label, to: entry.action.to, row: row, className: `page-headline-action is-${entry.kind}` }, index))) : (_jsx("a", { className: `page-headline-action is-${entry.kind}`, href: entry.link.href, onClick: entry.dialog
94
95
  ? (event) => {
95
96
  if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0)
96
97
  return;
@@ -15,7 +15,7 @@ import { presentationColumns } from './columnPresentation.js';
15
15
  import { humanName } from '@mistriwork/engine/shared/model.js';
16
16
  import { andQuery } from '@mistriwork/engine/shared/query.js';
17
17
  import { formatNumber } from '../locale.js';
18
- import { inAppPage, PageRenderContext, usePageApi } from './pageContext.js';
18
+ import { inAppPage, PageRenderContext, spoken, usePageApi } from './pageContext.js';
19
19
  import { Loading, SectionBox } from './PageSectionBox.js';
20
20
  import { dressFor, groupLabel, withUnit } from './valueModel.js';
21
21
  import { barShare, CurrencyFigures, EXACT, figureSayer, namedGroups, orderGroups, sayer } from './dashboardModel.js';
@@ -71,7 +71,7 @@ export function MetricSection({ section, plan }) {
71
71
  figures, and a loading bar of another height moved every section under
72
72
  the row when they came (test/built-client-vitals.mjs). */
73
73
  if (reading.isPending)
74
- return (_jsx(SectionBox, { section: section, foldable: false, body: _jsxs("button", { type: "button", className: "page-metric-value", disabled: true, tabIndex: -1, "aria-hidden": "true", style: { visibility: 'hidden' }, children: [_jsx("span", { className: "metric-number", children: "0" }), _jsx("span", { className: "metric-of", children: section.title ? '' : section.from })] }) }));
74
+ return (_jsx(SectionBox, { section: section, foldable: false, body: _jsxs("button", { type: "button", className: "page-metric-value", disabled: true, tabIndex: -1, "aria-hidden": "true", style: { visibility: 'hidden' }, children: [_jsx("span", { className: "metric-number", children: "0" }), _jsx("span", { className: "metric-of", children: section.title ? '' : spoken(section.from ?? '') })] }) }));
75
75
  if (reading.isError)
76
76
  return _jsx(SectionBox, { section: section, body: null, foldable: false, broken: reading.error.message });
77
77
  let aggregate;
@@ -109,7 +109,7 @@ export function MetricSection({ section, plan }) {
109
109
  const said = value === '—' ? value : dress?.text ? withUnit(dress.text, unit) : figureSayer(rule, unit, EXACT)(value);
110
110
  return (_jsx(SectionBox, { section: section, foldable: false, body: _jsxs("button", { type: "button", className: "page-metric-value", disabled: !open, title: open
111
111
  ? sayCopy('openTheThisCounted', { from: section.from ?? '' })
112
- : sayCopy('thisCountCannotBeReopened', { from: section.from ?? '' }), onClick: open ?? undefined, children: [_jsx("span", { className: "metric-number", children: said }), _jsx("span", { className: "metric-of", children: section.title ? '' : section.from })] }) }));
112
+ : sayCopy('thisCountCannotBeReopened', { from: section.from ?? '' }), onClick: open ?? undefined, children: [_jsx("span", { className: "metric-number", children: said }), _jsx("span", { className: "metric-of", children: section.title ? '' : spoken(section.from ?? '') })] }) }));
113
113
  }
114
114
  /** Groups of related rows, biggest first: the "mostly what?" answer. */
115
115
  export function BreakdownSection({ section, plan, base }) {
@@ -124,6 +124,8 @@ export function BreakdownSection({ section, plan, base }) {
124
124
  enabled: !plan.empty && Boolean(plan.breakdown),
125
125
  staleTime: 0,
126
126
  });
127
+ if (section.emptyMode === 'hide' && plan.empty)
128
+ return null;
127
129
  if (plan.empty) {
128
130
  /* Said as the reader would: which reference is unset, not a column's name. */
129
131
  const reference = section.of
@@ -150,6 +152,8 @@ export function BreakdownSection({ section, plan, base }) {
150
152
  /* The grouped column read through its path, so `campaign_id.kind` finds the vocabulary of the campaign's kind. */
151
153
  const allowed = presentationColumns(state.schema, findTable(section.from), [section.by ?? '']).get(section.by ?? '')?.allowed;
152
154
  const rows = orderGroups(got.rows, keyName, countName, allowed);
155
+ if (!rows.length && section.emptyMode === 'hide')
156
+ return null;
153
157
  // A table's name ("campaign_member") is the Workbench's vocabulary, not an
154
158
  // App reader's; a breakdown's title names groups, so it cannot be reused.
155
159
  if (!rows.length)
@@ -201,6 +205,9 @@ export function ChartSection({ section, plan, base }) {
201
205
  enabled: !plan.empty && Boolean(plan.breakdown),
202
206
  staleTime: 0,
203
207
  });
208
+ /* `empty: 'hide'`: a chart with nothing to draw leaves the page, as a related list does. */
209
+ if (section.emptyMode === 'hide' && plan.empty)
210
+ return null;
204
211
  if (plan.empty) {
205
212
  const reference = section.of
206
213
  ? inAppPage()
@@ -218,6 +225,8 @@ export function ChartSection({ section, plan, base }) {
218
225
  const got = data.data;
219
226
  if (!got || 'errors' in got)
220
227
  return (_jsx(SectionBox, { section: section, body: null, foldable: false, broken: (got && 'errors' in got ? got.errors[0]?.message : undefined) ?? sayCopy('thisChartCouldNotBeRead') }));
228
+ if (section.emptyMode === 'hide' && !got.rows.length)
229
+ return null;
221
230
  const from = section.from ?? '';
222
231
  /* Each key's column, its period dropped: "month issued_on" is labelled as issued_on is. */
223
232
  const [first = '', second = ''] = (section.by ?? '').split(',').map((key) => key.trim().split(/\s+/).pop() ?? '');
@@ -248,5 +257,5 @@ export function ChartSection({ section, plan, base }) {
248
257
  go(tableView(plan.breakdown.base, `${plan.breakdown.base} ${where}`), 'push');
249
258
  }
250
259
  : null;
251
- return (_jsx(SectionBox, { section: section, foldable: false, body: _jsx(ChartFigure, { answer: drawn, arrange: section.sort === 'value' ? 'value' : plan.breakdown.orderBy?.[0]?.name === 'value' ? undefined : 'answer', shape: section.shape, limit: section.limit, target: section.target, height: section.height, say: say, label: namedGroups(got, got.columns[0], firstLabel.say), seriesLabel: namedGroups(got, second ? got.columns[1] : undefined, labelFor(second).say), vocabulary: firstLabel.allowed, onPick: drill, empty: inAppPage() ? sayCopy('nothingToDrawYet') : sayCopy('noForThisRecord', { from }) }) }));
260
+ return (_jsx(SectionBox, { section: section, foldable: false, body: _jsx(ChartFigure, { answer: drawn, arrange: section.sort === 'value' ? 'value' : plan.breakdown.orderBy?.[0]?.name === 'value' ? undefined : 'answer', shape: section.shape, limit: section.limit, target: section.target, curve: section.curve, total: section.total, height: section.height, say: say, label: namedGroups(got, got.columns[0], firstLabel.say), seriesLabel: namedGroups(got, second ? got.columns[1] : undefined, labelFor(second).say), vocabulary: firstLabel.allowed, onPick: drill, empty: inAppPage() ? sayCopy('nothingToDrawYet') : sayCopy('noForThisRecord', { from }) }) }));
252
261
  }
@@ -12,7 +12,7 @@ import { ownedBy } from '../requestIdentity.js';
12
12
  import { columnLabel, recordLabel, api as coreApi, findTable, openRecord, rowLabel, state, writeAllowed } from '../core.js';
13
13
  import { relatedRows } from '../prefs.js';
14
14
  import { formatBytes, formatNumber, formatRelativeDay } from '../locale.js';
15
- import { columnKind } from '@mistriwork/engine/shared/schema.js';
15
+ import { columnKind, linkTarget } from '@mistriwork/engine/shared/schema.js';
16
16
  import { recordViewKey, recordViewLabel, withoutParent, withoutParentName } from '@mistriwork/engine/shared/referenceModel.js';
17
17
  import { groupsBody, listView } from '@mistriwork/engine/shared/recordReads.js';
18
18
  import { GROUP_ROWS_DEFAULT, GROUPS_DEFAULT } from '@mistriwork/engine/shared/pageModel.js';
@@ -264,7 +264,22 @@ function RelatedList({ section, plan, base, recordKey, onEdit, collapsed }) {
264
264
  const noun = (app ? (resourceOf(table)?.noun?.one ?? recordNoun(undefined, table.name)) : table.name).toLocaleLowerCase();
265
265
  const shown = (got.columns ?? []).filter((name) => !hidden.includes(name));
266
266
  const record = rows[0] ? recordForRow(rows[0]) : undefined;
267
- return (_jsx("section", { className: `${sectionClass(section)} page-card-section`, children: _jsx(CurrentCard, { table: table, caption: section.title, row: rows[0], columns: shown, show: Array.isArray(section.columns) ? section.columns : undefined, referenceLabels: labelColumns, labels: section.labels, record: record, title: record && app ? cardTitle(record.label, recordName) : undefined, noun: noun,
267
+ /* A card over a link table opens, and is named by, the record its far reference names: "Conversation 12", not the
268
+ link row that holds the two (linkTarget). */
269
+ const farColumn = linkTarget(table, section.path ?? '', section.opens);
270
+ const farReference = farColumn ? table.columns.find((column) => column.name === farColumn)?.references : undefined;
271
+ const farTable = farReference ? findTable(farReference.table) : undefined;
272
+ const farValue = rows[0] && farColumn ? rows[0][farColumn] : undefined;
273
+ const far = farColumn && farReference && farTable && farValue !== null && farValue !== undefined && farValue !== ''
274
+ ? {
275
+ table: farTable,
276
+ column: farColumn,
277
+ key: { [farReference.column]: farValue },
278
+ label: String(rows[0][labelColumns[farColumn] ?? ''] ?? farValue),
279
+ noun: (app ? (resourceOf(farTable)?.noun?.one ?? recordNoun(undefined, farTable.name)) : farTable.name).toLocaleLowerCase(),
280
+ }
281
+ : undefined;
282
+ return (_jsx("section", { className: `${sectionClass(section)} page-card-section`, children: _jsx(CurrentCard, { table: table, caption: section.title, row: rows[0], columns: shown, show: Array.isArray(section.columns) ? section.columns : undefined, referenceLabels: labelColumns, labels: section.labels, record: record, opens: far, title: far ? cardTitle(far.label, recordName) : record && app ? cardTitle(record.label, recordName) : undefined, noun: noun,
268
283
  /* Said with the record's noun, never the title: a title is a heading, not a noun ("In the shop now" said
269
284
  "No in the shop now right now."). */
270
285
  empty: authoredEmpty ?? _jsx(Empty, { text: say('noRightNow', { thing: noun }) }) }) }));
@@ -12,6 +12,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
12
  import { useContext, useEffect, useRef } from 'react';
13
13
  import { disclosure, findTable } from '../core.js';
14
14
  import { GridSkeleton } from './Skeleton.js';
15
+ import { Icon } from './Icon.js';
15
16
  import { sectionClass } from './pageModel.js';
16
17
  import { PageRenderContext, spoken } from './pageContext.js';
17
18
  import { useMessageLanguage } from './useMessageLanguage.js';
@@ -21,6 +22,8 @@ import { say } from '../copy/record/components/PageSectionBox.js';
21
22
  /* A suggested page titles a related list by its table's name (`visit_attachment`), which an App says as words, as
22
23
  every untitled list's head already is. An authored title has words or capitals of its own and is left as written. */
23
24
  const titled = (title) => (/^[a-z][a-z0-9_.]*$/.test(title) ? spoken(title) : title);
25
+ /** A section's mark leading its heading. A note draws its own over its words, so it has none here. */
26
+ const mark = (section) => section.icon && section.kind !== 'note' ? _jsx(Icon, { name: section.icon, size: 16, className: "dash-section-icon" }) : null;
24
27
  /** A section's box: its heading, or a fold when it is a later group of fields. */
25
28
  export function SectionBox({ section, body, foldable, broken, crashed, hidden, tools, }) {
26
29
  useMessageLanguage();
@@ -49,7 +52,7 @@ export function SectionBox({ section, body, foldable, broken, crashed, hidden, t
49
52
  return (_jsxs("section", { className: `${sectionClass(section)} page-broken`, children: [_jsx("h2", { className: "page-section-head", children: heading || say('thisSection') }), crashed ?? _jsx(Problem, { text: broken ?? '' })] }));
50
53
  }
51
54
  if (foldable && heading) {
52
- return (_jsx("section", { className: sectionClass(section), children: _jsxs("details", { className: "page-fold", ref: details, open: true, children: [_jsx("summary", { className: "page-section-head page-fold-head", children: _jsx("span", { children: heading }) }), content] }) }));
55
+ return (_jsx("section", { className: sectionClass(section), children: _jsxs("details", { className: "page-fold", ref: details, open: true, children: [_jsx("summary", { className: "page-section-head page-fold-head", children: _jsxs("span", { children: [mark(section), heading] }) }), content] }) }));
53
56
  }
54
57
  /* A gallery is a picture: its title names it for assistive technology,
55
58
  and a "Photos" heading over the photos says nothing a sighted reader
@@ -57,9 +60,9 @@ export function SectionBox({ section, body, foldable, broken, crashed, hidden, t
57
60
  const gallery = section.kind === 'list' && section.presentation === 'gallery';
58
61
  /* An embedded list view's heading is the way to the whole of it: the view's own room, where the reader has it. */
59
62
  const room = section.view && !preview ? navigate?.(section.view) : undefined;
60
- const headed = heading && (_jsx("h2", { className: gallery ? 'page-section-head visually-hidden' : 'page-section-head', children: room ? (_jsx("a", { className: "page-section-link", ...room, children: heading })) : (heading) }));
63
+ const headed = heading && (_jsxs("h2", { className: gallery ? 'page-section-head visually-hidden' : 'page-section-head', children: [mark(section), room ? (_jsx("a", { className: "page-section-link", ...room, children: heading })) : (heading)] }));
61
64
  return (_jsxs("section", { className: `${sectionClass(section)}${gallery ? ' page-gallery' : ''}`, hidden: hidden || undefined, children: [tools ? (_jsxs("div", { className: "page-section-bar", children: [headed, tools] })) : (headed), content] }));
62
65
  }
63
66
  export function Loading({ section }) {
64
- return (_jsxs("section", { className: `${sectionClass(section)} loading`, children: [section.title && _jsx("h2", { className: "page-section-head", children: titled(section.title) }), section.kind === 'list' ? _jsx(GridSkeleton, { columns: 4, rows: 3 }) : _jsx("div", { className: "sk-bar" })] }));
67
+ return (_jsxs("section", { className: `${sectionClass(section)} loading`, children: [section.title && (_jsxs("h2", { className: "page-section-head", children: [mark(section), titled(section.title)] })), section.kind === 'list' ? _jsx(GridSkeleton, { columns: 4, rows: 3 }) : _jsx("div", { className: "sk-bar" })] }));
65
68
  }
@@ -273,7 +273,7 @@ export function Sections({ page, base, recordKey: key, plans, entry, onLabel, on
273
273
  an empty list is neither hidden nor collapsed, its tab shows it and the strip already folds it. */
274
274
  const tabbed = (section) => section.kind === 'list' && section.presentation !== 'gallery' && (section.width === undefined || !inAppPage());
275
275
  /* Outside a strip, such a list is left out or said in one line with its neighbours (PageEmptyRun.tsx). */
276
- const emptyable = (section) => section.kind === 'list' && Boolean(section.emptyMode) && section.presentation !== 'card';
276
+ const emptyable = (section) => section.kind === 'list' && Boolean(section.emptyMode) && (section.presentation !== 'card' || section.emptyMode === 'hide');
277
277
  /* Where a tab holds nothing but such lists, it never ends up with nothing. */
278
278
  const onlyEmptyable = items.length > 0 && items.every(({ section }) => emptyable(section));
279
279
  for (let i = 0; i < items.length; i += 1) {
@@ -6,7 +6,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
6
6
  * the same related-create plan and form a related list uses.
7
7
  */
8
8
  import { useContext, useId, useLayoutEffect, useRef, useState } from 'react';
9
- import { useQuery, useQueryClient } from '@tanstack/react-query';
9
+ import { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query';
10
10
  import { findTable, labelPath, state } from '../core.js';
11
11
  import { shell } from '../shellMode.js';
12
12
  import { resourceOf } from './appRooms.js';
@@ -67,9 +67,10 @@ const runsOn = (r, prev) => Boolean(prev && !Array.isArray(prev) && !isEvent(pre
67
67
  function Row({ r, multi, conversation, continued = false, reacted, }) {
68
68
  const words = r.text == null || r.text === '' ? ('') : (_jsx(Value, { tableId: r.table, col: r.textColumn, value: r.text, compact: true, links: true, wholeText: conversation }));
69
69
  const tone = r.tone ? { 'data-tone': r.tone } : {};
70
+ const body = _jsx("div", { className: "timeline-text prose", children: words });
70
71
  if (isEvent(r))
71
72
  return (_jsxs("li", { className: "timeline-row is-compact", "data-timeline-row": true, ...tone, children: [_jsx("span", { className: "timeline-text", children: words }), _jsx(When, { at: r.when })] }));
72
- return (_jsxs("li", { className: `timeline-row${r.tone ? ' is-tinted' : ''}${r.other ? ' is-other' : ''}${continued ? ' is-continued' : ''}`, "data-timeline-row": true, ...tone, children: [r.by && !continued ? (_jsx("span", { className: `timeline-avatar avatar avatar-c${hueOf(r.by)}`, "aria-hidden": "true", children: initialsOf(r.by) })) : (_jsx("span", { className: "timeline-avatar", "aria-hidden": "true" })), _jsxs("span", { className: "timeline-head", children: [r.by && (continued ? _jsx("span", { className: "visually-hidden", children: r.by }) : _jsx("span", { className: "timeline-by", children: r.by })), r.detail != null && (_jsx("span", { className: "timeline-kind", children: _jsx(Value, { tableId: r.table, col: r.detailColumn, value: r.detail, compact: true }) })), multi && _jsx("span", { className: "timeline-source", children: r.source }), _jsx(When, { at: r.when })] }), _jsx("div", { className: "timeline-text prose", children: words }), reacted && r.entry && _jsx(Reactions, { reactions: reacted.reactions, entry: r.entry, tally: reacted.tally })] }));
73
+ return (_jsxs("li", { className: `timeline-row${r.tone ? ' is-tinted' : ''}${r.other ? ' is-other' : ''}${continued ? ' is-continued' : ''}`, "data-timeline-row": true, ...tone, children: [r.by && !continued ? (_jsx("span", { className: `timeline-avatar avatar avatar-c${hueOf(r.by)}`, "aria-hidden": "true", children: initialsOf(r.by) })) : (_jsx("span", { className: "timeline-avatar", "aria-hidden": "true" })), !r.by && body, _jsxs("span", { className: "timeline-head", children: [r.by && (continued ? _jsx("span", { className: "visually-hidden", children: r.by }) : _jsx("span", { className: "timeline-by", children: r.by })), r.detail != null && (_jsx("span", { className: "timeline-kind", children: _jsx(Value, { tableId: r.table, col: r.detailColumn, value: r.detail, compact: true }) })), multi && _jsx("span", { className: "timeline-source", children: r.source }), _jsx(When, { at: r.when })] }), r.by && body, reacted && r.entry && _jsx(Reactions, { reactions: reacted.reactions, entry: r.entry, tally: reacted.tally })] }));
73
74
  }
74
75
  /** Two or more events in a row, said as their count and opened in place. */
75
76
  function Fold({ rows, multi, conversation }) {
@@ -101,9 +102,16 @@ export function TimelineSection({ section, plan, base, recordKey }) {
101
102
  const atFoot = useRef(true);
102
103
  /* A row's line and detail are values of their stream's table, dressed by its display rules and drawn by its
103
104
  value components as a grid cell is; `table` is whose rules they are. */
105
+ /* "Show more" asks for another `limit` rows of every stream, on demand: the first page is the rows the page's
106
+ plan already asked, so a section nobody opens further costs no more than before. */
107
+ const step = section.limit ?? 20;
108
+ const [pages, setPages] = useState(1);
104
109
  const data = useQuery({
105
- queryKey: ['page-timeline', plan.streams, section.limit, section.tone, section.compact, section.streams],
110
+ queryKey: ['page-timeline', plan.streams, section.limit, section.tone, section.compact, section.streams, pages],
111
+ /* The rows already drawn stay while the next page comes, so the list does not blank or jump. */
112
+ placeholderData: keepPreviousData,
106
113
  queryFn: async () => {
114
+ let streamMore = false;
107
115
  const answers = await Promise.all(streams.map(async (stream, s) => {
108
116
  /* The stream as authored: its own tone and compact stand over the section's rules. */
109
117
  const own = section.streams?.[s];
@@ -122,13 +130,15 @@ export function TimelineSection({ section, plan, base, recordKey }) {
122
130
  if (stream.side?.error)
123
131
  throw new Error(stream.side.error);
124
132
  const asked = timelineReads({ table: (id) => findTable(id), namePath: (target) => labelPath(target) }, stream);
125
- const view = asked.view;
133
+ const view = pages > 1 ? { ...asked.view, limit: step * pages } : asked.view;
126
134
  const named = asked.view !== stream.view ? asked.view.columns?.at(-1)?.path : undefined;
127
135
  const byPath = named ?? stream.by;
128
136
  const others = asked.side ? api('/api/view/run', { view: asked.side, offset: 0 }) : undefined;
129
137
  const [got, otherRows] = await Promise.all([api('/api/view/run', { view, offset: 0 }), others]);
130
138
  if (!('view' in got))
131
139
  throw new Error(got.errors[0]?.message ?? say('thisActivityStreamCould'));
140
+ if (got.more)
141
+ streamMore = true;
132
142
  if (otherRows && !('view' in otherRows))
133
143
  throw new Error(otherRows.errors[0]?.message ?? say('thisActivityStreamCould'));
134
144
  const keyOf = (row, names, cols) => JSON.stringify(stream.key.map((column) => row[cols[names.indexOf(column)] ?? column] ?? null));
@@ -137,19 +147,19 @@ export function TimelineSection({ section, plan, base, recordKey }) {
137
147
  const names = (view.columns ?? []).map((c) => c.path);
138
148
  const cols = got.columns ?? names;
139
149
  const atCol = cols[names.indexOf(stream.at)] ?? stream.at;
140
- const showCol = cols[names.indexOf(stream.show)] ?? stream.show;
141
- const detailCol = stream.detail ? (cols[names.indexOf(stream.detail)] ?? stream.detail) : null;
150
+ const showCol = cols[names.indexOf(stream.text)] ?? stream.text;
151
+ const detailCol = stream.badge ? (cols[names.indexOf(stream.badge)] ?? stream.badge) : null;
142
152
  const byCol = byPath ? (cols[names.indexOf(byPath)] ?? byPath) : null;
143
153
  const markCol = (name) => cols[names.indexOf(name)] ?? name;
144
154
  const entryCol = stream.reacts ? markCol(stream.reacts) : undefined;
145
- const shown = table && listColumn(table, stream.show);
146
- const detailed = table && stream.detail ? listColumn(table, stream.detail) : undefined;
155
+ const shown = table && listColumn(table, stream.text);
156
+ const detailed = table && stream.badge ? listColumn(table, stream.badge) : undefined;
147
157
  return got.rows.map((row) => ({
148
158
  when: row[atCol] == null ? '' : String(row[atCol]),
149
159
  text: row[showCol] ?? null,
150
- ...(shown ? { textColumn: { ...shown, name: stream.show } } : {}),
160
+ ...(shown ? { textColumn: { ...shown, name: stream.text } } : {}),
151
161
  detail: detailCol && row[detailCol] != null && row[detailCol] !== '' ? row[detailCol] : null,
152
- ...(detailed ? { detailColumn: { ...detailed, name: stream.detail } } : {}),
162
+ ...(detailed ? { detailColumn: { ...detailed, name: stream.badge } } : {}),
153
163
  table: table?.id ?? stream.from,
154
164
  by: byCol && row[byCol] != null ? String(row[byCol]) : null,
155
165
  source: streamSource(stream.from, table),
@@ -172,11 +182,11 @@ export function TimelineSection({ section, plan, base, recordKey }) {
172
182
  })(),
173
183
  }));
174
184
  }));
175
- return answers
185
+ const merged = answers
176
186
  .flat()
177
187
  .filter((r) => r.when)
178
- .sort((a, b) => (a.when < b.when ? 1 : a.when > b.when ? -1 : 0))
179
- .slice(0, section.limit ?? 20);
188
+ .sort((a, b) => (a.when < b.when ? 1 : a.when > b.when ? -1 : 0));
189
+ return { rows: merged.slice(0, step * pages), more: streamMore || merged.length > step * pages };
180
190
  },
181
191
  staleTime: 0,
182
192
  });
@@ -237,7 +247,7 @@ export function TimelineSection({ section, plan, base, recordKey }) {
237
247
  scroller.scrollTop = scroller.scrollHeight;
238
248
  }, [conversation, scroller, data.data]);
239
249
  /* Reactions are counted for the entries on the page, once they are known: one read for all of them. */
240
- const entries = [...new Set((data.data ?? []).flatMap((r) => (r.entry && !isEvent(r) ? [r.entry.value] : [])))];
250
+ const entries = [...new Set((data.data?.rows ?? []).flatMap((r) => (r.entry && !isEvent(r) ? [r.entry.value] : [])))];
241
251
  const { tally, waiting } = useReactionTally(section.reactions, entries);
242
252
  const reacted = section.reactions && tally ? { reactions: section.reactions, tally } : undefined;
243
253
  /* Rows with reactions wait for them too, under the same skeleton: a row of kinds arriving later pushed every message
@@ -246,7 +256,7 @@ export function TimelineSection({ section, plan, base, recordKey }) {
246
256
  return _jsx(Loading, { section: section });
247
257
  if (data.isError)
248
258
  return _jsx(SectionBox, { section: section, body: null, foldable: false, broken: data.error.message });
249
- const rows = conversation ? [...(data.data ?? [])].reverse() : (data.data ?? []);
259
+ const rows = conversation ? [...(data.data?.rows ?? [])].reverse() : (data.data?.rows ?? []);
250
260
  /* A message names its stream only where the messages come from more than one: a conversation whose second stream
251
261
  is all quiet lines (time logged) said "Activity" over every message, a word that told the reader nothing. */
252
262
  const multi = new Set(rows.filter((r) => !isEvent(r)).map((r) => r.source)).size > 1;
@@ -281,7 +291,10 @@ export function TimelineSection({ section, plan, base, recordKey }) {
281
291
  }, children: ["+ ", section.create.label] })] }));
282
292
  /* The composer sends through the App's commands (TimelineComposer.tsx), drawn through the shell's slot. */
283
293
  const { TimelineComposer } = shell().slots;
284
- return (_jsx(SectionBox, { section: section, foldable: false, body: _jsxs(_Fragment, { children: [composeButton, rows.length ? (_jsx("div", { className: conversation ? 'timeline-scroll' : undefined, ...(conversation ? { 'data-scrolls': '' } : {}), ref: setScroller, children: _jsx("ol", { className: "timeline", children: byDay(rows).map(({ day, items }, d) => (_jsxs("li", { className: "timeline-day", children: [day && (_jsx("time", { className: "timeline-day-label", dateTime: day, children: formatDayHeading(day) })), _jsx("ol", { className: "timeline-rows", children: items.map((item, i) => Array.isArray(item) ? (_jsx(Fold, { rows: item, multi: multi, conversation: conversation }, `${item[0].when} ${item[0].table}`)) : (_jsx(Row, { r: item, multi: multi, conversation: conversation, continued: sided && runsOn(item, items[i - 1]), reacted: reacted }, `${item.when} ${item.table}`))) })] }, day || d))) }) })) : (_jsx(Empty, { text: say('nothingDatedYetForThisRecord') })), section.composer && !preview && shell().inApp() && TimelineComposer && (_jsx(TimelineComposer, { composer: section.composer, recordKey: recordKey, table: base?.id, onSent: () => void queries.invalidateQueries({
294
+ /* Older rows come in place: above a conversation (its oldest is at the top), below a feed. The button holds its row
295
+ whether or not it is working, so nothing moves under the pointer. */
296
+ const showMore = data.data?.more && (_jsx("div", { className: "timeline-more", children: _jsx("button", { type: "button", className: "ghost", disabled: data.isPlaceholderData, onClick: () => setPages(pages + 1), children: say('showMore') }) }));
297
+ return (_jsx(SectionBox, { section: section, foldable: false, body: _jsxs(_Fragment, { children: [composeButton, conversation && showMore, rows.length ? (_jsx("div", { className: conversation ? 'timeline-scroll' : undefined, ...(conversation ? { 'data-scrolls': '' } : {}), ref: setScroller, children: _jsx("ol", { className: "timeline", children: byDay(rows).map(({ day, items }, d) => (_jsxs("li", { className: "timeline-day", children: [day && (_jsx("time", { className: "timeline-day-label", dateTime: day, children: formatDayHeading(day) })), _jsx("ol", { className: "timeline-rows", children: items.map((item, i) => Array.isArray(item) ? (_jsx(Fold, { rows: item, multi: multi, conversation: conversation }, `${item[0].when} ${item[0].table}`)) : (_jsx(Row, { r: item, multi: multi, conversation: conversation, continued: sided && runsOn(item, items[i - 1]), reacted: reacted }, `${item.when} ${item.table}`))) })] }, day || d))) }) })) : (_jsx(Empty, { text: say('nothingDatedYetForThisRecord') })), !conversation && showMore, section.composer && !preview && shell().inApp() && TimelineComposer && (_jsx(TimelineComposer, { composer: section.composer, recordKey: recordKey, table: base?.id, onSent: () => void queries.invalidateQueries({
285
298
  predicate: (query) => ['page-list', 'page-timeline', 'page-metric', 'page-breakdown'].includes(String(query.queryKey[0])),
286
299
  }) }))] }) }));
287
300
  }
@@ -17,6 +17,8 @@ interface ValueProps {
17
17
  wholeText?: boolean;
18
18
  /** The record the value is of, where a money rule reads its currency from another of its columns (money.ts). */
19
19
  row?: Readonly<Record<string, unknown>>;
20
+ /** Draw the rule's `subtitle` (a column of the same record) as a second line under the value, as a list's cell does. */
21
+ subtitled?: boolean;
20
22
  }
21
23
  /** A value as the record and the page show it: dressed when the app says, plain otherwise. */
22
24
  export declare function Value(props: ValueProps): import("react").JSX.Element;
@@ -11,11 +11,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  import { Fragment } from 'react';
12
12
  import { api, columnDisplay, columnLabel, emptyWord, findTable, humanName, openRecord, refsFrom, state, toast } from '../core.js';
13
13
  import { opensRecord } from '../recordIntent.js';
14
- import { dressFor, linkFor, maskedText, ruleSays } from './valueModel.js';
14
+ import { dressFor, linkFor, maskedText, ruleSays, subtitlePath, wordFor } from './valueModel.js';
15
15
  import { rowCurrency } from '@mistriwork/engine/shared/money.js';
16
16
  import { dueOpen } from './dueOpen.js';
17
17
  import { JsonValue } from './JsonValue.js';
18
- import { jsonValueOf, previewOf } from './jsonModel.js';
18
+ import { itemsText, jsonValueOf, previewOf } from './jsonModel.js';
19
19
  import { TAGS_TYPE, tagChips } from '@mistriwork/engine/shared/tagLists.js';
20
20
  import { AvatarText, Dressed, Said } from './Dressed.js';
21
21
  import { ValueSlot } from './valueRenderers.js';
@@ -46,6 +46,16 @@ function breakable(text) {
46
46
  }
47
47
  /** A value as the record and the page show it: dressed when the app says, plain otherwise. */
48
48
  export function Value(props) {
49
+ const { subtitled, row, col } = props;
50
+ const body = _jsx(BareValue, { ...props });
51
+ const rule = subtitled && props.tableId !== undefined ? columnDisplay(props.tableId, col?.name ?? '') : null;
52
+ const path = subtitlePath(rule, col?.name ?? '');
53
+ const second = path !== undefined && row && Object.hasOwn(row, path) ? row[path] : undefined;
54
+ if (second === null || second === undefined || second === '')
55
+ return body;
56
+ return (_jsxs("span", { className: "value-subtitled", children: [body, _jsx("span", { className: "value-sub", children: String(second) })] }));
57
+ }
58
+ function BareValue(props) {
49
59
  const { col, value, tableId, compact = false, links = !compact } = props;
50
60
  const rule = tableId === undefined ? null : columnDisplay(tableId, col?.name ?? '');
51
61
  const drawn = _jsx(DrawnValue, { ...props, rule: rule });
@@ -102,10 +112,29 @@ function PlatformValue({ col, value, tableId, compact = false, links = !compact,
102
112
  return (_jsx("span", { className: "null", title: "null", children: emptyWord() }));
103
113
  return (_jsx("span", { className: "value-tags", children: chips.map((chip) => (_jsx("span", { className: `record-tag tone tone-${chip.tone ?? 'neutral'}`, children: chip.label }, chip.label))) }));
104
114
  }
105
- const json = jsonValueOf(col, value);
106
- if (json)
107
- return compact ? _jsx("span", { className: "json-preview-text", children: previewOf(json.value) }) : _jsx(JsonValue, { value: json.value });
108
115
  const declared = tableId === undefined ? null : columnDisplay(tableId, col?.name ?? '');
116
+ const json = jsonValueOf(col, value);
117
+ if (json) {
118
+ /* A list of plain values (roles, tags, sizes) is its values, each said in the rule's words as a single value is
119
+ (`values`, `humanize`), plainly: Raw and Copy belong to a document whose braces a reader may want, and are
120
+ not drawn over a row of chips. */
121
+ const items = Array.isArray(json.value) && json.value.length && json.value.every((item) => item === null || typeof item !== 'object');
122
+ const shown = items
123
+ ? json.value.map((item) => (typeof item === 'string' ? (wordFor(declared, item) ?? item) : item))
124
+ : json.value;
125
+ /* Where there is one line (a cell, a header's fact, a figure) a list of plain values is its words, comma between,
126
+ with no brackets: "Ram, Truck". Chips are for a field block, where there is room for them; `format: 'items'`
127
+ asks for one item per line there instead, as a text of lines is said. */
128
+ if (items && compact) {
129
+ const text = itemsText(shown);
130
+ return (_jsx("span", { className: "json-preview-text", title: text, children: text }));
131
+ }
132
+ if (items && declared?.format === 'items')
133
+ return (_jsx("ul", { className: "value-items", children: shown.map((item, index) => (_jsx("li", { children: String(item) }, index))) }));
134
+ if (compact)
135
+ return _jsx("span", { className: "json-preview-text", children: previewOf(shown) });
136
+ return _jsx(JsonValue, { value: shown, bar: !items });
137
+ }
109
138
  /* A money column whose currency is the record's own: the code its row holds. */
110
139
  const owned = declared?.currencyColumn && row
111
140
  ? { ...declared, currency: rowCurrency(declared, row, declared.currency ?? '') || undefined }
@@ -83,8 +83,8 @@ export interface Section {
83
83
  label: string;
84
84
  view: string;
85
85
  };
86
- /** note: the dashboard's banner, its tag and its picture. */
87
- variant?: 'banner';
86
+ /** note: quiet or callout, or the banner a `banner()` is served as, with its tag and its picture. */
87
+ variant?: 'quiet' | 'callout' | 'banner';
88
88
  eyebrow?: string;
89
89
  image?: import('@mistriwork/engine/shared/servedApp.js').LandingImage;
90
90
  error?: string;
@@ -68,6 +68,9 @@ export declare function countLabel(value: object, locale?: string): string;
68
68
  * the document is and a value out of context says nothing.
69
69
  */
70
70
  export declare function previewOf(value: object): string;
71
+ /** A list of plain values said as words, comma between: where one line is all there is room for (a cell, a header's
72
+ fact, a figure). A null among them is a gap nobody reads. */
73
+ export declare function itemsText(items: readonly unknown[]): string;
71
74
  /** What a scalar is best shown as. */
72
75
  export type Scalar = {
73
76
  kind: 'null';
@@ -189,6 +189,14 @@ export function previewOf(value) {
189
189
  const more = keys.length - shown.length;
190
190
  return `{ ${shown.join(', ')}${more ? `, +${more}` : ''} }`;
191
191
  }
192
+ /** A list of plain values said as words, comma between: where one line is all there is room for (a cell, a header's
193
+ fact, a figure). A null among them is a gap nobody reads. */
194
+ export function itemsText(items) {
195
+ return items
196
+ .filter((item) => item !== null && item !== undefined)
197
+ .map((item) => String(item))
198
+ .join(', ');
199
+ }
192
200
  export function scalarOf(value, locale) {
193
201
  if (value === null || value === undefined)
194
202
  return { kind: 'null' };
@@ -9,7 +9,7 @@
9
9
  */
10
10
  import { createContext, useContext } from 'react';
11
11
  import { ownedBy } from '../requestIdentity.js';
12
- import { api as request, findTable, labelPath, recordLabel, state } from '../core.js';
12
+ import { api as request, columnDisplay, findTable, labelPath, recordLabel, state } from '../core.js';
13
13
  import { humanName } from '@mistriwork/engine/shared/model.js';
14
14
  import { shell } from '../shellMode.js';
15
15
  import { resourceOf } from './appRooms.js';
@@ -43,5 +43,6 @@ export function recordReadNames() {
43
43
  namePath: (table) => labelPath(table),
44
44
  table: (id) => findTable(id),
45
45
  defined: (id) => resourceOf(shell().app(), id)?.defined,
46
+ display: (id, column) => columnDisplay(id, column),
46
47
  };
47
48
  }
@@ -12,6 +12,9 @@ export interface PageSection {
12
12
  sort?: string;
13
13
  height?: number;
14
14
  target?: number;
15
+ /** A line chart's curve and a donut's middle words, as a dashboard chart's. */
16
+ curve?: 'smooth' | 'straight';
17
+ total?: string;
15
18
  /** A note's words, mark and one way on. */
16
19
  text?: string;
17
20
  icon?: import('@mistriwork/engine/shared/appIcons.js').AppIconName;
@@ -42,8 +45,8 @@ export interface PageSection {
42
45
  from: string;
43
46
  path: string;
44
47
  at: string;
45
- show: string;
46
- detail?: string;
48
+ text: string;
49
+ badge?: string;
47
50
  by?: string;
48
51
  filter?: string;
49
52
  side?: string;
@@ -84,15 +87,17 @@ export interface PageSection {
84
87
  headerActions?: string[];
85
88
  /** A headline's second figure, its figure's earlier value, and small print. */
86
89
  subfigure?: string;
90
+ subtitle?: string;
87
91
  was?: string;
88
92
  note?: string;
89
93
  /** A similar list: rows of the page's own table sharing the record's `same` values, `near` its numbers. */
90
94
  similar?: import('@mistriwork/engine/shared/pageModel.js').PageSimilar;
95
+ opens?: string;
91
96
  workflow?: ResolvedWorkflowStatus;
92
97
  create?: RelatedCreate<string>;
93
98
  empty?: import('@mistriwork/engine/shared/listPresentations.js').AppListEmpty;
94
99
  /** Authored `empty: 'hide' | 'collapse'`: the list is left out, or said in one line, while it has no rows. */
95
- emptyMode?: 'hide' | 'collapse';
100
+ emptyMode?: 'hide' | 'collapse' | 'show';
96
101
  /** The rows under a header for each record they share (shared/pageModel.ts, PageGroup); `limit` is then the rows to a group. */
97
102
  group?: import('@mistriwork/engine/shared/pageModel.js').PageGroup;
98
103
  /** Columns summed in the list's footer, over every row it matches. */
@@ -142,8 +147,8 @@ export interface SectionPlan {
142
147
  view?: ViewDef;
143
148
  from: string;
144
149
  at: string;
145
- show: string;
146
- detail?: string;
150
+ text: string;
151
+ badge?: string;
147
152
  by?: string;
148
153
  /** A timeline's `side`: the stream's key columns, and its read narrowed to the other party's rows. */
149
154
  key?: string[];
@@ -2,6 +2,7 @@ export declare const say: import("../../../messages.js").RoomMessage<{
2
2
  readonly thisActivityStreamHasNoView: "This activity stream has no view definition.";
3
3
  readonly thisActivityStreamCould: "This activity stream could not be read.";
4
4
  readonly nothingDatedYetForThisRecord: "Nothing dated yet for this record.";
5
+ readonly showMore: "Show more";
5
6
  readonly updates: {
6
7
  readonly one: "{count} update";
7
8
  readonly other: "{count} updates";
@@ -4,5 +4,6 @@ export const say = defineMessages({
4
4
  thisActivityStreamHasNoView: 'This activity stream has no view definition.',
5
5
  thisActivityStreamCould: 'This activity stream could not be read.',
6
6
  nothingDatedYetForThisRecord: 'Nothing dated yet for this record.',
7
+ showMore: 'Show more',
7
8
  updates: { one: '{count} update', other: '{count} updates' },
8
9
  });
@@ -1000,6 +1000,8 @@ button.ghost.dash-open:hover { color: var(--ink); background: none; }
1000
1000
  /* The main line is cut as the second is, with an ellipsis: a link clipped mid-letter read as a typo. */
1001
1001
  .cell-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1002
1002
  .cell-sub { font: 400 var(--text-sm)/1.35 var(--sans); color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1003
+ .value-subtitled { display: inline-flex; flex-direction: column; min-width: 0; max-width: 100%; }
1004
+ .value-sub { font: 400 var(--text-sm)/1.35 var(--sans); color: var(--ink-muted); overflow-wrap: anywhere; }
1003
1005
  td.dressed { white-space: nowrap; }
1004
1006
  /* The columns an App's list could not hold, folded under the row's name (Grid.tsx `foldedOf`): each head and its value
1005
1007
  kept together, the line wrapping between them rather than the table scrolling sideways. Said a size down, the
@@ -813,6 +813,24 @@
813
813
  .page-head-facts > .page-fact::before {
814
814
  content: none;
815
815
  }
816
+ /* Facts past the line wait in a disclosure of the head's own, under the line and in its column. Closed, it is one
817
+ row of the same height whoever opens it, and its summary is the quiet caption a fact's is; opened, the rest
818
+ wrap as the line does, never sideways. */
819
+ .page-head.has-record > .page-head-more {
820
+ grid-column: 1;
821
+ min-width: 0;
822
+ margin-top: var(--space-2);
823
+ font-size: var(--text-md);
824
+ }
825
+ .page-head-more > summary {
826
+ display: inline-block;
827
+ cursor: pointer;
828
+ font: 500 var(--text-sm)/1.4 var(--sans);
829
+ color: var(--ink-muted);
830
+ }
831
+ .page-head-more > .page-head-facts {
832
+ margin-top: var(--space-3);
833
+ }
816
834
  .page-head-facts > .page-fact:has(> .page-fact-caption) {
817
835
  flex-direction: column;
818
836
  align-items: flex-start;
@@ -841,7 +859,7 @@
841
859
  flex-basis: 100%;
842
860
  margin-inline-start: 0;
843
861
  }
844
- .page-head.has-record > .page-head-facts {
862
+ .page-head.has-record > :is(.page-head-facts, .page-head-more) {
845
863
  grid-column: 1 / -1;
846
864
  order: -1;
847
865
  }
@@ -873,7 +891,7 @@
873
891
  flex-basis: 100%;
874
892
  margin-inline-start: 0;
875
893
  }
876
- .page-head.has-record > .page-head-facts {
894
+ .page-head.has-record > :is(.page-head-facts, .page-head-more) {
877
895
  grid-column: 1 / -1;
878
896
  order: -1;
879
897
  }
@@ -1915,6 +1933,10 @@
1915
1933
  .timeline-fold-toggle[aria-expanded='true'] svg {
1916
1934
  transform: rotate(90deg);
1917
1935
  }
1936
+ .timeline-more {
1937
+ padding-block: var(--space-2) 0;
1938
+ min-height: 32px;
1939
+ }
1918
1940
  .page-related-create.timeline-compose {
1919
1941
  padding-block: 0 var(--space-2h);
1920
1942
  }
@@ -3321,6 +3343,12 @@
3321
3343
  font: 500 calc(15px * var(--type-k)) var(--sans);
3322
3344
  font-variant-numeric: tabular-nums;
3323
3345
  }
3346
+ .page-headline-subtitle {
3347
+ display: block;
3348
+ margin-top: var(--space-1);
3349
+ color: var(--ink-muted);
3350
+ font: 500 var(--text-md)/1.4 var(--sans);
3351
+ }
3324
3352
  .page-headline-sub .num-value {
3325
3353
  font: inherit;
3326
3354
  color: var(--ink);
@@ -1291,6 +1291,13 @@
1291
1291
  .page-section-bar > .page-section-head {
1292
1292
  flex: 1 1 auto;
1293
1293
  }
1294
+ /* A section's mark leads its heading, in the heading's quieter ink (a dashboard section's is the same, Chart.css). */
1295
+ .page-section-head .dash-section-icon {
1296
+ flex: none;
1297
+ margin-right: var(--space-3);
1298
+ vertical-align: -2px;
1299
+ color: var(--ink-muted);
1300
+ }
1294
1301
  .page-section-bar > .page-related-create {
1295
1302
  flex-wrap: wrap;
1296
1303
  justify-content: flex-start;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistriwork/kit",
3
- "version": "1.0.0-rc.15",
3
+ "version": "1.0.0-rc.16",
4
4
  "description": "The shared React client both shells are drawn with: the walk and the address, Grid, Value, the record page, lists, filters and charts.",
5
5
  "homepage": "https://mistriwork.dev",
6
6
  "bugs": {
@@ -82,8 +82,8 @@
82
82
  "./package.json": "./package.json"
83
83
  },
84
84
  "dependencies": {
85
- "@mistriwork/engine": "1.0.0-rc.15",
86
- "@mistriwork/ui": "1.0.0-rc.15",
85
+ "@mistriwork/engine": "1.0.0-rc.16",
86
+ "@mistriwork/ui": "1.0.0-rc.16",
87
87
  "intl-messageformat": "12.1.2",
88
88
  "qrcode-generator": "^2.0.4"
89
89
  },
@@ -172,6 +172,6 @@
172
172
  }
173
173
  },
174
174
  "engines": {
175
- "node": ">=24.22.1"
175
+ "node": ">=24"
176
176
  }
177
177
  }