spell-ui 0.8.12 → 0.8.14

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 (68) hide show
  1. package/README-components.md +5 -3
  2. package/dist/{Dragging-B93hbRxF.js → Dragging-tHPSvf3G.js} +56 -13
  3. package/dist/Dragging-tHPSvf3G.js.map +1 -0
  4. package/dist/_spell-element/DOMElement.d.ts +8 -1
  5. package/dist/_spell-element/drawnWindow.d.ts +62 -0
  6. package/dist/_util/Dragging.d.ts +7 -0
  7. package/dist/components/components.types.d.ts +2 -0
  8. package/dist/components/ui-diagram/UIDiagram.d.ts +3 -0
  9. package/dist/components/ui-graph/GraphLayout.d.ts +54 -0
  10. package/dist/components/ui-graph/UIGraph.d.ts +355 -0
  11. package/dist/components/ui-graph/UIGraph.en.d.ts +137 -0
  12. package/dist/components/ui-graph/UIGraph.es.d.ts +48 -0
  13. package/dist/components/ui-graph/UIGraph.types.d.ts +193 -0
  14. package/dist/components/ui-graph/index.d.ts +5 -0
  15. package/dist/components/ui-json/UIJson.d.ts +275 -10
  16. package/dist/components/ui-json/UIJson.en.d.ts +148 -9
  17. package/dist/components/ui-json/UIJson.es.d.ts +34 -3
  18. package/dist/components/ui-json/index.d.ts +2 -2
  19. package/dist/components/ui-split-panel/UISplitPanel.d.ts +2 -16
  20. package/dist/components/ui-tree/UITree.d.ts +758 -26
  21. package/dist/components/ui-tree/UITree.en.d.ts +113 -3
  22. package/dist/components/ui-tree/UITree.es.d.ts +24 -0
  23. package/dist/components/ui-tree/UITree.types.d.ts +34 -0
  24. package/dist/components/ui-tree/UITreeItem.d.ts +40 -1
  25. package/dist/components/ui-tree/UITreeItem.en.d.ts +9 -0
  26. package/dist/components/ui-tree/UITreeItem.es.d.ts +2 -0
  27. package/dist/components/ui-tree/index.d.ts +3 -2
  28. package/dist/components/ui-tree-diagram/UITreeDiagram.d.ts +3 -0
  29. package/dist/{components.es-DEa8Ep42.js → components.es-DilRG1VO.js} +117 -9
  30. package/dist/components.es-DilRG1VO.js.map +1 -0
  31. package/dist/core.js +713 -671
  32. package/dist/core.js.map +1 -1
  33. package/dist/index.d.ts +1 -0
  34. package/dist/index.js +97 -96
  35. package/dist/jsx.d.ts +489 -20
  36. package/dist/ui-diagram.js +2 -2
  37. package/dist/ui-diagram.js.map +1 -1
  38. package/dist/ui-graph.editor-DLsXPyby.js +5 -0
  39. package/dist/ui-graph.editor-DLsXPyby.js.map +1 -0
  40. package/dist/ui-graph.js +1295 -0
  41. package/dist/ui-graph.js.map +1 -0
  42. package/dist/ui-json.editor-BS-v1bqO.js +5 -0
  43. package/dist/ui-json.editor-BS-v1bqO.js.map +1 -0
  44. package/dist/ui-json.js +629 -32
  45. package/dist/ui-json.js.map +1 -1
  46. package/dist/ui-property-editor.js +3 -2
  47. package/dist/ui-property-editor.js.map +1 -1
  48. package/dist/ui-root.js +34 -3
  49. package/dist/ui-root.js.map +1 -1
  50. package/dist/ui-site-nav.js +4 -4
  51. package/dist/ui-site-nav.js.map +1 -1
  52. package/dist/ui-split-panel.js +31 -61
  53. package/dist/ui-split-panel.js.map +1 -1
  54. package/dist/ui-tree-diagram.js +1 -1
  55. package/dist/ui-tree-diagram.js.map +1 -1
  56. package/dist/ui-tree.editor-Bqsa0dYQ.js +5 -0
  57. package/dist/ui-tree.editor-Bqsa0dYQ.js.map +1 -0
  58. package/dist/ui-tree.js +1734 -237
  59. package/dist/ui-tree.js.map +1 -1
  60. package/dist/util/PaneSizes.d.ts +42 -0
  61. package/dist/util/index.d.ts +2 -0
  62. package/package.json +1 -1
  63. package/dist/Dragging-B93hbRxF.js.map +0 -1
  64. package/dist/components.es-DEa8Ep42.js.map +0 -1
  65. package/dist/ui-json.editor-BgZbrB_W.js +0 -5
  66. package/dist/ui-json.editor-BgZbrB_W.js.map +0 -1
  67. package/dist/ui-tree.editor-BoQztwdz.js +0 -5
  68. package/dist/ui-tree.editor-BoQztwdz.js.map +0 -1
