@justanarthur/modo-ui-notch 0.2.0 → 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 (148) hide show
  1. package/README.md +11 -11
  2. package/blocks/activities/agenda/examples.mdx +21 -5
  3. package/blocks/activities/agenda/index.tsx +291 -182
  4. package/blocks/activities/clock/examples.mdx +73 -0
  5. package/blocks/activities/clock/index.tsx +619 -0
  6. package/blocks/activities/now-playing/examples.mdx +32 -13
  7. package/blocks/activities/now-playing/index.tsx +319 -126
  8. package/blocks/activities/weather/examples.mdx +115 -0
  9. package/blocks/activities/weather/index.tsx +634 -0
  10. package/blocks/app/expanded-island/examples.mdx +8 -7
  11. package/blocks/app/expanded-island/index.tsx +19 -3
  12. package/blocks/app/settings-window/examples.mdx +6 -2
  13. package/blocks/app/settings-window/index.tsx +25 -7
  14. package/blocks/system/clipboard/examples.mdx +83 -0
  15. package/blocks/system/clipboard/index.tsx +563 -0
  16. package/blocks/system/recent-files/examples.mdx +66 -0
  17. package/blocks/system/recent-files/index.tsx +542 -0
  18. package/blocks/system/system-stats/examples.mdx +38 -9
  19. package/blocks/system/system-stats/index.tsx +241 -107
  20. package/components/indicators/media-scrubber/examples.mdx +8 -0
  21. package/components/indicators/media-scrubber/index.tsx +37 -13
  22. package/components/island/island/examples.mdx +4 -4
  23. package/components/island/island/index.tsx +2 -2
  24. package/components/island/island-flash/examples.mdx +15 -18
  25. package/components/island/island-flash/index.tsx +4 -4
  26. package/components/island/island-tabs/examples.mdx +5 -5
  27. package/components/island/widget/examples.mdx +76 -0
  28. package/components/island/widget/index.tsx +431 -0
  29. package/dist/blocks/activities/agenda/index.d.ts +1 -1
  30. package/dist/blocks/activities/agenda/index.js +3 -3
  31. package/dist/blocks/activities/clock/index.d.ts +2 -0
  32. package/dist/blocks/activities/clock/index.js +25 -0
  33. package/dist/blocks/activities/now-playing/index.d.ts +3 -2
  34. package/dist/blocks/activities/now-playing/index.js +5 -3
  35. package/dist/blocks/activities/weather/index.d.ts +2 -0
  36. package/dist/blocks/activities/weather/index.js +21 -0
  37. package/dist/blocks/app/expanded-island/index.d.ts +1 -1
  38. package/dist/blocks/app/expanded-island/index.js +4 -3
  39. package/dist/blocks/app/settings-window/index.d.ts +1 -1
  40. package/dist/blocks/app/settings-window/index.js +1 -1
  41. package/dist/blocks/system/clipboard/index.d.ts +2 -0
  42. package/dist/blocks/system/clipboard/index.js +17 -0
  43. package/dist/blocks/system/recent-files/index.d.ts +2 -0
  44. package/dist/blocks/system/recent-files/index.js +19 -0
  45. package/dist/blocks/system/system-stats/index.d.ts +2 -2
  46. package/dist/blocks/system/system-stats/index.js +4 -1
  47. package/dist/components/indicators/media-scrubber/index.d.ts +1 -1
  48. package/dist/components/indicators/media-scrubber/index.js +1 -1
  49. package/dist/components/island/island/index.d.ts +1 -1
  50. package/dist/components/island/island/index.js +2 -2
  51. package/dist/components/island/island-flash/index.d.ts +1 -1
  52. package/dist/components/island/island-flash/index.js +1 -1
  53. package/dist/components/island/island-tabs/index.js +2 -2
  54. package/dist/components/island/widget/index.d.ts +2 -0
  55. package/dist/components/island/widget/index.js +30 -0
  56. package/dist/index.d.ts +15 -15
  57. package/dist/index.js +102 -58
  58. package/dist/lib/artwork.d.ts +2 -0
  59. package/dist/lib/artwork.js +8 -0
  60. package/dist/lib/geometry.js +1 -1
  61. package/dist/shared/chunk-2818esrq.d.ts +140 -0
  62. package/dist/shared/{chunk-yngkkxz2.d.ts → chunk-2m5dz8nf.d.ts} +4 -4
  63. package/dist/shared/chunk-3thgcfcq.d.ts +151 -0
  64. package/dist/shared/chunk-416tsgbc.d.ts +175 -0
  65. package/dist/shared/{chunk-zvh0d3qb.js → chunk-61t2dfte.js} +1 -1
  66. package/dist/shared/chunk-7fvnrtz4.d.ts +105 -0
  67. package/dist/shared/{chunk-hpsabfsd.d.ts → chunk-81fpptwp.d.ts} +1 -1
  68. package/dist/shared/chunk-9c7ewvkk.js +381 -0
  69. package/dist/shared/{chunk-mp1nx0ez.js → chunk-9m0xbg5v.js} +14 -3
  70. package/dist/shared/{chunk-wwjxs75m.js → chunk-9xtcv3sy.js} +26 -12
  71. package/dist/shared/chunk-bvtyjcce.d.ts +123 -0
  72. package/dist/shared/{chunk-s33y1pcq.js → chunk-cc9nwbtf.js} +20 -10
  73. package/dist/shared/chunk-da177e8r.d.ts +114 -0
  74. package/dist/shared/{chunk-6c1jbefs.d.ts → chunk-fexwzycv.d.ts} +3 -3
  75. package/dist/shared/chunk-gejenfap.d.ts +25 -0
  76. package/dist/shared/{chunk-rr5e0g15.d.ts → chunk-j755a1a5.d.ts} +7 -1
  77. package/dist/shared/chunk-j77cx8dp.js +498 -0
  78. package/dist/shared/chunk-mt0k6v8x.js +474 -0
  79. package/dist/shared/{chunk-78w7qwp0.js → chunk-ndf79pv5.js} +1 -1
  80. package/dist/shared/{chunk-9nhpg9t8.d.ts → chunk-pfhy5e4q.d.ts} +7 -1
  81. package/dist/shared/chunk-qdzemt2v.js +477 -0
  82. package/dist/shared/{chunk-rpfwv3pz.js → chunk-r471sknr.js} +1 -1
  83. package/dist/shared/chunk-s2jeqqan.js +243 -0
  84. package/dist/shared/chunk-t0hcxh89.d.ts +124 -0
  85. package/dist/shared/chunk-w5h6ay93.js +72 -0
  86. package/dist/shared/chunk-wkg17nxs.d.ts +101 -0
  87. package/dist/shared/chunk-x7f3g82r.js +285 -0
  88. package/dist/shared/chunk-xq5hc5gv.js +333 -0
  89. package/dist/shared/{chunk-sbnrhy5m.js → chunk-y0188bbn.js} +2 -2
  90. package/dist/shared/chunk-ym0xbses.js +518 -0
  91. package/dist/styles.css +97 -55
  92. package/index.ts +7 -6
  93. package/lib/artwork.ts +112 -0
  94. package/lib/geometry.ts +1 -1
  95. package/mock/activities.tsx +9 -32
  96. package/mock/artwork.tsx +13 -1
  97. package/mock/clipboard.tsx +79 -0
  98. package/mock/clock.tsx +77 -0
  99. package/mock/data.ts +30 -44
  100. package/mock/files.tsx +70 -0
  101. package/mock/island-content.tsx +43 -118
  102. package/mock/screen.tsx +76 -0
  103. package/mock/settings.tsx +370 -91
  104. package/mock/system.ts +46 -0
  105. package/mock/weather.tsx +105 -0
  106. package/package.json +7 -2
  107. package/blocks/activities/shelf/examples.mdx +0 -33
  108. package/blocks/activities/shelf/index.tsx +0 -289
  109. package/blocks/activities/timer/examples.mdx +0 -52
  110. package/blocks/activities/timer/index.tsx +0 -292
  111. package/blocks/system/controls/examples.mdx +0 -34
  112. package/blocks/system/controls/index.tsx +0 -167
  113. package/blocks/system/devices/examples.mdx +0 -25
  114. package/blocks/system/devices/index.tsx +0 -172
  115. package/blocks/system/power-alert/examples.mdx +0 -32
  116. package/blocks/system/power-alert/index.tsx +0 -89
  117. package/components/indicators/battery-glyph/examples.mdx +0 -22
  118. package/components/indicators/battery-glyph/index.tsx +0 -91
  119. package/dist/blocks/activities/shelf/index.d.ts +0 -2
  120. package/dist/blocks/activities/shelf/index.js +0 -14
  121. package/dist/blocks/activities/timer/index.d.ts +0 -2
  122. package/dist/blocks/activities/timer/index.js +0 -19
  123. package/dist/blocks/system/controls/index.d.ts +0 -2
  124. package/dist/blocks/system/controls/index.js +0 -10
  125. package/dist/blocks/system/devices/index.d.ts +0 -2
  126. package/dist/blocks/system/devices/index.js +0 -12
  127. package/dist/blocks/system/power-alert/index.d.ts +0 -2
  128. package/dist/blocks/system/power-alert/index.js +0 -9
  129. package/dist/components/indicators/battery-glyph/index.d.ts +0 -2
  130. package/dist/components/indicators/battery-glyph/index.js +0 -9
  131. package/dist/shared/chunk-2qpcsv5h.d.ts +0 -45
  132. package/dist/shared/chunk-45gytfr1.d.ts +0 -84
  133. package/dist/shared/chunk-50ffk4r7.d.ts +0 -69
  134. package/dist/shared/chunk-5w0yck07.d.ts +0 -32
  135. package/dist/shared/chunk-7hr53mby.js +0 -116
  136. package/dist/shared/chunk-b8jb1w72.js +0 -145
  137. package/dist/shared/chunk-cpewy6yg.js +0 -178
  138. package/dist/shared/chunk-e3e4s4ds.d.ts +0 -77
  139. package/dist/shared/chunk-enm6td0p.js +0 -280
  140. package/dist/shared/chunk-fvedaas2.d.ts +0 -33
  141. package/dist/shared/chunk-gex38j8x.d.ts +0 -82
  142. package/dist/shared/chunk-hwtxpzg0.js +0 -69
  143. package/dist/shared/chunk-phb53x1f.js +0 -252
  144. package/dist/shared/chunk-r8esmjfs.d.ts +0 -42
  145. package/dist/shared/chunk-rcp1g9ca.js +0 -70
  146. package/dist/shared/chunk-rx9sphz2.js +0 -266
  147. package/dist/shared/chunk-xdeek16r.d.ts +0 -58
  148. package/dist/shared/chunk-xkzjk1tq.js +0 -206
@@ -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 };
@@ -3,7 +3,7 @@
3
3
  import {
4
4
  DEFAULT_NOTCH2,
5
5
  stripLayout2
6
- } from "./chunk-zvh0d3qb.js";
6
+ } from "./chunk-61t2dfte.js";
7
7
  import {
8
8
  useIsland2
9
9
  } from "./chunk-d5qm9cps.js";