@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,582 @@
1
+ "use client";
2
+
3
+ import {
4
+ IslandFlash2
5
+ } from "./chunk-ndf79pv5.js";
6
+ import {
7
+ widget_default
8
+ } from "./chunk-wf0jtzhs.js";
9
+ import {
10
+ MINUTE2,
11
+ useEdgeClock2
12
+ } from "./chunk-gb56m10p.js";
13
+
14
+ // blocks/system/recent-files/index.tsx
15
+ import Button from "@justanarthur/modo-ui/components/actions/button";
16
+ import Meter from "@justanarthur/modo-ui/components/feedback/meter";
17
+ import Tabs from "@justanarthur/modo-ui/components/navigation/tabs";
18
+ import { SURFACE_BG } from "@justanarthur/modo-ui/lib/surface-classes";
19
+ import { useLift } from "@justanarthur/modo-ui/lib/surface-context";
20
+ import { useControllableState } from "@justanarthur/modo-ui/lib/use-controllable-state";
21
+ import { cn } from "@justanarthur/modo-ui/lib/utils";
22
+ import FluidHover from "@justanarthur/modo-ui/primitives/systems/fluid-hover";
23
+ import {
24
+ ArrowDownToLine,
25
+ ArrowUpRight,
26
+ Camera,
27
+ Copy,
28
+ File,
29
+ FileArchive,
30
+ FileAudio,
31
+ FileCode,
32
+ FileImage,
33
+ FileText,
34
+ FileVideo,
35
+ FolderSearch,
36
+ Trash2,
37
+ X
38
+ } from "lucide-react";
39
+ import { jsx, jsxs } from "react/jsx-runtime";
40
+ /*!
41
+ * Local addition: a notch app's recent files, the newest download or
42
+ * screenshot as the hero and the ones before it beside it, ready to open or
43
+ * drag out. Presentational: the files and what to do with them come in as
44
+ * props.
45
+ */
46
+ var SOURCE_LABEL = { downloads: "Downloads", screenshots: "Screenshots" };
47
+ var SOURCE_ICON = { downloads: ArrowDownToLine, screenshots: Camera };
48
+ var ROWS = 3;
49
+ var TILES = 6;
50
+ var TYPES = [
51
+ [/\.(png|jpe?g|gif|webp|heic|svg|tiff?)$/i, FileImage],
52
+ [/\.(mov|mp4|m4v|avi|mkv|webm)$/i, FileVideo],
53
+ [/\.(mp3|m4a|wav|aiff?|flac|ogg)$/i, FileAudio],
54
+ [/\.(zip|tar|gz|tgz|rar|7z|dmg|xip)$/i, FileArchive],
55
+ [/\.(m?[jt]sx?|json|css|html|swift|rs|go|py|rb|sh|ya?ml|toml)$/i, FileCode],
56
+ [/\.(pdf|md|txt|rtf|docx?|pages|key|numbers|csv)$/i, FileText]
57
+ ];
58
+ var iconFor = (name) => TYPES.find(([pattern]) => pattern.test(name))?.[1] ?? File;
59
+ function bytes(n) {
60
+ if (n >= 1e9)
61
+ return `${(n / 1e9).toFixed(1)} GB`;
62
+ if (n >= 1e6)
63
+ return `${n >= 1e8 ? Math.round(n / 1e6) : (n / 1e6).toFixed(1)} MB`;
64
+ return `${Math.max(1, Math.round(n / 1000))} KB`;
65
+ }
66
+ function part(n, total) {
67
+ const [unit, scale] = total >= 1e9 ? ["GB", 1e9] : total >= 1e6 ? ["MB", 1e6] : ["KB", 1000];
68
+ const digits = total / scale < 10 ? 1 : 0;
69
+ return `${(n / scale).toFixed(digits)} of ${(total / scale).toFixed(digits)} ${unit}`;
70
+ }
71
+ function ago(ms) {
72
+ const minutes = Math.floor(ms / MINUTE2);
73
+ if (minutes < 1)
74
+ return "just now";
75
+ if (minutes < 60)
76
+ return `${minutes} min ago`;
77
+ if (minutes < 24 * 60)
78
+ return `${Math.floor(minutes / 60)} h ago`;
79
+ return `${Math.floor(minutes / (24 * 60))} d ago`;
80
+ }
81
+ function short(ms) {
82
+ const minutes = Math.floor(ms / MINUTE2);
83
+ if (minutes < 1)
84
+ return "now";
85
+ if (minutes < 60)
86
+ return `${minutes} min`;
87
+ if (minutes < 24 * 60)
88
+ return `${Math.floor(minutes / 60)} h`;
89
+ return `${Math.floor(minutes / (24 * 60))} d`;
90
+ }
91
+ function left(seconds) {
92
+ if (seconds < 60)
93
+ return `${Math.max(1, Math.ceil(seconds))} s left`;
94
+ if (seconds < 3600)
95
+ return `${Math.ceil(seconds / 60)} min left`;
96
+ return `${Math.floor(seconds / 3600)} h ${Math.ceil(seconds % 3600 / 60)} min left`;
97
+ }
98
+ var dragOf = (file, onDragStart) => onDragStart ? { draggable: true, onDragStart: (event) => onDragStart(file, event) } : {};
99
+ var TILE = { default: "size-24 rounded-xl", compact: "size-20 rounded-xl" };
100
+ var SHEET_TILE = { default: "h-32 w-48 rounded-2xl", compact: "h-28 w-42 rounded-2xl" };
101
+ function Thumbnail({
102
+ file,
103
+ className,
104
+ glyph = 28
105
+ }) {
106
+ const level = useLift(1);
107
+ const Icon = iconFor(file.name);
108
+ return /* @__PURE__ */ jsxs("span", {
109
+ className: cn("relative flex shrink-0 items-center justify-center overflow-hidden text-muted-foreground", file.thumbnail == null && SURFACE_BG[level], className),
110
+ children: [
111
+ typeof file.thumbnail === "string" ? /* @__PURE__ */ jsx("img", {
112
+ alt: "",
113
+ src: file.thumbnail,
114
+ draggable: false,
115
+ className: "size-full object-cover"
116
+ }) : file.thumbnail ?? /* @__PURE__ */ jsx(Icon, {
117
+ size: glyph,
118
+ strokeWidth: 1.25
119
+ }),
120
+ /* @__PURE__ */ jsx("span", {
121
+ "aria-hidden": true,
122
+ className: "pointer-events-none absolute inset-0 rounded-[inherit] ring-1 ring-border ring-inset"
123
+ })
124
+ ]
125
+ });
126
+ }
127
+ function Hero({ file, now, props }) {
128
+ const { onOpen, onReveal, onCopy, onDelete } = props;
129
+ return /* @__PURE__ */ jsxs("div", {
130
+ className: "flex min-w-0 flex-col gap-2",
131
+ children: [
132
+ /* @__PURE__ */ jsxs("div", {
133
+ className: "flex min-w-0 flex-col gap-0.5",
134
+ children: [
135
+ /* @__PURE__ */ jsx(widget_default.Title, {
136
+ children: file.name
137
+ }),
138
+ /* @__PURE__ */ jsx(widget_default.Subtitle, {
139
+ children: [bytes(file.size), ago(now - file.addedAt), file.from && `from ${file.from}`].filter(Boolean).join(" · ")
140
+ })
141
+ ]
142
+ }),
143
+ /* @__PURE__ */ jsxs("div", {
144
+ className: "-mr-1 flex min-w-0 items-center justify-end gap-0.5",
145
+ children: [
146
+ onReveal && /* @__PURE__ */ jsx(widget_default.Action, {
147
+ icon: FolderSearch,
148
+ label: "Show in Finder",
149
+ onClick: () => onReveal(file)
150
+ }),
151
+ onCopy && /* @__PURE__ */ jsx(widget_default.Action, {
152
+ icon: Copy,
153
+ label: "Copy",
154
+ onClick: () => onCopy(file)
155
+ }),
156
+ onDelete && /* @__PURE__ */ jsx(widget_default.Action, {
157
+ icon: Trash2,
158
+ label: "Move to Trash",
159
+ onClick: () => onDelete(file)
160
+ }),
161
+ /* @__PURE__ */ jsx(Button, {
162
+ variant: "primary",
163
+ size: "compact",
164
+ leadingIcon: ArrowUpRight,
165
+ className: "ml-1.5",
166
+ onClick: () => onOpen?.(file),
167
+ children: "Open"
168
+ })
169
+ ]
170
+ })
171
+ ]
172
+ });
173
+ }
174
+ function Downloading({
175
+ download,
176
+ onCancel
177
+ }) {
178
+ const share = download.received / download.total;
179
+ return /* @__PURE__ */ jsxs("div", {
180
+ className: "flex min-w-0 flex-col gap-1.5",
181
+ children: [
182
+ /* @__PURE__ */ jsxs("div", {
183
+ className: "flex min-w-0 items-center gap-3",
184
+ children: [
185
+ /* @__PURE__ */ jsx(widget_default.Title, {
186
+ className: "flex-1",
187
+ children: download.name
188
+ }),
189
+ /* @__PURE__ */ jsxs("span", {
190
+ className: "shrink-0 text-caption tabular-nums text-muted-foreground",
191
+ children: [
192
+ Math.round(share * 100),
193
+ "%"
194
+ ]
195
+ }),
196
+ onCancel && /* @__PURE__ */ jsx("span", {
197
+ className: "-my-1 -mr-1 flex shrink-0",
198
+ children: /* @__PURE__ */ jsx(widget_default.Action, {
199
+ icon: X,
200
+ label: "Cancel download",
201
+ onClick: () => onCancel(download)
202
+ })
203
+ })
204
+ ]
205
+ }),
206
+ /* @__PURE__ */ jsx(Meter, {
207
+ variant: "line",
208
+ value: share,
209
+ tone: "default",
210
+ label: `${download.name}, ${Math.round(share * 100)}%`
211
+ }),
212
+ /* @__PURE__ */ jsxs(widget_default.Meta, {
213
+ children: [
214
+ /* @__PURE__ */ jsx(widget_default.MetaItem, {
215
+ children: part(download.received, download.total)
216
+ }),
217
+ /* @__PURE__ */ jsxs(widget_default.MetaItem, {
218
+ children: [
219
+ bytes(download.rate),
220
+ "/s"
221
+ ]
222
+ }),
223
+ /* @__PURE__ */ jsx(widget_default.MetaItem, {
224
+ children: left((download.total - download.received) / Math.max(1, download.rate))
225
+ })
226
+ ]
227
+ })
228
+ ]
229
+ });
230
+ }
231
+ function Empty({ source, className }) {
232
+ const level = useLift(1);
233
+ const Icon = SOURCE_ICON[source];
234
+ return /* @__PURE__ */ jsx("span", {
235
+ className: cn("flex shrink-0 items-center justify-center text-muted-foreground", SURFACE_BG[level], className),
236
+ children: /* @__PURE__ */ jsx(Icon, {
237
+ size: 28,
238
+ strokeWidth: 1.25
239
+ })
240
+ });
241
+ }
242
+ function Rows({ files, now, onOpen, onDragStart }) {
243
+ return /* @__PURE__ */ jsx(FluidHover, {
244
+ className: "-mx-2 flex flex-col gap-0",
245
+ children: files.slice(0, ROWS).map((file, index) => {
246
+ const Icon = iconFor(file.name);
247
+ return /* @__PURE__ */ jsx(FluidHover.Item, {
248
+ index,
249
+ title: file.name,
250
+ className: "h-7 px-2",
251
+ onClick: () => onOpen?.(file),
252
+ ...dragOf(file, onDragStart),
253
+ children: /* @__PURE__ */ jsx(widget_default.Row, {
254
+ className: "w-full",
255
+ leading: short(now - file.addedAt),
256
+ trailing: bytes(file.size),
257
+ children: /* @__PURE__ */ jsxs("span", {
258
+ className: "flex min-w-0 items-center gap-2",
259
+ children: [
260
+ /* @__PURE__ */ jsx(Icon, {
261
+ size: 14,
262
+ strokeWidth: 1.5,
263
+ className: "shrink-0 text-muted-foreground"
264
+ }),
265
+ /* @__PURE__ */ jsx("span", {
266
+ className: "min-w-0 truncate",
267
+ children: file.name
268
+ })
269
+ ]
270
+ })
271
+ })
272
+ }, file.id);
273
+ })
274
+ });
275
+ }
276
+ function Tiles({ files, onOpen, onDragStart }) {
277
+ return /* @__PURE__ */ jsx(FluidHover, {
278
+ columns: 3,
279
+ className: "-m-1 grid-cols-3 gap-0",
280
+ highlightClassName: "rounded-lg",
281
+ children: files.slice(0, TILES).map((file, index) => /* @__PURE__ */ jsx(FluidHover.Item, {
282
+ index,
283
+ title: file.name,
284
+ "aria-label": file.name,
285
+ className: "min-h-0 p-1",
286
+ onClick: () => onOpen?.(file),
287
+ ...dragOf(file, onDragStart),
288
+ children: /* @__PURE__ */ jsx(Thumbnail, {
289
+ file,
290
+ glyph: 16,
291
+ className: "aspect-[16/10] w-full rounded-md"
292
+ })
293
+ }, file.id))
294
+ });
295
+ }
296
+ function Grid({ files, now, onOpen, onDragStart }) {
297
+ return /* @__PURE__ */ jsx(FluidHover, {
298
+ columns: 5,
299
+ className: "-m-1.5 grid-cols-5 gap-0",
300
+ highlightClassName: "rounded-xl",
301
+ children: files.map((file, index) => /* @__PURE__ */ jsxs(FluidHover.Item, {
302
+ index,
303
+ title: file.name,
304
+ className: "min-h-0 flex-col items-stretch gap-1.5 p-1.5 text-left",
305
+ onClick: () => onOpen?.(file),
306
+ ...dragOf(file, onDragStart),
307
+ children: [
308
+ /* @__PURE__ */ jsx(Thumbnail, {
309
+ file,
310
+ glyph: 24,
311
+ className: "aspect-[4/3] w-full rounded-lg"
312
+ }),
313
+ /* @__PURE__ */ jsxs("span", {
314
+ className: "flex min-w-0 flex-col px-0.5",
315
+ children: [
316
+ /* @__PURE__ */ jsx("span", {
317
+ className: "truncate text-caption text-foreground",
318
+ children: file.name
319
+ }),
320
+ /* @__PURE__ */ jsxs("span", {
321
+ className: "truncate text-micro tabular-nums text-muted-foreground",
322
+ children: [
323
+ bytes(file.size),
324
+ " · ",
325
+ short(now - file.addedAt)
326
+ ]
327
+ })
328
+ ]
329
+ })
330
+ ]
331
+ }, file.id))
332
+ });
333
+ }
334
+ function RecentFilesLeading2({ source = "downloads" }) {
335
+ const Icon = SOURCE_ICON[source];
336
+ return /* @__PURE__ */ jsx(Icon, {
337
+ size: 16,
338
+ strokeWidth: 1.5,
339
+ className: "text-foreground"
340
+ });
341
+ }
342
+ function RecentFilesTrailing2({ download, count = 0 }) {
343
+ return /* @__PURE__ */ jsx("span", {
344
+ className: "text-caption weight-semibold tabular-nums text-foreground",
345
+ children: download ? `${Math.round(download.received / download.total * 100)}%` : count
346
+ });
347
+ }
348
+ function RecentFilesMinimal2({ download }) {
349
+ const share = download.received / download.total;
350
+ return /* @__PURE__ */ jsx(Meter, {
351
+ variant: "ring",
352
+ className: "size-5.5",
353
+ size: "compact",
354
+ tone: "default",
355
+ value: share,
356
+ label: `${download.name}, ${Math.round(share * 100)}%`
357
+ });
358
+ }
359
+ function RecentFilesSaved2({ file, onOpen }) {
360
+ return /* @__PURE__ */ jsx(IslandFlash2, {
361
+ icon: /* @__PURE__ */ jsx(Thumbnail, {
362
+ file,
363
+ glyph: 16,
364
+ className: "size-9 rounded-lg"
365
+ }),
366
+ title: file.source === "screenshots" ? "Screenshot saved" : "Downloaded",
367
+ caption: `${file.name} · ${bytes(file.size)}`,
368
+ action: onOpen && /* @__PURE__ */ jsx(Button, {
369
+ variant: "secondary",
370
+ size: "compact",
371
+ onClick: () => onOpen(file),
372
+ children: "Open"
373
+ })
374
+ });
375
+ }
376
+ var RecentFiles2 = Object.assign(function RecentFiles(props) {
377
+ const {
378
+ files,
379
+ download,
380
+ value: valueProp,
381
+ defaultValue = "downloads",
382
+ onValueChange,
383
+ onOpen,
384
+ onDragStart,
385
+ onClear,
386
+ onCancelDownload,
387
+ now: nowProp,
388
+ layout = "fit",
389
+ size,
390
+ className
391
+ } = props;
392
+ const ticking = useEdgeClock2(0, nowProp === undefined, MINUTE2);
393
+ const now = nowProp ?? ticking;
394
+ const [source, setSource] = useControllableState(valueProp, defaultValue, onValueChange);
395
+ const step = size ?? "default";
396
+ const shown = files.filter((file) => file.source === source).sort((a, b) => b.addedAt - a.addedAt);
397
+ const active = source === "downloads" ? download : undefined;
398
+ const [newest, ...rest] = shown;
399
+ const earlier = active ? shown : rest;
400
+ const limit = source === "screenshots" ? TILES : ROWS;
401
+ const empty = !newest && !active;
402
+ const header = /* @__PURE__ */ jsx(widget_default.Header, {
403
+ icon: SOURCE_ICON[source],
404
+ children: active ? ["Downloading", active.from].filter(Boolean).join(" · ") : [SOURCE_LABEL[source], shown.length && `${shown.length} ${shown.length === 1 ? "file" : "files"}`].filter(Boolean).join(" · ")
405
+ });
406
+ const media = active ? /* @__PURE__ */ jsx(Thumbnail, {
407
+ file: active,
408
+ className: TILE[step]
409
+ }) : newest ? /* @__PURE__ */ jsx("span", {
410
+ ...dragOf(newest, onDragStart),
411
+ className: cn(onDragStart && "cursor-grab"),
412
+ children: /* @__PURE__ */ jsx(Thumbnail, {
413
+ file: newest,
414
+ className: TILE[step]
415
+ })
416
+ }) : /* @__PURE__ */ jsx(Empty, {
417
+ source,
418
+ className: TILE[step]
419
+ });
420
+ const tabs = /* @__PURE__ */ jsx(Tabs, {
421
+ variant: "subtle",
422
+ size: "compact",
423
+ value: source,
424
+ onValueChange: (v) => setSource(v),
425
+ children: /* @__PURE__ */ jsxs(Tabs.List, {
426
+ className: "-ml-2",
427
+ children: [
428
+ /* @__PURE__ */ jsx(Tabs.Item, {
429
+ value: "downloads",
430
+ label: "Downloads"
431
+ }),
432
+ /* @__PURE__ */ jsx(Tabs.Item, {
433
+ value: "screenshots",
434
+ label: "Screenshots"
435
+ })
436
+ ]
437
+ })
438
+ });
439
+ const clear = onClear && !empty && /* @__PURE__ */ jsx(Button, {
440
+ variant: "ghost",
441
+ size: "compact",
442
+ className: "-mr-2 h-6 px-2",
443
+ onClick: () => onClear(source),
444
+ children: "Clear"
445
+ });
446
+ const nothing = /* @__PURE__ */ jsxs("div", {
447
+ className: "flex min-w-0 flex-col gap-0.5",
448
+ children: [
449
+ /* @__PURE__ */ jsx(widget_default.Title, {
450
+ children: source === "downloads" ? "No downloads yet" : "No screenshots yet"
451
+ }),
452
+ /* @__PURE__ */ jsx("span", {
453
+ className: "text-pretty text-caption text-muted-foreground",
454
+ children: source === "downloads" ? "Files you download land here, ready to open or drag out." : "Take one with ⇧⌘4 and it shows up here, ready to drag into a message."
455
+ })
456
+ ]
457
+ });
458
+ if (layout === "tall")
459
+ return /* @__PURE__ */ jsxs(widget_default.Sheet, {
460
+ size,
461
+ className,
462
+ children: [
463
+ /* @__PURE__ */ jsxs("div", {
464
+ className: "flex min-w-0 items-center justify-between gap-2",
465
+ children: [
466
+ tabs,
467
+ clear
468
+ ]
469
+ }),
470
+ /* @__PURE__ */ jsxs("div", {
471
+ className: "flex min-w-0 items-center gap-6",
472
+ children: [
473
+ active ? /* @__PURE__ */ jsx(Thumbnail, {
474
+ file: active,
475
+ glyph: 40,
476
+ className: SHEET_TILE[step]
477
+ }) : newest ? /* @__PURE__ */ jsx("span", {
478
+ ...dragOf(newest, onDragStart),
479
+ className: cn("shrink-0", onDragStart && "cursor-grab"),
480
+ children: /* @__PURE__ */ jsx(Thumbnail, {
481
+ file: newest,
482
+ glyph: 40,
483
+ className: SHEET_TILE[step]
484
+ })
485
+ }) : /* @__PURE__ */ jsx(Empty, {
486
+ source,
487
+ className: SHEET_TILE[step]
488
+ }),
489
+ /* @__PURE__ */ jsxs("div", {
490
+ className: "flex min-w-0 flex-1 flex-col gap-1",
491
+ children: [
492
+ header,
493
+ active ? /* @__PURE__ */ jsx(Downloading, {
494
+ download: active,
495
+ onCancel: onCancelDownload
496
+ }) : newest ? /* @__PURE__ */ jsx(Hero, {
497
+ file: newest,
498
+ now,
499
+ props
500
+ }) : nothing
501
+ ]
502
+ })
503
+ ]
504
+ }),
505
+ earlier.length > 0 && /* @__PURE__ */ jsx(widget_default.Section, {
506
+ label: active ? "Latest" : "Earlier",
507
+ trailing: /* @__PURE__ */ jsx("span", {
508
+ className: "tabular-nums",
509
+ children: earlier.length
510
+ }),
511
+ children: /* @__PURE__ */ jsx("div", {
512
+ className: "pt-1.5",
513
+ children: /* @__PURE__ */ jsx(Grid, {
514
+ files: earlier,
515
+ now,
516
+ onOpen,
517
+ onDragStart
518
+ })
519
+ })
520
+ })
521
+ ]
522
+ });
523
+ return /* @__PURE__ */ jsxs(widget_default, {
524
+ size,
525
+ className: cn("h-full", className),
526
+ media,
527
+ aside: /* @__PURE__ */ jsxs("div", {
528
+ className: "flex min-w-0 flex-col gap-1.5",
529
+ children: [
530
+ /* @__PURE__ */ jsxs("div", {
531
+ className: "flex min-w-0 items-center justify-between gap-2",
532
+ children: [
533
+ tabs,
534
+ /* @__PURE__ */ jsxs("span", {
535
+ className: "flex shrink-0 items-center gap-1.5 text-caption tabular-nums text-muted-foreground",
536
+ children: [
537
+ earlier.length > limit && /* @__PURE__ */ jsxs("span", {
538
+ children: [
539
+ earlier.length - limit,
540
+ " more"
541
+ ]
542
+ }),
543
+ clear
544
+ ]
545
+ })
546
+ ]
547
+ }),
548
+ empty ? null : earlier.length === 0 ? /* @__PURE__ */ jsx("span", {
549
+ className: "flex h-7 items-center text-body text-muted-foreground",
550
+ children: "Nothing earlier"
551
+ }) : source === "screenshots" ? /* @__PURE__ */ jsx(Tiles, {
552
+ files: earlier,
553
+ onOpen,
554
+ onDragStart
555
+ }) : /* @__PURE__ */ jsx(Rows, {
556
+ files: earlier,
557
+ now,
558
+ onOpen,
559
+ onDragStart
560
+ })
561
+ ]
562
+ }),
563
+ children: [
564
+ header,
565
+ active ? /* @__PURE__ */ jsx(Downloading, {
566
+ download: active,
567
+ onCancel: onCancelDownload
568
+ }) : newest ? /* @__PURE__ */ jsx(Hero, {
569
+ file: newest,
570
+ now,
571
+ props
572
+ }) : nothing
573
+ ]
574
+ });
575
+ }, {
576
+ Leading: RecentFilesLeading2,
577
+ Trailing: RecentFilesTrailing2,
578
+ Minimal: RecentFilesMinimal2,
579
+ Saved: RecentFilesSaved2
580
+ });
581
+ var recent_files_default = RecentFiles2;
582
+ export { RecentFilesLeading2, RecentFilesTrailing2, RecentFilesMinimal2, RecentFilesSaved2, RecentFiles2, recent_files_default };
@@ -0,0 +1,25 @@
1
+ import { ReactNode } from "react";
2
+ /** A track's picture: an image URL or any element; `null` when the track has none, `undefined` while it isn't known yet. */
3
+ type Artwork2 = string | ReactNode;
4
+ /** What the artwork tile shows: a picture, or the placeholder (`art: null`), under an `id` that changes only when the picture does. */
5
+ interface ShownArtwork2 {
6
+ id: string;
7
+ art: Artwork2 | null;
8
+ }
9
+ /**
10
+ * The artwork to show for the track `trackKey` names, held across updates.
11
+ *
12
+ * A URL is decoded before it replaces what's shown, so the swap is never to
13
+ * a blank. An update without artwork (`undefined`, or `null` for the same
14
+ * track) keeps the last good picture. A new track with `null`, or a URL that
15
+ * fails to load for a new track, shows the placeholder.
16
+ */
17
+ declare function useStableArtwork2(artwork: Artwork2 | null | undefined, trackKey: string): ShownArtwork2;
18
+ /**
19
+ * The color an image URL leans to, as `rgb(…)`: its pixels averaged, the
20
+ * vivid ones weighted up, so a mostly grey cover still lends its accent.
21
+ * Read once per URL; `undefined` until then, or when the image can't be
22
+ * read (a cross-origin image without CORS).
23
+ */
24
+ declare function useArtworkTint2(src?: string): string | undefined;
25
+ export { Artwork2, ShownArtwork2, useStableArtwork2, useArtworkTint2 };