@mistriwork/kit 1.0.0-rc.17 → 1.0.0-rc.18

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 (99) hide show
  1. package/dist/client/components/AppList.js +16 -6
  2. package/dist/client/components/Chart.css +5 -0
  3. package/dist/client/components/Chart.d.ts +17 -2
  4. package/dist/client/components/Chart.js +83 -22
  5. package/dist/client/components/ChartFigure.d.ts +3 -1
  6. package/dist/client/components/ChartFigure.js +14 -8
  7. package/dist/client/components/Content.js +3 -1
  8. package/dist/client/components/DashHead.d.ts +6 -0
  9. package/dist/client/components/DashHead.js +20 -0
  10. package/dist/client/components/Editable.js +1 -1
  11. package/dist/client/components/Grid.js +33 -4
  12. package/dist/client/components/JsonPreview.css +29 -0
  13. package/dist/client/components/JsonPreview.js +1 -1
  14. package/dist/client/components/JsonView.css +201 -62
  15. package/dist/client/components/JsonView.d.ts +43 -1
  16. package/dist/client/components/JsonView.js +320 -55
  17. package/dist/client/components/LayoutSwitch.d.ts +9 -0
  18. package/dist/client/components/LayoutSwitch.js +61 -0
  19. package/dist/client/components/ListEmpty.css +3 -0
  20. package/dist/client/components/LiveNotices.css +3 -0
  21. package/dist/client/components/NewRecord.d.ts +0 -2
  22. package/dist/client/components/NewRecord.js +61 -17
  23. package/dist/client/components/PageFields.js +22 -3
  24. package/dist/client/components/PageHead.js +26 -6
  25. package/dist/client/components/PageRelated.d.ts +28 -0
  26. package/dist/client/components/PageRelated.js +50 -3
  27. package/dist/client/components/PageSectionBox.d.ts +5 -1
  28. package/dist/client/components/PageSectionBox.js +5 -3
  29. package/dist/client/components/PageSections.js +26 -13
  30. package/dist/client/components/PageSkeleton.css +2 -0
  31. package/dist/client/components/PageSkeleton.js +11 -3
  32. package/dist/client/components/Palette.js +108 -10
  33. package/dist/client/components/RecordPicker.d.ts +2 -0
  34. package/dist/client/components/RecordPicker.js +34 -8
  35. package/dist/client/components/RecordSummaries.js +6 -1
  36. package/dist/client/components/Rooms.js +2 -2
  37. package/dist/client/components/TableRoom.js +15 -5
  38. package/dist/client/components/TableView.d.ts +2 -0
  39. package/dist/client/components/Value.js +1 -1
  40. package/dist/client/components/appListModel.d.ts +4 -0
  41. package/dist/client/components/appRooms.d.ts +2 -0
  42. package/dist/client/components/appRooms.js +2 -0
  43. package/dist/client/components/dashboardModel.d.ts +5 -0
  44. package/dist/client/components/directoryModel.d.ts +25 -0
  45. package/dist/client/components/directoryModel.js +88 -0
  46. package/dist/client/components/gridSizing.d.ts +3 -0
  47. package/dist/client/components/gridSizing.js +6 -2
  48. package/dist/client/components/jsonTree.d.ts +54 -0
  49. package/dist/client/components/jsonTree.js +190 -0
  50. package/dist/client/components/listSubtitles.d.ts +1 -0
  51. package/dist/client/components/listSubtitles.js +7 -0
  52. package/dist/client/components/newMenuModel.d.ts +14 -6
  53. package/dist/client/components/newMenuModel.js +37 -5
  54. package/dist/client/components/newRecordModel.d.ts +24 -2
  55. package/dist/client/components/newRecordModel.js +47 -4
  56. package/dist/client/components/pageContext.d.ts +2 -0
  57. package/dist/client/components/pageModel.d.ts +2 -0
  58. package/dist/client/components/sidebarModel.js +7 -3
  59. package/dist/client/composedReads.js +3 -1
  60. package/dist/client/copy/lists/components/AppList.d.ts +1 -0
  61. package/dist/client/copy/lists/components/AppList.js +1 -0
  62. package/dist/client/copy/lists/components/LayoutSwitch.d.ts +4 -0
  63. package/dist/client/copy/lists/components/LayoutSwitch.js +6 -0
  64. package/dist/client/copy/record/components/JsonView.d.ts +22 -0
  65. package/dist/client/copy/record/components/JsonView.js +19 -0
  66. package/dist/client/copy/record/components/PageHead.d.ts +1 -0
  67. package/dist/client/copy/record/components/PageHead.js +2 -0
  68. package/dist/client/copy/shell/components/Palette.d.ts +11 -0
  69. package/dist/client/copy/shell/components/Palette.js +14 -0
  70. package/dist/client/copy/shell/components/TopNav.d.ts +2 -1
  71. package/dist/client/copy/shell/components/TopNav.js +4 -2
  72. package/dist/client/copy/shell/components/directoryModel.d.ts +4 -0
  73. package/dist/client/copy/shell/components/directoryModel.js +6 -0
  74. package/dist/client/copy/shell/components/sidebarModel.d.ts +1 -0
  75. package/dist/client/copy/shell/components/sidebarModel.js +1 -0
  76. package/dist/client/core.d.ts +3 -3
  77. package/dist/client/core.js +6 -7
  78. package/dist/client/features.css +67 -7
  79. package/dist/client/index.html +2 -1
  80. package/dist/client/insert.js +1 -8
  81. package/dist/client/locale.d.ts +7 -0
  82. package/dist/client/locale.js +0 -0
  83. package/dist/client/lumenLook.css +9 -12
  84. package/dist/client/page.css +56 -15
  85. package/dist/client/palette.d.ts +3 -1
  86. package/dist/client/palette.js +19 -4
  87. package/dist/client/paletteRecents.d.ts +25 -0
  88. package/dist/client/paletteRecents.js +64 -0
  89. package/dist/client/partsLook.css +6 -3
  90. package/dist/client/sageLook.css +5 -3
  91. package/dist/client/shellMode.d.ts +2 -0
  92. package/dist/client/shellMode.js +1 -0
  93. package/dist/client/structure.css +201 -1
  94. package/dist/client/style.css +59 -10
  95. package/dist/client/themeFamilies.css +37 -0
  96. package/dist/client/visualThemes.css +12 -0
  97. package/dist/client/workbenchLook.css +415 -0
  98. package/dist/client/workshopLook.css +48 -25
  99. package/package.json +4 -3
@@ -39,9 +39,9 @@ import { Dropdown, readsAsName } from './Dropdown.js';
39
39
  import { RecordPicker } from './RecordPicker.js';
