@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,105 @@
1
+ import { SizeVariant } from "@justanarthur/modo-ui/lib/size-context";
2
+ import { JSX as JSX_1kxb } from "react";
3
+ /** One reading of the system. */
4
+ interface StatsSample2 {
5
+ /** CPU load, from 0 to 1. */
6
+ cpu: number;
7
+ /** Memory in use, in bytes. */
8
+ memoryUsed: number;
9
+ /** All the memory, in bytes. */
10
+ memoryTotal: number;
11
+ /** Memory pressure, from 0 to 1, as the system judges it; without it the share in use stands in. */
12
+ memoryPressure?: number;
13
+ /** Network in, in bytes per second. */
14
+ netIn: number;
15
+ /** Network out, in bytes per second. */
16
+ netOut: number;
17
+ }
18
+ interface StatsBattery2 {
19
+ /** The charge, in percent (0 to 100). */
20
+ level: number;
21
+ /** A charger is connected. */
22
+ charging?: boolean;
23
+ /** Minutes until full while charging, else until empty. */
24
+ minutesLeft?: number;
25
+ }
26
+ interface StatsDisk2 {
27
+ /** Free space on the startup disk, in bytes. */
28
+ free: number;
29
+ /** The disk's size, in bytes. */
30
+ total: number;
31
+ }
32
+ interface StatsProcess2 {
33
+ /** What tells it apart: its pid. */
34
+ id: string;
35
+ /** The app or process name. */
36
+ name: string;
37
+ /** Its share of the CPU, from 0 to 1. */
38
+ cpu: number;
39
+ /** The memory it holds, in bytes. */
40
+ memory?: number;
41
+ }
42
+ type StatsHero2 = "cpu" | "memory";
43
+ interface SystemStatsProps2 {
44
+ /** The readings so far, oldest first; the latest is the figure, all of them the trend. Without any, it is still measuring. */
45
+ samples: StatsSample2[];
46
+ /** Which figure is the hero: the CPU load, or memory pressure when memory is what's tight. Defaults to `'cpu'`. */
47
+ hero?: StatsHero2;
48
+ /** The battery, on a laptop. */
49
+ battery?: StatsBattery2;
50
+ /** The startup disk's free space. */
51
+ disk?: StatsDisk2;
52
+ /** Seconds since the last boot. */
53
+ uptime?: number;
54
+ /** The busiest processes, in any order: the top three list beside the hero, by CPU. */
55
+ processes?: StatsProcess2[];
56
+ /** Step on the size ladder. Omitted, it follows the surrounding SizeProvider. */
57
+ size?: SizeVariant;
58
+ /** Classes for the root, which fills its container. */
59
+ className?: string;
60
+ }
61
+ type Element_12xgc = JSX_1kxb["Element"];
62
+ /** The compact island's left wing: the CPU glyph. */
63
+ declare function SystemStatsLeading2(): Element_12xgc;
64
+ /** The compact island's right wing: the CPU load, a dash until the first reading. */
65
+ declare function SystemStatsTrailing2({ sample }: {
66
+ sample?: StatsSample2;
67
+ }): Element_12xgc;
68
+ /** The split island's bubble: the CPU load as a ring, in the warning hue from 75% and the error hue from 90%. */
69
+ declare function SystemStatsMinimal2({ sample }: {
70
+ sample?: StatsSample2;
71
+ }): Element_12xgc;
72
+ /**
73
+ * A notch app's system load: the busiest figure as the hero with its trend,
74
+ * the rest as facts, and the processes behind it.
75
+ *
76
+ * The hero is the CPU load, set large, with every reading so far as a
77
+ * modo-ui Sparkline beside it (it spans the width however many readings
78
+ * there are: the island stays open for seconds, too short to fill a fixed
79
+ * window). The line turns to the warning hue from 75% and the error hue
80
+ * from 90%, so the color comes from the load. When memory is what's tight,
81
+ * `hero="memory"` makes memory pressure the figure and its trend instead.
82
+ * Under it one word for how the machine is doing and who's busiest, then
83
+ * the facts: memory in use of all of it (or the CPU), the network's in and
84
+ * out rates, and, when given, the battery with its time left and the
85
+ * startup disk's free space. The uptime sits on the context line.
86
+ *
87
+ * Beside it, past a hairline, the busiest processes by CPU with the memory
88
+ * they hold, three at most and a count of the rest.
89
+ *
90
+ * CPU and network are rates between two readings, so before the first one
91
+ * lands (about a second after opening) the figures are dashes over the
92
+ * Sparkline's baseline.
93
+ *
94
+ * `SystemStats.Leading` and `SystemStats.Trailing` show the CPU load in the
95
+ * compact island's wings, `SystemStats.Minimal` as a ring in the split
96
+ * island's bubble.
97
+ *
98
+ * @example {@include ./examples.mdx}
99
+ */
100
+ declare const SystemStats2: (({ samples, hero, battery, disk, uptime, processes, size, className }: SystemStatsProps2) => Element_12xgc) & {
101
+ Leading: typeof SystemStatsLeading2;
102
+ Trailing: typeof SystemStatsTrailing2;
103
+ Minimal: typeof SystemStatsMinimal2;
104
+ };
105
+ export { StatsSample2, StatsBattery2, StatsDisk2, StatsProcess2, StatsHero2, SystemStatsProps2, SystemStatsLeading2, SystemStatsTrailing2, SystemStatsMinimal2, SystemStats2 };
@@ -0,0 +1,75 @@
1
+ import { IslandState2 } from "./chunk-cfzmfnyh.js";
2
+ import { ReactNode } from "react";
3
+ import { JSX as JSX_1kxb } from "react";
4
+ type CollapsedState2 = "idle" | "compact" | "split";
5
+ interface IslandProps2 {
6
+ /** What it shows (controlled). */
7
+ state?: IslandState2;
8
+ /** What it shows at first (uncontrolled). Defaults to `'idle'`. */
9
+ defaultState?: IslandState2;
10
+ /** Called with the state a press, a hover or Escape asks for. */
11
+ onStateChange?: (state: IslandState2) => void;
12
+ /** Where Escape and leaving the open island go back to. Defaults to the last of `idle`, `compact` or `split` it showed. */
13
+ collapsedState?: CollapsedState2;
14
+ /** Opens after a short hover and closes a moment after the pointer leaves. Defaults to `false`. */
15
+ expandOnHover?: boolean;
16
+ /** The hardware notch's width in px. Defaults to `185`. */
17
+ notchWidth?: number;
18
+ /** The notch's height in px: the compact island's and the menu bar's. Defaults to `32`. */
19
+ notchHeight?: number;
20
+ /** The open island's width in px; it shrinks to the room it has. Defaults to `720`. */
21
+ panelWidth?: number;
22
+ /** The open island's height in px. Defaults to `240`. */
23
+ panelHeight?: number;
24
+ /** The compact left wing: the activity's glyph (`compact` and `split`). */
25
+ leading?: ReactNode;
26
+ /** The compact right wing: its live value (`compact` and `split`). */
27
+ trailing?: ReactNode;
28
+ /** The second activity, in the bubble that melts off the island's right end (`split`). */
29
+ minimal?: ReactNode;
30
+ /** The open island's content, from its top edge: leave the notch's height free for tabs (`expanded`). */
31
+ expanded?: ReactNode;
32
+ /** The alert below the notch (`flash`), such as an IslandFlash. */
33
+ flash?: ReactNode;
34
+ /** Names what the wings or the flash show; a new one swaps them with the blur, so one alert replacing another reads as new. Defaults to the state. */
35
+ activity?: string;
36
+ /** The accessible name of the press that opens it. Defaults to `'Open the island'`. */
37
+ label?: string;
38
+ /** Classes for the root, which spans its container's width. */
39
+ className?: string;
40
+ }
41
+ type Element_12xgc = JSX_1kxb["Element"];
42
+ /**
43
+ * The island of a notch app: one black outline that hangs from the top edge,
44
+ * flows into it through concave shoulders and grows out of the hardware notch
45
+ * as its activities need room.
46
+ *
47
+ * Five states. `idle` is the bare notch. `compact` widens into two wings for
48
+ * an activity's `leading` glyph and `trailing` value. `split` keeps them and
49
+ * melts a second activity's `minimal` bubble off the right end through
50
+ * modo-ui's goo. `flash` drops below the notch for a moment's alert, and
51
+ * `expanded` opens the panel, whose `expanded` content starts at the top
52
+ * edge: leave the notch's height for an IslandTabs strip.
53
+ *
54
+ * The outline is one SVG path on motion values, so a change of state animates
55
+ * without layout: growing on the target state's spring tier, shrinking on the
56
+ * source's exit tween. The content swaps the way Apple's island does, the
57
+ * leaving content blurring out as the arriving one sharpens and grows in;
58
+ * under reduced motion the shape jumps and the content only fades. At rest
59
+ * nothing is clipped or filtered: the clip runs only while the outline moves,
60
+ * the goo only while the bubble detaches or rejoins.
61
+ *
62
+ * It is always true black (`fill-ink`), the color of the notch it grows from,
63
+ * and its content takes modo-ui's dark scope one surface up, so a tile inside
64
+ * reads as raised. Content reads the island's state and geometry with
65
+ * `useIsland()`.
66
+ *
67
+ * A press on the island opens it (a press on a control inside it is the
68
+ * control's); Escape, and with `expandOnHover` the pointer leaving, closes it
69
+ * back to the state it came from. Controlled through `state` /
70
+ * `onStateChange`, or uncontrolled from `defaultState`.
71
+ *
72
+ * @example {@include ./examples.mdx}
73
+ */
74
+ declare function Island2({ state: stateProp, defaultState, onStateChange, collapsedState, expandOnHover, notchWidth, notchHeight, panelWidth, panelHeight, leading, trailing, minimal, expanded, flash, activity, label, className }: IslandProps2): Element_12xgc;
75
+ export { CollapsedState2, IslandProps2, Island2 };
@@ -0,0 +1,381 @@
1
+ "use client";
2
+
3
+ import {
4
+ IslandFlash2
5
+ } from "./chunk-ndf79pv5.js";
6
+ import {
7
+ widget_default
8
+ } from "./chunk-x7f3g82r.js";
9
+ import {
10
+ SECOND2,
11
+ MINUTE2,
12
+ formatShort2,
13
+ useEdgeClock2
14
+ } from "./chunk-gb56m10p.js";
15
+
16
+ // blocks/activities/agenda/index.tsx
17
+ import Button from "@justanarthur/modo-ui/components/actions/button";
18
+ import { useControllableState } from "@justanarthur/modo-ui/lib/use-controllable-state";
19
+ import { cn } from "@justanarthur/modo-ui/lib/utils";
20
+ import { CalendarCheck, CalendarDays, ChevronDown, ChevronUp, Clock, Lock, MapPin, Video } from "lucide-react";
21
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
22
+ /*!
23
+ * Local addition: a notch app's calendar, the next event and the rest of
24
+ * today and tomorrow, with the countdown to the next one. Rebuilt from Just
25
+ * Notch's calendar plugin (`Agenda`, `Upcoming`, `Starting`, `Ring`,
26
+ * `Countdown`) as presentational parts: events, access and actions come in
27
+ * as props.
28
+ */
29
+ var ROWS = 3;
30
+ var time = (ms, locale) => new Date(ms).toLocaleTimeString(locale, { hour: "numeric", minute: "2-digit" });
31
+ function timeParts(ms, locale) {
32
+ const parts = new Intl.DateTimeFormat(locale, { hour: "numeric", minute: "2-digit" }).formatToParts(ms);
33
+ const period = parts.find((part) => part.type === "dayPeriod")?.value;
34
+ const value = parts.filter((part) => part.type !== "dayPeriod").map((part) => part.value).join("").trim();
35
+ return { value, period };
36
+ }
37
+ var range = (event, locale) => `${time(event.start, locale)} – ${time(event.end, locale)}`;
38
+ function length(ms) {
39
+ const minutes = Math.round(ms / MINUTE2);
40
+ if (minutes < 60)
41
+ return `${minutes} min`;
42
+ const hours = Math.floor(minutes / 60);
43
+ return minutes % 60 ? `${hours} h ${minutes % 60} min` : `${hours} h`;
44
+ }
45
+ function useUntil(start, unit = MINUTE2) {
46
+ const now = useEdgeClock2(start, Date.now() < start + SECOND2, unit);
47
+ return start - now;
48
+ }
49
+ function Dot({ color, className }) {
50
+ return /* @__PURE__ */ jsx("span", {
51
+ "aria-hidden": true,
52
+ className: cn("size-2.5 shrink-0 rounded-full", className),
53
+ style: { backgroundColor: color }
54
+ });
55
+ }
56
+ function Join({
57
+ event,
58
+ size,
59
+ onJoin
60
+ }) {
61
+ return /* @__PURE__ */ jsx(Button, {
62
+ variant: "primary",
63
+ size,
64
+ leadingIcon: Video,
65
+ onClick: () => onJoin?.(event),
66
+ children: "Join"
67
+ });
68
+ }
69
+ function When({ event, now, midnight, locale }) {
70
+ if (event.start <= now)
71
+ return /* @__PURE__ */ jsx(widget_default.Figure, {
72
+ value: "Now",
73
+ unit: `${length(event.end - now)} left`
74
+ });
75
+ if (event.start - now < 60 * MINUTE2)
76
+ return /* @__PURE__ */ jsx(widget_default.Figure, {
77
+ prefix: "in",
78
+ value: Math.max(1, Math.ceil((event.start - now) / MINUTE2)),
79
+ unit: "min"
80
+ });
81
+ const { value, period } = timeParts(event.start, locale);
82
+ return /* @__PURE__ */ jsx(widget_default.Figure, {
83
+ prefix: event.start >= midnight ? "Tomorrow" : "at",
84
+ value,
85
+ unit: period
86
+ });
87
+ }
88
+ function Hero({ event, now, midnight, locale, onJoin }) {
89
+ return /* @__PURE__ */ jsxs("div", {
90
+ className: "flex min-w-0 flex-col gap-1.5",
91
+ children: [
92
+ /* @__PURE__ */ jsxs("div", {
93
+ className: "flex min-w-0 items-end justify-between gap-3",
94
+ children: [
95
+ /* @__PURE__ */ jsx(When, {
96
+ event,
97
+ now,
98
+ midnight,
99
+ locale
100
+ }),
101
+ event.meetingUrl && /* @__PURE__ */ jsx(Join, {
102
+ event,
103
+ size: "compact",
104
+ onJoin
105
+ })
106
+ ]
107
+ }),
108
+ /* @__PURE__ */ jsxs("div", {
109
+ className: "flex min-w-0 flex-col gap-0.5",
110
+ children: [
111
+ /* @__PURE__ */ jsx(widget_default.Title, {
112
+ leading: /* @__PURE__ */ jsx(Dot, {
113
+ color: event.color
114
+ }),
115
+ children: event.title
116
+ }),
117
+ /* @__PURE__ */ jsxs(widget_default.Meta, {
118
+ className: "pl-4.5",
119
+ children: [
120
+ /* @__PURE__ */ jsx(widget_default.MetaItem, {
121
+ icon: Clock,
122
+ children: range(event, locale)
123
+ }),
124
+ event.meetingUrl && /* @__PURE__ */ jsx(widget_default.MetaItem, {
125
+ icon: Video,
126
+ children: "Video call"
127
+ }),
128
+ event.location && /* @__PURE__ */ jsx(widget_default.MetaItem, {
129
+ icon: MapPin,
130
+ children: event.location
131
+ })
132
+ ]
133
+ })
134
+ ]
135
+ })
136
+ ]
137
+ });
138
+ }
139
+ function Rows({ events, locale }) {
140
+ return events.map((event) => /* @__PURE__ */ jsx(widget_default.Row, {
141
+ leading: time(event.start, locale),
142
+ color: event.color,
143
+ trailing: event.meetingUrl ? /* @__PURE__ */ jsx(Video, {
144
+ size: 12,
145
+ strokeWidth: 1.5,
146
+ "aria-label": "Video call"
147
+ }) : event.location && /* @__PURE__ */ jsx("span", {
148
+ className: "max-w-24 truncate",
149
+ children: event.location
150
+ }),
151
+ children: event.title
152
+ }, event.id));
153
+ }
154
+ function More({ count }) {
155
+ if (count <= 0)
156
+ return null;
157
+ return /* @__PURE__ */ jsxs("span", {
158
+ className: "flex h-6 items-center pl-17.5 text-caption text-muted-foreground",
159
+ children: [
160
+ count,
161
+ " more"
162
+ ]
163
+ });
164
+ }
165
+ function AgendaLeading2({ event }) {
166
+ return /* @__PURE__ */ jsx(CalendarDays, {
167
+ size: 16,
168
+ strokeWidth: 1.5,
169
+ style: { color: event.color }
170
+ });
171
+ }
172
+ function AgendaTrailing2({ event }) {
173
+ const left = useUntil(event.start);
174
+ return /* @__PURE__ */ jsxs("span", {
175
+ className: "flex items-center gap-1 text-caption weight-semibold text-foreground tabular-nums",
176
+ children: [
177
+ /* @__PURE__ */ jsx(Dot, {
178
+ color: event.color,
179
+ className: "size-1.5"
180
+ }),
181
+ left > 0 ? formatShort2(left / SECOND2) : "now"
182
+ ]
183
+ });
184
+ }
185
+ var RING = 2 * Math.PI * 8;
186
+ function AgendaMinimal2({ event, lead = 10 * MINUTE2 }) {
187
+ const left = Math.max(0, useUntil(event.start, SECOND2));
188
+ const share = Math.min(1, left / lead);
189
+ return /* @__PURE__ */ jsxs("svg", {
190
+ role: "img",
191
+ "aria-label": `${event.title}, in ${formatShort2(left / SECOND2)}`,
192
+ viewBox: "0 0 20 20",
193
+ className: "size-5.5 -rotate-90",
194
+ children: [
195
+ /* @__PURE__ */ jsx("circle", {
196
+ cx: "10",
197
+ cy: "10",
198
+ r: "8",
199
+ fill: "none",
200
+ strokeWidth: "2.5",
201
+ className: "stroke-current text-border"
202
+ }),
203
+ /* @__PURE__ */ jsx("circle", {
204
+ cx: "10",
205
+ cy: "10",
206
+ r: "8",
207
+ fill: "none",
208
+ strokeWidth: "2.5",
209
+ strokeLinecap: "round",
210
+ strokeDasharray: RING,
211
+ strokeDashoffset: RING * (1 - share),
212
+ style: { stroke: event.color }
213
+ })
214
+ ]
215
+ });
216
+ }
217
+ function AgendaUpNext2({ event, locale, onJoin }) {
218
+ const now = event.start - useUntil(event.start);
219
+ return /* @__PURE__ */ jsx(widget_default, {
220
+ children: /* @__PURE__ */ jsx(Hero, {
221
+ event,
222
+ now,
223
+ midnight: new Date(now).setHours(24, 0, 0, 0),
224
+ locale,
225
+ onJoin
226
+ })
227
+ });
228
+ }
229
+ function AgendaStarting2({ event, onJoin }) {
230
+ const left = useUntil(event.start, SECOND2);
231
+ const when = left > 0 ? `Starts in ${formatShort2(left / SECOND2)}` : "Starting now";
232
+ return /* @__PURE__ */ jsx(IslandFlash2, {
233
+ icon: /* @__PURE__ */ jsx("span", {
234
+ className: "flex size-9 items-center justify-center rounded-lg",
235
+ style: { color: event.color, backgroundColor: `color-mix(in oklab, ${event.color} 22%, transparent)` },
236
+ children: event.meetingUrl ? /* @__PURE__ */ jsx(Video, {
237
+ size: 16,
238
+ strokeWidth: 1.5
239
+ }) : /* @__PURE__ */ jsx(CalendarDays, {
240
+ size: 16,
241
+ strokeWidth: 1.5
242
+ })
243
+ }),
244
+ title: event.title,
245
+ caption: event.location ? `${when} · ${event.location}` : when,
246
+ action: event.meetingUrl && /* @__PURE__ */ jsx(Join, {
247
+ event,
248
+ size: "compact",
249
+ onJoin
250
+ })
251
+ });
252
+ }
253
+ var Agenda2 = Object.assign(function Agenda({
254
+ events,
255
+ access = "granted",
256
+ now: nowProp,
257
+ locale,
258
+ tomorrowOpen: tomorrowOpenProp,
259
+ defaultTomorrowOpen = false,
260
+ onTomorrowOpenChange,
261
+ onRequestAccess,
262
+ onOpenSettings,
263
+ onJoin,
264
+ className
265
+ }) {
266
+ const ticking = useEdgeClock2(0, nowProp === undefined, MINUTE2);
267
+ const now = nowProp ?? ticking;
268
+ const [tomorrowOpen, setTomorrowOpen] = useControllableState(tomorrowOpenProp, defaultTomorrowOpen, onTomorrowOpenChange);
269
+ if (access === "undetermined")
270
+ return /* @__PURE__ */ jsx(widget_default.Message, {
271
+ icon: CalendarDays,
272
+ title: "See what's next",
273
+ description: "Your next event with a countdown, and the rest of today and tomorrow.",
274
+ actions: /* @__PURE__ */ jsx(Button, {
275
+ variant: "primary",
276
+ size: "compact",
277
+ onClick: onRequestAccess,
278
+ children: "Connect calendar"
279
+ }),
280
+ className
281
+ });
282
+ if (access === "denied")
283
+ return /* @__PURE__ */ jsx(widget_default.Message, {
284
+ icon: Lock,
285
+ title: "Calendar access is off",
286
+ description: "Turn it on in System Settings › Privacy & Security › Calendars.",
287
+ actions: /* @__PURE__ */ jsx(Button, {
288
+ variant: "secondary",
289
+ size: "compact",
290
+ onClick: onOpenSettings,
291
+ children: "Open System Settings"
292
+ }),
293
+ className
294
+ });
295
+ const midnight = new Date(now).setHours(24, 0, 0, 0);
296
+ const next = new Date(midnight).setHours(24, 0, 0, 0);
297
+ const live = events.filter((event) => event.end > now && event.start < next).sort((a, b) => a.start - b.start);
298
+ const allDay = live.filter((event) => event.allDay && event.start < midnight);
299
+ const timed = live.filter((event) => !event.allDay);
300
+ const [hero] = timed;
301
+ if (!hero)
302
+ return /* @__PURE__ */ jsx(widget_default.Message, {
303
+ icon: CalendarCheck,
304
+ title: allDay.length ? allDay.map((event) => event.title).join(", ") : "Nothing planned",
305
+ description: allDay.length ? "All day today; nothing else on the calendar." : "No more events today or tomorrow.",
306
+ className
307
+ });
308
+ const today = timed.filter((event) => event !== hero && event.start < midnight);
309
+ const tomorrow = timed.filter((event) => event !== hero && event.start >= midnight);
310
+ const tomorrowShown = tomorrowOpen ? tomorrow.slice(0, ROWS) : tomorrow.slice(0, 1);
311
+ const date = new Date(now).toLocaleDateString(locale, { weekday: "long", month: "long", day: "numeric" });
312
+ return /* @__PURE__ */ jsxs(widget_default, {
313
+ className,
314
+ aside: /* @__PURE__ */ jsxs(Fragment, {
315
+ children: [
316
+ /* @__PURE__ */ jsxs(widget_default.Section, {
317
+ label: "Later today",
318
+ children: [
319
+ today.length ? /* @__PURE__ */ jsx(Rows, {
320
+ events: today.slice(0, ROWS),
321
+ locale
322
+ }) : /* @__PURE__ */ jsx("span", {
323
+ className: "flex h-7 items-center text-body text-muted-foreground",
324
+ children: "Nothing else today"
325
+ }),
326
+ /* @__PURE__ */ jsx(More, {
327
+ count: today.length - ROWS
328
+ })
329
+ ]
330
+ }),
331
+ tomorrow.length > 0 && /* @__PURE__ */ jsxs(widget_default.Section, {
332
+ className: "mt-1",
333
+ label: "Tomorrow",
334
+ trailing: tomorrow.length > 1 && /* @__PURE__ */ jsx(Button, {
335
+ variant: "ghost",
336
+ size: "compact",
337
+ className: "-mr-2 h-6 px-2",
338
+ "aria-expanded": tomorrowOpen,
339
+ trailingIcon: tomorrowOpen ? ChevronUp : ChevronDown,
340
+ onClick: () => setTomorrowOpen(!tomorrowOpen),
341
+ children: tomorrowOpen ? "Less" : `${tomorrow.length - 1} more`
342
+ }),
343
+ children: [
344
+ /* @__PURE__ */ jsx(Rows, {
345
+ events: tomorrowShown,
346
+ locale
347
+ }),
348
+ tomorrowOpen && /* @__PURE__ */ jsx(More, {
349
+ count: tomorrow.length - ROWS
350
+ })
351
+ ]
352
+ })
353
+ ]
354
+ }),
355
+ children: [
356
+ /* @__PURE__ */ jsx(widget_default.Header, {
357
+ icon: CalendarDays,
358
+ trailing: allDay.map((event) => /* @__PURE__ */ jsx(widget_default.Chip, {
359
+ color: event.color,
360
+ children: event.title
361
+ }, event.id)),
362
+ children: date
363
+ }),
364
+ /* @__PURE__ */ jsx(Hero, {
365
+ event: hero,
366
+ now,
367
+ midnight,
368
+ locale,
369
+ onJoin
370
+ })
371
+ ]
372
+ });
373
+ }, {
374
+ Leading: AgendaLeading2,
375
+ Trailing: AgendaTrailing2,
376
+ Minimal: AgendaMinimal2,
377
+ UpNext: AgendaUpNext2,
378
+ Starting: AgendaStarting2
379
+ });
380
+ var agenda_default = Agenda2;
381
+ export { AgendaLeading2, AgendaTrailing2, AgendaMinimal2, AgendaUpNext2, AgendaStarting2, Agenda2, agenda_default };
@@ -0,0 +1,112 @@
1
+ "use client";
2
+
3
+ import {
4
+ DEFAULT_NOTCH2,
5
+ INSET2
6
+ } from "./chunk-61t2dfte.js";
7
+ import {
8
+ useIsland2
9
+ } from "./chunk-d5qm9cps.js";
10
+ import {
11
+ IslandTabs2
12
+ } from "./chunk-r471sknr.js";
13
+ import {
14
+ contentShown2,
15
+ contentHidden2,
16
+ contentEnter2
17
+ } from "./chunk-2s4q6mt0.js";
18
+
19
+ // blocks/app/expanded-island/index.tsx
20
+ import Button from "@justanarthur/modo-ui/components/actions/button";
21
+ import { useReduceMotion } from "@justanarthur/modo-ui/lib/reduced-motion";
22
+ import { useControllableState } from "@justanarthur/modo-ui/lib/use-controllable-state";
23
+ import { cn } from "@justanarthur/modo-ui/lib/utils";
24
+ import ScrollArea from "@justanarthur/modo-ui/primitives/layout/scroll-area";
25
+ import { SizeProvider } from "@justanarthur/modo-ui/primitives/systems/sizes";
26
+ import { Settings } from "lucide-react";
27
+ import { motion } from "motion/react";
28
+ import { useState } from "react";
29
+ import { jsx, jsxs } from "react/jsx-runtime";
30
+ /*!
31
+ * Local addition: the open island's layout, tabs in the wings, the tab's
32
+ * title and its view. Rebuilt from Just Notch's runtime
33
+ * (`island/expanded.tsx`) as a presentational block: tabs and their views
34
+ * come in as props.
35
+ */
36
+ function ExpandedIsland2({
37
+ tabs,
38
+ value: valueProp,
39
+ defaultValue,
40
+ onValueChange,
41
+ onSettings,
42
+ settingsLabel = "Settings",
43
+ empty = "Nothing here yet",
44
+ className
45
+ }) {
46
+ const island = useIsland2();
47
+ const [value, setValue] = useControllableState(valueProp, defaultValue ?? tabs[0]?.value, onValueChange);
48
+ const [hovered, setHovered] = useState(null);
49
+ const tab = tabs.find((t) => t.value === value) ?? tabs[0];
50
+ const title = tabs.find((t) => t.value === hovered)?.label ?? tab?.label;
51
+ const notch = island?.geometry.notch.height ?? DEFAULT_NOTCH2.height;
52
+ const reduced = useReduceMotion();
53
+ return /* @__PURE__ */ jsxs("div", {
54
+ className: cn("flex size-full flex-col", className),
55
+ children: [
56
+ /* @__PURE__ */ jsx(SizeProvider, {
57
+ size: "compact",
58
+ children: /* @__PURE__ */ jsx("div", {
59
+ className: "flex shrink-0 items-center",
60
+ style: { height: notch, paddingInline: INSET2 },
61
+ children: tabs.length > 0 ? /* @__PURE__ */ jsx(IslandTabs2, {
62
+ tabs,
63
+ value: tab?.value,
64
+ onValueChange: setValue,
65
+ onHoverChange: setHovered,
66
+ trailing: onSettings && /* @__PURE__ */ jsx(Button, {
67
+ variant: "ghost",
68
+ size: "icon-compact",
69
+ "aria-label": settingsLabel,
70
+ onClick: onSettings,
71
+ children: /* @__PURE__ */ jsx(Settings, {
72
+ size: 14,
73
+ strokeWidth: 1.5
74
+ })
75
+ })
76
+ }) : /* @__PURE__ */ jsx("div", {
77
+ className: "flex-1"
78
+ })
79
+ })
80
+ }),
81
+ /* @__PURE__ */ jsxs("div", {
82
+ className: "flex min-h-0 flex-1 flex-col pb-3",
83
+ children: [
84
+ /* @__PURE__ */ jsx("div", {
85
+ className: "flex h-6 shrink-0 items-end",
86
+ style: { paddingInline: INSET2 },
87
+ children: /* @__PURE__ */ jsx("span", {
88
+ className: "truncate text-caption weight-medium text-muted-foreground",
89
+ children: title
90
+ })
91
+ }),
92
+ /* @__PURE__ */ jsx(ScrollArea, {
93
+ className: "min-h-0 flex-1",
94
+ viewportClassName: "scroll-fade [&>div]:flex [&>div]:min-h-full [&>div]:flex-col",
95
+ children: /* @__PURE__ */ jsx(motion.div, {
96
+ className: "flex flex-1 flex-col py-1 [&>*]:flex-1",
97
+ style: { paddingInline: INSET2 },
98
+ initial: reduced ? { opacity: 0 } : contentHidden2,
99
+ animate: reduced ? { opacity: 1 } : contentShown2,
100
+ transition: contentEnter2,
101
+ children: tab ? tab.content : /* @__PURE__ */ jsx("div", {
102
+ className: "flex items-center justify-center text-caption text-muted-foreground",
103
+ children: empty
104
+ })
105
+ })
106
+ }, tab?.value)
107
+ ]
108
+ })
109
+ ]
110
+ });
111
+ }
112
+ export { ExpandedIsland2 };