@mistriwork/kit 1.0.0-rc.16 → 1.0.0-rc.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/dist/client/components/AppList.js +16 -6
  2. package/dist/client/components/CardsList.js +7 -1
  3. package/dist/client/components/Chart.css +5 -0
  4. package/dist/client/components/Chart.d.ts +17 -2
  5. package/dist/client/components/Chart.js +83 -22
  6. package/dist/client/components/ChartFigure.d.ts +3 -1
  7. package/dist/client/components/ChartFigure.js +14 -8
  8. package/dist/client/components/Content.js +3 -1
  9. package/dist/client/components/DashHead.d.ts +6 -0
  10. package/dist/client/components/DashHead.js +20 -0
  11. package/dist/client/components/Editable.js +1 -1
  12. package/dist/client/components/Export.js +8 -4
  13. package/dist/client/components/Grid.js +54 -6
  14. package/dist/client/components/JsonPreview.css +29 -0
  15. package/dist/client/components/JsonPreview.js +1 -1
  16. package/dist/client/components/JsonView.css +201 -62
  17. package/dist/client/components/JsonView.d.ts +43 -1
  18. package/dist/client/components/JsonView.js +320 -55
  19. package/dist/client/components/LayoutSwitch.d.ts +9 -0
  20. package/dist/client/components/LayoutSwitch.js +61 -0
  21. package/dist/client/components/ListEmpty.css +3 -0
  22. package/dist/client/components/LiveNotices.css +3 -0
  23. package/dist/client/components/NewRecord.d.ts +0 -2
  24. package/dist/client/components/NewRecord.js +61 -17
  25. package/dist/client/components/PageFields.js +23 -4
  26. package/dist/client/components/PageHead.js +28 -7
  27. package/dist/client/components/PageRelated.d.ts +28 -0
  28. package/dist/client/components/PageRelated.js +50 -3
  29. package/dist/client/components/PageSectionBox.d.ts +5 -1
  30. package/dist/client/components/PageSectionBox.js +5 -3
  31. package/dist/client/components/PageSections.js +26 -13
  32. package/dist/client/components/PageSkeleton.css +2 -0
  33. package/dist/client/components/PageSkeleton.js +11 -3
  34. package/dist/client/components/Palette.js +108 -10
  35. package/dist/client/components/RecordPicker.d.ts +2 -0
  36. package/dist/client/components/RecordPicker.js +34 -8
  37. package/dist/client/components/RecordSummaries.js +6 -1
  38. package/dist/client/components/Rooms.js +2 -2
  39. package/dist/client/components/SecondLine.d.ts +15 -0
  40. package/dist/client/components/SecondLine.js +18 -0
  41. package/dist/client/components/TableRoom.js +15 -5
  42. package/dist/client/components/TableView.d.ts +2 -0
  43. package/dist/client/components/Value.d.ts +1 -0
  44. package/dist/client/components/Value.js +7 -9
  45. package/dist/client/components/appListModel.d.ts +4 -0
  46. package/dist/client/components/appRooms.d.ts +2 -0
  47. package/dist/client/components/appRooms.js +2 -0
  48. package/dist/client/components/dashboardModel.d.ts +5 -0
  49. package/dist/client/components/directoryModel.d.ts +25 -0
  50. package/dist/client/components/directoryModel.js +88 -0
  51. package/dist/client/components/gridSizing.d.ts +3 -0
  52. package/dist/client/components/gridSizing.js +6 -2
  53. package/dist/client/components/jsonTree.d.ts +54 -0
  54. package/dist/client/components/jsonTree.js +190 -0
  55. package/dist/client/components/listSubtitles.d.ts +1 -0
  56. package/dist/client/components/listSubtitles.js +7 -0
  57. package/dist/client/components/newMenuModel.d.ts +14 -6
  58. package/dist/client/components/newMenuModel.js +37 -5
  59. package/dist/client/components/newRecordModel.d.ts +24 -2
  60. package/dist/client/components/newRecordModel.js +47 -4
  61. package/dist/client/components/pageContext.d.ts +2 -0
  62. package/dist/client/components/pageModel.d.ts +2 -0
  63. package/dist/client/components/sidebarModel.js +7 -3
  64. package/dist/client/components/textMeasure.d.ts +2 -0
  65. package/dist/client/components/textMeasure.js +16 -2
  66. package/dist/client/composedReads.js +3 -1
  67. package/dist/client/copy/lists/components/AppList.d.ts +1 -0
  68. package/dist/client/copy/lists/components/AppList.js +1 -0
  69. package/dist/client/copy/lists/components/LayoutSwitch.d.ts +4 -0
  70. package/dist/client/copy/lists/components/LayoutSwitch.js +6 -0
  71. package/dist/client/copy/record/components/JsonView.d.ts +22 -0
  72. package/dist/client/copy/record/components/JsonView.js +19 -0
  73. package/dist/client/copy/record/components/PageHead.d.ts +1 -0
  74. package/dist/client/copy/record/components/PageHead.js +2 -0
  75. package/dist/client/copy/shell/components/Palette.d.ts +11 -0
  76. package/dist/client/copy/shell/components/Palette.js +14 -0
  77. package/dist/client/copy/shell/components/TopNav.d.ts +2 -1
  78. package/dist/client/copy/shell/components/TopNav.js +4 -2
  79. package/dist/client/copy/shell/components/directoryModel.d.ts +4 -0
  80. package/dist/client/copy/shell/components/directoryModel.js +6 -0
  81. package/dist/client/copy/shell/components/sidebarModel.d.ts +1 -0
  82. package/dist/client/copy/shell/components/sidebarModel.js +1 -0
  83. package/dist/client/copy/workbench/components/Export.d.ts +3 -2
  84. package/dist/client/copy/workbench/components/Export.js +3 -2
  85. package/dist/client/core.d.ts +3 -3
  86. package/dist/client/core.js +6 -7
  87. package/dist/client/export.d.ts +5 -4
  88. package/dist/client/export.js +40 -19
  89. package/dist/client/features.css +67 -7
  90. package/dist/client/index.html +2 -1
  91. package/dist/client/insert.js +1 -8
  92. package/dist/client/locale.d.ts +7 -0
  93. package/dist/client/locale.js +0 -0
  94. package/dist/client/lumenLook.css +9 -12
  95. package/dist/client/page.css +63 -15
  96. package/dist/client/palette.d.ts +3 -1
  97. package/dist/client/palette.js +19 -4
  98. package/dist/client/paletteRecents.d.ts +25 -0
  99. package/dist/client/paletteRecents.js +64 -0
  100. package/dist/client/partsLook.css +6 -3
  101. package/dist/client/sageLook.css +5 -3
  102. package/dist/client/shellMode.d.ts +8 -0
  103. package/dist/client/shellMode.js +1 -0
  104. package/dist/client/structure.css +201 -1
  105. package/dist/client/style.css +59 -10
  106. package/dist/client/themeFamilies.css +37 -0
  107. package/dist/client/visualThemes.css +12 -0
  108. package/dist/client/workbenchLook.css +415 -0
  109. package/dist/client/workshopLook.css +48 -25
  110. package/package.json +4 -3
