@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
package/dist/patterns.js
ADDED
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use client";
|
|
3
|
+
import {
|
|
4
|
+
AudioPlayer
|
|
5
|
+
} from "./chunk-Q4ARHP76.js";
|
|
6
|
+
import {
|
|
7
|
+
EmojiPicker
|
|
8
|
+
} from "./chunk-7RMPDKZV.js";
|
|
9
|
+
import "./chunk-OLGZOPLD.js";
|
|
10
|
+
import {
|
|
11
|
+
Button,
|
|
12
|
+
ServiceRow
|
|
13
|
+
} from "./chunk-EBF2F3LN.js";
|
|
14
|
+
import {
|
|
15
|
+
useSignalStrings
|
|
16
|
+
} from "./chunk-U5W7O3QV.js";
|
|
17
|
+
import "./chunk-FCYIZANU.js";
|
|
18
|
+
|
|
19
|
+
// packages/ui/src/patterns.tsx
|
|
20
|
+
import {
|
|
21
|
+
File,
|
|
22
|
+
ChevronLeft,
|
|
23
|
+
ChevronRight,
|
|
24
|
+
Check,
|
|
25
|
+
CheckCheck,
|
|
26
|
+
Clock,
|
|
27
|
+
CircleAlert
|
|
28
|
+
} from "lucide-react";
|
|
29
|
+
import { Avatar as BaseAvatar } from "@base-ui/react/avatar";
|
|
30
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
31
|
+
function Avatar({
|
|
32
|
+
name,
|
|
33
|
+
src,
|
|
34
|
+
size = "normal",
|
|
35
|
+
decorative = false
|
|
36
|
+
}) {
|
|
37
|
+
return /* @__PURE__ */ jsxs(
|
|
38
|
+
BaseAvatar.Root,
|
|
39
|
+
{
|
|
40
|
+
className: "signal-avatar",
|
|
41
|
+
"data-size": size,
|
|
42
|
+
"aria-label": decorative ? void 0 : name,
|
|
43
|
+
"aria-hidden": decorative || void 0,
|
|
44
|
+
role: decorative ? void 0 : "img",
|
|
45
|
+
children: [
|
|
46
|
+
/* @__PURE__ */ jsx(BaseAvatar.Image, { src, alt: decorative ? "" : name }),
|
|
47
|
+
/* @__PURE__ */ jsx(BaseAvatar.Fallback, { children: name.trim().split(/\s+/).slice(0, 2).map((n) => n[0]).join("") })
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
function Breadcrumbs({
|
|
53
|
+
children,
|
|
54
|
+
label
|
|
55
|
+
}) {
|
|
56
|
+
const strings = useSignalStrings();
|
|
57
|
+
return /* @__PURE__ */ jsx(
|
|
58
|
+
"nav",
|
|
59
|
+
{
|
|
60
|
+
className: "signal-breadcrumbs",
|
|
61
|
+
"aria-label": label ?? strings.breadcrumbs.label,
|
|
62
|
+
children
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
function NavItem({
|
|
67
|
+
icon,
|
|
68
|
+
children,
|
|
69
|
+
current,
|
|
70
|
+
...props
|
|
71
|
+
}) {
|
|
72
|
+
return /* @__PURE__ */ jsxs(
|
|
73
|
+
"a",
|
|
74
|
+
{
|
|
75
|
+
...props,
|
|
76
|
+
className: "signal-nav-item",
|
|
77
|
+
"aria-current": current ? "page" : void 0,
|
|
78
|
+
children: [
|
|
79
|
+
icon,
|
|
80
|
+
/* @__PURE__ */ jsx("span", { children })
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
function Pagination({
|
|
86
|
+
page,
|
|
87
|
+
pageCount,
|
|
88
|
+
onPageChange,
|
|
89
|
+
label
|
|
90
|
+
}) {
|
|
91
|
+
const strings = useSignalStrings();
|
|
92
|
+
const count = Number.isFinite(pageCount) ? Math.max(0, Math.floor(pageCount)) : 0;
|
|
93
|
+
const current = Math.max(
|
|
94
|
+
1,
|
|
95
|
+
Math.min(count || 1, Number.isFinite(page) ? Math.floor(page) : 1)
|
|
96
|
+
);
|
|
97
|
+
const pages = [
|
|
98
|
+
...new Set(
|
|
99
|
+
[1, current - 1, current, current + 1, count].filter(
|
|
100
|
+
(p) => p > 0 && p <= count
|
|
101
|
+
)
|
|
102
|
+
)
|
|
103
|
+
].sort((a, b) => a - b);
|
|
104
|
+
return /* @__PURE__ */ jsxs(
|
|
105
|
+
"nav",
|
|
106
|
+
{
|
|
107
|
+
className: "signal-pagination",
|
|
108
|
+
"aria-label": label ?? strings.pagination.label,
|
|
109
|
+
children: [
|
|
110
|
+
/* @__PURE__ */ jsx(
|
|
111
|
+
Button,
|
|
112
|
+
{
|
|
113
|
+
"aria-label": strings.pagination.previous,
|
|
114
|
+
disabled: current <= 1 || !count,
|
|
115
|
+
onClick: () => onPageChange(current - 1),
|
|
116
|
+
iconOnly: true,
|
|
117
|
+
children: /* @__PURE__ */ jsx(ChevronLeft, {})
|
|
118
|
+
}
|
|
119
|
+
),
|
|
120
|
+
/* @__PURE__ */ jsx("div", { className: "signal-pagination-pages", children: pages.map((p, i) => /* @__PURE__ */ jsxs("span", { children: [
|
|
121
|
+
i > 0 && p > pages[i - 1] + 1 && /* @__PURE__ */ jsx("span", { className: "signal-pagination-gap", "aria-hidden": "true", children: "\u2026" }),
|
|
122
|
+
/* @__PURE__ */ jsx(
|
|
123
|
+
Button,
|
|
124
|
+
{
|
|
125
|
+
"aria-label": strings.pagination.page(p),
|
|
126
|
+
"aria-current": p === current ? "page" : void 0,
|
|
127
|
+
variant: p === current ? "primary" : "ghost",
|
|
128
|
+
onClick: () => onPageChange(p),
|
|
129
|
+
children: p
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
] }, p)) }),
|
|
133
|
+
/* @__PURE__ */ jsx(
|
|
134
|
+
Button,
|
|
135
|
+
{
|
|
136
|
+
"aria-label": strings.pagination.next,
|
|
137
|
+
disabled: current >= count,
|
|
138
|
+
onClick: () => onPageChange(current + 1),
|
|
139
|
+
iconOnly: true,
|
|
140
|
+
children: /* @__PURE__ */ jsx(ChevronRight, {})
|
|
141
|
+
}
|
|
142
|
+
),
|
|
143
|
+
/* @__PURE__ */ jsx("span", { className: "signal-pagination-summary", "aria-live": "polite", children: count ? strings.pagination.summary(current, count) : strings.pagination.none })
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
function KeyValue({
|
|
149
|
+
items,
|
|
150
|
+
divided = false
|
|
151
|
+
}) {
|
|
152
|
+
return /* @__PURE__ */ jsx("dl", { className: "signal-key-value", "data-divided": divided || void 0, children: items.map((item) => /* @__PURE__ */ jsxs("div", { children: [
|
|
153
|
+
/* @__PURE__ */ jsx("dt", { children: item.label }),
|
|
154
|
+
/* @__PURE__ */ jsx("dd", { children: item.value })
|
|
155
|
+
] }, item.label)) });
|
|
156
|
+
}
|
|
157
|
+
function Timeline({
|
|
158
|
+
label,
|
|
159
|
+
items
|
|
160
|
+
}) {
|
|
161
|
+
return /* @__PURE__ */ jsx("ol", { className: "signal-timeline", "aria-label": label, children: items.map((item) => /* @__PURE__ */ jsxs("li", { children: [
|
|
162
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true" }),
|
|
163
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
164
|
+
/* @__PURE__ */ jsx("strong", { children: item.title }),
|
|
165
|
+
item.detail && /* @__PURE__ */ jsx("p", { children: item.detail }),
|
|
166
|
+
/* @__PURE__ */ jsx("time", { dateTime: item.dateTime, children: item.time })
|
|
167
|
+
] })
|
|
168
|
+
] }, item.id)) });
|
|
169
|
+
}
|
|
170
|
+
function Message({
|
|
171
|
+
author,
|
|
172
|
+
avatar,
|
|
173
|
+
children,
|
|
174
|
+
time,
|
|
175
|
+
dateTime,
|
|
176
|
+
actions,
|
|
177
|
+
mode = "inline",
|
|
178
|
+
direction = "incoming",
|
|
179
|
+
delivery,
|
|
180
|
+
tags,
|
|
181
|
+
media,
|
|
182
|
+
reactions = [],
|
|
183
|
+
onReaction,
|
|
184
|
+
onAddReaction,
|
|
185
|
+
reactionOptions
|
|
186
|
+
}) {
|
|
187
|
+
const strings = useSignalStrings();
|
|
188
|
+
const DeliveryIcon = delivery === "sending" ? Clock : delivery === "failed" ? CircleAlert : delivery === "sent" ? Check : CheckCheck;
|
|
189
|
+
return /* @__PURE__ */ jsxs(
|
|
190
|
+
"article",
|
|
191
|
+
{
|
|
192
|
+
className: "signal-message",
|
|
193
|
+
"data-mode": mode,
|
|
194
|
+
"data-direction": direction,
|
|
195
|
+
children: [
|
|
196
|
+
/* @__PURE__ */ jsx("div", { className: "signal-message-avatar", children: avatar ?? /* @__PURE__ */ jsx(Avatar, { name: author }) }),
|
|
197
|
+
/* @__PURE__ */ jsxs("div", { className: "signal-message-content", children: [
|
|
198
|
+
/* @__PURE__ */ jsxs("header", { children: [
|
|
199
|
+
/* @__PURE__ */ jsx("strong", { children: author }),
|
|
200
|
+
tags && /* @__PURE__ */ jsx("span", { className: "signal-message-tags", children: tags })
|
|
201
|
+
] }),
|
|
202
|
+
/* @__PURE__ */ jsxs("div", { className: "signal-message-body", children: [
|
|
203
|
+
children,
|
|
204
|
+
media && /* @__PURE__ */ jsx("div", { className: "signal-message-media", children: media })
|
|
205
|
+
] }),
|
|
206
|
+
/* @__PURE__ */ jsxs("footer", { className: "signal-message-meta", children: [
|
|
207
|
+
/* @__PURE__ */ jsx("time", { dateTime, children: time }),
|
|
208
|
+
delivery && /* @__PURE__ */ jsxs("span", { className: "signal-message-delivery", "data-delivery": delivery, children: [
|
|
209
|
+
/* @__PURE__ */ jsx(DeliveryIcon, { "aria-hidden": "true" }),
|
|
210
|
+
strings.message.delivery[delivery]
|
|
211
|
+
] })
|
|
212
|
+
] }),
|
|
213
|
+
(reactions.length > 0 || onAddReaction) && /* @__PURE__ */ jsxs(
|
|
214
|
+
"div",
|
|
215
|
+
{
|
|
216
|
+
className: "signal-reactions",
|
|
217
|
+
"aria-label": strings.message.reactions(author),
|
|
218
|
+
children: [
|
|
219
|
+
reactions.map(
|
|
220
|
+
(reaction) => onReaction ? /* @__PURE__ */ jsxs(
|
|
221
|
+
Button,
|
|
222
|
+
{
|
|
223
|
+
className: "signal-reaction",
|
|
224
|
+
"aria-pressed": !!reaction.selected,
|
|
225
|
+
"aria-label": strings.message.reaction(
|
|
226
|
+
reaction.label,
|
|
227
|
+
reaction.count,
|
|
228
|
+
!!reaction.selected
|
|
229
|
+
),
|
|
230
|
+
onClick: () => onReaction(reaction),
|
|
231
|
+
children: [
|
|
232
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: reaction.emoji }),
|
|
233
|
+
/* @__PURE__ */ jsx("span", { children: reaction.count })
|
|
234
|
+
]
|
|
235
|
+
},
|
|
236
|
+
reaction.id
|
|
237
|
+
) : /* @__PURE__ */ jsxs(
|
|
238
|
+
"span",
|
|
239
|
+
{
|
|
240
|
+
className: "signal-reaction",
|
|
241
|
+
"aria-label": strings.message.reaction(
|
|
242
|
+
reaction.label,
|
|
243
|
+
reaction.count,
|
|
244
|
+
false
|
|
245
|
+
),
|
|
246
|
+
children: [
|
|
247
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: reaction.emoji }),
|
|
248
|
+
" ",
|
|
249
|
+
reaction.count
|
|
250
|
+
]
|
|
251
|
+
},
|
|
252
|
+
reaction.id
|
|
253
|
+
)
|
|
254
|
+
),
|
|
255
|
+
onAddReaction && /* @__PURE__ */ jsx(EmojiPicker, { onSelect: onAddReaction, items: reactionOptions })
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
),
|
|
259
|
+
actions && /* @__PURE__ */ jsx("div", { className: "signal-message-actions", children: actions })
|
|
260
|
+
] })
|
|
261
|
+
]
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
function Conversation({
|
|
266
|
+
label,
|
|
267
|
+
children,
|
|
268
|
+
live = "off"
|
|
269
|
+
}) {
|
|
270
|
+
return /* @__PURE__ */ jsx(
|
|
271
|
+
"div",
|
|
272
|
+
{
|
|
273
|
+
className: "signal-conversation",
|
|
274
|
+
role: "log",
|
|
275
|
+
"aria-label": label,
|
|
276
|
+
"aria-live": live,
|
|
277
|
+
"aria-relevant": "additions text",
|
|
278
|
+
children
|
|
279
|
+
}
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
function MediaAttachment(props) {
|
|
283
|
+
const strings = useSignalStrings();
|
|
284
|
+
if (props.kind === "file")
|
|
285
|
+
return /* @__PURE__ */ jsx("div", { className: "signal-media", children: /* @__PURE__ */ jsx(
|
|
286
|
+
FileRow,
|
|
287
|
+
{
|
|
288
|
+
name: props.name,
|
|
289
|
+
detail: props.detail,
|
|
290
|
+
action: props.action
|
|
291
|
+
}
|
|
292
|
+
) });
|
|
293
|
+
if (props.kind === "image") {
|
|
294
|
+
const picture = /* @__PURE__ */ jsx("img", { src: props.src, alt: props.alt, loading: "lazy" });
|
|
295
|
+
return /* @__PURE__ */ jsxs("figure", { className: "signal-media", children: [
|
|
296
|
+
props.onOpen ? /* @__PURE__ */ jsx(
|
|
297
|
+
Button,
|
|
298
|
+
{
|
|
299
|
+
className: "signal-media-open",
|
|
300
|
+
"aria-label": strings.message.openImage(props.alt),
|
|
301
|
+
onClick: props.onOpen,
|
|
302
|
+
children: picture
|
|
303
|
+
}
|
|
304
|
+
) : picture,
|
|
305
|
+
props.caption && /* @__PURE__ */ jsx("figcaption", { children: props.caption })
|
|
306
|
+
] });
|
|
307
|
+
}
|
|
308
|
+
if (props.kind === "audio") return /* @__PURE__ */ jsx(AudioPlayer, { ...props });
|
|
309
|
+
return /* @__PURE__ */ jsxs("figure", { className: "signal-media", children: [
|
|
310
|
+
/* @__PURE__ */ jsx(
|
|
311
|
+
"video",
|
|
312
|
+
{
|
|
313
|
+
controls: true,
|
|
314
|
+
preload: "metadata",
|
|
315
|
+
src: props.src,
|
|
316
|
+
poster: props.poster,
|
|
317
|
+
"aria-label": props.label,
|
|
318
|
+
children: props.captions && /* @__PURE__ */ jsx(
|
|
319
|
+
"track",
|
|
320
|
+
{
|
|
321
|
+
kind: "captions",
|
|
322
|
+
src: props.captions.src,
|
|
323
|
+
srcLang: props.captions.language,
|
|
324
|
+
label: props.captions.label,
|
|
325
|
+
default: true
|
|
326
|
+
}
|
|
327
|
+
)
|
|
328
|
+
}
|
|
329
|
+
),
|
|
330
|
+
/* @__PURE__ */ jsx("figcaption", { children: props.label })
|
|
331
|
+
] });
|
|
332
|
+
}
|
|
333
|
+
function FileRow({
|
|
334
|
+
name,
|
|
335
|
+
detail,
|
|
336
|
+
icon,
|
|
337
|
+
action
|
|
338
|
+
}) {
|
|
339
|
+
return /* @__PURE__ */ jsx(
|
|
340
|
+
ServiceRow,
|
|
341
|
+
{
|
|
342
|
+
icon: icon ?? /* @__PURE__ */ jsx(File, {}),
|
|
343
|
+
title: name,
|
|
344
|
+
description: detail,
|
|
345
|
+
action
|
|
346
|
+
}
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
function CodeBlock({
|
|
350
|
+
label,
|
|
351
|
+
children
|
|
352
|
+
}) {
|
|
353
|
+
return /* @__PURE__ */ jsx("pre", { className: "signal-code", tabIndex: 0, "aria-label": label, children: /* @__PURE__ */ jsx("code", { children }) });
|
|
354
|
+
}
|
|
355
|
+
function Skeleton({
|
|
356
|
+
label,
|
|
357
|
+
rows = 3
|
|
358
|
+
}) {
|
|
359
|
+
const strings = useSignalStrings();
|
|
360
|
+
return /* @__PURE__ */ jsx(
|
|
361
|
+
"div",
|
|
362
|
+
{
|
|
363
|
+
className: "signal-skeleton",
|
|
364
|
+
role: "status",
|
|
365
|
+
"aria-label": label ?? strings.loading.label,
|
|
366
|
+
children: Array.from({ length: Math.max(1, Math.min(rows, 20)) }, (_, i) => /* @__PURE__ */ jsx("span", { "aria-hidden": "true" }, i))
|
|
367
|
+
}
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
function Separator() {
|
|
371
|
+
return /* @__PURE__ */ jsx("hr", { className: "signal-separator" });
|
|
372
|
+
}
|
|
373
|
+
export {
|
|
374
|
+
Avatar,
|
|
375
|
+
Breadcrumbs,
|
|
376
|
+
CodeBlock,
|
|
377
|
+
Conversation,
|
|
378
|
+
FileRow,
|
|
379
|
+
KeyValue,
|
|
380
|
+
MediaAttachment,
|
|
381
|
+
Message,
|
|
382
|
+
NavItem,
|
|
383
|
+
Pagination,
|
|
384
|
+
Separator,
|
|
385
|
+
Skeleton,
|
|
386
|
+
Timeline
|
|
387
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
interface Load {
|
|
2
|
+
id: string;
|
|
3
|
+
watts?: number | null;
|
|
4
|
+
children?: readonly Load[];
|
|
5
|
+
}
|
|
6
|
+
interface Circuit {
|
|
7
|
+
id: string;
|
|
8
|
+
watts: number;
|
|
9
|
+
capacity: number;
|
|
10
|
+
limit?: number;
|
|
11
|
+
loads: readonly Load[];
|
|
12
|
+
}
|
|
13
|
+
/** The map's geometry in SVG units, 1:1 with CSS pixels at 100%. */
|
|
14
|
+
export declare const powerGeometry: {
|
|
15
|
+
readonly margin: 24;
|
|
16
|
+
readonly sourceWidth: 236;
|
|
17
|
+
readonly sourceHeight: 64;
|
|
18
|
+
/** Source bottom to the bus, and the bus to a circuit's top. */
|
|
19
|
+
readonly bus: 34;
|
|
20
|
+
readonly drop: 26;
|
|
21
|
+
readonly cardWidth: 212;
|
|
22
|
+
readonly cardHeight: 92;
|
|
23
|
+
readonly columnGap: 28;
|
|
24
|
+
/** A load's disc radius, one level's indent, the load pitch and the first load's offset. */
|
|
25
|
+
readonly radius: 13;
|
|
26
|
+
readonly indent: 30;
|
|
27
|
+
readonly row: 44;
|
|
28
|
+
readonly first: 32;
|
|
29
|
+
readonly textWidth: 158;
|
|
30
|
+
};
|
|
31
|
+
/** Where a circuit stands against its limit (a share of its rating, 0.8 by default) and its rating. */
|
|
32
|
+
export declare function circuitState(c: {
|
|
33
|
+
watts: number;
|
|
34
|
+
capacity: number;
|
|
35
|
+
limit?: number;
|
|
36
|
+
}): {
|
|
37
|
+
tone?: "warning" | "danger";
|
|
38
|
+
/** Watts left under the limit; negative when over it. */
|
|
39
|
+
free: number;
|
|
40
|
+
/** Load as a share of the rating. */
|
|
41
|
+
used: number;
|
|
42
|
+
limit: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* How a wire draws the current through it: wider for more power, and its
|
|
46
|
+
* dashes move faster when animated. The scale is the same at every voltage.
|
|
47
|
+
* Null when nothing flows.
|
|
48
|
+
*/
|
|
49
|
+
export declare function powerFlow(watts: number): {
|
|
50
|
+
width: number;
|
|
51
|
+
seconds: number;
|
|
52
|
+
} | null;
|
|
53
|
+
export interface PowerWire {
|
|
54
|
+
d: string;
|
|
55
|
+
/** What flows through it; null when nothing below is measured or estimated. */
|
|
56
|
+
watts: number | null;
|
|
57
|
+
/** The circuit it belongs to is over its limit or rating. */
|
|
58
|
+
tone?: "warning" | "danger";
|
|
59
|
+
}
|
|
60
|
+
export interface PowerPlacedLoad<L> {
|
|
61
|
+
load: L;
|
|
62
|
+
/** The circuit or load it is plugged into. */
|
|
63
|
+
parent: string;
|
|
64
|
+
circuit: string;
|
|
65
|
+
x: number;
|
|
66
|
+
y: number;
|
|
67
|
+
depth: number;
|
|
68
|
+
}
|
|
69
|
+
export interface PowerPlacedCircuit<C> {
|
|
70
|
+
circuit: C;
|
|
71
|
+
x: number;
|
|
72
|
+
y: number;
|
|
73
|
+
}
|
|
74
|
+
export interface PowerLayout<C, L> {
|
|
75
|
+
source: {
|
|
76
|
+
x: number;
|
|
77
|
+
y: number;
|
|
78
|
+
};
|
|
79
|
+
circuits: PowerPlacedCircuit<C>[];
|
|
80
|
+
/** Loads in reading order: each circuit's tree, parents before children. */
|
|
81
|
+
loads: PowerPlacedLoad<L>[];
|
|
82
|
+
wires: PowerWire[];
|
|
83
|
+
joints: {
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
}[];
|
|
87
|
+
width: number;
|
|
88
|
+
height: number;
|
|
89
|
+
}
|
|
90
|
+
export declare function layoutPowerMap<C extends Circuit>(circuits: readonly C[]): PowerLayout<C, C["loads"][number]>;
|
|
91
|
+
export {};
|
package/dist/power.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactElement, type ReactNode } from "react";
|
|
2
|
+
export { circuitState, layoutPowerMap, powerFlow, powerGeometry, type PowerLayout, type PowerPlacedCircuit, type PowerPlacedLoad, type PowerWire, } from "./power-layout.js";
|
|
3
|
+
type Icon = ReactElement<{
|
|
4
|
+
x?: number;
|
|
5
|
+
y?: number;
|
|
6
|
+
width?: number;
|
|
7
|
+
height?: number;
|
|
8
|
+
className?: string;
|
|
9
|
+
}>;
|
|
10
|
+
/** How sure a number is: a reading, an estimate (italic, "~"), or only a lower bound ("≥"). */
|
|
11
|
+
export type PowerBasis = "measured" | "estimated" | "partial";
|
|
12
|
+
export interface PowerMapLoad {
|
|
13
|
+
/** Unique across the map's loads. */
|
|
14
|
+
id: string;
|
|
15
|
+
label: string;
|
|
16
|
+
/** Watts through this load, including what is plugged into it. Omit when nothing measures or estimates it. */
|
|
17
|
+
watts?: number | null;
|
|
18
|
+
basis?: PowerBasis;
|
|
19
|
+
/** The second line. Defaults to the watts with its basis. */
|
|
20
|
+
description?: string;
|
|
21
|
+
/** A 24-unit icon element that passes x, y, width and height to its svg, such as a lucide-react icon. */
|
|
22
|
+
icon?: Icon;
|
|
23
|
+
status?: {
|
|
24
|
+
tone: "success" | "warning" | "danger" | "neutral";
|
|
25
|
+
label: string;
|
|
26
|
+
};
|
|
27
|
+
/** The load opens this destination. */
|
|
28
|
+
href?: string;
|
|
29
|
+
/** Details shown on hover and focus, after the name. */
|
|
30
|
+
tooltip?: ReactNode;
|
|
31
|
+
/** What is plugged into it, such as a UPS's or power strip's loads. */
|
|
32
|
+
children?: readonly PowerMapLoad[];
|
|
33
|
+
}
|
|
34
|
+
export interface PowerMapCircuit {
|
|
35
|
+
/** Unique across the map's circuits. */
|
|
36
|
+
id: string;
|
|
37
|
+
label: string;
|
|
38
|
+
/** A short tag before the name, such as the breaker's position. */
|
|
39
|
+
badge?: string;
|
|
40
|
+
/** The rating line, such as "120 V · 20 A". */
|
|
41
|
+
description?: string;
|
|
42
|
+
/** Watts on the circuit now. */
|
|
43
|
+
watts: number;
|
|
44
|
+
/** Watts the breaker is rated for. */
|
|
45
|
+
capacity: number;
|
|
46
|
+
/** The continuous limit as a share of the rating. Defaults to 0.8. */
|
|
47
|
+
limit?: number;
|
|
48
|
+
/** Shows the current beside the watts. */
|
|
49
|
+
volts?: number;
|
|
50
|
+
basis?: PowerBasis;
|
|
51
|
+
/** An alert is firing for it, even when it is back under its limit. */
|
|
52
|
+
alert?: boolean;
|
|
53
|
+
/** The card opens this destination. */
|
|
54
|
+
href?: string;
|
|
55
|
+
tooltip?: ReactNode;
|
|
56
|
+
loads: readonly PowerMapLoad[];
|
|
57
|
+
}
|
|
58
|
+
export interface PowerMapSource {
|
|
59
|
+
/** Defaults to "Mains". */
|
|
60
|
+
label?: string;
|
|
61
|
+
/** Watts drawn from it. Defaults to the sum of the circuits. */
|
|
62
|
+
watts?: number;
|
|
63
|
+
/** Watts the service is rated for; shows the share in use. */
|
|
64
|
+
capacity?: number;
|
|
65
|
+
/** The second line. Defaults to the share of the capacity, or the number of circuits. */
|
|
66
|
+
description?: string;
|
|
67
|
+
tooltip?: ReactNode;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Where power goes: the supply on top, one card per circuit with its load
|
|
71
|
+
* against its limit and rating, and what is plugged into each circuit below
|
|
72
|
+
* it. Each wire carries what is downstream of it and widens with it; when
|
|
73
|
+
* `animated`, dashes move along it, faster for more, and the map gains a
|
|
74
|
+
* control to stop them. One tab stop with tree keys.
|
|
75
|
+
*/
|
|
76
|
+
export declare function PowerMap({ source, circuits, label, onCircuitSelect, onLoadSelect, animated, legend, className, ...props }: Omit<ComponentProps<"div">, "children" | "onSelect"> & {
|
|
77
|
+
source?: PowerMapSource;
|
|
78
|
+
circuits: readonly PowerMapCircuit[];
|
|
79
|
+
/** Names the map. Defaults to "Power map". */
|
|
80
|
+
label?: string;
|
|
81
|
+
/** Makes every circuit card without an `href` a button. */
|
|
82
|
+
onCircuitSelect?: (circuit: PowerMapCircuit) => void;
|
|
83
|
+
/** Makes every load without an `href` a button. */
|
|
84
|
+
onLoadSelect?: (load: PowerMapLoad) => void;
|
|
85
|
+
/** Moves the current along the wires; reduced motion keeps it still. A control in the map stops it. */
|
|
86
|
+
animated?: boolean;
|
|
87
|
+
/** Shows the key below the map. */
|
|
88
|
+
legend?: boolean;
|
|
89
|
+
}): import("react").JSX.Element;
|
|
90
|
+
/** What the wires and numbers mean. PowerMap shows it unless `legend={false}`. */
|
|
91
|
+
export declare function PowerMapLegend({ className, ...props }: Omit<ComponentProps<"ul">, "children">): import("react").JSX.Element;
|