@justanarthur/modo-ui-notch 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +75 -2
- package/blocks/activities/agenda/examples.mdx +74 -0
- package/blocks/activities/agenda/index.tsx +441 -0
- package/blocks/activities/clock/examples.mdx +73 -0
- package/blocks/activities/clock/index.tsx +619 -0
- package/blocks/activities/now-playing/examples.mdx +68 -0
- package/blocks/activities/now-playing/index.tsx +411 -0
- package/blocks/activities/weather/examples.mdx +115 -0
- package/blocks/activities/weather/index.tsx +634 -0
- package/blocks/app/expanded-island/examples.mdx +46 -0
- package/blocks/app/expanded-island/index.tsx +143 -0
- package/blocks/app/settings-window/examples.mdx +34 -0
- package/blocks/app/settings-window/index.tsx +375 -0
- package/blocks/system/clipboard/examples.mdx +83 -0
- package/blocks/system/clipboard/index.tsx +563 -0
- package/blocks/system/recent-files/examples.mdx +66 -0
- package/blocks/system/recent-files/index.tsx +542 -0
- package/blocks/system/system-stats/examples.mdx +52 -0
- package/blocks/system/system-stats/index.tsx +312 -0
- package/components/indicators/countdown/examples.mdx +25 -0
- package/components/indicators/countdown/index.tsx +83 -0
- package/components/indicators/equalizer/examples.mdx +20 -0
- package/components/indicators/equalizer/index.tsx +116 -0
- package/components/indicators/media-scrubber/examples.mdx +29 -0
- package/components/indicators/media-scrubber/index.tsx +122 -0
- package/components/island/island/examples.mdx +57 -0
- package/components/island/island/index.tsx +415 -0
- package/components/island/island-flash/examples.mdx +52 -0
- package/components/island/island-flash/index.tsx +79 -0
- package/components/island/island-tabs/examples.mdx +53 -0
- package/components/island/island-tabs/index.tsx +285 -0
- package/components/island/widget/examples.mdx +76 -0
- package/components/island/widget/index.tsx +431 -0
- package/dist/blocks/activities/agenda/index.d.ts +2 -0
- package/dist/blocks/activities/agenda/index.js +21 -0
- package/dist/blocks/activities/clock/index.d.ts +2 -0
- package/dist/blocks/activities/clock/index.js +25 -0
- package/dist/blocks/activities/now-playing/index.d.ts +3 -0
- package/dist/blocks/activities/now-playing/index.js +24 -0
- package/dist/blocks/activities/weather/index.d.ts +2 -0
- package/dist/blocks/activities/weather/index.js +21 -0
- package/dist/blocks/app/expanded-island/index.d.ts +3 -0
- package/dist/blocks/app/expanded-island/index.js +11 -0
- package/dist/blocks/app/settings-window/index.d.ts +2 -0
- package/dist/blocks/app/settings-window/index.js +7 -0
- package/dist/blocks/system/clipboard/index.d.ts +2 -0
- package/dist/blocks/system/clipboard/index.js +17 -0
- package/dist/blocks/system/recent-files/index.d.ts +2 -0
- package/dist/blocks/system/recent-files/index.js +19 -0
- package/dist/blocks/system/system-stats/index.d.ts +2 -0
- package/dist/blocks/system/system-stats/index.js +15 -0
- package/dist/components/indicators/countdown/index.d.ts +2 -0
- package/dist/components/indicators/countdown/index.js +8 -0
- package/dist/components/indicators/equalizer/index.d.ts +2 -0
- package/dist/components/indicators/equalizer/index.js +7 -0
- package/dist/components/indicators/media-scrubber/index.d.ts +2 -0
- package/dist/components/indicators/media-scrubber/index.js +8 -0
- package/dist/components/island/island/index.d.ts +3 -0
- package/dist/components/island/island/index.js +10 -0
- package/dist/components/island/island-flash/index.d.ts +2 -0
- package/dist/components/island/island-flash/index.js +7 -0
- package/dist/components/island/island-tabs/index.d.ts +2 -0
- package/dist/components/island/island-tabs/index.js +9 -0
- package/dist/components/island/widget/index.d.ts +2 -0
- package/dist/components/island/widget/index.js +30 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +195 -0
- package/dist/lib/artwork.d.ts +2 -0
- package/dist/lib/artwork.js +8 -0
- package/dist/lib/clock.d.ts +2 -0
- package/dist/lib/clock.js +14 -0
- package/dist/lib/geometry.d.ts +2 -0
- package/dist/lib/geometry.js +24 -0
- package/dist/lib/island-context.d.ts +3 -0
- package/dist/lib/island-context.js +8 -0
- package/dist/lib/motion.d.ts +21 -0
- package/dist/lib/motion.js +16 -0
- package/dist/shared/chunk-152gpyq3.d.ts +13 -0
- package/dist/shared/chunk-2818esrq.d.ts +140 -0
- package/dist/shared/chunk-2f7zxrbk.js +65 -0
- package/dist/shared/chunk-2m5dz8nf.d.ts +88 -0
- package/dist/shared/chunk-2s4q6mt0.js +27 -0
- package/dist/shared/chunk-3thgcfcq.d.ts +151 -0
- package/dist/shared/chunk-416tsgbc.d.ts +175 -0
- package/dist/shared/chunk-502rmtap.js +54 -0
- package/dist/shared/chunk-52gb3g6r.d.ts +12 -0
- package/dist/shared/chunk-5en5aaj1.d.ts +33 -0
- package/dist/shared/chunk-61t2dfte.js +63 -0
- package/dist/shared/chunk-7fvnrtz4.d.ts +105 -0
- package/dist/shared/chunk-81fpptwp.d.ts +75 -0
- package/dist/shared/chunk-9c7ewvkk.js +381 -0
- package/dist/shared/chunk-9m0xbg5v.js +112 -0
- package/dist/shared/chunk-9xtcv3sy.js +88 -0
- package/dist/shared/chunk-bvtyjcce.d.ts +123 -0
- package/dist/shared/chunk-cc9nwbtf.js +315 -0
- package/dist/shared/chunk-cfzmfnyh.d.ts +63 -0
- package/dist/shared/chunk-d5qm9cps.js +10 -0
- package/dist/shared/chunk-da177e8r.d.ts +114 -0
- package/dist/shared/chunk-fexwzycv.d.ts +36 -0
- package/dist/shared/chunk-gb56m10p.js +39 -0
- package/dist/shared/chunk-gejenfap.d.ts +25 -0
- package/dist/shared/chunk-hrpxbqmx.d.ts +28 -0
- package/dist/shared/chunk-j755a1a5.d.ts +41 -0
- package/dist/shared/chunk-j77cx8dp.js +498 -0
- package/dist/shared/chunk-mt0k6v8x.js +474 -0
- package/dist/shared/chunk-ndf79pv5.js +58 -0
- package/dist/shared/chunk-pfhy5e4q.d.ts +53 -0
- package/dist/shared/chunk-qdzemt2v.js +477 -0
- package/dist/shared/chunk-r471sknr.js +209 -0
- package/dist/shared/chunk-s2jeqqan.js +243 -0
- package/dist/shared/chunk-t0hcxh89.d.ts +124 -0
- package/dist/shared/chunk-w48eyvfr.d.ts +56 -0
- package/dist/shared/chunk-w5h6ay93.js +72 -0
- package/dist/shared/chunk-wkg17nxs.d.ts +101 -0
- package/dist/shared/chunk-x7f3g82r.js +285 -0
- package/dist/shared/chunk-xq5hc5gv.js +333 -0
- package/dist/shared/chunk-y0188bbn.js +331 -0
- package/dist/shared/chunk-ym0xbses.js +518 -0
- package/dist/styles.css +264 -0
- package/index.ts +22 -0
- package/lib/artwork.ts +112 -0
- package/lib/clock.ts +53 -0
- package/lib/geometry.ts +130 -0
- package/lib/island-context.tsx +24 -0
- package/lib/motion.ts +42 -0
- package/mock/activities.tsx +77 -0
- package/mock/artwork.tsx +37 -0
- package/mock/clipboard.tsx +79 -0
- package/mock/clock.tsx +77 -0
- package/mock/data.ts +139 -0
- package/mock/desktop.tsx +83 -0
- package/mock/files.tsx +70 -0
- package/mock/fit.ts +26 -0
- package/mock/island-content.tsx +142 -0
- package/mock/scene.tsx +52 -0
- package/mock/screen.tsx +76 -0
- package/mock/settings.tsx +489 -0
- package/mock/system.ts +46 -0
- package/mock/weather.tsx +105 -0
- package/package.json +122 -4
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
IslandFlash2
|
|
5
|
+
} from "./chunk-ndf79pv5.js";
|
|
6
|
+
import {
|
|
7
|
+
widget_default
|
|
8
|
+
} from "./chunk-x7f3g82r.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 Hero({ clip, pinned, onPin, onCopy, onDelete }) {
|
|
186
|
+
const line = fact(clip);
|
|
187
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
188
|
+
className: "flex min-w-0 flex-col gap-2",
|
|
189
|
+
children: [
|
|
190
|
+
/* @__PURE__ */ jsx(Body, {
|
|
191
|
+
clip
|
|
192
|
+
}),
|
|
193
|
+
/* @__PURE__ */ jsxs("div", {
|
|
194
|
+
className: "flex min-w-0 items-center justify-between gap-3",
|
|
195
|
+
children: [
|
|
196
|
+
/* @__PURE__ */ jsx(widget_default.Meta, {
|
|
197
|
+
children: line && /* @__PURE__ */ jsx(widget_default.MetaItem, {
|
|
198
|
+
icon: KIND_ICON[clip.kind],
|
|
199
|
+
children: line
|
|
200
|
+
})
|
|
201
|
+
}),
|
|
202
|
+
/* @__PURE__ */ jsxs("div", {
|
|
203
|
+
className: "-mr-1 flex shrink-0 items-center gap-0.5",
|
|
204
|
+
children: [
|
|
205
|
+
/* @__PURE__ */ jsx(widget_default.Action, {
|
|
206
|
+
icon: Pin,
|
|
207
|
+
label: pinned ? "Unpin" : "Pin",
|
|
208
|
+
pressed: pinned,
|
|
209
|
+
onClick: onPin
|
|
210
|
+
}),
|
|
211
|
+
onDelete && /* @__PURE__ */ jsx(widget_default.Action, {
|
|
212
|
+
icon: Trash2,
|
|
213
|
+
label: "Delete",
|
|
214
|
+
onClick: () => onDelete(clip)
|
|
215
|
+
}),
|
|
216
|
+
/* @__PURE__ */ jsx(Button, {
|
|
217
|
+
variant: "primary",
|
|
218
|
+
size: "compact",
|
|
219
|
+
leadingIcon: Copy,
|
|
220
|
+
className: "ml-1.5",
|
|
221
|
+
onClick: () => onCopy?.(clip),
|
|
222
|
+
children: "Copy"
|
|
223
|
+
})
|
|
224
|
+
]
|
|
225
|
+
})
|
|
226
|
+
]
|
|
227
|
+
})
|
|
228
|
+
]
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
function List({ order, selected, pinned, now, searching, onPick, onCopy }) {
|
|
232
|
+
const level = useLift(1);
|
|
233
|
+
if (!order.length)
|
|
234
|
+
return /* @__PURE__ */ jsx("span", {
|
|
235
|
+
className: "flex h-7 items-center text-body text-muted-foreground",
|
|
236
|
+
children: "No clips match"
|
|
237
|
+
});
|
|
238
|
+
const start = Math.max(0, Math.min(selected - ROWS + 1, order.length - ROWS));
|
|
239
|
+
const shown = order.slice(start, start + ROWS);
|
|
240
|
+
const more = order.length - start - shown.length;
|
|
241
|
+
const groups = [
|
|
242
|
+
{ label: "Pinned", clips: shown.filter((clip) => pinned.includes(clip.id)) },
|
|
243
|
+
{ label: searching ? "Matches" : "Recent", clips: shown.filter((clip) => !pinned.includes(clip.id)) }
|
|
244
|
+
].filter((group) => group.clips.length);
|
|
245
|
+
return /* @__PURE__ */ jsx(FluidHover, {
|
|
246
|
+
className: "-mx-2 flex flex-col gap-0",
|
|
247
|
+
role: "listbox",
|
|
248
|
+
"aria-label": "Clipboard history",
|
|
249
|
+
children: groups.map((group, g) => /* @__PURE__ */ jsxs("div", {
|
|
250
|
+
role: "presentation",
|
|
251
|
+
className: "flex min-w-0 flex-col",
|
|
252
|
+
children: [
|
|
253
|
+
/* @__PURE__ */ jsxs("div", {
|
|
254
|
+
className: "flex h-6 items-center justify-between px-2 text-caption text-muted-foreground",
|
|
255
|
+
children: [
|
|
256
|
+
/* @__PURE__ */ jsx("span", {
|
|
257
|
+
children: group.label
|
|
258
|
+
}),
|
|
259
|
+
g === groups.length - 1 && more > 0 && /* @__PURE__ */ jsxs("span", {
|
|
260
|
+
className: "tabular-nums",
|
|
261
|
+
children: [
|
|
262
|
+
more,
|
|
263
|
+
" more"
|
|
264
|
+
]
|
|
265
|
+
})
|
|
266
|
+
]
|
|
267
|
+
}),
|
|
268
|
+
group.clips.map((clip) => {
|
|
269
|
+
const index = order.indexOf(clip);
|
|
270
|
+
const current = index === selected;
|
|
271
|
+
return /* @__PURE__ */ jsx(FluidHover.Item, {
|
|
272
|
+
index: index - start,
|
|
273
|
+
role: "option",
|
|
274
|
+
"aria-selected": current,
|
|
275
|
+
tabIndex: -1,
|
|
276
|
+
className: cn("h-7 px-2", current && SURFACE_BG[level]),
|
|
277
|
+
onClick: () => onPick(clip.id),
|
|
278
|
+
onDoubleClick: () => onCopy?.(clip),
|
|
279
|
+
children: /* @__PURE__ */ jsx(widget_default.Row, {
|
|
280
|
+
className: "w-full",
|
|
281
|
+
trailing: /* @__PURE__ */ jsxs(Fragment, {
|
|
282
|
+
children: [
|
|
283
|
+
pinned.includes(clip.id) && /* @__PURE__ */ jsx(Pin, {
|
|
284
|
+
size: 11,
|
|
285
|
+
strokeWidth: 1.5,
|
|
286
|
+
"aria-label": "Pinned"
|
|
287
|
+
}),
|
|
288
|
+
/* @__PURE__ */ jsx("span", {
|
|
289
|
+
className: "w-6 text-right tabular-nums",
|
|
290
|
+
children: short(now - clip.copiedAt)
|
|
291
|
+
})
|
|
292
|
+
]
|
|
293
|
+
}),
|
|
294
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
295
|
+
className: "flex min-w-0 items-center gap-2",
|
|
296
|
+
children: [
|
|
297
|
+
/* @__PURE__ */ jsx(Mark, {
|
|
298
|
+
clip
|
|
299
|
+
}),
|
|
300
|
+
/* @__PURE__ */ jsx("span", {
|
|
301
|
+
className: "min-w-0 truncate",
|
|
302
|
+
children: clip.kind === "link" ? domain(clip.content) : clip.content
|
|
303
|
+
})
|
|
304
|
+
]
|
|
305
|
+
})
|
|
306
|
+
})
|
|
307
|
+
}, clip.id);
|
|
308
|
+
})
|
|
309
|
+
]
|
|
310
|
+
}, group.label))
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
function ClipboardHistoryLeading2() {
|
|
314
|
+
return /* @__PURE__ */ jsx(ClipboardList, {
|
|
315
|
+
size: 16,
|
|
316
|
+
strokeWidth: 1.5,
|
|
317
|
+
className: "text-foreground"
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
function ClipboardHistoryTrailing2({ count }) {
|
|
321
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
322
|
+
className: "text-caption weight-semibold tabular-nums text-foreground",
|
|
323
|
+
children: [
|
|
324
|
+
count,
|
|
325
|
+
/* @__PURE__ */ jsx("span", {
|
|
326
|
+
className: "sr-only",
|
|
327
|
+
children: " new clips"
|
|
328
|
+
})
|
|
329
|
+
]
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
function ClipboardHistoryCopied2({ clip, onPin }) {
|
|
333
|
+
const level = useLift(1);
|
|
334
|
+
const Icon = KIND_ICON[clip.kind];
|
|
335
|
+
const tile = clip.kind === "color" ? /* @__PURE__ */ jsx("span", {
|
|
336
|
+
"aria-hidden": true,
|
|
337
|
+
className: "size-9 rounded-lg ring-1 ring-border ring-inset",
|
|
338
|
+
style: { backgroundColor: paint(clip) }
|
|
339
|
+
}) : clip.kind === "image" && clip.preview != null ? /* @__PURE__ */ jsx(Picture, {
|
|
340
|
+
preview: clip.preview,
|
|
341
|
+
className: "size-9 rounded-lg"
|
|
342
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
343
|
+
className: cn("flex size-9 items-center justify-center rounded-lg text-muted-foreground", SURFACE_BG[level]),
|
|
344
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
345
|
+
size: 16,
|
|
346
|
+
strokeWidth: 1.5
|
|
347
|
+
})
|
|
348
|
+
});
|
|
349
|
+
return /* @__PURE__ */ jsx(IslandFlash2, {
|
|
350
|
+
icon: tile,
|
|
351
|
+
title: `Copied ${KIND_LABEL[clip.kind].toLowerCase()}`,
|
|
352
|
+
caption: clip.kind === "link" ? domain(clip.content) : clip.content,
|
|
353
|
+
action: onPin && /* @__PURE__ */ jsx(Button, {
|
|
354
|
+
variant: "secondary",
|
|
355
|
+
size: "compact",
|
|
356
|
+
leadingIcon: Pin,
|
|
357
|
+
onClick: () => onPin(clip),
|
|
358
|
+
children: "Pin"
|
|
359
|
+
})
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
var ClipboardHistory2 = Object.assign(function ClipboardHistory({
|
|
363
|
+
clips,
|
|
364
|
+
value: valueProp,
|
|
365
|
+
defaultValue,
|
|
366
|
+
onValueChange,
|
|
367
|
+
pinned: pinnedProp,
|
|
368
|
+
defaultPinned = [],
|
|
369
|
+
onPinnedChange,
|
|
370
|
+
query: queryProp,
|
|
371
|
+
defaultQuery = "",
|
|
372
|
+
onQueryChange,
|
|
373
|
+
paused: pausedProp,
|
|
374
|
+
defaultPaused = false,
|
|
375
|
+
onPausedChange,
|
|
376
|
+
ignoredApp,
|
|
377
|
+
onCopy,
|
|
378
|
+
onDelete,
|
|
379
|
+
now: nowProp,
|
|
380
|
+
size,
|
|
381
|
+
className
|
|
382
|
+
}) {
|
|
383
|
+
const ticking = useEdgeClock2(0, nowProp === undefined, MINUTE2);
|
|
384
|
+
const now = nowProp ?? ticking;
|
|
385
|
+
const [value, setValue] = useControllableState(valueProp, defaultValue, onValueChange);
|
|
386
|
+
const [pinned, setPinned] = useControllableState(pinnedProp, defaultPinned, onPinnedChange);
|
|
387
|
+
const [query, setQuery] = useControllableState(queryProp, defaultQuery, onQueryChange);
|
|
388
|
+
const [paused, setPaused] = useControllableState(pausedProp, defaultPaused, onPausedChange);
|
|
389
|
+
const resume = /* @__PURE__ */ jsx(widget_default.Action, {
|
|
390
|
+
icon: paused ? Play : Pause,
|
|
391
|
+
label: paused ? "Resume history" : "Pause history",
|
|
392
|
+
onClick: () => setPaused(!paused)
|
|
393
|
+
});
|
|
394
|
+
if (!clips.length)
|
|
395
|
+
return /* @__PURE__ */ jsx(widget_default.Message, {
|
|
396
|
+
icon: paused ? Pause : ClipboardList,
|
|
397
|
+
title: paused ? "Clipboard history is paused" : "Copy something",
|
|
398
|
+
description: paused ? "Nothing you copy is kept until you resume." : "Text, links, images and colors you copy show up here, newest first.",
|
|
399
|
+
actions: paused && /* @__PURE__ */ jsx(Button, {
|
|
400
|
+
variant: "secondary",
|
|
401
|
+
size: "compact",
|
|
402
|
+
leadingIcon: Play,
|
|
403
|
+
onClick: () => setPaused(false),
|
|
404
|
+
children: "Resume"
|
|
405
|
+
}),
|
|
406
|
+
className
|
|
407
|
+
});
|
|
408
|
+
const needle = query.trim().toLowerCase();
|
|
409
|
+
const matches = needle ? clips.filter((clip) => [clip.content, clip.detail, clip.app].some((s) => s?.toLowerCase().includes(needle))) : clips;
|
|
410
|
+
const newest = [...matches].sort((a, b) => b.copiedAt - a.copiedAt);
|
|
411
|
+
const order = [
|
|
412
|
+
...newest.filter((clip) => pinned.includes(clip.id)),
|
|
413
|
+
...newest.filter((clip) => !pinned.includes(clip.id))
|
|
414
|
+
];
|
|
415
|
+
const found = order.findIndex((clip) => clip.id === value);
|
|
416
|
+
const selected = found < 0 ? Math.max(0, order.indexOf(newest[0])) : found;
|
|
417
|
+
const hero = order[selected] ?? clips[0];
|
|
418
|
+
const heroPinned = pinned.includes(hero.id);
|
|
419
|
+
const onKeyDown = (event) => {
|
|
420
|
+
const step = event.key === "ArrowDown" ? 1 : event.key === "ArrowUp" ? -1 : 0;
|
|
421
|
+
if (step) {
|
|
422
|
+
event.preventDefault();
|
|
423
|
+
const next = order[Math.max(0, Math.min(order.length - 1, selected + step))];
|
|
424
|
+
if (next)
|
|
425
|
+
setValue(next.id);
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
if (event.key === "Enter" && order[selected]) {
|
|
429
|
+
event.preventDefault();
|
|
430
|
+
onCopy?.(order[selected]);
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
return /* @__PURE__ */ jsx("div", {
|
|
434
|
+
className: cn("flex min-h-0 flex-col", className),
|
|
435
|
+
onKeyDown,
|
|
436
|
+
children: /* @__PURE__ */ jsxs(widget_default, {
|
|
437
|
+
size,
|
|
438
|
+
className: "flex-1",
|
|
439
|
+
aside: /* @__PURE__ */ jsxs("div", {
|
|
440
|
+
className: "flex min-w-0 flex-col gap-1",
|
|
441
|
+
children: [
|
|
442
|
+
/* @__PURE__ */ jsx(Input, {
|
|
443
|
+
size: "compact",
|
|
444
|
+
icon: Search,
|
|
445
|
+
placeholder: "Search clips",
|
|
446
|
+
"aria-label": "Search clips",
|
|
447
|
+
value: query,
|
|
448
|
+
onValueChange: setQuery
|
|
449
|
+
}),
|
|
450
|
+
/* @__PURE__ */ jsx(List, {
|
|
451
|
+
order,
|
|
452
|
+
selected,
|
|
453
|
+
pinned,
|
|
454
|
+
now,
|
|
455
|
+
searching: !!needle,
|
|
456
|
+
onPick: setValue,
|
|
457
|
+
onCopy
|
|
458
|
+
})
|
|
459
|
+
]
|
|
460
|
+
}),
|
|
461
|
+
media: hasMedia(hero) && /* @__PURE__ */ jsx(Media, {
|
|
462
|
+
clip: hero
|
|
463
|
+
}),
|
|
464
|
+
children: [
|
|
465
|
+
/* @__PURE__ */ jsx(widget_default.Header, {
|
|
466
|
+
icon: KIND_ICON[hero.kind],
|
|
467
|
+
trailing: /* @__PURE__ */ jsxs(Fragment, {
|
|
468
|
+
children: [
|
|
469
|
+
paused ? /* @__PURE__ */ jsx(widget_default.Chip, {
|
|
470
|
+
children: "Paused"
|
|
471
|
+
}) : ignoredApp && /* @__PURE__ */ jsxs(widget_default.Chip, {
|
|
472
|
+
children: [
|
|
473
|
+
"Ignoring ",
|
|
474
|
+
ignoredApp
|
|
475
|
+
]
|
|
476
|
+
}),
|
|
477
|
+
resume
|
|
478
|
+
]
|
|
479
|
+
}),
|
|
480
|
+
children: [hero.app ?? KIND_LABEL[hero.kind], ago(now - hero.copiedAt)].join(" · ")
|
|
481
|
+
}),
|
|
482
|
+
/* @__PURE__ */ jsx(Hero, {
|
|
483
|
+
clip: hero,
|
|
484
|
+
pinned: heroPinned,
|
|
485
|
+
onPin: () => setPinned(heroPinned ? pinned.filter((id) => id !== hero.id) : [...pinned, hero.id]),
|
|
486
|
+
onCopy,
|
|
487
|
+
onDelete
|
|
488
|
+
})
|
|
489
|
+
]
|
|
490
|
+
})
|
|
491
|
+
});
|
|
492
|
+
}, {
|
|
493
|
+
Leading: ClipboardHistoryLeading2,
|
|
494
|
+
Trailing: ClipboardHistoryTrailing2,
|
|
495
|
+
Copied: ClipboardHistoryCopied2
|
|
496
|
+
});
|
|
497
|
+
var clipboard_default = ClipboardHistory2;
|
|
498
|
+
export { ClipboardHistoryLeading2, ClipboardHistoryTrailing2, ClipboardHistoryCopied2, ClipboardHistory2, clipboard_default };
|