40
40
  import { DateField } from './DateField.js';
41
41
  import { isPickerDate } from '@mistriwork/ui/internal/datePickerModel.js';
42
- import { formatLocale, formatTimezone } from '../locale.js';
42
+ import { formatClockZone, formatLocale, formatTimezone } from '../locale.js';
43
43
  import { InputSlot, columnInput } from './inputRenderers.js';
44
- import { autoKey, isRequired } from '@mistriwork/engine/shared/form.js';
44
+ import { autoKey, enteredNow, isRequired, platformWritten } from '@mistriwork/engine/shared/form.js';
45
45
  import { columnTextRule, textRuleBreak } from '@mistriwork/engine/shared/textRules.js';
46
46
  import { shell } from '../shellMode.js';
47
47
  import { resourceOf } from './appRooms.js';
@@ -53,7 +53,7 @@ import { defaultCurrency } from '../locale.js';
53
53
  import { wordFor } from './valueModel.js';
54
54
  import { rowCurrency } from '@mistriwork/engine/shared/money.js';
55
55
  import { MinorMoneyInput, minorProblem } from './MinorMoneyInput.js';
56
- import { fieldInput, flagStart, formColumns, formFrame, formGroups, hasFormChanges, insertValues, isFormFieldVisible, missingFields, narrowingCondition, presetValue, } from './newRecordModel.js';
56
+ import { clockDefault, fieldInput, inferredNarrowing, flagStart, formColumns, formFrame, formGroups, hasFormChanges, insertValues, isFormFieldVisible, missingFields, narrowingCondition, presetValue, SEGMENTED_WORDS, } from './newRecordModel.js';
57
57
  import { derivedValue, formWords, resolvedForm, useMeDefaults } from './formDefaults.js';
58
58
  import { useRecordInsert } from './useRecordInsert.js';
59
59
  import { say } from '../copy/forms/components/NewRecord.js';
