@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,765 @@
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/clipboard/index.tsx
15
+ import Button from "@justanarthur/modo-ui/components/actions/button";
16
+ import Input from "@justanarthur/modo-ui/components/inputs/input";
17
+ import { SURFACE_BG } from "@justanarthur/modo-ui/lib/surface-classes";
18
+ import { useLift } from "@justanarthur/modo-ui/lib/surface-context";
19
+ import { useControllableState } from "@justanarthur/modo-ui/lib/use-controllable-state";
20
+ import { cn } from "@justanarthur/modo-ui/lib/utils";
21
+ import FluidHover from "@justanarthur/modo-ui/primitives/systems/fluid-hover";
22
+ import { ClipboardList, Copy, File, Image, Link2, Palette, Pause, Pin, Play, Search, Trash2, Type } from "lucide-react";
23
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
24
+ /*!
25
+ * Local addition: a notch app's clipboard history, the latest clip as the
26
+ * hero and the ones before it beside it, pinned ones on top. Presentational:
27
+ * the clips and what to do with them come in as props.
28
+ */
29
+ var ROWS = 3;
30
+ var KIND_ICON = {
31
+ text: Type,
32
+ link: Link2,
33
+ image: Image,
34
+ color: Palette,
35
+ file: File
36
+ };
37
+ var KIND_LABEL = {
38
+ text: "Text",
39
+ link: "Link",
40
+ image: "Image",
41
+ color: "Color",
42
+ file: "File"
43
+ };
44
+ function ago(ms) {
45
+ const minutes = Math.floor(ms / MINUTE2);
46
+ if (minutes < 1)
47
+ return "just now";
48
+ if (minutes < 60)
49
+ return `${minutes} min ago`;
50
+ if (minutes < 24 * 60)
51
+ return `${Math.floor(minutes / 60)} h ago`;
52
+ return `${Math.floor(minutes / (24 * 60))} d ago`;
53
+ }
54
+ function short(ms) {
55
+ const minutes = Math.floor(ms / MINUTE2);
56
+ if (minutes < 1)
57
+ return "now";
58
+ if (minutes < 60)
59
+ return `${minutes}m`;
60
+ if (minutes < 24 * 60)
61
+ return `${Math.floor(minutes / 60)}h`;
62
+ return `${Math.floor(minutes / (24 * 60))}d`;
63
+ }
64
+ function domain(url) {
65
+ try {
66
+ return new URL(url).hostname.replace(/^www\./, "");
67
+ } catch {
68
+ return url;
69
+ }
70
+ }
71
+ function path(url) {
72
+ try {
73
+ const { pathname, search } = new URL(url);
74
+ return `${pathname}${search}`.replace(/^\/$/, "");
75
+ } catch {
76
+ return "";
77
+ }
78
+ }
79
+ var paint = (clip) => clip.color ?? clip.content;
80
+ function Picture({ preview, className }) {
81
+ return /* @__PURE__ */ jsxs("span", {
82
+ className: cn("relative block shrink-0 overflow-hidden", className),
83
+ children: [
84
+ typeof preview === "string" ? /* @__PURE__ */ jsx("img", {
85
+ alt: "",
86
+ src: preview,
87
+ draggable: false,
88
+ className: "size-full object-cover"
89
+ }) : preview,
90
+ /* @__PURE__ */ jsx("span", {
91
+ "aria-hidden": true,
92
+ className: "pointer-events-none absolute inset-0 rounded-[inherit] ring-1 ring-border ring-inset"
93
+ })
94
+ ]
95
+ });
96
+ }
97
+ function Mark({ clip }) {
98
+ if (clip.kind === "color")
99
+ return /* @__PURE__ */ jsx("span", {
100
+ "aria-hidden": true,
101
+ className: "size-3.5 shrink-0 rounded-full",
102
+ style: { backgroundColor: paint(clip) }
103
+ });
104
+ if (clip.preview != null)
105
+ return /* @__PURE__ */ jsx(Picture, {
106
+ preview: clip.preview,
107
+ className: "size-4 rounded-sm"
108
+ });
109
+ const Icon = KIND_ICON[clip.kind];
110
+ return /* @__PURE__ */ jsx(Icon, {
111
+ size: 14,
112
+ strokeWidth: 1.5,
113
+ className: "shrink-0 text-muted-foreground"
114
+ });
115
+ }
116
+ var hasMedia = (clip) => clip.kind === "image" || clip.kind === "color" || clip.kind === "file";
117
+ function Media({ clip }) {
118
+ const level = useLift(1);
119
+ if (clip.kind === "image" && clip.preview != null)
120
+ return /* @__PURE__ */ jsx(Picture, {
121
+ preview: clip.preview,
122
+ className: "h-24 w-36 rounded-xl"
123
+ });
124
+ if (clip.kind === "color")
125
+ return /* @__PURE__ */ jsx("span", {
126
+ "aria-hidden": true,
127
+ className: "size-24 shrink-0 rounded-xl ring-1 ring-border ring-inset",
128
+ style: { backgroundColor: paint(clip) }
129
+ });
130
+ if (clip.kind === "file" || clip.kind === "image")
131
+ return /* @__PURE__ */ jsx("span", {
132
+ className: cn("flex size-24 items-center justify-center rounded-xl text-muted-foreground", SURFACE_BG[level]),
133
+ children: clip.kind === "file" ? /* @__PURE__ */ jsx(File, {
134
+ size: 28,
135
+ strokeWidth: 1.25
136
+ }) : /* @__PURE__ */ jsx(Image, {
137
+ size: 28,
138
+ strokeWidth: 1.25
139
+ })
140
+ });
141
+ return null;
142
+ }
143
+ function Body({ clip }) {
144
+ if (clip.kind === "text")
145
+ return /* @__PURE__ */ jsx("p", {
146
+ className: "line-clamp-2 min-w-0 text-title weight-medium break-words text-foreground",
147
+ children: clip.content
148
+ });
149
+ if (clip.kind === "link")
150
+ return /* @__PURE__ */ jsxs("div", {
151
+ className: "flex min-w-0 flex-col gap-0.5",
152
+ children: [
153
+ /* @__PURE__ */ jsx(widget_default.Title, {
154
+ leading: clip.preview != null && /* @__PURE__ */ jsx(Picture, {
155
+ preview: clip.preview,
156
+ className: "size-4 rounded-sm"
157
+ }),
158
+ children: domain(clip.content)
159
+ }),
160
+ clip.detail && /* @__PURE__ */ jsx(widget_default.Subtitle, {
161
+ children: clip.detail
162
+ })
163
+ ]
164
+ });
165
+ return /* @__PURE__ */ jsxs("div", {
166
+ className: "flex min-w-0 flex-col gap-0.5",
167
+ children: [
168
+ /* @__PURE__ */ jsx(widget_default.Title, {
169
+ className: cn(clip.kind === "color" && "font-mono"),
170
+ children: clip.content
171
+ }),
172
+ clip.detail && /* @__PURE__ */ jsx(widget_default.Subtitle, {
173
+ children: clip.detail
174
+ })
175
+ ]
176
+ });
177
+ }
178
+ function fact(clip) {
179
+ if (clip.kind === "text")
180
+ return `${clip.content.length} characters`;
181
+ if (clip.kind === "link")
182
+ return path(clip.content);
183
+ return;
184
+ }
185
+ function Actions({ clip, pinned, onPin, onCopy, onDelete }) {
186
+ return /* @__PURE__ */ jsxs("div", {
187
+ className: "-mr-1 flex shrink-0 items-center gap-0.5",
188
+ children: [
189
+ /* @__PURE__ */ jsx(widget_default.Action, {
190
+ icon: Pin,
191
+ label: pinned ? "Unpin" : "Pin",
192
+ pressed: pinned,
193
+ onClick: onPin
194
+ }),
195
+ onDelete && /* @__PURE__ */ jsx(widget_default.Action, {
196
+ icon: Trash2,
197
+ label: "Delete",
198
+ onClick: () => onDelete(clip)
199
+ }),
200
+ /* @__PURE__ */ jsx(Button, {
201
+ variant: "primary",
202
+ size: "compact",
203
+ leadingIcon: Copy,
204
+ className: "ml-1.5",
205
+ onClick: () => onCopy?.(clip),
206
+ children: "Copy"
207
+ })
208
+ ]
209
+ });
210
+ }
211
+ function Hero(props) {
212
+ const { clip } = props;
213
+ const line = fact(clip);
214
+ return /* @__PURE__ */ jsxs("div", {
215
+ className: "flex min-w-0 flex-col gap-2",
216
+ children: [
217
+ /* @__PURE__ */ jsx(Body, {
218
+ clip
219
+ }),
220
+ /* @__PURE__ */ jsxs("div", {
221
+ className: "flex min-w-0 items-center justify-between gap-3",
222
+ children: [
223
+ /* @__PURE__ */ jsx(widget_default.Meta, {
224
+ children: line && /* @__PURE__ */ jsx(widget_default.MetaItem, {
225
+ icon: KIND_ICON[clip.kind],
226
+ children: line
227
+ })
228
+ }),
229
+ /* @__PURE__ */ jsx(Actions, {
230
+ ...props
231
+ })
232
+ ]
233
+ })
234
+ ]
235
+ });
236
+ }
237
+ function List({ order, selected, pinned, now, searching, onPick, onCopy }) {
238
+ const level = useLift(1);
239
+ if (!order.length)
240
+ return /* @__PURE__ */ jsx("span", {
241
+ className: "flex h-7 items-center text-body text-muted-foreground",
242
+ children: "No clips match"
243
+ });
244
+ const start = Math.max(0, Math.min(selected - ROWS + 1, order.length - ROWS));
245
+ const shown = order.slice(start, start + ROWS);
246
+ const more = order.length - start - shown.length;
247
+ const groups = [
248
+ { label: "Pinned", clips: shown.filter((clip) => pinned.includes(clip.id)) },
249
+ { label: searching ? "Matches" : "Recent", clips: shown.filter((clip) => !pinned.includes(clip.id)) }
250
+ ].filter((group) => group.clips.length);
251
+ return /* @__PURE__ */ jsx(FluidHover, {
252
+ className: "-mx-2 flex flex-col gap-0",
253
+ role: "listbox",
254
+ "aria-label": "Clipboard history",
255
+ children: groups.map((group, g) => /* @__PURE__ */ jsxs("div", {
256
+ role: "presentation",
257
+ className: "flex min-w-0 flex-col",
258
+ children: [
259
+ /* @__PURE__ */ jsxs("div", {
260
+ className: "flex h-6 items-center justify-between px-2 text-caption text-muted-foreground",
261
+ children: [
262
+ /* @__PURE__ */ jsx("span", {
263
+ children: group.label
264
+ }),
265
+ g === groups.length - 1 && more > 0 && /* @__PURE__ */ jsxs("span", {
266
+ className: "tabular-nums",
267
+ children: [
268
+ more,
269
+ " more"
270
+ ]
271
+ })
272
+ ]
273
+ }),
274
+ group.clips.map((clip) => {
275
+ const index = order.indexOf(clip);
276
+ const current = index === selected;
277
+ return /* @__PURE__ */ jsx(FluidHover.Item, {
278
+ index: index - start,
279
+ role: "option",
280
+ "aria-selected": current,
281
+ tabIndex: -1,
282
+ className: cn("h-7 px-2", current && SURFACE_BG[level]),
283
+ onClick: () => onPick(clip.id),
284
+ onDoubleClick: () => onCopy?.(clip),
285
+ children: /* @__PURE__ */ jsx(widget_default.Row, {
286
+ className: "w-full",
287
+ trailing: /* @__PURE__ */ jsxs(Fragment, {
288
+ children: [
289
+ pinned.includes(clip.id) && /* @__PURE__ */ jsx(Pin, {
290
+ size: 11,
291
+ strokeWidth: 1.5,
292
+ "aria-label": "Pinned"
293
+ }),
294
+ /* @__PURE__ */ jsx("span", {
295
+ className: "w-6 text-right tabular-nums",
296
+ children: short(now - clip.copiedAt)
297
+ })
298
+ ]
299
+ }),
300
+ children: /* @__PURE__ */ jsxs("span", {
301
+ className: "flex min-w-0 items-center gap-2",
302
+ children: [
303
+ /* @__PURE__ */ jsx(Mark, {
304
+ clip
305
+ }),
306
+ /* @__PURE__ */ jsx("span", {
307
+ className: "min-w-0 truncate",
308
+ children: clip.kind === "link" ? domain(clip.content) : clip.content
309
+ })
310
+ ]
311
+ })
312
+ })
313
+ }, clip.id);
314
+ })
315
+ ]
316
+ }, group.label))
317
+ });
318
+ }
319
+ function Tile({ clip }) {
320
+ const level = useLift(1);
321
+ if (clip.kind === "color")
322
+ return /* @__PURE__ */ jsx("span", {
323
+ "aria-hidden": true,
324
+ className: "size-8 shrink-0 rounded-lg ring-1 ring-border ring-inset",
325
+ style: { backgroundColor: paint(clip) }
326
+ });
327
+ if (clip.kind === "image" && clip.preview != null)
328
+ return /* @__PURE__ */ jsx(Picture, {
329
+ preview: clip.preview,
330
+ className: "size-8 rounded-lg"
331
+ });
332
+ const Icon = KIND_ICON[clip.kind];
333
+ return /* @__PURE__ */ jsx("span", {
334
+ className: cn("flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground", SURFACE_BG[level]),
335
+ children: clip.kind === "link" && clip.preview != null ? /* @__PURE__ */ jsx(Picture, {
336
+ preview: clip.preview,
337
+ className: "size-4 rounded-sm"
338
+ }) : /* @__PURE__ */ jsx(Icon, {
339
+ size: 15,
340
+ strokeWidth: 1.5
341
+ })
342
+ });
343
+ }
344
+ function SheetList({ order, selected, pinned, now, searching, onPick, onCopy }) {
345
+ const level = useLift(1);
346
+ if (!order.length)
347
+ return /* @__PURE__ */ jsx("span", {
348
+ className: "flex h-12 items-center text-body text-muted-foreground",
349
+ children: "No clips match"
350
+ });
351
+ const groups = [
352
+ { label: "Pinned", clips: order.filter((clip) => pinned.includes(clip.id)) },
353
+ { label: searching ? "Matches" : "Recent", clips: order.filter((clip) => !pinned.includes(clip.id)) }
354
+ ].filter((group) => group.clips.length);
355
+ return /* @__PURE__ */ jsx(FluidHover, {
356
+ className: "-mx-2 flex flex-col gap-0",
357
+ role: "listbox",
358
+ "aria-label": "Clipboard history",
359
+ children: groups.map((group) => /* @__PURE__ */ jsxs("div", {
360
+ role: "presentation",
361
+ className: "flex min-w-0 flex-col",
362
+ children: [
363
+ /* @__PURE__ */ jsxs("div", {
364
+ className: "flex h-7 items-end justify-between px-2 pb-1 text-caption text-muted-foreground",
365
+ children: [
366
+ /* @__PURE__ */ jsx("span", {
367
+ children: group.label
368
+ }),
369
+ /* @__PURE__ */ jsx("span", {
370
+ className: "tabular-nums",
371
+ children: group.clips.length
372
+ })
373
+ ]
374
+ }),
375
+ group.clips.map((clip) => {
376
+ const index = order.indexOf(clip);
377
+ const current = index === selected;
378
+ return /* @__PURE__ */ jsx(FluidHover.Item, {
379
+ index,
380
+ role: "option",
381
+ "aria-selected": current,
382
+ tabIndex: -1,
383
+ className: cn("h-12 px-2", current && SURFACE_BG[level]),
384
+ onClick: () => onPick(clip.id),
385
+ onDoubleClick: () => onCopy?.(clip),
386
+ children: /* @__PURE__ */ jsxs("span", {
387
+ className: "flex w-full min-w-0 items-center gap-3",
388
+ children: [
389
+ /* @__PURE__ */ jsx(Tile, {
390
+ clip
391
+ }),
392
+ /* @__PURE__ */ jsxs("span", {
393
+ className: "flex min-w-0 flex-1 flex-col",
394
+ children: [
395
+ /* @__PURE__ */ jsx("span", {
396
+ className: "truncate text-body text-foreground",
397
+ children: clip.kind === "link" ? clip.detail ?? domain(clip.content) : clip.content
398
+ }),
399
+ /* @__PURE__ */ jsx("span", {
400
+ className: "truncate text-caption text-muted-foreground",
401
+ children: [
402
+ clip.kind === "link" ? domain(clip.content) : clip.app ?? KIND_LABEL[clip.kind],
403
+ short(now - clip.copiedAt)
404
+ ].join(" · ")
405
+ })
406
+ ]
407
+ }),
408
+ pinned.includes(clip.id) && /* @__PURE__ */ jsx(Pin, {
409
+ size: 12,
410
+ strokeWidth: 1.5,
411
+ "aria-label": "Pinned",
412
+ className: "shrink-0 text-muted-foreground"
413
+ })
414
+ ]
415
+ })
416
+ }, clip.id);
417
+ })
418
+ ]
419
+ }, group.label))
420
+ });
421
+ }
422
+ function Full({ clip }) {
423
+ const level = useLift(1);
424
+ if (clip.kind === "text")
425
+ return /* @__PURE__ */ jsx("p", {
426
+ className: "line-clamp-8 min-w-0 whitespace-pre-wrap text-title weight-medium break-words text-foreground",
427
+ children: clip.content
428
+ });
429
+ if (clip.kind === "link")
430
+ return /* @__PURE__ */ jsxs("div", {
431
+ className: "flex min-w-0 flex-col gap-1",
432
+ children: [
433
+ /* @__PURE__ */ jsx(widget_default.Title, {
434
+ leading: clip.preview != null && /* @__PURE__ */ jsx(Picture, {
435
+ preview: clip.preview,
436
+ className: "size-5 rounded-md"
437
+ }),
438
+ children: clip.detail ?? domain(clip.content)
439
+ }),
440
+ /* @__PURE__ */ jsx("span", {
441
+ className: "min-w-0 text-body break-all text-muted-foreground",
442
+ children: clip.content
443
+ })
444
+ ]
445
+ });
446
+ const picture = clip.kind === "color" ? /* @__PURE__ */ jsx("span", {
447
+ "aria-hidden": true,
448
+ className: "block h-36 w-full rounded-2xl ring-1 ring-border ring-inset",
449
+ style: { backgroundColor: paint(clip) }
450
+ }) : clip.kind === "image" && clip.preview != null ? /* @__PURE__ */ jsx(Picture, {
451
+ preview: clip.preview,
452
+ className: "aspect-[16/10] w-full rounded-2xl"
453
+ }) : /* @__PURE__ */ jsx("span", {
454
+ className: cn("flex h-36 w-full items-center justify-center rounded-2xl text-muted-foreground", SURFACE_BG[level]),
455
+ children: clip.kind === "file" ? /* @__PURE__ */ jsx(File, {
456
+ size: 40,
457
+ strokeWidth: 1.25
458
+ }) : /* @__PURE__ */ jsx(Image, {
459
+ size: 40,
460
+ strokeWidth: 1.25
461
+ })
462
+ });
463
+ return /* @__PURE__ */ jsxs("div", {
464
+ className: "flex min-w-0 flex-col gap-3",
465
+ children: [
466
+ picture,
467
+ /* @__PURE__ */ jsxs("div", {
468
+ className: "flex min-w-0 flex-col gap-0.5",
469
+ children: [
470
+ /* @__PURE__ */ jsx(widget_default.Title, {
471
+ className: cn(clip.kind === "color" && "font-mono"),
472
+ children: clip.content
473
+ }),
474
+ clip.detail && /* @__PURE__ */ jsx(widget_default.Subtitle, {
475
+ children: clip.detail
476
+ })
477
+ ]
478
+ })
479
+ ]
480
+ });
481
+ }
482
+ function Facts({ clip }) {
483
+ const words = clip.content.trim().split(/\s+/).length;
484
+ return /* @__PURE__ */ jsxs(widget_default.Meta, {
485
+ children: [
486
+ /* @__PURE__ */ jsx(widget_default.MetaItem, {
487
+ icon: KIND_ICON[clip.kind],
488
+ children: KIND_LABEL[clip.kind]
489
+ }),
490
+ clip.kind === "text" && /* @__PURE__ */ jsxs(widget_default.MetaItem, {
491
+ children: [
492
+ words,
493
+ " ",
494
+ words === 1 ? "word" : "words",
495
+ " · ",
496
+ clip.content.length,
497
+ " characters"
498
+ ]
499
+ }),
500
+ clip.kind === "link" && /* @__PURE__ */ jsx(widget_default.MetaItem, {
501
+ children: domain(clip.content)
502
+ }),
503
+ /* @__PURE__ */ jsxs(widget_default.MetaItem, {
504
+ children: [
505
+ "Copied ",
506
+ new Date(clip.copiedAt).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })
507
+ ]
508
+ })
509
+ ]
510
+ });
511
+ }
512
+ function Detail(props) {
513
+ const { clip, now } = props;
514
+ return /* @__PURE__ */ jsxs("div", {
515
+ className: "sticky top-0 flex min-w-0 flex-col gap-3",
516
+ children: [
517
+ /* @__PURE__ */ jsx(widget_default.Header, {
518
+ icon: KIND_ICON[clip.kind],
519
+ children: [clip.app ?? KIND_LABEL[clip.kind], ago(now - clip.copiedAt)].join(" · ")
520
+ }),
521
+ /* @__PURE__ */ jsx(Full, {
522
+ clip
523
+ }),
524
+ /* @__PURE__ */ jsx(Facts, {
525
+ clip
526
+ }),
527
+ /* @__PURE__ */ jsx("div", {
528
+ className: "flex justify-end pt-1",
529
+ children: /* @__PURE__ */ jsx(Actions, {
530
+ ...props
531
+ })
532
+ })
533
+ ]
534
+ });
535
+ }
536
+ function ClipboardHistoryLeading2() {
537
+ return /* @__PURE__ */ jsx(ClipboardList, {
538
+ size: 16,
539
+ strokeWidth: 1.5,
540
+ className: "text-foreground"
541
+ });
542
+ }
543
+ function ClipboardHistoryTrailing2({ count }) {
544
+ return /* @__PURE__ */ jsxs("span", {
545
+ className: "text-caption weight-semibold tabular-nums text-foreground",
546
+ children: [
547
+ count,
548
+ /* @__PURE__ */ jsx("span", {
549
+ className: "sr-only",
550
+ children: " new clips"
551
+ })
552
+ ]
553
+ });
554
+ }
555
+ function ClipboardHistoryCopied2({ clip, onPin }) {
556
+ const level = useLift(1);
557
+ const Icon = KIND_ICON[clip.kind];
558
+ const tile = clip.kind === "color" ? /* @__PURE__ */ jsx("span", {
559
+ "aria-hidden": true,
560
+ className: "size-9 rounded-lg ring-1 ring-border ring-inset",
561
+ style: { backgroundColor: paint(clip) }
562
+ }) : clip.kind === "image" && clip.preview != null ? /* @__PURE__ */ jsx(Picture, {
563
+ preview: clip.preview,
564
+ className: "size-9 rounded-lg"
565
+ }) : /* @__PURE__ */ jsx("span", {
566
+ className: cn("flex size-9 items-center justify-center rounded-lg text-muted-foreground", SURFACE_BG[level]),
567
+ children: /* @__PURE__ */ jsx(Icon, {
568
+ size: 16,
569
+ strokeWidth: 1.5
570
+ })
571
+ });
572
+ return /* @__PURE__ */ jsx(IslandFlash2, {
573
+ icon: tile,
574
+ title: `Copied ${KIND_LABEL[clip.kind].toLowerCase()}`,
575
+ caption: clip.kind === "link" ? domain(clip.content) : clip.content,
576
+ action: onPin && /* @__PURE__ */ jsx(Button, {
577
+ variant: "secondary",
578
+ size: "compact",
579
+ leadingIcon: Pin,
580
+ onClick: () => onPin(clip),
581
+ children: "Pin"
582
+ })
583
+ });
584
+ }
585
+ var ClipboardHistory2 = Object.assign(function ClipboardHistory({
586
+ clips,
587
+ value: valueProp,
588
+ defaultValue,
589
+ onValueChange,
590
+ pinned: pinnedProp,
591
+ defaultPinned = [],
592
+ onPinnedChange,
593
+ query: queryProp,
594
+ defaultQuery = "",
595
+ onQueryChange,
596
+ paused: pausedProp,
597
+ defaultPaused = false,
598
+ onPausedChange,
599
+ ignoredApp,
600
+ onCopy,
601
+ onDelete,
602
+ now: nowProp,
603
+ layout = "fit",
604
+ size,
605
+ className
606
+ }) {
607
+ const ticking = useEdgeClock2(0, nowProp === undefined, MINUTE2);
608
+ const now = nowProp ?? ticking;
609
+ const [value, setValue] = useControllableState(valueProp, defaultValue, onValueChange);
610
+ const [pinned, setPinned] = useControllableState(pinnedProp, defaultPinned, onPinnedChange);
611
+ const [query, setQuery] = useControllableState(queryProp, defaultQuery, onQueryChange);
612
+ const [paused, setPaused] = useControllableState(pausedProp, defaultPaused, onPausedChange);
613
+ const status = /* @__PURE__ */ jsxs(Fragment, {
614
+ children: [
615
+ paused ? /* @__PURE__ */ jsx(widget_default.Chip, {
616
+ children: "Paused"
617
+ }) : ignoredApp && /* @__PURE__ */ jsxs(widget_default.Chip, {
618
+ children: [
619
+ "Ignoring ",
620
+ ignoredApp
621
+ ]
622
+ }),
623
+ /* @__PURE__ */ jsx(widget_default.Action, {
624
+ icon: paused ? Play : Pause,
625
+ label: paused ? "Resume history" : "Pause history",
626
+ onClick: () => setPaused(!paused)
627
+ })
628
+ ]
629
+ });
630
+ if (!clips.length)
631
+ return /* @__PURE__ */ jsx(widget_default.Message, {
632
+ icon: paused ? Pause : ClipboardList,
633
+ title: paused ? "Clipboard history is paused" : "Copy something",
634
+ description: paused ? "Nothing you copy is kept until you resume." : "Text, links, images and colors you copy show up here, newest first.",
635
+ actions: paused && /* @__PURE__ */ jsx(Button, {
636
+ variant: "secondary",
637
+ size: "compact",
638
+ leadingIcon: Play,
639
+ onClick: () => setPaused(false),
640
+ children: "Resume"
641
+ }),
642
+ className
643
+ });
644
+ const needle = query.trim().toLowerCase();
645
+ const matches = needle ? clips.filter((clip) => [clip.content, clip.detail, clip.app].some((s) => s?.toLowerCase().includes(needle))) : clips;
646
+ const newest = [...matches].sort((a, b) => b.copiedAt - a.copiedAt);
647
+ const order = [
648
+ ...newest.filter((clip) => pinned.includes(clip.id)),
649
+ ...newest.filter((clip) => !pinned.includes(clip.id))
650
+ ];
651
+ const found = order.findIndex((clip) => clip.id === value);
652
+ const selected = found < 0 ? Math.max(0, order.indexOf(newest[0])) : found;
653
+ const hero = order[selected] ?? clips[0];
654
+ const heroPinned = pinned.includes(hero.id);
655
+ const togglePin = () => setPinned(heroPinned ? pinned.filter((id) => id !== hero.id) : [...pinned, hero.id]);
656
+ const onKeyDown = (event) => {
657
+ const step = event.key === "ArrowDown" ? 1 : event.key === "ArrowUp" ? -1 : 0;
658
+ if (step) {
659
+ event.preventDefault();
660
+ const next = order[Math.max(0, Math.min(order.length - 1, selected + step))];
661
+ if (next)
662
+ setValue(next.id);
663
+ return;
664
+ }
665
+ if (event.key === "Enter" && order[selected]) {
666
+ event.preventDefault();
667
+ onCopy?.(order[selected]);
668
+ }
669
+ };
670
+ const search = /* @__PURE__ */ jsx(Input, {
671
+ size: "compact",
672
+ icon: Search,
673
+ placeholder: "Search clips",
674
+ "aria-label": "Search clips",
675
+ value: query,
676
+ onValueChange: setQuery
677
+ });
678
+ const listProps = { order, selected, pinned, now, searching: !!needle, onPick: setValue, onCopy };
679
+ if (layout === "tall")
680
+ return /* @__PURE__ */ jsx("div", {
681
+ className: cn("flex min-w-0 flex-col", className),
682
+ onKeyDown,
683
+ children: /* @__PURE__ */ jsxs(widget_default.Sheet, {
684
+ size,
685
+ className: "gap-4",
686
+ children: [
687
+ /* @__PURE__ */ jsxs("div", {
688
+ className: "flex min-w-0 items-center gap-3",
689
+ children: [
690
+ /* @__PURE__ */ jsx("div", {
691
+ className: "min-w-0 flex-1",
692
+ children: search
693
+ }),
694
+ /* @__PURE__ */ jsx("span", {
695
+ className: "-mr-1 flex shrink-0 items-center gap-1.5",
696
+ children: status
697
+ })
698
+ ]
699
+ }),
700
+ /* @__PURE__ */ jsxs("div", {
701
+ className: "flex min-w-0 items-stretch gap-5",
702
+ children: [
703
+ /* @__PURE__ */ jsx("div", {
704
+ className: "w-[46%] min-w-0 shrink-0",
705
+ children: /* @__PURE__ */ jsx(SheetList, {
706
+ ...listProps
707
+ })
708
+ }),
709
+ /* @__PURE__ */ jsx("div", {
710
+ className: "min-w-0 flex-1 border-l border-border pl-5",
711
+ children: /* @__PURE__ */ jsx(Detail, {
712
+ clip: hero,
713
+ pinned: heroPinned,
714
+ onPin: togglePin,
715
+ onCopy,
716
+ onDelete,
717
+ now
718
+ })
719
+ })
720
+ ]
721
+ })
722
+ ]
723
+ })
724
+ });
725
+ return /* @__PURE__ */ jsx("div", {
726
+ className: cn("flex min-h-0 flex-col", className),
727
+ onKeyDown,
728
+ children: /* @__PURE__ */ jsxs(widget_default, {
729
+ size,
730
+ className: "flex-1",
731
+ aside: /* @__PURE__ */ jsxs("div", {
732
+ className: "flex min-w-0 flex-col gap-1",
733
+ children: [
734
+ search,
735
+ /* @__PURE__ */ jsx(List, {
736
+ ...listProps
737
+ })
738
+ ]
739
+ }),
740
+ media: hasMedia(hero) && /* @__PURE__ */ jsx(Media, {
741
+ clip: hero
742
+ }),
743
+ children: [
744
+ /* @__PURE__ */ jsx(widget_default.Header, {
745
+ icon: KIND_ICON[hero.kind],
746
+ trailing: status,
747
+ children: [hero.app ?? KIND_LABEL[hero.kind], ago(now - hero.copiedAt)].join(" · ")
748
+ }),
749
+ /* @__PURE__ */ jsx(Hero, {
750
+ clip: hero,
751
+ pinned: heroPinned,
752
+ onPin: togglePin,
753
+ onCopy,
754
+ onDelete
755
+ })
756
+ ]
757
+ })
758
+ });
759
+ }, {
760
+ Leading: ClipboardHistoryLeading2,
761
+ Trailing: ClipboardHistoryTrailing2,
762
+ Copied: ClipboardHistoryCopied2
763
+ });
764
+ var clipboard_default = ClipboardHistory2;
765
+ export { ClipboardHistoryLeading2, ClipboardHistoryTrailing2, ClipboardHistoryCopied2, ClipboardHistory2, clipboard_default };