@mistriwork/kit 1.0.0-rc.15 → 1.0.0-rc.17
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/dist/client/components/CardsList.js +7 -1
- package/dist/client/components/ChartFigure.d.ts +3 -2
- package/dist/client/components/ChartFigure.js +7 -5
- package/dist/client/components/Export.js +8 -4
- package/dist/client/components/Grid.js +21 -2
- package/dist/client/components/JsonView.d.ts +2 -1
- package/dist/client/components/JsonView.js +2 -2
- package/dist/client/components/PageCurrent.d.ts +10 -1
- package/dist/client/components/PageCurrent.js +10 -6
- package/dist/client/components/PageFields.js +15 -4
- package/dist/client/components/PageHead.js +11 -9
- package/dist/client/components/PageHeadline.d.ts +3 -1
- package/dist/client/components/PageHeadline.js +3 -2
- package/dist/client/components/PageMetrics.js +13 -4
- package/dist/client/components/PageRelated.js +17 -2
- package/dist/client/components/PageSectionBox.js +6 -3
- package/dist/client/components/PageSections.js +1 -1
- package/dist/client/components/PageTimeline.js +29 -16
- package/dist/client/components/SecondLine.d.ts +15 -0
- package/dist/client/components/SecondLine.js +18 -0
- package/dist/client/components/Value.d.ts +3 -0
- package/dist/client/components/Value.js +32 -5
- package/dist/client/components/dashboardModel.d.ts +2 -2
- package/dist/client/components/jsonModel.d.ts +3 -0
- package/dist/client/components/jsonModel.js +8 -0
- package/dist/client/components/pageContext.js +2 -1
- package/dist/client/components/pageModel.d.ts +10 -5
- package/dist/client/components/textMeasure.d.ts +2 -0
- package/dist/client/components/textMeasure.js +16 -2
- package/dist/client/copy/record/components/PageTimeline.d.ts +1 -0
- package/dist/client/copy/record/components/PageTimeline.js +1 -0
- package/dist/client/copy/workbench/components/Export.d.ts +3 -2
- package/dist/client/copy/workbench/components/Export.js +3 -2
- package/dist/client/export.d.ts +5 -4
- package/dist/client/export.js +40 -19
- package/dist/client/features.css +2 -0
- package/dist/client/page.css +37 -2
- package/dist/client/shellMode.d.ts +6 -0
- package/dist/client/structure.css +7 -0
- package/package.json +4 -4
|
@@ -24,6 +24,7 @@ import { primaryKey } from '@mistriwork/engine/shared/schema.js';
|
|
|
24
24
|
import { humanName } from '@mistriwork/engine/shared/model.js';
|
|
25
25
|
import { cardsImageSort, factWord } from '@mistriwork/engine/shared/appCards.js';
|
|
26
26
|
import { Value } from './Value.js';
|
|
27
|
+
import { Subtitled, secondLine } from './SecondLine.js';
|
|
27
28
|
import { dressFor, hueOf, initialsOf, maskedText } from './valueModel.js';
|
|
28
29
|
import { Icon } from './Icon.js';
|
|
29
30
|
import { useListOrder } from './useListOrder.js';
|
|
@@ -136,6 +137,10 @@ export function CardsList({ table, rows, spec, interactive = true, recordNavigat
|
|
|
136
137
|
const { column, value } = namedCell(table, name, row, referenceLabels);
|
|
137
138
|
return _jsx(Value, { col: column, value: value, tableId: table.id, compact: true });
|
|
138
139
|
};
|
|
140
|
+
/* The figure and a captioned line have room for their column's second line (`subtitle`), quiet under the value; a
|
|
141
|
+
summary, a foot and a badge are one line each (appListColumns.ts listSecondLineColumns). A label path's rule is
|
|
142
|
+
its own table's, so only the row's own columns are asked. */
|
|
143
|
+
const saidWithSecond = (row, name) => (_jsx(Subtitled, { tableId: table.id, column: name.includes('.') ? undefined : name, row: row, children: said(row, name) }));
|
|
139
144
|
// A line or a fact may be a label path ("dealer_id.name"): its caption is the App's, else its last step's.
|
|
140
145
|
const caption = (name) => columnLabel(table.id, name) ?? humanName(name.split('.').pop() ?? name);
|
|
141
146
|
const present = (row, name) => row[name] !== null && row[name] !== undefined && row[name] !== '';
|
|
@@ -161,6 +166,7 @@ export function CardsList({ table, rows, spec, interactive = true, recordNavigat
|
|
|
161
166
|
const key = keyOf(table, row);
|
|
162
167
|
const id = ordering.id(row);
|
|
163
168
|
const title = titleOf(row);
|
|
169
|
+
const titleSecond = spec.primary.includes('.') ? undefined : secondLine(table.id, spec.primary, row);
|
|
164
170
|
const src = typeof image === 'string' ? cardImageAddress(row[image]) : leadOf(row);
|
|
165
171
|
const avatar = spec.media === 'avatar';
|
|
166
172
|
/* An icon tile leads the card in a picture's place: it is no picture, so the card keeps its text layout. */
|
|
@@ -177,7 +183,7 @@ export function CardsList({ table, rows, spec, interactive = true, recordNavigat
|
|
|
177
183
|
? { name: dressed.icon, label: dressed.label, tone: dressed.kind === 'tone' ? dressed.tone : undefined }
|
|
178
184
|
: null;
|
|
179
185
|
const badge = spec.badge && row[spec.badge] != null && row[spec.badge] !== '' ? (_jsx("span", { className: "cards-badge", children: said(row, spec.badge) })) : null;
|
|
180
|
-
return (_jsx("li", { className: "cards-item", ...(win.windowed ? { 'data-index': win.lineOf(index), ref: win.measure } : {}), ...(id ? ordering.item(id) : {}), onKeyDown: id ? (event) => ordering.keyDown(event, id) : undefined, children: _jsxs("article", { className: `cards-card${hasMedia ? ' has-media' : ''}${avatar ? ' cards-profile' : ''}${changedRows.has(row) ? ` row-changed-${changedRows.get(row)}` : ''}`, children: [hasMedia && _jsx(CardPicture, { src: src, avatar: avatar, title: title, first: index < FIRST_ROW }), id && ordering.menu(id), _jsxs("div", { className: "cards-body", children: [tile && (_jsx("span", { className: `cards-tile${mark?.tone ? ` tone-${mark.tone}` : ''}`, children: mark && _jsx(Icon, { name: mark.name, label: mark.label, size: 22 }) })), _jsxs("h3", { className: "cards-title", children: [mark && !tile && _jsx(Icon, { name: mark.name, label: mark.label, className: "cards-icon" }), canOpen && key ? (_jsx("button", { type: "button", className: "cards-open", "data-order-focus": "", "aria-keyshortcuts": ordering.shortcuts, "data-opens": opensRecord(table.id, key), onClick: () => void openRecord(table.id, key, title, 'push', { records, list }), children: title })) : (_jsx("span", { children: title }))] }), description !== undefined && (_jsx("p", { className: "cards-description", title: description, children: description })), (!hasMedia || avatar) && badge, spec.value && row[spec.value] != null && _jsx("p", { className: "cards-value", children:
|
|
186
|
+
return (_jsx("li", { className: "cards-item", ...(win.windowed ? { 'data-index': win.lineOf(index), ref: win.measure } : {}), ...(id ? ordering.item(id) : {}), onKeyDown: id ? (event) => ordering.keyDown(event, id) : undefined, children: _jsxs("article", { className: `cards-card${hasMedia ? ' has-media' : ''}${avatar ? ' cards-profile' : ''}${changedRows.has(row) ? ` row-changed-${changedRows.get(row)}` : ''}`, children: [hasMedia && _jsx(CardPicture, { src: src, avatar: avatar, title: title, first: index < FIRST_ROW }), id && ordering.menu(id), _jsxs("div", { className: "cards-body", children: [tile && (_jsx("span", { className: `cards-tile${mark?.tone ? ` tone-${mark.tone}` : ''}`, children: mark && _jsx(Icon, { name: mark.name, label: mark.label, size: 22 }) })), _jsxs("h3", { className: "cards-title", children: [mark && !tile && _jsx(Icon, { name: mark.name, label: mark.label, className: "cards-icon" }), canOpen && key ? (_jsx("button", { type: "button", className: "cards-open", "data-order-focus": "", "aria-keyshortcuts": ordering.shortcuts, "data-opens": opensRecord(table.id, key), onClick: () => void openRecord(table.id, key, title, 'push', { records, list }), children: title })) : (_jsx("span", { children: title }))] }), titleSecond !== undefined && _jsx("p", { className: "cards-subtitle", children: titleSecond }), description !== undefined && (_jsx("p", { className: "cards-description", title: description, children: description })), (!hasMedia || avatar) && badge, spec.value && row[spec.value] != null && _jsx("p", { className: "cards-value", children: saidWithSecond(row, spec.value) }), spec.facts?.some((name) => present(row, name)) ? (_jsx("p", { className: "cards-summary", children: spec.facts.filter((name) => present(row, name)).map((name) => fact(row, name, 'cards-summary-item')) })) : null, spec.lines?.length ? (_jsx("dl", { className: "cards-facts", children: spec.lines.map((name) => (_jsxs("div", { className: "cards-fact", children: [_jsx("dt", { children: caption(name) }), _jsx("dd", { children: saidWithSecond(row, name) })] }, name))) })) : null] }), spec.footer?.length ? (_jsx("p", { className: "cards-foot", children: spec.footer.some((name) => present(row, name))
|
|
181
187
|
? spec.footer.filter((name) => present(row, name)).map((name) => fact(row, name, 'cards-foot-item'))
|
|
182
188
|
: '\u00a0' })) : null, hasMedia && !avatar && badge] }) }, key ? JSON.stringify(key) : index));
|
|
183
189
|
}), win.after > 0 && _jsx("li", { className: "cards-spacer", "aria-hidden": "true", style: { height: `${win.after}px` } })] }), ordering.live] }));
|
|
@@ -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: '
|
|
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 === '
|
|
33
|
-
? orderDeclared(answer?.rows ?? [], columns[0], columns[1]).slice(0, limit)
|
|
34
|
-
:
|
|
35
|
-
? orderDeclared(answer?.rows ?? [], columns[0], columns[1]
|
|
36
|
-
: (
|
|
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) => ({
|
|
@@ -82,13 +82,17 @@ export function ExportControl({ entry, data }) {
|
|
|
82
82
|
setOpen(false);
|
|
83
83
|
// `selected` rather than what came back, so the file follows the declared order.
|
|
84
84
|
saveExport(kind, data.table, selected, kind === 'csv' ? sheetAmounts(data.table, selected, rows) : rows);
|
|
85
|
+
/* Not streamed (a support visit): the one bounded read held whole, and the file says where it stopped. */
|
|
86
|
+
if (all && total > EXPORT_MAX_ROWS)
|
|
87
|
+
toast(say('stoppedAtTheCap', { max: formatNumber(EXPORT_MAX_ROWS) }));
|
|
85
88
|
};
|
|
86
89
|
/* JSON and the agent hand-off are Workbench tools; an App's list offers the columns and the CSV. */
|
|
87
90
|
const workbench = !shell().inApp();
|
|
88
91
|
const kinds = workbench ? ['csv', 'json'] : ['csv'];
|
|
89
92
|
const pageLabel = say('thisPageRows', { count: pageRows.length });
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
/* Every row: the server streams the file with no ceiling (exportRoute.ts); only its fallback stops at the cap. */
|
|
94
|
+
const allLabel = say('allMatchingRows', { count: formatNumber(total) });
|
|
95
|
+
return (_jsxs(_Fragment, { children: [_jsxs(DropMenu, { className: "export", triggerClassName: "export-summary", triggerTitle: say('downloadThisResult'), label: _jsxs(_Fragment, { children: [_jsx("span", { className: "export-word", children: say('export') }), _jsx("span", { className: "export-more", "aria-hidden": "true", children: "\u22EF" })] }), popupClassName: "export-menu", open: open, onOpenChange: setOpen, children: [_jsx("div", { className: "export-group", children: _jsxs(DropItem, { className: "export-item export-columns-item", onClick: () => setChoosing(true), children: [_jsx("span", { children: say('chooseColumns') }), _jsx("span", { className: "export-count", children: declared.length ? say('selectedOfDeclared', { selected: selected.length, declared: declared.length }) : `${selected.length}` })] }) }), kinds.map((kind) => (_jsxs("div", { className: "export-group", children: [_jsx("span", { className: "export-kind", children: kind.toUpperCase() }), _jsx(DropItem, { className: "export-item", disabled: busy === `${kind}:false`, closeOnClick: false, onClick: () => void deliver(kind, false), children: busy === `${kind}:false` ? say('fetching') : pageLabel }), total > pageRows.length && (_jsx(DropItem, { className: "export-item", disabled: busy === `${kind}:true`, closeOnClick: false, onClick: () => void deliver(kind, true), children: busy === `${kind}:true` ? say('fetching') : allLabel }))] }, kind))), workbench && (_jsxs("div", { className: "export-group", children: [_jsx("span", { className: "export-kind", children: say('agent') }), _jsx(DropItem, { className: "export-item", title: say('theQueryTheShape'), onClick: () => void copyPosition(positionOf(state, entry, { columns: displayed, shown: pageRows.length, total }), toast), children: say('copyThisPosition') })] })), total > EXPORT_MAX_ROWS && _jsx("p", { className: "export-note", children: say('streamedPastTheCap') })] }), choosing && (_jsx(ColumnChooser, { tableId: data.table, displayed: displayed, declared: declared, selected: selected, onClose: () => setChoosing(false), onDone: (picked) => {
|
|
92
96
|
rememberColumns(data.table, picked);
|
|
93
97
|
tick((n) => n + 1);
|
|
94
98
|
} }))] }));
|
|
@@ -130,8 +134,8 @@ function ColumnChooser({ tableId, displayed, declared, selected, onClose, onDone
|
|
|
130
134
|
}
|
|
131
135
|
/**
|
|
132
136
|
* A CSV says money as the figure a sheet reads, as the server's streamed file
|
|
133
|
-
* does (
|
|
134
|
-
*
|
|
137
|
+
* does (appExport.ts csvAmounts), and here where it does not stream — a
|
|
138
|
+
* support visit, this page: a column kept in minor units, 1999, is
|
|
135
139
|
* written 19.99 in its row's own currency.
|
|
136
140
|
*/
|
|
137
141
|
function sheetAmounts(tableId, columns, rows) {
|
|
@@ -50,7 +50,7 @@ import { Icon } from './Icon.js';
|
|
|
50
50
|
import { createRowHosts, RowDecoration, RowHostScope, RowTrailScope, rowKeyString, useRowHostScope, useRowTrailScope, } from './RowHost.js';
|
|
51
51
|
import { useGridKeyboard } from './useGridKeyboard.js';
|
|
52
52
|
import { useChangedRows } from '../liveState.js';
|
|
53
|
-
import { textMeasure } from './textMeasure.js';
|
|
53
|
+
import { fontLoaded, textMeasure } from './textMeasure.js';
|
|
54
54
|
import { presentationColumns } from './columnPresentation.js';
|
|
55
55
|
import { usePins } from './usePins.js';
|
|
56
56
|
import { useStickyHead } from './useStickyHead.js';
|
|
@@ -484,13 +484,18 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
484
484
|
status as a pill spends 41px there, one that says it as a dot and a word 12, and sizing every column for the
|
|
485
485
|
wider kept 30px of every table's room in a status that never used it. -1: the cell holds no chip. */
|
|
486
486
|
const [cellChips, setCellChips] = useState([]);
|
|
487
|
+
/* Counts the times a face arrived after the columns were sized in its fallback: the sizes are read again, once for
|
|
488
|
+
each, so a table's columns never stay as the fallback face set them (textMeasure.ts). */
|
|
489
|
+
const [faceEpoch, setFaceEpoch] = useState(0);
|
|
487
490
|
useLayoutEffect(() => {
|
|
488
491
|
if (sizing !== 'fit' || !wrap.current)
|
|
489
492
|
return;
|
|
490
493
|
const element = wrap.current;
|
|
491
494
|
/* The look says how wide its heads' characters set (gridSizing.ts); read
|
|
492
495
|
again when the reader picks another look, which moves no width. */
|
|
496
|
+
let sizedInFallback = false;
|
|
493
497
|
const measure = (contentWidth) => {
|
|
498
|
+
sizedInFallback = false;
|
|
494
499
|
const style = getComputedStyle(element);
|
|
495
500
|
/* clientWidth rounds up fractional layout widths. At density zoom that
|
|
496
501
|
can create a one-screen-pixel scroll range even when scrollWidth and
|
|
@@ -509,6 +514,7 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
509
514
|
upper: face.textTransform === 'uppercase',
|
|
510
515
|
tracking: parseFloat(face.letterSpacing) || 0,
|
|
511
516
|
};
|
|
517
|
+
sizedInFallback = sizedInFallback || !fontLoaded(next.font);
|
|
512
518
|
setHeadFace((was) => (was && was.font === next.font && was.upper === next.upper && was.tracking === next.tracking ? was : next));
|
|
513
519
|
}
|
|
514
520
|
/* A group's head is not a row of values: the first row that is one is sampled. */
|
|
@@ -519,6 +525,7 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
519
525
|
const font = getComputedStyle(cell);
|
|
520
526
|
return `${font.fontStyle} ${font.fontWeight} ${font.fontSize} ${font.fontFamily}`;
|
|
521
527
|
});
|
|
528
|
+
sizedInFallback = sizedInFallback || !fonts.every(fontLoaded);
|
|
522
529
|
setCellFonts((was) => (was.join('|') === fonts.join('|') ? was : fonts));
|
|
523
530
|
/* The widest chip of the sampled rows, not the first row's: a look may draw a neutral state as a bare word
|
|
524
531
|
and the rest as pills, and sized by a first-row "Ready" Sage cut every "In review" pill to "In rev…". */
|
|
@@ -547,7 +554,18 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
547
554
|
observer.observe(element);
|
|
548
555
|
const themeChanged = () => measure();
|
|
549
556
|
addHostListener(window, VISUAL_THEME_EVENT, themeChanged);
|
|
557
|
+
/* A face that arrives after the first measure: sized again with it, once, and only if the last measure was made
|
|
558
|
+
without it (a face already here moves nothing). */
|
|
559
|
+
const faces = globalThis.document?.fonts;
|
|
560
|
+
const arrived = () => {
|
|
561
|
+
if (!sizedInFallback)
|
|
562
|
+
return;
|
|
563
|
+
measure();
|
|
564
|
+
setFaceEpoch((was) => was + 1);
|
|
565
|
+
};
|
|
566
|
+
faces?.addEventListener?.('loadingdone', arrived);
|
|
550
567
|
return () => {
|
|
568
|
+
faces?.removeEventListener?.('loadingdone', arrived);
|
|
551
569
|
observer.disconnect();
|
|
552
570
|
removeHostListener(window, VISUAL_THEME_EVENT, themeChanged);
|
|
553
571
|
};
|
|
@@ -647,11 +665,12 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
647
665
|
headFace,
|
|
648
666
|
cellChips,
|
|
649
667
|
shift,
|
|
668
|
+
faceEpoch,
|
|
650
669
|
]);
|
|
651
670
|
/* Column i's cell follows the expander's when there is one. */
|
|
652
671
|
const measureText = useMemo(() => cellFonts.length
|
|
653
672
|
? (text, column) => textMeasure(cellFonts[Math.min(column + (slotted ? 1 : 0), cellFonts.length - 1)])?.(text) ?? text.length * 8
|
|
654
|
-
: undefined, [cellFonts, slotted]);
|
|
673
|
+
: undefined, [cellFonts, slotted, faceEpoch]);
|
|
655
674
|
/* An App's own list folds the columns its room cannot hold under the row's name, as a detail line, once its heads
|
|
656
675
|
and words have wrapped (gridSizing.ts): they are moved, not lost, and the list does not scroll sideways. An
|
|
657
676
|
embedded grid leaves them out, as it did. */
|
|
@@ -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 (
|
|
20
|
-
void openRecord(table.id,
|
|
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:
|
|
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
|
-
}) })),
|
|
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
|
|
@@ -205,7 +208,7 @@ export function FieldsSection({ page, section, index, base, recordKey: key, fold
|
|
|
205
208
|
? recordNoun(resourceOf(shell().app(), reference.table)?.noun, findTable(reference.table)?.name ?? reference.table)
|
|
206
209
|
: '';
|
|
207
210
|
const jump = (className, text) => (_jsx(RefJump, { references: reference, value: row[titlePath], label: titleLabel ? row[titleLabel] : undefined, table: base, column: titlePath, row: row, className: className, text: text }));
|
|
208
|
-
return (_jsx("section", { className: `${sectionClass(section)} page-card-section page-reference-card`, children: _jsxs("div", { className: "page-card", children: [section.title && _jsx("h2", { className: "page-card-caption", children: section.title }), _jsx("p", { className: "page-card-title", children: reference ? (jump('page-card-name')) : filled(titlePath) ? (_jsx(Value, { col: titleColumn, value: row[titlePath], tableId: base.id })) : (emptyWord()) }), rest.some(filled) && (_jsx("dl", { className: "page-card-facts", children: rest.filter(filled).map((path) => (_jsxs("div", { className: "page-card-fact", children: [_jsx("dt", { children: columnLabel(base.id, path, factsStem) ?? captionOf(path) }), _jsx("dd", { children: said(path) })] }, path))) })), reference && _jsx("p", { className: "page-card-foot", children: jump('page-card-more', say('common.view', { noun })) })] }) }));
|
|
211
|
+
return (_jsx("section", { className: `${sectionClass(section)} page-card-section page-reference-card`, children: _jsxs("div", { className: "page-card", children: [section.title && _jsx("h2", { className: "page-card-caption", children: section.title }), _jsx("p", { className: "page-card-title", children: reference ? (jump('page-card-name')) : filled(titlePath) ? (_jsx(Value, { col: titleColumn, value: row[titlePath], tableId: base.id, row: row, subtitled: !titlePath.includes('.') })) : (emptyWord()) }), rest.some(filled) && (_jsx("dl", { className: "page-card-facts", children: rest.filter(filled).map((path) => (_jsxs("div", { className: "page-card-fact", children: [_jsx("dt", { children: columnLabel(base.id, path, factsStem) ?? captionOf(path) }), _jsx("dd", { children: said(path) })] }, path))) })), reference && _jsx("p", { className: "page-card-foot", children: jump('page-card-more', say('common.view', { noun })) })] }) }));
|
|
209
212
|
}
|
|
210
213
|
/* A group of fields that all follow the same reference is that record
|
|
211
214
|
shown inline; its labels drop the hop they all share. */
|
|
@@ -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,11 +16,12 @@ 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';
|
|
23
23
|
import { RefJump, Value } from './Value.js';
|
|
24
|
+
import { Subtitled } from './SecondLine.js';
|
|
24
25
|
import { headerColumns } from '@mistriwork/engine/shared/recordReads.js';
|
|
25
26
|
import { presentationColumns } from './columnPresentation.js';
|
|
26
27
|
import { useDelete } from './DeleteButton.js';
|
|
@@ -264,16 +265,17 @@ function useRecordHeader({ page, base, recordKey: key, header, onSectionLabel, o
|
|
|
264
265
|
: undefined;
|
|
265
266
|
const adornments = new Map(facts.map((path) => [path, adornedAt(path)]));
|
|
266
267
|
const shown = facts.filter((path) => filled(path) || adornments.get(path));
|
|
268
|
+
const fact = (path) => {
|
|
269
|
+
const labels = section.factLabels;
|
|
270
|
+
const word = labels && Object.hasOwn(labels, path)
|
|
271
|
+
? factWord(labels[path], row[path], columnDisplay(base.id, path))
|
|
272
|
+
: undefined;
|
|
273
|
+
const before = word !== undefined && labels[path].position === 'before';
|
|
274
|
+
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) && (_jsx(Subtitled, { tableId: base.id, column: path.includes('.') ? undefined : path, row: row, children: said(path) })), word !== undefined && !before && _jsxs("span", { className: "page-fact-word", children: [" ", word] }), adornments.get(path)] }, path));
|
|
275
|
+
};
|
|
267
276
|
return {
|
|
268
277
|
/* Its caption is heard, not seen: beside the name a chip is its own word. */
|
|
269
278
|
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((
|
|
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,
|
|
279
|
+
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
280
|
};
|
|
279
281
|
}
|
|
@@ -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
|
-
|
|
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 }) }) }) }));
|