@mistriwork/kit 1.0.0-rc.14 → 1.0.0-rc.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/client/app.js +2 -1
  2. package/dist/client/components/AppList.js +12 -1
  3. package/dist/client/components/Dressed.js +3 -0
  4. package/dist/client/components/Editable.js +3 -2
  5. package/dist/client/components/ErrorBoundary.js +1 -1
  6. package/dist/client/components/Grid.d.ts +15 -1
  7. package/dist/client/components/Grid.js +44 -7
  8. package/dist/client/components/NewRecord.d.ts +3 -1
  9. package/dist/client/components/NewRecord.js +16 -5
  10. package/dist/client/components/PageFlowDiagram.css +1 -1
  11. package/dist/client/components/PageTimeline.js +18 -4
  12. package/dist/client/components/RecordSummaries.d.ts +5 -3
  13. package/dist/client/components/RecordSummaries.js +11 -2
  14. package/dist/client/components/TableRoom.d.ts +4 -1
  15. package/dist/client/components/TableRoom.js +10 -5
  16. package/dist/client/components/TableView.d.ts +4 -2
  17. package/dist/client/components/TableView.js +3 -3
  18. package/dist/client/components/TimelineReactions.css +49 -0
  19. package/dist/client/components/TimelineReactions.d.ts +18 -0
  20. package/dist/client/components/TimelineReactions.js +58 -0
  21. package/dist/client/components/TreePicker.css +25 -0
  22. package/dist/client/components/TreePicker.d.ts +59 -0
  23. package/dist/client/components/TreePicker.js +407 -0
  24. package/dist/client/components/Value.js +33 -2
  25. package/dist/client/components/appListModel.d.ts +2 -0
  26. package/dist/client/components/chromeIcons.d.ts +1 -0
  27. package/dist/client/components/chromeIcons.js +1 -0
  28. package/dist/client/components/inputRenderers.d.ts +7 -1
  29. package/dist/client/components/inputRenderers.js +2 -0
  30. package/dist/client/components/pageModel.d.ts +4 -0
  31. package/dist/client/components/reactionTally.d.ts +20 -0
  32. package/dist/client/components/reactionTally.js +46 -0
  33. package/dist/client/components/useGridGroups.d.ts +11 -0
  34. package/dist/client/components/useGridGroups.js +70 -0
  35. package/dist/client/components/useGridKeyboard.d.ts +2 -0
  36. package/dist/client/components/useGridKeyboard.js +18 -1
  37. package/dist/client/components/valueModel.d.ts +10 -3
  38. package/dist/client/components/valueModel.js +21 -1
  39. package/dist/client/copy/forms/components/TreePicker.d.ts +9 -0
  40. package/dist/client/copy/forms/components/TreePicker.js +11 -0
  41. package/dist/client/copy/lists/components/Grid.d.ts +1 -1
  42. package/dist/client/copy/lists/components/Grid.js +1 -1
  43. package/dist/client/copy/lists/components/useGridGroups.d.ts +3 -0
  44. package/dist/client/copy/lists/components/useGridGroups.js +5 -0
  45. package/dist/client/copy/record/components/TimelineReactions.d.ts +7 -0
  46. package/dist/client/copy/record/components/TimelineReactions.js +6 -0
  47. package/dist/client/copy/record/components/Value.d.ts +3 -0
  48. package/dist/client/copy/record/components/Value.js +3 -0
  49. package/dist/client/copy/shell/components/ErrorBoundary.d.ts +1 -1
  50. package/dist/client/copy/shell/components/ErrorBoundary.js +1 -1
  51. package/dist/client/features.css +35 -1
  52. package/dist/client/index.html +1 -1
  53. package/dist/client/page.css +3 -2
  54. package/dist/client/shellHost.d.ts +1 -1
  55. package/dist/client/shellHost.js +1 -1
  56. package/dist/client/structure.css +11 -3
  57. package/dist/client/style.css +11 -2
  58. package/package.json +3 -3
