@mistriwork/kit 1.0.0-rc.14 → 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.
- package/dist/client/app.js +2 -1
- package/dist/client/components/AppList.js +12 -1
- package/dist/client/components/ChartFigure.d.ts +3 -2
- package/dist/client/components/ChartFigure.js +7 -5
- package/dist/client/components/Dressed.js +3 -0
- package/dist/client/components/Editable.js +3 -2
- package/dist/client/components/ErrorBoundary.js +1 -1
- package/dist/client/components/Grid.d.ts +15 -1
- package/dist/client/components/Grid.js +44 -7
- package/dist/client/components/JsonView.d.ts +2 -1
- package/dist/client/components/JsonView.js +2 -2
- package/dist/client/components/NewRecord.d.ts +3 -1
- package/dist/client/components/NewRecord.js +16 -5
- package/dist/client/components/PageCurrent.d.ts +10 -1
- package/dist/client/components/PageCurrent.js +10 -6
- package/dist/client/components/PageFields.js +14 -3
- package/dist/client/components/PageFlowDiagram.css +1 -1
- package/dist/client/components/PageHead.js +10 -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 +44 -17
- package/dist/client/components/RecordSummaries.d.ts +5 -3
- package/dist/client/components/RecordSummaries.js +11 -2
- package/dist/client/components/TableRoom.d.ts +4 -1
- package/dist/client/components/TableRoom.js +10 -5
- package/dist/client/components/TableView.d.ts +4 -2
- package/dist/client/components/TableView.js +3 -3
- package/dist/client/components/TimelineReactions.css +49 -0
- package/dist/client/components/TimelineReactions.d.ts +18 -0
- package/dist/client/components/TimelineReactions.js +58 -0
- package/dist/client/components/TreePicker.css +25 -0
- package/dist/client/components/TreePicker.d.ts +59 -0
- package/dist/client/components/TreePicker.js +407 -0
- package/dist/client/components/Value.d.ts +2 -0
- package/dist/client/components/Value.js +67 -7
- package/dist/client/components/appListModel.d.ts +2 -0
- package/dist/client/components/chromeIcons.d.ts +1 -0
- package/dist/client/components/chromeIcons.js +1 -0
- package/dist/client/components/dashboardModel.d.ts +2 -2
- package/dist/client/components/inputRenderers.d.ts +7 -1
- package/dist/client/components/inputRenderers.js +2 -0
- 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 +14 -5
- package/dist/client/components/reactionTally.d.ts +20 -0
- package/dist/client/components/reactionTally.js +46 -0
- package/dist/client/components/useGridGroups.d.ts +11 -0
- package/dist/client/components/useGridGroups.js +70 -0
- package/dist/client/components/useGridKeyboard.d.ts +2 -0
- package/dist/client/components/useGridKeyboard.js +18 -1
- package/dist/client/components/valueModel.d.ts +10 -3
- package/dist/client/components/valueModel.js +21 -1
- package/dist/client/copy/forms/components/TreePicker.d.ts +9 -0
- package/dist/client/copy/forms/components/TreePicker.js +11 -0
- package/dist/client/copy/lists/components/Grid.d.ts +1 -1
- package/dist/client/copy/lists/components/Grid.js +1 -1
- package/dist/client/copy/lists/components/useGridGroups.d.ts +3 -0
- package/dist/client/copy/lists/components/useGridGroups.js +5 -0
- 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/record/components/TimelineReactions.d.ts +7 -0
- package/dist/client/copy/record/components/TimelineReactions.js +6 -0
- package/dist/client/copy/record/components/Value.d.ts +3 -0
- package/dist/client/copy/record/components/Value.js +3 -0
- package/dist/client/copy/shell/components/ErrorBoundary.d.ts +1 -1
- package/dist/client/copy/shell/components/ErrorBoundary.js +1 -1
- package/dist/client/features.css +37 -1
- package/dist/client/index.html +1 -1
- package/dist/client/page.css +33 -4
- package/dist/client/shellHost.d.ts +1 -1
- package/dist/client/shellHost.js +1 -1
- package/dist/client/structure.css +18 -3
- package/dist/client/style.css +11 -2
- package/package.json +4 -4
package/dist/client/app.js
CHANGED
|
@@ -276,7 +276,8 @@ function applyBrand() {
|
|
|
276
276
|
const inApp = shell().inApp();
|
|
277
277
|
sayBrandName(shellQuery('.brand-name'), app ? app.name : 'tablewalk', app?.shortName);
|
|
278
278
|
sayShellWords();
|
|
279
|
-
|
|
279
|
+
/* An App's tab carries the App's name alone (appChrome.js puts the room before it); the wordmark is the Workbench's. */
|
|
280
|
+
setTabTitle(app ? app.name : say('common.documentTitle', { title: state.schema.label }));
|
|
280
281
|
chrome.brand();
|
|
281
282
|
/* The class is the seam the stylesheet hides explorer chrome behind, the
|
|
282
283
|
way `first-run` already does. The app's colours ride the same switch. */
|
|
@@ -45,6 +45,7 @@ import { sameReads } from '../liveReads.js';
|
|
|
45
45
|
import { appListQuery, litTabFor, residueOf, searchColumn, shownTabs, visibleQuestion, wholeQuery, subtitleColumns, editedReferences, listReferenceNames, } from './appListModel.js';
|
|
46
46
|
import { boxTail, boxesFor } from './FilterBoxes.js';
|
|
47
47
|
import { onDemand } from './onDemand.js';
|
|
48
|
+
import { useGridGroups } from './useGridGroups.js';
|
|
48
49
|
const DefinedBoxes = onDemand(() => import('./DefinedFields.js'), 'DefinedBoxes', { quiet: true });
|
|
49
50
|
/* A list's single `per` value (`category_id = 3`), which picks the fields a row-defined column's boxes are. */
|
|
50
51
|
function oneValue(tail) {
|
|
@@ -423,6 +424,7 @@ export function AppList({ entry, spec, navigate, embedded = false, newButton, in
|
|
|
423
424
|
...subtitleColumns(entry.table, [...chosen]),
|
|
424
425
|
...editedReferences(spec),
|
|
425
426
|
...(spec.opens ? [spec.opens] : []),
|
|
427
|
+
...(spec.group ? [spec.group] : []),
|
|
426
428
|
...named,
|
|
427
429
|
]),
|
|
428
430
|
].filter((name) => !chosen.has(name))
|
|
@@ -457,6 +459,14 @@ export function AppList({ entry, spec, navigate, embedded = false, newButton, in
|
|
|
457
459
|
const totals = spec.totals?.length && !spec.presentation
|
|
458
460
|
? Object.fromEntries(spec.totals.map((column, i) => [column, totalAnswers[i]?.data]))
|
|
459
461
|
: undefined;
|
|
462
|
+
/* A grouped grid's heads: one breakdown over what the conditions match, never a read per group (useGridGroups.ts). */
|
|
463
|
+
const gridGroup = useGridGroups({
|
|
464
|
+
column: spec.presentation ? undefined : spec.group,
|
|
465
|
+
table,
|
|
466
|
+
query: entry.query,
|
|
467
|
+
totals: spec.totals,
|
|
468
|
+
connection,
|
|
469
|
+
});
|
|
460
470
|
const onGrid = (result) => {
|
|
461
471
|
setGridResult({
|
|
462
472
|
query: entry.query,
|
|
@@ -621,7 +631,7 @@ export function AppList({ entry, spec, navigate, embedded = false, newButton, in
|
|
|
621
631
|
void client.invalidateQueries({
|
|
622
632
|
queryKey: ['count', connection ?? ''],
|
|
623
633
|
});
|
|
624
|
-
} }) })), _jsx(BoardNewForm.Provider, { value: offersNew ? (spec.form ?? {}) : null, children: _jsx(RowOpensContext.Provider, { value: rowOpens, children: _jsx(TableRoom, { entry: gridEntry, sizing: spec.sizing, chrome: false, summaries: true, inset: !inDashboard, embedded: inDashboard, hide: keptHide, referenceLabels: referenceLabels, totals: keptTotals, density: spec.density,
|
|
634
|
+
} }) })), _jsx(BoardNewForm.Provider, { value: offersNew ? (spec.form ?? {}) : null, children: _jsx(RowOpensContext.Provider, { value: rowOpens, children: _jsx(TableRoom, { entry: gridEntry, sizing: spec.sizing, chrome: false, summaries: true, inset: !inDashboard, embedded: inDashboard, hide: keptHide, referenceLabels: referenceLabels, totals: keptTotals, ...(gridGroup ? { group: gridGroup } : {}), density: spec.density,
|
|
625
635
|
/* A ⋯ with nothing a reader may run is a dead control and a reserved column; the App payload already says what they may run. */
|
|
626
636
|
rowActions: Boolean(spec.rowActions && !spec.presentation && !embedded && mayRunAny(shell().app(), entry.table, spec.actions ?? [])), editable: spec.presentation || embedded ? undefined : spec.editable, inCrumbs: inCrumbs, onResult: keptOnGrid, presentation: embedded ? undefined : spec.presentation, present: shell().present ?? undefined, empty: embedded ? undefined : narrowedPast ? (noMatches) : authoredEmpty ? (_jsx(ListEmpty, { spec: authoredEmpty })) : ((nothingYet ?? tabEmpty)), actions: embedded ? undefined : spec.actions, listLabel: caption, order: embedded ? undefined : spec.order, export: exportOff ? false : undefined, interactive: embedded ? false : undefined }) }) })] })), [
|
|
627
637
|
gridPage,
|
|
@@ -636,6 +646,7 @@ export function AppList({ entry, spec, navigate, embedded = false, newButton, in
|
|
|
636
646
|
keptHide,
|
|
637
647
|
referenceLabels,
|
|
638
648
|
keptTotals,
|
|
649
|
+
gridGroup,
|
|
639
650
|
inCrumbs,
|
|
640
651
|
keptOnGrid,
|
|
641
652
|
authoredEmpty,
|
|
@@ -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) => ({
|
|
@@ -53,6 +53,9 @@ export const Dressed = memo(function Dressed({ dress, compact = false }) {
|
|
|
53
53
|
return compact ? _jsx("span", { className: "rich-text-excerpt", children: dress.text }) : _jsx(RichText, { html: dress.html });
|
|
54
54
|
case 'items':
|
|
55
55
|
return compact ? (_jsx("span", { title: dress.items.join('\n'), children: dress.text })) : (_jsx("ul", { className: "value-items", children: dress.items.map((item, index) => (_jsx("li", { children: item }, index))) }));
|
|
56
|
+
/* An address on its lines where there is room, on one line where there is not. */
|
|
57
|
+
case 'address':
|
|
58
|
+
return compact ? (_jsx("span", { title: dress.lines.join('\n'), children: dress.text })) : (_jsx("span", { className: "value-address", children: dress.lines.map((line, index) => (_jsx("span", { className: "value-address-line", children: line }, index))) }));
|
|
56
59
|
/* A mark stands where the tone's dot would, in its colour; the word stays the value, for every reader. */
|
|
57
60
|
case 'tone':
|
|
58
61
|
return dress.icon ? (_jsxs("span", { className: `tone tone-${dress.tone} tone-marked`, title: dress.label === dress.text ? undefined : dress.text, children: [_jsx(Icon, { name: dress.icon, size: 14, className: "value-mark-icon" }), dress.label] })) : (_jsx("span", { className: `tone tone-${dress.tone}${dress.figure ? ' tone-figure' : ''}`, title: dress.label === dress.text ? undefined : dress.text, children: dress.label }));
|
|
@@ -288,8 +288,9 @@ export function Editable({ table, row, column, recordKey, onSaved, app = false,
|
|
|
288
288
|
/* A reference and a link are values to follow, so the value is not the
|
|
289
289
|
edit button: a link inside a button is neither. The pencil beside it edits. */
|
|
290
290
|
const shownRule = columnDisplay(table.id, column.name);
|
|
291
|
-
/* Formatted text holds links and blocks of its own, so it is not drawn inside a button either
|
|
292
|
-
|
|
291
|
+
/* Formatted text holds links and blocks of its own, so it is not drawn inside a button either; nor is a value
|
|
292
|
+
with its own copy button. */
|
|
293
|
+
const followed = column.references || shownRule?.format === 'richText' || shownRule?.copy || linkFor(column.name, shownValue, shownRule, true);
|
|
293
294
|
return surface(followed && shownValue !== null && shownValue !== undefined ? (_jsxs("div", { className: "inline-field", children: [_jsx("div", { className: "inline-field-value", children: body }), _jsx("button", { ref: launcher, type: "button", className: "inline-edit-button", "aria-label": say('edit', { label }), title: say('edit', { label }), disabled: applying, onClick: () => setOpened(true), children: "\u270E" })] })) : (_jsx("button", { ref: launcher, type: "button", className: "inline-edit-value", "aria-label": say('edit', { label }), title: say('edit', { label }), disabled: applying, onClick: () => setOpened(true), children: body })));
|
|
294
295
|
}
|
|
295
296
|
const wrap = (editor) => surface(_jsxs(_Fragment, { children: [inline ? (_jsxs("div", { className: "inline-field inline-field-open", children: [editor, _jsx("button", { type: "button", className: "inline-edit-button", "aria-label": say('doneEditing', { label }), title: say('doneEditing', { label }), disabled: dirty || applying, onClick: () => setOpened(false), children: "\u2713" })] })) : (editor), error && (_jsx("span", { id: errorId, className: "edit-field-error", role: "alert", children: error }))] }));
|
|
@@ -20,7 +20,7 @@ import { message } from '../messages.js';
|
|
|
20
20
|
import { Problem } from './Notes.js';
|
|
21
21
|
import { say } from '../copy/shell/components/ErrorBoundary.js';
|
|
22
22
|
/** The console line the browser suites watch for. */
|
|
23
|
-
export const SECTION_ERROR = say('
|
|
23
|
+
export const SECTION_ERROR = say('aSectionCouldNotBeDrawn');
|
|
24
24
|
export class ErrorBoundary extends Component {
|
|
25
25
|
state = { error: undefined, key: this.props.resetKey };
|
|
26
26
|
static getDerivedStateFromError(error) {
|
|
@@ -67,6 +67,20 @@ interface GridProps {
|
|
|
67
67
|
editCell?: (row: Row, column: string, draw: CellDraw, label?: unknown) => ReactNode | undefined;
|
|
68
68
|
/** What the host draws in an empty cell in place of its empty mark (a suggestion waiting on it); undefined leaves the mark. One line: no row grows. */
|
|
69
69
|
adornCell?: (row: Row, column: string) => ReactNode | undefined;
|
|
70
|
+
/** The rows' groups, where the list has them: the rows arrive in the group's order, and each run of one value is drawn under its head. */
|
|
71
|
+
group?: GridGroup;
|
|
72
|
+
}
|
|
73
|
+
/** What a group's head says: its value, in words; how many rows it holds; each `totals` column's subtotal. */
|
|
74
|
+
export interface GroupHead {
|
|
75
|
+
label: string;
|
|
76
|
+
/** Every row of the group the list's conditions match, not the page's; absent while it is counted. */
|
|
77
|
+
count?: number;
|
|
78
|
+
sums?: Record<string, unknown>;
|
|
79
|
+
}
|
|
80
|
+
/** A grid's groups (a list view's `group`): the column whose value each row stands under, and the head for a value. */
|
|
81
|
+
export interface GridGroup {
|
|
82
|
+
column: string;
|
|
83
|
+
head: (value: unknown) => GroupHead;
|
|
70
84
|
}
|
|
71
85
|
interface Plan {
|
|
72
86
|
align: string;
|
|
@@ -118,5 +132,5 @@ interface CellColumn {
|
|
|
118
132
|
label: string | undefined;
|
|
119
133
|
}[];
|
|
120
134
|
}
|
|
121
|
-
export declare function Grid({ table, data, hide, labels, totals, totalsLabel, density, referenceLabels, sizing, interactive, virtual: mayVirtualise, onRowClick, list, current, emptyText, compact, firstRow, dropColumns, editCell, adornCell, }: GridProps): import("react").JSX.Element;
|
|
135
|
+
export declare function Grid({ table, data, hide, labels, totals, totalsLabel, density, referenceLabels, sizing, interactive, virtual: mayVirtualise, onRowClick, list, current, emptyText, compact, firstRow, dropColumns, editCell, adornCell, group, }: GridProps): import("react").JSX.Element;
|
|
122
136
|
export {};
|
|
@@ -26,7 +26,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
26
26
|
* column the reader placed, and another reader never sees it.
|
|
27
27
|
*/
|
|
28
28
|
import { useMessageLanguage } from './useMessageLanguage.js';
|
|
29
|
-
import { cloneElement, isValidElement, memo, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, } from 'react';
|
|
29
|
+
import { cloneElement, Fragment, isValidElement, memo, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, } from 'react';
|
|
30
30
|
import { createColumnHelper, tableFeatures, useTable } from '@tanstack/react-table';
|
|
31
31
|
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
32
32
|
import { columnDisplay, columnLabel, currentEntry, emptyWord, keyOf, openRecord, peekRecord, prefersPages, primaryKey, rowLabel, state, viewportBox, viewportScale, } from '../core.js';
|
|
@@ -46,6 +46,7 @@ import { hasChildren } from '../nested.js';
|
|
|
46
46
|
import { openFilterMenu, sortBy } from '../thmenu.js';
|
|
47
47
|
import { AppColumnMenuButton, useAppColumnMenu } from './AppColumnMenu.js';
|
|
48
48
|
import { DetailRow, Expander } from './Nested.js';
|
|
49
|
+
import { Icon } from './Icon.js';
|
|
49
50
|
import { createRowHosts, RowDecoration, RowHostScope, RowTrailScope, rowKeyString, useRowHostScope, useRowTrailScope, } from './RowHost.js';
|
|
50
51
|
import { useGridKeyboard } from './useGridKeyboard.js';
|
|
51
52
|
import { useChangedRows } from '../liveState.js';
|
|
@@ -76,6 +77,8 @@ const REFERENCE_MARK = '→';
|
|
|
76
77
|
const HEAD_CONTROL = 24;
|
|
77
78
|
/** A device that cannot hover keeps a head's caret and moves in the head's flow, beside its label (style.css). */
|
|
78
79
|
const touchHeads = () => typeof matchMedia === 'function' && matchMedia('(hover: none)').matches;
|
|
80
|
+
/** A group's value as the folded set and the head's identity hold it: the rows with no value are one group. */
|
|
81
|
+
const groupKey = (value) => (value === null || value === undefined ? '\u0000' : String(value));
|
|
79
82
|
/** Beyond a few hundred rows the DOM, not the database, is the bottleneck. */
|
|
80
83
|
const VIRTUAL_THRESHOLD = 300;
|
|
81
84
|
const OVERSCAN = 12;
|
|
@@ -394,7 +397,7 @@ function PlatformCell({ meta, plan, value, label, display, pin, edge, photo, wra
|
|
|
394
397
|
}
|
|
395
398
|
/* A vocabulary column that says where a row stands, kept when a narrow grid leaves columns out. */
|
|
396
399
|
const STATUS_NAME = /(^|_)(status|state|stage|phase)$/i;
|
|
397
|
-
export function Grid({ table, data, hide, labels, totals, totalsLabel = say('total'), density, referenceLabels, sizing = 'fit', interactive = true, virtual: mayVirtualise = true, onRowClick, list, current, emptyText, compact = false, firstRow = 0, dropColumns = false, editCell, adornCell, }) {
|
|
400
|
+
export function Grid({ table, data, hide, labels, totals, totalsLabel = say('total'), density, referenceLabels, sizing = 'fit', interactive = true, virtual: mayVirtualise = true, onRowClick, list, current, emptyText, compact = false, firstRow = 0, dropColumns = false, editCell, adornCell, group, }) {
|
|
398
401
|
const captionLanguage = useMessageLanguage();
|
|
399
402
|
const wrap = useRef(null);
|
|
400
403
|
const tableRef = useRef(null);
|
|
@@ -445,7 +448,13 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
445
448
|
/* Rows another person just changed, tinted for a moment (liveState.ts, docs/design.md rule 11). */
|
|
446
449
|
const changedRows = useChangedRows(table?.id, rows, (row) => (table ? keyOf(table, row) : null));
|
|
447
450
|
const openable = useMemo(() => rowKeys.filter((key) => key !== null), [rowKeys]);
|
|
448
|
-
|
|
451
|
+
/* A grouped grid is drawn whole: its heads stand between rows, and the window's model is uniform rows. A list's page is
|
|
452
|
+
the most it holds. */
|
|
453
|
+
const virtual = mayVirtualise && rows.length > VIRTUAL_THRESHOLD && !group;
|
|
454
|
+
/* The groups the reader folded, by value: kept across a page turn, so a group folded on one page stays folded on the
|
|
455
|
+
next it continues on. */
|
|
456
|
+
const [shutGroups, setShutGroups] = useState(() => new Set());
|
|
457
|
+
const foldedRow = useCallback((index) => Boolean(group) && shutGroups.has(groupKey(rows[index]?.[group.column])), [group, shutGroups, rows]);
|
|
449
458
|
/* Not where rows open as pages: the expander is the explorer's way of
|
|
450
459
|
seeing what points at a row, and an app's list gets that on the page
|
|
451
460
|
the row opens as. Nor on a windowed table: an opened detail is many
|
|
@@ -502,7 +511,9 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
502
511
|
};
|
|
503
512
|
setHeadFace((was) => (was && was.font === next.font && was.upper === next.upper && was.tracking === next.tracking ? was : next));
|
|
504
513
|
}
|
|
505
|
-
|
|
514
|
+
/* A group's head is not a row of values: the first row that is one is sampled. */
|
|
515
|
+
const first = element.querySelector('tbody tr:not(.grid-group-head)');
|
|
516
|
+
const cells = first ? [...first.querySelectorAll(':scope > td')] : [];
|
|
506
517
|
if (cells.length) {
|
|
507
518
|
const fonts = cells.map((cell) => {
|
|
508
519
|
const font = getComputedStyle(cell);
|
|
@@ -511,7 +522,7 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
511
522
|
setCellFonts((was) => (was.join('|') === fonts.join('|') ? was : fonts));
|
|
512
523
|
/* The widest chip of the sampled rows, not the first row's: a look may draw a neutral state as a bare word
|
|
513
524
|
and the rest as pills, and sized by a first-row "Ready" Sage cut every "In review" pill to "In rev…". */
|
|
514
|
-
const rows = [...element.querySelectorAll('tbody tr')].slice(0, GRID_SIZE_SAMPLE);
|
|
525
|
+
const rows = [...element.querySelectorAll('tbody tr:not(.grid-group-head)')].slice(0, GRID_SIZE_SAMPLE);
|
|
515
526
|
const chips = cells.map((_, index) => {
|
|
516
527
|
let extra = -1;
|
|
517
528
|
for (const row of rows) {
|
|
@@ -927,6 +938,7 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
927
938
|
onPeek: keyed ? (index) => peekRow(rows[index]) : undefined,
|
|
928
939
|
totalRows: data.exactTotal === false || data.cappedTotal ? undefined : data.total,
|
|
929
940
|
firstRow,
|
|
941
|
+
...(group ? { skip: foldedRow } : {}),
|
|
930
942
|
});
|
|
931
943
|
/* Whatever the column clipped gets its whole value on hover, decided at hover time, once, from its own overflow:
|
|
932
944
|
the cell, or the line inside it that cuts its own text (a row's name over its detail, a lead mark's body, a
|
|
@@ -1099,13 +1111,26 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
1099
1111
|
height: `${padTop}px`,
|
|
1100
1112
|
padding: 0,
|
|
1101
1113
|
border: 'none',
|
|
1102
|
-
} }) })), shown.map((i) => {
|
|
1114
|
+
} }) })), shown.map((i, at) => {
|
|
1103
1115
|
const row = modelRows[i];
|
|
1104
1116
|
if (!row)
|
|
1105
1117
|
return null;
|
|
1106
1118
|
const key = rowKeys[i];
|
|
1107
1119
|
const open = expandable && key !== null && expanded.has(key);
|
|
1108
|
-
|
|
1120
|
+
const drawn = (_jsx(Row, { index: i, rowKey: key, slot: slotted, hostRef: key === null ? undefined : hosts.ref(key), trail: trailing, trailRef: key === null || !trailHosts ? undefined : trailHosts.ref(key), record: row.original, navigable: navigable, opensPage: navigable && !onRowClick && !opens, onOpen: openOne, open: open, current: key !== null && key === currentKey, changed: changedRows.get(row.original), table: table, colSpan: colSpan, columns: cellColumns, editCell: editCell, adornCell: adornCell }, key === null ? `at:${i}` : `key:${key}`));
|
|
1121
|
+
if (!group)
|
|
1122
|
+
return drawn;
|
|
1123
|
+
/* A head where a run of one value begins: the first row drawn, or one whose group the row above is not. */
|
|
1124
|
+
const value = row.original[group.column];
|
|
1125
|
+
const named = groupKey(value);
|
|
1126
|
+
const starts = at === 0 || groupKey(modelRows[shown[at - 1]]?.original[group.column]) !== named;
|
|
1127
|
+
const shut = shutGroups.has(named);
|
|
1128
|
+
return (_jsxs(Fragment, { children: [starts && (_jsx(GroupHeadRow, { head: group.head(value), folded: shut, onToggle: () => setShutGroups((was) => {
|
|
1129
|
+
const next = new Set(was);
|
|
1130
|
+
if (!next.delete(named))
|
|
1131
|
+
next.add(named);
|
|
1132
|
+
return next;
|
|
1133
|
+
}), slot: slotted, trail: trailing, columns: ordered, table: table })), shut ? null : drawn] }, key === null ? `at:${i}` : `key:${key}`));
|
|
1109
1134
|
}), virtual && (_jsx("tr", { className: "virtual-spacer", "aria-hidden": "true", children: _jsx("td", { colSpan: colSpan, style: {
|
|
1110
1135
|
height: `${padBottom}px`,
|
|
1111
1136
|
padding: 0,
|
|
@@ -1119,6 +1144,18 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
1119
1144
|
}), trailing && _jsx("td", {})] }) }))] }), expandable &&
|
|
1120
1145
|
openable.map((key) => (_jsx(RowDecoration, { rowKey: key, store: hosts, children: _jsx(Expander, { open: expanded.has(key), onToggle: () => toggle(key) }) }, key))), virtual && _jsx("p", { className: "note virtual-note", children: say('rowsDrawnAsYouScroll', { count: rows.length }) }), !rows.length && _jsx("p", { className: "note grid-empty", children: emptyText })] }));
|
|
1121
1146
|
}
|
|
1147
|
+
/**
|
|
1148
|
+
* A group's head (a list view's `group`): a hairline row, not a box, that says the value, how many rows it holds and,
|
|
1149
|
+
* under each `totals` column, its subtotal — the breakdown's figures, so a group a page divides is counted whole. The
|
|
1150
|
+
* value is a button that folds the group's rows away and opens them again.
|
|
1151
|
+
*/
|
|
1152
|
+
function GroupHeadRow({ head, folded, onToggle, slot, trail, columns, table, }) {
|
|
1153
|
+
const sums = head.sums ?? {};
|
|
1154
|
+
/* The value spans the columns before the first subtotal, so each figure stands under the column it sums. */
|
|
1155
|
+
const first = columns.findIndex((name) => Object.hasOwn(sums, name));
|
|
1156
|
+
const lead = first < 0 ? columns.length : Math.max(1, first);
|
|
1157
|
+
return (_jsxs("tr", { className: `grid-group-head${folded ? ' is-folded' : ''}`, children: [slot && _jsx("td", { className: "expander-cell" }), _jsx("td", { colSpan: lead, className: "grid-group-cell", children: _jsxs("button", { type: "button", className: "grid-group-toggle", "aria-expanded": !folded, onClick: onToggle, children: [_jsx(Icon, { name: folded ? 'caret-right' : 'caret-down', size: 14, className: "grid-group-caret" }), _jsx("span", { className: "grid-group-name", children: head.label }), head.count !== undefined && _jsx("span", { className: "grid-group-count", children: formatNumber(head.count) })] }) }), columns.slice(lead).map((name) => Object.hasOwn(sums, name) ? (_jsx("td", { className: "align-right num grid-group-sum", children: _jsx(TotalValue, { value: sums[name], display: columnDisplay(table?.id, name) }) }, name)) : (_jsx("td", {}, name))), trail && _jsx("td", {})] }));
|
|
1158
|
+
}
|
|
1122
1159
|
/**
|
|
1123
1160
|
* One row, and its detail row when it is open. The leading cell, when the
|
|
1124
1161
|
* grid draws one, is the row's host: React never gives it children of its
|
|
@@ -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);
|
|
@@ -41,7 +41,7 @@ type FormBodyProps = NewRecordProps & {
|
|
|
41
41
|
};
|
|
42
42
|
/** The fields, the required check and the save, apart from any frame: once its starting words (`today`, `me`) are values. */
|
|
43
43
|
export declare function NewRecordForm(props: FormBodyProps): import("react").JSX.Element;
|
|
44
|
-
export declare function PlatformControl({ column, app, required, assigned, spoken, target, value, onChange, register, explicitNull, errorId, kind, rule, placeholder, as, where, waiting, helpId, }: {
|
|
44
|
+
export declare function PlatformControl({ column, app, required, assigned, spoken, target, value, onChange, register, explicitNull, errorId, kind, rule, placeholder, as, where, waiting, tree, helpId, }: {
|
|
45
45
|
column: ColumnMeta;
|
|
46
46
|
app: boolean;
|
|
47
47
|
/** Said to assistive technology as well as starred: the star is outside the control's name. */
|
|
@@ -64,6 +64,8 @@ export declare function PlatformControl({ column, app, required, assigned, spoke
|
|
|
64
64
|
/** A narrowed reference's condition; `waiting` while a field it reads is empty. */
|
|
65
65
|
where?: string;
|
|
66
66
|
waiting?: boolean;
|
|
67
|
+
/** The referenced table's parent column, where the form draws the reference as its hierarchy (`form.fields.<column>.tree`). */
|
|
68
|
+
tree?: string;
|
|
67
69
|
helpId?: string;
|
|
68
70
|
}): import("react").JSX.Element;
|
|
69
71
|
/**
|
|
@@ -23,14 +23,15 @@ import { useMessageLanguage } from './useMessageLanguage.js';
|
|
|
23
23
|
import { MultiStepForm } from './MultiStepForm.js';
|
|
24
24
|
import { Columns } from '@mistriwork/ui/FormParts.js';
|
|
25
25
|
import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
|
|
26
|
-
import { state, viewportBox, writeAllowed } from '../core.js';
|
|
26
|
+
import { api, labelColumn, labelPath, state, viewportBox, writeAllowed } from '../core.js';
|
|
27
|
+
import { ownedBy } from '../requestIdentity.js';
|
|
27
28
|
import { RichTextField, mentionSearch } from './RichTextField.js';
|
|
28
29
|
import { createPortal } from 'react-dom';
|
|
29
30
|
import { Modal } from '@mistriwork/ui/Modal.js';
|
|
30
31
|
import { Button } from '@mistriwork/ui/Button.js';
|
|
31
32
|
import { ConfirmDialog } from './Prompt.js';
|
|
32
33
|
import { useForm } from '@tanstack/react-form';
|
|
33
|
-
import { columnKind, isFlagColumn } from '@mistriwork/engine/shared/schema.js';
|
|
34
|
+
import { columnKind, isFlagColumn, primaryKey } from '@mistriwork/engine/shared/schema.js';
|
|
34
35
|
import { humanName, vocabularyWord } from '@mistriwork/engine/shared/model.js';
|
|
35
36
|
import { inferredFormDefaults } from '@mistriwork/engine/shared/formValues.js';
|
|
36
37
|
import { sessionIdentity } from '../sessionIdentity.js';
|
|
@@ -58,6 +59,8 @@ import { useRecordInsert } from './useRecordInsert.js';
|
|
|
58
59
|
import { say } from '../copy/forms/components/NewRecord.js';
|
|
59
60
|
export { autoKey, isRequired } from '@mistriwork/engine/shared/form.js';
|
|
60
61
|
const DefinedInputs = onDemand(() => import('./DefinedFields.js'), 'DefinedInputs', { quiet: true });
|
|
62
|
+
/* A reference drawn as its hierarchy (`form.fields.<column>.tree`): a part of its own, so a form without one carries none of it. */
|
|
63
|
+
const TreePicker = onDemand(() => import('./TreePicker.js'), 'TreePicker', { quiet: true });
|
|
61
64
|
const dateOnly = (column) => columnKind(column.type) === 'date' && !/time/i.test(column.type);
|
|
62
65
|
/* A date is judged in the Workbench too; a date and time only where an App draws its picker. */
|
|
63
66
|
const invalidDate = (column, value, kind) => value !== '' && (dateOnly(column) ? !isPickerDate(value) : kind === 'datetime' && !isPickerDateTime(value));
|
|
@@ -144,7 +147,8 @@ function NewRecordFormBody({ table, form, app, label: columnLabel, target, inser
|
|
|
144
147
|
? fieldInput(column, {
|
|
145
148
|
money: display?.(column)?.format === 'money',
|
|
146
149
|
richText: display?.(column)?.format === 'richText',
|
|
147
|
-
|
|
150
|
+
/* An address is written one part per line. */
|
|
151
|
+
multiline: dress(column)?.multiline ?? (display?.(column)?.format === 'address' ? true : undefined),
|
|
148
152
|
required: isRequired(column, assigned),
|
|
149
153
|
hasStart: switches.has(column.name) ||
|
|
150
154
|
(!isFlagColumn(column) && (presetValue(column, defaults) !== '' || column.default !== undefined || column.hasDefault === true)),
|
|
@@ -396,7 +400,7 @@ function NewRecordFormBody({ table, form, app, label: columnLabel, target, inser
|
|
|
396
400
|
const errorId = `${errorPrefix}-${index}-error`;
|
|
397
401
|
const help = [own?.help, waitingOn ? say('chooseFirst', { waitingOn }) : ''].filter(Boolean).join(' ') || undefined;
|
|
398
402
|
const helpId = help ? `${errorPrefix}-${index}-help` : undefined;
|
|
399
|
-
return (_jsxs("div", { className: `insert-field${app ? ' form-field' : ''}${fieldMessage ? ' missing is-invalid' : ''}`, children: [app ? (_jsxs("div", { className: "form-field-label-row", children: [_jsx("label", { className: "form-field-label", children: label(column) }), !required(column) && (_jsxs(_Fragment, { children: [' ', _jsx("span", { className: "form-field-optional-word", children: say('optionalWord') })] }))] })) : (_jsxs("label", { children: [label(column), _jsx("span", { className: "type", children: column.type.toLowerCase() }), column.primaryKey && _jsx("span", { className: "pk", children: say('common.key') }), required(column) && (_jsx("span", { className: "req", title: say('notNullWithNoDefault'), children: say('requiredMark') }))] })), _jsx(Control, { column: column, app: app, input: app ? columnInput(table.id, column.name) : undefined, resource: table.id, required: required(column), assigned: assigned, spoken: label(column), target: target, value: field.state.value, kind: kind, rule: app ? ruleIn(column, { ...defaults, ...values }) : (display?.(column) ?? undefined), placeholder: own?.placeholder, as: own?.as, where: narrowed === undefined ? undefined : narrowed || undefined, waiting: narrowed === undefined, helpId: helpId, onChange: (value) => {
|
|
403
|
+
return (_jsxs("div", { className: `insert-field${app ? ' form-field' : ''}${fieldMessage ? ' missing is-invalid' : ''}`, children: [app ? (_jsxs("div", { className: "form-field-label-row", children: [_jsx("label", { className: "form-field-label", children: label(column) }), !required(column) && (_jsxs(_Fragment, { children: [' ', _jsx("span", { className: "form-field-optional-word", children: say('optionalWord') })] }))] })) : (_jsxs("label", { children: [label(column), _jsx("span", { className: "type", children: column.type.toLowerCase() }), column.primaryKey && _jsx("span", { className: "pk", children: say('common.key') }), required(column) && (_jsx("span", { className: "req", title: say('notNullWithNoDefault'), children: say('requiredMark') }))] })), _jsx(Control, { column: column, app: app, input: app ? columnInput(table.id, column.name) : undefined, resource: table.id, required: required(column), assigned: assigned, spoken: label(column), target: target, value: field.state.value, kind: kind, rule: app ? ruleIn(column, { ...defaults, ...values }) : (display?.(column) ?? undefined), placeholder: own?.placeholder, as: own?.as, where: narrowed === undefined ? undefined : narrowed || undefined, waiting: narrowed === undefined, tree: kind === 'reference' ? own?.tree : undefined, helpId: helpId, onChange: (value) => {
|
|
400
404
|
edited.current.add(column.name);
|
|
401
405
|
field.handleChange(value);
|
|
402
406
|
/* A value taken from the record this field names follows the choice, until the person says their own. */
|
|
@@ -522,7 +526,7 @@ function useControlsStyle(wanted) {
|
|
|
522
526
|
}, [wanted]);
|
|
523
527
|
return here || controlsStyled;
|
|
524
528
|
}
|
|
525
|
-
export function PlatformControl({ column, app, required, assigned, spoken, target, value, onChange, register, explicitNull, errorId, kind, rule, placeholder, as, where, waiting = false, helpId, }) {
|
|
529
|
+
export function PlatformControl({ column, app, required, assigned, spoken, target, value, onChange, register, explicitNull, errorId, kind, rule, placeholder, as, where, waiting = false, tree, helpId, }) {
|
|
526
530
|
const dateId = useId();
|
|
527
531
|
const radioName = useId();
|
|
528
532
|
const styled = useControlsStyle(app && (as === 'cards' || as === 'buttons'));
|
|
@@ -629,6 +633,13 @@ export function PlatformControl({ column, app, required, assigned, spoken, targe
|
|
|
629
633
|
], value: value, valueClassName: quietWhenEmpty, ariaLabel: `${spoken}${app ? '' : ` (${column.type})`}`, onChange: onChange, buttonRef: setControl }));
|
|
630
634
|
}
|
|
631
635
|
const referenced = column.references ? target(column.references.table) : undefined;
|
|
636
|
+
if (referenced && tree) {
|
|
637
|
+
/* A plain column to search and say: a walked name or a label template is a view's, which a level's read is not. */
|
|
638
|
+
const naming = labelPath(referenced);
|
|
639
|
+
const plain = naming && !naming.includes('.') && !naming.startsWith('$') ? naming : (labelColumn(referenced) ?? primaryKey(referenced)[0]);
|
|
640
|
+
const connection = state.activeConnection;
|
|
641
|
+
return (_jsx(TreePicker, { from: referenced.id, by: primaryKey(referenced)[0], labelColumn: plain, parent: tree, where: where, ask: (path, body) => api(path, { ...ownedBy(connection), ...body }), scope: JSON.stringify([sessionIdentity().epoch, connection]), value: value, onChange: (next) => onChange(next === '' ? '' : String(next)), ariaLabel: spoken, inputRef: setControl, disabled: waiting, required: required, ...(placeholder ? { placeholder } : {}) }));
|
|
642
|
+
}
|
|
632
643
|
if (referenced) {
|
|
633
644
|
return (_jsx(RecordPicker, { table: referenced, value: value, onChange: onChange, ariaLabel: spoken, app: app, inputRef: setControl, where: where, disabled: waiting, ...(placeholder ? { placeholder } : {}) }));
|
|
634
645
|
}
|
|
@@ -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
|
|
@@ -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>
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
|
|
66
66
|
}
|
|
67
67
|
.flow-diagram-kind { display: flex; align-items: center; gap: var(--space-2h); min-width: 0; height: 16px; color: var(--ink-muted); }
|
|
68
|
-
.flow-diagram-kind > .
|
|
68
|
+
.flow-diagram-kind > .mistri-icon { flex: none; }
|
|
69
69
|
.flow-diagram-kind-word {
|
|
70
70
|
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
71
71
|
font-size: var(--text-xs); font-weight: 500; letter-spacing: var(--track-caps); text-transform: uppercase;
|
|
@@ -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((
|
|
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 {};
|