@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.
- package/dist/client/components/AppList.js +16 -6
- package/dist/client/components/CardsList.js +7 -1
- package/dist/client/components/Chart.css +5 -0
- package/dist/client/components/Chart.d.ts +17 -2
- package/dist/client/components/Chart.js +83 -22
- package/dist/client/components/ChartFigure.d.ts +3 -1
- package/dist/client/components/ChartFigure.js +14 -8
- package/dist/client/components/Content.js +3 -1
- package/dist/client/components/DashHead.d.ts +6 -0
- package/dist/client/components/DashHead.js +20 -0
- package/dist/client/components/Editable.js +1 -1
- package/dist/client/components/Export.js +8 -4
- package/dist/client/components/Grid.js +54 -6
- package/dist/client/components/JsonPreview.css +29 -0
- package/dist/client/components/JsonPreview.js +1 -1
- package/dist/client/components/JsonView.css +201 -62
- package/dist/client/components/JsonView.d.ts +43 -1
- package/dist/client/components/JsonView.js +320 -55
- package/dist/client/components/LayoutSwitch.d.ts +9 -0
- package/dist/client/components/LayoutSwitch.js +61 -0
- package/dist/client/components/ListEmpty.css +3 -0
- package/dist/client/components/LiveNotices.css +3 -0
- package/dist/client/components/NewRecord.d.ts +0 -2
- package/dist/client/components/NewRecord.js +61 -17
- package/dist/client/components/PageFields.js +23 -4
- package/dist/client/components/PageHead.js +28 -7
- package/dist/client/components/PageRelated.d.ts +28 -0
- package/dist/client/components/PageRelated.js +50 -3
- package/dist/client/components/PageSectionBox.d.ts +5 -1
- package/dist/client/components/PageSectionBox.js +5 -3
- package/dist/client/components/PageSections.js +26 -13
- package/dist/client/components/PageSkeleton.css +2 -0
- package/dist/client/components/PageSkeleton.js +11 -3
- package/dist/client/components/Palette.js +108 -10
- package/dist/client/components/RecordPicker.d.ts +2 -0
- package/dist/client/components/RecordPicker.js +34 -8
- package/dist/client/components/RecordSummaries.js +6 -1
- package/dist/client/components/Rooms.js +2 -2
- package/dist/client/components/SecondLine.d.ts +15 -0
- package/dist/client/components/SecondLine.js +18 -0
- package/dist/client/components/TableRoom.js +15 -5
- package/dist/client/components/TableView.d.ts +2 -0
- package/dist/client/components/Value.d.ts +1 -0
- package/dist/client/components/Value.js +7 -9
- package/dist/client/components/appListModel.d.ts +4 -0
- package/dist/client/components/appRooms.d.ts +2 -0
- package/dist/client/components/appRooms.js +2 -0
- package/dist/client/components/dashboardModel.d.ts +5 -0
- package/dist/client/components/directoryModel.d.ts +25 -0
- package/dist/client/components/directoryModel.js +88 -0
- package/dist/client/components/gridSizing.d.ts +3 -0
- package/dist/client/components/gridSizing.js +6 -2
- package/dist/client/components/jsonTree.d.ts +54 -0
- package/dist/client/components/jsonTree.js +190 -0
- package/dist/client/components/listSubtitles.d.ts +1 -0
- package/dist/client/components/listSubtitles.js +7 -0
- package/dist/client/components/newMenuModel.d.ts +14 -6
- package/dist/client/components/newMenuModel.js +37 -5
- package/dist/client/components/newRecordModel.d.ts +24 -2
- package/dist/client/components/newRecordModel.js +47 -4
- package/dist/client/components/pageContext.d.ts +2 -0
- package/dist/client/components/pageModel.d.ts +2 -0
- package/dist/client/components/sidebarModel.js +7 -3
- package/dist/client/components/textMeasure.d.ts +2 -0
- package/dist/client/components/textMeasure.js +16 -2
- package/dist/client/composedReads.js +3 -1
- package/dist/client/copy/lists/components/AppList.d.ts +1 -0
- package/dist/client/copy/lists/components/AppList.js +1 -0
- package/dist/client/copy/lists/components/LayoutSwitch.d.ts +4 -0
- package/dist/client/copy/lists/components/LayoutSwitch.js +6 -0
- package/dist/client/copy/record/components/JsonView.d.ts +22 -0
- package/dist/client/copy/record/components/JsonView.js +19 -0
- package/dist/client/copy/record/components/PageHead.d.ts +1 -0
- package/dist/client/copy/record/components/PageHead.js +2 -0
- package/dist/client/copy/shell/components/Palette.d.ts +11 -0
- package/dist/client/copy/shell/components/Palette.js +14 -0
- package/dist/client/copy/shell/components/TopNav.d.ts +2 -1
- package/dist/client/copy/shell/components/TopNav.js +4 -2
- package/dist/client/copy/shell/components/directoryModel.d.ts +4 -0
- package/dist/client/copy/shell/components/directoryModel.js +6 -0
- package/dist/client/copy/shell/components/sidebarModel.d.ts +1 -0
- package/dist/client/copy/shell/components/sidebarModel.js +1 -0
- package/dist/client/copy/workbench/components/Export.d.ts +3 -2
- package/dist/client/copy/workbench/components/Export.js +3 -2
- package/dist/client/core.d.ts +3 -3
- package/dist/client/core.js +6 -7
- package/dist/client/export.d.ts +5 -4
- package/dist/client/export.js +40 -19
- package/dist/client/features.css +67 -7
- package/dist/client/index.html +2 -1
- package/dist/client/insert.js +1 -8
- package/dist/client/locale.d.ts +7 -0
- package/dist/client/locale.js +0 -0
- package/dist/client/lumenLook.css +9 -12
- package/dist/client/page.css +63 -15
- package/dist/client/palette.d.ts +3 -1
- package/dist/client/palette.js +19 -4
- package/dist/client/paletteRecents.d.ts +25 -0
- package/dist/client/paletteRecents.js +64 -0
- package/dist/client/partsLook.css +6 -3
- package/dist/client/sageLook.css +5 -3
- package/dist/client/shellMode.d.ts +8 -0
- package/dist/client/shellMode.js +1 -0
- package/dist/client/structure.css +201 -1
- package/dist/client/style.css +59 -10
- package/dist/client/themeFamilies.css +37 -0
- package/dist/client/visualThemes.css +12 -0
- package/dist/client/workbenchLook.css +415 -0
- package/dist/client/workshopLook.css +48 -25
- package/package.json +4 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ColumnMeta, TableMeta } from '@mistriwork/engine/shared/schema.js';
|
|
2
2
|
import { AvatarText, Dressed } from './Dressed.js';
|
|
3
|
+
export { secondLine } from './SecondLine.js';
|
|
3
4
|
export { AvatarText, Dressed };
|
|
4
5
|
interface ValueProps {
|
|
5
6
|
col: ColumnMeta | undefined;
|
|
@@ -11,7 +11,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
import { Fragment } from 'react';
|
|
12
12
|
import { api, columnDisplay, columnLabel, emptyWord, findTable, humanName, openRecord, refsFrom, state, toast } from '../core.js';
|
|
13
13
|
import { opensRecord } from '../recordIntent.js';
|
|
14
|
-
import { dressFor, linkFor, maskedText, ruleSays,
|
|
14
|
+
import { dressFor, linkFor, maskedText, ruleSays, wordFor } from './valueModel.js';
|
|
15
15
|
import { rowCurrency } from '@mistriwork/engine/shared/money.js';
|
|
16
16
|
import { dueOpen } from './dueOpen.js';
|
|
17
17
|
import { JsonValue } from './JsonValue.js';
|
|
@@ -22,6 +22,9 @@ import { ValueSlot } from './valueRenderers.js';
|
|
|
22
22
|
import { Icon } from './Icon.js';
|
|
23
23
|
import { say } from '../copy/record/components/Value.js';
|
|
24
24
|
import { shellBody } from '../shellHost.js';
|
|
25
|
+
import { Subtitled } from './SecondLine.js';
|
|
26
|
+
/* The second line is a value's too: the board reads it from here, as it reads every value's words. */
|
|
27
|
+
export { secondLine } from './SecondLine.js';
|
|
25
28
|
/* Drawn here and in the grid; the rules that draw them read no global (Dressed.tsx). */
|
|
26
29
|
export { AvatarText, Dressed };
|
|
27
30
|
/** A value that is a link: mail, a call, or a web page, which opens beside the App rather than in place of it. */
|
|
@@ -46,14 +49,9 @@ function breakable(text) {
|
|
|
46
49
|
}
|
|
47
50
|
/** A value as the record and the page show it: dressed when the app says, plain otherwise. */
|
|
48
51
|
export function Value(props) {
|
|
49
|
-
const { subtitled, row, col } = props;
|
|
52
|
+
const { subtitled, row, col, tableId } = props;
|
|
50
53
|
const body = _jsx(BareValue, { ...props });
|
|
51
|
-
|
|
52
|
-
const path = subtitlePath(rule, col?.name ?? '');
|
|
53
|
-
const second = path !== undefined && row && Object.hasOwn(row, path) ? row[path] : undefined;
|
|
54
|
-
if (second === null || second === undefined || second === '')
|
|
55
|
-
return body;
|
|
56
|
-
return (_jsxs("span", { className: "value-subtitled", children: [body, _jsx("span", { className: "value-sub", children: String(second) })] }));
|
|
54
|
+
return subtitled ? (_jsx(Subtitled, { tableId: tableId, column: col?.name, row: row, children: body })) : (body);
|
|
57
55
|
}
|
|
58
56
|
function BareValue(props) {
|
|
59
57
|
const { col, value, tableId, compact = false, links = !compact } = props;
|
|
@@ -133,7 +131,7 @@ function PlatformValue({ col, value, tableId, compact = false, links = !compact,
|
|
|
133
131
|
return (_jsx("ul", { className: "value-items", children: shown.map((item, index) => (_jsx("li", { children: String(item) }, index))) }));
|
|
134
132
|
if (compact)
|
|
135
133
|
return _jsx("span", { className: "json-preview-text", children: previewOf(shown) });
|
|
136
|
-
return _jsx(JsonValue, { value: shown, bar: !items });
|
|
134
|
+
return _jsx(JsonValue, { value: shown, bar: !items, label: col?.name });
|
|
137
135
|
}
|
|
138
136
|
/* A money column whose currency is the record's own: the code its row holds. */
|
|
139
137
|
const owned = declared?.currencyColumn && row
|
|
@@ -48,6 +48,10 @@ export interface ListSpec {
|
|
|
48
48
|
count?: boolean;
|
|
49
49
|
/** Columns or label paths the list shows, in order. */
|
|
50
50
|
show?: string[];
|
|
51
|
+
/** A second line under a shown column where the list's columns are inferred (shared/listInference.ts). */
|
|
52
|
+
subtitles?: Readonly<Record<string, string>>;
|
|
53
|
+
/** The board the list may be switched to, where its machine has three to seven open states (listInference.ts). */
|
|
54
|
+
asBoard?: import('@mistriwork/engine/shared/listPresentations.js').AppBoardList;
|
|
51
55
|
filters?: string[];
|
|
52
56
|
/** The orders a reader may choose from the list's Sort menu. */
|
|
53
57
|
sorts?: Array<{
|
|
@@ -61,6 +61,8 @@ export declare const formViewKey: (pageId: string | undefined) => string | undef
|
|
|
61
61
|
export declare const INBOX_PAGE = "app:inbox";
|
|
62
62
|
/** The page id the assistant's own room rides, reserved as the inbox's is. */
|
|
63
63
|
export declare const ASSISTANT_PAGE = "app:assistant";
|
|
64
|
+
/** The page id the Directory rides (Directory.tsx): every list, page and New of a menu past a dozen places. */
|
|
65
|
+
export declare const DIRECTORY_PAGE = "app:directory";
|
|
64
66
|
/** Whether a room is the assistant's page. */
|
|
65
67
|
export declare const isAssistantRoom: (room: object) => room is AssistantRoom;
|
|
66
68
|
/** Whether a room is one of the App's lists: neither a dashboard, a form nor the assistant's page. */
|
|
@@ -22,6 +22,8 @@ export const formViewKey = (pageId) => pageId?.startsWith('form-') ? pageId.slic
|
|
|
22
22
|
export const INBOX_PAGE = 'app:inbox';
|
|
23
23
|
/** The page id the assistant's own room rides, reserved as the inbox's is. */
|
|
24
24
|
export const ASSISTANT_PAGE = 'app:assistant';
|
|
25
|
+
/** The page id the Directory rides (Directory.tsx): every list, page and New of a menu past a dozen places. */
|
|
26
|
+
export const DIRECTORY_PAGE = 'app:directory';
|
|
25
27
|
/** Whether a room is the assistant's page. */
|
|
26
28
|
export const isAssistantRoom = (room) => Object.hasOwn(room, 'assistant');
|
|
27
29
|
/** Whether a room is one of the App's lists: neither a dashboard, a form nor the assistant's page. */
|
|
@@ -94,6 +94,8 @@ export interface Section {
|
|
|
94
94
|
noDrill?: true;
|
|
95
95
|
/** Authored `empty: 'hide'`: the section is left out of the dashboard while it has nothing to draw. */
|
|
96
96
|
emptyMode?: 'hide';
|
|
97
|
+
/** Served only: a rows section that reads its rows and no total (an overview's). */
|
|
98
|
+
counted?: false;
|
|
97
99
|
/** The section's own windows, the first where it starts; `windowKey` names it in the address. */
|
|
98
100
|
windows?: string[];
|
|
99
101
|
windowKey?: string;
|
|
@@ -124,6 +126,9 @@ export interface DashboardDef {
|
|
|
124
126
|
heading?: string;
|
|
125
127
|
/** The title is not drawn; it stays for a screen reader. */
|
|
126
128
|
headingHidden?: true;
|
|
129
|
+
/** The head's form (`head`): `compact`, the title alone on one line with its verbs and no intro; `own`, a page that
|
|
130
|
+
draws its own head (`head: false`), its title kept for a screen reader and its intro left to it (DashHead.tsx). */
|
|
131
|
+
head?: 'compact' | 'own';
|
|
127
132
|
/** Plain text, authored with the dashboard and served only with it. */
|
|
128
133
|
description?: string;
|
|
129
134
|
sections: Section[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { BoundAppTarget } from '@mistriwork/engine/shared/appLinks.js';
|
|
2
|
+
import { type ShownApp } from './appRooms.js';
|
|
3
|
+
export interface DirectoryLine {
|
|
4
|
+
key: string;
|
|
5
|
+
label: string;
|
|
6
|
+
/** What it is, said under its name: a list, a page, a link, a New. */
|
|
7
|
+
kind: 'list' | 'page' | 'link' | 'new';
|
|
8
|
+
icon?: string;
|
|
9
|
+
/** Where a link leads, drawn as one so it opens in a new tab like any link. */
|
|
10
|
+
href?: string;
|
|
11
|
+
open: () => void;
|
|
12
|
+
}
|
|
13
|
+
interface DirectorySection {
|
|
14
|
+
/** The menu's group, as it heads its rows there; none for the menu's top level. */
|
|
15
|
+
label?: string;
|
|
16
|
+
lines: DirectoryLine[];
|
|
17
|
+
}
|
|
18
|
+
/** Every place, grouped as the menu groups it. */
|
|
19
|
+
export declare function directorySections(app: ShownApp, hrefOf?: (target: BoundAppTarget) => string | undefined): DirectorySection[];
|
|
20
|
+
/**
|
|
21
|
+
* The sections a typed word keeps, each line scored by the palette's matcher on its name and, at half weight, on its
|
|
22
|
+
* group's ("billing" finds the Billing group's rows): best first within a section, the menu's order otherwise.
|
|
23
|
+
*/
|
|
24
|
+
export declare function filterDirectory(sections: readonly DirectorySection[], query: string): DirectorySection[];
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Directory's lines (Directory.tsx): every place a long menu leads — its lists, its pages, its links — grouped as
|
|
3
|
+
* the menu groups them, then the rooms nav does not name, then every New this reader may use. Filtered by the
|
|
4
|
+
* palette's own matcher (paletteModel.ts `score`), so a word finds here what it finds there.
|
|
5
|
+
*/
|
|
6
|
+
import { go, pageView, state, tableView } from '../core.js';
|
|
7
|
+
import { shell } from '../shellMode.js';
|
|
8
|
+
import { appListQuery } from './appListModel.js';
|
|
9
|
+
import { appMenu, appRooms, isListRoom, roomPageId } from './appRooms.js';
|
|
10
|
+
import { newPaletteItems } from './newMenuModel.js';
|
|
11
|
+
import { score } from './paletteModel.js';
|
|
12
|
+
import { say } from '../copy/shell/components/directoryModel.js';
|
|
13
|
+
const visit = (entry) => {
|
|
14
|
+
if (isListRoom(entry))
|
|
15
|
+
go({ ...tableView(entry.table, appListQuery(entry)), view: entry.id }, 'reset');
|
|
16
|
+
else
|
|
17
|
+
go(pageView(roomPageId(entry), undefined, undefined, entry.label), 'reset');
|
|
18
|
+
};
|
|
19
|
+
function lineOf(entry) {
|
|
20
|
+
return {
|
|
21
|
+
key: `room:${entry.id}`,
|
|
22
|
+
label: entry.label,
|
|
23
|
+
kind: isListRoom(entry) ? 'list' : 'page',
|
|
24
|
+
...(entry.icon ? { icon: entry.icon } : {}),
|
|
25
|
+
open: () => visit(entry),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** The lines a menu node holds, its nested groups' included: a group inside a group is one section, read in order. */
|
|
29
|
+
function linesOf(node) {
|
|
30
|
+
if (node.kind === 'destination')
|
|
31
|
+
return node.entry.error ? [] : [lineOf(node.entry)];
|
|
32
|
+
if (node.kind === 'target')
|
|
33
|
+
return [{ key: `link:${node.href}`, label: node.label, kind: 'link', href: node.href, open: () => window.location.assign(node.href) }];
|
|
34
|
+
return node.children.flatMap(linesOf);
|
|
35
|
+
}
|
|
36
|
+
const leadsNowhere = () => undefined;
|
|
37
|
+
/** Every place, grouped as the menu groups it. */
|
|
38
|
+
export function directorySections(app, hrefOf = shell().slots.navTargets?.hrefs(app, state.schema) ??
|
|
39
|
+
leadsNowhere) {
|
|
40
|
+
const menu = appMenu(app, hrefOf);
|
|
41
|
+
const sections = [];
|
|
42
|
+
const top = [];
|
|
43
|
+
for (const node of menu) {
|
|
44
|
+
if (node.kind === 'group') {
|
|
45
|
+
const lines = linesOf(node);
|
|
46
|
+
if (lines.length)
|
|
47
|
+
sections.push({ label: node.label, lines });
|
|
48
|
+
}
|
|
49
|
+
else
|
|
50
|
+
top.push(...linesOf(node));
|
|
51
|
+
}
|
|
52
|
+
if (top.length)
|
|
53
|
+
sections.unshift({ lines: top });
|
|
54
|
+
/* A room nav does not name is still a place: the home of an App with no nav, a list only a link reaches. */
|
|
55
|
+
const named = new Set(sections.flatMap((section) => section.lines.map((line) => line.key)));
|
|
56
|
+
const rest = appRooms(app)
|
|
57
|
+
.filter((room) => !('error' in room && room.error) && !named.has(`room:${room.id}`))
|
|
58
|
+
.map((room) => lineOf(room));
|
|
59
|
+
if (rest.length)
|
|
60
|
+
sections.push({ label: say('more'), lines: rest });
|
|
61
|
+
const made = newPaletteItems(app).map((item, at) => ({
|
|
62
|
+
key: `new:${at}:${item.label}`,
|
|
63
|
+
label: item.label,
|
|
64
|
+
kind: 'new',
|
|
65
|
+
...(item.icon ? { icon: item.icon } : {}),
|
|
66
|
+
open: item.run,
|
|
67
|
+
}));
|
|
68
|
+
if (made.length)
|
|
69
|
+
sections.push({ label: say('new'), lines: made });
|
|
70
|
+
return sections;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The sections a typed word keeps, each line scored by the palette's matcher on its name and, at half weight, on its
|
|
74
|
+
* group's ("billing" finds the Billing group's rows): best first within a section, the menu's order otherwise.
|
|
75
|
+
*/
|
|
76
|
+
export function filterDirectory(sections, query) {
|
|
77
|
+
const asked = query.trim();
|
|
78
|
+
if (!asked)
|
|
79
|
+
return [...sections];
|
|
80
|
+
return sections.flatMap((section) => {
|
|
81
|
+
const lines = section.lines
|
|
82
|
+
.map((line, at) => ({ line, at, points: Math.max(score(line.label, asked), section.label ? score(section.label, asked) / 2 : 0) }))
|
|
83
|
+
.filter((scored) => scored.points > 0)
|
|
84
|
+
.sort((a, b) => b.points - a.points || a.at - b.at)
|
|
85
|
+
.map((scored) => scored.line);
|
|
86
|
+
return lines.length ? [{ ...section, lines }] : [];
|
|
87
|
+
});
|
|
88
|
+
}
|
|
@@ -18,6 +18,9 @@ interface GridColumnSize {
|
|
|
18
18
|
values: unknown[];
|
|
19
19
|
/** The second line a display rule draws under each value, in the smaller type. */
|
|
20
20
|
subValues?: unknown[];
|
|
21
|
+
/** The words the totals row draws under the column, in its heavier weight: a sum is wider than any row it adds up,
|
|
22
|
+
and a total cut to "$102,795...." is the one figure that must be read whole. */
|
|
23
|
+
total?: string;
|
|
21
24
|
/** Values drawn as tone chips: the dot, padding and border are width too. */
|
|
22
25
|
chip?: boolean;
|
|
23
26
|
/** Measured in the first row: what a chip draws beyond its words (the dot, gap and padding of the look wearing it). */
|
|
@@ -9,6 +9,8 @@ const READABLE_TEXT = 360;
|
|
|
9
9
|
and Cycle kept their whole words as their minimum. */
|
|
10
10
|
const TITLE_TEXT = 240;
|
|
11
11
|
const SECONDARY_TEXT = 120;
|
|
12
|
+
/** How much wider a figure sets in the totals row's 600 weight than in a cell's 400 (features.css). */
|
|
13
|
+
const TOTAL_WEIGHT = 1.1;
|
|
12
14
|
/** An avatar's disc (24px) and the gap before its name. */
|
|
13
15
|
const AVATAR_WIDTH = 32;
|
|
14
16
|
/** How wide a head's characters set: a sentence-case label in the interface
|
|
@@ -59,8 +61,10 @@ export function columnSizeHint(column, headChar = GRID_HEAD_CHAR, measure, squee
|
|
|
59
61
|
measured, 40px: Lumen's "In progress" chip draws 41px past its words (dot,
|
|
60
62
|
gap, 8px and 10px of padding), and at 22 its cell cut it to "In progress …"
|
|
61
63
|
in Thread's issues and Compass's ratings. */
|
|
62
|
-
const length = longest(column.values) + (column.chip ? 5 : 0);
|
|
63
|
-
|
|
64
|
+
const length = Math.max(longest(column.values), column.total?.length ?? 0) + (column.chip ? 5 : 0);
|
|
65
|
+
/* The total is set in the totals row's semibold, a tenth wider than the cell's own weight. */
|
|
66
|
+
const totalWidth = measure && column.total ? Math.ceil(measure(column.total) * TOTAL_WEIGHT) : 0;
|
|
67
|
+
const textWidth = (measure ? Math.max(Math.ceil(widest(column.values)), totalWidth) + (column.chip ? (column.chipExtra ?? CHIP_EXTRA) : 0) : length * 8) +
|
|
64
68
|
(column.avatar ? AVATAR_WIDTH : 0);
|
|
65
69
|
/* A second line asks for room, never lowers the floor: an email under a
|
|
66
70
|
name wants its width, but a narrow panel still keeps the name's minimum.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A child's path, as JavaScript would reach it: `a.b[2].c`, and a key that is
|
|
3
|
+
* not an identifier in brackets, quoted as JSON quotes it — `headers["x-id"]`,
|
|
4
|
+
* `[""]` — so a path pasted into a console or a jq-like query finds the value.
|
|
5
|
+
* The path is also the node's identity in the viewer: two different places
|
|
6
|
+
* can never be said the same way.
|
|
7
|
+
*/
|
|
8
|
+
export declare function childPath(parent: string, key: string | number): string;
|
|
9
|
+
/** The text a value is copied as: a string as itself (what is pasted into a search box), anything else as its JSON. */
|
|
10
|
+
export declare function copyTextOf(value: unknown): string;
|
|
11
|
+
/** What a scalar is said as on screen, where the filter can mark it. */
|
|
12
|
+
export declare function shownTextOf(value: unknown, locale: string | undefined): string;
|
|
13
|
+
/** How many nodes a document has, counting no further than `cap`: the filter is offered only past a screenful. */
|
|
14
|
+
export declare function nodeCount(value: unknown, cap: number): number;
|
|
15
|
+
/** Whether anything in the document folds: Expand all and Collapse all are offered only then. */
|
|
16
|
+
export declare function hasNested(value: unknown): boolean;
|
|
17
|
+
/** What a filter found: the paths whose key matched, whose value matched, and the containers holding either. */
|
|
18
|
+
export interface Found {
|
|
19
|
+
query: string;
|
|
20
|
+
keys: ReadonlySet<string>;
|
|
21
|
+
values: ReadonlySet<string>;
|
|
22
|
+
/** Containers with a match somewhere inside them: these open, so every match is in view. */
|
|
23
|
+
inside: ReadonlySet<string>;
|
|
24
|
+
count: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Every key and value the text appears in, case aside. A value is read both as
|
|
28
|
+
* its JSON (`12500`, `true`, `null`, `2026-11-04T16:42:09Z`) and as the viewer
|
|
29
|
+
* says it (`12,500`, `Nov 4, 2026`), so either spelling finds it. Array
|
|
30
|
+
* positions are not keys: `0` would match every list.
|
|
31
|
+
*/
|
|
32
|
+
export declare function search(value: unknown, query: string, locale: string | undefined): Found | null;
|
|
33
|
+
/** Whether a path is a match or holds one: an entry past a list's page is still drawn when it is. */
|
|
34
|
+
export declare function isFound(found: Found | null, path: string): boolean;
|
|
35
|
+
/** The pieces of a text around each place a query appears, case aside: the odd ones are the matches. */
|
|
36
|
+
export declare function splitOnMatches(text: string, query: string): string[];
|
|
37
|
+
/**
|
|
38
|
+
* A string that is a machine's word rather than a person's: a hex color (drawn
|
|
39
|
+
* with a swatch of itself), a uuid, an email address. Each is set in the code
|
|
40
|
+
* face, where `0`/`O` and `l`/`1` are told apart and every uuid lines up.
|
|
41
|
+
*/
|
|
42
|
+
export declare function textFace(text: string): {
|
|
43
|
+
code: boolean;
|
|
44
|
+
swatch?: string;
|
|
45
|
+
};
|
|
46
|
+
/** One piece of a line of raw JSON, by what it is. */
|
|
47
|
+
export interface Token {
|
|
48
|
+
kind: 'key' | 'string' | 'number' | 'boolean' | 'null' | 'punct' | 'space';
|
|
49
|
+
text: string;
|
|
50
|
+
}
|
|
51
|
+
/** A line of JSON text as tokens; together their text is the line, character for character. */
|
|
52
|
+
export declare function tokenizeLine(line: string): Token[];
|
|
53
|
+
/** A document's raw text, pretty-printed (big integers as their digits), a line of tokens at a time. */
|
|
54
|
+
export declare function rawLines(value: unknown): string[];
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the JSON viewer knows beyond a value's layout: where each part is (its
|
|
3
|
+
* path, said the way code reaches it), what a filter finds, what Copy takes,
|
|
4
|
+
* what a string is when it is a color or an id, and the raw text as tokens to
|
|
5
|
+
* tint. A module of its own, loaded with the viewer (JsonView.tsx is fetched
|
|
6
|
+
* on demand): jsonModel.ts is on every first page for the grid's one-line
|
|
7
|
+
* preview, and none of this is.
|
|
8
|
+
*/
|
|
9
|
+
import { isContainer, JsonBig, prettyJson, scalarOf, sizeOf } from './jsonModel.js';
|
|
10
|
+
const IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
|
|
11
|
+
/**
|
|
12
|
+
* A child's path, as JavaScript would reach it: `a.b[2].c`, and a key that is
|
|
13
|
+
* not an identifier in brackets, quoted as JSON quotes it — `headers["x-id"]`,
|
|
14
|
+
* `[""]` — so a path pasted into a console or a jq-like query finds the value.
|
|
15
|
+
* The path is also the node's identity in the viewer: two different places
|
|
16
|
+
* can never be said the same way.
|
|
17
|
+
*/
|
|
18
|
+
export function childPath(parent, key) {
|
|
19
|
+
if (typeof key === 'number')
|
|
20
|
+
return `${parent}[${key}]`;
|
|
21
|
+
if (IDENTIFIER.test(key))
|
|
22
|
+
return parent ? `${parent}.${key}` : key;
|
|
23
|
+
return `${parent}[${JSON.stringify(key)}]`;
|
|
24
|
+
}
|
|
25
|
+
/** The text a value is copied as: a string as itself (what is pasted into a search box), anything else as its JSON. */
|
|
26
|
+
export function copyTextOf(value) {
|
|
27
|
+
if (typeof value === 'string')
|
|
28
|
+
return value;
|
|
29
|
+
if (value instanceof JsonBig)
|
|
30
|
+
return value.text;
|
|
31
|
+
if (value === undefined || value === null)
|
|
32
|
+
return 'null';
|
|
33
|
+
if (isContainer(value))
|
|
34
|
+
return prettyJson(value);
|
|
35
|
+
return String(value);
|
|
36
|
+
}
|
|
37
|
+
/** A scalar's JSON text: what the filter reads beside what the reader sees. */
|
|
38
|
+
function rawTextOf(value) {
|
|
39
|
+
if (value instanceof JsonBig)
|
|
40
|
+
return value.text;
|
|
41
|
+
if (value === null || value === undefined)
|
|
42
|
+
return 'null';
|
|
43
|
+
return String(value);
|
|
44
|
+
}
|
|
45
|
+
/** What a scalar is said as on screen, where the filter can mark it. */
|
|
46
|
+
export function shownTextOf(value, locale) {
|
|
47
|
+
const said = scalarOf(value, locale);
|
|
48
|
+
switch (said.kind) {
|
|
49
|
+
case 'null':
|
|
50
|
+
return 'null';
|
|
51
|
+
case 'boolean':
|
|
52
|
+
return said.on ? 'true' : 'false';
|
|
53
|
+
case 'empty':
|
|
54
|
+
return '""';
|
|
55
|
+
default:
|
|
56
|
+
return said.text;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/** How many nodes a document has, counting no further than `cap`: the filter is offered only past a screenful. */
|
|
60
|
+
export function nodeCount(value, cap) {
|
|
61
|
+
let count = 0;
|
|
62
|
+
const walk = (item) => {
|
|
63
|
+
if (count >= cap || !isContainer(item))
|
|
64
|
+
return;
|
|
65
|
+
for (const child of Object.values(item)) {
|
|
66
|
+
if (count >= cap)
|
|
67
|
+
return;
|
|
68
|
+
count += 1;
|
|
69
|
+
walk(child);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
walk(value);
|
|
73
|
+
return count;
|
|
74
|
+
}
|
|
75
|
+
/** Whether anything in the document folds: Expand all and Collapse all are offered only then. */
|
|
76
|
+
export function hasNested(value) {
|
|
77
|
+
return isContainer(value) && Object.values(value).some((child) => isContainer(child) && sizeOf(child) > 0);
|
|
78
|
+
}
|
|
79
|
+
/** The most nodes one filter reads: a document past this is searched in its first part, which is still more than any page shows. */
|
|
80
|
+
const SEARCH_LIMIT = 200_000;
|
|
81
|
+
/**
|
|
82
|
+
* Every key and value the text appears in, case aside. A value is read both as
|
|
83
|
+
* its JSON (`12500`, `true`, `null`, `2026-11-04T16:42:09Z`) and as the viewer
|
|
84
|
+
* says it (`12,500`, `Nov 4, 2026`), so either spelling finds it. Array
|
|
85
|
+
* positions are not keys: `0` would match every list.
|
|
86
|
+
*/
|
|
87
|
+
export function search(value, query, locale) {
|
|
88
|
+
const needle = query.trim().toLocaleLowerCase();
|
|
89
|
+
if (!needle)
|
|
90
|
+
return null;
|
|
91
|
+
const keys = new Set();
|
|
92
|
+
const values = new Set();
|
|
93
|
+
const inside = new Set();
|
|
94
|
+
const has = (text) => text.toLocaleLowerCase().includes(needle);
|
|
95
|
+
let read = 0;
|
|
96
|
+
const walk = (item, path) => {
|
|
97
|
+
if (!isContainer(item))
|
|
98
|
+
return false;
|
|
99
|
+
let found = false;
|
|
100
|
+
const indexed = Array.isArray(item);
|
|
101
|
+
for (const [key, child] of Object.entries(item)) {
|
|
102
|
+
if (++read > SEARCH_LIMIT)
|
|
103
|
+
break;
|
|
104
|
+
const here = childPath(path, indexed ? Number(key) : key);
|
|
105
|
+
if (!indexed && has(key)) {
|
|
106
|
+
keys.add(here);
|
|
107
|
+
found = true;
|
|
108
|
+
}
|
|
109
|
+
if (isContainer(child)) {
|
|
110
|
+
if (walk(child, here)) {
|
|
111
|
+
inside.add(here);
|
|
112
|
+
found = true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else if (has(rawTextOf(child)) || has(shownTextOf(child, locale))) {
|
|
116
|
+
values.add(here);
|
|
117
|
+
found = true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return found;
|
|
121
|
+
};
|
|
122
|
+
walk(value, '');
|
|
123
|
+
return { query: query.trim(), keys, values, inside, count: keys.size + values.size };
|
|
124
|
+
}
|
|
125
|
+
/** Whether a path is a match or holds one: an entry past a list's page is still drawn when it is. */
|
|
126
|
+
export function isFound(found, path) {
|
|
127
|
+
return !!found && (found.keys.has(path) || found.values.has(path) || found.inside.has(path));
|
|
128
|
+
}
|
|
129
|
+
/** The pieces of a text around each place a query appears, case aside: the odd ones are the matches. */
|
|
130
|
+
export function splitOnMatches(text, query) {
|
|
131
|
+
if (!query)
|
|
132
|
+
return [text];
|
|
133
|
+
const escaped = query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
134
|
+
return text.split(new RegExp(`(${escaped})`, 'giu'));
|
|
135
|
+
}
|
|
136
|
+
const HEX_COLOR = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
137
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
138
|
+
const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
139
|
+
/**
|
|
140
|
+
* A string that is a machine's word rather than a person's: a hex color (drawn
|
|
141
|
+
* with a swatch of itself), a uuid, an email address. Each is set in the code
|
|
142
|
+
* face, where `0`/`O` and `l`/`1` are told apart and every uuid lines up.
|
|
143
|
+
*/
|
|
144
|
+
export function textFace(text) {
|
|
145
|
+
if (HEX_COLOR.test(text))
|
|
146
|
+
return { code: true, swatch: text };
|
|
147
|
+
return { code: UUID.test(text) || EMAIL.test(text) };
|
|
148
|
+
}
|
|
149
|
+
/* One token at a time from the line's start: a string (a key when a colon
|
|
150
|
+
follows it), a number, a literal, a punctuation mark, a run of spaces. The
|
|
151
|
+
text is the viewer's own pretty-printing, so it is always JSON; anything
|
|
152
|
+
else (it cannot happen) is passed through as punctuation, never dropped. */
|
|
153
|
+
const TOKEN = /("(?:[^"\\]|\\.)*")|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|(true|false)|(null)|([{}[\],:])|(\s+)/y;
|
|
154
|
+
const COLON_NEXT = /\s*:/y;
|
|
155
|
+
/** A line of JSON text as tokens; together their text is the line, character for character. */
|
|
156
|
+
export function tokenizeLine(line) {
|
|
157
|
+
const tokens = [];
|
|
158
|
+
let at = 0;
|
|
159
|
+
while (at < line.length) {
|
|
160
|
+
TOKEN.lastIndex = at;
|
|
161
|
+
const m = TOKEN.exec(line);
|
|
162
|
+
if (!m) {
|
|
163
|
+
tokens.push({ kind: 'punct', text: line[at] });
|
|
164
|
+
at += 1;
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
const [text, string, number, boolean, nul, , space] = m;
|
|
168
|
+
COLON_NEXT.lastIndex = at + text.length;
|
|
169
|
+
const kind = string !== undefined
|
|
170
|
+
? COLON_NEXT.test(line)
|
|
171
|
+
? 'key'
|
|
172
|
+
: 'string'
|
|
173
|
+
: number !== undefined
|
|
174
|
+
? 'number'
|
|
175
|
+
: boolean !== undefined
|
|
176
|
+
? 'boolean'
|
|
177
|
+
: nul !== undefined
|
|
178
|
+
? 'null'
|
|
179
|
+
: space !== undefined
|
|
180
|
+
? 'space'
|
|
181
|
+
: 'punct';
|
|
182
|
+
tokens.push({ kind, text });
|
|
183
|
+
at += text.length;
|
|
184
|
+
}
|
|
185
|
+
return tokens;
|
|
186
|
+
}
|
|
187
|
+
/** A document's raw text, pretty-printed (big integers as their digits), a line of tokens at a time. */
|
|
188
|
+
export function rawLines(value) {
|
|
189
|
+
return prettyJson(value).split('\n');
|
|
190
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ListSubtitles: import("react").Context<Readonly<Record<string, string>>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A list's own second lines, by column, where its columns are inferred (shared/listInference.ts inferListSubtitles):
|
|
3
|
+
* a job's number under its title. Said by the list (AppList.tsx) to the grid it draws, and nowhere else, so a list an
|
|
4
|
+
* author arranged and every record page keep the display rules they were given.
|
|
5
|
+
*/
|
|
6
|
+
import { createContext } from 'react';
|
|
7
|
+
export const ListSubtitles = createContext(undefined);
|
|
@@ -13,15 +13,23 @@ export declare function appNewEntries(app: NewMenuApp | null | undefined): NewMe
|
|
|
13
13
|
* signed-in form's page.
|
|
14
14
|
*/
|
|
15
15
|
export declare function openNewEntry(app: NewMenuApp, entry: NewMenuEntry): void;
|
|
16
|
+
/** One create line as the palette lists it: its words, what a search matches, its mark, and what it opens. */
|
|
17
|
+
interface NewPaletteItem {
|
|
18
|
+
kind: 'create';
|
|
19
|
+
label: string;
|
|
20
|
+
search: string;
|
|
21
|
+
icon?: string;
|
|
22
|
+
run: () => void;
|
|
23
|
+
}
|
|
16
24
|
/**
|
|
17
25
|
* The same lines as the palette lists them, searchable ("new supplier"). The
|
|
18
26
|
* palette (Palette.tsx) fetches this module when it opens over an App that
|
|
19
27
|
* declares the menu, so none of this is in the first page.
|
|
28
|
+
*
|
|
29
|
+
* A list's line is "New ticket", the verb its button says. A form's line is the
|
|
30
|
+
* command's own words ("Post this month's rent"): putting "New" before a verb
|
|
31
|
+
* made "New post this month's rent". Both are found by "new …", as the menu's
|
|
32
|
+
* button is the thing people reach for.
|
|
20
33
|
*/
|
|
21
|
-
export declare function newPaletteItems(app: NewMenuApp | null | undefined):
|
|
22
|
-
kind: 'action';
|
|
23
|
-
label: string;
|
|
24
|
-
search: string;
|
|
25
|
-
run: () => void;
|
|
26
|
-
}>;
|
|
34
|
+
export declare function newPaletteItems(app: NewMenuApp | null | undefined): NewPaletteItem[];
|
|
27
35
|
export {};
|
|
@@ -9,7 +9,8 @@ import { findTable, go, pageView, tableView } from '../core.js';
|
|
|
9
9
|
import { canInsert } from '../insert.js';
|
|
10
10
|
import { newMenuEntries } from '@mistriwork/engine/shared/servedApp.js';
|
|
11
11
|
import { appListQuery, newRecordNoun } from './appListModel.js';
|
|
12
|
-
import { formPageId, isListRoom, viewRoom } from './appRooms.js';
|
|
12
|
+
import { appMenu, appRooms, formPageId, isListRoom, viewRoom } from './appRooms.js';
|
|
13
|
+
import { navigationPaths } from './navigationTree.js';
|
|
13
14
|
import { say } from '../copy/shell/components/newMenuModel.js';
|
|
14
15
|
/** "ticket" → "Ticket": a menu line starts with a capital, and a noun is held in the sentence's case. */
|
|
15
16
|
const lineCase = (said) => said.charAt(0).toUpperCase() + said.slice(1);
|
|
@@ -41,18 +42,49 @@ export function openNewEntry(app, entry) {
|
|
|
41
42
|
}
|
|
42
43
|
go(pageView(formPageId(entry.view), undefined, undefined, room && 'label' in room ? room.label : entry.label), 'reset');
|
|
43
44
|
}
|
|
44
|
-
/** The palette's words for a line: "New ticket" — a noun keeps its own case after the verb; a name like "SLA" keeps its capitals. */
|
|
45
|
+
/** The palette's words for a list's line: "New ticket" — a noun keeps its own case after the verb; a name like "SLA" keeps its capitals. */
|
|
45
46
|
const phrase = (entry) => /^[A-Z][a-z]/.test(entry.label) ? entry.label.charAt(0).toLowerCase() + entry.label.slice(1) : entry.label;
|
|
46
47
|
/**
|
|
47
48
|
* The same lines as the palette lists them, searchable ("new supplier"). The
|
|
48
49
|
* palette (Palette.tsx) fetches this module when it opens over an App that
|
|
49
50
|
* declares the menu, so none of this is in the first page.
|
|
51
|
+
*
|
|
52
|
+
* A list's line is "New ticket", the verb its button says. A form's line is the
|
|
53
|
+
* command's own words ("Post this month's rent"): putting "New" before a verb
|
|
54
|
+
* made "New post this month's rent". Both are found by "new …", as the menu's
|
|
55
|
+
* button is the thing people reach for.
|
|
50
56
|
*/
|
|
51
57
|
export function newPaletteItems(app) {
|
|
52
58
|
if (!app)
|
|
53
59
|
return [];
|
|
54
|
-
return appNewEntries(app).map((entry) => {
|
|
55
|
-
const
|
|
56
|
-
|
|
60
|
+
return (app.ui.shell?.new?.length ? appNewEntries(app) : listedNewEntries(app)).map((entry) => {
|
|
61
|
+
const made = say('newThing', { thing: phrase(entry) });
|
|
62
|
+
const label = entry.table === undefined ? entry.label : made;
|
|
63
|
+
return {
|
|
64
|
+
kind: 'create',
|
|
65
|
+
label,
|
|
66
|
+
search: label === made ? made : `${label} ${made}`,
|
|
67
|
+
...(entry.icon === undefined ? {} : { icon: entry.icon }),
|
|
68
|
+
run: () => openNewEntry(app, entry),
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Where the App declares no New menu, what its lists offer: one line per table, the first list of it in the menu's
|
|
74
|
+
* order — the New its list's own button says ("New visit"), where this reader may add to it. A palette over an App
|
|
75
|
+
* with seven lists and a New button on each offered none of them, so "new visit" found nothing.
|
|
76
|
+
*/
|
|
77
|
+
function listedNewEntries(app) {
|
|
78
|
+
const menu = navigationPaths(appMenu(app)).map(({ entry }) => entry);
|
|
79
|
+
const rooms = [...menu, ...appRooms(app).filter((room) => !menu.some((listed) => listed.id === room.id))];
|
|
80
|
+
const tables = new Set();
|
|
81
|
+
return rooms.flatMap((room) => {
|
|
82
|
+
if (('error' in room && room.error) || !isListRoom(room) || tables.has(room.table))
|
|
83
|
+
return [];
|
|
84
|
+
tables.add(room.table);
|
|
85
|
+
if (!canInsert(findTable(room.table), true))
|
|
86
|
+
return [];
|
|
87
|
+
const noun = lineCase(newRecordNoun(room, findTable(room.table)?.name ?? room.table));
|
|
88
|
+
return [{ view: room.id, table: room.table, label: noun, ...(room.icon ? { icon: room.icon } : {}) }];
|
|
57
89
|
});
|
|
58
90
|
}
|