@justanarthur/modo-ui-notch 0.2.0 → 0.4.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.
Files changed (148) hide show
  1. package/README.md +11 -11
  2. package/blocks/activities/agenda/examples.mdx +29 -5
  3. package/blocks/activities/agenda/index.tsx +438 -181
  4. package/blocks/activities/clock/examples.mdx +89 -0
  5. package/blocks/activities/clock/index.tsx +917 -0
  6. package/blocks/activities/now-playing/examples.mdx +40 -13
  7. package/blocks/activities/now-playing/index.tsx +399 -120
  8. package/blocks/activities/weather/examples.mdx +123 -0
  9. package/blocks/activities/weather/index.tsx +863 -0
  10. package/blocks/app/expanded-island/examples.mdx +8 -7
  11. package/blocks/app/expanded-island/index.tsx +22 -4
  12. package/blocks/app/settings-window/examples.mdx +14 -2
  13. package/blocks/app/settings-window/index.tsx +33 -10
  14. package/blocks/system/clipboard/examples.mdx +91 -0
  15. package/blocks/system/clipboard/index.tsx +773 -0
  16. package/blocks/system/recent-files/examples.mdx +80 -0
  17. package/blocks/system/recent-files/index.tsx +627 -0
  18. package/blocks/system/system-stats/examples.mdx +46 -9
  19. package/blocks/system/system-stats/index.tsx +445 -104
  20. package/components/indicators/media-scrubber/examples.mdx +8 -0
  21. package/components/indicators/media-scrubber/index.tsx +37 -13
  22. package/components/island/island/examples.mdx +4 -4
  23. package/components/island/island/index.tsx +2 -2
  24. package/components/island/island-flash/examples.mdx +15 -18
  25. package/components/island/island-flash/index.tsx +4 -4
  26. package/components/island/island-tabs/examples.mdx +5 -5
  27. package/components/island/widget/examples.mdx +76 -0
  28. package/components/island/widget/index.tsx +465 -0
  29. package/dist/blocks/activities/agenda/index.d.ts +2 -1
  30. package/dist/blocks/activities/agenda/index.js +3 -3
  31. package/dist/blocks/activities/clock/index.d.ts +3 -0
  32. package/dist/blocks/activities/clock/index.js +25 -0
  33. package/dist/blocks/activities/now-playing/index.d.ts +4 -2
  34. package/dist/blocks/activities/now-playing/index.js +5 -3
  35. package/dist/blocks/activities/weather/index.d.ts +3 -0
  36. package/dist/blocks/activities/weather/index.js +21 -0
  37. package/dist/blocks/app/expanded-island/index.d.ts +1 -1
  38. package/dist/blocks/app/expanded-island/index.js +4 -3
  39. package/dist/blocks/app/settings-window/index.d.ts +1 -1
  40. package/dist/blocks/app/settings-window/index.js +1 -1
  41. package/dist/blocks/system/clipboard/index.d.ts +3 -0
  42. package/dist/blocks/system/clipboard/index.js +17 -0
  43. package/dist/blocks/system/recent-files/index.d.ts +3 -0
  44. package/dist/blocks/system/recent-files/index.js +19 -0
  45. package/dist/blocks/system/system-stats/index.d.ts +3 -2
  46. package/dist/blocks/system/system-stats/index.js +4 -1
  47. package/dist/components/indicators/media-scrubber/index.d.ts +1 -1
  48. package/dist/components/indicators/media-scrubber/index.js +1 -1
  49. package/dist/components/island/island/index.d.ts +1 -1
  50. package/dist/components/island/island/index.js +2 -2
  51. package/dist/components/island/island-flash/index.d.ts +1 -1
  52. package/dist/components/island/island-flash/index.js +1 -1
  53. package/dist/components/island/island-tabs/index.js +2 -2
  54. package/dist/components/island/widget/index.d.ts +2 -0
  55. package/dist/components/island/widget/index.js +32 -0
  56. package/dist/index.d.ts +15 -15
  57. package/dist/index.js +104 -58
  58. package/dist/lib/artwork.d.ts +2 -0
  59. package/dist/lib/artwork.js +8 -0
  60. package/dist/lib/geometry.js +1 -1
  61. package/dist/shared/{chunk-yngkkxz2.d.ts → chunk-0ym9mcqc.d.ts} +10 -6
  62. package/dist/shared/chunk-2b6gpn8k.js +444 -0
  63. package/dist/shared/chunk-3hcnf4yx.js +481 -0
  64. package/dist/shared/chunk-42wab62s.d.ts +197 -0
  65. package/dist/shared/{chunk-zvh0d3qb.js → chunk-61t2dfte.js} +1 -1
  66. package/dist/shared/{chunk-9nhpg9t8.d.ts → chunk-6tnq6p89.d.ts} +9 -1
  67. package/dist/shared/{chunk-hpsabfsd.d.ts → chunk-81fpptwp.d.ts} +1 -1
  68. package/dist/shared/chunk-93dtpjz7.js +789 -0
  69. package/dist/shared/{chunk-wwjxs75m.js → chunk-9xtcv3sy.js} +26 -12
  70. package/dist/shared/chunk-a6njb8db.d.ts +129 -0
  71. package/dist/shared/chunk-ab8mdg0n.d.ts +149 -0
  72. package/dist/shared/chunk-evqpf92s.d.ts +168 -0
  73. package/dist/shared/{chunk-6c1jbefs.d.ts → chunk-fexwzycv.d.ts} +3 -3
  74. package/dist/shared/chunk-gcyspvgr.js +582 -0
  75. package/dist/shared/chunk-gejenfap.d.ts +25 -0
  76. package/dist/shared/chunk-gkj0hjrn.d.ts +136 -0
  77. package/dist/shared/{chunk-rr5e0g15.d.ts → chunk-j755a1a5.d.ts} +7 -1
  78. package/dist/shared/chunk-n739am8j.d.ts +112 -0
  79. package/dist/shared/{chunk-78w7qwp0.js → chunk-ndf79pv5.js} +1 -1
  80. package/dist/shared/chunk-nwzpekvy.js +774 -0
  81. package/dist/shared/{chunk-rpfwv3pz.js → chunk-r471sknr.js} +1 -1
  82. package/dist/shared/chunk-sbrtesdg.d.ts +138 -0
  83. package/dist/shared/chunk-swc7dqpw.d.ts +115 -0
  84. package/dist/shared/chunk-t9wqhgzt.js +765 -0
  85. package/dist/shared/chunk-w5h6ay93.js +72 -0
  86. package/dist/shared/{chunk-mp1nx0ez.js → chunk-wayv5rhr.js} +15 -4
  87. package/dist/shared/chunk-wf0jtzhs.js +295 -0
  88. package/dist/shared/{chunk-sbnrhy5m.js → chunk-y0188bbn.js} +2 -2
  89. package/dist/shared/chunk-yq5svpk7.js +524 -0
  90. package/dist/shared/{chunk-s33y1pcq.js → chunk-z3tj1ydg.js} +23 -10
  91. package/dist/styles.css +151 -49
  92. package/index.ts +7 -6
  93. package/lib/artwork.ts +112 -0
  94. package/lib/geometry.ts +1 -1
  95. package/mock/activities.tsx +9 -32
  96. package/mock/artwork.tsx +13 -1
  97. package/mock/clipboard.tsx +113 -0
  98. package/mock/clock.tsx +77 -0
  99. package/mock/data.ts +78 -44
  100. package/mock/files.tsx +83 -0
  101. package/mock/island-content.tsx +79 -122
  102. package/mock/screen.tsx +76 -0
  103. package/mock/settings.tsx +370 -91
  104. package/mock/system.ts +49 -0
  105. package/mock/weather.tsx +135 -0
  106. package/package.json +7 -2
  107. package/blocks/activities/shelf/examples.mdx +0 -33
  108. package/blocks/activities/shelf/index.tsx +0 -289
  109. package/blocks/activities/timer/examples.mdx +0 -52
  110. package/blocks/activities/timer/index.tsx +0 -292
  111. package/blocks/system/controls/examples.mdx +0 -34
  112. package/blocks/system/controls/index.tsx +0 -167
  113. package/blocks/system/devices/examples.mdx +0 -25
  114. package/blocks/system/devices/index.tsx +0 -172
  115. package/blocks/system/power-alert/examples.mdx +0 -32
  116. package/blocks/system/power-alert/index.tsx +0 -89
  117. package/components/indicators/battery-glyph/examples.mdx +0 -22
  118. package/components/indicators/battery-glyph/index.tsx +0 -91
  119. package/dist/blocks/activities/shelf/index.d.ts +0 -2
  120. package/dist/blocks/activities/shelf/index.js +0 -14
  121. package/dist/blocks/activities/timer/index.d.ts +0 -2
  122. package/dist/blocks/activities/timer/index.js +0 -19
  123. package/dist/blocks/system/controls/index.d.ts +0 -2
  124. package/dist/blocks/system/controls/index.js +0 -10
  125. package/dist/blocks/system/devices/index.d.ts +0 -2
  126. package/dist/blocks/system/devices/index.js +0 -12
  127. package/dist/blocks/system/power-alert/index.d.ts +0 -2
  128. package/dist/blocks/system/power-alert/index.js +0 -9
  129. package/dist/components/indicators/battery-glyph/index.d.ts +0 -2
  130. package/dist/components/indicators/battery-glyph/index.js +0 -9
  131. package/dist/shared/chunk-2qpcsv5h.d.ts +0 -45
  132. package/dist/shared/chunk-45gytfr1.d.ts +0 -84
  133. package/dist/shared/chunk-50ffk4r7.d.ts +0 -69
  134. package/dist/shared/chunk-5w0yck07.d.ts +0 -32
  135. package/dist/shared/chunk-7hr53mby.js +0 -116
  136. package/dist/shared/chunk-b8jb1w72.js +0 -145
  137. package/dist/shared/chunk-cpewy6yg.js +0 -178
  138. package/dist/shared/chunk-e3e4s4ds.d.ts +0 -77
  139. package/dist/shared/chunk-enm6td0p.js +0 -280
  140. package/dist/shared/chunk-fvedaas2.d.ts +0 -33
  141. package/dist/shared/chunk-gex38j8x.d.ts +0 -82
  142. package/dist/shared/chunk-hwtxpzg0.js +0 -69
  143. package/dist/shared/chunk-phb53x1f.js +0 -252
  144. package/dist/shared/chunk-r8esmjfs.d.ts +0 -42
  145. package/dist/shared/chunk-rcp1g9ca.js +0 -70
  146. package/dist/shared/chunk-rx9sphz2.js +0 -266
  147. package/dist/shared/chunk-xdeek16r.d.ts +0 -58
  148. package/dist/shared/chunk-xkzjk1tq.js +0 -206
