spell-ui 0.8.12 → 0.8.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-components.md +5 -3
- package/dist/{Dragging-B93hbRxF.js → Dragging-tHPSvf3G.js} +56 -13
- package/dist/Dragging-tHPSvf3G.js.map +1 -0
- package/dist/_spell-element/DOMElement.d.ts +8 -1
- package/dist/_spell-element/drawnWindow.d.ts +62 -0
- package/dist/_util/Dragging.d.ts +7 -0
- package/dist/components/components.types.d.ts +2 -0
- package/dist/components/ui-diagram/UIDiagram.d.ts +3 -0
- package/dist/components/ui-graph/GraphLayout.d.ts +54 -0
- package/dist/components/ui-graph/UIGraph.d.ts +355 -0
- package/dist/components/ui-graph/UIGraph.en.d.ts +137 -0
- package/dist/components/ui-graph/UIGraph.es.d.ts +48 -0
- package/dist/components/ui-graph/UIGraph.types.d.ts +193 -0
- package/dist/components/ui-graph/index.d.ts +5 -0
- package/dist/components/ui-json/UIJson.d.ts +275 -10
- package/dist/components/ui-json/UIJson.en.d.ts +148 -9
- package/dist/components/ui-json/UIJson.es.d.ts +34 -3
- package/dist/components/ui-json/index.d.ts +2 -2
- package/dist/components/ui-split-panel/UISplitPanel.d.ts +2 -16
- package/dist/components/ui-tree/UITree.d.ts +758 -26
- package/dist/components/ui-tree/UITree.en.d.ts +113 -3
- package/dist/components/ui-tree/UITree.es.d.ts +24 -0
- package/dist/components/ui-tree/UITree.types.d.ts +34 -0
- package/dist/components/ui-tree/UITreeItem.d.ts +40 -1
- package/dist/components/ui-tree/UITreeItem.en.d.ts +9 -0
- package/dist/components/ui-tree/UITreeItem.es.d.ts +2 -0
- package/dist/components/ui-tree/index.d.ts +3 -2
- package/dist/components/ui-tree-diagram/UITreeDiagram.d.ts +3 -0
- package/dist/{components.es-DEa8Ep42.js → components.es-DilRG1VO.js} +117 -9
- package/dist/components.es-DilRG1VO.js.map +1 -0
- package/dist/core.js +713 -671
- package/dist/core.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +97 -96
- package/dist/jsx.d.ts +489 -20
- package/dist/ui-diagram.js +2 -2
- package/dist/ui-diagram.js.map +1 -1
- package/dist/ui-graph.editor-DLsXPyby.js +5 -0
- package/dist/ui-graph.editor-DLsXPyby.js.map +1 -0
- package/dist/ui-graph.js +1295 -0
- package/dist/ui-graph.js.map +1 -0
- package/dist/ui-json.editor-BS-v1bqO.js +5 -0
- package/dist/ui-json.editor-BS-v1bqO.js.map +1 -0
- package/dist/ui-json.js +629 -32
- package/dist/ui-json.js.map +1 -1
- package/dist/ui-property-editor.js +3 -2
- package/dist/ui-property-editor.js.map +1 -1
- package/dist/ui-root.js +34 -3
- package/dist/ui-root.js.map +1 -1
- package/dist/ui-site-nav.js +4 -4
- package/dist/ui-site-nav.js.map +1 -1
- package/dist/ui-split-panel.js +31 -61
- package/dist/ui-split-panel.js.map +1 -1
- package/dist/ui-tree-diagram.js +1 -1
- package/dist/ui-tree-diagram.js.map +1 -1
- package/dist/ui-tree.editor-Bqsa0dYQ.js +5 -0
- package/dist/ui-tree.editor-Bqsa0dYQ.js.map +1 -0
- package/dist/ui-tree.js +1734 -237
- package/dist/ui-tree.js.map +1 -1
- package/dist/util/PaneSizes.d.ts +42 -0
- package/dist/util/index.d.ts +2 -0
- package/package.json +1 -1
- package/dist/Dragging-B93hbRxF.js.map +0 -1
- package/dist/components.es-DEa8Ep42.js.map +0 -1
- package/dist/ui-json.editor-BgZbrB_W.js +0 -5
- package/dist/ui-json.editor-BgZbrB_W.js.map +0 -1
- package/dist/ui-tree.editor-BoQztwdz.js +0 -5
- package/dist/ui-tree.editor-BoQztwdz.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-tree-diagram.js","names":["ref={(box) => this.contentBox = box}","ref={(slot) => this.contentSlot = slot}","this","part={this.partForName(\"content\")}","style={this.placementStyle()}","ref={(slot) => this.nodesSlot = slot}","_tmpl$","_tmpl$2","_elementSetup_dec","_vocabulary_dec","_a","_init","E.UIComponent","E.proto","E.protoMerged","E.state","E.watches","E.onChange","_$getOwner","_$readShallow","_$setAttribute","__name","treeNodeCSS","ref={(svg) => this.svg = svg}","this","<svg\n ref={(svg) => this.svg = svg}\n class={this.rootClass}\n part={this.partForName(\"diagram\")}\n role={this.layout ? this.foldable || this.clickable ? \"group\" : \"img\" : void 0}\n aria-label={this.summary()}\n viewBox={this.viewBox()}\n style={this.sizeStyle()}\n >\n {this.fontSamples()}\n <For each={this.layout?.edges ?? []} keyed={false}>\n {(edge) => this.edge(edge)}\n </For>\n <For each={this.layout?.boxes ?? []} keyed={false}>\n {(box) => this.box(box)}\n </For>\n </svg>","<For each={this.layout?.edges ?? []} keyed={false}>\n {(edge) => this.edge(edge)}\n </For>","keyed={false}","<For each={this.layout?.boxes ?? []} keyed={false}>\n {(box) => this.box(box)}\n </For>","ref={(span) => this.fontSentinel = span}","ref={(slot) => this.nodesSlot = slot}","style={this.canvasStyle()}","class={this.rootClass}","part={this.partForName(\"diagram\")}","role={this.layout ? this.foldable || this.clickable ? \"group\" : \"img\" : void 0}","aria-label={this.summary()}","viewBox={this.viewBox()}","style={this.sizeStyle()}","class={SENTINEL_CLASS}","<div class={CANVAS_CLASS} style={this.canvasStyle()}>\n <svg\n ref={(svg) => this.svg = svg}\n class={this.rootClass}\n part={this.partForName(\"diagram\")}\n role={this.layout ? this.foldable || this.clickable ? \"group\" : \"img\" : void 0}\n aria-label={this.summary()}\n viewBox={this.viewBox()}\n style={this.sizeStyle()}\n >\n {this.fontSamples()}\n <For each={this.layout?.edges ?? []} keyed={false}>\n {(edge) => this.edge(edge)}\n </For>\n <For each={this.layout?.boxes ?? []} keyed={false}>\n {(box) => this.box(box)}\n </For>\n </svg>\n <span ref={(span) => this.fontSentinel = span} class={SENTINEL_CLASS} aria-hidden=\"true\">\n Mg\n </span>\n <slot ref={(slot) => this.nodesSlot = slot} />\n </div>","ref={(text) => this.samples.rootLabel = text}","ref={(text) => this.samples.label = text}","ref={(text) => this.samples.detail = text}","ref={(text) => this.samples.edgeLabel = text}","class={LABEL_CLASS}","font-size={String(fontSize)}","class={NODE_CLASS}","class={DETAIL_CLASS}","font-size={String(detailFontSize)}","class={EDGE_LABEL_CLASS}","font-size={String(edgeLabelFontSize)}","<defs>\n <g class={[NODE_CLASS, ROOT_CLASS]}>\n <text\n ref={(text) => this.samples.rootLabel = text}\n class={LABEL_CLASS}\n font-size={String(fontSize)}\n />\n </g>\n <g class={NODE_CLASS}>\n <text\n ref={(text) => this.samples.label = text}\n class={LABEL_CLASS}\n font-size={String(fontSize)}\n />\n <text\n ref={(text) => this.samples.detail = text}\n class={DETAIL_CLASS}\n font-size={String(detailFontSize)}\n />\n </g>\n <text\n ref={(text) => this.samples.edgeLabel = text}\n class={EDGE_LABEL_CLASS}\n font-size={String(edgeLabelFontSize)}\n />\n </defs>","<Show when={box().node.title}>{(title) => <title>{title()}</title>}</Show>","<g\n class={[\n NODE_CLASS,\n { [ROOT_CLASS]: isRoot(), [CLICKABLE_CLASS]: !!this.clickable },\n kind() && `kind-${kind()}`\n ]}\n part={[this.partForName(\"node\"), isRoot() && this.partForName(\"root-node\"), kind() && `kind-${kind()}`].filter(Boolean).join(\" \")}\n style={_UITreeDiagram.colorStyle(box().node.color)}\n role={this.clickable ? \"button\" : void 0}\n tabindex={this.clickable ? \"0\" : void 0}\n aria-label={this.clickable ? box().node.label : void 0}\n onClick={(event) => this.sendClick(box(), event)}\n onKeyDown={(event) => {\n if (this.clickable && event.target === event.currentTarget)\n this.onButtonKey(event, (original) => this.sendClick(box(), original));\n }}\n >\n <Show when={box().node.title}>{(title) => <title>{title()}</title>}</Show>\n <rect class={BOX_CLASS} x={box().x} y={box().y} width={box().width} height={box().height} />\n <Show when={box().node.label}>\n <text class={LABEL_CLASS} x={box().label.x} y={box().label.y} font-size={String(fontSize)}>\n {box().node.label}\n </text>\n </Show>\n <Show when={box().detail}>\n {(detail) => <text class={DETAIL_CLASS} x={detail().x} y={detail().y} font-size={String(detailFontSize)}>\n {box().node.detail}\n </text>}\n </Show>\n <Show when={this.foldable && box().childCount}>{this.foldButton(box)}</Show>\n </g>","<Show when={box().node.label}>\n <text class={LABEL_CLASS} x={box().label.x} y={box().label.y} font-size={String(fontSize)}>\n {box().node.label}\n </text>\n </Show>","x={box().label.x}","y={box().label.y}","<text class={LABEL_CLASS} x={box().label.x} y={box().label.y} font-size={String(fontSize)}>\n {box().node.label}\n </text>","<Show when={box().detail}>\n {(detail) => <text class={DETAIL_CLASS} x={detail().x} y={detail().y} font-size={String(detailFontSize)}>\n {box().node.detail}\n </text>}\n </Show>","x={detail().x}","y={detail().y}","<Show when={this.foldable && box().childCount}>{this.foldButton(box)}</Show>","this.foldable && box().childCount","part={[this.partForName(\"node\"), isRoot() && this.partForName(\"root-node\"), kind() && `kind-${kind()}`].filter(Boolean).join(\" \")}","style={_UITreeDiagram.colorStyle(box().node.color)}","role={this.clickable ? \"button\" : void 0}","tabindex={this.clickable ? \"0\" : void 0}","aria-label={this.clickable ? box().node.label : void 0}","class={BOX_CLASS}","x={box().x}","y={box().y}","width={box().width}","height={box().height}","part={this.partForName(\"toggle\")}","aria-expanded={box().isFolded ? \"false\" : \"true\"}","aria-label={label()}","transform={`translate(${box().exit.x} ${box().exit.y})`}","class={TOGGLE_TARGET_CLASS}","class={TOGGLE_CIRCLE_CLASS}","class={TOGGLE_MARK_CLASS}","d={box().isFolded ? PLUS_MARK : MINUS_MARK}","<g\n class={TOGGLE_CLASS}\n part={this.partForName(\"toggle\")}\n role=\"button\"\n tabindex=\"0\"\n aria-expanded={box().isFolded ? \"false\" : \"true\"}\n aria-label={label()}\n transform={`translate(${box().exit.x} ${box().exit.y})`}\n onClick={(event) => {\n event.stopPropagation();\n this.toggle(box(), event);\n }}\n onKeyDown={(event) => this.onButtonKey(event, (original) => this.toggle(box(), original))}\n >\n <title>{label()}</title>\n <circle class={TOGGLE_TARGET_CLASS} r={TOGGLE_TARGET_RADIUS} />\n <circle class={TOGGLE_CIRCLE_CLASS} r={TOGGLE_RADIUS} />\n <path class={TOGGLE_MARK_CLASS} d={box().isFolded ? PLUS_MARK : MINUS_MARK} />\n </g>","part={this.partForName(\"edge\")}","d={_UITreeDiagram.path(edge())}","<Show when={edge().label}>\n {(label) => <text\n class={EDGE_LABEL_CLASS}\n part={this.partForName(\"edge-label\")}\n x={label().x}\n y={label().y}\n font-size={String(TREE_DIAGRAM_METRICS.edgeLabelFontSize)}\n >\n {label().text}\n </text>}\n </Show>","part={this.partForName(\"edge-label\")}","x={label().x}","y={label().y}","font-size={String(TREE_DIAGRAM_METRICS.edgeLabelFontSize)}","E.UIComponent","E.proto","E.protoMerged","E.watches","E.state","E.on","E.derived","E.whileConnected","E.untracked","E.onChange","_$getOwner","_$readShallow","_$setAttribute","__name","treeDiagramCSS","TreeMeasure","Key","__decoratorStart","__publicField","__name$1","__decorateElement","__decoratorMetadata","__runInitializers","__privateAdd","JSON_CHANGED","getOwner$1","TreeData","value","seen","raw","node","detail","edgeLabel","title","color","kind","children","child","count","tree","text","TreeDiagramDirections","TREE_DIAGRAM_METRICS","TreeLayout","options","root","ROOT_PATH","levelLengths","gaps","levelGap","levelStarts","margin","depth","centres","low","high","centre","middle","shift","boxes","edges","cross","start","parent","from","last","crossTotal","mainTotal","size","labelWidth","charWidth","fontSize","detailWidth","detailFontSize","contentWidth","contentHeight","width","minBoxWidth","paddingX","labelLine","lineHeight","detailLine","height","paddingY","edgeLabelWidth","edgeLabelCharWidth","edgeLabelFontSize","edgeLabelPaddingX","edgeLabelHeight","edgeLabelPaddingY","edgeLabelCross","crossLength","isFolded","path","index","LABEL_LEAD","half","contours","offsets","needed","blocker","neededByPrevious","earlier","distance","merged","contour","at","shared","before","after","between","first","room","main","length","x","y","textTop","round","childCount","point","to","dx","dy","reach","label","gap","visit","treeDiagramVocabulary","treeNodeVocabulary","UITreeNode_default","_tmpl$$1","_tmpl$2$1","_watchContentSize_dec","_onChildrenChanged_dec","_children_dec","_placement_dec","_elementSetup_dec$1","_vocabulary_dec$1","_a$1","_init$1","_placement","TREE_NODE_RESIZED","_UITreeNode","UIComponent","proto","protoMerged","state","watches","onChange","box","isReady","isConnected","observer","_self$","_el$","_el$2","ref","slot","effect","readShallow","PLACED","className","_p$","t","setAttribute","style","a","_el$3","placement","ELEMENT_NODE","name","UI","domElement","found","element","held","TEXT_NODE","UITreeNode","UITreeDiagram_default","_tmpl$","_tmpl$2","_tmpl$3","_tmpl$4","_tmpl$5","_tmpl$6","_tmpl$7","_sendClick_dec","_onContentClick_dec","_onLayoutChanged_dec","_layout_dec","_toggle_dec","_foldedNodes_dec","_foldChanges_dec","_sizes_dec","_watchFontsAndSize_dec","_onNodeResized_dec","_drawnScale_dec","_measureVersion_dec","_drawnTree_dec","_nodesTree_dec","_nodesText_dec","_childTree_dec","_onChildDataChanged_dec","_childDataVersion_dec","_childText_dec","_elementSetup_dec","_vocabulary_dec","_a","_init","_childDataVersion","_measureVersion","_drawnScale","_foldChanges","_UITreeDiagram","on","derived","whileConnected","untracked","isServer","JsonChild","key","error","remeasure","sentinelWidth","svg","layout","rootLabel","perPixel","folded","foldChanges","drawnTree","FOLDABLE_METRICS","shown","place","component","content","event","target","each","act","EMPTY","_el$4","_el$5","_el$6","_el$7","insert","createComponent","For","edge","span","CANVAS_CLASS","SENTINEL_CLASS","o","i","n","s","h","r","_self$2","_el$8","_el$9","_el$10","_el$11","_el$12","_el$13","_el$14","NODE_CLASS","ROOT_CLASS","LABEL_CLASS","DETAIL_CLASS","EDGE_LABEL_CLASS","d","isRoot","_self$3","_el$15","_el$16","_el$18","_el$19","_el$20","original","Show","_el$21","_el$17","_el$22","memo","CLICKABLE_CLASS","BOX_CLASS","l","_self$4","_el$23","_el$24","_el$25","_el$26","_el$27","TOGGLE_TARGET_RADIUS","TOGGLE_RADIUS","TOGGLE_CLASS","TOGGLE_TARGET_CLASS","TOGGLE_CIRCLE_CLASS","TOGGLE_MARK_CLASS","PLUS_MARK","MINUS_MARK","_self$5","_el$28","EDGE_CLASS","_el$29","NATURAL_WIDTH","DRAWN_SCALE","params","word","hue","background","border","UITreeDiagram","delegateEvents"],"sources":["../src/components/ui-tree-diagram/TreeData.ts","../src/components/ui-tree-diagram/UITreeDiagram.types.ts","../src/components/ui-tree-diagram/TreeLayout.ts","../src/components/ui-tree-diagram/UITreeDiagram.en.ts","../src/components/ui-tree-diagram/UITreeNode.en.ts","../src/components/ui-tree-diagram/UITreeNode.tsx","../src/components/ui-tree-diagram/UITreeDiagram.tsx","../src/components/ui-tree-diagram/index.ts"],"sourcesContent":["import type { TreeDiagramNode } from \"./UITreeDiagram.types\"\n\n/****************\n * ### `TreeData`\n * Where a `<ui-tree-diagram>`'s tree comes from, made safe to lay out:\n * the `tree` property, or the JSON in a `<ui-json>` or `<script type=\"application/json\">` child (`JsonChild`).\n * - STATIC, plain DOM, no Solid: the component reads the tree through it, and names the diagram with `summary()`;\n * tests drive it directly.\n * - Lenient: data from a page is checked, not trusted.\n * - Anything that isn't an object is no node.\n * - A missing `label` is `\"\"`; a `detail` / `edgeLabel` / `title` / `color` / `kind` that isn't a string is dropped.\n * - `slot` is `edgeLabel`'s old name: spell's parse trees still write it (`P.TreeWriter`).\n * - `children` keeps only nodes.\n ****************/\nexport class TreeData {\n /**\n * `value` as a tree to draw, or `undefined` when it isn't one.\n * - Always a NEW tree: the caller's objects are never handed on, nor changed.\n * - A node met twice on the way down (a cycle, or one object shared by two parents) is drawn once:\n * where it's met first.\n * - NEVER throws.\n */\n static node(value: unknown, seen = new Set<object>()): TreeDiagramNode | undefined {\n if (typeof value !== \"object\" || value === null || Array.isArray(value) || seen.has(value)) return undefined\n seen.add(value)\n const raw = value as Record<string, unknown>\n const node: TreeDiagramNode = { label: TreeData.text(raw.label) ?? \"\" }\n const detail = TreeData.text(raw.detail)\n const edgeLabel = TreeData.text(raw.edgeLabel) ?? TreeData.text(raw.slot)\n const title = TreeData.text(raw.title)\n const color = TreeData.text(raw.color)\n const kind = TreeData.text(raw.kind)\n if (detail) node.detail = detail\n if (edgeLabel) node.edgeLabel = edgeLabel\n if (title) node.title = title\n if (color) node.color = color\n if (kind) node.kind = kind\n if (raw.folded === true) node.folded = true\n if (Array.isArray(raw.children)) {\n const children = raw.children.flatMap((child) => TreeData.node(child, seen) ?? [])\n if (children.length) node.children = children\n }\n return node\n }\n\n /**\n * Name of a diagram of `tree`, through `text` (the component's translated texts):\n * \"Tree: If, with 3 children\".\n */\n static summary(\n tree: TreeDiagramNode,\n text: (key: TreeDiagramSummaryKey, params: Record<string, string | number>) => string\n ): string {\n const count = tree.children?.length ?? 0\n const key = count === 0 ? \"summaryLeaf\" : count === 1 ? \"summaryOne\" : \"summary\"\n return text(key, { label: tree.label, count })\n }\n\n /** `value` as text: a string as is, a number or boolean written out, anything else `undefined`. */\n private static text(value: unknown): string | undefined {\n if (typeof value === \"string\") return value\n if (typeof value === \"number\" || typeof value === \"boolean\") return String(value)\n return undefined\n }\n}\n\n/** Keys of the texts that name a diagram: its root has children, one child, none. */\nexport type TreeDiagramSummaryKey = \"summary\" | \"summaryOne\" | \"summaryLeaf\"\n","/**\n * The types and constants of the tree diagram family: the data contract (`TreeDiagramNode`),\n * the layout's shapes and its metrics, shared by `TreeLayout`, `TreeData` and the component.\n * - Data only: nothing here runs.\n * - GENERIC: any tree from plain data. Spell's parse trees are one caller (docs pages, the app's editor, VS Code);\n * `ui` never imports spell or the parser.\n */\n\n////////////////\n// ## The data contract\n////////////////\n\n/** One node of a tree `<ui-tree-diagram>` draws. */\nexport type TreeDiagramNode = {\n /** The box's text, e.g. `If`, `Variable number`, `Number 15`. */\n label: string\n /** A second, smaller, muted line under the label, e.g. a datatype `number`; none: one line. */\n detail?: string\n /** Text on the line from its parent, e.g. `condition`, `body`, `otherwise`. JSON may say `slot`, its old name. */\n edgeLabel?: string\n /** Hover text (an SVG `<title>`), e.g. the source it came from. */\n title?: string\n /** Its box's colour, a hue of the theme's: `green`, `blue` ... */\n color?: string\n /** A word for what sort of node it is: its box is also part `kind-<word>`, for a page's own style. */\n kind?: string\n /** Starts folded: the nodes under it don't show. */\n folded?: boolean\n /** The `<ui-tree-node>` that wrote it; none for a tree from JSON. */\n element?: Element\n /** Its children, left to right. */\n children?: TreeDiagramNode[]\n}\n\n////////////////\n// ## Layout\n////////////////\n\n/** A point in the diagram's user units (its `viewBox`). */\nexport type TreeDiagramPoint = {\n readonly x: number\n readonly y: number\n}\n\n/** One node's box, placed: user units, `x` / `y` its TOP LEFT corner. */\nexport type TreeDiagramBox = {\n /** The node it draws. */\n readonly node: TreeDiagramNode\n /** Its depth: `0` for the root. */\n readonly depth: number\n /** Where it is in the tree: its child index at each depth, `0.2.1`; `0` for the root. */\n readonly path: string\n readonly x: number\n readonly y: number\n readonly width: number\n /** Every box in a level is as long along the tree as its longest, so edges leave a level at one place. */\n readonly height: number\n /** Where its lines leave it, and its fold button sits. */\n readonly exit: TreeDiagramPoint\n /** Where the label's line is centred (`dominant-baseline: central`). */\n readonly label: TreeDiagramPoint\n /** Where the detail's line is centred; none without a `detail`. */\n readonly detail?: TreeDiagramPoint\n /** What the node holds besides its text, centred at `x`, `y`; none when nothing. */\n readonly content?: TreeDiagramPoint & { readonly width: number; readonly height: number }\n /** How many children its node has, folded or not; none for a leaf. */\n readonly childCount?: number\n /** It's folded: the nodes under it aren't drawn. */\n readonly isFolded?: boolean\n}\n\n/** An edge label, placed: centred on its edge's midpoint, `width` x `height` the box the edge leaves clear. */\nexport type TreeDiagramEdgeLabel = {\n readonly text: string\n /** Centre. */\n readonly x: number\n readonly y: number\n readonly width: number\n readonly height: number\n}\n\n/** One parent => child line, from where it leaves the parent to where it reaches the child. */\nexport type TreeDiagramEdge = {\n readonly from: TreeDiagramPoint\n readonly to: TreeDiagramPoint\n /** The child's `edgeLabel`, at the line's midpoint. */\n readonly label?: TreeDiagramEdgeLabel\n /**\n * The stretch of the line NOT drawn, under the edge label: the line stops at `gap.from`, starts again at `gap.to`.\n */\n readonly gap?: { readonly from: TreeDiagramPoint; readonly to: TreeDiagramPoint }\n}\n\n/** A tree laid out: what `<ui-tree-diagram>` draws, in user units. */\nexport type TreeDiagramLayout = {\n /** Natural size: the `viewBox`. */\n readonly width: number\n readonly height: number\n /** Every node's box, depth first (the root first). */\n readonly boxes: readonly TreeDiagramBox[]\n /** Every parent => child line, in the same order as the children's boxes: `edges[i]` leads to `boxes[i + 1]`. */\n readonly edges: readonly TreeDiagramEdge[]\n}\n\n/** Which way a tree grows. Above the options: the vocabulary lists them. */\nexport const TreeDiagramDirections = [\"top-down\", \"left-right\"] as const\n\n/** One of `TreeDiagramDirections`. */\nexport type TreeDiagramDirection = (typeof TreeDiagramDirections)[number]\n\n/** A node's sizes, in user units, as measured (`TreeMeasure`): what's left out, `TreeLayout` estimates. */\nexport type TreeDiagramNodeSize = {\n readonly labelWidth?: number\n readonly detailWidth?: number\n readonly edgeLabelWidth?: number\n /** What it holds besides its text. */\n readonly contentWidth?: number\n readonly contentHeight?: number\n}\n\n/** What `TreeLayout` is told besides the tree. */\nexport type TreeDiagramLayoutOptions = {\n /** Sizes it works in. Default: `TREE_DIAGRAM_METRICS`. */\n metrics?: TreeDiagramMetrics\n /** Which way it grows. Default: `top-down`. */\n direction?: TreeDiagramDirection\n /** Each node's measured sizes, by the node. Default: all estimated. */\n sizes?: ReadonlyMap<TreeDiagramNode, TreeDiagramNodeSize>\n /** The nodes drawn as leaves. Default: none. */\n folded?: ReadonlySet<TreeDiagramNode>\n}\n\n/**\n * Sizes the layout works in, in USER UNITS (the `viewBox`'s): the label font is `fontSize` units,\n * and the sheet sets the `<svg>`'s width to `width / fontSize` em, so one label `em` on the page is `fontSize` units\n * here.\n * - Text widths are measured in a browser (`TreeMeasure`). `charWidth` and `edgeLabelCharWidth` are only for a static\n * server render, with nothing to measure with: over-estimates, so labels never overflow or collide.\n */\nexport const TREE_DIAGRAM_METRICS = {\n /** The label's font size; 1em on the page. */\n fontSize: 12,\n /** The detail line's font size. */\n detailFontSize: 10,\n /** The edge label's font size. */\n edgeLabelFontSize: 10,\n /** Estimated advance of one label character, per font size: a monospace font's, wider than a proportional one's. */\n charWidth: 0.6,\n /** Estimated advance of one edge label character, per font size. */\n edgeLabelCharWidth: 0.56,\n /** Line height, per font size. */\n lineHeight: 1.25,\n /** Space left and right of a box's text. */\n paddingX: 10,\n /** Space above and below a box's text. */\n paddingY: 6,\n /** The narrowest box. */\n minBoxWidth: 32,\n /** Space between one row's boxes and the next row's. */\n levelGap: 36,\n /** Least space between two boxes (or edge labels) side by side. */\n siblingGap: 14,\n /** Space kept clear left and right of an edge label's text. */\n edgeLabelPaddingX: 4,\n /** Space kept clear above and below an edge label's text. */\n edgeLabelPaddingY: 2,\n /** Space around the whole drawing: room for the root's thicker border. */\n margin: 2\n} as const\n\n/** Sizes `TreeLayout` works in: `TREE_DIAGRAM_METRICS`, or a test's own. */\nexport type TreeDiagramMetrics = { readonly [K in keyof typeof TREE_DIAGRAM_METRICS]: number }\n","import {\n TREE_DIAGRAM_METRICS,\n type TreeDiagramBox,\n type TreeDiagramDirection,\n type TreeDiagramEdge,\n type TreeDiagramEdgeLabel,\n type TreeDiagramLayout,\n type TreeDiagramLayoutOptions,\n type TreeDiagramMetrics,\n type TreeDiagramNode,\n type TreeDiagramNodeSize,\n type TreeDiagramPoint\n} from \"./UITreeDiagram.types\"\n\n/****************\n * ### `TreeLayout`\n * A tree laid out as `<ui-tree-diagram>` draws it, top-down or left to right: `TreeLayout.of(tree, options)`.\n * - PURE: numbers in, numbers out, no DOM, no Solid; so the maths is tested alone, and the same tree always gets\n * the same layout.\n * - Two axes, so one algorithm does both directions:\n * - the MAIN axis runs from parent to child: down, or to the right\n * - the CROSS axis runs between siblings: across, or down\n * - Levels: each depth is a level; every box in a level is as long on the main axis as its longest, so edges leave a\n * level at one place and every edge label between two levels sits at one place.\n * - Tidy: a parent is centred over its first and last child; sibling subtrees are pushed apart, depth by depth,\n * until no two boxes of the same level are closer than `siblingGap` (contours, after Reingold-Tilford).\n * - Small subtrees between two big ones spread evenly, rather than packing against the left one:\n * Reingold-Tilford's \"apportion\" step, as Buchheim and Walker tell it (`spreadBetween()`).\n * - Edge labels sit at their edge's midpoint, and the edge stops under them (`gap`).\n * A node's FOOTPRINT, what its level keeps clear, is its box or twice its edge label, whichever is wider:\n * so no edge label ever overlaps another, nor another edge (sibling's or cousin's), and no line runs under text.\n * - Sizes: each node's real ones, measured by whoever has a DOM and handed in (`options.sizes`, `TreeMeasure`).\n * What's not handed in is estimated from character counts (`TreeDiagramMetrics`): a static server render's case.\n * - A folded node is drawn as a leaf (`options.folded`).\n ****************/\nexport class TreeLayout {\n /** Sizes it works in. */\n readonly metrics: TreeDiagramMetrics\n /** Which way it grows. */\n readonly direction: TreeDiagramDirection\n /** The measured sizes: none, all estimated. */\n readonly sizes: ReadonlyMap<TreeDiagramNode, TreeDiagramNodeSize> | undefined\n /** The nodes drawn as leaves. */\n readonly folded: ReadonlySet<TreeDiagramNode> | undefined\n\n constructor(options: TreeDiagramLayoutOptions = {}) {\n this.metrics = options.metrics ?? TREE_DIAGRAM_METRICS\n this.direction = options.direction ?? \"top-down\"\n this.sizes = options.sizes\n this.folded = options.folded\n }\n\n /** `tree` laid out, in user units (`TREE_DIAGRAM_METRICS`, unless `options.metrics` says otherwise). NEVER throws. */\n static of(tree: TreeDiagramNode, options?: TreeDiagramLayoutOptions): TreeDiagramLayout {\n return new TreeLayout(options).layout(tree)\n }\n\n /** `tree` laid out. */\n layout(tree: TreeDiagramNode): TreeDiagramLayout {\n const { margin, levelGap } = this.metrics\n const root = this.measure(tree, 0, ROOT_PATH)\n const levelLengths: number[] = []\n // room each level leaves before it, for an edge label laid along the main axis\n const gaps: number[] = []\n TreeLayout.visit(root, (node) => {\n levelLengths[node.depth] = Math.max(levelLengths[node.depth] ?? 0, node.mainLength)\n gaps[node.depth] = Math.max(gaps[node.depth] ?? levelGap, this.gapFor(node))\n })\n const levelStarts = [margin]\n for (let depth = 1; depth < levelLengths.length; depth++)\n levelStarts[depth] = levelStarts[depth - 1]! + levelLengths[depth - 1]! + gaps[depth]!\n this.place(root)\n // centres, from the root at 0, then shifted so the first thing drawn starts at the margin\n const centres = new Map<Measured, number>([[root, 0]])\n TreeLayout.visit(root, (node) => {\n for (const child of node.children) centres.set(child, centres.get(node)! + child.offset)\n })\n let low = Infinity\n let high = -Infinity\n TreeLayout.visit(root, (node) => {\n const centre = centres.get(node)!\n low = Math.min(low, centre - node.crossLength / 2)\n high = Math.max(high, centre + node.crossLength / 2)\n for (const child of node.children) {\n if (!child.edgeLabel) continue\n const middle = (centre + centres.get(child)!) / 2\n low = Math.min(low, middle - child.edgeLabelCross / 2)\n high = Math.max(high, middle + child.edgeLabelCross / 2)\n }\n })\n const shift = margin - low\n const boxes: TreeDiagramBox[] = []\n const edges: TreeDiagramEdge[] = []\n TreeLayout.visit(root, (node, parent) => {\n const cross = centres.get(node)! + shift\n const start = levelStarts[node.depth]!\n boxes.push(this.box(node, cross, start, levelLengths[node.depth]!))\n if (!parent) return\n const from = this.point(levelStarts[parent.depth]! + levelLengths[parent.depth]!, centres.get(parent)! + shift)\n edges.push(this.edge(node, from, this.point(start, cross)))\n })\n const last = levelLengths.length - 1\n const crossTotal = TreeLayout.round(high - low + 2 * margin)\n const mainTotal = TreeLayout.round(levelStarts[last]! + levelLengths[last]! + margin)\n return {\n width: this.isTopDown ? crossTotal : mainTotal,\n height: this.isTopDown ? mainTotal : crossTotal,\n boxes,\n edges\n }\n }\n\n ////////////////\n // ## Measuring\n ////////////////\n\n /** Does it grow downward? Else to the right. */\n private get isTopDown(): boolean {\n return this.direction === \"top-down\"\n }\n\n /** `node` and its subtree, sized: box, edge label, footprint. */\n private measure(node: TreeDiagramNode, depth: number, path: string): Measured {\n const { fontSize, detailFontSize, edgeLabelFontSize, charWidth, edgeLabelCharWidth, lineHeight } = this.metrics\n const { paddingX, paddingY, minBoxWidth, edgeLabelPaddingX, edgeLabelPaddingY } = this.metrics\n const size = this.sizes?.get(node)\n const labelWidth = size?.labelWidth ?? TreeLayout.chars(node.label) * charWidth * fontSize\n const detailWidth = node.detail\n ? (size?.detailWidth ?? TreeLayout.chars(node.detail) * charWidth * detailFontSize)\n : 0\n const contentWidth = size?.contentWidth ?? 0\n const contentHeight = size?.contentHeight ?? 0\n const width = Math.max(minBoxWidth, Math.max(labelWidth, detailWidth, contentWidth) + 2 * paddingX)\n const labelLine = node.label || !contentHeight ? fontSize * lineHeight : 0\n const detailLine = node.detail ? detailFontSize * lineHeight : 0\n const height = 2 * paddingY + labelLine + detailLine + contentHeight\n const edgeLabel = node.edgeLabel || undefined\n const edgeLabelWidth = edgeLabel\n ? (size?.edgeLabelWidth ?? TreeLayout.chars(edgeLabel) * edgeLabelCharWidth * edgeLabelFontSize) +\n 2 * edgeLabelPaddingX\n : 0\n const edgeLabelHeight = edgeLabel ? edgeLabelFontSize * lineHeight + 2 * edgeLabelPaddingY : 0\n const edgeLabelCross = this.isTopDown ? edgeLabelWidth : edgeLabelHeight\n const crossLength = this.isTopDown ? width : height\n const isFolded = !!this.folded?.has(node)\n return {\n node,\n depth,\n path,\n width,\n height,\n labelLine,\n detailLine,\n contentWidth,\n contentHeight,\n crossLength,\n mainLength: this.isTopDown ? height : width,\n edgeLabel,\n edgeLabelWidth,\n edgeLabelHeight,\n edgeLabelCross,\n footprint: Math.max(crossLength, 2 * edgeLabelCross),\n isFolded,\n children: isFolded\n ? []\n : (node.children ?? []).map((child, index) => this.measure(child, depth + 1, `${path}.${index}`)),\n offset: 0\n }\n }\n\n /**\n * The room `node`'s level leaves before it: `levelGap`, or across a left-to-right tree its edge label's width.\n * - A top-down tree's label is short across the gap, and `levelGap` is always room enough.\n */\n private gapFor(node: Measured): number {\n return this.isTopDown ? this.metrics.levelGap : node.edgeLabelWidth + LABEL_LEAD\n }\n\n /**\n * Characters in `text`, for an estimate: code points, so an emoji or accented letter counts once.\n * - NOTE: wide (CJK) characters count one.\n */\n private static chars(text: string): number {\n return Array.from(text).length\n }\n\n ////////////////\n // ## Placing\n ////////////////\n\n /**\n * Place `node`'s children (each child's `offset` from `node`'s centre), and return `node`'s subtree's contour:\n * per depth below it (`0` = its own level), the nearest and farthest edge of any footprint, from its centre.\n * - Children are placed in order, each as close to the ones before it as their contours allow;\n * the ones it had to jump over spread evenly in the room that opens (`spreadBetween()`);\n * then `node` is centred over its first and last child.\n */\n private place(node: Measured): Contour {\n const half = node.footprint / 2\n if (!node.children.length) return { low: [-half], high: [half] }\n const contours = node.children.map((child) => this.place(child))\n const offsets = [0]\n for (let index = 1; index < contours.length; index++) {\n let needed = -Infinity\n let blocker = index - 1\n let neededByPrevious = -Infinity\n for (let earlier = index - 1; earlier >= 0; earlier--) {\n const distance = offsets[earlier]! + this.clearance(contours[earlier]!, contours[index]!)\n if (earlier === index - 1) neededByPrevious = distance\n if (distance > needed) {\n needed = distance\n blocker = earlier\n }\n }\n offsets[index] = needed\n TreeLayout.spreadBetween(offsets, blocker, index, needed - neededByPrevious)\n }\n const centre = (offsets[0]! + offsets[offsets.length - 1]!) / 2\n for (const [index, child] of node.children.entries()) child.offset = offsets[index]! - centre\n const merged: Contour = { low: [], high: [] }\n for (const [index, contour] of contours.entries()) {\n const at = offsets[index]! - centre\n for (let depth = 0; depth < contour.low.length; depth++) {\n merged.low[depth] = Math.min(merged.low[depth] ?? Infinity, contour.low[depth]! + at)\n merged.high[depth] = Math.max(merged.high[depth] ?? -Infinity, contour.high[depth]! + at)\n }\n }\n return { low: [-half, ...merged.low], high: [half, ...merged.high] }\n }\n\n /** How far past `before`'s centre `after`'s must be, for the two never to come closer than `siblingGap`. */\n private clearance(before: Contour, after: Contour): number {\n let distance = -Infinity\n const shared = Math.min(before.high.length, after.low.length)\n for (let depth = 0; depth < shared; depth++)\n distance = Math.max(distance, before.high[depth]! - after.low[depth]! + this.metrics.siblingGap)\n return distance\n }\n\n /**\n * The apportion step: subtree `last` was pushed `room` further than the one before it needed, because it hit\n * subtree `first`; the small ones between share that room evenly.\n * - Each moves right by its share of `room`, so each only gets further from the ones before it,\n * and none reaches `last`: the one before it had `room` to spare, and moves less than that.\n */\n private static spreadBetween(offsets: number[], first: number, last: number, room: number) {\n const between = last - first\n if (between < 2 || room <= 0) return\n for (let index = first + 1; index < last; index++) offsets[index]! += (room * (index - first)) / between\n }\n\n ////////////////\n // ## Output\n ////////////////\n\n /** The point `main` along the main axis, `cross` along the cross axis. */\n private point(main: number, cross: number): TreeDiagramPoint {\n return this.isTopDown ? { x: cross, y: main } : { x: main, y: cross }\n }\n\n /**\n * `node`'s box, centred on `cross`, in the level from `start`, `length` long on the main axis:\n * its label, detail and content stacked, and centred in it.\n */\n private box(node: Measured, cross: number, start: number, length: number): TreeDiagramBox {\n const { labelLine, detailLine, contentHeight, contentWidth } = node\n const width = this.isTopDown ? node.width : length\n const height = this.isTopDown ? length : node.height\n const x = this.isTopDown ? cross - width / 2 : start\n const y = this.isTopDown ? start : cross - height / 2\n const middle = x + width / 2\n const textTop = y + (height - labelLine - detailLine - contentHeight) / 2\n const round = TreeLayout.round\n const { point: at } = TreeLayout\n const childCount = node.node.children?.length ?? 0\n return {\n node: node.node,\n depth: node.depth,\n path: node.path,\n x: round(x),\n y: round(y),\n width: round(width),\n height: round(height),\n exit: at(this.isTopDown ? { x: middle, y: y + height } : { x: x + width, y: y + height / 2 }),\n label: at({ x: middle, y: textTop + labelLine / 2 }),\n ...(node.node.detail && { detail: at({ x: middle, y: textTop + labelLine + detailLine / 2 }) }),\n ...(contentHeight > 0 && {\n content: {\n ...at({ x: middle, y: textTop + labelLine + detailLine + contentHeight / 2 }),\n width: round(contentWidth),\n height: round(contentHeight)\n }\n }),\n ...(childCount > 0 && { childCount }),\n ...(node.isFolded && childCount > 0 && { isFolded: true })\n }\n }\n\n /**\n * The line from `from` (the parent's exit) to `to` (`child`'s entrance), with `child`'s edge label at\n * its midpoint and the stretch under the label left out.\n */\n private edge(child: Measured, from: TreeDiagramPoint, to: TreeDiagramPoint): TreeDiagramEdge {\n const { point } = TreeLayout\n if (!child.edgeLabel) return { from: point(from), to: point(to) }\n const dx = to.x - from.x\n const dy = to.y - from.y\n const middle = { x: from.x + dx / 2, y: from.y + dy / 2 }\n const width = child.edgeLabelWidth\n const height = child.edgeLabelHeight\n // the line meets the label's box at its side or its top / bottom, whichever comes first\n const reach = Math.min(dx ? width / 2 / Math.abs(dx) : Infinity, dy ? height / 2 / Math.abs(dy) : Infinity, 0.5)\n const label: TreeDiagramEdgeLabel = {\n text: child.edgeLabel,\n ...point(middle),\n width: TreeLayout.round(width),\n height: TreeLayout.round(height)\n }\n const gap = {\n from: point({ x: middle.x - reach * dx, y: middle.y - reach * dy }),\n to: point({ x: middle.x + reach * dx, y: middle.y + reach * dy })\n }\n return { from: point(from), to: point(to), label, gap }\n }\n\n /** `value` to 2 decimals: short, stable markup. */\n private static round(value: number): number {\n return Math.round(value * 100) / 100\n }\n\n /** `point`, rounded. */\n private static point(point: TreeDiagramPoint): TreeDiagramPoint {\n return { x: TreeLayout.round(point.x), y: TreeLayout.round(point.y) }\n }\n\n /** Call `visit` on `node`, then on each node below it, depth first; with each one's parent. */\n private static visit(node: Measured, visit: (node: Measured, parent?: Measured) => void, parent?: Measured) {\n visit(node, parent)\n for (const child of node.children) TreeLayout.visit(child, visit, node)\n }\n}\n\n/** The root's `path`; a child's adds its index, `0.2.1`. */\nconst ROOT_PATH = \"0\"\n\n/** Least room left and right of an edge label across a left-to-right tree's gap, together. */\nconst LABEL_LEAD = 24\n\n/** A node, sized, while it's laid out. */\ntype Measured = {\n readonly node: TreeDiagramNode\n readonly depth: number\n readonly path: string\n /** The box's own width. */\n readonly width: number\n /** The box's own height. */\n readonly height: number\n /** Height of its label's line; `0` for a node that's content alone. */\n readonly labelLine: number\n /** Height of its detail's line; `0` without one. */\n readonly detailLine: number\n readonly contentWidth: number\n readonly contentHeight: number\n /** The box along the cross axis. */\n readonly crossLength: number\n /** The box along the main axis: drawn as long as its level. */\n readonly mainLength: number\n /** Its edge label's text, when it has one. */\n readonly edgeLabel: string | undefined\n /** Its edge label's box, padding included; `0` without one. */\n readonly edgeLabelWidth: number\n readonly edgeLabelHeight: number\n /** Its edge label's box along the cross axis. */\n readonly edgeLabelCross: number\n /** What its level keeps clear: the box, or twice the edge label, whichever is longer. */\n readonly footprint: number\n /** Drawn as a leaf, though it may have children. */\n readonly isFolded: boolean\n readonly children: Measured[]\n /** Its centre, from its parent's; set by `place()`. */\n offset: number\n}\n\n/**\n * A subtree's outline: per depth below its root, its nearest and farthest footprint edge, from the root's centre.\n */\ntype Contour = {\n low: number[]\n high: number[]\n}\n","/**\n * The English vocabulary of `<ui-tree-diagram>`: every name the tag uses.\n * - Its tag, attributes (each with its kind and allowed values), parts and texts.\n * The shape is `ComponentVocabulary` (`spell/ui/vocabulary`).\n * - Ours, not Fomantic's: first drawn for spell's parse trees, but GENERIC.\n * - One rich property, `tree` (a `TreeDiagramNode`, `UITreeDiagram.types.ts`);\n * a static page gives it as a `<ui-json>` or `<script type=\"application/json\">` child instead.\n * - No class words: the class grammar is `ui tree diagram`, plus `empty` with nothing to draw.\n */\n\nimport type { ComponentVocabulary } from \"spell/ui/vocabulary\"\nimport { TreeDiagramDirections } from \"./UITreeDiagram.types\"\n\n/****************\n * ### `treeDiagramVocabulary`\n * The names of `<ui-tree-diagram>`, a tree drawn as an SVG:\n * `<svg class=\"ui tree diagram\" part=\"diagram\" role=\"img\" aria-label>`.\n ****************/\nexport const treeDiagramVocabulary = {\n tag: \"ui-tree-diagram\",\n icon: \"project diagram\",\n topics: [\"data display\", \"images\", \"views\"],\n aka: [\n \"tree\",\n \"tree chart\",\n \"hierarchy\",\n \"hierarchy diagram\",\n \"org chart\",\n \"parse tree\",\n \"syntax tree\",\n \"AST\",\n \"dendrogram\"\n ],\n skeleton: \"12 tall\",\n noun: \"tree diagram\",\n partOfSpeech: \"structure\",\n description:\n \"A tree diagram draws a tree: a box for each node, a line to each of its children. Write it as nested tags or as JSON.\",\n attributes: [\n {\n name: \"tree\",\n group: \"content\",\n kind: \"json\",\n reflect: false,\n description:\n \"The tree to draw, a `TreeDiagramNode`: `label`, and optional `detail`, `edgeLabel`, `title`, `color`, `kind`, `folded` and `children`. A \" +\n 'JS property (JSON in the attribute); wins over `<ui-tree-node>`, `<ui-json>` or `<script type=\"application/json\">` children. Set a NEW ' +\n \"tree to redraw.\"\n },\n {\n name: \"direction\",\n group: \"layout\",\n kind: \"enum\",\n values: TreeDiagramDirections,\n default: \"top-down\",\n description: \"Which way it grows: `top-down`, children under their parent, or `left-right`, children after it.\"\n },\n {\n name: \"foldable\",\n group: \"behaviour\",\n kind: \"boolean\",\n description:\n \"A node with children gets a button that folds them away, and opens them again; `ui-node-toggled` says so.\"\n },\n {\n name: \"clickable\",\n group: \"behaviour\",\n kind: \"boolean\",\n description:\n \"Its nodes look clickable and can be reached by keyboard: Enter or Space sends `ui-node-clicked`, as a click does.\"\n }\n ],\n events: [\n {\n name: \"ui-node-clicked\",\n detail: \"{ node: { label: string, element?: Element }, path: string, originalEvent: Event }\",\n description:\n \"A node was clicked, with or without `clickable`. `path` is its place, its child index at each depth: `0.2.1`. \" +\n \"A nested tag's node has its `element`.\"\n },\n {\n name: \"ui-node-toggled\",\n detail: \"{ node: { label: string, element?: Element }, path: string, folded: boolean, originalEvent: Event }\",\n description: \"A person folded a node, or opened it again.\"\n }\n ],\n slots: [{ name: \"\", description: \"The tree's root, a `<ui-tree-node>`, with the nodes under it inside it.\" }],\n parts: [\n { name: \"diagram\", description: \"The `<svg>`.\" },\n { name: \"node\", description: \"Each node's `<g>`: its box, label and detail.\" },\n { name: \"root-node\", description: \"The root's `<g>`, also part `node`.\" },\n { name: \"edge\", description: \"Each line from a parent to a child.\" },\n { name: \"edge-label\", description: \"Each edge label, on its line.\" },\n { name: \"toggle\", description: \"Each fold button, with `foldable`.\" }\n ],\n states: [],\n texts: [\n {\n key: \"summary\",\n text: \"Tree: {label}, with {count} children\",\n description: \"Name of a tree whose root has children.\"\n },\n {\n key: \"summaryOne\",\n text: \"Tree: {label}, with 1 child\",\n description: \"Name of a tree whose root has one child.\"\n },\n { key: \"summaryLeaf\", text: \"Tree: {label}\", description: \"Name of a tree of one node.\" },\n { key: \"foldNode\", text: \"Fold {label}\", description: \"A fold button's name, while the node's open.\" },\n { key: \"unfoldNode\", text: \"Open {label}\", description: \"A fold button's name, while the node's folded.\" }\n ]\n} as const satisfies ComponentVocabulary\n","/**\n * The English vocabulary of `<ui-tree-node>`: every name the tag uses.\n * - Its tag, attributes (each with its kind and allowed values) and parts.\n * The shape is `E.ComponentVocabulary` (`spell/ui/vocabulary`).\n * - Ours, not Fomantic's (epic `elemental-spell` P32).\n * - No class words: the class grammar is `ui tree node`, on the box around its content.\n */\n\nimport type { E } from \"spell/ui/core\"\n\n/****************\n * ### `treeNodeVocabulary`\n * The names of `<ui-tree-node>`, one node of a `<ui-tree-diagram>`, holding the nodes under it as its children.\n ****************/\nexport const treeNodeVocabulary = {\n tag: \"ui-tree-node\",\n icon: \"circle outline\",\n topics: [\"data display\", \"images\"],\n aka: [\"diagram node\", \"tree diagram node\", \"org chart box\", \"node\"],\n noun: \"tree node\",\n partOfSpeech: \"structure\",\n description:\n \"A tree node is one box of a tree diagram: its label, and the nodes under it as its children. Its text is its \" +\n \"label; any other element inside it shows in its box.\",\n attributes: [\n { name: \"label\", group: \"content\", kind: \"string\", description: \"The box's text. None: the node's own text.\" },\n {\n name: \"detail\",\n group: \"content\",\n kind: \"string\",\n description: \"A second, smaller, muted line under the label, e.g. a datatype.\"\n },\n {\n name: \"edge-label\",\n group: \"content\",\n kind: \"string\",\n property: \"edgeLabel\",\n description: \"Text on the line from its parent, e.g. `condition`: which part of its parent it is.\"\n },\n {\n name: \"hover-text\",\n group: \"content\",\n kind: \"string\",\n property: \"hoverText\",\n description: \"What shows when the pointer rests on its box, e.g. the source it came from.\"\n },\n {\n name: \"color\",\n group: \"appearance\",\n kind: \"enum\",\n values: \"hues\",\n description: \"The box's colour: its fill and border, in that hue.\"\n },\n {\n name: \"kind\",\n group: \"appearance\",\n kind: \"string\",\n description:\n \"A word for what sort of node it is, for a page's own style: its box is also part `kind-<word>`, so \" +\n \"`::part(kind-call)` reaches every node of that kind.\"\n },\n {\n name: \"folded\",\n group: \"behaviour\",\n kind: \"boolean\",\n description: \"Starts folded: the nodes under it don't show. A `foldable` diagram can open it again.\"\n }\n ],\n events: [],\n slots: [{ name: \"\", description: \"What shows in its box, besides its label; and the `<ui-tree-node>`s under it.\" }],\n parts: [{ name: \"content\", description: \"The box around what it holds, placed over the node's box in the drawing.\" }],\n states: [],\n texts: []\n} as const satisfies E.ComponentVocabulary\n","import type { JSX } from \"@solidjs/web\"\n\nimport { E, UI } from \"spell/ui/core\"\nimport { treeNodeVocabulary } from \"./UITreeNode.en\"\nimport type { TreeDiagramNode } from \"./UITreeDiagram.types\"\n\nimport treeNodeCSS from \"./UITreeNode.css?inline\"\n\n/**\n * What a `<ui-tree-node>` tells its diagram when what it holds changes size: plumbing, like the platform's `slotchange`.\n * - Bubbles to the diagram, which measures again.\n */\nexport const TREE_NODE_RESIZED = \"ui-tree-node-resized\"\n\n/** A `<ui-tree-node>` DOM element, typed. */\nexport type DOMTreeNodeElement = E.DOMElement<UITreeNode>\n\n/****************\n * ### `<ui-tree-node>`\n * The component behind `<ui-tree-node>`: one node of a `<ui-tree-diagram>` written as nested tags (epic\n * `elemental-spell` P32).\n *\n * <div class=\"ui tree node\" part=\"content\"><slot/></div> (what it holds, over its box in the drawing)\n * <slot/> (the nodes under it)\n *\n * - It draws no box: the diagram reads it into plain data (`nodeFrom()`), and draws it with the rest of the tree.\n * - Its own text is its label, unless `label` says.\n * - Any other element inside it shows over its box: a real element, in the page, so it keeps its state and events.\n * - The diagram measures it (`contentSize`), leaves room in the box, and says where it goes (`placement`).\n * - Slots by hand (`slotAssignment` `\"manual\"`, the platform's): the same children, split into two slots.\n ****************/\nexport class UITreeNode extends E.UIComponent<typeof treeNodeVocabulary> {\n @E.proto static vocabulary = treeNodeVocabulary\n @E.protoMerged static elementSetup = {\n styleSheets: { \"tree-node\": treeNodeCSS },\n delegatesFocus: false,\n slotAssignment: \"manual\" as const\n } satisfies Partial<E.ElementSetup>\n\n /** Where the diagram put what it holds, in percent of the drawing; `undefined`: not shown (it's folded away). */\n @E.state accessor placement: TreeNodePlacement | undefined = undefined\n\n /** The children it was given: nodes and everything else. */\n @E.watches({ childList: true })\n get children(): readonly ChildNode[] {\n return [...this.domElement.childNodes]\n }\n\n /** The nodes under it. */\n get nodeChildren(): Element[] {\n return this.children.filter((child): child is Element => UITreeNode.isNode(child))\n }\n\n /** What shows in its box, besides its label: nothing when it's only text, which is its label. */\n get contentChildren(): ChildNode[] {\n return UITreeNode.contentOf(this.domElement)\n }\n\n /** The box around what it holds. */\n private contentBox: HTMLElement | undefined\n private contentSlot: HTMLSlotElement | undefined\n private nodesSlot: HTMLSlotElement | undefined\n\n /** What it holds in pixels, before the drawing's scale; `undefined` when it holds nothing, or it isn't laid out. */\n get contentSize(): { width: number; height: number } | undefined {\n const box = this.contentBox\n if (!box || !this.contentChildren.length || !box.offsetWidth) return undefined\n return { width: box.offsetWidth, height: box.offsetHeight }\n }\n\n /** Hand each child to its slot; what it holds may have changed size. */\n @E.onChange(\"children\", \"isReady\")\n protected onChildrenChanged(_children: readonly ChildNode[], isReady: boolean) {\n if (!isReady) return\n this.contentSlot?.assign(...(this.contentChildren as (Element | Text)[]))\n this.nodesSlot?.assign(...this.nodeChildren)\n this.domElement.dispatchEvent(new Event(TREE_NODE_RESIZED, { bubbles: true }))\n }\n\n /** While it's in the page: says when what it holds changes size (an image loads, a closed section opens). */\n @E.onChange(\"isConnected\", \"isReady\")\n protected watchContentSize(isConnected: boolean, isReady: boolean) {\n const box = this.contentBox\n if (!isConnected || !isReady || !box) return\n const observer = new ResizeObserver(() => {\n this.domElement.dispatchEvent(new Event(TREE_NODE_RESIZED, { bubbles: true }))\n })\n observer.observe(box)\n return () => observer.disconnect()\n }\n\n render(): JSX.Element {\n return (\n <>\n <div\n ref={(box: HTMLDivElement) => (this.contentBox = box)}\n class={[this.rootClass, { [PLACED]: !!this.placement }]}\n part={this.partForName(\"content\")}\n style={this.placementStyle()}\n >\n <slot ref={(slot: HTMLSlotElement) => (this.contentSlot = slot)} />\n </div>\n <slot ref={(slot: HTMLSlotElement) => (this.nodesSlot = slot)} />\n </>\n )\n }\n\n /** Where `placement` says. */\n private placementStyle(): JSX.CSSProperties | undefined {\n const placement = this.placement\n return placement && { left: `${placement.left}%`, top: `${placement.top}%` }\n }\n\n ////////////////\n // ## Reading nodes\n ////////////////\n\n /**\n * Is `child` a `<ui-tree-node>`, in any language?\n * - Before the runtime loads, the canonical tag only: the translations are its.\n * - By `localName`: a static server render's children are linkedom elements.\n */\n static isNode(child: Node): child is Element {\n if (child.nodeType !== ELEMENT_NODE) return false\n const name = (child as Element).localName\n return (\n name === treeNodeVocabulary.tag ||\n (\"vocabulary\" in UI && UI.vocabulary.canonicalTagFor(name) === treeNodeVocabulary.tag)\n )\n }\n\n /** The first `<ui-tree-node>` child of `domElement`: a diagram's root. */\n static firstNodeOf(domElement: Element): Element | undefined {\n return [...domElement.children].find((child) => UITreeNode.isNode(child))\n }\n\n /**\n * `element` and the nodes under it as plain data, what a diagram draws; each node keeps its `element`.\n * - NEVER throws.\n */\n static nodeFrom(element: Element): TreeDiagramNode {\n const value = (name: string) => {\n const found = UITreeNode.value(element, name)\n return typeof found === \"string\" && found ? found : undefined\n }\n const children = [...element.children].filter((child) => UITreeNode.isNode(child)).map(UITreeNode.nodeFrom)\n const color = value(\"color\")\n const kind = value(\"kind\")\n const detail = value(\"detail\")\n const edgeLabel = value(\"edge-label\")\n const title = value(\"hover-text\")\n return {\n label: value(\"label\") ?? UITreeNode.textOf(element),\n element,\n ...(detail && { detail }),\n ...(edgeLabel && { edgeLabel }),\n ...(title && { title }),\n ...(color && { color }),\n ...(kind && { kind }),\n ...(UITreeNode.isFolded(element) && { folded: true }),\n ...(children.length && { children })\n }\n }\n\n /** What `element` holds besides its nodes, when an element's among it: else nothing, its text being its label. */\n static contentOf(element: Element): ChildNode[] {\n const held = [...element.childNodes].filter(\n (child) =>\n !UITreeNode.isNode(child) &&\n (child.nodeType === ELEMENT_NODE || (child.nodeType === TEXT_NODE && !!child.textContent?.trim()))\n )\n return held.some((child) => child.nodeType === ELEMENT_NODE) ? held : []\n }\n\n /** `element`'s own text: its text children, not the nodes under it; `\"\"` when it holds an element too. */\n private static textOf(element: Element): string {\n if (UITreeNode.contentOf(element).length) return \"\"\n let text = \"\"\n for (const child of element.childNodes) if (child.nodeType === TEXT_NODE) text += child.textContent\n return text.trim().replace(/\\s+/g, \" \")\n }\n\n /** Is `element` written `folded`? */\n private static isFolded(element: Element): boolean {\n const value = UITreeNode.value(element, \"folded\")\n return value === true || value === \"\" || value === \"true\"\n }\n\n /**\n * Attribute `name` of `element`, by its canonical name; before its family loads, the attribute's text.\n * - NEVER throws: a pending element has no definition yet (`valueNamed()` throws then).\n */\n private static value(element: Element, name: string): string | boolean | undefined {\n try {\n const value = (element as Element & { valueNamed?: (name: string) => unknown }).valueNamed?.(name)\n if (value !== undefined) return value as string | boolean\n } catch {\n // pending: its text, below\n }\n return element.getAttribute(name) ?? undefined\n }\n}\n\n/** The vocabulary's attribute getters, typed (see \"Attributes\" in `UIComponent`). */\nexport interface UITreeNode extends E.AttributeValues<typeof treeNodeVocabulary> {}\n\n/** Where what a node holds goes, its centre, in percent of the drawing. */\nexport type TreeNodePlacement = {\n readonly left: number\n readonly top: number\n}\n\n/** Class word of a content box the diagram has placed. */\nconst PLACED = \"placed\"\n\n/** `Node.ELEMENT_NODE` and `Node.TEXT_NODE`: no DOM global in shared code (`AGENTS.md`, SSR). */\nconst ELEMENT_NODE = 1\nconst TEXT_NODE = 3\n","import { For, Show, type Accessor } from \"solid-js\"\nimport { isServer, type JSX } from \"@solidjs/web\"\n\nimport { E, UIT } from \"spell/ui/core\"\n// Import directly: a leaf of the JSON family, what it takes to read a child (WWOD §4 › \"The barrel\")\nimport { JSON_CHANGED, JsonChild } from \"spell/ui/components/ui-json/JsonChild\"\nimport { treeDiagramVocabulary } from \"./UITreeDiagram.en\"\nimport { TreeData } from \"./TreeData\"\nimport { TreeLayout } from \"./TreeLayout\"\nimport { TreeMeasure, type TreeMeasureSamples } from \"./TreeMeasure\"\nimport { TREE_NODE_RESIZED, UITreeNode, type DOMTreeNodeElement } from \"./UITreeNode\"\nimport {\n TREE_DIAGRAM_METRICS,\n type TreeDiagramBox,\n type TreeDiagramEdge,\n type TreeDiagramLayout,\n type TreeDiagramNode,\n type TreeDiagramNodeSize\n} from \"./UITreeDiagram.types\"\n\nimport treeDiagramCSS from \"./UITreeDiagram.css?inline\"\n\n/****************\n * ### `UITreeDiagram`\n * The component behind `<ui-tree-diagram>`: a tree drawn as an SVG, top-down or left to right,\n * with a box per node, a line from each parent to each child, and a label on the line.\n *\n * - GENERIC: it draws any tree from plain data (`TreeDiagramNode`).\n * It was first drawn for spell's parse trees, but `ui` never imports spell or the parser.\n * - The tree, first match wins:\n * 1. the `tree` property (`tree={tree}` in Solid)\n * 2. a `<ui-tree-node>` child, with the nodes nested inside it, followed as it changes\n * 3. the JSON of a `<ui-json>` child, or a `<script type=\"application/json\">` child (static pages, `file://` too),\n * followed as it changes; a `<ui-json source>` once it loads\n * - Invalid JSON draws nothing, and warns once.\n * - It redraws when `tree` is set again: set a NEW tree (one changed in place isn't seen).\n * - The steps from tree to drawing:\n * 1. `TreeMeasure`: each text's real width in its real font, and the size of what a node holds\n * 2. `TreeLayout` (pure): those numbers in, boxes and lines out\n * 3. this class draws them; what a node holds is placed over its box by the node (`placement`)\n * - Measured again when a web font arrives, when the fonts' tokens change, and when what a node holds changes size.\n * - A static server render has nothing to measure with: `TreeLayout` estimates from character counts.\n * - Size: drawn at its natural size in em (`--_ui-tree-diagram-natural-width`),\n * shrinking to fit its container down to `--ui-tree-diagram-min-scale`, and scrolling sideways below that.\n * - Nothing to draw: the `<svg>` is `ui empty tree diagram`, hidden; the DOM element has no height.\n * - Accessibility: the `<svg>` is `role=\"img\"`, named by a summary (\"Tree: If, with 3 children\");\n * each node's `title` is its box's `<title>` (hover text).\n * - `foldable` or `clickable` make it `role=\"group\"` under the same name, with real buttons to Tab to.\n ****************/\nexport class UITreeDiagram extends E.UIComponent<typeof treeDiagramVocabulary> {\n @E.proto static vocabulary = treeDiagramVocabulary\n @E.protoMerged static elementSetup = {\n styleSheets: { \"tree-diagram\": treeDiagramCSS },\n delegatesFocus: false,\n slotAssignment: \"manual\" as const\n } satisfies Partial<E.ElementSetup>\n\n ////////////////\n // ## The tree\n ////////////////\n\n /**\n * Text of the JSON child, `<ui-json>` or `<script type=\"application/json\">`; `undefined` without one.\n * - Follows it as the page changes it.\n */\n @E.watches({ childList: true, characterData: true, subtree: true })\n get childText(): string | undefined {\n return isServer ? undefined : JsonChild.textOf(this.domElement)\n }\n\n /** Bumped when a `<ui-json>` child's data changes with no change in the page: its `source` loaded. */\n @E.state accessor childDataVersion = 0\n\n /** A `<ui-json>` child says its data changed. */\n @E.on(JSON_CHANGED)\n protected onChildDataChanged() {\n this.childDataVersion++\n }\n\n /**\n * The JSON child's tree; `undefined` without one, or when its JSON is invalid (warned once).\n * - `@derived`: parses JSON.\n */\n @E.derived\n get childTree(): TreeDiagramNode | undefined {\n const text = this.childText\n void this.childDataVersion\n if (text === undefined || isServer) return undefined\n return this.readChild(text)\n }\n\n /**\n * The nested `<ui-tree-node>`s, written out to compare; `undefined` without one.\n * - Follows them as the page changes them: readers hear only when something a tree holds moved.\n */\n @E.watches({ childList: true, characterData: true, attributes: true, subtree: true })\n get nodesText(): string | undefined {\n const root = UITreeNode.firstNodeOf(this.domElement)\n return root && JSON.stringify(UITreeNode.nodeFrom(root), (key, value) => (key === \"element\" ? undefined : value))\n }\n\n /**\n * The nested `<ui-tree-node>`s' tree; `undefined` without one.\n * - `@derived`: walks every node.\n */\n @E.derived\n get nodesTree(): TreeDiagramNode | undefined {\n if (this.nodesText === undefined) return undefined\n const root = UITreeNode.firstNodeOf(this.domElement)\n return root && UITreeNode.nodeFrom(root)\n }\n\n /**\n * The tree drawn: `tree` when it's a node, else the nested nodes', else the JSON child's; `undefined`: nothing\n * to draw.\n * - `@derived`: `TreeData.node()` copies the tree, checking every node.\n */\n @E.derived\n get drawnTree(): TreeDiagramNode | undefined {\n return TreeData.node(this.tree) ?? this.nodesTree ?? this.childTree\n }\n\n /** The JSON child's tree; invalid JSON warns (once per `text`, its text) and draws nothing. */\n private readChild(text: string): TreeDiagramNode | undefined {\n try {\n return TreeData.node(JsonChild.valueOf(this.domElement))\n } catch (error) {\n if (text !== this.warnedText)\n console.warn(`<${this.domElement.localName}>: invalid JSON in its script child`, error)\n this.warnedText = text\n return undefined\n }\n }\n\n /** Invalid JSON already warned about: a re-read of the same text stays quiet. */\n private warnedText: string | undefined\n\n ////////////////\n // ## Measuring\n ////////////////\n\n /** A text of each kind, in `<defs>`: what a real one's font comes to. Set as it draws. */\n private samples: Partial<TreeMeasureSamples> = {}\n /** The `<svg>`. Set as it draws. */\n private svg: SVGSVGElement | undefined\n /** A hidden line of label text: it changes size when the font does. */\n private fontSentinel: HTMLElement | undefined\n /** The `<slot>` the root `<ui-tree-node>` goes in. Set as it draws. */\n private nodesSlot: HTMLSlotElement | undefined\n\n /** Bumped when what was measured may have changed: it drew, a font arrived, what a node holds changed size. */\n @E.state accessor measureVersion = 0\n\n /** How far the drawing shrank to fit: what a node holds shrinks with it. */\n @E.state accessor drawnScale = 1\n\n /** What a node holds changed size. */\n @E.on(TREE_NODE_RESIZED)\n protected onNodeResized() {\n this.measureVersion++\n }\n\n /** While it's in the page: measures again when a web font arrives or the font changes; follows the scale. */\n @E.whileConnected\n protected watchFontsAndSize() {\n this.measureVersion++\n const remeasure = () => this.measureVersion++\n document.fonts?.addEventListener(\"loadingdone\", remeasure)\n const observer = new ResizeObserver(() => this.onDrawingResized())\n if (this.fontSentinel) observer.observe(this.fontSentinel)\n if (this.svg) observer.observe(this.svg)\n return () => {\n document.fonts?.removeEventListener(\"loadingdone\", remeasure)\n observer.disconnect()\n }\n }\n\n /** The sentinel or the `<svg>` changed size. */\n private onDrawingResized() {\n const sentinelWidth = this.fontSentinel?.offsetWidth\n if (sentinelWidth !== this.lastSentinelWidth) {\n this.lastSentinelWidth = sentinelWidth\n this.measureVersion++\n }\n this.drawnScale = this.scaleNow()\n }\n\n /** The sentinel's width last seen. */\n private lastSentinelWidth: number | undefined\n\n /** The drawing's width on the page, per its natural width; `1` when it isn't laid out. */\n private scaleNow(): number {\n const { svg, layout } = this\n const width = svg?.getBoundingClientRect().width\n if (!svg || !width || !layout) return 1\n return width / (layout.width * this.pixelsPerUnit() || width)\n }\n\n /** Pixels per user unit, at natural size: one label `em` on the page is `fontSize` units. */\n private pixelsPerUnit(): number {\n return Number.parseFloat(getComputedStyle(this.svg!).fontSize) / TREE_DIAGRAM_METRICS.fontSize\n }\n\n /**\n * Every node's measured sizes; `undefined` before it can measure (a server, or before it first draws).\n * - `@derived`: measures every text.\n * - Reads the DOM: `measureVersion` says when that changed.\n */\n @E.derived\n get sizes(): ReadonlyMap<TreeDiagramNode, TreeDiagramNodeSize> | undefined {\n const tree = this.drawnTree\n void this.measureVersion\n const { rootLabel, label, detail, edgeLabel } = this.samples\n if (isServer || !tree || !this.svg || !rootLabel || !label || !detail || !edgeLabel) return undefined\n return TreeMeasure.sizes(tree, { rootLabel, label, detail, edgeLabel }, (node) => this.contentSizeOf(node))\n }\n\n /** What `node` holds besides its text, in user units; `undefined` when nothing. */\n private contentSizeOf(node: TreeDiagramNode): { width: number; height: number } | undefined {\n const size = (node.element as DOMTreeNodeElement | undefined)?.component?.contentSize\n if (!size) return undefined\n const perPixel = 1 / this.pixelsPerUnit()\n return { width: size.width * perPixel, height: size.height * perPixel }\n }\n\n ////////////////\n // ## Folding\n ////////////////\n\n /** Nodes folded or opened by a person, by `path`; a tree that changes keeps them. */\n @E.state accessor foldChanges: ReadonlyMap<string, boolean> = new Map()\n\n /**\n * The nodes drawn as leaves: `folded` in the tree, unless a person changed it.\n * - `@derived`: walks every node.\n */\n @E.derived\n get foldedNodes(): ReadonlySet<TreeDiagramNode> {\n const folded = new Set<TreeDiagramNode>()\n const { drawnTree, foldChanges } = this\n const visit = (node: TreeDiagramNode, path: string) => {\n if (foldChanges.get(path) ?? node.folded) folded.add(node)\n node.children?.forEach((child, index) => visit(child, `${path}.${index}`))\n }\n if (drawnTree) visit(drawnTree, \"0\")\n return folded\n }\n\n /** Fold or open `box`'s node: `ui-node-toggled`, then the drawing. */\n @E.untracked\n private toggle(box: TreeDiagramBox, originalEvent: Event) {\n const folded = !box.isFolded\n this.foldChanges = new Map(this.foldChanges).set(box.path, folded)\n this.send(\"ui-node-toggled\", { node: box.node, path: box.path, folded, originalEvent })\n }\n\n ////////////////\n // ## Layout\n ////////////////\n\n /**\n * The tree laid out; `undefined` with nothing to draw.\n * - `@derived`: lays out every node.\n */\n @E.derived\n get layout(): TreeDiagramLayout | undefined {\n const tree = this.drawnTree\n if (!tree) return undefined\n return TreeLayout.of(tree, {\n direction: this.direction,\n sizes: this.sizes,\n folded: this.foldedNodes,\n metrics: this.foldable ? FOLDABLE_METRICS : TREE_DIAGRAM_METRICS\n })\n }\n\n /**\n * Tell each nested node where what it holds goes; a folded-away node, nowhere.\n * - And hand the root `<ui-tree-node>` to its slot.\n */\n @E.onChange(\"layout\", \"nodesTree\", \"isReady\")\n protected onLayoutChanged(\n layout: TreeDiagramLayout | undefined,\n tree: TreeDiagramNode | undefined,\n isReady: boolean\n ) {\n if (!isReady) return\n this.nodesSlot?.assign(...(tree?.element ? [tree.element] : []))\n this.drawnScale = this.scaleNow()\n const shown = new Map(layout?.boxes.map((box) => [box.node.element, box]))\n const place = (node: TreeDiagramNode) => {\n const component = (node.element as DOMTreeNodeElement | undefined)?.component\n const content = shown.get(node.element)?.content\n if (component) {\n component.placement =\n content && layout\n ? { left: (content.x / layout.width) * 100, top: (content.y / layout.height) * 100 }\n : undefined\n }\n node.children?.forEach(place)\n }\n if (tree) place(tree)\n }\n\n ////////////////\n // ## Clicks\n ////////////////\n\n /** A click on what a node holds: it's outside the `<svg>`, in the page. */\n @E.on(\"click\")\n protected onContentClick(event: MouseEvent) {\n const element = event\n .composedPath()\n .find((target) => target !== this.domElement && UITreeNode.isNode(target as Node)) as Element | undefined\n if (!element) return\n const box = this.layout?.boxes.find((each) => each.node.element === element)\n if (box) this.sendClick(box, event)\n }\n\n /** `ui-node-clicked`. */\n @E.untracked\n private sendClick(box: TreeDiagramBox, originalEvent: Event) {\n this.send(\"ui-node-clicked\", { node: box.node, path: box.path, originalEvent })\n }\n\n /** Enter or Space on a focused node or fold button does `act`. */\n private onButtonKey(event: KeyboardEvent, act: (event: Event) => void) {\n if (event.key !== UIT.Key.enter && event.key !== UIT.Key.space) return\n event.preventDefault()\n event.stopPropagation()\n act(event)\n }\n\n ////////////////\n // ## Drawing\n ////////////////\n\n /**\n * `empty` with nothing to draw.\n * - Reads `tree` itself, not just `drawnTree`: so the classes follow EVERY write to it,\n * as `ElementFixture.breakRender()` needs (the only attribute is a non-class one).\n */\n protected override get extraClass(): string | undefined {\n return TreeData.node(this.tree) || this.nodesTree || this.childTree ? undefined : EMPTY\n }\n\n render(): JSX.Element {\n return (\n <div class={CANVAS_CLASS} style={this.canvasStyle()}>\n <svg\n ref={(svg: SVGSVGElement) => (this.svg = svg)}\n class={this.rootClass}\n part={this.partForName(\"diagram\")}\n role={this.layout ? (this.foldable || this.clickable ? \"group\" : \"img\") : undefined}\n aria-label={this.summary()}\n viewBox={this.viewBox()}\n style={this.sizeStyle()}\n >\n {this.fontSamples()}\n <For each={this.layout?.edges ?? []} keyed={false}>\n {(edge) => this.edge(edge)}\n </For>\n <For each={this.layout?.boxes ?? []} keyed={false}>\n {(box) => this.box(box)}\n </For>\n </svg>\n <span ref={(span: HTMLElement) => (this.fontSentinel = span)} class={SENTINEL_CLASS} aria-hidden=\"true\">\n Mg\n </span>\n <slot ref={(slot: HTMLSlotElement) => (this.nodesSlot = slot)} />\n </div>\n )\n }\n\n /** A text of each kind, never drawn: what `TreeMeasure` reads each font from. */\n private fontSamples(): JSX.Element {\n const { fontSize, detailFontSize, edgeLabelFontSize } = TREE_DIAGRAM_METRICS\n return (\n <defs>\n <g class={[NODE_CLASS, ROOT_CLASS]}>\n <text\n ref={(text: SVGTextElement) => (this.samples.rootLabel = text)}\n class={LABEL_CLASS}\n font-size={String(fontSize)}\n />\n </g>\n <g class={NODE_CLASS}>\n <text\n ref={(text: SVGTextElement) => (this.samples.label = text)}\n class={LABEL_CLASS}\n font-size={String(fontSize)}\n />\n <text\n ref={(text: SVGTextElement) => (this.samples.detail = text)}\n class={DETAIL_CLASS}\n font-size={String(detailFontSize)}\n />\n </g>\n <text\n ref={(text: SVGTextElement) => (this.samples.edgeLabel = text)}\n class={EDGE_LABEL_CLASS}\n font-size={String(edgeLabelFontSize)}\n />\n </defs>\n )\n }\n\n /**\n * One node: its `<g>` (part `node`, the root's also `root-node`), `<title>`, box, label, detail, fold button.\n * - `box` is the For's accessor (`keyed={false}`): a redraw updates the same elements in place, by position.\n */\n private box(box: Accessor<TreeDiagramBox>): JSX.Element {\n const { fontSize, detailFontSize } = TREE_DIAGRAM_METRICS\n const isRoot = () => box().depth === 0\n const kind = () => UITreeDiagram.wordFor(box().node.kind)\n return (\n <g\n class={[\n NODE_CLASS,\n { [ROOT_CLASS]: isRoot(), [CLICKABLE_CLASS]: !!this.clickable },\n kind() && `kind-${kind()}`\n ]}\n part={[this.partForName(\"node\"), isRoot() && this.partForName(\"root-node\"), kind() && `kind-${kind()}`]\n .filter(Boolean)\n .join(\" \")}\n style={UITreeDiagram.colorStyle(box().node.color)}\n role={this.clickable ? \"button\" : undefined}\n tabindex={this.clickable ? \"0\" : undefined}\n aria-label={this.clickable ? box().node.label : undefined}\n onClick={(event: MouseEvent) => this.sendClick(box(), event)}\n onKeyDown={(event: KeyboardEvent) => {\n if (this.clickable && event.target === event.currentTarget)\n this.onButtonKey(event, (original) => this.sendClick(box(), original))\n }}\n >\n <Show when={box().node.title}>{(title) => <title>{title()}</title>}</Show>\n <rect class={BOX_CLASS} x={box().x} y={box().y} width={box().width} height={box().height} />\n <Show when={box().node.label}>\n <text class={LABEL_CLASS} x={box().label.x} y={box().label.y} font-size={String(fontSize)}>\n {box().node.label}\n </text>\n </Show>\n <Show when={box().detail}>\n {(detail) => (\n <text class={DETAIL_CLASS} x={detail().x} y={detail().y} font-size={String(detailFontSize)}>\n {box().node.detail}\n </text>\n )}\n </Show>\n <Show when={this.foldable && box().childCount}>{this.foldButton(box)}</Show>\n </g>\n )\n }\n\n /** `box`'s fold button (part `toggle`), where its lines leave it: a circle with a `+` or a `-`. */\n private foldButton(box: Accessor<TreeDiagramBox>): JSX.Element {\n const label = () => this.translationForKey(box().isFolded ? \"unfoldNode\" : \"foldNode\", { label: box().node.label })\n return (\n <g\n class={TOGGLE_CLASS}\n part={this.partForName(\"toggle\")}\n role=\"button\"\n tabindex=\"0\"\n aria-expanded={box().isFolded ? \"false\" : \"true\"}\n aria-label={label()}\n transform={`translate(${box().exit.x} ${box().exit.y})`}\n onClick={(event: MouseEvent) => {\n event.stopPropagation()\n this.toggle(box(), event)\n }}\n onKeyDown={(event: KeyboardEvent) => this.onButtonKey(event, (original) => this.toggle(box(), original))}\n >\n <title>{label()}</title>\n <circle class={TOGGLE_TARGET_CLASS} r={TOGGLE_TARGET_RADIUS} />\n <circle class={TOGGLE_CIRCLE_CLASS} r={TOGGLE_RADIUS} />\n <path class={TOGGLE_MARK_CLASS} d={box().isFolded ? PLUS_MARK : MINUS_MARK} />\n </g>\n )\n }\n\n /** One edge: its line (part `edge`), broken under its label (part `edge-label`). `edge`: as `box()`'s. */\n private edge(edge: Accessor<TreeDiagramEdge>): JSX.Element {\n return (\n <>\n <path class={EDGE_CLASS} part={this.partForName(\"edge\")} d={UITreeDiagram.path(edge())} />\n <Show when={edge().label}>\n {(label) => (\n <text\n class={EDGE_LABEL_CLASS}\n part={this.partForName(\"edge-label\")}\n x={label().x}\n y={label().y}\n font-size={String(TREE_DIAGRAM_METRICS.edgeLabelFontSize)}\n >\n {label().text}\n </text>\n )}\n </Show>\n </>\n )\n }\n\n /** `viewBox`: the layout's natural size. */\n private viewBox(): string | undefined {\n const layout = this.layout\n return layout && `0 0 ${layout.width} ${layout.height}`\n }\n\n /** The natural width in label `em`s, for the sheet to size the `<svg>` with. */\n private sizeStyle(): JSX.CSSProperties | undefined {\n const layout = this.layout\n return layout && { [NATURAL_WIDTH]: (layout.width / TREE_DIAGRAM_METRICS.fontSize).toFixed(3) }\n }\n\n /** How far the drawing shrank, for what its nodes hold. */\n private canvasStyle(): JSX.CSSProperties {\n return { [DRAWN_SCALE]: this.drawnScale.toFixed(4) }\n }\n\n /** The `<svg>`'s name: the root's label and how many children it has. */\n private summary(): string | undefined {\n const tree = this.drawnTree\n if (!tree) return undefined\n return TreeData.summary(tree, (key, params) => this.translationForKey(key, params))\n }\n\n /** `d` of an edge's `<path>`: one line, or two around the label's gap. */\n private static path({ from, to, gap }: TreeDiagramEdge): string {\n if (!gap) return `M${from.x} ${from.y}L${to.x} ${to.y}`\n return `M${from.x} ${from.y}L${gap.from.x} ${gap.from.y}M${gap.to.x} ${gap.to.y}L${to.x} ${to.y}`\n }\n\n /** `word` when it's safe in a class and a part name; else `undefined`. */\n private static wordFor(word: string | undefined): string | undefined {\n return word && /^[\\w-]+$/.test(word) ? word : undefined\n }\n\n /** A node's `color`: the node's tokens, set to that hue, on its `<g>`; the sheet reads them. */\n private static colorStyle(color: string | undefined): JSX.CSSProperties | undefined {\n const hue = UITreeDiagram.wordFor(color)\n if (!hue) return undefined\n const background = `var(--ui-${hue}-background)`\n const border = `var(--ui-${hue})`\n return {\n \"--ui-tree-diagram-node-background\": background,\n \"--ui-tree-diagram-node-border-color\": border,\n \"--ui-tree-diagram-root-background\": background,\n \"--ui-tree-diagram-root-border-color\": border\n }\n }\n}\n\n/** The vocabulary getters, typed (`UIComponent`'s doc). */\nexport interface UITreeDiagram extends E.AttributeValues<typeof treeDiagramVocabulary> {}\n\n/** Class word before the noun when there's nothing to draw (`ui empty tree diagram`): the `<svg>` hides. */\nconst EMPTY = \"empty\"\n\n/** Class of the box around the drawing and its nodes' content, the content's containing block. */\nconst CANVAS_CLASS = \"canvas\"\n/** Class of the hidden line that changes size when the font does. */\nconst SENTINEL_CLASS = \"font-sentinel\"\n\n/** Class of each node's `<g>`, its box, its texts; each edge; each edge label. */\nconst NODE_CLASS = \"node\"\nconst ROOT_CLASS = \"root\"\nconst CLICKABLE_CLASS = \"clickable\"\nconst BOX_CLASS = \"box\"\nconst LABEL_CLASS = \"label\"\nconst DETAIL_CLASS = \"detail\"\nconst EDGE_CLASS = \"edge\"\nconst EDGE_LABEL_CLASS = \"edge-label\"\n\n/** Class of a fold button's `<g>` and its pieces. */\nconst TOGGLE_CLASS = \"toggle\"\nconst TOGGLE_TARGET_CLASS = \"toggle-target\"\nconst TOGGLE_CIRCLE_CLASS = \"toggle-circle\"\nconst TOGGLE_MARK_CLASS = \"toggle-mark\"\n\n/** A fold button's circle, in user units. */\nconst TOGGLE_RADIUS = 6\n/** What a pointer can hit, around it. */\nconst TOGGLE_TARGET_RADIUS = 12\n/** The button's `+` and `-`, drawn so they're centred in any font. */\nconst PLUS_MARK = \"M-3 0H3M0 -3V3\"\nconst MINUS_MARK = \"M-3 0H3\"\n\n/** A foldable tree's room around the drawing: a button sticks out below its last row. */\nconst FOLDABLE_METRICS = { ...TREE_DIAGRAM_METRICS, margin: TOGGLE_RADIUS + 2 }\n\n/** Private custom property the sheet sizes the `<svg>` with: the layout's natural width, in label `em`s. */\nconst NATURAL_WIDTH = \"--_ui-tree-diagram-natural-width\"\n/** Private custom property what a node holds is scaled by: how far the drawing shrank. */\nconst DRAWN_SCALE = \"--_ui-tree-diagram-scale\"\n","/**\n * The tree diagram family: defines `<ui-tree-diagram>` and `<ui-tree-node>`, and exports their components.\n * - SIDE EFFECT: importing it defines the tag, and `<ui-json>` (where its tree may come from).\n * - Also the library's `spell/ui/ui-tree-diagram` entry (its size is in `notes/report.md`).\n * - `TreeLayout` (the pure layout), `TreeMeasure` (its numbers) and `TreeData` (reading and checking a tree) are exported too,\n * for a page that wants the numbers alone; `TreeDiagramNode` is the data contract.\n */\n\nimport { TreeData } from \"./TreeData\"\nimport { TreeLayout } from \"./TreeLayout\"\nimport { TreeMeasure } from \"./TreeMeasure\"\nimport { UITreeDiagram } from \"./UITreeDiagram\"\nimport { UITreeNode } from \"./UITreeNode\"\n\nimport \"spell/ui/components/ui-json\"\n\nUITreeDiagram.define()\nUITreeNode.define()\n\nexport { TreeData, TreeLayout, TreeMeasure, UITreeDiagram, UITreeNode }\nexport type {\n TreeDiagramBox,\n TreeDiagramDirection,\n TreeDiagramEdge,\n TreeDiagramEdgeLabel,\n TreeDiagramLayout,\n TreeDiagramLayoutOptions,\n TreeDiagramMetrics,\n TreeDiagramNode,\n TreeDiagramNodeSize,\n TreeDiagramPoint\n} from \"./UITreeDiagram.types\"\n"],"mappings":";;;;;;;AAcA,IAAamH,IAAb,MAAa,SAAS;CAQpB,OAAO,KAAK,GAAgB,oBAAO,IAAI,IAAY,GAAgC;EACjF,IAAI,OAAOC,KAAU,aAAYA,KAAkB,MAAM,QAAQA,CAAK,KAAKC,EAAK,IAAID,CAAK,GAAG;EAC5F,EAAK,IAAIA,CAAK;EACd,IAAME,IAAMF,GACNG,IAAwB,EAAE,OAAO,SAAS,KAAKD,EAAI,KAAK,KAAK,GAAG,GAChEE,IAAS,SAAS,KAAKF,EAAI,MAAM,GACjCG,IAAY,SAAS,KAAKH,EAAI,SAAS,KAAK,SAAS,KAAKA,EAAI,IAAI,GAClEI,IAAQ,SAAS,KAAKJ,EAAI,KAAK,GAC/BK,IAAQ,SAAS,KAAKL,EAAI,KAAK,GAC/BM,IAAO,SAAS,KAAKN,EAAI,IAAI;EAOnC,IANIE,MAAQ,EAAK,SAASA,IACtBC,MAAW,EAAK,YAAYA,IAC5BC,MAAO,EAAK,QAAQA,IACpBC,MAAO,EAAK,QAAQA,IACpBC,MAAM,EAAK,OAAOA,IA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6L,GAAA,IAAO,gBAAtBH,IAFWQ,CAAA,GAANjM,EAAA4L,GAAMK,CAAA,GAAkEzM,EAAAyM,GAAA,eAAA,GACpEpM,EADEoM,GACK,cAAahM,EAApB2L,GAAA,IADEK,GACkBtF,EAAA,CAAA,GAApB1G,EAAA2L,GAAA,IADEK,CAAA,GAEIpM,EAFJoM,GAEW,gBAAehM,EAAtB2L,GAAA,IAFJK,GAE0B;CACnC,aAAa,EAAE,gBAAgBxM,GAAe;CAC9C,gBAAgB;CAChB,gBAAgB;AAClB,CAAA,CAAA,GAJeQ,EAAA2L,GAAA,IAFJK,CAAA;AAAN,IAAMoG,KAANpG,GA2fD2B,KAAQ,SAGRU,KAAe,UAEfC,KAAiB,iBAGjBe,KAAa,QACbC,KAAa,QACbkB,KAAkB,aAClBC,KAAY,OACZlB,IAAc,SACdC,KAAe,UACfmC,KAAa,QACblC,KAAmB,cAGnB0B,KAAe,UACfC,KAAsB,iBACtBC,KAAsB,iBACtBC,KAAoB,eAGpBJ,KAAgB,GAEhBD,KAAuB,IAEvBM,KAAY,kBACZC,KAAa,WAGbtE,KAAmB;CAAE,GAAG9L;CAAsB,QAAQ;AAAkB,GAGxEyQ,KAAgB,oCAEhBC,KAAc;A,yBCjkBpBM,GAAc,OAAO,GACrBxI,EAAW,OAAO"}
|
|
1
|
+
{"version":3,"file":"ui-tree-diagram.js","names":["ref={(box) => this.contentBox = box}","ref={(slot) => this.contentSlot = slot}","this","part={this.partForName(\"content\")}","style={this.placementStyle()}","ref={(slot) => this.nodesSlot = slot}","_tmpl$","_tmpl$2","_elementSetup_dec","_vocabulary_dec","_a","_init","E.UIComponent","E.proto","E.protoMerged","E.state","E.watches","E.onChange","_$getOwner","_$readShallow","_$setAttribute","__name","treeNodeCSS","ref={(svg) => this.svg = svg}","this","<svg\n ref={(svg) => this.svg = svg}\n class={this.rootClass}\n part={this.partForName(\"diagram\")}\n role={this.layout ? this.foldable || this.clickable ? \"group\" : \"img\" : void 0}\n aria-label={this.summary()}\n viewBox={this.viewBox()}\n style={this.sizeStyle()}\n >\n {this.fontSamples()}\n <For each={this.layout?.edges ?? []} keyed={false}>\n {(edge) => this.edge(edge)}\n </For>\n <For each={this.layout?.boxes ?? []} keyed={false}>\n {(box) => this.box(box)}\n </For>\n </svg>","<For each={this.layout?.edges ?? []} keyed={false}>\n {(edge) => this.edge(edge)}\n </For>","keyed={false}","<For each={this.layout?.boxes ?? []} keyed={false}>\n {(box) => this.box(box)}\n </For>","ref={(span) => this.fontSentinel = span}","ref={(slot) => this.nodesSlot = slot}","style={this.canvasStyle()}","class={this.rootClass}","part={this.partForName(\"diagram\")}","role={this.layout ? this.foldable || this.clickable ? \"group\" : \"img\" : void 0}","aria-label={this.summary()}","viewBox={this.viewBox()}","style={this.sizeStyle()}","class={SENTINEL_CLASS}","<div class={CANVAS_CLASS} style={this.canvasStyle()}>\n <svg\n ref={(svg) => this.svg = svg}\n class={this.rootClass}\n part={this.partForName(\"diagram\")}\n role={this.layout ? this.foldable || this.clickable ? \"group\" : \"img\" : void 0}\n aria-label={this.summary()}\n viewBox={this.viewBox()}\n style={this.sizeStyle()}\n >\n {this.fontSamples()}\n <For each={this.layout?.edges ?? []} keyed={false}>\n {(edge) => this.edge(edge)}\n </For>\n <For each={this.layout?.boxes ?? []} keyed={false}>\n {(box) => this.box(box)}\n </For>\n </svg>\n <span ref={(span) => this.fontSentinel = span} class={SENTINEL_CLASS} aria-hidden=\"true\">\n Mg\n </span>\n <slot ref={(slot) => this.nodesSlot = slot} />\n </div>","ref={(text) => this.samples.rootLabel = text}","ref={(text) => this.samples.label = text}","ref={(text) => this.samples.detail = text}","ref={(text) => this.samples.edgeLabel = text}","class={LABEL_CLASS}","font-size={String(fontSize)}","class={NODE_CLASS}","class={DETAIL_CLASS}","font-size={String(detailFontSize)}","class={EDGE_LABEL_CLASS}","font-size={String(edgeLabelFontSize)}","<defs>\n <g class={[NODE_CLASS, ROOT_CLASS]}>\n <text\n ref={(text) => this.samples.rootLabel = text}\n class={LABEL_CLASS}\n font-size={String(fontSize)}\n />\n </g>\n <g class={NODE_CLASS}>\n <text\n ref={(text) => this.samples.label = text}\n class={LABEL_CLASS}\n font-size={String(fontSize)}\n />\n <text\n ref={(text) => this.samples.detail = text}\n class={DETAIL_CLASS}\n font-size={String(detailFontSize)}\n />\n </g>\n <text\n ref={(text) => this.samples.edgeLabel = text}\n class={EDGE_LABEL_CLASS}\n font-size={String(edgeLabelFontSize)}\n />\n </defs>","<Show when={box().node.title}>{(title) => <title>{title()}</title>}</Show>","<g\n class={[\n NODE_CLASS,\n { [ROOT_CLASS]: isRoot(), [CLICKABLE_CLASS]: !!this.clickable },\n kind() && `kind-${kind()}`\n ]}\n part={[this.partForName(\"node\"), isRoot() && this.partForName(\"root-node\"), kind() && `kind-${kind()}`].filter(Boolean).join(\" \")}\n style={_UITreeDiagram.colorStyle(box().node.color)}\n role={this.clickable ? \"button\" : void 0}\n tabindex={this.clickable ? \"0\" : void 0}\n aria-label={this.clickable ? box().node.label : void 0}\n onClick={(event) => this.sendClick(box(), event)}\n onKeyDown={(event) => {\n if (this.clickable && event.target === event.currentTarget)\n this.onButtonKey(event, (original) => this.sendClick(box(), original));\n }}\n >\n <Show when={box().node.title}>{(title) => <title>{title()}</title>}</Show>\n <rect class={BOX_CLASS} x={box().x} y={box().y} width={box().width} height={box().height} />\n <Show when={box().node.label}>\n <text class={LABEL_CLASS} x={box().label.x} y={box().label.y} font-size={String(fontSize)}>\n {box().node.label}\n </text>\n </Show>\n <Show when={box().detail}>\n {(detail) => <text class={DETAIL_CLASS} x={detail().x} y={detail().y} font-size={String(detailFontSize)}>\n {box().node.detail}\n </text>}\n </Show>\n <Show when={this.foldable && box().childCount}>{this.foldButton(box)}</Show>\n </g>","<Show when={box().node.label}>\n <text class={LABEL_CLASS} x={box().label.x} y={box().label.y} font-size={String(fontSize)}>\n {box().node.label}\n </text>\n </Show>","x={box().label.x}","y={box().label.y}","<text class={LABEL_CLASS} x={box().label.x} y={box().label.y} font-size={String(fontSize)}>\n {box().node.label}\n </text>","<Show when={box().detail}>\n {(detail) => <text class={DETAIL_CLASS} x={detail().x} y={detail().y} font-size={String(detailFontSize)}>\n {box().node.detail}\n </text>}\n </Show>","x={detail().x}","y={detail().y}","<Show when={this.foldable && box().childCount}>{this.foldButton(box)}</Show>","this.foldable && box().childCount","part={[this.partForName(\"node\"), isRoot() && this.partForName(\"root-node\"), kind() && `kind-${kind()}`].filter(Boolean).join(\" \")}","style={_UITreeDiagram.colorStyle(box().node.color)}","role={this.clickable ? \"button\" : void 0}","tabindex={this.clickable ? \"0\" : void 0}","aria-label={this.clickable ? box().node.label : void 0}","class={BOX_CLASS}","x={box().x}","y={box().y}","width={box().width}","height={box().height}","part={this.partForName(\"toggle\")}","aria-expanded={box().isFolded ? \"false\" : \"true\"}","aria-label={label()}","transform={`translate(${box().exit.x} ${box().exit.y})`}","class={TOGGLE_TARGET_CLASS}","class={TOGGLE_CIRCLE_CLASS}","class={TOGGLE_MARK_CLASS}","d={box().isFolded ? PLUS_MARK : MINUS_MARK}","<g\n class={TOGGLE_CLASS}\n part={this.partForName(\"toggle\")}\n role=\"button\"\n tabindex=\"0\"\n aria-expanded={box().isFolded ? \"false\" : \"true\"}\n aria-label={label()}\n transform={`translate(${box().exit.x} ${box().exit.y})`}\n onClick={(event) => {\n event.stopPropagation();\n this.toggle(box(), event);\n }}\n onKeyDown={(event) => this.onButtonKey(event, (original) => this.toggle(box(), original))}\n >\n <title>{label()}</title>\n <circle class={TOGGLE_TARGET_CLASS} r={TOGGLE_TARGET_RADIUS} />\n <circle class={TOGGLE_CIRCLE_CLASS} r={TOGGLE_RADIUS} />\n <path class={TOGGLE_MARK_CLASS} d={box().isFolded ? PLUS_MARK : MINUS_MARK} />\n </g>","part={this.partForName(\"edge\")}","d={_UITreeDiagram.path(edge())}","<Show when={edge().label}>\n {(label) => <text\n class={EDGE_LABEL_CLASS}\n part={this.partForName(\"edge-label\")}\n x={label().x}\n y={label().y}\n font-size={String(TREE_DIAGRAM_METRICS.edgeLabelFontSize)}\n >\n {label().text}\n </text>}\n </Show>","part={this.partForName(\"edge-label\")}","x={label().x}","y={label().y}","font-size={String(TREE_DIAGRAM_METRICS.edgeLabelFontSize)}","E.UIComponent","E.proto","E.protoMerged","E.watches","E.state","E.on","E.derived","E.whileConnected","E.untracked","E.onChange","_$getOwner","_$readShallow","_$setAttribute","__name","treeDiagramCSS","TreeMeasure","Key","__decoratorStart","__publicField","__name$1","__decorateElement","__decoratorMetadata","__runInitializers","__privateAdd","JSON_CHANGED","getOwner$1","TreeData","value","seen","raw","node","detail","edgeLabel","title","color","kind","children","child","count","tree","text","TreeDiagramDirections","TREE_DIAGRAM_METRICS","TreeLayout","options","root","ROOT_PATH","levelLengths","gaps","levelGap","levelStarts","margin","depth","centres","low","high","centre","middle","shift","boxes","edges","cross","start","parent","from","last","crossTotal","mainTotal","size","labelWidth","charWidth","fontSize","detailWidth","detailFontSize","contentWidth","contentHeight","width","minBoxWidth","paddingX","labelLine","lineHeight","detailLine","height","paddingY","edgeLabelWidth","edgeLabelCharWidth","edgeLabelFontSize","edgeLabelPaddingX","edgeLabelHeight","edgeLabelPaddingY","edgeLabelCross","crossLength","isFolded","path","index","LABEL_LEAD","half","contours","offsets","needed","blocker","neededByPrevious","earlier","distance","merged","contour","at","shared","before","after","between","first","room","main","length","x","y","textTop","round","childCount","point","to","dx","dy","reach","label","gap","visit","treeDiagramVocabulary","treeNodeVocabulary","UITreeNode_default","_tmpl$$1","_tmpl$2$1","_watchContentSize_dec","_onChildrenChanged_dec","_children_dec","_placement_dec","_elementSetup_dec$1","_vocabulary_dec$1","_a$1","_init$1","_placement","TREE_NODE_RESIZED","_UITreeNode","UIComponent","proto","protoMerged","state","watches","onChange","box","isReady","isConnected","observer","_self$","_el$","_el$2","ref","slot","effect","readShallow","PLACED","className","_p$","t","setAttribute","style","a","_el$3","placement","ELEMENT_NODE","name","UI","domElement","found","element","held","TEXT_NODE","UITreeNode","UITreeDiagram_default","_tmpl$","_tmpl$2","_tmpl$3","_tmpl$4","_tmpl$5","_tmpl$6","_tmpl$7","_sendClick_dec","_onContentClick_dec","_onLayoutChanged_dec","_layout_dec","_toggle_dec","_foldedNodes_dec","_foldChanges_dec","_sizes_dec","_watchFontsAndSize_dec","_onNodeResized_dec","_drawnScale_dec","_measureVersion_dec","_drawnTree_dec","_nodesTree_dec","_nodesText_dec","_childTree_dec","_onChildDataChanged_dec","_childDataVersion_dec","_childText_dec","_elementSetup_dec","_vocabulary_dec","_a","_init","_childDataVersion","_measureVersion","_drawnScale","_foldChanges","_UITreeDiagram","on","derived","whileConnected","untracked","isServer","JsonChild","key","error","remeasure","sentinelWidth","svg","layout","rootLabel","perPixel","folded","foldChanges","drawnTree","FOLDABLE_METRICS","shown","place","component","content","event","target","each","act","EMPTY","_el$4","_el$5","_el$6","_el$7","insert","createComponent","For","edge","span","CANVAS_CLASS","SENTINEL_CLASS","o","i","n","s","h","r","_self$2","_el$8","_el$9","_el$10","_el$11","_el$12","_el$13","_el$14","NODE_CLASS","ROOT_CLASS","LABEL_CLASS","DETAIL_CLASS","EDGE_LABEL_CLASS","d","isRoot","_self$3","_el$15","_el$16","_el$18","_el$19","_el$20","original","Show","_el$21","_el$17","_el$22","memo","CLICKABLE_CLASS","BOX_CLASS","l","_self$4","_el$23","_el$24","_el$25","_el$26","_el$27","TOGGLE_TARGET_RADIUS","TOGGLE_RADIUS","TOGGLE_CLASS","TOGGLE_TARGET_CLASS","TOGGLE_CIRCLE_CLASS","TOGGLE_MARK_CLASS","PLUS_MARK","MINUS_MARK","_self$5","_el$28","EDGE_CLASS","_el$29","NATURAL_WIDTH","DRAWN_SCALE","params","word","hue","background","border","UITreeDiagram","delegateEvents"],"sources":["../src/components/ui-tree-diagram/TreeData.ts","../src/components/ui-tree-diagram/UITreeDiagram.types.ts","../src/components/ui-tree-diagram/TreeLayout.ts","../src/components/ui-tree-diagram/UITreeDiagram.en.ts","../src/components/ui-tree-diagram/UITreeNode.en.ts","../src/components/ui-tree-diagram/UITreeNode.tsx","../src/components/ui-tree-diagram/UITreeDiagram.tsx","../src/components/ui-tree-diagram/index.ts"],"sourcesContent":["import type { TreeDiagramNode } from \"./UITreeDiagram.types\"\n\n/****************\n * ### `TreeData`\n * Where a `<ui-tree-diagram>`'s tree comes from, made safe to lay out:\n * the `tree` property, or the JSON in a `<ui-json>` or `<script type=\"application/json\">` child (`JsonChild`).\n * - STATIC, plain DOM, no Solid: the component reads the tree through it, and names the diagram with `summary()`;\n * tests drive it directly.\n * - Lenient: data from a page is checked, not trusted.\n * - Anything that isn't an object is no node.\n * - A missing `label` is `\"\"`; a `detail` / `edgeLabel` / `title` / `color` / `kind` that isn't a string is dropped.\n * - `slot` is `edgeLabel`'s old name: spell's parse trees still write it (`P.TreeWriter`).\n * - `children` keeps only nodes.\n ****************/\nexport class TreeData {\n /**\n * `value` as a tree to draw, or `undefined` when it isn't one.\n * - Always a NEW tree: the caller's objects are never handed on, nor changed.\n * - A node met twice on the way down (a cycle, or one object shared by two parents) is drawn once:\n * where it's met first.\n * - NEVER throws.\n */\n static node(value: unknown, seen = new Set<object>()): TreeDiagramNode | undefined {\n if (typeof value !== \"object\" || value === null || Array.isArray(value) || seen.has(value)) return undefined\n seen.add(value)\n const raw = value as Record<string, unknown>\n const node: TreeDiagramNode = { label: TreeData.text(raw.label) ?? \"\" }\n const detail = TreeData.text(raw.detail)\n const edgeLabel = TreeData.text(raw.edgeLabel) ?? TreeData.text(raw.slot)\n const title = TreeData.text(raw.title)\n const color = TreeData.text(raw.color)\n const kind = TreeData.text(raw.kind)\n if (detail) node.detail = detail\n if (edgeLabel) node.edgeLabel = edgeLabel\n if (title) node.title = title\n if (color) node.color = color\n if (kind) node.kind = kind\n if (raw.folded === true) node.folded = true\n if (Array.isArray(raw.children)) {\n const children = raw.children.flatMap((child) => TreeData.node(child, seen) ?? [])\n if (children.length) node.children = children\n }\n return node\n }\n\n /**\n * Name of a diagram of `tree`, through `text` (the component's translated texts):\n * \"Tree: If, with 3 children\".\n */\n static summary(\n tree: TreeDiagramNode,\n text: (key: TreeDiagramSummaryKey, params: Record<string, string | number>) => string\n ): string {\n const count = tree.children?.length ?? 0\n const key = count === 0 ? \"summaryLeaf\" : count === 1 ? \"summaryOne\" : \"summary\"\n return text(key, { label: tree.label, count })\n }\n\n /** `value` as text: a string as is, a number or boolean written out, anything else `undefined`. */\n private static text(value: unknown): string | undefined {\n if (typeof value === \"string\") return value\n if (typeof value === \"number\" || typeof value === \"boolean\") return String(value)\n return undefined\n }\n}\n\n/** Keys of the texts that name a diagram: its root has children, one child, none. */\nexport type TreeDiagramSummaryKey = \"summary\" | \"summaryOne\" | \"summaryLeaf\"\n","/**\n * The types and constants of the tree diagram family: the data contract (`TreeDiagramNode`),\n * the layout's shapes and its metrics, shared by `TreeLayout`, `TreeData` and the component.\n * - Data only: nothing here runs.\n * - GENERIC: any tree from plain data. Spell's parse trees are one caller (docs pages, the app's editor, VS Code);\n * `ui` never imports spell or the parser.\n */\n\n////////////////\n// ## The data contract\n////////////////\n\n/** One node of a tree `<ui-tree-diagram>` draws. */\nexport type TreeDiagramNode = {\n /** The box's text, e.g. `If`, `Variable number`, `Number 15`. */\n label: string\n /** A second, smaller, muted line under the label, e.g. a datatype `number`; none: one line. */\n detail?: string\n /** Text on the line from its parent, e.g. `condition`, `body`, `otherwise`. JSON may say `slot`, its old name. */\n edgeLabel?: string\n /** Hover text (an SVG `<title>`), e.g. the source it came from. */\n title?: string\n /** Its box's colour, a hue of the theme's: `green`, `blue` ... */\n color?: string\n /** A word for what sort of node it is: its box is also part `kind-<word>`, for a page's own style. */\n kind?: string\n /** Starts folded: the nodes under it don't show. */\n folded?: boolean\n /** The `<ui-tree-node>` that wrote it; none for a tree from JSON. */\n element?: Element\n /** Its children, left to right. */\n children?: TreeDiagramNode[]\n}\n\n////////////////\n// ## Layout\n////////////////\n\n/** A point in the diagram's user units (its `viewBox`). */\nexport type TreeDiagramPoint = {\n readonly x: number\n readonly y: number\n}\n\n/** One node's box, placed: user units, `x` / `y` its TOP LEFT corner. */\nexport type TreeDiagramBox = {\n /** The node it draws. */\n readonly node: TreeDiagramNode\n /** Its depth: `0` for the root. */\n readonly depth: number\n /** Where it is in the tree: its child index at each depth, `0.2.1`; `0` for the root. */\n readonly path: string\n readonly x: number\n readonly y: number\n readonly width: number\n /** Every box in a level is as long along the tree as its longest, so edges leave a level at one place. */\n readonly height: number\n /** Where its lines leave it, and its fold button sits. */\n readonly exit: TreeDiagramPoint\n /** Where the label's line is centred (`dominant-baseline: central`). */\n readonly label: TreeDiagramPoint\n /** Where the detail's line is centred; none without a `detail`. */\n readonly detail?: TreeDiagramPoint\n /** What the node holds besides its text, centred at `x`, `y`; none when nothing. */\n readonly content?: TreeDiagramPoint & { readonly width: number; readonly height: number }\n /** How many children its node has, folded or not; none for a leaf. */\n readonly childCount?: number\n /** It's folded: the nodes under it aren't drawn. */\n readonly isFolded?: boolean\n}\n\n/** An edge label, placed: centred on its edge's midpoint, `width` x `height` the box the edge leaves clear. */\nexport type TreeDiagramEdgeLabel = {\n readonly text: string\n /** Centre. */\n readonly x: number\n readonly y: number\n readonly width: number\n readonly height: number\n}\n\n/** One parent => child line, from where it leaves the parent to where it reaches the child. */\nexport type TreeDiagramEdge = {\n readonly from: TreeDiagramPoint\n readonly to: TreeDiagramPoint\n /** The child's `edgeLabel`, at the line's midpoint. */\n readonly label?: TreeDiagramEdgeLabel\n /**\n * The stretch of the line NOT drawn, under the edge label: the line stops at `gap.from`, starts again at `gap.to`.\n */\n readonly gap?: { readonly from: TreeDiagramPoint; readonly to: TreeDiagramPoint }\n}\n\n/** A tree laid out: what `<ui-tree-diagram>` draws, in user units. */\nexport type TreeDiagramLayout = {\n /** Natural size: the `viewBox`. */\n readonly width: number\n readonly height: number\n /** Every node's box, depth first (the root first). */\n readonly boxes: readonly TreeDiagramBox[]\n /** Every parent => child line, in the same order as the children's boxes: `edges[i]` leads to `boxes[i + 1]`. */\n readonly edges: readonly TreeDiagramEdge[]\n}\n\n/** Which way a tree grows. Above the options: the vocabulary lists them. */\nexport const TreeDiagramDirections = [\"top-down\", \"left-right\"] as const\n\n/** One of `TreeDiagramDirections`. */\nexport type TreeDiagramDirection = (typeof TreeDiagramDirections)[number]\n\n/** A node's sizes, in user units, as measured (`TreeMeasure`): what's left out, `TreeLayout` estimates. */\nexport type TreeDiagramNodeSize = {\n readonly labelWidth?: number\n readonly detailWidth?: number\n readonly edgeLabelWidth?: number\n /** What it holds besides its text. */\n readonly contentWidth?: number\n readonly contentHeight?: number\n}\n\n/** What `TreeLayout` is told besides the tree. */\nexport type TreeDiagramLayoutOptions = {\n /** Sizes it works in. Default: `TREE_DIAGRAM_METRICS`. */\n metrics?: TreeDiagramMetrics\n /** Which way it grows. Default: `top-down`. */\n direction?: TreeDiagramDirection\n /** Each node's measured sizes, by the node. Default: all estimated. */\n sizes?: ReadonlyMap<TreeDiagramNode, TreeDiagramNodeSize>\n /** The nodes drawn as leaves. Default: none. */\n folded?: ReadonlySet<TreeDiagramNode>\n}\n\n/**\n * Sizes the layout works in, in USER UNITS (the `viewBox`'s): the label font is `fontSize` units,\n * and the sheet sets the `<svg>`'s width to `width / fontSize` em, so one label `em` on the page is `fontSize` units\n * here.\n * - Text widths are measured in a browser (`TreeMeasure`). `charWidth` and `edgeLabelCharWidth` are only for a static\n * server render, with nothing to measure with: over-estimates, so labels never overflow or collide.\n */\nexport const TREE_DIAGRAM_METRICS = {\n /** The label's font size; 1em on the page. */\n fontSize: 12,\n /** The detail line's font size. */\n detailFontSize: 10,\n /** The edge label's font size. */\n edgeLabelFontSize: 10,\n /** Estimated advance of one label character, per font size: a monospace font's, wider than a proportional one's. */\n charWidth: 0.6,\n /** Estimated advance of one edge label character, per font size. */\n edgeLabelCharWidth: 0.56,\n /** Line height, per font size. */\n lineHeight: 1.25,\n /** Space left and right of a box's text. */\n paddingX: 10,\n /** Space above and below a box's text. */\n paddingY: 6,\n /** The narrowest box. */\n minBoxWidth: 32,\n /** Space between one row's boxes and the next row's. */\n levelGap: 36,\n /** Least space between two boxes (or edge labels) side by side. */\n siblingGap: 14,\n /** Space kept clear left and right of an edge label's text. */\n edgeLabelPaddingX: 4,\n /** Space kept clear above and below an edge label's text. */\n edgeLabelPaddingY: 2,\n /** Space around the whole drawing: room for the root's thicker border. */\n margin: 2\n} as const\n\n/** Sizes `TreeLayout` works in: `TREE_DIAGRAM_METRICS`, or a test's own. */\nexport type TreeDiagramMetrics = { readonly [K in keyof typeof TREE_DIAGRAM_METRICS]: number }\n","import {\n TREE_DIAGRAM_METRICS,\n type TreeDiagramBox,\n type TreeDiagramDirection,\n type TreeDiagramEdge,\n type TreeDiagramEdgeLabel,\n type TreeDiagramLayout,\n type TreeDiagramLayoutOptions,\n type TreeDiagramMetrics,\n type TreeDiagramNode,\n type TreeDiagramNodeSize,\n type TreeDiagramPoint\n} from \"./UITreeDiagram.types\"\n\n/****************\n * ### `TreeLayout`\n * A tree laid out as `<ui-tree-diagram>` draws it, top-down or left to right: `TreeLayout.of(tree, options)`.\n * - PURE: numbers in, numbers out, no DOM, no Solid; so the maths is tested alone, and the same tree always gets\n * the same layout.\n * - Two axes, so one algorithm does both directions:\n * - the MAIN axis runs from parent to child: down, or to the right\n * - the CROSS axis runs between siblings: across, or down\n * - Levels: each depth is a level; every box in a level is as long on the main axis as its longest, so edges leave a\n * level at one place and every edge label between two levels sits at one place.\n * - Tidy: a parent is centred over its first and last child; sibling subtrees are pushed apart, depth by depth,\n * until no two boxes of the same level are closer than `siblingGap` (contours, after Reingold-Tilford).\n * - Small subtrees between two big ones spread evenly, rather than packing against the left one:\n * Reingold-Tilford's \"apportion\" step, as Buchheim and Walker tell it (`spreadBetween()`).\n * - Edge labels sit at their edge's midpoint, and the edge stops under them (`gap`).\n * A node's FOOTPRINT, what its level keeps clear, is its box or twice its edge label, whichever is wider:\n * so no edge label ever overlaps another, nor another edge (sibling's or cousin's), and no line runs under text.\n * - Sizes: each node's real ones, measured by whoever has a DOM and handed in (`options.sizes`, `TreeMeasure`).\n * What's not handed in is estimated from character counts (`TreeDiagramMetrics`): a static server render's case.\n * - A folded node is drawn as a leaf (`options.folded`).\n ****************/\nexport class TreeLayout {\n /** Sizes it works in. */\n readonly metrics: TreeDiagramMetrics\n /** Which way it grows. */\n readonly direction: TreeDiagramDirection\n /** The measured sizes: none, all estimated. */\n readonly sizes: ReadonlyMap<TreeDiagramNode, TreeDiagramNodeSize> | undefined\n /** The nodes drawn as leaves. */\n readonly folded: ReadonlySet<TreeDiagramNode> | undefined\n\n constructor(options: TreeDiagramLayoutOptions = {}) {\n this.metrics = options.metrics ?? TREE_DIAGRAM_METRICS\n this.direction = options.direction ?? \"top-down\"\n this.sizes = options.sizes\n this.folded = options.folded\n }\n\n /** `tree` laid out, in user units (`TREE_DIAGRAM_METRICS`, unless `options.metrics` says otherwise). NEVER throws. */\n static of(tree: TreeDiagramNode, options?: TreeDiagramLayoutOptions): TreeDiagramLayout {\n return new TreeLayout(options).layout(tree)\n }\n\n /** `tree` laid out. */\n layout(tree: TreeDiagramNode): TreeDiagramLayout {\n const { margin, levelGap } = this.metrics\n const root = this.measure(tree, 0, ROOT_PATH)\n const levelLengths: number[] = []\n // room each level leaves before it, for an edge label laid along the main axis\n const gaps: number[] = []\n TreeLayout.visit(root, (node) => {\n levelLengths[node.depth] = Math.max(levelLengths[node.depth] ?? 0, node.mainLength)\n gaps[node.depth] = Math.max(gaps[node.depth] ?? levelGap, this.gapFor(node))\n })\n const levelStarts = [margin]\n for (let depth = 1; depth < levelLengths.length; depth++)\n levelStarts[depth] = levelStarts[depth - 1]! + levelLengths[depth - 1]! + gaps[depth]!\n this.place(root)\n // centres, from the root at 0, then shifted so the first thing drawn starts at the margin\n const centres = new Map<Measured, number>([[root, 0]])\n TreeLayout.visit(root, (node) => {\n for (const child of node.children) centres.set(child, centres.get(node)! + child.offset)\n })\n let low = Infinity\n let high = -Infinity\n TreeLayout.visit(root, (node) => {\n const centre = centres.get(node)!\n low = Math.min(low, centre - node.crossLength / 2)\n high = Math.max(high, centre + node.crossLength / 2)\n for (const child of node.children) {\n if (!child.edgeLabel) continue\n const middle = (centre + centres.get(child)!) / 2\n low = Math.min(low, middle - child.edgeLabelCross / 2)\n high = Math.max(high, middle + child.edgeLabelCross / 2)\n }\n })\n const shift = margin - low\n const boxes: TreeDiagramBox[] = []\n const edges: TreeDiagramEdge[] = []\n TreeLayout.visit(root, (node, parent) => {\n const cross = centres.get(node)! + shift\n const start = levelStarts[node.depth]!\n boxes.push(this.box(node, cross, start, levelLengths[node.depth]!))\n if (!parent) return\n const from = this.point(levelStarts[parent.depth]! + levelLengths[parent.depth]!, centres.get(parent)! + shift)\n edges.push(this.edge(node, from, this.point(start, cross)))\n })\n const last = levelLengths.length - 1\n const crossTotal = TreeLayout.round(high - low + 2 * margin)\n const mainTotal = TreeLayout.round(levelStarts[last]! + levelLengths[last]! + margin)\n return {\n width: this.isTopDown ? crossTotal : mainTotal,\n height: this.isTopDown ? mainTotal : crossTotal,\n boxes,\n edges\n }\n }\n\n ////////////////\n // ## Measuring\n ////////////////\n\n /** Does it grow downward? Else to the right. */\n private get isTopDown(): boolean {\n return this.direction === \"top-down\"\n }\n\n /** `node` and its subtree, sized: box, edge label, footprint. */\n private measure(node: TreeDiagramNode, depth: number, path: string): Measured {\n const { fontSize, detailFontSize, edgeLabelFontSize, charWidth, edgeLabelCharWidth, lineHeight } = this.metrics\n const { paddingX, paddingY, minBoxWidth, edgeLabelPaddingX, edgeLabelPaddingY } = this.metrics\n const size = this.sizes?.get(node)\n const labelWidth = size?.labelWidth ?? TreeLayout.chars(node.label) * charWidth * fontSize\n const detailWidth = node.detail\n ? (size?.detailWidth ?? TreeLayout.chars(node.detail) * charWidth * detailFontSize)\n : 0\n const contentWidth = size?.contentWidth ?? 0\n const contentHeight = size?.contentHeight ?? 0\n const width = Math.max(minBoxWidth, Math.max(labelWidth, detailWidth, contentWidth) + 2 * paddingX)\n const labelLine = node.label || !contentHeight ? fontSize * lineHeight : 0\n const detailLine = node.detail ? detailFontSize * lineHeight : 0\n const height = 2 * paddingY + labelLine + detailLine + contentHeight\n const edgeLabel = node.edgeLabel || undefined\n const edgeLabelWidth = edgeLabel\n ? (size?.edgeLabelWidth ?? TreeLayout.chars(edgeLabel) * edgeLabelCharWidth * edgeLabelFontSize) +\n 2 * edgeLabelPaddingX\n : 0\n const edgeLabelHeight = edgeLabel ? edgeLabelFontSize * lineHeight + 2 * edgeLabelPaddingY : 0\n const edgeLabelCross = this.isTopDown ? edgeLabelWidth : edgeLabelHeight\n const crossLength = this.isTopDown ? width : height\n const isFolded = !!this.folded?.has(node)\n return {\n node,\n depth,\n path,\n width,\n height,\n labelLine,\n detailLine,\n contentWidth,\n contentHeight,\n crossLength,\n mainLength: this.isTopDown ? height : width,\n edgeLabel,\n edgeLabelWidth,\n edgeLabelHeight,\n edgeLabelCross,\n footprint: Math.max(crossLength, 2 * edgeLabelCross),\n isFolded,\n children: isFolded\n ? []\n : (node.children ?? []).map((child, index) => this.measure(child, depth + 1, `${path}.${index}`)),\n offset: 0\n }\n }\n\n /**\n * The room `node`'s level leaves before it: `levelGap`, or across a left-to-right tree its edge label's width.\n * - A top-down tree's label is short across the gap, and `levelGap` is always room enough.\n */\n private gapFor(node: Measured): number {\n return this.isTopDown ? this.metrics.levelGap : node.edgeLabelWidth + LABEL_LEAD\n }\n\n /**\n * Characters in `text`, for an estimate: code points, so an emoji or accented letter counts once.\n * - NOTE: wide (CJK) characters count one.\n */\n private static chars(text: string): number {\n return Array.from(text).length\n }\n\n ////////////////\n // ## Placing\n ////////////////\n\n /**\n * Place `node`'s children (each child's `offset` from `node`'s centre), and return `node`'s subtree's contour:\n * per depth below it (`0` = its own level), the nearest and farthest edge of any footprint, from its centre.\n * - Children are placed in order, each as close to the ones before it as their contours allow;\n * the ones it had to jump over spread evenly in the room that opens (`spreadBetween()`);\n * then `node` is centred over its first and last child.\n */\n private place(node: Measured): Contour {\n const half = node.footprint / 2\n if (!node.children.length) return { low: [-half], high: [half] }\n const contours = node.children.map((child) => this.place(child))\n const offsets = [0]\n for (let index = 1; index < contours.length; index++) {\n let needed = -Infinity\n let blocker = index - 1\n let neededByPrevious = -Infinity\n for (let earlier = index - 1; earlier >= 0; earlier--) {\n const distance = offsets[earlier]! + this.clearance(contours[earlier]!, contours[index]!)\n if (earlier === index - 1) neededByPrevious = distance\n if (distance > needed) {\n needed = distance\n blocker = earlier\n }\n }\n offsets[index] = needed\n TreeLayout.spreadBetween(offsets, blocker, index, needed - neededByPrevious)\n }\n const centre = (offsets[0]! + offsets[offsets.length - 1]!) / 2\n for (const [index, child] of node.children.entries()) child.offset = offsets[index]! - centre\n const merged: Contour = { low: [], high: [] }\n for (const [index, contour] of contours.entries()) {\n const at = offsets[index]! - centre\n for (let depth = 0; depth < contour.low.length; depth++) {\n merged.low[depth] = Math.min(merged.low[depth] ?? Infinity, contour.low[depth]! + at)\n merged.high[depth] = Math.max(merged.high[depth] ?? -Infinity, contour.high[depth]! + at)\n }\n }\n return { low: [-half, ...merged.low], high: [half, ...merged.high] }\n }\n\n /** How far past `before`'s centre `after`'s must be, for the two never to come closer than `siblingGap`. */\n private clearance(before: Contour, after: Contour): number {\n let distance = -Infinity\n const shared = Math.min(before.high.length, after.low.length)\n for (let depth = 0; depth < shared; depth++)\n distance = Math.max(distance, before.high[depth]! - after.low[depth]! + this.metrics.siblingGap)\n return distance\n }\n\n /**\n * The apportion step: subtree `last` was pushed `room` further than the one before it needed, because it hit\n * subtree `first`; the small ones between share that room evenly.\n * - Each moves right by its share of `room`, so each only gets further from the ones before it,\n * and none reaches `last`: the one before it had `room` to spare, and moves less than that.\n */\n private static spreadBetween(offsets: number[], first: number, last: number, room: number) {\n const between = last - first\n if (between < 2 || room <= 0) return\n for (let index = first + 1; index < last; index++) offsets[index]! += (room * (index - first)) / between\n }\n\n ////////////////\n // ## Output\n ////////////////\n\n /** The point `main` along the main axis, `cross` along the cross axis. */\n private point(main: number, cross: number): TreeDiagramPoint {\n return this.isTopDown ? { x: cross, y: main } : { x: main, y: cross }\n }\n\n /**\n * `node`'s box, centred on `cross`, in the level from `start`, `length` long on the main axis:\n * its label, detail and content stacked, and centred in it.\n */\n private box(node: Measured, cross: number, start: number, length: number): TreeDiagramBox {\n const { labelLine, detailLine, contentHeight, contentWidth } = node\n const width = this.isTopDown ? node.width : length\n const height = this.isTopDown ? length : node.height\n const x = this.isTopDown ? cross - width / 2 : start\n const y = this.isTopDown ? start : cross - height / 2\n const middle = x + width / 2\n const textTop = y + (height - labelLine - detailLine - contentHeight) / 2\n const round = TreeLayout.round\n const { point: at } = TreeLayout\n const childCount = node.node.children?.length ?? 0\n return {\n node: node.node,\n depth: node.depth,\n path: node.path,\n x: round(x),\n y: round(y),\n width: round(width),\n height: round(height),\n exit: at(this.isTopDown ? { x: middle, y: y + height } : { x: x + width, y: y + height / 2 }),\n label: at({ x: middle, y: textTop + labelLine / 2 }),\n ...(node.node.detail && { detail: at({ x: middle, y: textTop + labelLine + detailLine / 2 }) }),\n ...(contentHeight > 0 && {\n content: {\n ...at({ x: middle, y: textTop + labelLine + detailLine + contentHeight / 2 }),\n width: round(contentWidth),\n height: round(contentHeight)\n }\n }),\n ...(childCount > 0 && { childCount }),\n ...(node.isFolded && childCount > 0 && { isFolded: true })\n }\n }\n\n /**\n * The line from `from` (the parent's exit) to `to` (`child`'s entrance), with `child`'s edge label at\n * its midpoint and the stretch under the label left out.\n */\n private edge(child: Measured, from: TreeDiagramPoint, to: TreeDiagramPoint): TreeDiagramEdge {\n const { point } = TreeLayout\n if (!child.edgeLabel) return { from: point(from), to: point(to) }\n const dx = to.x - from.x\n const dy = to.y - from.y\n const middle = { x: from.x + dx / 2, y: from.y + dy / 2 }\n const width = child.edgeLabelWidth\n const height = child.edgeLabelHeight\n // the line meets the label's box at its side or its top / bottom, whichever comes first\n const reach = Math.min(dx ? width / 2 / Math.abs(dx) : Infinity, dy ? height / 2 / Math.abs(dy) : Infinity, 0.5)\n const label: TreeDiagramEdgeLabel = {\n text: child.edgeLabel,\n ...point(middle),\n width: TreeLayout.round(width),\n height: TreeLayout.round(height)\n }\n const gap = {\n from: point({ x: middle.x - reach * dx, y: middle.y - reach * dy }),\n to: point({ x: middle.x + reach * dx, y: middle.y + reach * dy })\n }\n return { from: point(from), to: point(to), label, gap }\n }\n\n /** `value` to 2 decimals: short, stable markup. */\n private static round(value: number): number {\n return Math.round(value * 100) / 100\n }\n\n /** `point`, rounded. */\n private static point(point: TreeDiagramPoint): TreeDiagramPoint {\n return { x: TreeLayout.round(point.x), y: TreeLayout.round(point.y) }\n }\n\n /** Call `visit` on `node`, then on each node below it, depth first; with each one's parent. */\n private static visit(node: Measured, visit: (node: Measured, parent?: Measured) => void, parent?: Measured) {\n visit(node, parent)\n for (const child of node.children) TreeLayout.visit(child, visit, node)\n }\n}\n\n/** The root's `path`; a child's adds its index, `0.2.1`. */\nconst ROOT_PATH = \"0\"\n\n/** Least room left and right of an edge label across a left-to-right tree's gap, together. */\nconst LABEL_LEAD = 24\n\n/** A node, sized, while it's laid out. */\ntype Measured = {\n readonly node: TreeDiagramNode\n readonly depth: number\n readonly path: string\n /** The box's own width. */\n readonly width: number\n /** The box's own height. */\n readonly height: number\n /** Height of its label's line; `0` for a node that's content alone. */\n readonly labelLine: number\n /** Height of its detail's line; `0` without one. */\n readonly detailLine: number\n readonly contentWidth: number\n readonly contentHeight: number\n /** The box along the cross axis. */\n readonly crossLength: number\n /** The box along the main axis: drawn as long as its level. */\n readonly mainLength: number\n /** Its edge label's text, when it has one. */\n readonly edgeLabel: string | undefined\n /** Its edge label's box, padding included; `0` without one. */\n readonly edgeLabelWidth: number\n readonly edgeLabelHeight: number\n /** Its edge label's box along the cross axis. */\n readonly edgeLabelCross: number\n /** What its level keeps clear: the box, or twice the edge label, whichever is longer. */\n readonly footprint: number\n /** Drawn as a leaf, though it may have children. */\n readonly isFolded: boolean\n readonly children: Measured[]\n /** Its centre, from its parent's; set by `place()`. */\n offset: number\n}\n\n/**\n * A subtree's outline: per depth below its root, its nearest and farthest footprint edge, from the root's centre.\n */\ntype Contour = {\n low: number[]\n high: number[]\n}\n","/**\n * The English vocabulary of `<ui-tree-diagram>`: every name the tag uses.\n * - Its tag, attributes (each with its kind and allowed values), parts and texts.\n * The shape is `ComponentVocabulary` (`spell/ui/vocabulary`).\n * - Ours, not Fomantic's: first drawn for spell's parse trees, but GENERIC.\n * - One rich property, `tree` (a `TreeDiagramNode`, `UITreeDiagram.types.ts`);\n * a static page gives it as a `<ui-json>` or `<script type=\"application/json\">` child instead.\n * - No class words: the class grammar is `ui tree diagram`, plus `empty` with nothing to draw.\n */\n\nimport type { ComponentVocabulary } from \"spell/ui/vocabulary\"\nimport { TreeDiagramDirections } from \"./UITreeDiagram.types\"\n\n/****************\n * ### `treeDiagramVocabulary`\n * The names of `<ui-tree-diagram>`, a tree drawn as an SVG:\n * `<svg class=\"ui tree diagram\" part=\"diagram\" role=\"img\" aria-label>`.\n ****************/\nexport const treeDiagramVocabulary = {\n tag: \"ui-tree-diagram\",\n icon: \"project diagram\",\n topics: [\"data display\", \"images\", \"views\"],\n aka: [\n \"tree\",\n \"tree chart\",\n \"hierarchy\",\n \"hierarchy diagram\",\n \"org chart\",\n \"parse tree\",\n \"syntax tree\",\n \"AST\",\n \"dendrogram\"\n ],\n skeleton: \"12 tall\",\n noun: \"tree diagram\",\n partOfSpeech: \"structure\",\n description:\n \"A tree diagram draws a tree: a box for each node, a line to each of its children. Write it as nested tags or as JSON.\",\n attributes: [\n {\n name: \"tree\",\n group: \"content\",\n kind: \"json\",\n reflect: false,\n description:\n \"The tree to draw, a `TreeDiagramNode`: `label`, and optional `detail`, `edgeLabel`, `title`, `color`, `kind`, `folded` and `children`. A \" +\n 'JS property (JSON in the attribute); wins over `<ui-tree-node>`, `<ui-json>` or `<script type=\"application/json\">` children. Set a NEW ' +\n \"tree to redraw.\"\n },\n {\n name: \"direction\",\n group: \"layout\",\n kind: \"enum\",\n values: TreeDiagramDirections,\n default: \"top-down\",\n description: \"Which way it grows: `top-down`, children under their parent, or `left-right`, children after it.\"\n },\n {\n name: \"foldable\",\n group: \"behaviour\",\n kind: \"boolean\",\n description:\n \"A node with children gets a button that folds them away, and opens them again; `ui-node-toggled` says so.\"\n },\n {\n name: \"clickable\",\n group: \"behaviour\",\n kind: \"boolean\",\n description:\n \"Its nodes look clickable and can be reached by keyboard: Enter or Space sends `ui-node-clicked`, as a click does.\"\n }\n ],\n events: [\n {\n name: \"ui-node-clicked\",\n detail: \"{ node: { label: string, element?: Element }, path: string, originalEvent: Event }\",\n description:\n \"A node was clicked, with or without `clickable`. `path` is its place, its child index at each depth: `0.2.1`. \" +\n \"A nested tag's node has its `element`.\"\n },\n {\n name: \"ui-node-toggled\",\n detail: \"{ node: { label: string, element?: Element }, path: string, folded: boolean, originalEvent: Event }\",\n description: \"A person folded a node, or opened it again.\"\n }\n ],\n slots: [{ name: \"\", description: \"The tree's root, a `<ui-tree-node>`, with the nodes under it inside it.\" }],\n parts: [\n { name: \"diagram\", description: \"The `<svg>`.\" },\n { name: \"node\", description: \"Each node's `<g>`: its box, label and detail.\" },\n { name: \"root-node\", description: \"The root's `<g>`, also part `node`.\" },\n { name: \"edge\", description: \"Each line from a parent to a child.\" },\n { name: \"edge-label\", description: \"Each edge label, on its line.\" },\n { name: \"toggle\", description: \"Each fold button, with `foldable`.\" }\n ],\n states: [],\n texts: [\n {\n key: \"summary\",\n text: \"Tree: {label}, with {count} children\",\n description: \"Name of a tree whose root has children.\"\n },\n {\n key: \"summaryOne\",\n text: \"Tree: {label}, with 1 child\",\n description: \"Name of a tree whose root has one child.\"\n },\n { key: \"summaryLeaf\", text: \"Tree: {label}\", description: \"Name of a tree of one node.\" },\n { key: \"foldNode\", text: \"Fold {label}\", description: \"A fold button's name, while the node's open.\" },\n { key: \"unfoldNode\", text: \"Open {label}\", description: \"A fold button's name, while the node's folded.\" }\n ]\n} as const satisfies ComponentVocabulary\n","/**\n * The English vocabulary of `<ui-tree-node>`: every name the tag uses.\n * - Its tag, attributes (each with its kind and allowed values) and parts.\n * The shape is `E.ComponentVocabulary` (`spell/ui/vocabulary`).\n * - Ours, not Fomantic's (epic `elemental-spell` P32).\n * - No class words: the class grammar is `ui tree node`, on the box around its content.\n */\n\nimport type { E } from \"spell/ui/core\"\n\n/****************\n * ### `treeNodeVocabulary`\n * The names of `<ui-tree-node>`, one node of a `<ui-tree-diagram>`, holding the nodes under it as its children.\n ****************/\nexport const treeNodeVocabulary = {\n tag: \"ui-tree-node\",\n icon: \"circle outline\",\n topics: [\"data display\", \"images\"],\n aka: [\"diagram node\", \"tree diagram node\", \"org chart box\", \"node\"],\n noun: \"tree node\",\n partOfSpeech: \"structure\",\n description:\n \"A tree node is one box of a tree diagram: its label, and the nodes under it as its children. Its text is its \" +\n \"label; any other element inside it shows in its box.\",\n attributes: [\n { name: \"label\", group: \"content\", kind: \"string\", description: \"The box's text. None: the node's own text.\" },\n {\n name: \"detail\",\n group: \"content\",\n kind: \"string\",\n description: \"A second, smaller, muted line under the label, e.g. a datatype.\"\n },\n {\n name: \"edge-label\",\n group: \"content\",\n kind: \"string\",\n property: \"edgeLabel\",\n description: \"Text on the line from its parent, e.g. `condition`: which part of its parent it is.\"\n },\n {\n name: \"hover-text\",\n group: \"content\",\n kind: \"string\",\n property: \"hoverText\",\n description: \"What shows when the pointer rests on its box, e.g. the source it came from.\"\n },\n {\n name: \"color\",\n group: \"appearance\",\n kind: \"enum\",\n values: \"hues\",\n description: \"The box's colour: its fill and border, in that hue.\"\n },\n {\n name: \"kind\",\n group: \"appearance\",\n kind: \"string\",\n description:\n \"A word for what sort of node it is, for a page's own style: its box is also part `kind-<word>`, so \" +\n \"`::part(kind-call)` reaches every node of that kind.\"\n },\n {\n name: \"folded\",\n group: \"behaviour\",\n kind: \"boolean\",\n description: \"Starts folded: the nodes under it don't show. A `foldable` diagram can open it again.\"\n }\n ],\n events: [],\n slots: [{ name: \"\", description: \"What shows in its box, besides its label; and the `<ui-tree-node>`s under it.\" }],\n parts: [{ name: \"content\", description: \"The box around what it holds, placed over the node's box in the drawing.\" }],\n states: [],\n texts: []\n} as const satisfies E.ComponentVocabulary\n","import type { JSX } from \"@solidjs/web\"\n\nimport { E, UI } from \"spell/ui/core\"\nimport { treeNodeVocabulary } from \"./UITreeNode.en\"\nimport type { TreeDiagramNode } from \"./UITreeDiagram.types\"\n\nimport treeNodeCSS from \"./UITreeNode.css?inline\"\n\n/**\n * What a `<ui-tree-node>` tells its diagram when what it holds changes size: plumbing, like the platform's `slotchange`.\n * - Bubbles to the diagram, which measures again.\n */\nexport const TREE_NODE_RESIZED = \"ui-tree-node-resized\"\n\n/** A `<ui-tree-node>` DOM element, typed. */\nexport type DOMTreeNodeElement = E.DOMElement<UITreeNode>\n\n/****************\n * ### `<ui-tree-node>`\n * The component behind `<ui-tree-node>`: one node of a `<ui-tree-diagram>` written as nested tags (epic\n * `elemental-spell` P32).\n *\n * <div class=\"ui tree node\" part=\"content\"><slot/></div> (what it holds, over its box in the drawing)\n * <slot/> (the nodes under it)\n *\n * - It draws no box: the diagram reads it into plain data (`nodeFrom()`), and draws it with the rest of the tree.\n * - Its own text is its label, unless `label` says.\n * - Any other element inside it shows over its box: a real element, in the page, so it keeps its state and events.\n * - The diagram measures it (`contentSize`), leaves room in the box, and says where it goes (`placement`).\n * - Slots by hand (`slotAssignment` `\"manual\"`, the platform's): the same children, split into two slots.\n ****************/\nexport class UITreeNode extends E.UIComponent<typeof treeNodeVocabulary> {\n @E.proto static vocabulary = treeNodeVocabulary\n @E.protoMerged static elementSetup = {\n styleSheets: { \"tree-node\": treeNodeCSS },\n delegatesFocus: false,\n slotAssignment: \"manual\" as const\n } satisfies Partial<E.ElementSetup>\n\n /** Where the diagram put what it holds, in percent of the drawing; `undefined`: not shown (it's folded away). */\n @E.state accessor placement: TreeNodePlacement | undefined = undefined\n\n /** The children it was given: nodes and everything else. */\n @E.watches({ childList: true })\n get children(): readonly ChildNode[] {\n return [...this.domElement.childNodes]\n }\n\n /** The nodes under it. */\n get nodeChildren(): Element[] {\n return this.children.filter((child): child is Element => UITreeNode.isNode(child))\n }\n\n /** What shows in its box, besides its label: nothing when it's only text, which is its label. */\n get contentChildren(): ChildNode[] {\n return UITreeNode.contentOf(this.domElement)\n }\n\n /** The box around what it holds. */\n private contentBox: HTMLElement | undefined\n private contentSlot: HTMLSlotElement | undefined\n private nodesSlot: HTMLSlotElement | undefined\n\n /** What it holds in pixels, before the drawing's scale; `undefined` when it holds nothing, or it isn't laid out. */\n get contentSize(): { width: number; height: number } | undefined {\n const box = this.contentBox\n if (!box || !this.contentChildren.length || !box.offsetWidth) return undefined\n return { width: box.offsetWidth, height: box.offsetHeight }\n }\n\n /** Hand each child to its slot; what it holds may have changed size. */\n @E.onChange(\"children\", \"isReady\")\n protected onChildrenChanged(_children: readonly ChildNode[], isReady: boolean) {\n if (!isReady) return\n this.contentSlot?.assign(...(this.contentChildren as (Element | Text)[]))\n this.nodesSlot?.assign(...this.nodeChildren)\n this.domElement.dispatchEvent(new Event(TREE_NODE_RESIZED, { bubbles: true }))\n }\n\n /** While it's in the page: says when what it holds changes size (an image loads, a closed section opens). */\n @E.onChange(\"isConnected\", \"isReady\")\n protected watchContentSize(isConnected: boolean, isReady: boolean) {\n const box = this.contentBox\n if (!isConnected || !isReady || !box) return\n const observer = new ResizeObserver(() => {\n this.domElement.dispatchEvent(new Event(TREE_NODE_RESIZED, { bubbles: true }))\n })\n observer.observe(box)\n return () => observer.disconnect()\n }\n\n render(): JSX.Element {\n return (\n <>\n <div\n ref={(box: HTMLDivElement) => (this.contentBox = box)}\n class={[this.rootClass, { [PLACED]: !!this.placement }]}\n part={this.partForName(\"content\")}\n style={this.placementStyle()}\n >\n <slot ref={(slot: HTMLSlotElement) => (this.contentSlot = slot)} />\n </div>\n <slot ref={(slot: HTMLSlotElement) => (this.nodesSlot = slot)} />\n </>\n )\n }\n\n /** Where `placement` says. */\n private placementStyle(): JSX.CSSProperties | undefined {\n const placement = this.placement\n return placement && { left: `${placement.left}%`, top: `${placement.top}%` }\n }\n\n ////////////////\n // ## Reading nodes\n ////////////////\n\n /**\n * Is `child` a `<ui-tree-node>`, in any language?\n * - Before the runtime loads, the canonical tag only: the translations are its.\n * - By `localName`: a static server render's children are linkedom elements.\n */\n static isNode(child: Node): child is Element {\n if (child.nodeType !== ELEMENT_NODE) return false\n const name = (child as Element).localName\n return (\n name === treeNodeVocabulary.tag ||\n (\"vocabulary\" in UI && UI.vocabulary.canonicalTagFor(name) === treeNodeVocabulary.tag)\n )\n }\n\n /** The first `<ui-tree-node>` child of `domElement`: a diagram's root. */\n static firstNodeOf(domElement: Element): Element | undefined {\n return [...domElement.children].find((child) => UITreeNode.isNode(child))\n }\n\n /**\n * `element` and the nodes under it as plain data, what a diagram draws; each node keeps its `element`.\n * - NEVER throws.\n */\n static nodeFrom(element: Element): TreeDiagramNode {\n const value = (name: string) => {\n const found = UITreeNode.value(element, name)\n return typeof found === \"string\" && found ? found : undefined\n }\n const children = [...element.children].filter((child) => UITreeNode.isNode(child)).map(UITreeNode.nodeFrom)\n const color = value(\"color\")\n const kind = value(\"kind\")\n const detail = value(\"detail\")\n const edgeLabel = value(\"edge-label\")\n const title = value(\"hover-text\")\n return {\n label: value(\"label\") ?? UITreeNode.textOf(element),\n element,\n ...(detail && { detail }),\n ...(edgeLabel && { edgeLabel }),\n ...(title && { title }),\n ...(color && { color }),\n ...(kind && { kind }),\n ...(UITreeNode.isFolded(element) && { folded: true }),\n ...(children.length && { children })\n }\n }\n\n /** What `element` holds besides its nodes, when an element's among it: else nothing, its text being its label. */\n static contentOf(element: Element): ChildNode[] {\n const held = [...element.childNodes].filter(\n (child) =>\n !UITreeNode.isNode(child) &&\n (child.nodeType === ELEMENT_NODE || (child.nodeType === TEXT_NODE && !!child.textContent?.trim()))\n )\n return held.some((child) => child.nodeType === ELEMENT_NODE) ? held : []\n }\n\n /** `element`'s own text: its text children, not the nodes under it; `\"\"` when it holds an element too. */\n private static textOf(element: Element): string {\n if (UITreeNode.contentOf(element).length) return \"\"\n let text = \"\"\n for (const child of element.childNodes) if (child.nodeType === TEXT_NODE) text += child.textContent\n return text.trim().replace(/\\s+/g, \" \")\n }\n\n /** Is `element` written `folded`? */\n private static isFolded(element: Element): boolean {\n const value = UITreeNode.value(element, \"folded\")\n return value === true || value === \"\" || value === \"true\"\n }\n\n /**\n * Attribute `name` of `element`, by its canonical name; before its family loads, the attribute's text.\n * - NEVER throws: a pending element has no definition yet (`valueNamed()` throws then).\n */\n private static value(element: Element, name: string): string | boolean | undefined {\n try {\n const value = (element as Element & { valueNamed?: (name: string) => unknown }).valueNamed?.(name)\n if (value !== undefined) return value as string | boolean\n } catch {\n // pending: its text, below\n }\n return element.getAttribute(name) ?? undefined\n }\n}\n\n/** The vocabulary's attribute getters, typed (see \"Attributes\" in `UIComponent`). */\nexport interface UITreeNode extends E.AttributeValues<typeof treeNodeVocabulary> {}\n\n/** Where what a node holds goes, its centre, in percent of the drawing. */\nexport type TreeNodePlacement = {\n readonly left: number\n readonly top: number\n}\n\n/** Class word of a content box the diagram has placed. */\nconst PLACED = \"placed\"\n\n/** `Node.ELEMENT_NODE` and `Node.TEXT_NODE`: no DOM global in shared code (`AGENTS.md`, SSR). */\nconst ELEMENT_NODE = 1\nconst TEXT_NODE = 3\n","import { For, Show, type Accessor } from \"solid-js\"\nimport { isServer, type JSX } from \"@solidjs/web\"\n\nimport { E, UIT } from \"spell/ui/core\"\n// Import directly: a leaf of the JSON family, what it takes to read a child (WWOD §4 › \"The barrel\")\nimport { JSON_CHANGED, JsonChild } from \"spell/ui/components/ui-json/JsonChild\"\nimport { treeDiagramVocabulary } from \"./UITreeDiagram.en\"\nimport { TreeData } from \"./TreeData\"\nimport { TreeLayout } from \"./TreeLayout\"\nimport { TreeMeasure, type TreeMeasureSamples } from \"./TreeMeasure\"\nimport { TREE_NODE_RESIZED, UITreeNode, type DOMTreeNodeElement } from \"./UITreeNode\"\nimport {\n TREE_DIAGRAM_METRICS,\n type TreeDiagramBox,\n type TreeDiagramEdge,\n type TreeDiagramLayout,\n type TreeDiagramNode,\n type TreeDiagramNodeSize\n} from \"./UITreeDiagram.types\"\n\nimport treeDiagramCSS from \"./UITreeDiagram.css?inline\"\n\n/****************\n * ### `UITreeDiagram`\n * The component behind `<ui-tree-diagram>`: a tree drawn as an SVG, top-down or left to right,\n * with a box per node, a line from each parent to each child, and a label on the line.\n *\n * - GENERIC: it draws any tree from plain data (`TreeDiagramNode`).\n * It was first drawn for spell's parse trees, but `ui` never imports spell or the parser.\n * - The tree, first match wins:\n * 1. the `tree` property (`tree={tree}` in Solid)\n * 2. a `<ui-tree-node>` child, with the nodes nested inside it, followed as it changes\n * 3. the JSON of a `<ui-json>` child, or a `<script type=\"application/json\">` child (static pages, `file://` too),\n * followed as it changes; a `<ui-json source>` once it loads\n * - Invalid JSON draws nothing, and warns once.\n * - It redraws when `tree` is set again: set a NEW tree (one changed in place isn't seen).\n * - The steps from tree to drawing:\n * 1. `TreeMeasure`: each text's real width in its real font, and the size of what a node holds\n * 2. `TreeLayout` (pure): those numbers in, boxes and lines out\n * 3. this class draws them; what a node holds is placed over its box by the node (`placement`)\n * - Measured again when a web font arrives, when the fonts' tokens change, and when what a node holds changes size.\n * - A static server render has nothing to measure with: `TreeLayout` estimates from character counts.\n * - Size: drawn at its natural size in em (`--_ui-tree-diagram-natural-width`),\n * shrinking to fit its container down to `--ui-tree-diagram-min-scale`, and scrolling sideways below that.\n * - Nothing to draw: the `<svg>` is `ui empty tree diagram`, hidden; the DOM element has no height.\n * - Accessibility: the `<svg>` is `role=\"img\"`, named by a summary (\"Tree: If, with 3 children\");\n * each node's `title` is its box's `<title>` (hover text).\n * - `foldable` or `clickable` make it `role=\"group\"` under the same name, with real buttons to Tab to.\n * - Spell UI's other drawings of boxes and lines:\n * - `<ui-diagram>`: boxes in columns (the NERD drawing)\n * - `<ui-graph>`: any graph, in layers left to right, with ports, nested graphs, pan and zoom\n ****************/\nexport class UITreeDiagram extends E.UIComponent<typeof treeDiagramVocabulary> {\n @E.proto static vocabulary = treeDiagramVocabulary\n @E.protoMerged static elementSetup = {\n styleSheets: { \"tree-diagram\": treeDiagramCSS },\n delegatesFocus: false,\n slotAssignment: \"manual\" as const\n } satisfies Partial<E.ElementSetup>\n\n ////////////////\n // ## The tree\n ////////////////\n\n /**\n * Text of the JSON child, `<ui-json>` or `<script type=\"application/json\">`; `undefined` without one.\n * - Follows it as the page changes it.\n */\n @E.watches({ childList: true, characterData: true, subtree: true })\n get childText(): string | undefined {\n return isServer ? undefined : JsonChild.textOf(this.domElement)\n }\n\n /** Bumped when a `<ui-json>` child's data changes with no change in the page: its `source` loaded. */\n @E.state accessor childDataVersion = 0\n\n /** A `<ui-json>` child says its data changed. */\n @E.on(JSON_CHANGED)\n protected onChildDataChanged() {\n this.childDataVersion++\n }\n\n /**\n * The JSON child's tree; `undefined` without one, or when its JSON is invalid (warned once).\n * - `@derived`: parses JSON.\n */\n @E.derived\n get childTree(): TreeDiagramNode | undefined {\n const text = this.childText\n void this.childDataVersion\n if (text === undefined || isServer) return undefined\n return this.readChild(text)\n }\n\n /**\n * The nested `<ui-tree-node>`s, written out to compare; `undefined` without one.\n * - Follows them as the page changes them: readers hear only when something a tree holds moved.\n */\n @E.watches({ childList: true, characterData: true, attributes: true, subtree: true })\n get nodesText(): string | undefined {\n const root = UITreeNode.firstNodeOf(this.domElement)\n return root && JSON.stringify(UITreeNode.nodeFrom(root), (key, value) => (key === \"element\" ? undefined : value))\n }\n\n /**\n * The nested `<ui-tree-node>`s' tree; `undefined` without one.\n * - `@derived`: walks every node.\n */\n @E.derived\n get nodesTree(): TreeDiagramNode | undefined {\n if (this.nodesText === undefined) return undefined\n const root = UITreeNode.firstNodeOf(this.domElement)\n return root && UITreeNode.nodeFrom(root)\n }\n\n /**\n * The tree drawn: `tree` when it's a node, else the nested nodes', else the JSON child's; `undefined`: nothing\n * to draw.\n * - `@derived`: `TreeData.node()` copies the tree, checking every node.\n */\n @E.derived\n get drawnTree(): TreeDiagramNode | undefined {\n return TreeData.node(this.tree) ?? this.nodesTree ?? this.childTree\n }\n\n /** The JSON child's tree; invalid JSON warns (once per `text`, its text) and draws nothing. */\n private readChild(text: string): TreeDiagramNode | undefined {\n try {\n return TreeData.node(JsonChild.valueOf(this.domElement))\n } catch (error) {\n if (text !== this.warnedText)\n console.warn(`<${this.domElement.localName}>: invalid JSON in its script child`, error)\n this.warnedText = text\n return undefined\n }\n }\n\n /** Invalid JSON already warned about: a re-read of the same text stays quiet. */\n private warnedText: string | undefined\n\n ////////////////\n // ## Measuring\n ////////////////\n\n /** A text of each kind, in `<defs>`: what a real one's font comes to. Set as it draws. */\n private samples: Partial<TreeMeasureSamples> = {}\n /** The `<svg>`. Set as it draws. */\n private svg: SVGSVGElement | undefined\n /** A hidden line of label text: it changes size when the font does. */\n private fontSentinel: HTMLElement | undefined\n /** The `<slot>` the root `<ui-tree-node>` goes in. Set as it draws. */\n private nodesSlot: HTMLSlotElement | undefined\n\n /** Bumped when what was measured may have changed: it drew, a font arrived, what a node holds changed size. */\n @E.state accessor measureVersion = 0\n\n /** How far the drawing shrank to fit: what a node holds shrinks with it. */\n @E.state accessor drawnScale = 1\n\n /** What a node holds changed size. */\n @E.on(TREE_NODE_RESIZED)\n protected onNodeResized() {\n this.measureVersion++\n }\n\n /** While it's in the page: measures again when a web font arrives or the font changes; follows the scale. */\n @E.whileConnected\n protected watchFontsAndSize() {\n this.measureVersion++\n const remeasure = () => this.measureVersion++\n document.fonts?.addEventListener(\"loadingdone\", remeasure)\n const observer = new ResizeObserver(() => this.onDrawingResized())\n if (this.fontSentinel) observer.observe(this.fontSentinel)\n if (this.svg) observer.observe(this.svg)\n return () => {\n document.fonts?.removeEventListener(\"loadingdone\", remeasure)\n observer.disconnect()\n }\n }\n\n /** The sentinel or the `<svg>` changed size. */\n private onDrawingResized() {\n const sentinelWidth = this.fontSentinel?.offsetWidth\n if (sentinelWidth !== this.lastSentinelWidth) {\n this.lastSentinelWidth = sentinelWidth\n this.measureVersion++\n }\n this.drawnScale = this.scaleNow()\n }\n\n /** The sentinel's width last seen. */\n private lastSentinelWidth: number | undefined\n\n /** The drawing's width on the page, per its natural width; `1` when it isn't laid out. */\n private scaleNow(): number {\n const { svg, layout } = this\n const width = svg?.getBoundingClientRect().width\n if (!svg || !width || !layout) return 1\n return width / (layout.width * this.pixelsPerUnit() || width)\n }\n\n /** Pixels per user unit, at natural size: one label `em` on the page is `fontSize` units. */\n private pixelsPerUnit(): number {\n return Number.parseFloat(getComputedStyle(this.svg!).fontSize) / TREE_DIAGRAM_METRICS.fontSize\n }\n\n /**\n * Every node's measured sizes; `undefined` before it can measure (a server, or before it first draws).\n * - `@derived`: measures every text.\n * - Reads the DOM: `measureVersion` says when that changed.\n */\n @E.derived\n get sizes(): ReadonlyMap<TreeDiagramNode, TreeDiagramNodeSize> | undefined {\n const tree = this.drawnTree\n void this.measureVersion\n const { rootLabel, label, detail, edgeLabel } = this.samples\n if (isServer || !tree || !this.svg || !rootLabel || !label || !detail || !edgeLabel) return undefined\n return TreeMeasure.sizes(tree, { rootLabel, label, detail, edgeLabel }, (node) => this.contentSizeOf(node))\n }\n\n /** What `node` holds besides its text, in user units; `undefined` when nothing. */\n private contentSizeOf(node: TreeDiagramNode): { width: number; height: number } | undefined {\n const size = (node.element as DOMTreeNodeElement | undefined)?.component?.contentSize\n if (!size) return undefined\n const perPixel = 1 / this.pixelsPerUnit()\n return { width: size.width * perPixel, height: size.height * perPixel }\n }\n\n ////////////////\n // ## Folding\n ////////////////\n\n /** Nodes folded or opened by a person, by `path`; a tree that changes keeps them. */\n @E.state accessor foldChanges: ReadonlyMap<string, boolean> = new Map()\n\n /**\n * The nodes drawn as leaves: `folded` in the tree, unless a person changed it.\n * - `@derived`: walks every node.\n */\n @E.derived\n get foldedNodes(): ReadonlySet<TreeDiagramNode> {\n const folded = new Set<TreeDiagramNode>()\n const { drawnTree, foldChanges } = this\n const visit = (node: TreeDiagramNode, path: string) => {\n if (foldChanges.get(path) ?? node.folded) folded.add(node)\n node.children?.forEach((child, index) => visit(child, `${path}.${index}`))\n }\n if (drawnTree) visit(drawnTree, \"0\")\n return folded\n }\n\n /** Fold or open `box`'s node: `ui-node-toggled`, then the drawing. */\n @E.untracked\n private toggle(box: TreeDiagramBox, originalEvent: Event) {\n const folded = !box.isFolded\n this.foldChanges = new Map(this.foldChanges).set(box.path, folded)\n this.send(\"ui-node-toggled\", { node: box.node, path: box.path, folded, originalEvent })\n }\n\n ////////////////\n // ## Layout\n ////////////////\n\n /**\n * The tree laid out; `undefined` with nothing to draw.\n * - `@derived`: lays out every node.\n */\n @E.derived\n get layout(): TreeDiagramLayout | undefined {\n const tree = this.drawnTree\n if (!tree) return undefined\n return TreeLayout.of(tree, {\n direction: this.direction,\n sizes: this.sizes,\n folded: this.foldedNodes,\n metrics: this.foldable ? FOLDABLE_METRICS : TREE_DIAGRAM_METRICS\n })\n }\n\n /**\n * Tell each nested node where what it holds goes; a folded-away node, nowhere.\n * - And hand the root `<ui-tree-node>` to its slot.\n */\n @E.onChange(\"layout\", \"nodesTree\", \"isReady\")\n protected onLayoutChanged(\n layout: TreeDiagramLayout | undefined,\n tree: TreeDiagramNode | undefined,\n isReady: boolean\n ) {\n if (!isReady) return\n this.nodesSlot?.assign(...(tree?.element ? [tree.element] : []))\n this.drawnScale = this.scaleNow()\n const shown = new Map(layout?.boxes.map((box) => [box.node.element, box]))\n const place = (node: TreeDiagramNode) => {\n const component = (node.element as DOMTreeNodeElement | undefined)?.component\n const content = shown.get(node.element)?.content\n if (component) {\n component.placement =\n content && layout\n ? { left: (content.x / layout.width) * 100, top: (content.y / layout.height) * 100 }\n : undefined\n }\n node.children?.forEach(place)\n }\n if (tree) place(tree)\n }\n\n ////////////////\n // ## Clicks\n ////////////////\n\n /** A click on what a node holds: it's outside the `<svg>`, in the page. */\n @E.on(\"click\")\n protected onContentClick(event: MouseEvent) {\n const element = event\n .composedPath()\n .find((target) => target !== this.domElement && UITreeNode.isNode(target as Node)) as Element | undefined\n if (!element) return\n const box = this.layout?.boxes.find((each) => each.node.element === element)\n if (box) this.sendClick(box, event)\n }\n\n /** `ui-node-clicked`. */\n @E.untracked\n private sendClick(box: TreeDiagramBox, originalEvent: Event) {\n this.send(\"ui-node-clicked\", { node: box.node, path: box.path, originalEvent })\n }\n\n /** Enter or Space on a focused node or fold button does `act`. */\n private onButtonKey(event: KeyboardEvent, act: (event: Event) => void) {\n if (event.key !== UIT.Key.enter && event.key !== UIT.Key.space) return\n event.preventDefault()\n event.stopPropagation()\n act(event)\n }\n\n ////////////////\n // ## Drawing\n ////////////////\n\n /**\n * `empty` with nothing to draw.\n * - Reads `tree` itself, not just `drawnTree`: so the classes follow EVERY write to it,\n * as `ElementFixture.breakRender()` needs (the only attribute is a non-class one).\n */\n protected override get extraClass(): string | undefined {\n return TreeData.node(this.tree) || this.nodesTree || this.childTree ? undefined : EMPTY\n }\n\n render(): JSX.Element {\n return (\n <div class={CANVAS_CLASS} style={this.canvasStyle()}>\n <svg\n ref={(svg: SVGSVGElement) => (this.svg = svg)}\n class={this.rootClass}\n part={this.partForName(\"diagram\")}\n role={this.layout ? (this.foldable || this.clickable ? \"group\" : \"img\") : undefined}\n aria-label={this.summary()}\n viewBox={this.viewBox()}\n style={this.sizeStyle()}\n >\n {this.fontSamples()}\n <For each={this.layout?.edges ?? []} keyed={false}>\n {(edge) => this.edge(edge)}\n </For>\n <For each={this.layout?.boxes ?? []} keyed={false}>\n {(box) => this.box(box)}\n </For>\n </svg>\n <span ref={(span: HTMLElement) => (this.fontSentinel = span)} class={SENTINEL_CLASS} aria-hidden=\"true\">\n Mg\n </span>\n <slot ref={(slot: HTMLSlotElement) => (this.nodesSlot = slot)} />\n </div>\n )\n }\n\n /** A text of each kind, never drawn: what `TreeMeasure` reads each font from. */\n private fontSamples(): JSX.Element {\n const { fontSize, detailFontSize, edgeLabelFontSize } = TREE_DIAGRAM_METRICS\n return (\n <defs>\n <g class={[NODE_CLASS, ROOT_CLASS]}>\n <text\n ref={(text: SVGTextElement) => (this.samples.rootLabel = text)}\n class={LABEL_CLASS}\n font-size={String(fontSize)}\n />\n </g>\n <g class={NODE_CLASS}>\n <text\n ref={(text: SVGTextElement) => (this.samples.label = text)}\n class={LABEL_CLASS}\n font-size={String(fontSize)}\n />\n <text\n ref={(text: SVGTextElement) => (this.samples.detail = text)}\n class={DETAIL_CLASS}\n font-size={String(detailFontSize)}\n />\n </g>\n <text\n ref={(text: SVGTextElement) => (this.samples.edgeLabel = text)}\n class={EDGE_LABEL_CLASS}\n font-size={String(edgeLabelFontSize)}\n />\n </defs>\n )\n }\n\n /**\n * One node: its `<g>` (part `node`, the root's also `root-node`), `<title>`, box, label, detail, fold button.\n * - `box` is the For's accessor (`keyed={false}`): a redraw updates the same elements in place, by position.\n */\n private box(box: Accessor<TreeDiagramBox>): JSX.Element {\n const { fontSize, detailFontSize } = TREE_DIAGRAM_METRICS\n const isRoot = () => box().depth === 0\n const kind = () => UITreeDiagram.wordFor(box().node.kind)\n return (\n <g\n class={[\n NODE_CLASS,\n { [ROOT_CLASS]: isRoot(), [CLICKABLE_CLASS]: !!this.clickable },\n kind() && `kind-${kind()}`\n ]}\n part={[this.partForName(\"node\"), isRoot() && this.partForName(\"root-node\"), kind() && `kind-${kind()}`]\n .filter(Boolean)\n .join(\" \")}\n style={UITreeDiagram.colorStyle(box().node.color)}\n role={this.clickable ? \"button\" : undefined}\n tabindex={this.clickable ? \"0\" : undefined}\n aria-label={this.clickable ? box().node.label : undefined}\n onClick={(event: MouseEvent) => this.sendClick(box(), event)}\n onKeyDown={(event: KeyboardEvent) => {\n if (this.clickable && event.target === event.currentTarget)\n this.onButtonKey(event, (original) => this.sendClick(box(), original))\n }}\n >\n <Show when={box().node.title}>{(title) => <title>{title()}</title>}</Show>\n <rect class={BOX_CLASS} x={box().x} y={box().y} width={box().width} height={box().height} />\n <Show when={box().node.label}>\n <text class={LABEL_CLASS} x={box().label.x} y={box().label.y} font-size={String(fontSize)}>\n {box().node.label}\n </text>\n </Show>\n <Show when={box().detail}>\n {(detail) => (\n <text class={DETAIL_CLASS} x={detail().x} y={detail().y} font-size={String(detailFontSize)}>\n {box().node.detail}\n </text>\n )}\n </Show>\n <Show when={this.foldable && box().childCount}>{this.foldButton(box)}</Show>\n </g>\n )\n }\n\n /** `box`'s fold button (part `toggle`), where its lines leave it: a circle with a `+` or a `-`. */\n private foldButton(box: Accessor<TreeDiagramBox>): JSX.Element {\n const label = () => this.translationForKey(box().isFolded ? \"unfoldNode\" : \"foldNode\", { label: box().node.label })\n return (\n <g\n class={TOGGLE_CLASS}\n part={this.partForName(\"toggle\")}\n role=\"button\"\n tabindex=\"0\"\n aria-expanded={box().isFolded ? \"false\" : \"true\"}\n aria-label={label()}\n transform={`translate(${box().exit.x} ${box().exit.y})`}\n onClick={(event: MouseEvent) => {\n event.stopPropagation()\n this.toggle(box(), event)\n }}\n onKeyDown={(event: KeyboardEvent) => this.onButtonKey(event, (original) => this.toggle(box(), original))}\n >\n <title>{label()}</title>\n <circle class={TOGGLE_TARGET_CLASS} r={TOGGLE_TARGET_RADIUS} />\n <circle class={TOGGLE_CIRCLE_CLASS} r={TOGGLE_RADIUS} />\n <path class={TOGGLE_MARK_CLASS} d={box().isFolded ? PLUS_MARK : MINUS_MARK} />\n </g>\n )\n }\n\n /** One edge: its line (part `edge`), broken under its label (part `edge-label`). `edge`: as `box()`'s. */\n private edge(edge: Accessor<TreeDiagramEdge>): JSX.Element {\n return (\n <>\n <path class={EDGE_CLASS} part={this.partForName(\"edge\")} d={UITreeDiagram.path(edge())} />\n <Show when={edge().label}>\n {(label) => (\n <text\n class={EDGE_LABEL_CLASS}\n part={this.partForName(\"edge-label\")}\n x={label().x}\n y={label().y}\n font-size={String(TREE_DIAGRAM_METRICS.edgeLabelFontSize)}\n >\n {label().text}\n </text>\n )}\n </Show>\n </>\n )\n }\n\n /** `viewBox`: the layout's natural size. */\n private viewBox(): string | undefined {\n const layout = this.layout\n return layout && `0 0 ${layout.width} ${layout.height}`\n }\n\n /** The natural width in label `em`s, for the sheet to size the `<svg>` with. */\n private sizeStyle(): JSX.CSSProperties | undefined {\n const layout = this.layout\n return layout && { [NATURAL_WIDTH]: (layout.width / TREE_DIAGRAM_METRICS.fontSize).toFixed(3) }\n }\n\n /** How far the drawing shrank, for what its nodes hold. */\n private canvasStyle(): JSX.CSSProperties {\n return { [DRAWN_SCALE]: this.drawnScale.toFixed(4) }\n }\n\n /** The `<svg>`'s name: the root's label and how many children it has. */\n private summary(): string | undefined {\n const tree = this.drawnTree\n if (!tree) return undefined\n return TreeData.summary(tree, (key, params) => this.translationForKey(key, params))\n }\n\n /** `d` of an edge's `<path>`: one line, or two around the label's gap. */\n private static path({ from, to, gap }: TreeDiagramEdge): string {\n if (!gap) return `M${from.x} ${from.y}L${to.x} ${to.y}`\n return `M${from.x} ${from.y}L${gap.from.x} ${gap.from.y}M${gap.to.x} ${gap.to.y}L${to.x} ${to.y}`\n }\n\n /** `word` when it's safe in a class and a part name; else `undefined`. */\n private static wordFor(word: string | undefined): string | undefined {\n return word && /^[\\w-]+$/.test(word) ? word : undefined\n }\n\n /** A node's `color`: the node's tokens, set to that hue, on its `<g>`; the sheet reads them. */\n private static colorStyle(color: string | undefined): JSX.CSSProperties | undefined {\n const hue = UITreeDiagram.wordFor(color)\n if (!hue) return undefined\n const background = `var(--ui-${hue}-background)`\n const border = `var(--ui-${hue})`\n return {\n \"--ui-tree-diagram-node-background\": background,\n \"--ui-tree-diagram-node-border-color\": border,\n \"--ui-tree-diagram-root-background\": background,\n \"--ui-tree-diagram-root-border-color\": border\n }\n }\n}\n\n/** The vocabulary getters, typed (`UIComponent`'s doc). */\nexport interface UITreeDiagram extends E.AttributeValues<typeof treeDiagramVocabulary> {}\n\n/** Class word before the noun when there's nothing to draw (`ui empty tree diagram`): the `<svg>` hides. */\nconst EMPTY = \"empty\"\n\n/** Class of the box around the drawing and its nodes' content, the content's containing block. */\nconst CANVAS_CLASS = \"canvas\"\n/** Class of the hidden line that changes size when the font does. */\nconst SENTINEL_CLASS = \"font-sentinel\"\n\n/** Class of each node's `<g>`, its box, its texts; each edge; each edge label. */\nconst NODE_CLASS = \"node\"\nconst ROOT_CLASS = \"root\"\nconst CLICKABLE_CLASS = \"clickable\"\nconst BOX_CLASS = \"box\"\nconst LABEL_CLASS = \"label\"\nconst DETAIL_CLASS = \"detail\"\nconst EDGE_CLASS = \"edge\"\nconst EDGE_LABEL_CLASS = \"edge-label\"\n\n/** Class of a fold button's `<g>` and its pieces. */\nconst TOGGLE_CLASS = \"toggle\"\nconst TOGGLE_TARGET_CLASS = \"toggle-target\"\nconst TOGGLE_CIRCLE_CLASS = \"toggle-circle\"\nconst TOGGLE_MARK_CLASS = \"toggle-mark\"\n\n/** A fold button's circle, in user units. */\nconst TOGGLE_RADIUS = 6\n/** What a pointer can hit, around it. */\nconst TOGGLE_TARGET_RADIUS = 12\n/** The button's `+` and `-`, drawn so they're centred in any font. */\nconst PLUS_MARK = \"M-3 0H3M0 -3V3\"\nconst MINUS_MARK = \"M-3 0H3\"\n\n/** A foldable tree's room around the drawing: a button sticks out below its last row. */\nconst FOLDABLE_METRICS = { ...TREE_DIAGRAM_METRICS, margin: TOGGLE_RADIUS + 2 }\n\n/** Private custom property the sheet sizes the `<svg>` with: the layout's natural width, in label `em`s. */\nconst NATURAL_WIDTH = \"--_ui-tree-diagram-natural-width\"\n/** Private custom property what a node holds is scaled by: how far the drawing shrank. */\nconst DRAWN_SCALE = \"--_ui-tree-diagram-scale\"\n","/**\n * The tree diagram family: defines `<ui-tree-diagram>` and `<ui-tree-node>`, and exports their components.\n * - SIDE EFFECT: importing it defines the tag, and `<ui-json>` (where its tree may come from).\n * - Also the library's `spell/ui/ui-tree-diagram` entry (its size is in `notes/report.md`).\n * - `TreeLayout` (the pure layout), `TreeMeasure` (its numbers) and `TreeData` (reading and checking a tree) are exported too,\n * for a page that wants the numbers alone; `TreeDiagramNode` is the data contract.\n */\n\nimport { TreeData } from \"./TreeData\"\nimport { TreeLayout } from \"./TreeLayout\"\nimport { TreeMeasure } from \"./TreeMeasure\"\nimport { UITreeDiagram } from \"./UITreeDiagram\"\nimport { UITreeNode } from \"./UITreeNode\"\n\nimport \"spell/ui/components/ui-json\"\n\nUITreeDiagram.define()\nUITreeNode.define()\n\nexport { TreeData, TreeLayout, TreeMeasure, UITreeDiagram, UITreeNode }\nexport type {\n TreeDiagramBox,\n TreeDiagramDirection,\n TreeDiagramEdge,\n TreeDiagramEdgeLabel,\n TreeDiagramLayout,\n TreeDiagramLayoutOptions,\n TreeDiagramMetrics,\n TreeDiagramNode,\n TreeDiagramNodeSize,\n TreeDiagramPoint\n} from \"./UITreeDiagram.types\"\n"],"mappings":";;;;;;;AAcA,IAAamH,IAAb,MAAa,SAAS;CAQpB,OAAO,KAAK,GAAgB,oBAAO,IAAI,IAAY,GAAgC;EACjF,IAAI,OAAOC,KAAU,aAAYA,KAAkB,MAAM,QAAQA,CAAK,KAAKC,EAAK,IAAID,CAAK,GAAG;EAC5F,EAAK,IAAIA,CAAK;EACd,IAAME,IAAMF,GACNG,IAAwB,EAAE,OAAO,SAAS,KAAKD,EAAI,KAAK,KAAK,GAAG,GAChEE,IAAS,SAAS,KAAKF,EAAI,MAAM,GACjCG,IAAY,SAAS,KAAKH,EAAI,SAAS,KAAK,SAAS,KAAKA,EAAI,IAAI,GAClEI,IAAQ,SAAS,KAAKJ,EAAI,KAAK,GAC/BK,IAAQ,SAAS,KAAKL,EAAI,KAAK,GAC/BM,IAAO,SAAS,KAAKN,EAAI,IAAI;EAOnC,IANIE,MAAQ,EAAK,SAASA,IACtBC,MAAW,EAAK,YAAYA,IAC5BC,MAAO,EAAK,QAAQA,IACpBC,MAAO,EAAK,QAAQA,IACpBC,MAAM,EAAK,OAAOA,IAClBN,EAAI,WAAW,OAAM,EAAK,SAAS,KACnC,MAAM,QAAQA,EAAI,QAAQ,GAAG;GAC/B,IAAMO,IAAWP,EAAI,SAAS,SAAS,MAAU,SAAS,KAA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ApB2L,GAAA,IADEK,GACkBtF,EAAA,CAAA,GAApB1G,EAAA2L,GAAA,IADEK,CAAA,GAEIpM,EAFJoM,GAEW,gBAAehM,EAAtB2L,GAAA,IAFJK,GAE0B;CACnC,aAAa,EAAE,gBAAgBxM,GAAe;CAC9C,gBAAgB;CAChB,gBAAgB;AAClB,CAAA,CAAA,GAJeQ,EAAA2L,GAAA,IAFJK,CAAA;AAAN,IAAMoG,KAANpG,GA2fD2B,KAAQ,SAGRU,KAAe,UAEfC,KAAiB,iBAGjBe,KAAa,QACbC,KAAa,QACbkB,KAAkB,aAClBC,KAAY,OACZlB,IAAc,SACdC,KAAe,UACfmC,KAAa,QACblC,KAAmB,cAGnB0B,KAAe,UACfC,KAAsB,iBACtBC,KAAsB,iBACtBC,KAAoB,eAGpBJ,KAAgB,GAEhBD,KAAuB,IAEvBM,KAAY,kBACZC,KAAa,WAGbtE,KAAmB;CAAE,GAAG9L;CAAsB,QAAQ;AAAkB,GAGxEyQ,KAAgB,oCAEhBC,KAAc;A,yBCpkBpBM,GAAc,OAAO,GACrBxI,EAAW,OAAO"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// src/components/ui-tree/ui-tree.editor.html?raw
|
|
2
|
+
var e = "<!-- <ui-tree>'s property editor layout: move, pair (<ui-fields>) or leave out (data-omit) its properties. How: Spell UI's AGENTS.md, \"Property editor layouts\". -->\n<ui-property-editor schema=\"ui-tree\" data-omit=\"items path\">\n <ui-property-group label=\"Appearance\" data-group=\"appearance\">\n <ui-property name=\"appearance\"></ui-property>\n <ui-property name=\"column-titles\"></ui-property>\n <ui-property name=\"size\"></ui-property>\n <ui-property name=\"show\"></ui-property>\n <ui-property name=\"narrow-before\"></ui-property>\n </ui-property-group>\n <ui-property-group label=\"Behaviour\" data-group=\"behaviour\">\n <ui-property name=\"choose\"></ui-property>\n <ui-property name=\"filter\"></ui-property>\n <ui-property name=\"tools\"></ui-property>\n <ui-property name=\"label\"></ui-property>\n <ui-property name=\"sticky-path\"></ui-property>\n <ui-property name=\"sticky-detail\"></ui-property>\n </ui-property-group>\n</ui-property-editor>\n";
|
|
3
|
+
export { e as default };
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=ui-tree.editor-Bqsa0dYQ.js.map
|