@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.
Files changed (79) hide show
  1. package/dist/client/app.js +2 -1
  2. package/dist/client/components/AppList.js +12 -1
  3. package/dist/client/components/ChartFigure.d.ts +3 -2
  4. package/dist/client/components/ChartFigure.js +7 -5
  5. package/dist/client/components/Dressed.js +3 -0
  6. package/dist/client/components/Editable.js +3 -2
  7. package/dist/client/components/ErrorBoundary.js +1 -1
  8. package/dist/client/components/Grid.d.ts +15 -1
  9. package/dist/client/components/Grid.js +44 -7
  10. package/dist/client/components/JsonView.d.ts +2 -1
  11. package/dist/client/components/JsonView.js +2 -2
  12. package/dist/client/components/NewRecord.d.ts +3 -1
  13. package/dist/client/components/NewRecord.js +16 -5
  14. package/dist/client/components/PageCurrent.d.ts +10 -1
  15. package/dist/client/components/PageCurrent.js +10 -6
  16. package/dist/client/components/PageFields.js +14 -3
  17. package/dist/client/components/PageFlowDiagram.css +1 -1
  18. package/dist/client/components/PageHead.js +10 -9
  19. package/dist/client/components/PageHeadline.d.ts +3 -1
  20. package/dist/client/components/PageHeadline.js +3 -2
  21. package/dist/client/components/PageMetrics.js +13 -4
  22. package/dist/client/components/PageRelated.js +17 -2
  23. package/dist/client/components/PageSectionBox.js +6 -3
  24. package/dist/client/components/PageSections.js +1 -1
  25. package/dist/client/components/PageTimeline.js +44 -17
  26. package/dist/client/components/RecordSummaries.d.ts +5 -3
  27. package/dist/client/components/RecordSummaries.js +11 -2
  28. package/dist/client/components/TableRoom.d.ts +4 -1
  29. package/dist/client/components/TableRoom.js +10 -5
  30. package/dist/client/components/TableView.d.ts +4 -2
  31. package/dist/client/components/TableView.js +3 -3
  32. package/dist/client/components/TimelineReactions.css +49 -0
  33. package/dist/client/components/TimelineReactions.d.ts +18 -0
  34. package/dist/client/components/TimelineReactions.js +58 -0
  35. package/dist/client/components/TreePicker.css +25 -0
  36. package/dist/client/components/TreePicker.d.ts +59 -0
  37. package/dist/client/components/TreePicker.js +407 -0
  38. package/dist/client/components/Value.d.ts +2 -0
  39. package/dist/client/components/Value.js +67 -7
  40. package/dist/client/components/appListModel.d.ts +2 -0
  41. package/dist/client/components/chromeIcons.d.ts +1 -0
  42. package/dist/client/components/chromeIcons.js +1 -0
  43. package/dist/client/components/dashboardModel.d.ts +2 -2
  44. package/dist/client/components/inputRenderers.d.ts +7 -1
  45. package/dist/client/components/inputRenderers.js +2 -0
  46. package/dist/client/components/jsonModel.d.ts +3 -0
  47. package/dist/client/components/jsonModel.js +8 -0
  48. package/dist/client/components/pageContext.js +2 -1
  49. package/dist/client/components/pageModel.d.ts +14 -5
  50. package/dist/client/components/reactionTally.d.ts +20 -0
  51. package/dist/client/components/reactionTally.js +46 -0
  52. package/dist/client/components/useGridGroups.d.ts +11 -0
  53. package/dist/client/components/useGridGroups.js +70 -0
  54. package/dist/client/components/useGridKeyboard.d.ts +2 -0
  55. package/dist/client/components/useGridKeyboard.js +18 -1
  56. package/dist/client/components/valueModel.d.ts +10 -3
  57. package/dist/client/components/valueModel.js +21 -1
  58. package/dist/client/copy/forms/components/TreePicker.d.ts +9 -0
  59. package/dist/client/copy/forms/components/TreePicker.js +11 -0
  60. package/dist/client/copy/lists/components/Grid.d.ts +1 -1
  61. package/dist/client/copy/lists/components/Grid.js +1 -1
  62. package/dist/client/copy/lists/components/useGridGroups.d.ts +3 -0
  63. package/dist/client/copy/lists/components/useGridGroups.js +5 -0
  64. package/dist/client/copy/record/components/PageTimeline.d.ts +1 -0
  65. package/dist/client/copy/record/components/PageTimeline.js +1 -0
  66. package/dist/client/copy/record/components/TimelineReactions.d.ts +7 -0
  67. package/dist/client/copy/record/components/TimelineReactions.js +6 -0
  68. package/dist/client/copy/record/components/Value.d.ts +3 -0
  69. package/dist/client/copy/record/components/Value.js +3 -0
  70. package/dist/client/copy/shell/components/ErrorBoundary.d.ts +1 -1
  71. package/dist/client/copy/shell/components/ErrorBoundary.js +1 -1
  72. package/dist/client/features.css +37 -1
  73. package/dist/client/index.html +1 -1
  74. package/dist/client/page.css +33 -4
  75. package/dist/client/shellHost.d.ts +1 -1
  76. package/dist/client/shellHost.js +1 -1
  77. package/dist/client/structure.css +18 -3
  78. package/dist/client/style.css +11 -2
  79. package/package.json +4 -4
@@ -59,7 +59,7 @@ export function wasShown(row, figure, was) {
59
59
  const [then, now] = [Number(row[was]), Number(row[figure])];
60
60
  return Number.isFinite(then) && Number.isFinite(now) && then > now;
61
61
  }
