@mistriwork/kit 1.0.0-rc.36 → 1.0.0-rc.37

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.
@@ -80,6 +80,12 @@ function trailSetting() {
80
80
  return { top: true, home: true };
81
81
  return { top: said?.top ?? false, home: said?.home ?? false };
82
82
  }
83
+ function bareAt(entry) {
84
+ if (!entry || entry.kind !== 'page' || entry.table || !entry.pageId)
85
+ return false;
86
+ const app = shell().app();
87
+ return (app && dashboardAt(app, entry.pageId)?.layout) === 'bare';
88
+ }
83
89
  // Indices stay the walk's own: only the selected row is left off the end.
84
90
  const trailOf = (walked) => (splitSelection(walked) ? walked.slice(0, -1) : walked);
85
91
  /**
@@ -92,6 +98,12 @@ export function crumbBarShown(walked) {
92
98
  const setting = trailSetting();
93
99
  if (!setting)
94
100
  return false;
101
+ /* A bare page owns the window, and the bar is part of the frame it takes out of the flow (features.css hides the
102
+ sidebar and top bar, not this). Drawn over it, the sticky bar sat on top of the page's own controls and took their
103
+ clicks once the walk had a second step — a param set with `push` — so the page's own layout decides, whatever the
104
+ setting or the history. */
105
+ if (bareAt(walked.at(-1)))
106
+ return false;
95
107
  if (setting.top)
96
108
  return true;
97
109
  const stack = trailOf(walked);
@@ -12,7 +12,7 @@ import { humanName } from '@mistriwork/engine/shared/model.js';
12
12
  import { isAppIcon } from '@mistriwork/engine/shared/appIcons.js';
13
13
  import { shell } from '../shellMode.js';
14
14
  import { findTable, openRecord } from '../core.js';
15
- import { findRecords, findableTables } from './recordSearch.js';
15
+ import { findAcross, searchedTables } from './recordSearch.js';
16
16
  import { appRooms, isListRoom } from './appRooms.js';
17
17
  import { Icon } from './Icon.js';
18
18
  import { whenMenuChanges } from '../menu.js';
@@ -108,9 +108,20 @@ function kindWord(kind) {
108
108
  return kind;
109
109
  }
110
110
  }
111
+ /** The tables the term is searched in: every list the reader's menu holds, up to the search's own ceiling (recordSearch.ts),
112
+ and how many past it are left out. */
111
113
  function recordTables() {
112
114
  const app = shell().inApp() ? shell().app() : null;
113
- return app ? findableTables(app) : [];
115
+ return app ? searchedTables(app) : { tables: [], left: 0 };
116
+ }
117
+ /** The hits one from each table in turn, so the few a palette shows are not the first tables' alone. */
118
+ function interleaved(lists, most) {
119
+ const out = [];
120
+ for (let at = 0; out.length < most && lists.some((each) => at < each.length); at++)
121
+ for (const each of lists)
122
+ if (at < each.length && out.length < most)
123
+ out.push(each[at]);
124
+ return out;
114
125
  }
