@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.
Files changed (141) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +75 -2
  3. package/blocks/activities/agenda/examples.mdx +74 -0
  4. package/blocks/activities/agenda/index.tsx +441 -0
  5. package/blocks/activities/clock/examples.mdx +73 -0
  6. package/blocks/activities/clock/index.tsx +619 -0
  7. package/blocks/activities/now-playing/examples.mdx +68 -0
  8. package/blocks/activities/now-playing/index.tsx +411 -0
  9. package/blocks/activities/weather/examples.mdx +115 -0
  10. package/blocks/activities/weather/index.tsx +634 -0
  11. package/blocks/app/expanded-island/examples.mdx +46 -0
  12. package/blocks/app/expanded-island/index.tsx +143 -0
  13. package/blocks/app/settings-window/examples.mdx +34 -0
  14. package/blocks/app/settings-window/index.tsx +375 -0
  15. package/blocks/system/clipboard/examples.mdx +83 -0
  16. package/blocks/system/clipboard/index.tsx +563 -0
  17. package/blocks/system/recent-files/examples.mdx +66 -0
  18. package/blocks/system/recent-files/index.tsx +542 -0
  19. package/blocks/system/system-stats/examples.mdx +52 -0
  20. package/blocks/system/system-stats/index.tsx +312 -0
  21. package/components/indicators/countdown/examples.mdx +25 -0
  22. package/components/indicators/countdown/index.tsx +83 -0
  23. package/components/indicators/equalizer/examples.mdx +20 -0
  24. package/components/indicators/equalizer/index.tsx +116 -0
  25. package/components/indicators/media-scrubber/examples.mdx +29 -0
  26. package/components/indicators/media-scrubber/index.tsx +122 -0
  27. package/components/island/island/examples.mdx +57 -0
  28. package/components/island/island/index.tsx +415 -0
  29. package/components/island/island-flash/examples.mdx +52 -0
  30. package/components/island/island-flash/index.tsx +79 -0
  31. package/components/island/island-tabs/examples.mdx +53 -0
  32. package/components/island/island-tabs/index.tsx +285 -0
  33. package/components/island/widget/examples.mdx +76 -0
  34. package/components/island/widget/index.tsx +431 -0
  35. package/dist/blocks/activities/agenda/index.d.ts +2 -0
  36. package/dist/blocks/activities/agenda/index.js +21 -0
  37. package/dist/blocks/activities/clock/index.d.ts +2 -0
  38. package/dist/blocks/activities/clock/index.js +25 -0
  39. package/dist/blocks/activities/now-playing/index.d.ts +3 -0
  40. package/dist/blocks/activities/now-playing/index.js +24 -0
  41. package/dist/blocks/activities/weather/index.d.ts +2 -0
  42. package/dist/blocks/activities/weather/index.js +21 -0
  43. package/dist/blocks/app/expanded-island/index.d.ts +3 -0
  44. package/dist/blocks/app/expanded-island/index.js +11 -0
  45. package/dist/blocks/app/settings-window/index.d.ts +2 -0
  46. package/dist/blocks/app/settings-window/index.js +7 -0
  47. package/dist/blocks/system/clipboard/index.d.ts +2 -0
  48. package/dist/blocks/system/clipboard/index.js +17 -0
  49. package/dist/blocks/system/recent-files/index.d.ts +2 -0
  50. package/dist/blocks/system/recent-files/index.js +19 -0
  51. package/dist/blocks/system/system-stats/index.d.ts +2 -0
  52. package/dist/blocks/system/system-stats/index.js +15 -0
  53. package/dist/components/indicators/countdown/index.d.ts +2 -0
  54. package/dist/components/indicators/countdown/index.js +8 -0
  55. package/dist/components/indicators/equalizer/index.d.ts +2 -0
  56. package/dist/components/indicators/equalizer/index.js +7 -0
  57. package/dist/components/indicators/media-scrubber/index.d.ts +2 -0
  58. package/dist/components/indicators/media-scrubber/index.js +8 -0
  59. package/dist/components/island/island/index.d.ts +3 -0
  60. package/dist/components/island/island/index.js +10 -0
  61. package/dist/components/island/island-flash/index.d.ts +2 -0
  62. package/dist/components/island/island-flash/index.js +7 -0
  63. package/dist/components/island/island-tabs/index.d.ts +2 -0
  64. package/dist/components/island/island-tabs/index.js +9 -0
  65. package/dist/components/island/widget/index.d.ts +2 -0
  66. package/dist/components/island/widget/index.js +30 -0
  67. package/dist/index.d.ts +21 -0
  68. package/dist/index.js +195 -0
  69. package/dist/lib/artwork.d.ts +2 -0
  70. package/dist/lib/artwork.js +8 -0
  71. package/dist/lib/clock.d.ts +2 -0
  72. package/dist/lib/clock.js +14 -0
  73. package/dist/lib/geometry.d.ts +2 -0
  74. package/dist/lib/geometry.js +24 -0
  75. package/dist/lib/island-context.d.ts +3 -0
  76. package/dist/lib/island-context.js +8 -0
  77. package/dist/lib/motion.d.ts +21 -0
  78. package/dist/lib/motion.js +16 -0
  79. package/dist/shared/chunk-152gpyq3.d.ts +13 -0
  80. package/dist/shared/chunk-2818esrq.d.ts +140 -0
  81. package/dist/shared/chunk-2f7zxrbk.js +65 -0
  82. package/dist/shared/chunk-2m5dz8nf.d.ts +88 -0
  83. package/dist/shared/chunk-2s4q6mt0.js +27 -0
  84. package/dist/shared/chunk-3thgcfcq.d.ts +151 -0
  85. package/dist/shared/chunk-416tsgbc.d.ts +175 -0
  86. package/dist/shared/chunk-502rmtap.js +54 -0
  87. package/dist/shared/chunk-52gb3g6r.d.ts +12 -0
  88. package/dist/shared/chunk-5en5aaj1.d.ts +33 -0
  89. package/dist/shared/chunk-61t2dfte.js +63 -0
  90. package/dist/shared/chunk-7fvnrtz4.d.ts +105 -0
  91. package/dist/shared/chunk-81fpptwp.d.ts +75 -0
  92. package/dist/shared/chunk-9c7ewvkk.js +381 -0
  93. package/dist/shared/chunk-9m0xbg5v.js +112 -0
  94. package/dist/shared/chunk-9xtcv3sy.js +88 -0
  95. package/dist/shared/chunk-bvtyjcce.d.ts +123 -0
  96. package/dist/shared/chunk-cc9nwbtf.js +315 -0
  97. package/dist/shared/chunk-cfzmfnyh.d.ts +63 -0
  98. package/dist/shared/chunk-d5qm9cps.js +10 -0
  99. package/dist/shared/chunk-da177e8r.d.ts +114 -0
  100. package/dist/shared/chunk-fexwzycv.d.ts +36 -0
  101. package/dist/shared/chunk-gb56m10p.js +39 -0
  102. package/dist/shared/chunk-gejenfap.d.ts +25 -0
  103. package/dist/shared/chunk-hrpxbqmx.d.ts +28 -0
  104. package/dist/shared/chunk-j755a1a5.d.ts +41 -0
  105. package/dist/shared/chunk-j77cx8dp.js +498 -0
  106. package/dist/shared/chunk-mt0k6v8x.js +474 -0
  107. package/dist/shared/chunk-ndf79pv5.js +58 -0
  108. package/dist/shared/chunk-pfhy5e4q.d.ts +53 -0
  109. package/dist/shared/chunk-qdzemt2v.js +477 -0
  110. package/dist/shared/chunk-r471sknr.js +209 -0
  111. package/dist/shared/chunk-s2jeqqan.js +243 -0
  112. package/dist/shared/chunk-t0hcxh89.d.ts +124 -0
  113. package/dist/shared/chunk-w48eyvfr.d.ts +56 -0
  114. package/dist/shared/chunk-w5h6ay93.js +72 -0
  115. package/dist/shared/chunk-wkg17nxs.d.ts +101 -0
  116. package/dist/shared/chunk-x7f3g82r.js +285 -0
  117. package/dist/shared/chunk-xq5hc5gv.js +333 -0
  118. package/dist/shared/chunk-y0188bbn.js +331 -0
  119. package/dist/shared/chunk-ym0xbses.js +518 -0
  120. package/dist/styles.css +264 -0
  121. package/index.ts +22 -0
  122. package/lib/artwork.ts +112 -0
  123. package/lib/clock.ts +53 -0
  124. package/lib/geometry.ts +130 -0
  125. package/lib/island-context.tsx +24 -0
  126. package/lib/motion.ts +42 -0
  127. package/mock/activities.tsx +77 -0
  128. package/mock/artwork.tsx +37 -0
  129. package/mock/clipboard.tsx +79 -0
  130. package/mock/clock.tsx +77 -0
  131. package/mock/data.ts +139 -0
  132. package/mock/desktop.tsx +83 -0
  133. package/mock/files.tsx +70 -0
  134. package/mock/fit.ts +26 -0
  135. package/mock/island-content.tsx +142 -0
  136. package/mock/scene.tsx +52 -0
  137. package/mock/screen.tsx +76 -0
  138. package/mock/settings.tsx +489 -0
  139. package/mock/system.ts +46 -0
  140. package/mock/weather.tsx +105 -0
  141. package/package.json +122 -4