@@ -0,0 +1,193 @@
1
+ /**
2
+ * The types and constants of the graph family: the data contract (`GraphData`, `GraphNode`, `GraphEdge` ...),
3
+ * the layout's shapes and its metrics, shared by `GraphLayout` and the component.
4
+ * - Data only: nothing here runs.
5
+ * - GENERIC: any node / edge graph from plain data.
6
+ * A subclass may draw one domain's graphs (a netlist, a pipeline ...); `ui` knows nothing about them.
7
+ */
8
+ /** A graph `<ui-graph>` draws: its nodes, and the edges between them (or their ports). */
9
+ export type GraphData = {
10
+ nodes: GraphNode[];
11
+ edges?: GraphEdge[];
12
+ };
13
+ /** What a node's `children` may be: a graph, or a function giving one (or a promise of one), called on first open. */
14
+ export type GraphChildren = GraphData | (() => GraphData | Promise<GraphData>);
15
+ /** One node of a graph. */
16
+ export type GraphNode = {
17
+ /** Unique among its graph's nodes (not across levels: a node in a child graph is known by its `path`). */
18
+ id: string;
19
+ /** The box's text; none: its `id`. */
20
+ label?: string;
21
+ /** A word for what sort of node it is: its `<g>` is also class and part `kind-<word>`, for a page's own style. */
22
+ kind?: string;
23
+ /** Where edges attach: drawn on the box's sides. */
24
+ ports?: GraphPort[];
25
+ /** A graph inside it, shown when it's opened: in place, in a modal or instead of the graph (`child-view`). */
26
+ children?: GraphChildren;
27
+ /** How THIS node's children open; none: the element's `child-view`. */
28
+ childView?: GraphChildView;
29
+ /** Starts open (`inline` only). */
30
+ open?: boolean;
31
+ /** Hover text (an SVG `<title>`). */
32
+ title?: string;
33
+ /** Anything the page wants to keep with the node: never read by the graph. */
34
+ data?: unknown;
35
+ };
36
+ /** A place on a node's side where edges attach. */
37
+ export type GraphPort = {
38
+ /** Unique among its node's ports. */
39
+ id: string;
40
+ /** Text beside it; none: no text. */
41
+ label?: string;
42
+ /**
43
+ * Which side it's on.
44
+ * - None: `kind` `in` / `input` => `left`, `out` / `output` => `right`; else the side most of its edges come from.
45
+ */
46
+ side?: GraphPortSide;
47
+ /** A word for what sort of port it is: class and part `kind-<word>`. */
48
+ kind?: string;
49
+ };
50
+ /**
51
+ * One end of an edge: a node, and optionally one of its ports.
52
+ * - `node` `""` (or left out) is the ENCLOSING node, the one whose `children` this graph is: `port` names ITS port.
53
+ * Drawn on the container's side when opened in place, and as a pin on the graph's edge in a modal or drill view.
54
+ */
55
+ export type GraphEnd = {
56
+ node?: string;
57
+ port?: string;
58
+ };
59
+ /** One edge, from one end to the other. */
60
+ export type GraphEdge = {
61
+ /** Unique among its graph's edges; none: its index, `#3`. */
62
+ id?: string;
63
+ from: GraphEnd;
64
+ to: GraphEnd;
65
+ /** A word for what sort of edge it is: class and part `kind-<word>`. */
66
+ kind?: string;
67
+ /** Text at the edge's middle. */
68
+ label?: string;
69
+ /** Anything the page wants to keep with it. */
70
+ data?: unknown;
71
+ };
72
+ /** A port's side. Above its type: the layout lists them. */
73
+ export declare const GraphPortSides: readonly ["left", "right", "top", "bottom"];
74
+ export type GraphPortSide = (typeof GraphPortSides)[number];
75
+ /** How a node's children are shown when it opens. Above its type: the vocabulary lists them. */
76
+ export declare const GraphChildViews: readonly ["inline", "modal", "drill"];
77
+ export type GraphChildView = (typeof GraphChildViews)[number];
78
+ /** What's selected: a node, an edge or a port, by `path` (a node's ids from the top, joined by `/`). */
79
+ export type GraphSelection = {
80
+ kind: "node" | "edge" | "port";
81
+ /** The item's own `id` (an edge without one: `#<index>`). */
82
+ id: string;
83
+ /**
84
+ * Where it is: the node's path (`cpu/alu`), the edge's graph path then `#` and its id (`cpu#e3`),
85
+ * a port's node path then `:` and its id (`cpu/alu:a`).
86
+ */
87
+ path: string;
88
+ };
89
+ /** A point in the drawing's user units. */
90
+ export type GraphPoint = {
91
+ readonly x: number;
92
+ readonly y: number;
93
+ };
94
+ /** A port, placed: absolute, on its node's side. */
95
+ export type GraphPlacedPort = GraphPoint & {
96
+ readonly port: GraphPort;
97
+ readonly side: GraphPortSide;
98
+ /** Its node's path, then `:` and its id. */
99
+ readonly path: string;
100
+ };
101
+ /** A node, placed: absolute user units, `x` / `y` its top left corner. */
102
+ export type GraphPlacedNode = {
103
+ readonly node: GraphNode;
104
+ /** Its ids from the top, joined by `/`. */
105
+ readonly path: string;
106
+ /** How deep it is: `0` for the shown graph's own nodes. */
107
+ readonly depth: number;
108
+ readonly x: number;
109
+ readonly y: number;
110
+ readonly width: number;
111
+ readonly height: number;
112
+ readonly ports: readonly GraphPlacedPort[];
113
+ /** It has children (loaded or not). */
114
+ readonly hasChildren: boolean;
115
+ /** It's open in place: a container, its child graph drawn inside it. */
116
+ readonly isOpen: boolean;
117
+ /** Its children are loading. */
118
+ readonly isLoading?: boolean;
119
+ };
120
+ /** An edge, placed: absolute points, from its start to its end, drawn as a smooth path through them. */
121
+ export type GraphPlacedEdge = {
122
+ readonly edge: GraphEdge;
123
+ /** Its id, `#<index>` without one. */
124
+ readonly id: string;
125
+ /** Its graph's path (`""` at the top), then `#`, then its id. */
126
+ readonly path: string;
127
+ /** The paths of what it joins: a node's path, or a port's (`node:port`). */
128
+ readonly fromPath: string;
129
+ readonly toPath: string;
130
+ readonly points: readonly GraphPoint[];
131
+ /** Which side of its start it leaves from, and which side of its end it enters by. */
132
+ readonly fromSide: GraphPortSide;
133
+ readonly toSide: GraphPortSide;
134
+ readonly depth: number;
135
+ };
136
+ /** A boundary pin: an enclosing node's port, drawn on the graph's own edge (modal and drill views). */
137
+ export type GraphPlacedPin = GraphPoint & {
138
+ readonly port: GraphPort;
139
+ readonly side: GraphPortSide;
140
+ readonly path: string;
141
+ };
142
+ /** A graph laid out: what `<ui-graph>` draws, every level flattened, in user units. */
143
+ export type GraphLayoutResult = {
144
+ readonly width: number;
145
+ readonly height: number;
146
+ /** Every node, parents before their children. */
147
+ readonly nodes: readonly GraphPlacedNode[];
148
+ readonly edges: readonly GraphPlacedEdge[];
149
+ /** The enclosing node's ports, at the top level's sides. */
150
+ readonly pins: readonly GraphPlacedPin[];
151
+ };
152
+ /** What `GraphLayout` is told besides the graph. */
153
+ export type GraphLayoutOptions = {
154
+ metrics?: GraphMetrics;
155
+ /** A text's width in user units at `fontSize`; default: estimated from its length. */
156
+ textWidth?: (text: string, fontSize: number) => number;
157
+ /** A node's text; default: its label, else its id. */
158
+ label?: (node: GraphNode) => string;
159
+ /** The child graph of each node open in place, by path. */
160
+ openChildren?: ReadonlyMap<string, GraphData>;
161
+ /** Paths of nodes whose children are loading. */
162
+ loading?: ReadonlySet<string>;
163
+ /** The enclosing node's ports: drawn as pins on the graph's sides. */
164
+ boundary?: readonly GraphPort[];
165
+ /** The shown graph's own path, `""` at the top: what its nodes' paths start with. */
166
+ prefix?: string;
167
+ };
168
+ /** Sizes the layout works in, in user units. */
169
+ export declare const GRAPH_METRICS: {
170
+ readonly fontSize: 12;
171
+ readonly portFontSize: 10;
172
+ /** Estimated advance of one character, per font size. */
173
+ readonly charWidth: 0.6;
174
+ readonly paddingX: 12;
175
+ readonly nodeHeight: 32;
176
+ readonly minNodeWidth: 48;
177
+ /** Space between ports along a side. */
178
+ readonly portSpacing: 18;
179
+ readonly portRadius: 3.5;
180
+ /** Space between layers. */
181
+ readonly layerGap: 56;
182
+ /** Space between nodes in a layer. */
183
+ readonly nodeGap: 18;
184
+ /** A container's header (its label and toggle), and the padding round its child graph. */
185
+ readonly headerHeight: 26;
186
+ readonly containerPadding: 14;
187
+ /** Room for the toggle button, right of a label. */
188
+ readonly toggleWidth: 18;
189
+ readonly margin: 24;
190
+ };
191
+ export type GraphMetrics = {
192
+ readonly [K in keyof typeof GRAPH_METRICS]: number;
193
+ };
@@ -0,0 +1,5 @@
1
+ import { GraphLayout } from './GraphLayout';
2
+ import { DOMGraphElement, UIGraph } from './UIGraph';
3
+ export { DOMGraphElement, GraphLayout, UIGraph };
4
+ export { GRAPH_METRICS, GraphChildViews, GraphPortSides } from './UIGraph.types';
5
+ export type { GraphChildren, GraphChildView, GraphData, GraphEdge, GraphEnd, GraphLayoutOptions, GraphLayoutResult, GraphMetrics, GraphNode, GraphPlacedEdge, GraphPlacedNode, GraphPlacedPin, GraphPlacedPort, GraphPoint, GraphPort, GraphPortSide, GraphSelection } from './UIGraph.types';
@@ -3,7 +3,7 @@ import { E } from 'spell/ui/core';
3
3
  import { jsonVocabulary } from './UIJson.en';
