@mistriwork/kit 1.0.0-rc.16 → 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 (110) hide show
  1. package/dist/client/components/AppList.js +16 -6
  2. package/dist/client/components/CardsList.js +7 -1
  3. package/dist/client/components/Chart.css +5 -0
  4. package/dist/client/components/Chart.d.ts +17 -2
  5. package/dist/client/components/Chart.js +83 -22
  6. package/dist/client/components/ChartFigure.d.ts +3 -1
  7. package/dist/client/components/ChartFigure.js +14 -8
  8. package/dist/client/components/Content.js +3 -1
  9. package/dist/client/components/DashHead.d.ts +6 -0
  10. package/dist/client/components/DashHead.js +20 -0
  11. package/dist/client/components/Editable.js +1 -1
  12. package/dist/client/components/Export.js +8 -4
  13. package/dist/client/components/Grid.js +54 -6
  14. package/dist/client/components/JsonPreview.css +29 -0
  15. package/dist/client/components/JsonPreview.js +1 -1
  16. package/dist/client/components/JsonView.css +201 -62
  17. package/dist/client/components/JsonView.d.ts +43 -1
  18. package/dist/client/components/JsonView.js +320 -55
  19. package/dist/client/components/LayoutSwitch.d.ts +9 -0
  20. package/dist/client/components/LayoutSwitch.js +61 -0
  21. package/dist/client/components/ListEmpty.css +3 -0
  22. package/dist/client/components/LiveNotices.css +3 -0
  23. package/dist/client/components/NewRecord.d.ts +0 -2
  24. package/dist/client/components/NewRecord.js +61 -17
  25. package/dist/client/components/PageFields.js +23 -4
  26. package/dist/client/components/PageHead.js +28 -7
  27. package/dist/client/components/PageRelated.d.ts +28 -0
  28. package/dist/client/components/PageRelated.js +50 -3
  29. package/dist/client/components/PageSectionBox.d.ts +5 -1
  30. package/dist/client/components/PageSectionBox.js +5 -3
  31. package/dist/client/components/PageSections.js +26 -13
  32. package/dist/client/components/PageSkeleton.css +2 -0
  33. package/dist/client/components/PageSkeleton.js +11 -3
  34. package/dist/client/components/Palette.js +108 -10
  35. package/dist/client/components/RecordPicker.d.ts +2 -0
  36. package/dist/client/components/RecordPicker.js +34 -8
  37. package/dist/client/components/RecordSummaries.js +6 -1
  38. package/dist/client/components/Rooms.js +2 -2
  39. package/dist/client/components/SecondLine.d.ts +15 -0
  40. package/dist/client/components/SecondLine.js +18 -0
  41. package/dist/client/components/TableRoom.js +15 -5
  42. package/dist/client/components/TableView.d.ts +2 -0
  43. package/dist/client/components/Value.d.ts +1 -0
  44. package/dist/client/components/Value.js +7 -9
  45. package/dist/client/components/appListModel.d.ts +4 -0
  46. package/dist/client/components/appRooms.d.ts +2 -0
  47. package/dist/client/components/appRooms.js +2 -0
  48. package/dist/client/components/dashboardModel.d.ts +5 -0
  49. package/dist/client/components/directoryModel.d.ts +25 -0
  50. package/dist/client/components/directoryModel.js +88 -0
  51. package/dist/client/components/gridSizing.d.ts +3 -0
  52. package/dist/client/components/gridSizing.js +6 -2
  53. package/dist/client/components/jsonTree.d.ts +54 -0
  54. package/dist/client/components/jsonTree.js +190 -0
  55. package/dist/client/components/listSubtitles.d.ts +1 -0
  56. package/dist/client/components/listSubtitles.js +7 -0
  57. package/dist/client/components/newMenuModel.d.ts +14 -6
  58. package/dist/client/components/newMenuModel.js +37 -5
  59. package/dist/client/components/newRecordModel.d.ts +24 -2
  60. package/dist/client/components/newRecordModel.js +47 -4
  61. package/dist/client/components/pageContext.d.ts +2 -0
  62. package/dist/client/components/pageModel.d.ts +2 -0
  63. package/dist/client/components/sidebarModel.js +7 -3
  64. package/dist/client/components/textMeasure.d.ts +2 -0
  65. package/dist/client/components/textMeasure.js +16 -2
  66. package/dist/client/composedReads.js +3 -1
  67. package/dist/client/copy/lists/components/AppList.d.ts +1 -0
  68. package/dist/client/copy/lists/components/AppList.js +1 -0
  69. package/dist/client/copy/lists/components/LayoutSwitch.d.ts +4 -0
  70. package/dist/client/copy/lists/components/LayoutSwitch.js +6 -0
  71. package/dist/client/copy/record/components/JsonView.d.ts +22 -0
  72. package/dist/client/copy/record/components/JsonView.js +19 -0
  73. package/dist/client/copy/record/components/PageHead.d.ts +1 -0
  74. package/dist/client/copy/record/components/PageHead.js +2 -0
  75. package/dist/client/copy/shell/components/Palette.d.ts +11 -0
  76. package/dist/client/copy/shell/components/Palette.js +14 -0
  77. package/dist/client/copy/shell/components/TopNav.d.ts +2 -1
  78. package/dist/client/copy/shell/components/TopNav.js +4 -2
  79. package/dist/client/copy/shell/components/directoryModel.d.ts +4 -0
  80. package/dist/client/copy/shell/components/directoryModel.js +6 -0
  81. package/dist/client/copy/shell/components/sidebarModel.d.ts +1 -0
  82. package/dist/client/copy/shell/components/sidebarModel.js +1 -0
  83. package/dist/client/copy/workbench/components/Export.d.ts +3 -2
  84. package/dist/client/copy/workbench/components/Export.js +3 -2
  85. package/dist/client/core.d.ts +3 -3
  86. package/dist/client/core.js +6 -7
  87. package/dist/client/export.d.ts +5 -4
  88. package/dist/client/export.js +40 -19
  89. package/dist/client/features.css +67 -7
  90. package/dist/client/index.html +2 -1
  91. package/dist/client/insert.js +1 -8
  92. package/dist/client/locale.d.ts +7 -0
  93. package/dist/client/locale.js +0 -0
  94. package/dist/client/lumenLook.css +9 -12
  95. package/dist/client/page.css +63 -15
  96. package/dist/client/palette.d.ts +3 -1
  97. package/dist/client/palette.js +19 -4
  98. package/dist/client/paletteRecents.d.ts +25 -0
  99. package/dist/client/paletteRecents.js +64 -0
  100. package/dist/client/partsLook.css +6 -3
  101. package/dist/client/sageLook.css +5 -3
  102. package/dist/client/shellMode.d.ts +8 -0
  103. package/dist/client/shellMode.js +1 -0
  104. package/dist/client/structure.css +201 -1
  105. package/dist/client/style.css +59 -10
  106. package/dist/client/themeFamilies.css +37 -0
  107. package/dist/client/visualThemes.css +12 -0
  108. package/dist/client/workbenchLook.css +415 -0
  109. package/dist/client/workshopLook.css +48 -25
  110. package/package.json +4 -3
