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

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 (102) hide show
  1. package/dist/client/components/AppList.js +16 -6
  2. package/dist/client/components/Chart.css +5 -0
  3. package/dist/client/components/Chart.d.ts +17 -2
  4. package/dist/client/components/Chart.js +83 -22
  5. package/dist/client/components/ChartFigure.d.ts +3 -1
  6. package/dist/client/components/ChartFigure.js +14 -8
  7. package/dist/client/components/Content.js +3 -1
  8. package/dist/client/components/DashHead.d.ts +6 -0
  9. package/dist/client/components/DashHead.js +20 -0
  10. package/dist/client/components/Editable.js +1 -1
  11. package/dist/client/components/Grid.js +33 -4
  12. package/dist/client/components/JsonPreview.css +29 -0
  13. package/dist/client/components/JsonPreview.js +1 -1
  14. package/dist/client/components/JsonView.css +201 -62
  15. package/dist/client/components/JsonView.d.ts +43 -1
  16. package/dist/client/components/JsonView.js +320 -55
  17. package/dist/client/components/LayoutSwitch.d.ts +9 -0
  18. package/dist/client/components/LayoutSwitch.js +61 -0
  19. package/dist/client/components/ListEmpty.css +3 -0
  20. package/dist/client/components/ListFilterBar.js +1 -1
  21. package/dist/client/components/LiveNotices.css +3 -0
  22. package/dist/client/components/NewRecord.d.ts +0 -2
  23. package/dist/client/components/NewRecord.js +61 -17
  24. package/dist/client/components/PageFields.js +22 -3
  25. package/dist/client/components/PageHead.js +26 -6
  26. package/dist/client/components/PageRelated.d.ts +28 -0
  27. package/dist/client/components/PageRelated.js +50 -3
  28. package/dist/client/components/PageSectionBox.d.ts +5 -1
  29. package/dist/client/components/PageSectionBox.js +5 -3
  30. package/dist/client/components/PageSections.js +26 -13
  31. package/dist/client/components/PageSkeleton.css +2 -0
  32. package/dist/client/components/PageSkeleton.js +11 -3
  33. package/dist/client/components/Palette.js +108 -10
  34. package/dist/client/components/RecordPicker.d.ts +2 -0
  35. package/dist/client/components/RecordPicker.js +34 -8
  36. package/dist/client/components/RecordSummaries.js +6 -1
  37. package/dist/client/components/Rooms.js +2 -2
  38. package/dist/client/components/TableRoom.js +15 -5
  39. package/dist/client/components/TableView.d.ts +2 -0
  40. package/dist/client/components/Value.js +1 -1
  41. package/dist/client/components/appListModel.d.ts +4 -0
  42. package/dist/client/components/appRooms.d.ts +2 -0
  43. package/dist/client/components/appRooms.js +2 -0
  44. package/dist/client/components/dashboardModel.d.ts +5 -0
  45. package/dist/client/components/directoryModel.d.ts +25 -0
  46. package/dist/client/components/directoryModel.js +88 -0
  47. package/dist/client/components/gridSizing.d.ts +3 -0
  48. package/dist/client/components/gridSizing.js +6 -2
  49. package/dist/client/components/jsonTree.d.ts +54 -0
  50. package/dist/client/components/jsonTree.js +190 -0
  51. package/dist/client/components/listSubtitles.d.ts +1 -0
  52. package/dist/client/components/listSubtitles.js +7 -0
  53. package/dist/client/components/newMenuModel.d.ts +14 -6
  54. package/dist/client/components/newMenuModel.js +37 -5
  55. package/dist/client/components/newRecordModel.d.ts +24 -2
  56. package/dist/client/components/newRecordModel.js +47 -4
  57. package/dist/client/components/pageContext.d.ts +2 -0
  58. package/dist/client/components/pageModel.d.ts +2 -0
  59. package/dist/client/components/sidebarModel.js +7 -3
  60. package/dist/client/composedReads.js +3 -1
  61. package/dist/client/copy/filters/components/ListFilterBar.d.ts +1 -1
  62. package/dist/client/copy/filters/components/ListFilterBar.js +2 -1
  63. package/dist/client/copy/lists/components/AppList.d.ts +1 -0
  64. package/dist/client/copy/lists/components/AppList.js +1 -0
  65. package/dist/client/copy/lists/components/LayoutSwitch.d.ts +4 -0
  66. package/dist/client/copy/lists/components/LayoutSwitch.js +6 -0
  67. package/dist/client/copy/record/components/JsonView.d.ts +22 -0
  68. package/dist/client/copy/record/components/JsonView.js +19 -0
  69. package/dist/client/copy/record/components/PageHead.d.ts +1 -0
  70. package/dist/client/copy/record/components/PageHead.js +2 -0
  71. package/dist/client/copy/shell/components/Palette.d.ts +11 -0
  72. package/dist/client/copy/shell/components/Palette.js +14 -0
  73. package/dist/client/copy/shell/components/TopNav.d.ts +2 -1
  74. package/dist/client/copy/shell/components/TopNav.js +4 -2
  75. package/dist/client/copy/shell/components/directoryModel.d.ts +4 -0
  76. package/dist/client/copy/shell/components/directoryModel.js +6 -0
  77. package/dist/client/copy/shell/components/sidebarModel.d.ts +1 -0
  78. package/dist/client/copy/shell/components/sidebarModel.js +1 -0
  79. package/dist/client/core.d.ts +3 -3
  80. package/dist/client/core.js +6 -7
  81. package/dist/client/features.css +67 -7
  82. package/dist/client/index.html +2 -1
  83. package/dist/client/insert.js +1 -8
  84. package/dist/client/locale.d.ts +7 -0
  85. package/dist/client/locale.js +0 -0
  86. package/dist/client/lumenLook.css +12 -13
  87. package/dist/client/page.css +56 -15
  88. package/dist/client/palette.d.ts +3 -1
  89. package/dist/client/palette.js +19 -4
  90. package/dist/client/paletteRecents.d.ts +25 -0
  91. package/dist/client/paletteRecents.js +64 -0
  92. package/dist/client/partsLook.css +32 -3
  93. package/dist/client/sageLook.css +5 -3
  94. package/dist/client/shellMode.d.ts +2 -0
  95. package/dist/client/shellMode.js +1 -0
  96. package/dist/client/structure.css +201 -1
  97. package/dist/client/style.css +59 -10
  98. package/dist/client/themeFamilies.css +37 -0
  99. package/dist/client/visualThemes.css +12 -0
  100. package/dist/client/workbenchLook.css +420 -0
  101. package/dist/client/workshopLook.css +48 -25
  102. package/package.json +4 -3
