@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,243 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
widget_default
|
|
5
|
+
} from "./chunk-x7f3g82r.js";
|
|
6
|
+
|
|
7
|
+
// blocks/system/system-stats/index.tsx
|
|
8
|
+
import Sparkline from "@justanarthur/modo-ui/components/data-display/sparkline";
|
|
9
|
+
import Meter from "@justanarthur/modo-ui/components/feedback/meter";
|
|
10
|
+
import { cn } from "@justanarthur/modo-ui/lib/utils";
|
|
11
|
+
import {
|
|
12
|
+
Activity,
|
|
13
|
+
ArrowDown,
|
|
14
|
+
ArrowUp,
|
|
15
|
+
BatteryCharging,
|
|
16
|
+
BatteryFull,
|
|
17
|
+
BatteryLow,
|
|
18
|
+
BatteryMedium,
|
|
19
|
+
Cpu,
|
|
20
|
+
HardDrive,
|
|
21
|
+
MemoryStick
|
|
22
|
+
} from "lucide-react";
|
|
23
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
24
|
+
/*!
|
|
25
|
+
* Local addition: a notch app's system load, the busiest figure as the hero
|
|
26
|
+
* with its trend, the rest as facts and the busiest processes beside it.
|
|
27
|
+
* Rebuilt from Just Notch's stats plugin (`System`, `Tile`, `Measuring`,
|
|
28
|
+
* `CpuLoad`) on the kit's Widget frame and modo-ui's Sparkline and Meter:
|
|
29
|
+
* the readings come in as props.
|
|
30
|
+
*/
|
|
31
|
+
var ROWS = 3;
|
|
32
|
+
var percent = (v) => `${Math.round(v * 100)}%`;
|
|
33
|
+
var share = (v) => v < 0.1 ? `${(v * 100).toFixed(1)}%` : percent(v);
|
|
34
|
+
function bytes(n) {
|
|
35
|
+
if (n >= 100000000000)
|
|
36
|
+
return `${Math.round(n / 1e9)} GB`;
|
|
37
|
+
if (n >= 1e9)
|
|
38
|
+
return `${(n / 1e9).toFixed(1)} GB`;
|
|
39
|
+
return `${Math.round(n / 1e6)} MB`;
|
|
40
|
+
}
|
|
41
|
+
function rate(bps) {
|
|
42
|
+
if (bps >= 1e6)
|
|
43
|
+
return `${(bps / 1e6).toFixed(1)} MB/s`;
|
|
44
|
+
if (bps >= 1000)
|
|
45
|
+
return `${Math.round(bps / 1000)} KB/s`;
|
|
46
|
+
return `${Math.round(bps)} B/s`;
|
|
47
|
+
}
|
|
48
|
+
function span(seconds) {
|
|
49
|
+
const minutes = Math.floor(seconds / 60);
|
|
50
|
+
const hours = Math.floor(minutes / 60);
|
|
51
|
+
const days = Math.floor(hours / 24);
|
|
52
|
+
if (days)
|
|
53
|
+
return `${days} d ${hours % 24} h`;
|
|
54
|
+
if (hours)
|
|
55
|
+
return `${hours} h ${minutes % 60} min`;
|
|
56
|
+
return `${minutes} min`;
|
|
57
|
+
}
|
|
58
|
+
var clock = (minutes) => `${Math.floor(minutes / 60)}:${String(Math.round(minutes % 60)).padStart(2, "0")}`;
|
|
59
|
+
function toneOf(load) {
|
|
60
|
+
if (load >= 0.9)
|
|
61
|
+
return "error";
|
|
62
|
+
if (load >= 0.75)
|
|
63
|
+
return "warning";
|
|
64
|
+
return "current";
|
|
65
|
+
}
|
|
66
|
+
function verdict(load) {
|
|
67
|
+
if (load >= 0.9)
|
|
68
|
+
return "Under strain";
|
|
69
|
+
if (load >= 0.6)
|
|
70
|
+
return "Busy";
|
|
71
|
+
if (load >= 0.2)
|
|
72
|
+
return "Steady";
|
|
73
|
+
return "Idle";
|
|
74
|
+
}
|
|
75
|
+
var pressureOf = (sample) => sample.memoryPressure ?? sample.memoryUsed / sample.memoryTotal;
|
|
76
|
+
function batteryIcon({ level, charging }) {
|
|
77
|
+
if (charging)
|
|
78
|
+
return BatteryCharging;
|
|
79
|
+
if (level <= 20)
|
|
80
|
+
return BatteryLow;
|
|
81
|
+
if (level <= 70)
|
|
82
|
+
return BatteryMedium;
|
|
83
|
+
return BatteryFull;
|
|
84
|
+
}
|
|
85
|
+
function BatteryItem({ battery }) {
|
|
86
|
+
const left = battery.minutesLeft === undefined ? undefined : clock(battery.minutesLeft);
|
|
87
|
+
return /* @__PURE__ */ jsxs(widget_default.MetaItem, {
|
|
88
|
+
icon: batteryIcon(battery),
|
|
89
|
+
children: [
|
|
90
|
+
battery.level,
|
|
91
|
+
"%",
|
|
92
|
+
left && ` · ${left} ${battery.charging ? "to full" : "left"}`
|
|
93
|
+
]
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function Facts({ last, hero, battery, disk }) {
|
|
97
|
+
const dash = "–";
|
|
98
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
99
|
+
className: "flex min-w-0 flex-col gap-1",
|
|
100
|
+
children: [
|
|
101
|
+
/* @__PURE__ */ jsxs(widget_default.Meta, {
|
|
102
|
+
children: [
|
|
103
|
+
hero === "cpu" ? /* @__PURE__ */ jsx(widget_default.MetaItem, {
|
|
104
|
+
icon: MemoryStick,
|
|
105
|
+
children: last ? `${bytes(last.memoryUsed)} of ${bytes(last.memoryTotal)}` : dash
|
|
106
|
+
}) : /* @__PURE__ */ jsx(widget_default.MetaItem, {
|
|
107
|
+
icon: Cpu,
|
|
108
|
+
children: last ? `${percent(last.cpu)} CPU` : dash
|
|
109
|
+
}),
|
|
110
|
+
/* @__PURE__ */ jsx(widget_default.MetaItem, {
|
|
111
|
+
icon: ArrowDown,
|
|
112
|
+
children: last ? rate(last.netIn) : dash
|
|
113
|
+
}),
|
|
114
|
+
/* @__PURE__ */ jsx(widget_default.MetaItem, {
|
|
115
|
+
icon: ArrowUp,
|
|
116
|
+
children: last ? rate(last.netOut) : dash
|
|
117
|
+
})
|
|
118
|
+
]
|
|
119
|
+
}),
|
|
120
|
+
(battery || disk) && /* @__PURE__ */ jsxs(widget_default.Meta, {
|
|
121
|
+
children: [
|
|
122
|
+
battery && /* @__PURE__ */ jsx(BatteryItem, {
|
|
123
|
+
battery
|
|
124
|
+
}),
|
|
125
|
+
disk && /* @__PURE__ */ jsxs(widget_default.MetaItem, {
|
|
126
|
+
icon: HardDrive,
|
|
127
|
+
children: [
|
|
128
|
+
bytes(disk.free),
|
|
129
|
+
" free"
|
|
130
|
+
]
|
|
131
|
+
})
|
|
132
|
+
]
|
|
133
|
+
})
|
|
134
|
+
]
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function Processes({ processes }) {
|
|
138
|
+
const top = [...processes].sort((a, b) => b.cpu - a.cpu);
|
|
139
|
+
const more = top.length - ROWS;
|
|
140
|
+
return /* @__PURE__ */ jsxs(widget_default.Section, {
|
|
141
|
+
label: "Top processes",
|
|
142
|
+
trailing: /* @__PURE__ */ jsx("span", {
|
|
143
|
+
children: "CPU · memory"
|
|
144
|
+
}),
|
|
145
|
+
children: [
|
|
146
|
+
top.slice(0, ROWS).map((process) => /* @__PURE__ */ jsx(widget_default.Row, {
|
|
147
|
+
leading: share(process.cpu),
|
|
148
|
+
trailing: process.memory !== undefined && bytes(process.memory),
|
|
149
|
+
children: process.name
|
|
150
|
+
}, process.id)),
|
|
151
|
+
more > 0 && /* @__PURE__ */ jsxs("span", {
|
|
152
|
+
className: "flex h-6 items-center pl-17.5 text-caption text-muted-foreground",
|
|
153
|
+
children: [
|
|
154
|
+
more,
|
|
155
|
+
" more"
|
|
156
|
+
]
|
|
157
|
+
})
|
|
158
|
+
]
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
function SystemStatsLeading2() {
|
|
162
|
+
return /* @__PURE__ */ jsx(Cpu, {
|
|
163
|
+
size: 16,
|
|
164
|
+
strokeWidth: 1.5,
|
|
165
|
+
className: "text-muted-foreground"
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
function SystemStatsTrailing2({ sample }) {
|
|
169
|
+
if (!sample)
|
|
170
|
+
return /* @__PURE__ */ jsx("span", {
|
|
171
|
+
className: "text-caption weight-semibold text-muted-foreground",
|
|
172
|
+
children: "–"
|
|
173
|
+
});
|
|
174
|
+
return /* @__PURE__ */ jsx("span", {
|
|
175
|
+
className: "text-caption weight-semibold tabular-nums text-foreground",
|
|
176
|
+
children: percent(sample.cpu)
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
function SystemStatsMinimal2({ sample }) {
|
|
180
|
+
const load = sample?.cpu ?? 0;
|
|
181
|
+
return /* @__PURE__ */ jsx(Meter, {
|
|
182
|
+
variant: "ring",
|
|
183
|
+
className: "size-5.5",
|
|
184
|
+
size: "compact",
|
|
185
|
+
value: load,
|
|
186
|
+
label: sample ? `CPU, ${percent(load)}` : "CPU, measuring"
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
var SystemStats2 = Object.assign(function SystemStats({ samples, hero = "cpu", battery, disk, uptime, processes, size, className }) {
|
|
190
|
+
const last = samples.at(-1);
|
|
191
|
+
const series = hero === "cpu" ? samples.map((s) => s.cpu) : samples.map(pressureOf);
|
|
192
|
+
const load = last ? hero === "cpu" ? last.cpu : pressureOf(last) : 0;
|
|
193
|
+
const name = hero === "cpu" ? "CPU" : "Memory pressure";
|
|
194
|
+
const busiest = processes?.length ? processes.reduce((a, b) => b.cpu > a.cpu ? b : a).name : undefined;
|
|
195
|
+
return /* @__PURE__ */ jsxs(widget_default, {
|
|
196
|
+
size,
|
|
197
|
+
className: cn("h-full", className),
|
|
198
|
+
aside: processes?.length ? /* @__PURE__ */ jsx(Processes, {
|
|
199
|
+
processes
|
|
200
|
+
}) : undefined,
|
|
201
|
+
children: [
|
|
202
|
+
/* @__PURE__ */ jsx(widget_default.Header, {
|
|
203
|
+
icon: Activity,
|
|
204
|
+
children: uptime === undefined ? "System" : `System · up ${span(uptime)}`
|
|
205
|
+
}),
|
|
206
|
+
/* @__PURE__ */ jsxs("div", {
|
|
207
|
+
className: "flex min-w-0 items-end gap-4",
|
|
208
|
+
"aria-busy": !last,
|
|
209
|
+
children: [
|
|
210
|
+
/* @__PURE__ */ jsx(widget_default.Figure, {
|
|
211
|
+
value: last ? percent(load) : "–",
|
|
212
|
+
unit: hero === "cpu" ? "CPU" : "pressure",
|
|
213
|
+
className: "shrink-0"
|
|
214
|
+
}),
|
|
215
|
+
/* @__PURE__ */ jsx(Sparkline, {
|
|
216
|
+
values: series,
|
|
217
|
+
max: 1,
|
|
218
|
+
area: true,
|
|
219
|
+
tone: toneOf(load),
|
|
220
|
+
label: last ? `${name}, ${percent(load)}` : `${name}, measuring`,
|
|
221
|
+
className: cn("mb-1.5 h-9 min-w-0 flex-1", !last && "text-muted-foreground")
|
|
222
|
+
})
|
|
223
|
+
]
|
|
224
|
+
}),
|
|
225
|
+
/* @__PURE__ */ jsx(widget_default.Subtitle, {
|
|
226
|
+
className: "mb-1",
|
|
227
|
+
children: last ? [verdict(load), busiest && `${busiest} is busiest`].filter(Boolean).join(" · ") : "Measuring…"
|
|
228
|
+
}),
|
|
229
|
+
/* @__PURE__ */ jsx(Facts, {
|
|
230
|
+
last,
|
|
231
|
+
hero,
|
|
232
|
+
battery,
|
|
233
|
+
disk
|
|
234
|
+
})
|
|
235
|
+
]
|
|
236
|
+
});
|
|
237
|
+
}, {
|
|
238
|
+
Leading: SystemStatsLeading2,
|
|
239
|
+
Trailing: SystemStatsTrailing2,
|
|
240
|
+
Minimal: SystemStatsMinimal2
|
|
241
|
+
});
|
|
242
|
+
var system_stats_default = SystemStats2;
|
|
243
|
+
export { SystemStatsLeading2, SystemStatsTrailing2, SystemStatsMinimal2, SystemStats2, system_stats_default };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { SizeVariant } from "@justanarthur/modo-ui/lib/size-context";
|
|
2
|
+
import { DragEvent, ReactNode } from "react";
|
|
3
|
+
import { JSX as JSX_1kxb } from "react";
|
|
4
|
+
type RecentFilesSource2 = "downloads" | "screenshots";
|
|
5
|
+
interface RecentFile2 {
|
|
6
|
+
/** What tells it apart: its path. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** Its name, with the extension: it picks the glyph when there is no thumbnail. */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Its size, in bytes. */
|
|
11
|
+
size: number;
|
|
12
|
+
/** When it landed, in epoch ms. */
|
|
13
|
+
addedAt: number;
|
|
14
|
+
/** The folder it is in. */
|
|
15
|
+
source: RecentFilesSource2;
|
|
16
|
+
/** A preview: an image URL, or any element. */
|
|
17
|
+
thumbnail?: string | ReactNode;
|
|
18
|
+
/** Where a download came from: a site's domain. */
|
|
19
|
+
from?: string;
|
|
20
|
+
}
|
|
21
|
+
interface RecentDownload2 {
|
|
22
|
+
/** What tells it apart. */
|
|
23
|
+
id: string;
|
|
24
|
+
/** The file's name. */
|
|
25
|
+
name: string;
|
|
26
|
+
/** Bytes in so far. */
|
|
27
|
+
received: number;
|
|
28
|
+
/** The file's size, in bytes. */
|
|
29
|
+
total: number;
|
|
30
|
+
/** The current speed, in bytes per second. */
|
|
31
|
+
rate: number;
|
|
32
|
+
/** Where it comes from: a site's domain. */
|
|
33
|
+
from?: string;
|
|
34
|
+
}
|
|
35
|
+
interface RecentFilesProps2 {
|
|
36
|
+
/** The files of both folders, in any order: each folder lists newest first. */
|
|
37
|
+
files: RecentFile2[];
|
|
38
|
+
/** A download under way: it takes the hero on Downloads, with its progress and speed. */
|
|
39
|
+
download?: RecentDownload2 | null;
|
|
40
|
+
/** The folder shown (controlled). */
|
|
41
|
+
value?: RecentFilesSource2;
|
|
42
|
+
/** The folder shown at first (uncontrolled). Defaults to `'downloads'`. */
|
|
43
|
+
defaultValue?: RecentFilesSource2;
|
|
44
|
+
/** Called with the folder when the switch is pressed. */
|
|
45
|
+
onValueChange?: (source: RecentFilesSource2) => void;
|
|
46
|
+
/** Called by Open, or a press on a file in the list. */
|
|
47
|
+
onOpen?: (file: RecentFile2) => void;
|
|
48
|
+
/** Called by Show in Finder. */
|
|
49
|
+
onReveal?: (file: RecentFile2) => void;
|
|
50
|
+
/** Called by Copy, to put the file on the clipboard. */
|
|
51
|
+
onCopy?: (file: RecentFile2) => void;
|
|
52
|
+
/** Called when a file starts to be dragged out, with the drag event, for the host to start a native drag. Without it nothing drags. */
|
|
53
|
+
onDragStart?: (file: RecentFile2, event: DragEvent) => void;
|
|
54
|
+
/** Called by Move to Trash. */
|
|
55
|
+
onDelete?: (file: RecentFile2) => void;
|
|
56
|
+
/** Called by Clear with the folder whose list to clear; without it the button hides. */
|
|
57
|
+
onClear?: (source: RecentFilesSource2) => void;
|
|
58
|
+
/** Called by the download's Cancel. */
|
|
59
|
+
onCancelDownload?: (download: RecentDownload2) => void;
|
|
60
|
+
/** The moment the times are read at, in epoch ms. Defaults to now, re-read on each minute. */
|
|
61
|
+
now?: number;
|
|
62
|
+
/** Step on the size ladder. Omitted, it follows the surrounding SizeProvider. */
|
|
63
|
+
size?: SizeVariant;
|
|
64
|
+
/** Classes for the root, which fills its container. */
|
|
65
|
+
className?: string;
|
|
66
|
+
}
|
|
67
|
+
type Element_12xgc = JSX_1kxb["Element"];
|
|
68
|
+
/** The compact island's left wing: the download glyph, or the camera for a screenshot. */
|
|
69
|
+
declare function RecentFilesLeading2({ source }: {
|
|
70
|
+
source?: RecentFilesSource2;
|
|
71
|
+
}): Element_12xgc;
|
|
72
|
+
interface TrailingProps {
|
|
73
|
+
/** A download under way: its progress shows. */
|
|
74
|
+
download?: RecentDownload2 | null;
|
|
75
|
+
/** Otherwise, how many files came in since the island was open. */
|
|
76
|
+
count?: number;
|
|
77
|
+
}
|
|
78
|
+
/** The compact island's right wing: a download's progress, else the count of new files. */
|
|
79
|
+
declare function RecentFilesTrailing2({ download, count }: TrailingProps): Element_12xgc;
|
|
80
|
+
/** The split island's bubble: a download's progress as a ring. */
|
|
81
|
+
declare function RecentFilesMinimal2({ download }: {
|
|
82
|
+
download: RecentDownload2;
|
|
83
|
+
}): Element_12xgc;
|
|
84
|
+
interface SavedProps {
|
|
85
|
+
/** The file that landed. */
|
|
86
|
+
file: RecentFile2;
|
|
87
|
+
/** Called by Open; without it the button hides. */
|
|
88
|
+
onOpen?: (file: RecentFile2) => void;
|
|
89
|
+
}
|
|
90
|
+
/** The island's flash when a file lands: its thumbnail or glyph, `Downloaded` or `Screenshot saved`, and Open. */
|
|
91
|
+
declare function RecentFilesSaved2({ file, onOpen }: SavedProps): Element_12xgc;
|
|
92
|
+
/**
|
|
93
|
+
* A notch app's recent files: the newest download or screenshot as the
|
|
94
|
+
* hero, the ones before it beside it, ready to open or drag out.
|
|
95
|
+
*
|
|
96
|
+
* The hero is the folder's newest file: its thumbnail, or its type's
|
|
97
|
+
* glyph on a tile, then its name, its size, how long ago it landed and
|
|
98
|
+
* where it came from, with Show in Finder, Copy, Move to Trash and Open.
|
|
99
|
+
* Beside it, past a hairline, a switch picks the folder, Downloads or
|
|
100
|
+
* Screenshots (`value` / `defaultValue` / `onValueChange`), over the ones
|
|
101
|
+
* before the newest: downloads as rows of age, glyph, name and size, and
|
|
102
|
+
* screenshots as a grid of image tiles, since a screenshot is found by
|
|
103
|
+
* its look. A press opens a file, and with `onDragStart` every picture and
|
|
104
|
+
* row drags out (the host starts the native drag); Clear empties the list.
|
|
105
|
+
*
|
|
106
|
+
* While a download is under way (`download`) it takes the hero on
|
|
107
|
+
* Downloads: its name, the progress as a modo-ui Meter line, how much is
|
|
108
|
+
* in, the speed and the time left, and Cancel. An empty folder says what
|
|
109
|
+
* will land in it, the switch still beside it.
|
|
110
|
+
*
|
|
111
|
+
* `RecentFiles.Leading` and `RecentFiles.Trailing` show the glyph and the
|
|
112
|
+
* download's progress (or the count of new files) in the compact island's
|
|
113
|
+
* wings, `RecentFiles.Minimal` the progress as a ring in the split
|
|
114
|
+
* island's bubble, and `RecentFiles.Saved` is the flash when a file lands.
|
|
115
|
+
*
|
|
116
|
+
* @example {@include ./examples.mdx}
|
|
117
|
+
*/
|
|
118
|
+
declare const RecentFiles2: ((props: RecentFilesProps2) => Element_12xgc) & {
|
|
119
|
+
Leading: typeof RecentFilesLeading2;
|
|
120
|
+
Trailing: typeof RecentFilesTrailing2;
|
|
121
|
+
Minimal: typeof RecentFilesMinimal2;
|
|
122
|
+
Saved: typeof RecentFilesSaved2;
|
|
123
|
+
};
|
|
124
|
+
export { RecentFilesSource2, RecentFile2, RecentDownload2, RecentFilesProps2, RecentFilesLeading2, RecentFilesTrailing2, RecentFilesMinimal2, RecentFilesSaved2, RecentFiles2 };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { IconComponent } from "@justanarthur/modo-ui/lib/icon-context";
|
|
2
|
+
import { SizeVariant } from "@justanarthur/modo-ui/lib/size-context";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { JSX as JSX_1kxb } from "react";
|
|
5
|
+
interface IslandTab2 {
|
|
6
|
+
/** What selecting it reports. */
|
|
7
|
+
value: string;
|
|
8
|
+
/** Its name: the tab's accessible name, and the title a consumer shows for it. */
|
|
9
|
+
label: string;
|
|
10
|
+
/** Its glyph. */
|
|
11
|
+
icon: IconComponent;
|
|
12
|
+
}
|
|
13
|
+
interface IslandTabsProps2 {
|
|
14
|
+
/** The tabs, in order: they fill the left wing, then the right one. */
|
|
15
|
+
tabs: IslandTab2[];
|
|
16
|
+
/** The selected tab's value (controlled). */
|
|
17
|
+
value?: string;
|
|
18
|
+
/** The tab selected at first (uncontrolled). Defaults to the first tab. */
|
|
19
|
+
defaultValue?: string;
|
|
20
|
+
/** Called with the value of the tab a press or an arrow key selects. */
|
|
21
|
+
onValueChange?: (value: string) => void;
|
|
22
|
+
/** Called with the value of the tab under the pointer, or `null`, so a title can preview it. */
|
|
23
|
+
onHoverChange?: (value: string | null) => void;
|
|
24
|
+
/** Step on the size ladder. Defaults to the surrounding SizeProvider, else `'default'`. */
|
|
25
|
+
size?: SizeVariant;
|
|
26
|
+
/** The notch the strip leaves free, centered. Defaults to the enclosing Island's, else `185`. */
|
|
27
|
+
notchWidth?: number;
|
|
28
|
+
/** Content at the far right of the right wing, such as a settings button; the tabs keep clear of it. */
|
|
29
|
+
trailing?: ReactNode;
|
|
30
|
+
/** The tab list's accessible name. Defaults to `'Widgets'`. */
|
|
31
|
+
label?: string;
|
|
32
|
+
/** Classes for the root, which spans its container's width. */
|
|
33
|
+
className?: string;
|
|
34
|
+
}
|
|
35
|
+
type Element_12xgc = JSX_1kxb["Element"];
|
|
36
|
+
/**
|
|
37
|
+
* The open island's icon tabs, in both wings around the notch: the left
|
|
38
|
+
* wing's, a gap the width of the notch, then the right wing's.
|
|
39
|
+
*
|
|
40
|
+
* The tabs fill the left wing first and balance into the right one, keeping
|
|
41
|
+
* clear of the `trailing` content at its far end. The selected tab's pill is
|
|
42
|
+
* modo-ui's liquid indicator: it melts from tab to tab, across the notch too;
|
|
43
|
+
* a fluid hover highlight lights the tab under the pointer and the keyboard
|
|
44
|
+
* gets a focus ring that springs between tabs. Past what both wings hold the
|
|
45
|
+
* strip scrolls behind the notch, which hides the tabs passing under it; its
|
|
46
|
+
* outer edges fade with `scroll-fade-x` and a vertical wheel scrolls it
|
|
47
|
+
* sideways.
|
|
48
|
+
*
|
|
49
|
+
* The strip shows icons only. Show the selected tab's title yourself, or the
|
|
50
|
+
* hovered one's as a preview through `onHoverChange`. Arrow keys, Home and End
|
|
51
|
+
* move the selection. Inside an Island it reads the notch's width from it.
|
|
52
|
+
*
|
|
53
|
+
* @example {@include ./examples.mdx}
|
|
54
|
+
*/
|
|
55
|
+
declare function IslandTabs2({ tabs, value: valueProp, defaultValue, onValueChange, onHoverChange, size: sizeProp, notchWidth, trailing, label, className }: IslandTabsProps2): Element_12xgc;
|
|
56
|
+
export { IslandTab2, IslandTabsProps2, IslandTabs2 };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// lib/artwork.ts
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
var NONE = "none";
|
|
6
|
+
function useStableArtwork2(artwork, trackKey) {
|
|
7
|
+
const id = typeof artwork === "string" ? artwork : `node:${trackKey}`;
|
|
8
|
+
const [shown, setShown] = useState(() => artwork == null ? { id: NONE, art: null, track: trackKey } : { id, art: artwork, track: trackKey });
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (artwork === undefined)
|
|
11
|
+
return;
|
|
12
|
+
if (artwork === null) {
|
|
13
|
+
setShown((prev) => prev.track === trackKey ? prev : { id: NONE, art: null, track: trackKey });
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (typeof artwork !== "string") {
|
|
17
|
+
setShown((prev) => prev.id === id ? prev : { id, art: artwork, track: trackKey });
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
let live = true;
|
|
21
|
+
const image = new Image;
|
|
22
|
+
image.src = artwork;
|
|
23
|
+
image.decode().then(() => live && setShown((prev) => prev.id === id ? prev : { id, art: artwork, track: trackKey }), () => live && setShown((prev) => prev.track === trackKey ? prev : { id: NONE, art: null, track: trackKey }));
|
|
24
|
+
return () => {
|
|
25
|
+
live = false;
|
|
26
|
+
};
|
|
27
|
+
}, [id, trackKey, artwork === null, artwork === undefined]);
|
|
28
|
+
if (shown.id === id && artwork != null && typeof artwork !== "string")
|
|
29
|
+
return { id, art: artwork };
|
|
30
|
+
return shown;
|
|
31
|
+
}
|
|
32
|
+
var SAMPLE = 12;
|
|
33
|
+
function useArtworkTint2(src) {
|
|
34
|
+
const [tint, setTint] = useState();
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!src)
|
|
37
|
+
return;
|
|
38
|
+
let live = true;
|
|
39
|
+
const image = new Image;
|
|
40
|
+
image.crossOrigin = "anonymous";
|
|
41
|
+
image.src = src;
|
|
42
|
+
image.decode().then(() => {
|
|
43
|
+
const canvas = document.createElement("canvas");
|
|
44
|
+
canvas.width = canvas.height = SAMPLE;
|
|
45
|
+
const context = canvas.getContext("2d", { willReadFrequently: true });
|
|
46
|
+
if (!context)
|
|
47
|
+
return;
|
|
48
|
+
context.drawImage(image, 0, 0, SAMPLE, SAMPLE);
|
|
49
|
+
const { data } = context.getImageData(0, 0, SAMPLE, SAMPLE);
|
|
50
|
+
let r = 0;
|
|
51
|
+
let g = 0;
|
|
52
|
+
let b = 0;
|
|
53
|
+
let total = 0;
|
|
54
|
+
for (let i = 0;i < data.length; i += 4) {
|
|
55
|
+
const [pr = 0, pg = 0, pb = 0] = [data[i], data[i + 1], data[i + 2]];
|
|
56
|
+
const weight = 0.1 + (Math.max(pr, pg, pb) - Math.min(pr, pg, pb)) / 255;
|
|
57
|
+
r += pr * weight;
|
|
58
|
+
g += pg * weight;
|
|
59
|
+
b += pb * weight;
|
|
60
|
+
total += weight;
|
|
61
|
+
}
|
|
62
|
+
if (live)
|
|
63
|
+
setTint({ src, color: `rgb(${r / total} ${g / total} ${b / total})` });
|
|
64
|
+
}).catch(() => live && setTint({ src }));
|
|
65
|
+
return () => {
|
|
66
|
+
live = false;
|
|
67
|
+
};
|
|
68
|
+
}, [src]);
|
|
69
|
+
return tint && tint.src === src ? tint.color : undefined;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export { useStableArtwork2, useArtworkTint2 };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { JSX as JSX_1kxb } from "react";
|
|
2
|
+
type AgendaAccess2 = "granted" | "undetermined" | "denied";
|
|
3
|
+
interface AgendaEvent2 {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
/** When it starts, in epoch ms. */
|
|
7
|
+
start: number;
|
|
8
|
+
/** When it ends, in epoch ms. */
|
|
9
|
+
end: number;
|
|
10
|
+
allDay?: boolean;
|
|
11
|
+
location?: string;
|
|
12
|
+
/** A video call's link: the event gets a Join button. */
|
|
13
|
+
meetingUrl?: string;
|
|
14
|
+
/** Its calendar's color, any CSS color: data, so it paints the dot, the mark and the ring inline. */
|
|
15
|
+
color: string;
|
|
16
|
+
}
|
|
17
|
+
interface AgendaProps2 {
|
|
18
|
+
/** The events, in any order. */
|
|
19
|
+
events: AgendaEvent2[];
|
|
20
|
+
/** Whether the calendar may be read: undetermined asks, denied points to the system's settings. Defaults to `'granted'`. */
|
|
21
|
+
access?: AgendaAccess2;
|
|
22
|
+
/** The moment the agenda is read at, in epoch ms. Defaults to now, re-read on each minute. */
|
|
23
|
+
now?: number;
|
|
24
|
+
/** Formats the times and the date. Defaults to the browser's locale. */
|
|
25
|
+
locale?: Intl.LocalesArgument;
|
|
26
|
+
/** Tomorrow's events are unfolded (controlled); folded, only its first shows. */
|
|
27
|
+
tomorrowOpen?: boolean;
|
|
28
|
+
/** Tomorrow's events are unfolded at first (uncontrolled). Defaults to `false`. */
|
|
29
|
+
defaultTomorrowOpen?: boolean;
|
|
30
|
+
/** Called with the new state when tomorrow's fold is pressed. */
|
|
31
|
+
onTomorrowOpenChange?: (open: boolean) => void;
|
|
32
|
+
/** Called by Connect calendar while access is undetermined. */
|
|
33
|
+
onRequestAccess?: () => void;
|
|
34
|
+
/** Called by Open System Settings while access is denied. */
|
|
35
|
+
onOpenSettings?: () => void;
|
|
36
|
+
/** Called by the next event's Join button. */
|
|
37
|
+
onJoin?: (event: AgendaEvent2) => void;
|
|
38
|
+
/** Classes for the root, which fills its container. */
|
|
39
|
+
className?: string;
|
|
40
|
+
}
|
|
41
|
+
interface PartProps {
|
|
42
|
+
/** The event the activity counts down to. */
|
|
43
|
+
event: AgendaEvent2;
|
|
44
|
+
}
|
|
45
|
+
type Element_12xgc = JSX_1kxb["Element"];
|
|
46
|
+
/** The compact island's left wing: the calendar glyph in the event's color. */
|
|
47
|
+
declare function AgendaLeading2({ event }: PartProps): Element_12xgc;
|
|
48
|
+
/** The compact island's right wing: the event's color dot and the time until it starts, `12m` then `45s`. */
|
|
49
|
+
declare function AgendaTrailing2({ event }: PartProps): Element_12xgc;
|
|
50
|
+
interface MinimalProps extends PartProps {
|
|
51
|
+
/** How long before the start the countdown opens, in ms: the full ring. Defaults to 10 minutes. */
|
|
52
|
+
lead?: number;
|
|
53
|
+
}
|
|
54
|
+
/** The split island's bubble: a ring in the event's color that empties as the start nears. */
|
|
55
|
+
declare function AgendaMinimal2({ event, lead }: MinimalProps): Element_12xgc;
|
|
56
|
+
interface ActivityProps extends PartProps {
|
|
57
|
+
/** Formats the times. Defaults to the browser's locale. */
|
|
58
|
+
locale?: Intl.LocalesArgument;
|
|
59
|
+
/** Called by the Join button, shown when the event has a `meetingUrl`. */
|
|
60
|
+
onJoin?: (event: AgendaEvent2) => void;
|
|
61
|
+
}
|
|
62
|
+
/** The open island's "Up next" view: the next event alone, as the agenda's hero. */
|
|
63
|
+
declare function AgendaUpNext2({ event, locale, onJoin }: ActivityProps): Element_12xgc;
|
|
64
|
+
/** The island's flash a minute before the start: the calendar's color, the title, how soon and where, and Join. */
|
|
65
|
+
declare function AgendaStarting2({ event, onJoin }: Omit<ActivityProps, "locale">): Element_12xgc;
|
|
66
|
+
/**
|
|
67
|
+
* A notch app's calendar: the next event as the hero, the rest of today and
|
|
68
|
+
* tomorrow beside it.
|
|
69
|
+
*
|
|
70
|
+
* The hero is how soon the next event is, set large: `in 12 min` within the
|
|
71
|
+
* hour, `Now` with the time left while it runs, else its start time. Under
|
|
72
|
+
* it the title after its calendar's color, the time range, the place and
|
|
73
|
+
* whether it's a call, and a Join button when it has a `meetingUrl`. Today's
|
|
74
|
+
* all-day events are chips on the date line above. Beside it, past a
|
|
75
|
+
* hairline, the timeline: the rest of today as rows of start time, color
|
|
76
|
+
* mark and title, then tomorrow folded to its first event
|
|
77
|
+
* (`tomorrowOpen` / `onTomorrowOpenChange`, or kept here). Ended events drop
|
|
78
|
+
* off; `now` follows the clock on each minute unless you pin it.
|
|
79
|
+
*
|
|
80
|
+
* Before the calendar may be read it asks to connect
|
|
81
|
+
* (`access="undetermined"`), and when access is off it says where to turn it
|
|
82
|
+
* on (`"denied"`).
|
|
83
|
+
*
|
|
84
|
+
* The countdown to the next event is an activity of parts:
|
|
85
|
+
* `Agenda.Leading` and `Agenda.Trailing` for the compact island's wings (the
|
|
86
|
+
* glyph in the event's color, and its dot with `12m` that turns to seconds
|
|
87
|
+
* in the last minute), `Agenda.Minimal`, a ring in its color that empties
|
|
88
|
+
* toward the start, for the split island's bubble, `Agenda.UpNext` for the
|
|
89
|
+
* open island and `Agenda.Starting`, the flash a minute before. Each
|
|
90
|
+
* re-renders only on the edge of the unit it shows.
|
|
91
|
+
*
|
|
92
|
+
* @example {@include ./examples.mdx}
|
|
93
|
+
*/
|
|
94
|
+
declare const Agenda2: (({ events, access, now: nowProp, locale, tomorrowOpen: tomorrowOpenProp, defaultTomorrowOpen, onTomorrowOpenChange, onRequestAccess, onOpenSettings, onJoin, className }: AgendaProps2) => Element_12xgc) & {
|
|
95
|
+
Leading: typeof AgendaLeading2;
|
|
96
|
+
Trailing: typeof AgendaTrailing2;
|
|
97
|
+
Minimal: typeof AgendaMinimal2;
|
|
98
|
+
UpNext: typeof AgendaUpNext2;
|
|
99
|
+
Starting: typeof AgendaStarting2;
|
|
100
|
+
};
|
|
101
|
+
export { AgendaAccess2, AgendaEvent2, AgendaProps2, AgendaLeading2, AgendaTrailing2, AgendaMinimal2, AgendaUpNext2, AgendaStarting2, Agenda2 };
|