@mistriwork/kit 1.0.0-rc.14 → 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.
Files changed (58) hide show
  1. package/dist/client/app.js +2 -1
  2. package/dist/client/components/AppList.js +12 -1
  3. package/dist/client/components/Dressed.js +3 -0
  4. package/dist/client/components/Editable.js +3 -2
  5. package/dist/client/components/ErrorBoundary.js +1 -1
  6. package/dist/client/components/Grid.d.ts +15 -1
  7. package/dist/client/components/Grid.js +44 -7
  8. package/dist/client/components/NewRecord.d.ts +3 -1
  9. package/dist/client/components/NewRecord.js +16 -5
  10. package/dist/client/components/PageFlowDiagram.css +1 -1
  11. package/dist/client/components/PageTimeline.js +18 -4
  12. package/dist/client/components/RecordSummaries.d.ts +5 -3
  13. package/dist/client/components/RecordSummaries.js +11 -2
  14. package/dist/client/components/TableRoom.d.ts +4 -1
  15. package/dist/client/components/TableRoom.js +10 -5
  16. package/dist/client/components/TableView.d.ts +4 -2
  17. package/dist/client/components/TableView.js +3 -3
  18. package/dist/client/components/TimelineReactions.css +49 -0
  19. package/dist/client/components/TimelineReactions.d.ts +18 -0
  20. package/dist/client/components/TimelineReactions.js +58 -0
  21. package/dist/client/components/TreePicker.css +25 -0
  22. package/dist/client/components/TreePicker.d.ts +59 -0
  23. package/dist/client/components/TreePicker.js +407 -0
  24. package/dist/client/components/Value.js +33 -2
  25. package/dist/client/components/appListModel.d.ts +2 -0
  26. package/dist/client/components/chromeIcons.d.ts +1 -0
  27. package/dist/client/components/chromeIcons.js +1 -0
  28. package/dist/client/components/inputRenderers.d.ts +7 -1
  29. package/dist/client/components/inputRenderers.js +2 -0
  30. package/dist/client/components/pageModel.d.ts +4 -0
  31. package/dist/client/components/reactionTally.d.ts +20 -0
  32. package/dist/client/components/reactionTally.js +46 -0
  33. package/dist/client/components/useGridGroups.d.ts +11 -0
  34. package/dist/client/components/useGridGroups.js +70 -0
  35. package/dist/client/components/useGridKeyboard.d.ts +2 -0
  36. package/dist/client/components/useGridKeyboard.js +18 -1
  37. package/dist/client/components/valueModel.d.ts +10 -3
  38. package/dist/client/components/valueModel.js +21 -1
  39. package/dist/client/copy/forms/components/TreePicker.d.ts +9 -0
  40. package/dist/client/copy/forms/components/TreePicker.js +11 -0
  41. package/dist/client/copy/lists/components/Grid.d.ts +1 -1
  42. package/dist/client/copy/lists/components/Grid.js +1 -1
  43. package/dist/client/copy/lists/components/useGridGroups.d.ts +3 -0
  44. package/dist/client/copy/lists/components/useGridGroups.js +5 -0
  45. package/dist/client/copy/record/components/TimelineReactions.d.ts +7 -0
  46. package/dist/client/copy/record/components/TimelineReactions.js +6 -0
  47. package/dist/client/copy/record/components/Value.d.ts +3 -0
  48. package/dist/client/copy/record/components/Value.js +3 -0
  49. package/dist/client/copy/shell/components/ErrorBoundary.d.ts +1 -1
  50. package/dist/client/copy/shell/components/ErrorBoundary.js +1 -1
  51. package/dist/client/features.css +35 -1
  52. package/dist/client/index.html +1 -1
  53. package/dist/client/page.css +3 -2
  54. package/dist/client/shellHost.d.ts +1 -1
  55. package/dist/client/shellHost.js +1 -1
  56. package/dist/client/structure.css +11 -3
  57. package/dist/client/style.css +11 -2
  58. package/package.json +3 -3
