@mistriwork/kit 1.0.0-rc.13 → 1.0.0-rc.15
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/Composer.js +2 -2
- package/dist/client/components/Diagram.js +1 -1
- 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 +71 -8
- package/dist/client/components/NewRecord.d.ts +3 -1
- package/dist/client/components/NewRecord.js +16 -5
- package/dist/client/components/PageFlowDiagram.css +1 -1
- package/dist/client/components/PageTimeline.js +18 -4
- package/dist/client/components/RecordSummaries.d.ts +5 -3
- package/dist/client/components/RecordSummaries.js +11 -2
- package/dist/client/components/Summary.js +1 -1
- 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.js +33 -2
- 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/gridSizing.d.ts +3 -0
- package/dist/client/components/gridSizing.js +1 -1
- package/dist/client/components/inputRenderers.d.ts +7 -1
- package/dist/client/components/inputRenderers.js +2 -0
- package/dist/client/components/pageModel.d.ts +4 -0
- 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/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/copy/shell/visualTheme.d.ts +2 -0
- package/dist/client/copy/shell/visualTheme.js +2 -0
- package/dist/client/copy/workbench/components/Composer.d.ts +2 -2
- package/dist/client/copy/workbench/components/Composer.js +2 -2
- package/dist/client/copy/workbench/components/Diagram.d.ts +1 -1
- package/dist/client/copy/workbench/components/Diagram.js +1 -1
- package/dist/client/copy/workbench/components/Summary.d.ts +3 -3
- package/dist/client/copy/workbench/components/Summary.js +3 -3
- package/dist/client/features.css +41 -4
- package/dist/client/fonts/faces.css +53 -0
- package/dist/client/index.html +1 -1
- package/dist/client/page.css +3 -2
- package/dist/client/shellHost.d.ts +1 -1
- package/dist/client/shellHost.js +1 -1
- package/dist/client/structure.css +11 -3
- package/dist/client/style.css +11 -2
- package/dist/client/visualTheme.d.ts +29 -0
- package/dist/client/visualTheme.js +94 -17
- package/dist/client/visualThemes.css +2 -1
- package/package.json +10 -3
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,
|
|
@@ -115,7 +115,7 @@ function summaryLabel(fn, column, isDate) {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
function SummariseMenu({ fk, child }) {
|
|
118
|
-
const items = [{ value: '', label: say('
|
|
118
|
+
const items = [{ value: '', label: say('summarize'), detail: say('aTotalAnAverage') }];
|
|
119
119
|
for (const column of child.columns) {
|
|
120
120
|
if (column.primaryKey || column.references)
|
|
121
121
|
continue;
|
|
@@ -133,7 +133,7 @@ function SummariseMenu({ fk, child }) {
|
|
|
133
133
|
}
|
|
134
134
|
if (items.length === 1)
|
|
135
135
|
return null;
|
|
136
|
-
return (_jsx("span", { className: "composer-menu", children: _jsx(Dropdown, { items: items, value: "", ariaLabel: say('
|
|
136
|
+
return (_jsx("span", { className: "composer-menu", children: _jsx(Dropdown, { items: items, value: "", ariaLabel: say('summarizeName', { name: child.name }), onChange: (value) => {
|
|
137
137
|
if (!value)
|
|
138
138
|
return;
|
|
139
139
|
const [fn, column] = value.split(':');
|
|
@@ -225,7 +225,7 @@ export function NeighbourhoodDiagram({ tableId, expandable = true }) {
|
|
|
225
225
|
return _jsx("p", { className: "note", children: say('hasNoForeignKeys', { tableId }) });
|
|
226
226
|
const { left, right, self, width, height, leftX, midX, rightX, focusTop, focusAnchor, drawn } = layout;
|
|
227
227
|
const drawing = (_jsxs(_Fragment, { children: [_jsx(Arrow, { id: "arrow", size: 7 }), left.map((node) => (_jsxs("g", { children: [_jsx(Edge, { x1: leftX + NODE_W, y1: node.top + HEAD_H / 2, x2: midX, y2: focusAnchor, label: node.columns.join(' · '), marker: "arrow" }), _jsx(Node, { tableId: node.table, x: leftX, y: node.top, role: "out", repaint: repaint })] }, node.table))), right.map((node) => (_jsxs("g", { children: [_jsx(Edge, { x1: rightX, y1: node.top + HEAD_H / 2, x2: midX + NODE_W, y2: focusAnchor, label: node.columns.join(' · '), marker: "arrow" }), _jsx(Node, { tableId: node.table, x: rightX, y: node.top, role: "in", repaint: repaint })] }, node.table))), self.length ? (_jsxs(_Fragment, { children: [_jsx("path", { className: "edge", markerEnd: "url(#arrow)", d: `M${midX + NODE_W * 0.3},${focusTop} C${midX + NODE_W * 0.1},${focusTop - 34} ${midX + NODE_W * 0.9},${focusTop - 34} ${midX + NODE_W * 0.7},${focusTop}` }), _jsx("text", { x: midX + NODE_W / 2, y: focusTop - 22, className: "edge-label", textAnchor: "middle", children: self.map((fk) => fk.from.columns.join(', ')).join(' · ') })] })) : null, _jsx(Node, { tableId: tableId, x: midX, y: focusTop, role: "focus", repaint: repaint })] }));
|
|
228
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "diagram-head", children: [_jsx("h2", { className: "diagram-title", children: say('andWhatItTouches', { name: focus.name }) }), _jsx(SchemaExportControl, { schema: schemaOf(), only: drawn, picture: () => ({ svg: svg.current ?? undefined, size: { width, height } }) })] }), _jsx(PanZoom, { size: { width, height }, focus: { x: midX + NODE_W / 2, y: focusAnchor }, svgRef: svg, label: say('
|
|
228
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "diagram-head", children: [_jsx("h2", { className: "diagram-title", children: say('andWhatItTouches', { name: focus.name }) }), _jsx(SchemaExportControl, { schema: schemaOf(), only: drawn, picture: () => ({ svg: svg.current ?? undefined, size: { width, height } }) })] }), _jsx(PanZoom, { size: { width, height }, focus: { x: midX + NODE_W / 2, y: focusAnchor }, svgRef: svg, label: say('foreignKeyNeighborhood', { tableId }), expand: expandable ? () => setFull(true) : undefined, children: drawing }), _jsxs("p", { className: "diagram-legend", children: [_jsx("span", { className: "legend-out", children: say('points') }), _jsx("span", { children: ` ${focus.name} ` }), _jsx("span", { className: "legend-in", children: say('pointed') })] }), full ? (_jsx(Fullscreen, { onClose: () => setFull(false), children: _jsx("div", { className: "diagram", children: _jsx(NeighbourhoodDiagram, { tableId: tableId, expandable: false }) }) })) : null] }));
|
|
229
229
|
}
|
|
230
230
|
/* ---------- the whole schema ---------- */
|
|
231
231
|
export function SchemaDiagram({ expandable = true }) {
|
|
@@ -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';
|
|
@@ -72,6 +73,12 @@ const FOLD_ROOM = 150;
|
|
|
72
73
|
const TAGS_SHOWN = 3;
|
|
73
74
|
/* The mark a reference's head draws after its label, and its sizing counts. */
|
|
74
75
|
const REFERENCE_MARK = '→';
|
|
76
|
+
/** A head's caret and each of its move buttons: 24px (style.css, `.th-filter`, `.th-move`). */
|
|
77
|
+
const HEAD_CONTROL = 24;
|
|
78
|
+
/** A device that cannot hover keeps a head's caret and moves in the head's flow, beside its label (style.css). */
|
|
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));
|
|
75
82
|
/** Beyond a few hundred rows the DOM, not the database, is the bottleneck. */
|
|
76
83
|
const VIRTUAL_THRESHOLD = 300;
|
|
77
84
|
const OVERSCAN = 12;
|
|
@@ -390,7 +397,7 @@ function PlatformCell({ meta, plan, value, label, display, pin, edge, photo, wra
|
|
|
390
397
|
}
|
|
391
398
|
/* A vocabulary column that says where a row stands, kept when a narrow grid leaves columns out. */
|
|
392
399
|
const STATUS_NAME = /(^|_)(status|state|stage|phase)$/i;
|
|
393
|
-
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, }) {
|
|
394
401
|
const captionLanguage = useMessageLanguage();
|
|
395
402
|
const wrap = useRef(null);
|
|
396
403
|
const tableRef = useRef(null);
|
|
@@ -441,7 +448,13 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
441
448
|
/* Rows another person just changed, tinted for a moment (liveState.ts, docs/design.md rule 11). */
|
|
442
449
|
const changedRows = useChangedRows(table?.id, rows, (row) => (table ? keyOf(table, row) : null));
|
|
443
450
|
const openable = useMemo(() => rowKeys.filter((key) => key !== null), [rowKeys]);
|
|
444
|
-
|
|
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]);
|
|
445
458
|
/* Not where rows open as pages: the expander is the explorer's way of
|
|
446
459
|
seeing what points at a row, and an app's list gets that on the page
|
|
447
460
|
the row opens as. Nor on a windowed table: an opened detail is many
|
|
@@ -498,7 +511,9 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
498
511
|
};
|
|
499
512
|
setHeadFace((was) => (was && was.font === next.font && was.upper === next.upper && was.tracking === next.tracking ? was : next));
|
|
500
513
|
}
|
|
501
|
-
|
|
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')] : [];
|
|
502
517
|
if (cells.length) {
|
|
503
518
|
const fonts = cells.map((cell) => {
|
|
504
519
|
const font = getComputedStyle(cell);
|
|
@@ -507,7 +522,7 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
507
522
|
setCellFonts((was) => (was.join('|') === fonts.join('|') ? was : fonts));
|
|
508
523
|
/* The widest chip of the sampled rows, not the first row's: a look may draw a neutral state as a bare word
|
|
509
524
|
and the rest as pills, and sized by a first-row "Ready" Sage cut every "In review" pill to "In rev…". */
|
|
510
|
-
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);
|
|
511
526
|
const chips = cells.map((_, index) => {
|
|
512
527
|
let extra = -1;
|
|
513
528
|
for (const row of rows) {
|
|
@@ -571,6 +586,12 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
571
586
|
/* A reference's arrow stands beside its label in the sort (the head, below), after the sort's 4px gap:
|
|
572
587
|
uncounted, it took the room past the label that the resizer's strip is (style.css). */
|
|
573
588
|
mark: byName.get(name)?.references ? 4 + (headMeasure ? headSet(REFERENCE_MARK) : GRID_HEAD_CHAR) : undefined,
|
|
589
|
+
/* On touch the head's caret and moves stand beside its label, which gives way to them. The key's label is the
|
|
590
|
+
shortest and gave way whole: a phone drew the Workbench's "id KEY ↓" as "KEY ↓". Its column keeps their
|
|
591
|
+
room; any other head's label may still give way, as it was designed to. */
|
|
592
|
+
touchControls: byName.get(name)?.primaryKey && !shell().inApp() && touchHeads()
|
|
593
|
+
? HEAD_CONTROL * ((interactive ? 2 : 0) + (language && (!table?.filterable || table.filterable.includes(name)) ? 1 : 0))
|
|
594
|
+
: undefined,
|
|
574
595
|
showTime: plan.showTime,
|
|
575
596
|
values: rows.slice(0, GRID_SIZE_SAMPLE).map((row) => {
|
|
576
597
|
if (labelColumn && row[labelColumn] != null)
|
|
@@ -610,7 +631,23 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
610
631
|
(Boolean(display?.tone && !display.format && !display.bar) ||
|
|
611
632
|
(Boolean(byName.get(name)?.allowed?.length) && STATUS_NAME.test(name))),
|
|
612
633
|
};
|
|
613
|
-
}), [
|
|
634
|
+
}), [
|
|
635
|
+
asked,
|
|
636
|
+
plans,
|
|
637
|
+
referenceLabels,
|
|
638
|
+
table?.id,
|
|
639
|
+
table?.filterable,
|
|
640
|
+
labels,
|
|
641
|
+
interactive,
|
|
642
|
+
language,
|
|
643
|
+
captionLanguage,
|
|
644
|
+
byName,
|
|
645
|
+
rows,
|
|
646
|
+
titleName,
|
|
647
|
+
headFace,
|
|
648
|
+
cellChips,
|
|
649
|
+
shift,
|
|
650
|
+
]);
|
|
614
651
|
/* Column i's cell follows the expander's when there is one. */
|
|
615
652
|
const measureText = useMemo(() => cellFonts.length
|
|
616
653
|
? (text, column) => textMeasure(cellFonts[Math.min(column + (slotted ? 1 : 0), cellFonts.length - 1)])?.(text) ?? text.length * 8
|
|
@@ -901,6 +938,7 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
901
938
|
onPeek: keyed ? (index) => peekRow(rows[index]) : undefined,
|
|
902
939
|
totalRows: data.exactTotal === false || data.cappedTotal ? undefined : data.total,
|
|
903
940
|
firstRow,
|
|
941
|
+
...(group ? { skip: foldedRow } : {}),
|
|
904
942
|
});
|
|
905
943
|
/* Whatever the column clipped gets its whole value on hover, decided at hover time, once, from its own overflow:
|
|
906
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
|
|
@@ -1073,13 +1111,26 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
1073
1111
|
height: `${padTop}px`,
|
|
1074
1112
|
padding: 0,
|
|
1075
1113
|
border: 'none',
|
|
1076
|
-
} }) })), shown.map((i) => {
|
|
1114
|
+
} }) })), shown.map((i, at) => {
|
|
1077
1115
|
const row = modelRows[i];
|
|
1078
1116
|
if (!row)
|
|
1079
1117
|
return null;
|
|
1080
1118
|
const key = rowKeys[i];
|
|
1081
1119
|
const open = expandable && key !== null && expanded.has(key);
|
|
1082
|
-
|
|
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}`));
|
|
1083
1134
|
}), virtual && (_jsx("tr", { className: "virtual-spacer", "aria-hidden": "true", children: _jsx("td", { colSpan: colSpan, style: {
|
|
1084
1135
|
height: `${padBottom}px`,
|
|
1085
1136
|
padding: 0,
|
|
@@ -1093,6 +1144,18 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
1093
1144
|
}), trailing && _jsx("td", {})] }) }))] }), expandable &&
|
|
1094
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 })] }));
|
|
1095
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
|
+
}
|
|
1096
1159
|
/**
|
|
1097
1160
|
* One row, and its detail row when it is open. The leading cell, when the
|
|
1098
1161
|
* grid draws one, is the row's host: React never gives it children of its
|
|
@@ -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
|
}
|
|
@@ -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;
|
|
@@ -23,6 +23,7 @@ import { Empty } from './Notes.js';
|
|
|
23
23
|
import { Value } from './Value.js';
|
|
24
24
|
import { listColumn } from './listColumn.js';
|
|
25
25
|
import { say } from '../copy/record/components/PageTimeline.js';
|
|
26
|
+
import { useReactionTally } from './reactionTally.js';
|
|
26
27
|
/**
|
|
27
28
|
* What a merged row says it is: its resource's noun ("Call", "Note"), the word
|
|
28
29
|
* a New button and a page already use, and the table's name as a person says
|
|
@@ -63,12 +64,12 @@ function When({ at }) {
|
|
|
63
64
|
const runsOn = (r, prev) => Boolean(prev && !Array.isArray(prev) && !isEvent(prev) && r.by && prev.by === r.by && prev.other === r.other && prev.tone === r.tone);
|
|
64
65
|
/** One row: an event is one quiet line; a message is who, what kind and when over its words, its author said once a run
|
|
65
66
|
where the section has sides. */
|
|
66
|
-
function Row({ r, multi, conversation, continued = false, }) {
|
|
67
|
+
function Row({ r, multi, conversation, continued = false, reacted, }) {
|
|
67
68
|
const words = r.text == null || r.text === '' ? ('') : (_jsx(Value, { tableId: r.table, col: r.textColumn, value: r.text, compact: true, links: true, wholeText: conversation }));
|
|
68
69
|
const tone = r.tone ? { 'data-tone': r.tone } : {};
|
|
69
70
|
if (isEvent(r))
|
|
70
71
|
return (_jsxs("li", { className: "timeline-row is-compact", "data-timeline-row": true, ...tone, children: [_jsx("span", { className: "timeline-text", children: words }), _jsx(When, { at: r.when })] }));
|
|
71
|
-
return (_jsxs("li", { className: `timeline-row${r.tone ? ' is-tinted' : ''}${r.other ? ' is-other' : ''}${continued ? ' is-continued' : ''}`, "data-timeline-row": true, ...tone, children: [r.by && !continued ? (_jsx("span", { className: `timeline-avatar avatar avatar-c${hueOf(r.by)}`, "aria-hidden": "true", children: initialsOf(r.by) })) : (_jsx("span", { className: "timeline-avatar", "aria-hidden": "true" })), _jsxs("span", { className: "timeline-head", children: [r.by && (continued ? _jsx("span", { className: "visually-hidden", children: r.by }) : _jsx("span", { className: "timeline-by", children: r.by })), r.detail != null && (_jsx("span", { className: "timeline-kind", children: _jsx(Value, { tableId: r.table, col: r.detailColumn, value: r.detail, compact: true }) })), multi && _jsx("span", { className: "timeline-source", children: r.source }), _jsx(When, { at: r.when })] }), _jsx("div", { className: "timeline-text prose", children: words })] }));
|
|
72
|
+
return (_jsxs("li", { className: `timeline-row${r.tone ? ' is-tinted' : ''}${r.other ? ' is-other' : ''}${continued ? ' is-continued' : ''}`, "data-timeline-row": true, ...tone, children: [r.by && !continued ? (_jsx("span", { className: `timeline-avatar avatar avatar-c${hueOf(r.by)}`, "aria-hidden": "true", children: initialsOf(r.by) })) : (_jsx("span", { className: "timeline-avatar", "aria-hidden": "true" })), _jsxs("span", { className: "timeline-head", children: [r.by && (continued ? _jsx("span", { className: "visually-hidden", children: r.by }) : _jsx("span", { className: "timeline-by", children: r.by })), r.detail != null && (_jsx("span", { className: "timeline-kind", children: _jsx(Value, { tableId: r.table, col: r.detailColumn, value: r.detail, compact: true }) })), multi && _jsx("span", { className: "timeline-source", children: r.source }), _jsx(When, { at: r.when })] }), _jsx("div", { className: "timeline-text prose", children: words }), reacted && r.entry && _jsx(Reactions, { reactions: reacted.reactions, entry: r.entry, tally: reacted.tally })] }));
|
|
72
73
|
}
|
|
73
74
|
/** Two or more events in a row, said as their count and opened in place. */
|
|
74
75
|
function Fold({ rows, multi, conversation }) {
|
|
@@ -79,10 +80,13 @@ function Fold({ rows, multi, conversation }) {
|
|
|
79
80
|
/** The record's activity as one stream, merged newest-first (or, as a conversation, oldest-first) across its streams. */
|
|
80
81
|
/* The other side's stylesheet, a part of its own: only a section with a `side` (its own or a stream's) asks for it. */
|
|
81
82
|
const Sides = onDemand(() => import('./TimelineSides.js'), 'TimelineSides', { quiet: true });
|
|
83
|
+
/* An entry's reactions, a part of their own with their stylesheet: only a section with `reactions` asks for it. */
|
|
84
|
+
const Reactions = onDemand(() => import('./TimelineReactions.js'), 'ReactionRow', { quiet: true });
|
|
82
85
|
export function TimelineSection({ section, plan, base, recordKey }) {
|
|
83
86
|
/* Rows with sides wait for their dress, under the section's one skeleton, so nothing moves when it comes. */
|
|
84
87
|
const sided = Boolean(section.side || section.streams?.some((stream) => stream.side));
|
|
85
88
|
const sidesHere = useArrived(Sides, sided);
|
|
89
|
+
const reactionsHere = useArrived(Reactions, Boolean(section.reactions));
|
|
86
90
|
const api = usePageApi();
|
|
87
91
|
const { preview, isCurrent, openRelated } = useContext(PageRenderContext);
|
|
88
92
|
const queries = useQueryClient();
|
|
@@ -137,6 +141,7 @@ export function TimelineSection({ section, plan, base, recordKey }) {
|
|
|
137
141
|
const detailCol = stream.detail ? (cols[names.indexOf(stream.detail)] ?? stream.detail) : null;
|
|
138
142
|
const byCol = byPath ? (cols[names.indexOf(byPath)] ?? byPath) : null;
|
|
139
143
|
const markCol = (name) => cols[names.indexOf(name)] ?? name;
|
|
144
|
+
const entryCol = stream.reacts ? markCol(stream.reacts) : undefined;
|
|
140
145
|
const shown = table && listColumn(table, stream.show);
|
|
141
146
|
const detailed = table && stream.detail ? listColumn(table, stream.detail) : undefined;
|
|
142
147
|
return got.rows.map((row) => ({
|
|
@@ -148,6 +153,9 @@ export function TimelineSection({ section, plan, base, recordKey }) {
|
|
|
148
153
|
table: table?.id ?? stream.from,
|
|
149
154
|
by: byCol && row[byCol] != null ? String(row[byCol]) : null,
|
|
150
155
|
source: streamSource(stream.from, table),
|
|
156
|
+
...(entryCol && (typeof row[entryCol] === 'string' || typeof row[entryCol] === 'number')
|
|
157
|
+
? { entry: { column: stream.reacts, value: row[entryCol] } }
|
|
158
|
+
: {}),
|
|
151
159
|
/* A column's value picks the tone, and a one-line row: the section's rules read each row's own columns,
|
|
152
160
|
where the stream says neither for all its rows. */
|
|
153
161
|
...(() => {
|
|
@@ -228,7 +236,13 @@ export function TimelineSection({ section, plan, base, recordKey }) {
|
|
|
228
236
|
atFoot.current = true;
|
|
229
237
|
scroller.scrollTop = scroller.scrollHeight;
|
|
230
238
|
}, [conversation, scroller, data.data]);
|
|
231
|
-
|
|
239
|
+
/* Reactions are counted for the entries on the page, once they are known: one read for all of them. */
|
|
240
|
+
const entries = [...new Set((data.data ?? []).flatMap((r) => (r.entry && !isEvent(r) ? [r.entry.value] : [])))];
|
|
241
|
+
const { tally, waiting } = useReactionTally(section.reactions, entries);
|
|
242
|
+
const reacted = section.reactions && tally ? { reactions: section.reactions, tally } : undefined;
|
|
243
|
+
/* Rows with reactions wait for them too, under the same skeleton: a row of kinds arriving later pushed every message
|
|
244
|
+
below it down. */
|
|
245
|
+
if (data.isPending || (sided && !sidesHere) || (section.reactions && (!reactionsHere || waiting)))
|
|
232
246
|
return _jsx(Loading, { section: section });
|
|
233
247
|
if (data.isError)
|
|
234
248
|
return _jsx(SectionBox, { section: section, body: null, foldable: false, broken: data.error.message });
|
|
@@ -267,7 +281,7 @@ export function TimelineSection({ section, plan, base, recordKey }) {
|
|
|
267
281
|
}, children: ["+ ", section.create.label] })] }));
|
|
268
282
|
/* The composer sends through the App's commands (TimelineComposer.tsx), drawn through the shell's slot. */
|
|
269
283
|
const { TimelineComposer } = shell().slots;
|
|
270
|
-
return (_jsx(SectionBox, { section: section, foldable: false, body: _jsxs(_Fragment, { children: [composeButton, rows.length ? (_jsx("div", { className: conversation ? 'timeline-scroll' : undefined, ...(conversation ? { 'data-scrolls': '' } : {}), ref: setScroller, children: _jsx("ol", { className: "timeline", children: byDay(rows).map(({ day, items }, d) => (_jsxs("li", { className: "timeline-day", children: [day && (_jsx("time", { className: "timeline-day-label", dateTime: day, children: formatDayHeading(day) })), _jsx("ol", { className: "timeline-rows", children: items.map((item, i) => Array.isArray(item) ? (_jsx(Fold, { rows: item, multi: multi, conversation: conversation }, `${item[0].when} ${item[0].table}`)) : (_jsx(Row, { r: item, multi: multi, conversation: conversation, continued: sided && runsOn(item, items[i - 1]) }, `${item.when} ${item.table}`))) })] }, day || d))) }) })) : (_jsx(Empty, { text: say('nothingDatedYetForThisRecord') })), section.composer && !preview && shell().inApp() && TimelineComposer && (_jsx(TimelineComposer, { composer: section.composer, recordKey: recordKey, table: base?.id, onSent: () => void queries.invalidateQueries({
|
|
284
|
+
return (_jsx(SectionBox, { section: section, foldable: false, body: _jsxs(_Fragment, { children: [composeButton, rows.length ? (_jsx("div", { className: conversation ? 'timeline-scroll' : undefined, ...(conversation ? { 'data-scrolls': '' } : {}), ref: setScroller, children: _jsx("ol", { className: "timeline", children: byDay(rows).map(({ day, items }, d) => (_jsxs("li", { className: "timeline-day", children: [day && (_jsx("time", { className: "timeline-day-label", dateTime: day, children: formatDayHeading(day) })), _jsx("ol", { className: "timeline-rows", children: items.map((item, i) => Array.isArray(item) ? (_jsx(Fold, { rows: item, multi: multi, conversation: conversation }, `${item[0].when} ${item[0].table}`)) : (_jsx(Row, { r: item, multi: multi, conversation: conversation, continued: sided && runsOn(item, items[i - 1]), reacted: reacted }, `${item.when} ${item.table}`))) })] }, day || d))) }) })) : (_jsx(Empty, { text: say('nothingDatedYetForThisRecord') })), section.composer && !preview && shell().inApp() && TimelineComposer && (_jsx(TimelineComposer, { composer: section.composer, recordKey: recordKey, table: base?.id, onSent: () => void queries.invalidateQueries({
|
|
271
285
|
predicate: (query) => ['page-list', 'page-timeline', 'page-metric', 'page-breakdown'].includes(String(query.queryKey[0])),
|
|
272
286
|
}) }))] }) }));
|
|
273
287
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
2
|
import { type TableMeta } from '@mistriwork/engine/shared/schema.js';
|
|
3
3
|
import type { TrailList } from '../recordTrail.js';
|
|
4
|
-
import type { GridData } from './Grid.js';
|
|
4
|
+
import type { GridData, GridGroup } from './Grid.js';
|
|
5
5
|
/**
|
|
6
6
|
* The columns a question holds to one value (`status = new`, a tab's own
|
|
7
7
|
* condition): every record the list shows says the same there, so a summary
|
|
@@ -28,7 +28,7 @@ export declare function linkTitleColumn(table: TableMeta, columns: string[], par
|
|
|
28
28
|
* fewer has the same one in two dresses.
|
|
29
29
|
*/
|
|
30
30
|
export declare function tableSaysMore(table: TableMeta, columns: string[], rows: Array<Record<string, unknown>>, query?: string, referenceLabels?: Record<string, string>): boolean;
|
|
31
|
-
export declare function RecordSummaries({ table, data, columns, labels, referenceLabels, list, recordForRow, query, parent, adornFact, }: {
|
|
31
|
+
export declare function RecordSummaries({ table, data, columns, labels, referenceLabels, list, recordForRow, query, parent, adornFact, group, }: {
|
|
32
32
|
table: TableMeta;
|
|
33
33
|
data: GridData;
|
|
34
34
|
columns: string[];
|
|
@@ -52,4 +52,6 @@ export declare function RecordSummaries({ table, data, columns, labels, referenc
|
|
|
52
52
|
* wraps, so anything wider arriving later would move the facts after it.
|
|
53
53
|
*/
|
|
54
54
|
adornFact?: (row: Record<string, unknown>, column: string) => ReactNode | undefined;
|
|
55
|
+
/** The rows' groups (a list view's `group`): a head where a run of one value begins, as the grid draws one. */
|
|
56
|
+
group?: GridGroup;
|
|
55
57
|
}): import("react").JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from 'react';
|
|
2
3
|
import { useMessageLanguage } from './useMessageLanguage.js';
|
|
3
4
|
import { columnLabel, keyOf, labelPath, openRecord, recordLabel, rowLabel, state } from '../core.js';
|
|
4
5
|
import { opensRecord } from '../recordIntent.js';
|
|
@@ -9,6 +10,7 @@ import { rowOpensTarget, useRowOpens } from './rowOpens.js';
|
|
|
9
10
|
import { presentationColumns } from './columnPresentation.js';
|
|
10
11
|
import { splitConditions, splitQuery } from '../clauses.js';
|
|
11
12
|
import { say } from '../copy/record/components/RecordSummaries.js';
|
|
13
|
+
import { formatNumber } from '../locale.js';
|
|
12
14
|
/**
|
|
13
15
|
* The columns a question holds to one value (`status = new`, a tab's own
|
|
14
16
|
* condition): every record the list shows says the same there, so a summary
|
|
@@ -89,7 +91,7 @@ export function tableSaysMore(table, columns, rows, query, referenceLabels) {
|
|
|
89
91
|
name !== naming &&
|
|
90
92
|
!rows.every((row, i) => shownValue(row, name, referenceLabels) === titles[i]));
|
|
91
93
|
}
|
|
92
|
-
export function RecordSummaries({ table, data, columns, labels, referenceLabels, list, recordForRow, query, parent, adornFact, }) {
|
|
94
|
+
export function RecordSummaries({ table, data, columns, labels, referenceLabels, list, recordForRow, query, parent, adornFact, group, }) {
|
|
93
95
|
useMessageLanguage();
|
|
94
96
|
const fixed = fixedColumns(query);
|
|
95
97
|
const linkTitle = linkTitleColumn(table, columns, [...fixed, ...(parent ? [parent] : [])], referenceLabels);
|
|
@@ -124,7 +126,11 @@ export function RecordSummaries({ table, data, columns, labels, referenceLabels,
|
|
|
124
126
|
const records = items.flatMap(({ key, label }) => (key ? [{ key, label }] : []));
|
|
125
127
|
const trail = opens ? {} : { records, list };
|
|
126
128
|
return (_jsx("ul", { className: "record-summaries", "aria-label": say('common.records'), children: items.map(({ row, key, label: title, opensTable }, index) => {
|
|
127
|
-
|
|
129
|
+
/* A grouped list's head, read as the grid's is: the value, its whole count and each subtotal by its caption. */
|
|
130
|
+
const head = group && (index === 0 || String(items[index - 1].row[group.column] ?? '\u0000') !== String(row[group.column] ?? '\u0000'))
|
|
131
|
+
? group.head(row[group.column])
|
|
132
|
+
: undefined;
|
|
133
|
+
const summary = (_jsxs("li", { className: `record-summary${key ? ' is-navigable' : ''}`, "data-opens": key ? opensRecord(opensTable ?? table.id, key) : undefined, onClick: (event) => {
|
|
128
134
|
// The title remains the keyboard target; nested controls own their clicks.
|
|
129
135
|
if (!key ||
|
|
130
136
|
event.target.closest('button, a, input, select, textarea, summary, [role="button"], [contenteditable="true"]'))
|
|
@@ -147,5 +153,8 @@ export function RecordSummaries({ table, data, columns, labels, referenceLabels,
|
|
|
147
153
|
const adorned = adornFact && (value === null || value === undefined || value === '') ? adornFact(row, name) : undefined;
|
|
148
154
|
return (_jsxs("div", { children: [_jsx("dt", { children: labels?.[name] ?? columnLabel(table.id, name) ?? humanName(name) }), _jsx("dd", { children: adorned ?? _jsx(Value, { tableId: table.id, col: label == null ? col : { ...col, type: 'TEXT' }, value: value, compact: true }) })] }, name));
|
|
149
155
|
}) })] }, key ? JSON.stringify(key) : index));
|
|
156
|
+
if (!head)
|
|
157
|
+
return summary;
|
|
158
|
+
return (_jsxs(Fragment, { children: [_jsxs("li", { className: "record-summary-group", children: [_jsx("span", { className: "record-summary-group-name", children: head.label }), head.count !== undefined && _jsx("span", { className: "record-summary-group-count", children: formatNumber(head.count) }), Object.entries(head.sums ?? {}).map(([name, figure]) => (_jsxs("span", { className: "record-summary-group-sum", children: [labels?.[name] ?? columnLabel(table.id, name) ?? humanName(name), ' ', _jsx(Value, { tableId: table.id, col: presentationColumns(state.schema, table, [name]).get(name), value: figure, compact: true })] }, name)))] }), summary] }, key ? JSON.stringify(key) : index));
|
|
150
159
|
}) }));
|
|
151
160
|
}
|