62
- export function PageHeadline({ tableId, row, paths, column, actions, subfigure, was, note }) {
62
+ export function PageHeadline({ tableId, row, paths, column, actions, subfigure, subtitle, was, note }) {
63
63
  useMessageLanguage();
64
64
  const caption = (path) => columnLabel(tableId, path) ?? humanName(path.split('.').pop() ?? path);
65
65
  const [figure, ...facts] = paths;
@@ -88,9 +88,10 @@ export function PageHeadline({ tableId, row, paths, column, actions, subfigure,
88
88
  });
89
89
  const [asking, setAsking] = useState(null);
90
90
  const second = subfigure !== undefined && hasValue(row[subfigure]);
91
+ const line = subtitle !== undefined && hasValue(row[subtitle]);
91
92
  const earlier = wasShown(row, figure, was);
92
93
  const shownFacts = facts.filter((path) => hasValue(row[path]));
93
- return (_jsxs("div", { className: "page-headline", children: [figure !== undefined && (_jsxs("p", { className: "page-headline-figure", children: [_jsxs("span", { className: "visually-hidden", children: [caption(figure), ": "] }), _jsx(Value, { col: column(figure), value: row[figure], tableId: tableId, compact: true, row: row }), earlier && (_jsxs(_Fragment, { children: [' ', _jsxs("s", { className: "page-headline-was", children: [_jsxs("span", { className: "visually-hidden", children: [caption(was), ": "] }), _jsx(Value, { col: column(was), value: row[was], tableId: tableId, compact: true })] })] }))] })), second && (_jsxs("p", { className: "page-headline-sub", children: [_jsx("span", { className: "page-headline-sub-caption", children: caption(subfigure) }), ' ', _jsx(Value, { col: column(subfigure), value: row[subfigure], tableId: tableId, compact: true })] })), links.some(Boolean) && (_jsx("div", { className: "page-headline-actions", children: links.map((entry, index) => !entry ? null : 'action' in entry && entry.action ? (TargetAction && (_jsx(TargetAction, { label: entry.action.label, to: entry.action.to, row: row, className: `page-headline-action is-${entry.kind}` }, index))) : (_jsx("a", { className: `page-headline-action is-${entry.kind}`, href: entry.link.href, onClick: entry.dialog
94
+ return (_jsxs("div", { className: "page-headline", children: [figure !== undefined && (_jsxs("p", { className: "page-headline-figure", children: [_jsxs("span", { className: "visually-hidden", children: [caption(figure), ": "] }), _jsx(Value, { col: column(figure), value: row[figure], tableId: tableId, compact: true, row: row, subtitled: true }), earlier && (_jsxs(_Fragment, { children: [' ', _jsxs("s", { className: "page-headline-was", children: [_jsxs("span", { className: "visually-hidden", children: [caption(was), ": "] }), _jsx(Value, { col: column(was), value: row[was], tableId: tableId, compact: true })] })] })), line && (_jsx("span", { className: "page-headline-subtitle", children: _jsx(Value, { col: column(subtitle), value: row[subtitle], tableId: tableId, compact: true }) }))] })), second && (_jsxs("p", { className: "page-headline-sub", children: [_jsx("span", { className: "page-headline-sub-caption", children: caption(subfigure) }), ' ', _jsx(Value, { col: column(subfigure), value: row[subfigure], tableId: tableId, compact: true })] })), links.some(Boolean) && (_jsx("div", { className: "page-headline-actions", children: links.map((entry, index) => !entry ? null : 'action' in entry && entry.action ? (TargetAction && (_jsx(TargetAction, { label: entry.action.label, to: entry.action.to, row: row, className: `page-headline-action is-${entry.kind}` }, index))) : (_jsx("a", { className: `page-headline-action is-${entry.kind}`, href: entry.link.href, onClick: entry.dialog
94
95
  ? (event) => {
95
96
  if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0)
96
97
  return;
@@ -15,7 +15,7 @@ import { presentationColumns } from './columnPresentation.js';
15
15
  import { humanName } from '@mistriwork/engine/shared/model.js';
16
16
  import { andQuery } from '@mistriwork/engine/shared/query.js';
17
17
  import { formatNumber } from '../locale.js';
18
- import { inAppPage, PageRenderContext, usePageApi } from './pageContext.js';
18
+ import { inAppPage, PageRenderContext, spoken, usePageApi } from './pageContext.js';
19
19
  import { Loading, SectionBox } from './PageSectionBox.js';
20
20
  import { dressFor, groupLabel, withUnit } from './valueModel.js';
21
21
  import { barShare, CurrencyFigures, EXACT, figureSayer, namedGroups, orderGroups, sayer } from './dashboardModel.js';
@@ -71,7 +71,7 @@ export function MetricSection({ section, plan }) {
71
71
  figures, and a loading bar of another height moved every section under
72
72
  the row when they came (test/built-client-vitals.mjs). */
73
73
  if (reading.isPending)
74
- return (_jsx(SectionBox, { section: section, foldable: false, body: _jsxs("button", { type: "button", className: "page-metric-value", disabled: true, tabIndex: -1, "aria-hidden": "true", style: { visibility: 'hidden' }, children: [_jsx("span", { className: "metric-number", children: "0" }), _jsx("span", { className: "metric-of", children: section.title ? '' : section.from })] }) }));
74
+ return (_jsx(SectionBox, { section: section, foldable: false, body: _jsxs("button", { type: "button", className: "page-metric-value", disabled: true, tabIndex: -1, "aria-hidden": "true", style: { visibility: 'hidden' }, children: [_jsx("span", { className: "metric-number", children: "0" }), _jsx("span", { className: "metric-of", children: section.title ? '' : spoken(section.from ?? '') })] }) }));
75
75
  if (reading.isError)
76
76
  return _jsx(SectionBox, { section: section, body: null, foldable: false, broken: reading.error.message });
77
77
  let aggregate;
@@ -109,7 +109,7 @@ export function MetricSection({ section, plan }) {
109
109
  const said = value === '—' ? value : dress?.text ? withUnit(dress.text, unit) : figureSayer(rule, unit, EXACT)(value);
110
110
  return (_jsx(SectionBox, { section: section, foldable: false, body: _jsxs("button", { type: "button", className: "page-metric-value", disabled: !open, title: open
111
111
  ? sayCopy('openTheThisCounted', { from: section.from ?? '' })
112
- : sayCopy('thisCountCannotBeReopened', { from: section.from ?? '' }), onClick: open ?? undefined, children: [_jsx("span", { className: "metric-number", children: said }), _jsx("span", { className: "metric-of", children: section.title ? '' : section.from })] }) }));
112
+ : sayCopy('thisCountCannotBeReopened', { from: section.from ?? '' }), onClick: open ?? undefined, children: [_jsx("span", { className: "metric-number", children: said }), _jsx("span", { className: "metric-of", children: section.title ? '' : spoken(section.from ?? '') })] }) }));
113
113
  }
114
114
  /** Groups of related rows, biggest first: the "mostly what?" answer. */
115
115
  export function BreakdownSection({ section, plan, base }) {
@@ -124,6 +124,8 @@ export function BreakdownSection({ section, plan, base }) {
124
124
  enabled: !plan.empty && Boolean(plan.breakdown),
125
125
  staleTime: 0,
126
126
  });
127
+ if (section.emptyMode === 'hide' && plan.empty)
128
+ return null;
127
129
  if (plan.empty) {
128
130
  /* Said as the reader would: which reference is unset, not a column's name. */
129
131
  const reference = section.of
@@ -150,6 +152,8 @@ export function BreakdownSection({ section, plan, base }) {
150
152
  /* The grouped column read through its path, so `campaign_id.kind` finds the vocabulary of the campaign's kind. */
151
153
  const allowed = presentationColumns(state.schema, findTable(section.from), [section.by ?? '']).get(section.by ?? '')?.allowed;
152
154
  const rows = orderGroups(got.rows, keyName, countName, allowed);
155
+ if (!rows.length && section.emptyMode === 'hide')
156
+ return null;
153
157
  // A table's name ("campaign_member") is the Workbench's vocabulary, not an
154
158
  // App reader's; a breakdown's title names groups, so it cannot be reused.
155
159
  if (!rows.length)
@@ -201,6 +205,9 @@ export function ChartSection({ section, plan, base }) {
201
205
  enabled: !plan.empty && Boolean(plan.breakdown),
202
206
  staleTime: 0,
203
207
  });
208
+ /* `empty: 'hide'`: a chart with nothing to draw leaves the page, as a related list does. */
209
+ if (section.emptyMode === 'hide' && plan.empty)
210
+ return null;
204
211
  if (plan.empty) {
205
212
  const reference = section.of
206
213
  ? inAppPage()
@@ -218,6 +225,8 @@ export function ChartSection({ section, plan, base }) {
218
225
  const got = data.data;
219
226
  if (!got || 'errors' in got)
220
227
  return (_jsx(SectionBox, { section: section, body: null, foldable: false, broken: (got && 'errors' in got ? got.errors[0]?.message : undefined) ?? sayCopy('thisChartCouldNotBeRead') }));
228
+ if (section.emptyMode === 'hide' && !got.rows.length)
229
+ return null;
221
230
  const from = section.from ?? '';
222
231
  /* Each key's column, its period dropped: "month issued_on" is labelled as issued_on is. */
223
232
  const [first = '', second = ''] = (section.by ?? '').split(',').map((key) => key.trim().split(/\s+/).pop() ?? '');
@@ -248,5 +257,5 @@ export function ChartSection({ section, plan, base }) {
248
257
  go(tableView(plan.breakdown.base, `${plan.breakdown.base} ${where}`), 'push');
249
258
  }
250
259
  : null;
251
- return (_jsx(SectionBox, { section: section, foldable: false, body: _jsx(ChartFigure, { answer: drawn, arrange: section.sort === 'value' ? 'value' : plan.breakdown.orderBy?.[0]?.name === 'value' ? undefined : 'answer', shape: section.shape, limit: section.limit, target: section.target, height: section.height, say: say, label: namedGroups(got, got.columns[0], firstLabel.say), seriesLabel: namedGroups(got, second ? got.columns[1] : undefined, labelFor(second).say), vocabulary: firstLabel.allowed, onPick: drill, empty: inAppPage() ? sayCopy('nothingToDrawYet') : sayCopy('noForThisRecord', { from }) }) }));
260
+ return (_jsx(SectionBox, { section: section, foldable: false, body: _jsx(ChartFigure, { answer: drawn, arrange: section.sort === 'value' ? 'value' : plan.breakdown.orderBy?.[0]?.name === 'value' ? undefined : 'answer', shape: section.shape, limit: section.limit, target: section.target, curve: section.curve, total: section.total, height: section.height, say: say, label: namedGroups(got, got.columns[0], firstLabel.say), seriesLabel: namedGroups(got, second ? got.columns[1] : undefined, labelFor(second).say), vocabulary: firstLabel.allowed, onPick: drill, empty: inAppPage() ? sayCopy('nothingToDrawYet') : sayCopy('noForThisRecord', { from }) }) }));
252
261
  }
@@ -12,7 +12,7 @@ import { ownedBy } from '../requestIdentity.js';
12
12
  import { columnLabel, recordLabel, api as coreApi, findTable, openRecord, rowLabel, state, writeAllowed } from '../core.js';
13
13
  import { relatedRows } from '../prefs.js';
14
14
  import { formatBytes, formatNumber, formatRelativeDay } from '../locale.js';
15
- import { columnKind } from '@mistriwork/engine/shared/schema.js';
15
+ import { columnKind, linkTarget } from '@mistriwork/engine/shared/schema.js';
16
16
  import { recordViewKey, recordViewLabel, withoutParent, withoutParentName } from '@mistriwork/engine/shared/referenceModel.js';
17
17
  import { groupsBody, listView } from '@mistriwork/engine/shared/recordReads.js';
18
18
  import { GROUP_ROWS_DEFAULT, GROUPS_DEFAULT } from '@mistriwork/engine/shared/pageModel.js';
@@ -264,7 +264,22 @@ function RelatedList({ section, plan, base, recordKey, onEdit, collapsed }) {
264
264
  const noun = (app ? (resourceOf(table)?.noun?.one ?? recordNoun(undefined, table.name)) : table.name).toLocaleLowerCase();
265
265
  const shown = (got.columns ?? []).filter((name) => !hidden.includes(name));
266
266
  const record = rows[0] ? recordForRow(rows[0]) : undefined;
267
- return (_jsx("section", { className: `${sectionClass(section)} page-card-section`, children: _jsx(CurrentCard, { table: table, caption: section.title, row: rows[0], columns: shown, show: Array.isArray(section.columns) ? section.columns : undefined, referenceLabels: labelColumns, labels: section.labels, record: record, title: record && app ? cardTitle(record.label, recordName) : undefined, noun: noun,
267
+ /* A card over a link table opens, and is named by, the record its far reference names: "Conversation 12", not the
268
+ link row that holds the two (linkTarget). */
269
+ const farColumn = linkTarget(table, section.path ?? '', section.opens);
270
+ const farReference = farColumn ? table.columns.find((column) => column.name === farColumn)?.references : undefined;
271
+ const farTable = farReference ? findTable(farReference.table) : undefined;
272
+ const farValue = rows[0] && farColumn ? rows[0][farColumn] : undefined;
273
+ const far = farColumn && farReference && farTable && farValue !== null && farValue !== undefined && farValue !== ''
274
+ ? {
275
+ table: farTable,
276
+ column: farColumn,
277
+ key: { [farReference.column]: farValue },
278
+ label: String(rows[0][labelColumns[farColumn] ?? ''] ?? farValue),
279
+ noun: (app ? (resourceOf(farTable)?.noun?.one ?? recordNoun(undefined, farTable.name)) : farTable.name).toLocaleLowerCase(),
280
+ }
281
+ : undefined;
282
+ return (_jsx("section", { className: `${sectionClass(section)} page-card-section`, children: _jsx(CurrentCard, { table: table, caption: section.title, row: rows[0], columns: shown, show: Array.isArray(section.columns) ? section.columns : undefined, referenceLabels: labelColumns, labels: section.labels, record: record, opens: far, title: far ? cardTitle(far.label, recordName) : record && app ? cardTitle(record.label, recordName) : undefined, noun: noun,
268
283
  /* Said with the record's noun, never the title: a title is a heading, not a noun ("In the shop now" said
269
284
  "No in the shop now right now."). */
270
285
  empty: authoredEmpty ?? _jsx(Empty, { text: say('noRightNow', { thing: noun }) }) }) }));
@@ -12,6 +12,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
12
  import { useContext, useEffect, useRef } from 'react';
13
13
  import { disclosure, findTable } from '../core.js';
14
14
  import { GridSkeleton } from './Skeleton.js';
15
+ import { Icon } from './Icon.js';
15
16
  import { sectionClass } from './pageModel.js';
16
17
  import { PageRenderContext, spoken } from './pageContext.js';
17
18
  import { useMessageLanguage } from './useMessageLanguage.js';
@@ -21,6 +22,8 @@ import { say } from '../copy/record/components/PageSectionBox.js';
21
22
  /* A suggested page titles a related list by its table's name (`visit_attachment`), which an App says as words, as
22
23
  every untitled list's head already is. An authored title has words or capitals of its own and is left as written. */
23
24
  const titled = (title) => (/^[a-z][a-z0-9_.]*$/.test(title) ? spoken(title) : title);
25
+ /** A section's mark leading its heading. A note draws its own over its words, so it has none here. */
26
+ const mark = (section) => section.icon && section.kind !== 'note' ? _jsx(Icon, { name: section.icon, size: 16, className: "dash-section-icon" }) : null;
24
27
  /** A section's box: its heading, or a fold when it is a later group of fields. */
25
28
  export function SectionBox({ section, body, foldable, broken, crashed, hidden, tools, }) {
26
29
  useMessageLanguage();
@@ -49,7 +52,7 @@ export function SectionBox({ section, body, foldable, broken, crashed, hidden, t
49
52
  return (_jsxs("section", { className: `${sectionClass(section)} page-broken`, children: [_jsx("h2", { className: "page-section-head", children: heading || say('thisSection') }), crashed ?? _jsx(Problem, { text: broken ?? '' })] }));
50
53
  }
51
54
  if (foldable && heading) {
52
- return (_jsx("section", { className: sectionClass(section), children: _jsxs("details", { className: "page-fold", ref: details, open: true, children: [_jsx("summary", { className: "page-section-head page-fold-head", children: _jsx("span", { children: heading }) }), content] }) }));
55
+ return (_jsx("section", { className: sectionClass(section), children: _jsxs("details", { className: "page-fold", ref: details, open: true, children: [_jsx("summary", { className: "page-section-head page-fold-head", children: _jsxs("span", { children: [mark(section), heading] }) }), content] }) }));
53
56
  }
54
57
  /* A gallery is a picture: its title names it for assistive technology,
55
58
  and a "Photos" heading over the photos says nothing a sighted reader
@@ -57,9 +60,9 @@ export function SectionBox({ section, body, foldable, broken, crashed, hidden, t
57
60
  const gallery = section.kind === 'list' && section.presentation === 'gallery';
58
61
  /* An embedded list view's heading is the way to the whole of it: the view's own room, where the reader has it. */
59
62
  const room = section.view && !preview ? navigate?.(section.view) : undefined;
60
- const headed = heading && (_jsx("h2", { className: gallery ? 'page-section-head visually-hidden' : 'page-section-head', children: room ? (_jsx("a", { className: "page-section-link", ...room, children: heading })) : (heading) }));
63
+ const headed = heading && (_jsxs("h2", { className: gallery ? 'page-section-head visually-hidden' : 'page-section-head', children: [mark(section), room ? (_jsx("a", { className: "page-section-link", ...room, children: heading })) : (heading)] }));
61
64
  return (_jsxs("section", { className: `${sectionClass(section)}${gallery ? ' page-gallery' : ''}`, hidden: hidden || undefined, children: [tools ? (_jsxs("div", { className: "page-section-bar", children: [headed, tools] })) : (headed), content] }));
62
65
  }
63
66
  export function Loading({ section }) {
64
- return (_jsxs("section", { className: `${sectionClass(section)} loading`, children: [section.title && _jsx("h2", { className: "page-section-head", children: titled(section.title) }), section.kind === 'list' ? _jsx(GridSkeleton, { columns: 4, rows: 3 }) : _jsx("div", { className: "sk-bar" })] }));
67
+ return (_jsxs("section", { className: `${sectionClass(section)} loading`, children: [section.title && (_jsxs("h2", { className: "page-section-head", children: [mark(section), titled(section.title)] })), section.kind === 'list' ? _jsx(GridSkeleton, { columns: 4, rows: 3 }) : _jsx("div", { className: "sk-bar" })] }));
65
68
  }
@@ -273,7 +273,7 @@ export function Sections({ page, base, recordKey: key, plans, entry, onLabel, on
273
273
  an empty list is neither hidden nor collapsed, its tab shows it and the strip already folds it. */
274
274
  const tabbed = (section) => section.kind === 'list' && section.presentation !== 'gallery' && (section.width === undefined || !inAppPage());
275
275
  /* Outside a strip, such a list is left out or said in one line with its neighbours (PageEmptyRun.tsx). */
276
- const emptyable = (section) => section.kind === 'list' && Boolean(section.emptyMode) && section.presentation !== 'card';
276
+ const emptyable = (section) => section.kind === 'list' && Boolean(section.emptyMode) && (section.presentation !== 'card' || section.emptyMode === 'hide');
277
277
  /* Where a tab holds nothing but such lists, it never ends up with nothing. */
278
278
  const onlyEmptyable = items.length > 0 && items.every(({ section }) => emptyable(section));
279
279
  for (let i = 0; i < items.length; i += 1) {
@@ -6,7 +6,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
6
6
  * the same related-create plan and form a related list uses.
7
7
  */
8
8
  import { useContext, useId, useLayoutEffect, useRef, useState } from 'react';
9
- import { useQuery, useQueryClient } from '@tanstack/react-query';
9
+ import { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query';
10
10
  import { findTable, labelPath, state } from '../core.js';
11
11
  import { shell } from '../shellMode.js';
12
12
  import { resourceOf } from './appRooms.js';
@@ -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,13 @@ 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 } : {};
70
+ const body = _jsx("div", { className: "timeline-text prose", children: words });
69
71
  if (isEvent(r))
70
72
  return (_jsxs("li", { className: "timeline-row is-compact", "data-timeline-row": true, ...tone, children: [_jsx("span", { className: "timeline-text", children: words }), _jsx(When, { at: r.when })] }));
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 })] }));
73
+ return (_jsxs("li", { className: `timeline-row${r.tone ? ' is-tinted' : ''}${r.other ? ' is-other' : ''}${continued ? ' is-continued' : ''}`, "data-timeline-row": true, ...tone, children: [r.by && !continued ? (_jsx("span", { className: `timeline-avatar avatar avatar-c${hueOf(r.by)}`, "aria-hidden": "true", children: initialsOf(r.by) })) : (_jsx("span", { className: "timeline-avatar", "aria-hidden": "true" })), !r.by && body, _jsxs("span", { className: "timeline-head", children: [r.by && (continued ? _jsx("span", { className: "visually-hidden", children: r.by }) : _jsx("span", { className: "timeline-by", children: r.by })), r.detail != null && (_jsx("span", { className: "timeline-kind", children: _jsx(Value, { tableId: r.table, col: r.detailColumn, value: r.detail, compact: true }) })), multi && _jsx("span", { className: "timeline-source", children: r.source }), _jsx(When, { at: r.when })] }), r.by && body, reacted && r.entry && _jsx(Reactions, { reactions: reacted.reactions, entry: r.entry, tally: reacted.tally })] }));
72
74
  }
73
75
  /** Two or more events in a row, said as their count and opened in place. */
74
76
  function Fold({ rows, multi, conversation }) {
@@ -79,10 +81,13 @@ function Fold({ rows, multi, conversation }) {
79
81
  /** The record's activity as one stream, merged newest-first (or, as a conversation, oldest-first) across its streams. */
80
82
  /* 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
83
  const Sides = onDemand(() => import('./TimelineSides.js'), 'TimelineSides', { quiet: true });
84
+ /* An entry's reactions, a part of their own with their stylesheet: only a section with `reactions` asks for it. */
85
+ const Reactions = onDemand(() => import('./TimelineReactions.js'), 'ReactionRow', { quiet: true });
82
86
  export function TimelineSection({ section, plan, base, recordKey }) {
83
87
  /* Rows with sides wait for their dress, under the section's one skeleton, so nothing moves when it comes. */
84
88
  const sided = Boolean(section.side || section.streams?.some((stream) => stream.side));
85
89
  const sidesHere = useArrived(Sides, sided);
90
+ const reactionsHere = useArrived(Reactions, Boolean(section.reactions));
86
91
  const api = usePageApi();
87
92
  const { preview, isCurrent, openRelated } = useContext(PageRenderContext);
88
93
  const queries = useQueryClient();
@@ -97,9 +102,16 @@ export function TimelineSection({ section, plan, base, recordKey }) {
97
102
  const atFoot = useRef(true);
98
103
  /* A row's line and detail are values of their stream's table, dressed by its display rules and drawn by its
99
104
  value components as a grid cell is; `table` is whose rules they are. */
105
+ /* "Show more" asks for another `limit` rows of every stream, on demand: the first page is the rows the page's
106
+ plan already asked, so a section nobody opens further costs no more than before. */
107
+ const step = section.limit ?? 20;
108
+ const [pages, setPages] = useState(1);
100
109
  const data = useQuery({
101
- queryKey: ['page-timeline', plan.streams, section.limit, section.tone, section.compact, section.streams],
110
+ queryKey: ['page-timeline', plan.streams, section.limit, section.tone, section.compact, section.streams, pages],
111
+ /* The rows already drawn stay while the next page comes, so the list does not blank or jump. */
112
+ placeholderData: keepPreviousData,
102
113
  queryFn: async () => {
114
+ let streamMore = false;
103
115
  const answers = await Promise.all(streams.map(async (stream, s) => {
104
116
  /* The stream as authored: its own tone and compact stand over the section's rules. */
105
117
  const own = section.streams?.[s];
@@ -118,13 +130,15 @@ export function TimelineSection({ section, plan, base, recordKey }) {
118
130
  if (stream.side?.error)
119
131
  throw new Error(stream.side.error);
120
132
  const asked = timelineReads({ table: (id) => findTable(id), namePath: (target) => labelPath(target) }, stream);
121
- const view = asked.view;
133
+ const view = pages > 1 ? { ...asked.view, limit: step * pages } : asked.view;
122
134
  const named = asked.view !== stream.view ? asked.view.columns?.at(-1)?.path : undefined;
123
135
  const byPath = named ?? stream.by;
124
136
  const others = asked.side ? api('/api/view/run', { view: asked.side, offset: 0 }) : undefined;
125
137
  const [got, otherRows] = await Promise.all([api('/api/view/run', { view, offset: 0 }), others]);
126
138
  if (!('view' in got))
127
139
  throw new Error(got.errors[0]?.message ?? say('thisActivityStreamCould'));
140
+ if (got.more)
141
+ streamMore = true;
128
142
  if (otherRows && !('view' in otherRows))
129
143
  throw new Error(otherRows.errors[0]?.message ?? say('thisActivityStreamCould'));
130
144
  const keyOf = (row, names, cols) => JSON.stringify(stream.key.map((column) => row[cols[names.indexOf(column)] ?? column] ?? null));
@@ -133,21 +147,25 @@ export function TimelineSection({ section, plan, base, recordKey }) {
133
147
  const names = (view.columns ?? []).map((c) => c.path);
134
148
  const cols = got.columns ?? names;
135
149
  const atCol = cols[names.indexOf(stream.at)] ?? stream.at;
136
- const showCol = cols[names.indexOf(stream.show)] ?? stream.show;
137
- const detailCol = stream.detail ? (cols[names.indexOf(stream.detail)] ?? stream.detail) : null;
150
+ const showCol = cols[names.indexOf(stream.text)] ?? stream.text;
151
+ const detailCol = stream.badge ? (cols[names.indexOf(stream.badge)] ?? stream.badge) : null;
138
152
  const byCol = byPath ? (cols[names.indexOf(byPath)] ?? byPath) : null;
139
153
  const markCol = (name) => cols[names.indexOf(name)] ?? name;
140
- const shown = table && listColumn(table, stream.show);
141
- const detailed = table && stream.detail ? listColumn(table, stream.detail) : undefined;
154
+ const entryCol = stream.reacts ? markCol(stream.reacts) : undefined;
155
+ const shown = table && listColumn(table, stream.text);
156
+ const detailed = table && stream.badge ? listColumn(table, stream.badge) : undefined;
142
157
  return got.rows.map((row) => ({
143
158
  when: row[atCol] == null ? '' : String(row[atCol]),
144
159
  text: row[showCol] ?? null,
145
- ...(shown ? { textColumn: { ...shown, name: stream.show } } : {}),
160
+ ...(shown ? { textColumn: { ...shown, name: stream.text } } : {}),
146
161
  detail: detailCol && row[detailCol] != null && row[detailCol] !== '' ? row[detailCol] : null,
147
- ...(detailed ? { detailColumn: { ...detailed, name: stream.detail } } : {}),
162
+ ...(detailed ? { detailColumn: { ...detailed, name: stream.badge } } : {}),
148
163
  table: table?.id ?? stream.from,
149
164
  by: byCol && row[byCol] != null ? String(row[byCol]) : null,
150
165
  source: streamSource(stream.from, table),
166
+ ...(entryCol && (typeof row[entryCol] === 'string' || typeof row[entryCol] === 'number')
167
+ ? { entry: { column: stream.reacts, value: row[entryCol] } }
168
+ : {}),
151
169
  /* A column's value picks the tone, and a one-line row: the section's rules read each row's own columns,
152
170
  where the stream says neither for all its rows. */
153
171
  ...(() => {
@@ -164,11 +182,11 @@ export function TimelineSection({ section, plan, base, recordKey }) {
164
182
  })(),
165
183
  }));
166
184
  }));
167
- return answers
185
+ const merged = answers
168
186
  .flat()
169
187
  .filter((r) => r.when)
170
- .sort((a, b) => (a.when < b.when ? 1 : a.when > b.when ? -1 : 0))
171
- .slice(0, section.limit ?? 20);
188
+ .sort((a, b) => (a.when < b.when ? 1 : a.when > b.when ? -1 : 0));
189
+ return { rows: merged.slice(0, step * pages), more: streamMore || merged.length > step * pages };
172
190
  },
173
191
  staleTime: 0,
174
192
  });
@@ -228,11 +246,17 @@ export function TimelineSection({ section, plan, base, recordKey }) {
228
246
  atFoot.current = true;
229
247
  scroller.scrollTop = scroller.scrollHeight;
230
248
  }, [conversation, scroller, data.data]);
231
- if (data.isPending || (sided && !sidesHere))
249
+ /* Reactions are counted for the entries on the page, once they are known: one read for all of them. */
250
+ const entries = [...new Set((data.data?.rows ?? []).flatMap((r) => (r.entry && !isEvent(r) ? [r.entry.value] : [])))];
251
+ const { tally, waiting } = useReactionTally(section.reactions, entries);
252
+ const reacted = section.reactions && tally ? { reactions: section.reactions, tally } : undefined;
253
+ /* Rows with reactions wait for them too, under the same skeleton: a row of kinds arriving later pushed every message
254
+ below it down. */
255
+ if (data.isPending || (sided && !sidesHere) || (section.reactions && (!reactionsHere || waiting)))
232
256
  return _jsx(Loading, { section: section });
233
257
  if (data.isError)
234
258
  return _jsx(SectionBox, { section: section, body: null, foldable: false, broken: data.error.message });
235
- const rows = conversation ? [...(data.data ?? [])].reverse() : (data.data ?? []);
259
+ const rows = conversation ? [...(data.data?.rows ?? [])].reverse() : (data.data?.rows ?? []);
236
260
  /* A message names its stream only where the messages come from more than one: a conversation whose second stream
237
261
  is all quiet lines (time logged) said "Activity" over every message, a word that told the reader nothing. */
238
262
  const multi = new Set(rows.filter((r) => !isEvent(r)).map((r) => r.source)).size > 1;
@@ -267,7 +291,10 @@ export function TimelineSection({ section, plan, base, recordKey }) {
267
291
  }, children: ["+ ", section.create.label] })] }));
268
292
  /* The composer sends through the App's commands (TimelineComposer.tsx), drawn through the shell's slot. */
269
293
  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({
294
+ /* Older rows come in place: above a conversation (its oldest is at the top), below a feed. The button holds its row
295
+ whether or not it is working, so nothing moves under the pointer. */
296
+ const showMore = data.data?.more && (_jsx("div", { className: "timeline-more", children: _jsx("button", { type: "button", className: "ghost", disabled: data.isPlaceholderData, onClick: () => setPages(pages + 1), children: say('showMore') }) }));
297
+ return (_jsx(SectionBox, { section: section, foldable: false, body: _jsxs(_Fragment, { children: [composeButton, conversation && showMore, rows.length ? (_jsx("div", { className: conversation ? 'timeline-scroll' : undefined, ...(conversation ? { 'data-scrolls': '' } : {}), ref: setScroller, children: _jsx("ol", { className: "timeline", children: byDay(rows).map(({ day, items }, d) => (_jsxs("li", { className: "timeline-day", children: [day && (_jsx("time", { className: "timeline-day-label", dateTime: day, children: formatDayHeading(day) })), _jsx("ol", { className: "timeline-rows", children: items.map((item, i) => Array.isArray(item) ? (_jsx(Fold, { rows: item, multi: multi, conversation: conversation }, `${item[0].when} ${item[0].table}`)) : (_jsx(Row, { r: item, multi: multi, conversation: conversation, continued: sided && runsOn(item, items[i - 1]), reacted: reacted }, `${item.when} ${item.table}`))) })] }, day || d))) }) })) : (_jsx(Empty, { text: say('nothingDatedYetForThisRecord') })), !conversation && showMore, section.composer && !preview && shell().inApp() && TimelineComposer && (_jsx(TimelineComposer, { composer: section.composer, recordKey: recordKey, table: base?.id, onSent: () => void queries.invalidateQueries({
271
298
  predicate: (query) => ['page-list', 'page-timeline', 'page-metric', 'page-breakdown'].includes(String(query.queryKey[0])),
272
299
  }) }))] }) }));
273
300
  }
@@ -1,7 +1,7 @@
1
- import type { ReactNode } from 'react';
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
- return (_jsxs("li", { className: `record-summary${key ? ' is-navigable' : ''}`, "data-opens": key ? opensRecord(opensTable ?? table.id, key) : undefined, onClick: (event) => {
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
  }
@@ -22,6 +22,7 @@
22
22
  import { type ReactNode } from 'react';
23
23
  import type { TableMeta } from '@mistriwork/engine/shared/schema.js';
24
24
  import type { ResourceHttpSuccess } from '@mistriwork/engine/shared/resourceHttp.js';
25
+ import type { GridGroup } from './Grid.js';
25
26
  import { type TableEntry, type TableViewProps } from './TableView.js';
26
27
  type RunData = ResourceHttpSuccess<'/api/run'>;
27
28
  interface TableRoomProps {
@@ -50,6 +51,8 @@ interface TableRoomProps {
50
51
  referenceLabels?: Record<string, string>;
51
52
  /** Column → its total over the whole query; undefined while it is asked. */
52
53
  totals?: Record<string, unknown>;
54
+ /** The rows' groups (a list view's `group`): read in the group's order, each run under its head (useGridGroups.ts). */
55
+ group?: GridGroup;
53
56
  density?: 'comfortable' | 'compact';
54
57
  /** A ⋯ menu at the end of each row with the record's own actions. */
55
58
  rowActions?: boolean;
@@ -66,7 +69,7 @@ interface TableRoomProps {
66
69
  /** The answer, once it has rows and columns. */
67
70
  onResult?: (data: RunData) => void;
68
71
  }
69
- export declare function TableRoom({ entry, chrome, inset, interactive, hide, labels, referenceLabels, totals, density, rowActions, editable, inCrumbs, sizing, export: exportOn, summaries, embedded, version, onResult, presentation, present, actions, listLabel, order, recordNavigation, empty, }: TableRoomProps): import("react").JSX.Element;
72
+ export declare function TableRoom({ entry, chrome, inset, interactive, hide, labels, referenceLabels, totals, group, density, rowActions, editable, inCrumbs, sizing, export: exportOn, summaries, embedded, version, onResult, presentation, present, actions, listLabel, order, recordNavigation, empty, }: TableRoomProps): import("react").JSX.Element;
70
73
  /**
71
74
  * A refusal in the reader's words. An API's refusal quotes columns as the API
72
75
  * names them (`carrier_id`) and lists which (`columns`); an App calls them by
@@ -20,7 +20,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
20
20
  * is a grid embedded in someone else's surface — an app list, a dashboard
21
21
  * section, a page's chooser — and touches nothing but its own box.
22
22
  */
23
- import { useEffect } from 'react';
23
+ import { useEffect, useMemo } from 'react';
24
24
  import { useQuery } from '@tanstack/react-query';
25
25
  import { $, api, columnLabel, findTable, go, pageSize, setExplain, showErrors, state, tableView } from '../core.js';
26
26
  import { explicitLimit } from '../clauses.js';
@@ -35,6 +35,7 @@ import { onDemand, useArrived } from './onDemand.js';
35
35
  import { FilterBar } from './FilterBoxes.js';
36
36
  import { Delayed, GridSkeleton } from './Skeleton.js';
37
37
  import { Problem, Refused } from './Notes.js';
38
+ import { groupedQuestion } from '@mistriwork/engine/shared/listQuestion.js';
38
39
  import { GridCellEdit, isApiConnection, TableView, ViewTabs } from './TableView.js';
39
40
  import { pageStepFor, stepList } from './pageStep.js';
40
41
  import { ExportHold } from './ExportHold.js';
@@ -73,7 +74,7 @@ const thingOf = (entry, table) => {
73
74
  return kind === 'row' || (kind === 'page' && named) ? say('thingRecord') : table ? say('thingList') : say('thingPage');
74
75
  };
75
76
  const connection = () => state.activeConnection ?? '';
76
- export function TableRoom({ entry, chrome = true, inset = chrome, interactive = true, hide, labels, referenceLabels, totals, density, rowActions, editable, inCrumbs, sizing, export: exportOn = true, summaries = false, embedded = false, version = 0, onResult, presentation, present, actions, listLabel, order, recordNavigation = false, empty, }) {
77
+ export function TableRoom({ entry, chrome = true, inset = chrome, interactive = true, hide, labels, referenceLabels, totals, group, density, rowActions, editable, inCrumbs, sizing, export: exportOn = true, summaries = false, embedded = false, version = 0, onResult, presentation, present, actions, listLabel, order, recordNavigation = false, empty, }) {
77
78
  /* A tab this reader cannot have here falls back to Rows: Definition and API
78
79
  are the operator's, API only over an API, and an API's definition is its
79
80
  description, so it has no Definition tab. */
@@ -94,7 +95,7 @@ export function TableRoom({ entry, chrome = true, inset = chrome, interactive =
94
95
  if (bar)
95
96
  bar.value = entry.query;
96
97
  }, [chrome, entry.query]);
97
- return (_jsxs(_Fragment, { children: [chrome && (_jsx("div", { className: "grid-host", children: _jsx(ViewTabs, { entry: entry }) })), chrome && tab === 'rows' && _jsx(FilterSection, { entry: entry }, entry.query), _jsx("div", { className: inset ? 'grid-inset' : undefined, children: tab === 'diagram' ? (_jsx("div", { className: "panel-pad", children: _jsx("div", { className: "diagram", children: _jsx(NeighbourhoodDiagram, { tableId: entry.table }) }) })) : tab === 'api' ? (_jsx(ApiOperations, { table: entry.table })) : tab === 'ddl' ? (_jsx(DdlPane, { table: entry.table })) : (_jsx(Rows, { entry: entry, chrome: chrome, interactive: interactive, hide: hide, labels: labels, referenceLabels: referenceLabels, totals: totals, density: density, rowActions: rowActions, editable: editable, inCrumbs: inCrumbs, sizing: sizing, exportOn: exportOn, summaries: summaries, embedded: embedded, version: version, onResult: onResult, presentation: presentation, present: present, actions: actions, listLabel: listLabel, order: order, recordNavigation: recordNavigation, empty: empty })) })] }));
98
+ return (_jsxs(_Fragment, { children: [chrome && (_jsx("div", { className: "grid-host", children: _jsx(ViewTabs, { entry: entry }) })), chrome && tab === 'rows' && _jsx(FilterSection, { entry: entry }, entry.query), _jsx("div", { className: inset ? 'grid-inset' : undefined, children: tab === 'diagram' ? (_jsx("div", { className: "panel-pad", children: _jsx("div", { className: "diagram", children: _jsx(NeighbourhoodDiagram, { tableId: entry.table }) }) })) : tab === 'api' ? (_jsx(ApiOperations, { table: entry.table })) : tab === 'ddl' ? (_jsx(DdlPane, { table: entry.table })) : (_jsx(Rows, { entry: entry, chrome: chrome, interactive: interactive, hide: hide, labels: labels, referenceLabels: referenceLabels, totals: totals, group: group, density: density, rowActions: rowActions, editable: editable, inCrumbs: inCrumbs, sizing: sizing, exportOn: exportOn, summaries: summaries, embedded: embedded, version: version, onResult: onResult, presentation: presentation, present: present, actions: actions, listLabel: listLabel, order: order, recordNavigation: recordNavigation, empty: empty })) })] }));
98
99
  }
99
100
  const escaped = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
100
101
  /**
@@ -146,7 +147,11 @@ function keepTotal(key, reply) {
146
147
  listTotals.delete(listTotals.keys().next().value);
147
148
  listTotals.set(key, { total, ...(exactTotal !== undefined ? { exactTotal } : {}), ...(cappedTotal ? { cappedTotal } : {}) });
148
149
  }
149
- function Rows({ entry, chrome, interactive, hide, labels, referenceLabels, totals, density, rowActions, editable, inCrumbs, sizing, exportOn, summaries, embedded, version, onResult, presentation, present, actions, listLabel, order, recordNavigation, empty, }) {
150
+ function Rows({ entry: given, chrome, interactive, hide, labels, referenceLabels, totals, group, density, rowActions, editable, inCrumbs, sizing, exportOn, summaries, embedded, version, onResult, presentation, present, actions, listLabel, order, recordNavigation, empty, }) {
151
+ /* A grouped list's rows are read in the group's order, each group's together under its head: said to the read and
152
+ the pager that steps it, while the walk keeps the reader's own question (a header's sort writes that). */
153
+ const groupedQuery = group ? groupedQuestion(given.query, group.column) : given.query;
154
+ const entry = useMemo(() => (groupedQuery === given.query ? given : { ...given, query: groupedQuery }), [given, groupedQuery]);
150
155
  const table = findTable(entry.table);
151
156
  /* An explicit `limit` in the query is a deliberate statement and beats the page size. */
152
157
  const asked = explicitLimit(entry.query);
@@ -230,7 +235,7 @@ function Rows({ entry, chrome, interactive, hide, labels, referenceLabels, total
230
235
  /* Not over a question that failed: its error says why there are no rows. */
231
236
  if (empty && !run.isPlaceholderData && data.rows.length === 0 && page === 0 && !data.errors?.length)
232
237
  return _jsx(_Fragment, { children: empty });
233
- return (_jsxs(_Fragment, { children: [held.held ? _jsx(LivePill, { held: held.held, show: held.show }) : null, _jsx(TableView, { entry: entry, data: data, chrome: chrome, interactive: interactive, hide: hide, labels: labels, referenceLabels: referenceLabels, totals: totals, density: density, rowActions: rowActions, editable: editable, inCrumbs: inCrumbs, sizing: sizing, export: exportOn, summaries: summaries, embedded: embedded, presentation: presentation, present: present, actions: actions, listLabel: listLabel, order: order, recordNavigation: recordNavigation, at: askedFor.get(data) ?? { page, size }, busy: run.isPlaceholderData })] }));
238
+ return (_jsxs(_Fragment, { children: [held.held ? _jsx(LivePill, { held: held.held, show: held.show }) : null, _jsx(TableView, { entry: entry, data: data, chrome: chrome, interactive: interactive, hide: hide, labels: labels, referenceLabels: referenceLabels, totals: totals, group: group, density: density, rowActions: rowActions, editable: editable, inCrumbs: inCrumbs, sizing: sizing, export: exportOn, summaries: summaries, embedded: embedded, presentation: presentation, present: present, actions: actions, listLabel: listLabel, order: order, recordNavigation: recordNavigation, at: askedFor.get(data) ?? { page, size }, busy: run.isPlaceholderData })] }));
234
239
  }
235
240
  /** The table's definition: the statement the database keeps, or one rebuilt from its catalog. */
236
241
  function DdlPane({ table }) {
@@ -1,5 +1,5 @@
1
1
  import { type TableMeta } from '@mistriwork/engine/shared/schema.js';
2
- import { type GridData } from './Grid.js';
2
+ import { type GridData, type GridGroup } from './Grid.js';
3
3
  import { trailListFor } from '../recordTrail.js';
4
4
  import { type ReactNode } from 'react';
5
5
  import { type ListOrder } from './useListOrder.js';
@@ -79,6 +79,8 @@ export interface TableViewProps {
79
79
  referenceLabels?: Record<string, string>;
80
80
  /** Column → its total over the whole query, for the grid's footer. */
81
81
  totals?: Record<string, unknown>;
82
+ /** The rows' groups, each run of one value under its head (Grid.tsx `group`). */
83
+ group?: GridGroup;
82
84
  density?: 'comfortable' | 'compact';
83
85
  /** A ⋯ menu at the end of each row with the record's own actions. */
84
86
  rowActions?: boolean;
@@ -108,4 +110,4 @@ export interface PageAt {
108
110
  export declare function ViewTabs({ entry }: {
109
111
  entry: TableEntry;
110
112
  }): import("react").JSX.Element;
111
- export declare function TableView({ entry, data, chrome, interactive, hide, labels, referenceLabels, totals, density, rowActions, editable, inCrumbs, sizing, export: exportOn, summaries, embedded, presentation, present, actions, listLabel, order, recordNavigation, at: given, busy, }: TableViewProps): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal>;
113
+ export declare function TableView({ entry, data, chrome, interactive, hide, labels, referenceLabels, totals, group, density, rowActions, editable, inCrumbs, sizing, export: exportOn, summaries, embedded, presentation, present, actions, listLabel, order, recordNavigation, at: given, busy, }: TableViewProps): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal>;
@@ -203,7 +203,7 @@ function PageBox({ page, last, onGo }) {
203
203
  onGo(Math.round(asked) - 1);
204
204
  } }));
205
205
  }
206
- export function TableView({ entry, data, chrome, interactive, hide, labels, referenceLabels, totals, density, rowActions, editable, inCrumbs, sizing, export: exportOn = true, summaries = false, embedded = false, presentation, present, actions, listLabel, order, recordNavigation = false, at: given, busy = false, }) {
206
+ export function TableView({ entry, data, chrome, interactive, hide, labels, referenceLabels, totals, group, density, rowActions, editable, inCrumbs, sizing, export: exportOn = true, summaries = false, embedded = false, presentation, present, actions, listLabel, order, recordNavigation = false, at: given, busy = false, }) {
207
207
  /* Records or table: how a narrow screen shows the rows, the reader's pick. The page's own list draws the switch at
208
208
  the end of its control strip (AppList), beside the tabs; anywhere else, over the rows. */
209
209
  const [layout, setLayout] = useState('records');
@@ -312,7 +312,7 @@ export function TableView({ entry, data, chrome, interactive, hide, labels, refe
312
312
  leading cell for a reader offered bulk actions, a grip there for a view
313
313
  kept in hand order, a ⋯ at the end of each row when the view asks for
314
314
  row menus. */
315
- const gridOf = (rows) => (_jsx(Grid, { table: table, data: rows === data.rows ? data : { ...data, rows }, hide: hide, labels: labels, referenceLabels: referenceLabels, totals: totals, density: density, sizing: sizing, interactive: interactive, firstRow: firstRow, list: list, current: current, dropColumns: embedded || beside, editCell: editCell, ...(adornCell ? { adornCell } : {}) }));
315
+ const gridOf = (rows) => (_jsx(Grid, { table: table, data: rows === data.rows ? data : { ...data, rows }, hide: hide, labels: labels, referenceLabels: referenceLabels, totals: totals, ...(group ? { group } : {}), density: density, sizing: sizing, interactive: interactive, firstRow: firstRow, list: list, current: current, dropColumns: embedded || beside, editCell: editCell, ...(adornCell ? { adornCell } : {}) }));
316
316
  const hasOrder = Boolean(listOrder && table);
317
317
  const ordered = hasOrder && listOrder && table ? (_jsx(GridOrder, { table: table, rows: data.rows, order: listOrder, interactive: interactive, children: gridOf })) : (gridOf(data.rows));
318
318
  const selected = table && selectableGrid(table, actions ?? [], interactive, editing) ? (_jsxs(RowHosts, { children: [_jsx(GridSelection, { table: table, rows: data.rows, actions: actions ?? [], interactive: interactive, editable: editing }), ordered] })) : !hasOrder ? (ordered) : (_jsx(RowHosts, { children: ordered }));
@@ -320,5 +320,5 @@ export function TableView({ entry, data, chrome, interactive, hide, labels, refe
320
320
  const tableGrid = rowActions && (interactive || embedded) && table && actions?.some((action) => action.header !== false) && primaryKey(table).length ? (_jsxs(RowTrailHosts, { children: [_jsx(RowActions, { table: table, rows: data.rows, actions: actions, onDone: () => render() }), selected] })) : (selected);
321
321
  return (_jsxs(_Fragment, { children: [_jsx(ResultHead, { entry: entry, data: data, chrome: chrome, interactive: interactive, exportOn: exportOn, at: at, headRef: head, inCrumbs: inCrumbs }), _jsxs("div", { className: hasSummaries ? `responsive-results show-${embedded || !choice ? 'records' : layout}` : undefined, children: [hasSummaries && (_jsxs(_Fragment, { children: [!embedded &&
322
322
  choice &&
323
- presentationSwitch(_jsx(PresentationSwitch, { layout: layout, onChange: setLayout, label: say('common.listPresentation'), records: say('common.records'), table: say('common.table') })), _jsx(RecordSummaries, { table: table, data: data, columns: (data.columns ?? []).filter((name) => !hide?.includes(name)), labels: labels, referenceLabels: referenceLabels, list: list, query: entry.query, ...(adornCell ? { adornFact: (row, column) => adornCell(row, column, 'summary') } : {}) })] })), _jsx("div", { className: "result-table", "aria-busy": busy || undefined, children: tableGrid })] }), _jsx(Pager, { entry: entry, data: data, at: at, range: inCrumbs })] }));
323
+ presentationSwitch(_jsx(PresentationSwitch, { layout: layout, onChange: setLayout, label: say('common.listPresentation'), records: say('common.records'), table: say('common.table') })), _jsx(RecordSummaries, { table: table, data: data, columns: (data.columns ?? []).filter((name) => !hide?.includes(name)), labels: labels, referenceLabels: referenceLabels, list: list, query: entry.query, ...(group ? { group } : {}), ...(adornCell ? { adornFact: (row, column) => adornCell(row, column, 'summary') } : {}) })] })), _jsx("div", { className: "result-table", "aria-busy": busy || undefined, children: tableGrid })] }), _jsx(Pager, { entry: entry, data: data, at: at, range: inCrumbs })] }));
324
324
  }