@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,65 @@
1
+ "use client";
2
+
3
+ // components/indicators/equalizer/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 { useEffect, useRef } from "react";
9
+ import { jsx } from "react/jsx-runtime";
10
+ /*!
11
+ * Local addition: the now-playing level bars of a notch app's compact wing.
12
+ * Rebuilt from Just Notch's now-playing plugin (`Bars`).
13
+ */
14
+ var LOOPS = [
15
+ { levels: [0.35, 1, 0.5, 0.8, 0.35], beats: 5 },
16
+ { levels: [0.7, 0.4, 0.95, 0.55, 0.7], beats: 4 },
17
+ { levels: [0.5, 0.9, 0.3, 1, 0.5], beats: 6 },
18
+ { levels: [0.4, 0.75, 0.6, 0.3, 0.4], beats: 4.5 },
19
+ { levels: [0.6, 0.3, 0.85, 0.45, 0.6], beats: 5.5 }
20
+ ];
21
+ var REST = 0.2;
22
+ var STILL = [0.5, 0.85, 0.65, 0.4, 0.7];
23
+ function Bar({ loop, live, level, className }) {
24
+ const ref = useRef(null);
25
+ useEffect(() => {
26
+ const bar = ref.current;
27
+ if (!live || !bar)
28
+ return;
29
+ const animation = bar.animate(loop.levels.map((l) => ({ transform: `scaleY(${l})` })), {
30
+ duration: spring.slow.duration * loop.beats * 1000,
31
+ easing: "ease-in-out",
32
+ iterations: Number.POSITIVE_INFINITY
33
+ });
34
+ return () => animation.cancel();
35
+ }, [live, loop]);
36
+ return /* @__PURE__ */ jsx(motion.span, {
37
+ ref,
38
+ className: cn("h-full w-0.75 rounded-full", className),
39
+ initial: false,
40
+ animate: { scaleY: level },
41
+ transition: spring.moderate
42
+ });
43
+ }
44
+ function Equalizer2({
45
+ playing = true,
46
+ bars = 4,
47
+ label,
48
+ barClassName = "bg-foreground",
49
+ className
50
+ }) {
51
+ const reduced = useReduceMotion();
52
+ const live = playing && !reduced;
53
+ const count = Math.min(Math.max(1, Math.round(bars)), LOOPS.length);
54
+ return /* @__PURE__ */ jsx("span", {
55
+ ...label ? { role: "img", "aria-label": label } : { "aria-hidden": true },
56
+ className: cn("inline-flex h-3.5 shrink-0 items-center gap-0.5", className),
57
+ children: LOOPS.slice(0, count).map((loop, i) => /* @__PURE__ */ jsx(Bar, {
58
+ loop,
59
+ live,
60
+ level: playing ? STILL[i] ?? REST : REST,
61
+ className: barClassName
62
+ }, loop.beats))
63
+ });
64
+ }
65
+ export { Equalizer2 };
@@ -0,0 +1,88 @@
1
+ import { IconComponent } from "@justanarthur/modo-ui/lib/icon-context";
2
+ import { ReactNode } from "react";
3
+ import { JSX as JSX_1kxb } from "react";
4
+ type ScreensPreference2 = "notched" | "all";
5
+ interface AppPreferences2 {
6
+ /** Start the app when the user logs in. */
7
+ launchAtLogin: boolean;
8
+ /** Where the island shows: on the notched screen only, or on every screen. */
9
+ screens: ScreensPreference2;
10
+ }
11
+ interface SettingsPlugin2 {
12
+ id: string;
13
+ name: string;
14
+ /** One line on what it adds. */
15
+ description?: string;
16
+ /** Its glyph in the Plugins list. */
17
+ icon?: IconComponent;
18
+ /** Its settings, on a page of its own under Plugin settings. */
19
+ settings?: ReactNode;
20
+ }
21
+ interface SettingsPermission2 {
22
+ id: string;
23
+ label: string;
24
+ /** What the app does with it. */
25
+ description: string;
26
+ /** Whether macOS granted it; unset while it's being read. */
27
+ granted?: boolean;
28
+ }
29
+ interface AboutRow2 {
30
+ label: string;
31
+ value: ReactNode;
32
+ }
33
+ interface SettingsWindowProps2 {
34
+ /** The app's name, over the sidebar. Defaults to `'Notch'`. */
35
+ name?: string;
36
+ /** The page shown: `general`, `plugins`, `permissions`, `about` or `plugin:<id>` (controlled). */
37
+ value?: string;
38
+ /** The page shown at first (uncontrolled). Defaults to `'general'`. */
39
+ defaultValue?: string;
40
+ /** Called with the page a sidebar row opens. */
41
+ onValueChange?: (value: string) => void;
42
+ /** The General page's preferences (controlled). */
43
+ preferences?: AppPreferences2;
44
+ /** The preferences at first (uncontrolled). Defaults to launching at login on the notched screen only. */
45
+ defaultPreferences?: AppPreferences2;
46
+ /** Called with every preference when one changes. */
47
+ onPreferencesChange?: (preferences: AppPreferences2) => void;
48
+ /** The installed plugins. Defaults to `[]`. */
49
+ plugins?: SettingsPlugin2[];
50
+ /** Which plugins are on, by id (controlled). */
51
+ enabled?: Record<string, boolean>;
52
+ /** Which plugins are on at first (uncontrolled). Defaults to every plugin. */
53
+ defaultEnabled?: Record<string, boolean>;
54
+ /** Called with every plugin's state when a switch changes one. */
55
+ onEnabledChange?: (enabled: Record<string, boolean>) => void;
56
+ /** What macOS lets the app read and control. Defaults to `[]`. */
57
+ permissions?: SettingsPermission2[];
58
+ /** Called by Open Settings on a permission that isn't granted. */
59
+ onOpenPermission?: (id: string) => void;
60
+ /** The About page's rows: version, mode, screen. Defaults to `[]`. */
61
+ about?: AboutRow2[];
62
+ /** Classes for the window's content, which fills its container. */
63
+ className?: string;
64
+ }
65
+ type Element_12xgc = JSX_1kxb["Element"];
66
+ /**
67
+ * A notch app's settings window: General, Plugins, Permissions and About,
68
+ * and a page for each plugin's own settings.
69
+ *
70
+ * A modo-ui Sidebar pinned open (the window is small, about 760 × 520, so
71
+ * it never folds into a drawer) lists the pages under the app's `name`, then
72
+ * the plugins that bring settings. General holds the launch at login Switch
73
+ * and a ChoiceList of the screens the island shows on. Plugins lists each
74
+ * installed plugin with its glyph, its line, a Switch that turns it on or
75
+ * off and, for one that brings settings, a chevron to its page. Permissions
76
+ * shows what macOS granted as a StatusDot per row, with Open Settings beside
77
+ * one that isn't granted, and a spinner while it's being read. About lists the `about` rows. A plugin's page shows its
78
+ * `settings` node under its name.
79
+ *
80
+ * The page, the preferences and the plugins' states each run both ways
81
+ * (`value`, `preferences`, `enabled` with their `default*` and `on*Change`),
82
+ * so the window works on its own or on a host's store. It fills its
83
+ * container; the window's frame and title bar are the host's.
84
+ *
85
+ * @example {@include ./examples.mdx}
86
+ */
87
+ declare function SettingsWindow2({ name, value, defaultValue, onValueChange, preferences: preferencesProp, defaultPreferences, onPreferencesChange, plugins, enabled: enabledProp, defaultEnabled, onEnabledChange, permissions, onOpenPermission, about, className }: SettingsWindowProps2): Element_12xgc;
88
+ export { ScreensPreference2, AppPreferences2, SettingsPlugin2, SettingsPermission2, AboutRow2, SettingsWindowProps2, SettingsWindow2 };
@@ -0,0 +1,27 @@
1
+ // lib/motion.ts
2
+ import { spring, springEnter } from "@justanarthur/modo-ui/lib/springs";
3
+ var SIZE = { idle: 0, compact: 1, split: 1, flash: 2, expanded: 3 };
4
+ var TIER = {
5
+ idle: spring.moderate,
6
+ compact: spring.moderate,
7
+ split: spring.moderate,
8
+ flash: spring.slow,
9
+ expanded: spring.goo
10
+ };
11
+ function shapeTransition2(from, to) {
12
+ if (SIZE[to] >= SIZE[from])
13
+ return springEnter(TIER[to]);
14
+ return from === "expanded" ? spring.slow.exit : TIER[from].exit;
15
+ }
16
+ var bubbleTransition2 = (detaching) => detaching ? springEnter(spring.goo) : spring.goo.exit;
17
+ var contentShown2 = { opacity: 1, scale: 1, filter: "blur(0px)", transitionEnd: { filter: "none" } };
18
+ var contentHidden2 = { opacity: 0, scale: 0.94, filter: "blur(6px)" };
19
+ var contentEnter2 = {
20
+ type: "tween",
21
+ duration: spring.slow.duration,
22
+ ease: "easeOut",
23
+ delay: spring.fast.duration
24
+ };
25
+ var contentLeave2 = { type: "tween", ...spring.fast.exit, ease: "easeIn" };
26
+
27
+ export { shapeTransition2, bubbleTransition2, contentShown2, contentHidden2, contentEnter2, contentLeave2 };
@@ -0,0 +1,151 @@
1
+ import { JSX as JSX_1kxb } from "react";
2
+ type WeatherCondition2 = "clear" | "partly-cloudy" | "cloudy" | "fog" | "drizzle" | "rain" | "heavy-rain" | "sleet" | "snow" | "thunderstorm";
3
+ type WeatherUnit2 = "celsius" | "fahrenheit";
4
+ type WeatherAccess2 = "granted" | "undetermined" | "denied";
5
+ type WeatherStatus2 = "ready" | "loading" | "error" | "offline";
6
+ /** The weather now: Open-Meteo's `current` block. Temperatures in °C, wind in km/h. */
7
+ interface WeatherNow2 {
8
+ /** When it was read, in epoch ms: the "updated" line counts from it. */
9
+ time: number;
10
+ temperature: number;
11
+ /** How warm it feels, in °C: `apparent_temperature`. */
12
+ apparent?: number;
13
+ condition: WeatherCondition2;
14
+ /** Daylight, for the sun or the moon in the glyph: `is_day`. Defaults to `true`. */
15
+ isDay?: boolean;
16
+ /** Wind speed in km/h. */
17
+ wind?: number;
18
+ /** Relative humidity, 0–100. */
19
+ humidity?: number;
20
+ /** The UV index. */
21
+ uv?: number;
22
+ }
23
+ /** One hour of the forecast: Open-Meteo's `hourly` arrays, zipped. */
24
+ interface WeatherHour2 {
25
+ /** The hour's start, in epoch ms. */
26
+ time: number;
27
+ temperature: number;
28
+ condition: WeatherCondition2;
29
+ /** Defaults to `true`. */
30
+ isDay?: boolean;
31
+ /** The chance of rain or snow, 0–100: `precipitation_probability`. */
32
+ precipitation?: number;
33
+ }
34
+ /** One day of the forecast: Open-Meteo's `daily` arrays, zipped. */
35
+ interface WeatherDay2 {
36
+ /** The day's start, in epoch ms. */
37
+ date: number;
38
+ condition: WeatherCondition2;
39
+ high: number;
40
+ low: number;
41
+ /** The day's highest chance of rain or snow, 0–100: `precipitation_probability_max`. */
42
+ precipitation?: number;
43
+ }
44
+ interface WeatherProps2 {
45
+ /** Where the forecast is for: a city's name. */
46
+ location?: string;
47
+ /** The weather now; without it the widget shows its state (`status`, `access`) or loads. */
48
+ current?: WeatherNow2 | null;
49
+ /** The hourly forecast, in any order: the hours from now on fill the strip. */
50
+ hours?: WeatherHour2[];
51
+ /** The daily forecast, today first: today gives the high and low, the next day the Tomorrow row. */
52
+ days?: WeatherDay2[];
53
+ /** Shows temperatures in this unit (and wind in mph for `'fahrenheit'`); the data stays in °C and km/h. Defaults to `'celsius'`. */
54
+ unit?: WeatherUnit2;
55
+ /** Whether the location may be read: undetermined asks, denied points to the system's settings. Defaults to `'granted'`. */
56
+ access?: WeatherAccess2;
57
+ /** How the last fetch went. `loading` shows placeholders until there is a `current`; `error` and `offline` keep the last forecast up and say so, or explain without one. Defaults to `'ready'`. */
58
+ status?: WeatherStatus2;
59
+ /** The moment the forecast is read at, in epoch ms. Defaults to now, re-read on each minute. */
60
+ now?: number;
61
+ /** Formats the hours. Defaults to the browser's locale. */
62
+ locale?: Intl.LocalesArgument;
63
+ /** Called by the refresh button, and by Try again after an error; without it neither shows. */
64
+ onRefresh?: () => void;
65
+ /** Called by Allow location while access is undetermined. */
66
+ onRequestAccess?: () => void;
67
+ /** Called by Open System Settings while access is denied. */
68
+ onOpenSettings?: () => void;
69
+ /** Classes for the root, which fills its container. */
70
+ className?: string;
71
+ }
72
+ /**
73
+ * Open-Meteo's `weather_code` (WMO 4677) as a condition.
74
+ *
75
+ * @example conditionFromCode(61) // 'rain'
76
+ */
77
+ declare function conditionFromCode2(code: number): WeatherCondition2;
78
+ interface PartProps {
79
+ /** The weather now. */
80
+ current: WeatherNow2;
81
+ }
82
+ type Element_12xgc = JSX_1kxb["Element"];
83
+ /** The compact island's left wing: the condition's glyph in its hue. */
84
+ declare function WeatherLeading2({ current }: PartProps): Element_12xgc;
85
+ /** The compact island's right wing: the temperature. */
86
+ declare function WeatherTrailing2({ current, unit }: PartProps & {
87
+ unit?: WeatherUnit2;
88
+ }): Element_12xgc;
89
+ /** The split island's bubble: the condition's glyph on a disc. */
90
+ declare function WeatherMinimal2({ current }: PartProps): Element_12xgc;
91
+ type WeatherAlertSeverity2 = "notice" | "warning" | "severe";
92
+ interface WeatherAlertProps2 {
93
+ /** What is coming: its glyph, and the title's noun. */
94
+ condition: WeatherCondition2;
95
+ /** When it starts, in epoch ms: the title counts down to it, `Rain in 15 min`, on each minute. */
96
+ startsAt?: number;
97
+ /** The title in place of the countdown, for a warning: `Thunderstorm warning`. */
98
+ title?: string;
99
+ /** One line more: how long, how much. */
100
+ caption?: string;
101
+ /** How serious: the tile's hue, info, warning or error. Defaults to `'notice'`. */
102
+ severity?: WeatherAlertSeverity2;
103
+ /** The button's label. Defaults to `'Details'`. */
104
+ actionLabel?: string;
105
+ /** Called by the button; without it the button hides. */
106
+ onAction?: () => void;
107
+ }
108
+ /** The island's flash before the weather turns: `Rain in 15 min`, or a warning, with one action. */
109
+ declare function WeatherAlert2({ condition, startsAt, title, caption, severity, actionLabel, onAction }: WeatherAlertProps2): Element_12xgc;
110
+ /**
111
+ * A notch app's weather: the temperature now as the hero, the next hours
112
+ * and tomorrow beside it.
113
+ *
114
+ * The hero is the temperature in display type after the condition's glyph,
115
+ * in its hue (the sun's amber, rain's blue, the rest plain); under it the
116
+ * condition, how warm it feels and, when the next hours turn wet, around
117
+ * when. The meta line carries today's high and low, the chance of rain,
118
+ * the wind, and the humidity and UV index when given, the last giving way
119
+ * first. The header names the place and how long ago the forecast was
120
+ * read, with a refresh button when `onRefresh` is given. Beside it, past a
121
+ * hairline, the next six hours as a strip of hour, glyph and temperature,
122
+ * with the chance of rain under each once any hour is wet, then tomorrow as
123
+ * a row.
124
+ *
125
+ * The data is Open-Meteo's shape, zipped into objects: `current`, `hours`
126
+ * and `days` (today first), in °C and km/h; `unit="fahrenheit"` converts
127
+ * what it shows, wind in mph. `conditionFromCode` turns a WMO weather code
128
+ * into a condition.
129
+ *
130
+ * Before the location may be read it asks for it (`access="undetermined"`),
131
+ * and when access is off it says where to turn it on (`"denied"`). The
132
+ * first fetch shows placeholders (`status="loading"`); a failed one says so
133
+ * with Try again (`"error"`), and offline it says it will update when back
134
+ * (`"offline"`). Once there is a forecast, those keep it up and say so in
135
+ * the header instead.
136
+ *
137
+ * The other forms are parts: `Weather.Leading` and `Weather.Trailing` for
138
+ * the compact island's wings (the glyph and the temperature),
139
+ * `Weather.Minimal`, the glyph on a disc, for the split island's bubble,
140
+ * and `Weather.Alert`, the flash before rain or a warning. Nothing ticks but
141
+ * the minute of the "updated" line.
142
+ *
143
+ * @example {@include ./examples.mdx}
144
+ */
145
+ declare const Weather2: (({ location, current, hours, days, unit, access, status, now: nowProp, locale, onRefresh, onRequestAccess, onOpenSettings, className }: WeatherProps2) => Element_12xgc) & {
146
+ Leading: typeof WeatherLeading2;
147
+ Trailing: typeof WeatherTrailing2;
148
+ Minimal: typeof WeatherMinimal2;
149
+ Alert: typeof WeatherAlert2;
150
+ };
151
+ export { WeatherCondition2, WeatherUnit2, WeatherAccess2, WeatherStatus2, WeatherNow2, WeatherHour2, WeatherDay2, WeatherProps2, conditionFromCode2, WeatherLeading2, WeatherTrailing2, WeatherMinimal2, WeatherAlertSeverity2, WeatherAlertProps2, WeatherAlert2, Weather2 };
@@ -0,0 +1,175 @@
1
+ import { IconComponent } from "@justanarthur/modo-ui/lib/icon-context";
2
+ import { SizeVariant } from "@justanarthur/modo-ui/lib/size-context";
3
+ import { LucideIcon } from "lucide-react";
4
+ import { ReactNode } from "react";
5
+ import { JSX as JSX_1kxb } from "react";
6
+ interface WidgetHeaderProps2 {
7
+ /** The glyph before the label: the source app, the widget's kind. */
8
+ icon?: IconComponent;
9
+ /** The context: where it comes from, which day it is. */
10
+ children: ReactNode;
11
+ /** Quiet actions at the end of the line, such as `Widget.Action`s. */
12
+ trailing?: ReactNode;
13
+ /** Classes for the row. */
14
+ className?: string;
15
+ }
16
+ type Element_12xgc = JSX_1kxb["Element"];
17
+ /** The context line at the top of a widget: a glyph, where it comes from, and quiet actions at the end. */
18
+ declare function WidgetHeader2({ icon: Icon, children, trailing, className }: WidgetHeaderProps2): Element_12xgc;
19
+ interface WidgetTitleProps2 {
20
+ /** The hero's name: a track, an event. */
21
+ children: ReactNode;
22
+ /** A mark before it, such as a calendar's color dot. */
23
+ leading?: ReactNode;
24
+ /** Classes for the row. */
25
+ className?: string;
26
+ }
27
+ /** The hero's name, on the title role: one line, truncating. */
28
+ declare function WidgetTitle2({ children, leading, className }: WidgetTitleProps2): Element_12xgc;
29
+ /** The line under the title: who, where, what else; muted, one line. */
30
+ declare function WidgetSubtitle2({ children, className }: {
31
+ children: ReactNode;
32
+ className?: string;
33
+ }): Element_12xgc;
34
+ interface WidgetFigureProps2 {
35
+ /** The number, or the one word that stands for it (`Now`). */
36
+ value: ReactNode;
37
+ /** The unit after it, set smaller and muted: `min`, `%`. */
38
+ unit?: ReactNode;
39
+ /** A word before it, set like the unit: `in`. */
40
+ prefix?: ReactNode;
41
+ /** A data color for the value (a calendar's, an artwork's); without one it is the text color. */
42
+ color?: string;
43
+ /** Classes for the row. */
44
+ className?: string;
45
+ }
46
+ /** A widget's hero number on the display role, its unit beside it on the title role, digits tabular. */
47
+ declare function WidgetFigure2({ value, unit, prefix, color, className }: WidgetFigureProps2): Element_12xgc;
48
+ interface WidgetMetaItemProps2 {
49
+ /** The glyph before it: a clock, a pin, a speaker. */
50
+ icon?: IconComponent;
51
+ /** The fact. */
52
+ children: ReactNode;
53
+ }
54
+ /** One fact of a meta row: a glyph and a few words. */
55
+ declare function WidgetMetaItem2({ icon: Icon, children }: WidgetMetaItemProps2): Element_12xgc;
56
+ /** Supporting facts in a row, each a glyph and a few words, muted; the last one gives way first. */
57
+ declare function WidgetMeta2({ children, className }: {
58
+ children: ReactNode;
59
+ className?: string;
60
+ }): Element_12xgc;
61
+ interface WidgetActionProps2 {
62
+ /** The glyph: a Lucide icon, or any component taking its props. */
63
+ icon: LucideIcon;
64
+ /** What it does: the accessible name and the tooltip. */
65
+ label: string;
66
+ /** Called on press. */
67
+ onClick?: () => void;
68
+ /** A toggle that is on (shuffle, a like): the glyph in the text color, `aria-pressed`. Leave it out for a plain action. */
69
+ pressed?: boolean;
70
+ /** `primary` is the widget's main action (play / pause): a larger glyph in the text color. Defaults to `'default'`. */
71
+ emphasis?: "default" | "primary";
72
+ /** Fills the glyph, for solid transport glyphs. Defaults to `false`. */
73
+ filled?: boolean;
74
+ /** A data color for the glyph while pressed (the artwork's tint). */
75
+ color?: string;
76
+ /** No press. Defaults to `false`. */
77
+ disabled?: boolean;
78
+ }
79
+ /** A quiet icon button with a tooltip: muted at rest, the text color on hover and while pressed. */
80
+ declare function WidgetAction2({ icon: Icon, label, onClick, pressed, emphasis, filled, color, disabled }: WidgetActionProps2): Element_12xgc;
81
+ interface WidgetMessageProps2 {
82
+ /** The glyph in the tile. */
83
+ icon: IconComponent;
84
+ /** What's going on, in a few words. */
85
+ title: ReactNode;
86
+ /** What to do about it. */
87
+ description?: ReactNode;
88
+ /** The way forward: a Button or two. */
89
+ actions?: ReactNode;
90
+ /** Classes for the root, which fills the widget. */
91
+ className?: string;
92
+ }
93
+ /** A widget's empty, permission or error state, laid out across the wide, short island: tile, text, then the action. */
94
+ declare function WidgetMessage2({ icon: Icon, title, description, actions, className }: WidgetMessageProps2): Element_12xgc;
95
+ interface WidgetSectionProps2 {
96
+ /** The group's name: `Later today`, `Tomorrow`. */
97
+ label: ReactNode;
98
+ /** Content at the end of the label's line: chips, a count, a fold toggle. */
99
+ trailing?: ReactNode;
100
+ /** The rows. */
101
+ children?: ReactNode;
102
+ /** Classes for the section. */
103
+ className?: string;
104
+ }
105
+ /** A group of rows under a muted caption, the way a list's section reads. */
106
+ declare function WidgetSection2({ label, trailing, children, className }: WidgetSectionProps2): Element_12xgc;
107
+ interface WidgetRowProps2 {
108
+ /** The figure at the start, muted and tabular: a time. */
109
+ leading?: ReactNode;
110
+ /** A data color for the mark between the figure and the title: a calendar's. */
111
+ color?: string;
112
+ /** The row's text. */
113
+ children: ReactNode;
114
+ /** Muted content at the end: a glyph, a place. */
115
+ trailing?: ReactNode;
116
+ /** Classes for the row. */
117
+ className?: string;
118
+ }
119
+ /** A list row for the island: a muted figure, a color mark, the title, and a muted end; the compact control height. */
120
+ declare function WidgetRow2({ leading, color, children, trailing, className }: WidgetRowProps2): Element_12xgc;
121
+ interface WidgetChipProps2 {
122
+ /** A data color for its dot. */
123
+ color?: string;
124
+ /** The chip's text. */
125
+ children: ReactNode;
126
+ }
127
+ /** A small label on a wash one surface up: an all-day event, a state. */
128
+ declare function WidgetChip2({ color, children }: WidgetChipProps2): Element_12xgc;
129
+ interface WidgetProps2 {
130
+ /** The hero's picture at the start, as tall as the widget: artwork, a ring. */
131
+ media?: ReactNode;
132
+ /** The supporting column at the end, past a hairline: a list, a timeline. It folds away when the widget is narrow. */
133
+ aside?: ReactNode;
134
+ /** The main column: header, hero, meta, actions. */
135
+ children: ReactNode;
136
+ /** Step on the size ladder for every part inside. Omitted, the widget follows the surrounding SizeProvider. */
137
+ size?: SizeVariant;
138
+ /** Classes for the root, which fills the island's content area. */
139
+ className?: string;
140
+ }
141
+ /**
142
+ * The frame every open-island widget is built in: the hero's picture, the
143
+ * main column, and a supporting column past a hairline.
144
+ *
145
+ * One hero per widget, set large: a name on the title role
146
+ * (`Widget.Title`) or a number on the display role (`Widget.Figure`), then
147
+ * one muted line (`Widget.Subtitle`), then the supporting facts as glyph and
148
+ * words (`Widget.Meta`). Context goes on the line above (`Widget.Header`),
149
+ * actions are quiet icon buttons with tooltips (`Widget.Action`), and lists
150
+ * are rows of a muted figure, a color mark and a title (`Widget.Row` under
151
+ * a `Widget.Section`). Color comes from the content (an artwork's tint, a
152
+ * calendar's color, a status hue), never from decoration; depth from one
153
+ * surface step (`Widget.Chip`, `Widget.Message`'s tile), never from boxes.
154
+ * Empty and permission states are a `Widget.Message`, laid out across the
155
+ * wide, short island.
156
+ *
157
+ * The frame fills the island's content area. The aside folds away under
158
+ * 30rem of width, so a narrower panel keeps the hero.
159
+ *
160
+ * @example {@include ./examples.mdx}
161
+ */
162
+ declare const Widget2: (({ media, aside, children, size, className }: WidgetProps2) => Element_12xgc) & {
163
+ Header: typeof WidgetHeader2;
164
+ Title: typeof WidgetTitle2;
165
+ Subtitle: typeof WidgetSubtitle2;
166
+ Figure: typeof WidgetFigure2;
167
+ Meta: typeof WidgetMeta2;
168
+ MetaItem: typeof WidgetMetaItem2;
169
+ Action: typeof WidgetAction2;
170
+ Message: typeof WidgetMessage2;
171
+ Section: typeof WidgetSection2;
172
+ Row: typeof WidgetRow2;
173
+ Chip: typeof WidgetChip2;
174
+ };
175
+ export { WidgetHeaderProps2, WidgetHeader2, WidgetTitleProps2, WidgetTitle2, WidgetSubtitle2, WidgetFigureProps2, WidgetFigure2, WidgetMetaItemProps2, WidgetMetaItem2, WidgetMeta2, WidgetActionProps2, WidgetAction2, WidgetMessageProps2, WidgetMessage2, WidgetSectionProps2, WidgetSection2, WidgetRowProps2, WidgetRow2, WidgetChipProps2, WidgetChip2, WidgetProps2, Widget2 };
@@ -0,0 +1,54 @@
1
+ "use client";
2
+
3
+ import {
4
+ SECOND2,
5
+ MINUTE2,
6
+ formatClock2,
7
+ formatShort2,
8
+ useEdgeClock2
9
+ } from "./chunk-gb56m10p.js";
10
+
11
+ // components/indicators/countdown/index.tsx
12
+ import { cn } from "@justanarthur/modo-ui/lib/utils";
13
+ import { useEffect, useMemo, useRef, useState } from "react";
14
+ import { jsx } from "react/jsx-runtime";
15
+ /*!
16
+ * Local addition: the time left on a notch app's timer, as text that ticks
17
+ * only on second edges. Rebuilt from Just Notch's timer plugin (`Countdown`,
18
+ * `useRemaining`).
19
+ */
20
+ function Countdown2({
21
+ endsAt,
22
+ duration = 0,
23
+ paused = false,
24
+ remaining,
25
+ format = "clock",
26
+ onEnd,
27
+ className
28
+ }) {
29
+ const [mounted] = useState(Date.now);
30
+ const end = endsAt ?? mounted + duration;
31
+ const [coarse, setCoarse] = useState(format === "short" && end - Date.now() > MINUTE2);
32
+ const now = useEdgeClock2(end, !paused && Date.now() < end + SECOND2, coarse ? MINUTE2 : SECOND2);
33
+ const pausedLeft = useMemo(() => end - Date.now(), [paused, end]);
34
+ const left = Math.max(0, paused ? remaining ?? pausedLeft : end - now);
35
+ useEffect(() => setCoarse(format === "short" && left > MINUTE2), [format, left]);
36
+ const ended = useRef(false);
37
+ useEffect(() => {
38
+ if (left > 0 || paused) {
39
+ ended.current = false;
40
+ return;
41
+ }
42
+ if (ended.current)
43
+ return;
44
+ ended.current = true;
45
+ onEnd?.();
46
+ }, [left, paused, onEnd]);
47
+ const seconds = left / SECOND2;
48
+ return /* @__PURE__ */ jsx("span", {
49
+ role: "timer",
50
+ className: cn("tabular-nums", className),
51
+ children: format === "short" ? formatShort2(seconds) : formatClock2(Math.ceil(seconds))
52
+ });
53
+ }
54
+ export { Countdown2 };
@@ -0,0 +1,12 @@
1
+ import { IslandState2, IslandGeometry2, Shape2 } from "./chunk-cfzmfnyh.js";
2
+ import { Context as Context_rri5bl } from "react";
3
+ interface IslandContextValue2 {
4
+ state: IslandState2;
5
+ geometry: IslandGeometry2;
6
+ /** The outline of `state`, fitted to the room the island has. */
7
+ shape: Shape2;
8
+ }
9
+ declare const IslandContext2: Context_rri5bl<IslandContextValue2 | null>;
10
+ /** The enclosing Island's state and geometry, or `null` outside one. */
11
+ declare function useIsland2(): IslandContextValue2 | null;
12
+ export { IslandContextValue2, IslandContext2, useIsland2 };
@@ -0,0 +1,33 @@
1
+ import { JSX as JSX_1kxb } from "react";
2
+ type CountdownFormat2 = "clock" | "short";
3
+ interface CountdownProps2 {
4
+ /** When it ends, in epoch ms. */
5
+ endsAt?: number;
6
+ /** How long it runs from when it mounts, in ms, when there is no `endsAt`. Defaults to `0`. */
7
+ duration?: number;
8
+ /** Stop the clock: it holds the time left when it paused, or `remaining`. Defaults to `false`. */
9
+ paused?: boolean;
10
+ /** The time left to show while paused, in ms. */
11
+ remaining?: number;
12
+ /** `clock` is `4:05`; `short` is the largest unit, rounded up: `4m`, then `45s` in the last minute. Defaults to `'clock'`. */
13
+ format?: CountdownFormat2;
14
+ /** Called once when it reaches zero. */
15
+ onEnd?: () => void;
16
+ /** Classes for the text, such as its role and weight. */
17
+ className?: string;
18
+ }
19
+ type Element_12xgc = JSX_1kxb["Element"];
20
+ /**
21
+ * The time left, as text: `4:05`, or `4m` where room is short (a compact
22
+ * wing).
23
+ *
24
+ * It re-renders once per shown unit, on the unit's edge counted from the end,
25
+ * never in between: a second for the clock, a minute for the short form until
26
+ * its last minute. So a running timer costs one render a second at most, and
27
+ * the digits change exactly when a second has passed. Digits are tabular, so
28
+ * the text holds its width as it ticks. Paused, it holds the time left.
29
+ *
30
+ * @example {@include ./examples.mdx}
31
+ */
32
+ declare function Countdown2({ endsAt, duration, paused, remaining, format, onEnd, className }: CountdownProps2): Element_12xgc;
33
+ export { CountdownFormat2, CountdownProps2, Countdown2 };
@@ -0,0 +1,63 @@
1
+ // lib/geometry.ts
2
+ var ISLAND_STATES2 = ["idle", "compact", "split", "expanded", "flash"];
3
+ var DEFAULT_NOTCH2 = { width: 185, height: 32 };
4
+ var DEFAULT_PANEL2 = { width: 720, height: 240 };
5
+ var INSET2 = 20;
6
+ var NOTCH_GAP2 = 8;
7
+ var FLASH_REACH = 64;
8
+ var FLASH_DROP = 48;
9
+ var slotWidth2 = (notch) => notch.height + 8;
10
+ function shapeFor2(state, { notch, panel }, room = Number.POSITIVE_INFINITY) {
11
+ const slot = slotWidth2(notch);
12
+ if (state === "idle")
13
+ return { w: notch.width, h: notch.height, radius: 10, shoulder: 6 };
14
+ if (state === "compact" || state === "split")
15
+ return { w: notch.width + 2 * slot, h: notch.height, radius: 13, shoulder: 8 };
16
+ if (state === "flash")
17
+ return {
18
+ w: Math.min(notch.width + 2 * (slot + FLASH_REACH), room - 20),
19
+ h: notch.height + FLASH_DROP,
20
+ radius: 24,
21
+ shoulder: 10
22
+ };
23
+ return { w: Math.max(notch.width, Math.min(panel.width, room - 28)), h: panel.height, radius: 32, shoulder: 14 };
24
+ }
25
+ function bubbleFor2(shape, notch, detached) {
26
+ const r = notch.height / 2 - 1;
27
+ return detached ? { x: shape.w / 2 + shape.shoulder + 14 + r, r } : { x: shape.w / 2 - r, r: r * 0.5 };
28
+ }
29
+ var CIRCLE = 0.5523;
30
+ var SMOOTH_SPAN = 1.28;
31
+ var SMOOTH_HANDLE = 0.64;
32
+ function islandPath2(cx, { w, h, radius, shoulder }) {
33
+ const s = Math.max(0, Math.min(shoulder, h / 2));
34
+ const span = Math.max(0, Math.min(radius * SMOOTH_SPAN, h - s, w / 2));
35
+ const k = span * (1 - SMOOTH_HANDLE);
36
+ const q = s * (1 - CIRCLE);
37
+ const l = cx - w / 2;
38
+ const r = cx + w / 2;
39
+ return [
40
+ `M${l - s} -1`,
41
+ `L${l - s} 0`,
42
+ `C${l - q} 0 ${l} ${q} ${l} ${s}`,
43
+ `L${l} ${h - span}`,
44
+ `C${l} ${h - k} ${l + k} ${h} ${l + span} ${h}`,
45
+ `L${r - span} ${h}`,
46
+ `C${r - k} ${h} ${r} ${h - k} ${r} ${h - span}`,
47
+ `L${r} ${s}`,
48
+ `C${r} ${q} ${r + q} 0 ${r + s} 0`,
49
+ `L${r + s} -1`,
50
+ "Z"
51
+ ].join("");
52
+ }
53
+ function stripLayout2(count, width, notchWidth, tab, reserve = 0) {
54
+ const left = Math.max(0, (width - notchWidth) / 2 - NOTCH_GAP2);
55
+ const leftCap = Math.floor(left / tab);
56
+ const rightCap = Math.max(0, Math.floor((left - reserve) / tab));
57
+ const overflow = count > leftCap + rightCap;
58
+ const before = overflow ? leftCap : Math.min(leftCap, Math.max(Math.ceil(count / 2), count - rightCap));
59
+ const hole = { start: left, end: width - left };
60
+ return { before, overflow, hole, spacer: hole.end - before * tab };
61
+ }
62
+
63
+ export { ISLAND_STATES2, DEFAULT_NOTCH2, DEFAULT_PANEL2, INSET2, NOTCH_GAP2, slotWidth2, shapeFor2, bubbleFor2, islandPath2, stripLayout2 };