@@ -6,22 +6,185 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
6
6
  * object as quiet labels beside their values, like records as a table,
7
7
  * words as chips. Two levels open and deeper ones folded behind a count,
8
8
  * long arrays a page at a time — so a document of any size reads top-down
9
- * instead of as one line of braces. Raw is the text itself, pretty-printed,
10
- * for the reader who wants the braces; Copy takes that text.
9
+ * instead of as one line of braces. Raw is the text itself, pretty-printed
10
+ * and tinted, for the reader who wants the braces; Copy takes that text.
11
+ *
12
+ * What a developer's viewer gives, it gives too, without giving up the
13
+ * layout: a filter over keys and values that marks each match and opens
14
+ * whatever holds one; Expand all and Collapse all; each node's value and
15
+ * path (`data.lines[2].sku`) a click or a key away; values tinted by type,
16
+ * quietly, from the tokens (a hex color with its swatch, an id in the code
17
+ * face).
18
+ *
19
+ * The keyboard's tree pattern (APG), as TreeList.tsx has it: the document is
20
+ * one `role="tree"` and one Tab stop, the node last visited. Up and Down move
21
+ * through what is open, Right opens a node or steps into it, Left folds it or
22
+ * steps out to its parent, Home and End go to the ends, Enter and Space fold.
23
+ * Every key, value, row and item is a `treeitem` with its level, its place
24
+ * among its siblings and, when it holds something, `aria-expanded`; its name
25
+ * is said for it (`city: London`), so a folded branch is never read out
26
+ * whole. The tree rather than the description list and table it draws:
27
+ * those name a pair or a cell, but not where it is, whether it opens, or
28
+ * how to get back out — and a reader moving by key needs all three. A table
29
+ * row's name carries its column names, so nothing the header said is lost.
30
+ * The current node's own controls (Copy value, Copy path, a link) are the
31
+ * Tab stops after it; every other node's wait until it is current.
11
32
  *
12
33
  * Read-only on purpose: a document is changed by the statement that owns
13
34
  * it, not by a box pretending a tree is a line of text.
14
35
  */
15
- import { useEffect, useState } from 'react';
36
+ import './JsonView.css';
37
+ import { createContext, useContext, useDeferredValue, useEffect, useLayoutEffect, useMemo, useRef, useState, } from 'react';
16
38
  import { formatLocale } from '../locale.js';
17
39
  import { countLabel, isContainer, ITEM_PAGE, KEY_PAGE, layoutOf, MORE_STEP, OPEN_DEPTH, prettyJson, restOf, scalarOf, sizeOf, } from './jsonModel.js';
40
+ import { childPath, copyTextOf, hasNested, isFound, nodeCount, rawLines, search, shownTextOf, splitOnMatches, textFace, tokenizeLine, } from './jsonTree.js';
18
41
  import { say } from '../copy/record/components/JsonView.js';
