@justanarthur/modo-ui-notch 0.0.0-stage → 0.2.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 +58 -0
- package/blocks/activities/agenda/index.tsx +332 -0
- package/blocks/activities/now-playing/examples.mdx +49 -0
- package/blocks/activities/now-playing/index.tsx +218 -0
- package/blocks/activities/shelf/examples.mdx +33 -0
- package/blocks/activities/shelf/index.tsx +289 -0
- package/blocks/activities/timer/examples.mdx +52 -0
- package/blocks/activities/timer/index.tsx +292 -0
- package/blocks/app/expanded-island/examples.mdx +45 -0
- package/blocks/app/expanded-island/index.tsx +127 -0
- package/blocks/app/settings-window/examples.mdx +30 -0
- package/blocks/app/settings-window/index.tsx +357 -0
- package/blocks/system/controls/examples.mdx +34 -0
- package/blocks/system/controls/index.tsx +167 -0
- package/blocks/system/devices/examples.mdx +25 -0
- package/blocks/system/devices/index.tsx +172 -0
- package/blocks/system/power-alert/examples.mdx +32 -0
- package/blocks/system/power-alert/index.tsx +89 -0
- package/blocks/system/system-stats/examples.mdx +23 -0
- package/blocks/system/system-stats/index.tsx +178 -0
- package/components/indicators/battery-glyph/examples.mdx +22 -0
- package/components/indicators/battery-glyph/index.tsx +91 -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 +21 -0
- package/components/indicators/media-scrubber/index.tsx +98 -0
- package/components/island/island/examples.mdx +57 -0
- package/components/island/island/index.tsx +415 -0
- package/components/island/island-flash/examples.mdx +55 -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/dist/blocks/activities/agenda/index.d.ts +2 -0
- package/dist/blocks/activities/agenda/index.js +21 -0
- package/dist/blocks/activities/now-playing/index.d.ts +2 -0
- package/dist/blocks/activities/now-playing/index.js +22 -0
- package/dist/blocks/activities/shelf/index.d.ts +2 -0
- package/dist/blocks/activities/shelf/index.js +14 -0
- package/dist/blocks/activities/timer/index.d.ts +2 -0
- package/dist/blocks/activities/timer/index.js +19 -0
- package/dist/blocks/app/expanded-island/index.d.ts +3 -0
- package/dist/blocks/app/expanded-island/index.js +10 -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/controls/index.d.ts +2 -0
- package/dist/blocks/system/controls/index.js +10 -0
- package/dist/blocks/system/devices/index.d.ts +2 -0
- package/dist/blocks/system/devices/index.js +12 -0
- package/dist/blocks/system/power-alert/index.d.ts +2 -0
- package/dist/blocks/system/power-alert/index.js +9 -0
- package/dist/blocks/system/system-stats/index.d.ts +2 -0
- package/dist/blocks/system/system-stats/index.js +12 -0
- package/dist/components/indicators/battery-glyph/index.d.ts +2 -0
- package/dist/components/indicators/battery-glyph/index.js +9 -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/index.d.ts +21 -0
- package/dist/index.js +151 -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-2f7zxrbk.js +65 -0
- package/dist/shared/chunk-2qpcsv5h.d.ts +45 -0
- package/dist/shared/chunk-2s4q6mt0.js +27 -0
- package/dist/shared/chunk-45gytfr1.d.ts +84 -0
- package/dist/shared/chunk-502rmtap.js +54 -0
- package/dist/shared/chunk-50ffk4r7.d.ts +69 -0
- package/dist/shared/chunk-52gb3g6r.d.ts +12 -0
- package/dist/shared/chunk-5en5aaj1.d.ts +33 -0
- package/dist/shared/chunk-5w0yck07.d.ts +32 -0
- package/dist/shared/chunk-6c1jbefs.d.ts +36 -0
- package/dist/shared/chunk-78w7qwp0.js +58 -0
- package/dist/shared/chunk-7hr53mby.js +116 -0
- package/dist/shared/chunk-9nhpg9t8.d.ts +47 -0
- package/dist/shared/chunk-b8jb1w72.js +145 -0
- package/dist/shared/chunk-cfzmfnyh.d.ts +63 -0
- package/dist/shared/chunk-cpewy6yg.js +178 -0
- package/dist/shared/chunk-d5qm9cps.js +10 -0
- package/dist/shared/chunk-e3e4s4ds.d.ts +77 -0
- package/dist/shared/chunk-enm6td0p.js +280 -0
- package/dist/shared/chunk-fvedaas2.d.ts +33 -0
- package/dist/shared/chunk-gb56m10p.js +39 -0
- package/dist/shared/chunk-gex38j8x.d.ts +82 -0
- package/dist/shared/chunk-hpsabfsd.d.ts +75 -0
- package/dist/shared/chunk-hrpxbqmx.d.ts +28 -0
- package/dist/shared/chunk-hwtxpzg0.js +69 -0
- package/dist/shared/chunk-mp1nx0ez.js +101 -0
- package/dist/shared/chunk-phb53x1f.js +252 -0
- package/dist/shared/chunk-r8esmjfs.d.ts +42 -0
- package/dist/shared/chunk-rcp1g9ca.js +70 -0
- package/dist/shared/chunk-rpfwv3pz.js +209 -0
- package/dist/shared/chunk-rr5e0g15.d.ts +35 -0
- package/dist/shared/chunk-rx9sphz2.js +266 -0
- package/dist/shared/chunk-s33y1pcq.js +305 -0
- package/dist/shared/chunk-sbnrhy5m.js +331 -0
- package/dist/shared/chunk-w48eyvfr.d.ts +56 -0
- package/dist/shared/chunk-wwjxs75m.js +74 -0
- package/dist/shared/chunk-xdeek16r.d.ts +58 -0
- package/dist/shared/chunk-xkzjk1tq.js +206 -0
- package/dist/shared/chunk-yngkkxz2.d.ts +88 -0
- package/dist/shared/chunk-zvh0d3qb.js +63 -0
- package/dist/styles.css +222 -0
- package/index.ts +21 -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 +100 -0
- package/mock/artwork.tsx +25 -0
- package/mock/data.ts +153 -0
- package/mock/desktop.tsx +83 -0
- package/mock/fit.ts +26 -0
- package/mock/island-content.tsx +217 -0
- package/mock/scene.tsx +52 -0
- package/mock/settings.tsx +210 -0
- package/package.json +117 -4
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { JSX as JSX_1kxb } from "react";
|
|
2
|
+
type TimerKind2 = "focus" | "break" | "custom";
|
|
3
|
+
/** A run: running while it has `endsAt`, paused while it has `remaining`. */
|
|
4
|
+
interface TimerRun2 {
|
|
5
|
+
kind: TimerKind2;
|
|
6
|
+
/** Its whole length, in ms. */
|
|
7
|
+
total: number;
|
|
8
|
+
/** When it ends, in epoch ms, while it runs. */
|
|
9
|
+
endsAt?: number;
|
|
10
|
+
/** The time left, in ms, while it is paused. */
|
|
11
|
+
remaining?: number;
|
|
12
|
+
}
|
|
13
|
+
interface TimerProps2 {
|
|
14
|
+
/** The run (controlled); `null` shows the picker. */
|
|
15
|
+
value?: TimerRun2 | null;
|
|
16
|
+
/** The run at first (uncontrolled). Defaults to `null`. */
|
|
17
|
+
defaultValue?: TimerRun2 | null;
|
|
18
|
+
/** Called with the run a start, pause, resume, +1 min or cancel leaves, and `null` when it ends. */
|
|
19
|
+
onValueChange?: (run: TimerRun2 | null) => void;
|
|
20
|
+
/** Called when a run reaches zero, with the kind that starts next in a Pomodoro cycle. */
|
|
21
|
+
onEnd?: (run: TimerRun2, next?: TimerKind2) => void;
|
|
22
|
+
/** The picker's quick lengths, in minutes, before the Pomodoro preset. Defaults to `[1, 5, 10]`. */
|
|
23
|
+
presets?: number[];
|
|
24
|
+
/** Pomodoro cycles: when a focus run ends a break starts on its own, then focus again. Defaults to `false`. */
|
|
25
|
+
pomodoro?: boolean;
|
|
26
|
+
/** A focus run's length, in minutes. Defaults to `25`. */
|
|
27
|
+
focusMinutes?: number;
|
|
28
|
+
/** A break's length, in minutes. Defaults to `5`. */
|
|
29
|
+
breakMinutes?: number;
|
|
30
|
+
/** Classes for the root, which fills its container. */
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
type Element_12xgc = JSX_1kxb["Element"];
|
|
34
|
+
/** The compact island's left wing: the timer's glyph. */
|
|
35
|
+
declare function TimerLeading2(): Element_12xgc;
|
|
36
|
+
/** The compact island's right wing: the time left, muted while paused. */
|
|
37
|
+
declare function TimerTrailing2({ run }: {
|
|
38
|
+
run: TimerRun2;
|
|
39
|
+
}): Element_12xgc;
|
|
40
|
+
/** The split island's bubble: a ring of the time left. */
|
|
41
|
+
declare function TimerMinimal2({ run }: {
|
|
42
|
+
run: TimerRun2;
|
|
43
|
+
}): Element_12xgc;
|
|
44
|
+
interface TimerDoneProps2 {
|
|
45
|
+
/** The run that ended. Defaults to `'custom'`. */
|
|
46
|
+
kind?: TimerKind2;
|
|
47
|
+
/** The kind a Pomodoro cycle starts next. */
|
|
48
|
+
next?: TimerKind2;
|
|
49
|
+
/** The next run's length, in minutes. */
|
|
50
|
+
minutes?: number;
|
|
51
|
+
}
|
|
52
|
+
/** The island's flash when a run reaches zero: "Time's up", and what starts next in a Pomodoro cycle. */
|
|
53
|
+
declare function TimerDone2({ kind, next, minutes }: TimerDoneProps2): Element_12xgc;
|
|
54
|
+
/**
|
|
55
|
+
* A notch app's timer: pick a length, watch it run down, hear when it's up.
|
|
56
|
+
*
|
|
57
|
+
* Without a run it shows the picker: quick lengths (`presets`), a Pomodoro
|
|
58
|
+
* focus run and a custom length in minutes on a NumberInput. A run shows a
|
|
59
|
+
* Meter ring of the time left beside the time itself in display type, with
|
|
60
|
+
* +1 min, pause / resume and cancel. The run is a value (`value` /
|
|
61
|
+
* `onValueChange`, or kept here from `defaultValue`): a running one carries
|
|
62
|
+
* when it ends, a paused one the time it had left, so a host can persist it
|
|
63
|
+
* and resume after a reload. The time re-renders once a second, on the
|
|
64
|
+
* second's edge, and nothing runs while it is paused.
|
|
65
|
+
*
|
|
66
|
+
* At zero it calls `onEnd` and clears the run, unless `pomodoro` cycles:
|
|
67
|
+
* then a focus run hands over to a break and a break back to focus.
|
|
68
|
+
*
|
|
69
|
+
* The other forms are parts: `Timer.Leading` and `Timer.Trailing` for the
|
|
70
|
+
* compact island's wings (the glyph and the time left), `Timer.Minimal` for
|
|
71
|
+
* the split island's bubble (the ring) and `Timer.Done`, the "Time's up"
|
|
72
|
+
* flash.
|
|
73
|
+
*
|
|
74
|
+
* @example {@include ./examples.mdx}
|
|
75
|
+
*/
|
|
76
|
+
declare function Timer2({ value, defaultValue, onValueChange, onEnd, presets, pomodoro, focusMinutes, breakMinutes, className }: TimerProps2): Element_12xgc;
|
|
77
|
+
export { TimerKind2, TimerRun2, TimerProps2, TimerLeading2, TimerTrailing2, TimerMinimal2, TimerDoneProps2, TimerDone2, Timer2 };
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
SECOND2,
|
|
5
|
+
MINUTE2,
|
|
6
|
+
formatShort2,
|
|
7
|
+
useEdgeClock2
|
|
8
|
+
} from "./chunk-gb56m10p.js";
|
|
9
|
+
import {
|
|
10
|
+
Countdown2
|
|
11
|
+
} from "./chunk-502rmtap.js";
|
|
12
|
+
import {
|
|
13
|
+
IslandFlash2
|
|
14
|
+
} from "./chunk-78w7qwp0.js";
|
|
15
|
+
|
|
16
|
+
// blocks/activities/agenda/index.tsx
|
|
17
|
+
import Button from "@justanarthur/modo-ui/components/actions/button";
|
|
18
|
+
import EmptyState from "@justanarthur/modo-ui/components/feedback/empty-state";
|
|
19
|
+
import Meter from "@justanarthur/modo-ui/components/feedback/meter";
|
|
20
|
+
import { useSize } from "@justanarthur/modo-ui/lib/size-context";
|
|
21
|
+
import { cn } from "@justanarthur/modo-ui/lib/utils";
|
|
22
|
+
import { CalendarCheck, CalendarDays, Video } from "lucide-react";
|
|
23
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
24
|
+
/*!
|
|
25
|
+
* Local addition: a notch app's calendar, today's and tomorrow's events and
|
|
26
|
+
* the countdown to the next one. Rebuilt from Just Notch's calendar plugin
|
|
27
|
+
* (`Agenda`, `Upcoming`, `Starting`, `Ring`, `Countdown`) as presentational
|
|
28
|
+
* parts: events, access and actions come in as props.
|
|
29
|
+
*/
|
|
30
|
+
var clock = (ms, locale) => new Date(ms).toLocaleTimeString(locale, { hour: "numeric", minute: "2-digit" });
|
|
31
|
+
var span = (event, locale) => event.allDay ? "All day" : `${clock(event.start, locale)} – ${clock(event.end, locale)}`;
|
|
32
|
+
var meta = (event, locale) => event.location ? `${span(event, locale)} · ${event.location}` : span(event, locale);
|
|
33
|
+
function relative(ms) {
|
|
34
|
+
if (ms <= 0)
|
|
35
|
+
return "Now";
|
|
36
|
+
if (ms < MINUTE2)
|
|
37
|
+
return "In less than a minute";
|
|
38
|
+
return `In ${Math.ceil(ms / MINUTE2)} min`;
|
|
39
|
+
}
|
|
40
|
+
function useUntil(start, unit = MINUTE2) {
|
|
41
|
+
const now = useEdgeClock2(start, Date.now() < start + SECOND2, unit);
|
|
42
|
+
return start - now;
|
|
43
|
+
}
|
|
44
|
+
function Join({
|
|
45
|
+
event,
|
|
46
|
+
size,
|
|
47
|
+
onJoin
|
|
48
|
+
}) {
|
|
49
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
50
|
+
variant: "secondary",
|
|
51
|
+
size,
|
|
52
|
+
leadingIcon: Video,
|
|
53
|
+
onClick: () => onJoin?.(event),
|
|
54
|
+
children: "Join"
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function AgendaLeading2({ event }) {
|
|
58
|
+
return /* @__PURE__ */ jsx(CalendarDays, {
|
|
59
|
+
size: 16,
|
|
60
|
+
strokeWidth: 1.5,
|
|
61
|
+
style: { color: event.color }
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function AgendaTrailing2({ event }) {
|
|
65
|
+
return /* @__PURE__ */ jsx("span", {
|
|
66
|
+
className: "text-caption weight-semibold",
|
|
67
|
+
style: { color: event.color },
|
|
68
|
+
children: /* @__PURE__ */ jsx(Countdown2, {
|
|
69
|
+
endsAt: event.start,
|
|
70
|
+
format: "short"
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function AgendaMinimal2({ event, lead = 10 * MINUTE2 }) {
|
|
75
|
+
const left = Math.max(0, useUntil(event.start, SECOND2));
|
|
76
|
+
return /* @__PURE__ */ jsx(Meter, {
|
|
77
|
+
variant: "ring",
|
|
78
|
+
label: `${event.title}, in ${formatShort2(left / SECOND2)}`,
|
|
79
|
+
value: Math.min(1, left / lead),
|
|
80
|
+
tone: "default",
|
|
81
|
+
animate: false,
|
|
82
|
+
className: "size-5.5"
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function AgendaUpNext2({ event, locale, onJoin }) {
|
|
86
|
+
const left = useUntil(event.start);
|
|
87
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
88
|
+
className: "flex size-full items-center gap-4",
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ jsx("span", {
|
|
91
|
+
className: "h-14 w-1 shrink-0 rounded-full",
|
|
92
|
+
style: { backgroundColor: event.color }
|
|
93
|
+
}),
|
|
94
|
+
/* @__PURE__ */ jsxs("div", {
|
|
95
|
+
className: "flex min-w-0 flex-1 flex-col gap-1",
|
|
96
|
+
children: [
|
|
97
|
+
/* @__PURE__ */ jsx("span", {
|
|
98
|
+
className: "text-caption weight-semibold tabular-nums",
|
|
99
|
+
style: { color: event.color },
|
|
100
|
+
children: relative(left)
|
|
101
|
+
}),
|
|
102
|
+
/* @__PURE__ */ jsx("span", {
|
|
103
|
+
className: "truncate text-title weight-semibold text-foreground",
|
|
104
|
+
children: event.title
|
|
105
|
+
}),
|
|
106
|
+
/* @__PURE__ */ jsx("span", {
|
|
107
|
+
className: "truncate text-body text-muted-foreground",
|
|
108
|
+
children: meta(event, locale)
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
}),
|
|
112
|
+
event.meetingUrl && /* @__PURE__ */ jsx(Join, {
|
|
113
|
+
event,
|
|
114
|
+
size: "default",
|
|
115
|
+
onJoin
|
|
116
|
+
})
|
|
117
|
+
]
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function AgendaStarting2({ event, onJoin }) {
|
|
121
|
+
const left = useUntil(event.start, SECOND2);
|
|
122
|
+
return /* @__PURE__ */ jsx(IslandFlash2, {
|
|
123
|
+
icon: /* @__PURE__ */ jsx("span", {
|
|
124
|
+
className: "size-2.5 rounded-full",
|
|
125
|
+
style: { backgroundColor: event.color }
|
|
126
|
+
}),
|
|
127
|
+
title: event.title,
|
|
128
|
+
caption: relative(left),
|
|
129
|
+
action: event.meetingUrl && /* @__PURE__ */ jsx(Join, {
|
|
130
|
+
event,
|
|
131
|
+
size: "compact",
|
|
132
|
+
onJoin
|
|
133
|
+
})
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function Row({
|
|
137
|
+
event,
|
|
138
|
+
locale,
|
|
139
|
+
onJoin
|
|
140
|
+
}) {
|
|
141
|
+
const size = useSize();
|
|
142
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
143
|
+
className: cn("flex items-center gap-3", size.control),
|
|
144
|
+
children: [
|
|
145
|
+
/* @__PURE__ */ jsx("span", {
|
|
146
|
+
className: "size-2 shrink-0 rounded-full",
|
|
147
|
+
style: { backgroundColor: event.color }
|
|
148
|
+
}),
|
|
149
|
+
/* @__PURE__ */ jsx("span", {
|
|
150
|
+
className: "w-16 shrink-0 whitespace-nowrap text-caption tabular-nums text-muted-foreground",
|
|
151
|
+
children: event.allDay ? "All day" : clock(event.start, locale)
|
|
152
|
+
}),
|
|
153
|
+
/* @__PURE__ */ jsxs("span", {
|
|
154
|
+
className: "flex min-w-0 flex-1 items-baseline gap-2",
|
|
155
|
+
children: [
|
|
156
|
+
/* @__PURE__ */ jsx("span", {
|
|
157
|
+
className: "min-w-0 truncate text-body text-foreground",
|
|
158
|
+
children: event.title
|
|
159
|
+
}),
|
|
160
|
+
event.location && !event.meetingUrl && /* @__PURE__ */ jsx("span", {
|
|
161
|
+
className: "min-w-0 shrink-[100] truncate text-caption text-muted-foreground",
|
|
162
|
+
children: event.location
|
|
163
|
+
})
|
|
164
|
+
]
|
|
165
|
+
}),
|
|
166
|
+
event.meetingUrl && /* @__PURE__ */ jsx(Join, {
|
|
167
|
+
event,
|
|
168
|
+
size: "compact",
|
|
169
|
+
onJoin
|
|
170
|
+
})
|
|
171
|
+
]
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
function Day({ title, events, empty, locale, onJoin }) {
|
|
175
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
176
|
+
"aria-label": title,
|
|
177
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
178
|
+
children: [
|
|
179
|
+
/* @__PURE__ */ jsx("h3", {
|
|
180
|
+
className: "m-0 flex h-5 items-center text-caption weight-normal text-muted-foreground",
|
|
181
|
+
children: title
|
|
182
|
+
}),
|
|
183
|
+
events.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
184
|
+
className: "m-0 flex h-9 items-center text-body text-muted-foreground",
|
|
185
|
+
children: empty
|
|
186
|
+
}) : /* @__PURE__ */ jsx("ul", {
|
|
187
|
+
className: "m-0 flex list-none flex-col p-0",
|
|
188
|
+
children: events.map((event) => /* @__PURE__ */ jsx(Row, {
|
|
189
|
+
event,
|
|
190
|
+
locale,
|
|
191
|
+
onJoin
|
|
192
|
+
}, event.id))
|
|
193
|
+
})
|
|
194
|
+
]
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
function Agenda2({
|
|
198
|
+
events,
|
|
199
|
+
access = "granted",
|
|
200
|
+
now: nowProp,
|
|
201
|
+
locale,
|
|
202
|
+
onRequestAccess,
|
|
203
|
+
onOpenSettings,
|
|
204
|
+
onJoin,
|
|
205
|
+
className
|
|
206
|
+
}) {
|
|
207
|
+
const ticking = useEdgeClock2(0, nowProp === undefined, MINUTE2);
|
|
208
|
+
const now = nowProp ?? ticking;
|
|
209
|
+
if (access === "undetermined")
|
|
210
|
+
return /* @__PURE__ */ jsx("div", {
|
|
211
|
+
className: cn("flex size-full items-center justify-center", className),
|
|
212
|
+
children: /* @__PURE__ */ jsx(EmptyState, {
|
|
213
|
+
size: "compact",
|
|
214
|
+
icon: CalendarDays,
|
|
215
|
+
title: "See what's next",
|
|
216
|
+
description: "Today's and tomorrow's events, with a countdown before each one starts.",
|
|
217
|
+
actions: /* @__PURE__ */ jsx(Button, {
|
|
218
|
+
variant: "primary",
|
|
219
|
+
size: "compact",
|
|
220
|
+
onClick: onRequestAccess,
|
|
221
|
+
children: "Connect calendar"
|
|
222
|
+
})
|
|
223
|
+
})
|
|
224
|
+
});
|
|
225
|
+
if (access === "denied")
|
|
226
|
+
return /* @__PURE__ */ jsx("div", {
|
|
227
|
+
className: cn("flex size-full items-center justify-center", className),
|
|
228
|
+
children: /* @__PURE__ */ jsx(EmptyState, {
|
|
229
|
+
size: "compact",
|
|
230
|
+
icon: CalendarDays,
|
|
231
|
+
title: "Calendar access is off",
|
|
232
|
+
description: "Turn it on in Privacy & Security › Calendars.",
|
|
233
|
+
actions: /* @__PURE__ */ jsx(Button, {
|
|
234
|
+
variant: "secondary",
|
|
235
|
+
size: "compact",
|
|
236
|
+
onClick: onOpenSettings,
|
|
237
|
+
children: "Open System Settings"
|
|
238
|
+
})
|
|
239
|
+
})
|
|
240
|
+
});
|
|
241
|
+
const midnight = new Date(now).setHours(24, 0, 0, 0);
|
|
242
|
+
const next = new Date(midnight).setHours(24, 0, 0, 0);
|
|
243
|
+
const live = events.filter((event) => event.end > now && event.start < next);
|
|
244
|
+
if (live.length === 0)
|
|
245
|
+
return /* @__PURE__ */ jsx("div", {
|
|
246
|
+
className: cn("flex size-full items-center justify-center", className),
|
|
247
|
+
children: /* @__PURE__ */ jsx(EmptyState, {
|
|
248
|
+
size: "compact",
|
|
249
|
+
icon: CalendarCheck,
|
|
250
|
+
title: "Nothing planned",
|
|
251
|
+
description: "No events for the rest of today or tomorrow."
|
|
252
|
+
})
|
|
253
|
+
});
|
|
254
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
255
|
+
className: cn("flex min-h-full gap-8", className),
|
|
256
|
+
children: [
|
|
257
|
+
/* @__PURE__ */ jsx(Day, {
|
|
258
|
+
title: "Today",
|
|
259
|
+
events: live.filter((event) => event.start < midnight),
|
|
260
|
+
empty: "Nothing else today",
|
|
261
|
+
locale,
|
|
262
|
+
onJoin
|
|
263
|
+
}),
|
|
264
|
+
/* @__PURE__ */ jsx(Day, {
|
|
265
|
+
title: "Tomorrow",
|
|
266
|
+
events: live.filter((event) => event.start >= midnight),
|
|
267
|
+
empty: "Nothing planned",
|
|
268
|
+
locale,
|
|
269
|
+
onJoin
|
|
270
|
+
})
|
|
271
|
+
]
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
Agenda2.Leading = AgendaLeading2;
|
|
275
|
+
Agenda2.Trailing = AgendaTrailing2;
|
|
276
|
+
Agenda2.Minimal = AgendaMinimal2;
|
|
277
|
+
Agenda2.UpNext = AgendaUpNext2;
|
|
278
|
+
Agenda2.Starting = AgendaStarting2;
|
|
279
|
+
var agenda_default = Agenda2;
|
|
280
|
+
export { AgendaLeading2, AgendaTrailing2, AgendaMinimal2, AgendaUpNext2, AgendaStarting2, Agenda2, agenda_default };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { JSX as JSX_1kxb } from "react";
|
|
2
|
+
type BatteryTone2 = "default" | "success" | "warning" | "error";
|
|
3
|
+
interface BatteryGlyphProps2 {
|
|
4
|
+
/** The charge, in percent (0 to 100). */
|
|
5
|
+
level: number;
|
|
6
|
+
/** A charger is connected: the bolt shows and the tone turns to success. Defaults to `false`. */
|
|
7
|
+
charging?: boolean;
|
|
8
|
+
/** The fill's hue. Defaults to success while charging, error at 10% and below, warning at 20% and below, else the text color. */
|
|
9
|
+
tone?: BatteryTone2;
|
|
10
|
+
/** Fill up from empty when it first shows, as a flash opens. Defaults to `true`. */
|
|
11
|
+
fillIn?: boolean;
|
|
12
|
+
/** What screen readers hear. Defaults to the level, and "charging" while it charges. */
|
|
13
|
+
label?: string;
|
|
14
|
+
/** Classes for the glyph. */
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
/** The tone a battery at `level` takes on its own. */
|
|
18
|
+
declare function batteryTone2(level: number, charging: boolean): BatteryTone2;
|
|
19
|
+
type Element_12xgc = JSX_1kxb["Element"];
|
|
20
|
+
/**
|
|
21
|
+
* A battery at a glance: a case that fills to the charge, a bolt while it
|
|
22
|
+
* charges.
|
|
23
|
+
*
|
|
24
|
+
* The fill turns to the success hue while charging and to the warning and
|
|
25
|
+
* error hues as the charge runs low, unless `tone` pins one. It fills up from
|
|
26
|
+
* empty when it first shows, on the slow spring, the way a power alert opens;
|
|
27
|
+
* a later change of level springs from where it was. A sliver always shows,
|
|
28
|
+
* so an empty battery still reads as one.
|
|
29
|
+
*
|
|
30
|
+
* @example {@include ./examples.mdx}
|
|
31
|
+
*/
|
|
32
|
+
declare function BatteryGlyph2({ level, charging, tone, fillIn, label, className }: BatteryGlyphProps2): Element_12xgc;
|
|
33
|
+
export { BatteryTone2, BatteryGlyphProps2, batteryTone2, BatteryGlyph2 };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// lib/clock.ts
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
var SECOND2 = 1000;
|
|
6
|
+
var MINUTE2 = 60 * SECOND2;
|
|
7
|
+
function formatClock2(seconds) {
|
|
8
|
+
const s = Math.max(0, Math.floor(seconds));
|
|
9
|
+
const ss = String(s % 60).padStart(2, "0");
|
|
10
|
+
if (s < 3600)
|
|
11
|
+
return `${Math.floor(s / 60)}:${ss}`;
|
|
12
|
+
return `${Math.floor(s / 3600)}:${String(Math.floor(s / 60) % 60).padStart(2, "0")}:${ss}`;
|
|
13
|
+
}
|
|
14
|
+
function formatShort2(seconds) {
|
|
15
|
+
const s = Math.max(0, Math.ceil(seconds));
|
|
16
|
+
if (s < 60)
|
|
17
|
+
return `${s}s`;
|
|
18
|
+
if (s < 3600)
|
|
19
|
+
return `${Math.ceil(s / 60)}m`;
|
|
20
|
+
return `${Math.ceil(s / 3600)}h`;
|
|
21
|
+
}
|
|
22
|
+
function useEdgeClock2(anchor, running, unit = SECOND2) {
|
|
23
|
+
const [now, setNow] = useState(Date.now);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!running)
|
|
26
|
+
return;
|
|
27
|
+
let timer;
|
|
28
|
+
const tick = () => {
|
|
29
|
+
const t = Date.now();
|
|
30
|
+
setNow(t);
|
|
31
|
+
const offset = ((anchor - t) % unit + unit) % unit;
|
|
32
|
+
timer = setTimeout(tick, offset || unit);
|
|
33
|
+
};
|
|
34
|
+
tick();
|
|
35
|
+
return () => clearTimeout(timer);
|
|
36
|
+
}, [anchor, running, unit]);
|
|
37
|
+
return running ? now : Date.now();
|
|
38
|
+
}
|
|
39
|
+
export { SECOND2, MINUTE2, formatClock2, formatShort2, useEdgeClock2 };
|
|
@@ -0,0 +1,82 @@
|
|
|
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 and the countdown inline. */
|
|
15
|
+
color: string;
|
|
16
|
+
}
|
|
17
|
+
interface AgendaProps2 {
|
|
18
|
+
/** The events, in start 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. Defaults to the browser's locale. */
|
|
25
|
+
locale?: Intl.LocalesArgument;
|
|
26
|
+
/** Called by Connect calendar while access is undetermined. */
|
|
27
|
+
onRequestAccess?: () => void;
|
|
28
|
+
/** Called by Open System Settings while access is denied. */
|
|
29
|
+
onOpenSettings?: () => void;
|
|
30
|
+
/** Called by an event's Join button. */
|
|
31
|
+
onJoin?: (event: AgendaEvent2) => void;
|
|
32
|
+
/** Classes for the root, which fills its container. */
|
|
33
|
+
className?: string;
|
|
34
|
+
}
|
|
35
|
+
interface PartProps {
|
|
36
|
+
/** The event the activity counts down to. */
|
|
37
|
+
event: AgendaEvent2;
|
|
38
|
+
}
|
|
39
|
+
type Element_12xgc = JSX_1kxb["Element"];
|
|
40
|
+
/** The compact island's left wing: the calendar glyph in the event's color. */
|
|
41
|
+
declare function AgendaLeading2({ event }: PartProps): Element_12xgc;
|
|
42
|
+
/** The compact island's right wing: the time until it starts, `4m` then `45s`. */
|
|
43
|
+
declare function AgendaTrailing2({ event }: PartProps): Element_12xgc;
|
|
44
|
+
interface MinimalProps extends PartProps {
|
|
45
|
+
/** How long before the start the countdown opens, in ms: the full ring. Defaults to 10 minutes. */
|
|
46
|
+
lead?: number;
|
|
47
|
+
}
|
|
48
|
+
/** The split island's bubble: a ring that empties as the start nears. */
|
|
49
|
+
declare function AgendaMinimal2({ event, lead }: MinimalProps): Element_12xgc;
|
|
50
|
+
interface ActivityProps extends PartProps {
|
|
51
|
+
/** Formats the times. Defaults to the browser's locale. */
|
|
52
|
+
locale?: Intl.LocalesArgument;
|
|
53
|
+
/** Called by the Join button, shown when the event has a `meetingUrl`. */
|
|
54
|
+
onJoin?: (event: AgendaEvent2) => void;
|
|
55
|
+
}
|
|
56
|
+
/** The open island's "Up next" view: how soon, the title, the time and place, and Join. */
|
|
57
|
+
declare function AgendaUpNext2({ event, locale, onJoin }: ActivityProps): Element_12xgc;
|
|
58
|
+
/** The island's flash a minute before the start: the title, how soon, and Join. */
|
|
59
|
+
declare function AgendaStarting2({ event, onJoin }: Omit<ActivityProps, "locale">): Element_12xgc;
|
|
60
|
+
/**
|
|
61
|
+
* A notch app's calendar: what's left of today and what's on tomorrow, side
|
|
62
|
+
* by side.
|
|
63
|
+
*
|
|
64
|
+
* Each event is a row with its calendar's color as a dot, its start time (or
|
|
65
|
+
* All day), its title and place, and a Join button when it has a video call.
|
|
66
|
+
* Events that have ended drop off; the day boundary is read from `now`, which
|
|
67
|
+
* follows the clock on each minute unless you pin it. Before the calendar may
|
|
68
|
+
* be read it asks to connect (`access="undetermined"`), and when access is
|
|
69
|
+
* off it points to the system's settings (`"denied"`).
|
|
70
|
+
*
|
|
71
|
+
* The countdown to the next event is an activity of parts:
|
|
72
|
+
* `Agenda.Leading` and `Agenda.Trailing` for the compact island's wings (the
|
|
73
|
+
* glyph in the event's color, and `4m` that turns to seconds in the last
|
|
74
|
+
* minute), `Agenda.Minimal`, a ring that empties toward the start, for the
|
|
75
|
+
* split island's bubble, `Agenda.UpNext` for the open island and
|
|
76
|
+
* `Agenda.Starting`, the flash a minute before. Each re-renders only on the
|
|
77
|
+
* edge of the unit it shows.
|
|
78
|
+
*
|
|
79
|
+
* @example {@include ./examples.mdx}
|
|
80
|
+
*/
|
|
81
|
+
declare function Agenda2({ events, access, now: nowProp, locale, onRequestAccess, onOpenSettings, onJoin, className }: AgendaProps2): Element_12xgc;
|
|
82
|
+
export { AgendaAccess2, AgendaEvent2, AgendaProps2, AgendaLeading2, AgendaTrailing2, AgendaMinimal2, AgendaUpNext2, AgendaStarting2, Agenda2 };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { IslandState2 } from "./chunk-cfzmfnyh.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { JSX as JSX_1kxb } from "react";
|
|
4
|
+
type CollapsedState2 = "idle" | "compact" | "split";
|
|
5
|
+
interface IslandProps2 {
|
|
6
|
+
/** What it shows (controlled). */
|
|
7
|
+
state?: IslandState2;
|
|
8
|
+
/** What it shows at first (uncontrolled). Defaults to `'idle'`. */
|
|
9
|
+
defaultState?: IslandState2;
|
|
10
|
+
/** Called with the state a press, a hover or Escape asks for. */
|
|
11
|
+
onStateChange?: (state: IslandState2) => void;
|
|
12
|
+
/** Where Escape and leaving the open island go back to. Defaults to the last of `idle`, `compact` or `split` it showed. */
|
|
13
|
+
collapsedState?: CollapsedState2;
|
|
14
|
+
/** Opens after a short hover and closes a moment after the pointer leaves. Defaults to `false`. */
|
|
15
|
+
expandOnHover?: boolean;
|
|
16
|
+
/** The hardware notch's width in px. Defaults to `185`. */
|
|
17
|
+
notchWidth?: number;
|
|
18
|
+
/** The notch's height in px: the compact island's and the menu bar's. Defaults to `32`. */
|
|
19
|
+
notchHeight?: number;
|
|
20
|
+
/** The open island's width in px; it shrinks to the room it has. Defaults to `720`. */
|
|
21
|
+
panelWidth?: number;
|
|
22
|
+
/** The open island's height in px. Defaults to `320`. */
|
|
23
|
+
panelHeight?: number;
|
|
24
|
+
/** The compact left wing: the activity's glyph (`compact` and `split`). */
|
|
25
|
+
leading?: ReactNode;
|
|
26
|
+
/** The compact right wing: its live value (`compact` and `split`). */
|
|
27
|
+
trailing?: ReactNode;
|
|
28
|
+
/** The second activity, in the bubble that melts off the island's right end (`split`). */
|
|
29
|
+
minimal?: ReactNode;
|
|
30
|
+
/** The open island's content, from its top edge: leave the notch's height free for tabs (`expanded`). */
|
|
31
|
+
expanded?: ReactNode;
|
|
32
|
+
/** The alert below the notch (`flash`), such as an IslandFlash. */
|
|
33
|
+
flash?: ReactNode;
|
|
34
|
+
/** Names what the wings or the flash show; a new one swaps them with the blur, so one alert replacing another reads as new. Defaults to the state. */
|
|
35
|
+
activity?: string;
|
|
36
|
+
/** The accessible name of the press that opens it. Defaults to `'Open the island'`. */
|
|
37
|
+
label?: string;
|
|
38
|
+
/** Classes for the root, which spans its container's width. */
|
|
39
|
+
className?: string;
|
|
40
|
+
}
|
|
41
|
+
type Element_12xgc = JSX_1kxb["Element"];
|
|
42
|
+
/**
|
|
43
|
+
* The island of a notch app: one black outline that hangs from the top edge,
|
|
44
|
+
* flows into it through concave shoulders and grows out of the hardware notch
|
|
45
|
+
* as its activities need room.
|
|
46
|
+
*
|
|
47
|
+
* Five states. `idle` is the bare notch. `compact` widens into two wings for
|
|
48
|
+
* an activity's `leading` glyph and `trailing` value. `split` keeps them and
|
|
49
|
+
* melts a second activity's `minimal` bubble off the right end through
|
|
50
|
+
* modo-ui's goo. `flash` drops below the notch for a moment's alert, and
|
|
51
|
+
* `expanded` opens the panel, whose `expanded` content starts at the top
|
|
52
|
+
* edge: leave the notch's height for an IslandTabs strip.
|
|
53
|
+
*
|
|
54
|
+
* The outline is one SVG path on motion values, so a change of state animates
|
|
55
|
+
* without layout: growing on the target state's spring tier, shrinking on the
|
|
56
|
+
* source's exit tween. The content swaps the way Apple's island does, the
|
|
57
|
+
* leaving content blurring out as the arriving one sharpens and grows in;
|
|
58
|
+
* under reduced motion the shape jumps and the content only fades. At rest
|
|
59
|
+
* nothing is clipped or filtered: the clip runs only while the outline moves,
|
|
60
|
+
* the goo only while the bubble detaches or rejoins.
|
|
61
|
+
*
|
|
62
|
+
* It is always true black (`fill-ink`), the color of the notch it grows from,
|
|
63
|
+
* and its content takes modo-ui's dark scope one surface up, so a tile inside
|
|
64
|
+
* reads as raised. Content reads the island's state and geometry with
|
|
65
|
+
* `useIsland()`.
|
|
66
|
+
*
|
|
67
|
+
* A press on the island opens it (a press on a control inside it is the
|
|
68
|
+
* control's); Escape, and with `expandOnHover` the pointer leaving, closes it
|
|
69
|
+
* back to the state it came from. Controlled through `state` /
|
|
70
|
+
* `onStateChange`, or uncontrolled from `defaultState`.
|
|
71
|
+
*
|
|
72
|
+
* @example {@include ./examples.mdx}
|
|
73
|
+
*/
|
|
74
|
+
declare function Island2({ state: stateProp, defaultState, onStateChange, collapsedState, expandOnHover, notchWidth, notchHeight, panelWidth, panelHeight, leading, trailing, minimal, expanded, flash, activity, label, className }: IslandProps2): Element_12xgc;
|
|
75
|
+
export { CollapsedState2, IslandProps2, Island2 };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { JSX as JSX_1kxb } from "react";
|
|
2
|
+
interface EqualizerProps2 {
|
|
3
|
+
/** Music is playing: the bars move. Paused, they settle low. Defaults to `true`. */
|
|
4
|
+
playing?: boolean;
|
|
5
|
+
/** How many bars, from 1 to 5. Defaults to `4`. */
|
|
6
|
+
bars?: number;
|
|
7
|
+
/** What screen readers hear. Without one the bars are hidden from them. */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** Classes for the bars' fill. Defaults to `'bg-foreground'`. */
|
|
10
|
+
barClassName?: string;
|
|
11
|
+
/** Classes for the row, such as its height. Defaults to `'h-3.5'`. */
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
type Element_12xgc = JSX_1kxb["Element"];
|
|
15
|
+
/**
|
|
16
|
+
* Level bars for what's playing: they dance while music plays and settle low
|
|
17
|
+
* when it pauses.
|
|
18
|
+
*
|
|
19
|
+
* Each bar loops its own levels at its own pace on the Web Animations API, a
|
|
20
|
+
* `transform` loop the compositor runs, so playing music costs no JavaScript
|
|
21
|
+
* per frame. Pausing springs the bars down to rest; under reduced motion they
|
|
22
|
+
* hold still at a level instead of dancing. They take the text color, or any
|
|
23
|
+
* fill through `barClassName` (an artwork's tint).
|
|
24
|
+
*
|
|
25
|
+
* @example {@include ./examples.mdx}
|
|
26
|
+
*/
|
|
27
|
+
declare function Equalizer2({ playing, bars, label, barClassName, className }: EqualizerProps2): Element_12xgc;
|
|
28
|
+
export { EqualizerProps2, Equalizer2 };
|