@@ -0,0 +1,477 @@
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
+ SECOND2,
11
+ MINUTE2,
12
+ formatClock2,
13
+ useEdgeClock2
14
+ } from "./chunk-gb56m10p.js";
15
+
16
+ // blocks/activities/clock/index.tsx
17
+ import Button from "@justanarthur/modo-ui/components/actions/button";
18
+ import Meter from "@justanarthur/modo-ui/components/feedback/meter";
19
+ import { useControllableState } from "@justanarthur/modo-ui/lib/use-controllable-state";
20
+ import { cn } from "@justanarthur/modo-ui/lib/utils";
21
+ import {
22
+ CalendarDays,
23
+ Clock3,
24
+ Coffee,
25
+ Moon,
26
+ Pause,
27
+ Play,
28
+ Plus,
29
+ Repeat,
30
+ RotateCcw,
31
+ SkipForward,
32
+ Sun,
33
+ Target,
34
+ Timer
35
+ } from "lucide-react";
36
+ import { useEffect } from "react";
37
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
38
+ /*!
39
+ * Local addition: a notch app's clock, the time, the date and a few world
40
+ * clocks, with a Pomodoro cycle that takes the widget over while it runs.
41
+ * The run is a value the host may own and persist.
42
+ */
43
+ var DEFAULTS = { focus: 25, shortBreak: 5, longBreak: 15, rounds: 4 };
44
+ var RING = {
45
+ focus: "[&_circle:last-child]:text-status-warning",
46
+ "short-break": "[&_circle:last-child]:text-status-success",
47
+ "long-break": "[&_circle:last-child]:text-status-success"
48
+ };
49
+ var DOT = {
50
+ focus: "bg-status-warning",
51
+ "short-break": "bg-status-success",
52
+ "long-break": "bg-status-success"
53
+ };
54
+ var TILE = {
55
+ focus: "bg-status-warning/16 text-status-warning",
56
+ "short-break": "bg-status-success/16 text-status-success",
57
+ "long-break": "bg-status-success/16 text-status-success"
58
+ };
59
+ var MARK = {
60
+ focus: "var(--status-warning)",
61
+ "short-break": "var(--status-success)",
62
+ "long-break": "var(--status-success)"
63
+ };
64
+ var GLYPH = { focus: Target, "short-break": Coffee, "long-break": Coffee };
65
+ var settingsOf = (pomodoro) => ({
66
+ ...DEFAULTS,
67
+ ...pomodoro || {}
68
+ });
69
+ var lengthOf = (phase, settings) => (phase === "focus" ? settings.focus : phase === "short-break" ? settings.shortBreak : settings.longBreak) * MINUTE2;
70
+ function following(run, settings) {
71
+ if (run.phase === "focus")
72
+ return { phase: run.round >= settings.rounds ? "long-break" : "short-break", round: run.round };
73
+ return { phase: "focus", round: run.phase === "long-break" ? 1 : run.round + 1 };
74
+ }
75
+ function startPomodoro2(pomodoro) {
76
+ const total = lengthOf("focus", settingsOf(pomodoro));
77
+ return { phase: "focus", round: 1, total, endsAt: Date.now() + total };
78
+ }
79
+ function advancePomodoro2(run, pomodoro) {
80
+ const settings = settingsOf(pomodoro);
81
+ const next = following(run, settings);
82
+ const total = lengthOf(next.phase, settings);
83
+ return { ...next, total, remaining: total };
84
+ }
85
+ function resumePomodoro2(run) {
86
+ return { phase: run.phase, round: run.round, total: run.total, endsAt: Date.now() + (run.remaining ?? run.total) };
87
+ }
88
+ var pause = (run, left) => ({
89
+ phase: run.phase,
90
+ round: run.round,
91
+ total: run.total,
92
+ remaining: left
93
+ });
94
+ var addMinute = (run) => run.endsAt === undefined ? { ...run, total: run.total + MINUTE2, remaining: (run.remaining ?? run.total) + MINUTE2 } : { ...run, total: run.total + MINUTE2, endsAt: run.endsAt + MINUTE2 };
95
+ function useLeft(run) {
96
+ const end = run.endsAt ?? 0;
97
+ const now = useEdgeClock2(end, run.endsAt !== undefined && Date.now() < end + SECOND2);
98
+ return run.endsAt === undefined ? run.remaining ?? run.total : Math.max(0, end - now);
99
+ }
100
+ function phaseName(run, rounds) {
101
+ if (run.phase === "focus")
102
+ return `Focus ${run.round} of ${rounds}`;
103
+ return run.phase === "long-break" ? "Long break" : "Short break";
104
+ }
105
+ function timeParts(ms, { locale, hour12, timeZone, seconds }) {
106
+ const parts = new Intl.DateTimeFormat(locale, {
107
+ hour: "numeric",
108
+ minute: "2-digit",
109
+ second: seconds ? "2-digit" : undefined,
110
+ hour12,
111
+ timeZone
112
+ }).formatToParts(ms);
113
+ const period = parts.find((part) => part.type === "dayPeriod")?.value;
114
+ const text = parts.filter((part) => part.type !== "dayPeriod").map((part) => part.value).join("").trim();
115
+ return { text, period };
116
+ }
117
+ var shortTime = (ms, options) => new Date(ms).toLocaleTimeString(options.locale, {
118
+ hour: "numeric",
119
+ minute: "2-digit",
120
+ hour12: options.hour12,
121
+ timeZone: options.timeZone
122
+ });
123
+ function offsetOf(ms, timeZone) {
124
+ if (!timeZone)
125
+ return -new Date(ms).getTimezoneOffset();
126
+ const name = new Intl.DateTimeFormat("en-US", { timeZone, timeZoneName: "longOffset" }).formatToParts(ms).find((part) => part.type === "timeZoneName")?.value;
127
+ const match = name?.match(/([+-])(\d{2}):(\d{2})/);
128
+ if (!match)
129
+ return 0;
130
+ const minutes = Number(match[2]) * 60 + Number(match[3]);
131
+ return match[1] === "-" ? -minutes : minutes;
132
+ }
133
+ function offsetLabel(minutes) {
134
+ if (minutes === 0)
135
+ return "Same time";
136
+ const sign = minutes > 0 ? "+" : "−";
137
+ const h = Math.floor(Math.abs(minutes) / 60);
138
+ const m = Math.abs(minutes) % 60;
139
+ return m ? `${sign}${h}:${String(m).padStart(2, "0")}` : `${sign}${h}h`;
140
+ }
141
+ var dayKey = (ms, timeZone) => new Intl.DateTimeFormat("en-CA", { timeZone, year: "numeric", month: "2-digit", day: "2-digit" }).format(ms);
142
+ var hourIn = (ms, timeZone) => Number(new Intl.DateTimeFormat("en-US", { timeZone, hour: "numeric", hourCycle: "h23" }).format(ms));
143
+ function ZoneRow({ zone, now, locale, hour12, timeZone }) {
144
+ const there = dayKey(now, zone.timeZone);
145
+ const here = dayKey(now, timeZone);
146
+ const day = there > here ? "Tomorrow" : there < here ? "Yesterday" : undefined;
147
+ const hour = hourIn(now, zone.timeZone);
148
+ const DayGlyph = hour >= 6 && hour < 18 ? Sun : Moon;
149
+ return /* @__PURE__ */ jsx(widget_default.Row, {
150
+ leading: shortTime(now, { locale, hour12, timeZone: zone.timeZone }),
151
+ trailing: /* @__PURE__ */ jsxs(Fragment, {
152
+ children: [
153
+ day && /* @__PURE__ */ jsxs("span", {
154
+ children: [
155
+ day,
156
+ " ·"
157
+ ]
158
+ }),
159
+ /* @__PURE__ */ jsx("span", {
160
+ className: "tabular-nums",
161
+ children: offsetLabel(offsetOf(now, zone.timeZone) - offsetOf(now, timeZone))
162
+ }),
163
+ /* @__PURE__ */ jsx(DayGlyph, {
164
+ size: 12,
165
+ strokeWidth: 1.5,
166
+ "aria-label": DayGlyph === Sun ? "Day" : "Night",
167
+ className: "ml-1"
168
+ })
169
+ ]
170
+ }),
171
+ children: zone.city
172
+ });
173
+ }
174
+ function PhaseRing({ run, rounds = DEFAULTS.rounds, className }) {
175
+ const left = useLeft(run);
176
+ return /* @__PURE__ */ jsx(Meter, {
177
+ variant: "ring",
178
+ label: `${phaseName(run, rounds)}, ${formatClock2(Math.ceil(left / SECOND2))} left`,
179
+ value: run.total ? left / run.total : 0,
180
+ tone: "default",
181
+ animate: false,
182
+ className: cn(RING[run.phase], className)
183
+ });
184
+ }
185
+ function ClockLeading2({ run }) {
186
+ if (!run)
187
+ return null;
188
+ return /* @__PURE__ */ jsx(PhaseRing, {
189
+ run,
190
+ className: "size-4"
191
+ });
192
+ }
193
+ function TimeLeft({ run }) {
194
+ const left = useLeft(run);
195
+ return /* @__PURE__ */ jsx("span", {
196
+ className: cn("text-caption weight-semibold tabular-nums", run.endsAt === undefined ? "text-muted-foreground" : "text-foreground"),
197
+ children: formatClock2(Math.ceil(left / SECOND2))
198
+ });
199
+ }
200
+ function ClockTrailing2({ run }) {
201
+ if (!run)
202
+ return null;
203
+ return /* @__PURE__ */ jsx(TimeLeft, {
204
+ run
205
+ });
206
+ }
207
+ function ClockMinimal2({ run }) {
208
+ if (!run)
209
+ return null;
210
+ return /* @__PURE__ */ jsx(PhaseRing, {
211
+ run,
212
+ className: "size-5.5"
213
+ });
214
+ }
215
+ function ClockPhaseDone2({ ended, pomodoro, onStart }) {
216
+ const settings = settingsOf(pomodoro);
217
+ const next = following(ended, settings);
218
+ const minutes = lengthOf(next.phase, settings) / MINUTE2;
219
+ const Glyph = GLYPH[next.phase];
220
+ const breakNext = next.phase !== "focus";
221
+ const title = !breakNext ? "Break over" : next.phase === "long-break" ? "Focus done — long break" : "Focus done — break time";
222
+ const caption = !breakNext ? `${phaseName(next, settings.rounds)} · ${minutes} min` : next.phase === "long-break" ? `${minutes} min break · all ${settings.rounds} rounds done` : `${minutes} min break · ${ended.round} of ${settings.rounds} rounds done`;
223
+ return /* @__PURE__ */ jsx(IslandFlash2, {
224
+ icon: /* @__PURE__ */ jsx("span", {
225
+ className: cn("flex size-9 items-center justify-center rounded-lg", TILE[next.phase]),
226
+ children: /* @__PURE__ */ jsx(Glyph, {
227
+ size: 16,
228
+ strokeWidth: 1.5
229
+ })
230
+ }),
231
+ title,
232
+ caption,
233
+ action: onStart && /* @__PURE__ */ jsx(Button, {
234
+ variant: "secondary",
235
+ size: "compact",
236
+ onClick: onStart,
237
+ children: breakNext ? "Start break" : "Start focus"
238
+ })
239
+ });
240
+ }
241
+ function schedule(run, start, settings, count) {
242
+ const phases = [];
243
+ let at = run;
244
+ let when = start;
245
+ for (let i = 0;i < count; i++) {
246
+ at = following(at, settings);
247
+ const length = lengthOf(at.phase, settings);
248
+ phases.push({ ...at, start: when, length });
249
+ when += length;
250
+ }
251
+ return phases;
252
+ }
253
+ function Running({ run, settings, onChange, onPhaseEnd, locale, hour12, timeZone, className }) {
254
+ const left = useLeft(run);
255
+ const running = run.endsAt !== undefined;
256
+ const now = running ? (run.endsAt ?? 0) - left : Date.now();
257
+ useEffect(() => {
258
+ if (!running || left > 0)
259
+ return;
260
+ const next = advancePomodoro2(run, settings);
261
+ onPhaseEnd?.(run, next);
262
+ onChange(next);
263
+ }, [running, left, run, settings, onChange, onPhaseEnd]);
264
+ const ends = now + left;
265
+ const ready = !running && left === run.total;
266
+ const next = following(run, settings);
267
+ const options = { locale, hour12, timeZone };
268
+ const status = running ? `Until ${shortTime(ends, options)}` : ready ? `Ready · ${Math.round(run.total / MINUTE2)} min` : "Paused";
269
+ const nextLabel = next.phase === "focus" ? `${phaseName(next, settings.rounds)} next` : `${lengthOf(next.phase, settings) / MINUTE2} min ${next.phase === "long-break" ? "long break" : "break"} next`;
270
+ return /* @__PURE__ */ jsxs(widget_default, {
271
+ className,
272
+ media: /* @__PURE__ */ jsx(PhaseRing, {
273
+ run,
274
+ rounds: settings.rounds,
275
+ className: "size-24"
276
+ }),
277
+ aside: /* @__PURE__ */ jsx(widget_default.Section, {
278
+ label: "Up next",
279
+ trailing: /* @__PURE__ */ jsx("span", {
280
+ className: "tabular-nums",
281
+ children: shortTime(Date.now(), options)
282
+ }),
283
+ children: schedule(run, ends, settings, 3).map((phase) => /* @__PURE__ */ jsx(widget_default.Row, {
284
+ leading: shortTime(phase.start, options),
285
+ color: MARK[phase.phase],
286
+ trailing: `${phase.length / MINUTE2} min`,
287
+ children: phaseName(phase, settings.rounds)
288
+ }, `${phase.phase}-${phase.round}-${phase.start}`))
289
+ }),
290
+ children: [
291
+ /* @__PURE__ */ jsx(widget_default.Header, {
292
+ icon: Timer,
293
+ trailing: /* @__PURE__ */ jsx(widget_default.Action, {
294
+ icon: RotateCcw,
295
+ label: "Reset",
296
+ onClick: () => onChange(null)
297
+ }),
298
+ children: "Pomodoro"
299
+ }),
300
+ /* @__PURE__ */ jsxs("div", {
301
+ className: "flex min-w-0 items-center justify-between gap-3",
302
+ children: [
303
+ /* @__PURE__ */ jsx(widget_default.Figure, {
304
+ value: formatClock2(Math.ceil(left / SECOND2))
305
+ }),
306
+ /* @__PURE__ */ jsxs("div", {
307
+ className: "-mr-1 flex shrink-0 items-center gap-1",
308
+ children: [
309
+ /* @__PURE__ */ jsx(widget_default.Action, {
310
+ icon: Plus,
311
+ label: "Add a minute",
312
+ onClick: () => onChange(addMinute(run))
313
+ }),
314
+ /* @__PURE__ */ jsx(widget_default.Action, {
315
+ icon: running ? Pause : Play,
316
+ label: running ? "Pause" : ready ? "Start" : "Resume",
317
+ emphasis: "primary",
318
+ filled: true,
319
+ onClick: () => onChange(running ? pause(run, left) : resumePomodoro2(run))
320
+ }),
321
+ /* @__PURE__ */ jsx(widget_default.Action, {
322
+ icon: SkipForward,
323
+ label: next.phase === "focus" ? "Skip to focus" : "Skip to break",
324
+ filled: true,
325
+ onClick: () => onChange(resumePomodoro2(advancePomodoro2(run, settings)))
326
+ })
327
+ ]
328
+ })
329
+ ]
330
+ }),
331
+ /* @__PURE__ */ jsxs("div", {
332
+ className: "flex min-w-0 flex-col gap-0.5",
333
+ children: [
334
+ /* @__PURE__ */ jsx(widget_default.Title, {
335
+ leading: /* @__PURE__ */ jsx("span", {
336
+ "aria-hidden": true,
337
+ className: cn("size-2.5 shrink-0 rounded-full", DOT[run.phase])
338
+ }),
339
+ children: phaseName(run, settings.rounds)
340
+ }),
341
+ /* @__PURE__ */ jsxs(widget_default.Meta, {
342
+ className: "pl-4.5",
343
+ children: [
344
+ /* @__PURE__ */ jsx(widget_default.MetaItem, {
345
+ icon: running ? Clock3 : Pause,
346
+ children: status
347
+ }),
348
+ /* @__PURE__ */ jsx(widget_default.MetaItem, {
349
+ icon: GLYPH[next.phase],
350
+ children: nextLabel
351
+ })
352
+ ]
353
+ })
354
+ ]
355
+ })
356
+ ]
357
+ });
358
+ }
359
+ var Clock2 = Object.assign(function Clock({
360
+ zones = [],
361
+ seconds = false,
362
+ hour12,
363
+ timeZone,
364
+ locale,
365
+ now: nowProp,
366
+ pomodoro,
367
+ value,
368
+ defaultValue = null,
369
+ onValueChange,
370
+ onPhaseEnd,
371
+ className
372
+ }) {
373
+ const [run, setRun] = useControllableState(value, defaultValue, onValueChange);
374
+ const ticking = useEdgeClock2(0, nowProp === undefined && !run, seconds ? SECOND2 : MINUTE2);
375
+ const settings = settingsOf(pomodoro);
376
+ if (run)
377
+ return /* @__PURE__ */ jsx(Running, {
378
+ run,
379
+ settings,
380
+ onChange: setRun,
381
+ onPhaseEnd,
382
+ locale,
383
+ hour12,
384
+ timeZone,
385
+ className
386
+ });
387
+ const now = nowProp ?? ticking;
388
+ const time = timeParts(now, { locale, hour12, timeZone });
389
+ const second = seconds && new Intl.DateTimeFormat("en-US", { second: "2-digit", timeZone }).format(now);
390
+ const date = new Date(now).toLocaleDateString(locale, { weekday: "long", month: "long", day: "numeric", timeZone });
391
+ const zoneName = new Intl.DateTimeFormat(locale, { timeZone, timeZoneName: "long" }).formatToParts(now).find((part) => part.type === "timeZoneName")?.value;
392
+ return /* @__PURE__ */ jsxs(widget_default, {
393
+ className,
394
+ aside: zones.length > 0 && /* @__PURE__ */ jsx(widget_default.Section, {
395
+ label: "World clock",
396
+ children: zones.slice(0, 3).map((zone) => /* @__PURE__ */ jsx(ZoneRow, {
397
+ zone,
398
+ now,
399
+ locale,
400
+ hour12,
401
+ timeZone
402
+ }, zone.timeZone + zone.city))
403
+ }),
404
+ children: [
405
+ /* @__PURE__ */ jsx(widget_default.Header, {
406
+ icon: CalendarDays,
407
+ children: date
408
+ }),
409
+ /* @__PURE__ */ jsxs("div", {
410
+ className: "flex min-w-0 items-end justify-between gap-3",
411
+ children: [
412
+ /* @__PURE__ */ jsx(widget_default.Figure, {
413
+ value: /* @__PURE__ */ jsxs(Fragment, {
414
+ children: [
415
+ time.text,
416
+ second && /* @__PURE__ */ jsxs("span", {
417
+ className: "text-muted-foreground",
418
+ children: [
419
+ ":",
420
+ second.padStart(2, "0")
421
+ ]
422
+ })
423
+ ]
424
+ }),
425
+ unit: time.period
426
+ }),
427
+ pomodoro !== false && /* @__PURE__ */ jsx(Button, {
428
+ variant: "secondary",
429
+ size: "compact",
430
+ leadingIcon: Play,
431
+ className: "mb-1",
432
+ onClick: () => setRun(startPomodoro2(settings)),
433
+ children: "Start focus"
434
+ })
435
+ ]
436
+ }),
437
+ zoneName && /* @__PURE__ */ jsx(widget_default.Subtitle, {
438
+ children: zoneName
439
+ }),
440
+ pomodoro !== false && /* @__PURE__ */ jsxs(widget_default.Meta, {
441
+ className: "mt-1",
442
+ children: [
443
+ /* @__PURE__ */ jsxs(widget_default.MetaItem, {
444
+ icon: Target,
445
+ children: [
446
+ settings.focus,
447
+ " min focus"
448
+ ]
449
+ }),
450
+ /* @__PURE__ */ jsxs(widget_default.MetaItem, {
451
+ icon: Coffee,
452
+ children: [
453
+ settings.shortBreak,
454
+ " / ",
455
+ settings.longBreak,
456
+ " min breaks"
457
+ ]
458
+ }),
459
+ /* @__PURE__ */ jsxs(widget_default.MetaItem, {
460
+ icon: Repeat,
461
+ children: [
462
+ settings.rounds,
463
+ " rounds"
464
+ ]
465
+ })
466
+ ]
467
+ })
468
+ ]
469
+ });
470
+ }, {
471
+ Leading: ClockLeading2,
472
+ Trailing: ClockTrailing2,
473
+ Minimal: ClockMinimal2,
474
+ PhaseDone: ClockPhaseDone2
475
+ });
476
+ var clock_default = Clock2;
477
+ export { startPomodoro2, advancePomodoro2, resumePomodoro2, ClockLeading2, ClockTrailing2, ClockMinimal2, ClockPhaseDone2, Clock2, clock_default };
@@ -0,0 +1,209 @@
1
+ "use client";
2
+
3
+ import {
4
+ DEFAULT_NOTCH2,
5
+ stripLayout2
6
+ } from "./chunk-61t2dfte.js";
7
+ import {
8
+ useIsland2
9
+ } from "./chunk-d5qm9cps.js";
10
+
11
+ // components/island/island-tabs/index.tsx
12
+ import { FocusRing } from "@justanarthur/modo-ui/lib/focus-ring";
13
+ import { GooIndicator } from "@justanarthur/modo-ui/lib/goo-indicator";
14
+ import { useRowFocus } from "@justanarthur/modo-ui/lib/row-group";
15
+ import { useShape } from "@justanarthur/modo-ui/lib/shape-context";
16
+ import { useSize } from "@justanarthur/modo-ui/lib/size-context";
17
+ import { useControllableState } from "@justanarthur/modo-ui/lib/use-controllable-state";
18
+ import { useFluidHover, useRegisterFluidHoverItem } from "@justanarthur/modo-ui/lib/use-fluid-hover";
19
+ import { cn } from "@justanarthur/modo-ui/lib/utils";
20
+ import { FluidHoverHighlight } from "@justanarthur/modo-ui/primitives/systems/fluid-hover";
21
+ import {
22
+ useEffect,
23
+ useLayoutEffect,
24
+ useRef,
25
+ useState
26
+ } from "react";
27
+ import { jsx, jsxs } from "react/jsx-runtime";
28
+ /*!
29
+ * Local addition: the open island's icon tabs, split across the two wings
30
+ * around the notch. Rebuilt from Just Notch's runtime (`island/tabs.tsx`) on
31
+ * modo-ui's fluid hover, liquid indicator and focus ring.
32
+ */
33
+ var TAB_WIDTH = { default: 40, compact: 30 };
34
+ var TAB_CLASS = { default: "w-10", compact: "w-7.5" };
35
+ var FADE = 16;
36
+ var NOTCH_FADE = 8;
37
+ function TabButton({ tab, index, selected, lit, size: sizeProp, register, onSelect }) {
38
+ const ref = useRef(null);
39
+ const size = useSize(sizeProp);
40
+ const shape = useShape();
41
+ useRegisterFluidHoverItem(register, index, ref);
42
+ const Icon = tab.icon;
43
+ return /* @__PURE__ */ jsx("button", {
44
+ ref,
45
+ type: "button",
46
+ role: "tab",
47
+ "aria-selected": selected,
48
+ "aria-label": tab.label,
49
+ tabIndex: selected ? 0 : -1,
50
+ "data-fluid-hover-index": index,
51
+ className: cn("relative z-10 flex shrink-0 cursor-pointer items-center justify-center bg-transparent outline-none transition-[color] duration-fast", size.control, TAB_CLASS[size.variant], shape.bg, lit ? "text-foreground" : "text-muted-foreground"),
52
+ onClick: () => onSelect(index),
53
+ children: /* @__PURE__ */ jsx(Icon, {
54
+ size: size.icon,
55
+ strokeWidth: lit ? 2 : 1.5,
56
+ className: "transition-[stroke-width] duration-fast"
57
+ })
58
+ });
59
+ }
60
+ function useWidth(ref) {
61
+ const [width, setWidth] = useState(0);
62
+ useLayoutEffect(() => {
63
+ const el = ref.current;
64
+ if (!el)
65
+ return;
66
+ setWidth(el.offsetWidth);
67
+ const observer = new ResizeObserver(() => setWidth(el.offsetWidth));
68
+ observer.observe(el);
69
+ return () => observer.disconnect();
70
+ }, [ref]);
71
+ return width;
72
+ }
73
+ function IslandTabs2({
74
+ tabs,
75
+ value: valueProp,
76
+ defaultValue,
77
+ onValueChange,
78
+ onHoverChange,
79
+ size: sizeProp,
80
+ notchWidth,
81
+ trailing,
82
+ label = "Widgets",
83
+ className
84
+ }) {
85
+ const [value, setValue] = useControllableState(valueProp, defaultValue ?? tabs[0]?.value, onValueChange);
86
+ const size = useSize(sizeProp);
87
+ const shape = useShape();
88
+ const island = useIsland2();
89
+ const notch = notchWidth ?? island?.geometry.notch.width ?? DEFAULT_NOTCH2.width;
90
+ const root = useRef(null);
91
+ const viewport = useRef(null);
92
+ const strip = useRef(null);
93
+ const end = useRef(null);
94
+ const width = useWidth(root);
95
+ const reserve = useWidth(end);
96
+ const hover = useFluidHover(strip, { axis: "x" });
97
+ const focus = useRowFocus(hover);
98
+ const selected = Math.max(0, tabs.findIndex((tab) => tab.value === value));
99
+ const layout = stripLayout2(tabs.length, width, notch, TAB_WIDTH[size.variant], reserve);
100
+ const hovered = hover.activeIndex === null ? null : tabs[hover.activeIndex]?.value ?? null;
101
+ const report = useRef(onHoverChange);
102
+ report.current = onHoverChange;
103
+ useEffect(() => report.current?.(hovered), [hovered]);
104
+ useEffect(() => {
105
+ const el = viewport.current;
106
+ const active = el?.querySelector("[role=tab][aria-selected=true]");
107
+ if (!el || !active)
108
+ return;
109
+ if (el.contains(document.activeElement) && document.activeElement !== active)
110
+ active.focus({ preventScroll: true });
111
+ const left = active.offsetLeft - el.scrollLeft;
112
+ const right = left + active.offsetWidth - el.clientWidth;
113
+ if (left < 0)
114
+ el.scrollBy({ left: left - FADE });
115
+ else if (right > 0)
116
+ el.scrollBy({ left: right + FADE });
117
+ }, [selected]);
118
+ useEffect(() => {
119
+ const el = viewport.current;
120
+ if (!el || !layout.overflow)
121
+ return;
122
+ const onWheel = (event) => {
123
+ if (Math.abs(event.deltaY) <= Math.abs(event.deltaX))
124
+ return;
125
+ event.preventDefault();
126
+ el.scrollLeft += event.deltaY;
127
+ };
128
+ el.addEventListener("wheel", onWheel, { passive: false });
129
+ return () => el.removeEventListener("wheel", onWheel);
130
+ }, [layout.overflow]);
131
+ const select = (index) => {
132
+ const tab = tabs[index];
133
+ if (tab)
134
+ setValue(tab.value);
135
+ };
136
+ const onKeyDown = (event) => {
137
+ const next = event.key === "ArrowRight" ? selected + 1 : event.key === "ArrowLeft" ? selected - 1 : event.key === "Home" ? 0 : event.key === "End" ? tabs.length - 1 : null;
138
+ if (next === null || !tabs[next])
139
+ return;
140
+ event.preventDefault();
141
+ select(next);
142
+ };
143
+ const hole = layout.overflow ? {
144
+ maskImage: `linear-gradient(to right, black ${layout.hole.start - NOTCH_FADE}px, transparent ${layout.hole.start}px, transparent ${layout.hole.end}px, black ${layout.hole.end + NOTCH_FADE}px)`
145
+ } : undefined;
146
+ const rect = hover.isMeasured ? hover.itemRects[selected] : undefined;
147
+ const button = (tab, index) => /* @__PURE__ */ jsx(TabButton, {
148
+ tab,
149
+ index,
150
+ selected: index === selected,
151
+ lit: index === selected || index === hover.activeIndex,
152
+ size: size.variant,
153
+ register: hover.registerItem,
154
+ onSelect: select
155
+ }, tab.value);
156
+ return /* @__PURE__ */ jsxs("div", {
157
+ ref: root,
158
+ className: cn("relative flex w-full min-w-0 items-center", size.control, className),
159
+ children: [
160
+ /* @__PURE__ */ jsx("div", {
161
+ className: "relative h-full min-w-0 flex-1",
162
+ style: hole,
163
+ children: /* @__PURE__ */ jsx("div", {
164
+ ref: viewport,
165
+ className: cn("h-full overflow-x-auto overflow-y-hidden scrollbar-hide", layout.overflow && "scroll-fade-x [--scroll-fade-size:16px]"),
166
+ children: /* @__PURE__ */ jsxs("div", {
167
+ ref: strip,
168
+ role: "tablist",
169
+ "aria-label": label,
170
+ className: "relative flex h-full w-max min-w-full items-center",
171
+ onKeyDown,
172
+ onMouseMove: hover.handlers.onMouseMove,
173
+ onMouseEnter: hover.handlers.onMouseEnter,
174
+ onMouseLeave: hover.handlers.onMouseLeave,
175
+ onFocus: focus.handlers.onFocus,
176
+ onBlur: focus.handlers.onBlur,
177
+ children: [
178
+ rect && /* @__PURE__ */ jsx(GooIndicator, {
179
+ rect,
180
+ className: cn("bg-active", shape.bg)
181
+ }),
182
+ /* @__PURE__ */ jsx(FluidHoverHighlight, {
183
+ hover,
184
+ hidden: hover.activeIndex === selected,
185
+ className: shape.bg
186
+ }),
187
+ /* @__PURE__ */ jsx(FocusRing, {
188
+ rect: focus.focusRect
189
+ }),
190
+ tabs.slice(0, layout.before).map(button),
191
+ /* @__PURE__ */ jsx("div", {
192
+ "aria-hidden": true,
193
+ className: "h-full shrink-0 grow",
194
+ style: { minWidth: layout.spacer }
195
+ }),
196
+ tabs.slice(layout.before).map((tab, i) => button(tab, layout.before + i))
197
+ ]
198
+ })
199
+ })
200
+ }),
201
+ trailing && /* @__PURE__ */ jsx("div", {
202
+ ref: end,
203
+ className: "flex shrink-0 items-center",
204
+ children: trailing
205
+ })
206
+ ]
207
+ });
208
+ }
209
+ export { IslandTabs2 };