19
- export function JsonView({ value, bar = true }) {
20
- const [raw, setRaw] = useState(false);
42
+ /** The filter is offered past this many nodes: a dozen lines are read faster than searched. */
43
+ const FILTER_FROM = 12;
44
+ /** Raw lines tinted token by token; past these a line is drawn plain, so a huge document is a page, not a freeze. */
45
+ const TINTED_LINES = 4000;
46
+ const TreeContext = createContext({});
47
+ const useTree = () => useContext(TreeContext);
48
+ export function JsonView({ value, bar = true, label, head, tail, }) {
21
49
  const locale = formatLocale();
22
- return (_jsxs("div", { className: "json-view", children: [bar && (_jsxs("div", { className: "json-bar", children: [_jsx("button", { type: "button", className: "json-tool", "aria-pressed": raw, onClick: () => setRaw(!raw), children: say('raw') }), _jsx(CopyButton, { value: value })] })), raw ? (_jsx("pre", { className: "json-raw", tabIndex: 0, "aria-label": say('rawJson'), children: prettyJson(value) })) : (_jsx(Node, { value: value, depth: 0, locale: locale }))] }));
50
+ const [mode, setMode] = useState('tree');
51
+ const [wrap, setWrap] = useState(false);
52
+ const [opening, setOpening] = useState('auto');
53
+ const [query, setQuery] = useState('');
54
+ const asked = useDeferredValue(query.trim());
55
+ /* A fold the reader set by hand holds for the filter it was set under; a new
56
+ filter opens what holds its matches afresh. */
57
+ const [folds, setFolds] = useState({ asked: '', map: new Map() });
58
+ const [current, setCurrent] = useState(null);
59
+ const [said, setSaid] = useState('');
60
+ const filterRef = useRef(null);
61
+ const treeRef = useRef(null);
62
+ const filterable = useMemo(() => nodeCount(value, FILTER_FROM + 1) > FILTER_FROM, [value]);
63
+ const nested = useMemo(() => hasNested(value), [value]);
64
+ const found = useMemo(() => (filterable && asked ? search(value, asked, locale) : null), [filterable, value, asked, locale]);
65
+ /* A filter that finds nothing folds nothing: the document stays as it was, and the bar says so. */
66
+ const folding = found?.count ? found : null;
67
+ const own = folds.asked === asked ? folds.map : null;
68
+ useEffect(() => {
69
+ if (!said)
70
+ return;
71
+ const timer = setTimeout(() => setSaid(''), 1600);
72
+ return () => clearTimeout(timer);
73
+ }, [said]);
74
+ /* The tree is one Tab stop. When the node that held it is folded away or
75
+ paged out, the first node takes it, so Tab always lands somewhere. */
76
+ useLayoutEffect(() => {
77
+ const root = treeRef.current;
78
+ if (!root || root.querySelector('[role="treeitem"][tabindex="0"]'))
79
+ return;
80
+ const first = root.querySelector('[role="treeitem"]');
81
+ if (first?.dataset.path !== undefined)
82
+ setCurrent(first.dataset.path);
83
+ });
84
+ const tree = {
85
+ locale,
86
+ found: folding,
87
+ current,
88
+ copies: bar,
89
+ isOpen: (path, depth, holdsMatch) => {
90
+ const set = own?.get(path);
91
+ if (set !== undefined)
92
+ return set;
93
+ if (opening === 'open' || (folding && holdsMatch))
94
+ return true;
95
+ if (folding || opening === 'closed')
96
+ return false;
97
+ return depth < OPEN_DEPTH;
98
+ },
99
+ toggle: (path, open) => setFolds((prev) => ({ asked, map: new Map(prev.asked === asked ? prev.map : []).set(path, open) })),
100
+ copy: async (text, done) => {
101
+ try {
102
+ await navigator.clipboard.writeText(text);
103
+ setSaid(done);
104
+ return true;
105
+ }
106
+ catch {
107
+ /* Clipboard access can be refused — an insecure origin, a permission
108
+ denied; the text is one Raw away. */
109
+ setSaid(say('common.theBrowserRefusedClipboard'));
110
+ return false;
111
+ }
112
+ },
113
+ };
114
+ const openAll = (to) => {
115
+ setOpening(to);
116
+ setFolds({ asked, map: new Map() });
117
+ };
118
+ const onKey = (event) => {
119
+ const target = event.target;
120
+ const item = target.closest('[role="treeitem"]');
121
+ if (!item || item.dataset.path === undefined)
122
+ return;
123
+ const items = [...event.currentTarget.querySelectorAll('[role="treeitem"]')];
124
+ const at = items.indexOf(item);
125
+ const expanded = item.getAttribute('aria-expanded');
126
+ const go = (next) => next?.focus();
127
+ switch (event.key) {
128
+ case 'ArrowDown':
129
+ go(items[at + 1]);
130
+ break;
131
+ case 'ArrowUp':
132
+ go(items[at - 1]);
133
+ break;
134
+ case 'Home':
135
+ go(items[0]);
136
+ break;
137
+ case 'End':
138
+ go(items.at(-1));
139
+ break;
140
+ case 'ArrowRight':
141
+ if (expanded === 'false')
142
+ tree.toggle(item.dataset.path, true);
143
+ else if (items[at + 1] && item.contains(items[at + 1]))
144
+ go(items[at + 1]);
145
+ break;
146
+ case 'ArrowLeft':
147
+ if (expanded === 'true')
148
+ tree.toggle(item.dataset.path, false);
149
+ else
150
+ go(item.parentElement?.closest('[role="treeitem"]'));
151
+ break;
152
+ case 'Enter':
153
+ case ' ':
154
+ /* On a node's own button or link, the key is that control's. */
155
+ if (target !== item || expanded === null)
156
+ return;
157
+ tree.toggle(item.dataset.path, expanded === 'false');
158
+ break;
159
+ default:
160
+ return;
161
+ }
162
+ event.preventDefault();
163
+ };
164
+ const onFocus = (event) => {
165
+ const path = event.target.closest('[role="treeitem"]')?.dataset.path;
166
+ if (path !== undefined && path !== current)
167
+ setCurrent(path);
168
+ };
169
+ /* `/` finds, as it does in a code host's viewer: from anywhere in the document, to its filter. */
170
+ const onViewKey = (event) => {
171
+ if (event.key !== '/' || !filterRef.current || event.target instanceof HTMLInputElement)
172
+ return;
173
+ event.preventDefault();
174
+ filterRef.current.focus();
175
+ };
176
+ const treeMode = mode === 'tree';
177
+ const layout = layoutOf(value);
178
+ return (_jsxs("div", { className: "json-view", onKeyDown: onViewKey, children: [bar && (_jsxs("div", { className: "json-bar", children: [head, treeMode && filterable && (_jsxs("div", { className: "json-filter", children: [_jsx("input", { ref: filterRef, type: "search", className: "json-filter-input", value: query, placeholder: say('filter'), "aria-label": say('filterKeysAndValues'), spellCheck: false, autoComplete: "off", onChange: (event) => setQuery(event.target.value), onKeyDown: (event) => {
179
+ /* Escape clears a filter first; only an empty one lets Escape close the dialog it is in. */
180
+ if (event.key !== 'Escape' || !query)
181
+ return;
182
+ event.preventDefault();
183
+ event.stopPropagation();
184
+ setQuery('');
185
+ } }), _jsx("span", { className: "json-count", "aria-live": "polite", children: found ? (found.count ? say('matches', { count: found.count }) : say('noMatches')) : '' })] })), _jsxs("div", { className: "json-tools", children: [treeMode && nested && (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "json-tool", onClick: () => openAll('open'), children: say('expandAll') }), _jsx("button", { type: "button", className: "json-tool", onClick: () => openAll('closed'), children: say('collapseAll') })] })), !treeMode && (_jsx("button", { type: "button", className: "json-tool", "aria-pressed": wrap, title: say('wrapLines'), onClick: () => setWrap(!wrap), children: say('wrap') })), _jsxs("div", { className: "json-modes", role: "group", "aria-label": say('view'), children: [_jsx("button", { type: "button", className: "json-mode", "aria-pressed": treeMode, onClick: () => setMode('tree'), children: say('tree') }), _jsx("button", { type: "button", className: "json-mode", "aria-pressed": !treeMode, onClick: () => setMode('raw'), children: say('raw') })] }), _jsx(CopyButton, { value: value, copy: tree.copy }), tail] })] })), !treeMode ? (_jsx(RawText, { value: value, wrap: wrap })) : layout.kind === 'empty' ? (_jsx("span", { className: "json-empty", children: layout.text })) : (_jsx("div", { ref: treeRef, role: "tree", "aria-label": label ?? say('document'), className: "json-tree", onKeyDown: onKey, onFocus: onFocus, children: _jsx(TreeContext.Provider, { value: tree, children: _jsx(Node, { value: value, path: "", depth: 0, level: 1 }) }) })), _jsx("span", { className: "visually-hidden", role: "status", children: said })] }));
23
186
  }
