@justanarthur/modo-ui-notch 0.2.0 → 0.4.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 +29 -5
  3. package/blocks/activities/agenda/index.tsx +438 -181
  4. package/blocks/activities/clock/examples.mdx +89 -0
  5. package/blocks/activities/clock/index.tsx +917 -0
  6. package/blocks/activities/now-playing/examples.mdx +40 -13
  7. package/blocks/activities/now-playing/index.tsx +399 -120
  8. package/blocks/activities/weather/examples.mdx +123 -0
  9. package/blocks/activities/weather/index.tsx +863 -0
  10. package/blocks/app/expanded-island/examples.mdx +8 -7
  11. package/blocks/app/expanded-island/index.tsx +22 -4
  12. package/blocks/app/settings-window/examples.mdx +14 -2
  13. package/blocks/app/settings-window/index.tsx +33 -10
  14. package/blocks/system/clipboard/examples.mdx +91 -0
  15. package/blocks/system/clipboard/index.tsx +773 -0
  16. package/blocks/system/recent-files/examples.mdx +80 -0
  17. package/blocks/system/recent-files/index.tsx +627 -0
  18. package/blocks/system/system-stats/examples.mdx +46 -9
  19. package/blocks/system/system-stats/index.tsx +445 -104
  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 +465 -0
  29. package/dist/blocks/activities/agenda/index.d.ts +2 -1
  30. package/dist/blocks/activities/agenda/index.js +3 -3
  31. package/dist/blocks/activities/clock/index.d.ts +3 -0
  32. package/dist/blocks/activities/clock/index.js +25 -0
  33. package/dist/blocks/activities/now-playing/index.d.ts +4 -2
  34. package/dist/blocks/activities/now-playing/index.js +5 -3
  35. package/dist/blocks/activities/weather/index.d.ts +3 -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 +3 -0
  42. package/dist/blocks/system/clipboard/index.js +17 -0
  43. package/dist/blocks/system/recent-files/index.d.ts +3 -0
  44. package/dist/blocks/system/recent-files/index.js +19 -0
  45. package/dist/blocks/system/system-stats/index.d.ts +3 -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 +32 -0
  56. package/dist/index.d.ts +15 -15
  57. package/dist/index.js +104 -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-yngkkxz2.d.ts → chunk-0ym9mcqc.d.ts} +10 -6
  62. package/dist/shared/chunk-2b6gpn8k.js +444 -0
  63. package/dist/shared/chunk-3hcnf4yx.js +481 -0
  64. package/dist/shared/chunk-42wab62s.d.ts +197 -0
  65. package/dist/shared/{chunk-zvh0d3qb.js → chunk-61t2dfte.js} +1 -1
  66. package/dist/shared/{chunk-9nhpg9t8.d.ts → chunk-6tnq6p89.d.ts} +9 -1
  67. package/dist/shared/{chunk-hpsabfsd.d.ts → chunk-81fpptwp.d.ts} +1 -1
  68. package/dist/shared/chunk-93dtpjz7.js +789 -0
  69. package/dist/shared/{chunk-wwjxs75m.js → chunk-9xtcv3sy.js} +26 -12
  70. package/dist/shared/chunk-a6njb8db.d.ts +129 -0
  71. package/dist/shared/chunk-ab8mdg0n.d.ts +149 -0
  72. package/dist/shared/chunk-evqpf92s.d.ts +168 -0
  73. package/dist/shared/{chunk-6c1jbefs.d.ts → chunk-fexwzycv.d.ts} +3 -3
  74. package/dist/shared/chunk-gcyspvgr.js +582 -0
  75. package/dist/shared/chunk-gejenfap.d.ts +25 -0
  76. package/dist/shared/chunk-gkj0hjrn.d.ts +136 -0
  77. package/dist/shared/{chunk-rr5e0g15.d.ts → chunk-j755a1a5.d.ts} +7 -1
  78. package/dist/shared/chunk-n739am8j.d.ts +112 -0
  79. package/dist/shared/{chunk-78w7qwp0.js → chunk-ndf79pv5.js} +1 -1
  80. package/dist/shared/chunk-nwzpekvy.js +774 -0
  81. package/dist/shared/{chunk-rpfwv3pz.js → chunk-r471sknr.js} +1 -1
  82. package/dist/shared/chunk-sbrtesdg.d.ts +138 -0
  83. package/dist/shared/chunk-swc7dqpw.d.ts +115 -0
  84. package/dist/shared/chunk-t9wqhgzt.js +765 -0
  85. package/dist/shared/chunk-w5h6ay93.js +72 -0
  86. package/dist/shared/{chunk-mp1nx0ez.js → chunk-wayv5rhr.js} +15 -4
  87. package/dist/shared/chunk-wf0jtzhs.js +295 -0
  88. package/dist/shared/{chunk-sbnrhy5m.js → chunk-y0188bbn.js} +2 -2
  89. package/dist/shared/chunk-yq5svpk7.js +524 -0
  90. package/dist/shared/{chunk-s33y1pcq.js → chunk-z3tj1ydg.js} +23 -10
  91. package/dist/styles.css +151 -49
  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 +113 -0
  98. package/mock/clock.tsx +77 -0
  99. package/mock/data.ts +78 -44
  100. package/mock/files.tsx +83 -0
  101. package/mock/island-content.tsx +79 -122
  102. package/mock/screen.tsx +76 -0
  103. package/mock/settings.tsx +370 -91
  104. package/mock/system.ts +49 -0
  105. package/mock/weather.tsx +135 -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
