@slotform/react-ui 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +44 -2
- package/dist/density.d.ts +4 -0
- package/dist/density.d.ts.map +1 -0
- package/dist/density.js +8 -0
- package/dist/density.js.map +1 -0
- package/dist/index.d.ts +400 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +388 -0
- package/dist/index.js.map +1 -0
- package/dist/node/canvas.d.ts +3 -0
- package/dist/node/canvas.d.ts.map +1 -0
- package/dist/node/canvas.js +13 -0
- package/dist/node/canvas.js.map +1 -0
- package/dist/node/codegen.d.ts +6 -0
- package/dist/node/codegen.d.ts.map +1 -0
- package/dist/node/codegen.js +70 -0
- package/dist/node/codegen.js.map +1 -0
- package/dist/node/css-escape.d.ts +8 -0
- package/dist/node/css-escape.d.ts.map +1 -0
- package/dist/node/css-escape.js +12 -0
- package/dist/node/css-escape.js.map +1 -0
- package/dist/node/fonts.d.ts +6 -0
- package/dist/node/fonts.d.ts.map +1 -0
- package/dist/node/fonts.js +219 -0
- package/dist/node/fonts.js.map +1 -0
- package/dist/node/lint.d.ts +3 -0
- package/dist/node/lint.d.ts.map +1 -0
- package/dist/node/lint.js +23 -0
- package/dist/node/lint.js.map +1 -0
- package/dist/node/mode.d.ts +9 -0
- package/dist/node/mode.d.ts.map +1 -0
- package/dist/node/mode.js +38 -0
- package/dist/node/mode.js.map +1 -0
- package/dist/node/theme.d.ts +13 -0
- package/dist/node/theme.d.ts.map +1 -0
- package/dist/node/theme.js +160 -0
- package/dist/node/theme.js.map +1 -0
- package/dist/types.d.ts +250 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +80 -0
- package/dist/types.js.map +1 -0
- package/guide/acts.md +61 -0
- package/guide/audio.md +77 -0
- package/guide/blocks.md +82 -0
- package/guide/canvas-choosing.md +34 -0
- package/guide/canvas-editing.md +36 -0
- package/guide/canvas-layout.md +46 -0
- package/guide/canvas-opening.md +47 -0
- package/guide/canvas-overview.md +24 -0
- package/guide/canvas-states.md +37 -0
- package/guide/canvas-view.md +46 -0
- package/guide/canvas.md +94 -0
- package/guide/containers.md +60 -0
- package/guide/content.md +40 -0
- package/guide/controls.md +89 -0
- package/guide/density.md +48 -0
- package/guide/dock.md +42 -0
- package/guide/drag.md +38 -0
- package/guide/figures.md +25 -0
- package/guide/forms.md +82 -0
- package/guide/pane-bar.md +11 -0
- package/guide/pane.md +50 -0
- package/guide/reference.md +74 -0
- package/guide/rules.md +109 -0
- package/guide/section.md +29 -0
- package/guide/shell.md +26 -0
- package/guide/shots.md +37 -0
- package/guide/sidebar.md +30 -0
- package/guide/table.md +119 -0
- package/lint/no-arbitrary-value.grit +9 -0
- package/lint/no-class-on-component.grit +12 -0
- package/lint/no-density.grit +8 -0
- package/lint/no-host-look.grit +38 -0
- package/lint/no-img.grit +10 -0
- package/lint/no-navigate-act.grit +22 -0
- package/lint/no-raw-style.grit +8 -0
- package/package.json +150 -3
- package/src/density.ts +9 -0
- package/src/index.ts +503 -0
- package/src/node/canvas.ts +14 -0
- package/src/node/codegen.ts +100 -0
- package/src/node/css-escape.ts +27 -0
- package/src/node/fonts.ts +260 -0
- package/src/node/lint.ts +25 -0
- package/src/node/mode.ts +64 -0
- package/src/node/theme.ts +232 -0
- package/src/types.ts +120 -0
- package/src/ui/atoms/avatar/base.tsx +42 -0
- package/src/ui/atoms/button/glyph.tsx +244 -0
- package/src/ui/atoms/button/link.tsx +81 -0
- package/src/ui/atoms/button/look.ts +32 -0
- package/src/ui/atoms/button/reason.tsx +69 -0
- package/src/ui/atoms/chip/base.tsx +85 -0
- package/src/ui/atoms/count/base.tsx +27 -0
- package/src/ui/atoms/icon/index.tsx +51 -0
- package/src/ui/atoms/message/waiting.tsx +19 -0
- package/src/ui/atoms/prose/painted.tsx +35 -0
- package/src/ui/atoms/row/badges.tsx +226 -0
- package/src/ui/atoms/row/leading.tsx +166 -0
- package/src/ui/atoms/row/lock.tsx +17 -0
- package/src/ui/atoms/row/marks.tsx +79 -0
- package/src/ui/atoms/section/card.tsx +27 -0
- package/src/ui/atoms/spinner/index.tsx +42 -0
- package/src/ui/atoms/status/base.tsx +51 -0
- package/src/ui/atoms/status/change.tsx +29 -0
- package/src/ui/atoms/status/dot.tsx +45 -0
- package/src/ui/atoms/switch/checkbox.tsx +121 -0
- package/src/ui/atoms/turn.tsx +28 -0
- package/src/ui/components/action-bar/base.tsx +276 -0
- package/src/ui/components/action-bar/index.tsx +20 -0
- package/src/ui/components/avatar/index.tsx +21 -0
- package/src/ui/components/banner/index.tsx +207 -0
- package/src/ui/components/banner/pending.tsx +109 -0
- package/src/ui/components/bar-chart/index.tsx +701 -0
- package/src/ui/components/button/base.tsx +214 -0
- package/src/ui/components/button/face.tsx +84 -0
- package/src/ui/components/button/index.tsx +206 -0
- package/src/ui/components/canvas/connection.tsx +26 -0
- package/src/ui/components/canvas/edges.tsx +116 -0
- package/src/ui/components/canvas/elk.ts +260 -0
- package/src/ui/components/canvas/floor.ts +173 -0
- package/src/ui/components/canvas/geometry.ts +772 -0
- package/src/ui/components/canvas/ground.tsx +97 -0
- package/src/ui/components/canvas/group.tsx +156 -0
- package/src/ui/components/canvas/hit.ts +40 -0
- package/src/ui/components/canvas/index.tsx +497 -0
- package/src/ui/components/canvas/label.tsx +53 -0
- package/src/ui/components/canvas/layout.ts +543 -0
- package/src/ui/components/canvas/lift.ts +272 -0
- package/src/ui/components/canvas/look.ts +129 -0
- package/src/ui/components/canvas/node.tsx +689 -0
- package/src/ui/components/canvas/open.ts +243 -0
- package/src/ui/components/canvas/opening.ts +240 -0
- package/src/ui/components/canvas/view.ts +621 -0
- package/src/ui/components/canvas/viewport.ts +417 -0
- package/src/ui/components/canvas/zoom.tsx +113 -0
- package/src/ui/components/card/index.tsx +20 -0
- package/src/ui/components/chip/index.tsx +24 -0
- package/src/ui/components/code/frame.ts +2 -0
- package/src/ui/components/code/index.tsx +234 -0
- package/src/ui/components/columns/index.tsx +51 -0
- package/src/ui/components/count/index.tsx +17 -0
- package/src/ui/components/diff/index.tsx +249 -0
- package/src/ui/components/diff/word.tsx +104 -0
- package/src/ui/components/dock/index.tsx +262 -0
- package/src/ui/components/file-row/index.tsx +213 -0
- package/src/ui/components/form/base.tsx +280 -0
- package/src/ui/components/form/derive.tsx +269 -0
- package/src/ui/components/form/index.tsx +49 -0
- package/src/ui/components/form/saved.tsx +39 -0
- package/src/ui/components/form-field/index.tsx +658 -0
- package/src/ui/components/gallery/index.tsx +83 -0
- package/src/ui/components/gate/index.tsx +183 -0
- package/src/ui/components/image/base.tsx +245 -0
- package/src/ui/components/image/index.tsx +58 -0
- package/src/ui/components/input/base.tsx +246 -0
- package/src/ui/components/input/code.tsx +108 -0
- package/src/ui/components/input/drop.ts +37 -0
- package/src/ui/components/input/file.tsx +154 -0
- package/src/ui/components/input/index.tsx +132 -0
- package/src/ui/components/input/prose.tsx +107 -0
- package/src/ui/components/input/refusal.tsx +30 -0
- package/src/ui/components/item-header/base.tsx +410 -0
- package/src/ui/components/menu/base.tsx +319 -0
- package/src/ui/components/message/attachments.tsx +101 -0
- package/src/ui/components/message/base.tsx +266 -0
- package/src/ui/components/message-input/index.tsx +377 -0
- package/src/ui/components/missing/base.tsx +45 -0
- package/src/ui/components/pane/head.tsx +399 -0
- package/src/ui/components/pane/index.tsx +325 -0
- package/src/ui/components/picker/base.tsx +1551 -0
- package/src/ui/components/picker/index.tsx +224 -0
- package/src/ui/components/picker/list.tsx +423 -0
- package/src/ui/components/picker/segments.tsx +183 -0
- package/src/ui/components/prose/index.tsx +259 -0
- package/src/ui/components/qr-code/index.tsx +65 -0
- package/src/ui/components/row/acts.tsx +126 -0
- package/src/ui/components/row/fact.tsx +54 -0
- package/src/ui/components/row/index.tsx +1370 -0
- package/src/ui/components/row/progress.tsx +38 -0
- package/src/ui/components/row/status.tsx +54 -0
- package/src/ui/components/row/title.ts +7 -0
- package/src/ui/components/rules/index.tsx +290 -0
- package/src/ui/components/section/band.tsx +39 -0
- package/src/ui/components/section/head.tsx +267 -0
- package/src/ui/components/section/index.tsx +409 -0
- package/src/ui/components/section/rows.tsx +356 -0
- package/src/ui/components/sheet/base.tsx +272 -0
- package/src/ui/components/sheet/confirm.tsx +79 -0
- package/src/ui/components/sheet/docked.tsx +218 -0
- package/src/ui/components/sheet/form.tsx +76 -0
- package/src/ui/components/sheet/head.tsx +120 -0
- package/src/ui/components/sheet/index.tsx +45 -0
- package/src/ui/components/sheet/layer.tsx +168 -0
- package/src/ui/components/sheet/outlet.tsx +58 -0
- package/src/ui/components/sheet/task.tsx +41 -0
- package/src/ui/components/shell/cut.tsx +116 -0
- package/src/ui/components/shell/drag.tsx +45 -0
- package/src/ui/components/shell/host.tsx +71 -0
- package/src/ui/components/shell/index.tsx +737 -0
- package/src/ui/components/shell/panes.tsx +76 -0
- package/src/ui/components/shell/preview.ts +230 -0
- package/src/ui/components/shell/rail.tsx +163 -0
- package/src/ui/components/shell/row.ts +11 -0
- package/src/ui/components/shell/switcher.tsx +143 -0
- package/src/ui/components/shell/tree.tsx +252 -0
- package/src/ui/components/slider/base.tsx +139 -0
- package/src/ui/components/slider/index.tsx +57 -0
- package/src/ui/components/stages/index.tsx +198 -0
- package/src/ui/components/stats/count-links.tsx +47 -0
- package/src/ui/components/stats/index.tsx +203 -0
- package/src/ui/components/stats/meter.tsx +213 -0
- package/src/ui/components/stats/parts.ts +10 -0
- package/src/ui/components/step-count/index.tsx +45 -0
- package/src/ui/components/switch/base.tsx +86 -0
- package/src/ui/components/switch/index.tsx +38 -0
- package/src/ui/components/table/columns.tsx +131 -0
- package/src/ui/components/table/index.tsx +2215 -0
- package/src/ui/components/text/index.tsx +37 -0
- package/src/ui/components/thread/index.tsx +503 -0
- package/src/ui/components/thread/latest.tsx +59 -0
- package/src/ui/components/toast/index.tsx +113 -0
- package/src/ui/components/toast/layer.tsx +26 -0
- package/src/ui/components/toolbar/filters.tsx +161 -0
- package/src/ui/components/toolbar/index.tsx +125 -0
- package/src/ui/components/waveform/index.tsx +205 -0
- package/src/ui/globals.css +427 -0
- package/src/ui/lib/act.ts +60 -0
- package/src/ui/lib/age.ts +49 -0
- package/src/ui/lib/bound.ts +16 -0
- package/src/ui/lib/canvas-layout.ts +11 -0
- package/src/ui/lib/caret.ts +9 -0
- package/src/ui/lib/chip-lines.ts +3 -0
- package/src/ui/lib/closed.ts +8 -0
- package/src/ui/lib/code.tsx +184 -0
- package/src/ui/lib/columns.ts +39 -0
- package/src/ui/lib/commit.ts +24 -0
- package/src/ui/lib/container.ts +112 -0
- package/src/ui/lib/copy.ts +29 -0
- package/src/ui/lib/drag.ts +575 -0
- package/src/ui/lib/empty.tsx +85 -0
- package/src/ui/lib/field.ts +39 -0
- package/src/ui/lib/focus.ts +175 -0
- package/src/ui/lib/folds.ts +67 -0
- package/src/ui/lib/follow.ts +220 -0
- package/src/ui/lib/form.ts +19 -0
- package/src/ui/lib/guards.ts +38 -0
- package/src/ui/lib/heading.ts +14 -0
- package/src/ui/lib/ink.ts +26 -0
- package/src/ui/lib/lang.ts +7 -0
- package/src/ui/lib/leave.ts +14 -0
- package/src/ui/lib/lockup.tsx +145 -0
- package/src/ui/lib/measure.ts +22 -0
- package/src/ui/lib/media.ts +63 -0
- package/src/ui/lib/modality.ts +69 -0
- package/src/ui/lib/moment.ts +13 -0
- package/src/ui/lib/more.tsx +76 -0
- package/src/ui/lib/navigate.ts +210 -0
- package/src/ui/lib/noop.ts +3 -0
- package/src/ui/lib/not-found.tsx +40 -0
- package/src/ui/lib/paint.tsx +55 -0
- package/src/ui/lib/parts-line.tsx +54 -0
- package/src/ui/lib/picked.ts +18 -0
- package/src/ui/lib/player-store.ts +38 -0
- package/src/ui/lib/player.ts +139 -0
- package/src/ui/lib/portal.ts +12 -0
- package/src/ui/lib/read.tsx +269 -0
- package/src/ui/lib/region.tsx +49 -0
- package/src/ui/lib/reorder.ts +154 -0
- package/src/ui/lib/rest.ts +16 -0
- package/src/ui/lib/saved.ts +29 -0
- package/src/ui/lib/scramble.tsx +147 -0
- package/src/ui/lib/scrolls.ts +70 -0
- package/src/ui/lib/style.ts +6 -0
- package/src/ui/lib/swap.tsx +107 -0
- package/src/ui/lib/toast.ts +39 -0
- package/src/ui/lib/walk-classes.ts +16 -0
- package/src/ui/lib/window.tsx +376 -0
- package/src/ui/worker.d.ts +4 -0
|
@@ -0,0 +1,689 @@
|
|
|
1
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
2
|
+
import type { CanvasNode, CanvasPoint } from "@slotform/ui-core/descriptors";
|
|
3
|
+
import { useWords } from "@slotform/ui-core/react/words";
|
|
4
|
+
import { named } from "@slotform/ui-core/tokens";
|
|
5
|
+
import {
|
|
6
|
+
BLOCK_IN,
|
|
7
|
+
CANVAS_PORT,
|
|
8
|
+
CANVAS_PORT_HIT,
|
|
9
|
+
canvasNode,
|
|
10
|
+
canvasNodeGlyph,
|
|
11
|
+
canvasNodeInk,
|
|
12
|
+
canvasNodeMark,
|
|
13
|
+
canvasNodeName,
|
|
14
|
+
canvasNodeText,
|
|
15
|
+
FLOW_IN,
|
|
16
|
+
PATH_TONE,
|
|
17
|
+
} from "@slotform/ui-core/variants";
|
|
18
|
+
import {
|
|
19
|
+
type KeyboardEvent,
|
|
20
|
+
type MouseEvent,
|
|
21
|
+
type PointerEvent,
|
|
22
|
+
type RefObject,
|
|
23
|
+
useEffect,
|
|
24
|
+
useLayoutEffect,
|
|
25
|
+
useRef,
|
|
26
|
+
useState,
|
|
27
|
+
} from "react";
|
|
28
|
+
import { IconButtonLink } from "../../atoms/button/glyph.tsx";
|
|
29
|
+
import { Icon } from "../../atoms/icon/index.tsx";
|
|
30
|
+
import { StatusBadge } from "../../atoms/row/badges.tsx";
|
|
31
|
+
import { StatusDot } from "../../atoms/status/dot.tsx";
|
|
32
|
+
import { Count } from "../count/index.tsx";
|
|
33
|
+
import { UNZOOM } from "./floor.ts";
|
|
34
|
+
import type { Size } from "./geometry.ts";
|
|
35
|
+
import { hit, keyboardFocus } from "./hit.ts";
|
|
36
|
+
import { client, heldAt, useLift } from "./lift.ts";
|
|
37
|
+
import { FOCUSED, HOVERED, type NodeLook } from "./look.ts";
|
|
38
|
+
import { keyStep } from "./view.ts";
|
|
39
|
+
import type { About, Viewport } from "./viewport.ts";
|
|
40
|
+
|
|
41
|
+
const BOX = "absolute flex items-center text-start select-none";
|
|
42
|
+
// A call node's card leaves its end to the open act, which stands over it: the
|
|
43
|
+
// act's size, the inset from the edge and a pair of air.
|
|
44
|
+
const OPENABLE =
|
|
45
|
+
"pe-[calc(var(--spacing-control)+var(--spacing-gap)+var(--spacing-gap))]";
|
|
46
|
+
// The open act stands over the card's own box, which takes no pointer but for
|
|
47
|
+
// the act itself.
|
|
48
|
+
const OPEN_BOX =
|
|
49
|
+
"absolute flex items-center justify-end pe-gap pointer-events-none";
|
|
50
|
+
const OPEN_ACT = "pointer-events-auto";
|
|
51
|
+
// A decision's diamond, behind the node's icon in a box of the glyph's size.
|
|
52
|
+
const MARK_BOX =
|
|
53
|
+
"relative isolate flex shrink-0 items-center justify-center size-control";
|
|
54
|
+
// A node held by a long press draws the selection's colour at the focus ring's
|
|
55
|
+
// width; its lift (`LIFT`, in the node's cell) is marked by `data-lifted`.
|
|
56
|
+
const HELD = "outline-2 outline-selected-outline";
|
|
57
|
+
const GRAB = "cursor-grab active:cursor-grabbing";
|
|
58
|
+
// The card of a node that has not landed: it keeps its box, so the layout does
|
|
59
|
+
// not move, and draws nothing until it lands. The card whose glyph stands in
|
|
60
|
+
// its place keeps its box too, and fades out on the answer's `fast` (`FADED`)
|
|
61
|
+
// as the glyph fades in; it is inert and hidden from a reader meanwhile, since
|
|
62
|
+
// the glyph is the node.
|
|
63
|
+
const INVISIBLE = "invisible";
|
|
64
|
+
const FADED = "opacity-0 pointer-events-none";
|
|
65
|
+
// A dragged node stands over the others where they overlap, in the layer's own
|
|
66
|
+
// stacking context, with no shadow: the hairline and the ground say it is held.
|
|
67
|
+
const LIFTED = "z-1";
|
|
68
|
+
// The in port a dragged link would end on fills with ink. A pointer capture
|
|
69
|
+
// holds :hover on the out port, so the canvas hit-tests and says which.
|
|
70
|
+
const TARGET = "bg-edge-strong";
|
|
71
|
+
const PORT_IN = "cursor-default";
|
|
72
|
+
const PORT_OUT = "cursor-crosshair";
|
|
73
|
+
// A node's status is a badge (`StatusBadge`): its tone's mark and its word in a
|
|
74
|
+
// box that never breaks, under the title; the node's line, or its warning in
|
|
75
|
+
// the line's place, is plain text under it (a sentence is text, never a
|
|
76
|
+
// badge). The line wraps to a second line and is cut at that one's end, so a
|
|
77
|
+
// list of callers or answers keeps more than its first words; the node
|
|
78
|
+
// measures its height, so a two-line node lays out at it.
|
|
79
|
+
const COLUMN = "flex flex-col flex-auto min-w-0";
|
|
80
|
+
const LINE = "truncate";
|
|
81
|
+
const LINE_TWO = "line-clamp-2 break-words";
|
|
82
|
+
const BADGE_ROW = "flex min-w-0";
|
|
83
|
+
// The trailing column holds what is no mark of the line: the figure, and the
|
|
84
|
+
// warning's danger dot.
|
|
85
|
+
const TRAILING = "flex flex-col items-end shrink-0 text-meta leading-meta";
|
|
86
|
+
// A port's hit stands centred on the node's border edge (a pixel outside the
|
|
87
|
+
// padding box it is placed in), where a route starts or ends: a line of no
|
|
88
|
+
// height along the edge centres the hit across it and takes no pointer.
|
|
89
|
+
const EDGE = "absolute inset-x-0 h-0 flex items-center justify-center";
|
|
90
|
+
const EDGE_TOP = "-top-px";
|
|
91
|
+
const EDGE_BOTTOM = "-bottom-px";
|
|
92
|
+
const HIT = "flex items-center justify-center shrink-0";
|
|
93
|
+
// The glyph form: a box over the card's own, taking no pointer itself, and the
|
|
94
|
+
// glyph button in it, which does. The marks are seated on the glyph's right
|
|
95
|
+
// corners, clear of its icon: the status above, the warning below.
|
|
96
|
+
const GLYPH_BOX =
|
|
97
|
+
"absolute flex items-center justify-center pointer-events-none";
|
|
98
|
+
const GLYPH =
|
|
99
|
+
"relative flex items-center justify-center size-control pointer-events-auto select-none";
|
|
100
|
+
// The off node's slash, over its icon in the glyph's box.
|
|
101
|
+
const OFF_MARK = "absolute inset-0 flex items-center justify-center";
|
|
102
|
+
// The overview's name, at the glyph's inline end and centred on it. It stands a
|
|
103
|
+
// gap out, clear of the marks seated at the glyph's end (`CANVAS_NODE_MARK`),
|
|
104
|
+
// and scales with the glyph, so it keeps the floor size on screen at any zoom.
|
|
105
|
+
const NAME = "absolute start-full top-1/2 -translate-y-1/2 ms-gap";
|
|
106
|
+
// Reports the element's layout size: the border box, which the layer's scale
|
|
107
|
+
// does not change. The callback only records it, so it cannot loop.
|
|
108
|
+
function useSize(
|
|
109
|
+
id: string,
|
|
110
|
+
report: (id: string, size: Size) => void,
|
|
111
|
+
): [HTMLElement | null, (element: HTMLElement | null) => void] {
|
|
112
|
+
const [element, setElement] = useState<HTMLElement | null>(null);
|
|
113
|
+
useLayoutEffect(() => {
|
|
114
|
+
if (!element) return;
|
|
115
|
+
const watch = new ResizeObserver(([entry]) => {
|
|
116
|
+
const box = entry?.borderBoxSize[0];
|
|
117
|
+
if (box) report(id, { width: box.inlineSize, height: box.blockSize });
|
|
118
|
+
});
|
|
119
|
+
watch.observe(element);
|
|
120
|
+
return () => watch.disconnect();
|
|
121
|
+
}, [element, id, report]);
|
|
122
|
+
return [element, setElement];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Where a node stands, and how large once it is measured.
|
|
126
|
+
interface Placed {
|
|
127
|
+
x: number;
|
|
128
|
+
y: number;
|
|
129
|
+
width?: number;
|
|
130
|
+
height?: number;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const stop = (event: { stopPropagation(): void }) => event.stopPropagation();
|
|
134
|
+
|
|
135
|
+
const swallow = (event: MouseEvent) => {
|
|
136
|
+
event.stopPropagation();
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// What a node's pointer can do, and with which parts of the canvas it does it.
|
|
141
|
+
export interface NodeEdit {
|
|
142
|
+
viewport: Viewport;
|
|
143
|
+
region: RefObject<HTMLElement | null>;
|
|
144
|
+
// The touch density: a finger lifts a node by a long press, and a node's
|
|
145
|
+
// ports are drawn at the target size at any zoom.
|
|
146
|
+
touch: boolean;
|
|
147
|
+
// With `onMove` on a pointer, above the text floor, the node follows a drag.
|
|
148
|
+
draggable: boolean;
|
|
149
|
+
// With `onMove` in the touch density, above the text floor, a long press
|
|
150
|
+
// lifts the node and a mouse still drags it at once.
|
|
151
|
+
liftable: boolean;
|
|
152
|
+
// With `onConnect`, the node shows an in and an out port.
|
|
153
|
+
ports: boolean;
|
|
154
|
+
// Sets a node's live position, `null` clearing it.
|
|
155
|
+
at: (id: string, point: CanvasPoint | null) => void;
|
|
156
|
+
// A move the viewer made (a release that moved the node, an arrow key):
|
|
157
|
+
// reports it at whole pixels, then clears the live position.
|
|
158
|
+
drop: (id: string, point: CanvasPoint) => void;
|
|
159
|
+
// Sets the connection in progress from a node, `null` clearing it.
|
|
160
|
+
// `target` is the node whose in port the pointer is over.
|
|
161
|
+
linking: (
|
|
162
|
+
from: string,
|
|
163
|
+
to: CanvasPoint | null,
|
|
164
|
+
target: string | null,
|
|
165
|
+
) => void;
|
|
166
|
+
onConnect?: (from: string, to: string | null) => void;
|
|
167
|
+
// Where a node stands at a scale, which a glyph's zoom holds it by.
|
|
168
|
+
about: (id: string) => About;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Whether the node has landed: it was measured but not yet placed, and now it
|
|
172
|
+
// is, so it fades in at its place. A node that came with its place never did.
|
|
173
|
+
function useLanded(landing: boolean): boolean {
|
|
174
|
+
const [was, setWas] = useState(landing);
|
|
175
|
+
if (landing && !was) setWas(true);
|
|
176
|
+
return was && !landing;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// A node: its glyph, its text column and its trailing figure, placed in flow
|
|
180
|
+
// coordinates. With `onSelect`, or when it can be moved, it is one button
|
|
181
|
+
// named by its visible text; without either, the same box, drawn and not
|
|
182
|
+
// operated. Under the text floor (`below`)
|
|
183
|
+
// the card keeps its box and draws nothing, and a glyph button stands over it;
|
|
184
|
+
// until the canvas is `bare` the glyph carries its node's name.
|
|
185
|
+
// This is the one place a node's pointer handlers live.
|
|
186
|
+
export function NodeView({
|
|
187
|
+
node,
|
|
188
|
+
look,
|
|
189
|
+
box,
|
|
190
|
+
landing,
|
|
191
|
+
lifted,
|
|
192
|
+
targeted,
|
|
193
|
+
below,
|
|
194
|
+
bare,
|
|
195
|
+
edit,
|
|
196
|
+
onSelect,
|
|
197
|
+
onSize,
|
|
198
|
+
onFocusVisible,
|
|
199
|
+
}: {
|
|
200
|
+
node: CanvasNode;
|
|
201
|
+
look: NodeLook;
|
|
202
|
+
box: Placed;
|
|
203
|
+
// Measured but not yet placed: it draws nothing until it is.
|
|
204
|
+
landing: boolean;
|
|
205
|
+
// A drag holds it, so it stands over the nodes it crosses.
|
|
206
|
+
lifted: boolean;
|
|
207
|
+
// A link being drawn would end on its in port.
|
|
208
|
+
targeted: boolean;
|
|
209
|
+
// The canvas is under the text floor: the node is its glyph alone.
|
|
210
|
+
below: boolean;
|
|
211
|
+
// The canvas is under the overview's floor: the glyph carries no name.
|
|
212
|
+
bare: boolean;
|
|
213
|
+
edit: NodeEdit;
|
|
214
|
+
onSelect?: (id: string | null) => void;
|
|
215
|
+
onSize: (id: string, size: Size) => void;
|
|
216
|
+
// A keyboard focus brings the node into view.
|
|
217
|
+
onFocusVisible: (id: string) => void;
|
|
218
|
+
}) {
|
|
219
|
+
const {
|
|
220
|
+
viewport,
|
|
221
|
+
region,
|
|
222
|
+
touch,
|
|
223
|
+
draggable,
|
|
224
|
+
liftable,
|
|
225
|
+
ports,
|
|
226
|
+
at,
|
|
227
|
+
drop,
|
|
228
|
+
linking,
|
|
229
|
+
onConnect,
|
|
230
|
+
about,
|
|
231
|
+
} = edit;
|
|
232
|
+
const { id } = node;
|
|
233
|
+
const [full, measure] = useSize(id, onSize);
|
|
234
|
+
const arrived = useLanded(landing);
|
|
235
|
+
const words = useWords();
|
|
236
|
+
const lift = useLift({
|
|
237
|
+
id,
|
|
238
|
+
enabled: liftable,
|
|
239
|
+
viewport,
|
|
240
|
+
at,
|
|
241
|
+
drop,
|
|
242
|
+
place: () => ({ x: box.x, y: box.y }),
|
|
243
|
+
});
|
|
244
|
+
// A press on the node holds where it took the node; one on the out port, whether
|
|
245
|
+
// the pointer has left it.
|
|
246
|
+
const held = useRef<{
|
|
247
|
+
grab: CanvasPoint;
|
|
248
|
+
from: CanvasPoint;
|
|
249
|
+
target: HTMLElement;
|
|
250
|
+
} | null>(null);
|
|
251
|
+
const linked = useRef<CanvasPoint | null>(null);
|
|
252
|
+
const moved = useRef(false);
|
|
253
|
+
// A node unmounted mid-drag or mid-link (its data changed under the press)
|
|
254
|
+
// ends the edge pan it was driving.
|
|
255
|
+
useEffect(
|
|
256
|
+
() => () => {
|
|
257
|
+
if (held.current || linked.current) viewport.edge(null);
|
|
258
|
+
},
|
|
259
|
+
[viewport],
|
|
260
|
+
);
|
|
261
|
+
// The click that ends a drag is armed to be swallowed until it arrives or a
|
|
262
|
+
// task passes: a release off the node fires no click, and no event says so.
|
|
263
|
+
const armed = useRef(false);
|
|
264
|
+
// A glyph activated by a key hands its focus to the card that replaces it.
|
|
265
|
+
const refocus = useRef(false);
|
|
266
|
+
const figure = node.number ?? node.count;
|
|
267
|
+
const lines = { line: node.line, off: words.off, warning: node.warning };
|
|
268
|
+
const body = lines[look.shows];
|
|
269
|
+
const status = look.status ? node.status : undefined;
|
|
270
|
+
const part = (name: "overline" | "title" | "line", value: string) => (
|
|
271
|
+
<span
|
|
272
|
+
className={cn(
|
|
273
|
+
canvasNodeText({ part: name, tone: look.tone }),
|
|
274
|
+
name === "line" ? LINE_TWO : LINE,
|
|
275
|
+
)}
|
|
276
|
+
>
|
|
277
|
+
{value}
|
|
278
|
+
</span>
|
|
279
|
+
);
|
|
280
|
+
const { width, height } = box;
|
|
281
|
+
const frame =
|
|
282
|
+
width !== undefined && height !== undefined
|
|
283
|
+
? { x: box.x, y: box.y, width, height }
|
|
284
|
+
: null;
|
|
285
|
+
const glyphed = below && frame !== null;
|
|
286
|
+
const opens = look.role === "call" && node.href !== undefined;
|
|
287
|
+
const movable = draggable || liftable;
|
|
288
|
+
const focusable = onSelect !== undefined || movable;
|
|
289
|
+
// The node's icon draws in the node's own ink (`canvasNodeInk`): it would else
|
|
290
|
+
// take the ink the page resolved before the mode scope it stands in.
|
|
291
|
+
const classes = cn(
|
|
292
|
+
canvasNode({ state: look.state, role: look.role, tone: look.surface }),
|
|
293
|
+
canvasNodeInk({ tone: look.surface }),
|
|
294
|
+
BOX,
|
|
295
|
+
opens && OPENABLE,
|
|
296
|
+
lift.lifted && HELD,
|
|
297
|
+
onSelect && look.state === "rest" && HOVERED,
|
|
298
|
+
focusable && FOCUSED,
|
|
299
|
+
draggable && GRAB,
|
|
300
|
+
lifted && LIFTED,
|
|
301
|
+
landing && INVISIBLE,
|
|
302
|
+
glyphed && FADED,
|
|
303
|
+
// A node that lands fades in at its place.
|
|
304
|
+
arrived && !landing && BLOCK_IN,
|
|
305
|
+
);
|
|
306
|
+
// A node's place is a coordinate of the flow, known at run time.
|
|
307
|
+
const place = { left: box.x, top: box.y };
|
|
308
|
+
|
|
309
|
+
useEffect(() => {
|
|
310
|
+
if (below || !refocus.current) return;
|
|
311
|
+
refocus.current = false;
|
|
312
|
+
full?.focus();
|
|
313
|
+
}, [below, full]);
|
|
314
|
+
|
|
315
|
+
// A mouse in the touch density drags at once, and the press marks the node
|
|
316
|
+
// before d3-zoom's `mousedown` reads its filter; the mark goes with the press.
|
|
317
|
+
const unpan = (element: HTMLElement) => {
|
|
318
|
+
if (touch) element.removeAttribute("data-no-pan");
|
|
319
|
+
};
|
|
320
|
+
const press = (event: PointerEvent<HTMLElement>) => {
|
|
321
|
+
if (event.button !== 0) return;
|
|
322
|
+
if (touch) event.currentTarget.setAttribute("data-no-pan", "");
|
|
323
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
324
|
+
const point = viewport.screenToFlow(client(event));
|
|
325
|
+
held.current = {
|
|
326
|
+
grab: { x: point.x - box.x, y: point.y - box.y },
|
|
327
|
+
from: client(event),
|
|
328
|
+
target: event.currentTarget,
|
|
329
|
+
};
|
|
330
|
+
moved.current = false;
|
|
331
|
+
};
|
|
332
|
+
const drag = (event: PointerEvent<HTMLElement>) => {
|
|
333
|
+
const state = held.current;
|
|
334
|
+
if (!state) return;
|
|
335
|
+
if (event.clientX !== state.from.x || event.clientY !== state.from.y)
|
|
336
|
+
moved.current = true;
|
|
337
|
+
if (!moved.current) return;
|
|
338
|
+
const follow = (point: CanvasPoint) =>
|
|
339
|
+
at(id, heldAt(viewport, point, state.grab));
|
|
340
|
+
follow(client(event));
|
|
341
|
+
viewport.edge({ point: client(event), follow });
|
|
342
|
+
};
|
|
343
|
+
const release = (event: PointerEvent<HTMLElement>) => {
|
|
344
|
+
const state = held.current;
|
|
345
|
+
if (!state) return;
|
|
346
|
+
held.current = null;
|
|
347
|
+
viewport.edge(null);
|
|
348
|
+
unpan(state.target);
|
|
349
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
350
|
+
if (!moved.current) return;
|
|
351
|
+
drop(id, heldAt(viewport, client(event), state.grab));
|
|
352
|
+
armed.current = true;
|
|
353
|
+
setTimeout(() => {
|
|
354
|
+
armed.current = false;
|
|
355
|
+
}, 0);
|
|
356
|
+
};
|
|
357
|
+
const cancel = () => {
|
|
358
|
+
const state = held.current;
|
|
359
|
+
if (!state) return;
|
|
360
|
+
held.current = null;
|
|
361
|
+
viewport.edge(null);
|
|
362
|
+
unpan(state.target);
|
|
363
|
+
at(id, null);
|
|
364
|
+
};
|
|
365
|
+
// d3 does not suppress the click that ends a drag it rejected, so the node
|
|
366
|
+
// does: neither it nor the region's ground click sees it.
|
|
367
|
+
const guard = (event: MouseEvent) => {
|
|
368
|
+
if (!armed.current) return;
|
|
369
|
+
armed.current = false;
|
|
370
|
+
swallow(event);
|
|
371
|
+
};
|
|
372
|
+
const handlers = (() => {
|
|
373
|
+
if (draggable)
|
|
374
|
+
return {
|
|
375
|
+
"data-no-pan": "",
|
|
376
|
+
onPointerDown: press,
|
|
377
|
+
onPointerMove: drag,
|
|
378
|
+
onPointerUp: release,
|
|
379
|
+
onPointerCancel: cancel,
|
|
380
|
+
onClickCapture: guard,
|
|
381
|
+
};
|
|
382
|
+
// A finger on a node pans like one on the ground until the node lifts, and
|
|
383
|
+
// the lift is the one `data-no-pan` the filter reads at the next touch.
|
|
384
|
+
if (touch)
|
|
385
|
+
return {
|
|
386
|
+
"data-no-pan": lift.lifted ? "" : undefined,
|
|
387
|
+
onPointerDown: (event: PointerEvent<HTMLElement>) => {
|
|
388
|
+
lift.bind.onPointerDown(event);
|
|
389
|
+
if (liftable && event.pointerType === "mouse") press(event);
|
|
390
|
+
},
|
|
391
|
+
onPointerMove: (event: PointerEvent<HTMLElement>) => {
|
|
392
|
+
drag(event);
|
|
393
|
+
lift.bind.onPointerMove(event);
|
|
394
|
+
},
|
|
395
|
+
onPointerUp: (event: PointerEvent<HTMLElement>) => {
|
|
396
|
+
release(event);
|
|
397
|
+
lift.bind.onPointerUp(event);
|
|
398
|
+
},
|
|
399
|
+
onPointerCancel: (event: PointerEvent<HTMLElement>) => {
|
|
400
|
+
cancel();
|
|
401
|
+
lift.bind.onPointerCancel(event);
|
|
402
|
+
},
|
|
403
|
+
onClickCapture: (event: MouseEvent) => {
|
|
404
|
+
guard(event);
|
|
405
|
+
lift.bind.onClickCapture(event);
|
|
406
|
+
},
|
|
407
|
+
onContextMenu: lift.bind.onContextMenu,
|
|
408
|
+
};
|
|
409
|
+
return {};
|
|
410
|
+
})();
|
|
411
|
+
|
|
412
|
+
const link = {
|
|
413
|
+
press(event: PointerEvent<HTMLElement>) {
|
|
414
|
+
stop(event);
|
|
415
|
+
if (event.button !== 0) return;
|
|
416
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
417
|
+
linked.current = client(event);
|
|
418
|
+
moved.current = false;
|
|
419
|
+
},
|
|
420
|
+
move(event: PointerEvent<HTMLElement>) {
|
|
421
|
+
const from = linked.current;
|
|
422
|
+
if (!from) return;
|
|
423
|
+
if (event.clientX !== from.x || event.clientY !== from.y)
|
|
424
|
+
moved.current = true;
|
|
425
|
+
const target = region.current;
|
|
426
|
+
if (!moved.current || !target) return;
|
|
427
|
+
const follow = (point: CanvasPoint) =>
|
|
428
|
+
linking(id, viewport.screenToFlow(point), hit(point, target).node);
|
|
429
|
+
follow(client(event));
|
|
430
|
+
viewport.edge({ point: client(event), follow });
|
|
431
|
+
},
|
|
432
|
+
release(event: PointerEvent<HTMLElement>) {
|
|
433
|
+
if (!linked.current) return;
|
|
434
|
+
linked.current = null;
|
|
435
|
+
viewport.edge(null);
|
|
436
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
437
|
+
linking(id, null, null);
|
|
438
|
+
const target = region.current;
|
|
439
|
+
if (!moved.current || !target) return;
|
|
440
|
+
const found = hit(client(event), target);
|
|
441
|
+
if (found.node !== null) onConnect?.(id, found.node);
|
|
442
|
+
else if (found.ground) onConnect?.(id, null);
|
|
443
|
+
},
|
|
444
|
+
cancel() {
|
|
445
|
+
if (!linked.current) return;
|
|
446
|
+
linked.current = null;
|
|
447
|
+
viewport.edge(null);
|
|
448
|
+
linking(id, null, null);
|
|
449
|
+
},
|
|
450
|
+
};
|
|
451
|
+
// On touch a port's hit stands at the target size at any zoom.
|
|
452
|
+
const reach = touch ? UNZOOM : undefined;
|
|
453
|
+
const connectors =
|
|
454
|
+
ports && !glyphed ? (
|
|
455
|
+
<>
|
|
456
|
+
<span className={cn(EDGE, EDGE_TOP)}>
|
|
457
|
+
{/* biome-ignore lint/a11y/noStaticElementInteractions: a port is a pointer shortcut; connecting by keyboard is the consumer's own sheet, so it takes no role and no key. */}
|
|
458
|
+
{/* biome-ignore lint/a11y/useKeyWithClickEvents: a port is a pointer shortcut; connecting by keyboard is the consumer's own sheet, so it takes no role and no key. */}
|
|
459
|
+
<span
|
|
460
|
+
data-port="in"
|
|
461
|
+
data-node={id}
|
|
462
|
+
data-no-pan
|
|
463
|
+
onPointerDown={stop}
|
|
464
|
+
onClick={swallow}
|
|
465
|
+
style={reach}
|
|
466
|
+
className={cn(CANVAS_PORT_HIT, HIT, PORT_IN)}
|
|
467
|
+
>
|
|
468
|
+
<span className={cn(CANVAS_PORT, "shrink-0", targeted && TARGET)} />
|
|
469
|
+
</span>
|
|
470
|
+
</span>
|
|
471
|
+
<span className={cn(EDGE, EDGE_BOTTOM)}>
|
|
472
|
+
{/* biome-ignore lint/a11y/noStaticElementInteractions: a port is a pointer shortcut; connecting by keyboard is the consumer's own sheet, so it takes no role and no key. */}
|
|
473
|
+
{/* biome-ignore lint/a11y/useKeyWithClickEvents: a port is a pointer shortcut; connecting by keyboard is the consumer's own sheet, so it takes no role and no key. */}
|
|
474
|
+
<span
|
|
475
|
+
data-port="out"
|
|
476
|
+
data-node={id}
|
|
477
|
+
data-no-pan
|
|
478
|
+
onPointerDown={link.press}
|
|
479
|
+
onPointerMove={link.move}
|
|
480
|
+
onPointerUp={link.release}
|
|
481
|
+
onPointerCancel={link.cancel}
|
|
482
|
+
onClick={swallow}
|
|
483
|
+
style={reach}
|
|
484
|
+
className={cn(CANVAS_PORT_HIT, HIT, PORT_OUT)}
|
|
485
|
+
>
|
|
486
|
+
<span className={cn(CANVAS_PORT, "shrink-0")} />
|
|
487
|
+
</span>
|
|
488
|
+
</span>
|
|
489
|
+
</>
|
|
490
|
+
) : null;
|
|
491
|
+
|
|
492
|
+
// A decision's icon stands in its diamond, which sits behind it.
|
|
493
|
+
const icon =
|
|
494
|
+
look.role === "decision" ? (
|
|
495
|
+
<span className={MARK_BOX}>
|
|
496
|
+
<span
|
|
497
|
+
aria-hidden
|
|
498
|
+
className={canvasNodeGlyph({
|
|
499
|
+
state: look.state,
|
|
500
|
+
role: "decision",
|
|
501
|
+
tone: look.surface,
|
|
502
|
+
})}
|
|
503
|
+
/>
|
|
504
|
+
<Icon name={node.icon} fit="meta" />
|
|
505
|
+
</span>
|
|
506
|
+
) : (
|
|
507
|
+
<Icon name={node.icon} fit="meta" />
|
|
508
|
+
);
|
|
509
|
+
// The status is a badge; the line (the warning in its place) is text under it.
|
|
510
|
+
const meta = (
|
|
511
|
+
<>
|
|
512
|
+
{status ? (
|
|
513
|
+
<span className={BADGE_ROW}>
|
|
514
|
+
<StatusBadge status={status} />
|
|
515
|
+
</span>
|
|
516
|
+
) : null}
|
|
517
|
+
{body ? part("line", body) : null}
|
|
518
|
+
</>
|
|
519
|
+
);
|
|
520
|
+
const content = (
|
|
521
|
+
<>
|
|
522
|
+
{icon}
|
|
523
|
+
<span className={COLUMN}>
|
|
524
|
+
{node.overline ? part("overline", node.overline) : null}
|
|
525
|
+
{part("title", node.title)}
|
|
526
|
+
{meta}
|
|
527
|
+
</span>
|
|
528
|
+
{figure === undefined && !look.warning ? null : (
|
|
529
|
+
<span className={TRAILING}>
|
|
530
|
+
{figure === undefined ? null : <Count value={figure} />}
|
|
531
|
+
{look.warning ? <StatusDot tone="failed" /> : null}
|
|
532
|
+
</span>
|
|
533
|
+
)}
|
|
534
|
+
{connectors}
|
|
535
|
+
</>
|
|
536
|
+
);
|
|
537
|
+
const focused = keyboardFocus(id, onFocusVisible);
|
|
538
|
+
// An arrow moves a movable node by a step (`keyStep`), as a drop does.
|
|
539
|
+
const nudge = (event: KeyboardEvent<HTMLButtonElement>) => {
|
|
540
|
+
const by = keyStep(event.key, event.shiftKey);
|
|
541
|
+
if (!movable || !by) return;
|
|
542
|
+
event.preventDefault();
|
|
543
|
+
drop(id, { x: box.x + by.x, y: box.y + by.y });
|
|
544
|
+
};
|
|
545
|
+
const element = focusable ? (
|
|
546
|
+
<button
|
|
547
|
+
type="button"
|
|
548
|
+
ref={measure}
|
|
549
|
+
data-node={id}
|
|
550
|
+
data-focus={id}
|
|
551
|
+
data-lifted={lift.lifted ? "" : undefined}
|
|
552
|
+
inert={glyphed}
|
|
553
|
+
aria-hidden={glyphed || undefined}
|
|
554
|
+
style={place}
|
|
555
|
+
onClick={onSelect && (() => onSelect(id))}
|
|
556
|
+
onKeyDown={nudge}
|
|
557
|
+
onFocus={focused}
|
|
558
|
+
className={classes}
|
|
559
|
+
{...handlers}
|
|
560
|
+
>
|
|
561
|
+
{content}
|
|
562
|
+
</button>
|
|
563
|
+
) : (
|
|
564
|
+
<div
|
|
565
|
+
ref={measure}
|
|
566
|
+
data-node={id}
|
|
567
|
+
data-lifted={lift.lifted ? "" : undefined}
|
|
568
|
+
inert={glyphed}
|
|
569
|
+
aria-hidden={glyphed || undefined}
|
|
570
|
+
style={place}
|
|
571
|
+
className={classes}
|
|
572
|
+
{...handlers}
|
|
573
|
+
>
|
|
574
|
+
{content}
|
|
575
|
+
</div>
|
|
576
|
+
);
|
|
577
|
+
// A tap, a click and a key all zoom to the node at its own size about its
|
|
578
|
+
// centre, which stays where it stands, and bring the full form back; they never select it. A key's click hands focus on to it.
|
|
579
|
+
const glyph = glyphed ? (
|
|
580
|
+
// The glyph box's place and size are coordinates of the flow, known at run time.
|
|
581
|
+
<div
|
|
582
|
+
data-node={id}
|
|
583
|
+
className={cn(GLYPH_BOX, FLOW_IN)}
|
|
584
|
+
style={{
|
|
585
|
+
left: frame.x,
|
|
586
|
+
top: frame.y,
|
|
587
|
+
width: frame.width,
|
|
588
|
+
height: frame.height,
|
|
589
|
+
}}
|
|
590
|
+
>
|
|
591
|
+
<button
|
|
592
|
+
type="button"
|
|
593
|
+
// The name the glyph carries alone, and whole where the overview cuts it: a native tooltip, which also names the button for axe and voice control.
|
|
594
|
+
title={
|
|
595
|
+
look.shows === "off" ? `${node.title}, ${words.off}` : node.title
|
|
596
|
+
}
|
|
597
|
+
data-focus={id}
|
|
598
|
+
onClick={(event) => {
|
|
599
|
+
refocus.current = event.detail === 0;
|
|
600
|
+
viewport.zoomTo(about(id));
|
|
601
|
+
}}
|
|
602
|
+
onFocus={focused}
|
|
603
|
+
onPointerDown={lift.bind.onPointerDown}
|
|
604
|
+
onPointerMove={lift.bind.onPointerMove}
|
|
605
|
+
onPointerUp={lift.bind.onPointerUp}
|
|
606
|
+
onPointerCancel={lift.bind.onPointerCancel}
|
|
607
|
+
onClickCapture={lift.bind.onClickCapture}
|
|
608
|
+
style={UNZOOM}
|
|
609
|
+
className={cn(
|
|
610
|
+
GLYPH,
|
|
611
|
+
PATH_TONE,
|
|
612
|
+
canvasNodeInk({ tone: look.surface }),
|
|
613
|
+
FOCUSED,
|
|
614
|
+
)}
|
|
615
|
+
>
|
|
616
|
+
<span
|
|
617
|
+
aria-hidden
|
|
618
|
+
data-shape
|
|
619
|
+
className={canvasNodeGlyph({
|
|
620
|
+
state: look.state,
|
|
621
|
+
role: look.role,
|
|
622
|
+
tone: look.surface,
|
|
623
|
+
})}
|
|
624
|
+
/>
|
|
625
|
+
<Icon name={node.icon} fit="body" />
|
|
626
|
+
{/* An off node says Off at every zoom, the overview and the glyph alone included, where words drop: a slash through its icon. */}
|
|
627
|
+
{look.shows === "off" ? (
|
|
628
|
+
<span aria-hidden data-off className={OFF_MARK}>
|
|
629
|
+
<Icon name="Slash" fit="body" />
|
|
630
|
+
</span>
|
|
631
|
+
) : null}
|
|
632
|
+
{bare ? null : (
|
|
633
|
+
<span
|
|
634
|
+
data-name
|
|
635
|
+
className={cn(canvasNodeName({ tone: look.tone }), NAME)}
|
|
636
|
+
>
|
|
637
|
+
{node.title}
|
|
638
|
+
</span>
|
|
639
|
+
)}
|
|
640
|
+
{look.status && node.status ? (
|
|
641
|
+
<span
|
|
642
|
+
className={canvasNodeMark({ role: look.role, place: "status" })}
|
|
643
|
+
>
|
|
644
|
+
<StatusDot tone={node.status.tone} />
|
|
645
|
+
</span>
|
|
646
|
+
) : null}
|
|
647
|
+
{look.warning ? (
|
|
648
|
+
<span
|
|
649
|
+
className={canvasNodeMark({ role: look.role, place: "warning" })}
|
|
650
|
+
>
|
|
651
|
+
<StatusDot tone="failed" />
|
|
652
|
+
</span>
|
|
653
|
+
) : null}
|
|
654
|
+
</button>
|
|
655
|
+
</div>
|
|
656
|
+
) : null;
|
|
657
|
+
// The open act of a call node, over the card's own box at its end. It is the
|
|
658
|
+
// card's sibling (an anchor cannot stand in a button), so it never selects
|
|
659
|
+
// the node, and a drag from it pans no more than from the zoom stack.
|
|
660
|
+
const open =
|
|
661
|
+
opens && !glyphed && frame !== null && node.href !== undefined ? (
|
|
662
|
+
<div
|
|
663
|
+
data-no-pan
|
|
664
|
+
className={OPEN_BOX}
|
|
665
|
+
// The box's place and size are coordinates of the flow, known at run time.
|
|
666
|
+
style={{
|
|
667
|
+
left: frame.x,
|
|
668
|
+
top: frame.y,
|
|
669
|
+
width: frame.width,
|
|
670
|
+
height: frame.height,
|
|
671
|
+
}}
|
|
672
|
+
>
|
|
673
|
+
<span className={OPEN_ACT}>
|
|
674
|
+
<IconButtonLink
|
|
675
|
+
icon="ArrowUpRight"
|
|
676
|
+
label={named(words.open, node.title)}
|
|
677
|
+
href={node.href}
|
|
678
|
+
/>
|
|
679
|
+
</span>
|
|
680
|
+
</div>
|
|
681
|
+
) : null;
|
|
682
|
+
return (
|
|
683
|
+
<>
|
|
684
|
+
{element}
|
|
685
|
+
{open}
|
|
686
|
+
{glyph}
|
|
687
|
+
</>
|
|
688
|
+
);
|
|
689
|
+
}
|