24
- function CopyButton({ value }) {
187
+ function CopyButton({ value, copy }) {
25
188
  const [said, setSaid] = useState(null);
26
189
  useEffect(() => {
27
190
  if (!said)
@@ -29,47 +192,36 @@ function CopyButton({ value }) {
29
192
  const timer = setTimeout(() => setSaid(null), 1600);
30
193
  return () => clearTimeout(timer);
31
194
  }, [said]);
32
- const copy = async () => {
33
- try {
34
- await navigator.clipboard.writeText(prettyJson(value));
35
- setSaid('copied');
36
- }
37
- catch {
38
- /* Clipboard access can be refused — an insecure origin, a permission
39
- denied; the text is one Raw away. */
40
- setSaid('refused');
41
- }
42
- };
43
- return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "json-tool", onClick: () => void copy(), children: said === 'copied' ? say('copied') : said === 'refused' ? say('copyRefused') : say('copy') }), _jsx("span", { className: "visually-hidden", role: "status", children: said === 'copied' ? say('copiedTheJson') : said === 'refused' ? say('common.theBrowserRefusedClipboard') : '' })] }));
195
+ return (_jsx("button", { type: "button", className: "json-tool", onClick: () => void copy(prettyJson(value), say('copiedTheJson')).then((ok) => setSaid(ok ? 'copied' : 'refused')), children: said === 'copied' ? say('copied') : said === 'refused' ? say('copyRefused') : say('copy') }));
196
+ }
197
+ /** A value said in a node's name: what is drawn, and a container by its count. */
198
+ function spoken(value, locale) {
199
+ if (isContainer(value))
200
+ return sizeOf(value) ? countLabel(value, locale) : Array.isArray(value) ? '[]' : '{}';
201
+ return value === '' ? say('anEmptyString') : shownTextOf(value, locale);
202
+ }
203
+ /** Whether a container holds a match anywhere inside: it opens while the filter stands. */
204
+ function holds(found, value, base) {
205
+ if (!found)
206
+ return false;
207
+ const indexed = Array.isArray(value);
208
+ return Object.keys(value).some((key) => isFound(found, childPath(base, indexed ? Number(key) : key)));
44
209
  }
45
- function Node({ value, depth, locale }) {
210
+ function Node({ value, path, depth, level }) {
46
211
  const layout = layoutOf(value);
47
212
  switch (layout.kind) {
48
213
  case 'scalar':
49
- return _jsx(Scalar, { value: value, locale: locale });
50
214
  case 'empty':
51
- return _jsx("span", { className: "json-empty", children: layout.text });
215
+ return null;
52
216
  case 'fields':
53
- return _jsx(Fields, { layout: layout, depth: depth, locale: locale });
217
+ return _jsx(Fields, { layout: layout, path: path, depth: depth, level: level });
54
218
  case 'table':
55
- return _jsx(Table, { layout: layout, depth: depth, locale: locale });
219
+ return _jsx(Table, { layout: layout, path: path, depth: depth, level: level });
56
220
  case 'chips':
57
- return _jsx(Items, { items: layout.items, locale: locale, chips: true });
58
221
  case 'lines':
59
- return _jsx(Items, { items: layout.items, locale: locale, chips: false });
222
+ return _jsx(Items, { items: layout.items, chips: layout.kind === 'chips', path: path, level: level });
60
223
  }
61
224
  }
62
- /** A value inside a container: a container with something in it folds behind its count; anything else is drawn as it is. */
63
- function Child({ value, depth, locale, name }) {
64
- if (!isContainer(value) || !sizeOf(value))
65
- return _jsx(Node, { value: value, depth: depth, locale: locale });
66
- return _jsx(Fold, { value: value, depth: depth, locale: locale, name: name });
67
- }
68
- function Fold({ value, depth, locale, name }) {
69
- const [open, setOpen] = useState(depth < OPEN_DEPTH);
70
- const count = countLabel(value, locale);
71
- return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "json-fold", "aria-expanded": open, "aria-label": `${name}: ${count}`, onClick: () => setOpen(!open), children: [_jsx("span", { className: "json-caret", "aria-hidden": "true", children: open ? '▾' : '▸' }), count] }), open && (_jsx("div", { className: "json-group", children: _jsx(Node, { value: value, depth: depth, locale: locale }) }))] }));
72
- }
73
225
  /** The rest of a long list, a step at a time, and never the whole of a huge one at once. */