@@ -1,252 +0,0 @@
1
- "use client";
2
-
3
- // blocks/activities/shelf/index.tsx
4
- import Button from "@justanarthur/modo-ui/components/actions/button";
5
- import EmptyState from "@justanarthur/modo-ui/components/feedback/empty-state";
6
- import ContextMenu from "@justanarthur/modo-ui/components/overlays/context-menu";
7
- import { useReduceMotion } from "@justanarthur/modo-ui/lib/reduced-motion";
8
- import { spring } from "@justanarthur/modo-ui/lib/springs";
9
- import { useControllableState } from "@justanarthur/modo-ui/lib/use-controllable-state";
10
- import { cn } from "@justanarthur/modo-ui/lib/utils";
11
- import FluidHover from "@justanarthur/modo-ui/primitives/systems/fluid-hover";
12
- import {
13
- ArrowDownToLine,
14
- Check,
15
- File,
16
- FileArchive,
17
- FileAudio,
18
- FileCode,
19
- FileImage,
20
- Files,
21
- FileText,
22
- FileVideo,
23
- Send,
24
- Trash2
25
- } from "lucide-react";
26
- import { AnimatePresence, motion } from "motion/react";
27
- import { useRef } from "react";
28
- import { jsx, jsxs } from "react/jsx-runtime";
29
- /*!
30
- * Local addition: a notch app's file shelf, the files dragged onto the notch
31
- * to keep for later. Rebuilt from Just Notch's shelf plugin (`Shelf`, `Tile`,
32
- * `DropFlash`, `Count`) as presentational parts: the files and what to do
33
- * with them come in as props.
34
- */
35
- var DRAG_SLOP_PX = 4;
36
- var TYPES = [
37
- [/\.(png|jpe?g|gif|webp|heic|svg|tiff?)$/i, FileImage],
38
- [/\.(mov|mp4|m4v|avi|mkv|webm)$/i, FileVideo],
39
- [/\.(mp3|m4a|wav|aiff?|flac|ogg)$/i, FileAudio],
40
- [/\.(zip|tar|gz|tgz|rar|7z|dmg)$/i, FileArchive],
41
- [/\.(m?[jt]sx?|json|css|html|swift|rs|go|py|rb|sh|ya?ml|toml)$/i, FileCode],
42
- [/\.(pdf|md|txt|rtf|docx?|pages|key|numbers|csv)$/i, FileText]
43
- ];
44
- var iconFor = (name) => TYPES.find(([pattern]) => pattern.test(name))?.[1] ?? File;
45
- var count = (n) => `${n} ${n === 1 ? "file" : "files"}`;
46
- function Thumbnail({ file }) {
47
- const Icon = iconFor(file.name);
48
- return /* @__PURE__ */ jsx("span", {
49
- className: "flex size-14 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-3 text-muted-foreground",
50
- children: typeof file.thumbnail === "string" ? /* @__PURE__ */ jsx("img", {
51
- alt: "",
52
- src: file.thumbnail,
53
- draggable: false,
54
- className: "size-full object-cover"
55
- }) : file.thumbnail ?? /* @__PURE__ */ jsx(Icon, {
56
- size: 20,
57
- strokeWidth: 1.5
58
- })
59
- });
60
- }
61
- function Tile({ file, index, onOpen, onReveal, onRemove, onDragOut }) {
62
- const reduced = useReduceMotion();
63
- const press = useRef(undefined);
64
- return /* @__PURE__ */ jsx(motion.div, {
65
- layout: !reduced,
66
- initial: { opacity: 0, scale: reduced ? 1 : 0.9 },
67
- animate: { opacity: 1, scale: 1 },
68
- exit: { opacity: 0, scale: reduced ? 1 : 0.9, transition: spring.moderate.exit },
69
- transition: spring.moderate,
70
- children: /* @__PURE__ */ jsxs(ContextMenu, {
71
- size: "compact",
72
- children: [
73
- /* @__PURE__ */ jsx(ContextMenu.Trigger, {
74
- children: /* @__PURE__ */ jsxs(FluidHover.Item, {
75
- index,
76
- title: file.name,
77
- className: "h-auto w-20 flex-col items-center justify-start gap-1.5 p-1.5",
78
- onPointerDown: (event) => {
79
- if (event.button === 0)
80
- press.current = { x: event.clientX, y: event.clientY };
81
- },
82
- onPointerMove: (event) => {
83
- const start = press.current;
84
- if (!start || Math.hypot(event.clientX - start.x, event.clientY - start.y) < DRAG_SLOP_PX)
85
- return;
86
- press.current = undefined;
87
- onDragOut?.(file);
88
- },
89
- onPointerUp: () => {
90
- press.current = undefined;
91
- },
92
- onDoubleClick: () => onOpen?.(file),
93
- children: [
94
- /* @__PURE__ */ jsx(Thumbnail, {
95
- file
96
- }),
97
- /* @__PURE__ */ jsx("span", {
98
- className: "w-full truncate text-center text-micro text-foreground",
99
- children: file.name
100
- })
101
- ]
102
- })
103
- }),
104
- /* @__PURE__ */ jsxs(ContextMenu.Content, {
105
- className: "dark text-foreground",
106
- children: [
107
- /* @__PURE__ */ jsx(ContextMenu.Item, {
108
- index: 0,
109
- label: "Open",
110
- onSelect: () => onOpen?.(file)
111
- }),
112
- /* @__PURE__ */ jsx(ContextMenu.Item, {
113
- index: 1,
114
- label: "Show in Finder",
115
- onSelect: () => onReveal?.(file)
116
- }),
117
- /* @__PURE__ */ jsx(ContextMenu.Separator, {}),
118
- /* @__PURE__ */ jsx(ContextMenu.Item, {
119
- index: 2,
120
- icon: Trash2,
121
- label: "Remove from shelf",
122
- onSelect: () => onRemove(file)
123
- })
124
- ]
125
- })
126
- ]
127
- })
128
- });
129
- }
130
- function ShelfLeading2() {
131
- return /* @__PURE__ */ jsx(Files, {
132
- size: 16,
133
- strokeWidth: 1.5,
134
- className: "text-foreground"
135
- });
136
- }
137
- function ShelfTrailing2({ count: n }) {
138
- return /* @__PURE__ */ jsx("span", {
139
- className: "text-caption weight-medium tabular-nums text-foreground",
140
- children: n
141
- });
142
- }
143
- function ShelfDrop2({ phase, count: n, total = n, className }) {
144
- const reduced = useReduceMotion();
145
- const added = phase === "added";
146
- return /* @__PURE__ */ jsxs("div", {
147
- className: cn("flex h-10 items-center gap-3 rounded-xl border px-3 transition-[border-color] duration-moderate", added ? "border-transparent" : "border-dashed border-brand", className),
148
- children: [
149
- /* @__PURE__ */ jsx(AnimatePresence, {
150
- initial: false,
151
- mode: "popLayout",
152
- children: /* @__PURE__ */ jsx(motion.span, {
153
- className: cn("flex shrink-0", added ? "text-status-success" : "text-brand"),
154
- initial: { opacity: 0, scale: reduced ? 1 : 0.6 },
155
- animate: { opacity: 1, scale: 1 },
156
- exit: { opacity: 0, scale: reduced ? 1 : 0.6, transition: spring.fast.exit },
157
- transition: spring.moderate,
158
- children: added ? /* @__PURE__ */ jsx(Check, {
159
- size: 16,
160
- strokeWidth: 2
161
- }) : /* @__PURE__ */ jsx(ArrowDownToLine, {
162
- size: 16,
163
- strokeWidth: 1.5
164
- })
165
- }, phase)
166
- }),
167
- /* @__PURE__ */ jsx("span", {
168
- className: "min-w-0 flex-1 truncate text-body weight-semibold text-foreground",
169
- children: added ? "Added to shelf" : "Drop to shelf"
170
- }),
171
- /* @__PURE__ */ jsx("span", {
172
- className: "shrink-0 text-caption tabular-nums text-muted-foreground",
173
- children: added ? `${total} on shelf` : count(n)
174
- })
175
- ]
176
- });
177
- }
178
- function Shelf2({
179
- value,
180
- defaultValue = [],
181
- onValueChange,
182
- onOpen,
183
- onReveal,
184
- onAirDrop,
185
- onDragOut,
186
- className
187
- }) {
188
- const [files, setFiles] = useControllableState(value, defaultValue, onValueChange);
189
- if (files.length === 0)
190
- return /* @__PURE__ */ jsx("div", {
191
- className: cn("flex size-full items-center justify-center", className),
192
- children: /* @__PURE__ */ jsx(EmptyState, {
193
- size: "compact",
194
- icon: Files,
195
- title: "Shelf is empty",
196
- description: "Drag files onto the notch to keep them here."
197
- })
198
- });
199
- return /* @__PURE__ */ jsxs("div", {
200
- className: cn("flex size-full flex-col gap-2", className),
201
- children: [
202
- /* @__PURE__ */ jsxs("div", {
203
- className: "flex shrink-0 items-center justify-between gap-3",
204
- children: [
205
- /* @__PURE__ */ jsx("span", {
206
- className: "text-caption tabular-nums text-muted-foreground",
207
- children: count(files.length)
208
- }),
209
- /* @__PURE__ */ jsxs("div", {
210
- className: "-mr-3 flex items-center gap-1",
211
- children: [
212
- onAirDrop && /* @__PURE__ */ jsx(Button, {
213
- variant: "ghost",
214
- size: "compact",
215
- leadingIcon: Send,
216
- onClick: () => onAirDrop(files),
217
- children: "AirDrop"
218
- }),
219
- /* @__PURE__ */ jsx(Button, {
220
- variant: "ghost",
221
- size: "compact",
222
- leadingIcon: Trash2,
223
- onClick: () => setFiles([]),
224
- children: "Clear"
225
- })
226
- ]
227
- })
228
- ]
229
- }),
230
- /* @__PURE__ */ jsx(FluidHover, {
231
- axis: "x",
232
- className: "-mx-3 flex min-h-0 flex-1 items-start overflow-x-auto overflow-y-hidden px-1.5",
233
- children: /* @__PURE__ */ jsx(AnimatePresence, {
234
- initial: false,
235
- children: files.map((file, i) => /* @__PURE__ */ jsx(Tile, {
236
- file,
237
- index: i,
238
- onOpen,
239
- onReveal,
240
- onRemove: (removed) => setFiles(files.filter((f) => f.id !== removed.id)),
241
- onDragOut
242
- }, file.id))
243
- })
244
- })
245
- ]
246
- });
247
- }
248
- Shelf2.Drop = ShelfDrop2;
249
- Shelf2.Leading = ShelfLeading2;
250
- Shelf2.Trailing = ShelfTrailing2;
251
- var shelf_default = Shelf2;
252
- export { ShelfLeading2, ShelfTrailing2, ShelfDrop2, Shelf2, shelf_default };
@@ -1,42 +0,0 @@
1
- import { JSX as JSX_1kxb } from "react";
2
- type DeviceKind2 = "headphones" | "keyboard" | "mouse" | "speaker" | "gamepad" | "phone" | "watch" | "other";
3
- interface DeviceInfo2 {
4
- id: string;
5
- name: string;
6
- /** What it is, for its glyph. */
7
- kind: DeviceKind2;
8
- connected: boolean;
9
- /** Its charge in percent, when it reports one. */
10
- battery?: number;
11
- charging?: boolean;
12
- }
13
- interface DevicesProps2 {
14
- /** The paired devices; connected ones list first, then by name. */
15
- devices: DeviceInfo2[];
16
- /** Called by the empty state's Open Bluetooth Settings; without it the button hides. */
17
- onOpenSettings?: () => void;
18
- /** Classes for the root, which fills its container. */
19
- className?: string;
20
- }
21
- type Element_12xgc = JSX_1kxb["Element"];
22
- /** The island's flash when a device connects: its glyph, name and battery. */
23
- declare function DevicesConnected2({ device }: {
24
- device: DeviceInfo2;
25
- }): Element_12xgc;
26
- /**
27
- * A notch app's Bluetooth devices: what's paired, what's connected and how
28
- * much charge each has left.
29
- *
30
- * Devices list in two columns, connected first: a glyph for the kind of
31
- * device (raised while connected), the name, a StatusDot with Connected or
32
- * Not connected, and for a connected device that reports one, its charge as
33
- * a figure and a BatteryGlyph, which turns to the warning and error hues as
34
- * it runs low. Without devices it says how to pair one, with a button to the
35
- * system's Bluetooth settings when `onOpenSettings` is given.
36
- *
37
- * `Devices.Connected` is the island's flash when a device connects.
38
- *
39
- * @example {@include ./examples.mdx}
40
- */
41
- declare function Devices2({ devices, onOpenSettings, className }: DevicesProps2): Element_12xgc;
42
- export { DeviceKind2, DeviceInfo2, DevicesProps2, DevicesConnected2, Devices2 };
@@ -1,70 +0,0 @@
1
- "use client";
2
-
3
- import {
4
- BatteryGlyph2
5
- } from "./chunk-hwtxpzg0.js";
6
- import {
7
- IslandFlash2
8
- } from "./chunk-78w7qwp0.js";
9
-
10
- // blocks/system/power-alert/index.tsx
11
- import { BatteryLow, BatteryWarning, Unplug, Zap } from "lucide-react";
12
- import { jsx } from "react/jsx-runtime";
13
- /*!
14
- * Local addition: a notch app's power alerts. Rebuilt from Just Notch's
15
- * power plugin (`Charging`, `Unplugged`, `Low`, `Critical`) as one
16
- * presentational flash: the battery comes in as props.
17
- */
18
- var ALERT = {
19
- charging: {
20
- title: "Charging",
21
- tone: "success",
22
- icon: /* @__PURE__ */ jsx(Zap, {
23
- size: 18,
24
- strokeWidth: 1.5,
25
- fill: "currentColor"
26
- }),
27
- verb: "until full"
28
- },
29
- unplugged: { title: "On battery", tone: "default", icon: /* @__PURE__ */ jsx(Unplug, {
30
- size: 18,
31
- strokeWidth: 1.5
32
- }), verb: "remaining" },
33
- low: {
34
- title: "Low battery",
35
- tone: "warning",
36
- icon: /* @__PURE__ */ jsx(BatteryLow, {
37
- size: 18,
38
- strokeWidth: 1.5
39
- }),
40
- caption: "Plug in soon"
41
- },
42
- critical: {
43
- title: "Battery critically low",
44
- tone: "error",
45
- icon: /* @__PURE__ */ jsx(BatteryWarning, {
46
- size: 18,
47
- strokeWidth: 1.5
48
- }),
49
- caption: "Plug in now"
50
- }
51
- };
52
- var span = (minutes) => minutes >= 60 ? `${Math.floor(minutes / 60)} h ${Math.round(minutes % 60)} min` : `${Math.round(minutes)} min`;
53
- function PowerAlert2({ kind, level, minutes, caption, className }) {
54
- const alert = ALERT[kind];
55
- const detail = minutes !== undefined && alert.verb ? `${span(minutes)} ${alert.verb}` : alert.caption;
56
- return /* @__PURE__ */ jsx(IslandFlash2, {
57
- className,
58
- icon: alert.icon,
59
- tone: alert.tone,
60
- title: alert.title,
61
- caption: caption ?? detail,
62
- value: `${Math.round(level)}%`,
63
- trailing: /* @__PURE__ */ jsx(BatteryGlyph2, {
64
- level,
65
- charging: kind === "charging",
66
- tone: alert.tone
67
- })
68
- });
69
- }
70
- export { PowerAlert2 };
@@ -1,266 +0,0 @@
1
- "use client";
2
-
3
- import {
4
- SECOND2,
5
- MINUTE2,
6
- formatClock2,
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/timer/index.tsx
17
- import Button from "@justanarthur/modo-ui/components/actions/button";
18
- import Meter from "@justanarthur/modo-ui/components/feedback/meter";
19
- import NumberInput from "@justanarthur/modo-ui/components/inputs/number-input";
20
- import { useControllableState } from "@justanarthur/modo-ui/lib/use-controllable-state";
21
- import { cn } from "@justanarthur/modo-ui/lib/utils";
22
- import { Pause, Play, Plus, Timer as TimerIcon, X } from "lucide-react";
23
- import { useState } from "react";
24
- import { jsx, jsxs } from "react/jsx-runtime";
25
- /*!
26
- * Local addition: a notch app's timer, from picking a length to "Time's up".
27
- * Rebuilt from Just Notch's timer plugin (`Picker`, `Running`, `Ring`,
28
- * `TimeUp`) as presentational parts: the run is a value the host may own.
29
- */
30
- var LABEL = { focus: "Focus", break: "Break", custom: "Timer" };
31
- var start = (minutes, kind) => ({
32
- kind,
33
- total: minutes * MINUTE2,
34
- endsAt: Date.now() + minutes * MINUTE2
35
- });
36
- var pause = (run) => ({ kind: run.kind, total: run.total, remaining: timeLeft(run, Date.now()) });
37
- var resume = (run) => ({
38
- kind: run.kind,
39
- total: run.total,
40
- endsAt: Date.now() + (run.remaining ?? 0)
41
- });
42
- var addMinute = (run) => run.endsAt === undefined ? { ...run, total: run.total + MINUTE2, remaining: (run.remaining ?? 0) + MINUTE2 } : { ...run, total: run.total + MINUTE2, endsAt: run.endsAt + MINUTE2 };
43
- function timeLeft(run, now) {
44
- return run.endsAt === undefined ? run.remaining ?? 0 : Math.max(0, run.endsAt - now);
45
- }
46
- function useTimeLeft(run) {
47
- const end = run.endsAt ?? 0;
48
- const now = useEdgeClock2(end, run.endsAt !== undefined && Date.now() < end + SECOND2);
49
- return timeLeft(run, now);
50
- }
51
- function Ring({ run, className }) {
52
- const left = useTimeLeft(run);
53
- return /* @__PURE__ */ jsx(Meter, {
54
- variant: "ring",
55
- label: `${LABEL[run.kind]}, ${formatClock2(Math.ceil(left / SECOND2))} left`,
56
- value: run.total ? left / run.total : 0,
57
- tone: "default",
58
- animate: false,
59
- className
60
- });
61
- }
62
- function Clock({ run, className, onEnd }) {
63
- const paused = run.endsAt === undefined;
64
- return /* @__PURE__ */ jsx(Countdown2, {
65
- endsAt: run.endsAt,
66
- paused,
67
- remaining: run.remaining,
68
- onEnd,
69
- className: cn(className, paused ? "text-muted-foreground" : "text-status-warning")
70
- });
71
- }
72
- function TimerLeading2() {
73
- return /* @__PURE__ */ jsx(TimerIcon, {
74
- size: 16,
75
- strokeWidth: 1.5,
76
- className: "text-status-warning"
77
- });
78
- }
79
- function TimerTrailing2({ run }) {
80
- return /* @__PURE__ */ jsx(Clock, {
81
- run,
82
- className: "text-caption weight-medium"
83
- });
84
- }
85
- function TimerMinimal2({ run }) {
86
- return /* @__PURE__ */ jsx(Ring, {
87
- run,
88
- className: "size-5.5"
89
- });
90
- }
91
- function TimerDone2({ kind = "custom", next, minutes }) {
92
- const detail = next ? `${LABEL[next]} starts now${minutes ? ` · ${minutes} min` : ""}` : `${LABEL[kind]} finished`;
93
- return /* @__PURE__ */ jsx(IslandFlash2, {
94
- icon: /* @__PURE__ */ jsx(TimerIcon, {
95
- size: 20,
96
- strokeWidth: 1.5
97
- }),
98
- tone: "warning",
99
- title: "Time's up",
100
- caption: detail
101
- });
102
- }
103
- function Picker({ presets, focusMinutes, onStart }) {
104
- const [minutes, setMinutes] = useState(null);
105
- const valid = minutes !== null && Number.isInteger(minutes) && minutes >= 1 && minutes <= 99;
106
- const submit = (event) => {
107
- event.preventDefault();
108
- if (valid)
109
- onStart(start(minutes, "custom"));
110
- };
111
- return /* @__PURE__ */ jsxs("div", {
112
- className: "flex size-full flex-col justify-center gap-3",
113
- children: [
114
- /* @__PURE__ */ jsxs("div", {
115
- className: "grid grid-cols-4 gap-2",
116
- children: [
117
- presets.map((m) => /* @__PURE__ */ jsxs(Button, {
118
- variant: "tertiary",
119
- onClick: () => onStart(start(m, "custom")),
120
- children: [
121
- m,
122
- " min"
123
- ]
124
- }, m)),
125
- /* @__PURE__ */ jsx(Button, {
126
- variant: "tertiary",
127
- onClick: () => onStart(start(focusMinutes, "focus")),
128
- children: "Pomodoro"
129
- })
130
- ]
131
- }),
132
- /* @__PURE__ */ jsxs("form", {
133
- className: "flex items-center gap-2",
134
- onSubmit: submit,
135
- children: [
136
- /* @__PURE__ */ jsx("div", {
137
- className: "min-w-0 flex-1",
138
- children: /* @__PURE__ */ jsx(NumberInput, {
139
- className: "w-full",
140
- variant: "bordered",
141
- min: 1,
142
- max: 99,
143
- placeholder: "Custom minutes",
144
- "aria-label": "Custom minutes",
145
- endAdornment: "min",
146
- value: minutes,
147
- onValueChange: setMinutes
148
- })
149
- }),
150
- /* @__PURE__ */ jsx(Button, {
151
- type: "submit",
152
- variant: "primary",
153
- leadingIcon: Play,
154
- disabled: !valid,
155
- children: "Start"
156
- })
157
- ]
158
- })
159
- ]
160
- });
161
- }
162
- function Running({ run, onChange, onEnd }) {
163
- const paused = run.endsAt === undefined;
164
- return /* @__PURE__ */ jsxs("div", {
165
- className: "flex size-full items-center gap-5",
166
- children: [
167
- /* @__PURE__ */ jsx(Ring, {
168
- run,
169
- className: "size-16"
170
- }),
171
- /* @__PURE__ */ jsxs("div", {
172
- className: "flex min-w-0 flex-1 flex-col",
173
- children: [
174
- /* @__PURE__ */ jsxs("span", {
175
- className: "truncate text-caption text-muted-foreground",
176
- children: [
177
- LABEL[run.kind],
178
- " · ",
179
- Math.round(run.total / MINUTE2),
180
- " min",
181
- paused ? " · Paused" : ""
182
- ]
183
- }),
184
- /* @__PURE__ */ jsx(Clock, {
185
- run,
186
- className: "text-display",
187
- onEnd
188
- })
189
- ]
190
- }),
191
- /* @__PURE__ */ jsxs("div", {
192
- className: "flex shrink-0 items-center gap-2",
193
- children: [
194
- /* @__PURE__ */ jsx(Button, {
195
- variant: "tertiary",
196
- leadingIcon: Plus,
197
- onClick: () => onChange(addMinute(run)),
198
- children: "1 min"
199
- }),
200
- /* @__PURE__ */ jsx(Button, {
201
- variant: "tertiary",
202
- size: "icon",
203
- className: "text-status-warning",
204
- "aria-label": paused ? "Resume" : "Pause",
205
- onClick: () => onChange(paused ? resume(run) : pause(run)),
206
- children: paused ? /* @__PURE__ */ jsx(Play, {
207
- size: 16,
208
- strokeWidth: 1.5,
209
- fill: "currentColor"
210
- }) : /* @__PURE__ */ jsx(Pause, {
211
- size: 16,
212
- strokeWidth: 1.5,
213
- fill: "currentColor"
214
- })
215
- }),
216
- /* @__PURE__ */ jsx(Button, {
217
- variant: "tertiary",
218
- size: "icon",
219
- "aria-label": "Cancel",
220
- onClick: () => onChange(null),
221
- children: /* @__PURE__ */ jsx(X, {
222
- size: 16,
223
- strokeWidth: 1.5
224
- })
225
- })
226
- ]
227
- })
228
- ]
229
- });
230
- }
231
- function Timer2({
232
- value,
233
- defaultValue = null,
234
- onValueChange,
235
- onEnd,
236
- presets = [1, 5, 10],
237
- pomodoro = false,
238
- focusMinutes = 25,
239
- breakMinutes = 5,
240
- className
241
- }) {
242
- const [run, setRun] = useControllableState(value, defaultValue, onValueChange);
243
- const complete = (ended) => {
244
- const next = pomodoro && ended.kind !== "custom" ? ended.kind === "focus" ? "break" : "focus" : undefined;
245
- onEnd?.(ended, next);
246
- setRun(next ? start(next === "break" ? breakMinutes : focusMinutes, next) : null);
247
- };
248
- return /* @__PURE__ */ jsx("div", {
249
- className: cn("size-full", className),
250
- children: run ? /* @__PURE__ */ jsx(Running, {
251
- run,
252
- onChange: setRun,
253
- onEnd: () => complete(run)
254
- }) : /* @__PURE__ */ jsx(Picker, {
255
- presets,
256
- focusMinutes,
257
- onStart: setRun
258
- })
259
- });
260
- }
261
- Timer2.Leading = TimerLeading2;
262
- Timer2.Trailing = TimerTrailing2;
263
- Timer2.Minimal = TimerMinimal2;
264
- Timer2.Done = TimerDone2;
265
- var timer_default = Timer2;
266
- export { TimerLeading2, TimerTrailing2, TimerMinimal2, TimerDone2, Timer2, timer_default };
@@ -1,58 +0,0 @@
1
- import { JSX as JSX_1kxb } from "react";
2
- type ControlKind2 = "volume" | "brightness" | "keyboard";
3
- /** The levels, from 0 to 1. A missing brightness or keyboard level hides its row (no built-in display, no backlight). */
4
- interface ControlLevels2 {
5
- volume: number;
6
- muted?: boolean;
7
- brightness?: number;
8
- keyboard?: number;
9
- }
10
- interface ControlsProps2 {
11
- /** The levels (controlled). */
12
- value?: ControlLevels2;
13
- /** The levels at first (uncontrolled). Defaults to the volume at half. */
14
- defaultValue?: ControlLevels2;
15
- /** Called with every level when a slider moves one; moving volume unmutes it. */
16
- onValueChange?: (levels: ControlLevels2) => void;
17
- /** The audio output's name, on a muted row under the sliders. */
18
- output?: string;
19
- /** Classes for the root, which fills its container. */
20
- className?: string;
21
- }
22
- interface ControlsLevelProps2 {
23
- /** What it sets. */
24
- kind: ControlKind2;
25
- /** The level, from 0 to 1 (controlled). */
26
- value?: number;
27
- /** The level at first (uncontrolled). Defaults to `0`. */
28
- defaultValue?: number;
29
- /** Called with the level, from 0 to 1, as the slider moves. */
30
- onValueChange?: (value: number) => void;
31
- /** Volume only: it is muted, so it reads 0 and shows the crossed speaker until moved. */
32
- muted?: boolean;
33
- /** Classes for the row. */
34
- className?: string;
35
- }
36
- type Element_12xgc = JSX_1kxb["Element"];
37
- /** One level as a row: a glyph that follows it, a compact slider and the percent. Pass it as the HUD's flash, keyed by kind. */
38
- declare function ControlsLevel2({ kind, value: valueProp, defaultValue, onValueChange, muted, className }: ControlsLevelProps2): Element_12xgc;
39
- /**
40
- * A notch app's system controls: volume, display brightness and keyboard
41
- * backlight as sliders, and the audio output.
42
- *
43
- * Each row is a glyph that follows its level (the speaker's waves, a muted
44
- * cross, the sun's rays, the backlight off), modo-ui's compact Slider and the
45
- * level in percent. A display without a brightness reading, or a keyboard
46
- * without a backlight, leaves its level out and so its row. The levels are
47
- * one value from 0 to 1 each (`value` / `onValueChange`, or kept here from
48
- * `defaultValue`); moving the volume unmutes it.
49
- *
50
- * `Controls.Level` is one row on its own: the HUD flash that replaces the
51
- * system's overlay when a volume or brightness key is pressed. Key it by
52
- * kind, so pressing a brightness key while the volume shows swaps the flash
53
- * instead of repainting it.
54
- *
55
- * @example {@include ./examples.mdx}
56
- */
57
- declare function Controls2({ value, defaultValue, onValueChange, output, className }: ControlsProps2): Element_12xgc;
58
- export { ControlKind2, ControlLevels2, ControlsProps2, ControlsLevelProps2, ControlsLevel2, Controls2 };