@@ -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
- setTabTitle(say('common.documentTitle', { title: app ? app.name : state.schema.label }));
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,
@@ -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
- const followed = column.references || shownRule?.format === 'richText' || linkFor(column.name, shownValue, shownRule, true);
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('tablewalkASectionCould');
23
+ export const SECTION_ERROR = say('aSectionCouldNotBeDrawn');
24
24
  export class ErrorBoundary extends Component {
25
25
  state = { error: undefined, key: this.props.resetKey };
26
26
  static getDerivedStateFromError(error) {
@@ -67,6 +67,20 @@ interface GridProps {
67
67
  editCell?: (row: Row, column: string, draw: CellDraw, label?: unknown) => ReactNode | undefined;
68
68
  /** What the host draws in an empty cell in place of its empty mark (a suggestion waiting on it); undefined leaves the mark. One line: no row grows. */
69
69
  adornCell?: (row: Row, column: string) => ReactNode | undefined;
70
+ /** The rows' groups, where the list has them: the rows arrive in the group's order, and each run of one value is drawn under its head. */
71
+ group?: GridGroup;
72
+ }
73
+ /** What a group's head says: its value, in words; how many rows it holds; each `totals` column's subtotal. */
74
+ export interface GroupHead {
75
+ label: string;
76
+ /** Every row of the group the list's conditions match, not the page's; absent while it is counted. */
77
+ count?: number;
78
+ sums?: Record<string, unknown>;
79
+ }
80
+ /** A grid's groups (a list view's `group`): the column whose value each row stands under, and the head for a value. */
81
+ export interface GridGroup {
82
+ column: string;
83
+ head: (value: unknown) => GroupHead;
70
84
  }
71
85
  interface Plan {
72
86
  align: string;
@@ -118,5 +132,5 @@ interface CellColumn {
118
132
  label: string | undefined;
119
133
  }[];
120
134
  }
121
- export declare function Grid({ table, data, hide, labels, totals, totalsLabel, density, referenceLabels, sizing, interactive, virtual: mayVirtualise, onRowClick, list, current, emptyText, compact, firstRow, dropColumns, editCell, adornCell, }: GridProps): import("react").JSX.Element;
135
+ export declare function Grid({ table, data, hide, labels, totals, totalsLabel, density, referenceLabels, sizing, interactive, virtual: mayVirtualise, onRowClick, list, current, emptyText, compact, firstRow, dropColumns, editCell, adornCell, group, }: GridProps): import("react").JSX.Element;
122
136
  export {};
@@ -26,7 +26,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
26
26
  * column the reader placed, and another reader never sees it.
27
27
  */
28
28
  import { useMessageLanguage } from './useMessageLanguage.js';
29
- import { cloneElement, isValidElement, memo, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, } from 'react';
29
+ import { cloneElement, Fragment, isValidElement, memo, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, } from 'react';
30
30
  import { createColumnHelper, tableFeatures, useTable } from '@tanstack/react-table';
31
31
  import { useVirtualizer } from '@tanstack/react-virtual';
32
32
  import { columnDisplay, columnLabel, currentEntry, emptyWord, keyOf, openRecord, peekRecord, prefersPages, primaryKey, rowLabel, state, viewportBox, viewportScale, } from '../core.js';
@@ -46,6 +46,7 @@ import { hasChildren } from '../nested.js';
46
46
  import { openFilterMenu, sortBy } from '../thmenu.js';
47
47
  import { AppColumnMenuButton, useAppColumnMenu } from './AppColumnMenu.js';
48
48
  import { DetailRow, Expander } from './Nested.js';
49
+ import { Icon } from './Icon.js';
49
50
  import { createRowHosts, RowDecoration, RowHostScope, RowTrailScope, rowKeyString, useRowHostScope, useRowTrailScope, } from './RowHost.js';
50
51
  import { useGridKeyboard } from './useGridKeyboard.js';
51
52
  import { useChangedRows } from '../liveState.js';
@@ -76,6 +77,8 @@ const REFERENCE_MARK = '→';
76
77
  const HEAD_CONTROL = 24;
77
78
  /** A device that cannot hover keeps a head's caret and moves in the head's flow, beside its label (style.css). */
78
79
  const touchHeads = () => typeof matchMedia === 'function' && matchMedia('(hover: none)').matches;
80
+ /** A group's value as the folded set and the head's identity hold it: the rows with no value are one group. */
81
+ const groupKey = (value) => (value === null || value === undefined ? '\u0000' : String(value));
79
82
  /** Beyond a few hundred rows the DOM, not the database, is the bottleneck. */
80
83
  const VIRTUAL_THRESHOLD = 300;
81
84
  const OVERSCAN = 12;
@@ -394,7 +397,7 @@ function PlatformCell({ meta, plan, value, label, display, pin, edge, photo, wra
394
397
  }
395
398
  /* A vocabulary column that says where a row stands, kept when a narrow grid leaves columns out. */
396
399
  const STATUS_NAME = /(^|_)(status|state|stage|phase)$/i;
397
- export function Grid({ table, data, hide, labels, totals, totalsLabel = say('total'), density, referenceLabels, sizing = 'fit', interactive = true, virtual: mayVirtualise = true, onRowClick, list, current, emptyText, compact = false, firstRow = 0, dropColumns = false, editCell, adornCell, }) {
400
+ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('total'), density, referenceLabels, sizing = 'fit', interactive = true, virtual: mayVirtualise = true, onRowClick, list, current, emptyText, compact = false, firstRow = 0, dropColumns = false, editCell, adornCell, group, }) {
398
401
  const captionLanguage = useMessageLanguage();
399
402
  const wrap = useRef(null);
400
403
  const tableRef = useRef(null);
@@ -445,7 +448,13 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
445
448
  /* Rows another person just changed, tinted for a moment (liveState.ts, docs/design.md rule 11). */
446
449
  const changedRows = useChangedRows(table?.id, rows, (row) => (table ? keyOf(table, row) : null));
447
450
  const openable = useMemo(() => rowKeys.filter((key) => key !== null), [rowKeys]);
448
- const virtual = mayVirtualise && rows.length > VIRTUAL_THRESHOLD;
451
+ /* A grouped grid is drawn whole: its heads stand between rows, and the window's model is uniform rows. A list's page is
452
+ the most it holds. */
453
+ const virtual = mayVirtualise && rows.length > VIRTUAL_THRESHOLD && !group;
454
+ /* The groups the reader folded, by value: kept across a page turn, so a group folded on one page stays folded on the
455
+ next it continues on. */
456
+ const [shutGroups, setShutGroups] = useState(() => new Set());
457
+ const foldedRow = useCallback((index) => Boolean(group) && shutGroups.has(groupKey(rows[index]?.[group.column])), [group, shutGroups, rows]);
449
458
  /* Not where rows open as pages: the expander is the explorer's way of
450
459
  seeing what points at a row, and an app's list gets that on the page
451
460
  the row opens as. Nor on a windowed table: an opened detail is many
@@ -502,7 +511,9 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
502
511
  };
503
512
  setHeadFace((was) => (was && was.font === next.font && was.upper === next.upper && was.tracking === next.tracking ? was : next));
504
513
  }
505
- const cells = [...element.querySelectorAll('tbody tr:first-child > td')];
514
+ /* A group's head is not a row of values: the first row that is one is sampled. */
515
+ const first = element.querySelector('tbody tr:not(.grid-group-head)');
516
+ const cells = first ? [...first.querySelectorAll(':scope > td')] : [];
506
517
  if (cells.length) {
507
518
  const fonts = cells.map((cell) => {
508
519
  const font = getComputedStyle(cell);
@@ -511,7 +522,7 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
511
522
  setCellFonts((was) => (was.join('|') === fonts.join('|') ? was : fonts));
512
523
  /* The widest chip of the sampled rows, not the first row's: a look may draw a neutral state as a bare word
513
524
  and the rest as pills, and sized by a first-row "Ready" Sage cut every "In review" pill to "In rev…". */
514
- const rows = [...element.querySelectorAll('tbody tr')].slice(0, GRID_SIZE_SAMPLE);
525
+ const rows = [...element.querySelectorAll('tbody tr:not(.grid-group-head)')].slice(0, GRID_SIZE_SAMPLE);
515
526
  const chips = cells.map((_, index) => {
516
527
  let extra = -1;
517
528
  for (const row of rows) {
@@ -927,6 +938,7 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
927
938
  onPeek: keyed ? (index) => peekRow(rows[index]) : undefined,
928
939
  totalRows: data.exactTotal === false || data.cappedTotal ? undefined : data.total,
929
940
  firstRow,
941
+ ...(group ? { skip: foldedRow } : {}),
930
942
  });
931
943
  /* Whatever the column clipped gets its whole value on hover, decided at hover time, once, from its own overflow:
932
944
  the cell, or the line inside it that cuts its own text (a row's name over its detail, a lead mark's body, a
@@ -1099,13 +1111,26 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
1099
1111
  height: `${padTop}px`,
1100
1112
  padding: 0,
1101
1113
  border: 'none',
1102
- } }) })), shown.map((i) => {
1114
+ } }) })), shown.map((i, at) => {
1103
1115
  const row = modelRows[i];
1104
1116
  if (!row)
1105
1117
  return null;
1106
1118
  const key = rowKeys[i];
1107
1119
  const open = expandable && key !== null && expanded.has(key);
1108
- return (_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}`));
1120
+ const drawn = (_jsx(Row, { index: i, rowKey: key, slot: slotted, hostRef: key === null ? undefined : hosts.ref(key), trail: trailing, trailRef: key === null || !trailHosts ? undefined : trailHosts.ref(key), record: row.original, navigable: navigable, opensPage: navigable && !onRowClick && !opens, onOpen: openOne, open: open, current: key !== null && key === currentKey, changed: changedRows.get(row.original), table: table, colSpan: colSpan, columns: cellColumns, editCell: editCell, adornCell: adornCell }, key === null ? `at:${i}` : `key:${key}`));
1121
+ if (!group)
1122
+ return drawn;
1123
+ /* A head where a run of one value begins: the first row drawn, or one whose group the row above is not. */
1124
+ const value = row.original[group.column];
1125
+ const named = groupKey(value);
1126
+ const starts = at === 0 || groupKey(modelRows[shown[at - 1]]?.original[group.column]) !== named;
1127
+ const shut = shutGroups.has(named);
1128
+ return (_jsxs(Fragment, { children: [starts && (_jsx(GroupHeadRow, { head: group.head(value), folded: shut, onToggle: () => setShutGroups((was) => {
1129
+ const next = new Set(was);
1130
+ if (!next.delete(named))
1131
+ next.add(named);
1132
+ return next;
1133
+ }), slot: slotted, trail: trailing, columns: ordered, table: table })), shut ? null : drawn] }, key === null ? `at:${i}` : `key:${key}`));
1109
1134
  }), virtual && (_jsx("tr", { className: "virtual-spacer", "aria-hidden": "true", children: _jsx("td", { colSpan: colSpan, style: {
1110
1135
  height: `${padBottom}px`,
1111
1136
  padding: 0,
@@ -1119,6 +1144,18 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
1119
1144
  }), trailing && _jsx("td", {})] }) }))] }), expandable &&
