@praxical/ui 0.0.0-stage → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +23 -2
  3. package/dist/activity-calendar.d.ts +13 -0
  4. package/dist/activity-calendar.js +7 -0
  5. package/dist/activity-heatmap.d.ts +14 -0
  6. package/dist/activity-heatmap.js +13 -0
  7. package/dist/chart-data.d.ts +9 -0
  8. package/dist/chart-data.js +9 -0
  9. package/dist/charts.d.ts +56 -0
  10. package/dist/charts.js +424 -0
  11. package/dist/chunk-7RMPDKZV.js +541 -0
  12. package/dist/chunk-7RTW3X7C.js +142 -0
  13. package/dist/chunk-EBF2F3LN.js +1523 -0
  14. package/dist/chunk-FCYIZANU.js +385 -0
  15. package/dist/chunk-HMO4VQZN.js +58 -0
  16. package/dist/chunk-II677WPC.js +177 -0
  17. package/dist/chunk-KZHUBPY6.js +102 -0
  18. package/dist/chunk-OLGZOPLD.js +166 -0
  19. package/dist/chunk-PDSV773E.js +52 -0
  20. package/dist/chunk-Q4ARHP76.js +457 -0
  21. package/dist/chunk-U5W7O3QV.js +22 -0
  22. package/dist/chunk-V6MXR4P2.js +275 -0
  23. package/dist/chunk-VZZDLRM5.js +152 -0
  24. package/dist/chunk-WEM2UQPR.js +110 -0
  25. package/dist/chunk-XFNDEA5M.js +104 -0
  26. package/dist/chunk-YKFAA7GU.js +72 -0
  27. package/dist/code-value.d.ts +13 -0
  28. package/dist/code-value.js +10 -0
  29. package/dist/code.d.ts +36 -0
  30. package/dist/code.js +198 -0
  31. package/dist/collection.d.ts +21 -0
  32. package/dist/collection.js +48 -0
  33. package/dist/content.d.ts +42 -0
  34. package/dist/content.js +122 -0
  35. package/dist/display.d.ts +58 -0
  36. package/dist/display.js +27 -0
  37. package/dist/feedback.d.ts +34 -0
  38. package/dist/feedback.js +184 -0
  39. package/dist/file-tree.d.ts +17 -0
  40. package/dist/file-tree.js +11 -0
  41. package/dist/forms.d.ts +69 -0
  42. package/dist/forms.js +273 -0
  43. package/dist/git-graph.d.ts +8 -0
  44. package/dist/git-graph.js +15 -0
  45. package/dist/git-layout.d.ts +24 -0
  46. package/dist/git-layout.js +7 -0
  47. package/dist/image-viewer.d.ts +18 -0
  48. package/dist/image-viewer.js +11 -0
  49. package/dist/index.d.ts +363 -0
  50. package/dist/index.js +98 -0
  51. package/dist/inputs.d.ts +112 -0
  52. package/dist/inputs.js +938 -0
  53. package/dist/layout.d.ts +56 -0
  54. package/dist/layout.js +180 -0
  55. package/dist/map-frame.d.ts +37 -0
  56. package/dist/map-frame.js +13 -0
  57. package/dist/media.d.ts +40 -0
  58. package/dist/media.js +19 -0
  59. package/dist/network-layout.d.ts +94 -0
  60. package/dist/network-layout.js +19 -0
  61. package/dist/network.d.ts +111 -0
  62. package/dist/network.js +354 -0
  63. package/dist/overlays.d.ts +95 -0
  64. package/dist/overlays.js +25 -0
  65. package/dist/patterns.d.ts +117 -0
  66. package/dist/patterns.js +387 -0
  67. package/dist/power-layout.d.ts +91 -0
  68. package/dist/power-layout.js +13 -0
  69. package/dist/power.d.ts +91 -0
  70. package/dist/power.js +353 -0
  71. package/dist/signal-context.d.ts +11 -0
  72. package/dist/signal-context.js +15 -0
  73. package/dist/strings-es-419.d.ts +13 -0
  74. package/dist/strings-es-419.js +357 -0
  75. package/dist/strings-fr.d.ts +15 -0
  76. package/dist/strings-fr.js +359 -0
  77. package/dist/strings-ja.d.ts +16 -0
  78. package/dist/strings-ja.js +357 -0
  79. package/dist/strings-pt-BR.d.ts +13 -0
  80. package/dist/strings-pt-BR.js +357 -0
  81. package/dist/strings.d.ts +394 -0
  82. package/dist/strings.js +15 -0
  83. package/dist/styles.css +2 -0
  84. package/dist/tab-bar.d.ts +20 -0
  85. package/dist/tab-bar.js +114 -0
  86. package/package.json +154 -3
