@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
@@ -1,69 +0,0 @@
1
- "use client";
2
-
3
- // components/indicators/battery-glyph/index.tsx
4
- import { useReduceMotion } from "@justanarthur/modo-ui/lib/reduced-motion";
5
- import { spring } from "@justanarthur/modo-ui/lib/springs";
6
- import { cn } from "@justanarthur/modo-ui/lib/utils";
7
- import { motion } from "motion/react";
8
- import { jsx, jsxs } from "react/jsx-runtime";
9
- /*!
10
- * Local addition: a battery that fills to its level, for a notch app's power
11
- * alerts. Rebuilt from Just Notch's power plugin (`Battery`).
12
- */
13
- var FILL = {
14
- default: "bg-foreground",
15
- success: "bg-status-success",
16
- warning: "bg-status-warning",
17
- error: "bg-status-error"
18
- };
19
- function batteryTone2(level, charging) {
20
- if (charging)
21
- return "success";
22
- if (level <= 10)
23
- return "error";
24
- if (level <= 20)
25
- return "warning";
26
- return "default";
27
- }
28
- function BatteryGlyph2({
29
- level,
30
- charging = false,
31
- tone,
32
- fillIn = true,
33
- label,
34
- className
35
- }) {
36
- const reduced = useReduceMotion();
37
- const share = Math.max(0.06, Math.min(1, level / 100));
38
- const name = label ?? `${Math.round(level)}%${charging ? ", charging" : ""}`;
39
- return /* @__PURE__ */ jsxs("span", {
40
- role: "img",
41
- "aria-label": name,
42
- className: cn("inline-flex shrink-0 items-center gap-px", className),
43
- children: [
44
- /* @__PURE__ */ jsxs("span", {
45
- className: "relative h-3.5 w-7 overflow-hidden rounded-box bg-active p-0.5",
46
- children: [
47
- /* @__PURE__ */ jsx(motion.span, {
48
- className: cn("block h-full w-full origin-left rounded-glyph", FILL[tone ?? batteryTone2(level, charging)]),
49
- initial: fillIn && !reduced ? { scaleX: 0 } : false,
50
- animate: { scaleX: share },
51
- transition: reduced ? { duration: 0 } : spring.slow
52
- }),
53
- charging && /* @__PURE__ */ jsx("svg", {
54
- "aria-hidden": true,
55
- viewBox: "0 0 24 24",
56
- className: "absolute inset-0 m-auto size-3 fill-foreground",
57
- children: /* @__PURE__ */ jsx("path", {
58
- d: "M13 2 4.5 13.5H11L10 22l8.5-11.5H12z"
59
- })
60
- })
61
- ]
62
- }),
63
- /* @__PURE__ */ jsx("span", {
64
- className: "h-1.5 w-0.5 rounded-r-full bg-active"
65
- })
66
- ]
67
- });
68
- }
69
- export { batteryTone2, BatteryGlyph2 };
@@ -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 };