74
226
  function More({ total, shown, onMore }) {
75
227
  if (shown >= total)
@@ -77,42 +229,155 @@ function More({ total, shown, onMore }) {
77
229
  const next = Math.min(total - shown, MORE_STEP);
78
230
  return (_jsx("button", { type: "button", className: "json-more", title: say('notShown', { total: (total - shown).toLocaleString() }), onClick: () => onMore(shown + next), children: say('showMore', { next: next.toLocaleString() }) }));
79
231
  }
80
- function Fields({ layout, depth, locale }) {
232
+ /** A text with the filter's matches marked; `whole` marks all of it when the match was in the value's JSON, not its words. */
233
+ function Marked({ text, query, whole = false }) {
234
+ const parts = splitOnMatches(text, query);
235
+ if (parts.length === 1)
236
+ return whole ? _jsx("mark", { className: "json-mark", children: text }) : _jsx(_Fragment, { children: text });
237
+ return (_jsx(_Fragment, { children: parts.map((part, i) => i % 2 ? (_jsx("mark", { className: "json-mark", children: part }, i)) : (part)) }));
238
+ }
239
+ /** A folded container's count, in its own braces: `{3 keys}`, `[12 items]`. */
240
+ function Summary({ value, onClick }) {
241
+ const { locale } = useTree();
242
+ const [open, close] = Array.isArray(value) ? ['[', ']'] : ['{', '}'];
243
+ return (_jsxs("span", { className: "json-summary", onClick: onClick, children: [open, countLabel(value, locale), close] }));
244
+ }
245
+ /**
246
+ * A node's two copies: its value (a string as itself, anything else as JSON)
247
+ * and its path. Drawn on hover and when the node is current; the status line
248
+ * says what was taken, as the bar's Copy does.
249
+ */
250
+ function Actions({ value, path, name, active }) {
251
+ const tree = useTree();
252
+ const [done, setDone] = useState(null);
253
+ useEffect(() => {
254
+ if (!done)
255
+ return;
256
+ const timer = setTimeout(() => setDone(null), 1600);
257
+ return () => clearTimeout(timer);
258
+ }, [done]);
259
+ const take = (what) => (event) => {
260
+ event.stopPropagation();
261
+ const text = what === 'value' ? copyTextOf(value) : (path ?? '');
262
+ const said = what === 'value' ? say('copiedValueOf', { path: name }) : say('copiedPath', { path: text });
263
+ void tree.copy(text, said).then((ok) => ok && setDone(what));
264
+ };
265
+ if (!tree.copies)
266
+ return null;
267
+ return (_jsxs("span", { className: "json-actions", children: [_jsx("button", { type: "button", className: "json-act", tabIndex: active ? 0 : -1, "aria-label": say('copyValueOf', { path: name }), onClick: take('value'), children: done === 'value' ? say('copied') : say('copyValue') }), path && (_jsx("button", { type: "button", className: "json-act", tabIndex: active ? 0 : -1, "aria-label": say('copyPathOf', { path }), onClick: take('path'), children: done === 'path' ? say('copied') : say('copyPath') }))] }));
268
+ }
269
+ /** An object's keys, or a mixed array's positions: each a node, its caret in a gutter so every key starts on one line. */
270
+ function Fields({ layout, path, depth, level, }) {
271
+ const { found } = useTree();
81
272
  const [shown, setShown] = useState(layout.indexed ? ITEM_PAGE : KEY_PAGE);
82
- return (_jsxs(_Fragment, { children: [_jsx("dl", { className: "json-fields", children: layout.entries.slice(0, shown).map(([key, item]) => (_jsxs("div", { className: "json-field", children: [_jsx("dt", { className: layout.indexed ? 'json-key json-index' : 'json-key', children: key === '' ? '""' : key }), _jsx("dd", { children: _jsx(Child, { value: item, depth: depth + 1, locale: locale, name: key }) })] }, key))) }), _jsx(More, { total: layout.entries.length, shown: shown, onMore: setShown })] }));
273
+ const total = layout.entries.length;
274
+ return (_jsxs(_Fragment, { children: [_jsx("div", { className: "json-fields", children: layout.entries.map(([key, item], i) => {
275
+ const here = childPath(path, layout.indexed ? i : key);
276
+ /* Past the page, a match is still drawn: the filter's count never names a node nobody can see. */
277
+ if (i >= shown && !isFound(found, here))
278
+ return null;
279
+ return (_jsx(Entry, { name: key, indexed: layout.indexed, value: item, path: here, depth: depth + 1, level: level, place: [i + 1, total] }, key));
280
+ }) }), _jsx(More, { total: total, shown: shown, onMore: setShown })] }));
281
+ }
282
+ function Entry({ name, indexed, value, path, depth, level, place, }) {
283
+ const tree = useTree();
284
+ const folds = isContainer(value) && sizeOf(value) > 0;
285
+ const open = folds && tree.isOpen(path, depth, !!tree.found?.inside.has(path));
286
+ const active = tree.current === path;
287
+ const toggle = folds ? () => tree.toggle(path, !open) : undefined;
288
+ const key = name === '' ? '""' : name;
289
+ return (_jsxs("div", { role: "treeitem", className: "json-entry", "data-path": path, "aria-level": level, "aria-posinset": place[0], "aria-setsize": place[1], "aria-expanded": folds ? open : undefined, "aria-label": `${key}: ${spoken(value, tree.locale)}`, tabIndex: active ? 0 : -1, children: [_jsxs("div", { className: folds ? 'json-row is-fold' : 'json-row', children: [_jsx("span", { className: "json-caret", "aria-hidden": "true", onClick: toggle, children: folds ? (open ? '▾' : '▸') : null }), _jsx("span", { className: indexed ? 'json-key json-index' : 'json-key', onClick: toggle, children: !indexed && tree.found?.keys.has(path) ? _jsx(Marked, { text: key, query: tree.found.query }) : key }), _jsx("span", { className: "json-value", children: folds ? _jsx(Summary, { value: value, onClick: toggle }) : _jsx(Scalar, { value: value, path: path, active: active }) }), _jsx(Actions, { value: value, path: path, name: path, active: active })] }), open && (_jsx("div", { role: "group", className: "json-group", children: _jsx(Node, { value: value, path: path, depth: depth, level: level + 1 }) }))] }));
83
290
  }
84
- function Table({ layout, depth, locale }) {
291
+ /** A container inside a table's cell, or a row's columns past the drawn ones: a node that folds in place. */
292
+ function Fold({ value, id, base, copyPath, depth, level, name, }) {
293
+ const tree = useTree();
294
+ const open = tree.isOpen(id, depth, holds(tree.found, value, base));
295
+ const active = tree.current === id;
296
+ const toggle = () => tree.toggle(id, !open);
297
+ return (_jsxs("div", { role: "treeitem", className: "json-fold", "data-path": id, "aria-level": level, "aria-expanded": open, "aria-label": `${name}: ${countLabel(value, tree.locale)}`, tabIndex: active ? 0 : -1, children: [_jsxs("div", { className: "json-fold-row", children: [_jsx("span", { className: "json-caret", "aria-hidden": "true", onClick: toggle, children: open ? '▾' : '▸' }), _jsx(Summary, { value: value, onClick: toggle }), _jsx(Actions, { value: value, path: copyPath ? id : null, name: name, active: active })] }), open && (_jsx("div", { role: "group", className: "json-group", children: _jsx(Node, { value: value, path: base, depth: depth, level: level + 1 }) }))] }));
298
+ }
299
+ function Table({ layout, path, depth, level }) {
300
+ const { found } = useTree();
85
301
  const [shown, setShown] = useState(ITEM_PAGE);
86
302
  const { columns, folded, rows } = layout;
87
303
  /* A column of figures is read by its place values: right-aligned, head and all. */
88
304
  const figures = new Set(columns.filter((column) => rows.some((row) => typeof row[column] === 'number') && rows.every((row) => row[column] == null || typeof row[column] === 'number')));
89
305
  const align = (column) => (figures.has(column) ? 'json-figures' : undefined);
90
- return (_jsxs(_Fragment, { children: [_jsx("div", { className: "json-table-wrap", children: _jsxs("table", { className: "json-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [columns.map((column) => (_jsx("th", { scope: "col", className: align(column), children: column }, column))), folded.length > 0 && (_jsx("th", { scope: "col", title: folded.join(', '), children: say('moreFolded', { count: folded.length }) }))] }) }), _jsx("tbody", { children: rows.slice(0, shown).map((row, i) => {
91
- const rest = folded.length ? restOf(row, columns) : null;
92
- return (_jsxs("tr", { children: [columns.map((column) => (_jsx("td", { className: align(column), children: Object.hasOwn(row, column) && (_jsx(Child, { value: row[column], depth: depth + 2, locale: locale, name: `${column}, row ${i + 1}` })) }, column))), rest && (_jsx("td", { children: sizeOf(rest) > 0 && _jsx(Fold, { value: rest, depth: OPEN_DEPTH, locale: locale, name: `Row ${i + 1}, the rest` }) }))] }, i));
306
+ /* A key the filter found is a column here: its head is marked once, not each row. */
307
+ const keyFound = (column) => !!found && rows.some((_, i) => found.keys.has(childPath(childPath(path, i), column)));
308
+ return (_jsxs(_Fragment, { children: [_jsx("div", { className: "json-table-wrap", children: _jsxs("table", { className: "json-table", role: "none", children: [_jsx("thead", { "aria-hidden": "true", children: _jsxs("tr", { children: [columns.map((column) => (_jsx("th", { scope: "col", className: align(column), children: found && keyFound(column) ? _jsx(Marked, { text: column, query: found.query }) : column }, column))), folded.length > 0 && _jsx("th", { title: folded.join(', '), children: say('moreFolded', { count: folded.length }) }), _jsx("th", { className: "json-act-cell" })] }) }), _jsx("tbody", { role: "none", children: rows.map((row, i) => {
309
+ const here = childPath(path, i);
310
+ if (i >= shown && !isFound(found, here))
311
+ return null;
312
+ return (_jsx(TableRow, { row: row, index: i, total: rows.length, path: here, columns: columns, folded: folded, depth: depth, level: level, align: align }, i));
93
313
  }) })] }) }), _jsx(More, { total: rows.length, shown: shown, onMore: setShown })] }));
94
314
  }
95
- function Items({ items, locale, chips }) {
315
+ function TableRow({ row, index, total, path, columns, folded, depth, level, align, }) {
316
+ const tree = useTree();
317
+ const active = tree.current === path;
318
+ const rest = folded.length ? restOf(row, columns) : null;
319
+ const said = columns
320
+ .filter((column) => Object.hasOwn(row, column))
321
+ .map((column) => `${column} ${spoken(row[column], tree.locale)}`)
322
+ .join(', ');
323
+ return (_jsxs("tr", { role: "treeitem", className: "json-tr", "data-path": path, "aria-level": level, "aria-posinset": index + 1, "aria-setsize": total, "aria-label": `${say('row', { n: index + 1 })}: ${said}`, tabIndex: active ? 0 : -1, children: [columns.map((column) => (_jsx("td", { role: "none", className: align(column), children: Object.hasOwn(row, column) && (_jsx(Cell, { value: row[column], path: childPath(path, column), depth: depth + 2, level: level + 1, active: active })) }, column))), rest && (_jsx("td", { role: "none", children: sizeOf(rest) > 0 && (_jsx("div", { role: "group", children: _jsx(Fold, { value: rest, id: `${path}#rest`, base: path, copyPath: false, depth: OPEN_DEPTH, level: level + 1, name: say('rowRest', { n: index + 1 }) }) })) })), _jsx("td", { role: "none", className: "json-act-cell", children: _jsx(Actions, { value: row, path: path, name: path, active: active }) })] }));
324
+ }
325
+ function Cell({ value, path, depth, level, active }) {
326
+ if (!isContainer(value) || !sizeOf(value))
327
+ return _jsx(Scalar, { value: value, path: path, active: active });
328
+ return (_jsx("div", { role: "group", children: _jsx(Fold, { value: value, id: path, base: path, copyPath: true, depth: depth, level: level, name: path }) }));
329
+ }
330
+ function Items({ items, chips, path, level }) {
331
+ const tree = useTree();
96
332
  const [shown, setShown] = useState(ITEM_PAGE);
97
- const drawn = items.slice(0, shown).map((item, i) => (_jsx("li", { className: chips ? 'json-chip' : undefined, children: _jsx(Scalar, { value: item, locale: locale }) }, i)));
98
- return (_jsxs(_Fragment, { children: [chips ? (_jsx("ul", { className: "json-chips", children: drawn })) : (_jsx("ol", { className: "json-lines", start: 0, children: drawn })), _jsx(More, { total: items.length, shown: shown, onMore: setShown })] }));
333
+ const drawn = items.map((item, i) => {
334
+ const here = childPath(path, i);
335
+ if (i >= shown && !isFound(tree.found, here))
336
+ return null;
337
+ const active = tree.current === here;
338
+ return (_jsxs("li", { role: "treeitem", className: chips ? 'json-chip' : 'json-item', "data-path": here, "aria-level": level, "aria-posinset": i + 1, "aria-setsize": items.length, "aria-label": `${i}: ${spoken(item, tree.locale)}`, tabIndex: active ? 0 : -1, children: [_jsx(Scalar, { value: item, path: here, active: active }), _jsx(Actions, { value: item, path: here, name: here, active: active })] }, i));
339
+ });
340
+ return (_jsxs(_Fragment, { children: [chips ? (_jsx("ul", { className: "json-chips", role: "none", children: drawn })) : (_jsx("ol", { className: "json-lines", start: 0, role: "none", children: drawn })), _jsx(More, { total: items.length, shown: shown, onMore: setShown })] }));
99
341
  }
100
- function Scalar({ value, locale }) {
342
+ function Scalar({ value, path, active }) {
343
+ const { locale, found } = useTree();
344
+ if (isContainer(value))
345
+ return _jsx("span", { className: "json-empty", children: Array.isArray(value) ? '[]' : '{}' });
101
346
  const said = scalarOf(value, locale);
347
+ const query = found?.values.has(path) ? found.query : '';
348
+ const mark = (text) => (query ? _jsx(Marked, { text: text, query: query, whole: true }) : text);
102
349
  switch (said.kind) {
103
350
  case 'null':
104
- return (_jsx("span", { className: "json-null", title: "null", children: "\u2014" }));
351
+ return _jsx("span", { className: "json-null", children: mark('null') });
105
352
  case 'boolean':
106
- return _jsx("span", { className: `json-bool${said.on ? ' yes' : ''}`, children: said.on ? say('common.yes') : say('common.no') });
353
+ return _jsx("span", { className: "json-bool", children: mark(said.on ? 'true' : 'false') });
107
354
  case 'number':
108
- return (_jsx("span", { className: "json-number", title: said.title, children: said.text }));
355
+ return (_jsx("span", { className: "json-number", title: said.title, children: mark(said.text) }));
109
356
  case 'link':
110
- return (_jsx("a", { className: "json-link", href: said.href, target: "_blank", rel: "noopener noreferrer", children: said.text }));
357
+ return (_jsx("a", { className: "json-link", href: said.href, target: "_blank", rel: "noopener noreferrer", tabIndex: active ? 0 : -1, children: mark(said.text) }));
111
358
  case 'date':
112
- return (_jsx("time", { className: "json-date", dateTime: said.title, title: said.title, children: said.text }));
359
+ return (_jsx("time", { className: "json-date", dateTime: said.title, title: said.title, children: mark(said.text) }));
113
360
  case 'empty':
114
- return (_jsx("span", { className: "json-empty", title: say('anEmptyString'), children: "\"\"" }));
115
- case 'text':
116
- return _jsx("span", { className: said.long ? 'json-text json-long' : 'json-text', children: said.text });
361
+ return (_jsx("span", { className: "json-empty", title: say('anEmptyString'), children: mark('""') }));
362
+ case 'text': {
363
+ if (said.long)
364
+ return _jsx("span", { className: "json-text json-long", children: mark(said.text) });
365
+ const face = textFace(said.text);
366
+ return (_jsxs("span", { className: face.code ? 'json-text json-code' : 'json-text', children: [face.swatch && _jsx("span", { className: "json-swatch", style: { background: face.swatch }, "aria-hidden": "true" }), mark(said.text)] }));
367
+ }
117
368
  }
118
369
  }
370
+ /**
371
+ * The text itself, tinted by hand — keys, strings, numbers, literals, null and
372
+ * punctuation each in its type's ink — with each line's number in a gutter the
373
+ * selection never takes (a pseudo-element's content is not text), and long
374
+ * lines on one line until Wrap. Each line ends in its own line break, so a
375
+ * selection copies as the JSON it shows.
376
+ */
377
+ function RawText({ value, wrap }) {
378
+ const lines = useMemo(() => rawLines(value), [value]);
379
+ const style = { '--json-digits': String(lines.length).length };
380
+ return (_jsx("pre", { className: wrap ? 'json-raw is-wrapped' : 'json-raw', role: "region", tabIndex: 0, "aria-label": say('rawJson'), style: style, children: lines.map((line, i) => (_jsxs("span", { className: "json-line", "data-n": i + 1, children: [i < TINTED_LINES
381
+ ? tokenizeLine(line).map((token, j) => token.kind === 'space' ? (token.text) : (_jsx("span", { className: `json-t-${token.kind}`, children: token.text }, j)))
382
+ : line, i < lines.length - 1 ? '\n' : null] }, i))) }));
383
+ }
@@ -0,0 +1,9 @@
1
+ type ListLayout = 'list' | 'board';
2
+ /** The layout a view is read in, and the way to change it; always the list where the view offers no board. */
3
+ export declare function useListLayout(view: string | undefined, offered: boolean): [ListLayout, (layout: ListLayout) => void];
4
+ export declare function LayoutSwitch({ layout, onChange, label }: {
5
+ layout: ListLayout;
6
+ onChange: (layout: ListLayout) => void;
7
+ label: string;
8
+ }): import("react").JSX.Element;
9
+ export {};
@@ -0,0 +1,61 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * A list read as rows or as a board (listInference.ts inferBoard): a two-icon segmented control at the end of the
4
+ * filter bar, drawn as a phone's Records/Table switch is (PresentationSwitch.tsx) but at every width, the names on
5
+ * the buttons for a screen reader. The reader's choice is kept in their browser per view, as a board's folded lanes are: it is
6
+ * how they like to read the list, not a question about it, so the address does not carry it. The views read as boards
7
+ * are said in a cookie too (boardLanes.ts BOARD_COOKIE), so a page opened on one carries the board's reads, not the
8
+ * list's (firstPaintRooms.ts).
9
+ */
10
+ import { useCallback, useState } from 'react';
11
+ import { BOARD_COOKIE } from '@mistriwork/engine/shared/boardLanes.js';
12
+ import { say } from '../copy/lists/components/LayoutSwitch.js';
13
+ const KEY = 'mistri.listLayout';
14
+ /** The cookie says what the store says: a year, for this site's every path, never sent to another site. */
15
+ function sayBoards(all) {
16
+ const boards = Object.keys(all).filter((view) => all[view] === 'board');
17
+ document.cookie = boards.length
18
+ ? `${BOARD_COOKIE}=${boards.map(encodeURIComponent).join(',')}; path=/; max-age=31536000; SameSite=Lax`
19
+ : `${BOARD_COOKIE}=; path=/; max-age=0; SameSite=Lax`;
20
+ }
21
+ function kept(view) {
22
+ if (!view)
23
+ return 'list';
24
+ try {
25
+ const all = JSON.parse(localStorage.getItem(KEY) ?? '{}');
26
+ // A choice kept before the cookie said it is said now, so the next page carries it.
27
+ if (all[view] === 'board' && !document.cookie.includes(`${BOARD_COOKIE}=`))
28
+ sayBoards(all);
29
+ return all[view] === 'board' ? 'board' : 'list';
30
+ }
31
+ catch {
32
+ return 'list';
33
+ }
34
+ }
35
+ function keep(view, layout) {
36
+ try {
37
+ const all = JSON.parse(localStorage.getItem(KEY) ?? '{}');
38
+ if (layout === 'list')
39
+ delete all[view];
40
+ else
41
+ all[view] = layout;
42
+ localStorage.setItem(KEY, JSON.stringify(all));
43
+ sayBoards(all);
44
+ }
45
+ catch {
46
+ /* A browser that keeps nothing still switches; it forgets on the next visit. */
47
+ }
48
+ }
49
+ /** The layout a view is read in, and the way to change it; always the list where the view offers no board. */
50
+ export function useListLayout(view, offered) {
51
+ const [layout, setLayout] = useState(() => (offered ? kept(view) : 'list'));
52
+ const change = useCallback((next) => {
53
+ setLayout(next);
54
+ if (view)
55
+ keep(view, next);
56
+ }, [view]);
57
+ return [offered ? layout : 'list', change];
58
+ }
59
+ export function LayoutSwitch({ layout, onChange, label }) {
60
+ return (_jsx("div", { className: "list-layout", role: "group", "aria-label": label, children: ['list', 'board'].map((mode) => (_jsx("button", { type: "button", className: "list-layout-seg", "aria-pressed": layout === mode, "aria-label": mode === 'list' ? say('asList') : say('asBoard'), title: mode === 'list' ? say('asList') : say('asBoard'), onClick: () => onChange(mode), children: _jsx("svg", { viewBox: "0 0 16 16", width: "16", height: "16", "aria-hidden": "true", fill: "none", stroke: "currentColor", strokeWidth: "1.4", children: mode === 'list' ? (_jsx("path", { d: "M2 4h12M2 8h12M2 12h12" })) : (_jsxs(_Fragment, { children: [_jsx("rect", { x: "2", y: "2.5", width: "3", height: "11", rx: "0.5" }), _jsx("rect", { x: "6.5", y: "2.5", width: "3", height: "7", rx: "0.5" }), _jsx("rect", { x: "11", y: "2.5", width: "3", height: "9", rx: "0.5" })] })) }) }, mode))) }));
61
+ }
@@ -10,4 +10,7 @@
10
10
  /* In a section the edge is the section's own: no list inset. */
11
11
  .page-section .list-problem > .problem { padding-inline: 0; }
12
12
  .page-section .list-empty.empty-note { padding-inline: 0; }
13
+ /* A dashboard section's list stands on the section's edge too, so its "No leases ending soon" starts under its title
14
+ and not 14px in. */
15
+ .dash-list .list-empty.empty-note { padding-inline: 0; }
13
16
  }
@@ -24,6 +24,9 @@
24
24
  max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
25
25
  font: var(--text-xs)/16px var(--sans); color: var(--ink-muted);
26
26
  }
27
+ /* Under an App's trail that row keeps no height (page.css): the words stand at its end in the room between the
28
+ trail's rule and the name, still out of flow. */
29
+ .page-head.has-trail .live-updated { top: auto; bottom: var(--space-1); transform: none; }
27
30
 
28
31
  /* In a draft's bar beside the fields (a dialog, a board's card), a row of its own across it. */
29
32
  .live-notice {
@@ -24,8 +24,6 @@ export interface NewRecordProps {
24
24
  retainUncertain?: boolean;
25
25
  /** How the App dresses a column (`display`): its vocabulary's words, its currency. */
26
26
  display?: (column: ColumnMeta) => DisplayRule | null | undefined;
27
- /** The App's name, over a New form drawn as a page. */
28
- appName?: string;
29
27
  /** True synchronously before dispatch; false only after a known local phase.
30
28
  * Cleanup never emits settlement. Used by the host's existing exit guard. */
31
29
  onUnresolvedChange?: (unresolved: boolean) => void;