@zsherman/viz 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/CHANGELOG.md +14 -0
- package/LICENSE +373 -0
- package/README.md +13 -2
- package/THIRD_PARTY_NOTICES.md +79 -0
- package/dist/dom/flow/flow.js +370 -0
- package/dist/dom/flow/flow.styles.js +158 -0
- package/dist/dom/flow/index.js +4 -0
- package/dist/dom/flow/layout.js +51 -0
- package/dist/dom/geo-map/geo-map.js +1037 -0
- package/dist/dom/geo-map/geo-map.styles.js +184 -0
- package/dist/dom/geo-map/geometry.js +231 -0
- package/dist/dom/geo-map/index.js +3 -0
- package/dist/dom/geo-map/types.js +0 -0
- package/dist/dom/geo-map/world.js +15 -0
- package/dist/dom/index.js +6 -0
- package/dist/solid/flow/flow.jsx +180 -0
- package/dist/solid/flow/flow.styles.jsx +158 -0
- package/dist/solid/flow/index.jsx +4 -0
- package/dist/solid/flow/layout.jsx +51 -0
- package/dist/solid/geo-map/geo-map.jsx +698 -0
- package/dist/solid/geo-map/geo-map.styles.jsx +184 -0
- package/dist/solid/geo-map/geometry.jsx +231 -0
- package/dist/solid/geo-map/index.jsx +3 -0
- package/dist/solid/geo-map/types.jsx +0 -0
- package/dist/solid/geo-map/world.jsx +15 -0
- package/dist/solid/index.jsx +6 -0
- package/dist/styles.css +1 -0
- package/dist/types/flow/flow.d.ts +92 -0
- package/dist/types/flow/flow.styles.d.ts +137 -0
- package/dist/types/flow/index.d.ts +6 -0
- package/dist/types/flow/layout.d.ts +47 -0
- package/dist/types/geo-map/geo-map.d.ts +70 -0
- package/dist/types/geo-map/geo-map.styles.d.ts +188 -0
- package/dist/types/geo-map/geometry.d.ts +116 -0
- package/dist/types/geo-map/index.d.ts +4 -0
- package/dist/types/geo-map/types.d.ts +103 -0
- package/dist/types/geo-map/world.d.ts +11 -0
- package/dist/types/index.d.ts +2 -0
- package/docs/api.json +297 -0
- package/docs/flow.md +255 -0
- package/docs/geo-map.md +320 -0
- package/docs/llms.txt +43 -0
- package/docs/search-index.json +64 -0
- package/package.json +66 -4
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import "@stylexjs/stylex";
|
|
2
|
+
// src/geo-map/geo-map.styles.ts
|
|
3
|
+
const styles = {
|
|
4
|
+
root: {
|
|
5
|
+
kB7OPa: "x9f619",
|
|
6
|
+
kVAEAm: "x1n2onr6",
|
|
7
|
+
kzqmXN: "xh8yej3",
|
|
8
|
+
k7Eaqz: "xeuugli",
|
|
9
|
+
kVQacm: "x7giv3",
|
|
10
|
+
kaIpWk: "x1oiwymw",
|
|
11
|
+
kWkggS: "x1e14fz7",
|
|
12
|
+
kMv6JI: "x13rcfk",
|
|
13
|
+
kGuDYH: "x409pna",
|
|
14
|
+
kMwMTN: "x1yjpjgc",
|
|
15
|
+
kfSwDN: "x87ps6o",
|
|
16
|
+
kO7zv1: "x1winvzj",
|
|
17
|
+
$$css: true
|
|
18
|
+
},
|
|
19
|
+
aspect: {
|
|
20
|
+
kOBAk4: "x1wskzqf",
|
|
21
|
+
$$css: true
|
|
22
|
+
},
|
|
23
|
+
interactive: {
|
|
24
|
+
kFalU9: "x5ve5x3",
|
|
25
|
+
kkrTdU: "x1jm3nie xch2mbi",
|
|
26
|
+
$$css: true
|
|
27
|
+
},
|
|
28
|
+
svg: {
|
|
29
|
+
kVAEAm: "x10l6tqk",
|
|
30
|
+
kpwlN0: "x10a8y8t",
|
|
31
|
+
k1xSpc: "x1lliihq",
|
|
32
|
+
kzqmXN: "xh8yej3",
|
|
33
|
+
kZKoxP: "x5yr21d",
|
|
34
|
+
kVQacm: "xb3r6kr",
|
|
35
|
+
$$css: true
|
|
36
|
+
},
|
|
37
|
+
water: {
|
|
38
|
+
kDwRjp: "x16pbne5",
|
|
39
|
+
kjVXCG: "x17ickob x8jos32",
|
|
40
|
+
kfJifR: "xnpr05h",
|
|
41
|
+
kREpy8: "x13efnbd",
|
|
42
|
+
$$css: true
|
|
43
|
+
},
|
|
44
|
+
globe: {
|
|
45
|
+
kWkggS: "xjbqb8w",
|
|
46
|
+
$$css: true
|
|
47
|
+
},
|
|
48
|
+
graticule: {
|
|
49
|
+
kDwRjp: "xbh8q5q",
|
|
50
|
+
kjVXCG: "x17ickob x16cwk3t",
|
|
51
|
+
kfJifR: "xnpr05h",
|
|
52
|
+
kREpy8: "x13efnbd",
|
|
53
|
+
$$css: true
|
|
54
|
+
},
|
|
55
|
+
land: {
|
|
56
|
+
kDwRjp: "x1n8x9jh x1h8bevw",
|
|
57
|
+
kjVXCG: "xkkurtx x8jos32",
|
|
58
|
+
kfJifR: "x7mprgd",
|
|
59
|
+
kJdQPc: "x1f6yumg",
|
|
60
|
+
kREpy8: "x13efnbd",
|
|
61
|
+
$$css: true
|
|
62
|
+
},
|
|
63
|
+
connection: {
|
|
64
|
+
kDwRjp: "xbh8q5q",
|
|
65
|
+
kjVXCG: "x125p37g",
|
|
66
|
+
kfJifR: "x33it27",
|
|
67
|
+
kU5bRw: "x1owpc8m",
|
|
68
|
+
kDd8S0: "x1jhn8ml",
|
|
69
|
+
kREpy8: "x13efnbd",
|
|
70
|
+
kAXs8y: "x1kzknox",
|
|
71
|
+
k1ekBW: "xmlsesc",
|
|
72
|
+
kIyJzY: "xctwqe3 x12w9bfk",
|
|
73
|
+
$$css: true
|
|
74
|
+
},
|
|
75
|
+
connectionActive: {
|
|
76
|
+
kDd8S0: "x1g350g8",
|
|
77
|
+
$$css: true
|
|
78
|
+
},
|
|
79
|
+
connectionDimmed: {
|
|
80
|
+
kDd8S0: "x1ykn073",
|
|
81
|
+
$$css: true
|
|
82
|
+
},
|
|
83
|
+
connectionHit: {
|
|
84
|
+
kDwRjp: "xbh8q5q",
|
|
85
|
+
kjVXCG: "xmy28x3",
|
|
86
|
+
kfJifR: "x1xdcvi0",
|
|
87
|
+
kREpy8: "x13efnbd",
|
|
88
|
+
kfzvcC: "x1bz8pot",
|
|
89
|
+
kkrTdU: "x1ypdohk",
|
|
90
|
+
$$css: true
|
|
91
|
+
},
|
|
92
|
+
flowing: {
|
|
93
|
+
k5rJSQ: "xwfxw7d",
|
|
94
|
+
kKVMdj: "xlfe1sc x1aquc0h",
|
|
95
|
+
k44tkh: "xegkacw",
|
|
96
|
+
kyAemX: "x1esw782",
|
|
97
|
+
ko0y90: "xa4qsjk",
|
|
98
|
+
$$css: true
|
|
99
|
+
},
|
|
100
|
+
markers: {
|
|
101
|
+
kVAEAm: "x10l6tqk",
|
|
102
|
+
kpwlN0: "x10a8y8t",
|
|
103
|
+
kfzvcC: "x47corl",
|
|
104
|
+
$$css: true
|
|
105
|
+
},
|
|
106
|
+
marker: {
|
|
107
|
+
kB7OPa: "x9f619",
|
|
108
|
+
kVAEAm: "x10l6tqk",
|
|
109
|
+
kzqmXN: "x1wcgf0",
|
|
110
|
+
kZKoxP: "x1lh3j6m",
|
|
111
|
+
koQZXg: "xf7xvjo",
|
|
112
|
+
keoZOQ: "x1vvmsko",
|
|
113
|
+
kaIpWk: "x1dg1y8n",
|
|
114
|
+
kfzvcC: "x67bb7w",
|
|
115
|
+
kkrTdU: "x1ypdohk",
|
|
116
|
+
k3XXqK: "x1t137rt x9v5kkp",
|
|
117
|
+
kMeerF: "x1de99jn",
|
|
118
|
+
kInvED: "x1wfwxd8",
|
|
119
|
+
kjBf7l: "xi1ptex x1x84bn5",
|
|
120
|
+
kgeoSG: "x1cpjm7i",
|
|
121
|
+
kEoFBp: "x1hmns74",
|
|
122
|
+
k75S9Q: "xgdch9p",
|
|
123
|
+
k96MEf: "x1knuo7r",
|
|
124
|
+
kQmYQc: "xwx4but",
|
|
125
|
+
kOlAkY: "xohe065",
|
|
126
|
+
kgzTxl: "x2m5qxi",
|
|
127
|
+
krMjp6: "x1b9nyww",
|
|
128
|
+
kJ33su: "x1yqnvuy",
|
|
129
|
+
kPB484: "xkv1yzh",
|
|
130
|
+
k5Ohv7: "x197iw8s",
|
|
131
|
+
kj4x2v: "x1fo1fc9",
|
|
132
|
+
kfXFYZ: "x24hq8c x1s5fmf",
|
|
133
|
+
kLkRvE: "x1b2dzgi x15j5p1n",
|
|
134
|
+
ku0W4C: "x13rwrtk",
|
|
135
|
+
k7KCAZ: "x1j7sxfd",
|
|
136
|
+
kKXxxB: "xatfyau x13sdc92",
|
|
137
|
+
kqUdNP: "xtfyijf",
|
|
138
|
+
kcTAPf: "x5ob0zg x1d1rss7 x1fllji7",
|
|
139
|
+
k5QlbN: "xfbg1o9 x1bvh3x3",
|
|
140
|
+
k5JduY: "x1s928wv",
|
|
141
|
+
kwXMNM: "x1j6awrg",
|
|
142
|
+
kv0HGH: "xz6k3c1",
|
|
143
|
+
kUfP38: "xejimk3",
|
|
144
|
+
kPGmMm: "x1941vk7",
|
|
145
|
+
kbwMcY: "x86avzo",
|
|
146
|
+
kXtpa: "x18bwxvc x1pl2zow",
|
|
147
|
+
kU8QeM: "xwnwc82",
|
|
148
|
+
kypkao: "xmf22ne x1u9stpq",
|
|
149
|
+
$$css: true
|
|
150
|
+
},
|
|
151
|
+
farSide: {
|
|
152
|
+
kSiTet: "xg01cxk",
|
|
153
|
+
kfzvcC: "x47corl",
|
|
154
|
+
$$css: true
|
|
155
|
+
},
|
|
156
|
+
controls: {
|
|
157
|
+
kVAEAm: "x10l6tqk",
|
|
158
|
+
kt4wiu: "x19c05j1",
|
|
159
|
+
krVfgx: "xz22vgf",
|
|
160
|
+
k1xSpc: "x78zum5",
|
|
161
|
+
kXwgrk: "xdt5ytf",
|
|
162
|
+
kOIVth: "xz09phk",
|
|
163
|
+
kkrTdU: "x1sqbtui",
|
|
164
|
+
$$css: true
|
|
165
|
+
},
|
|
166
|
+
tooltipBody: {
|
|
167
|
+
k1xSpc: "x78zum5",
|
|
168
|
+
kXwgrk: "xdt5ytf",
|
|
169
|
+
kGNEyG: "x1cy8zhl",
|
|
170
|
+
kOIVth: "xpowot6",
|
|
171
|
+
$$css: true
|
|
172
|
+
},
|
|
173
|
+
tooltipTitle: {
|
|
174
|
+
k1xSpc: "x1lliihq",
|
|
175
|
+
k63SB2: "x1vmg6u2",
|
|
176
|
+
$$css: true
|
|
177
|
+
},
|
|
178
|
+
tooltipLine: {
|
|
179
|
+
k1xSpc: "x1lliihq",
|
|
180
|
+
kSiTet: "x1us6l5c",
|
|
181
|
+
$$css: true
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
export { styles };
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { geoAlbers, geoDistance, geoEquirectangular, geoInterpolate, geoMercator, geoNaturalEarth1, geoOrthographic } from "d3-geo";
|
|
2
|
+
// src/geo-map/geometry.ts
|
|
3
|
+
/**
|
|
4
|
+
* The GeoMap's geometry: projections, connection arcs, the globe's drag and wheel, and fitting a view to
|
|
5
|
+
* markers. Pure functions of their inputs (d3-geo for the math, no DOM), so they run on the server and in
|
|
6
|
+
* unit tests. A Solid rewrite of hyper-ui's maps (packages/viz/src/{geo-map,connection-map,shared}), where
|
|
7
|
+
* D3 classes owned the DOM; here Solid renders and d3-geo only projects.
|
|
8
|
+
*/
|
|
9
|
+
const SPHERE = { type: "Sphere" };
|
|
10
|
+
/** The space kept around the world when it's fitted into the map's box, in pixels. */
|
|
11
|
+
const FIT_PADDING = 8;
|
|
12
|
+
/** A fresh d3 projection of the given kind, before fitting. */
|
|
13
|
+
function baseProjection(type) {
|
|
14
|
+
switch (type) {
|
|
15
|
+
case "mercator": return geoMercator();
|
|
16
|
+
case "equirectangular": return geoEquirectangular();
|
|
17
|
+
case "orthographic": return geoOrthographic().clipAngle(90);
|
|
18
|
+
case "albers": return geoAlbers();
|
|
19
|
+
default: return geoNaturalEarth1();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A projection fitted to a `width` × `height` box: the whole world (the sphere) inside it with
|
|
24
|
+
* `FIT_PADDING` around, centered. A globe is turned to `rotation` first and then scaled by `scale` (1 is
|
|
25
|
+
* the fitted disc).
|
|
26
|
+
*/
|
|
27
|
+
function fittedProjection(type, width, height, rotation = [
|
|
28
|
+
0,
|
|
29
|
+
0,
|
|
30
|
+
0
|
|
31
|
+
], scale = 1) {
|
|
32
|
+
const p = baseProjection(type);
|
|
33
|
+
if (type === "orthographic") p.rotate(rotation);
|
|
34
|
+
const pad = Math.min(8, width / 4, height / 4);
|
|
35
|
+
p.fitExtent([[pad, pad], [Math.max(pad + 1, width - pad), Math.max(pad + 1, height - pad)]], SPHERE);
|
|
36
|
+
if (scale !== 1) p.scale(p.scale() * scale);
|
|
37
|
+
return p;
|
|
38
|
+
}
|
|
39
|
+
/** Whether a point faces the viewer on a globe turned to `rotation` (within 90° of its center). */
|
|
40
|
+
function facesViewer(point, rotation) {
|
|
41
|
+
return geoDistance(point, [-rotation[0], -rotation[1]]) < Math.PI / 2 - 1e-9;
|
|
42
|
+
}
|
|
43
|
+
/** The rotation that puts `[longitude, latitude]` in the middle of a globe, keeping its roll. */
|
|
44
|
+
function rotationFacing(point, roll = 0) {
|
|
45
|
+
return [
|
|
46
|
+
-point[0],
|
|
47
|
+
-point[1],
|
|
48
|
+
roll
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
const fmt = (n) => Math.round(n * 100) / 100;
|
|
52
|
+
/**
|
|
53
|
+
* A connection between two points on screen, as an SVG path (`connection-map.ts:517-618`):
|
|
54
|
+
*
|
|
55
|
+
* - `straight`: a line.
|
|
56
|
+
* - `quadratic`: a curve whose control point sits off the midpoint, perpendicular to the line, by 0.3 of
|
|
57
|
+
* the distance (always to the same side of the travel direction, so A→B and B→A bow apart).
|
|
58
|
+
* - `greatCircle` on a flat map: a gentler curve (0.2 of the distance), always bowed up the screen, which
|
|
59
|
+
* reads as the shortest way over the globe without wrapping around the map's edge.
|
|
60
|
+
*/
|
|
61
|
+
function screenArc(style, a, b) {
|
|
62
|
+
const [x1, y1] = a;
|
|
63
|
+
const [x2, y2] = b;
|
|
64
|
+
const dx = x2 - x1;
|
|
65
|
+
const dy = y2 - y1;
|
|
66
|
+
const len = Math.hypot(dx, dy);
|
|
67
|
+
if (style === "straight" || len === 0) return `M${fmt(x1)},${fmt(y1)}L${fmt(x2)},${fmt(y2)}`;
|
|
68
|
+
const perpX = -dy / len;
|
|
69
|
+
const perpY = dx / len;
|
|
70
|
+
const midX = (x1 + x2) / 2;
|
|
71
|
+
const midY = (y1 + y2) / 2;
|
|
72
|
+
let offset;
|
|
73
|
+
if (style === "quadratic") offset = len * .3;
|
|
74
|
+
else offset = len * .2 * (perpY < 0 ? 1 : -1);
|
|
75
|
+
const cx = midX + perpX * offset;
|
|
76
|
+
const cy = midY + perpY * offset;
|
|
77
|
+
return `M${fmt(x1)},${fmt(y1)}Q${fmt(cx)},${fmt(cy)} ${fmt(x2)},${fmt(y2)}`;
|
|
78
|
+
}
|
|
79
|
+
/** How many points a great-circle arc on the globe is sampled at. */
|
|
80
|
+
const ARC_SAMPLES = 50;
|
|
81
|
+
/**
|
|
82
|
+
* A great circle between two places on a globe: `geoInterpolate` sampled at `ARC_SAMPLES` points and
|
|
83
|
+
* projected. Points over the horizon are left out, so an arc that crosses it ends at the edge (hyper-ui
|
|
84
|
+
* dropped the whole arc as soon as one end turned away). Empty when none of it faces the viewer.
|
|
85
|
+
*/
|
|
86
|
+
function globeArc(projection, a, b) {
|
|
87
|
+
const interpolate = geoInterpolate(a, b);
|
|
88
|
+
const rotation = projection.rotate();
|
|
89
|
+
let d = "";
|
|
90
|
+
let drawing = false;
|
|
91
|
+
for (let i = 0; i <= 50; i++) {
|
|
92
|
+
const at = interpolate(i / 50);
|
|
93
|
+
const xy = facesViewer(at, rotation) ? projection(at) : null;
|
|
94
|
+
if (!xy) {
|
|
95
|
+
drawing = false;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
d += `${drawing ? "L" : "M"}${fmt(xy[0])},${fmt(xy[1])}`;
|
|
99
|
+
drawing = true;
|
|
100
|
+
}
|
|
101
|
+
return /L/.test(d) ? d : "";
|
|
102
|
+
}
|
|
103
|
+
/** Degrees of rotation per dragged pixel, at a scale of 1. */
|
|
104
|
+
const GLOBE_SENSITIVITY = .5;
|
|
105
|
+
const GLOBE_SCALE_MIN = .5;
|
|
106
|
+
const GLOBE_SCALE_MAX = 8;
|
|
107
|
+
const clamp = (value, min, max) => Math.max(min, Math.min(max, value));
|
|
108
|
+
/** The next globe view for an event; the same object when nothing changed. */
|
|
109
|
+
function globeTransition(view, event) {
|
|
110
|
+
switch (event.type) {
|
|
111
|
+
case "dragStart": return {
|
|
112
|
+
...view,
|
|
113
|
+
drag: {
|
|
114
|
+
x: event.x,
|
|
115
|
+
y: event.y,
|
|
116
|
+
from: view.rotation
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
case "dragMove": {
|
|
120
|
+
if (!view.drag) return view;
|
|
121
|
+
const { from } = view.drag;
|
|
122
|
+
const k = GLOBE_SENSITIVITY / view.scale;
|
|
123
|
+
const rotation = [
|
|
124
|
+
from[0] + (event.x - view.drag.x) * k,
|
|
125
|
+
clamp(from[1] - (event.y - view.drag.y) * k, -90, 90),
|
|
126
|
+
from[2]
|
|
127
|
+
];
|
|
128
|
+
return rotation[0] === view.rotation[0] && rotation[1] === view.rotation[1] ? view : {
|
|
129
|
+
...view,
|
|
130
|
+
rotation
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
case "dragEnd": return view.drag ? {
|
|
134
|
+
...view,
|
|
135
|
+
drag: null
|
|
136
|
+
} : view;
|
|
137
|
+
case "scaleBy": return globeTransition(view, {
|
|
138
|
+
type: "scaleTo",
|
|
139
|
+
scale: view.scale * event.factor
|
|
140
|
+
});
|
|
141
|
+
case "scaleTo": {
|
|
142
|
+
const scale = clamp(event.scale, GLOBE_SCALE_MIN, 8);
|
|
143
|
+
return scale === view.scale ? view : {
|
|
144
|
+
...view,
|
|
145
|
+
scale
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
case "rotateTo": return {
|
|
149
|
+
...view,
|
|
150
|
+
rotation: event.rotation,
|
|
151
|
+
drag: null
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/** The box around projected points, or null for none. */
|
|
156
|
+
function boundsOf(points) {
|
|
157
|
+
if (points.length === 0) return null;
|
|
158
|
+
let left = Infinity;
|
|
159
|
+
let top = Infinity;
|
|
160
|
+
let right = -Infinity;
|
|
161
|
+
let bottom = -Infinity;
|
|
162
|
+
for (const [x, y] of points) {
|
|
163
|
+
left = Math.min(left, x);
|
|
164
|
+
right = Math.max(right, x);
|
|
165
|
+
top = Math.min(top, y);
|
|
166
|
+
bottom = Math.max(bottom, y);
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
left,
|
|
170
|
+
top,
|
|
171
|
+
right,
|
|
172
|
+
bottom
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
const FLAT_ZOOM_MIN = 1;
|
|
176
|
+
const FLAT_ZOOM_MAX = 12;
|
|
177
|
+
/**
|
|
178
|
+
* A flat view kept in bounds: zoomed between `FLAT_ZOOM_MIN` and `FLAT_ZOOM_MAX`, and panned no further
|
|
179
|
+
* than the world's edges (at zoom 1 it doesn't move).
|
|
180
|
+
*/
|
|
181
|
+
function clampFlat(view, width, height) {
|
|
182
|
+
const zoom = clamp(view.zoom, 1, 12);
|
|
183
|
+
return {
|
|
184
|
+
zoom,
|
|
185
|
+
x: clamp(view.x, width * (1 - zoom), 0),
|
|
186
|
+
y: clamp(view.y, height * (1 - zoom), 0)
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* The flat view that shows `rect` whole and centered with `padding` around it, zoomed in no further than
|
|
191
|
+
* `maxZoom` (a lone marker gets `maxZoom`).
|
|
192
|
+
*/
|
|
193
|
+
function fitFlat(rect, width, height, padding = 48, maxZoom = 6) {
|
|
194
|
+
const w = rect.right - rect.left;
|
|
195
|
+
const h = rect.bottom - rect.top;
|
|
196
|
+
const zoom = Math.min(w > 0 ? (width - padding * 2) / w : maxZoom, h > 0 ? (height - padding * 2) / h : maxZoom, maxZoom);
|
|
197
|
+
const z = Math.max(1, zoom);
|
|
198
|
+
const cx = (rect.left + rect.right) / 2;
|
|
199
|
+
const cy = (rect.top + rect.bottom) / 2;
|
|
200
|
+
return clampFlat({
|
|
201
|
+
zoom: z,
|
|
202
|
+
x: width / 2 - cx * z,
|
|
203
|
+
y: height / 2 - cy * z
|
|
204
|
+
}, width, height);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* The globe view that shows every place: turned to face their middle (the mean of their unit vectors,
|
|
208
|
+
* so places on both sides of the date line average correctly), and scaled until the farthest one sits
|
|
209
|
+
* inside the disc's rim. A spread wider than a hemisphere keeps the fitted disc (scale 1).
|
|
210
|
+
*/
|
|
211
|
+
function globeFit(places, roll = 0) {
|
|
212
|
+
if (places.length === 0) return null;
|
|
213
|
+
let x = 0;
|
|
214
|
+
let y = 0;
|
|
215
|
+
let z = 0;
|
|
216
|
+
const rad = Math.PI / 180;
|
|
217
|
+
for (const [lon, lat] of places) {
|
|
218
|
+
const c = Math.cos(lat * rad);
|
|
219
|
+
x += c * Math.cos(lon * rad);
|
|
220
|
+
y += c * Math.sin(lon * rad);
|
|
221
|
+
z += Math.sin(lat * rad);
|
|
222
|
+
}
|
|
223
|
+
const center = Math.hypot(x, y, z) < 1e-9 ? places[0] : [Math.atan2(y, x) / rad, Math.atan2(z, Math.hypot(x, y)) / rad];
|
|
224
|
+
const spread = Math.max(...places.map((p) => geoDistance(p, center)));
|
|
225
|
+
const scale = spread >= Math.PI / 2 || spread < 1e-6 ? 1 : clamp(.8 / Math.sin(spread), 1, 8);
|
|
226
|
+
return {
|
|
227
|
+
rotation: rotationFacing(center, roll),
|
|
228
|
+
scale: spread < 1e-6 ? 2 : scale
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
export { ARC_SAMPLES, FIT_PADDING, FLAT_ZOOM_MAX, FLAT_ZOOM_MIN, GLOBE_SCALE_MAX, GLOBE_SCALE_MIN, GLOBE_SENSITIVITY, baseProjection, boundsOf, clampFlat, facesViewer, fitFlat, fittedProjection, globeArc, globeFit, globeTransition, rotationFacing, screenArc };
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/geo-map/world.ts
|
|
2
|
+
let loading;
|
|
3
|
+
/**
|
|
4
|
+
* The countries at 1:110m, as GeoJSON. Loads once per page (later calls share the request); call it early
|
|
5
|
+
* to start the load before a map mounts, or pass its result as `worldData` to render land on the server.
|
|
6
|
+
*/
|
|
7
|
+
function loadWorld() {
|
|
8
|
+
loading ??= Promise.all([import("world-atlas/countries-110m.json"), import("topojson-client")]).then(([atlas, topojson]) => {
|
|
9
|
+
const topology = atlas.default ?? atlas;
|
|
10
|
+
return topojson.feature(topology, topology.objects.countries);
|
|
11
|
+
});
|
|
12
|
+
loading.catch(() => loading = void 0);
|
|
13
|
+
return loading;
|
|
14
|
+
}
|
|
15
|
+
export { loadWorld };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Flow, FlowBackground, FlowControls, FlowEdge, FlowMiniMap, FlowNode } from "./flow/flow.jsx";
|
|
2
|
+
import { layoutFlow } from "./flow/layout.jsx";
|
|
3
|
+
import { BaseEdge, Handle, Panel, Position, createEdgeStore, createNodeStore, getBezierPath, getSmoothStepPath, getStraightPath, useSolidFlow } from "./flow/index.jsx";
|
|
4
|
+
import { loadWorld } from "./geo-map/world.jsx";
|
|
5
|
+
import { GeoMap, geoMapColor } from "./geo-map/geo-map.jsx";
|
|
6
|
+
export { BaseEdge, Flow, FlowBackground, FlowControls, FlowEdge, FlowMiniMap, FlowNode, GeoMap, Handle, Panel, Position, createEdgeStore, createNodeStore, geoMapColor, getBezierPath, getSmoothStepPath, getStraightPath, layoutFlow, loadWorld, useSolidFlow };
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer sui.reset,ui-sdk;@layer sui.base{@layer xyflow{.solid-flow__zoom{z-index:4}.solid-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.solid-flow__viewport-portal{-webkit-user-select:none;user-select:none}.solid-flow__pane{z-index:1;touch-action:none;&:before{content:"";position:absolute;inset:0}&.draggable:before{cursor:grab}&.selection,&.selection:before{cursor:pointer}}.solid-flow__pan-cursor{z-index:1000;cursor:grabbing;position:absolute;inset:0}.solid-flow__panel{z-index:5;margin:15px;position:absolute;&.top{top:0}&.bottom{bottom:0}&.left{left:0}&.right{right:0}&.top,&.bottom{&.center{left:50%;transform:translate(-15px)translate(-50%)}}&.left,&.right{&.center{top:50%;transform:translateY(-15px)translateY(-50%)}}}.solid-flow__nodes{z-index:0;pointer-events:none;transform-origin:0 0}.a11y-hidden{display:none}.a11y-live-msg{clip:rect(0px, 0px, 0px, 0px);clip-path:inset(100%);border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.solid-flow{--xy-connectionline-stroke-default:#b1b1b7;--xy-connectionline-stroke-width-default:1}.solid-flow__connectionline{z-index:1001;position:absolute;overflow:visible}.solid-flow__connection{pointer-events:none;& .animated{stroke-dasharray:5;animation:.5s linear infinite dashdraw}}.solid-flow__connection-path{fill:none;stroke:var(--xy-connectionline-stroke,var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width,var(--xy-connectionline-stroke-width-default))}.solid-flow{--xy-edge-stroke-default:light-dark(#b1b1b7,#3e3e3e);--xy-edge-stroke-width-default:1;--xy-edge-stroke-selected-default:light-dark(#555,#727272)}.solid-flow__edge-label{text-align:center;position:absolute}.solid-flow__edge-label.transparent{background:0 0}.solid-flow__edgeupdater{cursor:move;pointer-events:all}.solid-flow__edge-path{stroke:var(--xy-edge-stroke,var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width,var(--xy-edge-stroke-width-default));fill:none}.solid-flow__arrowhead polyline{stroke:var(--xy-edge-stroke,var(--xy-edge-stroke-default))}.solid-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke,var(--xy-edge-stroke-default))}.solid-flow__edges{position:absolute;& svg{pointer-events:none;position:absolute;overflow:visible}}.solid-flow__edge{pointer-events:visibleStroke;&.selectable{cursor:pointer}&.animated path{stroke-dasharray:5;animation:.5s linear infinite dashdraw}&.animated path.solid-flow__edge-interaction{stroke-dasharray:none;animation:none}&.inactive{pointer-events:none}&.selected,&:focus,&:focus-visible{outline:none}&.selected .solid-flow__edge-path,&.selectable:focus .solid-flow__edge-path,&.selectable:focus-visible .solid-flow__edge-path{stroke:var(--xy-edge-stroke-selected,var(--xy-edge-stroke-selected-default))}}.solid-flow__handle{pointer-events:none;min-width:5px;min-height:5px;position:absolute;&.connectingfrom{pointer-events:all}}.solid-flow:not(.connecting) .solid-flow__handle.connectable.connectablestart,.solid-flow.connecting.connection-strict.connecting-from-source .solid-flow__handle.connectable.connectableend.target:not(.excluded),.solid-flow.connecting.connection-strict.connecting-from-target .solid-flow__handle.connectable.connectableend.source:not(.excluded),.solid-flow.connecting:not(.connection-strict) .solid-flow__handle.connectable.connectableend:not(.excluded){pointer-events:all;cursor:crosshair}.solid-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.solid-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.solid-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.solid-flow__handle-bottom{top:auto;bottom:0;left:50%;transform:translate(-50%,50%)}.solid-flow__node{-webkit-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default;position:absolute;&.selectable{cursor:pointer}&.draggable{cursor:grab;pointer-events:all;&.dragging{cursor:grabbing}}}.solid-flow__selection-wrapper{z-index:2000;pointer-events:all;position:absolute;top:0;left:0;&:focus,&:focus-visible{outline:none}}.solid-flow__selection{z-index:6;position:absolute;top:0;left:0}.solid-flow{--xy-background-color-default:light-dark(#0000,#141414);--xy-background-pattern-dots-color-default:light-dark(#91919a,#555);--xy-background-pattern-lines-color-default:light-dark(#eee,#333);--xy-background-pattern-cross-color-default:light-dark(#e2e2e2,#333)}.solid-flow__background{pointer-events:none;z-index:-1;background-color:var(--xy-background-color-props,var(--xy-background-color,var(--xy-background-color-default)))}.solid-flow__background-pattern{&.dots{fill:var(--xy-background-pattern-color-props,var(--xy-background-pattern-color,var(--xy-background-pattern-dots-color-default)))}&.lines{stroke:var(--xy-background-pattern-color-props,var(--xy-background-pattern-color,var(--xy-background-pattern-lines-color-default)))}&.cross{stroke:var(--xy-background-pattern-color-props,var(--xy-background-pattern-color,var(--xy-background-pattern-cross-color-default)))}}.solid-flow__controls{flex-direction:column;display:flex;&.horizontal{flex-direction:row}}.solid-flow__controls-button{justify-content:center;align-items:center;width:26px;height:26px;padding:4px;display:flex;& svg{fill:currentColor;width:100%;max-width:12px;max-height:12px}}.solid-flow{--xy-minimap-background-color-default:light-dark(#fff,#141414);--xy-minimap-mask-background-color-default:light-dark(#f0f0f099,#3c3c3c99);--xy-minimap-mask-stroke-color-default:transparent;--xy-minimap-mask-stroke-width-default:1;--xy-minimap-node-background-color-default:light-dark(#e2e2e2,#2b2b2b);--xy-minimap-node-stroke-color-default:transparent;--xy-minimap-node-stroke-width-default:2}.solid-flow__minimap{background:var(--xy-minimap-background-color-props,var(--xy-minimap-background-color,var(--xy-minimap-background-color-default)))}.solid-flow__minimap-svg{display:block}.solid-flow__minimap-mask{fill:var(--xy-minimap-mask-background-color-props,var(--xy-minimap-mask-background-color,var(--xy-minimap-mask-background-color-default)));stroke:var(--xy-minimap-mask-stroke-color-props,var(--xy-minimap-mask-stroke-color,var(--xy-minimap-mask-stroke-color-default)));stroke-width:var(--xy-minimap-mask-stroke-width-props,var(--xy-minimap-mask-stroke-width,var(--xy-minimap-mask-stroke-width-default)))}.solid-flow__minimap-node{fill:var(--xy-minimap-node-background-color-props,var(--xy-minimap-node-background-color,var(--xy-minimap-node-background-color-default)));stroke:var(--xy-minimap-node-stroke-color-props,var(--xy-minimap-node-stroke-color,var(--xy-minimap-node-stroke-color-default)));stroke-width:var(--xy-minimap-node-stroke-width-props,var(--xy-minimap-node-stroke-width,var(--xy-minimap-node-stroke-width-default)))}.solid-flow{--xy-resize-background-color-default:#3367d9}.solid-flow__resize-control{position:absolute;&.left,&.right{cursor:ew-resize}&.top,&.bottom{cursor:ns-resize}&.top.left,&.bottom.right{cursor:nwse-resize}&.bottom.left,&.top.right{cursor:nesw-resize}}.solid-flow__resize-control.handle{background-color:var(--xy-resize-background-color,var(--xy-resize-background-color-default));border:1px solid #fff;border-radius:1px;width:5px;height:5px;translate:-50% -50%;&.left{top:50%;left:0}&.right{top:50%;left:100%}&.top{top:0;left:50%}&.bottom{top:100%;left:50%}&.top.left,&.bottom.left{left:0}&.top.right,&.bottom.right{left:100%}}.solid-flow__resize-control.line{border-color:var(--xy-resize-background-color,var(--xy-resize-background-color-default));border-style:solid;border-width:0;&.left,&.right{width:1px;height:100%;top:0;transform:translate(-50%)}&.top,&.bottom{width:100%;height:1px;left:0;transform:translateY(-50%)}&.left{border-left-width:1px;left:0}&.right{border-right-width:1px;left:100%}&.top{border-top-width:1px;top:0}&.bottom{border-bottom-width:1px;top:100%}}.solid-flow{--xy-attribution-background-color-default:light-dark(#ffffff80,#96969640)}.solid-flow__attribution{background:var(--xy-attribution-background-color,var(--xy-attribution-background-color-default));margin:0;padding:2px 3px;font-size:10px;& a{color:#999;text-decoration:none}}.solid-flow__container{-webkit-user-select:none;user-select:none;width:100%;height:100%;position:absolute;top:0;left:0}.solid-flow{z-index:0;background-color:var(--xy-background-color,var(--xy-background-color-default));color-scheme:light dark;direction:ltr;width:100%;height:100%;position:relative;overflow:hidden}[data-theme=dark] .solid-flow,.dark .solid-flow{color-scheme:dark}[data-theme=light] .solid-flow,.light .solid-flow,.solid-flow.light{color-scheme:light}.solid-flow.dark{color-scheme:dark}@keyframes dashdraw{0%{stroke-dashoffset:10px}}.solid-flow{--xy-node-color-default:light-dark(currentColor,#f8f8f8);--xy-node-border-default:1px solid light-dark(#1a192b,#3c3c3c);--xy-node-background-color-default:light-dark(#fff,#1e1e1e);--xy-node-group-background-color-default:#f0f0f040;--xy-node-boxshadow-hover-default:0 1px 4px 1px light-dark(#00000014,#ffffff14);--xy-node-boxshadow-selected-default:0 0 0 .5px light-dark(#1a192b,#999);--xy-node-border-radius-default:3px;--xy-handle-background-color-default:light-dark(#1a192b,#bebebe);--xy-handle-border-color-default:light-dark(#fff,#1e1e1e);--xy-selection-background-color-default:light-dark(#0059dc14,#c8c8dc14);--xy-selection-border-default:1px dotted light-dark(#0059dccc,#c8c8dccc);--xy-controls-button-background-color-default:light-dark(#fefefe,#2b2b2b);--xy-controls-button-background-color-hover-default:light-dark(#f4f4f4,#3e3e3e);--xy-controls-button-color-default:light-dark(currentColor,#f8f8f8);--xy-controls-button-color-hover-default:light-dark(currentColor,#fff);--xy-controls-button-border-color-default:light-dark(#eee,#5b5b5b);--xy-controls-box-shadow-default:0 0 2px 1px #00000014;--xy-edge-label-background-color-default:light-dark(#fff,#141414);--xy-edge-label-color-default:light-dark(currentColor,#f8f8f8)}.solid-flow__edge{&.updating{& .solid-flow__edge-path{stroke:#777}}}.solid-flow__edge-label{color:var(--xy-edge-label-color,var(--xy-edge-label-color-default));background:var(--xy-edge-label-background-color,var(--xy-edge-label-background-color-default));padding:2px;font-size:10px}.solid-flow__node.selectable{&:focus,&:focus-visible{outline:none}}.solid-flow__node-input,.solid-flow__node-default,.solid-flow__node-output,.solid-flow__node-group{border-radius:var(--xy-node-border-radius,var(--xy-node-border-radius-default));width:150px;color:var(--xy-node-color,var(--xy-node-color-default));text-align:center;border:var(--xy-node-border,var(--xy-node-border-default));background-color:var(--xy-node-background-color,var(--xy-node-background-color-default));padding:10px;font-size:12px;&.selectable{&:hover{box-shadow:var(--xy-node-boxshadow-hover,var(--xy-node-boxshadow-hover-default))}&.selected,&:focus,&:focus-visible{box-shadow:var(--xy-node-boxshadow-selected,var(--xy-node-boxshadow-selected-default))}}}.solid-flow__node-group{background-color:var(--xy-node-group-background-color,var(--xy-node-group-background-color-default))}.solid-flow__selection{background:var(--xy-selection-background-color,var(--xy-selection-background-color-default));border:var(--xy-selection-border,var(--xy-selection-border-default));&:focus,&:focus-visible{outline:none}}.solid-flow__handle{background-color:var(--xy-handle-background-color,var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color,var(--xy-handle-border-color-default));border-radius:100%;width:6px;height:6px}.solid-flow__controls{box-shadow:var(--xy-controls-box-shadow,var(--xy-controls-box-shadow-default))}.solid-flow__controls-button{cursor:pointer;-webkit-user-select:none;user-select:none;background:var(--xy-controls-button-background-color-props,var(--xy-controls-button-background-color,var(--xy-controls-button-background-color-default)));border:none;border-bottom:1px solid var(--xy-controls-button-border-color-props,var(--xy-controls-button-border-color,var(--xy-controls-button-border-color-default)));color:var(--xy-controls-button-color-props,var(--xy-controls-button-color,var(--xy-controls-button-color-default)));&:hover{background:var(--xy-controls-button-background-color-hover-props,var(--xy-controls-button-background-color-hover,var(--xy-controls-button-background-color-hover-default)));color:var(--xy-controls-button-color-hover-props,var(--xy-controls-button-color-hover,var(--xy-controls-button-color-hover-default)))}&:disabled{pointer-events:none;& svg{fill-opacity:.4}}&:last-child{border-bottom:none}}.solid-flow__controls.horizontal .solid-flow__controls-button{border-bottom:none;border-right:1px solid var(--xy-controls-button-border-color-props,var(--xy-controls-button-border-color,var(--xy-controls-button-border-color-default)));&:last-child{border-right:none}}}}@layer sui.components{@layer priority1{:root{--sui-chart-1:light-dark(oklch(57.5% .163 255.5),oklch(62.2% .161 255.1));--sui-chart-2:light-dark(oklch(67.1% .175 40.6),oklch(62.2% .173 40.1));--sui-chart-3:light-dark(oklch(66.9% .141 162.1),oklch(62.1% .128 163.1));--sui-chart-4:light-dark(oklch(76.4% .161 75.1),oklch(67% .143 73.2));--sui-chart-5:light-dark(oklch(71.6% .141 357.4),oklch(62.2% .171 .8));--sui-chart-6:light-dark(oklch(52.9% .18 142.5),oklch(62.1% .207 142.6));--sui-chart-7:light-dark(oklch(52.7% .197 283.4),oklch(67% .145 286.8));--sui-chart-8:light-dark(oklch(62.3% .191 24.9),oklch(66.9% .159 22.3));--sui-chart-heat-1:light-dark(oklch(97% .06 102),oklch(88% .08 100));--sui-chart-heat-2:light-dark(oklch(91% .11 92),oklch(82% .11 88));--sui-chart-heat-3:light-dark(oklch(83% .12 70),oklch(76% .12 68));--sui-chart-heat-4:light-dark(oklch(72% .14 45),oklch(69% .14 45));--sui-chart-heat-5:light-dark(oklch(52% .17 27),oklch(52% .16 27));--sui-chart-heat-text:oklch(24% .03 60);--sui-chart-heat-text-inverse:oklch(98.5% .005 90);--sui-map-water:light-dark(oklch(97.5% .004 250),oklch(18.5% .006 260));--sui-map-land:light-dark(oklch(91.5% .005 260),oklch(30% .008 260));--sui-map-land-border:light-dark(oklch(98.5% .002 260),oklch(22% .006 260));--sui-map-graticule:light-dark(oklch(0% 0 0/.08),oklch(100% 0 0/.07))}.x1hgq7sz{--flow-ink:var(--sui-accent-text)}.x1x3owhy{--flow-ink:var(--sui-danger-text)}.xbfl7yv{--flow-ink:var(--sui-success-text)}.x1lxbday{--flow-ink:var(--sui-text-muted)}.xdzv0v4{--flow-ink:var(--sui-text-subtle)}.xmdc92d{--flow-ink:var(--sui-warning-text)}.x26i07e{--flow-node-edge:var(--sui-accent)}.x1v79dzn{--flow-node-edge:var(--sui-border-strong)}.x1w067c4{--flow-node-edge:var(--sui-border)}.x18kdt69{--flow-node-edge:var(--sui-danger)}.x1dbrlxx{--flow-node-edge:var(--sui-warning)}}@layer priority2{.x10a8y8t{inset:0}}@layer priority3{.x1vl23hm{border-color:var(--flow-node-edge)}.x1xfin0c{border-color:var(--sui-border-strong)}.x1wpxzwl{border-color:var(--sui-border)}.x1dg1y8n{border-radius:var(--sui-radius-full)}.x1oiwymw{border-radius:var(--sui-radius-lg)}.x1ttroej{border-radius:var(--sui-radius-md)}.x1y0btm7{border-style:solid}.xmkeg23{border-width:1px}.x12lumcd{flex:auto}.xpowot6{gap:var(--sui-space-0_5)}.xz09phk{gap:var(--sui-space-1)}.x8rwxmg{gap:var(--sui-space-2)}.x7giv3{overflow:clip}.xb3r6kr{overflow:hidden}.xqy2vlu{padding-block:var(--sui-space-2)}.xxobuei{padding-inline:var(--sui-space-3)}@media (forced-colors:active){.x1w1tqly.x1w1tqly{border-color:canvastext}}}@layer priority4{.x1winvzj{-webkit-user-select:none}.x6s0dn4{align-items:center}.x1cy8zhl{align-items:flex-start}.xemfg65{animation-duration:.8s}.xegkacw{animation-duration:.9s}.xa4qsjk{animation-iteration-count:infinite}.xlfe1sc{animation-name:x11jlj4t-B}.x10xa9bi{animation-name:x6iaekb-B}.x1esw782{animation-timing-function:linear}.x186iv6y{aspect-ratio:16/9}.x1wskzqf{aspect-ratio:2}.xjbqb8w{background-color:#0000}.x1e14fz7{background-color:var(--sui-map-water)}.xm9f0jk{background-color:var(--sui-surface)}.x1ca8aof{box-shadow:var(--sui-shadow-xs)}.x9f619{box-sizing:border-box}.x1eitvad{color:var(--flow-ink)}.xe2mk2a{color:var(--sui-text-muted)}.x1yjpjgc{color:var(--sui-text)}.x1sqbtui{cursor:auto}.x1jm3nie{cursor:grab}.x1ypdohk{cursor:pointer}.x1lliihq{display:block}.x78zum5{display:flex}.x3nfvp2{display:inline-flex}.xbh8q5q{fill:none}.x1n8x9jh{fill:var(--sui-map-land)}.x16pbne5{fill:var(--sui-map-water)}.xdt5ytf{flex-direction:column}.x2lah0s{flex-shrink:0}.x13rcfk{font-family:var(--sui-font-sans)}.x409pna{font-size:var(--sui-text-sm)}.xb5fjo1{font-size:var(--sui-text-xs)}.xss6m8b{font-variant-numeric:tabular-nums}.x1vmg6u2{font-weight:var(--sui-weight-medium)}.x1kzknox{forced-color-adjust:none}.x19c05j1{inset-inline-end:var(--sui-space-2)}.xl56j7k{justify-content:center}.xau0z5x{line-height:var(--sui-leading-tight)}.x1us6l5c{opacity:.8}.xg01cxk{opacity:0}.x1g21a3s{outline-color:highlight}.xi1ptex{outline-color:var(--sui-focus)}.x1wfwxd8{outline-offset:0}.x1t137rt{outline-style:none}.x1de99jn{outline-width:2px}.x67bb7w{pointer-events:auto}.x47corl{pointer-events:none}.x1bz8pot{pointer-events:stroke}.x10l6tqk{position:absolute}.x1n2onr6{position:relative}.xmy28x3{stroke:#0000}.xbf09jc{stroke:var(--flow-edge-color)}.x125p37g{stroke:var(--geo-map-color)}.x17ickob{stroke:var(--sui-map-graticule)}.xkkurtx{stroke:var(--sui-map-land-border)}.xwfxw7d{stroke-dasharray:6 6}.x1o3yjxk{stroke-dasharray:8 8}.x1owpc8m{stroke-linecap:round}.x1f6yumg{stroke-linejoin:round}.x1ykn073{stroke-opacity:.12}.x1jhn8ml{stroke-opacity:.7}.x1g350g8{stroke-opacity:1}.x7mprgd{stroke-width:.6px}.xhr4kjn{stroke-width:1.5px}.xnpr05h{stroke-width:1px}.x1xdcvi0{stroke-width:10px}.x33it27{stroke-width:var(--geo-map-weight)}.x1yc453h{text-align:start}.xlyipyv{text-overflow:ellipsis}.x5ve5x3{touch-action:none}.xctwqe3{transition-duration:var(--sui-duration-fast)}.xkdsq27{transition-property:box-shadow}.xmlsesc{transition-property:stroke-opacity}.x87ps6o{-webkit-user-select:none;user-select:none}.x13efnbd{vector-effect:non-scaling-stroke}.xuxw1ft{white-space:nowrap}.xuhup3a.xuhup3a:where(.selected>*){box-shadow:0 0 0 2px var(--sui-accent)}.x9v5kkp:focus-visible{outline-style:solid}.xch2mbi:active{cursor:grabbing}@media (prefers-reduced-motion:reduce){.x1aquc0h.x1aquc0h{animation-name:none}}@media (forced-colors:active){.xs5hli.xs5hli{color:canvastext}.x1h8bevw.x1h8bevw{fill:canvas}.x1x84bn5.x1x84bn5{outline-color:highlight}.x1894zjx.x1894zjx{outline-style:none}.x8jos32.x8jos32{stroke:canvastext}.x16cwk3t.x16cwk3t{stroke:graytext}}@media (prefers-reduced-motion:reduce){.x12w9bfk.x12w9bfk{transition-duration:0s}}@media (forced-colors:active){.x131agne.x131agne.x131agne:where(.selected>*){outline-style:solid}}}@layer priority5{.xz22vgf{bottom:var(--sui-space-2)}.x5yr21d{height:100%}.x1l36t39{height:1rem}.xdk7pt{height:8px}.x1lh3j6m{height:max(1.5rem,calc(var(--geo-map-radius) * 2px + 6px))}.xf7xvjo{margin-left:calc(max(1.5rem,calc(var(--geo-map-radius) * 2px + 6px)) / -2)}.x1vvmsko{margin-top:calc(max(1.5rem,calc(var(--geo-map-radius) * 2px + 6px)) / -2)}.x16suv20{min-height:8px}.xeuugli{min-width:0}.x11inojt{min-width:8px}.xh8yej3{width:100%}.xcdlrvm{width:1rem}.x1xc55vz{width:8px}.x1wcgf0{width:max(1.5rem,calc(var(--geo-map-radius) * 2px + 6px))}}@layer priority6{.xz6k3c1:after{inset:calc(50% - var(--geo-map-radius) * 1px - 5px)}}@layer priority7{.x18bwxvc:after{border-color:var(--geo-map-color)}.x24hq8c:before{border-color:var(--sui-surface)}.xejimk3:after,.xkv1yzh:before{border-radius:var(--sui-radius-full)}.x1fo1fc9:before,.x86avzo:after{border-style:solid}.x197iw8s:before{border-width:1.5px}.x1941vk7:after{border-width:2px}@media (forced-colors:active){.x1s5fmf.x1s5fmf:before{border-color:canvas}.x1pl2zow.x1pl2zow:after{border-color:highlight}}}@layer priority8{.x1b2dzgi:before{background-color:var(--geo-map-color)}.xwx4but:before{box-sizing:content-box}.x1cpjm7i:before,.x1s928wv:after{content:""}.x13rwrtk:before,.xwnwc82:after{forced-color-adjust:none}.xmf22ne:after{opacity:0}.xfbg1o9:before{opacity:1}.x1hmns74:before,.x1j6awrg:after{position:absolute}.x5ob0zg:before{transform:none}.xatfyau:before{transition-duration:var(--sui-duration-fast)}.x1j7sxfd:before{transition-property:transform,opacity}.xtfyijf:before{transition-timing-function:var(--sui-ease-out)}.x1bvh3x3.x1bvh3x3:where([data-dimmed]):before{opacity:.3}.x1u9stpq.x1u9stpq:where([aria-selected=true]):after{opacity:1}.x1d1rss7.x1d1rss7:where([data-active],:hover):before{transform:scale(1.3)}@media (forced-colors:active){.x15j5p1n.x15j5p1n:before{background-color:canvastext}}@media (prefers-reduced-motion:reduce){.x1fllji7.x1fllji7:before{transform:none}.x13sdc92.x13sdc92:before{transition-duration:0s}}}@layer priority9{.x2m5qxi:before{height:calc(var(--geo-map-radius) * 2px)}.xgdch9p:before{left:50%}.x1b9nyww:before{margin-left:calc(var(--geo-map-radius) * -1px - 1.5px)}.x1yqnvuy:before{margin-top:calc(var(--geo-map-radius) * -1px - 1.5px)}.x1knuo7r:before{top:50%}.xohe065:before{width:calc(var(--geo-map-radius) * 2px)}}@keyframes x11jlj4t-B{0%{stroke-dashoffset:12px}to{stroke-dashoffset:0}}@keyframes x6iaekb-B{0%{stroke-dashoffset:16px}to{stroke-dashoffset:0}}[data-slot=flow] .solid-flow{--xy-background-color:transparent;--xy-background-pattern-color:var(--sui-border-strong);--xy-node-color:var(--sui-text);--xy-node-background-color:var(--sui-surface);--xy-node-border:1px solid var(--sui-border-strong);--xy-node-border-radius:var(--sui-radius-md);--xy-node-boxshadow-hover:var(--sui-shadow-sm);--xy-node-boxshadow-selected:0 0 0 2px var(--sui-accent);--xy-node-group-background-color:var(--sui-surface-muted);--xy-edge-stroke:var(--sui-border-strong);--xy-edge-stroke-selected:var(--sui-accent);--xy-edge-stroke-width:1.5;--xy-edge-label-background-color:var(--sui-surface);--xy-edge-label-color:var(--sui-text-muted);--xy-connectionline-stroke:var(--sui-accent);--xy-handle-background-color:var(--sui-surface);--xy-handle-border-color:var(--sui-border-strong);--xy-selection-background-color:var(--sui-accent-subtle);--xy-selection-border:1px dashed var(--sui-accent);--xy-controls-button-background-color:var(--sui-surface);--xy-controls-button-background-color-hover:var(--sui-surface-hover);--xy-controls-button-color:var(--sui-text);--xy-controls-button-color-hover:var(--sui-text);--xy-controls-button-border-color:var(--sui-border);--xy-controls-box-shadow:var(--sui-shadow-sm);--xy-minimap-background-color:var(--sui-surface);--xy-minimap-mask-background-color:color-mix(in oklab, var(--sui-text-muted) 14%, transparent);--xy-minimap-mask-stroke-color:var(--sui-accent);--xy-minimap-node-background-color:var(--sui-border-strong);--xy-minimap-node-stroke-color:var(--sui-border-strong);--xy-attribution-background-color:var(--sui-surface);--xy-resize-background-color:var(--sui-accent);color:var(--sui-text);font-family:inherit}[data-slot=flow] .solid-flow__node-step{box-shadow:none;background:0 0;border:0;padding:0}[data-slot=flow] .solid-flow__controls-button:focus-visible{outline:2px solid var(--sui-focus);outline-offset:-2px}[data-slot=flow] .solid-flow__node:focus-visible,[data-slot=flow] .solid-flow__edge:focus-visible{outline:2px solid var(--sui-focus);outline-offset:2px}[data-slot=flow] .solid-flow__minimap{border:1px solid var(--sui-border);border-radius:var(--sui-radius-md);overflow:hidden}@media (prefers-reduced-motion:reduce){[data-slot=flow] .solid-flow__edge.animated path,[data-slot=flow] .solid-flow__edge .animated{animation:none}}@media (forced-colors:active){[data-slot=flow] .solid-flow__controls-button{border:1px solid buttontext}}}@layer sui.theme;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Controls, type BackgroundProps, type Edge, type EdgeProps, type MiniMapProps, type Node, type NodeProps, type SolidFlowProps } from "@dschz/solid-flow";
|
|
2
|
+
import { type IconNode } from "@zsherman/kit/icon";
|
|
3
|
+
import type { JSX } from "@solidjs/web";
|
|
4
|
+
/** Where a step is: Trace's statuses, with the same icons and colors. */
|
|
5
|
+
export type FlowStatus = "pending" | "running" | "success" | "warning" | "error";
|
|
6
|
+
/** What a step node shows. A type (not an interface) so it fits solid-flow's node data. */
|
|
7
|
+
export type FlowNodeData = {
|
|
8
|
+
/** What the step is ("Load to warehouse"). The node's name for screen readers, after its status. */
|
|
9
|
+
title: string;
|
|
10
|
+
/** A second line ("orders, 1.2M rows"). */
|
|
11
|
+
description?: string;
|
|
12
|
+
/** Where the step is; without it, the node has no status icon (or `icon`). */
|
|
13
|
+
status?: FlowStatus;
|
|
14
|
+
/** An icon of your own (`@zsherman/kit/icons` data) instead of the status icon. */
|
|
15
|
+
icon?: IconNode;
|
|
16
|
+
/** A short value at the end ("2m 14s"). */
|
|
17
|
+
meta?: string;
|
|
18
|
+
};
|
|
19
|
+
/** A step node: `type: "step"` (the Flow's default node type) with `FlowNodeData`. */
|
|
20
|
+
export type FlowNodeItem = Node<FlowNodeData, "step">;
|
|
21
|
+
/** What a kit edge shows. */
|
|
22
|
+
export type FlowEdgeData = {
|
|
23
|
+
/** Dashes move along the edge, source to target (data moving); still under reduced motion. */
|
|
24
|
+
flowing?: boolean;
|
|
25
|
+
/** The line's color. @defaultValue "neutral" */
|
|
26
|
+
tone?: "neutral" | "accent" | "success" | "warning" | "danger";
|
|
27
|
+
};
|
|
28
|
+
/** A kit edge: `type: "flow"` (the Flow's default edge type) with `FlowEdgeData`. */
|
|
29
|
+
export type FlowEdgeItem = Edge<FlowEdgeData, "flow">;
|
|
30
|
+
/**
|
|
31
|
+
* The step node (node type `"step"`): its status icon (the kit Spinner while running), title, description
|
|
32
|
+
* and meta, with its status said before the title for screen readers ("Failed: Load to warehouse"). Handles
|
|
33
|
+
* sit on the sides `layoutFlow` gives it (left and right by default); they show only where connecting is on.
|
|
34
|
+
*/
|
|
35
|
+
export declare function FlowNode(props: NodeProps<FlowNodeData, "step">): JSX.Element;
|
|
36
|
+
/**
|
|
37
|
+
* The kit edge (edge type `"flow"`): a curve in the edge's tone, with dashes moving source to target when
|
|
38
|
+
* `data.flowing` (they stop under reduced motion).
|
|
39
|
+
*/
|
|
40
|
+
export declare function FlowEdge(props: EdgeProps<FlowEdgeData, "flow">): JSX.Element;
|
|
41
|
+
declare const NODE_TYPES: {
|
|
42
|
+
step: typeof FlowNode;
|
|
43
|
+
};
|
|
44
|
+
declare const EDGE_TYPES: {
|
|
45
|
+
flow: typeof FlowEdge;
|
|
46
|
+
};
|
|
47
|
+
/** The Flow's own node types, for typed stores: `createNodeStore<FlowNodeTypes>([…])`. */
|
|
48
|
+
export type FlowNodeTypes = typeof NODE_TYPES;
|
|
49
|
+
/** The Flow's own edge types, for typed stores: `createEdgeStore<FlowEdgeTypes>([…])`. */
|
|
50
|
+
export type FlowEdgeTypes = typeof EDGE_TYPES;
|
|
51
|
+
export interface FlowProps<NodeType extends Node = Node, EdgeType extends Edge = Edge> extends Omit<SolidFlowProps<NodeType, EdgeType>, "class" | "style" | "children" | "height" | "width"> {
|
|
52
|
+
/** The flow's accessible name: what the graph shows ("Nightly ETL: 2 of 6 steps failed"). */
|
|
53
|
+
label: string;
|
|
54
|
+
/**
|
|
55
|
+
* A view of the graph: pan, zoom and select only (no dragging, connecting or deleting), and the wheel
|
|
56
|
+
* scrolls the page (pinch or Ctrl/⌘ + wheel zooms). `false` makes it an editor; set the interaction props
|
|
57
|
+
* (`nodesDraggable`, `nodesConnectable`, …) yourself to mix. @defaultValue true
|
|
58
|
+
*/
|
|
59
|
+
readOnly?: boolean;
|
|
60
|
+
/** The flow's height (a number is pixels). Without it the flow is 16:9. */
|
|
61
|
+
height?: number | string;
|
|
62
|
+
/** Shows the zoom and fit buttons. @defaultValue true */
|
|
63
|
+
controls?: boolean;
|
|
64
|
+
/** Shows a minimap in the bottom corner. @defaultValue false */
|
|
65
|
+
minimap?: boolean;
|
|
66
|
+
/** Draws a dot grid behind the graph. @defaultValue true */
|
|
67
|
+
background?: boolean;
|
|
68
|
+
/** Classes for the flow's root, after the kit's. */
|
|
69
|
+
class?: string;
|
|
70
|
+
/** Styles for the flow's root, after its `height`. */
|
|
71
|
+
style?: JSX.CSSProperties;
|
|
72
|
+
/** Extra parts inside the flow (a `Panel`, your own controls). */
|
|
73
|
+
children?: JSX.Element;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* A pannable, zoomable graph of nodes and edges, themed by the kit: step nodes (`type: "step"`, with a status,
|
|
77
|
+
* an icon, a title, a description and meta) and kit edges (`type: "flow"`, the default; `data.flowing` for
|
|
78
|
+
* moving data) beside your own node and edge types. Nodes and edges are solid-flow's: pass stores from
|
|
79
|
+
* `createNodeStore` / `createEdgeStore` to control them, or `defaultNodes` / `defaultEdges`; `layoutFlow`
|
|
80
|
+
* places nodes that come without positions.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* <Flow label="Nightly ETL" defaultNodes={layoutFlow(nodes, edges)} defaultEdges={edges} height={360} />
|
|
84
|
+
*/
|
|
85
|
+
export declare function Flow<NodeType extends Node = Node, EdgeType extends Edge = Edge>(props: FlowProps<NodeType, EdgeType>): JSX.Element;
|
|
86
|
+
/** The dot grid behind the graph, in the kit's border color. */
|
|
87
|
+
export declare function FlowBackground(props: BackgroundProps): JSX.Element;
|
|
88
|
+
/** Zoom in, zoom out and fit, in the kit's button colors (the `--xy-controls-*` variables). */
|
|
89
|
+
export declare function FlowControls(props: Parameters<typeof Controls>[0]): JSX.Element;
|
|
90
|
+
/** A minimap of the graph in the corner, in the kit's surface and border colors. */
|
|
91
|
+
export declare function FlowMiniMap<NodeType extends Node>(props: Partial<MiniMapProps<NodeType>>): JSX.Element;
|
|
92
|
+
export {};
|