@@ -103,8 +103,9 @@ function NewRecordFormAsking({ words, ...props }) {
103
103
  function NewRecordFormBody({ table, form, app, label: columnLabel, target, insert, onAdded, onCancel, onPendingChange, onDiscardChange, onUnresolvedChange, compact = false, retainUncertain = compact, display, frame = app ? 'drawer' : 'dialog', }) {
104
104
  useMessageLanguage();
105
105
  const assigned = autoKey(table);
106
- const columns = formColumns(table, form, app);
107
- const groups = formGroups(table, form, app);
106
+ const written = app ? newFormWritten(table) : undefined;
107
+ const columns = formColumns(table, form, app, written);
108
+ const groups = formGroups(table, form, app, written);
108
109
  /* A switch is on or off, never "leave it": a flag it draws starts where the
109
110
  form, else the database, says — off for one that must be answered — and
110
111
  that start is sent like any default. */
@@ -120,6 +121,13 @@ function NewRecordFormBody({ table, form, app, label: columnLabel, target, inser
120
121
  const defaults = {
121
122
  ...Object.fromEntries(flags),
122
123
  ...(app ? inferredFormDefaults({ columns }) : {}),
124
+ /* When the record was entered starts at now (form.ts, enteredNow), said as the date field says a moment. */
125
+ ...(app
126
+ ? Object.fromEntries(enteredNow(columns, form?.defaults ?? {}).map((column) => [
127
+ column.name,
128
+ clockDefault('now', column, new Date(), formatClockZone()),
129
+ ]))
130
+ : {}),
123
131
  ...(form?.defaults ?? {}),
124
132
  };
125
133
  const switches = new Set(flags.map(([name]) => name));
@@ -188,7 +196,11 @@ function NewRecordFormBody({ table, form, app, label: columnLabel, target, inser
188
196
  /* What the form fills without asking (a bound parent key, a hidden default), as its boxes would hold it. */
189
197
  const draftDefaults = Object.fromEntries(Object.entries(defaults).map(([name, value]) => [name, value === null || value === undefined ? '' : String(value)]));
190
198
  /* The fields whose choices read another: a picker narrowed by a project empties when the project changes. */
191
- const dependents = (name) => columns.filter((column) => Object.values(dress(column)?.where ?? {}).includes(name));
199
+ /* What a picker's choices are narrowed by: the form's word (`where`), else the schema's (a site picked after its
200
+ customer, newRecordModel.ts inferredNarrowing). */
201
+ const inferredWhere = app ? inferredNarrowing(columns, target) : {};
202
+ const whereOf = (column) => dress(column)?.where ?? inferredWhere[column.name];
203
+ const dependents = (name) => columns.filter((column) => Object.values(whereOf(column) ?? {}).includes(name));
192
204
  /* Steps carve the New form into pages (`form.steps`); an inline Quick Add stays one row. */
193
205
  const steps = !compact && form?.steps?.length ? form.steps : undefined;
194
206
  const [stepIndex, setStepIndex] = useState(0);
@@ -362,9 +374,10 @@ function NewRecordFormBody({ table, form, app, label: columnLabel, target, inser
362
374
  const own = dress(column);
363
375
  /* A narrowed picker offers nothing until the fields it reads are filled, and says which. */
364
376
  /* It reads the draft, and the values the form fills without asking (a bound parent key, a default). */
365
- const narrowed = own?.where && kind === 'reference' ? narrowingCondition(own.where, { ...defaults, ...values }) : '';
377
+ const where = whereOf(column);
378
+ const narrowed = where && kind === 'reference' ? narrowingCondition(where, { ...defaults, ...values }) : '';
366
379
  const waitingOn = narrowed === undefined
367
- ? Object.values(own.where)
380
+ ? Object.values(where)
368
381
  .map((name) => table.columns.find((c) => c.name === name))
369
382
  .filter((c) => Boolean(c))
370
383
  .map(label)
@@ -400,7 +413,7 @@ function NewRecordFormBody({ table, form, app, label: columnLabel, target, inser
400
413
  const errorId = `${errorPrefix}-${index}-error`;
401
414
  const help = [own?.help, waitingOn ? say('chooseFirst', { waitingOn }) : ''].filter(Boolean).join(' ') || undefined;
402
415
  const helpId = help ? `${errorPrefix}-${index}-help` : undefined;
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) => {
416
+ return (_jsxs("div", { "data-kind": app && (kind === 'number' || kind === 'money' || kind === 'date' || kind === 'datetime') ? kind : undefined, 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) => {
404
417
  edited.current.add(column.name);
405
418
  field.handleChange(value);
406
419
  /* A value taken from the record this field names follows the choice, until the person says their own. */
@@ -412,12 +425,30 @@ function NewRecordFormBody({ table, form, app, label: columnLabel, target, inser
412
425
  f.setFieldValue(name, taken);
413
426
  });
414
427
  }
415
- /* A choice narrowed by this field no longer belongs to it. */
428
+ /* A choice narrowed by this field goes only where it no longer belongs to the pick. A deal
429
+ the form was given (opened from the deal, or from the assistant's proposal) stays when
430
+ the account picked is that deal's own: with the inferred narrowing every New form that
431
+ asks the account first would otherwise drop the record it was opened for. */
416
432
  for (const dependent of dependents(column.name)) {
417
- if (f.getFieldValue(dependent.name)) {
433
+ const held = f.getFieldValue(dependent.name);
434
+ if (!held)
435
+ continue;
436
+ const drop = () => {
437
+ if (f.getFieldValue(dependent.name) !== held)
438
+ return;
418
439
  edited.current.add(dependent.name);
419
440
  f.setFieldValue(dependent.name, '');
441
+ setDirty(hasFormChanges(columns, f.state.values, defaults, edited.current));
442
+ };
443
+ const remote = Object.entries(whereOf(dependent) ?? {}).find(([, local]) => local === column.name)?.[0];
444
+ if (value === '' || value === null || value === undefined || !remote) {
445
+ drop();
446
+ continue;
420
447
  }
448
+ void derivedValue(`${dependent.name}.${remote}`, dependent, String(held), target).then((under) => {
449
+ if (f.getFieldValue(column.name) === value && under !== String(value))
450
+ drop();
451
+ });
421
452
  }
422
453
  if (serverError)
423
454
  setClearedServerFields((previous) => {
@@ -613,7 +644,9 @@ export function PlatformControl({ column, app, required, assigned, spoken, targe
613
644
  ['0', say('common.no')],
614
645
  ];
615
646
  const cards = as === 'cards';
616
- return (_jsx("div", { className: cards ? 'choice-cards' : 'choice-pair', role: "radiogroup", "aria-label": spoken, "aria-required": required || undefined, children: words.map(([stored, said], index) => (_jsxs("label", { className: `${cards ? 'choice-card' : 'choice-pick'}${value === stored ? ' is-on' : ''}`, children: [cards && rule?.icons?.[stored] && isAppIcon(rule.icons[stored]) ? (_jsx("span", { className: "choice-card-icon", "aria-hidden": "true", children: _jsx(Icon, { name: rule.icons[stored] }) })) : null, cards ? _jsx("span", { className: "choice-card-label", children: said }) : null, _jsx("input", { type: "radio", name: radioName, value: stored, className: "choice-input", checked: value === stored, onChange: () => onChange(stored), ref: index === 0 ? setControl : undefined }), cards ? _jsx("span", { className: "choice-box", "aria-hidden": "true" }) : said] }, stored))) }));
647
+ /* A vocabulary here has no descriptions, so what keeps its cards is only how many words there are. */
648
+ const stacked = cards && words.length > SEGMENTED_WORDS;
649
+ return (_jsx("div", { className: stacked ? 'choice-cards' : cards ? 'choice-row' : 'choice-pair', role: "radiogroup", "aria-label": spoken, "aria-required": required || undefined, children: words.map(([stored, said], index) => (_jsxs("label", { className: `${stacked ? 'choice-card' : 'choice-pick'}${value === stored ? ' is-on' : ''}`, children: [cards && rule?.icons?.[stored] && isAppIcon(rule.icons[stored]) ? (_jsx("span", { className: stacked ? 'choice-card-icon' : 'choice-pick-icon', "aria-hidden": "true", children: _jsx(Icon, { name: rule.icons[stored] }) })) : null, stacked ? _jsx("span", { className: "choice-card-label", children: said }) : null, _jsx("input", { type: "radio", name: radioName, value: stored, className: "choice-input", checked: value === stored, onChange: () => onChange(stored), ref: index === 0 ? setControl : undefined }), stacked ? _jsx("span", { className: "choice-box", "aria-hidden": "true" }) : said] }, stored))) }));
617
650
  }
618
651
  if (((kind === 'radios' && as !== 'select') || (as === 'radios' && app)) && allowed?.length) {
619
652
  return (_jsx("div", { className: "command-choices insert-choices", role: "radiogroup", "aria-label": spoken, "aria-required": required || undefined, children: allowed.map((stored, index) => (_jsxs("label", { className: "command-choice", children: [_jsx("input", { type: "radio", name: radioName, value: stored, checked: value === stored, onChange: () => onChange(stored), ref: index === 0 ? setControl : undefined }), word(stored)] }, stored))) }));
@@ -644,7 +677,10 @@ export function PlatformControl({ column, app, required, assigned, spoken, targe
644
677
  return (_jsx(RecordPicker, { table: referenced, value: value, onChange: onChange, ariaLabel: spoken, app: app, inputRef: setControl, where: where, disabled: waiting, ...(placeholder ? { placeholder } : {}) }));
645
678
  }
646
679
  if (dateOnly(column) || kind === 'datetime') {
647
- return (_jsx(DateField, { id: dateId, inputRef: setControl, className: "insert-input", value: value, onChange: onChange, withTime: kind === 'datetime', "aria-label": app ? spoken : `${column.name} (${column.type})`, placeholder: said || (kind === 'datetime' ? say('yyyyMmDdHh') : 'YYYY-MM-DD'), locale: formatLocale(), timezone: formatTimezone() }));
680
+ return (_jsx(DateField, { id: dateId, inputRef: setControl, className: "insert-input", value: value, onChange: onChange, withTime: kind === 'datetime', "aria-label": app ? spoken : `${column.name} (${column.type})`,
681
+ /* A day's box says the locale's pattern, as its hint does and as it reads what is typed (MM/DD/YYYY in
682
+ en-US; ISO is read too): the field's own (DateField.tsx). */
683
+ placeholder: said || (kind === 'datetime' ? say('yyyyMmDdHh') : undefined), locale: formatLocale(), timezone: formatTimezone() }));
648
684
  }
649
685
  /* Formatted text: the editor, fetched when the form first draws one. A new record has no row yet for a
650
686
  picture to be attached to, so it takes pictures once it is saved and edited. */
@@ -716,6 +752,11 @@ function newRecordTitle(table, app) {
716
752
  thing: app ? humanName(table.name).toLowerCase() : table.name,
717
753
  });
718
754
  }
755
+ /** What the database and this App's machine fill on a new record of `table`, unasked (form.ts, platformWritten). */
756
+ function newFormWritten(table) {
757
+ const machine = resourceOf(shell().app(), table.id)?.machine;
758
+ return platformWritten(table, machine ? { column: machine.column, states: machine.states.map((state) => state.value) } : undefined);
759
+ }
719
760
  /**
720
761
  * The New form as an app shows it: a drawer over the list. A modal hid the
721
762
  * list you were on, fought the picker's menu for room, and could not be
@@ -723,15 +764,18 @@ function newRecordTitle(table, app) {
723
764
  * which takes the first Escape.
724
765
  */
725
766
  export function NewRecordDrawer(props) {
726
- const frame = props.app ? formFrame(props.form, formColumns(props.table, props.form, props.app).length) : 'drawer';
767
+ const frame = props.app
768
+ ? formFrame(props.form, formColumns(props.table, props.form, props.app, newFormWritten(props.table)).length)
769
+ : 'drawer';
727
770
  const pane = frame === 'page' ? shellById('content') : null;
728
771
  return pane ? _jsx(NewRecordPage, { ...props, pane: pane }) : _jsx(NewRecordSheet, { ...props });
729
772
  }
730
773
  /**
731
774
  * The New form as a page of its own (`form.open: 'page'`, or a long or
732
775
  * stepped form): drawn in the content pane, beside the App's menu, as a
733
- * command form is — one centred measure under the App's name and the
734
- * form's title. The list it was opened from stays where it was, hidden
776
+ * command form is — one centred measure under the form's title; the App's
777
+ * name is the bar's already, so it is not said over the title again. The
778
+ * list it was opened from stays where it was, hidden
735
779
  * rather than taken down, so Cancel finds it as it was left.
736
780
  */
737
781
  function NewRecordPage({ pane, ...props }) {
@@ -752,7 +796,7 @@ function NewRecordPage({ pane, ...props }) {
752
796
  back.focus({ preventScroll: true });
753
797
  });
754
798
  }, []);
755
- return createPortal(_jsxs("div", { className: "newrecord-page-host", children: [_jsxs("section", { className: "form-page newrecord-page", "aria-labelledby": titleId, children: [props.appName && _jsx("p", { className: "eyebrow", children: props.appName }), _jsx("h1", { id: titleId, children: title }), props.form?.description && _jsx("p", { className: "form-page-description", children: props.form.description }), _jsx(NewRecordForm, { ...props, frame: "page", onCancel: dismissal.close, onPendingChange: dismissal.change, onDiscardChange: dismissal.discardChange })] }), dismissal.discard && _jsx(DiscardNewRecord, { onDone: dismissal.resolve })] }), pane);
799
+ return createPortal(_jsxs("div", { className: "newrecord-page-host", children: [_jsxs("section", { className: "form-page newrecord-page", "aria-labelledby": titleId, children: [_jsx("h1", { id: titleId, children: title }), props.form?.description && _jsx("p", { className: "form-page-description", children: props.form.description }), _jsx(NewRecordForm, { ...props, frame: "page", onCancel: dismissal.close, onPendingChange: dismissal.change, onDiscardChange: dismissal.discardChange })] }), dismissal.discard && _jsx(DiscardNewRecord, { onDone: dismissal.resolve })] }), pane);
756
800
  }
757
801
  /**
758
802
  * Everything beside `panel` and beside each of its ancestors up to the shell's body made inert, until the release
@@ -12,7 +12,7 @@ import { useContext, useEffect } from 'react';
12
12
  import { useQuery } from '@tanstack/react-query';
13
13
  import { readRecordSource, shareRecordSource } from '../recordSource.js';
14
14
  import { readPageFields } from './pageFieldsRead.js';
15
- import { dressFor, sayValue } from './valueModel.js';
15
+ import { choiceWord, dressFor, sayValue } from './valueModel.js';
16
16
  import { pathEqualityFilter, recordKey as checkedRecordKey } from '../resourceRequests.js';
17
17
  import { columnDisplay, columnLabel, emptyWord, findTable, labelPath, primaryKey, rowLabel, state } from '../core.js';
18
18
  import { humanName } from '@mistriwork/engine/shared/model.js';
@@ -28,9 +28,10 @@ import { WorkflowStatus } from './WorkflowStatus.js';
28
28
  import { api as callApi, toast } from '../core.js';
29
29
  import { ownedBy } from '../requestIdentity.js';
30
30
  import { PageHeadline } from './PageHeadline.js';
31
- import { PageRenderContext, recordReadNames, usePageApi } from './pageContext.js';
31
+ import { PageRenderContext, inAppPage, recordReadNames, usePageApi } from './pageContext.js';
32
32
  import { Loading, SectionBox } from './PageSectionBox.js';
33
33
  import { sectionClass } from './pageModel.js';
34
+ import { isInferredPage } from '@mistriwork/engine/shared/pageModel.js';
34
35
  import { say } from '../copy/record/components/PageFields.js';
35
36
  import { onDemand } from './onDemand.js';
36
37
  const DefinedFields = onDemand(() => import('./DefinedFields.js'), 'DefinedFields', { quiet: true });
@@ -223,6 +224,16 @@ export function FieldsSection({ page, section, index, base, recordKey: key, fold
223
224
  return null;
224
225
  return (_jsx(SectionBox, { section: section, foldable: foldable, body: _jsx("p", { className: "page-group-empty", title: say('nothingHereEveryField'), children: "\u2014" }) }));
225
226
  }
227
+ /* The inferred page's form (pageAnatomy.ts), and the record's name as its head says it: what the form need not repeat. */
228
+ const inferredForm = rail && section.region !== 'aside' && isInferredPage(page, inAppPage());
229
+ const name = String(rowLabel(base, row)).trim().toLowerCase();
230
+ const saysTheName = (path, value) => {
231
+ const column = columnAt(path);
232
+ if (column?.references || typeof value === 'object')
233
+ return false;
234
+ const text = column?.allowed?.length ? choiceWord(columnDisplay(base.id, path), String(value)) : String(value);
235
+ return text.trim().toLowerCase() === name;
236
+ };
226
237
  const bound = resourceOf(shell().app(), base.id)?.defined;
227
238
  const definedOf = (id) => resourceOf(shell().app(), id)?.defined;
228
239
  const fields = (named ? paths.filter((path) => path !== namePath) : paths).map((path) => {
@@ -257,6 +268,12 @@ export function FieldsSection({ page, section, index, base, recordKey: key, fold
257
268
  recordActions.list.some((action) => !action.command && Object.keys(action.set).length === 1 && path in action.set)) {
258
269
  dd = (_jsx("dd", { className: "page-field-edit", children: _jsx(ActionPick, { tableId: base.id, recordKey: key, column: path, value: value, actions: recordActions, caption: columnLabel(base.id, path, stem) ?? path, onDone: onEdit, connection: connection }) }));
259
270
  }
271
+ else if (inferredForm && !adorned && filled(path) && saysTheName(path, value)) {
272
+ /* A value the record's name already says ("Labor", a labor line's kind beside its name "Labor") is not said
273
+ again under it: the classic form leaves it out as it leaves out an empty one. Where the reader may set it,
274
+ it stays, as the place to set it (the branch above). */
275
+ return null;
276
+ }
260
277
  else if (hideEmpty && !filled(path) && !adorned) {
261
278
  return null;
262
279
  }
@@ -300,6 +317,8 @@ export function FieldsSection({ page, section, index, base, recordKey: key, fold
300
317
  /* Both are lists of terms, so both are drawn as one: a property rail says
301
318
  caption beside value, the grid says them in columns. A grid of <dt>/<dd>
302
319
  in a <div> had no list for assistive technology to announce. */
303
- const grid = rail ? (_jsx("dl", { className: "page-properties", style: columns ? { '--page-properties-columns': String(columns) } : undefined, children: fields })) : (_jsx("dl", { className: `page-field-grid${presentation === 'summary' ? ' page-field-summary' : ''}`, "data-columns": columns, style: columns ? { '--page-field-columns': `repeat(${columns}, minmax(0, 1fr))` } : undefined, children: fields }));
320
+ /* An inferred page's form is the classic one (structure.css); a rail an author placed keeps its own dress. */
321
+ const classic = inferredForm;
322
+ const grid = rail ? (_jsx("dl", { className: classic ? 'page-properties page-classic' : 'page-properties', style: columns ? { '--page-properties-columns': String(columns) } : undefined, children: fields })) : (_jsx("dl", { className: `page-field-grid${presentation === 'summary' ? ' page-field-summary' : ''}`, "data-columns": columns, style: columns ? { '--page-field-columns': `repeat(${columns}, minmax(0, 1fr))` } : undefined, children: fields }));
304
323
  return (_jsx(SectionBox, { section: section, foldable: foldable, body: _jsxs(_Fragment, { children: [section.workflow && _jsx(WorkflowStatus, { definition: section.workflow, value: row[section.workflow.field], reachable: reachable }), grid] }) }));
305
324
  }
@@ -40,6 +40,7 @@ import { primaryKey } from '@mistriwork/engine/shared/schema.js';
40
40
  import { documentsOf } from '../documents.js';
41
41
  import { useMessageLanguage } from './useMessageLanguage.js';
42
42
  import { say } from '../copy/record/components/PageHead.js';
43
+ import { formatSpan } from '../locale.js';
43
44
  import { recordNotFound } from './RecordGone.js';
44
45
  import { drawnLayout } from '@mistriwork/engine/shared/pageLayouts.js';
45
46
  import { useCrumbSlots } from './crumbSlot.js';
@@ -74,6 +75,9 @@ export function PageHead({ entry, page, base, others, onLayout, actions, host, o
74
75
  screen (page.css). */
75
76
  const { tools: crumbTools } = useCrumbSlots();
76
77
  const actionsInBar = Boolean(crumbTools && !host && !phone && shell().inApp());
78
+ /* A record room of an App under the trail: the bar is drawn in the render that draws the room (crumbSlot.ts), so
79
+ this is known before the first paint and the head never changes height after it. */
80
+ const trailed = Boolean(key && crumbTools && !host && shell().inApp());
77
81
  const said = useRecordHeader({
78
82
  page,
79
83
  base,
@@ -147,7 +151,7 @@ export function PageHead({ entry, page, base, others, onLayout, actions, host, o
147
151
  else
148
152
  onPending({ inPlace: false });
149
153
  } }) })) : null;
150
- return (_jsxs("div", { className: `page-head${key ? ' has-record' : ''}${!host && shell().inApp() ? ' is-room' : ''}${avatarDeclared ? ' has-avatar' : ''}`, "data-layout": drawnLayout(page), children: [_jsxs("div", { className: "page-head-top", children: [authoring && items.length ? (_jsx("div", { className: "page-title-pick", children: _jsx(Dropdown, { ariaLabel: say('common.page'), value: page.id, items: [
154
+ return (_jsxs("div", { className: `page-head${key ? ' has-record' : ''}${!host && shell().inApp() ? ' is-room' : ''}${avatarDeclared ? ' has-avatar' : ''}${trailed ? ' has-trail' : ''}`, "data-layout": drawnLayout(page), children: [_jsxs("div", { className: "page-head-top", children: [authoring && items.length ? (_jsx("div", { className: "page-title-pick", children: _jsx(Dropdown, { ariaLabel: say('common.page'), value: page.id, items: [
151
155
  { value: page.id, label: sayPage(page), detail: sourceOf(page) },
152
156
  ...items.map((p) => ({ value: p.id, label: sayPage(p), detail: sourceOf(p) })),
153
157
  ], onChange: (id) => {
@@ -155,9 +159,12 @@ export function PageHead({ entry, page, base, others, onLayout, actions, host, o
155
159
  go({ ...entry, pageId: id }, 'replace');
156
160
  }, valueClassName: "page-title" }) })) : key ? (
157
161
  /* Over a record's name its kind is a label for someone who works
158
- across tables; a public reader came for the car, not "VEHICLE". */
159
- shell().publicVisitor() ? null : (_jsx("span", { className: "page-title", children: sayPage(page) }))) : (_jsx("h1", { className: "page-title", children: sayPage(page) })), !shell().inApp() && (_jsx("button", { type: "button", className: `ghost page-pin${pinned ? ' is-pinned' : ''}`, "aria-pressed": pinned, title: pinned ? say('isPinnedToTheHome', { name: page.name }) : say('pinToTheHome', { name: page.name }), "aria-label": pinned ? say('isPinnedToTheHome', { name: page.name }) : say('pinToTheHome', { name: page.name }), onClick: () => setPinned(togglePinned(page)), children: pinned ? '★' : '☆' })), key && changedElsewhere && !gone && _jsx(LiveUpdatedLine, { table: base, recordKey: key }), authoring && (_jsx(Button, { size: "compact", className: "page-edit", title: page.source === 'saved' ? say('addRemoveAndReorder') : say('thisPageBelongsToTheFile'), onClick: onLayout, children: page.source === 'saved' ? say('layout') : say('copyLayout') }))] }), key && (_jsxs("div", { className: "root-bar", children: [recordAvatar &&
160
- (photo && photo !== brokenPhoto ? (_jsx("img", { className: `page-record-avatar avatar avatar-photo avatar-c${hueOf(label)}`, src: photo, alt: "", decoding: "async", onError: () => setBrokenPhoto(photo) })) : (_jsx("span", { className: `page-record-avatar avatar avatar-c${hueOf(label)}`, "aria-hidden": "true", children: initialsOf(label) }))), title ? (_jsx("div", { className: "root-current", role: "heading", "aria-level": 1, "aria-label": label, children: title() })) : (_jsx("h1", { className: "root-current", children: _jsx("span", { title: label, children: label }) })), starred && _jsx(FavoriteStar, { favorite: starred, name: label }), said.status, _jsx(RecordTrailNav, { entry: entry })] })), toolbar && actionsInBar ? createPortal(toolbar, crumbTools, 'record-actions') : toolbar, key && said.facts, key && tagRule && _jsx(RecordTags, { rule: tagRule, recordKey: key, isCurrent: isCurrent }), deleting.dialog, key && (_jsx("div", { className: `page-pending${liveDraft ? ' has-live-draft' : ''}`, children: _jsx(PendingBar, { table: base, recordKey: key, placement: host?.pendingBar, isCurrent: isCurrent, onDone: (done) => onPending(host ? done : (done ?? { inPlace: true })) }) }))] }));
162
+ across tables; a public reader came for the car, not "VEHICLE".
163
+ Under an App's trail it is heard and not seen: the trail already
164
+ says "Bookings › Ava Thompson", and a third "BOOKING" over the
165
+ name was the same place said again (docs/design.md, the record head). */
166
+ shell().publicVisitor() ? null : (_jsx("span", { className: trailed ? 'page-title visually-hidden' : 'page-title', children: sayPage(page) }))) : (_jsx("h1", { className: "page-title", children: sayPage(page) })), !shell().inApp() && (_jsx("button", { type: "button", className: `ghost page-pin${pinned ? ' is-pinned' : ''}`, "aria-pressed": pinned, title: pinned ? say('isPinnedToTheHome', { name: page.name }) : say('pinToTheHome', { name: page.name }), "aria-label": pinned ? say('isPinnedToTheHome', { name: page.name }) : say('pinToTheHome', { name: page.name }), onClick: () => setPinned(togglePinned(page)), children: pinned ? '★' : '☆' })), key && changedElsewhere && !gone && _jsx(LiveUpdatedLine, { table: base, recordKey: key }), authoring && (_jsx(Button, { size: "compact", className: "page-edit", title: page.source === 'saved' ? say('addRemoveAndReorder') : say('thisPageBelongsToTheFile'), onClick: onLayout, children: page.source === 'saved' ? say('layout') : say('copyLayout') }))] }), key && (_jsxs("div", { className: "root-bar", children: [recordAvatar &&
167
+ (photo && photo !== brokenPhoto ? (_jsx("img", { className: `page-record-avatar avatar avatar-photo avatar-c${hueOf(label)}`, src: photo, alt: "", decoding: "async", onError: () => setBrokenPhoto(photo) })) : (_jsx("span", { className: `page-record-avatar avatar avatar-c${hueOf(label)}`, "aria-hidden": "true", children: initialsOf(label) }))), title ? (_jsx("div", { className: "root-current", role: "heading", "aria-level": 1, "aria-label": label, children: title() })) : (_jsx("h1", { className: "root-current", children: _jsx("span", { title: label, children: label }) })), starred && _jsx(FavoriteStar, { favorite: starred, name: label }), said.status, _jsx(RecordTrailNav, { entry: entry })] })), key && said.subtitle, toolbar && actionsInBar ? createPortal(toolbar, crumbTools, 'record-actions') : toolbar, key && said.facts, key && tagRule && _jsx(RecordTags, { rule: tagRule, recordKey: key, isCurrent: isCurrent }), deleting.dialog, key && (_jsx("div", { className: `page-pending${liveDraft ? ' has-live-draft' : ''}`, children: _jsx(PendingBar, { table: base, recordKey: key, placement: host?.pendingBar, isCurrent: isCurrent, onDone: (done) => onPending(host ? done : (done ?? { inPlace: true })) }) }))] }));
161
168
  }
162
169
  /**
163
170
  * Whether a verb takes something away: named (by id) in the header's `destructive`,
@@ -242,10 +249,14 @@ function useRecordHeader({ page, base, recordKey: key, header, onSectionLabel, o
242
249
  pushed the whole page down when it came (test/built-client-vitals.mjs). So is it while the host's adornments are
243
250
  asked about one of its empty facts: an empty fact is left out, and one the host adorns would join the line late. */
244
251
  const waitsOnHost = Boolean(row && adornHeld?.length) && facts.some((path) => adornHeld.includes(path) && (row[path] ?? '') === '');
245
- if (section && ((!row && data.isPending) || waitsOnHost) && facts.length)
252
+ /* The line under the name is held the same way: the page says whether it has one, the row only what it says. */
253
+ const subtitlePath = section?.subtitle;
254
+ const heldSubtitle = subtitlePath ? (_jsx("p", { className: "page-head-subtitle", "aria-hidden": "true", style: { visibility: 'hidden' }, children: "\u00A0" })) : null;
255
+ if (section && ((!row && data.isPending) || waitsOnHost) && (facts.length || subtitlePath))
246
256
  return {
247
257
  status: null,
248
- facts: (_jsx("ul", { className: "page-facts page-head-facts", "aria-hidden": "true", style: { visibility: 'hidden' }, children: _jsx("li", { className: "page-fact", children: "\u00A0" }) })),
258
+ facts: facts.length ? (_jsx("ul", { className: "page-facts page-head-facts", "aria-hidden": "true", style: { visibility: 'hidden' }, children: _jsx("li", { className: "page-fact", children: "\u00A0" }) })) : null,
259
+ subtitle: heldSubtitle,
249
260
  };
250
261
  if (!section || !row)
251
262
  return { status: null, facts: null };
@@ -266,6 +277,12 @@ function useRecordHeader({ page, base, recordKey: key, header, onSectionLabel, o
266
277
  const adornments = new Map(facts.map((path) => [path, adornedAt(path)]));
267
278
  const shown = facts.filter((path) => filled(path) || adornments.get(path));
268
279
  const fact = (path) => {
280
+ /* A span said once, start to end ("Sep 13, 2026, 2:00 – 4:00 PM"), where the page reads the fact as one
281
+ (pageAnatomy.ts, spanOf); an end it cannot pair is the start alone, as before. */
282
+ const end = section.spans?.[path];
283
+ const span = end && filled(end) && typeof row[path] === 'string' ? formatSpan(row[path], String(row[end])) : null;
284
+ if (span)
285
+ return (_jsxs("li", { className: "page-fact", children: [_jsxs("span", { className: "page-fact-caption", children: [say('when'), _jsx("span", { className: "visually-hidden", children: ": " })] }), _jsx("span", { children: span }), adornments.get(path)] }, path));
269
286
  const labels = section.factLabels;
270
287
  const word = labels && Object.hasOwn(labels, path)
271
288
  ? factWord(labels[path], row[path], columnDisplay(base.id, path))
@@ -274,6 +291,9 @@ function useRecordHeader({ page, base, recordKey: key, header, onSectionLabel, o
274
291
  return (_jsxs("li", { className: "page-fact", children: [word === undefined && (_jsxs("span", { className: "page-fact-caption", children: [captionOf(path), _jsx("span", { className: "visually-hidden", children: ": " })] })), before && _jsxs("span", { className: "page-fact-word", children: [word, " "] }), filled(path) && (_jsx(Subtitled, { tableId: base.id, column: path.includes('.') ? undefined : path, row: row, children: said(path) })), word !== undefined && !before && _jsxs("span", { className: "page-fact-word", children: [" ", word] }), adornments.get(path)] }, path));
275
292
  };
276
293
  return {
294
+ /* Quiet under the name, as a name's second line is in a list. A record without one keeps the line's room, unseen:
295
+ the line was held while the row was read, and taking it away then would move everything under it. */
296
+ subtitle: subtitlePath && filled(subtitlePath) ? (_jsx("p", { className: "page-head-subtitle", children: _jsx(Value, { col: columnAt(subtitlePath), value: row[subtitlePath], tableId: base.id, compact: true }) })) : (heldSubtitle),
277
297
  /* Its caption is heard, not seen: beside the name a chip is its own word. */
278
298
  status: status && filled(status) ? (_jsxs("span", { className: "page-head-status", children: [_jsxs("span", { className: "visually-hidden", children: [captionOf(status), ": "] }), said(status)] })) : null,
279
299
  facts: shown.length ? (_jsxs(_Fragment, { children: [_jsx("ul", { className: "page-facts page-head-facts", "aria-label": say('common.keyFacts'), children: shown.slice(0, HEADER_FACTS_SHOWN).map(fact) }), shown.length > HEADER_FACTS_SHOWN && (_jsxs("details", { className: "page-head-more", children: [_jsx("summary", { children: say('common.more') }), _jsx("ul", { className: "page-facts page-head-facts", children: shown.slice(HEADER_FACTS_SHOWN).map(fact) })] }))] })) : null,
@@ -1,5 +1,32 @@
1
1
  import { type TableMeta } from '@mistriwork/engine/shared/schema.js';
2
2
  import { type RecordActions, type SlotProps } from './pageContext.js';
3
+ /** A related list's count: its rows, and whether there are more than the count read up to ("10,000+"). */
4
+ interface Counted {
5
+ total: number;
6
+ capped: boolean;
7
+ }
8
+ /** The record an inferred page counts its related lists' rows for. */
9
+ export interface Counting {
10
+ base: TableMeta;
11
+ recordKey: Record<string, unknown>;
12
+ }
13
+ /**
14
+ * How many rows each of an inferred page's related lists holds, by its question (recordReads.ts,
15
+ * relatedCountQuestion): one request for a strip of tabs, or for a list alone, built as the server built it for the
16
+ * page's compose, so a composed page is answered at once. Kept beside the list badges' counts, so a write that
17
+ * refreshes those refreshes these.
18
+ */
19
+ export declare function useRelatedCounts(sections: readonly SlotProps['section'][], counting: Counting | undefined): Map<string, Counted | null> | undefined;
20
+ /**
21
+ * A related list's count, on its tab or beside its heading. It stands in room kept for it from the first paint
22
+ * (features.css, `.tab-count`), so its arrival moves no tab, no heading and no fold; a list that is no one hop back
23
+ * to the record has no count, and keeps no room.
24
+ */
25
+ export declare function RelatedCount({ section, counting, counts, }: {
26
+ section: SlotProps['section'];
27
+ counting: Counting;
28
+ counts: Map<string, Counted | null> | undefined;
29
+ }): import("react").JSX.Element;
3
30
  /** Rows related to the root: the real list. */
4
31
  export declare function ListSection(props: SlotProps): import("react").JSX.Element;
5
32
  /** Its first page as the server asks it for the page's compose (shared/recordReads.ts): the names and keys a row needs added. */
@@ -68,3 +95,4 @@ export declare function relatedDoor(section: SlotProps['section'], base: TableMe
68
95
  canCreate: boolean;
69
96
  door: boolean;
70
97
  };
98
+ export {};
@@ -14,7 +14,7 @@ import { relatedRows } from '../prefs.js';
14
14
  import { formatBytes, formatNumber, formatRelativeDay } from '../locale.js';
15
15
  import { columnKind, linkTarget } from '@mistriwork/engine/shared/schema.js';
16
16
  import { recordViewKey, recordViewLabel, withoutParent, withoutParentName } from '@mistriwork/engine/shared/referenceModel.js';
17
- import { groupsBody, listView } from '@mistriwork/engine/shared/recordReads.js';
17
+ import { groupsBody, listView, relatedCountsBody } from '@mistriwork/engine/shared/recordReads.js';
18
18
  import { GROUP_ROWS_DEFAULT, GROUPS_DEFAULT } from '@mistriwork/engine/shared/pageModel.js';
19
19
  import { groupFactPaths, groupTable } from '@mistriwork/engine/shared/pagePaths.js';
20
20
  import { andQuery, quoteValue } from '@mistriwork/engine/shared/query.js';
@@ -65,6 +65,51 @@ function resourceOf(table) {
65
65
  function fileOf(table) {
66
66
  return resourceOf(table)?.file;
67
67
  }
68
+ /**
69
+ * How many rows each of an inferred page's related lists holds, by its question (recordReads.ts,
70
+ * relatedCountQuestion): one request for a strip of tabs, or for a list alone, built as the server built it for the
71
+ * page's compose, so a composed page is answered at once. Kept beside the list badges' counts, so a write that
72
+ * refreshes those refreshes these.
73
+ */
74
+ export function useRelatedCounts(sections, counting) {
75
+ const api = usePageApi();
76
+ const { connection, preview } = useContext(PageRenderContext);
77
+ const body = counting && !preview && !shell().publicVisitor()
78
+ ? relatedCountsBody(state.schema, sections, counting.base, counting.recordKey)
79
+ : undefined;
80
+ return useQuery({
81
+ queryKey: ['count', connection ?? state.activeConnection ?? '', 'related', body?.items ?? []],
82
+ queryFn: async () => {
83
+ const data = (await api('/api/counts', body));
84
+ /* In the shape a list's badges keep theirs (AppList.tsx), under the same key, so either reads the other's. */
85
+ return new Map(body.items.map((question, i) => {
86
+ const result = data.results?.[i];
87
+ return [
88
+ question,
89
+ result && !result.errors?.length && typeof result.total === 'number'
90
+ ? { total: result.total, capped: result.cappedTotal === true }
91
+ : null,
92
+ ];
93
+ }));
94
+ },
95
+ enabled: Boolean(body),
96
+ staleTime: 0,
97
+ }).data;
98
+ }
99
+ /**
100
+ * A related list's count, on its tab or beside its heading. It stands in room kept for it from the first paint
101
+ * (features.css, `.tab-count`), so its arrival moves no tab, no heading and no fold; a list that is no one hop back
102
+ * to the record has no count, and keeps no room.
103
+ */
104
+ export function RelatedCount({ section, counting, counts, }) {
105
+ if (section.kind !== 'list')
106
+ return null;
107
+ const question = relatedCountsBody(state.schema, [section], counting.base, counting.recordKey)?.items[0];
108
+ if (question === undefined)
109
+ return null;
110
+ const known = counts?.get(question);
111
+ return _jsx("span", { className: "tab-count", children: known && _jsx("span", { children: `${formatNumber(known.total)}${known.capped ? '+' : ''}` }) });
112
+ }
68
113
  /** Rows related to the root: the real list. */
69
114
  export function ListSection(props) {
70
115
  return _jsx(RelatedList, { ...props });
@@ -127,9 +172,11 @@ export function relatedDoor(section, base, recordKey, context) {
127
172
  return { noun, create, placed, creation, defaults, canCreate, door: canCreate || placed.length > 0 };
128
173
  }
129
174
  /** Rows related to the root, a page at a time — the real list, not a sample of one. */
130
- function RelatedList({ section, plan, base, recordKey, onEdit, collapsed }) {
175
+ function RelatedList({ section, plan, base, recordKey, onEdit, collapsed, counted }) {
131
176
  const api = usePageApi();
132
177
  const { preview, isCurrent, openRelated, connection, recordName, onActionDone, actions: recordActions } = useContext(PageRenderContext);
178
+ const counting = counted ? { base, recordKey } : undefined;
179
+ const counts = useRelatedCounts(counted ? [section] : [], counting);
133
180
  const queries = useQueryClient();
134
181
  const [added, setAdded] = useState(false);
135
182
  const createButton = useRef(null);
@@ -631,7 +678,7 @@ function RelatedList({ section, plan, base, recordKey, onEdit, collapsed }) {
631
678
  /* An empty list said in one line: only its Add stands there, an upload for a list of files. */
632
679
  if (collapsed)
633
680
  return file && canCreate ? (_jsx(AttachmentList, { items: [], empty: false, emptyText: "", upload: { label: create.label, maxBytes: file.maxBytes ?? FILE_MAX_BYTES_DEFAULT, send } })) : ((tools ?? null));
634
- return (_jsx(SectionBox, { section: section, foldable: false, tools: tools, body: _jsxs("div", { className: "page-list-body", children: [(file ? undefined : authoredEmpty) ??
681
+ return (_jsx(SectionBox, { section: section, foldable: false, tools: tools, count: counting && _jsx(RelatedCount, { section: section, counting: counting, counts: counts }), body: _jsxs("div", { className: "page-list-body", children: [(file ? undefined : authoredEmpty) ??
635
682
  (grouped && groupsGot && view ? (_jsx(GroupedBody, { section: section, groups: groupsGot, offset: offset, perPage: section.group?.limit ?? GROUPS_DEFAULT, onOffset: setOffset, view: view, labelColumns: labelColumns, rowsPerGroup: limit, ...(groupMoves ? { moves: groupMoves } : {}), overall: summed && totals
636
683
  ? { label: say('totalAllThings', { things: things || say('recordsNoun') }), sums: totals }
637
684
  : undefined, grid: (data, subtotals, subtotalsLabel) => {
@@ -10,10 +10,14 @@
10
10
  */
11
11
  import { type ReactNode } from 'react';
12
12
  import { type PageSection } from './pageModel.js';
13
+ /** What an untitled history is called in the reader's language: its heading, and its tab on an inferred page. */
14
+ export declare const historyWord: () => string;
13
15
  /** A section's box: its heading, or a fold when it is a later group of fields. */
14
- export declare function SectionBox({ section, body, foldable, broken, crashed, hidden, tools, }: {
16
+ export declare function SectionBox({ section, body, foldable, broken, crashed, hidden, tools, count, }: {
15
17
  section: PageSection;
16
18
  body: ReactNode;
19
+ /** How many rows a related list holds, said after its heading (PageRelated.tsx, RelatedCount). */
20
+ count?: ReactNode;
17
21
  /** What the section offers beside its heading — a related list's Add and verbs — drawn in the heading's row. */
18
22
  tools?: ReactNode;
19
23
  foldable: boolean;
@@ -22,16 +22,18 @@ import { say } from '../copy/record/components/PageSectionBox.js';
22
22
  /* A suggested page titles a related list by its table's name (`visit_attachment`), which an App says as words, as
23
23
  every untitled list's head already is. An authored title has words or capitals of its own and is left as written. */
24
24
  const titled = (title) => (/^[a-z][a-z0-9_.]*$/.test(title) ? spoken(title) : title);
25
+ /** What an untitled history is called in the reader's language: its heading, and its tab on an inferred page. */
26
+ export const historyWord = () => say('history');
25
27
  /** A section's mark leading its heading. A note draws its own over its words, so it has none here. */
26
28
  const mark = (section) => section.icon && section.kind !== 'note' ? _jsx(Icon, { name: section.icon, size: 16, className: "dash-section-icon" }) : null;
27
29
  /** A section's box: its heading, or a fold when it is a later group of fields. */
28
- export function SectionBox({ section, body, foldable, broken, crashed, hidden, tools, }) {
30
+ export function SectionBox({ section, body, foldable, broken, crashed, hidden, tools, count, }) {
29
31
  useMessageLanguage();
30
32
  const { preview } = useContext(PageRenderContext);
31
33
  const content = preview ? (_jsx("div", { style: { display: 'contents' }, inert: true, children: body })) : (body);
32
34
  const heading = (section.title === undefined ? undefined : titled(section.title)) ??
33
35
  (section.kind === 'history'
34
- ? say('history')
36
+ ? historyWord()
35
37
  : section.kind === 'flows'
36
38
  ? say('flows')
37
39
  : section.kind === 'diagram'
@@ -60,7 +62,7 @@ export function SectionBox({ section, body, foldable, broken, crashed, hidden, t
60
62
  const gallery = section.kind === 'list' && section.presentation === 'gallery';
61
63
  /* An embedded list view's heading is the way to the whole of it: the view's own room, where the reader has it. */
62
64
  const room = section.view && !preview ? navigate?.(section.view) : undefined;
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)] }));
65
+ 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), count] }));
64
66
  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] }));
65
67
  }
66
68
  export function Loading({ section }) {