nish-ui 1.8.0 → 2.0.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/README.md +223 -61
- package/dist/base-tailwind.css +1757 -0
- package/dist/base.css +1590 -1445
- package/dist/chart.d.ts +4 -1
- package/dist/chart.js +122 -49
- package/dist/elements-all.d.ts +8 -0
- package/dist/elements-all.js +178 -0
- package/dist/elements-charts.d.ts +124 -2
- package/dist/elements-charts.js +131 -1
- package/dist/elements-data.d.ts +166 -2
- package/dist/elements-data.js +46 -1
- package/dist/elements-forms.d.ts +71 -0
- package/dist/elements-forms.js +24 -25
- package/dist/elements.d.ts +71 -0
- package/dist/elements.js +4 -5
- package/dist/esm/chart-values.js +58 -0
- package/dist/esm/chart.js +10 -0
- package/dist/esm/cn.js +19 -0
- package/dist/esm/combobox-filter.js +13 -0
- package/dist/esm/components/accordion.js +166 -0
- package/dist/esm/components/app-shell.js +198 -0
- package/dist/esm/components/avatar-classes.js +28 -0
- package/dist/esm/components/avatar.js +113 -0
- package/dist/esm/components/breadcrumbs.js +154 -0
- package/dist/esm/components/canvas/follow-caption.js +32 -0
- package/dist/esm/components/canvas/follow.js +119 -0
- package/dist/esm/components/canvas/icons.js +70 -0
- package/dist/esm/components/canvas/index.js +10 -0
- package/dist/esm/components/canvas/layout.js +258 -0
- package/dist/esm/components/canvas/legend.js +93 -0
- package/dist/esm/components/canvas/minimap.js +127 -0
- package/dist/esm/components/canvas/node.js +87 -0
- package/dist/esm/components/canvas/route.js +262 -0
- package/dist/esm/components/canvas/system-canvas.js +837 -0
- package/dist/esm/components/canvas/types.js +10 -0
- package/dist/esm/components/canvas/view.js +47 -0
- package/dist/esm/components/chart-hooks.js +19 -0
- package/dist/esm/components/charts.js +467 -0
- package/dist/esm/components/client.js +24 -0
- package/dist/esm/components/combobox.js +343 -0
- package/dist/esm/components/command.js +403 -0
- package/dist/esm/components/data-classes.js +159 -0
- package/dist/esm/components/data.js +517 -0
- package/dist/esm/components/display-classes.js +130 -0
- package/dist/esm/components/display.js +755 -0
- package/dist/esm/components/error-boundary.js +64 -0
- package/dist/esm/components/feedback.js +136 -0
- package/dist/esm/components/file-dropzone.js +184 -0
- package/dist/esm/components/filters.js +108 -0
- package/dist/esm/components/flow.js +746 -0
- package/dist/esm/components/forms-classes.js +43 -0
- package/dist/esm/components/forms.js +581 -0
- package/dist/esm/components/hooks-classes.js +9 -0
- package/dist/esm/components/hooks.js +236 -0
- package/dist/esm/components/icons.js +96 -0
- package/dist/esm/components/inbox-classes.js +29 -0
- package/dist/esm/components/inbox.js +257 -0
- package/dist/esm/components/latest.js +13 -0
- package/dist/esm/components/layout-vars.js +96 -0
- package/dist/esm/components/layout.js +272 -0
- package/dist/esm/components/media.js +143 -0
- package/dist/esm/components/nav.js +614 -0
- package/dist/esm/components/overlay-classes.js +66 -0
- package/dist/esm/components/overlay.js +1447 -0
- package/dist/esm/components/pagination-classes.js +29 -0
- package/dist/esm/components/pagination.js +154 -0
- package/dist/esm/components/portal.js +16 -0
- package/dist/esm/components/primitives-classes.js +198 -0
- package/dist/esm/components/primitives.js +268 -0
- package/dist/esm/components/progress.js +77 -0
- package/dist/esm/components/provider.js +32 -0
- package/dist/esm/components/radio-group.js +186 -0
- package/dist/esm/components/resource-classes.js +133 -0
- package/dist/esm/components/resource.js +209 -0
- package/dist/esm/components/segmented.js +178 -0
- package/dist/esm/components/separator.js +38 -0
- package/dist/esm/components/service-tokens.js +221 -0
- package/dist/esm/components/settings.js +301 -0
- package/dist/esm/components/slider.js +262 -0
- package/dist/esm/components/split-classes.js +8 -0
- package/dist/esm/components/split.js +411 -0
- package/dist/esm/components/strings.js +119 -0
- package/dist/esm/components/table.js +144 -0
- package/dist/esm/components/tabs-classes.js +21 -0
- package/dist/esm/components/tabs.js +201 -0
- package/dist/esm/components/tag-input.js +257 -0
- package/dist/esm/components/theme-toggle.js +177 -0
- package/dist/esm/components/toast.js +361 -0
- package/dist/esm/components/url-state.js +118 -0
- package/dist/esm/components/visually-hidden.js +20 -0
- package/dist/esm/format.js +320 -0
- package/dist/esm/inbox-client.js +2 -0
- package/dist/esm/inbox-types.js +2 -0
- package/dist/esm/index.js +320 -0
- package/dist/esm/runtime.js +37 -0
- package/dist/esm/server/inbox/client.js +297 -0
- package/dist/esm/server/inbox/types.js +24 -0
- package/dist/esm/sparkline-path.js +59 -0
- package/dist/esm/split-layout.js +419 -0
- package/dist/esm/system-canvas.js +2 -0
- package/dist/esm/theme.js +804 -0
- package/dist/esm/tokens.mjs +425 -0
- package/dist/esm/url.js +20 -0
- package/dist/files.json +5 -1
- package/dist/fonts/LICENSE-Inter.txt +93 -0
- package/dist/format.d.ts +32 -18
- package/dist/format.js +227 -82
- package/dist/inbox-client.js +3 -1
- package/dist/index.d.ts +1689 -667
- package/dist/nish-components.css +4701 -3169
- package/dist/nish-components.min.css +1 -0
- package/dist/nish.css +1603 -1450
- package/dist/nish.min.css +1 -0
- package/dist/node/eslint.js +29 -14
- package/dist/node/th-check.js +29 -14
- package/dist/node/vite.d.ts +12 -0
- package/dist/node/vite.js +12 -2
- package/dist/server/hono.d.ts +15 -6
- package/dist/server/hono.js +30 -25
- package/dist/server/index.d.ts +3 -10
- package/dist/server/index.js +71 -38
- package/dist/{spa-DuVB5O7S.d.ts → spa-BLlMc0eI.d.ts} +38 -5
- package/dist/system-canvas-BLuWd69H.d.ts +183 -0
- package/dist/system-canvas.d.ts +2 -168
- package/dist/tailwind-core.css +114 -0
- package/dist/tailwind.css +3 -7
- package/dist/theme-init.js +23 -9
- package/dist/theme-init.sha256 +1 -0
- package/dist/theme.d.ts +246 -4
- package/dist/theme.global.js +357 -90
- package/dist/theme.js +338 -68
- package/dist/tokens.css +14 -6
- package/dist/tokens.dtcg.json +1513 -0
- package/dist/tokens.js +29 -14
- package/dist/tokens.json +512 -0
- package/package.json +51 -13
- package/dist/chart.js.map +0 -1
- package/dist/elements-charts.js.map +0 -1
- package/dist/elements-data.js.map +0 -1
- package/dist/elements-forms.js.map +0 -1
- package/dist/elements.js.map +0 -1
- package/dist/format.js.map +0 -1
- package/dist/inbox-client.js.map +0 -1
- package/dist/index.js +0 -10260
- package/dist/index.js.map +0 -1
- package/dist/server/hono.js.map +0 -1
- package/dist/server/index.js.map +0 -1
- package/dist/split-layout.js.map +0 -1
- package/dist/system-canvas.js +0 -2204
- package/dist/system-canvas.js.map +0 -1
- package/dist/theme.global.js.map +0 -1
- package/dist/theme.js.map +0 -1
package/dist/system-canvas.js
DELETED
|
@@ -1,2204 +0,0 @@
|
|
|
1
|
-
// src/components/canvas/system-canvas.tsx
|
|
2
|
-
import {
|
|
3
|
-
Fragment as Fragment4,
|
|
4
|
-
useCallback as useCallback3,
|
|
5
|
-
useEffect as useEffect7,
|
|
6
|
-
useLayoutEffect as useLayoutEffect3,
|
|
7
|
-
useMemo as useMemo2,
|
|
8
|
-
useRef as useRef8,
|
|
9
|
-
useState as useState6
|
|
10
|
-
} from "react";
|
|
11
|
-
|
|
12
|
-
// src/cn.ts
|
|
13
|
-
import { clsx } from "clsx";
|
|
14
|
-
import { extendTailwindMerge } from "tailwind-merge";
|
|
15
|
-
var twMerge = extendTailwindMerge({
|
|
16
|
-
extend: {
|
|
17
|
-
theme: {
|
|
18
|
-
text: ["2xs", "3xs"]
|
|
19
|
-
},
|
|
20
|
-
classGroups: {
|
|
21
|
-
shadow: [{ shadow: ["card", "pop", "modal"] }]
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
function cn(...inputs) {
|
|
26
|
-
return twMerge(clsx(inputs));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// src/components/flow.tsx
|
|
30
|
-
import {
|
|
31
|
-
useEffect as useEffect2,
|
|
32
|
-
useLayoutEffect,
|
|
33
|
-
useMemo,
|
|
34
|
-
useRef as useRef2,
|
|
35
|
-
useState as useState2
|
|
36
|
-
} from "react";
|
|
37
|
-
|
|
38
|
-
// src/components/hooks.tsx
|
|
39
|
-
import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
40
|
-
import { jsx } from "react/jsx-runtime";
|
|
41
|
-
function useMediaQuery(query) {
|
|
42
|
-
const subscribe = useCallback(
|
|
43
|
-
(onChange) => {
|
|
44
|
-
if (typeof window === "undefined" || !window.matchMedia) return () => {
|
|
45
|
-
};
|
|
46
|
-
const mq = window.matchMedia(query);
|
|
47
|
-
mq.addEventListener("change", onChange);
|
|
48
|
-
return () => mq.removeEventListener("change", onChange);
|
|
49
|
-
},
|
|
50
|
-
[query]
|
|
51
|
-
);
|
|
52
|
-
const get = () => typeof window !== "undefined" && !!window.matchMedia && window.matchMedia(query).matches;
|
|
53
|
-
return useSyncExternalStore(subscribe, get, () => false);
|
|
54
|
-
}
|
|
55
|
-
var BREAKPOINTS = { sm: 640, md: 768, lg: 1024, xl: 1280 };
|
|
56
|
-
var BREAKPOINT_QUERIES = ["xl", "lg", "md", "sm"].map((name) => [
|
|
57
|
-
name,
|
|
58
|
-
`(min-width: ${BREAKPOINTS[name]}px)`
|
|
59
|
-
]);
|
|
60
|
-
|
|
61
|
-
// src/components/icons.tsx
|
|
62
|
-
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
63
|
-
function Svg({ size = 16, children, ...rest }) {
|
|
64
|
-
return /* @__PURE__ */ jsx2(
|
|
65
|
-
"svg",
|
|
66
|
-
{
|
|
67
|
-
width: size,
|
|
68
|
-
height: size,
|
|
69
|
-
viewBox: "0 0 24 24",
|
|
70
|
-
fill: "none",
|
|
71
|
-
stroke: "currentColor",
|
|
72
|
-
strokeWidth: 2,
|
|
73
|
-
strokeLinecap: "round",
|
|
74
|
-
strokeLinejoin: "round",
|
|
75
|
-
"aria-hidden": "true",
|
|
76
|
-
focusable: "false",
|
|
77
|
-
...rest,
|
|
78
|
-
children
|
|
79
|
-
}
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
var LoaderIcon = (p) => /* @__PURE__ */ jsx2(Svg, { ...p, children: /* @__PURE__ */ jsx2("path", { d: "M21 12a9 9 0 1 1-6.22-8.56" }) });
|
|
83
|
-
var ChevronDownIcon = (p) => /* @__PURE__ */ jsx2(Svg, { ...p, children: /* @__PURE__ */ jsx2("path", { d: "m6 9 6 6 6-6" }) });
|
|
84
|
-
|
|
85
|
-
// src/components/primitives.tsx
|
|
86
|
-
import {
|
|
87
|
-
forwardRef,
|
|
88
|
-
useId
|
|
89
|
-
} from "react";
|
|
90
|
-
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
91
|
-
var BUTTON_VARIANT = {
|
|
92
|
-
primary: "bg-th-accent text-th-on-accent hover:bg-th-accent/90 active:bg-th-accent/80",
|
|
93
|
-
secondary: "border border-th-line-strong bg-th-surface text-th-hi hover:bg-th-elevated",
|
|
94
|
-
ghost: "text-th-hi2 hover:bg-th-elevated hover:text-th-hi",
|
|
95
|
-
danger: "bg-th-loss text-th-on-loss hover:bg-th-loss/90 active:bg-th-loss/80",
|
|
96
|
-
soft: "bg-th-accent-soft text-th-accent hover:bg-th-accent/20 active:bg-th-accent/25",
|
|
97
|
-
subtle: "bg-th-elevated text-th-hi hover:bg-th-overlay",
|
|
98
|
-
link: "h-auto p-0 font-medium text-th-accent underline-offset-2 hover:underline"
|
|
99
|
-
};
|
|
100
|
-
var BUTTON_SIZE = {
|
|
101
|
-
xs: "h-6 gap-1 px-2 text-2xs pointer-coarse:min-h-11",
|
|
102
|
-
sm: "h-7 gap-1.5 px-2.5 text-xs pointer-coarse:min-h-11",
|
|
103
|
-
md: "h-9 gap-2 px-3.5 text-sm pointer-coarse:min-h-11",
|
|
104
|
-
lg: "h-11 gap-2 px-5 text-base"
|
|
105
|
-
};
|
|
106
|
-
var LINK_SIZE = {
|
|
107
|
-
xs: "gap-1 text-2xs",
|
|
108
|
-
sm: "gap-1 text-xs",
|
|
109
|
-
md: "gap-1.5 text-sm",
|
|
110
|
-
lg: "gap-2 text-base"
|
|
111
|
-
};
|
|
112
|
-
var BUTTON_BASE = "inline-flex shrink-0 select-none items-center justify-center whitespace-nowrap rounded-lg font-medium transition-[color,background-color,border-color,transform] duration-150";
|
|
113
|
-
var PRESS = "pointer-coarse:not-disabled:active:scale-[0.97]";
|
|
114
|
-
var LINK_HIT = "pointer-coarse:relative pointer-coarse:after:absolute pointer-coarse:after:-inset-x-2 pointer-coarse:after:-inset-y-3 pointer-coarse:after:content-['']";
|
|
115
|
-
var BUTTON_DISABLED = "disabled:pointer-events-none disabled:border disabled:border-th-line disabled:bg-th-elevated disabled:text-th-ghost disabled:shadow-none";
|
|
116
|
-
var LINK_DISABLED = "disabled:pointer-events-none disabled:text-th-ghost disabled:no-underline";
|
|
117
|
-
function buttonClass({ variant = "secondary", size = "md", inline = false, className } = {}) {
|
|
118
|
-
return cn(
|
|
119
|
-
BUTTON_BASE,
|
|
120
|
-
variant === "link" ? LINK_SIZE[size] : BUTTON_SIZE[size],
|
|
121
|
-
variant === "link" ? !inline && LINK_HIT : PRESS,
|
|
122
|
-
BUTTON_VARIANT[variant],
|
|
123
|
-
className
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
var Button = forwardRef(function Button2({ variant = "secondary", size = "md", inline = false, loading = false, icon, className, children, disabled, type = "button", ...rest }, ref) {
|
|
127
|
-
return /* @__PURE__ */ jsxs2(
|
|
128
|
-
"button",
|
|
129
|
-
{
|
|
130
|
-
ref,
|
|
131
|
-
type,
|
|
132
|
-
disabled: disabled || loading,
|
|
133
|
-
"aria-busy": loading || void 0,
|
|
134
|
-
className: buttonClass({
|
|
135
|
-
variant,
|
|
136
|
-
size,
|
|
137
|
-
inline,
|
|
138
|
-
className: cn(variant === "link" ? LINK_DISABLED : BUTTON_DISABLED, className)
|
|
139
|
-
}),
|
|
140
|
-
...rest,
|
|
141
|
-
children: [
|
|
142
|
-
loading ? /* @__PURE__ */ jsx3(LoaderIcon, { size: size === "xs" || size === "sm" ? 12 : 14, className: "animate-spin" }) : icon,
|
|
143
|
-
children
|
|
144
|
-
]
|
|
145
|
-
}
|
|
146
|
-
);
|
|
147
|
-
});
|
|
148
|
-
var ICON_SIZE = {
|
|
149
|
-
"2xs": "size-5 rounded",
|
|
150
|
-
xs: "size-6 rounded-md",
|
|
151
|
-
sm: "size-7 rounded-lg",
|
|
152
|
-
md: "size-9 rounded-lg"
|
|
153
|
-
};
|
|
154
|
-
var ICON_VARIANT = {
|
|
155
|
-
ghost: { idle: "text-th-hi3 hover:bg-th-elevated hover:text-th-hi", active: "bg-th-elevated text-th-hi" },
|
|
156
|
-
subtle: { idle: "bg-th-elevated text-th-hi hover:bg-th-overlay", active: "bg-th-overlay text-th-hi" },
|
|
157
|
-
soft: { idle: "bg-th-accent-soft text-th-accent hover:bg-th-accent/20", active: "bg-th-accent/25 text-th-accent" }
|
|
158
|
-
};
|
|
159
|
-
var ICON_DANGER = "hover:bg-th-loss-soft hover:text-th-loss active:bg-th-loss-soft active:text-th-loss";
|
|
160
|
-
function iconButtonClass({
|
|
161
|
-
size = "md",
|
|
162
|
-
variant = "ghost",
|
|
163
|
-
tone = "neutral",
|
|
164
|
-
active = false,
|
|
165
|
-
className
|
|
166
|
-
} = {}) {
|
|
167
|
-
return cn(
|
|
168
|
-
"inline-flex shrink-0 items-center justify-center transition-[color,background-color,border-color,transform] duration-150",
|
|
169
|
-
PRESS,
|
|
170
|
-
"disabled:pointer-events-none disabled:bg-transparent disabled:text-th-ghost",
|
|
171
|
-
"pointer-coarse:min-h-11 pointer-coarse:min-w-11",
|
|
172
|
-
ICON_SIZE[size],
|
|
173
|
-
ICON_VARIANT[variant].idle,
|
|
174
|
-
active && ICON_VARIANT[variant].active,
|
|
175
|
-
tone === "danger" && ICON_DANGER,
|
|
176
|
-
active && tone === "danger" && "bg-th-loss-soft text-th-loss",
|
|
177
|
-
className
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
var IconButton = forwardRef(function IconButton2({ label, size = "md", active = false, variant = "ghost", tone = "neutral", className, children, type = "button", ...rest }, ref) {
|
|
181
|
-
return /* @__PURE__ */ jsx3(
|
|
182
|
-
"button",
|
|
183
|
-
{
|
|
184
|
-
ref,
|
|
185
|
-
type,
|
|
186
|
-
"aria-label": label,
|
|
187
|
-
title: label,
|
|
188
|
-
"aria-pressed": active || void 0,
|
|
189
|
-
className: iconButtonClass({ size, variant, tone, active, className }),
|
|
190
|
-
...rest,
|
|
191
|
-
children
|
|
192
|
-
}
|
|
193
|
-
);
|
|
194
|
-
});
|
|
195
|
-
var CARD_PADDING = {
|
|
196
|
-
none: "",
|
|
197
|
-
sm: "p-3",
|
|
198
|
-
md: "p-4 sm:p-5",
|
|
199
|
-
lg: "p-6"
|
|
200
|
-
};
|
|
201
|
-
var resolvePadding = (padding, padded) => padding ?? (padded === false ? "none" : "md");
|
|
202
|
-
function cardClass({ padding, padded, interactive = false, variant = "surface", className } = {}) {
|
|
203
|
-
const inset = variant === "inset";
|
|
204
|
-
return cn(
|
|
205
|
-
inset ? "rounded-lg border border-transparent bg-th-elevated" : "rounded-xl border border-th-line bg-th-surface shadow-card",
|
|
206
|
-
CARD_PADDING[resolvePadding(padding, padded)],
|
|
207
|
-
interactive && (inset ? "transition-colors duration-150 hover:bg-th-overlay" : "transition-colors duration-150 hover:border-th-line-strong hover:bg-th-elevated/60"),
|
|
208
|
-
className
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
function CardHeader({
|
|
212
|
-
title,
|
|
213
|
-
description,
|
|
214
|
-
action,
|
|
215
|
-
icon,
|
|
216
|
-
as: Heading = "h2",
|
|
217
|
-
divided = false,
|
|
218
|
-
titleId,
|
|
219
|
-
className,
|
|
220
|
-
...rest
|
|
221
|
-
}) {
|
|
222
|
-
return /* @__PURE__ */ jsxs2(
|
|
223
|
-
"div",
|
|
224
|
-
{
|
|
225
|
-
className: cn(
|
|
226
|
-
"flex flex-wrap items-center justify-between gap-x-3 gap-y-2",
|
|
227
|
-
divided && "border-b border-th-line px-4 py-3",
|
|
228
|
-
className
|
|
229
|
-
),
|
|
230
|
-
...rest,
|
|
231
|
-
children: [
|
|
232
|
-
/* @__PURE__ */ jsxs2("div", { className: "flex min-w-0 items-start gap-2", children: [
|
|
233
|
-
icon ? /* @__PURE__ */ jsx3("span", { className: "mt-0.5 inline-flex shrink-0 text-th-hi3", "aria-hidden": "true", children: icon }) : null,
|
|
234
|
-
/* @__PURE__ */ jsxs2("div", { className: "min-w-0", children: [
|
|
235
|
-
/* @__PURE__ */ jsx3(Heading, { id: titleId, className: "text-sm font-semibold text-th-hi", children: title }),
|
|
236
|
-
description ? /* @__PURE__ */ jsx3("p", { className: "mt-0.5 text-xs text-th-hi3", children: description }) : null
|
|
237
|
-
] })
|
|
238
|
-
] }),
|
|
239
|
-
action ? /* @__PURE__ */ jsx3("div", { className: "flex shrink-0 flex-wrap items-center gap-2", children: action }) : null
|
|
240
|
-
]
|
|
241
|
-
}
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
var Card = forwardRef(function Card2({ as = "div", padding, padded, interactive = false, variant = "surface", title, description, action, className, children, ...rest }, ref) {
|
|
245
|
-
const Tag = as;
|
|
246
|
-
const pad = resolvePadding(padding, padded);
|
|
247
|
-
const headingId = useId();
|
|
248
|
-
const region = title != null && (as === "section" || as === "article" || as === "aside");
|
|
249
|
-
return /* @__PURE__ */ jsxs2(
|
|
250
|
-
Tag,
|
|
251
|
-
{
|
|
252
|
-
ref,
|
|
253
|
-
"aria-labelledby": region && !rest["aria-label"] && !rest["aria-labelledby"] ? headingId : void 0,
|
|
254
|
-
className: cardClass({ padding: pad, interactive, variant, className }),
|
|
255
|
-
...rest,
|
|
256
|
-
children: [
|
|
257
|
-
title != null ? /* @__PURE__ */ jsx3(
|
|
258
|
-
CardHeader,
|
|
259
|
-
{
|
|
260
|
-
title,
|
|
261
|
-
description,
|
|
262
|
-
action,
|
|
263
|
-
titleId: headingId,
|
|
264
|
-
divided: pad === "none",
|
|
265
|
-
className: pad === "none" ? void 0 : "mb-3"
|
|
266
|
-
}
|
|
267
|
-
) : null,
|
|
268
|
-
children
|
|
269
|
-
]
|
|
270
|
-
}
|
|
271
|
-
);
|
|
272
|
-
});
|
|
273
|
-
var FIELD = "w-full min-w-0 rounded-lg border border-th-line-strong bg-th-elevated text-th-hi placeholder:text-th-ghost transition-colors duration-150 hover:border-th-hi3/60 focus:border-th-accent focus:outline-none focus:ring-2 focus:ring-th-accent/25 disabled:cursor-not-allowed disabled:opacity-50 aria-[invalid=true]:border-th-loss";
|
|
274
|
-
var FIELD_SIZE = {
|
|
275
|
-
xs: { box: "h-7 pointer-coarse:min-h-11", pad: "pl-2 pr-2", text: "text-2xs pointer-coarse:text-base" },
|
|
276
|
-
sm: { box: "h-8 pointer-coarse:min-h-11", pad: "pl-2.5 pr-2.5", text: "text-xs pointer-coarse:text-base" },
|
|
277
|
-
md: { box: "h-9 pointer-coarse:min-h-11", pad: "pl-3 pr-3", text: "text-sm pointer-coarse:text-base" }
|
|
278
|
-
};
|
|
279
|
-
var FIELD_INVALID = "border-th-loss hover:border-th-loss";
|
|
280
|
-
function fieldClass({ size = "md", invalid = false, className } = {}) {
|
|
281
|
-
const s = FIELD_SIZE[size];
|
|
282
|
-
return cn(FIELD, s.box, s.pad, s.text, invalid && FIELD_INVALID, className);
|
|
283
|
-
}
|
|
284
|
-
var Input = forwardRef(function Input2({ invalid, size = "md", leading, trailing, wrapperClassName, className, ...rest }, ref) {
|
|
285
|
-
const input = /* @__PURE__ */ jsx3(
|
|
286
|
-
"input",
|
|
287
|
-
{
|
|
288
|
-
ref,
|
|
289
|
-
"aria-invalid": invalid || void 0,
|
|
290
|
-
className: fieldClass({ size, className: cn(leading != null && "pl-8", trailing != null && "pr-8", className) }),
|
|
291
|
-
...rest
|
|
292
|
-
}
|
|
293
|
-
);
|
|
294
|
-
if (leading == null && trailing == null) return input;
|
|
295
|
-
return /* @__PURE__ */ jsxs2("span", { className: cn("relative inline-flex w-full min-w-0 items-center", wrapperClassName), children: [
|
|
296
|
-
leading != null ? /* @__PURE__ */ jsx3("span", { className: "pointer-events-none absolute inset-y-0 left-0 flex w-8 items-center justify-center text-sm text-th-hi2", children: leading }) : null,
|
|
297
|
-
input,
|
|
298
|
-
trailing != null ? /* @__PURE__ */ jsx3("span", { className: "absolute inset-y-0 right-0 flex min-w-8 items-center justify-center pr-0.5 text-sm text-th-hi2", children: trailing }) : null
|
|
299
|
-
] });
|
|
300
|
-
});
|
|
301
|
-
var SELECT_SIZE = {
|
|
302
|
-
xs: { pad: "pl-2 pr-6", chevron: "right-1.5", icon: 12 },
|
|
303
|
-
sm: { pad: "pl-2.5 pr-7", chevron: "right-2", icon: 13 },
|
|
304
|
-
md: { pad: "pl-3 pr-8", chevron: "right-2.5", icon: 14 }
|
|
305
|
-
};
|
|
306
|
-
var Select = forwardRef(function Select2({ invalid, size = "md", selectClassName, className, children, ...rest }, ref) {
|
|
307
|
-
const s = SELECT_SIZE[size];
|
|
308
|
-
return /* @__PURE__ */ jsxs2("span", { className: cn("relative inline-flex w-full min-w-0", className), children: [
|
|
309
|
-
/* @__PURE__ */ jsx3(
|
|
310
|
-
"select",
|
|
311
|
-
{
|
|
312
|
-
ref,
|
|
313
|
-
"aria-invalid": invalid || void 0,
|
|
314
|
-
className: fieldClass({ size, className: cn("appearance-none", s.pad, selectClassName) }),
|
|
315
|
-
...rest,
|
|
316
|
-
children
|
|
317
|
-
}
|
|
318
|
-
),
|
|
319
|
-
/* @__PURE__ */ jsx3(ChevronDownIcon, { size: s.icon, className: cn("pointer-events-none absolute top-1/2 -translate-y-1/2 text-th-hi3", s.chevron) })
|
|
320
|
-
] });
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
// src/components/flow.tsx
|
|
324
|
-
import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
325
|
-
function usePrefersReducedMotion() {
|
|
326
|
-
return useMediaQuery("(prefers-reduced-motion: reduce)");
|
|
327
|
-
}
|
|
328
|
-
function TickerText({ text, as = "span", className }) {
|
|
329
|
-
const reduced = usePrefersReducedMotion();
|
|
330
|
-
const [state, setState] = useState2({ text, prev: null });
|
|
331
|
-
let cur = state;
|
|
332
|
-
if (state.text !== text) {
|
|
333
|
-
cur = { text, prev: reduced ? null : state.text };
|
|
334
|
-
setState(cur);
|
|
335
|
-
}
|
|
336
|
-
const animating = cur.prev !== null;
|
|
337
|
-
useEffect2(() => {
|
|
338
|
-
if (!animating) return;
|
|
339
|
-
const timer = setTimeout(() => setState((s) => s.prev === null ? s : { ...s, prev: null }), 300);
|
|
340
|
-
return () => clearTimeout(timer);
|
|
341
|
-
}, [animating, cur.text]);
|
|
342
|
-
const Tag = as;
|
|
343
|
-
return /* @__PURE__ */ jsxs3(Tag, { className: cn("nish-flow-ticker grid min-w-0 overflow-hidden", className), title: cur.text, children: [
|
|
344
|
-
cur.prev !== null ? /* @__PURE__ */ jsx4("span", { className: "nish-flow-ticker-out", "aria-hidden": "true", children: cur.prev }, `prev:${cur.prev}`) : null,
|
|
345
|
-
/* @__PURE__ */ jsx4("span", { className: animating ? "nish-flow-ticker-in" : void 0, children: cur.text }, cur.text)
|
|
346
|
-
] });
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
// src/components/canvas/follow-caption.tsx
|
|
350
|
-
import { memo } from "react";
|
|
351
|
-
|
|
352
|
-
// src/components/display.tsx
|
|
353
|
-
import {
|
|
354
|
-
createContext,
|
|
355
|
-
useContext,
|
|
356
|
-
useEffect as useEffect3,
|
|
357
|
-
useRef as useRef3,
|
|
358
|
-
useState as useState3
|
|
359
|
-
} from "react";
|
|
360
|
-
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
361
|
-
var FILL = {
|
|
362
|
-
ok: "bg-th-ok-fill",
|
|
363
|
-
warn: "bg-th-warn-fill",
|
|
364
|
-
loss: "bg-th-loss-fill",
|
|
365
|
-
info: "bg-th-info-fill",
|
|
366
|
-
accent: "bg-th-accent",
|
|
367
|
-
neutral: "bg-th-ghost"
|
|
368
|
-
};
|
|
369
|
-
var DOT_SIZE = { xs: "size-1.5", sm: "size-2", md: "size-2.5", lg: "size-3.5" };
|
|
370
|
-
var HALO = {
|
|
371
|
-
ok: "ring-4 ring-th-ok-fill/25",
|
|
372
|
-
warn: "ring-4 ring-th-warn-fill/25",
|
|
373
|
-
loss: "ring-4 ring-th-loss-fill/25",
|
|
374
|
-
info: "ring-4 ring-th-info-fill/25",
|
|
375
|
-
accent: "ring-4 ring-th-accent/25",
|
|
376
|
-
neutral: "ring-4 ring-th-ghost/25"
|
|
377
|
-
};
|
|
378
|
-
function StatusDot({ tone, size = "sm", pulse = false, halo = false, label, className }) {
|
|
379
|
-
return /* @__PURE__ */ jsx5(
|
|
380
|
-
"span",
|
|
381
|
-
{
|
|
382
|
-
role: label ? "img" : void 0,
|
|
383
|
-
"aria-label": label,
|
|
384
|
-
"aria-hidden": label ? void 0 : true,
|
|
385
|
-
className: cn(
|
|
386
|
-
"inline-block shrink-0 rounded-full",
|
|
387
|
-
DOT_SIZE[size],
|
|
388
|
-
FILL[tone],
|
|
389
|
-
halo && HALO[tone],
|
|
390
|
-
pulse && "motion-safe:animate-pulse",
|
|
391
|
-
className
|
|
392
|
-
)
|
|
393
|
-
}
|
|
394
|
-
);
|
|
395
|
-
}
|
|
396
|
-
var InStatGrid = createContext(false);
|
|
397
|
-
|
|
398
|
-
// src/components/canvas/follow-caption.tsx
|
|
399
|
-
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
400
|
-
var FollowCaption = memo(function FollowCaption2({ step }) {
|
|
401
|
-
if (!step) return null;
|
|
402
|
-
const only = step.targets.length === 1 ? step.targets[0] : null;
|
|
403
|
-
const text = step.mode === "idle" ? "Following \xB7 waiting for activity" : only ? `Following \xB7 ${only.group} \u203A ${only.label}` : `Following ${step.targets.length} active pieces`;
|
|
404
|
-
return /* @__PURE__ */ jsxs5(
|
|
405
|
-
"div",
|
|
406
|
-
{
|
|
407
|
-
"data-canvas-ui": true,
|
|
408
|
-
role: "status",
|
|
409
|
-
"aria-live": "polite",
|
|
410
|
-
className: "absolute bottom-[68px] left-3 z-10 flex max-w-[min(420px,calc(100%-24px))] items-center gap-2 rounded-xl border border-th-line bg-th-surface px-3 py-2 text-xs text-th-hi shadow-card min-[600px]:bottom-3",
|
|
411
|
-
children: [
|
|
412
|
-
/* @__PURE__ */ jsx6(StatusDot, { tone: "accent", pulse: step.mode !== "idle" }),
|
|
413
|
-
/* @__PURE__ */ jsxs5("div", { className: "min-w-0", children: [
|
|
414
|
-
/* @__PURE__ */ jsx6("div", { className: "truncate", children: text }),
|
|
415
|
-
only?.note ? /* @__PURE__ */ jsx6(TickerText, { as: "div", text: only.note, className: "truncate text-th-ghost" }) : null
|
|
416
|
-
] })
|
|
417
|
-
]
|
|
418
|
-
}
|
|
419
|
-
);
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
// src/components/canvas/follow.ts
|
|
423
|
-
import { useEffect as useEffect4, useRef as useRef4, useState as useState4 } from "react";
|
|
424
|
-
|
|
425
|
-
// src/components/canvas/view.ts
|
|
426
|
-
var MIN_K = 0.3;
|
|
427
|
-
var MAX_K = 2;
|
|
428
|
-
var PHONE_K = 0.55;
|
|
429
|
-
var PHONE_MAX_W = 600;
|
|
430
|
-
var FIT_PAD = 48;
|
|
431
|
-
var LABEL_K = 0.8;
|
|
432
|
-
var ANIM_MS = 300;
|
|
433
|
-
var FOLLOW_MS = 700;
|
|
434
|
-
var LOD_K = 0.6;
|
|
435
|
-
var DOUBLE_MS = 300;
|
|
436
|
-
var DOUBLE_PX = 10;
|
|
437
|
-
var DRAG_PX = 4;
|
|
438
|
-
var KEY_PAN = 48;
|
|
439
|
-
var ZOOM_STEP = 1.25;
|
|
440
|
-
var clampK = (k) => Math.min(MAX_K, Math.max(MIN_K, k));
|
|
441
|
-
var ease = (t) => t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
|
|
442
|
-
function zoomAround(v, k, px, py) {
|
|
443
|
-
const nk = clampK(k);
|
|
444
|
-
const r = nk / v.k;
|
|
445
|
-
return { k: nk, x: px - (px - v.x) * r, y: py - (py - v.y) * r };
|
|
446
|
-
}
|
|
447
|
-
function centerOn(w, h, k, box) {
|
|
448
|
-
return { k, x: w / 2 - (box.x + box.w / 2) * k, y: h / 2 - (box.y + box.h / 2) * k };
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
// src/components/canvas/follow.ts
|
|
452
|
-
var CYCLE_MS = 6e3;
|
|
453
|
-
var BBOX_PAD = 80;
|
|
454
|
-
var VIEW_PAD = 96;
|
|
455
|
-
var PHONE_W = 600;
|
|
456
|
-
var PHONE_TOP = 0.45;
|
|
457
|
-
function followTargets(groups, layout) {
|
|
458
|
-
const out = [];
|
|
459
|
-
for (const g of groups) {
|
|
460
|
-
for (const n of g.nodes) {
|
|
461
|
-
const box = layout.nodes[n.id];
|
|
462
|
-
if (!n.active || !box) continue;
|
|
463
|
-
out.push({ id: n.id, label: n.label, group: g.title, note: n.note, box, groupBox: layout.groups[g.id], at: n.activeAt ?? 0 });
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
return out.sort((a, b) => b.at - a.at);
|
|
467
|
-
}
|
|
468
|
-
function place(w, h, k, box, groupBox, top = 0) {
|
|
469
|
-
const v = centerOn(w, h, k, box);
|
|
470
|
-
if (w >= PHONE_W) return v;
|
|
471
|
-
const y = Math.max(h * PHONE_TOP / 2, top + box.h * k / 2) - (box.y + box.h / 2) * k;
|
|
472
|
-
if (groupBox && groupBox.w * k <= w - 24) return { ...v, x: w / 2 - (groupBox.x + groupBox.w / 2) * k, y };
|
|
473
|
-
return { ...v, y };
|
|
474
|
-
}
|
|
475
|
-
function followStep(targets, i, w, h, fit, top = 0) {
|
|
476
|
-
if (targets.length === 0) return { mode: "idle", view: fit, targets: [] };
|
|
477
|
-
const phone = w < PHONE_W;
|
|
478
|
-
const single = phone ? 0.8 : 1;
|
|
479
|
-
if (targets.length === 1) {
|
|
480
|
-
return { mode: "all", targets, view: place(w, h, single, targets[0].box, targets[0].groupBox, top) };
|
|
481
|
-
}
|
|
482
|
-
let x0 = Infinity;
|
|
483
|
-
let y0 = Infinity;
|
|
484
|
-
let x1 = -Infinity;
|
|
485
|
-
let y1 = -Infinity;
|
|
486
|
-
for (const t of targets) {
|
|
487
|
-
x0 = Math.min(x0, t.box.x);
|
|
488
|
-
y0 = Math.min(y0, t.box.y);
|
|
489
|
-
x1 = Math.max(x1, t.box.x + t.box.w);
|
|
490
|
-
y1 = Math.max(y1, t.box.y + t.box.h);
|
|
491
|
-
}
|
|
492
|
-
const bbox = { x: x0 - BBOX_PAD, y: y0 - BBOX_PAD, w: x1 - x0 + 2 * BBOX_PAD, h: y1 - y0 + 2 * BBOX_PAD };
|
|
493
|
-
const kAll = Math.min((w - VIEW_PAD) / bbox.w, (h - VIEW_PAD) / bbox.h, 1.1);
|
|
494
|
-
if (kAll >= (phone ? 0.55 : 0.75)) {
|
|
495
|
-
return { mode: "all", targets, view: place(w, h, clampK(kAll), bbox, void 0, top) };
|
|
496
|
-
}
|
|
497
|
-
const target = targets[(i % targets.length + targets.length) % targets.length];
|
|
498
|
-
return { mode: "one", targets: [target], view: place(w, h, single, target.box, target.groupBox, top) };
|
|
499
|
-
}
|
|
500
|
-
var followSignature = (targets) => targets.map((t) => t.id).sort().join("|");
|
|
501
|
-
var captionKey = (targets) => targets.map((t) => `${t.id}:${t.label}:${t.group}:${t.note ?? ""}`).join("|");
|
|
502
|
-
function useFollow(o) {
|
|
503
|
-
const { on, groups, layout, size } = o;
|
|
504
|
-
const latest = useRef4(o);
|
|
505
|
-
useEffect4(() => {
|
|
506
|
-
latest.current = o;
|
|
507
|
-
});
|
|
508
|
-
const index = useRef4(0);
|
|
509
|
-
const visiting = useRef4(null);
|
|
510
|
-
const [step, setStep] = useState4(null);
|
|
511
|
-
const targets = on ? followTargets(groups, layout) : [];
|
|
512
|
-
const sig = followSignature(targets);
|
|
513
|
-
const caption = captionKey(targets);
|
|
514
|
-
const indexKey = useRef4("");
|
|
515
|
-
useEffect4(() => {
|
|
516
|
-
if (!on) {
|
|
517
|
-
indexKey.current = "";
|
|
518
|
-
return;
|
|
519
|
-
}
|
|
520
|
-
const key = sig;
|
|
521
|
-
if (indexKey.current !== key) {
|
|
522
|
-
indexKey.current = key;
|
|
523
|
-
index.current = 0;
|
|
524
|
-
visiting.current = null;
|
|
525
|
-
}
|
|
526
|
-
let timer;
|
|
527
|
-
const run = (advance) => {
|
|
528
|
-
const cur = latest.current;
|
|
529
|
-
const ts = followTargets(cur.groups, cur.layout);
|
|
530
|
-
const at = visiting.current ? ts.findIndex((t) => t.id === visiting.current) : -1;
|
|
531
|
-
index.current = at < 0 ? 0 : advance ? at + 1 : at;
|
|
532
|
-
const next = followStep(ts, index.current, cur.size.w, cur.size.h, cur.fit(), cur.inset ?? 0);
|
|
533
|
-
visiting.current = next.mode === "one" ? next.targets[0]?.id ?? null : null;
|
|
534
|
-
setStep(next);
|
|
535
|
-
cur.fly(next.view);
|
|
536
|
-
if (next.mode === "one" && timer === void 0) timer = setInterval(() => run(true), CYCLE_MS);
|
|
537
|
-
if (next.mode !== "one" && timer !== void 0) {
|
|
538
|
-
clearInterval(timer);
|
|
539
|
-
timer = void 0;
|
|
540
|
-
}
|
|
541
|
-
};
|
|
542
|
-
run(false);
|
|
543
|
-
return () => {
|
|
544
|
-
if (timer !== void 0) clearInterval(timer);
|
|
545
|
-
};
|
|
546
|
-
}, [on, sig, layout, size.w, size.h]);
|
|
547
|
-
useEffect4(() => {
|
|
548
|
-
if (!on) return;
|
|
549
|
-
const cur = latest.current;
|
|
550
|
-
const ts = followTargets(cur.groups, cur.layout);
|
|
551
|
-
setStep((prev) => {
|
|
552
|
-
if (!prev || prev.mode === "idle") return prev;
|
|
553
|
-
const fresh = prev.mode === "one" ? ts.filter((t) => t.id === visiting.current) : ts;
|
|
554
|
-
if (fresh.length === 0 || captionKey(prev.targets) === captionKey(fresh)) return prev;
|
|
555
|
-
return { ...prev, targets: fresh };
|
|
556
|
-
});
|
|
557
|
-
}, [on, caption]);
|
|
558
|
-
return { step: on ? step : null };
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
// src/components/canvas/icons.tsx
|
|
562
|
-
import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
563
|
-
function Svg2({ children, ...rest }) {
|
|
564
|
-
return /* @__PURE__ */ jsx7(
|
|
565
|
-
"svg",
|
|
566
|
-
{
|
|
567
|
-
width: 16,
|
|
568
|
-
height: 16,
|
|
569
|
-
viewBox: "0 0 24 24",
|
|
570
|
-
fill: "none",
|
|
571
|
-
stroke: "currentColor",
|
|
572
|
-
strokeWidth: 2,
|
|
573
|
-
strokeLinecap: "round",
|
|
574
|
-
strokeLinejoin: "round",
|
|
575
|
-
"aria-hidden": "true",
|
|
576
|
-
focusable: "false",
|
|
577
|
-
...rest,
|
|
578
|
-
children
|
|
579
|
-
}
|
|
580
|
-
);
|
|
581
|
-
}
|
|
582
|
-
var KIND_ICON = {
|
|
583
|
-
ui: /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
584
|
-
/* @__PURE__ */ jsx7("rect", { x: "3", y: "4", width: "18", height: "16", rx: "2" }),
|
|
585
|
-
/* @__PURE__ */ jsx7("path", { d: "M3 9h18" })
|
|
586
|
-
] }),
|
|
587
|
-
service: /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
588
|
-
/* @__PURE__ */ jsx7("rect", { x: "3", y: "3", width: "18", height: "7", rx: "2" }),
|
|
589
|
-
/* @__PURE__ */ jsx7("rect", { x: "3", y: "14", width: "18", height: "7", rx: "2" }),
|
|
590
|
-
/* @__PURE__ */ jsx7("path", { d: "M7 6.5h.01M7 17.5h.01" })
|
|
591
|
-
] }),
|
|
592
|
-
worker: /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
593
|
-
/* @__PURE__ */ jsx7("rect", { x: "6", y: "6", width: "12", height: "12", rx: "2" }),
|
|
594
|
-
/* @__PURE__ */ jsx7("path", { d: "M9 2v4M15 2v4M9 18v4M15 18v4M2 9h4M2 15h4M18 9h4M18 15h4" })
|
|
595
|
-
] }),
|
|
596
|
-
library: /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
597
|
-
/* @__PURE__ */ jsx7("path", { d: "M4 19.5A2.5 2.5 0 0 1 6.5 17H20" }),
|
|
598
|
-
/* @__PURE__ */ jsx7("path", { d: "M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z" })
|
|
599
|
-
] }),
|
|
600
|
-
infra: /* @__PURE__ */ jsx7("path", { d: "M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z" }),
|
|
601
|
-
data: /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
602
|
-
/* @__PURE__ */ jsx7("ellipse", { cx: "12", cy: "5", rx: "9", ry: "3" }),
|
|
603
|
-
/* @__PURE__ */ jsx7("path", { d: "M3 5v14a9 3 0 0 0 18 0V5" }),
|
|
604
|
-
/* @__PURE__ */ jsx7("path", { d: "M3 12a9 3 0 0 0 18 0" })
|
|
605
|
-
] }),
|
|
606
|
-
tool: /* @__PURE__ */ jsx7("path", { d: "M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z" }),
|
|
607
|
-
docs: /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
608
|
-
/* @__PURE__ */ jsx7("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
|
|
609
|
-
/* @__PURE__ */ jsx7("path", { d: "M14 2v6h6M8 13h8M8 17h5" })
|
|
610
|
-
] })
|
|
611
|
-
};
|
|
612
|
-
var PlusIcon = () => /* @__PURE__ */ jsx7(Svg2, { children: /* @__PURE__ */ jsx7("path", { d: "M12 5v14M5 12h14" }) });
|
|
613
|
-
var MinusIcon = () => /* @__PURE__ */ jsx7(Svg2, { children: /* @__PURE__ */ jsx7("path", { d: "M5 12h14" }) });
|
|
614
|
-
var FitIcon = () => /* @__PURE__ */ jsxs6(Svg2, { children: [
|
|
615
|
-
/* @__PURE__ */ jsx7("path", { d: "M8 3H5a2 2 0 0 0-2 2v3M16 3h3a2 2 0 0 1 2 2v3M8 21H5a2 2 0 0 1-2-2v-3M16 21h3a2 2 0 0 0 2-2v-3" }),
|
|
616
|
-
/* @__PURE__ */ jsx7("rect", { x: "8", y: "8", width: "8", height: "8", rx: "1" })
|
|
617
|
-
] });
|
|
618
|
-
var FollowIcon = () => /* @__PURE__ */ jsxs6(Svg2, { children: [
|
|
619
|
-
/* @__PURE__ */ jsx7("circle", { cx: "12", cy: "12", r: "7" }),
|
|
620
|
-
/* @__PURE__ */ jsx7("path", { d: "M12 2v3M12 19v3M2 12h3M19 12h3" }),
|
|
621
|
-
/* @__PURE__ */ jsx7("circle", { cx: "12", cy: "12", r: "1.5", fill: "currentColor" })
|
|
622
|
-
] });
|
|
623
|
-
|
|
624
|
-
// src/components/canvas/layout.ts
|
|
625
|
-
var NODE_W = 172;
|
|
626
|
-
var NODE_H = 56;
|
|
627
|
-
var NODE_GAP = 12;
|
|
628
|
-
var GROUP_PAD = 16;
|
|
629
|
-
var GROUP_HEAD = 52;
|
|
630
|
-
var MIN_COLUMN_STEP = 420;
|
|
631
|
-
var CHANNEL_EDGE = 60;
|
|
632
|
-
var GROUP_GAP_X = 56;
|
|
633
|
-
var BAND_TITLE = 40;
|
|
634
|
-
var GAP_MIN = 72;
|
|
635
|
-
var GAP_MAX = 240;
|
|
636
|
-
var COLUMN_TITLE_ROOM = 36;
|
|
637
|
-
function sizeGroups(groups) {
|
|
638
|
-
const sized = /* @__PURE__ */ new Map();
|
|
639
|
-
for (const g of groups) {
|
|
640
|
-
const cols = g.nodes.length > 1 ? 2 : 1;
|
|
641
|
-
const rows = Math.ceil(g.nodes.length / cols);
|
|
642
|
-
const w = GROUP_PAD * 2 + cols * NODE_W + (cols - 1) * NODE_GAP;
|
|
643
|
-
const h = GROUP_HEAD + GROUP_PAD + (rows > 0 ? rows * NODE_H + (rows - 1) * NODE_GAP : 0);
|
|
644
|
-
sized.set(g.id, { w, h, cols });
|
|
645
|
-
}
|
|
646
|
-
return sized;
|
|
647
|
-
}
|
|
648
|
-
function placeGroup(out, g, s, x, y) {
|
|
649
|
-
out.groups[g.id] = { x, y, w: s.w, h: s.h };
|
|
650
|
-
g.nodes.forEach((n, i) => {
|
|
651
|
-
out.nodes[n.id] = {
|
|
652
|
-
x: x + GROUP_PAD + i % s.cols * (NODE_W + NODE_GAP),
|
|
653
|
-
y: y + GROUP_HEAD + Math.floor(i / s.cols) * (NODE_H + NODE_GAP),
|
|
654
|
-
w: NODE_W,
|
|
655
|
-
h: NODE_H
|
|
656
|
-
};
|
|
657
|
-
});
|
|
658
|
-
}
|
|
659
|
-
function layoutBands(groups, width, edges) {
|
|
660
|
-
const out = {
|
|
661
|
-
mode: "bands",
|
|
662
|
-
width: 0,
|
|
663
|
-
height: 0,
|
|
664
|
-
titleRoom: 0,
|
|
665
|
-
headers: [],
|
|
666
|
-
groups: {},
|
|
667
|
-
nodes: {}
|
|
668
|
-
};
|
|
669
|
-
if (groups.length === 0) return out;
|
|
670
|
-
const sized = sizeGroups(groups);
|
|
671
|
-
const bandOf = (g) => g.band ?? g.column;
|
|
672
|
-
const bandIds = [...new Set(groups.map(bandOf))].sort((a, b) => a - b);
|
|
673
|
-
const rows = [];
|
|
674
|
-
for (const band of bandIds) {
|
|
675
|
-
const members = groups.map((g, i) => ({ g, i })).filter((m) => bandOf(m.g) === band).sort((a, b) => a.g.column - b.g.column || a.i - b.i).map((m) => m.g);
|
|
676
|
-
let cur = null;
|
|
677
|
-
for (const g of members) {
|
|
678
|
-
const s = sized.get(g.id);
|
|
679
|
-
if (cur && cur.w + GROUP_GAP_X + s.w <= width) {
|
|
680
|
-
cur.list.push(g);
|
|
681
|
-
cur.w += GROUP_GAP_X + s.w;
|
|
682
|
-
cur.h = Math.max(cur.h, s.h);
|
|
683
|
-
} else {
|
|
684
|
-
cur = { band, firstOfBand: cur === null, list: [g], w: s.w, h: s.h };
|
|
685
|
-
rows.push(cur);
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
const rowOf = /* @__PURE__ */ new Map();
|
|
690
|
-
rows.forEach((r, ri) => {
|
|
691
|
-
for (const g of r.list) {
|
|
692
|
-
rowOf.set(g.id, ri);
|
|
693
|
-
for (const n of g.nodes) rowOf.set(n.id, ri);
|
|
694
|
-
}
|
|
695
|
-
});
|
|
696
|
-
const ends = Array.from(
|
|
697
|
-
{ length: Math.max(0, rows.length - 1) },
|
|
698
|
-
() => /* @__PURE__ */ new Set()
|
|
699
|
-
);
|
|
700
|
-
for (const e of edges) {
|
|
701
|
-
const s = rowOf.get(e.from);
|
|
702
|
-
const t = rowOf.get(e.to);
|
|
703
|
-
if (s === void 0 || t === void 0 || s === t) continue;
|
|
704
|
-
if (s < t) {
|
|
705
|
-
ends[s].add(`df:${e.from}`);
|
|
706
|
-
ends[t - 1].add(`dt:${e.to}`);
|
|
707
|
-
} else {
|
|
708
|
-
ends[s - 1].add(`uf:${e.from}`);
|
|
709
|
-
ends[t].add(`ut:${e.to}`);
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
const widest = rows.reduce((m, r) => Math.max(m, r.w), 0);
|
|
713
|
-
out.width = CHANNEL_EDGE + widest + CHANNEL_EDGE;
|
|
714
|
-
let y = CHANNEL_EDGE + BAND_TITLE;
|
|
715
|
-
rows.forEach((r, ri) => {
|
|
716
|
-
if (ri > 0) {
|
|
717
|
-
const gap = Math.min(
|
|
718
|
-
GAP_MAX,
|
|
719
|
-
Math.max(GAP_MIN, 40 + 8 * ends[ri - 1].size)
|
|
720
|
-
);
|
|
721
|
-
y += gap + (r.firstOfBand ? BAND_TITLE : 0);
|
|
722
|
-
}
|
|
723
|
-
let x = CHANNEL_EDGE + (widest - r.w) / 2;
|
|
724
|
-
r.list.forEach((g, gi) => {
|
|
725
|
-
const s = sized.get(g.id);
|
|
726
|
-
placeGroup(out, g, s, x, y);
|
|
727
|
-
if (r.firstOfBand && gi === 0)
|
|
728
|
-
out.headers.push({ index: r.band, x, y: y - 12 });
|
|
729
|
-
x += s.w + GROUP_GAP_X;
|
|
730
|
-
});
|
|
731
|
-
if (ri === rows.length - 1) out.height = y + r.h + CHANNEL_EDGE;
|
|
732
|
-
y += r.h;
|
|
733
|
-
});
|
|
734
|
-
return out;
|
|
735
|
-
}
|
|
736
|
-
function layoutSystem(groups, o = {}) {
|
|
737
|
-
if (o.mode === "bands")
|
|
738
|
-
return layoutBands(groups, o.width ?? 0, o.edges ?? []);
|
|
739
|
-
const columnGap = o.columnGap ?? 120;
|
|
740
|
-
const rowGap = o.rowGap ?? 40;
|
|
741
|
-
const columns = [...new Set(groups.map((g) => g.column))].sort(
|
|
742
|
-
(a, b) => a - b
|
|
743
|
-
);
|
|
744
|
-
const sized = sizeGroups(groups);
|
|
745
|
-
const stackHeight = (list) => list.reduce((sum, g) => sum + sized.get(g.id).h, 0) + Math.max(0, list.length - 1) * rowGap;
|
|
746
|
-
const whole = columns.map((c) => groups.filter((g) => g.column === c));
|
|
747
|
-
const sorted = whole.map(stackHeight).sort((a, b) => a - b);
|
|
748
|
-
const median = sorted.length === 0 ? 0 : sorted[Math.floor(sorted.length / 2)];
|
|
749
|
-
const members = [];
|
|
750
|
-
for (const list of whole) {
|
|
751
|
-
const h = stackHeight(list);
|
|
752
|
-
const parts = median > 0 && list.length > 1 ? Math.min(3, list.length, Math.ceil(h / (median * 1.5))) : 1;
|
|
753
|
-
if (parts <= 1) {
|
|
754
|
-
members.push(list);
|
|
755
|
-
continue;
|
|
756
|
-
}
|
|
757
|
-
const goal = h / parts;
|
|
758
|
-
let cur = [];
|
|
759
|
-
let cuts = 0;
|
|
760
|
-
for (const g of list) {
|
|
761
|
-
if (cur.length > 0 && cuts < parts - 1 && stackHeight(cur) + rowGap + sized.get(g.id).h / 2 > goal) {
|
|
762
|
-
members.push(cur);
|
|
763
|
-
cur = [];
|
|
764
|
-
cuts++;
|
|
765
|
-
}
|
|
766
|
-
cur.push(g);
|
|
767
|
-
}
|
|
768
|
-
members.push(cur);
|
|
769
|
-
}
|
|
770
|
-
const heights = members.map(stackHeight);
|
|
771
|
-
const tallest = heights.reduce((m, h) => Math.max(m, h), 0);
|
|
772
|
-
const out = {
|
|
773
|
-
mode: "columns",
|
|
774
|
-
width: 0,
|
|
775
|
-
height: tallest,
|
|
776
|
-
titleRoom: COLUMN_TITLE_ROOM,
|
|
777
|
-
headers: [],
|
|
778
|
-
groups: {},
|
|
779
|
-
nodes: {}
|
|
780
|
-
};
|
|
781
|
-
let x = members.length > 0 ? CHANNEL_EDGE : 0;
|
|
782
|
-
members.forEach((list, ci) => {
|
|
783
|
-
const widest = list.reduce((m, g) => Math.max(m, sized.get(g.id).w), 0);
|
|
784
|
-
let y = (tallest - heights[ci]) / 2;
|
|
785
|
-
for (const g of list) {
|
|
786
|
-
placeGroup(out, g, sized.get(g.id), x, y);
|
|
787
|
-
y += sized.get(g.id).h + rowGap;
|
|
788
|
-
}
|
|
789
|
-
out.width = Math.max(out.width, x + widest);
|
|
790
|
-
x += Math.max(MIN_COLUMN_STEP, widest + columnGap);
|
|
791
|
-
});
|
|
792
|
-
if (members.length > 0) out.width += CHANNEL_EDGE;
|
|
793
|
-
for (const c of columns) {
|
|
794
|
-
const boxes = groups.filter((g) => g.column === c).map((g) => out.groups[g.id]);
|
|
795
|
-
out.headers.push({
|
|
796
|
-
index: c,
|
|
797
|
-
x: Math.min(...boxes.map((b) => b.x)),
|
|
798
|
-
y: Math.min(...boxes.map((b) => b.y)) - COLUMN_TITLE_ROOM
|
|
799
|
-
});
|
|
800
|
-
}
|
|
801
|
-
return out;
|
|
802
|
-
}
|
|
803
|
-
function layoutCandidates(groups, edges, mode = "auto") {
|
|
804
|
-
if (mode === "columns")
|
|
805
|
-
return {
|
|
806
|
-
mode,
|
|
807
|
-
bands: [],
|
|
808
|
-
columns: layoutSystem(groups, { mode: "columns" })
|
|
809
|
-
};
|
|
810
|
-
const sized = sizeGroups(groups);
|
|
811
|
-
const widths = groups.map((g) => sized.get(g.id).w).sort((a, b) => b - a);
|
|
812
|
-
const perBand = /* @__PURE__ */ new Map();
|
|
813
|
-
for (const g of groups) {
|
|
814
|
-
const b = g.band ?? g.column;
|
|
815
|
-
perBand.set(b, (perBand.get(b) ?? 0) + 1);
|
|
816
|
-
}
|
|
817
|
-
const maxN = Math.max(0, ...perBand.values());
|
|
818
|
-
const rowWidths = [];
|
|
819
|
-
let sum = 0;
|
|
820
|
-
for (let n = 1; n <= maxN; n++) {
|
|
821
|
-
sum += widths[n - 1];
|
|
822
|
-
rowWidths.push(sum + (n - 1) * GROUP_GAP_X);
|
|
823
|
-
}
|
|
824
|
-
if (rowWidths.length === 0) rowWidths.push(0);
|
|
825
|
-
return {
|
|
826
|
-
mode,
|
|
827
|
-
bands: [...new Set(rowWidths)].map(
|
|
828
|
-
(width) => layoutSystem(groups, { mode: "bands", width, edges })
|
|
829
|
-
),
|
|
830
|
-
columns: mode === "auto" ? layoutSystem(groups, { mode: "columns" }) : null
|
|
831
|
-
};
|
|
832
|
-
}
|
|
833
|
-
var PHONE_LAYOUT_W = 480;
|
|
834
|
-
var SCROLL_K = 0.35;
|
|
835
|
-
function chooseLayout(c, viewport) {
|
|
836
|
-
if (c.mode === "columns") return c.columns;
|
|
837
|
-
const candidates = c.bands;
|
|
838
|
-
if (viewport.w <= 0 || viewport.h <= 0) return candidates[0];
|
|
839
|
-
const score = (l) => {
|
|
840
|
-
if (l.width <= 0 || l.height <= 0) return 1;
|
|
841
|
-
return Math.min(
|
|
842
|
-
(viewport.w - 2 * FIT_PAD) / l.width,
|
|
843
|
-
(viewport.h - 2 * FIT_PAD) / (l.height + l.titleRoom),
|
|
844
|
-
1
|
|
845
|
-
);
|
|
846
|
-
};
|
|
847
|
-
const scores = candidates.map(score);
|
|
848
|
-
const top = Math.max(...scores);
|
|
849
|
-
let best = 0;
|
|
850
|
-
scores.forEach((s, i) => {
|
|
851
|
-
if (top - s < 5e-3) best = i;
|
|
852
|
-
});
|
|
853
|
-
if (viewport.w < PHONE_LAYOUT_W || top < (viewport.w < PHONE_MAX_W ? PHONE_K : SCROLL_K)) {
|
|
854
|
-
let pick = candidates[0];
|
|
855
|
-
for (const x of candidates) if (x.width * PHONE_K <= viewport.w - 24) pick = x;
|
|
856
|
-
return pick;
|
|
857
|
-
}
|
|
858
|
-
const bands = candidates[best];
|
|
859
|
-
if (c.mode === "bands" || !c.columns) return bands;
|
|
860
|
-
return score(c.columns) > scores[best] ? c.columns : bands;
|
|
861
|
-
}
|
|
862
|
-
function pickLayout(groups, edges, viewport, mode = "auto") {
|
|
863
|
-
return chooseLayout(layoutCandidates(groups, edges, mode), viewport);
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
// src/components/canvas/legend.tsx
|
|
867
|
-
import { memo as memo2, useEffect as useEffect5, useId as useId2, useRef as useRef5, useState as useState5 } from "react";
|
|
868
|
-
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
869
|
-
var DASH = {
|
|
870
|
-
solid: { width: 1.75 },
|
|
871
|
-
dashed: { dash: "6 5", width: 1.75 },
|
|
872
|
-
dotted: { dash: "0.5 6", width: 2.25, cap: "round" }
|
|
873
|
-
};
|
|
874
|
-
function Sample({ line }) {
|
|
875
|
-
const d = DASH[line ?? "solid"];
|
|
876
|
-
return /* @__PURE__ */ jsx8("svg", { width: 28, height: 10, viewBox: "0 0 28 10", "aria-hidden": "true", focusable: "false", className: "shrink-0", children: /* @__PURE__ */ jsx8("line", { x1: 2, y1: 5, x2: 26, y2: 5, stroke: "currentColor", strokeWidth: d.width, strokeDasharray: d.dash, strokeLinecap: d.cap }) });
|
|
877
|
-
}
|
|
878
|
-
var EdgeLegend = memo2(function EdgeLegend2({ kinds, hidden, onToggle }) {
|
|
879
|
-
const [open, setOpen] = useState5(false);
|
|
880
|
-
const rootRef = useRef5(null);
|
|
881
|
-
const buttonRef = useRef5(null);
|
|
882
|
-
const panelId = useId2();
|
|
883
|
-
useEffect5(() => {
|
|
884
|
-
if (!open) return;
|
|
885
|
-
const onDown = (e) => {
|
|
886
|
-
if (!rootRef.current?.contains(e.target)) setOpen(false);
|
|
887
|
-
};
|
|
888
|
-
const onKey = (e) => {
|
|
889
|
-
if (e.key !== "Escape") return;
|
|
890
|
-
e.stopPropagation();
|
|
891
|
-
setOpen(false);
|
|
892
|
-
buttonRef.current?.focus();
|
|
893
|
-
};
|
|
894
|
-
document.addEventListener("pointerdown", onDown, true);
|
|
895
|
-
document.addEventListener("keydown", onKey, true);
|
|
896
|
-
return () => {
|
|
897
|
-
document.removeEventListener("pointerdown", onDown, true);
|
|
898
|
-
document.removeEventListener("keydown", onKey, true);
|
|
899
|
-
};
|
|
900
|
-
}, [open]);
|
|
901
|
-
if (kinds.length === 0) return null;
|
|
902
|
-
const nHidden = kinds.filter((k) => hidden.has(k.id)).length;
|
|
903
|
-
return /* @__PURE__ */ jsxs7("div", { ref: rootRef, "data-canvas-ui": true, className: "absolute left-3 top-3 z-[5] flex flex-col items-start gap-1.5", children: [
|
|
904
|
-
/* @__PURE__ */ jsxs7(
|
|
905
|
-
"button",
|
|
906
|
-
{
|
|
907
|
-
ref: buttonRef,
|
|
908
|
-
type: "button",
|
|
909
|
-
"aria-expanded": open,
|
|
910
|
-
"aria-controls": open ? panelId : void 0,
|
|
911
|
-
onClick: () => setOpen((o) => !o),
|
|
912
|
-
className: "inline-flex h-11 items-center gap-2 rounded-xl border border-th-line bg-th-surface px-3 text-sm text-th-hi shadow-pop outline-none hover:bg-th-elevated focus-visible:ring-2 focus-visible:ring-th-accent",
|
|
913
|
-
children: [
|
|
914
|
-
/* @__PURE__ */ jsx8(Svg2, { children: /* @__PURE__ */ jsx8("path", { d: "M3 6h18M3 12h18M3 18h18" }) }),
|
|
915
|
-
/* @__PURE__ */ jsx8("span", { children: "Lines" }),
|
|
916
|
-
nHidden > 0 ? /* @__PURE__ */ jsxs7("span", { className: "text-th-hi3", children: [
|
|
917
|
-
"\xB7 ",
|
|
918
|
-
nHidden,
|
|
919
|
-
" hidden"
|
|
920
|
-
] }) : null
|
|
921
|
-
]
|
|
922
|
-
}
|
|
923
|
-
),
|
|
924
|
-
open ? /* @__PURE__ */ jsx8("div", { id: panelId, role: "menu", "aria-label": "Lines", className: "overflow-hidden rounded-xl border border-th-line bg-th-surface shadow-pop", style: { width: "min(240px, calc(100vw - 24px))" }, children: kinds.map((k) => {
|
|
925
|
-
const on = !hidden.has(k.id);
|
|
926
|
-
return /* @__PURE__ */ jsxs7(
|
|
927
|
-
"button",
|
|
928
|
-
{
|
|
929
|
-
type: "button",
|
|
930
|
-
role: "menuitemcheckbox",
|
|
931
|
-
"aria-checked": on,
|
|
932
|
-
onClick: () => onToggle(k.id),
|
|
933
|
-
className: cn(
|
|
934
|
-
"flex h-11 w-full items-center gap-3 px-3 text-left text-sm outline-none hover:bg-th-elevated focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-th-accent",
|
|
935
|
-
on ? "text-th-hi" : "text-th-hi3"
|
|
936
|
-
),
|
|
937
|
-
children: [
|
|
938
|
-
/* @__PURE__ */ jsx8(Sample, { line: k.line }),
|
|
939
|
-
/* @__PURE__ */ jsx8("span", { className: "min-w-0 flex-1 truncate", children: k.label }),
|
|
940
|
-
/* @__PURE__ */ jsx8("span", { "aria-hidden": "true", className: cn("relative h-5 w-9 shrink-0 rounded-full border transition-colors", on ? "border-th-accent bg-th-accent" : "border-th-line-strong bg-th-elevated"), children: /* @__PURE__ */ jsx8("span", { className: cn("absolute top-0.5 size-3.5 rounded-full transition-all", on ? "left-[18px] bg-th-on-accent" : "left-0.5 bg-th-hi3") }) })
|
|
941
|
-
]
|
|
942
|
-
},
|
|
943
|
-
k.id
|
|
944
|
-
);
|
|
945
|
-
}) }) : null
|
|
946
|
-
] });
|
|
947
|
-
});
|
|
948
|
-
|
|
949
|
-
// src/components/canvas/minimap.tsx
|
|
950
|
-
import { memo as memo3, useCallback as useCallback2, useEffect as useEffect6, useImperativeHandle, useRef as useRef6 } from "react";
|
|
951
|
-
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
952
|
-
var MAP_W = 176;
|
|
953
|
-
var MAP_MAX_H = 132;
|
|
954
|
-
var MAP_MIN_H = 60;
|
|
955
|
-
var MIN_CANVAS_W = 600;
|
|
956
|
-
var hueVar = (hue, soft) => hue ? `var(--nish-${hue}${soft ? "-soft" : ""})` : soft ? "var(--nish-accent-soft)" : "var(--nish-accent)";
|
|
957
|
-
var Minimap = memo3(function Minimap2({
|
|
958
|
-
layout,
|
|
959
|
-
groups,
|
|
960
|
-
handleRef,
|
|
961
|
-
onJump
|
|
962
|
-
}) {
|
|
963
|
-
const wrapRef = useRef6(null);
|
|
964
|
-
const svgRef = useRef6(null);
|
|
965
|
-
const rectRef = useRef6(null);
|
|
966
|
-
const last = useRef6(null);
|
|
967
|
-
const totalH = layout.height + layout.titleRoom;
|
|
968
|
-
const ok = layout.width > 0 && totalH > 0;
|
|
969
|
-
const s = ok ? Math.min(MAP_W / layout.width, MAP_MAX_H / totalH) : 1;
|
|
970
|
-
const mapH = ok ? Math.min(MAP_MAX_H, Math.max(MAP_MIN_H, MAP_W * totalH / layout.width)) : MAP_MIN_H;
|
|
971
|
-
const ox = (MAP_W - layout.width * s) / 2;
|
|
972
|
-
const oy = (mapH - totalH * s) / 2;
|
|
973
|
-
const draw = useCallback2(() => {
|
|
974
|
-
const cur = last.current;
|
|
975
|
-
const wrap = wrapRef.current;
|
|
976
|
-
const rect = rectRef.current;
|
|
977
|
-
if (!cur || !wrap || !rect) return;
|
|
978
|
-
const { v, size } = cur;
|
|
979
|
-
wrap.style.display = size.w < MIN_CANVAS_W ? "none" : "";
|
|
980
|
-
const x0 = Math.max(0, ox + -v.x / v.k * s);
|
|
981
|
-
const y0 = Math.max(0, oy + (-v.y / v.k + layout.titleRoom) * s);
|
|
982
|
-
const x1 = Math.min(MAP_W, ox + (-v.x + size.w) / v.k * s);
|
|
983
|
-
const y1 = Math.min(mapH, oy + ((-v.y + size.h) / v.k + layout.titleRoom) * s);
|
|
984
|
-
rect.setAttribute("x", String(x0));
|
|
985
|
-
rect.setAttribute("y", String(y0));
|
|
986
|
-
rect.setAttribute("width", String(Math.max(0, x1 - x0)));
|
|
987
|
-
rect.setAttribute("height", String(Math.max(0, y1 - y0)));
|
|
988
|
-
}, [ox, oy, s, mapH, layout.titleRoom]);
|
|
989
|
-
useImperativeHandle(
|
|
990
|
-
handleRef,
|
|
991
|
-
() => ({
|
|
992
|
-
setView(v, size) {
|
|
993
|
-
last.current = { v, size };
|
|
994
|
-
draw();
|
|
995
|
-
}
|
|
996
|
-
}),
|
|
997
|
-
[draw]
|
|
998
|
-
);
|
|
999
|
-
useEffect6(() => {
|
|
1000
|
-
draw();
|
|
1001
|
-
}, [draw]);
|
|
1002
|
-
const jump = (e) => {
|
|
1003
|
-
const svg = svgRef.current;
|
|
1004
|
-
if (!svg || !ok) return;
|
|
1005
|
-
const box = svg.getBoundingClientRect();
|
|
1006
|
-
if (box.width <= 0 || box.height <= 0) return;
|
|
1007
|
-
const px = (e.clientX - box.left) / box.width * MAP_W;
|
|
1008
|
-
const py = (e.clientY - box.top) / box.height * mapH;
|
|
1009
|
-
onJump((px - ox) / s, (py - oy) / s - layout.titleRoom);
|
|
1010
|
-
};
|
|
1011
|
-
return /* @__PURE__ */ jsx9(
|
|
1012
|
-
"div",
|
|
1013
|
-
{
|
|
1014
|
-
ref: wrapRef,
|
|
1015
|
-
"data-canvas-ui": true,
|
|
1016
|
-
"aria-hidden": "true",
|
|
1017
|
-
className: "nish-canvas-minimap absolute right-3 top-3 z-[5] overflow-hidden rounded-xl border border-th-line bg-th-surface shadow-pop",
|
|
1018
|
-
style: { display: "none" },
|
|
1019
|
-
children: /* @__PURE__ */ jsxs8(
|
|
1020
|
-
"svg",
|
|
1021
|
-
{
|
|
1022
|
-
ref: svgRef,
|
|
1023
|
-
width: MAP_W,
|
|
1024
|
-
height: mapH,
|
|
1025
|
-
viewBox: `0 0 ${MAP_W} ${mapH}`,
|
|
1026
|
-
className: "block cursor-pointer touch-none",
|
|
1027
|
-
onPointerDown: (e) => {
|
|
1028
|
-
if (e.button !== 0) return;
|
|
1029
|
-
e.currentTarget.setPointerCapture(e.pointerId);
|
|
1030
|
-
jump(e);
|
|
1031
|
-
},
|
|
1032
|
-
onPointerMove: (e) => {
|
|
1033
|
-
if (e.currentTarget.hasPointerCapture(e.pointerId)) jump(e);
|
|
1034
|
-
},
|
|
1035
|
-
onPointerUp: (e) => {
|
|
1036
|
-
if (e.currentTarget.hasPointerCapture(e.pointerId)) e.currentTarget.releasePointerCapture(e.pointerId);
|
|
1037
|
-
},
|
|
1038
|
-
children: [
|
|
1039
|
-
groups.map((g) => {
|
|
1040
|
-
const b = layout.groups[g.id];
|
|
1041
|
-
if (!b) return null;
|
|
1042
|
-
return /* @__PURE__ */ jsx9(
|
|
1043
|
-
"rect",
|
|
1044
|
-
{
|
|
1045
|
-
x: ox + b.x * s,
|
|
1046
|
-
y: oy + (b.y + layout.titleRoom) * s,
|
|
1047
|
-
width: b.w * s,
|
|
1048
|
-
height: b.h * s,
|
|
1049
|
-
rx: 3,
|
|
1050
|
-
fill: hueVar(g.hue, true),
|
|
1051
|
-
stroke: hueVar(g.hue, false),
|
|
1052
|
-
strokeWidth: 1
|
|
1053
|
-
},
|
|
1054
|
-
g.id
|
|
1055
|
-
);
|
|
1056
|
-
}),
|
|
1057
|
-
groups.map(
|
|
1058
|
-
(g) => g.nodes.map((n) => {
|
|
1059
|
-
const b = layout.nodes[n.id];
|
|
1060
|
-
if (!n.active || !b) return null;
|
|
1061
|
-
return /* @__PURE__ */ jsx9("circle", { cx: ox + (b.x + b.w / 2) * s, cy: oy + (b.y + b.h / 2 + layout.titleRoom) * s, r: 3, fill: hueVar(g.hue, false) }, n.id);
|
|
1062
|
-
})
|
|
1063
|
-
),
|
|
1064
|
-
/* @__PURE__ */ jsx9("rect", { ref: rectRef, x: 0, y: 0, width: 0, height: 0, fill: "var(--nish-accent)", fillOpacity: 0.1, stroke: "var(--nish-accent)", strokeWidth: 1 })
|
|
1065
|
-
]
|
|
1066
|
-
}
|
|
1067
|
-
)
|
|
1068
|
-
}
|
|
1069
|
-
);
|
|
1070
|
-
});
|
|
1071
|
-
|
|
1072
|
-
// src/components/canvas/node.tsx
|
|
1073
|
-
import { memo as memo4, useLayoutEffect as useLayoutEffect2, useRef as useRef7 } from "react";
|
|
1074
|
-
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1075
|
-
function hueStyle(hue) {
|
|
1076
|
-
return {
|
|
1077
|
-
"--c": hue ? `var(--nish-${hue})` : "var(--nish-accent)",
|
|
1078
|
-
"--c-soft": hue ? `var(--nish-${hue}-soft)` : "var(--nish-accent-soft)"
|
|
1079
|
-
};
|
|
1080
|
-
}
|
|
1081
|
-
var clamp01 = (n) => n == null || !Number.isFinite(n) ? 0 : Math.min(1, Math.max(0, n));
|
|
1082
|
-
function usePing(active) {
|
|
1083
|
-
const ref = useRef7(null);
|
|
1084
|
-
const prev = useRef7(active);
|
|
1085
|
-
useLayoutEffect2(() => {
|
|
1086
|
-
const was = prev.current;
|
|
1087
|
-
prev.current = active;
|
|
1088
|
-
const el = ref.current;
|
|
1089
|
-
if (!el || was || !active) return;
|
|
1090
|
-
el.removeAttribute("data-fx");
|
|
1091
|
-
void el.offsetWidth;
|
|
1092
|
-
el.setAttribute("data-fx", "ping");
|
|
1093
|
-
const timer = setTimeout(() => el.removeAttribute("data-fx"), 450);
|
|
1094
|
-
return () => clearTimeout(timer);
|
|
1095
|
-
}, [active]);
|
|
1096
|
-
return ref;
|
|
1097
|
-
}
|
|
1098
|
-
var NodeView = memo4(
|
|
1099
|
-
function NodeView2({ node, groupTitle, hue, box, selected, dim, delay, onSelect }) {
|
|
1100
|
-
const active = !!node.active;
|
|
1101
|
-
const heat = clamp01(node.heat);
|
|
1102
|
-
const ref = usePing(active);
|
|
1103
|
-
const count = node.count ?? 0;
|
|
1104
|
-
const style = {
|
|
1105
|
-
...hueStyle(hue),
|
|
1106
|
-
left: box.x,
|
|
1107
|
-
top: box.y,
|
|
1108
|
-
width: box.w,
|
|
1109
|
-
height: box.h,
|
|
1110
|
-
"--nish-canvas-delay": `${delay}ms`
|
|
1111
|
-
};
|
|
1112
|
-
if (!active && heat > 0) {
|
|
1113
|
-
const vars = style;
|
|
1114
|
-
vars["--nish-canvas-heat-line"] = `color-mix(in srgb, var(--c) ${Math.round(heat * 70)}%, var(--nish-line))`;
|
|
1115
|
-
vars["--nish-canvas-heat-glow"] = `0 0 ${Math.round(6 + heat * 16)}px color-mix(in srgb, var(--c) ${Math.round(heat * 60)}%, transparent)`;
|
|
1116
|
-
}
|
|
1117
|
-
const aria = `${node.label}, ${groupTitle}${active ? node.note ? `, active: ${node.note}` : ", active" : ""}`;
|
|
1118
|
-
return /* @__PURE__ */ jsx10("div", { className: "nish-canvas-slot", style, "data-active": active || void 0, "data-dim": dim || void 0, children: /* @__PURE__ */ jsxs9(
|
|
1119
|
-
"button",
|
|
1120
|
-
{
|
|
1121
|
-
ref,
|
|
1122
|
-
type: "button",
|
|
1123
|
-
className: "nish-canvas-node",
|
|
1124
|
-
"data-canvas-id": node.id,
|
|
1125
|
-
"data-active": active || void 0,
|
|
1126
|
-
"data-selected": selected || void 0,
|
|
1127
|
-
"data-heat": heat > 0 || void 0,
|
|
1128
|
-
"aria-label": aria,
|
|
1129
|
-
title: node.detail || void 0,
|
|
1130
|
-
"aria-pressed": selected,
|
|
1131
|
-
onClick: () => onSelect?.(node.id, "node"),
|
|
1132
|
-
children: [
|
|
1133
|
-
node.kind ? /* @__PURE__ */ jsx10("span", { className: "nish-canvas-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx10(Svg2, { children: KIND_ICON[node.kind] }) }) : null,
|
|
1134
|
-
/* @__PURE__ */ jsxs9("span", { className: "nish-canvas-text", children: [
|
|
1135
|
-
/* @__PURE__ */ jsx10("span", { className: "nish-canvas-label", children: node.label }),
|
|
1136
|
-
active && node.note ? /* @__PURE__ */ jsx10("span", { className: "nish-canvas-note", "aria-hidden": "true", children: /* @__PURE__ */ jsx10(TickerText, { text: node.note, as: "span" }) }) : node.detail ? /* @__PURE__ */ jsx10("span", { className: "nish-canvas-detail", children: node.detail }) : null
|
|
1137
|
-
] }),
|
|
1138
|
-
count > 1 ? /* @__PURE__ */ jsx10("span", { className: "nish-canvas-count", children: count }) : null,
|
|
1139
|
-
active ? /* @__PURE__ */ jsx10("span", { className: "nish-canvas-live", "aria-hidden": "true" }) : null
|
|
1140
|
-
]
|
|
1141
|
-
}
|
|
1142
|
-
) });
|
|
1143
|
-
},
|
|
1144
|
-
(a, b) => a.groupTitle === b.groupTitle && a.hue === b.hue && a.selected === b.selected && a.dim === b.dim && a.delay === b.delay && a.onSelect === b.onSelect && a.box.x === b.box.x && a.box.y === b.box.y && a.node.id === b.node.id && a.node.label === b.node.label && a.node.kind === b.node.kind && a.node.detail === b.node.detail && a.node.active === b.node.active && a.node.note === b.node.note && a.node.count === b.node.count && Math.round(clamp01(a.node.heat) * 100) === Math.round(clamp01(b.node.heat) * 100)
|
|
1145
|
-
);
|
|
1146
|
-
|
|
1147
|
-
// src/components/canvas/route.ts
|
|
1148
|
-
var LANE_MARGIN = 16;
|
|
1149
|
-
var TRACK_GAP = 8;
|
|
1150
|
-
var CLEARANCE = 8;
|
|
1151
|
-
var OUTSIDE_GAP = 24;
|
|
1152
|
-
var CORNER_R = 6;
|
|
1153
|
-
function roundedPath(pts) {
|
|
1154
|
-
const f = (v) => String(Math.round(v * 100) / 100);
|
|
1155
|
-
let d = `M${f(pts[0][0])} ${f(pts[0][1])}`;
|
|
1156
|
-
for (let i = 1; i < pts.length - 1; i++) {
|
|
1157
|
-
const [ax, ay] = pts[i - 1];
|
|
1158
|
-
const [bx, by] = pts[i];
|
|
1159
|
-
const [cx, cy] = pts[i + 1];
|
|
1160
|
-
const r = Math.min(CORNER_R, (Math.abs(bx - ax) + Math.abs(by - ay)) / 2, (Math.abs(cx - bx) + Math.abs(cy - by)) / 2);
|
|
1161
|
-
const ux = Math.sign(bx - ax);
|
|
1162
|
-
const uy = Math.sign(by - ay);
|
|
1163
|
-
const vx = Math.sign(cx - bx);
|
|
1164
|
-
const vy = Math.sign(cy - by);
|
|
1165
|
-
d += `L${f(bx - ux * r)} ${f(by - uy * r)}A${f(r)} ${f(r)} 0 0 ${ux * vy - uy * vx > 0 ? 1 : 0} ${f(bx + vx * r)} ${f(by + vy * r)}`;
|
|
1166
|
-
}
|
|
1167
|
-
const last = pts[pts.length - 1];
|
|
1168
|
-
return `${d}L${f(last[0])} ${f(last[1])}`;
|
|
1169
|
-
}
|
|
1170
|
-
function corners(pts) {
|
|
1171
|
-
const out = [];
|
|
1172
|
-
for (const p of pts) {
|
|
1173
|
-
const prev = out[out.length - 1];
|
|
1174
|
-
if (prev && prev[0] === p[0] && prev[1] === p[1]) continue;
|
|
1175
|
-
const before = out[out.length - 2];
|
|
1176
|
-
if (prev && before && (before[0] === prev[0] && prev[0] === p[0] || before[1] === prev[1] && prev[1] === p[1])) out.pop();
|
|
1177
|
-
out.push(p);
|
|
1178
|
-
}
|
|
1179
|
-
return out;
|
|
1180
|
-
}
|
|
1181
|
-
function labelPoint(pts) {
|
|
1182
|
-
let best = { x: pts[0][0], y: pts[0][1] };
|
|
1183
|
-
let len = -1;
|
|
1184
|
-
for (let i = 1; i < pts.length; i++) {
|
|
1185
|
-
const [ax, ay] = pts[i - 1];
|
|
1186
|
-
const [bx, by] = pts[i];
|
|
1187
|
-
const l = Math.abs(bx - ax) + Math.abs(by - ay);
|
|
1188
|
-
if (l > len) {
|
|
1189
|
-
len = l;
|
|
1190
|
-
best = { x: (ax + bx) / 2, y: (ay + by) / 2 };
|
|
1191
|
-
}
|
|
1192
|
-
}
|
|
1193
|
-
return best;
|
|
1194
|
-
}
|
|
1195
|
-
var flip = (b) => ({ x: b.y, y: b.x, w: b.h, h: b.w });
|
|
1196
|
-
function routeEdges(layout, groups, edges) {
|
|
1197
|
-
if (layout.mode !== "bands") return routeColumns(layout, groups, edges);
|
|
1198
|
-
const t = { ...layout, mode: "columns", width: layout.height, height: layout.width, groups: {}, nodes: {} };
|
|
1199
|
-
for (const id of Object.keys(layout.groups)) t.groups[id] = flip(layout.groups[id]);
|
|
1200
|
-
for (const id of Object.keys(layout.nodes)) t.nodes[id] = flip(layout.nodes[id]);
|
|
1201
|
-
const groupOf = /* @__PURE__ */ new Map();
|
|
1202
|
-
for (const g of groups) for (const n of g.nodes) groupOf.set(n.id, g.id);
|
|
1203
|
-
const inside = [];
|
|
1204
|
-
const outside = [];
|
|
1205
|
-
for (const e of edges) {
|
|
1206
|
-
const g = groupOf.get(e.from);
|
|
1207
|
-
(g !== void 0 && g === groupOf.get(e.to) ? inside : outside).push(e);
|
|
1208
|
-
}
|
|
1209
|
-
const routed = routeColumns(t, groups, outside);
|
|
1210
|
-
const result = {};
|
|
1211
|
-
for (const e of inside) {
|
|
1212
|
-
const a = layout.nodes[e.from];
|
|
1213
|
-
const b = layout.nodes[e.to];
|
|
1214
|
-
if (!a || !b || e.from === e.to) continue;
|
|
1215
|
-
let points;
|
|
1216
|
-
let dir;
|
|
1217
|
-
if (b.y >= a.y + a.h) {
|
|
1218
|
-
const ax = a.x + a.w / 2;
|
|
1219
|
-
const bx = b.x + b.w / 2;
|
|
1220
|
-
if (b.y <= a.y + a.h + NODE_GAP + 1) {
|
|
1221
|
-
const my = (a.y + a.h + b.y) / 2;
|
|
1222
|
-
points = corners([[ax, a.y + a.h], [ax, my], [bx, my], [bx, b.y]]);
|
|
1223
|
-
} else {
|
|
1224
|
-
const gb = layout.groups[groupOf.get(e.from)];
|
|
1225
|
-
const hasRightColumn = !!gb && gb.x + gb.w - (a.x + a.w) > NODE_GAP + 20;
|
|
1226
|
-
const gx = hasRightColumn ? a.x + a.w + NODE_GAP / 2 : a.x - NODE_GAP / 2;
|
|
1227
|
-
const y1 = a.y + a.h + NODE_GAP / 2;
|
|
1228
|
-
const y2 = b.y - NODE_GAP / 2;
|
|
1229
|
-
points = corners([[ax, a.y + a.h], [ax, y1], [gx, y1], [gx, y2], [bx, y2], [bx, b.y]]);
|
|
1230
|
-
}
|
|
1231
|
-
dir = "down";
|
|
1232
|
-
} else if (b.x >= a.x + a.w && Math.abs(b.y - a.y) < 1) {
|
|
1233
|
-
const cy = a.y + a.h / 2;
|
|
1234
|
-
points = [[a.x + a.w, cy], [b.x, cy]];
|
|
1235
|
-
dir = "right";
|
|
1236
|
-
} else {
|
|
1237
|
-
continue;
|
|
1238
|
-
}
|
|
1239
|
-
result[e.id] = { id: e.id, points, d: roundedPath(points), dir };
|
|
1240
|
-
}
|
|
1241
|
-
for (const id of Object.keys(routed)) {
|
|
1242
|
-
const points = routed[id].points.map(([x, y]) => [y, x]);
|
|
1243
|
-
result[id] = { id, points, d: roundedPath(points), dir: "down" };
|
|
1244
|
-
}
|
|
1245
|
-
return result;
|
|
1246
|
-
}
|
|
1247
|
-
function routeColumns(layout, groups, edges) {
|
|
1248
|
-
const result = {};
|
|
1249
|
-
const cards = [];
|
|
1250
|
-
for (const g of groups) {
|
|
1251
|
-
const box = layout.groups[g.id];
|
|
1252
|
-
if (box) cards.push({ id: g.id, box });
|
|
1253
|
-
}
|
|
1254
|
-
if (cards.length === 0) return result;
|
|
1255
|
-
const colX = [...new Set(cards.map((c) => c.box.x))].sort((a, b) => a - b);
|
|
1256
|
-
const cols = colX.map((x) => ({ x, right: x, boxes: [] }));
|
|
1257
|
-
const colOf = /* @__PURE__ */ new Map();
|
|
1258
|
-
for (const { id, box } of cards) {
|
|
1259
|
-
const ci = colX.indexOf(box.x);
|
|
1260
|
-
colOf.set(id, ci);
|
|
1261
|
-
cols[ci].right = Math.max(cols[ci].right, box.x + box.w);
|
|
1262
|
-
cols[ci].boxes.push(box);
|
|
1263
|
-
}
|
|
1264
|
-
const channelOf = (j) => {
|
|
1265
|
-
if (j <= 0) return [cols[0].x - CHANNEL_EDGE, cols[0].x];
|
|
1266
|
-
if (j >= cols.length) return [cols[cols.length - 1].right, cols[cols.length - 1].right + CHANNEL_EDGE];
|
|
1267
|
-
return [cols[j - 1].right, cols[j].x];
|
|
1268
|
-
};
|
|
1269
|
-
const minY = cards.reduce((m, c) => Math.min(m, c.box.y), Infinity);
|
|
1270
|
-
const maxY = cards.reduce((m, c) => Math.max(m, c.box.y + c.box.h), -Infinity);
|
|
1271
|
-
const groupOfNode = /* @__PURE__ */ new Map();
|
|
1272
|
-
for (const g of groups) for (const n of g.nodes) groupOfNode.set(n.id, g.id);
|
|
1273
|
-
const portOf = (id, side) => {
|
|
1274
|
-
const nb = layout.nodes[id];
|
|
1275
|
-
const gid = nb ? groupOfNode.get(id) : id;
|
|
1276
|
-
const gb = gid ? layout.groups[gid] : void 0;
|
|
1277
|
-
if (!gid || !gb || !colOf.has(gid)) return void 0;
|
|
1278
|
-
const y = nb ? nb.y + nb.h / 2 : gb.y + gb.h / 2;
|
|
1279
|
-
return { key: `${side}|${gid}|${y}`, x: side === "o" ? gb.x + gb.w : gb.x, y, col: colOf.get(gid) };
|
|
1280
|
-
};
|
|
1281
|
-
const fanOut = /* @__PURE__ */ new Map();
|
|
1282
|
-
const wires = [];
|
|
1283
|
-
for (const edge of edges) {
|
|
1284
|
-
const src = portOf(edge.from, "o");
|
|
1285
|
-
const dst = portOf(edge.to, "i");
|
|
1286
|
-
if (!src || !dst) continue;
|
|
1287
|
-
fanOut.set(src.key, (fanOut.get(src.key) ?? 0) + 1);
|
|
1288
|
-
wires.push({ edge, src, dst, mode: dst.col === src.col + 1 ? "next" : dst.col > src.col ? "far" : "back", exit: "", entry: "" });
|
|
1289
|
-
}
|
|
1290
|
-
const lanes = /* @__PURE__ */ new Map();
|
|
1291
|
-
const inChannel = /* @__PURE__ */ new Map();
|
|
1292
|
-
const lane = (channel, key, w) => {
|
|
1293
|
-
const id = `${channel}|${key}`;
|
|
1294
|
-
let l = lanes.get(id);
|
|
1295
|
-
if (!l) {
|
|
1296
|
-
l = { key: id, ys: 0, n: 0, x: 0 };
|
|
1297
|
-
lanes.set(id, l);
|
|
1298
|
-
const list = inChannel.get(channel);
|
|
1299
|
-
if (list) list.push(l);
|
|
1300
|
-
else inChannel.set(channel, [l]);
|
|
1301
|
-
}
|
|
1302
|
-
l.ys += (w.src.y + w.dst.y) / 2;
|
|
1303
|
-
l.n++;
|
|
1304
|
-
return id;
|
|
1305
|
-
};
|
|
1306
|
-
for (const w of wires) {
|
|
1307
|
-
if (w.mode === "next") {
|
|
1308
|
-
w.exit = w.entry = lane(w.dst.col, fanOut.get(w.src.key) > 1 ? w.src.key : w.dst.key, w);
|
|
1309
|
-
} else {
|
|
1310
|
-
w.exit = lane(w.src.col + 1, w.src.key, w);
|
|
1311
|
-
w.entry = lane(w.dst.col, w.dst.key, w);
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
for (const [channel, list] of inChannel) {
|
|
1315
|
-
const [l, r] = channelOf(channel);
|
|
1316
|
-
const lo = l + LANE_MARGIN;
|
|
1317
|
-
const hi = r - LANE_MARGIN;
|
|
1318
|
-
list.sort((a, b) => a.ys / a.n - b.ys / b.n || (a.key < b.key ? -1 : 1));
|
|
1319
|
-
list.forEach((ln, i) => {
|
|
1320
|
-
ln.x = list.length === 1 || hi <= lo ? (l + r) / 2 : lo + (hi - lo) * i / (list.length - 1);
|
|
1321
|
-
});
|
|
1322
|
-
}
|
|
1323
|
-
const taken = [];
|
|
1324
|
-
for (const w of wires) {
|
|
1325
|
-
taken.push({ y: w.src.y, xa: w.src.x, xb: lanes.get(w.exit).x, src: w.src.key, dst: w.dst.key, track: false });
|
|
1326
|
-
taken.push({ y: w.dst.y, xa: lanes.get(w.entry).x, xb: w.dst.x, src: w.src.key, dst: w.dst.key, track: false });
|
|
1327
|
-
}
|
|
1328
|
-
const sameLine = (h, w) => h.src === w.src.key || h.dst === w.dst.key;
|
|
1329
|
-
const trackFree = (y, xa, xb, w) => {
|
|
1330
|
-
for (const h of taken) {
|
|
1331
|
-
if (Math.min(xb, h.xb) - Math.max(xa, h.xa) <= 0.5) continue;
|
|
1332
|
-
const dy = Math.abs(h.y - y);
|
|
1333
|
-
if (dy < 0.5 ? !sameLine(h, w) : h.track && dy < TRACK_GAP - 0.5) return false;
|
|
1334
|
-
}
|
|
1335
|
-
return true;
|
|
1336
|
-
};
|
|
1337
|
-
const spanOf = (w) => w.mode === "far" ? [w.src.col + 1, w.dst.col - 1] : [w.dst.col, w.src.col];
|
|
1338
|
-
const cardFree = (y, c0, c1) => {
|
|
1339
|
-
for (let c = c0; c <= c1; c++) for (const b of cols[c].boxes) if (y > b.y - CLEARANCE + 1e-6 && y < b.y + b.h + CLEARANCE - 1e-6) return false;
|
|
1340
|
-
return true;
|
|
1341
|
-
};
|
|
1342
|
-
const bandCache = /* @__PURE__ */ new Map();
|
|
1343
|
-
const bandsOf = (c0, c1) => {
|
|
1344
|
-
const id = `${c0}-${c1}`;
|
|
1345
|
-
let bands = bandCache.get(id);
|
|
1346
|
-
if (bands) return bands;
|
|
1347
|
-
const spans = [];
|
|
1348
|
-
for (let c = c0; c <= c1; c++) for (const b of cols[c].boxes) spans.push([b.y - CLEARANCE, b.y + b.h + CLEARANCE]);
|
|
1349
|
-
spans.sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
|
1350
|
-
bands = [];
|
|
1351
|
-
let end = spans[0][1];
|
|
1352
|
-
for (const [a, b] of spans) {
|
|
1353
|
-
if (a >= end) bands.push([end, a]);
|
|
1354
|
-
end = Math.max(end, b);
|
|
1355
|
-
}
|
|
1356
|
-
bandCache.set(id, bands);
|
|
1357
|
-
return bands;
|
|
1358
|
-
};
|
|
1359
|
-
const gap = (avg, [lo, hi]) => avg < lo ? lo - avg : avg > hi ? avg - hi : 0;
|
|
1360
|
-
const wanted = /* @__PURE__ */ new Map();
|
|
1361
|
-
for (const w of wires) {
|
|
1362
|
-
if (w.mode === "next") continue;
|
|
1363
|
-
const avg = (w.src.y + w.dst.y) / 2;
|
|
1364
|
-
let best;
|
|
1365
|
-
for (const b of bandsOf(...spanOf(w))) if (!best || gap(avg, b) < gap(avg, best)) best = b;
|
|
1366
|
-
if (best) wanted.set(`${best[0]}|${best[1]}`, (wanted.get(`${best[0]}|${best[1]}`) ?? 0) + 1);
|
|
1367
|
-
}
|
|
1368
|
-
const trackYs = /* @__PURE__ */ new Map();
|
|
1369
|
-
for (const w of wires) {
|
|
1370
|
-
if (w.mode === "next") continue;
|
|
1371
|
-
const [c0, c1] = spanOf(w);
|
|
1372
|
-
const avg = (w.src.y + w.dst.y) / 2;
|
|
1373
|
-
const near = (a, b) => Math.abs(a - avg) - Math.abs(b - avg) || a - b;
|
|
1374
|
-
const candidates = [];
|
|
1375
|
-
for (const h of taken) if (h.track && sameLine(h, w) && !candidates.includes(h.y)) candidates.push(h.y);
|
|
1376
|
-
for (const b of [...bandsOf(c0, c1)].sort((p, q) => gap(avg, p) - gap(avg, q) || p[0] - q[0])) {
|
|
1377
|
-
const n = Math.min(Math.floor((b[1] - b[0]) / TRACK_GAP) + 1, wanted.get(`${b[0]}|${b[1]}`) ?? 1);
|
|
1378
|
-
const slots = [];
|
|
1379
|
-
for (let i = 0; i < n; i++) slots.push((b[0] + b[1]) / 2 + TRACK_GAP * (i - (n - 1) / 2));
|
|
1380
|
-
candidates.push(...slots.sort(near));
|
|
1381
|
-
}
|
|
1382
|
-
const outer = [];
|
|
1383
|
-
for (let k = 0; k <= wires.length; k++) outer.push(minY - OUTSIDE_GAP - TRACK_GAP * k, maxY + OUTSIDE_GAP + TRACK_GAP * k);
|
|
1384
|
-
candidates.push(...outer.sort(near));
|
|
1385
|
-
const xo = lanes.get(w.exit).x;
|
|
1386
|
-
const xe = lanes.get(w.entry).x;
|
|
1387
|
-
const xa = Math.min(xo, xe);
|
|
1388
|
-
const xb = Math.max(xo, xe);
|
|
1389
|
-
const y = candidates.find((c) => cardFree(c, c0, c1) && trackFree(c, xa, xb, w)) ?? candidates[candidates.length - 1];
|
|
1390
|
-
trackYs.set(w.edge.id, y);
|
|
1391
|
-
taken.push({ y, xa, xb, src: w.src.key, dst: w.dst.key, track: true });
|
|
1392
|
-
}
|
|
1393
|
-
for (const w of wires) {
|
|
1394
|
-
const { src, dst } = w;
|
|
1395
|
-
const xo = lanes.get(w.exit).x;
|
|
1396
|
-
const xe = lanes.get(w.entry).x;
|
|
1397
|
-
const ty = trackYs.get(w.edge.id);
|
|
1398
|
-
const raw = w.mode === "next" ? [[src.x, src.y], [xo, src.y], [xo, dst.y], [dst.x, dst.y]] : [[src.x, src.y], [xo, src.y], [xo, ty], [xe, ty], [xe, dst.y], [dst.x, dst.y]];
|
|
1399
|
-
const points = corners(raw);
|
|
1400
|
-
result[w.edge.id] = { id: w.edge.id, points, d: roundedPath(points), dir: "right" };
|
|
1401
|
-
}
|
|
1402
|
-
return result;
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
|
-
// src/components/canvas/system-canvas.tsx
|
|
1406
|
-
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1407
|
-
var insetFor = (w, minimap) => minimap && w >= MINIMAP_MIN_W ? TOP_INSET_MINIMAP : TOP_INSET;
|
|
1408
|
-
var NO_KINDS = [];
|
|
1409
|
-
var TOP_INSET = 64;
|
|
1410
|
-
var TOP_INSET_MINIMAP = 150;
|
|
1411
|
-
var MINIMAP_MIN_W = 600;
|
|
1412
|
-
var CORNER_W = 200;
|
|
1413
|
-
var initialHidden = (kinds) => new Set(kinds.filter((k) => k.hidden).map((k) => k.id));
|
|
1414
|
-
function SystemCanvas({
|
|
1415
|
-
groups,
|
|
1416
|
-
edges,
|
|
1417
|
-
columns,
|
|
1418
|
-
bands,
|
|
1419
|
-
layout: layoutMode = "auto",
|
|
1420
|
-
edgeKinds,
|
|
1421
|
-
follow,
|
|
1422
|
-
onFollowChange,
|
|
1423
|
-
minimap = true,
|
|
1424
|
-
selected = null,
|
|
1425
|
-
onSelect,
|
|
1426
|
-
height = "100%",
|
|
1427
|
-
label = "System map",
|
|
1428
|
-
className
|
|
1429
|
-
}) {
|
|
1430
|
-
const reduced = usePrefersReducedMotion();
|
|
1431
|
-
const viewportRef = useRef8(null);
|
|
1432
|
-
const worldRef = useRef8(null);
|
|
1433
|
-
const view = useRef8({ x: 0, y: 0, k: 1 });
|
|
1434
|
-
const target = useRef8(null);
|
|
1435
|
-
const raf = useRef8(0);
|
|
1436
|
-
const size = useRef8({ w: 0, h: 0 });
|
|
1437
|
-
const touched = useRef8(false);
|
|
1438
|
-
const zoomLabelRef = useRef8(null);
|
|
1439
|
-
const miniRef = useRef8(null);
|
|
1440
|
-
const [labelsOn, setLabelsOn] = useState6(true);
|
|
1441
|
-
const [hoverId, setHoverId] = useState6(null);
|
|
1442
|
-
const [viewport, setViewport] = useState6({ w: 0, h: 0 });
|
|
1443
|
-
const kindList = edgeKinds ?? NO_KINDS;
|
|
1444
|
-
const kindSig = kindList.map((k) => k.id).join("|");
|
|
1445
|
-
const [hiddenState, setHiddenState] = useState6(() => ({
|
|
1446
|
-
sig: kindSig,
|
|
1447
|
-
set: initialHidden(kindList)
|
|
1448
|
-
}));
|
|
1449
|
-
let hiddenKinds = hiddenState.set;
|
|
1450
|
-
if (hiddenState.sig !== kindSig) {
|
|
1451
|
-
const next = { sig: kindSig, set: initialHidden(kindList) };
|
|
1452
|
-
setHiddenState(next);
|
|
1453
|
-
hiddenKinds = next.set;
|
|
1454
|
-
}
|
|
1455
|
-
const toggleKind = useCallback3((id) => {
|
|
1456
|
-
setHiddenState((s) => {
|
|
1457
|
-
const set = new Set(s.set);
|
|
1458
|
-
if (!set.delete(id)) set.add(id);
|
|
1459
|
-
return { sig: s.sig, set };
|
|
1460
|
-
});
|
|
1461
|
-
}, []);
|
|
1462
|
-
const visibleEdges = useMemo2(() => edges.filter((e) => !e.kind || !hiddenKinds.has(e.kind)), [edges, hiddenKinds]);
|
|
1463
|
-
const lineOf = useMemo2(() => new Map(kindList.map((k) => [k.id, k.line ?? "solid"])), [kindList]);
|
|
1464
|
-
const [internalFollow, setInternalFollow] = useState6(false);
|
|
1465
|
-
const followOn = follow ?? internalFollow;
|
|
1466
|
-
const followRef = useRef8(followOn);
|
|
1467
|
-
const followProps = useRef8({ controlled: follow !== void 0, onFollowChange });
|
|
1468
|
-
const setFollow = useCallback3((on) => {
|
|
1469
|
-
if (!followProps.current.controlled) setInternalFollow(on);
|
|
1470
|
-
followProps.current.onFollowChange?.(on);
|
|
1471
|
-
}, []);
|
|
1472
|
-
const markMoved = useCallback3(() => {
|
|
1473
|
-
touched.current = true;
|
|
1474
|
-
if (followRef.current) {
|
|
1475
|
-
followRef.current = false;
|
|
1476
|
-
setFollow(false);
|
|
1477
|
-
}
|
|
1478
|
-
}, [setFollow]);
|
|
1479
|
-
const sig = groups.map((g) => `${g.id}:${g.column}:${g.band ?? ""}:${g.nodes.map((n) => n.id).join(",")}`).join("|");
|
|
1480
|
-
const visSig = visibleEdges.map((e) => `${e.id}:${e.from}:${e.to}`).join("|");
|
|
1481
|
-
const cands = useMemo2(() => layoutCandidates(groups, visibleEdges, layoutMode), [sig, visSig, layoutMode]);
|
|
1482
|
-
const [picked, setPicked] = useState6(() => ({ layout: chooseLayout(cands, { w: 0, h: 0 }), w: 0, h: 0 }));
|
|
1483
|
-
const layout = picked.layout;
|
|
1484
|
-
const latest = useRef8({
|
|
1485
|
-
cands,
|
|
1486
|
-
minimap,
|
|
1487
|
-
groups,
|
|
1488
|
-
layout,
|
|
1489
|
-
vis: visibleEdges,
|
|
1490
|
-
mode: layoutMode
|
|
1491
|
-
});
|
|
1492
|
-
useLayoutEffect3(() => {
|
|
1493
|
-
followRef.current = followOn;
|
|
1494
|
-
followProps.current = { controlled: follow !== void 0, onFollowChange };
|
|
1495
|
-
latest.current = { cands, minimap, groups, layout, vis: visibleEdges, mode: layoutMode };
|
|
1496
|
-
});
|
|
1497
|
-
const apply = useCallback3((v) => {
|
|
1498
|
-
view.current = v;
|
|
1499
|
-
const world = worldRef.current;
|
|
1500
|
-
const vp = viewportRef.current;
|
|
1501
|
-
if (world) world.style.transform = `translate3d(${v.x}px,${v.y}px,0) scale(${v.k})`;
|
|
1502
|
-
if (vp) {
|
|
1503
|
-
const maj = `${120 * v.k}px ${120 * v.k}px`;
|
|
1504
|
-
const min = `${24 * v.k}px ${24 * v.k}px`;
|
|
1505
|
-
vp.style.backgroundPosition = `${v.x}px ${v.y}px`;
|
|
1506
|
-
vp.style.backgroundSize = `${maj}, ${maj}, ${min}, ${min}`;
|
|
1507
|
-
vp.dataset.grid = v.k < LOD_K ? "major" : "both";
|
|
1508
|
-
const lod = v.k < LOD_K ? "far" : "near";
|
|
1509
|
-
if (vp.dataset.lod !== lod) vp.dataset.lod = lod;
|
|
1510
|
-
}
|
|
1511
|
-
miniRef.current?.setView(v, size.current);
|
|
1512
|
-
const zl = zoomLabelRef.current;
|
|
1513
|
-
if (zl) {
|
|
1514
|
-
const text = `${Math.round(v.k * 100)}%`;
|
|
1515
|
-
if (zl.textContent !== text) zl.textContent = text;
|
|
1516
|
-
}
|
|
1517
|
-
const on = v.k >= LABEL_K;
|
|
1518
|
-
setLabelsOn((old) => old === on ? old : on);
|
|
1519
|
-
}, []);
|
|
1520
|
-
const stop = useCallback3(() => {
|
|
1521
|
-
cancelAnimationFrame(raf.current);
|
|
1522
|
-
raf.current = 0;
|
|
1523
|
-
target.current = null;
|
|
1524
|
-
}, []);
|
|
1525
|
-
const go = useCallback3(
|
|
1526
|
-
(v, animate, ms = ANIM_MS) => {
|
|
1527
|
-
cancelAnimationFrame(raf.current);
|
|
1528
|
-
if (!animate || reduced) {
|
|
1529
|
-
target.current = null;
|
|
1530
|
-
apply(v);
|
|
1531
|
-
return;
|
|
1532
|
-
}
|
|
1533
|
-
const from = { ...view.current };
|
|
1534
|
-
target.current = v;
|
|
1535
|
-
const t0 = performance.now();
|
|
1536
|
-
const step2 = (now) => {
|
|
1537
|
-
const t = Math.min(1, (now - t0) / ms);
|
|
1538
|
-
const e = ease(t);
|
|
1539
|
-
const k = from.k * Math.pow(v.k / from.k, e);
|
|
1540
|
-
apply({
|
|
1541
|
-
k,
|
|
1542
|
-
x: from.x + (v.x - from.x) * e,
|
|
1543
|
-
y: from.y + (v.y - from.y) * e
|
|
1544
|
-
});
|
|
1545
|
-
if (t < 1) raf.current = requestAnimationFrame(step2);
|
|
1546
|
-
else {
|
|
1547
|
-
raf.current = 0;
|
|
1548
|
-
target.current = null;
|
|
1549
|
-
apply(v);
|
|
1550
|
-
}
|
|
1551
|
-
};
|
|
1552
|
-
raf.current = requestAnimationFrame(step2);
|
|
1553
|
-
},
|
|
1554
|
-
[apply, reduced]
|
|
1555
|
-
);
|
|
1556
|
-
const fitView = useCallback3(() => {
|
|
1557
|
-
const { w, h } = size.current;
|
|
1558
|
-
const { groups: gs, layout: lay, minimap: mini } = latest.current;
|
|
1559
|
-
const cw = Math.max(1, lay.width);
|
|
1560
|
-
const ch = Math.max(1, lay.height + lay.titleRoom);
|
|
1561
|
-
const inset = insetFor(w, mini);
|
|
1562
|
-
const free = Math.min((w - FIT_PAD * 2) / cw, (h - FIT_PAD * 2) / ch, 1);
|
|
1563
|
-
const fx = (w - cw * free) / 2;
|
|
1564
|
-
const fy = FIT_PAD + (h - FIT_PAD * 2 - ch * free) / 2 + lay.titleRoom * free;
|
|
1565
|
-
const underCorner = Object.values(lay.groups).some((b) => {
|
|
1566
|
-
const top0 = fy + b.y * free;
|
|
1567
|
-
const left = fx + b.x * free;
|
|
1568
|
-
const right = left + b.w * free;
|
|
1569
|
-
return top0 < inset && (left < CORNER_W || right > w - CORNER_W);
|
|
1570
|
-
});
|
|
1571
|
-
const top = underCorner ? inset : FIT_PAD;
|
|
1572
|
-
const availH = h - top - FIT_PAD;
|
|
1573
|
-
const fit = Math.min((w - FIT_PAD * 2) / cw, availH / ch, 1);
|
|
1574
|
-
if (fit >= PHONE_K || w >= PHONE_MAX_W && fit >= SCROLL_K - 0.05 || gs.length === 0) {
|
|
1575
|
-
const k = clampK(Number.isFinite(fit) && fit > 0 ? fit : 1);
|
|
1576
|
-
return {
|
|
1577
|
-
k,
|
|
1578
|
-
x: (w - lay.width * k) / 2,
|
|
1579
|
-
y: top + (availH - ch * k) / 2 + lay.titleRoom * k
|
|
1580
|
-
};
|
|
1581
|
-
}
|
|
1582
|
-
let box;
|
|
1583
|
-
let activeGroup;
|
|
1584
|
-
for (const g of gs) {
|
|
1585
|
-
const n = g.nodes.find((node) => node.active);
|
|
1586
|
-
if (n) {
|
|
1587
|
-
box = lay.nodes[n.id];
|
|
1588
|
-
activeGroup = lay.groups[g.id];
|
|
1589
|
-
break;
|
|
1590
|
-
}
|
|
1591
|
-
}
|
|
1592
|
-
const pk = clampK(Math.min(1, Math.max(PHONE_K, (w - 48) / Math.max(1, lay.width))));
|
|
1593
|
-
const pinY = (y) => Math.max(Math.min(y, top + lay.titleRoom * pk), h - FIT_PAD - lay.height * pk);
|
|
1594
|
-
const centerX = lay.width * pk <= w - 24 ? (w - lay.width * pk) / 2 : void 0;
|
|
1595
|
-
if (!box) {
|
|
1596
|
-
const first = lay.groups[gs[0].id];
|
|
1597
|
-
const x = centerX ?? (first ? w / 2 - (first.x + first.w / 2) * pk : FIT_PAD);
|
|
1598
|
-
return { k: pk, x, y: top + lay.titleRoom * pk };
|
|
1599
|
-
}
|
|
1600
|
-
const v = centerOn(w, h, pk, box);
|
|
1601
|
-
const gb = activeGroup;
|
|
1602
|
-
if (centerX !== void 0) v.x = centerX;
|
|
1603
|
-
else if (gb && gb.w * pk <= w - 24) v.x = w / 2 - (gb.x + gb.w / 2) * pk;
|
|
1604
|
-
return { ...v, y: pinY(Math.max(h / 2, top + box.h * pk / 2) - (box.y + box.h / 2) * pk) };
|
|
1605
|
-
}, []);
|
|
1606
|
-
const doFit = useCallback3(
|
|
1607
|
-
(animate) => {
|
|
1608
|
-
if (size.current.w <= 0 || size.current.h <= 0) return;
|
|
1609
|
-
go(fitView(), animate);
|
|
1610
|
-
},
|
|
1611
|
-
[fitView, go]
|
|
1612
|
-
);
|
|
1613
|
-
const relayout = useCallback3(
|
|
1614
|
-
(data) => {
|
|
1615
|
-
const { cands: cs, layout: cur } = latest.current;
|
|
1616
|
-
const { w, h } = size.current;
|
|
1617
|
-
const next = chooseLayout(cs, { w, h });
|
|
1618
|
-
if (!data && next.mode === cur.mode && next.width === cur.width && next.height === cur.height) {
|
|
1619
|
-
if (!touched.current && !followRef.current) doFit(false);
|
|
1620
|
-
return;
|
|
1621
|
-
}
|
|
1622
|
-
setPicked({ layout: next, w, h });
|
|
1623
|
-
if (followRef.current) setViewport((old) => old.w === w && old.h === h ? old : { w, h });
|
|
1624
|
-
},
|
|
1625
|
-
[doFit]
|
|
1626
|
-
);
|
|
1627
|
-
const layoutRaf = useRef8(0);
|
|
1628
|
-
const settleTimer = useRef8(void 0);
|
|
1629
|
-
const syncViewport = useCallback3(() => {
|
|
1630
|
-
const { w, h } = size.current;
|
|
1631
|
-
setViewport((old) => old.w === w && old.h === h ? old : { w, h });
|
|
1632
|
-
}, []);
|
|
1633
|
-
useLayoutEffect3(() => {
|
|
1634
|
-
const vp = viewportRef.current;
|
|
1635
|
-
if (!vp) return;
|
|
1636
|
-
let first = true;
|
|
1637
|
-
const measure = () => {
|
|
1638
|
-
const r = vp.getBoundingClientRect();
|
|
1639
|
-
size.current = { w: r.width, h: r.height };
|
|
1640
|
-
if (first) {
|
|
1641
|
-
first = false;
|
|
1642
|
-
setViewport({ w: r.width, h: r.height });
|
|
1643
|
-
relayout(true);
|
|
1644
|
-
return;
|
|
1645
|
-
}
|
|
1646
|
-
if (layoutRaf.current) return;
|
|
1647
|
-
layoutRaf.current = requestAnimationFrame(() => {
|
|
1648
|
-
layoutRaf.current = 0;
|
|
1649
|
-
relayout(false);
|
|
1650
|
-
miniRef.current?.setView(view.current, size.current);
|
|
1651
|
-
clearTimeout(settleTimer.current);
|
|
1652
|
-
settleTimer.current = setTimeout(syncViewport, 150);
|
|
1653
|
-
});
|
|
1654
|
-
};
|
|
1655
|
-
measure();
|
|
1656
|
-
const ro = new ResizeObserver(measure);
|
|
1657
|
-
ro.observe(vp);
|
|
1658
|
-
return () => {
|
|
1659
|
-
ro.disconnect();
|
|
1660
|
-
cancelAnimationFrame(layoutRaf.current);
|
|
1661
|
-
layoutRaf.current = 0;
|
|
1662
|
-
clearTimeout(settleTimer.current);
|
|
1663
|
-
};
|
|
1664
|
-
}, [relayout, syncViewport]);
|
|
1665
|
-
useEffect7(() => {
|
|
1666
|
-
if (followOn) syncViewport();
|
|
1667
|
-
}, [followOn, syncViewport]);
|
|
1668
|
-
const firstData = useRef8(true);
|
|
1669
|
-
useLayoutEffect3(() => {
|
|
1670
|
-
if (firstData.current) {
|
|
1671
|
-
firstData.current = false;
|
|
1672
|
-
return;
|
|
1673
|
-
}
|
|
1674
|
-
relayout(true);
|
|
1675
|
-
}, [sig, visSig, layoutMode, relayout]);
|
|
1676
|
-
const prevLayout = useRef8(null);
|
|
1677
|
-
const fitted = useRef8(false);
|
|
1678
|
-
const relayoutTimer = useRef8(void 0);
|
|
1679
|
-
useLayoutEffect3(() => {
|
|
1680
|
-
const prev = prevLayout.current;
|
|
1681
|
-
prevLayout.current = layout;
|
|
1682
|
-
if (picked.w <= 0 || picked.h <= 0) return;
|
|
1683
|
-
if (!fitted.current) {
|
|
1684
|
-
fitted.current = true;
|
|
1685
|
-
doFit(false);
|
|
1686
|
-
return;
|
|
1687
|
-
}
|
|
1688
|
-
const moved = !prev || prev.mode !== layout.mode || prev.width !== layout.width || prev.height !== layout.height;
|
|
1689
|
-
if (!moved) {
|
|
1690
|
-
if (!touched.current && !followRef.current) doFit(false);
|
|
1691
|
-
return;
|
|
1692
|
-
}
|
|
1693
|
-
const vp = viewportRef.current;
|
|
1694
|
-
if (vp) {
|
|
1695
|
-
vp.dataset.relayout = "true";
|
|
1696
|
-
clearTimeout(relayoutTimer.current);
|
|
1697
|
-
relayoutTimer.current = setTimeout(() => {
|
|
1698
|
-
delete vp.dataset.relayout;
|
|
1699
|
-
}, 500);
|
|
1700
|
-
}
|
|
1701
|
-
stop();
|
|
1702
|
-
if (!touched.current && !followRef.current) doFit(true);
|
|
1703
|
-
}, [layout, picked.w, picked.h, doFit, stop]);
|
|
1704
|
-
useEffect7(() => () => clearTimeout(relayoutTimer.current), []);
|
|
1705
|
-
useEffect7(() => () => cancelAnimationFrame(raf.current), []);
|
|
1706
|
-
const zoomBy = useCallback3(
|
|
1707
|
-
(factor, animate) => {
|
|
1708
|
-
markMoved();
|
|
1709
|
-
const base = target.current ?? view.current;
|
|
1710
|
-
const { w, h } = size.current;
|
|
1711
|
-
go(zoomAround(base, base.k * factor, w / 2, h / 2), animate);
|
|
1712
|
-
},
|
|
1713
|
-
[go, markMoved]
|
|
1714
|
-
);
|
|
1715
|
-
useEffect7(() => {
|
|
1716
|
-
const vp = viewportRef.current;
|
|
1717
|
-
if (!vp) return;
|
|
1718
|
-
const onWheel = (e) => {
|
|
1719
|
-
if (e.target?.closest("[data-canvas-ui]")) return;
|
|
1720
|
-
e.preventDefault();
|
|
1721
|
-
stop();
|
|
1722
|
-
markMoved();
|
|
1723
|
-
const unit = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? size.current.h : 1;
|
|
1724
|
-
const v = view.current;
|
|
1725
|
-
if (e.ctrlKey) {
|
|
1726
|
-
const r = vp.getBoundingClientRect();
|
|
1727
|
-
apply(zoomAround(v, v.k * Math.exp(-e.deltaY * unit * 15e-4), e.clientX - r.left, e.clientY - r.top));
|
|
1728
|
-
} else {
|
|
1729
|
-
apply({ ...v, x: v.x - e.deltaX * unit, y: v.y - e.deltaY * unit });
|
|
1730
|
-
}
|
|
1731
|
-
};
|
|
1732
|
-
vp.addEventListener("wheel", onWheel, { passive: false });
|
|
1733
|
-
return () => vp.removeEventListener("wheel", onWheel);
|
|
1734
|
-
}, [apply, stop, markMoved]);
|
|
1735
|
-
const pointers = useRef8(/* @__PURE__ */ new Map());
|
|
1736
|
-
const gesture = useRef8({
|
|
1737
|
-
mode: "none",
|
|
1738
|
-
startX: 0,
|
|
1739
|
-
startY: 0,
|
|
1740
|
-
lastX: 0,
|
|
1741
|
-
lastY: 0,
|
|
1742
|
-
pinchDist: 1,
|
|
1743
|
-
pinchMid: { x: 0, y: 0 },
|
|
1744
|
-
pinchView: { x: 0, y: 0, k: 1 }
|
|
1745
|
-
});
|
|
1746
|
-
const dragged = useRef8(false);
|
|
1747
|
-
const lastTap = useRef8(null);
|
|
1748
|
-
const lastDouble = useRef8(0);
|
|
1749
|
-
const local = (e) => {
|
|
1750
|
-
const r = viewportRef.current.getBoundingClientRect();
|
|
1751
|
-
return { x: e.clientX - r.left, y: e.clientY - r.top };
|
|
1752
|
-
};
|
|
1753
|
-
const doubleAt = (el, p) => {
|
|
1754
|
-
if (el.closest("[data-canvas-ui]") || el.closest(".nish-canvas-slot")) return;
|
|
1755
|
-
const { w, h } = size.current;
|
|
1756
|
-
const head = el.closest(".nish-canvas-head");
|
|
1757
|
-
if (head) {
|
|
1758
|
-
const box = latest.current.layout.groups[head.dataset.canvasId ?? ""];
|
|
1759
|
-
if (!box) return;
|
|
1760
|
-
const k = Math.min(1.5, Math.max(MIN_K, Math.min((w - FIT_PAD * 2) / box.w, (h - FIT_PAD * 2) / box.h)));
|
|
1761
|
-
markMoved();
|
|
1762
|
-
go(centerOn(w, h, k, box), true);
|
|
1763
|
-
return;
|
|
1764
|
-
}
|
|
1765
|
-
markMoved();
|
|
1766
|
-
const base = target.current ?? view.current;
|
|
1767
|
-
go(zoomAround(base, base.k * 1.5, p.x, p.y), true);
|
|
1768
|
-
};
|
|
1769
|
-
const onDoubleClick = (e) => {
|
|
1770
|
-
if (performance.now() - lastDouble.current < 600) return;
|
|
1771
|
-
doubleAt(e.target, local(e));
|
|
1772
|
-
};
|
|
1773
|
-
const startPinch = () => {
|
|
1774
|
-
const pts = [...pointers.current.values()];
|
|
1775
|
-
const [a, b] = pts;
|
|
1776
|
-
const g = gesture.current;
|
|
1777
|
-
g.mode = "pinch";
|
|
1778
|
-
g.pinchDist = Math.max(1, Math.hypot(a.x - b.x, a.y - b.y));
|
|
1779
|
-
g.pinchMid = { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };
|
|
1780
|
-
g.pinchView = { ...view.current };
|
|
1781
|
-
dragged.current = true;
|
|
1782
|
-
};
|
|
1783
|
-
const onPointerDown = (e) => {
|
|
1784
|
-
if (e.pointerType === "mouse" && e.button !== 0) return;
|
|
1785
|
-
if (e.target.closest("[data-canvas-ui]")) return;
|
|
1786
|
-
stop();
|
|
1787
|
-
const p = local(e);
|
|
1788
|
-
pointers.current.set(e.pointerId, p);
|
|
1789
|
-
const vp = viewportRef.current;
|
|
1790
|
-
const g = gesture.current;
|
|
1791
|
-
if (pointers.current.size === 1) {
|
|
1792
|
-
dragged.current = false;
|
|
1793
|
-
g.mode = "pending";
|
|
1794
|
-
g.startX = g.lastX = p.x;
|
|
1795
|
-
g.startY = g.lastY = p.y;
|
|
1796
|
-
} else if (pointers.current.size === 2) {
|
|
1797
|
-
for (const id of pointers.current.keys()) {
|
|
1798
|
-
try {
|
|
1799
|
-
vp.setPointerCapture(id);
|
|
1800
|
-
} catch {
|
|
1801
|
-
}
|
|
1802
|
-
}
|
|
1803
|
-
markMoved();
|
|
1804
|
-
startPinch();
|
|
1805
|
-
}
|
|
1806
|
-
};
|
|
1807
|
-
const onPointerMove = (e) => {
|
|
1808
|
-
if (!pointers.current.has(e.pointerId)) return;
|
|
1809
|
-
const p = local(e);
|
|
1810
|
-
pointers.current.set(e.pointerId, p);
|
|
1811
|
-
const g = gesture.current;
|
|
1812
|
-
if (g.mode === "pinch" && pointers.current.size >= 2) {
|
|
1813
|
-
const [a, b] = [...pointers.current.values()];
|
|
1814
|
-
const dist = Math.max(1, Math.hypot(a.x - b.x, a.y - b.y));
|
|
1815
|
-
const mid = { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };
|
|
1816
|
-
const s = g.pinchView;
|
|
1817
|
-
const k = clampK(s.k * (dist / g.pinchDist));
|
|
1818
|
-
const wx = (g.pinchMid.x - s.x) / s.k;
|
|
1819
|
-
const wy = (g.pinchMid.y - s.y) / s.k;
|
|
1820
|
-
apply({ k, x: mid.x - wx * k, y: mid.y - wy * k });
|
|
1821
|
-
return;
|
|
1822
|
-
}
|
|
1823
|
-
if (g.mode === "pending") {
|
|
1824
|
-
if (Math.hypot(p.x - g.startX, p.y - g.startY) < DRAG_PX) return;
|
|
1825
|
-
stop();
|
|
1826
|
-
g.mode = "pan";
|
|
1827
|
-
dragged.current = true;
|
|
1828
|
-
markMoved();
|
|
1829
|
-
setHoverId(null);
|
|
1830
|
-
try {
|
|
1831
|
-
viewportRef.current.setPointerCapture(e.pointerId);
|
|
1832
|
-
} catch {
|
|
1833
|
-
}
|
|
1834
|
-
viewportRef.current.dataset.dragging = "true";
|
|
1835
|
-
}
|
|
1836
|
-
if (g.mode === "pan") {
|
|
1837
|
-
const v = view.current;
|
|
1838
|
-
apply({ ...v, x: v.x + (p.x - g.lastX), y: v.y + (p.y - g.lastY) });
|
|
1839
|
-
g.lastX = p.x;
|
|
1840
|
-
g.lastY = p.y;
|
|
1841
|
-
}
|
|
1842
|
-
};
|
|
1843
|
-
const endPointer = (e) => {
|
|
1844
|
-
if (!pointers.current.delete(e.pointerId)) return;
|
|
1845
|
-
const vp = viewportRef.current;
|
|
1846
|
-
try {
|
|
1847
|
-
vp.releasePointerCapture(e.pointerId);
|
|
1848
|
-
} catch {
|
|
1849
|
-
}
|
|
1850
|
-
const g = gesture.current;
|
|
1851
|
-
if (pointers.current.size === 1 && g.mode === "pinch") {
|
|
1852
|
-
const [rest] = [...pointers.current.values()];
|
|
1853
|
-
g.mode = "pan";
|
|
1854
|
-
g.lastX = rest.x;
|
|
1855
|
-
g.lastY = rest.y;
|
|
1856
|
-
} else if (pointers.current.size === 0) {
|
|
1857
|
-
if (g.mode === "pending" && e.pointerType === "touch" && e.type === "pointerup") {
|
|
1858
|
-
const p = local(e);
|
|
1859
|
-
const now = performance.now();
|
|
1860
|
-
const el = e.target.closest("[data-canvas-id]") ?? e.target;
|
|
1861
|
-
const lt = lastTap.current;
|
|
1862
|
-
if (lt && now - lt.t <= DOUBLE_MS && lt.el === el && Math.hypot(p.x - lt.x, p.y - lt.y) <= DOUBLE_PX) {
|
|
1863
|
-
lastTap.current = null;
|
|
1864
|
-
lastDouble.current = now;
|
|
1865
|
-
doubleAt(e.target, p);
|
|
1866
|
-
} else {
|
|
1867
|
-
lastTap.current = { t: now, x: p.x, y: p.y, el };
|
|
1868
|
-
}
|
|
1869
|
-
}
|
|
1870
|
-
g.mode = "none";
|
|
1871
|
-
delete vp.dataset.dragging;
|
|
1872
|
-
setTimeout(() => {
|
|
1873
|
-
dragged.current = false;
|
|
1874
|
-
}, 0);
|
|
1875
|
-
}
|
|
1876
|
-
};
|
|
1877
|
-
const onClickCapture = (e) => {
|
|
1878
|
-
if (dragged.current) {
|
|
1879
|
-
e.stopPropagation();
|
|
1880
|
-
e.preventDefault();
|
|
1881
|
-
}
|
|
1882
|
-
};
|
|
1883
|
-
const onPointerOver = (e) => {
|
|
1884
|
-
if (e.pointerType === "touch" || gesture.current.mode === "pan" || gesture.current.mode === "pinch") return;
|
|
1885
|
-
if (typeof window.matchMedia === "function" && !window.matchMedia("(hover: hover)").matches) return;
|
|
1886
|
-
const id = e.target.closest("[data-canvas-id]")?.getAttribute("data-canvas-id") ?? null;
|
|
1887
|
-
setHoverId((old) => old === id ? old : id);
|
|
1888
|
-
};
|
|
1889
|
-
const onPointerLeave = () => setHoverId(null);
|
|
1890
|
-
const prevSelected = useRef8(selected);
|
|
1891
|
-
useEffect7(() => {
|
|
1892
|
-
if (prevSelected.current === selected) return;
|
|
1893
|
-
prevSelected.current = selected;
|
|
1894
|
-
if (!selected || followRef.current) return;
|
|
1895
|
-
const lay = latest.current.layout;
|
|
1896
|
-
const box = lay.nodes[selected] ?? lay.groups[selected];
|
|
1897
|
-
const { w, h } = size.current;
|
|
1898
|
-
if (!box || w <= 0 || h <= 0) return;
|
|
1899
|
-
const v = target.current ?? view.current;
|
|
1900
|
-
const left = box.x * v.k + v.x;
|
|
1901
|
-
const top = box.y * v.k + v.y;
|
|
1902
|
-
const inside = left >= 0 && top >= 0 && left + box.w * v.k <= w && top + box.h * v.k <= h;
|
|
1903
|
-
if (inside && v.k >= LOD_K) return;
|
|
1904
|
-
const k = clampK(Math.max(v.k, 0.8));
|
|
1905
|
-
const next = centerOn(w, h, k, box);
|
|
1906
|
-
if (w < PHONE_MAX_W) next.y = h * 0.45 / 2 - (box.y + box.h / 2) * k;
|
|
1907
|
-
touched.current = true;
|
|
1908
|
-
go(next, true);
|
|
1909
|
-
}, [selected, go]);
|
|
1910
|
-
const onScroll = () => {
|
|
1911
|
-
const vp = viewportRef.current;
|
|
1912
|
-
if (vp && (vp.scrollLeft !== 0 || vp.scrollTop !== 0)) {
|
|
1913
|
-
vp.scrollLeft = 0;
|
|
1914
|
-
vp.scrollTop = 0;
|
|
1915
|
-
}
|
|
1916
|
-
};
|
|
1917
|
-
const onFocusCapture = (e) => {
|
|
1918
|
-
const vp = viewportRef.current;
|
|
1919
|
-
const el = e.target;
|
|
1920
|
-
if (!vp || el === vp) return;
|
|
1921
|
-
if (pointers.current.size > 0 || !el.matches(":focus-visible")) return;
|
|
1922
|
-
const id = el.closest("[data-canvas-id]")?.dataset.canvasId;
|
|
1923
|
-
if (!id) return;
|
|
1924
|
-
const box = latest.current.layout.nodes[id] ?? latest.current.layout.groups[id];
|
|
1925
|
-
if (!box) return;
|
|
1926
|
-
const v = view.current;
|
|
1927
|
-
const { w, h } = size.current;
|
|
1928
|
-
const left = box.x * v.k + v.x;
|
|
1929
|
-
const top = box.y * v.k + v.y;
|
|
1930
|
-
if (left >= 0 && top >= 0 && left + box.w * v.k <= w && top + box.h * v.k <= h) return;
|
|
1931
|
-
markMoved();
|
|
1932
|
-
go(centerOn(w, h, v.k, box), true);
|
|
1933
|
-
};
|
|
1934
|
-
const onKeyDown = (e) => {
|
|
1935
|
-
if (e.altKey || e.metaKey) return;
|
|
1936
|
-
if (e.target.closest("[data-canvas-ui]")) return;
|
|
1937
|
-
const v = view.current;
|
|
1938
|
-
switch (e.key) {
|
|
1939
|
-
case "ArrowLeft":
|
|
1940
|
-
stop();
|
|
1941
|
-
markMoved();
|
|
1942
|
-
apply({ ...v, x: v.x + KEY_PAN });
|
|
1943
|
-
break;
|
|
1944
|
-
case "ArrowRight":
|
|
1945
|
-
stop();
|
|
1946
|
-
markMoved();
|
|
1947
|
-
apply({ ...v, x: v.x - KEY_PAN });
|
|
1948
|
-
break;
|
|
1949
|
-
case "ArrowUp":
|
|
1950
|
-
stop();
|
|
1951
|
-
markMoved();
|
|
1952
|
-
apply({ ...v, y: v.y + KEY_PAN });
|
|
1953
|
-
break;
|
|
1954
|
-
case "ArrowDown":
|
|
1955
|
-
stop();
|
|
1956
|
-
markMoved();
|
|
1957
|
-
apply({ ...v, y: v.y - KEY_PAN });
|
|
1958
|
-
break;
|
|
1959
|
-
case "+":
|
|
1960
|
-
case "=":
|
|
1961
|
-
zoomBy(ZOOM_STEP, true);
|
|
1962
|
-
break;
|
|
1963
|
-
case "-":
|
|
1964
|
-
case "_":
|
|
1965
|
-
zoomBy(1 / ZOOM_STEP, true);
|
|
1966
|
-
break;
|
|
1967
|
-
case "0":
|
|
1968
|
-
touched.current = false;
|
|
1969
|
-
doFit(true);
|
|
1970
|
-
break;
|
|
1971
|
-
default:
|
|
1972
|
-
return;
|
|
1973
|
-
}
|
|
1974
|
-
e.preventDefault();
|
|
1975
|
-
};
|
|
1976
|
-
const columnIndex = useMemo2(() => {
|
|
1977
|
-
const order = [...new Set(groups.map((g) => g.column))].sort((a, b) => a - b);
|
|
1978
|
-
return new Map(order.map((c, i) => [c, i]));
|
|
1979
|
-
}, [sig]);
|
|
1980
|
-
const lookup = useMemo2(() => {
|
|
1981
|
-
const nodes = /* @__PURE__ */ new Map();
|
|
1982
|
-
const grps = /* @__PURE__ */ new Map();
|
|
1983
|
-
for (const g of groups) {
|
|
1984
|
-
grps.set(g.id, g);
|
|
1985
|
-
for (const n of g.nodes) nodes.set(n.id, { group: g, node: n });
|
|
1986
|
-
}
|
|
1987
|
-
return { nodes, grps };
|
|
1988
|
-
}, [groups]);
|
|
1989
|
-
const headerViews = useMemo2(
|
|
1990
|
-
() => layout.headers.flatMap((h) => {
|
|
1991
|
-
const text = layout.mode === "bands" ? bands?.[h.index] ?? columns?.[h.index] : columns?.[h.index];
|
|
1992
|
-
return text ? [{ key: `${layout.mode}:${h.index}`, x: h.x, y: h.y, text }] : [];
|
|
1993
|
-
}),
|
|
1994
|
-
[layout, bands, columns]
|
|
1995
|
-
);
|
|
1996
|
-
const routes = useMemo2(() => routeEdges(layout, groups, visibleEdges), [layout, visSig]);
|
|
1997
|
-
const { edgeViews, ports } = useMemo2(() => {
|
|
1998
|
-
const hueOf = (id) => {
|
|
1999
|
-
const n = lookup.nodes.get(id);
|
|
2000
|
-
if (n) return { hue: n.group.hue, active: !!n.node.active };
|
|
2001
|
-
const g = lookup.grps.get(id);
|
|
2002
|
-
if (g) return { hue: g.hue, active: g.nodes.some((x) => x.active) };
|
|
2003
|
-
return void 0;
|
|
2004
|
-
};
|
|
2005
|
-
const views = visibleEdges.flatMap((edge) => {
|
|
2006
|
-
const route = routes[edge.id];
|
|
2007
|
-
const to = hueOf(edge.to);
|
|
2008
|
-
if (!route || !to) return [];
|
|
2009
|
-
const line = edge.dashed ? "dashed" : (edge.kind ? lineOf.get(edge.kind) : void 0) ?? "solid";
|
|
2010
|
-
return [
|
|
2011
|
-
{
|
|
2012
|
-
edge,
|
|
2013
|
-
route,
|
|
2014
|
-
line,
|
|
2015
|
-
mid: labelPoint(route.points),
|
|
2016
|
-
hue: to.hue,
|
|
2017
|
-
active: to.active
|
|
2018
|
-
}
|
|
2019
|
-
];
|
|
2020
|
-
});
|
|
2021
|
-
views.sort((a, b) => Number(a.active) - Number(b.active));
|
|
2022
|
-
const dots = /* @__PURE__ */ new Map();
|
|
2023
|
-
for (const v of views) {
|
|
2024
|
-
const p = v.route.points[0];
|
|
2025
|
-
const key = `${p[0]}|${p[1]}`;
|
|
2026
|
-
const old = dots.get(key);
|
|
2027
|
-
if (!old || v.active && !old.active) dots.set(key, { x: p[0], y: p[1], hue: v.hue, active: v.active });
|
|
2028
|
-
}
|
|
2029
|
-
return { edgeViews: views, ports: [...dots.entries()] };
|
|
2030
|
-
}, [visibleEdges, routes, lookup, lineOf]);
|
|
2031
|
-
const focus = useMemo2(() => {
|
|
2032
|
-
const id = hoverId ?? selected;
|
|
2033
|
-
if (!id) return null;
|
|
2034
|
-
const node = lookup.nodes.get(id);
|
|
2035
|
-
const grp = node ? node.group : lookup.grps.get(id);
|
|
2036
|
-
if (!grp) return null;
|
|
2037
|
-
const mine = new Set(node ? [id] : [id, ...grp.nodes.map((n) => n.id)]);
|
|
2038
|
-
const related = /* @__PURE__ */ new Set([id, grp.id]);
|
|
2039
|
-
if (!node) for (const n of grp.nodes) related.add(n.id);
|
|
2040
|
-
const addEnd = (eid) => {
|
|
2041
|
-
related.add(eid);
|
|
2042
|
-
const n = lookup.nodes.get(eid);
|
|
2043
|
-
if (n) related.add(n.group.id);
|
|
2044
|
-
const g = lookup.grps.get(eid);
|
|
2045
|
-
if (g) for (const x of g.nodes) related.add(x.id);
|
|
2046
|
-
};
|
|
2047
|
-
const hot = /* @__PURE__ */ new Set();
|
|
2048
|
-
for (const e of visibleEdges) {
|
|
2049
|
-
if (!mine.has(e.from) && !mine.has(e.to)) continue;
|
|
2050
|
-
hot.add(e.id);
|
|
2051
|
-
addEnd(e.from);
|
|
2052
|
-
addEnd(e.to);
|
|
2053
|
-
}
|
|
2054
|
-
return { related, hot };
|
|
2055
|
-
}, [hoverId, selected, lookup, visibleEdges]);
|
|
2056
|
-
const fly = useCallback3((v) => go(v, true, FOLLOW_MS), [go]);
|
|
2057
|
-
const { step } = useFollow({
|
|
2058
|
-
on: followOn,
|
|
2059
|
-
groups,
|
|
2060
|
-
layout,
|
|
2061
|
-
size: viewport,
|
|
2062
|
-
fit: fitView,
|
|
2063
|
-
inset: TOP_INSET,
|
|
2064
|
-
fly
|
|
2065
|
-
});
|
|
2066
|
-
const canFollow = useMemo2(() => groups.some((g) => g.nodes.some((n) => n.active !== void 0)), [groups]);
|
|
2067
|
-
const jumpTo = useCallback3(
|
|
2068
|
-
(wx, wy) => {
|
|
2069
|
-
stop();
|
|
2070
|
-
markMoved();
|
|
2071
|
-
const { w, h } = size.current;
|
|
2072
|
-
const v = view.current;
|
|
2073
|
-
apply({ k: v.k, x: w / 2 - wx * v.k, y: h / 2 - wy * v.k });
|
|
2074
|
-
},
|
|
2075
|
-
[apply, stop, markMoved]
|
|
2076
|
-
);
|
|
2077
|
-
const layoutKey = `${layout.mode}:${layout.width}`;
|
|
2078
|
-
return /* @__PURE__ */ jsxs10(
|
|
2079
|
-
"div",
|
|
2080
|
-
{
|
|
2081
|
-
ref: viewportRef,
|
|
2082
|
-
role: "application",
|
|
2083
|
-
"aria-label": label,
|
|
2084
|
-
"aria-roledescription": "canvas",
|
|
2085
|
-
tabIndex: 0,
|
|
2086
|
-
className: cn("nish-canvas", className),
|
|
2087
|
-
style: { height },
|
|
2088
|
-
"data-grid": "both",
|
|
2089
|
-
"data-lod": "near",
|
|
2090
|
-
"data-focus": focus ? "true" : void 0,
|
|
2091
|
-
onPointerDown,
|
|
2092
|
-
onPointerMove,
|
|
2093
|
-
onPointerUp: endPointer,
|
|
2094
|
-
onPointerCancel: endPointer,
|
|
2095
|
-
onPointerOver,
|
|
2096
|
-
onPointerLeave,
|
|
2097
|
-
onDoubleClick,
|
|
2098
|
-
onClickCapture,
|
|
2099
|
-
onKeyDown,
|
|
2100
|
-
onScroll,
|
|
2101
|
-
onFocusCapture,
|
|
2102
|
-
children: [
|
|
2103
|
-
/* @__PURE__ */ jsxs10("div", { ref: worldRef, className: "nish-canvas-world", style: { width: layout.width, height: layout.height }, children: [
|
|
2104
|
-
headerViews.map((t) => /* @__PURE__ */ jsx11("div", { className: "nish-canvas-coltitle", style: layout.mode === "bands" ? { left: t.x, top: t.y, lineHeight: 1, transform: "translateY(-100%)" } : { left: t.x, top: t.y }, children: t.text }, t.key)),
|
|
2105
|
-
/* @__PURE__ */ jsx11("svg", { className: "nish-canvas-edges", width: layout.width, height: layout.height, "aria-hidden": "true", focusable: "false", children: edgeViews.map(({ edge, route, line, mid, hue, active }) => {
|
|
2106
|
-
const hot = focus?.hot.has(edge.id) ?? false;
|
|
2107
|
-
const end = route.points[route.points.length - 1];
|
|
2108
|
-
const [ex, ey] = end;
|
|
2109
|
-
const arrow = route.dir === "down" ? `M${ex} ${ey}L${ex - 3.5} ${ey - 8}L${ex + 3.5} ${ey - 8}Z` : `M${ex} ${ey}L${ex - 8} ${ey - 3.5}L${ex - 8} ${ey + 3.5}Z`;
|
|
2110
|
-
return /* @__PURE__ */ jsxs10("g", { style: hueStyle(hue), className: "nish-canvas-edge", "data-active": active || void 0, "data-line": line, "data-hot": hot || void 0, children: [
|
|
2111
|
-
/* @__PURE__ */ jsx11("path", { className: "nish-canvas-edge-line", d: route.d, fill: "none" }),
|
|
2112
|
-
/* @__PURE__ */ jsx11("path", { className: "nish-canvas-arrow", d: arrow }),
|
|
2113
|
-
active ? /* @__PURE__ */ jsx11("circle", { className: "nish-canvas-dot", r: "3.5", style: { offsetPath: `path("${route.d}")` } }) : null,
|
|
2114
|
-
edge.label && (labelsOn || hot) ? /* @__PURE__ */ jsx11("text", { className: "nish-canvas-edge-label", x: mid.x, y: mid.y - 6, textAnchor: "middle", children: edge.label }) : null
|
|
2115
|
-
] }, edge.id);
|
|
2116
|
-
}) }, `e${layoutKey}`),
|
|
2117
|
-
/* @__PURE__ */ jsx11("svg", { className: "nish-canvas-ports", width: layout.width, height: layout.height, "aria-hidden": "true", focusable: "false", children: ports.map(([key, p]) => /* @__PURE__ */ jsx11("circle", { className: "nish-canvas-port", cx: p.x, cy: p.y, r: 3, style: hueStyle(p.hue), "data-active": p.active || void 0 }, key)) }, `p${layoutKey}`),
|
|
2118
|
-
groups.map((g) => {
|
|
2119
|
-
const box = layout.groups[g.id];
|
|
2120
|
-
if (!box) return null;
|
|
2121
|
-
const live = g.nodes.some((n) => n.active);
|
|
2122
|
-
const delay = (columnIndex.get(g.column) ?? 0) * 80;
|
|
2123
|
-
return /* @__PURE__ */ jsxs10(Fragment4, { children: [
|
|
2124
|
-
/* @__PURE__ */ jsxs10(
|
|
2125
|
-
"div",
|
|
2126
|
-
{
|
|
2127
|
-
className: "nish-canvas-group",
|
|
2128
|
-
style: {
|
|
2129
|
-
...hueStyle(g.hue),
|
|
2130
|
-
left: box.x,
|
|
2131
|
-
top: box.y,
|
|
2132
|
-
width: box.w,
|
|
2133
|
-
height: box.h,
|
|
2134
|
-
"--nish-canvas-delay": `${delay}ms`
|
|
2135
|
-
},
|
|
2136
|
-
"data-live": live || void 0,
|
|
2137
|
-
"data-selected": selected === g.id || void 0,
|
|
2138
|
-
"data-related": focus?.related.has(g.id) || void 0,
|
|
2139
|
-
children: [
|
|
2140
|
-
/* @__PURE__ */ jsx11("span", { className: "nish-canvas-band", "aria-hidden": "true" }),
|
|
2141
|
-
/* @__PURE__ */ jsxs10("button", { type: "button", className: "nish-canvas-head", "data-canvas-id": g.id, "aria-pressed": selected === g.id, onClick: () => onSelect?.(g.id, "group"), children: [
|
|
2142
|
-
/* @__PURE__ */ jsxs10("span", { className: "nish-canvas-headtext", children: [
|
|
2143
|
-
/* @__PURE__ */ jsx11("span", { className: "nish-canvas-title", children: g.title }),
|
|
2144
|
-
g.subtitle ? /* @__PURE__ */ jsx11("span", { className: "nish-canvas-subtitle", children: g.subtitle }) : null
|
|
2145
|
-
] }),
|
|
2146
|
-
g.badge ? /* @__PURE__ */ jsx11("span", { className: "nish-canvas-badge", children: g.badge }) : null
|
|
2147
|
-
] })
|
|
2148
|
-
]
|
|
2149
|
-
}
|
|
2150
|
-
),
|
|
2151
|
-
g.nodes.map((n) => {
|
|
2152
|
-
const nb = layout.nodes[n.id];
|
|
2153
|
-
if (!nb) return null;
|
|
2154
|
-
return /* @__PURE__ */ jsx11(
|
|
2155
|
-
NodeView,
|
|
2156
|
-
{
|
|
2157
|
-
node: n,
|
|
2158
|
-
groupTitle: g.title,
|
|
2159
|
-
hue: g.hue,
|
|
2160
|
-
box: nb,
|
|
2161
|
-
selected: selected === n.id,
|
|
2162
|
-
dim: focus ? !focus.related.has(n.id) : false,
|
|
2163
|
-
delay,
|
|
2164
|
-
onSelect
|
|
2165
|
-
},
|
|
2166
|
-
n.id
|
|
2167
|
-
);
|
|
2168
|
-
})
|
|
2169
|
-
] }, g.id);
|
|
2170
|
-
})
|
|
2171
|
-
] }),
|
|
2172
|
-
/* @__PURE__ */ jsx11(EdgeLegend, { kinds: kindList, hidden: hiddenKinds, onToggle: toggleKind }),
|
|
2173
|
-
minimap ? /* @__PURE__ */ jsx11(Minimap, { layout, groups, handleRef: miniRef, onJump: jumpTo }) : null,
|
|
2174
|
-
/* @__PURE__ */ jsx11(FollowCaption, { step }),
|
|
2175
|
-
/* @__PURE__ */ jsxs10("div", { "data-canvas-ui": true, className: "nish-canvas-controls", children: [
|
|
2176
|
-
/* @__PURE__ */ jsx11("span", { ref: zoomLabelRef, className: "nish-canvas-zoom", "aria-hidden": "true", children: "100%" }),
|
|
2177
|
-
/* @__PURE__ */ jsx11(IconButton, { label: "Zoom out", variant: "ghost", className: "size-11", onClick: () => zoomBy(1 / ZOOM_STEP, true), children: /* @__PURE__ */ jsx11(MinusIcon, {}) }),
|
|
2178
|
-
/* @__PURE__ */ jsx11(IconButton, { label: "Zoom in", variant: "ghost", className: "size-11", onClick: () => zoomBy(ZOOM_STEP, true), children: /* @__PURE__ */ jsx11(PlusIcon, {}) }),
|
|
2179
|
-
/* @__PURE__ */ jsx11(
|
|
2180
|
-
IconButton,
|
|
2181
|
-
{
|
|
2182
|
-
label: "Fit to screen",
|
|
2183
|
-
variant: "ghost",
|
|
2184
|
-
className: "size-11",
|
|
2185
|
-
onClick: () => {
|
|
2186
|
-
touched.current = false;
|
|
2187
|
-
doFit(true);
|
|
2188
|
-
},
|
|
2189
|
-
children: /* @__PURE__ */ jsx11(FitIcon, {})
|
|
2190
|
-
}
|
|
2191
|
-
),
|
|
2192
|
-
canFollow ? /* @__PURE__ */ jsx11(IconButton, { label: "Follow activity", variant: "ghost", className: "size-11", active: followOn, "aria-pressed": followOn, onClick: () => setFollow(!followOn), children: /* @__PURE__ */ jsx11(FollowIcon, {}) }) : null
|
|
2193
|
-
] })
|
|
2194
|
-
]
|
|
2195
|
-
}
|
|
2196
|
-
);
|
|
2197
|
-
}
|
|
2198
|
-
export {
|
|
2199
|
-
SystemCanvas,
|
|
2200
|
-
layoutSystem,
|
|
2201
|
-
pickLayout,
|
|
2202
|
-
routeEdges
|
|
2203
|
-
};
|
|
2204
|
-
//# sourceMappingURL=system-canvas.js.map
|