@@ -0,0 +1,407 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * A reference picker over a hierarchy: a reference whose records hang from one another by a parent column
4
+ * (`tree: 'parent_id'`, on a command's reference and on a New form's field). A category three levels down is found
5
+ * by walking to it, not by remembering its exact name, and once chosen it is said with its path — Hardware ›
6
+ * Laptops › Batteries — so two records of one name under different parents are told apart.
7
+ *
8
+ * The box is a combobox (APG) whose popup is the tree: focus stays in the box, the lit row is its active
9
+ * descendant. Up and Down move through what is open, Right opens a branch or steps into it, Left folds it or steps
10
+ * out to its parent, Home and End go to the ends, Enter chooses, Escape closes. Typing searches every level at once,
11
+ * the popup a list of matches each said with its path; clearing the box goes back to the tree.
12
+ *
13
+ * Read lazily, a level at a time: the records with no parent when the box opens, a branch's children when it is
14
+ * opened, and for each level one breakdown says which of its records have children, so a leaf draws no caret and
15
+ * nothing is read per record. A record whose parent the field's own filter leaves out is not under any branch; a
16
+ * search finds it. A path is read upward a level per request, bounded, and a loop in the data ends it.
17
+ *
18
+ * Every read is the reader's own (`ask`): the reader's connection, or a public form's visitor read, so the tree
19
+ * offers only the records its reader may read, as a flat picker does. Nothing slides open (motion rule 8).
20
+ */
21
+ import './TreePicker.css';
22
+ import { Fragment, useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
23
+ import { useQueryClient } from '@tanstack/react-query';
24
+ import { Popover } from '@base-ui/react/popover';
25
+ import { layoutViewport, zoomAnchor } from '@mistriwork/ui/internal/anchor.js';
26
+ import { viewportBox } from '@mistriwork/ui/internal/ruler.js';
27
+ import { popupContainer, shellById } from '../shellHost.js';
28
+ import { andQuery, quoteValue } from '@mistriwork/engine/shared/query.js';
29
+ import { Icon } from './Icon.js';
30
+ import { formatNumber } from '../locale.js';
31
+ import { say } from '../copy/forms/components/TreePicker.js';
32
+ /** A level's records read at once; past it the level says so, and a search finds the rest. */
33
+ const LEVEL = 200;
34
+ /** A search's matches. */
35
+ const MATCHES = 20;
36
+ /** How far up a path is read. */
37
+ const DEPTH = 12;
38
+ const blank = (value) => value === null || value === undefined || value === '';
39
+ export function TreePicker({ from, by, labelColumn, parent, where, ask, scope, value, onChange, known, id, ariaLabel, listLabel, describedBy, invalid, required, disabled, placeholder, inputRef, }) {
40
+ const client = useQueryClient();
41
+ const base = useId();
42
+ const listId = `${base}-tree`;
43
+ const trailId = `${base}-trail`;
44
+ const [nodes, setNodes] = useState(new Map());
45
+ const [kids, setKids] = useState(new Map());
46
+ const [cut, setCut] = useState(new Set());
47
+ const [branches, setBranches] = useState(new Map());
48
+ const [opened, setOpened] = useState(new Set());
49
+ const [open, setOpen] = useState(false);
50
+ const [text, setText] = useState('');
51
+ const [typed, setTyped] = useState(false);
52
+ const [asked, setAsked] = useState('');
53
+ const [matches, setMatches] = useState();
54
+ const [active, setActive] = useState();
55
+ const known$ = useRef(nodes);
56
+ known$.current = nodes;
57
+ const requested = useRef(new Set());
58
+ /* The answers belong to their reader and their question: a new one starts the tree again. */
59
+ const question = JSON.stringify([scope, from, by, labelColumn, parent, where ?? '']);
60
+ const [held, setHeld] = useState(question);
61
+ if (held !== question) {
62
+ setHeld(question);
63
+ setNodes(new Map());
64
+ setKids(new Map());
65
+ setCut(new Set());
66
+ setBranches(new Map());
67
+ setOpened(new Set());
68
+ setMatches(undefined);
69
+ requested.current = new Set();
70
+ }
71
+ const shown = `show ${[...new Set([by, labelColumn, parent])].join(', ')}`;
72
+ const nodeOf = (row) => {
73
+ const key = row?.[by];
74
+ if (!(typeof key === 'string' || (typeof key === 'number' && Number.isSafeInteger(key))))
75
+ return null;
76
+ const up = row[parent];
77
+ return { key: String(key), value: key, label: String(row[labelColumn] ?? key), parent: blank(up) ? null : String(up) };
78
+ };
79
+ const learn = (found) => {
80
+ if (!found.length)
81
+ return;
82
+ const next = new Map(known$.current);
83
+ for (const node of found)
84
+ next.set(node.key, node);
85
+ known$.current = next;
86
+ setNodes(next);
87
+ };
88
+ const rowsOf = (q, limit) => client.fetchQuery({
89
+ queryKey: ['tree-picker', scope, q, limit],
90
+ staleTime: 30_000,
91
+ queryFn: async () => {
92
+ const data = await ask('/api/run', { q, limit, offset: 0, count: 'none' });
93
+ if (data.errors?.length || !Array.isArray(data.rows))
94
+ throw new Error(say('couldNotLoad'));
95
+ return data.rows;
96
+ },
97
+ });
98
+ /* Which of a level's records have children: one breakdown of the parent column over them, never a read each. */
99
+ const parentsAmong = (values) => client.fetchQuery({
100
+ queryKey: ['tree-picker', scope, 'branches', from, parent, where ?? '', values],
101
+ staleTime: 30_000,
102
+ queryFn: async () => {
103
+ const text = `${from} ${andQuery(where, `${parent} in (${values.map(quoteValue).join(', ')})`)} count as children by ${parent}`;
104
+ const data = await ask('/api/breakdown', { text, limit: values.length });
105
+ if (data.errors?.length || !Array.isArray(data.rows))
106
+ throw new Error(say('couldNotLoad'));
107
+ return new Set(data.rows.filter((row) => Number(row.children) > 0).map((row) => String(row[parent])));
108
+ },
109
+ });
110
+ const level = async (key) => {
111
+ if (requested.current.has(key))
112
+ return;
113
+ requested.current.add(key);
114
+ setKids((was) => new Map(was).set(key, 'loading'));
115
+ const above = known$.current.get(key);
116
+ const condition = key === '' ? `${parent} is empty` : `${parent} = ${quoteValue(above ? above.value : key)}`;
117
+ try {
118
+ const rows = await rowsOf(`${from} ${andQuery(where, condition)} ${shown} sort ${labelColumn}`, LEVEL + 1);
119
+ const found = rows
120
+ .slice(0, LEVEL)
121
+ .map(nodeOf)
122
+ .filter((node) => node !== null);
123
+ learn(found);
124
+ setKids((was) => new Map(was).set(key, found.map((node) => node.key)));
125
+ if (rows.length > LEVEL)
126
+ setCut((was) => new Set(was).add(key));
127
+ if (key !== '')
128
+ setBranches((was) => new Map(was).set(key, found.length > 0));
129
+ if (!found.length)
130
+ return;
131
+ /* Unknown where the breakdown cannot be read: such a record draws its caret and is settled when opened. */
132
+ const has = await parentsAmong(found.map((node) => node.value)).catch(() => undefined);
133
+ if (has)
134
+ setBranches((was) => {
135
+ const next = new Map(was);
136
+ for (const node of found)
137
+ if (!next.has(node.key) || next.get(node.key) !== false)
138
+ next.set(node.key, has.has(node.key));
139
+ return next;
140
+ });
141
+ }
142
+ catch {
143
+ requested.current.delete(key);
144
+ setKids((was) => new Map(was).set(key, 'error'));
145
+ }
146
+ };
147
+ /* A record's path, its root first, from what has been read: a loop in the data ends it rather than spinning. */
148
+ const pathOf = (key, map = nodes) => {
149
+ const out = [];
150
+ const seen = new Set();
151
+ for (let at = map.get(key); at && !seen.has(at.key) && out.length <= DEPTH; at = at.parent === null ? undefined : map.get(at.parent)) {
152
+ seen.add(at.key);
153
+ out.unshift(at);
154
+ }
155
+ return out;
156
+ };
157
+ /* The parents above these records that are not read yet, a level per request, bounded. */
158
+ const climb = async (start) => {
159
+ const missing = (list) => [
160
+ ...new Set(list.flatMap((node) => (node.parent === null || known$.current.has(node.parent) ? [] : [node.parent]))),
161
+ ];
162
+ let wanted = missing(start);
163
+ for (let step = 0; step < DEPTH && wanted.length; step++) {
164
+ const rows = await rowsOf(`${from} ${by} in (${wanted.map(quoteValue).join(', ')}) ${shown}`, wanted.length);
165
+ const found = rows.map(nodeOf).filter((node) => node !== null);
166
+ learn(found);
167
+ wanted = missing(found);
168
+ }
169
+ };
170
+ /* The chosen record, read by its key under the field's own filter, and its path above it. */
171
+ const chosen = blank(value) ? undefined : String(value);
172
+ useEffect(() => {
173
+ if (value === undefined || value === '')
174
+ return;
175
+ let live = true;
176
+ const have = known$.current.get(String(value));
177
+ const read = have
178
+ ? Promise.resolve(have)
179
+ : rowsOf(`${from} ${andQuery(where, `${by} = ${quoteValue(value)}`)} ${shown}`, 1).then((rows) => {
180
+ const node = nodeOf(rows[0]);
181
+ if (node && live)
182
+ learn([node]);
183
+ return node;
184
+ });
185
+ void read.then((node) => (node && live ? climb([node]) : undefined)).catch(() => { });
186
+ return () => {
187
+ live = false;
188
+ };
189
+ }, [value, question]);
190
+ const searching = typed && text.trim() !== '';
191
+ useEffect(() => {
192
+ const timer = setTimeout(() => setAsked(text.trim()), 150);
193
+ return () => clearTimeout(timer);
194
+ }, [text]);
195
+ useEffect(() => {
196
+ if (!open || !searching || !asked)
197
+ return;
198
+ let live = true;
199
+ const condition = `${labelColumn} contains ${JSON.stringify(asked)}`;
200
+ rowsOf(`${from} ${andQuery(where, condition)} ${shown} sort ${labelColumn}`, MATCHES)
201
+ .then(async (rows) => {
202
+ const found = rows.map(nodeOf).filter((node) => node !== null);
203
+ learn(found);
204
+ /* A path that cannot be read leaves the match said alone, not the search failed. */
205
+ await climb(found).catch(() => { });
206
+ if (live)
207
+ setMatches({ for: asked, keys: found.map((node) => node.key) });
208
+ })
209
+ .catch(() => live && setMatches({ for: asked, error: true }));
210
+ return () => {
211
+ live = false;
212
+ };
213
+ }, [open, searching, asked, question]);
214
+ /* Opened on the tree, it reads its tops and opens the way down to the chosen record, which is lit. */
215
+ const revealed = useRef(false);
216
+ useEffect(() => {
217
+ if (!open || searching) {
218
+ if (!open)
219
+ revealed.current = false;
220
+ return;
221
+ }
222
+ void level('');
223
+ if (revealed.current || !chosen)
224
+ return;
225
+ const path = pathOf(chosen);
226
+ if (!path.length || path[0].parent !== null)
227
+ return;
228
+ revealed.current = true;
229
+ const above = path.slice(0, -1);
230
+ setOpened((was) => new Set([...was, ...above.map((node) => node.key)]));
231
+ for (const node of above)
232
+ void level(node.key);
233
+ setActive(chosen);
234
+ }, [open, searching, chosen, nodes]);
235
+ const branch = (key) => branches.get(key) !== false;
236
+ const lines = [];
237
+ if (searching) {
238
+ const answer = matches?.for === text.trim() ? matches : undefined;
239
+ if (!answer)
240
+ lines.push({ key: 'note:', depth: 1, note: say('loading') });
241
+ else if ('error' in answer)
242
+ lines.push({ key: 'note:', depth: 1, note: say('couldNotLoad') });
243
+ else if (!answer.keys.length)
244
+ lines.push({ key: 'note:', depth: 1, note: say('noMatches') });
245
+ else
246
+ for (const key of answer.keys) {
247
+ const node = nodes.get(key);
248
+ if (node)
249
+ lines.push({
250
+ key,
251
+ depth: 1,
252
+ node,
253
+ path: pathOf(key)
254
+ .slice(0, -1)
255
+ .map((above) => above.label),
256
+ });
257
+ }
258
+ }
259
+ else {
260
+ const walk = (key, depth, seen) => {
261
+ const here = kids.get(key);
262
+ if (here === undefined || here === 'loading')
263
+ return void lines.push({ key: `note:${key}`, depth, note: say('loading') });
264
+ if (here === 'error')
265
+ return void lines.push({ key: `note:${key}`, depth, note: say('couldNotLoad') });
266
+ if (!here.length && key === '')
267
+ lines.push({ key: 'note:', depth, note: say('nothingToChoose') });
268
+ for (const child of here) {
269
+ const node = nodes.get(child);
270
+ if (!node || seen.has(child))
271
+ continue;
272
+ lines.push({ key: child, depth, node });
273
+ if (opened.has(child) && branch(child))
274
+ walk(child, depth + 1, new Set(seen).add(child));
275
+ }
276
+ if (cut.has(key))
277
+ lines.push({ key: `more:${key}`, depth, note: say('firstOnly', { count: formatNumber(LEVEL) }) });
278
+ };
279
+ if (open)
280
+ walk('', 1, new Set());
281
+ }
282
+ const choosable = lines.filter((line) => line.node);
283
+ const current = choosable.find((line) => line.key === active) ?? (searching ? choosable[0] : undefined);
284
+ const lineId = (line) => `${base}-${lines.indexOf(line)}`;
285
+ useEffect(() => {
286
+ if (open && current)
287
+ shellById(lineId(current))?.scrollIntoView?.({ block: 'nearest' });
288
+ }, [open, current?.key]);
289
+ const expand = (key) => {
290
+ setOpened((was) => new Set(was).add(key));
291
+ void level(key);
292
+ };
293
+ const fold = (key) => setOpened((was) => {
294
+ const next = new Set(was);
295
+ next.delete(key);
296
+ return next;
297
+ });
298
+ const close = () => {
299
+ setOpen(false);
300
+ /* Left with a record still chosen, the box says its name again rather than the half-typed search. */
301
+ if (chosen !== undefined) {
302
+ setTyped(false);
303
+ setText('');
304
+ }
305
+ };
306
+ const pick = (node) => {
307
+ onChange(node.value, node.label);
308
+ setTyped(false);
309
+ setText('');
310
+ setActive(node.key);
311
+ setOpen(false);
312
+ };
313
+ const onKeyDown = (event) => {
314
+ const at = current ? choosable.indexOf(current) : -1;
315
+ const light = (line) => line && setActive(line.key);
316
+ const tree = open && !searching && current?.node;
317
+ const keys = {
318
+ ArrowDown: () => (open ? light(choosable[Math.min(at + 1, choosable.length - 1)]) : setOpen(true)),
319
+ ArrowUp: () => (open ? light(choosable[Math.max(at - 1, 0)]) : setOpen(true)),
320
+ Home: open && !searching ? () => light(choosable[0]) : undefined,
321
+ End: open && !searching ? () => light(choosable[choosable.length - 1]) : undefined,
322
+ ArrowRight: tree
323
+ ? () => {
324
+ const key = current.key;
325
+ const below = kids.get(key);
326
+ if (!opened.has(key)) {
327
+ if (branch(key))
328
+ expand(key);
329
+ }
330
+ else if (Array.isArray(below) && below.length)
331
+ setActive(below[0]);
332
+ }
333
+ : undefined,
334
+ ArrowLeft: tree
335
+ ? () => {
336
+ const node = current.node;
337
+ if (opened.has(node.key) && branch(node.key))
338
+ fold(node.key);
339
+ else if (node.parent !== null && choosable.some((line) => line.key === node.parent))
340
+ setActive(node.parent);
341
+ }
342
+ : undefined,
343
+ Enter: open && current?.node ? () => pick(current.node) : undefined,
344
+ Escape: open
345
+ ? () => {
346
+ event.stopPropagation();
347
+ close();
348
+ }
349
+ : undefined,
350
+ };
351
+ const run = keys[event.key];
352
+ if (!run)
353
+ return;
354
+ event.preventDefault();
355
+ run();
356
+ };
357
+ /* The popup is as wide as the box, measured on the house ruler when it opens and again only when the box resizes:
358
+ Base UI's own anchor width is recomputed as the rows arrive (Typeahead.tsx says why that loops). */
359
+ const frame = useRef(null);
360
+ const [width, setWidth] = useState(null);
361
+ const [container, setContainer] = useState(null);
362
+ useLayoutEffect(() => {
363
+ if (!open || !frame.current)
364
+ return;
365
+ const anchor = frame.current;
366
+ setContainer(anchor.closest('dialog, [role="dialog"]'));
367
+ const measure = () => {
368
+ const measured = viewportBox(anchor).width;
369
+ setWidth(measured > 0 ? measured : null);
370
+ };
371
+ measure();
372
+ if (typeof ResizeObserver === 'undefined')
373
+ return;
374
+ const observer = new ResizeObserver(measure);
375
+ observer.observe(anchor);
376
+ return () => observer.disconnect();
377
+ }, [open]);
378
+ const box = typed ? text : chosen === undefined ? '' : (nodes.get(chosen)?.label ?? known ?? chosen);
379
+ const trail = chosen === undefined || typed ? [] : pathOf(chosen);
380
+ const said = trail.length > 1;
381
+ return (_jsxs("div", { className: "tree-picker", children: [_jsxs("div", { className: "picker", ref: frame, children: [_jsx("input", { ref: inputRef, id: id, className: "picker-input", role: "combobox", "aria-label": ariaLabel, "aria-expanded": open, "aria-controls": listId, "aria-haspopup": searching ? 'listbox' : 'tree', "aria-autocomplete": "list", "aria-activedescendant": open && current ? lineId(current) : undefined, "aria-describedby": [describedBy, said ? trailId : undefined].filter(Boolean).join(' ') || undefined, "aria-invalid": invalid || undefined, required: required, disabled: disabled, placeholder: placeholder ?? say('choose'), autoComplete: "off", value: box, onChange: (event) => {
382
+ setText(event.target.value);
383
+ setTyped(true);
384
+ setActive(undefined);
385
+ setOpen(true);
386
+ if (chosen !== undefined)
387
+ onChange('');
388
+ }, onClick: () => !disabled && setOpen(true), onBlur: close, onKeyDown: onKeyDown }), _jsx(Popover.Root, { open: open && !disabled, modal: false, onOpenChange: () => { }, children: _jsx(Popover.Portal, { container: container ?? popupContainer(), children: _jsx(Popover.Positioner, { anchor: () => (frame.current ? zoomAnchor(frame.current) : null), positionMethod: "fixed", side: "bottom", align: "start", sideOffset: 4, collisionBoundary: layoutViewport(), collisionPadding: 8, style: { zIndex: 40, width: width === null ? 'var(--anchor-width)' : `${width}px`, maxWidth: 'var(--available-width)' }, children: _jsx(Popover.Popup, { role: "presentation", initialFocus: false, finalFocus: false, className: "picker-popup tree-picker-popup", onMouseDown: (event) => event.preventDefault(), children: _jsx("ul", { id: listId, role: searching ? 'listbox' : 'tree', "aria-label": ariaLabel ?? listLabel, className: "picker-list", children: lines.map((line) => {
389
+ const node = line.node;
390
+ if (!node)
391
+ return (_jsx("li", { role: "presentation", className: "picker-empty", style: { paddingInlineStart: indent(line.depth) }, children: line.note }, line.key));
392
+ const lit = line === current;
393
+ const opens = !searching && branch(node.key);
394
+ return (_jsxs("li", { id: lineId(line), role: searching ? 'option' : 'treeitem', "aria-level": searching ? undefined : line.depth, "aria-expanded": opens ? opened.has(node.key) : undefined, "aria-selected": lit, className: `picker-option tree-picker-option${lit ? ' active' : ''}${node.key === chosen ? ' chosen' : ''}`, style: searching ? undefined : { paddingInlineStart: indent(line.depth) }, onClick: () => pick(node), children: [!searching && (_jsx("span", { className: `tree-picker-caret${opens ? '' : ' is-leaf'}`, "aria-hidden": "true", onClick: (event) => {
395
+ event.stopPropagation();
396
+ setActive(node.key);
397
+ if (!opens)
398
+ return;
399
+ if (opened.has(node.key))
400
+ fold(node.key);
401
+ else
402
+ expand(node.key);
403
+ }, children: opens && _jsx(Icon, { name: opened.has(node.key) ? 'caret-down' : 'caret-right', size: 12 }) })), _jsx("span", { className: "picker-option-label", children: node.label }), line.path && line.path.length > 0 && (_jsx("span", { className: "picker-option-detail tree-picker-path", children: line.path.join(' › ') }))] }, line.key));
404
+ }) }) }) }) }) })] }), said && (_jsx("p", { id: trailId, className: "tree-picker-trail", "aria-label": say('path'), children: trail.map((node, index) => (_jsxs(Fragment, { children: [index > 0 && (_jsx("span", { className: "tree-picker-sep", "aria-hidden": "true", children: "\u203A" })), _jsx("span", { children: node.label })] }, node.key))) }))] }));
405
+ }
406
+ /* A level's inset: the caret column stands under its parent's name. */
407
+ const indent = (depth) => `calc(var(--space-2) + ${(depth - 1) * 18}px)`;
@@ -9,7 +9,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
9
  * the row, a click that goes there.
10
10
  */
11
11
  import { Fragment } from 'react';
12
- import { api, columnDisplay, emptyWord, findTable, openRecord, refsFrom, state } from '../core.js';
12
+ import { api, columnDisplay, columnLabel, emptyWord, findTable, humanName, openRecord, refsFrom, state, toast } from '../core.js';
13
13
  import { opensRecord } from '../recordIntent.js';
14
14
  import { dressFor, linkFor, maskedText, ruleSays } from './valueModel.js';
15
15
  import { rowCurrency } from '@mistriwork/engine/shared/money.js';
@@ -19,12 +19,16 @@ import { jsonValueOf, previewOf } from './jsonModel.js';
19
19
  import { TAGS_TYPE, tagChips } from '@mistriwork/engine/shared/tagLists.js';
20
20
  import { AvatarText, Dressed, Said } from './Dressed.js';
21
21
  import { ValueSlot } from './valueRenderers.js';
22
+ import { Icon } from './Icon.js';
22
23
  import { say } from '../copy/record/components/Value.js';
23
24
  import { shellBody } from '../shellHost.js';
24
25
  /* Drawn here and in the grid; the rules that draw them read no global (Dressed.tsx). */
25
26
  export { AvatarText, Dressed };
26
27
  /** A value that is a link: mail, a call, or a web page, which opens beside the App rather than in place of it. */
27
28
  function ValueLink({ link }) {
29
+ /* An address is drawn on its lines, as it is written on an envelope, and opens a map search beside the App. */
30
+ if (link.kind === 'address')
31
+ return (_jsx("a", { className: "value-link value-address", href: link.href, target: "_blank", rel: "noopener noreferrer", title: say('findOnAMap'), children: (link.lines ?? [link.text]).map((line, index) => (_jsx("span", { className: "value-address-line", children: line }, index))) }));
28
32
  const text = breakable(link.text);
29
33
  /* The break points are not words: the link is named by its text whole. */
30
34
  const named = { title: link.text, ...(typeof text === 'string' ? {} : { 'aria-label': link.text }) };
@@ -42,8 +46,35 @@ function breakable(text) {
42
46
  }
43
47
  /** A value as the record and the page show it: dressed when the app says, plain otherwise. */
44
48
  export function Value(props) {
45
- const { col, value, tableId, compact = false } = props;
49
+ const { col, value, tableId, compact = false, links = !compact } = props;
46
50
  const rule = tableId === undefined ? null : columnDisplay(tableId, col?.name ?? '');
51
+ const drawn = _jsx(DrawnValue, { ...props, rule: rule });
52
+ /* A rule's `copy` puts a copy button beside the value — not where the value stands inside a target of its own (a
53
+ card, a row that opens: a button in a button is neither), and not for a value a mask hides. */
54
+ if (!rule?.copy ||
55
+ !links ||
56
+ value === null ||
57
+ value === undefined ||
58
+ value === '' ||
59
+ maskedText(rule, value) !== undefined ||
60
+ !shellBody().classList.contains('app-mode'))
61
+ return drawn;
62
+ return (_jsxs("span", { className: "value-copyable", children: [drawn, _jsx(CopyValue, { value: value, label: columnLabel(tableId, col?.name ?? '') ?? humanName(col?.name ?? '') })] }));
63
+ }
64
+ /** The stored value to the clipboard, as stored: an id past 2^53 arrives as a string and is copied as one. */
65
+ function CopyValue({ value, label }) {
66
+ const named = say('copyValue', { label });
67
+ return (_jsx("button", { type: "button", className: "value-copy", "aria-label": named, title: named, onClick: () => {
68
+ const text = typeof value === 'object' ? JSON.stringify(value) : String(value);
69
+ navigator.clipboard
70
+ .writeText(text)
71
+ .then(() => toast(say('copiedValue', { label })))
72
+ /* The clipboard can be refused — an insecure origin, a permission denied; the value is on screen. */
73
+ .catch(() => toast(say('common.theBrowserRefusedClipboard'), 'error'));
74
+ }, children: _jsx(Icon, { name: "copy", size: 16 }) }));
75
+ }
76
+ function DrawnValue(props) {
77
+ const { col, value, tableId, compact = false, rule } = props;
47
78
  /* The App's own renderer, where its display rule names one: the value drawn
48
79
  the platform's way until it has arrived, and whenever it cannot draw. An
49
80
  empty value is the platform's to say, as it is in a grid cell. */
@@ -19,6 +19,8 @@ export interface ListSpec {
19
19
  icon?: string;
20
20
  /** Columns summed in the grid's footer, over the whole query. */
21
21
  totals?: string[];
22
+ /** The column the grid's rows are grouped by: read in its order, each group under a head with its count and subtotals. */
23
+ group?: string;
22
24
  /** Row height; 'comfortable' is the default. */
23
25
  density?: 'comfortable' | 'compact';
24
26
  /** A ⋯ menu at the end of each row with the record's own actions. */
@@ -6,6 +6,7 @@ export declare const CHROME_ICON_GLYPHS: {
6
6
  'calendar-blank': [string[], string[]];
7
7
  bell: [string[], string[]];
8
8
  'check-circle': [string[], string[]];
9
+ copy: [string[], string[]];
9
10
  gear: [string[], string[]];
10
11
  list: [string[], string[]];
11
12
  lock: [string[], string[]];
@@ -6,6 +6,7 @@ export const CHROME_ICON_GLYPHS = {
6
6
  'calendar-blank': [["M208,32H184V24a8,8,0,0,0-16,0v8H88V24a8,8,0,0,0-16,0v8H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM72,48v8a8,8,0,0,0,16,0V48h80v8a8,8,0,0,0,16,0V48h24V80H48V48ZM208,208H48V96H208V208Z"], ["M208,28H188V24a12,12,0,0,0-24,0v4H92V24a12,12,0,0,0-24,0v4H48A20,20,0,0,0,28,48V208a20,20,0,0,0,20,20H208a20,20,0,0,0,20-20V48A20,20,0,0,0,208,28ZM68,52a12,12,0,0,0,24,0h72a12,12,0,0,0,24,0h16V76H52V52ZM52,204V100H204V204Z"]],
7
7
  'bell': [["M221.8,175.94C216.25,166.38,208,139.33,208,104a80,80,0,1,0-160,0c0,35.34-8.26,62.38-13.81,71.94A16,16,0,0,0,48,200H88.81a40,40,0,0,0,78.38,0H208a16,16,0,0,0,13.8-24.06ZM128,216a24,24,0,0,1-22.62-16h45.24A24,24,0,0,1,128,216ZM48,184c7.7-13.24,16-43.92,16-80a64,64,0,1,1,128,0c0,36.05,8.28,66.73,16,80Z"], ["M225.29,165.93C216.61,151,212,129.57,212,104a84,84,0,0,0-168,0c0,25.58-4.59,47-13.27,61.93A20.08,20.08,0,0,0,30.66,186,19.77,19.77,0,0,0,48,196H84.18a44,44,0,0,0,87.64,0H208a19.77,19.77,0,0,0,17.31-10A20.08,20.08,0,0,0,225.29,165.93ZM128,212a20,20,0,0,1-19.6-16h39.2A20,20,0,0,1,128,212ZM54.66,172C63.51,154,68,131.14,68,104a60,60,0,0,1,120,0c0,27.13,4.48,50,13.33,68Z"]],
8
8
  'check-circle': [["M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z"], ["M176.49,95.51a12,12,0,0,1,0,17l-56,56a12,12,0,0,1-17,0l-24-24a12,12,0,1,1,17-17L112,143l47.51-47.52A12,12,0,0,1,176.49,95.51ZM236,128A108,108,0,1,1,128,20,108.12,108.12,0,0,1,236,128Zm-24,0a84,84,0,1,0-84,84A84.09,84.09,0,0,0,212,128Z"]],
9
+ 'copy': [["M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z"], ["M216,28H88A12,12,0,0,0,76,40V76H40A12,12,0,0,0,28,88V216a12,12,0,0,0,12,12H168a12,12,0,0,0,12-12V180h36a12,12,0,0,0,12-12V40A12,12,0,0,0,216,28ZM156,204H52V100H156Zm48-48H180V88a12,12,0,0,0-12-12H100V52H204Z"]],
9
10
  'gear': [["M128,80a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Zm88-29.84q.06-2.16,0-4.32l14.92-18.64a8,8,0,0,0,1.48-7.06,107.21,107.21,0,0,0-10.88-26.25,8,8,0,0,0-6-3.93l-23.72-2.64q-1.48-1.56-3-3L186,40.54a8,8,0,0,0-3.94-6,107.71,107.71,0,0,0-26.25-10.87,8,8,0,0,0-7.06,1.49L130.16,40Q128,40,125.84,40L107.2,25.11a8,8,0,0,0-7.06-1.48A107.6,107.6,0,0,0,73.89,34.51a8,8,0,0,0-3.93,6L67.32,64.27q-1.56,1.49-3,3L40.54,70a8,8,0,0,0-6,3.94,107.71,107.71,0,0,0-10.87,26.25,8,8,0,0,0,1.49,7.06L40,125.84Q40,128,40,130.16L25.11,148.8a8,8,0,0,0-1.48,7.06,107.21,107.21,0,0,0,10.88,26.25,8,8,0,0,0,6,3.93l23.72,2.64q1.49,1.56,3,3L70,215.46a8,8,0,0,0,3.94,6,107.71,107.71,0,0,0,26.25,10.87,8,8,0,0,0,7.06-1.49L125.84,216q2.16.06,4.32,0l18.64,14.92a8,8,0,0,0,7.06,1.48,107.21,107.21,0,0,0,26.25-10.88,8,8,0,0,0,3.93-6l2.64-23.72q1.56-1.48,3-3L215.46,186a8,8,0,0,0,6-3.94,107.71,107.71,0,0,0,10.87-26.25,8,8,0,0,0-1.49-7.06Zm-16.1-6.5a73.93,73.93,0,0,1,0,8.68,8,8,0,0,0,1.74,5.48l14.19,17.73a91.57,91.57,0,0,1-6.23,15L187,173.11a8,8,0,0,0-5.1,2.64,74.11,74.11,0,0,1-6.14,6.14,8,8,0,0,0-2.64,5.1l-2.51,22.58a91.32,91.32,0,0,1-15,6.23l-17.74-14.19a8,8,0,0,0-5-1.75h-.48a73.93,73.93,0,0,1-8.68,0,8,8,0,0,0-5.48,1.74L100.45,215.8a91.57,91.57,0,0,1-15-6.23L82.89,187a8,8,0,0,0-2.64-5.1,74.11,74.11,0,0,1-6.14-6.14,8,8,0,0,0-5.1-2.64L46.43,170.6a91.32,91.32,0,0,1-6.23-15l14.19-17.74a8,8,0,0,0,1.74-5.48,73.93,73.93,0,0,1,0-8.68,8,8,0,0,0-1.74-5.48L40.2,100.45a91.57,91.57,0,0,1,6.23-15L69,82.89a8,8,0,0,0,5.1-2.64,74.11,74.11,0,0,1,6.14-6.14A8,8,0,0,0,82.89,69L85.4,46.43a91.32,91.32,0,0,1,15-6.23l17.74,14.19a8,8,0,0,0,5.48,1.74,73.93,73.93,0,0,1,8.68,0,8,8,0,0,0,5.48-1.74L155.55,40.2a91.57,91.57,0,0,1,15,6.23L173.11,69a8,8,0,0,0,2.64,5.1,74.11,74.11,0,0,1,6.14,6.14,8,8,0,0,0,5.1,2.64l22.58,2.51a91.32,91.32,0,0,1,6.23,15l-14.19,17.74A8,8,0,0,0,199.87,123.66Z"], ["M128,76a52,52,0,1,0,52,52A52.06,52.06,0,0,0,128,76Zm0,80a28,28,0,1,1,28-28A28,28,0,0,1,128,156Zm92-27.21v-1.58l14-17.51a12,12,0,0,0,2.23-10.59A111.75,111.75,0,0,0,225,71.89,12,12,0,0,0,215.89,66L193.61,63.5l-1.11-1.11L190,40.1A12,12,0,0,0,184.11,31a111.67,111.67,0,0,0-27.23-11.27A12,12,0,0,0,146.3,22L128.79,36h-1.58L109.7,22a12,12,0,0,0-10.59-2.23A111.75,111.75,0,0,0,71.89,31.05,12,12,0,0,0,66,40.11L63.5,62.39,62.39,63.5,40.1,66A12,12,0,0,0,31,71.89,111.67,111.67,0,0,0,19.77,99.12,12,12,0,0,0,22,109.7l14,17.51v1.58L22,146.3a12,12,0,0,0-2.23,10.59,111.75,111.75,0,0,0,11.29,27.22A12,12,0,0,0,40.11,190l22.28,2.48,1.11,1.11L66,215.9A12,12,0,0,0,71.89,225a111.67,111.67,0,0,0,27.23,11.27A12,12,0,0,0,109.7,234l17.51-14h1.58l17.51,14a12,12,0,0,0,10.59,2.23A111.75,111.75,0,0,0,184.11,225a12,12,0,0,0,5.91-9.06l2.48-22.28,1.11-1.11L215.9,190a12,12,0,0,0,9.06-5.91,111.67,111.67,0,0,0,11.27-27.23A12,12,0,0,0,234,146.3Zm-24.12-4.89a70.1,70.1,0,0,1,0,8.2,12,12,0,0,0,2.61,8.22l12.84,16.05A86.47,86.47,0,0,1,207,166.86l-20.43,2.27a12,12,0,0,0-7.65,4,69,69,0,0,1-5.8,5.8,12,12,0,0,0-4,7.65L166.86,207a86.47,86.47,0,0,1-10.49,4.35l-16.05-12.85a12,12,0,0,0-7.5-2.62c-.24,0-.48,0-.72,0a70.1,70.1,0,0,1-8.2,0,12.06,12.06,0,0,0-8.22,2.6L99.63,211.33A86.47,86.47,0,0,1,89.14,207l-2.27-20.43a12,12,0,0,0-4-7.65,69,69,0,0,1-5.8-5.8,12,12,0,0,0-7.65-4L49,166.86a86.47,86.47,0,0,1-4.35-10.49l12.84-16.05a12,12,0,0,0,2.61-8.22,70.1,70.1,0,0,1,0-8.2,12,12,0,0,0-2.61-8.22L44.67,99.63A86.47,86.47,0,0,1,49,89.14l20.43-2.27a12,12,0,0,0,7.65-4,69,69,0,0,1,5.8-5.8,12,12,0,0,0,4-7.65L89.14,49a86.47,86.47,0,0,1,10.49-4.35l16.05,12.85a12.06,12.06,0,0,0,8.22,2.6,70.1,70.1,0,0,1,8.2,0,12,12,0,0,0,8.22-2.6l16.05-12.85A86.47,86.47,0,0,1,166.86,49l2.27,20.43a12,12,0,0,0,4,7.65,69,69,0,0,1,5.8,5.8,12,12,0,0,0,7.65,4L207,89.14a86.47,86.47,0,0,1,4.35,10.49l-12.84,16.05A12,12,0,0,0,195.88,123.9Z"]],
10
11
  'list': [["M224,128a8,8,0,0,1-8,8H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM40,72H216a8,8,0,0,0,0-16H40a8,8,0,0,0,0,16ZM216,184H40a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16Z"], ["M228,128a12,12,0,0,1-12,12H40a12,12,0,0,1,0-24H216A12,12,0,0,1,228,128ZM40,76H216a12,12,0,0,0,0-24H40a12,12,0,0,0,0,24ZM216,180H40a12,12,0,0,0,0,24H216a12,12,0,0,0,0-24Z"]],
11
12
  'lock': [["M208,80H176V56a48,48,0,0,0-96,0V80H48A16,16,0,0,0,32,96V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V96A16,16,0,0,0,208,80ZM96,56a32,32,0,0,1,64,0V80H96ZM208,208H48V96H208V208Zm-68-56a12,12,0,1,1-12-12A12,12,0,0,1,140,152Z"], ["M208,76H180V56A52,52,0,0,0,76,56V76H48A20,20,0,0,0,28,96V208a20,20,0,0,0,20,20H208a20,20,0,0,0,20-20V96A20,20,0,0,0,208,76ZM100,56a28,28,0,0,1,56,0V76H100ZM204,204H52V100H204Zm-60-52a16,16,0,1,1-16-16A16,16,0,0,1,144,152Z"]],
@@ -29,14 +29,20 @@ interface InputComponentProps {
29
29
  required: boolean;
30
30
  /** The field's caption, for a control that names itself. */
31
31
  label: string;
32
- /** The column, or the command's input, it stands for. */
32
+ /** The column, or the command's input, it stands for. A command's input carries the rule a built-in input reads
33
+ from a column's display rule (a rating's `outOf`), having no column to read it from. */
33
34
  field: {
34
35
  name: string;
35
36
  resource?: string;
37
+ rule?: {
38
+ outOf?: number;
39
+ };
36
40
  };
37
41
  /** Which form: a record's edit, a New form, or a command's. */
38
42
  context: 'edit' | 'new' | 'command';
39
43
  }
44
+ /** The input component id of the platform's own input for a format: what a command's field drawn as one asks for. */
45
+ export declare const builtInInputId: (format: string) => string;
40
46
  /** The App's input component for a resource's column, where it declares one (`resources.<name>.inputs`), else the
41
47
  platform's own for the column's display rule, where it has one (a rating's stars, a slider, a color). */
42
48
  export declare function columnInput(tableId: string, column: string): string | undefined;
@@ -5,6 +5,8 @@ import { componentSlot } from './componentSlot.js';
5
5
  /* The platform's own inputs for a display rule's formats — stars, a slider, a color, a time, a month, a year, a JSON document — are
6
6
  named like this and loaded like an author's, from one chunk of their own (builtInInputs.tsx). */
7
7
  const BUILT_IN = 'mistri:';
8
+ /** The input component id of the platform's own input for a format: what a command's field drawn as one asks for. */
9
+ export const builtInInputId = (format) => `${BUILT_IN}${format}`;
8
10
  const Slot = componentSlot({
9
11
  className: 'custom-input',
10
12
  load: (id) => (id.startsWith(BUILT_IN) ? shell().components.builtIn(id.slice(BUILT_IN.length)) : shell().components.load(id)),
@@ -58,6 +58,8 @@ export interface PageSection {
58
58
  compact?: Record<string, string[]>;
59
59
  /** The other party's rows, drawn against the far edge: asked by the server as each stream's `side` read (SectionPlan). */
60
60
  side?: string;
61
+ /** Reactions under each entry, their columns named by the server (page.ts timelineReactions). */
62
+ reactions?: import('@mistriwork/engine/shared/pageModel.js').TimelineReactions;
61
63
  filter?: string;
62
64
  fn?: string;
63
65
  column?: string;
@@ -150,6 +152,8 @@ export interface SectionPlan {
150
152
  empty?: boolean;
151
153
  view?: ViewDef;
152
154
  };
155
+ /** The column the section's reactions name this stream's rows by, read with them (pagePlans.ts). */
156
+ reacts?: string;
153
157
  }>;
154
158
  /** A custom section's reads, each planned as a list, by name. */
155
159
  reads?: Record<string, {
@@ -0,0 +1,20 @@
1
+ import type { TimelineReactions as Reactions } from '@mistriwork/engine/shared/pageModel.js';
2
+ /** An entry as the reactions name it: the column of its table `whose` refers to (its key), and its value there. */
3
+ export interface ReactionEntry {
4
+ column: string;
5
+ value: string | number;
6
+ }
7
+ /** Every entry's counts by kind, and the kinds the reader gave, keyed by `entryKey`. */
8
+ export interface ReactionTally {
9
+ counts: ReadonlyMap<string, number>;
10
+ mine: ReadonlySet<string>;
11
+ }
12
+ export declare const entryKey: (entry: string | number, kind: string) => string;
13
+ /**
14
+ * The tally for these entries, and whether it is still on its way: a reader who may not read the reactions gets none
15
+ * (and is not kept waiting), and the entries draw no row.
16
+ */
17
+ export declare function useReactionTally(reactions: Reactions | undefined, entries: ReadonlyArray<string | number>): {
18
+ tally?: ReactionTally;
19
+ waiting: boolean;
20
+ };
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The page's reactions, counted: one breakdown over every entry on the page by kind, and the reader's own beside it
3
+ * (`<by> = me`), asked in the same moment so they travel as one request (breakdownBatch.ts). On the page's own path,
4
+ * so a timeline holds its rows until the counts are in and nothing moves when they come; the row that draws them is a
5
+ * part of its own (TimelineReactions.tsx).
6
+ */
7
+ import { useQuery } from '@tanstack/react-query';
8
+ import { andQuery, quoteValue } from '@mistriwork/engine/shared/query.js';
9
+ import { batchedBreakdown } from '../breakdownBatch.js';
10
+ /* The query language's word for the signed-in reader: their row of `auth.me`'s table, read where the rows are. */
11
+ const ME = 'me';
12
+ export const entryKey = (entry, kind) => JSON.stringify([String(entry), kind]);
13
+ /* A breakdown's rows as [entry, kind, count]: its first two columns are the keys it was asked by, the last the count. */
14
+ function tallied(answer) {
15
+ const data = answer;
16
+ if (data.errors?.length || !data.columns || data.columns.length < 3)
17
+ throw new Error('reactions');
18
+ const [entry, kind] = data.columns;
19
+ const count = data.columns.at(-1);
20
+ return (data.rows ?? []).map((row) => [String(row[entry]), String(row[kind]), Number(row[count]) || 0]);
21
+ }
22
+ /**
23
+ * The tally for these entries, and whether it is still on its way: a reader who may not read the reactions gets none
24
+ * (and is not kept waiting), and the entries draw no row.
25
+ */
26
+ export function useReactionTally(reactions, entries) {
27
+ const asked = Boolean(reactions?.whose && reactions.by && reactions.column && entries.length);
28
+ const tally = useQuery({
29
+ queryKey: ['page-reactions', reactions, entries],
30
+ enabled: asked,
31
+ queryFn: async () => {
32
+ const { from, whose, by, column, kinds } = reactions;
33
+ const these = andQuery(`${whose} in (${entries.map(quoteValue).join(', ')})`, `${column} in (${kinds.map(quoteValue).join(', ')})`);
34
+ const most = entries.length * kinds.length;
35
+ const ask = (narrow) => batchedBreakdown({ text: [from, narrow, 'count by', `${whose}, ${column}`].join(' '), limit: most });
36
+ const [all, own] = await Promise.all([ask(these), ask(andQuery(these, `${by} = ${ME}`))]);
37
+ return {
38
+ counts: new Map(tallied(all).map(([entry, kind, count]) => [entryKey(entry, kind), count])),
39
+ mine: new Set(tallied(own).flatMap(([entry, kind, count]) => (count > 0 ? [entryKey(entry, kind)] : []))),
40
+ };
41
+ },
42
+ staleTime: 0,
43
+ retry: false,
44
+ });
45
+ return { ...(asked && tally.isSuccess ? { tally: tally.data } : {}), waiting: asked && tally.isPending };
46
+ }
@@ -0,0 +1,11 @@
1
+ import type { TableMeta } from '@mistriwork/engine/shared/schema.js';
2
+ import type { GridGroup } from './Grid.js';
3
+ export declare function useGridGroups({ column, table, query, totals, connection, }: {
4
+ /** The view's `group`; absent, the grid is not grouped and nothing is asked. */
5
+ column: string | undefined;
6
+ table: TableMeta | undefined;
7
+ /** The list's question as the reader has it: its conditions are the heads' too, its sort and page are not. */
8
+ query: string;
9
+ totals: readonly string[] | undefined;
10
+ connection: string | null | undefined;
11
+ }): GridGroup | undefined;