package/dist/power.js ADDED
@@ -0,0 +1,353 @@
1
+ 'use client';
2
+ "use client";
3
+ import {
4
+ circuitState,
5
+ layoutPowerMap,
6
+ powerFlow,
7
+ powerGeometry
8
+ } from "./chunk-WEM2UQPR.js";
9
+ import {
10
+ MapFrame,
11
+ clip
12
+ } from "./chunk-II677WPC.js";
13
+ import {
14
+ Button
15
+ } from "./chunk-EBF2F3LN.js";
16
+ import {
17
+ useSignalLocale,
18
+ useSignalStrings
19
+ } from "./chunk-U5W7O3QV.js";
20
+ import "./chunk-FCYIZANU.js";
21
+
22
+ // packages/ui/src/power.tsx
23
+ import {
24
+ cloneElement,
25
+ useMemo,
26
+ useState
27
+ } from "react";
28
+ import { AlertTriangle, Plug, Zap } from "lucide-react";
29
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
30
+ var cx = (...names) => names.filter(Boolean).join(" ");
31
+ var SOURCE = "source";
32
+ var circuitKey = (id) => `circuit:${id}`;
33
+ var loadKey = (id) => `load:${id}`;
34
+ function useFormat() {
35
+ const strings = useSignalStrings().power;
36
+ const locale = useSignalLocale();
37
+ const number = (v, digits) => new Intl.NumberFormat(locale, { maximumFractionDigits: digits }).format(v);
38
+ const power = (w) => Math.abs(w) >= 1e3 ? strings.kilowatts(number(w / 1e3, Math.abs(w) >= 1e4 ? 1 : 2)) : strings.watts(number(w, 0));
39
+ const amps = (a) => strings.amps(number(a, a < 10 ? 1 : 0));
40
+ const percent = (v) => new Intl.NumberFormat(locale, { style: "percent" }).format(v);
41
+ const value = (watts, basis) => watts === void 0 || watts === null ? strings.unknown : basis === "estimated" ? strings.estimated(power(watts)) : basis === "partial" ? strings.partial(power(watts)) : power(watts);
42
+ return { strings, power, amps, percent, value };
43
+ }
44
+ function PowerMap({
45
+ source = {},
46
+ circuits,
47
+ label,
48
+ onCircuitSelect,
49
+ onLoadSelect,
50
+ animated = false,
51
+ legend = true,
52
+ className,
53
+ ...props
54
+ }) {
55
+ const f = useFormat();
56
+ const s = f.strings;
57
+ const [running, setRunning] = useState(animated);
58
+ const L = useMemo(() => layoutPowerMap(circuits), [circuits]);
59
+ const items = useMemo(
60
+ () => [
61
+ { id: SOURCE },
62
+ ...L.circuits.flatMap(({ circuit: c }) => [
63
+ { id: circuitKey(c.id), parent: SOURCE },
64
+ ...L.loads.filter((l) => l.circuit === c.id).map((l) => ({ id: loadKey(l.load.id), parent: l.depth ? loadKey(l.parent) : circuitKey(c.id) }))
65
+ ])
66
+ ],
67
+ [L]
68
+ );
69
+ if (!circuits.length) return /* @__PURE__ */ jsx("p", { className: "signal-muted", children: s.empty });
70
+ const total = source.watts ?? circuits.reduce((a, c) => a + c.watts, 0);
71
+ return /* @__PURE__ */ jsx("div", { ...props, className: cx("signal-power-map", className), "data-animated": running || void 0, children: /* @__PURE__ */ jsx(
72
+ MapFrame,
73
+ {
74
+ className: "signal-power-frame",
75
+ label: label ?? s.map,
76
+ hint: s.mapHint,
77
+ width: L.width,
78
+ height: L.height,
79
+ items,
80
+ tools: animated && /* @__PURE__ */ jsx(Button, { variant: "ghost", iconOnly: true, "aria-label": s.animate, tooltip: true, "aria-pressed": running, onClick: () => setRunning(!running), children: /* @__PURE__ */ jsx(Zap, { "aria-hidden": "true" }) }),
81
+ after: legend && /* @__PURE__ */ jsx(PowerMapLegend, {}),
82
+ children: (frame) => /* @__PURE__ */ jsxs(Fragment, { children: [
83
+ /* @__PURE__ */ jsxs("g", { "aria-hidden": "true", children: [
84
+ L.wires.map((w, i) => /* @__PURE__ */ jsx(Wire, { wire: w }, i)),
85
+ L.joints.map((j, i) => /* @__PURE__ */ jsx("circle", { cx: j.x, cy: j.y, r: 3, className: "signal-power-joint" }, i))
86
+ ] }),
87
+ /* @__PURE__ */ jsx(
88
+ Source,
89
+ {
90
+ x: L.source.x,
91
+ y: L.source.y,
92
+ label: source.label ?? s.source,
93
+ value: f.power(total),
94
+ sub: source.description ?? (source.capacity ? s.share(f.percent(total / source.capacity), f.power(source.capacity)) : s.circuits(circuits.length)),
95
+ frame,
96
+ tooltip: source.tooltip
97
+ }
98
+ ),
99
+ L.circuits.map(({ circuit: c, x, y }) => /* @__PURE__ */ jsx(Card, { c, x, y, frame, onSelect: onCircuitSelect }, c.id)),
100
+ L.loads.map(({ load: l, x, y }) => /* @__PURE__ */ jsx(LoadNode, { l, x, y, frame, onSelect: onLoadSelect }, l.id))
101
+ ] })
102
+ }
103
+ ) });
104
+ }
105
+ function Wire({ wire }) {
106
+ const flow = wire.watts === null ? null : powerFlow(wire.watts);
107
+ return /* @__PURE__ */ jsxs(
108
+ "g",
109
+ {
110
+ className: "signal-power-wire",
111
+ "data-tone": wire.tone,
112
+ "data-idle": !flow || void 0,
113
+ "data-unknown": wire.watts === null || void 0,
114
+ children: [
115
+ flow && /* @__PURE__ */ jsx("path", { d: wire.d, className: "signal-power-glow", style: { strokeWidth: flow.width + 6 } }),
116
+ /* @__PURE__ */ jsx("path", { d: wire.d, className: "signal-power-core", style: flow ? { strokeWidth: flow.width } : void 0 }),
117
+ flow && /* @__PURE__ */ jsx(
118
+ "path",
119
+ {
120
+ d: wire.d,
121
+ className: "signal-power-current",
122
+ style: { strokeWidth: flow.width, animationDuration: `${flow.seconds}s` }
123
+ }
124
+ )
125
+ ]
126
+ }
127
+ );
128
+ }
129
+ function Item({
130
+ frame,
131
+ id,
132
+ tip,
133
+ said,
134
+ href,
135
+ onSelect,
136
+ className,
137
+ attrs,
138
+ children
139
+ }) {
140
+ const common = {
141
+ ...frame.item(id, tip),
142
+ ...attrs,
143
+ className,
144
+ "data-action": href || onSelect ? "" : void 0,
145
+ "aria-label": said
146
+ };
147
+ return href ? /* @__PURE__ */ jsx("a", { ...common, href, children }) : /* @__PURE__ */ jsx(
148
+ "g",
149
+ {
150
+ ...common,
151
+ role: onSelect ? "button" : "img",
152
+ onClick: onSelect,
153
+ onKeyDown: (e) => {
154
+ if (onSelect && (e.key === "Enter" || e.key === " ")) {
155
+ e.preventDefault();
156
+ onSelect();
157
+ }
158
+ },
159
+ children
160
+ }
161
+ );
162
+ }
163
+ var Tip = ({ title, lines, extra }) => /* @__PURE__ */ jsxs("span", { className: "signal-network-tip", children: [
164
+ /* @__PURE__ */ jsx("strong", { children: title }),
165
+ lines.filter(Boolean).map((l) => /* @__PURE__ */ jsx("span", { children: l }, l)),
166
+ extra
167
+ ] });
168
+ function Source({
169
+ x,
170
+ y,
171
+ label,
172
+ value,
173
+ sub,
174
+ frame,
175
+ tooltip
176
+ }) {
177
+ const g = powerGeometry;
178
+ const cy = y + g.sourceHeight / 2;
179
+ return /* @__PURE__ */ jsxs(
180
+ Item,
181
+ {
182
+ frame,
183
+ id: SOURCE,
184
+ className: "signal-power-source",
185
+ said: [label, value, sub].join(", "),
186
+ tip: /* @__PURE__ */ jsx(Tip, { title: label, lines: [value, sub], extra: tooltip }),
187
+ children: [
188
+ /* @__PURE__ */ jsx("rect", { x, y, width: g.sourceWidth, height: g.sourceHeight, rx: 6, className: "signal-power-card" }),
189
+ /* @__PURE__ */ jsx("circle", { cx: x + 32, cy, r: 18, className: "signal-power-bolt-disc" }),
190
+ /* @__PURE__ */ jsx(Zap, { x: x + 22, y: cy - 10, width: 20, height: 20, className: "signal-power-bolt", "aria-hidden": "true" }),
191
+ /* @__PURE__ */ jsx("text", { x: x + 60, y: y + 22, className: "signal-network-sub", children: clip(label, 22) }),
192
+ /* @__PURE__ */ jsx("text", { x: x + 60, y: y + 42, className: "signal-power-big", children: value }),
193
+ /* @__PURE__ */ jsx("text", { x: x + 60, y: y + 56, className: "signal-network-sub", children: clip(sub, 24) })
194
+ ]
195
+ }
196
+ );
197
+ }
198
+ function Card({
199
+ c,
200
+ x,
201
+ y,
202
+ frame,
203
+ onSelect
204
+ }) {
205
+ const f = useFormat();
206
+ const s = f.strings;
207
+ const g = powerGeometry;
208
+ const state = circuitState(c);
209
+ const over = state.free < 0;
210
+ const track = g.cardWidth - 24;
211
+ const fill = Math.max(0, Math.min(1, state.used)) * track;
212
+ const badge = c.badge ? Math.max(22, 8 + 7 * c.badge.length) : 0;
213
+ const load = [f.value(c.watts, c.basis), c.volts ? f.amps(c.watts / c.volts) : ""].filter(Boolean).join(" \xB7 ");
214
+ const free = over ? s.over(f.power(-state.free)) : s.free(f.power(state.free));
215
+ const status = state.tone === "danger" ? s.overRating : state.tone === "warning" ? s.overLimit(f.percent(state.limit)) : "";
216
+ const lines = [
217
+ c.description,
218
+ load,
219
+ c.capacity > 0 ? s.share(f.percent(state.used), f.power(c.capacity)) : "",
220
+ free,
221
+ status,
222
+ c.alert && s.alert
223
+ ];
224
+ return /* @__PURE__ */ jsxs(
225
+ Item,
226
+ {
227
+ frame,
228
+ id: circuitKey(c.id),
229
+ className: "signal-power-circuit",
230
+ attrs: { "data-tone": state.tone },
231
+ said: [c.label, c.badge, ...lines].filter(Boolean).join(", "),
232
+ tip: /* @__PURE__ */ jsx(Tip, { title: c.badge ? `${c.badge} \xB7 ${c.label}` : c.label, lines, extra: c.tooltip }),
233
+ href: c.href,
234
+ onSelect: onSelect && !c.href ? () => onSelect(c) : void 0,
235
+ children: [
236
+ /* @__PURE__ */ jsx("rect", { x, y, width: g.cardWidth, height: g.cardHeight, rx: 4, className: "signal-power-card" }),
237
+ c.badge && /* @__PURE__ */ jsxs(Fragment, { children: [
238
+ /* @__PURE__ */ jsx("rect", { x: x + 12, y: y + 9, width: badge, height: 18, rx: 2, className: "signal-power-badge" }),
239
+ /* @__PURE__ */ jsx("text", { x: x + 12 + badge / 2, y: y + 22, textAnchor: "middle", className: "signal-power-badge-text", children: c.badge })
240
+ ] }),
241
+ /* @__PURE__ */ jsx("text", { x: x + (c.badge ? 20 + badge : 12), y: y + 22, className: "signal-network-name", children: clip(c.label, c.badge ? 20 : 24) }),
242
+ (state.tone || c.alert) && /* @__PURE__ */ jsx(
243
+ AlertTriangle,
244
+ {
245
+ x: x + g.cardWidth - 27,
246
+ y: y + 9,
247
+ width: 15,
248
+ height: 15,
249
+ className: "signal-power-alert",
250
+ "aria-hidden": "true"
251
+ }
252
+ ),
253
+ c.description && /* @__PURE__ */ jsx("text", { x: x + 12, y: y + 41, className: "signal-network-sub", children: clip(c.description, 28) }),
254
+ /* @__PURE__ */ jsx("rect", { x: x + 12, y: y + 50, width: track, height: 8, rx: 1, className: "signal-power-track" }),
255
+ fill > 0 && /* @__PURE__ */ jsx("rect", { x: x + 12, y: y + 50, width: Math.max(4, fill), height: 8, rx: 1, className: "signal-power-fill" }),
256
+ /* @__PURE__ */ jsx(
257
+ "line",
258
+ {
259
+ x1: x + 12 + track * state.limit,
260
+ x2: x + 12 + track * state.limit,
261
+ y1: y + 46,
262
+ y2: y + 62,
263
+ className: "signal-power-limit"
264
+ }
265
+ ),
266
+ /* @__PURE__ */ jsx("text", { x: x + 12, y: y + 79, className: "signal-power-load", "data-basis": c.basis, children: load }),
267
+ /* @__PURE__ */ jsx("text", { x: x + g.cardWidth - 12, y: y + 79, textAnchor: "end", className: "signal-power-free", "data-over": over || void 0, children: free })
268
+ ]
269
+ }
270
+ );
271
+ }
272
+ function LoadNode({
273
+ l,
274
+ x,
275
+ y,
276
+ frame,
277
+ onSelect
278
+ }) {
279
+ const f = useFormat();
280
+ const r = powerGeometry.radius;
281
+ const note = l.description ?? f.value(l.watts, l.basis);
282
+ return /* @__PURE__ */ jsxs(
283
+ Item,
284
+ {
285
+ frame,
286
+ id: loadKey(l.id),
287
+ className: "signal-network-node signal-power-load-node",
288
+ said: [l.label, note, l.status?.label].filter(Boolean).join(", "),
289
+ tip: /* @__PURE__ */ jsx(Tip, { title: l.label, lines: [note, l.status?.label], extra: l.tooltip }),
290
+ href: l.href,
291
+ onSelect: onSelect && !l.href ? () => onSelect(l) : void 0,
292
+ children: [
293
+ /* @__PURE__ */ jsx("circle", { cx: x, cy: y, r, className: "signal-network-disc" }),
294
+ cloneElement(l.icon ?? /* @__PURE__ */ jsx(Plug, {}), {
295
+ x: x - 7,
296
+ y: y - 7,
297
+ width: 14,
298
+ height: 14,
299
+ className: "signal-network-icon",
300
+ "aria-hidden": true
301
+ }),
302
+ l.status && /* @__PURE__ */ jsx("circle", { cx: x + r * 0.72, cy: y + r * 0.72, r: 3.5, className: "signal-network-status", "data-tone": l.status.tone }),
303
+ /* @__PURE__ */ jsx("text", { x: x + r + 8, y: y - 1, className: "signal-network-name", children: clip(l.label, 22) }),
304
+ /* @__PURE__ */ jsx(
305
+ "text",
306
+ {
307
+ x: x + r + 8,
308
+ y: y + 12,
309
+ className: "signal-power-draw",
310
+ "data-basis": l.watts === void 0 || l.watts === null ? "unknown" : l.basis,
311
+ children: clip(note, 26)
312
+ }
313
+ )
314
+ ]
315
+ }
316
+ );
317
+ }
318
+ function PowerMapLegend({ className, ...props }) {
319
+ const f = useFormat();
320
+ const s = f.strings;
321
+ const wire = (label, watts, tone) => /* @__PURE__ */ jsxs("li", { children: [
322
+ /* @__PURE__ */ jsx("svg", { width: "34", height: "12", "aria-hidden": "true", children: /* @__PURE__ */ jsx(Wire, { wire: { d: "M3,6 H31", watts, tone } }) }),
323
+ label
324
+ ] }, label);
325
+ return /* @__PURE__ */ jsxs("ul", { ...props, className: cx("signal-network-legend", className), "aria-label": s.mapLegend, children: [
326
+ wire(s.current, 900),
327
+ wire(s.overLimitKey, 900, "warning"),
328
+ wire(s.overRating, 900, "danger"),
329
+ wire(s.nothing, null),
330
+ /* @__PURE__ */ jsxs("li", { children: [
331
+ /* @__PURE__ */ jsx("span", { className: "signal-network-speed-key", children: f.power(266) }),
332
+ " ",
333
+ s.measured,
334
+ ",",
335
+ " ",
336
+ /* @__PURE__ */ jsx("span", { className: "signal-network-speed-key", "data-declared": "", children: f.value(60, "estimated") }),
337
+ " ",
338
+ s.estimatedKey,
339
+ ", ",
340
+ /* @__PURE__ */ jsx("span", { className: "signal-network-speed-key", children: f.value(99, "partial") }),
341
+ " ",
342
+ s.partialKey
343
+ ] })
344
+ ] });
345
+ }
346
+ export {
347
+ PowerMap,
348
+ PowerMapLegend,
349
+ circuitState,
350
+ layoutPowerMap,
351
+ powerFlow,
352
+ powerGeometry
353
+ };
@@ -0,0 +1,11 @@
1
+ import { type SignalStrings } from "./strings.js";
2
+ /** Locale and strings live here, not in the component entry point, so a module
3
+ * that only needs to read them (charts, tab bar, activity heatmap) does not
4
+ * pull the whole control library into its chunk. */
5
+ export declare const LocaleContext: import("react").Context<string>;
6
+ export declare const StringsContext: import("react").Context<SignalStrings>;
7
+ /** The BCP 47 tag set on the nearest `SignalProvider`; everything the library
8
+ * formats with `Intl` uses it. */
9
+ export declare function useSignalLocale(): string;
10
+ /** The merged strings table of the nearest `SignalProvider`. */
11
+ export declare function useSignalStrings(): SignalStrings;
@@ -0,0 +1,15 @@
1
+ 'use client';
2
+ "use client";
3
+ import {
4
+ LocaleContext,
5
+ StringsContext,
6
+ useSignalLocale,
7
+ useSignalStrings
8
+ } from "./chunk-U5W7O3QV.js";
9
+ import "./chunk-FCYIZANU.js";
10
+ export {
11
+ LocaleContext,
12
+ StringsContext,
13
+ useSignalLocale,
14
+ useSignalStrings
15
+ };
@@ -0,0 +1,13 @@
1
+ /** Spanish (Latin America) strings for Signal.
2
+ *
3
+ * Machine first-pass translation (Claude, September 2026), not yet reviewed
4
+ * by a native speaker. Report or correct wording in this file; the English
5
+ * table in `strings.ts` is the source.
6
+ *
7
+ * import { SignalProvider } from "@praxical/ui";
8
+ * import { strings } from "@praxical/ui/strings/es-419";
9
+ * <SignalProvider locale="es-419" strings={strings}>…</SignalProvider>
10
+ */
11
+ import type { SignalStrings } from "./strings.js";
12
+ export declare const strings: SignalStrings;
13
+ export default strings;