@@ -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
- const textWidth = (measure ? Math.ceil(widest(column.values)) + (column.chip ? (column.chipExtra ?? CHIP_EXTRA) : 0) : length * 8) +
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): Array<{
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 label = say('newThing', { thing: phrase(entry) });
56
- return { kind: 'action', label, search: label, run: () => openNewEntry(app, entry) };
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
  }
@@ -1,3 +1,9 @@
1
+ /**
2
+ * The New form's rules, apart from its drawing (NewRecord.tsx, DefinedFields.tsx, PageRelated.tsx): which columns it
3
+ * asks and in what groups, which a condition hides, what each starts at (a declared default, today or now, a flag's
4
+ * start), the control each field gets, how an earlier pick narrows a later one, whether it opens as a drawer or a page,
5
+ * and what is missing or changed before the values are written.
6
+ */
1
7
  import { type ColumnMeta, type TableMeta } from '@mistriwork/engine/shared/schema.js';
2
8
  import type { AppForm } from '@mistriwork/engine/shared/servedApp.js';
3
9
  import { type FormScalar } from '@mistriwork/engine/shared/formValues.js';
@@ -12,9 +18,14 @@ interface FormGroup {
12
18
  /** Unknown draft dependencies stay visible so an incomplete form never hides
13
19
  * the control needed to resolve its own condition. */
14
20
  export declare function isFormFieldVisible(form: FormCuration | undefined, column: ColumnMeta, values: Readonly<Record<string, FormScalar | string>>, table: TableMeta): boolean;
15
- export declare function formColumns(table: TableMeta, form: FormCuration | undefined, app: boolean): ColumnMeta[];
21
+ /**
22
+ * The columns a New form asks, in order. `written` is what the database and the App's machine fill without being
23
+ * asked (platformWritten in form.ts): left out where the form names its fields by the schema, kept where the App's
24
+ * form names one itself (in `show`, a step or a group), since a declared field is the author's to ask.
25
+ */
26
+ export declare function formColumns(table: TableMeta, form: FormCuration | undefined, app: boolean, written?: ReadonlySet<string>): ColumnMeta[];
16
27
  /** Grouped fields retain authored order; ungrouped fields follow in form order. */
17
- export declare function formGroups(table: TableMeta, form: FormCuration | undefined, app: boolean): FormGroup[];
28
+ export declare function formGroups(table: TableMeta, form: FormCuration | undefined, app: boolean, written?: ReadonlySet<string>): FormGroup[];
18
29
  export declare function presetValue(column: ColumnMeta, defaults: Record<string, unknown>): string;
19
30
  /** Returning to a displayed preset is clean, except when clearing means omission. */
20
31
  export declare function hasFormChanges(columns: ColumnMeta[], values: Record<string, string>, defaults: Record<string, unknown>, edited: ReadonlySet<string>): boolean;
@@ -30,6 +41,9 @@ export declare function missingFields(columns: ColumnMeta[], values: Record<stri
30
41
  /** Where the New form is drawn: what it says, else a drawer for a short form and a page for a long or stepped one. */
31
42
  export declare function formFrame(form: FormCuration | undefined, fieldCount: number): 'drawer' | 'page';
32
43
  export type FieldInput = 'text' | 'textarea' | 'richText' | 'number' | 'money' | 'radios' | 'listbox' | 'switch' | 'flag' | 'date' | 'datetime' | 'reference';
44
+ /** A choice declared as cards, up to this many words and none described, is a row of picks instead: five stacked cards
45
+ took 270px to say five words (docs/design.md, Forms). A card that carries a description keeps its card. */
46
+ export declare const SEGMENTED_WORDS = 5;
33
47
  /**
34
48
  * The input an App's New form draws a column as, from the column and how the
35
49
  * App dresses it. `hasStart` is whether the field starts with a value (a form
@@ -48,6 +62,14 @@ export declare function fieldInput(column: ColumnMeta, options: {
48
62
  export declare function clockDefault(word: 'today' | 'now', column: ColumnMeta, now: Date, timeZone?: string): string;
49
63
  /** The choices a narrowed reference offers, in the query language: `project_id = 4`; undefined while a field it reads is empty. */
50
64
  export declare function narrowingCondition(where: Readonly<Record<string, string>> | undefined, values: Readonly<Record<string, unknown>>): string | undefined;
65
+ /**
66
+ * The pickers a form narrows by an earlier pick where the App's form says nothing (`fields.<column>.where`): a
67
+ * reference whose table points at the table of a required reference asked before it, by exactly one column, offers
68
+ * only the records under that pick — a job's site among the chosen customer's sites, never every customer's. An
69
+ * optional earlier pick narrows nothing, since a picker waiting on a field that may stay empty would wait for good.
70
+ * The narrowing is the picker's, as a declared one is: the server still takes any record the reader may name.
71
+ */
72
+ export declare function inferredNarrowing(columns: readonly ColumnMeta[], target: (tableId: string) => TableMeta | undefined): Record<string, Record<string, string>>;
51
73
  /**
52
74
  * Where a flag's switch starts: the form's default, else the database's when
53
75
  * it is a plain true or false, else off for a flag that must be answered. A