1120
1145
  openable.map((key) => (_jsx(RowDecoration, { rowKey: key, store: hosts, children: _jsx(Expander, { open: expanded.has(key), onToggle: () => toggle(key) }) }, key))), virtual && _jsx("p", { className: "note virtual-note", children: say('rowsDrawnAsYouScroll', { count: rows.length }) }), !rows.length && _jsx("p", { className: "note grid-empty", children: emptyText })] }));
1121
1146
  }
1147
+ /**
1148
+ * A group's head (a list view's `group`): a hairline row, not a box, that says the value, how many rows it holds and,
1149
+ * under each `totals` column, its subtotal — the breakdown's figures, so a group a page divides is counted whole. The
1150
+ * value is a button that folds the group's rows away and opens them again.
1151
+ */
1152
+ function GroupHeadRow({ head, folded, onToggle, slot, trail, columns, table, }) {
1153
+ const sums = head.sums ?? {};
1154
+ /* The value spans the columns before the first subtotal, so each figure stands under the column it sums. */
1155
+ const first = columns.findIndex((name) => Object.hasOwn(sums, name));
1156
+ const lead = first < 0 ? columns.length : Math.max(1, first);
1157
+ return (_jsxs("tr", { className: `grid-group-head${folded ? ' is-folded' : ''}`, children: [slot && _jsx("td", { className: "expander-cell" }), _jsx("td", { colSpan: lead, className: "grid-group-cell", children: _jsxs("button", { type: "button", className: "grid-group-toggle", "aria-expanded": !folded, onClick: onToggle, children: [_jsx(Icon, { name: folded ? 'caret-right' : 'caret-down', size: 14, className: "grid-group-caret" }), _jsx("span", { className: "grid-group-name", children: head.label }), head.count !== undefined && _jsx("span", { className: "grid-group-count", children: formatNumber(head.count) })] }) }), columns.slice(lead).map((name) => Object.hasOwn(sums, name) ? (_jsx("td", { className: "align-right num grid-group-sum", children: _jsx(TotalValue, { value: sums[name], display: columnDisplay(table?.id, name) }) }, name)) : (_jsx("td", {}, name))), trail && _jsx("td", {})] }));
1158
+ }
1122
1159
  /**
1123
1160
  * One row, and its detail row when it is open. The leading cell, when the
1124
1161
  * grid draws one, is the row's host: React never gives it children of its
@@ -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
- multiline: dress(column)?.multiline,
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 > .tw-icon { flex: none; }
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
- if (data.isPending || (sided && !sidesHere))
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 { 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