4
4
  /****************
5
5
  * ### `DOMJsonElement`
6
- * The DOM element of `<ui-json>`: the source element's script API, plus `value`.
6
+ * The DOM element of `<ui-json>`: the source element's script API, plus `value`, `item`, `copy()` and `setQuotes()`.
7
7
  ****************/
8
8
  export declare class DOMJsonElement extends E.DOMLoadableElement<UIJson> {
9
9
  /**
@@ -13,24 +13,56 @@ export declare class DOMJsonElement extends E.DOMLoadableElement<UIJson> {
13
13
  get value(): unknown;
14
14
  /** Hold `value` instead, written as JSON into `content`: `dirty` until saved; sends `ui-changed`. */
15
15
  set value(value: unknown);
16
+ /**
17
+ * A thing to show: its `data`, else the thing itself, becomes `value`.
18
+ * - So it draws a tree's pick with no page code: `<ui-tree>` hands its `detail` element the picked row as `item`.
19
+ * - An element without `data` (a `<ui-tree-item>`): nothing to show.
20
+ */
21
+ get item(): unknown;
22
+ set item(item: unknown);
23
+ /** The last `item`: declared, never a field, as a family DOM class has none (`DOMElement`, "Defined early"). */
24
+ private shownItem;
25
+ /**
26
+ * Copy the data to the clipboard, as JSON with 2-space indents; true once it's there.
27
+ * - NEVER throws
28
+ */
29
+ copy(): Promise<boolean>;
30
+ /** Quotes round keys or not: the `quotes` attribute. */
31
+ setQuotes(on: boolean): void;
16
32
  }
