@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,474 @@
|
|
|
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/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
|
+
function Thumbnail({
|
|
101
|
+
file,
|
|
102
|
+
className,
|
|
103
|
+
glyph = 28
|
|
104
|
+
}) {
|
|
105
|
+
const level = useLift(1);
|
|
106
|
+
const Icon = iconFor(file.name);
|
|
107
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
108
|
+
className: cn("relative flex shrink-0 items-center justify-center overflow-hidden text-muted-foreground", file.thumbnail == null && SURFACE_BG[level], className),
|
|
109
|
+
children: [
|
|
110
|
+
typeof file.thumbnail === "string" ? /* @__PURE__ */ jsx("img", {
|
|
111
|
+
alt: "",
|
|
112
|
+
src: file.thumbnail,
|
|
113
|
+
draggable: false,
|
|
114
|
+
className: "size-full object-cover"
|
|
115
|
+
}) : file.thumbnail ?? /* @__PURE__ */ jsx(Icon, {
|
|
116
|
+
size: glyph,
|
|
117
|
+
strokeWidth: 1.25
|
|
118
|
+
}),
|
|
119
|
+
/* @__PURE__ */ jsx("span", {
|
|
120
|
+
"aria-hidden": true,
|
|
121
|
+
className: "pointer-events-none absolute inset-0 rounded-[inherit] ring-1 ring-border ring-inset"
|
|
122
|
+
})
|
|
123
|
+
]
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function Hero({ file, now, props }) {
|
|
127
|
+
const { onOpen, onReveal, onCopy, onDelete } = props;
|
|
128
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
129
|
+
className: "flex min-w-0 flex-col gap-2",
|
|
130
|
+
children: [
|
|
131
|
+
/* @__PURE__ */ jsxs("div", {
|
|
132
|
+
className: "flex min-w-0 flex-col gap-0.5",
|
|
133
|
+
children: [
|
|
134
|
+
/* @__PURE__ */ jsx(widget_default.Title, {
|
|
135
|
+
children: file.name
|
|
136
|
+
}),
|
|
137
|
+
/* @__PURE__ */ jsx(widget_default.Subtitle, {
|
|
138
|
+
children: [bytes(file.size), ago(now - file.addedAt), file.from && `from ${file.from}`].filter(Boolean).join(" · ")
|
|
139
|
+
})
|
|
140
|
+
]
|
|
141
|
+
}),
|
|
142
|
+
/* @__PURE__ */ jsxs("div", {
|
|
143
|
+
className: "-mr-1 flex min-w-0 items-center justify-end gap-0.5",
|
|
144
|
+
children: [
|
|
145
|
+
onReveal && /* @__PURE__ */ jsx(widget_default.Action, {
|
|
146
|
+
icon: FolderSearch,
|
|
147
|
+
label: "Show in Finder",
|
|
148
|
+
onClick: () => onReveal(file)
|
|
149
|
+
}),
|
|
150
|
+
onCopy && /* @__PURE__ */ jsx(widget_default.Action, {
|
|
151
|
+
icon: Copy,
|
|
152
|
+
label: "Copy",
|
|
153
|
+
onClick: () => onCopy(file)
|
|
154
|
+
}),
|
|
155
|
+
onDelete && /* @__PURE__ */ jsx(widget_default.Action, {
|
|
156
|
+
icon: Trash2,
|
|
157
|
+
label: "Move to Trash",
|
|
158
|
+
onClick: () => onDelete(file)
|
|
159
|
+
}),
|
|
160
|
+
/* @__PURE__ */ jsx(Button, {
|
|
161
|
+
variant: "primary",
|
|
162
|
+
size: "compact",
|
|
163
|
+
leadingIcon: ArrowUpRight,
|
|
164
|
+
className: "ml-1.5",
|
|
165
|
+
onClick: () => onOpen?.(file),
|
|
166
|
+
children: "Open"
|
|
167
|
+
})
|
|
168
|
+
]
|
|
169
|
+
})
|
|
170
|
+
]
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
function Downloading({
|
|
174
|
+
download,
|
|
175
|
+
onCancel
|
|
176
|
+
}) {
|
|
177
|
+
const share = download.received / download.total;
|
|
178
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
179
|
+
className: "flex min-w-0 flex-col gap-1.5",
|
|
180
|
+
children: [
|
|
181
|
+
/* @__PURE__ */ jsxs("div", {
|
|
182
|
+
className: "flex min-w-0 items-center gap-3",
|
|
183
|
+
children: [
|
|
184
|
+
/* @__PURE__ */ jsx(widget_default.Title, {
|
|
185
|
+
className: "flex-1",
|
|
186
|
+
children: download.name
|
|
187
|
+
}),
|
|
188
|
+
/* @__PURE__ */ jsxs("span", {
|
|
189
|
+
className: "shrink-0 text-caption tabular-nums text-muted-foreground",
|
|
190
|
+
children: [
|
|
191
|
+
Math.round(share * 100),
|
|
192
|
+
"%"
|
|
193
|
+
]
|
|
194
|
+
}),
|
|
195
|
+
onCancel && /* @__PURE__ */ jsx("span", {
|
|
196
|
+
className: "-my-1 -mr-1 flex shrink-0",
|
|
197
|
+
children: /* @__PURE__ */ jsx(widget_default.Action, {
|
|
198
|
+
icon: X,
|
|
199
|
+
label: "Cancel download",
|
|
200
|
+
onClick: () => onCancel(download)
|
|
201
|
+
})
|
|
202
|
+
})
|
|
203
|
+
]
|
|
204
|
+
}),
|
|
205
|
+
/* @__PURE__ */ jsx(Meter, {
|
|
206
|
+
variant: "line",
|
|
207
|
+
value: share,
|
|
208
|
+
tone: "default",
|
|
209
|
+
label: `${download.name}, ${Math.round(share * 100)}%`
|
|
210
|
+
}),
|
|
211
|
+
/* @__PURE__ */ jsxs(widget_default.Meta, {
|
|
212
|
+
children: [
|
|
213
|
+
/* @__PURE__ */ jsx(widget_default.MetaItem, {
|
|
214
|
+
children: part(download.received, download.total)
|
|
215
|
+
}),
|
|
216
|
+
/* @__PURE__ */ jsxs(widget_default.MetaItem, {
|
|
217
|
+
children: [
|
|
218
|
+
bytes(download.rate),
|
|
219
|
+
"/s"
|
|
220
|
+
]
|
|
221
|
+
}),
|
|
222
|
+
/* @__PURE__ */ jsx(widget_default.MetaItem, {
|
|
223
|
+
children: left((download.total - download.received) / Math.max(1, download.rate))
|
|
224
|
+
})
|
|
225
|
+
]
|
|
226
|
+
})
|
|
227
|
+
]
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
function Empty({ source, className }) {
|
|
231
|
+
const level = useLift(1);
|
|
232
|
+
const Icon = SOURCE_ICON[source];
|
|
233
|
+
return /* @__PURE__ */ jsx("span", {
|
|
234
|
+
className: cn("flex shrink-0 items-center justify-center text-muted-foreground", SURFACE_BG[level], className),
|
|
235
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
236
|
+
size: 28,
|
|
237
|
+
strokeWidth: 1.25
|
|
238
|
+
})
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
function Rows({ files, now, onOpen, onDragStart }) {
|
|
242
|
+
return /* @__PURE__ */ jsx(FluidHover, {
|
|
243
|
+
className: "-mx-2 flex flex-col gap-0",
|
|
244
|
+
children: files.slice(0, ROWS).map((file, index) => {
|
|
245
|
+
const Icon = iconFor(file.name);
|
|
246
|
+
return /* @__PURE__ */ jsx(FluidHover.Item, {
|
|
247
|
+
index,
|
|
248
|
+
title: file.name,
|
|
249
|
+
className: "h-7 px-2",
|
|
250
|
+
onClick: () => onOpen?.(file),
|
|
251
|
+
...dragOf(file, onDragStart),
|
|
252
|
+
children: /* @__PURE__ */ jsx(widget_default.Row, {
|
|
253
|
+
className: "w-full",
|
|
254
|
+
leading: short(now - file.addedAt),
|
|
255
|
+
trailing: bytes(file.size),
|
|
256
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
257
|
+
className: "flex min-w-0 items-center gap-2",
|
|
258
|
+
children: [
|
|
259
|
+
/* @__PURE__ */ jsx(Icon, {
|
|
260
|
+
size: 14,
|
|
261
|
+
strokeWidth: 1.5,
|
|
262
|
+
className: "shrink-0 text-muted-foreground"
|
|
263
|
+
}),
|
|
264
|
+
/* @__PURE__ */ jsx("span", {
|
|
265
|
+
className: "min-w-0 truncate",
|
|
266
|
+
children: file.name
|
|
267
|
+
})
|
|
268
|
+
]
|
|
269
|
+
})
|
|
270
|
+
})
|
|
271
|
+
}, file.id);
|
|
272
|
+
})
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
function Tiles({ files, onOpen, onDragStart }) {
|
|
276
|
+
return /* @__PURE__ */ jsx(FluidHover, {
|
|
277
|
+
columns: 3,
|
|
278
|
+
className: "-m-1 grid-cols-3 gap-0",
|
|
279
|
+
highlightClassName: "rounded-lg",
|
|
280
|
+
children: files.slice(0, TILES).map((file, index) => /* @__PURE__ */ jsx(FluidHover.Item, {
|
|
281
|
+
index,
|
|
282
|
+
title: file.name,
|
|
283
|
+
"aria-label": file.name,
|
|
284
|
+
className: "min-h-0 p-1",
|
|
285
|
+
onClick: () => onOpen?.(file),
|
|
286
|
+
...dragOf(file, onDragStart),
|
|
287
|
+
children: /* @__PURE__ */ jsx(Thumbnail, {
|
|
288
|
+
file,
|
|
289
|
+
glyph: 16,
|
|
290
|
+
className: "aspect-[16/10] w-full rounded-md"
|
|
291
|
+
})
|
|
292
|
+
}, file.id))
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
function RecentFilesLeading2({ source = "downloads" }) {
|
|
296
|
+
const Icon = SOURCE_ICON[source];
|
|
297
|
+
return /* @__PURE__ */ jsx(Icon, {
|
|
298
|
+
size: 16,
|
|
299
|
+
strokeWidth: 1.5,
|
|
300
|
+
className: "text-foreground"
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
function RecentFilesTrailing2({ download, count = 0 }) {
|
|
304
|
+
return /* @__PURE__ */ jsx("span", {
|
|
305
|
+
className: "text-caption weight-semibold tabular-nums text-foreground",
|
|
306
|
+
children: download ? `${Math.round(download.received / download.total * 100)}%` : count
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
function RecentFilesMinimal2({ download }) {
|
|
310
|
+
const share = download.received / download.total;
|
|
311
|
+
return /* @__PURE__ */ jsx(Meter, {
|
|
312
|
+
variant: "ring",
|
|
313
|
+
className: "size-5.5",
|
|
314
|
+
size: "compact",
|
|
315
|
+
tone: "default",
|
|
316
|
+
value: share,
|
|
317
|
+
label: `${download.name}, ${Math.round(share * 100)}%`
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
function RecentFilesSaved2({ file, onOpen }) {
|
|
321
|
+
return /* @__PURE__ */ jsx(IslandFlash2, {
|
|
322
|
+
icon: /* @__PURE__ */ jsx(Thumbnail, {
|
|
323
|
+
file,
|
|
324
|
+
glyph: 16,
|
|
325
|
+
className: "size-9 rounded-lg"
|
|
326
|
+
}),
|
|
327
|
+
title: file.source === "screenshots" ? "Screenshot saved" : "Downloaded",
|
|
328
|
+
caption: `${file.name} · ${bytes(file.size)}`,
|
|
329
|
+
action: onOpen && /* @__PURE__ */ jsx(Button, {
|
|
330
|
+
variant: "secondary",
|
|
331
|
+
size: "compact",
|
|
332
|
+
onClick: () => onOpen(file),
|
|
333
|
+
children: "Open"
|
|
334
|
+
})
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
var RecentFiles2 = Object.assign(function RecentFiles(props) {
|
|
338
|
+
const {
|
|
339
|
+
files,
|
|
340
|
+
download,
|
|
341
|
+
value: valueProp,
|
|
342
|
+
defaultValue = "downloads",
|
|
343
|
+
onValueChange,
|
|
344
|
+
onOpen,
|
|
345
|
+
onDragStart,
|
|
346
|
+
onClear,
|
|
347
|
+
onCancelDownload,
|
|
348
|
+
now: nowProp,
|
|
349
|
+
size,
|
|
350
|
+
className
|
|
351
|
+
} = props;
|
|
352
|
+
const ticking = useEdgeClock2(0, nowProp === undefined, MINUTE2);
|
|
353
|
+
const now = nowProp ?? ticking;
|
|
354
|
+
const [source, setSource] = useControllableState(valueProp, defaultValue, onValueChange);
|
|
355
|
+
const step = size ?? "default";
|
|
356
|
+
const shown = files.filter((file) => file.source === source).sort((a, b) => b.addedAt - a.addedAt);
|
|
357
|
+
const active = source === "downloads" ? download : undefined;
|
|
358
|
+
const [newest, ...rest] = shown;
|
|
359
|
+
const earlier = active ? shown : rest;
|
|
360
|
+
const limit = source === "screenshots" ? TILES : ROWS;
|
|
361
|
+
const empty = !newest && !active;
|
|
362
|
+
const header = /* @__PURE__ */ jsx(widget_default.Header, {
|
|
363
|
+
icon: SOURCE_ICON[source],
|
|
364
|
+
children: active ? ["Downloading", active.from].filter(Boolean).join(" · ") : [SOURCE_LABEL[source], shown.length && `${shown.length} ${shown.length === 1 ? "file" : "files"}`].filter(Boolean).join(" · ")
|
|
365
|
+
});
|
|
366
|
+
const media = active ? /* @__PURE__ */ jsx(Thumbnail, {
|
|
367
|
+
file: active,
|
|
368
|
+
className: TILE[step]
|
|
369
|
+
}) : newest ? /* @__PURE__ */ jsx("span", {
|
|
370
|
+
...dragOf(newest, onDragStart),
|
|
371
|
+
className: cn(onDragStart && "cursor-grab"),
|
|
372
|
+
children: /* @__PURE__ */ jsx(Thumbnail, {
|
|
373
|
+
file: newest,
|
|
374
|
+
className: TILE[step]
|
|
375
|
+
})
|
|
376
|
+
}) : /* @__PURE__ */ jsx(Empty, {
|
|
377
|
+
source,
|
|
378
|
+
className: TILE[step]
|
|
379
|
+
});
|
|
380
|
+
return /* @__PURE__ */ jsxs(widget_default, {
|
|
381
|
+
size,
|
|
382
|
+
className: cn("h-full", className),
|
|
383
|
+
media,
|
|
384
|
+
aside: /* @__PURE__ */ jsxs("div", {
|
|
385
|
+
className: "flex min-w-0 flex-col gap-1.5",
|
|
386
|
+
children: [
|
|
387
|
+
/* @__PURE__ */ jsxs("div", {
|
|
388
|
+
className: "flex min-w-0 items-center justify-between gap-2",
|
|
389
|
+
children: [
|
|
390
|
+
/* @__PURE__ */ jsx(Tabs, {
|
|
391
|
+
variant: "subtle",
|
|
392
|
+
size: "compact",
|
|
393
|
+
value: source,
|
|
394
|
+
onValueChange: (v) => setSource(v),
|
|
395
|
+
children: /* @__PURE__ */ jsxs(Tabs.List, {
|
|
396
|
+
className: "-ml-2",
|
|
397
|
+
children: [
|
|
398
|
+
/* @__PURE__ */ jsx(Tabs.Item, {
|
|
399
|
+
value: "downloads",
|
|
400
|
+
label: "Downloads"
|
|
401
|
+
}),
|
|
402
|
+
/* @__PURE__ */ jsx(Tabs.Item, {
|
|
403
|
+
value: "screenshots",
|
|
404
|
+
label: "Screenshots"
|
|
405
|
+
})
|
|
406
|
+
]
|
|
407
|
+
})
|
|
408
|
+
}),
|
|
409
|
+
/* @__PURE__ */ jsxs("span", {
|
|
410
|
+
className: "flex shrink-0 items-center gap-1.5 text-caption tabular-nums text-muted-foreground",
|
|
411
|
+
children: [
|
|
412
|
+
earlier.length > limit && /* @__PURE__ */ jsxs("span", {
|
|
413
|
+
children: [
|
|
414
|
+
earlier.length - limit,
|
|
415
|
+
" more"
|
|
416
|
+
]
|
|
417
|
+
}),
|
|
418
|
+
onClear && !empty && /* @__PURE__ */ jsx(Button, {
|
|
419
|
+
variant: "ghost",
|
|
420
|
+
size: "compact",
|
|
421
|
+
className: "-mr-2 h-6 px-2",
|
|
422
|
+
onClick: () => onClear(source),
|
|
423
|
+
children: "Clear"
|
|
424
|
+
})
|
|
425
|
+
]
|
|
426
|
+
})
|
|
427
|
+
]
|
|
428
|
+
}),
|
|
429
|
+
empty ? null : earlier.length === 0 ? /* @__PURE__ */ jsx("span", {
|
|
430
|
+
className: "flex h-7 items-center text-body text-muted-foreground",
|
|
431
|
+
children: "Nothing earlier"
|
|
432
|
+
}) : source === "screenshots" ? /* @__PURE__ */ jsx(Tiles, {
|
|
433
|
+
files: earlier,
|
|
434
|
+
onOpen,
|
|
435
|
+
onDragStart
|
|
436
|
+
}) : /* @__PURE__ */ jsx(Rows, {
|
|
437
|
+
files: earlier,
|
|
438
|
+
now,
|
|
439
|
+
onOpen,
|
|
440
|
+
onDragStart
|
|
441
|
+
})
|
|
442
|
+
]
|
|
443
|
+
}),
|
|
444
|
+
children: [
|
|
445
|
+
header,
|
|
446
|
+
active ? /* @__PURE__ */ jsx(Downloading, {
|
|
447
|
+
download: active,
|
|
448
|
+
onCancel: onCancelDownload
|
|
449
|
+
}) : newest ? /* @__PURE__ */ jsx(Hero, {
|
|
450
|
+
file: newest,
|
|
451
|
+
now,
|
|
452
|
+
props
|
|
453
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
454
|
+
className: "flex min-w-0 flex-col gap-0.5",
|
|
455
|
+
children: [
|
|
456
|
+
/* @__PURE__ */ jsx(widget_default.Title, {
|
|
457
|
+
children: source === "downloads" ? "No downloads yet" : "No screenshots yet"
|
|
458
|
+
}),
|
|
459
|
+
/* @__PURE__ */ jsx("span", {
|
|
460
|
+
className: "text-pretty text-caption text-muted-foreground",
|
|
461
|
+
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."
|
|
462
|
+
})
|
|
463
|
+
]
|
|
464
|
+
})
|
|
465
|
+
]
|
|
466
|
+
});
|
|
467
|
+
}, {
|
|
468
|
+
Leading: RecentFilesLeading2,
|
|
469
|
+
Trailing: RecentFilesTrailing2,
|
|
470
|
+
Minimal: RecentFilesMinimal2,
|
|
471
|
+
Saved: RecentFilesSaved2
|
|
472
|
+
});
|
|
473
|
+
var recent_files_default = RecentFiles2;
|
|
474
|
+
export { RecentFilesLeading2, RecentFilesTrailing2, RecentFilesMinimal2, RecentFilesSaved2, RecentFiles2, recent_files_default };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// components/island/island-flash/index.tsx
|
|
2
|
+
import { cn } from "@justanarthur/modo-ui/lib/utils";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
/*!
|
|
5
|
+
* Local addition: the layout of a notch app's transient alert, the island's
|
|
6
|
+
* `flash` content. Generalised from Just Notch's power, HUD and now-playing
|
|
7
|
+
* flashes; the kit's blocks build their own on it.
|
|
8
|
+
*/
|
|
9
|
+
var TONE = {
|
|
10
|
+
default: "text-foreground",
|
|
11
|
+
success: "text-status-success",
|
|
12
|
+
warning: "text-status-warning",
|
|
13
|
+
error: "text-status-error",
|
|
14
|
+
info: "text-status-info"
|
|
15
|
+
};
|
|
16
|
+
function IslandFlash2({
|
|
17
|
+
title,
|
|
18
|
+
caption,
|
|
19
|
+
icon,
|
|
20
|
+
tone = "default",
|
|
21
|
+
value,
|
|
22
|
+
trailing,
|
|
23
|
+
action,
|
|
24
|
+
className
|
|
25
|
+
}) {
|
|
26
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
27
|
+
className: cn("flex min-w-0 items-center gap-3", className),
|
|
28
|
+
children: [
|
|
29
|
+
icon && /* @__PURE__ */ jsx("span", {
|
|
30
|
+
className: cn("flex size-8 shrink-0 items-center justify-center", TONE[tone]),
|
|
31
|
+
children: icon
|
|
32
|
+
}),
|
|
33
|
+
/* @__PURE__ */ jsxs("div", {
|
|
34
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
35
|
+
children: [
|
|
36
|
+
/* @__PURE__ */ jsx("span", {
|
|
37
|
+
className: "truncate text-body weight-semibold text-foreground",
|
|
38
|
+
children: title
|
|
39
|
+
}),
|
|
40
|
+
caption && /* @__PURE__ */ jsx("span", {
|
|
41
|
+
className: "truncate text-caption text-muted-foreground",
|
|
42
|
+
children: caption
|
|
43
|
+
})
|
|
44
|
+
]
|
|
45
|
+
}),
|
|
46
|
+
value !== undefined && /* @__PURE__ */ jsx("span", {
|
|
47
|
+
className: cn("shrink-0 text-subtitle weight-semibold tabular-nums", TONE[tone]),
|
|
48
|
+
children: value
|
|
49
|
+
}),
|
|
50
|
+
trailing,
|
|
51
|
+
action && /* @__PURE__ */ jsx("span", {
|
|
52
|
+
className: "flex shrink-0 items-center",
|
|
53
|
+
children: action
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export { IslandFlash2 };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { IslandTab2 } from "./chunk-w48eyvfr.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { JSX as JSX_1kxb } from "react";
|
|
4
|
+
interface ExpandedIslandTab2 extends IslandTab2 {
|
|
5
|
+
/** The tab's view, in the content area. */
|
|
6
|
+
content: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
interface ExpandedIslandProps2 {
|
|
9
|
+
/** The tabs, in order, each with its view. */
|
|
10
|
+
tabs: ExpandedIslandTab2[];
|
|
11
|
+
/** The selected tab's value (controlled). */
|
|
12
|
+
value?: string;
|
|
13
|
+
/** The tab selected at first (uncontrolled). Defaults to the first tab. */
|
|
14
|
+
defaultValue?: string;
|
|
15
|
+
/** Called with the value of the tab a press or an arrow key selects. */
|
|
16
|
+
onValueChange?: (value: string) => void;
|
|
17
|
+
/** Called by the settings button at the right wing's far end; without it the button hides. */
|
|
18
|
+
onSettings?: () => void;
|
|
19
|
+
/** The settings button's accessible name. Defaults to `'Settings'`. */
|
|
20
|
+
settingsLabel?: string;
|
|
21
|
+
/** What the content area says without tabs. Defaults to `'Nothing here yet'`. */
|
|
22
|
+
empty?: ReactNode;
|
|
23
|
+
/** Classes for the root, which fills the open island. */
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
type Element_12xgc = JSX_1kxb["Element"];
|
|
27
|
+
/**
|
|
28
|
+
* The open island's layout: icon tabs in the wings around the notch, the
|
|
29
|
+
* tab's title under them, and its view in a content area of fixed height.
|
|
30
|
+
*
|
|
31
|
+
* The header is the notch's height, so the tabs sit in the wings beside the
|
|
32
|
+
* hardware notch: the kit's IslandTabs at the compact step, with a settings
|
|
33
|
+
* button at the right wing's far end when `onSettings` is given. Under it
|
|
34
|
+
* the selected tab's title, or the hovered tab's as a preview. The view
|
|
35
|
+
* fills the rest: the area keeps its height whatever the view holds, and a
|
|
36
|
+
* taller view scrolls inside it, its edges fading with `scroll-fade` (a
|
|
37
|
+
* modo-ui ScrollArea), back at the top on each new tab, where the new view
|
|
38
|
+
* sharpens in the way the island swaps its content. Every part starts at
|
|
39
|
+
* the island's one inset, clear of its rounded bottom corners.
|
|
40
|
+
*
|
|
41
|
+
* The views are made for the area the default panel leaves (about 680 × 165
|
|
42
|
+
* at 720 × 240): build each one on the kit's Widget frame, so every tab has
|
|
43
|
+
* one hero set large, a muted line, its facts and quiet actions in the same
|
|
44
|
+
* places.
|
|
45
|
+
*
|
|
46
|
+
* Pass it as the Island's `expanded`; it reads the notch from the Island.
|
|
47
|
+
* Selection runs through `value` / `onValueChange`, or is kept here from
|
|
48
|
+
* `defaultValue`.
|
|
49
|
+
*
|
|
50
|
+
* @example {@include ./examples.mdx}
|
|
51
|
+
*/
|
|
52
|
+
declare function ExpandedIsland2({ tabs, value: valueProp, defaultValue, onValueChange, onSettings, settingsLabel, empty, className }: ExpandedIslandProps2): Element_12xgc;
|
|
53
|
+
export { ExpandedIslandTab2, ExpandedIslandProps2, ExpandedIsland2 };
|