@xeonr/platform-ui 1.11.0 → 1.12.0
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/dist/auth/AuthCode.d.ts +48 -0
- package/dist/auth/AuthCode.d.ts.map +1 -0
- package/dist/auth/AuthCode.js +197 -0
- package/dist/auth/AuthCode.js.map +1 -0
- package/dist/auth/AuthConsent.d.ts +69 -0
- package/dist/auth/AuthConsent.d.ts.map +1 -0
- package/dist/auth/AuthConsent.js +155 -0
- package/dist/auth/AuthConsent.js.map +1 -0
- package/dist/auth/AuthControls.d.ts +133 -0
- package/dist/auth/AuthControls.d.ts.map +1 -0
- package/dist/auth/AuthControls.js +379 -0
- package/dist/auth/AuthControls.js.map +1 -0
- package/dist/auth/AuthPanel.d.ts +106 -0
- package/dist/auth/AuthPanel.d.ts.map +1 -0
- package/dist/auth/AuthPanel.js +317 -0
- package/dist/auth/AuthPanel.js.map +1 -0
- package/dist/auth.d.ts +5 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +15 -0
- package/dist/auth.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kit/Anchored.js +109 -109
- package/dist/kit/Anchored.js.map +1 -1
- package/dist/kit/ApiKeyForm.js +73 -73
- package/dist/kit/ApiKeyForm.js.map +1 -1
- package/dist/kit/ApiKeys.js +144 -144
- package/dist/kit/ApiKeys.js.map +1 -1
- package/dist/kit/Badge.js +45 -45
- package/dist/kit/Badge.js.map +1 -1
- package/dist/kit/Blocks.d.ts.map +1 -1
- package/dist/kit/Blocks.js +103 -102
- package/dist/kit/Blocks.js.map +1 -1
- package/dist/kit/Board.js +54 -54
- package/dist/kit/Board.js.map +1 -1
- package/dist/kit/Button.d.ts +3 -3
- package/dist/kit/Button.d.ts.map +1 -1
- package/dist/kit/Button.js +55 -50
- package/dist/kit/Button.js.map +1 -1
- package/dist/kit/Card.d.ts.map +1 -1
- package/dist/kit/Card.js +36 -29
- package/dist/kit/Card.js.map +1 -1
- package/dist/kit/ChartFrame.js +54 -54
- package/dist/kit/ChartFrame.js.map +1 -1
- package/dist/kit/ChartTypes.js +215 -215
- package/dist/kit/ChartTypes.js.map +1 -1
- package/dist/kit/Charts.js +605 -605
- package/dist/kit/Charts.js.map +1 -1
- package/dist/kit/Checkbox.js +16 -16
- package/dist/kit/Checkbox.js.map +1 -1
- package/dist/kit/Chip.js +21 -21
- package/dist/kit/Chip.js.map +1 -1
- package/dist/kit/Choice.js +24 -24
- package/dist/kit/Choice.js.map +1 -1
- package/dist/kit/CodeEditor.js +25 -25
- package/dist/kit/CodeEditor.js.map +1 -1
- package/dist/kit/Color.js +74 -74
- package/dist/kit/Color.js.map +1 -1
- package/dist/kit/Combobox.js +67 -67
- package/dist/kit/Combobox.js.map +1 -1
- package/dist/kit/CommandPalette.d.ts.map +1 -1
- package/dist/kit/CommandPalette.js +96 -86
- package/dist/kit/CommandPalette.js.map +1 -1
- package/dist/kit/Comment.js +7 -7
- package/dist/kit/Comment.js.map +1 -1
- package/dist/kit/Controls.js +122 -122
- package/dist/kit/Controls.js.map +1 -1
- package/dist/kit/DataGrid.js +97 -97
- package/dist/kit/DataGrid.js.map +1 -1
- package/dist/kit/DataTable.d.ts.map +1 -1
- package/dist/kit/DataTable.js +196 -195
- package/dist/kit/DataTable.js.map +1 -1
- package/dist/kit/DatePicker.js +242 -242
- package/dist/kit/DatePicker.js.map +1 -1
- package/dist/kit/Drawer.d.ts.map +1 -1
- package/dist/kit/Drawer.js +15 -14
- package/dist/kit/Drawer.js.map +1 -1
- package/dist/kit/Dropzone.js +80 -80
- package/dist/kit/Dropzone.js.map +1 -1
- package/dist/kit/Editable.d.ts.map +1 -1
- package/dist/kit/Editable.js +130 -129
- package/dist/kit/Editable.js.map +1 -1
- package/dist/kit/EmptyState.d.ts.map +1 -1
- package/dist/kit/EmptyState.js +14 -13
- package/dist/kit/EmptyState.js.map +1 -1
- package/dist/kit/EntityHeader.d.ts.map +1 -1
- package/dist/kit/EntityHeader.js +17 -16
- package/dist/kit/EntityHeader.js.map +1 -1
- package/dist/kit/Facet.js +52 -52
- package/dist/kit/Facet.js.map +1 -1
- package/dist/kit/FacetRail.js +91 -91
- package/dist/kit/FacetRail.js.map +1 -1
- package/dist/kit/Forbidden.js +7 -7
- package/dist/kit/Forbidden.js.map +1 -1
- package/dist/kit/Form.d.ts.map +1 -1
- package/dist/kit/Form.js +144 -143
- package/dist/kit/Form.js.map +1 -1
- package/dist/kit/Graph.js +429 -429
- package/dist/kit/Graph.js.map +1 -1
- package/dist/kit/GroupedMultiSelect.js +115 -115
- package/dist/kit/GroupedMultiSelect.js.map +1 -1
- package/dist/kit/Icon.d.ts +2 -0
- package/dist/kit/Icon.d.ts.map +1 -1
- package/dist/kit/Icon.js +3 -1
- package/dist/kit/Icon.js.map +1 -1
- package/dist/kit/JumpList.js +11 -11
- package/dist/kit/JumpList.js.map +1 -1
- package/dist/kit/KV.js +6 -6
- package/dist/kit/KV.js.map +1 -1
- package/dist/kit/Layout.js +5 -5
- package/dist/kit/Layout.js.map +1 -1
- package/dist/kit/List.js +74 -74
- package/dist/kit/List.js.map +1 -1
- package/dist/kit/LogView.js +68 -68
- package/dist/kit/LogView.js.map +1 -1
- package/dist/kit/Markdown.js +37 -37
- package/dist/kit/Markdown.js.map +1 -1
- package/dist/kit/Marker.js +42 -42
- package/dist/kit/Marker.js.map +1 -1
- package/dist/kit/Menu.js +128 -128
- package/dist/kit/Menu.js.map +1 -1
- package/dist/kit/Modal.d.ts.map +1 -1
- package/dist/kit/Modal.js +86 -75
- package/dist/kit/Modal.js.map +1 -1
- package/dist/kit/MultiCombobox.js +157 -157
- package/dist/kit/MultiCombobox.js.map +1 -1
- package/dist/kit/PageHeader.d.ts.map +1 -1
- package/dist/kit/PageHeader.js +8 -7
- package/dist/kit/PageHeader.js.map +1 -1
- package/dist/kit/Panel.d.ts.map +1 -1
- package/dist/kit/Panel.js +33 -14
- package/dist/kit/Panel.js.map +1 -1
- package/dist/kit/Picker.js +159 -159
- package/dist/kit/Picker.js.map +1 -1
- package/dist/kit/PipelineFlow.js +86 -86
- package/dist/kit/PipelineFlow.js.map +1 -1
- package/dist/kit/Popover.js +67 -67
- package/dist/kit/Popover.js.map +1 -1
- package/dist/kit/Range.js +76 -76
- package/dist/kit/Range.js.map +1 -1
- package/dist/kit/Reorder.js +95 -95
- package/dist/kit/Reorder.js.map +1 -1
- package/dist/kit/Search.js +27 -27
- package/dist/kit/Search.js.map +1 -1
- package/dist/kit/Secret.js +26 -26
- package/dist/kit/Secret.js.map +1 -1
- package/dist/kit/Skeleton.js +14 -14
- package/dist/kit/Skeleton.js.map +1 -1
- package/dist/kit/Sparkline.js +51 -51
- package/dist/kit/Sparkline.js.map +1 -1
- package/dist/kit/Spectrum.js +163 -163
- package/dist/kit/Spectrum.js.map +1 -1
- package/dist/kit/Splash.js +3 -3
- package/dist/kit/Splash.js.map +1 -1
- package/dist/kit/Split.js +13 -13
- package/dist/kit/Split.js.map +1 -1
- package/dist/kit/SplitButton.d.ts.map +1 -1
- package/dist/kit/SplitButton.js +8 -6
- package/dist/kit/SplitButton.js.map +1 -1
- package/dist/kit/Stat.d.ts.map +1 -1
- package/dist/kit/Stat.js +61 -60
- package/dist/kit/Stat.js.map +1 -1
- package/dist/kit/Stepper.js +22 -22
- package/dist/kit/Stepper.js.map +1 -1
- package/dist/kit/TabStrip.js +68 -68
- package/dist/kit/TabStrip.js.map +1 -1
- package/dist/kit/Text.js +63 -63
- package/dist/kit/Text.js.map +1 -1
- package/dist/kit/Toast.js +29 -29
- package/dist/kit/Toast.js.map +1 -1
- package/dist/kit/Tooltip.js +83 -83
- package/dist/kit/Tooltip.js.map +1 -1
- package/dist/kit/Trace.js +33 -33
- package/dist/kit/Trace.js.map +1 -1
- package/dist/kit/Upload.js +88 -88
- package/dist/kit/Upload.js.map +1 -1
- package/dist/theme/ThemeProvider.d.ts +17 -1
- package/dist/theme/ThemeProvider.d.ts.map +1 -1
- package/dist/theme/ThemeProvider.js +40 -4
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/theme/ThemeScope.d.ts +9 -1
- package/dist/theme/ThemeScope.d.ts.map +1 -1
- package/dist/theme/ThemeScope.js +11 -4
- package/dist/theme/ThemeScope.js.map +1 -1
- package/dist/theme/tokens.d.ts +48 -0
- package/dist/theme/tokens.d.ts.map +1 -1
- package/dist/theme/tokens.js +167 -3
- package/dist/theme/tokens.js.map +1 -1
- package/package.json +8 -2
- package/scripts/stable-styled-ids.mjs +75 -0
package/dist/kit/Graph.js
CHANGED
|
@@ -14,20 +14,20 @@ const BAND_H = 24;
|
|
|
14
14
|
const DOT = 9;
|
|
15
15
|
const portKey = (node, port, side) => `${side}|${node}|${port}`;
|
|
16
16
|
const TONE_STROKE = {
|
|
17
|
-
|
|
17
|
+
brand: v.brand, ok: v.success, warn: v.warning, crit: v.danger, info: v.info, run: v.running, mut: v.faint, data: v.data
|
|
18
18
|
};
|
|
19
19
|
const TONE_BG = {
|
|
20
|
-
|
|
20
|
+
brand: v.brand08, ok: v.successBg, warn: v.warningBg, crit: v.dangerBg, info: v.infoBg, run: v.runningBg, mut: v.hover, data: v.dataBg
|
|
21
21
|
};
|
|
22
22
|
/** A cubic from an output dot to an input dot; loops back when the input is behind. */
|
|
23
23
|
function curve(a, b) {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
const dx = Math.max(40, Math.abs(b.x - a.x) / 2);
|
|
25
|
+
return `M${a.x},${a.y} C${a.x + dx},${a.y} ${b.x - dx},${b.y} ${b.x},${b.y}`;
|
|
26
26
|
}
|
|
27
27
|
function midpoint(a, b) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
// The midpoint of the cubic above, which for symmetric control points is the
|
|
29
|
+
// average of the ends.
|
|
30
|
+
return { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };
|
|
31
31
|
}
|
|
32
32
|
const LANE_H = 12;
|
|
33
33
|
const CORNER = 8;
|
|
@@ -39,44 +39,44 @@ const STUB = 14;
|
|
|
39
39
|
* not overlap.
|
|
40
40
|
*/
|
|
41
41
|
function laned(a, b, laneY) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
const x1 = a.x + STUB;
|
|
43
|
+
const x2 = b.x - STUB;
|
|
44
|
+
const r = CORNER;
|
|
45
|
+
return `M${a.x},${a.y} H${x1 - r} Q${x1},${a.y} ${x1},${a.y + r} V${laneY - r} Q${x1},${laneY} ${x1 + r},${laneY}` +
|
|
46
|
+
` H${x2 - r} Q${x2},${laneY} ${x2},${laneY - r} V${b.y + r} Q${x2},${b.y} ${x2 + r},${b.y} H${b.x}`;
|
|
47
47
|
}
|
|
48
48
|
/** Which edges go under the row, and in which lane. */
|
|
49
49
|
function assignLanes(nodes, edges) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
50
|
+
const order = new Map(nodes.map((n, i) => [n.id, i]));
|
|
51
|
+
const spans = [];
|
|
52
|
+
for (const e of edges) {
|
|
53
|
+
const i = order.get(e.from.node);
|
|
54
|
+
const j = order.get(e.to.node);
|
|
55
|
+
if (i === undefined || j === undefined || j === i + 1)
|
|
56
|
+
continue;
|
|
57
|
+
spans.push({ id: e.id, i: Math.min(i, j), j: Math.max(i, j) });
|
|
58
|
+
}
|
|
59
|
+
// The shortest span takes the lane nearest the row, so an edge's stubs cross
|
|
60
|
+
// as few other lanes as the shared source allows.
|
|
61
|
+
spans.sort((p, q) => p.i - q.i || p.j - q.j);
|
|
62
|
+
const lanes = [];
|
|
63
|
+
const out = new Map();
|
|
64
|
+
for (const sp of spans) {
|
|
65
|
+
let lane = lanes.findIndex((last) => last <= sp.i);
|
|
66
|
+
if (lane === -1) {
|
|
67
|
+
lane = lanes.length;
|
|
68
|
+
lanes.push(sp.j);
|
|
69
|
+
} else
|
|
70
|
+
|
|
71
|
+
lanes[lane] = sp.j;
|
|
72
|
+
out.set(sp.id, lane);
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
75
|
}
|
|
76
76
|
// ---------------------------------------------------------------------------
|
|
77
77
|
// Styles
|
|
78
78
|
// ---------------------------------------------------------------------------
|
|
79
|
-
const Surface = styled.div `
|
|
79
|
+
const Surface = styled.div.withConfig({ componentId: "sc-yq0u64-0" })`
|
|
80
80
|
position: relative;
|
|
81
81
|
overflow: auto;
|
|
82
82
|
border: 1px solid ${v.line};
|
|
@@ -85,15 +85,15 @@ const Surface = styled.div `
|
|
|
85
85
|
background-image: radial-gradient(${v.line} 1px, transparent 1px);
|
|
86
86
|
background-size: 16px 16px;
|
|
87
87
|
`;
|
|
88
|
-
const Content = styled.div `
|
|
88
|
+
const Content = styled.div.withConfig({ componentId: "sc-yq0u64-1" })`
|
|
89
89
|
position: relative;
|
|
90
90
|
display: inline-flex;
|
|
91
91
|
align-items: flex-start;
|
|
92
92
|
gap: ${GAP}px;
|
|
93
|
-
padding: ${(p) =>
|
|
93
|
+
padding: ${(p) => p.$band ? PAD + BAND_H : PAD}px ${PAD}px ${(p) => PAD + (p.$lanes ? 6 + p.$lanes * LANE_H : 0)}px;
|
|
94
94
|
min-width: 100%;
|
|
95
95
|
`;
|
|
96
|
-
const Band = styled.div `
|
|
96
|
+
const Band = styled.div.withConfig({ componentId: "sc-yq0u64-2" })`
|
|
97
97
|
position: absolute;
|
|
98
98
|
height: ${BAND_H - 6}px;
|
|
99
99
|
padding: 0 8px;
|
|
@@ -101,7 +101,7 @@ const Band = styled.div `
|
|
|
101
101
|
align-items: center;
|
|
102
102
|
gap: 6px;
|
|
103
103
|
border: 1px dashed ${v.brand55};
|
|
104
|
-
border-radius: 5px;
|
|
104
|
+
border-radius: min(5px, ${v.rCtl});
|
|
105
105
|
background: ${v.brand08};
|
|
106
106
|
color: ${v.brand};
|
|
107
107
|
font-size: 10.5px;
|
|
@@ -111,29 +111,29 @@ const Band = styled.div `
|
|
|
111
111
|
pointer-events: none;
|
|
112
112
|
code { font-family: ${v.mono}; font-weight: 500; }
|
|
113
113
|
`;
|
|
114
|
-
const NodeBox = styled.div `
|
|
114
|
+
const NodeBox = styled.div.withConfig({ componentId: "sc-yq0u64-3" })`
|
|
115
115
|
position: relative;
|
|
116
116
|
flex: none;
|
|
117
117
|
width: ${(p) => p.$w}px;
|
|
118
|
-
border-radius: 10px;
|
|
119
|
-
background: ${(p) =>
|
|
120
|
-
border: ${(p) =>
|
|
121
|
-
box-shadow: ${(p) =>
|
|
118
|
+
border-radius: min(10px, ${v.rCard});
|
|
119
|
+
background: ${(p) => p.$dim ? v.surface2 : v.surface};
|
|
120
|
+
border: ${(p) => p.$dim ? "1px dashed" : "1.5px solid"} ${(p) => p.$selected ? v.brand : p.$dim ? v.line2 : TONE_STROKE[p.$tone] === v.faint ? v.line2 : TONE_STROKE[p.$tone]};
|
|
121
|
+
box-shadow: ${(p) => p.$selected ? `0 0 0 3px ${v.brand22}` : "none"};
|
|
122
122
|
color: ${v.text};
|
|
123
|
-
cursor: ${(p) =>
|
|
123
|
+
cursor: ${(p) => p.$selectable ? "pointer" : "default"};
|
|
124
124
|
outline: none;
|
|
125
|
-
${(p) => p.$selectable && css
|
|
125
|
+
${(p) => p.$selectable && css`&:hover { border-color: ${v.brand}; }`}
|
|
126
126
|
&:focus-visible { box-shadow: ${v.ring}; }
|
|
127
127
|
`;
|
|
128
|
-
const Head = styled.div `
|
|
128
|
+
const Head = styled.div.withConfig({ componentId: "sc-yq0u64-4" })`
|
|
129
129
|
display: flex;
|
|
130
130
|
align-items: center;
|
|
131
131
|
justify-content: space-between;
|
|
132
132
|
gap: 6px;
|
|
133
133
|
padding: 6px 10px;
|
|
134
134
|
border-bottom: 1px solid ${v.line};
|
|
135
|
-
border-radius: 9px 9px 0 0;
|
|
136
|
-
background: ${(p) =>
|
|
135
|
+
border-radius: min(9px, ${v.rCard}) min(9px, ${v.rCard}) 0 0;
|
|
136
|
+
background: ${(p) => p.$dim || p.$tone === "mut" ? "transparent" : TONE_BG[p.$tone]};
|
|
137
137
|
min-width: 0;
|
|
138
138
|
& > .title { flex: 1 1 auto; display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 600; font-size: 12.5px; }
|
|
139
139
|
/* The kind gives way before the title does: a step called "resize" keeps
|
|
@@ -145,7 +145,7 @@ const Head = styled.div `
|
|
|
145
145
|
& > .title > strong:only-child { flex: 0 1 auto; max-width: 100%; }
|
|
146
146
|
& > .badge { flex: none; display: inline-flex; }
|
|
147
147
|
`;
|
|
148
|
-
const Body = styled.div `
|
|
148
|
+
const Body = styled.div.withConfig({ componentId: "sc-yq0u64-5" })`
|
|
149
149
|
display: flex;
|
|
150
150
|
align-items: flex-start;
|
|
151
151
|
gap: 4px;
|
|
@@ -153,12 +153,12 @@ const Body = styled.div `
|
|
|
153
153
|
min-height: 34px;
|
|
154
154
|
& > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
|
|
155
155
|
`;
|
|
156
|
-
const PortRow = styled.div `
|
|
156
|
+
const PortRow = styled.div.withConfig({ componentId: "sc-yq0u64-6" })`
|
|
157
157
|
position: relative;
|
|
158
158
|
min-height: 20px;
|
|
159
159
|
min-width: 0;
|
|
160
|
-
padding: ${(p) =>
|
|
161
|
-
text-align: ${(p) =>
|
|
160
|
+
padding: ${(p) => p.$side === "in" ? "1px 4px 1px 14px" : "1px 14px 1px 4px"};
|
|
161
|
+
text-align: ${(p) => p.$side === "in" ? "left" : "right"};
|
|
162
162
|
font-size: 11.5px;
|
|
163
163
|
line-height: 18px;
|
|
164
164
|
& > .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
@@ -166,26 +166,26 @@ const PortRow = styled.div `
|
|
|
166
166
|
& > .label.required { font-weight: 600; }
|
|
167
167
|
& > .value { color: ${v.faint}; font-family: ${v.mono}; font-size: 10.5px; line-height: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
168
168
|
`;
|
|
169
|
-
const Dot = styled.span `
|
|
169
|
+
const Dot = styled.span.withConfig({ componentId: "sc-yq0u64-7" })`
|
|
170
170
|
position: absolute;
|
|
171
171
|
top: 5px;
|
|
172
|
-
${(p) =>
|
|
172
|
+
${(p) => p.$side === "in" ? "left" : "right"}: -${DOT / 2 + 1}px;
|
|
173
173
|
width: ${DOT}px;
|
|
174
174
|
height: ${DOT}px;
|
|
175
175
|
border-radius: 50%;
|
|
176
|
-
background: ${(p) =>
|
|
176
|
+
background: ${(p) => p.$target ? v.success : v.brand};
|
|
177
177
|
border: 1.5px solid ${v.surface};
|
|
178
178
|
box-sizing: border-box;
|
|
179
|
-
${(p) => p.$live && css
|
|
180
|
-
${(p) => p.$target && css
|
|
179
|
+
${(p) => p.$live && css`cursor: crosshair; &:hover { transform: scale(1.35); }`}
|
|
180
|
+
${(p) => p.$target && css`transform: scale(1.5); box-shadow: 0 0 0 3px ${v.successBg};`}
|
|
181
181
|
transition: transform 80ms ease;
|
|
182
182
|
`;
|
|
183
|
-
const NoPorts = styled.div `
|
|
183
|
+
const NoPorts = styled.div.withConfig({ componentId: "sc-yq0u64-8" })`
|
|
184
184
|
color: ${v.faint};
|
|
185
185
|
font-size: 11px;
|
|
186
186
|
padding: 1px 8px;
|
|
187
187
|
`;
|
|
188
|
-
const Foot = styled.div `
|
|
188
|
+
const Foot = styled.div.withConfig({ componentId: "sc-yq0u64-9" })`
|
|
189
189
|
padding: 4px 10px 6px;
|
|
190
190
|
border-top: 1px solid ${v.line};
|
|
191
191
|
font-size: 11px;
|
|
@@ -194,8 +194,8 @@ const Foot = styled.div `
|
|
|
194
194
|
& > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
195
195
|
& > .note { color: ${v.danger}; }
|
|
196
196
|
`;
|
|
197
|
-
const march = keyframes
|
|
198
|
-
const Overlay = styled.svg `
|
|
197
|
+
const march = keyframes`to { stroke-dashoffset: -20; }`;
|
|
198
|
+
const Overlay = styled.svg.withConfig({ componentId: "sc-yq0u64-10" })`
|
|
199
199
|
position: absolute;
|
|
200
200
|
top: 0;
|
|
201
201
|
left: 0;
|
|
@@ -209,11 +209,11 @@ const Overlay = styled.svg `
|
|
|
209
209
|
.flow { fill: none; stroke: ${v.faint}; stroke-width: 1.25px; stroke-dasharray: 5 4; opacity: 0.7; }
|
|
210
210
|
.draft { fill: none; stroke: ${v.brand}; stroke-width: 1.5px; stroke-dasharray: 4 3; }
|
|
211
211
|
`;
|
|
212
|
-
const EdgeLabel = styled.div `
|
|
212
|
+
const EdgeLabel = styled.div.withConfig({ componentId: "sc-yq0u64-11" })`
|
|
213
213
|
position: absolute;
|
|
214
214
|
transform: translate(-50%, -50%);
|
|
215
215
|
padding: 1px 6px;
|
|
216
|
-
border-radius: 4px;
|
|
216
|
+
border-radius: min(4px, ${v.rCtl});
|
|
217
217
|
font-size: 10px;
|
|
218
218
|
font-weight: 600;
|
|
219
219
|
white-space: nowrap;
|
|
@@ -222,7 +222,7 @@ const EdgeLabel = styled.div `
|
|
|
222
222
|
border: 1px solid ${(p) => TONE_STROKE[p.$tone]};
|
|
223
223
|
pointer-events: none;
|
|
224
224
|
`;
|
|
225
|
-
const Remove = styled.button `
|
|
225
|
+
const Remove = styled.button.withConfig({ componentId: "sc-yq0u64-12" })`
|
|
226
226
|
position: absolute;
|
|
227
227
|
transform: translate(-50%, -50%);
|
|
228
228
|
width: 20px;
|
|
@@ -239,7 +239,7 @@ const Remove = styled.button `
|
|
|
239
239
|
box-shadow: 0 1px 2px ${v.scrim};
|
|
240
240
|
&:hover { background: ${v.dangerBg}; }
|
|
241
241
|
`;
|
|
242
|
-
const Empty = styled.div `
|
|
242
|
+
const Empty = styled.div.withConfig({ componentId: "sc-yq0u64-13" })`
|
|
243
243
|
padding: 22px;
|
|
244
244
|
text-align: center;
|
|
245
245
|
color: ${v.faint};
|
|
@@ -257,258 +257,258 @@ const Empty = styled.div `
|
|
|
257
257
|
* `Steps` walkthrough or a `RowList`; a tree is a `RowList` with `depth`.
|
|
258
258
|
*/
|
|
259
259
|
export function Graph(props) {
|
|
260
|
-
|
|
260
|
+
return props.layout === "layered" ? _jsx(LayeredGraph, { ...props }) : _jsx(RowGraph, { ...props });
|
|
261
261
|
}
|
|
262
|
-
function RowGraph({ nodes, edges, mode = "view", selected = null, onSelect, onConnect, onDisconnect, flow = true, minHeight = 200, empty, label, className
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
262
|
+
function RowGraph({ nodes, edges, mode = "view", selected = null, onSelect, onConnect, onDisconnect, flow = true, minHeight = 200, empty, label, className }) {
|
|
263
|
+
const content = useRef(null);
|
|
264
|
+
const portEls = useRef(new Map());
|
|
265
|
+
const nodeEls = useRef(new Map());
|
|
266
|
+
const [m, setM] = useState(null);
|
|
267
|
+
const [picked, setPicked] = useState(null);
|
|
268
|
+
const [draft, setDraft] = useState(null);
|
|
269
|
+
// A drag that started on a port ends with a click on the node it sits in;
|
|
270
|
+
// that click is the drag's, not a selection.
|
|
271
|
+
const dragged = useRef(false);
|
|
272
|
+
const editing = mode === "edit";
|
|
273
|
+
const hasBand = nodes.some((n) => n.group);
|
|
274
|
+
const lanes = useMemo(() => assignLanes(nodes, edges), [nodes, edges]);
|
|
275
|
+
const laneCount = lanes.size ? Math.max(...lanes.values()) + 1 : 0;
|
|
276
|
+
// Measure every port dot and node box relative to the content's origin, and
|
|
277
|
+
// keep the measurement when nothing moved — a state change here re-renders,
|
|
278
|
+
// and a re-render that measures the same numbers must not loop.
|
|
279
|
+
const measure = useCallback(() => {
|
|
280
|
+
const root = content.current;
|
|
281
|
+
if (!root)
|
|
282
|
+
return;
|
|
283
|
+
const origin = root.getBoundingClientRect();
|
|
284
|
+
const ports = {};
|
|
285
|
+
for (const [key, el] of portEls.current) {
|
|
286
|
+
const r = el.getBoundingClientRect();
|
|
287
|
+
ports[key] = { x: r.left - origin.left + r.width / 2, y: r.top - origin.top + r.height / 2 };
|
|
288
|
+
}
|
|
289
|
+
const boxes = {};
|
|
290
|
+
for (const [id, el] of nodeEls.current) {
|
|
291
|
+
const r = el.getBoundingClientRect();
|
|
292
|
+
boxes[id] = { x: r.left - origin.left, y: r.top - origin.top, w: r.width, h: r.height };
|
|
293
|
+
}
|
|
294
|
+
const next = { ports, boxes, w: root.scrollWidth, h: root.scrollHeight };
|
|
295
|
+
setM((prev) => prev && sameMeasure(prev, next) ? prev : next);
|
|
296
|
+
}, []);
|
|
297
|
+
useLayoutEffect(() => {measure();});
|
|
298
|
+
useEffect(() => {
|
|
299
|
+
const root = content.current;
|
|
300
|
+
if (!root || typeof ResizeObserver === "undefined")
|
|
301
|
+
return;
|
|
302
|
+
const ro = new ResizeObserver(() => measure());
|
|
303
|
+
ro.observe(root);
|
|
304
|
+
for (const el of nodeEls.current.values())
|
|
305
|
+
ro.observe(el);
|
|
306
|
+
return () => ro.disconnect();
|
|
307
|
+
}, [measure, nodes.length]);
|
|
308
|
+
// A picked edge that the caller removed, or that stopped existing, is forgotten.
|
|
309
|
+
// Adjusted during render rather than in effects that reset it afterwards.
|
|
310
|
+
if (picked && (!editing || !edges.some((e) => e.id === picked)))
|
|
311
|
+
setPicked(null);
|
|
312
|
+
const register = useCallback((key) => (el) => {
|
|
313
|
+
if (el)
|
|
314
|
+
portEls.current.set(key, el);else
|
|
315
|
+
|
|
316
|
+
portEls.current.delete(key);
|
|
317
|
+
}, []);
|
|
318
|
+
const registerNode = useCallback((id) => (el) => {
|
|
319
|
+
if (el)
|
|
320
|
+
nodeEls.current.set(id, el);else
|
|
321
|
+
|
|
322
|
+
nodeEls.current.delete(id);
|
|
323
|
+
}, []);
|
|
324
|
+
// --- wiring by drag ---------------------------------------------------
|
|
325
|
+
const toLocal = useCallback((e) => {
|
|
326
|
+
const origin = content.current?.getBoundingClientRect();
|
|
327
|
+
return origin ? { x: e.clientX - origin.left, y: e.clientY - origin.top } : { x: 0, y: 0 };
|
|
328
|
+
}, []);
|
|
329
|
+
const startDrag = (node, port, side) => (e) => {
|
|
330
|
+
if (!editing || !onConnect)
|
|
331
|
+
return;
|
|
332
|
+
e.preventDefault();
|
|
333
|
+
e.stopPropagation();
|
|
334
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
335
|
+
setDraft({ from: { node, port, side }, at: toLocal(e), over: null });
|
|
336
|
+
dragged.current = true;
|
|
337
|
+
};
|
|
338
|
+
const moveDrag = (e) => {
|
|
339
|
+
if (!draft)
|
|
340
|
+
return;
|
|
341
|
+
const over = portUnder(e.clientX, e.clientY, draft.from.side === "out" ? "in" : "out");
|
|
342
|
+
setDraft({ ...draft, at: toLocal(e), over: over && over.node !== draft.from.node ? over : null });
|
|
343
|
+
};
|
|
344
|
+
const endDrag = (e) => {
|
|
345
|
+
if (!draft)
|
|
346
|
+
return;
|
|
347
|
+
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
348
|
+
const over = portUnder(e.clientX, e.clientY, draft.from.side === "out" ? "in" : "out");
|
|
349
|
+
if (over && over.node !== draft.from.node && onConnect) {
|
|
350
|
+
const a = { node: draft.from.node, port: draft.from.port };
|
|
351
|
+
if (draft.from.side === "out")
|
|
352
|
+
onConnect(a, over);else
|
|
353
|
+
|
|
354
|
+
onConnect(over, a);
|
|
355
|
+
}
|
|
356
|
+
setDraft(null);
|
|
357
|
+
};
|
|
358
|
+
const remove = (edge) => {onDisconnect?.(edge);setPicked(null);};
|
|
359
|
+
const onKey = (e) => {
|
|
360
|
+
if (!editing || !picked)
|
|
361
|
+
return;
|
|
362
|
+
if (e.key === "Delete" || e.key === "Backspace") {
|
|
363
|
+
const edge = edges.find((x) => x.id === picked);
|
|
364
|
+
if (edge) {
|
|
332
365
|
e.preventDefault();
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
else
|
|
354
|
-
onConnect(over, a);
|
|
355
|
-
}
|
|
356
|
-
setDraft(null);
|
|
357
|
-
};
|
|
358
|
-
const remove = (edge) => { onDisconnect?.(edge); setPicked(null); };
|
|
359
|
-
const onKey = (e) => {
|
|
360
|
-
if (!editing || !picked)
|
|
361
|
-
return;
|
|
362
|
-
if (e.key === "Delete" || e.key === "Backspace") {
|
|
363
|
-
const edge = edges.find((x) => x.id === picked);
|
|
364
|
-
if (edge) {
|
|
365
|
-
e.preventDefault();
|
|
366
|
-
remove(edge);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
if (e.key === "Escape")
|
|
370
|
-
setPicked(null);
|
|
366
|
+
remove(edge);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (e.key === "Escape")
|
|
370
|
+
setPicked(null);
|
|
371
|
+
};
|
|
372
|
+
// --- group bands --------------------------------------------------------
|
|
373
|
+
const bands = useMemo(() => {
|
|
374
|
+
if (!m || !hasBand)
|
|
375
|
+
return [];
|
|
376
|
+
const out = [];
|
|
377
|
+
let cur = null;
|
|
378
|
+
const flush = () => {
|
|
379
|
+
if (!cur)
|
|
380
|
+
return;
|
|
381
|
+
const a = m.boxes[cur.first];
|
|
382
|
+
const b = m.boxes[cur.last];
|
|
383
|
+
if (a && b && cur.count > 1)
|
|
384
|
+
out.push({ key: `${cur.label}:${cur.first}`, label: cur.label, count: cur.count, x: a.x - 6, w: b.x + b.w - a.x + 12 });
|
|
385
|
+
cur = null;
|
|
371
386
|
};
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
387
|
+
for (const n of nodes) {
|
|
388
|
+
if (n.group && cur && cur.label === n.group) {
|
|
389
|
+
cur.last = n.id;
|
|
390
|
+
cur.count++;
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
flush();
|
|
394
|
+
if (n.group)
|
|
395
|
+
cur = { label: n.group, first: n.id, last: n.id, count: 1 };
|
|
396
|
+
}
|
|
397
|
+
flush();
|
|
398
|
+
return out;
|
|
399
|
+
}, [m, nodes, hasBand]);
|
|
400
|
+
if (nodes.length === 0) {
|
|
401
|
+
return _jsx(Surface, { className: className, style: { minHeight }, children: _jsx(Empty, { children: empty ?? "Nothing to draw yet." }) });
|
|
402
|
+
}
|
|
403
|
+
const tonesUsed = new Set(["mut"]);
|
|
404
|
+
for (const e of edges)
|
|
405
|
+
tonesUsed.add(e.tone ?? "brand");
|
|
406
|
+
return _jsx(Surface, { className: className, style: { minHeight }, ...(label ? { role: "group", "aria-label": label } : {}), tabIndex: editing ? 0 : undefined, onKeyDown: onKey, onClick: () => setPicked(null), children: _jsxs(Content, { ref: content, "$band": hasBand, "$lanes": laneCount, children: [bands.map((b) => _jsxs(Band, { style: { left: b.x, top: PAD - 2, width: b.w }, children: ["inlined ", _jsx("code", { children: b.label }), " \u00B7 ", b.count, " step", b.count === 1 ? "" : "s"] }, b.key)), nodes.map((n) => {
|
|
407
|
+
const selectable = !n.dim && !!onSelect;
|
|
408
|
+
const tone = n.tone ?? "mut";
|
|
409
|
+
const open = () => {if (selectable)
|
|
410
|
+
onSelect?.(n.id === selected ? null : n.id);};
|
|
411
|
+
const ins = n.inputs ?? [];
|
|
412
|
+
const outs = n.outputs ?? [];
|
|
413
|
+
return _jsxs(NodeBox, { ref: registerNode(n.id), "$w": n.width ?? NODE_W, "$tone": tone, "$dim": !!n.dim, "$selected": selected === n.id, "$selectable": selectable, "data-node": n.id, ...(selectable ? { role: "button", tabIndex: 0, "aria-pressed": selected === n.id } : {}), onClick: (e) => {e.stopPropagation();if (dragged.current) {
|
|
414
|
+
dragged.current = false;
|
|
415
|
+
return;
|
|
416
|
+
}setPicked(null);open();}, onKeyDown: (e) => {if (selectable && (e.key === "Enter" || e.key === " ")) {
|
|
417
|
+
e.preventDefault();
|
|
418
|
+
open();
|
|
419
|
+
}}, children: [_jsxs(Head, { "$tone": tone, "$dim": !!n.dim, children: [_jsxs("span", { className: "title", children: [n.kind ? _jsx(Tag, { className: "kind", "$tone": n.dim ? "mut" : "brand", children: _jsx("span", { children: n.kind }) }) : null, _jsx("strong", { children: n.title })] }), n.badge ? _jsx("span", { className: "badge", children: n.badge }) : null] }), ins.length === 0 && outs.length === 0 && !n.sub && !n.note ? null : _jsxs(Body, { children: [_jsx("div", { children: ins.length === 0 ? n.dim ? null : _jsx(NoPorts, { children: "no inputs" }) : ins.map((p) => _jsxs(PortRow, { "$side": "in", "data-port-row": true, title: p.hint ?? `${p.label}${p.sub ? ` · ${p.sub}` : ""}`, children: [_jsx(Dot, { ref: register(portKey(n.id, p.id, "in")), "$side": "in", "$live": editing && !!onConnect, "$target": !!draft && draft.over?.node === n.id && draft.over.port === p.id, "data-port": p.id, "data-port-node": n.id, "data-port-side": "in", onPointerDown: startDrag(n.id, p.id, "in"), onPointerMove: moveDrag, onPointerUp: endDrag }), _jsxs("div", { className: `label${p.required ? " required" : ""}`, children: [p.label, p.required ? "*" : "", p.sub ? _jsxs("span", { className: "sub", children: [" \u00B7 ", p.sub] }) : null] }), p.value ? _jsxs("div", { className: "value", children: ["= ", p.value] }) : null] }, p.id)) }), _jsx("div", { children: outs.length === 0 ? n.dim ? null : _jsx(NoPorts, { style: { textAlign: "right" }, children: "no outputs" }) : outs.map((p) => _jsxs(PortRow, { "$side": "out", "data-port-row": true, title: p.hint ?? `${p.label}${p.sub ? ` · ${p.sub}` : ""}`, children: [_jsx(Dot, { ref: register(portKey(n.id, p.id, "out")), "$side": "out", "$live": editing && !!onConnect, "$target": !!draft && draft.over?.node === n.id && draft.over.port === p.id, "data-port": p.id, "data-port-node": n.id, "data-port-side": "out", onPointerDown: startDrag(n.id, p.id, "out"), onPointerMove: moveDrag, onPointerUp: endDrag }), _jsxs("div", { className: `label${p.required ? " required" : ""}`, children: [p.label, p.sub ? _jsxs("span", { className: "sub", children: [" \u00B7 ", p.sub] }) : null] })] }, p.id)) })] }), n.sub || n.note ? _jsxs(Foot, { children: [n.sub ? _jsx("div", { children: n.sub }) : null, n.note ? _jsx("div", { className: "note", children: n.note }) : null] }) : null] }, n.id);
|
|
420
|
+
}), m ? (() => {
|
|
421
|
+
const floor = Math.max(0, ...Object.values(m.boxes).map((b) => b.y + b.h));
|
|
422
|
+
const laneY = (lane) => floor + 10 + lane * LANE_H;
|
|
423
|
+
const geometry = (e) => {
|
|
424
|
+
const a = m.ports[portKey(e.from.node, e.from.port, "out")];
|
|
425
|
+
const b = m.ports[portKey(e.to.node, e.to.port, "in")];
|
|
426
|
+
if (!a || !b)
|
|
427
|
+
return null;
|
|
428
|
+
const lane = lanes.get(e.id);
|
|
429
|
+
if (lane === undefined)
|
|
430
|
+
return { d: curve(a, b), mid: midpoint(a, b) };
|
|
431
|
+
const y = laneY(lane);
|
|
432
|
+
return { d: laned(a, b, y), mid: { x: (a.x + STUB + b.x - STUB) / 2, y } };
|
|
386
433
|
};
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
434
|
+
return _jsxs(_Fragment, { children: [_jsxs(Overlay, { width: m.w, height: m.h, "aria-hidden": true, children: [_jsx("defs", { children: [...tonesUsed].map((t) => _jsx("marker", { id: `x-graph-arrow-${t}`, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "7", markerHeight: "7", orient: "auto-start-reverse", children: _jsx("path", { d: "M0,0 L10,5 L0,10 z", fill: TONE_STROKE[t] }) }, t)) }), flow ? nodes.slice(0, -1).map((n, i) => {
|
|
435
|
+
const a = m.boxes[n.id];
|
|
436
|
+
const b = m.boxes[nodes[i + 1].id];
|
|
437
|
+
if (!a || !b)
|
|
438
|
+
return null;
|
|
439
|
+
// Through the headers, which every node has at the same height.
|
|
440
|
+
const from = { x: a.x + a.w, y: a.y + 17 };
|
|
441
|
+
const to = { x: b.x, y: b.y + 17 };
|
|
442
|
+
return _jsx("path", { className: "flow", d: curve(from, to), markerEnd: "url(#x-graph-arrow-mut)" }, `flow:${n.id}`);
|
|
443
|
+
}) : null, edges.map((e) => {
|
|
444
|
+
const g = geometry(e);
|
|
445
|
+
if (!g)
|
|
446
|
+
return null;
|
|
447
|
+
const tone = e.tone ?? "brand";
|
|
448
|
+
const d = g.d;
|
|
449
|
+
return _jsxs("g", { children: [_jsx("path", { className: `edge${e.animated ? " animated" : ""}${picked === e.id ? " picked" : ""}`, d: d, stroke: TONE_STROKE[tone], markerEnd: `url(#x-graph-arrow-${tone})` }), _jsx("path", { className: `hit${editing && onDisconnect ? "" : " static"}`, d: d, onClick: (ev) => {ev.stopPropagation();setPicked(picked === e.id ? null : e.id);} })] }, e.id);
|
|
450
|
+
}), draft ? (() => {
|
|
451
|
+
const a = m.ports[portKey(draft.from.node, draft.from.port, draft.from.side)];
|
|
452
|
+
if (!a)
|
|
453
|
+
return null;
|
|
454
|
+
const b = draft.over ? m.ports[portKey(draft.over.node, draft.over.port, draft.from.side === "out" ? "in" : "out")] ?? draft.at : draft.at;
|
|
455
|
+
return _jsx("path", { className: "draft", d: draft.from.side === "out" ? curve(a, b) : curve(b, a) });
|
|
456
|
+
})() : null] }), edges.map((e) => {
|
|
457
|
+
const g = geometry(e);
|
|
458
|
+
if (!g)
|
|
459
|
+
return null;
|
|
460
|
+
const mid = g.mid;
|
|
461
|
+
if (editing && onDisconnect && picked === e.id) {
|
|
462
|
+
return _jsx(Remove, { type: "button", "aria-label": "Remove this connection", title: "Remove this connection", style: { left: mid.x, top: mid.y }, onClick: (ev) => {ev.stopPropagation();remove(e);}, children: "\u00D7" }, `rm:${e.id}`);
|
|
392
463
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}
|
|
397
|
-
flush();
|
|
398
|
-
return out;
|
|
399
|
-
}, [m, nodes, hasBand]);
|
|
400
|
-
if (nodes.length === 0) {
|
|
401
|
-
return _jsx(Surface, { className: className, style: { minHeight }, children: _jsx(Empty, { children: empty ?? "Nothing to draw yet." }) });
|
|
402
|
-
}
|
|
403
|
-
const tonesUsed = new Set(["mut"]);
|
|
404
|
-
for (const e of edges)
|
|
405
|
-
tonesUsed.add(e.tone ?? "brand");
|
|
406
|
-
return (_jsx(Surface, { className: className, style: { minHeight }, ...(label ? { role: "group", "aria-label": label } : {}), tabIndex: editing ? 0 : undefined, onKeyDown: onKey, onClick: () => setPicked(null), children: _jsxs(Content, { ref: content, "$band": hasBand, "$lanes": laneCount, children: [bands.map((b) => (_jsxs(Band, { style: { left: b.x, top: PAD - 2, width: b.w }, children: ["inlined ", _jsx("code", { children: b.label }), " \u00B7 ", b.count, " step", b.count === 1 ? "" : "s"] }, b.key))), nodes.map((n) => {
|
|
407
|
-
const selectable = !n.dim && !!onSelect;
|
|
408
|
-
const tone = n.tone ?? "mut";
|
|
409
|
-
const open = () => { if (selectable)
|
|
410
|
-
onSelect?.(n.id === selected ? null : n.id); };
|
|
411
|
-
const ins = n.inputs ?? [];
|
|
412
|
-
const outs = n.outputs ?? [];
|
|
413
|
-
return (_jsxs(NodeBox, { ref: registerNode(n.id), "$w": n.width ?? NODE_W, "$tone": tone, "$dim": !!n.dim, "$selected": selected === n.id, "$selectable": selectable, "data-node": n.id, ...(selectable ? { role: "button", tabIndex: 0, "aria-pressed": selected === n.id } : {}), onClick: (e) => { e.stopPropagation(); if (dragged.current) {
|
|
414
|
-
dragged.current = false;
|
|
415
|
-
return;
|
|
416
|
-
} setPicked(null); open(); }, onKeyDown: (e) => { if (selectable && (e.key === "Enter" || e.key === " ")) {
|
|
417
|
-
e.preventDefault();
|
|
418
|
-
open();
|
|
419
|
-
} }, children: [_jsxs(Head, { "$tone": tone, "$dim": !!n.dim, children: [_jsxs("span", { className: "title", children: [n.kind ? _jsx(Tag, { className: "kind", "$tone": n.dim ? "mut" : "brand", children: _jsx("span", { children: n.kind }) }) : null, _jsx("strong", { children: n.title })] }), n.badge ? _jsx("span", { className: "badge", children: n.badge }) : null] }), ins.length === 0 && outs.length === 0 && !n.sub && !n.note ? null : (_jsxs(Body, { children: [_jsx("div", { children: ins.length === 0 ? (n.dim ? null : _jsx(NoPorts, { children: "no inputs" })) : ins.map((p) => (_jsxs(PortRow, { "$side": "in", "data-port-row": true, title: p.hint ?? `${p.label}${p.sub ? ` · ${p.sub}` : ""}`, children: [_jsx(Dot, { ref: register(portKey(n.id, p.id, "in")), "$side": "in", "$live": editing && !!onConnect, "$target": !!draft && draft.over?.node === n.id && draft.over.port === p.id, "data-port": p.id, "data-port-node": n.id, "data-port-side": "in", onPointerDown: startDrag(n.id, p.id, "in"), onPointerMove: moveDrag, onPointerUp: endDrag }), _jsxs("div", { className: `label${p.required ? " required" : ""}`, children: [p.label, p.required ? "*" : "", p.sub ? _jsxs("span", { className: "sub", children: [" \u00B7 ", p.sub] }) : null] }), p.value ? _jsxs("div", { className: "value", children: ["= ", p.value] }) : null] }, p.id))) }), _jsx("div", { children: outs.length === 0 ? (n.dim ? null : _jsx(NoPorts, { style: { textAlign: "right" }, children: "no outputs" })) : outs.map((p) => (_jsxs(PortRow, { "$side": "out", "data-port-row": true, title: p.hint ?? `${p.label}${p.sub ? ` · ${p.sub}` : ""}`, children: [_jsx(Dot, { ref: register(portKey(n.id, p.id, "out")), "$side": "out", "$live": editing && !!onConnect, "$target": !!draft && draft.over?.node === n.id && draft.over.port === p.id, "data-port": p.id, "data-port-node": n.id, "data-port-side": "out", onPointerDown: startDrag(n.id, p.id, "out"), onPointerMove: moveDrag, onPointerUp: endDrag }), _jsxs("div", { className: `label${p.required ? " required" : ""}`, children: [p.label, p.sub ? _jsxs("span", { className: "sub", children: [" \u00B7 ", p.sub] }) : null] })] }, p.id))) })] })), n.sub || n.note ? (_jsxs(Foot, { children: [n.sub ? _jsx("div", { children: n.sub }) : null, n.note ? _jsx("div", { className: "note", children: n.note }) : null] })) : null] }, n.id));
|
|
420
|
-
}), m ? (() => {
|
|
421
|
-
const floor = Math.max(0, ...Object.values(m.boxes).map((b) => b.y + b.h));
|
|
422
|
-
const laneY = (lane) => floor + 10 + lane * LANE_H;
|
|
423
|
-
const geometry = (e) => {
|
|
424
|
-
const a = m.ports[portKey(e.from.node, e.from.port, "out")];
|
|
425
|
-
const b = m.ports[portKey(e.to.node, e.to.port, "in")];
|
|
426
|
-
if (!a || !b)
|
|
427
|
-
return null;
|
|
428
|
-
const lane = lanes.get(e.id);
|
|
429
|
-
if (lane === undefined)
|
|
430
|
-
return { d: curve(a, b), mid: midpoint(a, b) };
|
|
431
|
-
const y = laneY(lane);
|
|
432
|
-
return { d: laned(a, b, y), mid: { x: (a.x + STUB + b.x - STUB) / 2, y } };
|
|
433
|
-
};
|
|
434
|
-
return (_jsxs(_Fragment, { children: [_jsxs(Overlay, { width: m.w, height: m.h, "aria-hidden": true, children: [_jsx("defs", { children: [...tonesUsed].map((t) => (_jsx("marker", { id: `x-graph-arrow-${t}`, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "7", markerHeight: "7", orient: "auto-start-reverse", children: _jsx("path", { d: "M0,0 L10,5 L0,10 z", fill: TONE_STROKE[t] }) }, t))) }), flow ? nodes.slice(0, -1).map((n, i) => {
|
|
435
|
-
const a = m.boxes[n.id];
|
|
436
|
-
const b = m.boxes[nodes[i + 1].id];
|
|
437
|
-
if (!a || !b)
|
|
438
|
-
return null;
|
|
439
|
-
// Through the headers, which every node has at the same height.
|
|
440
|
-
const from = { x: a.x + a.w, y: a.y + 17 };
|
|
441
|
-
const to = { x: b.x, y: b.y + 17 };
|
|
442
|
-
return _jsx("path", { className: "flow", d: curve(from, to), markerEnd: "url(#x-graph-arrow-mut)" }, `flow:${n.id}`);
|
|
443
|
-
}) : null, edges.map((e) => {
|
|
444
|
-
const g = geometry(e);
|
|
445
|
-
if (!g)
|
|
446
|
-
return null;
|
|
447
|
-
const tone = e.tone ?? "brand";
|
|
448
|
-
const d = g.d;
|
|
449
|
-
return (_jsxs("g", { children: [_jsx("path", { className: `edge${e.animated ? " animated" : ""}${picked === e.id ? " picked" : ""}`, d: d, stroke: TONE_STROKE[tone], markerEnd: `url(#x-graph-arrow-${tone})` }), _jsx("path", { className: `hit${editing && onDisconnect ? "" : " static"}`, d: d, onClick: (ev) => { ev.stopPropagation(); setPicked(picked === e.id ? null : e.id); } })] }, e.id));
|
|
450
|
-
}), draft ? (() => {
|
|
451
|
-
const a = m.ports[portKey(draft.from.node, draft.from.port, draft.from.side)];
|
|
452
|
-
if (!a)
|
|
453
|
-
return null;
|
|
454
|
-
const b = draft.over ? m.ports[portKey(draft.over.node, draft.over.port, draft.from.side === "out" ? "in" : "out")] ?? draft.at : draft.at;
|
|
455
|
-
return _jsx("path", { className: "draft", d: draft.from.side === "out" ? curve(a, b) : curve(b, a) });
|
|
456
|
-
})() : null] }), edges.map((e) => {
|
|
457
|
-
const g = geometry(e);
|
|
458
|
-
if (!g)
|
|
459
|
-
return null;
|
|
460
|
-
const mid = g.mid;
|
|
461
|
-
if (editing && onDisconnect && picked === e.id) {
|
|
462
|
-
return _jsx(Remove, { type: "button", "aria-label": "Remove this connection", title: "Remove this connection", style: { left: mid.x, top: mid.y }, onClick: (ev) => { ev.stopPropagation(); remove(e); }, children: "\u00D7" }, `rm:${e.id}`);
|
|
463
|
-
}
|
|
464
|
-
return e.label ? _jsx(EdgeLabel, { "$tone": e.tone ?? "brand", style: { left: mid.x, top: mid.y }, children: e.label }, `lb:${e.id}`) : null;
|
|
465
|
-
})] }));
|
|
466
|
-
})() : null] }) }));
|
|
464
|
+
return e.label ? _jsx(EdgeLabel, { "$tone": e.tone ?? "brand", style: { left: mid.x, top: mid.y }, children: e.label }, `lb:${e.id}`) : null;
|
|
465
|
+
})] });
|
|
466
|
+
})() : null] }) });
|
|
467
467
|
}
|
|
468
468
|
function sameMeasure(a, b) {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
469
|
+
if (a.w !== b.w || a.h !== b.h)
|
|
470
|
+
return false;
|
|
471
|
+
const ak = Object.keys(a.ports);
|
|
472
|
+
const bk = Object.keys(b.ports);
|
|
473
|
+
if (ak.length !== bk.length)
|
|
474
|
+
return false;
|
|
475
|
+
for (const k of bk) {
|
|
476
|
+
const p = a.ports[k];
|
|
477
|
+
const q = b.ports[k];
|
|
478
|
+
if (!p || Math.abs(p.x - q.x) > 0.5 || Math.abs(p.y - q.y) > 0.5)
|
|
479
|
+
return false;
|
|
480
|
+
}
|
|
481
|
+
const an = Object.keys(a.boxes);
|
|
482
|
+
const bn = Object.keys(b.boxes);
|
|
483
|
+
if (an.length !== bn.length)
|
|
484
|
+
return false;
|
|
485
|
+
for (const k of bn) {
|
|
486
|
+
const p = a.boxes[k];
|
|
487
|
+
const q = b.boxes[k];
|
|
488
|
+
if (!p || Math.abs(p.x - q.x) > 0.5 || Math.abs(p.y - q.y) > 0.5 || Math.abs(p.w - q.w) > 0.5 || Math.abs(p.h - q.h) > 0.5)
|
|
489
|
+
return false;
|
|
490
|
+
}
|
|
491
|
+
return true;
|
|
492
492
|
}
|
|
493
493
|
/** The port dot under a point, of the side a drag can land on; the dot is tiny, so its row counts too. */
|
|
494
494
|
function portUnder(x, y, side) {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
495
|
+
if (typeof document === "undefined")
|
|
496
|
+
return null;
|
|
497
|
+
let el = document.elementFromPoint(x, y);
|
|
498
|
+
while (el && !(el instanceof HTMLElement && el.dataset.port !== undefined)) {
|
|
499
|
+
if (el instanceof HTMLElement && el.dataset.node !== undefined)
|
|
500
|
+
break;
|
|
501
|
+
el = el.parentElement;
|
|
502
|
+
}
|
|
503
|
+
if (el instanceof HTMLElement && el.dataset.port !== undefined && el.dataset.portSide === side && el.dataset.portNode) {
|
|
504
|
+
return { node: el.dataset.portNode, port: el.dataset.port };
|
|
505
|
+
}
|
|
506
|
+
// Not on a dot: the row the dot sits in also takes the drop.
|
|
507
|
+
const row = document.elementFromPoint(x, y)?.closest("[data-port-row]");
|
|
508
|
+
const dot = row?.querySelector(`[data-port-side="${side}"]`);
|
|
509
|
+
if (dot?.dataset.portNode && dot.dataset.port !== undefined)
|
|
510
|
+
return { node: dot.dataset.portNode, port: dot.dataset.port };
|
|
511
|
+
return null;
|
|
512
512
|
}
|
|
513
513
|
// ---------------------------------------------------------------------------
|
|
514
514
|
// Layered layout
|
|
@@ -518,24 +518,24 @@ const ROW_GAP = 14;
|
|
|
518
518
|
const PASS_W = 20;
|
|
519
519
|
const COMPACT_W = 168;
|
|
520
520
|
const GUESS_H = { full: 64, compact: 44 };
|
|
521
|
-
const LayeredContent = styled.div `
|
|
521
|
+
const LayeredContent = styled.div.withConfig({ componentId: "sc-yq0u64-14" })`
|
|
522
522
|
position: relative;
|
|
523
523
|
min-width: 100%;
|
|
524
524
|
`;
|
|
525
|
-
const Placed = styled.div `
|
|
525
|
+
const Placed = styled.div.withConfig({ componentId: "sc-yq0u64-15" })`
|
|
526
526
|
position: absolute;
|
|
527
527
|
transition: opacity 120ms ease;
|
|
528
|
-
opacity: ${(p) =>
|
|
528
|
+
opacity: ${(p) => p.$faded ? 0.35 : 1};
|
|
529
529
|
`;
|
|
530
|
-
const Compact = styled.div `
|
|
530
|
+
const Compact = styled.div.withConfig({ componentId: "sc-yq0u64-16" })`
|
|
531
531
|
display: grid;
|
|
532
532
|
grid-template-columns: auto minmax(0, 1fr);
|
|
533
533
|
align-items: center;
|
|
534
534
|
column-gap: 8px;
|
|
535
535
|
min-height: ${GUESS_H.compact - 3}px;
|
|
536
536
|
padding: 5px 10px;
|
|
537
|
-
border-radius: 9px;
|
|
538
|
-
background: ${(p) =>
|
|
537
|
+
border-radius: min(9px, ${v.rCard});
|
|
538
|
+
background: ${(p) => p.$dim || p.$tone === "mut" ? "transparent" : TONE_BG[p.$tone]};
|
|
539
539
|
font-size: 12.5px;
|
|
540
540
|
line-height: 16px;
|
|
541
541
|
& > .icon { grid-row: span 2; display: inline-flex; }
|
|
@@ -543,123 +543,123 @@ const Compact = styled.div `
|
|
|
543
543
|
& > .sub { min-width: 0; color: ${v.muted}; font-size: 11px; line-height: 14px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
544
544
|
& > :only-child, & > .icon + strong:last-child { grid-row: auto; }
|
|
545
545
|
`;
|
|
546
|
-
const LayeredOverlay = styled(Overlay) `
|
|
546
|
+
const LayeredOverlay = styled(Overlay).withConfig({ componentId: "sc-yq0u64-17" })`
|
|
547
547
|
.edge { transition: opacity 120ms ease; }
|
|
548
548
|
.edge.faded { opacity: 0.18; }
|
|
549
549
|
.edge.lit { stroke-width: 2.25px; }
|
|
550
550
|
`;
|
|
551
551
|
/** A path through points: a curve across each gap between columns, a straight run through each column passed. */
|
|
552
552
|
function connector(points) {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
553
|
+
let d = `M${points[0].x},${points[0].y}`;
|
|
554
|
+
for (let i = 1; i < points.length; i++) {
|
|
555
|
+
const a = points[i - 1];
|
|
556
|
+
const b = points[i];
|
|
557
|
+
if (i % 2 === 1) {
|
|
558
|
+
const dx = (b.x - a.x) / 2;
|
|
559
|
+
d += ` C${a.x + dx},${a.y} ${b.x - dx},${b.y} ${b.x},${b.y}`;
|
|
560
|
+
} else
|
|
561
|
+
|
|
562
|
+
d += ` L${b.x},${b.y}`;
|
|
563
|
+
}
|
|
564
|
+
return d;
|
|
565
565
|
}
|
|
566
|
-
function LayeredGraph({ nodes, edges, selected = null, onSelect, minHeight = 200, empty, label, className, reduce = true, density = "full"
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
566
|
+
function LayeredGraph({ nodes, edges, selected = null, onSelect, minHeight = 200, empty, label, className, reduce = true, density = "full" }) {
|
|
567
|
+
const compact = density === "compact";
|
|
568
|
+
const byId = useMemo(() => new Map(nodes.map((n) => [n.id, n])), [nodes]);
|
|
569
|
+
const edgeById = useMemo(() => new Map(edges.map((e) => [e.id, e])), [edges]);
|
|
570
|
+
const layout = useMemo(() => layeredLayout(nodes.map((n) => n.id), edges.map((e) => ({ id: e.id, from: e.from.node, to: e.to.node })), reduce), [nodes, edges, reduce]);
|
|
571
|
+
const nodeEls = useRef(new Map());
|
|
572
|
+
const [heights, setHeights] = useState({});
|
|
573
|
+
const [lit, setLit] = useState(null);
|
|
574
|
+
const measure = useCallback(() => {
|
|
575
|
+
const next = {};
|
|
576
|
+
for (const [id, el] of nodeEls.current)
|
|
577
|
+
next[id] = el.offsetHeight;
|
|
578
|
+
setHeights((prev) => {
|
|
579
|
+
const pk = Object.keys(prev);
|
|
580
|
+
const nk = Object.keys(next);
|
|
581
|
+
if (pk.length === nk.length && nk.every((k) => Math.abs((prev[k] ?? -1) - next[k]) < 0.5))
|
|
582
|
+
return prev;
|
|
583
|
+
return next;
|
|
584
|
+
});
|
|
585
|
+
}, []);
|
|
586
|
+
// A ResizeObserver reports each element once when observed, then on every
|
|
587
|
+
// change: that is the first measurement too (until then, a guess per density).
|
|
588
|
+
const nodeSet = nodes.map((n) => n.id).join("\u0000");
|
|
589
|
+
useEffect(() => {
|
|
590
|
+
if (typeof ResizeObserver === "undefined")
|
|
591
|
+
return;
|
|
592
|
+
const ro = new ResizeObserver(() => measure());
|
|
593
|
+
for (const el of nodeEls.current.values())
|
|
594
|
+
ro.observe(el);
|
|
595
|
+
return () => ro.disconnect();
|
|
596
|
+
}, [measure, nodeSet]);
|
|
597
|
+
const registerNode = useCallback((id) => (el) => {
|
|
598
|
+
if (el)
|
|
599
|
+
nodeEls.current.set(id, el);else
|
|
600
|
+
|
|
601
|
+
nodeEls.current.delete(id);
|
|
602
|
+
}, []);
|
|
603
|
+
// A node that left the graph stops being lit.
|
|
604
|
+
if (lit && !byId.has(lit))
|
|
605
|
+
setLit(null);
|
|
606
|
+
if (nodes.length === 0) {
|
|
607
|
+
return _jsx(Surface, { className: className, style: { minHeight }, children: _jsx(Empty, { children: empty ?? "Nothing to draw yet." }) });
|
|
608
|
+
}
|
|
609
|
+
// Geometry: every column as wide as its widest node, every slot one pitch tall,
|
|
610
|
+
// each column centred on the tallest.
|
|
611
|
+
const widthOf = (id) => byId.get(id)?.width ?? (compact ? COMPACT_W : NODE_W);
|
|
612
|
+
const tallest = Math.max(GUESS_H[density], ...Object.values(heights));
|
|
613
|
+
const pitch = tallest + ROW_GAP;
|
|
614
|
+
const cols = layout.columns;
|
|
615
|
+
const colW = cols.map((c) => Math.max(PASS_W, ...c.map((s) => s.kind === "node" ? widthOf(s.id) : PASS_W)));
|
|
616
|
+
const colX = [];
|
|
617
|
+
cols.forEach((_, i) => colX.push(i === 0 ? PAD : colX[i - 1] + colW[i - 1] + COL_GAP));
|
|
618
|
+
const most = Math.max(1, ...cols.map((c) => c.length));
|
|
619
|
+
const slotTop = (c, i) => PAD + ((most - cols[c].length) / 2 + i) * pitch;
|
|
620
|
+
const box = {};
|
|
621
|
+
cols.forEach((col, c) => col.forEach((s, i) => {
|
|
622
|
+
if (s.kind !== "node")
|
|
623
|
+
return;
|
|
624
|
+
const h = heights[s.id] ?? GUESS_H[density];
|
|
625
|
+
box[s.id] = { x: colX[c], y: slotTop(c, i) + (tallest - h) / 2, w: widthOf(s.id), h };
|
|
626
|
+
}));
|
|
627
|
+
const W = colX[cols.length - 1] + colW[cols.length - 1] + PAD;
|
|
628
|
+
const H = PAD * 2 + most * pitch - ROW_GAP;
|
|
629
|
+
const mid = (c, i) => slotTop(c, i) + tallest / 2;
|
|
630
|
+
const related = lit ? layout.related(lit) : null;
|
|
631
|
+
const tonesUsed = new Set(["mut"]);
|
|
632
|
+
for (const e of layout.edges)
|
|
633
|
+
tonesUsed.add(edgeById.get(e.id)?.tone ?? "brand");
|
|
634
|
+
return _jsx(Surface, { className: className, style: { minHeight }, ...(label ? { role: "group", "aria-label": label } : {}), children: _jsxs(LayeredContent, { style: { width: W, height: Math.max(H, minHeight - 2) }, children: [_jsxs(LayeredOverlay, { width: W, height: H, "aria-hidden": true, children: [_jsx("defs", { children: [...tonesUsed].map((t) => _jsx("marker", { id: `x-graph-arrow-${t}`, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "7", markerHeight: "7", orient: "auto-start-reverse", children: _jsx("path", { d: "M0,0 L10,5 L0,10 z", fill: TONE_STROKE[t] }) }, t)) }), layout.edges.map((le) => {
|
|
635
|
+
const e = edgeById.get(le.id);
|
|
636
|
+
const a = box[le.from];
|
|
637
|
+
const b = box[le.to];
|
|
638
|
+
if (!e || !a || !b)
|
|
639
|
+
return null;
|
|
640
|
+
const points = [{ x: a.x + a.w, y: a.y + a.h / 2 }];
|
|
641
|
+
const from = layout.column.get(le.from);
|
|
642
|
+
(layout.passes.get(le.id) ?? []).forEach((slot, k) => {
|
|
643
|
+
const c = from + 1 + k;
|
|
644
|
+
const y = mid(c, slot);
|
|
645
|
+
points.push({ x: colX[c], y }, { x: colX[c] + colW[c], y });
|
|
646
|
+
});
|
|
647
|
+
points.push({ x: b.x - 2, y: b.y + b.h / 2 });
|
|
648
|
+
const tone = e.tone ?? "brand";
|
|
649
|
+
const on = related ? related.has(le.from) && related.has(le.to) : false;
|
|
650
|
+
const cls = `edge${e.animated ? " animated" : ""}${related ? on ? " lit" : " faded" : ""}`;
|
|
651
|
+
return _jsx("path", { className: cls, d: connector(points), stroke: TONE_STROKE[tone], markerEnd: `url(#x-graph-arrow-${tone})`, "data-edge": le.id }, le.id);
|
|
652
|
+
})] }), cols.flatMap((col) => col).filter((s) => s.kind === "node").map((s) => {
|
|
653
|
+
const n = byId.get(s.id);
|
|
654
|
+
const b = box[n.id];
|
|
655
|
+
const selectable = !n.dim && !!onSelect;
|
|
656
|
+
const tone = n.tone ?? "mut";
|
|
657
|
+
const open = () => {if (selectable)
|
|
658
|
+
onSelect?.(n.id === selected ? null : n.id);};
|
|
659
|
+
return _jsx(Placed, { "$faded": !!related && !related.has(n.id), style: { left: b.x, top: b.y, width: b.w }, children: _jsx(NodeBox, { ref: registerNode(n.id), "$w": b.w, "$tone": tone, "$dim": !!n.dim, "$selected": selected === n.id, "$selectable": selectable, "data-node": n.id, ...(selectable ? { role: "button", tabIndex: 0, "aria-pressed": selected === n.id } : { tabIndex: 0 }), ...(n.ariaLabel ? { "aria-label": n.ariaLabel } : {}), onMouseEnter: () => setLit(n.id), onMouseLeave: () => setLit((x) => x === n.id ? null : x), onFocus: () => setLit(n.id), onBlur: () => setLit((x) => x === n.id ? null : x), onClick: open, onKeyDown: (e) => {if (selectable && (e.key === "Enter" || e.key === " ")) {
|
|
660
|
+
e.preventDefault();
|
|
661
|
+
open();
|
|
662
|
+
}}, children: compact ? _jsxs(Compact, { "$tone": tone, "$dim": !!n.dim, children: [n.icon ? _jsx("span", { className: "icon", children: n.icon }) : null, _jsx("strong", { title: typeof n.title === "string" ? n.title : undefined, children: n.title }), n.sub ? _jsx("span", { className: "sub", children: n.sub }) : null] }) : _jsxs(_Fragment, { children: [_jsxs(Head, { "$tone": tone, "$dim": !!n.dim, style: n.sub || n.note ? undefined : { borderBottom: "none", borderRadius: `min(9px, ${v.rCard})` }, children: [_jsxs("span", { className: "title", children: [n.icon ? _jsx("span", { style: { display: "inline-flex", flex: "none" }, children: n.icon }) : null, n.kind ? _jsx(Tag, { className: "kind", "$tone": n.dim ? "mut" : "brand", children: _jsx("span", { children: n.kind }) }) : null, _jsx("strong", { children: n.title })] }), n.badge ? _jsx("span", { className: "badge", children: n.badge }) : null] }), n.sub || n.note ? _jsxs(Foot, { style: { borderTop: "none" }, children: [n.sub ? _jsx("div", { children: n.sub }) : null, n.note ? _jsx("div", { className: "note", children: n.note }) : null] }) : null] }) }) }, n.id);
|
|
663
|
+
})] }) });
|
|
664
664
|
}
|
|
665
|
-
//# sourceMappingURL=Graph.js.map
|
|
665
|
+
//# sourceMappingURL=Graph.js.map
|