@@ -11,14 +11,16 @@ import { shell } from '../shellMode.js';
11
11
  import { useContext, useEffect, useId, useRef, useState } from 'react';
12
12
  import { useQuery } from '@tanstack/react-query';
13
13
  import { findTable } from '../core.js';
14
+ import { HISTORY_TAB, isInferredPage } from '@mistriwork/engine/shared/pageModel.js';
15
+ import { tabbedSection } from '@mistriwork/engine/shared/recordReads.js';
14
16
  import { rootMatches, sectionClass } from './pageModel.js';
15
17
  import { PageRenderContext, inAppPage, spoken, usePageApi } from './pageContext.js';
16
- import { Loading, SectionBox } from './PageSectionBox.js';
18
+ import { Loading, SectionBox, historyWord } from './PageSectionBox.js';
17
19
  import { FieldsSection } from './PageFields.js';
18
20
  import { BreakdownSection, ChartSection, MetricSection } from './PageMetrics.js';
19
21
  import { DashboardNote } from './DashboardNote.js';
20
22
  import { TimelineSection } from './PageTimeline.js';
21
- import { ListSection } from './PageRelated.js';
23
+ import { ListSection, RelatedCount, useRelatedCounts } from './PageRelated.js';
22
24
  import { EmptyRun } from './PageEmptyRun.js';
23
25
  import { useMessageLanguage } from './useMessageLanguage.js';
24
26
  import { useTabFold } from './useTabFold.js';
@@ -201,19 +203,26 @@ export function TabStrip({ tabs, name, entry, onTab, draw, scoped, eager = [], c
201
203
  }, children: tab.label }, tab.key))) }), _jsx("div", { className: "page-tab-more", "data-fold-more": "", "data-folded": folded.size ? undefined : '', "aria-hidden": !folded.size || undefined, children: _jsx(DropMenu, { className: "page-tab-more-menu", triggerClassName: "page-tab", label: message('common.more'), popupClassName: "page-actions-popup", align: "end", children: tabs.map((tab, i) => folded.has(i) ? (_jsx(DropItem, { className: "page-actions-item", onClick: () => show(i), children: tab.label }, tab.key)) : null) }) })] }), _jsx("div", { className: "page-tabpanels", children: tabs.map((tab, i) => (_jsx("div", { className: "page-tabpanel", role: "tabpanel", id: `${id}-tabpanel-${i}`, "aria-labelledby": `${id}-tab-${i}`, tabIndex: i === active ? 0 : -1, hidden: i !== active, inert: i !== active, "aria-hidden": i !== active, children: drawn.has(i) ? draw(i) : null }, tab.key))) })] }));
202
204
  }
203
205
  /** A run of lists as tabs: the names across the top, one table under them, fetched when opened. */