17
33
  /****************
18
34
  * ### `<ui-json>`
19
- * The component behind `<ui-json>`: JSON data held in a page, drawing nothing (epic `elemental-spell` P31).
35
+ * The component behind `<ui-json>`: JSON data held in a page, drawn as an indented outline whose objects and arrays
36
+ * open and close (epic `elemental-spell` P31; the outline from epic `from-jarvis` P3).
20
37
  *
21
38
  * - Where it comes from is `LoadableComponent`'s: `source` through `UI.sources`, else its own text.
22
39
  * So `load`, `reload()`, `loaded`, `save()` and `ui-error` are the same as `<ui-code>`'s.
23
40
  * - What it adds: `value`, the parsed data, and `ui-changed` when that changes.
24
41
  * - Text that isn't JSON: `value` is `undefined`, one console warning, `ui-error` (`render`), `:state(error)`.
25
- * As it draws nothing, a failed load warns too: nothing else would show it.
26
- * - An element that takes JSON reads a `<ui-json>` child through `JsonChild`.
42
+ * - An element that takes JSON reads a `<ui-json>` child through `JsonChild`; that element's sheet hides it.
43
+ * `hidden` hides any other.
44
+ *
45
+ * The outline:
46
+ * - Two spaces per level, monospace, coloured by the theme's code tokens (`--ui-code-attr`, `--ui-code-string` ...).
47
+ * - A header (part `header`; `no-header` hides it), of plain icon buttons:
48
+ * Copy, and a toggle for the quotes round keys (`quotes`).
49
+ * - Each object and array has a toggle in the gutter just before its own indent:
50
+ * a real `<button aria-expanded>` (part `toggle`) holding a chevron; Alt-click opens or closes its branch.
51
+ * - Closed, it's one line: `[ 1, 2, 3, ... ]`, `{ "a": 1, ... }`, cut to the characters that fit (`columns`).
52
+ * - `depth` levels start open (`1`: the top alone).
53
+ * - A closed object's members aren't drawn: 387 of them cost one line until it's opened.
54
+ * - A click on a key or value sends `ui-navigating` (`{ path, key, value, part }`; cancelable):
55
+ * the page decides what it means.
56
+ * - `editable`: double-click a key or a value to edit it in a control that fits it (`editorKindFor()`).
57
+ * The data goes through `content`, so it's `dirty` until saved, and `ui-changed` is sent.
27
58
  ****************/