115
126
  export function Palette({ prefill = '', onClose }) {
116
127
  const input = useRef(null);
@@ -151,23 +162,24 @@ export function Palette({ prefill = '', onClose }) {
151
162
  useEffect(() => {
152
163
  const term = query.trim();
153
164
  const mine = ++recordToken.current;
154
- const tables = recordTables();
165
+ const { tables } = recordTables();
155
166
  if (term.length < 2 || !tables.length) {
156
167
  setRecords({ term, items: [] });
157
168
  return;
158
169
  }
159
170
  const timer = setTimeout(() => {
160
- void Promise.all(tables.map(async (findable) => (await findRecords(findable, term, 3)).map((found) => ({
161
- kind: 'record',
162
- label: found.label,
163
- search: '',
164
- detail: `${humanName(findable.table.name)} · ${Object.values(found.key).join('/')}`,
165
- icon: findable.room.icon,
166
- run: found.open,
167
- })))).then((hits) => {
171
+ void findAcross(tables, term, 3).then((found) => {
168
172
  if (mine !== recordToken.current)
169
173
  return;
170
- setRecords({ term, items: hits.flat().slice(0, 9) });
174
+ const hits = found.map((own, at) => own.map((each) => ({
175
+ kind: 'record',
176
+ label: each.label,
177
+ search: '',
178
+ detail: `${humanName(tables[at].table.name)} · ${Object.values(each.key).join('/')}`,
179
+ icon: tables[at].room.icon,
180
+ run: each.open,
181
+ })));
182
+ setRecords({ term, items: interleaved(hits, MOST.records) });
171
183
  });
172
184
  }, prefill && query === prefill ? 0 : 180);
173
185
  return () => clearTimeout(timer);
@@ -186,7 +198,8 @@ export function Palette({ prefill = '', onClose }) {
186
198
  the box never named. Until the hits answer this text, "nothing matches"
187
199
  is not yet true either. */
188
200
  const hits = offeredChoices({ typed: term, asked: records.term, rows: records.items, label: (item) => item.label });
189
- const settled = hits.answered || term.length < 2 || !recordTables().length;
201
+ const { tables: searched, left } = recordTables();
202
+ const settled = hits.answered || term.length < 2 || !searched.length;
190
203
  /* An App's rows stand in groups, each ranked within itself: where the reader was (only before they type — typing is
191
204
  asking for something else), the pages, what they can make, the commands, and the records the words found. A room
192
205
  they were just in is under Recent and not again under Pages. */
@@ -272,5 +285,5 @@ export function Palette({ prefill = '', onClose }) {
272
285
  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}`));
273
286
  })] }, group));
274
287
  })
275
- : 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] }) }));
288
+ : 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 && left > 0 ? (_jsx("p", { className: "palette-note", role: "note", children: say('searchedSome', { searched: searched.length, total: searched.length + left }) })) : null, 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] }) }));
276
289
  }
@@ -17,8 +17,21 @@ export interface Found {
17
17
  key: Record<string, unknown>;
18
18
  open: () => void;
19
19
  }
20
- /** The tables whose records the reader may find: those of `tables` (ids), or of the App's first lists. */
20
+ /** The most tables one search asks at once, and how many of them are in flight together: a search is one request per
21
+ table, and an App's menu may hold a few dozen lists. */
22
+ export declare const SEARCHED_MOST = 24;
23
+ /** The tables whose records the reader may find: those of `tables` (ids), or of the App's menu, at most `most`. */
21
24
  export declare function findableTables(app: ServedApp, tables?: readonly string[], most?: number): Findable[];
25
+ /** The tables a search over the whole menu asks, and how many it leaves out past SEARCHED_MOST (so it can say so). */
26
+ export declare function searchedTables(app: ServedApp): {
27
+ tables: Findable[];
28
+ left: number;
29
+ };
30
+ /**
31
+ * `limit` records of each table whose names hold `term`, the tables asked a few at a time and answered in the menu's
32
+ * order. A refusal answers nothing for its table (findRecords), never the whole search's failure.
33
+ */
34
+ export declare function findAcross(findables: readonly Findable[], term: string, limit: number, concurrency?: number): Promise<Found[][]>;
22
35
  /**
23
36
  * The line a hit says under its name: what its list says first under a
24
37
  * card's title — a cards description, else the first of its lines — or its
@@ -21,8 +21,12 @@ function findableOf(room) {
21
21
  const label = table ? (labelPath(table) ?? primaryKey(table)[0]) : undefined;
22
22
  return table && label && primaryKey(table).length ? { table, label, room } : undefined;
23
23
  }
24
- /** The tables whose records the reader may find: those of `tables` (ids), or of the App's first lists. */
25
- export function findableTables(app, tables, most = 6) {
24
+ /** The most tables one search asks at once, and how many of them are in flight together: a search is one request per
25
+ table, and an App's menu may hold a few dozen lists. */
26
+ export const SEARCHED_MOST = 24;
27
+ const SEARCH_CONCURRENCY = 6;
28
+ /** Every table the reader may find records of: those of `tables` (ids), or of every list the menu holds, in its order. */
29
+ function findableAll(app, tables) {
26
30
  const seen = new Set();
27
31
  const out = [];
28
32
  const rooms = listRooms(app, Boolean(tables));
@@ -33,11 +37,32 @@ export function findableTables(app, tables, most = 6) {
33
37
  const found = findableOf(room);
34
38
  if (found)
35
39
  out.push(found);
36
- if (out.length >= most)
37
- break;
38
40
  }
39
41
  return out;
40
42
  }
43
+ /** The tables whose records the reader may find: those of `tables` (ids), or of the App's menu, at most `most`. */
44
+ export function findableTables(app, tables, most = SEARCHED_MOST) {
45
+ return findableAll(app, tables).slice(0, most);
46
+ }
47
+ /** The tables a search over the whole menu asks, and how many it leaves out past SEARCHED_MOST (so it can say so). */
48
+ export function searchedTables(app) {
49
+ const every = findableAll(app);
50
+ return { tables: every.slice(0, SEARCHED_MOST), left: Math.max(0, every.length - SEARCHED_MOST) };
51
+ }
52
+ /**
53
+ * `limit` records of each table whose names hold `term`, the tables asked a few at a time and answered in the menu's
54
+ * order. A refusal answers nothing for its table (findRecords), never the whole search's failure.
55
+ */
56
+ export async function findAcross(findables, term, limit, concurrency = SEARCH_CONCURRENCY) {
57
+ const answers = findables.map(() => []);
58
+ let next = 0;
59
+ const worker = async () => {
60
+ for (let at = next++; at < findables.length; at = next++)
61
+ answers[at] = await findRecords(findables[at], term, limit);
62
+ };
63
+ await Promise.all(Array.from({ length: Math.min(concurrency, findables.length) }, worker));
64
+ return answers;
65
+ }
41
66
  /**
42
67
  * The line a hit says under its name: what its list says first under a
43
68
  * card's title — a cards description, else the first of its lines — or its
@@ -3,6 +3,7 @@ export declare const say: import("../../../messages.js").RoomMessage<{
3
3
  readonly goToATable: "Go to a table, view, saved filter or database…";
4
4
  readonly nothingMatches: "Nothing matches \"{term}\".";
5
5
  readonly nothingToGo: "Nothing to go to.";
6
+ readonly searchedSome: "Records are searched in {searched} of {total} lists.";
6
7
  readonly kindPage: "page";
7
8
  readonly kindView: "view";
8
9
  readonly kindTable: "table";
@@ -5,6 +5,8 @@ export const say = defineMessages({
5
5
  goToATable: 'Go to a table, view, saved filter or database…',
6
6
  nothingMatches: 'Nothing matches "{term}".',
7
7
  nothingToGo: 'Nothing to go to.',
8
+ /* An App with more lists than one search asks: the ones left out are said, not silently unsearched. */
9
+ searchedSome: 'Records are searched in {searched} of {total} lists.',
8
10
  /* The badge on each row says what it opens, in the reader's words rather than the registry's identifiers. */
9
11
  kindPage: 'page',
10
12
  kindView: 'view',
@@ -624,6 +624,7 @@ html[data-starting] .content.nav-holding.nav-holding-focusable > :not(.nav-held)
624
624
  .palette-item.active .palette-label { color: var(--accent-ink); }
625
625
  .palette-detail { font: var(--text-xs) var(--mono); color: var(--ink-subtle); }
626
626
  .palette-empty { padding: var(--space-5); margin: 0; font-size: var(--text-sm); color: var(--ink-muted); }
627
+ .palette-note { padding: var(--space-2) var(--space-3h); margin: 0; font-size: var(--text-xs); color: var(--ink-subtle); }
627
628
 
628
629
  /* An App's palette (Palette.tsx, `palette-grouped`; the Workbench keeps the flat list above): rows in groups under
629
630
  quiet headings, each with the mark its room or table has in the menu, the kind said in the line under the name and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistriwork/kit",
3
- "version": "1.0.0-rc.36",
3
+ "version": "1.0.0-rc.37",
4
4
  "description": "The shared React client both shells are drawn with: the walk and the address, Grid, Value, the record page, lists, filters and charts.",
5
5
  "homepage": "https://mistriwork.dev",
6
6
  "bugs": {
@@ -83,8 +83,8 @@
83
83
  "./package.json": "./package.json"
84
84
  },
85
85
  "dependencies": {
86
- "@mistriwork/engine": "1.0.0-rc.36",
87
- "@mistriwork/ui": "1.0.0-rc.36",
86
+ "@mistriwork/engine": "1.0.0-rc.37",
87
+ "@mistriwork/ui": "1.0.0-rc.37",
88
88
  "intl-messageformat": "12.1.2",
89
89
  "qrcode-generator": "^2.0.4"
90
90
  },