204
- function ListTabs({ items, entry, onTab, draw, scoped, }) {
206
+ function ListTabs({ items, entry, onTab, draw, scoped, counting, }) {
205
207
  useMessageLanguage();
206
208
  /* The token is the source's words (apps.ts keepAddresses), so an address names one tab in every language. */
207
- const named = (item) => item.section.addressWords?.title ??
208
- item.section.title ??
209
- findTable(item.section.from ?? '')?.name ??
210
- item.section.from ??
211
- '';
209
+ const named = (item) => item.section.kind === 'history'
210
+ ? HISTORY_TAB
211
+ : (item.section.addressWords?.title ??
212
+ item.section.title ??
213
+ findTable(item.section.from ?? '')?.name ??
214
+ item.section.from ??
215
+ '');
216
+ const counts = useRelatedCounts(items.map((item) => item.section), counting);
217
+ const word = (item) => item.section.kind === 'history' && item.section.title === undefined
218
+ ? historyWord()
219
+ : (item.section.title ?? spoken(findTable(item.section.from ?? '')?.name ?? item.section.from ?? ''));
220
+ const counted = (item) => (counting ? _jsx(RelatedCount, { section: item.section, counting: counting, counts: counts }) : null);
212
221
  // Read as the strip renders: the run is still being gathered when the strip is created.
213
222
  const tabs = items.map((item) => ({
214
223
  key: item.index,
215
224
  token: scoped ? `section:${item.index}` : named(item),
216
- label: item.section.title ?? spoken(findTable(item.section.from ?? '')?.name ?? item.section.from ?? ''),
225
+ label: (_jsxs(_Fragment, { children: [word(item), counted(item)] })),
217
226
  }));
218
227
  return _jsx(TabStrip, { tabs: tabs, name: "Related lists", entry: entry, onTab: onTab, draw: (i) => draw(items[i]), scoped: scoped });
219
228
  }
@@ -250,7 +259,7 @@ export function Sections({ page, base, recordKey: key, plans, entry, onLabel, on
250
259
  const scoped = region === 'aside';
251
260
  /* Each section stands behind its own boundary: one that throws while
252
261
  drawing says so under its heading, and the rest of the page stays. */
253
- const draw = (item, collapsed) => (_jsx(ErrorBoundary, { fallback: (note) => _jsx(SectionBox, { section: item.section, body: null, foldable: false, crashed: note }), children: _jsx(Slot, { page: page, section: item.section, index: item.index, plan: plans.find((p) => p.index === item.index) ?? { index: item.index }, base: base, recordKey: key, foldable: item.section.kind === 'fields' && item.index !== firstFields && !shell().publicVisitor(), entry: entry, onLabel: region ? undefined : onLabel, onSectionLabel: region ? onSectionLabel : undefined, onEdit: onEdit, titleOwner: titleOwner, onTitleEditor: onTitleEditor, collapsed: collapsed }) }, `${item.index}${collapsed ? '-add' : ''}`));
262
+ const draw = (item, collapsed, counted) => (_jsx(ErrorBoundary, { fallback: (note) => _jsx(SectionBox, { section: item.section, body: null, foldable: false, crashed: note }), children: _jsx(Slot, { page: page, section: item.section, index: item.index, plan: plans.find((p) => p.index === item.index) ?? { index: item.index }, base: base, recordKey: key, foldable: item.section.kind === 'fields' && item.index !== firstFields && !shell().publicVisitor(), entry: entry, onLabel: region ? undefined : onLabel, onSectionLabel: region ? onSectionLabel : undefined, onEdit: onEdit, titleOwner: titleOwner, onTitleEditor: onTitleEditor, collapsed: collapsed, counted: counted }) }, `${item.index}${collapsed ? '-add' : ''}`));
254
263
  /* A sequence of sections as the page draws them. `listTabs` is off inside
255
264
  a section's tab: a strip of lists inside a strip of sections is tabs in
256
265
  tabs, so there a panel's lists stack. */
@@ -260,6 +269,9 @@ export function Sections({ page, base, recordKey: key, plans, entry, onLabel, on
260
269
  full-width box. The Workbench's pages, built from the schema or by
261
270
  drag, keep the strip unless they say `listTabs: false`. */
262
271
  const autoTabs = inAppPage() ? page.listTabs === true : page.listTabs !== false;
272
+ /* The page an App infers for a record counts its tabs and ends them with the history (pageAnatomy.ts); a page an
273
+ author wrote is drawn as written. */
274
+ const inferred = isInferredPage(page, inAppPage());
263
275
  const lay = (items, listTabs, grouped = false) => {
264
276
  /* How long the run of lists containing each section is, so a run of one
265
277
  stays a plain section: one tab is a heading with a border around it. */
@@ -271,7 +283,7 @@ export function Sections({ page, base, recordKey: key, plans, entry, onLabel, on
271
283
  placement anyone chose, and its lists keep the strip. */
272
284
  /* A list that says what it does while empty (`empty: 'hide' | 'collapse'`) is a tab like any other: inside a strip
273
285
  an empty list is neither hidden nor collapsed, its tab shows it and the strip already folds it. */
274
- const tabbed = (section) => section.kind === 'list' && section.presentation !== 'gallery' && (section.width === undefined || !inAppPage());
286
+ const tabbed = (section) => tabbedSection(section, inAppPage(), inferred);
275
287
  /* Outside a strip, such a list is left out or said in one line with its neighbours (PageEmptyRun.tsx). */
276
288
  const emptyable = (section) => section.kind === 'list' && Boolean(section.emptyMode) && (section.presentation !== 'card' || section.emptyMode === 'hide');
277
289
  /* Where a tab holds nothing but such lists, it never ends up with nothing. */
@@ -305,7 +317,7 @@ export function Sections({ page, base, recordKey: key, plans, entry, onLabel, on
305
317
  if (listTabs && autoTabs && listRuns.has(i) && (listRuns.get(i) ?? 0) > 1) {
306
318
  if (!strip) {
307
319
  strip = [];
308
- laid.push(_jsx(ListTabs, { items: strip, entry: entry, onTab: onTab, draw: draw, scoped: scoped }, `tabs-${i}`));
320
+ laid.push(_jsx(ListTabs, { items: strip, entry: entry, onTab: onTab, draw: draw, scoped: scoped, counting: inferred ? { base, recordKey: key } : undefined }, `tabs-${i}`));
309
321
  }
310
322
  strip.push(item);
311
323
  leave = null;
@@ -321,7 +333,8 @@ export function Sections({ page, base, recordKey: key, plans, entry, onLabel, on
321
333
  return;
322
334
  }
323
335
  leave = null;
324
- laid.push(draw(item));
336
+ /* A related list alone on an inferred page says its count in its head, as it would on its tab. */
337
+ laid.push(draw(item, false, inferred && listTabs && autoTabs && item.section.kind === 'list' && tabbed(item.section)));
325
338
  });
326
339
  return laid;
327
340
  };
@@ -11,6 +11,8 @@
11
11
  .sk-page-section { display: grid; gap: var(--space-4); }
12
12
  .sk-page-fields { grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: var(--space-4) var(--field-gap); }
13
13
  .sk-page-aside .sk-page-fields { grid-template-columns: minmax(0, 1fr); }
14
+ .sk-page-fields.is-rail { grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); }
15
+ .sk-page-fields.is-rail .sk-page-field { grid-template-columns: min(8rem, 30%) minmax(0, 1fr); align-items: center; gap: var(--space-4); }
14
16
  .sk-page-field { display: grid; gap: var(--space-1h); }
15
17
  .sk-page-block { display: grid; gap: var(--space-3); }
16
18
  .sk-page-section .sk-grid { padding-inline: 0; }
@@ -8,7 +8,9 @@ import { GridSkeleton, bar, widthAt } from './Skeleton.js';
8
8
  import './PageSkeleton.css';
9
9
  /** One section of a record page, before it answers: its title's bar, then rows in its own shape. */
10
10
  function sectionShape(section, i) {
11
- const body = section.kind === 'fields' ? (_jsx("div", { className: "sk-fields sk-page-fields", children: Array.from({ length: Math.min(Math.max(section.paths?.length ?? 4, 2), 8) }, (_, f) => (_jsxs("div", { className: "sk-page-field", children: [bar(30, 9), bar(widthAt(f + i), 12)] }, f))) })) : section.kind === 'list' ? (_jsx(GridSkeleton, { columns: 4, rows: 3 })) : (_jsxs("div", { className: "sk-page-block", children: [bar(widthAt(i) + 10, 12), bar(widthAt(i + 1), 12), bar(widthAt(i + 2) * 0.6, 12)] }));
11
+ /* A rail, and an inferred page's classic form, say each caption beside its value (structure.css). */
12
+ const rail = section.kind === 'fields' && section.presentation === 'properties';
13
+ const body = section.kind === 'fields' ? (_jsx("div", { className: rail ? 'sk-fields sk-page-fields is-rail' : 'sk-fields sk-page-fields', children: Array.from({ length: Math.min(Math.max(section.paths?.length ?? 4, 2), 8) }, (_, f) => (_jsxs("div", { className: "sk-page-field", children: [bar(30, 9), bar(widthAt(f + i), 12)] }, f))) })) : section.kind === 'list' ? (_jsx(GridSkeleton, { columns: 4, rows: 3 })) : (_jsxs("div", { className: "sk-page-block", children: [bar(widthAt(i) + 10, 12), bar(widthAt(i + 1), 12), bar(widthAt(i + 2) * 0.6, 12)] }));
12
14
  return (_jsxs("section", { className: "sk-page-section", children: [section.title ? bar(18, 12) : null, body] }, i));
13
15
  }
14
16
  /**
@@ -19,7 +21,13 @@ function sectionShape(section, i) {
19
21
  */
20
22
  export function PageSkeleton({ sections }) {
21
23
  const shown = sections.filter((section) => !section.hidden);
22
- const main = shown.filter((section) => section.region !== 'aside').slice(0, 4);
24
+ /* The header is the head's, drawn above; the main column's placeholders are its sections. */
25
+ const main = shown
26
+ .filter((section) => section.region !== 'aside' && !(section.kind === 'fields' && section.presentation === 'header'))
27
+ .slice(0, 4);
23
28
  const aside = shown.filter((section) => section.region === 'aside').slice(0, 3);
24
- return (_jsxs("div", { className: "sk-page", role: "status", "aria-label": say('loadingRecord'), children: [_jsxs("div", { className: "sk-page-head", children: [bar(32, 22), _jsx("div", { className: "sk-page-facts", children: Array.from({ length: 4 }, (_, f) => (_jsxs("span", { className: "sk-page-fact", children: [bar(60, 9), bar(widthAt(f + 2), 12)] }, f))) })] }), _jsxs("div", { className: aside.length ? 'page-layout sk-page-layout' : 'sk-page-layout', children: [_jsx("div", { className: "sk-page-main", children: main.map(sectionShape) }), aside.length ? _jsx("div", { className: "sk-page-aside", children: aside.map(sectionShape) }) : null] })] }));
29
+ /* The head as the page draws it: a record's kind is not drawn over its name in an App (PageHead.tsx), and the line
30
+ under the name stands where the page has one. */
31
+ const subtitled = shown.some((section) => section.kind === 'fields' && section.presentation === 'header' && section.subtitle);
32
+ return (_jsxs("div", { className: "sk-page", role: "status", "aria-label": say('loadingRecord'), children: [_jsxs("div", { className: "sk-page-head", children: [bar(32, 22), subtitled ? bar(22, 12) : null, _jsx("div", { className: "sk-page-facts", children: Array.from({ length: 4 }, (_, f) => (_jsxs("span", { className: "sk-page-fact", children: [bar(60, 9), bar(widthAt(f + 2), 12)] }, f))) })] }), _jsxs("div", { className: aside.length ? 'page-layout sk-page-layout' : 'sk-page-layout', children: [_jsx("div", { className: "sk-page-main", children: main.map(sectionShape) }), aside.length ? _jsx("div", { className: "sk-page-aside", children: aside.map(sectionShape) }) : null] })] }));
25
33
  }
@@ -9,14 +9,77 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
9
  */
10
10
  import { useEffect, useRef, useState } from 'react';
11
11
  import { humanName } from '@mistriwork/engine/shared/model.js';
12
+ import { isAppIcon } from '@mistriwork/engine/shared/appIcons.js';
12
13
  import { shell } from '../shellMode.js';
14
+ import { findTable, openRecord } from '../core.js';
13
15
  import { findRecords, findableTables } from './recordSearch.js';
16
+ import { appRooms, isListRoom } from './appRooms.js';
17
+ import { Icon } from './Icon.js';
14
18
  import { whenMenuChanges } from '../menu.js';
15
19
  import { entries } from '../palette.js';
20
+ import { recentVisits } from '../paletteRecents.js';
16
21
  import { score } from './paletteModel.js';
17
22
  import { offeredChoices } from './pickerStaleness.js';
18
23
  import { say } from '../copy/shell/components/Palette.js';
19
24
  import { addHostListener, removeHostListener } from '../shellHost.js';
25
+ const GROUPS = ['recent', 'pages', 'create', 'commands', 'records'];
26
+ /** A palette is a shortlist: the best of each group, so one long group cannot push the others off the list. */
27
+ const MOST = { recent: 4, pages: 8, create: 5, commands: 4, records: 9 };
28
+ /** Before anything is typed a long menu's pages are a first handful, not the menu again: Create must be on the list's
29
+ first screen. A menu that fits the shortlist (MOST.pages) is shown whole: cut to five, an App of seven lists hid
30
+ two of them until a word was typed. */
31
+ const FIRST_PAGES = 5;
32
+ const groupOf = (item) => item.kind === 'page' ? 'pages' : item.kind === 'create' ? 'create' : item.kind === 'record' ? 'records' : 'commands';
33
+ function groupWord(group) {
34
+ switch (group) {
35
+ case 'recent':
36
+ return say('groupRecent');
37
+ case 'pages':
38
+ return say('groupPages');
39
+ case 'create':
40
+ return say('groupCreate');
41
+ case 'commands':
42
+ return say('groupCommands');
43
+ case 'records':
44
+ return say('groupRecords');
45
+ }
46
+ }
47
+ /** The line under a row's name: what it opens, said in words and then what the row says of itself. A record's own line begins with its table, which is its kind. */
48
+ function detailOf(item) {
49
+ if (item.kind === 'record')
50
+ return item.detail ?? undefined;
51
+ const word = kindWord(item.kind);
52
+ const kind = word.charAt(0).toUpperCase() + word.slice(1);
53
+ return item.detail ? say('kindDetail', { kind, detail: item.detail }) : kind;
54
+ }
55
+ /** The mark of the list that serves a table: what a record of it is drawn with. */
56
+ function iconOfTable(tableId) {
57
+ const app = shell().app();
58
+ return app ? appRooms(app).find((room) => isListRoom(room) && room.table === tableId)?.icon : undefined;
59
+ }
60
+ /** Where the reader just was: the rooms they left (found among the palette's own pages) and the records they read. */
61
+ function recentItems(listed) {
62
+ const places = new Map(listed.flatMap((item) => (item.kind === 'page' && item.room !== undefined ? [[item.room, item]] : [])));
63
+ return recentVisits()
64
+ .flatMap((visit) => {
65
+ if ('room' in visit) {
66
+ const place = places.get(visit.room);
67
+ return place ? [place] : [];
68
+ }
69
+ const table = findTable(visit.table);
70
+ return [
71
+ {
72
+ kind: 'record',
73
+ label: visit.label,
74
+ search: '',
75
+ detail: `${humanName(table?.name ?? visit.table)} · ${Object.values(visit.key).join('/')}`,
76
+ icon: iconOfTable(visit.table),
77
+ run: () => void openRecord(visit.table, visit.key, visit.label),
78
+ },
79
+ ];
80
+ })
81
+ .slice(0, MOST.recent);
82
+ }
20
83
  /** In app mode the App's lists name the tables worth searching and their label columns name the words people search by. */
21
84
  /** What a row opens, in words: the kinds are the registry's identifiers, not copy. */
22
85
  function kindWord(kind) {
@@ -39,6 +102,8 @@ function kindWord(kind) {
39
102
  return say('kindSql');
40
103
  case 'database':
41
104
  return say('kindDatabase');
105
+ case 'create':
106
+ return say('kindCreate');
42
107
  default:
43
108
  return kind;
44
109
  }
@@ -51,12 +116,12 @@ export function Palette({ prefill = '', onClose }) {
51
116
  const input = useRef(null);
52
117
  const list = useRef(null);
53
118
  const [listed, setAll] = useState(() => entries());
54
- /* The header's New menu, searchable, from the reading its button uses — fetched with that reading, and only
55
- where the App declares the menu, so the shell's first page carries none of it. */
119
+ /* The header's New menu, searchable, from the reading its button uses — or, where the App declares none, the New
120
+ its lists offer — fetched with that reading, so the shell's first page carries none of it. */
56
121
  const [made, setMade] = useState([]);
57
122
  useEffect(() => {
58
123
  const app = shell().inApp() ? shell().app() : null;
59
- if (!app?.ui.shell?.new?.length)
124
+ if (!app)
60
125
  return;
61
126
  let live = true;
62
127
  void import('./newMenuModel.js').then((model) => {
@@ -95,6 +160,7 @@ export function Palette({ prefill = '', onClose }) {
95
160
  label: found.label,
96
161
  search: '',
97
162
  detail: `${humanName(findable.table.name)} · ${Object.values(found.key).join('/')}`,
163
+ icon: findable.room.icon,
98
164
  run: found.open,
99
165
  })))).then((hits) => {
100
166
  if (mine !== recordToken.current)
@@ -105,21 +171,41 @@ export function Palette({ prefill = '', onClose }) {
105
171
  return () => clearTimeout(timer);
106
172
  }, [query]); // eslint-disable-line react-hooks/exhaustive-deps
107
173
  const term = query.trim();
108
- const named = all
174
+ const inApp = shell().inApp();
175
+ const ranked = all
109
176
  .map((item) => ({ item, points: score(item.search, term) }))
110
177
  .filter(({ points }) => points > 0)
111
178
  .sort((a, b) => b.points - a.points)
112
- // Bounded because a palette is a shortlist.
113
- .slice(0, 20)
114
179
  .map(({ item }) => item);
180
+ // Bounded because a palette is a shortlist.
181
+ const named = ranked.slice(0, 20);
115
182
  /* Hits for earlier text keep only the rows this text also names: with
116
183
  nothing named above them, the first is lit and Enter would open a record
117
184
  the box never named. Until the hits answer this text, "nothing matches"
118
185
  is not yet true either. */
119
186
  const hits = offeredChoices({ typed: term, asked: records.term, rows: records.items, label: (item) => item.label });
120
187
  const settled = hits.answered || term.length < 2 || !recordTables().length;
188
+ /* An App's rows stand in groups, each ranked within itself: where the reader was (only before they type — typing is
189
+ asking for something else), the pages, what they can make, the commands, and the records the words found. A room
190
+ they were just in is under Recent and not again under Pages. */
191
+ const recent = inApp && !term ? recentItems(listed) : [];
192
+ const recentRooms = new Set(recent.flatMap((item) => (item.room === undefined ? [] : [item.room])));
193
+ const pageCount = ranked.filter((item) => groupOf(item) === 'pages' && !(item.room !== undefined && recentRooms.has(item.room))).length;
194
+ const grouped = GROUPS.map((group) => ({
195
+ group,
196
+ items: group === 'recent'
197
+ ? recent
198
+ : (group === 'records'
199
+ ? hits.choices
200
+ : ranked.filter((item) => groupOf(item) === group && !(item.room !== undefined && recentRooms.has(item.room)))).slice(0, group === 'pages' && !term && pageCount > MOST.pages ? FIRST_PAGES : MOST[group]),
201
+ }))
202
+ .filter(({ items }) => items.length)
203
+ .map((entry, at, every) => ({ ...entry, from: every.slice(0, at).reduce((sum, { items }) => sum + items.length, 0) }));
121
204
  /* Record hits ride below the named things: a table you typed exactly still wins the top. */
122
- const shown = [...named, ...hits.choices].slice(0, 20);
205
+ const rows = inApp
206
+ ? grouped.flatMap(({ group, items }) => items.map((item) => ({ item, group })))
207
+ : [...named, ...hits.choices].slice(0, 20).map((item) => ({ item, group: groupOf(item) }));
208
+ const shown = rows.map(({ item }) => item);
123
209
  const current = shown.length ? ((active % shown.length) + shown.length) % shown.length : 0;
124
210
  const choose = (index) => {
125
211
  const item = shown[index];
@@ -162,15 +248,27 @@ export function Palette({ prefill = '', onClose }) {
162
248
  return () => removeHostListener(document, 'keydown', onKey, true);
163
249
  });
164
250
  useEffect(() => {
165
- list.current?.children[current]?.scrollIntoView?.({ block: 'nearest' });
251
+ const row = list.current?.querySelector(`#palette-o${current}`);
252
+ /* The first row of a group brings its heading with it, so a list scrolled up by the arrows does not leave the
253
+ group nameless. */
254
+ const head = row?.previousElementSibling?.classList.contains('palette-group-head') ? row.previousElementSibling : row;
255
+ head?.scrollIntoView?.({ block: 'nearest' });
166
256
  }, [current, shown.length]);
167
257
  return (_jsx("div", { className: "palette-backdrop", onPointerDown: (e) => {
168
258
  if (e.target === e.currentTarget)
169
259
  onClose();
170
- }, children: _jsxs("div", { className: "palette", role: "dialog", "aria-modal": "true", "aria-label": say('navigation.search'), children: [_jsx("input", { ref: input, type: "text", className: "palette-input", placeholder: shell().inApp() ? say('searchRecordsPagesAndCommands') : say('goToATable'), "aria-label": say('navigation.search'), autoComplete: "off", spellCheck: false, role: "combobox", "aria-autocomplete": "list", "aria-expanded": "true", "aria-controls": "palette-list", "aria-activedescendant": shown.length ? `palette-o${current}` : undefined, value: query, onChange: (e) => {
260
+ }, children: _jsxs("div", { className: `palette${inApp ? ' palette-grouped' : ''}`, role: "dialog", "aria-modal": "true", "aria-label": say('navigation.search'), children: [_jsx("input", { ref: input, type: "text", className: "palette-input", placeholder: shell().inApp() ? say('searchRecordsPagesAndCommands') : say('goToATable'), "aria-label": say('navigation.search'), autoComplete: "off", spellCheck: false, role: "combobox", "aria-autocomplete": "list", "aria-expanded": "true", "aria-controls": "palette-list", "aria-activedescendant": shown.length ? `palette-o${current}` : undefined, value: query, onChange: (e) => {
171
261
  setQuery(e.currentTarget.value);
172
262
  setActive(0);
173
263
  } }), _jsx("div", { ref: list, className: "palette-list", id: "palette-list", role: "listbox", children: !shown.length
174
264
  ? settled && _jsx("p", { className: "palette-empty", children: term ? say('nothingMatches', { term }) : say('nothingToGo') })
175
- : shown.map((item, i) => (_jsxs("div", { className: `palette-item${i === current ? ' active' : ''}`, id: `palette-o${i}`, role: "option", "aria-selected": i === current, onClick: () => choose(i), onMouseMove: () => setActive(i), children: [_jsx("span", { className: `palette-kind kind-${item.kind}`, children: kindWord(item.kind) }), _jsx("span", { className: "palette-label", children: item.label }), item.detail ? _jsx("span", { className: "palette-detail", children: item.detail }) : null] }, `${item.kind}:${item.label}:${i}`))) })] }) }));
265
+ : inApp
266
+ ? grouped.map(({ group, items, from: first }) => {
267
+ return (_jsxs("div", { className: "palette-group", role: "group", "aria-labelledby": `palette-g-${group}`, children: [_jsx("div", { className: "palette-group-head", id: `palette-g-${group}`, children: groupWord(group) }), items.map((item, at) => {
268
+ const i = first + at;
269
+ const detail = detailOf(item);
270
+ return (_jsxs("div", { className: `palette-item${i === current ? ' active' : ''}`, id: `palette-o${i}`, role: "option", "aria-selected": i === current, "aria-labelledby": `palette-o${i}-name`, "aria-describedby": detail ? `palette-o${i}-line` : undefined, "data-group": group, onClick: () => choose(i), onMouseMove: () => setActive(i), children: [_jsx("span", { className: "palette-icon", "aria-hidden": "true", children: isAppIcon(item.icon) ? _jsx(Icon, { name: item.icon, size: 16 }) : null }), _jsx("span", { className: "palette-label", id: `palette-o${i}-name`, children: item.label }), detail ? (_jsx("span", { className: "palette-detail", id: `palette-o${i}-line`, children: detail })) : null] }, `${group}:${item.kind}:${item.label}:${at}`));
271
+ })] }, group));
272
+ })
273
+ : shown.map((item, i) => (_jsxs("div", { className: `palette-item${i === current ? ' active' : ''}`, id: `palette-o${i}`, role: "option", "aria-selected": i === current, onClick: () => choose(i), onMouseMove: () => setActive(i), children: [_jsx("span", { className: `palette-kind kind-${item.kind}`, children: kindWord(item.kind) }), _jsx("span", { className: "palette-label", children: item.label }), item.detail ? _jsx("span", { className: "palette-detail", children: item.detail }) : null] }, `${item.kind}:${item.label}:${i}`))) }), inApp ? (_jsxs("div", { className: "palette-foot", "aria-hidden": "true", children: [_jsxs("span", { className: "palette-hint", children: [_jsx("kbd", { children: "\u2191" }), _jsx("kbd", { children: "\u2193" }), " ", say('hintMove')] }), _jsxs("span", { className: "palette-hint", children: [_jsx("kbd", { children: "\u21B5" }), " ", say('hintOpen')] }), _jsxs("span", { className: "palette-hint", children: [_jsx("kbd", { children: say('keyEscape') }), " ", say('hintClose')] })] })) : null] }) }));
176
274
  }
@@ -5,6 +5,8 @@ interface Choice {
5
5
  label: string;
6
6
  /** The row the choice was read from, where the picker draws more of it than its name (`face`). */
7
7
  row?: Record<string, unknown>;
8
+ /** The second line that tells it from another of the same name (referenceSubline.ts): its code, email, parent, day. */
9
+ sub?: string;
8
10
  }
9
11
  /** More of each choice than its name: the columns it is read with, and how a choice is drawn from them (FormLines.tsx). */
10
12
  interface PickerFace {
@@ -25,17 +25,27 @@ import { primaryKey } from '@mistriwork/engine/shared/schema.js';
25
25
  import { humanName } from '@mistriwork/engine/shared/model.js';
26
26
  import { shell } from '../shellMode.js';
27
27
  import { resourceOf } from './appRooms.js';
28
+ import { collidingNames, referenceSubline, sublineText } from '@mistriwork/engine/shared/referenceSubline.js';
28
29
  import { sessionIdentity, subscribeSessionIdentity } from '../sessionIdentity.js';
29
30
  import { say } from '../copy/forms/components/RecordPicker.js';
30
31
  const LIMIT = 20;
32
+ /** The second line a table's choices are read with, by the rule every reference shares, with the App's display rule. */
33
+ function sublineFor(table) {
34
+ const naming = labelPath(table);
35
+ if (naming?.startsWith('$'))
36
+ return undefined;
37
+ const display = resourceOf(shell().app(), table.id)?.display;
38
+ return referenceSubline(state.schema ?? undefined, table, naming, display);
39
+ }
31
40
  /** The rows whose name contains the text, twenty at a time, every value bound. */
32
- async function searchRecords(table, text, valueColumn = primaryKey(table)[0], connection = state.activeConnection, narrowed = '', more = []) {
41
+ async function searchRecords(table, text, valueColumn = primaryKey(table)[0], connection = state.activeConnection, narrowed = '', more = [], sub) {
33
42
  const naming = labelPath(table) ?? valueColumn;
34
43
  const pk = valueColumn;
35
44
  if (!pk)
36
45
  return [];
46
+ const second = sub && sub.path !== pk ? [sub.path] : [];
37
47
  const where = [narrowed, text ? `${naming} contains ${JSON.stringify(text)}` : ''].filter(Boolean).join(' and ');
38
- const q = [table.id, where, `show ${[...new Set([naming, pk, ...primaryKey(table), ...more])].join(', ')}`, `sort ${naming}`]
48
+ const q = [table.id, where, `show ${[...new Set([naming, pk, ...primaryKey(table), ...more, ...second])].join(', ')}`, `sort ${naming}`]
39
49
  .filter(Boolean)
40
50
  .join(' ');
41
51
  const data = await api('/api/run', {
@@ -49,6 +59,7 @@ async function searchRecords(table, text, valueColumn = primaryKey(table)[0], co
49
59
  value: String(r[pk]),
50
60
  label: recordLabel(table) === undefined ? String(r[naming] ?? r[pk]) : rowLabel(table, r),
51
61
  ...(more.length ? { row: r } : {}),
62
+ ...(second.length && sublineText(r[second[0]]) ? { sub: sublineText(r[second[0]]) } : {}),
52
63
  }));
53
64
  }
54
65
  export function RecordPicker(props) {
@@ -71,10 +82,14 @@ function RecordPickerControl(props) {
71
82
  const editing = props.editing;
72
83
  const connection = state.activeConnection;
73
84
  const valueColumn = props.valueColumn ?? primaryKey(table)[0];
85
+ /* What tells two choices of one name apart (a face draws its own). */
86
+ const subline = props.face ? undefined : sublineFor(table);
74
87
  const ids = props.multiple === true ? props.value : props.value ? [props.value] : [];
75
88
  /* Labels for what is chosen: known once a name has been picked, the id
76
89
  itself until then (a preset value arrives as an id alone). */
77
90
  const [labels, setLabels] = useState(new Map());
91
+ /* Each chosen record's second line, so two chips of one name are told apart as their choices were. */
92
+ const [subs, setSubs] = useState(new Map());
78
93
  /* A value's name: fetched, else the one the caller draws for it (`known`), else the value itself. */
79
94
  const known = props.multiple !== true ? props.known : undefined;
80
95
  const nameOf = (value) => labels.get(value) ?? (known?.value === value ? known.label : undefined) ?? value;
@@ -141,8 +156,9 @@ function RecordPickerControl(props) {
141
156
  recordLabel(table),
142
157
  props.where ?? '',
143
158
  props.face?.columns.join(),
159
+ subline?.path,
144
160
  ],
145
- queryFn: () => searchRecords(table, asked, valueColumn, connection, props.where, props.face?.columns),
161
+ queryFn: () => searchRecords(table, asked, valueColumn, connection, props.where, props.face?.columns, props.face ? undefined : subline),
146
162
  enabled: open && !props.disabled,
147
163
  /* The last answer stays on screen while the next is fetched: a list
148
164
  that empties between keystrokes flickers, and an option someone is
@@ -169,13 +185,13 @@ function RecordPickerControl(props) {
169
185
  label: (o) => o.label,
170
186
  });
171
187
  const selected = useQuery({
172
- queryKey: ['picker-labels', connection, table.id, valueColumn, ids, props.scope, labelPath(table), recordLabel(table)],
188
+ queryKey: ['picker-labels', connection, table.id, valueColumn, ids, props.scope, labelPath(table), recordLabel(table), subline?.path],
173
189
  enabled: Boolean(valueColumn && ids.length),
174
190
  queryFn: async () => {
175
191
  const naming = labelPath(table) ?? valueColumn;
176
- const columns = [...new Set([valueColumn, naming, ...primaryKey(table)])];
192
+ const columns = [...new Set([valueColumn, naming, ...primaryKey(table), ...(props.multiple && subline ? [subline.path] : [])])];
177
193
  /* A walked name and a label template (`$label`) are paths, which a view reads and a plain query does not. */
178
- const data = naming.includes('.') || naming.startsWith('$')
194
+ const data = columns.some((path) => path.includes('.')) || naming.startsWith('$')
179
195
  ? await api('/api/view/run', {
180
196
  ...ownedBy(connection),
181
197
  view: {
@@ -202,12 +218,15 @@ function RecordPickerControl(props) {
202
218
  return (data.rows ?? []).map((row) => ({
203
219
  value: String(row[valueColumn]),
204
220
  label: recordLabel(table) === undefined ? String(row[naming] ?? row[valueColumn]) : rowLabel(table, row),
221
+ ...(props.multiple && subline && sublineText(row[subline.path]) ? { sub: sublineText(row[subline.path]) } : {}),
205
222
  }));
206
223
  },
207
224
  });
208
225
  useEffect(() => {
209
226
  if (selected.data)
210
227
  setLabels((known) => new Map([...known, ...selected.data.map((choice) => [choice.value, choice.label])]));
228
+ if (selected.data?.some((choice) => choice.sub))
229
+ setSubs((known) => new Map([...known, ...selected.data.flatMap((choice) => (choice.sub ? [[choice.value, choice.sub]] : []))]));
211
230
  }, [selected.data]);
212
231
  useEffect(() => {
213
232
  if (editing)
@@ -230,6 +249,8 @@ function RecordPickerControl(props) {
230
249
  };
231
250
  const pick = (choice) => {
232
251
  setLabels((m) => new Map(m).set(choice.value, choice.label));
252
+ if (choice.sub)
253
+ setSubs((m) => new Map(m).set(choice.value, choice.sub));
233
254
  if (props.multiple) {
234
255
  report(ids.includes(choice.value) ? ids.filter((v) => v !== choice.value) : [...ids, choice.value]);
235
256
  setText('');
@@ -252,6 +273,11 @@ function RecordPickerControl(props) {
252
273
  input.current?.focus();
253
274
  };
254
275
  const shownLabel = (value) => labels.get(value) ?? value;
276
+ /* A second line where it tells two of one name apart, or always where the App's display asked for one. */
277
+ const twice = collidingNames(options.map((o) => o.label));
278
+ const subOf = (o) => (o.sub && (subline?.declared || twice.has(o.label)) ? o.sub : undefined);
279
+ const twiceChosen = collidingNames(ids.map(shownLabel));
280
+ const chipName = (value) => twiceChosen.has(shownLabel(value)) && subs.get(value) ? `${shownLabel(value)} · ${subs.get(value)}` : shownLabel(value);
255
281
  return (_jsxs("div", { className: `picker${props.multiple ? ' picker-multi' : ''}`, ref: wrap, onKeyDownCapture: (e) => {
256
282
  if (editing && open && e.key === 'Escape') {
257
283
  e.preventDefault();
@@ -261,7 +287,7 @@ function RecordPickerControl(props) {
261
287
  setOpen(false);
262
288
  }
263
289
  }, children: [_jsx("span", { className: "picker-chips", children: props.multiple &&
264
- ids.map((value) => (_jsxs("span", { className: "picker-chip", children: [_jsx("span", { children: shownLabel(value) }), _jsx("button", { type: "button", className: "picker-chip-x", "aria-label": say('remove', { shownLabel: shownLabel(value) }), onClick: () => remove(value), children: "\u00D7" })] }, value))) }), _jsx(Typeahead, { text: text, onText: (next) => {
290
+ ids.map((value) => (_jsxs("span", { className: "picker-chip", children: [_jsx("span", { children: chipName(value) }), _jsx("button", { type: "button", className: "picker-chip-x", "aria-label": say('remove', { shownLabel: chipName(value) }), onClick: () => remove(value), children: "\u00D7" })] }, value))) }), _jsx(Typeahead, { text: text, onText: (next) => {
265
291
  if (editing)
266
292
  setSearch(next);
267
293
  else
@@ -269,7 +295,7 @@ function RecordPickerControl(props) {
269
295
  setOpen(true);
270
296
  if (!editing && !props.multiple && ids.length)
271
297
  report([]);
272
- }, open: open, onOpenChange: setOpen, items: options, itemKey: (o) => o.value, itemLabel: (o) => o.label, itemClassName: (o, highlighted) => `picker-option${highlighted ? ' active' : ''}${ids.includes(o.value) ? ' chosen' : ''}`, renderItem: (o) => props.face && o.row ? (props.face.draw(o.row, o.label, options.flatMap((each) => (each.row ? [each.row] : [])))) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "picker-option-label", children: o.label }), !props.hideKey && o.label !== o.value && _jsx("span", { className: "picker-option-detail", children: o.value })] })), onPick: pick, inputRef: setInput, popupRef: editing?.popupRef, anchorRef: wrap, fit: "width", inputProps: {
298
+ }, open: open, onOpenChange: setOpen, items: options, itemKey: (o) => o.value, itemLabel: (o) => o.label, itemClassName: (o, highlighted) => `picker-option${highlighted ? ' active' : ''}${ids.includes(o.value) ? ' chosen' : ''}`, renderItem: (o) => props.face && o.row ? (props.face.draw(o.row, o.label, options.flatMap((each) => (each.row ? [each.row] : [])))) : (_jsxs(_Fragment, { children: [subOf(o) ? (_jsxs("span", { className: "picker-option-name", children: [_jsx("span", { className: "picker-option-label", children: o.label }), _jsx("span", { className: "picker-option-sub", children: subOf(o) })] })) : (_jsx("span", { className: "picker-option-label", children: o.label })), !props.hideKey && o.label !== o.value && _jsx("span", { className: "picker-option-detail", children: o.value })] })), onPick: pick, inputRef: setInput, popupRef: editing?.popupRef, anchorRef: wrap, fit: "width", inputProps: {
273
299
  type: 'text',
274
300
  className: 'picker-input',
275
301
  'aria-label': ariaLabel ?? say('choose', { name: humanName(table.name) }),
@@ -5,6 +5,7 @@ import { columnLabel, keyOf, labelPath, openRecord, recordLabel, rowLabel, state
5
5
  import { opensRecord } from '../recordIntent.js';
6
6
  import { humanName } from '@mistriwork/engine/shared/model.js';
7
7
  import { primaryKey } from '@mistriwork/engine/shared/schema.js';
8
+ import { TAGS_TYPE, tagChips } from '@mistriwork/engine/shared/tagLists.js';
8
9
  import { Value } from './Value.js';
9
10
  import { rowOpensTarget, useRowOpens } from './rowOpens.js';
10
11
  import { presentationColumns } from './columnPresentation.js';
@@ -151,7 +152,11 @@ export function RecordSummaries({ table, data, columns, labels, referenceLabels,
151
152
  };
152
153
  const value = label ?? row[name];
153
154
  const adorned = adornFact && (value === null || value === undefined || value === '') ? adornFact(row, name) : undefined;
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));
155
+ /* An App's phone row leaves a fact with no value out (style.css): its caption is not drawn, so the mark
156
+ alone would say nothing. What the host draws in its place (`adornFact`) is something, and stays. */
157
+ const empty = adorned === undefined &&
158
+ (value === null || value === undefined || value === '' || (col.type === TAGS_TYPE && !tagChips(value).length));
159
+ return (_jsxs("div", { "data-empty": empty ? '' : undefined, 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));
155
160
  }) })] }, key ? JSON.stringify(key) : index));
156
161
  if (!head)
157
162
  return summary;
@@ -6,7 +6,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
6
6
  * (a crumb corrected once a name is known, the address written when a
7
7
  * control moves) and the host the component is drawn into.
8
8
  */
9
- import { FavoriteStar } from './FavoriteStar.js';
9
+ import { DashHead } from './DashHead.js';
10
10
  import { useEffect, useRef, useState } from 'react';
11
11
  import { allowMutationExit, api, beginNavigation, captureNavigation, currentEntry, findTable, go, humanName, keyOf, pageFor, pageView, primaryKey, refsTo, renderCrumbs, state, tableView, } from '../core.js';
12
12
  import { equalityFilter } from '../resourceRequests.js';
@@ -125,7 +125,7 @@ function DashboardBody({ entry, dashboard }) {
125
125
  state.navMode = 'replace';
126
126
  syncHash();
127
127
  };
128
- return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "applist-head dash-head", children: [_jsx("h1", { className: `applist-title${dashboard.headingHidden ? ' visually-hidden' : ''}`, children: dashboard.heading ?? dashboard.label }), dashboard.favorite && (_jsx(FavoriteStar, { favorite: { kind: 'view', view: dashboard.id, label: dashboard.label }, name: dashboard.label })), dashboard.description && _jsx("p", { className: "note dash-description", children: dashboard.description })] }), _jsx("div", { children: Dashboard && (_jsx(Dashboard, { dashboard: dashboard, window: fromLink, picks: pickedFromLink, periods: periodsFromLink, onWindow: (w) => {
128
+ return (_jsxs(_Fragment, { children: [_jsx(DashHead, { dashboard: dashboard }), _jsx("div", { children: Dashboard && (_jsx(Dashboard, { dashboard: dashboard, window: fromLink, picks: pickedFromLink, periods: periodsFromLink, onWindow: (w) => {
129
129
  windowOn.current = w;
130
130
  writeSlot();
131
131
  }, onPick: (p) => {
@@ -0,0 +1,15 @@
1
+ /**
2
+ * A column's second line: the column its display rule names (`subtitle`, another column of the same record), drawn
3
+ * quietly under the value wherever there is room for one (docs/design.md). Its own module so a test that stands a
4
+ * value in for Value.tsx still draws the second line it is about.
5
+ */
6
+ import type { ReactNode } from 'react';
7
+ /** The second line of `column` on `row`, as the record or the list read it with the row; none where it has no value. */
8
+ export declare function secondLine(tableId: string | undefined, column: string | undefined, row: Readonly<Record<string, unknown>> | undefined): string | undefined;
9
+ /** Something drawn with its column's second line quietly under it, as a list's cell does. */
10
+ export declare function Subtitled({ tableId, column, row, children, }: {
11
+ tableId: string | undefined;
12
+ column: string | undefined;
13
+ row: Readonly<Record<string, unknown>> | undefined;
14
+ children: ReactNode;
15
+ }): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal>;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { columnDisplay } from '../core.js';
3
+ import { subtitlePath } from './valueModel.js';
4
+ /** The second line of `column` on `row`, as the record or the list read it with the row; none where it has no value. */
5
+ export function secondLine(tableId, column, row) {
6
+ if (tableId === undefined || !column || !row)
7
+ return undefined;
8
+ const path = subtitlePath(columnDisplay(tableId, column), column);
9
+ const second = path !== undefined && Object.hasOwn(row, path) ? row[path] : undefined;
10
+ return second === null || second === undefined || second === '' ? undefined : String(second);
11
+ }
12
+ /** Something drawn with its column's second line quietly under it, as a list's cell does. */
13
+ export function Subtitled({ tableId, column, row, children, }) {
14
+ const second = secondLine(tableId, column, row);
15
+ if (second === undefined)
16
+ return children;
17
+ return (_jsxs("span", { className: "value-subtitled", children: [children, _jsx("span", { className: "value-sub", children: second })] }));
18
+ }
@@ -41,6 +41,7 @@ import { pageStepFor, stepList } from './pageStep.js';
41
41
  import { ExportHold } from './ExportHold.js';
42
42
  import { batchedRun } from '../breakdownBatch.js';
43
43
  import { useListHold } from '../liveState.js';
44
+ import { laneWindow } from '@mistriwork/engine/shared/boardLanes.js';
44
45
  import { say } from '../copy/lists/components/TableRoom.js';
45
46
  /* The diagrams are a chunk of their own, loaded when the Diagram tab is first opened. */
46
47
  /**
@@ -159,16 +160,25 @@ function Rows({ entry: given, chrome, interactive, hide, labels, referenceLabels
159
160
  const page = state.page;
160
161
  const source = connection();
161
162
  /* A page the pager stepped to is read by key, the end with its own length (pageStep.ts). */
162
- const step = asked ? undefined : pageStepFor(stepList(source, entry.table, entry.query, size), page);
163
- const limit = asked ?? step?.limit ?? size;
164
- const offset = asked ? 0 : page * size;
163
+ /* A board reads its lanes' first pages in this one read, windowed by its lane column (boardLanes.ts), and no total:
164
+ it counts its lanes in a breakdown of its own (BoardList.tsx). A query with its own limit is laid out as it is. */
165
+ const board = presentation?.kind === 'board' && !asked ? laneWindow(presentation.by) : undefined;
166
+ const step = asked || board ? undefined : pageStepFor(stepList(source, entry.table, entry.query, size), page);
167
+ const limit = board?.limit ?? asked ?? step?.limit ?? size;
168
+ const offset = asked || board ? 0 : page * size;
165
169
  const exact = entry.exactCount === true;
166
170
  const run = useQuery({
167
- queryKey: ['run', source, entry.table, entry.query, limit, offset, exact, version, step?.body],
171
+ queryKey: ['run', source, entry.table, entry.query, limit, offset, exact, version, step?.body ?? board?.lanes.by],
168
172
  queryFn: async () => {
169
173
  const totalKey = JSON.stringify([source, entry.table, entry.query, exact, version]);
170
174
  const known = offset > 0 ? listTotals.get(totalKey) : undefined;
171
- const asked = { q: entry.query, limit, offset, exactCount: exact, ...(known ? { count: 'none' } : {}) };
175
+ const asked = {
176
+ q: entry.query,
177
+ limit,
178
+ offset,
179
+ exactCount: exact,
180
+ ...(board ? { count: board.count, lanes: board.lanes } : known || entry.counted === false ? { count: 'none' } : {}),
181
+ };
172
182
  /* A table on a dashboard is asked with the dashboard's other sections,
173
183
  in one request (breakdownBatch.ts); a room's own list, and a page
174
184
  stepped to by key, are asked alone. */
@@ -17,6 +17,8 @@ export interface TableEntry {
17
17
  query: string;
18
18
  tab?: string;
19
19
  exactCount?: boolean;
20
+ /** Rows only, no total: a list whose room says none (an overview's, appOverview.ts). */
21
+ counted?: false;
20
22
  }
21
23
  /** What a list's presentation is drawn from (`present`): the list's own props, and the page of rows it holds. */
22
24
  export interface PresentArgs {