@@ -0,0 +1,481 @@
1
+ "use client";
2
+
3
+ import {
4
+ widget_default
5
+ } from "./chunk-wf0jtzhs.js";
6
+
7
+ // blocks/system/system-stats/index.tsx
8
+ import Sparkline from "@justanarthur/modo-ui/components/data-display/sparkline";
9
+ import Table from "@justanarthur/modo-ui/components/data-display/table";
10
+ import Meter from "@justanarthur/modo-ui/components/feedback/meter";
11
+ import { cn } from "@justanarthur/modo-ui/lib/utils";
12
+ import {
13
+ Activity,
14
+ ArrowDown,
15
+ ArrowUp,
16
+ BatteryCharging,
17
+ BatteryFull,
18
+ BatteryLow,
19
+ BatteryMedium,
20
+ Cpu,
21
+ HardDrive,
22
+ MemoryStick,
23
+ Network
24
+ } from "lucide-react";
25
+ import { jsx, jsxs } from "react/jsx-runtime";
26
+ /*!
27
+ * Local addition: a notch app's system load, the busiest figure as the hero
28
+ * with its trend, the rest as facts and the busiest processes beside it.
29
+ * Rebuilt from Just Notch's stats plugin (`System`, `Tile`, `Measuring`,
30
+ * `CpuLoad`) on the kit's Widget frame and modo-ui's Sparkline and Meter:
31
+ * the readings come in as props.
32
+ */
33
+ var ROWS = 3;
34
+ var SHEET_ROWS = 8;
35
+ var percent = (v) => `${Math.round(v * 100)}%`;
36
+ var share = (v) => v < 0.1 ? `${(v * 100).toFixed(1)}%` : percent(v);
37
+ function bytes(n) {
38
+ if (n >= 100000000000)
39
+ return `${Math.round(n / 1e9)} GB`;
40
+ if (n >= 1e9)
41
+ return `${(n / 1e9).toFixed(1)} GB`;
42
+ return `${Math.round(n / 1e6)} MB`;
43
+ }
44
+ function rate(bps) {
45
+ if (bps >= 1e6)
46
+ return `${(bps / 1e6).toFixed(1)} MB/s`;
47
+ if (bps >= 1000)
48
+ return `${Math.round(bps / 1000)} KB/s`;
49
+ return `${Math.round(bps)} B/s`;
50
+ }
51
+ function span(seconds) {
52
+ const minutes = Math.floor(seconds / 60);
53
+ const hours = Math.floor(minutes / 60);
54
+ const days = Math.floor(hours / 24);
55
+ if (days)
56
+ return `${days} d ${hours % 24} h`;
57
+ if (hours)
58
+ return `${hours} h ${minutes % 60} min`;
59
+ return `${minutes} min`;
60
+ }
61
+ var clock = (minutes) => `${Math.floor(minutes / 60)}:${String(Math.round(minutes % 60)).padStart(2, "0")}`;
62
+ function toneOf(load) {
63
+ if (load >= 0.9)
64
+ return "error";
65
+ if (load >= 0.75)
66
+ return "warning";
67
+ return "current";
68
+ }
69
+ function verdict(load) {
70
+ if (load >= 0.9)
71
+ return "Under strain";
72
+ if (load >= 0.6)
73
+ return "Busy";
74
+ if (load >= 0.2)
75
+ return "Steady";
76
+ return "Idle";
77
+ }
78
+ var pressureOf = (sample) => sample.memoryPressure ?? sample.memoryUsed / sample.memoryTotal;
79
+ function batteryIcon({ level, charging }) {
80
+ if (charging)
81
+ return BatteryCharging;
82
+ if (level <= 20)
83
+ return BatteryLow;
84
+ if (level <= 70)
85
+ return BatteryMedium;
86
+ return BatteryFull;
87
+ }
88
+ function BatteryItem({ battery }) {
89
+ const left = battery.minutesLeft === undefined ? undefined : clock(battery.minutesLeft);
90
+ return /* @__PURE__ */ jsxs(widget_default.MetaItem, {
91
+ icon: batteryIcon(battery),
92
+ children: [
93
+ battery.level,
94
+ "%",
95
+ left && ` · ${left} ${battery.charging ? "to full" : "left"}`
96
+ ]
97
+ });
98
+ }
99
+ function Facts({ last, hero, battery, disk }) {
100
+ const dash = "–";
101
+ return /* @__PURE__ */ jsxs("div", {
102
+ className: "flex min-w-0 flex-col gap-1",
103
+ children: [
104
+ /* @__PURE__ */ jsxs(widget_default.Meta, {
105
+ children: [
106
+ hero === "cpu" ? /* @__PURE__ */ jsx(widget_default.MetaItem, {
107
+ icon: MemoryStick,
108
+ children: last ? `${bytes(last.memoryUsed)} of ${bytes(last.memoryTotal)}` : dash
109
+ }) : /* @__PURE__ */ jsx(widget_default.MetaItem, {
110
+ icon: Cpu,
111
+ children: last ? `${percent(last.cpu)} CPU` : dash
112
+ }),
113
+ /* @__PURE__ */ jsx(widget_default.MetaItem, {
114
+ icon: ArrowDown,
115
+ children: last ? rate(last.netIn) : dash
116
+ }),
117
+ /* @__PURE__ */ jsx(widget_default.MetaItem, {
118
+ icon: ArrowUp,
119
+ children: last ? rate(last.netOut) : dash
120
+ })
121
+ ]
122
+ }),
123
+ (battery || disk) && /* @__PURE__ */ jsxs(widget_default.Meta, {
124
+ children: [
125
+ battery && /* @__PURE__ */ jsx(BatteryItem, {
126
+ battery
127
+ }),
128
+ disk && /* @__PURE__ */ jsxs(widget_default.MetaItem, {
129
+ icon: HardDrive,
130
+ children: [
131
+ bytes(disk.free),
132
+ " free"
133
+ ]
134
+ })
135
+ ]
136
+ })
137
+ ]
138
+ });
139
+ }
140
+ function Processes({ processes }) {
141
+ const top = [...processes].sort((a, b) => b.cpu - a.cpu);
142
+ const more = top.length - ROWS;
143
+ return /* @__PURE__ */ jsxs(widget_default.Section, {
144
+ label: "Top processes",
145
+ trailing: /* @__PURE__ */ jsx("span", {
146
+ children: "CPU · memory"
147
+ }),
148
+ children: [
149
+ top.slice(0, ROWS).map((process) => /* @__PURE__ */ jsx(widget_default.Row, {
150
+ leading: share(process.cpu),
151
+ trailing: process.memory !== undefined && bytes(process.memory),
152
+ children: process.name
153
+ }, process.id)),
154
+ more > 0 && /* @__PURE__ */ jsxs("span", {
155
+ className: "flex h-6 items-center pl-17.5 text-caption text-muted-foreground",
156
+ children: [
157
+ more,
158
+ " more"
159
+ ]
160
+ })
161
+ ]
162
+ });
163
+ }
164
+ function Trend({ label, icon: Icon, value, unit, series, caption, className }) {
165
+ return /* @__PURE__ */ jsxs("div", {
166
+ className: cn("flex min-w-0 flex-col gap-1", className),
167
+ "aria-busy": value === undefined,
168
+ children: [
169
+ /* @__PURE__ */ jsx(widget_default.Header, {
170
+ icon: Icon,
171
+ children: label
172
+ }),
173
+ /* @__PURE__ */ jsx(widget_default.Figure, {
174
+ value: value === undefined ? "–" : percent(value),
175
+ unit
176
+ }),
177
+ /* @__PURE__ */ jsx(Sparkline, {
178
+ values: series,
179
+ max: 1,
180
+ area: true,
181
+ tone: toneOf(value ?? 0),
182
+ label: value === undefined ? `${label}, measuring` : `${label}, ${percent(value)}`,
183
+ className: cn("my-1 h-14 w-full", value === undefined && "text-muted-foreground")
184
+ }),
185
+ /* @__PURE__ */ jsx(widget_default.Subtitle, {
186
+ children: caption
187
+ })
188
+ ]
189
+ });
190
+ }
191
+ function batteryTone({ level, charging }) {
192
+ if (charging)
193
+ return "default";
194
+ if (level <= 10)
195
+ return "error";
196
+ if (level <= 20)
197
+ return "warning";
198
+ return "default";
199
+ }
200
+ function ProcessTable({ processes }) {
201
+ const top = [...processes].sort((a, b) => b.cpu - a.cpu).slice(0, SHEET_ROWS);
202
+ const head = "text-caption weight-normal text-muted-foreground";
203
+ return /* @__PURE__ */ jsx(widget_default.Section, {
204
+ label: "Top processes",
205
+ trailing: /* @__PURE__ */ jsx("span", {
206
+ children: "by CPU"
207
+ }),
208
+ children: /* @__PURE__ */ jsxs(Table, {
209
+ children: [
210
+ /* @__PURE__ */ jsx(Table.Header, {
211
+ children: /* @__PURE__ */ jsxs(Table.Row, {
212
+ children: [
213
+ /* @__PURE__ */ jsx(Table.Head, {
214
+ className: head,
215
+ children: "Name"
216
+ }),
217
+ /* @__PURE__ */ jsx(Table.Head, {
218
+ className: cn(head, "text-right"),
219
+ children: "CPU"
220
+ }),
221
+ /* @__PURE__ */ jsx(Table.Head, {
222
+ className: cn(head, "w-24 text-right"),
223
+ children: "Memory"
224
+ })
225
+ ]
226
+ })
227
+ }),
228
+ /* @__PURE__ */ jsx(Table.Body, {
229
+ children: top.map((process) => /* @__PURE__ */ jsxs(Table.Row, {
230
+ children: [
231
+ /* @__PURE__ */ jsx(Table.Cell, {
232
+ className: "text-foreground",
233
+ children: process.name
234
+ }),
235
+ /* @__PURE__ */ jsx(Table.Cell, {
236
+ children: /* @__PURE__ */ jsxs("span", {
237
+ className: "flex items-center justify-end gap-3",
238
+ children: [
239
+ /* @__PURE__ */ jsx(Meter, {
240
+ variant: "line",
241
+ value: process.cpu,
242
+ label: `${process.name}, CPU`,
243
+ className: "w-24"
244
+ }),
245
+ /* @__PURE__ */ jsx("span", {
246
+ className: "w-12 text-right tabular-nums",
247
+ children: share(process.cpu)
248
+ })
249
+ ]
250
+ })
251
+ }),
252
+ /* @__PURE__ */ jsx(Table.Cell, {
253
+ className: "text-right tabular-nums",
254
+ children: process.memory === undefined ? "–" : bytes(process.memory)
255
+ })
256
+ ]
257
+ }, process.id))
258
+ })
259
+ ]
260
+ })
261
+ });
262
+ }
263
+ function Sheet({ samples, hero, battery, disk, uptime, processes, size, className }) {
264
+ const last = samples.at(-1);
265
+ const busiest = processes?.length ? processes.reduce((a, b) => b.cpu > a.cpu ? b : a).name : undefined;
266
+ const cpu = /* @__PURE__ */ jsx(Trend, {
267
+ label: "CPU",
268
+ icon: Cpu,
269
+ value: last?.cpu,
270
+ unit: "load",
271
+ series: samples.map((s) => s.cpu),
272
+ caption: last ? [verdict(last.cpu), busiest && `${busiest} is busiest`].filter(Boolean).join(" · ") : "Measuring…"
273
+ }, "cpu");
274
+ const memory = /* @__PURE__ */ jsx(Trend, {
275
+ label: "Memory",
276
+ icon: MemoryStick,
277
+ value: last && pressureOf(last),
278
+ unit: "pressure",
279
+ series: samples.map(pressureOf),
280
+ caption: last ? `${bytes(last.memoryUsed)} of ${bytes(last.memoryTotal)} in use` : "Measuring…"
281
+ }, "memory");
282
+ const [first, second] = hero === "cpu" ? [cpu, memory] : [memory, cpu];
283
+ const left = battery?.minutesLeft === undefined ? undefined : clock(battery.minutesLeft);
284
+ return /* @__PURE__ */ jsxs(widget_default.Sheet, {
285
+ size,
286
+ className,
287
+ children: [
288
+ /* @__PURE__ */ jsxs("div", {
289
+ className: "flex min-w-0 flex-col gap-2",
290
+ children: [
291
+ /* @__PURE__ */ jsx(widget_default.Header, {
292
+ icon: Activity,
293
+ children: uptime === undefined ? "System" : `System · up ${span(uptime)}`
294
+ }),
295
+ /* @__PURE__ */ jsxs("div", {
296
+ className: "grid grid-cols-2 divide-x divide-border [&>*]:px-6 [&>*:first-child]:pl-0 [&>*:last-child]:pr-0",
297
+ children: [
298
+ first,
299
+ second
300
+ ]
301
+ })
302
+ ]
303
+ }),
304
+ /* @__PURE__ */ jsxs("div", {
305
+ className: "grid auto-cols-fr grid-flow-col divide-x divide-border [&>*]:px-6 [&>*:first-child]:pl-0 [&>*:last-child]:pr-0",
306
+ children: [
307
+ /* @__PURE__ */ jsxs("div", {
308
+ className: "flex min-w-0 flex-col gap-1",
309
+ "aria-busy": !last,
310
+ children: [
311
+ /* @__PURE__ */ jsx(widget_default.Header, {
312
+ icon: Network,
313
+ children: "Network"
314
+ }),
315
+ /* @__PURE__ */ jsxs("div", {
316
+ className: "flex min-w-0 items-baseline gap-5",
317
+ children: [
318
+ /* @__PURE__ */ jsxs("span", {
319
+ className: "flex items-center gap-1.5 whitespace-nowrap text-title weight-semibold tabular-nums text-foreground",
320
+ children: [
321
+ /* @__PURE__ */ jsx(ArrowDown, {
322
+ size: 16,
323
+ strokeWidth: 1.5,
324
+ "aria-label": "In",
325
+ className: "text-muted-foreground"
326
+ }),
327
+ last ? rate(last.netIn) : "–"
328
+ ]
329
+ }),
330
+ /* @__PURE__ */ jsxs("span", {
331
+ className: "flex items-center gap-1.5 whitespace-nowrap text-title weight-semibold tabular-nums text-muted-foreground",
332
+ children: [
333
+ /* @__PURE__ */ jsx(ArrowUp, {
334
+ size: 16,
335
+ strokeWidth: 1.5,
336
+ "aria-label": "Out"
337
+ }),
338
+ last ? rate(last.netOut) : "–"
339
+ ]
340
+ })
341
+ ]
342
+ }),
343
+ /* @__PURE__ */ jsx(Sparkline, {
344
+ values: samples.map((s) => s.netIn),
345
+ secondary: samples.map((s) => s.netOut),
346
+ area: true,
347
+ label: last ? `Network, ${rate(last.netIn)} in, ${rate(last.netOut)} out` : "Network, measuring",
348
+ className: cn("my-1 h-12 w-full", !last && "text-muted-foreground")
349
+ })
350
+ ]
351
+ }),
352
+ (battery || disk) && /* @__PURE__ */ jsxs("div", {
353
+ className: "flex min-w-0 flex-col justify-center gap-4",
354
+ children: [
355
+ battery && /* @__PURE__ */ jsx(Meter, {
356
+ label: battery.charging ? "Battery, charging" : "Battery",
357
+ value: battery.level,
358
+ max: 100,
359
+ tone: batteryTone(battery),
360
+ detail: `${battery.level}%${left ? ` · ${left} ${battery.charging ? "to full" : "left"}` : ""}`
361
+ }),
362
+ disk && /* @__PURE__ */ jsx(Meter, {
363
+ label: "Startup disk",
364
+ value: disk.total - disk.free,
365
+ max: disk.total,
366
+ detail: `${bytes(disk.free)} free of ${bytes(disk.total)}`
367
+ })
368
+ ]
369
+ })
370
+ ]
371
+ }),
372
+ processes?.length ? /* @__PURE__ */ jsx(ProcessTable, {
373
+ processes
374
+ }) : null
375
+ ]
376
+ });
377
+ }
378
+ function SystemStatsLeading2() {
379
+ return /* @__PURE__ */ jsx(Cpu, {
380
+ size: 16,
381
+ strokeWidth: 1.5,
382
+ className: "text-muted-foreground"
383
+ });
384
+ }
385
+ function SystemStatsTrailing2({ sample }) {
386
+ if (!sample)
387
+ return /* @__PURE__ */ jsx("span", {
388
+ className: "text-caption weight-semibold text-muted-foreground",
389
+ children: "–"
390
+ });
391
+ return /* @__PURE__ */ jsx("span", {
392
+ className: "text-caption weight-semibold tabular-nums text-foreground",
393
+ children: percent(sample.cpu)
394
+ });
395
+ }
396
+ function SystemStatsMinimal2({ sample }) {
397
+ const load = sample?.cpu ?? 0;
398
+ return /* @__PURE__ */ jsx(Meter, {
399
+ variant: "ring",
400
+ className: "size-5.5",
401
+ size: "compact",
402
+ value: load,
403
+ label: sample ? `CPU, ${percent(load)}` : "CPU, measuring"
404
+ });
405
+ }
406
+ var SystemStats2 = Object.assign(function SystemStats({
407
+ samples,
408
+ hero = "cpu",
409
+ battery,
410
+ disk,
411
+ uptime,
412
+ processes,
413
+ size,
414
+ layout = "fit",
415
+ className
416
+ }) {
417
+ if (layout === "tall")
418
+ return /* @__PURE__ */ jsx(Sheet, {
419
+ size,
420
+ samples,
421
+ hero,
422
+ battery,
423
+ disk,
424
+ uptime,
425
+ processes,
426
+ className
427
+ });
428
+ const last = samples.at(-1);
429
+ const series = hero === "cpu" ? samples.map((s) => s.cpu) : samples.map(pressureOf);
430
+ const load = last ? hero === "cpu" ? last.cpu : pressureOf(last) : 0;
431
+ const name = hero === "cpu" ? "CPU" : "Memory pressure";
432
+ const busiest = processes?.length ? processes.reduce((a, b) => b.cpu > a.cpu ? b : a).name : undefined;
433
+ return /* @__PURE__ */ jsxs(widget_default, {
434
+ size,
435
+ className: cn("h-full", className),
436
+ aside: processes?.length ? /* @__PURE__ */ jsx(Processes, {
437
+ processes
438
+ }) : undefined,
439
+ children: [
440
+ /* @__PURE__ */ jsx(widget_default.Header, {
441
+ icon: Activity,
442
+ children: uptime === undefined ? "System" : `System · up ${span(uptime)}`
443
+ }),
444
+ /* @__PURE__ */ jsxs("div", {
445
+ className: "flex min-w-0 items-end gap-4",
446
+ "aria-busy": !last,
447
+ children: [
448
+ /* @__PURE__ */ jsx(widget_default.Figure, {
449
+ value: last ? percent(load) : "–",
450
+ unit: hero === "cpu" ? "CPU" : "pressure",
451
+ className: "shrink-0"
452
+ }),
453
+ /* @__PURE__ */ jsx(Sparkline, {
454
+ values: series,
455
+ max: 1,
456
+ area: true,
457
+ tone: toneOf(load),
458
+ label: last ? `${name}, ${percent(load)}` : `${name}, measuring`,
459
+ className: cn("mb-1.5 h-9 min-w-0 flex-1", !last && "text-muted-foreground")
460
+ })
461
+ ]
462
+ }),
463
+ /* @__PURE__ */ jsx(widget_default.Subtitle, {
464
+ className: "mb-1",
465
+ children: last ? [verdict(load), busiest && `${busiest} is busiest`].filter(Boolean).join(" · ") : "Measuring…"
466
+ }),
467
+ /* @__PURE__ */ jsx(Facts, {
468
+ last,
469
+ hero,
470
+ battery,
471
+ disk
472
+ })
473
+ ]
474
+ });
475
+ }, {
476
+ Leading: SystemStatsLeading2,
477
+ Trailing: SystemStatsTrailing2,
478
+ Minimal: SystemStatsMinimal2
479
+ });
480
+ var system_stats_default = SystemStats2;
481
+ export { SystemStatsLeading2, SystemStatsTrailing2, SystemStatsMinimal2, SystemStats2, system_stats_default };
@@ -0,0 +1,197 @@
1
+ import { IconComponent } from "@justanarthur/modo-ui/lib/icon-context";
2
+ import { SizeVariant } from "@justanarthur/modo-ui/lib/size-context";
3
+ import { LucideIcon } from "lucide-react";
4
+ import { ReactNode } from "react";
5
+ import { JSX as JSX_1kxb } from "react";
6
+ interface WidgetHeaderProps2 {
7
+ /** The glyph before the label: the source app, the widget's kind. */
8
+ icon?: IconComponent;
9
+ /** The context: where it comes from, which day it is. */
10
+ children: ReactNode;
11
+ /** Quiet actions at the end of the line, such as `Widget.Action`s. */
12
+ trailing?: ReactNode;
13
+ /** Classes for the row. */
14
+ className?: string;
15
+ }
16
+ type Element_12xgc = JSX_1kxb["Element"];
17
+ /** The context line at the top of a widget: a glyph, where it comes from, and quiet actions at the end. */
18
+ declare function WidgetHeader2({ icon: Icon, children, trailing, className }: WidgetHeaderProps2): Element_12xgc;
19
+ interface WidgetTitleProps2 {
20
+ /** The hero's name: a track, an event. */
21
+ children: ReactNode;
22
+ /** A mark before it, such as a calendar's color dot. */
23
+ leading?: ReactNode;
24
+ /** Classes for the row. */
25
+ className?: string;
26
+ }
27
+ /** The hero's name, on the title role: one line, truncating. */
28
+ declare function WidgetTitle2({ children, leading, className }: WidgetTitleProps2): Element_12xgc;
29
+ /** The line under the title: who, where, what else; muted, one line. */
30
+ declare function WidgetSubtitle2({ children, className }: {
31
+ children: ReactNode;
32
+ className?: string;
33
+ }): Element_12xgc;
34
+ interface WidgetFigureProps2 {
35
+ /** The number, or the one word that stands for it (`Now`). */
36
+ value: ReactNode;
37
+ /** The unit after it, set smaller and muted: `min`, `%`. */
38
+ unit?: ReactNode;
39
+ /** A word before it, set like the unit: `in`. */
40
+ prefix?: ReactNode;
41
+ /** A data color for the value (a calendar's, an artwork's); without one it is the text color. */
42
+ color?: string;
43
+ /** Classes for the row. */
44
+ className?: string;
45
+ }
46
+ /** A widget's hero number on the display role, its unit beside it on the title role, digits tabular. */
47
+ declare function WidgetFigure2({ value, unit, prefix, color, className }: WidgetFigureProps2): Element_12xgc;
48
+ interface WidgetMetaItemProps2 {
49
+ /** The glyph before it: a clock, a pin, a speaker. */
50
+ icon?: IconComponent;
51
+ /** The fact. */
52
+ children: ReactNode;
53
+ }
54
+ /** One fact of a meta row: a glyph and a few words. */
55
+ declare function WidgetMetaItem2({ icon: Icon, children }: WidgetMetaItemProps2): Element_12xgc;
56
+ /** Supporting facts in a row, each a glyph and a few words, muted; the last one gives way first. */
57
+ declare function WidgetMeta2({ children, className }: {
58
+ children: ReactNode;
59
+ className?: string;
60
+ }): Element_12xgc;
61
+ interface WidgetActionProps2 {
62
+ /** The glyph: a Lucide icon, or any component taking its props. */
63
+ icon: LucideIcon;
64
+ /** What it does: the accessible name and the tooltip. */
65
+ label: string;
66
+ /** Called on press. */
67
+ onClick?: () => void;
68
+ /** A toggle that is on (shuffle, a like): the glyph in the text color, `aria-pressed`. Leave it out for a plain action. */
69
+ pressed?: boolean;
70
+ /** `primary` is the widget's main action (play / pause): a larger glyph in the text color. Defaults to `'default'`. */
71
+ emphasis?: "default" | "primary";
72
+ /** Fills the glyph, for solid transport glyphs. Defaults to `false`. */
73
+ filled?: boolean;
74
+ /** A data color for the glyph while pressed (the artwork's tint). */
75
+ color?: string;
76
+ /** No press. Defaults to `false`. */
77
+ disabled?: boolean;
78
+ }
79
+ /** A quiet icon button with a tooltip: muted at rest, the text color on hover and while pressed. */
80
+ declare function WidgetAction2({ icon: Icon, label, onClick, pressed, emphasis, filled, color, disabled }: WidgetActionProps2): Element_12xgc;
81
+ interface WidgetMessageProps2 {
82
+ /** The glyph in the tile. */
83
+ icon: IconComponent;
84
+ /** What's going on, in a few words. */
85
+ title: ReactNode;
86
+ /** What to do about it. */
87
+ description?: ReactNode;
88
+ /** The way forward: a Button or two. */
89
+ actions?: ReactNode;
90
+ /** Classes for the root, which fills the widget. */
91
+ className?: string;
92
+ }
93
+ /** A widget's empty, permission or error state, laid out across the wide, short island: tile, text, then the action. */
94
+ declare function WidgetMessage2({ icon: Icon, title, description, actions, className }: WidgetMessageProps2): Element_12xgc;
95
+ interface WidgetSectionProps2 {
96
+ /** The group's name: `Later today`, `Tomorrow`. */
97
+ label: ReactNode;
98
+ /** Content at the end of the label's line: chips, a count, a fold toggle. */
99
+ trailing?: ReactNode;
100
+ /** The rows. */
101
+ children?: ReactNode;
102
+ /** Classes for the section. */
103
+ className?: string;
104
+ }
105
+ /** A group of rows under a muted caption, the way a list's section reads. */
106
+ declare function WidgetSection2({ label, trailing, children, className }: WidgetSectionProps2): Element_12xgc;
107
+ interface WidgetRowProps2 {
108
+ /** The figure at the start, muted and tabular: a time. */
109
+ leading?: ReactNode;
110
+ /** A data color for the mark between the figure and the title: a calendar's. */
111
+ color?: string;
112
+ /** The row's text. */
113
+ children: ReactNode;
114
+ /** Muted content at the end: a glyph, a place. */
115
+ trailing?: ReactNode;
116
+ /** Classes for the row. */
117
+ className?: string;
118
+ }
119
+ /** A list row for the island: a muted figure, a color mark, the title, and a muted end; the compact control height. */
120
+ declare function WidgetRow2({ leading, color, children, trailing, className }: WidgetRowProps2): Element_12xgc;
121
+ interface WidgetChipProps2 {
122
+ /** A data color for its dot. */
123
+ color?: string;
124
+ /** The chip's text. */
125
+ children: ReactNode;
126
+ }
127
+ /** A small label on a wash one surface up: an all-day event, a state. */
128
+ declare function WidgetChip2({ color, children }: WidgetChipProps2): Element_12xgc;
129
+ type WidgetLayout2 = "fit" | "tall";
130
+ interface WidgetSheetProps2 {
131
+ /** The bands, top to bottom: the hero first, then the lists and details. */
132
+ children: ReactNode;
133
+ /** Step on the size ladder for every part inside. Omitted, the widget follows the surrounding SizeProvider. */
134
+ size?: SizeVariant;
135
+ /** Classes for the column. */
136
+ className?: string;
137
+ }
138
+ /**
139
+ * The frame of a widget at the open island's tall snap (a sheet about
140
+ * 692 × 476): bands stacked top to bottom, the hero first, set larger, then
141
+ * the lists and details the short island has no room for. Bands sit apart
142
+ * on space alone; a band of columns splits them with hairlines.
143
+ */
144
+ declare function WidgetSheet2({ children, size, className }: WidgetSheetProps2): Element_12xgc;
145
+ interface WidgetProps2 {
146
+ /** The hero's picture at the start, as tall as the widget: artwork, a ring. */
147
+ media?: ReactNode;
148
+ /** The supporting column at the end, past a hairline: a list, a timeline. It folds away when the widget is narrow. */
149
+ aside?: ReactNode;
150
+ /** The main column: header, hero, meta, actions. */
151
+ children: ReactNode;
152
+ /** Step on the size ladder for every part inside. Omitted, the widget follows the surrounding SizeProvider. */
153
+ size?: SizeVariant;
154
+ /** Classes for the root, which fills the island's content area. */
155
+ className?: string;
156
+ }
157
+ /**
158
+ * The frame every open-island widget is built in: the hero's picture, the
159
+ * main column, and a supporting column past a hairline.
160
+ *
161
+ * One hero per widget, set large: a name on the title role
162
+ * (`Widget.Title`) or a number on the display role (`Widget.Figure`), then
163
+ * one muted line (`Widget.Subtitle`), then the supporting facts as glyph and
164
+ * words (`Widget.Meta`). Context goes on the line above (`Widget.Header`),
165
+ * actions are quiet icon buttons with tooltips (`Widget.Action`), and lists
166
+ * are rows of a muted figure, a color mark and a title (`Widget.Row` under
167
+ * a `Widget.Section`). Color comes from the content (an artwork's tint, a
168
+ * calendar's color, a status hue), never from decoration; depth from one
169
+ * surface step (`Widget.Chip`, `Widget.Message`'s tile), never from boxes.
170
+ * Empty and permission states are a `Widget.Message`, laid out across the
171
+ * wide, short island.
172
+ *
173
+ * At the island's tall snap a widget shows more, not the same layout
174
+ * stretched: each block takes `layout="tall"` and builds a `Widget.Sheet`,
175
+ * bands of fuller lists, larger pictures and the details the short island
176
+ * leaves out.
177
+ *
178
+ * The frame fills the island's content area. The aside folds away under
179
+ * 30rem of width, so a narrower panel keeps the hero.
180
+ *
181
+ * @example {@include ./examples.mdx}
182
+ */
183
+ declare const Widget2: (({ media, aside, children, size, className }: WidgetProps2) => Element_12xgc) & {
184
+ Header: typeof WidgetHeader2;
185
+ Title: typeof WidgetTitle2;
186
+ Subtitle: typeof WidgetSubtitle2;
187
+ Figure: typeof WidgetFigure2;
188
+ Meta: typeof WidgetMeta2;
189
+ MetaItem: typeof WidgetMetaItem2;
190
+ Action: typeof WidgetAction2;
191
+ Message: typeof WidgetMessage2;
192
+ Section: typeof WidgetSection2;
193
+ Row: typeof WidgetRow2;
194
+ Chip: typeof WidgetChip2;
195
+ Sheet: typeof WidgetSheet2;
196
+ };
197
+ export { WidgetHeaderProps2, WidgetHeader2, WidgetTitleProps2, WidgetTitle2, WidgetSubtitle2, WidgetFigureProps2, WidgetFigure2, WidgetMetaItemProps2, WidgetMetaItem2, WidgetMeta2, WidgetActionProps2, WidgetAction2, WidgetMessageProps2, WidgetMessage2, WidgetSectionProps2, WidgetSection2, WidgetRowProps2, WidgetRow2, WidgetChipProps2, WidgetChip2, WidgetLayout2, WidgetSheetProps2, WidgetSheet2, WidgetProps2, Widget2 };
@@ -1,7 +1,7 @@
1
1
  // lib/geometry.ts
2
2
  var ISLAND_STATES2 = ["idle", "compact", "split", "expanded", "flash"];
3
3
  var DEFAULT_NOTCH2 = { width: 185, height: 32 };
4
- var DEFAULT_PANEL2 = { width: 720, height: 320 };
4
+ var DEFAULT_PANEL2 = { width: 720, height: 240 };
5
5
  var INSET2 = 20;
6
6
  var NOTCH_GAP2 = 8;
7
7
  var FLASH_REACH = 64;