@praxical/ui 0.0.0-stage → 0.11.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/LICENSE +21 -0
- package/README.md +23 -2
- package/dist/activity-calendar.d.ts +13 -0
- package/dist/activity-calendar.js +7 -0
- package/dist/activity-heatmap.d.ts +14 -0
- package/dist/activity-heatmap.js +13 -0
- package/dist/chart-data.d.ts +9 -0
- package/dist/chart-data.js +9 -0
- package/dist/charts.d.ts +56 -0
- package/dist/charts.js +424 -0
- package/dist/chunk-7RMPDKZV.js +541 -0
- package/dist/chunk-7RTW3X7C.js +142 -0
- package/dist/chunk-EBF2F3LN.js +1523 -0
- package/dist/chunk-FCYIZANU.js +385 -0
- package/dist/chunk-HMO4VQZN.js +58 -0
- package/dist/chunk-II677WPC.js +177 -0
- package/dist/chunk-KZHUBPY6.js +102 -0
- package/dist/chunk-OLGZOPLD.js +166 -0
- package/dist/chunk-PDSV773E.js +52 -0
- package/dist/chunk-Q4ARHP76.js +457 -0
- package/dist/chunk-U5W7O3QV.js +22 -0
- package/dist/chunk-V6MXR4P2.js +275 -0
- package/dist/chunk-VZZDLRM5.js +152 -0
- package/dist/chunk-WEM2UQPR.js +110 -0
- package/dist/chunk-XFNDEA5M.js +104 -0
- package/dist/chunk-YKFAA7GU.js +72 -0
- package/dist/code-editor.css +76 -0
- package/dist/code-editor.d.ts +44 -0
- package/dist/code-editor.js +287 -0
- package/dist/code-value.d.ts +13 -0
- package/dist/code-value.js +10 -0
- package/dist/code.d.ts +36 -0
- package/dist/code.js +198 -0
- package/dist/collection.d.ts +21 -0
- package/dist/collection.js +48 -0
- package/dist/content.d.ts +42 -0
- package/dist/content.js +122 -0
- package/dist/display.d.ts +58 -0
- package/dist/display.js +27 -0
- package/dist/feedback.d.ts +34 -0
- package/dist/feedback.js +184 -0
- package/dist/file-tree.d.ts +17 -0
- package/dist/file-tree.js +11 -0
- package/dist/forms.d.ts +69 -0
- package/dist/forms.js +273 -0
- package/dist/git-graph.d.ts +8 -0
- package/dist/git-graph.js +15 -0
- package/dist/git-layout.d.ts +24 -0
- package/dist/git-layout.js +7 -0
- package/dist/image-viewer.d.ts +18 -0
- package/dist/image-viewer.js +11 -0
- package/dist/index.d.ts +363 -0
- package/dist/index.js +98 -0
- package/dist/inputs.d.ts +112 -0
- package/dist/inputs.js +938 -0
- package/dist/layout.d.ts +56 -0
- package/dist/layout.js +180 -0
- package/dist/map-frame.d.ts +37 -0
- package/dist/map-frame.js +13 -0
- package/dist/media.d.ts +40 -0
- package/dist/media.js +19 -0
- package/dist/network-layout.d.ts +94 -0
- package/dist/network-layout.js +19 -0
- package/dist/network.d.ts +111 -0
- package/dist/network.js +354 -0
- package/dist/overlays.d.ts +95 -0
- package/dist/overlays.js +25 -0
- package/dist/patterns.d.ts +117 -0
- package/dist/patterns.js +387 -0
- package/dist/power-layout.d.ts +91 -0
- package/dist/power-layout.js +13 -0
- package/dist/power.d.ts +91 -0
- package/dist/power.js +353 -0
- package/dist/signal-context.d.ts +11 -0
- package/dist/signal-context.js +15 -0
- package/dist/strings-es-419.d.ts +13 -0
- package/dist/strings-es-419.js +357 -0
- package/dist/strings-fr.d.ts +15 -0
- package/dist/strings-fr.js +359 -0
- package/dist/strings-ja.d.ts +16 -0
- package/dist/strings-ja.js +357 -0
- package/dist/strings-pt-BR.d.ts +13 -0
- package/dist/strings-pt-BR.js +357 -0
- package/dist/strings.d.ts +394 -0
- package/dist/strings.js +15 -0
- package/dist/styles.css +2 -0
- package/dist/tab-bar.d.ts +20 -0
- package/dist/tab-bar.js +114 -0
- package/package.json +199 -3
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import {
|
|
3
|
+
Button
|
|
4
|
+
} from "./chunk-EBF2F3LN.js";
|
|
5
|
+
import {
|
|
6
|
+
useSignalLocale,
|
|
7
|
+
useSignalStrings
|
|
8
|
+
} from "./chunk-U5W7O3QV.js";
|
|
9
|
+
|
|
10
|
+
// packages/ui/src/display.tsx
|
|
11
|
+
import {
|
|
12
|
+
ArrowUpRight,
|
|
13
|
+
CircleAlert,
|
|
14
|
+
CircleCheck,
|
|
15
|
+
Info,
|
|
16
|
+
TriangleAlert,
|
|
17
|
+
X
|
|
18
|
+
} from "lucide-react";
|
|
19
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
+
var cx = (...values) => values.filter(Boolean).join(" ");
|
|
21
|
+
function Link({
|
|
22
|
+
external,
|
|
23
|
+
variant = "inline",
|
|
24
|
+
className,
|
|
25
|
+
children,
|
|
26
|
+
...props
|
|
27
|
+
}) {
|
|
28
|
+
return /* @__PURE__ */ jsxs(
|
|
29
|
+
"a",
|
|
30
|
+
{
|
|
31
|
+
...props,
|
|
32
|
+
className: cx("signal-link", className),
|
|
33
|
+
"data-variant": variant,
|
|
34
|
+
target: external ? "_blank" : props.target,
|
|
35
|
+
rel: external ? "noreferrer" : props.rel,
|
|
36
|
+
children: [
|
|
37
|
+
children,
|
|
38
|
+
external && /* @__PURE__ */ jsx(ArrowUpRight, { "aria-hidden": "true" })
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
function Tag({
|
|
44
|
+
tone = "neutral",
|
|
45
|
+
icon,
|
|
46
|
+
onRemove,
|
|
47
|
+
removeLabel,
|
|
48
|
+
className,
|
|
49
|
+
children,
|
|
50
|
+
...props
|
|
51
|
+
}) {
|
|
52
|
+
const strings = useSignalStrings();
|
|
53
|
+
const remove = removeLabel ?? strings.tag.remove;
|
|
54
|
+
return /* @__PURE__ */ jsxs("span", { ...props, "data-tone": tone, className: cx("signal-tag", className), children: [
|
|
55
|
+
icon,
|
|
56
|
+
/* @__PURE__ */ jsx("span", { children }),
|
|
57
|
+
onRemove && /* @__PURE__ */ jsx(
|
|
58
|
+
"button",
|
|
59
|
+
{
|
|
60
|
+
type: "button",
|
|
61
|
+
className: "signal-tag-remove",
|
|
62
|
+
"aria-label": `${remove}: ${typeof children === "string" ? children : ""}`.trim(),
|
|
63
|
+
onClick: onRemove,
|
|
64
|
+
children: /* @__PURE__ */ jsx(X, { "aria-hidden": "true" })
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
] });
|
|
68
|
+
}
|
|
69
|
+
function StatusDot({
|
|
70
|
+
tone = "neutral",
|
|
71
|
+
label,
|
|
72
|
+
pulse = false,
|
|
73
|
+
className,
|
|
74
|
+
...props
|
|
75
|
+
}) {
|
|
76
|
+
return /* @__PURE__ */ jsx(
|
|
77
|
+
"span",
|
|
78
|
+
{
|
|
79
|
+
...props,
|
|
80
|
+
role: "img",
|
|
81
|
+
"aria-label": label,
|
|
82
|
+
"data-tone": tone,
|
|
83
|
+
"data-pulse": pulse || void 0,
|
|
84
|
+
className: cx("signal-status-dot", className)
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
var relative = (date, now, locale) => {
|
|
89
|
+
const seconds = Math.round((date.getTime() - now.getTime()) / 1e3);
|
|
90
|
+
const units = [
|
|
91
|
+
["year", 31536e3],
|
|
92
|
+
["month", 2592e3],
|
|
93
|
+
["week", 604800],
|
|
94
|
+
["day", 86400],
|
|
95
|
+
["hour", 3600],
|
|
96
|
+
["minute", 60]
|
|
97
|
+
];
|
|
98
|
+
const format = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
|
|
99
|
+
for (const [unit, size] of units)
|
|
100
|
+
if (Math.abs(seconds) >= size)
|
|
101
|
+
return format.format(Math.round(seconds / size), unit);
|
|
102
|
+
return format.format(seconds, "second");
|
|
103
|
+
};
|
|
104
|
+
function Time({
|
|
105
|
+
value,
|
|
106
|
+
format = "datetime",
|
|
107
|
+
timeZone,
|
|
108
|
+
now,
|
|
109
|
+
className,
|
|
110
|
+
...props
|
|
111
|
+
}) {
|
|
112
|
+
const locale = useSignalLocale();
|
|
113
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
114
|
+
if (Number.isNaN(date.getTime()))
|
|
115
|
+
return /* @__PURE__ */ jsx("time", { ...props, className: cx("signal-time", className), children: "\u2014" });
|
|
116
|
+
const exact = date.toLocaleString(locale, {
|
|
117
|
+
dateStyle: "long",
|
|
118
|
+
timeStyle: "long",
|
|
119
|
+
timeZone
|
|
120
|
+
});
|
|
121
|
+
const text = format === "relative" ? relative(date, now ?? /* @__PURE__ */ new Date(), locale) : format === "utc" ? date.toISOString().replace("T", " ").slice(0, 19) + " UTC" : date.toLocaleString(locale, {
|
|
122
|
+
dateStyle: format === "time" ? void 0 : "medium",
|
|
123
|
+
timeStyle: format === "date" ? void 0 : "short",
|
|
124
|
+
timeZone
|
|
125
|
+
});
|
|
126
|
+
return /* @__PURE__ */ jsx(
|
|
127
|
+
"time",
|
|
128
|
+
{
|
|
129
|
+
...props,
|
|
130
|
+
dateTime: date.toISOString(),
|
|
131
|
+
title: exact,
|
|
132
|
+
className: cx("signal-time", className),
|
|
133
|
+
"data-format": format,
|
|
134
|
+
suppressHydrationWarning: format === "relative",
|
|
135
|
+
children: text
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
var icons = {
|
|
140
|
+
neutral: Info,
|
|
141
|
+
accent: Info,
|
|
142
|
+
success: CircleCheck,
|
|
143
|
+
warning: TriangleAlert,
|
|
144
|
+
danger: CircleAlert
|
|
145
|
+
};
|
|
146
|
+
function Banner({
|
|
147
|
+
tone = "neutral",
|
|
148
|
+
title,
|
|
149
|
+
action,
|
|
150
|
+
onDismiss,
|
|
151
|
+
dismissLabel,
|
|
152
|
+
className,
|
|
153
|
+
children,
|
|
154
|
+
...props
|
|
155
|
+
}) {
|
|
156
|
+
const strings = useSignalStrings();
|
|
157
|
+
const Icon = icons[tone];
|
|
158
|
+
return /* @__PURE__ */ jsxs(
|
|
159
|
+
"div",
|
|
160
|
+
{
|
|
161
|
+
...props,
|
|
162
|
+
role: tone === "danger" ? "alert" : "status",
|
|
163
|
+
"data-tone": tone,
|
|
164
|
+
className: cx("signal-banner", className),
|
|
165
|
+
children: [
|
|
166
|
+
/* @__PURE__ */ jsx(Icon, { className: "signal-banner-icon", "aria-hidden": "true" }),
|
|
167
|
+
/* @__PURE__ */ jsxs("div", { className: "signal-banner-text", children: [
|
|
168
|
+
title && /* @__PURE__ */ jsx("strong", { children: title }),
|
|
169
|
+
children && /* @__PURE__ */ jsx("span", { children })
|
|
170
|
+
] }),
|
|
171
|
+
action && /* @__PURE__ */ jsx("div", { className: "signal-banner-action", children: action }),
|
|
172
|
+
onDismiss && /* @__PURE__ */ jsx(
|
|
173
|
+
Button,
|
|
174
|
+
{
|
|
175
|
+
variant: "ghost",
|
|
176
|
+
iconOnly: true,
|
|
177
|
+
"aria-label": dismissLabel ?? strings.banner.dismiss,
|
|
178
|
+
onClick: onDismiss,
|
|
179
|
+
children: /* @__PURE__ */ jsx(X, {})
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
function Callout({
|
|
187
|
+
tone = "neutral",
|
|
188
|
+
title,
|
|
189
|
+
className,
|
|
190
|
+
children,
|
|
191
|
+
...props
|
|
192
|
+
}) {
|
|
193
|
+
return /* @__PURE__ */ jsxs("aside", { ...props, "data-tone": tone, className: cx("signal-callout", className), children: [
|
|
194
|
+
title && /* @__PURE__ */ jsx("strong", { children: title }),
|
|
195
|
+
/* @__PURE__ */ jsx("div", { children })
|
|
196
|
+
] });
|
|
197
|
+
}
|
|
198
|
+
function SkeletonRows({
|
|
199
|
+
rows = 3,
|
|
200
|
+
label,
|
|
201
|
+
avatar = false
|
|
202
|
+
}) {
|
|
203
|
+
const strings = useSignalStrings();
|
|
204
|
+
return /* @__PURE__ */ jsx(
|
|
205
|
+
"div",
|
|
206
|
+
{
|
|
207
|
+
className: "signal-skeleton-rows",
|
|
208
|
+
role: "status",
|
|
209
|
+
"aria-label": label ?? strings.loading.label,
|
|
210
|
+
children: Array.from({ length: Math.max(1, Math.min(rows, 20)) }, (_, i) => /* @__PURE__ */ jsxs("div", { "aria-hidden": "true", children: [
|
|
211
|
+
avatar && /* @__PURE__ */ jsx("i", { className: "signal-skeleton-avatar" }),
|
|
212
|
+
/* @__PURE__ */ jsx("span", { className: "signal-skeleton-line", style: { width: `${62 + i * 17 % 30}%` } }),
|
|
213
|
+
/* @__PURE__ */ jsx("span", { className: "signal-skeleton-line", "data-short": true })
|
|
214
|
+
] }, i))
|
|
215
|
+
}
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
function SkeletonTable({
|
|
219
|
+
rows = 5,
|
|
220
|
+
columns = 4,
|
|
221
|
+
label
|
|
222
|
+
}) {
|
|
223
|
+
const strings = useSignalStrings();
|
|
224
|
+
const cols = Math.max(1, Math.min(columns, 8));
|
|
225
|
+
return /* @__PURE__ */ jsxs(
|
|
226
|
+
"div",
|
|
227
|
+
{
|
|
228
|
+
className: "signal-skeleton-table",
|
|
229
|
+
role: "status",
|
|
230
|
+
"aria-label": label ?? strings.loading.table,
|
|
231
|
+
children: [
|
|
232
|
+
/* @__PURE__ */ jsx("div", { "aria-hidden": "true", "data-head": true, children: Array.from({ length: cols }, (_, c) => /* @__PURE__ */ jsx("span", { className: "signal-skeleton-line" }, c)) }),
|
|
233
|
+
Array.from({ length: Math.max(1, Math.min(rows, 20)) }, (_, r) => /* @__PURE__ */ jsx("div", { "aria-hidden": "true", children: Array.from({ length: cols }, (_2, c) => /* @__PURE__ */ jsx(
|
|
234
|
+
"span",
|
|
235
|
+
{
|
|
236
|
+
className: "signal-skeleton-line",
|
|
237
|
+
style: { width: `${55 + (r + 1) * (c + 3) * 13 % 40}%` }
|
|
238
|
+
},
|
|
239
|
+
c
|
|
240
|
+
)) }, r))
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
function SkeletonCard({ label }) {
|
|
246
|
+
const strings = useSignalStrings();
|
|
247
|
+
return /* @__PURE__ */ jsxs(
|
|
248
|
+
"div",
|
|
249
|
+
{
|
|
250
|
+
className: "signal-skeleton-card",
|
|
251
|
+
role: "status",
|
|
252
|
+
"aria-label": label ?? strings.loading.label,
|
|
253
|
+
children: [
|
|
254
|
+
/* @__PURE__ */ jsx("div", { "aria-hidden": "true", children: /* @__PURE__ */ jsx("span", { className: "signal-skeleton-line", style: { width: "40%" } }) }),
|
|
255
|
+
/* @__PURE__ */ jsxs("div", { "aria-hidden": "true", children: [
|
|
256
|
+
/* @__PURE__ */ jsx("span", { className: "signal-skeleton-block" }),
|
|
257
|
+
/* @__PURE__ */ jsx("span", { className: "signal-skeleton-line" }),
|
|
258
|
+
/* @__PURE__ */ jsx("span", { className: "signal-skeleton-line", style: { width: "70%" } })
|
|
259
|
+
] })
|
|
260
|
+
]
|
|
261
|
+
}
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export {
|
|
266
|
+
Link,
|
|
267
|
+
Tag,
|
|
268
|
+
StatusDot,
|
|
269
|
+
Time,
|
|
270
|
+
Banner,
|
|
271
|
+
Callout,
|
|
272
|
+
SkeletonRows,
|
|
273
|
+
SkeletonTable,
|
|
274
|
+
SkeletonCard
|
|
275
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// packages/ui/src/network-layout.ts
|
|
4
|
+
function linkSpeedTier(mbps) {
|
|
5
|
+
if (mbps <= 100) return 0;
|
|
6
|
+
if (mbps <= 1e3) return 1;
|
|
7
|
+
if (mbps < 1e4) return 2;
|
|
8
|
+
if (mbps < 25e3) return 3;
|
|
9
|
+
return 4;
|
|
10
|
+
}
|
|
11
|
+
function formatLinkSpeed(mbps) {
|
|
12
|
+
if (!(mbps > 0)) return "";
|
|
13
|
+
return mbps >= 1e3 ? `${+(mbps / 1e3).toFixed(1)}G` : `${Math.round(mbps)}M`;
|
|
14
|
+
}
|
|
15
|
+
function formatBitRate(bitsPerSecond) {
|
|
16
|
+
const b = Number.isFinite(bitsPerSecond) ? bitsPerSecond : 0;
|
|
17
|
+
if (b < 1) return "0";
|
|
18
|
+
const [v, unit] = b >= 1e9 ? [b / 1e9, "G"] : b >= 1e6 ? [b / 1e6, "M"] : b >= 1e3 ? [b / 1e3, "k"] : [b, ""];
|
|
19
|
+
return `${v >= 100 ? Math.round(v) : +v.toFixed(1)}${unit}`;
|
|
20
|
+
}
|
|
21
|
+
function portLabel(port) {
|
|
22
|
+
if (port.label) return port.label;
|
|
23
|
+
const i = port.name.lastIndexOf("/");
|
|
24
|
+
return i >= 0 ? port.name.slice(i + 1) : port.name;
|
|
25
|
+
}
|
|
26
|
+
function faceplateGrid(block) {
|
|
27
|
+
const rows = Math.max(1, Math.min(4, Math.floor(block.rows ?? 1) || 1));
|
|
28
|
+
const cols = Math.max(1, Math.ceil(block.ports.length / rows));
|
|
29
|
+
const cells = block.ports.map(
|
|
30
|
+
(_, index) => block.order === "column" ? { row: index % rows, col: Math.floor(index / rows), index } : { row: Math.floor(index / cols), col: index % cols, index }
|
|
31
|
+
);
|
|
32
|
+
return { rows, cols, cells };
|
|
33
|
+
}
|
|
34
|
+
var mapGeometry = {
|
|
35
|
+
/** Node radius, and a stacked leaf's. */
|
|
36
|
+
radius: 18,
|
|
37
|
+
leafRadius: 13,
|
|
38
|
+
/** A node's own column, and the room for its two lines of text. */
|
|
39
|
+
nodeWidth: 128,
|
|
40
|
+
/** Disc edge to the cable's start ring: clears the second text line by about 6px. */
|
|
41
|
+
labelHeight: 42,
|
|
42
|
+
/** Icon top to the next level's icon top. */
|
|
43
|
+
level: 124,
|
|
44
|
+
gap: 16,
|
|
45
|
+
/** Stacked leaf pitch and the width of a stack. */
|
|
46
|
+
row: 38,
|
|
47
|
+
stackWidth: 214,
|
|
48
|
+
/** This many leaves under one parent stack into a list. */
|
|
49
|
+
stackFrom: 3,
|
|
50
|
+
margin: 24
|
|
51
|
+
};
|
|
52
|
+
var kids = (n) => n.children ?? [];
|
|
53
|
+
function layoutNetworkMap(roots) {
|
|
54
|
+
const g = mapGeometry;
|
|
55
|
+
const seen = /* @__PURE__ */ new Set();
|
|
56
|
+
const split = (n) => {
|
|
57
|
+
const children = kids(n).filter((c) => !seen.has(c.id) && (seen.add(c.id), true));
|
|
58
|
+
const leaves = children.filter((c) => kids(c).length === 0);
|
|
59
|
+
return leaves.length < g.stackFrom ? { stack: [], singles: children } : { stack: leaves, singles: children.filter((c) => kids(c).length > 0) };
|
|
60
|
+
};
|
|
61
|
+
const parts = /* @__PURE__ */ new Map();
|
|
62
|
+
const sizes = /* @__PURE__ */ new Map();
|
|
63
|
+
const measure = (n) => {
|
|
64
|
+
const hit = sizes.get(n.id);
|
|
65
|
+
if (hit) return hit;
|
|
66
|
+
const part = split(n);
|
|
67
|
+
parts.set(n.id, part);
|
|
68
|
+
const slots = [
|
|
69
|
+
...part.stack.length ? [{ w: g.stackWidth, h: (part.stack.length - 1) * g.row + 2 * g.radius }] : [],
|
|
70
|
+
...part.singles.map(measure)
|
|
71
|
+
];
|
|
72
|
+
const childWidth = slots.reduce((a, s) => a + s.w, 0) + g.gap * Math.max(0, slots.length - 1);
|
|
73
|
+
const size = {
|
|
74
|
+
w: Math.max(g.nodeWidth, childWidth),
|
|
75
|
+
h: slots.length ? g.level + Math.max(...slots.map((s) => s.h)) : 2 * g.radius + g.labelHeight
|
|
76
|
+
};
|
|
77
|
+
sizes.set(n.id, size);
|
|
78
|
+
return size;
|
|
79
|
+
};
|
|
80
|
+
const out = { nodes: [], edges: [], spines: [], joints: [], width: 0, height: 0 };
|
|
81
|
+
const place = (n, x0, y0, parent) => {
|
|
82
|
+
const size = measure(n);
|
|
83
|
+
const me = { node: n, parent, x: x0 + size.w / 2, y: y0 + g.radius, stacked: false };
|
|
84
|
+
out.nodes.push(me);
|
|
85
|
+
const { stack, singles } = parts.get(n.id);
|
|
86
|
+
if (!stack.length && !singles.length) return me;
|
|
87
|
+
const slotsWidth = (stack.length ? g.stackWidth + g.gap : 0) + singles.reduce((a, s) => a + measure(s).w + g.gap, 0) - g.gap;
|
|
88
|
+
let x2 = x0 + (size.w - slotsWidth) / 2;
|
|
89
|
+
const top = y0 + g.level;
|
|
90
|
+
const sx = me.x;
|
|
91
|
+
const sy = me.y + g.radius + g.labelHeight;
|
|
92
|
+
out.joints.push({ x: sx, y: sy });
|
|
93
|
+
const curve = (tx, ty) => {
|
|
94
|
+
const my = (sy + ty) / 2;
|
|
95
|
+
return `M${sx},${sy} C${sx},${my} ${tx},${my} ${tx},${ty}`;
|
|
96
|
+
};
|
|
97
|
+
if (stack.length) {
|
|
98
|
+
const spineX = x2 + 14;
|
|
99
|
+
const last = top + g.radius + (stack.length - 1) * g.row;
|
|
100
|
+
out.spines.push(`${curve(spineX, top)} V${last - 8}`);
|
|
101
|
+
stack.forEach((leaf, i) => {
|
|
102
|
+
const cy = top + g.radius + i * g.row;
|
|
103
|
+
const child = { node: leaf, parent: n.id, x: spineX + 30, y: cy, stacked: true };
|
|
104
|
+
out.nodes.push(child);
|
|
105
|
+
out.edges.push({
|
|
106
|
+
child,
|
|
107
|
+
d: `M${spineX},${cy - 8} Q${spineX},${cy} ${spineX + 8},${cy} H${child.x - g.leafRadius}`,
|
|
108
|
+
labelX: child.x + g.leafRadius + 8,
|
|
109
|
+
labelY: cy + 12,
|
|
110
|
+
stacked: true
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
x2 += g.stackWidth + g.gap;
|
|
114
|
+
}
|
|
115
|
+
for (const s of singles) {
|
|
116
|
+
const w = measure(s).w;
|
|
117
|
+
const child = place(s, x2, top, n.id);
|
|
118
|
+
out.edges.push({
|
|
119
|
+
child,
|
|
120
|
+
d: curve(child.x, child.y - g.radius),
|
|
121
|
+
labelX: child.x + 6,
|
|
122
|
+
labelY: child.y - g.radius - 8,
|
|
123
|
+
stacked: false
|
|
124
|
+
});
|
|
125
|
+
x2 += w + g.gap;
|
|
126
|
+
}
|
|
127
|
+
return me;
|
|
128
|
+
};
|
|
129
|
+
let x = g.margin;
|
|
130
|
+
let h = 0;
|
|
131
|
+
for (const root of roots) {
|
|
132
|
+
if (seen.has(root.id)) continue;
|
|
133
|
+
seen.add(root.id);
|
|
134
|
+
const size = measure(root);
|
|
135
|
+
place(root, x, g.margin);
|
|
136
|
+
x += size.w + g.gap * 3;
|
|
137
|
+
h = Math.max(h, size.h);
|
|
138
|
+
}
|
|
139
|
+
out.width = roots.length ? x - g.gap * 3 + g.margin : 2 * g.margin;
|
|
140
|
+
out.height = h + g.margin * 2;
|
|
141
|
+
return out;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export {
|
|
145
|
+
linkSpeedTier,
|
|
146
|
+
formatLinkSpeed,
|
|
147
|
+
formatBitRate,
|
|
148
|
+
portLabel,
|
|
149
|
+
faceplateGrid,
|
|
150
|
+
mapGeometry,
|
|
151
|
+
layoutNetworkMap
|
|
152
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// packages/ui/src/power-layout.ts
|
|
4
|
+
var powerGeometry = {
|
|
5
|
+
margin: 24,
|
|
6
|
+
sourceWidth: 236,
|
|
7
|
+
sourceHeight: 64,
|
|
8
|
+
/** Source bottom to the bus, and the bus to a circuit's top. */
|
|
9
|
+
bus: 34,
|
|
10
|
+
drop: 26,
|
|
11
|
+
cardWidth: 212,
|
|
12
|
+
cardHeight: 92,
|
|
13
|
+
columnGap: 28,
|
|
14
|
+
/** A load's disc radius, one level's indent, the load pitch and the first load's offset. */
|
|
15
|
+
radius: 13,
|
|
16
|
+
indent: 30,
|
|
17
|
+
row: 44,
|
|
18
|
+
first: 32,
|
|
19
|
+
textWidth: 158
|
|
20
|
+
};
|
|
21
|
+
function circuitState(c) {
|
|
22
|
+
const limit = c.limit !== void 0 && c.limit > 0 && c.limit <= 1 ? c.limit : 0.8;
|
|
23
|
+
const capacity = c.capacity > 0 ? c.capacity : 0;
|
|
24
|
+
const watts = Number.isFinite(c.watts) ? Math.max(0, c.watts) : 0;
|
|
25
|
+
const tone = capacity && watts > capacity ? "danger" : capacity && watts > capacity * limit ? "warning" : void 0;
|
|
26
|
+
return { tone, free: capacity * limit - watts, used: capacity ? watts / capacity : 0, limit };
|
|
27
|
+
}
|
|
28
|
+
function powerFlow(watts) {
|
|
29
|
+
if (!(watts > 0.5)) return null;
|
|
30
|
+
const amps = watts / 120;
|
|
31
|
+
const width = amps < 1 ? 1.5 : amps < 4 ? 2.25 : amps < 10 ? 3 : amps < 16 ? 3.75 : 4.5;
|
|
32
|
+
const speed = 10 + 10 * Math.min(amps, 40);
|
|
33
|
+
return { width, seconds: +(12 / speed).toFixed(3) };
|
|
34
|
+
}
|
|
35
|
+
var sum = (ls) => ls.reduce((a, l) => a + (l.watts ?? 0), 0);
|
|
36
|
+
var known = (ls) => ls.some((l) => l.watts !== void 0 && l.watts !== null);
|
|
37
|
+
function layoutPowerMap(circuits) {
|
|
38
|
+
const g = powerGeometry;
|
|
39
|
+
const depthOf = (ls) => ls.length ? 1 + Math.max(...ls.map((l) => depthOf(l.children ?? []))) : 0;
|
|
40
|
+
const cols = circuits.map(
|
|
41
|
+
(c) => Math.max(g.cardWidth, 20 + g.indent * Math.max(1, depthOf(c.loads)) + g.radius + 8 + g.textWidth)
|
|
42
|
+
);
|
|
43
|
+
const inner = cols.reduce((a, w) => a + w, 0) + g.columnGap * Math.max(0, cols.length - 1);
|
|
44
|
+
const width = Math.max(inner, g.sourceWidth) + 2 * g.margin;
|
|
45
|
+
const rootX = width / 2;
|
|
46
|
+
const busY = g.margin + g.sourceHeight + g.bus;
|
|
47
|
+
const cardY = busY + g.drop;
|
|
48
|
+
const out = {
|
|
49
|
+
source: { x: rootX - g.sourceWidth / 2, y: g.margin },
|
|
50
|
+
circuits: [],
|
|
51
|
+
loads: [],
|
|
52
|
+
wires: [],
|
|
53
|
+
joints: [],
|
|
54
|
+
width,
|
|
55
|
+
height: 0
|
|
56
|
+
};
|
|
57
|
+
let bottom = cardY + g.cardHeight;
|
|
58
|
+
const hang = (loads, parent, sx, sy, y, depth, c, tone) => {
|
|
59
|
+
let prev = sy;
|
|
60
|
+
loads.forEach((l, i) => {
|
|
61
|
+
const rest = loads.slice(i);
|
|
62
|
+
out.wires.push({ d: `M${sx},${prev} V${y - 8}`, watts: known(rest) ? sum(rest) : null, tone });
|
|
63
|
+
const x2 = sx + g.indent;
|
|
64
|
+
out.wires.push({
|
|
65
|
+
d: `M${sx},${y - 8} Q${sx},${y} ${sx + 8},${y} H${x2 - g.radius}`,
|
|
66
|
+
watts: l.watts ?? null,
|
|
67
|
+
tone
|
|
68
|
+
});
|
|
69
|
+
out.loads.push({ load: l, parent, circuit: c.id, x: x2, y, depth });
|
|
70
|
+
bottom = Math.max(bottom, y + g.radius + 6);
|
|
71
|
+
prev = y - 8;
|
|
72
|
+
y = l.children?.length ? hang(l.children, l.id, x2, y + g.radius, y + g.row, depth + 1, c, tone) : y + g.row;
|
|
73
|
+
});
|
|
74
|
+
return y;
|
|
75
|
+
};
|
|
76
|
+
let x = g.margin + (width - 2 * g.margin - inner) / 2;
|
|
77
|
+
const centres = [];
|
|
78
|
+
circuits.forEach((c, i) => {
|
|
79
|
+
const cx = x + cols[i] / 2;
|
|
80
|
+
const tone = circuitState(c).tone;
|
|
81
|
+
out.circuits.push({ circuit: c, x: cx - g.cardWidth / 2, y: cardY });
|
|
82
|
+
out.wires.push({ d: `M${cx},${busY} V${cardY}`, watts: c.watts, tone });
|
|
83
|
+
out.joints.push({ x: cx, y: busY });
|
|
84
|
+
centres.push({ x: cx, watts: c.watts, tone });
|
|
85
|
+
hang(c.loads, c.id, cx - g.cardWidth / 2 + 20, cardY + g.cardHeight, cardY + g.cardHeight + g.first, 0, c, tone);
|
|
86
|
+
x += cols[i] + g.columnGap;
|
|
87
|
+
});
|
|
88
|
+
if (circuits.length)
|
|
89
|
+
out.wires.push({
|
|
90
|
+
d: `M${rootX},${g.margin + g.sourceHeight} V${busY}`,
|
|
91
|
+
watts: circuits.reduce((a, c) => a + c.watts, 0)
|
|
92
|
+
});
|
|
93
|
+
for (const side of [-1, 1]) {
|
|
94
|
+
const run = centres.filter((p) => (p.x - rootX) * side > 0.5).sort((a, b) => (a.x - b.x) * side);
|
|
95
|
+
let from = rootX;
|
|
96
|
+
run.forEach((p, i) => {
|
|
97
|
+
out.wires.push({ d: `M${from},${busY} H${p.x}`, watts: run.slice(i).reduce((a, q) => a + q.watts, 0) });
|
|
98
|
+
from = p.x;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
out.height = bottom + g.margin;
|
|
102
|
+
return out;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export {
|
|
106
|
+
powerGeometry,
|
|
107
|
+
circuitState,
|
|
108
|
+
powerFlow,
|
|
109
|
+
layoutPowerMap
|
|
110
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import {
|
|
3
|
+
layoutGitGraph
|
|
4
|
+
} from "./chunk-YKFAA7GU.js";
|
|
5
|
+
import {
|
|
6
|
+
Badge,
|
|
7
|
+
Button
|
|
8
|
+
} from "./chunk-EBF2F3LN.js";
|
|
9
|
+
import {
|
|
10
|
+
useSignalStrings
|
|
11
|
+
} from "./chunk-U5W7O3QV.js";
|
|
12
|
+
|
|
13
|
+
// packages/ui/src/git-graph.tsx
|
|
14
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
var laneColor = (lane) => [
|
|
16
|
+
"var(--signal-brand)",
|
|
17
|
+
"var(--signal-success)",
|
|
18
|
+
"var(--signal-warning)",
|
|
19
|
+
"var(--signal-danger)"
|
|
20
|
+
][lane % 4];
|
|
21
|
+
function GitGraph({
|
|
22
|
+
commits,
|
|
23
|
+
label,
|
|
24
|
+
selected,
|
|
25
|
+
onSelect
|
|
26
|
+
}) {
|
|
27
|
+
const strings = useSignalStrings();
|
|
28
|
+
const { rows, edges, laneCount } = layoutGitGraph(commits), width = laneCount * 22 + 12;
|
|
29
|
+
if (!commits.length)
|
|
30
|
+
return /* @__PURE__ */ jsx("p", { className: "signal-muted", children: strings.git.empty });
|
|
31
|
+
return /* @__PURE__ */ jsxs("figure", { className: "signal-git-graph", children: [
|
|
32
|
+
/* @__PURE__ */ jsx("figcaption", { children: label ?? strings.git.label }),
|
|
33
|
+
/* @__PURE__ */ jsx("div", { className: "signal-git-scroll", children: /* @__PURE__ */ jsxs(
|
|
34
|
+
"div",
|
|
35
|
+
{
|
|
36
|
+
className: "signal-git-layout",
|
|
37
|
+
style: { gridTemplateColumns: `${width}px minmax(0, 1fr)` },
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ jsxs(
|
|
40
|
+
"svg",
|
|
41
|
+
{
|
|
42
|
+
width,
|
|
43
|
+
height: commits.length * 58,
|
|
44
|
+
viewBox: `0 0 ${width} ${commits.length * 58}`,
|
|
45
|
+
"aria-hidden": "true",
|
|
46
|
+
children: [
|
|
47
|
+
edges.map((edge, i) => /* @__PURE__ */ jsx(
|
|
48
|
+
"path",
|
|
49
|
+
{
|
|
50
|
+
d: `M ${edge.fromLane * 22 + 17} ${edge.fromRow * 58} L ${edge.toLane * 22 + 17} ${edge.toRow * 58}`,
|
|
51
|
+
stroke: laneColor(edge.toLane),
|
|
52
|
+
strokeWidth: "2",
|
|
53
|
+
strokeDasharray: edge.dashed ? "4 3" : void 0,
|
|
54
|
+
fill: "none"
|
|
55
|
+
},
|
|
56
|
+
i
|
|
57
|
+
)),
|
|
58
|
+
rows.map((row, i) => /* @__PURE__ */ jsx(
|
|
59
|
+
"circle",
|
|
60
|
+
{
|
|
61
|
+
cx: row.lane * 22 + 17,
|
|
62
|
+
cy: (i + 0.5) * 58,
|
|
63
|
+
r: "4",
|
|
64
|
+
fill: "var(--signal-surface)",
|
|
65
|
+
stroke: laneColor(row.lane),
|
|
66
|
+
strokeWidth: "2"
|
|
67
|
+
},
|
|
68
|
+
row.id
|
|
69
|
+
))
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
),
|
|
73
|
+
/* @__PURE__ */ jsx("ol", { children: commits.map((commit) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
|
|
74
|
+
Button,
|
|
75
|
+
{
|
|
76
|
+
className: "signal-git-commit",
|
|
77
|
+
"aria-pressed": selected === commit.id,
|
|
78
|
+
onClick: () => onSelect?.(commit),
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ jsxs("span", { className: "signal-git-subject", children: [
|
|
81
|
+
commit.refs?.map((ref) => /* @__PURE__ */ jsx(Badge, { tone: "accent", children: ref }, ref)),
|
|
82
|
+
/* @__PURE__ */ jsx("strong", { children: commit.subject })
|
|
83
|
+
] }),
|
|
84
|
+
/* @__PURE__ */ jsxs("span", { className: "signal-git-meta", children: [
|
|
85
|
+
/* @__PURE__ */ jsx("code", { children: commit.id.slice(0, 8) }),
|
|
86
|
+
commit.author && /* @__PURE__ */ jsx("span", { children: commit.author }),
|
|
87
|
+
commit.time && /* @__PURE__ */ jsx("span", { children: commit.time })
|
|
88
|
+
] }),
|
|
89
|
+
/* @__PURE__ */ jsx("span", { className: "signal-sr-only", children: commit.parents.length ? strings.git.parents(
|
|
90
|
+
commit.parents.map((id) => id.slice(0, 8)).join(", ")
|
|
91
|
+
) : strings.git.root })
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
) }, commit.id)) })
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
) }),
|
|
98
|
+
/* @__PURE__ */ jsx("p", { className: "signal-git-hint", children: strings.git.hint })
|
|
99
|
+
] });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export {
|
|
103
|
+
GitGraph
|
|
104
|
+
};
|