28
59
  export declare class UIJson extends E.LoadableComponent<typeof jsonVocabulary> {
29
60
  static vocabulary: {
30
61
  readonly tag: "ui-json";
31
62
  readonly icon: "code";
32
63
  readonly topics: readonly ["data display", "modules"];
33
- readonly aka: readonly ["data", "data island", "json script", "application/json", "data block", "datos"];
64
+ readonly aka: readonly ["data", "data island", "json script", "application/json", "data block", "json viewer", "json tree", "object inspector", "pretty print", "datos"];
65
+ readonly skeleton: "4 line paragraph";
34
66
  readonly noun: "JSON data";
35
67
  readonly partOfSpeech: "property";
36
68
  readonly description: string;
@@ -44,6 +76,36 @@ export declare class UIJson extends E.LoadableComponent<typeof jsonVocabulary> {
44
76
  readonly values: readonly ["eager", "visible", "idle"];
45
77
  readonly default: "eager";
46
78
  readonly description: string;
79
+ }, {
80
+ readonly name: "depth";
81
+ readonly group: "behaviour";
82
+ readonly kind: "number";
83
+ readonly default: 1;
84
+ readonly description: string;
85
+ }, {
86
+ readonly name: "quotes";
87
+ readonly group: "appearance";
88
+ readonly kind: "boolean";
89
+ readonly default: true;
90
+ readonly description: string;
91
+ }, {
92
+ readonly name: "no-header";
93
+ readonly group: "appearance";
94
+ readonly kind: "boolean";
95
+ readonly default: false;
96
+ readonly description: "Hides the header: the Copy and quotes buttons.";
97
+ }, {
98
+ readonly name: "editable";
99
+ readonly group: "behaviour";
100
+ readonly kind: "boolean";
101
+ readonly default: false;
102
+ readonly description: string;
103
+ }, {
104
+ readonly name: "editors";
105
+ readonly group: "behaviour";
106
+ readonly kind: "json";
107
+ readonly reflect: false;
108
+ readonly description: string;
47
109
  }];
48
110
  readonly events: readonly [{
49
111
  readonly name: "ui-loaded";
@@ -67,9 +129,42 @@ export declare class UIJson extends E.LoadableComponent<typeof jsonVocabulary> {
67
129
  readonly detail: "{ kind: 'load' | 'cross-origin' | 'file-protocol' | 'save' | 'conflict' | 'no-saver' | 'render', source?: string, error: unknown }";
68
130
  readonly cancelable: true;
69
131
  readonly description: string;
132
+ }, {
133
+ readonly name: "ui-navigating";
134
+ readonly cancelable: true;
135
+ readonly detail: "{ path: (string | number)[], key: string | number | undefined, value: unknown, part: \"key\" | \"value\" }";
136
+ readonly description: string;
137
+ }, {
138
+ readonly name: "ui-copied";
139
+ readonly detail: "{ content: string }";
140
+ readonly description: "The Copy button copied `content`, as JSON.";
70
141
  }];
71
142
  readonly slots: readonly [];
72
- readonly parts: readonly [];
143
+ readonly parts: readonly [{
144
+ readonly name: "loader";
145
+ readonly description: "The `<ui-loader>` shown while `source` loads.";
146
+ }, {
147
+ readonly name: "error";
148
+ readonly description: "The `<ui-message>` shown when loading or showing failed.";
149
+ }, {
150
+ readonly name: "viewer";
151
+ readonly description: "The box round it all.";
152
+ }, {
153
+ readonly name: "header";
154
+ readonly description: "The bar above the data: Copy, then the quotes button.";
155
+ }, {
156
+ readonly name: "row";
157
+ readonly description: "Each line.";
158
+ }, {
159
+ readonly name: "toggle";
160
+ readonly description: "Each object's or array's open / close button, a chevron in the left gutter; Alt-click: its whole branch.";
161
+ }, {
162
+ readonly name: "preview";
163
+ readonly description: "A closed object or array, on one line.";
164
+ }, {
165
+ readonly name: "editor";
166
+ readonly description: "The control a key or value is edited in (`editable`).";
167
+ }];
73
168
  readonly states: readonly [{
74
169
  readonly name: "loading";
75
170
  readonly description: "Fetching `source`.";
@@ -83,7 +178,79 @@ export declare class UIJson extends E.LoadableComponent<typeof jsonVocabulary> {
83
178
  readonly name: "dirty";
84
179
  readonly description: "`content` changed since it was loaded or saved.";
85
180
  }];
86
- readonly texts: readonly [];
181
+ readonly texts: readonly [{
182
+ readonly key: "sourceLoading";
183
+ readonly text: "Loading {source}";
184
+ readonly description: "Accessible name of the loader.";
185
+ }, {
186
+ readonly key: "sourceLoadError";
187
+ readonly text: "Couldn't load {source}.";
188
+ readonly description: "The fetch failed.";
189
+ }, {
190
+ readonly key: "sourceCrossOrigin";
191
+ readonly text: "Can't show {source}: only files from this site can be shown.";
192
+ readonly description: "`source` is on another origin.";
193
+ }, {
194
+ readonly key: "sourceFileProtocol";
195
+ readonly text: "Can't load {source}: this page was opened from disk. Open it from a web server to see it.";
196
+ readonly description: "The page is a `file://` page.";
197
+ }, {
198
+ readonly key: "sourceRenderError";
199
+ readonly text: "Couldn't show {source}.";
200
+ readonly description: "The text arrived, but couldn't be shown.";
201
+ }, {
202
+ readonly key: "jsonCopy";
203
+ readonly text: "Copy JSON";
204
+ readonly description: "The header's Copy button.";
205
+ }, {
206
+ readonly key: "jsonCopied";
207
+ readonly text: "Copied";
208
+ readonly description: "The Copy button, for a moment after it copied.";
209
+ }, {
210
+ readonly key: "jsonQuotes";
211
+ readonly text: "Quotes round keys";
212
+ readonly description: "The quotes button's name (a toggle).";
213
+ }, {
214
+ readonly key: "jsonQuotesOff";
215
+ readonly text: "Hide the quotes round keys";
216
+ readonly description: "The quotes button's tooltip, on.";
217
+ }, {
218
+ readonly key: "jsonQuotesOn";
219
+ readonly text: "Show the quotes round keys";
220
+ readonly description: "The quotes button's tooltip, off.";
221
+ }, {
222
+ readonly key: "jsonEditKey";
223
+ readonly text: "Key";
224
+ readonly description: "The field a key is edited in.";
225
+ }, {
226
+ readonly key: "jsonEditValue";
227
+ readonly text: "Value";
228
+ readonly description: "The control a value is edited in.";
229
+ }, {
230
+ readonly key: "jsonOpen";
231
+ readonly text: "Open {key}";
232
+ readonly description: "A closed object's or array's toggle.";
233
+ }, {
234
+ readonly key: "jsonClose";
235
+ readonly text: "Close {key}";
236
+ readonly description: "An open object's or array's toggle.";
237
+ }, {
238
+ readonly key: "jsonAllInside";
239
+ readonly text: "Alt: everything inside";
240
+ readonly description: "Added to a toggle's tooltip.";
241
+ }, {
242
+ readonly key: "jsonTop";
243
+ readonly text: "the data";
244
+ readonly description: "The top value's name, in its toggle's label.";
245
+ }, {
246
+ readonly key: "jsonEmpty";
247
+ readonly text: "No data";
248
+ readonly description: "Nothing to show: no text, or a `source` still loading.";
249
+ }, {
250
+ readonly key: "jsonInvalid";
251
+ readonly text: "This isn't JSON: {message}";
252
+ readonly description: "The error message when its text isn't JSON; `{message}` is the parser's.";
253
+ }];
87
254
  };
88
255
  static elementSetup: {
89
256
  styleSheets: {
@@ -101,16 +268,94 @@ export declare class UIJson extends E.LoadableComponent<typeof jsonVocabulary> {
101
268
  get value(): unknown;
102
269
  /** Did loading fail, or isn't its text JSON? `:state(error)`. */
103
270
  get hasError(): boolean;
271
+ /**
272
+ * As the base's, but text that isn't JSON says why, in the parser's words.
273
+ * - Read from `parsed`, not the base's `loadError`: the first load step clears that after the first parse.
274
+ */
275
+ get errorText(): string | undefined;
104
276
  /** Has `onParsedChanged()` run once? What's there when it first draws is no change. */
105
277
  private hasStarted;
106
- /** The data changed: `ui-changed`, or the error when its text isn't JSON. */
278
+ /** The next new data is an edit made here: what's open stays open. */
279
+ private keepsToggles;
280
+ /** The data changed: `ui-changed`, or the error when its text isn't JSON; new data opens by `depth` again. */
107
281
  protected onParsedChanged({ value, error }: ParsedJson): void;
108
- /** As `LoadableComponent`'s, and warns: it draws nothing, so no message would show it. */
282
+ /** As `LoadableComponent`'s, and warns: a `<ui-json>` is often unseen, a diagram's data or `hidden`. */
109
283
  protected onLoadError(error: unknown, kind?: E.SourceErrorKind): void;
110
284
  /** Not the base's `ui-changed`, which says only the text: `onParsedChanged()` says the data too. */
111
285
  protected sendSourceEvent(name: E.SourceEventName, detail: object): boolean;
112
- render(): JSX.Element;
286
+ /** The open state of the objects and arrays a person toggled, by path; the rest follow `depth`. */
287
+ accessor toggled: ReadonlyMap<string, boolean>;
288
+ /** How many levels start open. */
289
+ get openDepth(): number;
290
+ /** Is the object or array at `path`, `level` deep, open? */
291
+ isOpen(path: string, level: number): boolean;
292
+ /** Open or close the object or array at `path`; `branch`: everything inside it too. */
293
+ toggle(path: string, value: unknown, level: number, branch?: boolean): void;
294
+ /** Copy's job: the JSON to the clipboard, then a check for a moment. */
295
+ readonly clipboard: E.ClipboardCopy;
296
+ /**
297
+ * Copy the data, as JSON with 2-space indents, to the clipboard; `ui-copied`.
298
+ * - Always real JSON, whatever `quotes` says.
299
+ * - NEVER throws
300
+ */
301
+ copy(): Promise<boolean>;
302
+ /** Quotes round keys or not: the `quotes` attribute (`quotes="no"` when off). */
303
+ setQuotes(on: boolean): void;
113
304
  protected renderContent(): JSX.Element;
305
+ /** The outline's box, measured for `columns`. */
306
+ private box;
307
+ /** How many characters fit on a line; `undefined` until measured. */
308
+ accessor columns: number | undefined;
309
+ /** Keep `columns` in step with the element's width: a closed line's preview is cut to it. */
310
+ protected watchWidth(): (() => void) | undefined;
311
+ /**
312
+ * Copy and the quotes toggle: plain icon buttons, as big as an example's code button.
313
+ * - Native `<button>`s, not `<ui-button>`s: no ring at rest, a background only on hover, a fill while pressed.
314
+ * - The quotes toggle draws its glyph as text, `""`: the icon set has no outline quote mark.
315
+ */
316
+ private header;
317
+ /** The whole outline, rebuilt only when the data changes. */
318
+ private tree;
319
+ /** One value: a line; an object or array, its line, then (open) its members and its closing line. */
320
+ private entry;
321
+ /** A closed object or array, on one line: `{ "a": 1, ... }`. */
322
+ private closed;
323
+ /** `"key": `, for an object's member; nothing for an array's or the top's. */
324
+ private keyOf;
325
+ /** A scalar: `"text"`, `12`, `true`, `null`. */
326
+ private scalar;
327
+ /** `shown` as a link: a click sends `ui-navigating`. */
328
+ private link;
329
+ /** The key or value being edited: its path, `EDIT_SEP`, `key` or `value`. */
330
+ accessor editing: string | undefined;
331
+ /**
332
+ * The control `editable` shows for a value: what `editors` names for its key, else what its type picks.
333
+ * - a string: `text`; an ISO date or date and time: `date` / `datetime`
334
+ * - a number: `number`; `true` / `false`: `boolean`; `null`: `json`
335
+ */
336
+ editorKindFor(key: Key, value: unknown): JsonEditorKind;
337
+ /** `editors`, the property, as an object; `{}` without one. */
338
+ private get editorsByKey();
339
+ /** `span`, which an `editable` outline swaps for a control on a double-click. */
340
+ private editableAs;
341
+ /** The control for `edit`: a Spell UI input that fits the value. */
342
+ private editor;
343
+ /**
344
+ * Follow an editor: Enter or leaving it keeps the edit, Escape drops it.
345
+ * - A checkbox or a pick list keeps a change at once
346
+ * (`ui-changed`, which a translated tag sends under its own name: the editors are always `ui-*` tags).
347
+ * - Focuses it once its family has drawn it.
348
+ */
349
+ private watchEditor;
350
+ /** Keep an edit: a key renamed, or a value replaced; `NO_CHANGE` just ends it. */
351
+ private commitEdit;
352
+ /** A click waiting to see if it's the start of a double-click (`editable`). */
353
+ private pendingNavigate;
354
+ /**
355
+ * A key or value was clicked: `ui-navigating`, unless it's part of a double-click, an edit or a selection.
356
+ * - `editable`: it waits a moment, so a double-click's first click sends nothing.
357
+ */
358
+ private navigate;
114
359
  /**
115
360
  * `text` as data: its `value`, or its `error` when it isn't JSON; neither for empty text.
116
361
  * - NEVER throws.
@@ -127,3 +372,23 @@ export type ParsedJson = {
127
372
  /** Why the text isn't JSON: `JSON.parse()`'s `SyntaxError`. */
128
373
  error?: unknown;
129
374
  };
375
+ /** `ui-navigating`'s detail: the member clicked, by its path from the top (`[]`: the top value itself). */
376
+ export type JsonNavigateDetail = {
377
+ /** the keys from the top value down to the member */
378
+ path: Path;
379
+ /** its key (an array member's: its index); the top value's: `undefined` */
380
+ key: Key;
381
+ /** its value, as it is (an object or array too, when its key was clicked) */
382
+ value: unknown;
383
+ /** what was clicked */
384
+ part: JsonPart;
385
+ };
386
+ /** The controls `editable` shows: `editors` names one per key (`UIJson.editorKindFor()`). */
387
+ export declare const JSON_EDITOR_KINDS: readonly ["text", "number", "date", "datetime", "boolean", "json"];
388
+ /** A control `editable` shows: one of `JSON_EDITOR_KINDS`, or a pick list of these choices. */
389
+ export type JsonEditorKind = (typeof JSON_EDITOR_KINDS)[number] | string[];
390
+ /** A key's or value's place in the data. */
391
+ type Key = string | number | undefined;
392
+ type Path = (string | number)[];
393
+ type JsonPart = "key" | "value";
394
+ export {};