@justanarthur/modo-ui-notch 0.0.0-stage → 0.2.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 (136) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +75 -2
  3. package/blocks/activities/agenda/examples.mdx +58 -0
  4. package/blocks/activities/agenda/index.tsx +332 -0
  5. package/blocks/activities/now-playing/examples.mdx +49 -0
  6. package/blocks/activities/now-playing/index.tsx +218 -0
  7. package/blocks/activities/shelf/examples.mdx +33 -0
  8. package/blocks/activities/shelf/index.tsx +289 -0
  9. package/blocks/activities/timer/examples.mdx +52 -0
  10. package/blocks/activities/timer/index.tsx +292 -0
  11. package/blocks/app/expanded-island/examples.mdx +45 -0
  12. package/blocks/app/expanded-island/index.tsx +127 -0
  13. package/blocks/app/settings-window/examples.mdx +30 -0
  14. package/blocks/app/settings-window/index.tsx +357 -0
  15. package/blocks/system/controls/examples.mdx +34 -0
  16. package/blocks/system/controls/index.tsx +167 -0
  17. package/blocks/system/devices/examples.mdx +25 -0
  18. package/blocks/system/devices/index.tsx +172 -0
  19. package/blocks/system/power-alert/examples.mdx +32 -0
  20. package/blocks/system/power-alert/index.tsx +89 -0
  21. package/blocks/system/system-stats/examples.mdx +23 -0
  22. package/blocks/system/system-stats/index.tsx +178 -0
  23. package/components/indicators/battery-glyph/examples.mdx +22 -0
  24. package/components/indicators/battery-glyph/index.tsx +91 -0
  25. package/components/indicators/countdown/examples.mdx +25 -0
  26. package/components/indicators/countdown/index.tsx +83 -0
  27. package/components/indicators/equalizer/examples.mdx +20 -0
  28. package/components/indicators/equalizer/index.tsx +116 -0
  29. package/components/indicators/media-scrubber/examples.mdx +21 -0
  30. package/components/indicators/media-scrubber/index.tsx +98 -0
  31. package/components/island/island/examples.mdx +57 -0
  32. package/components/island/island/index.tsx +415 -0
  33. package/components/island/island-flash/examples.mdx +55 -0
  34. package/components/island/island-flash/index.tsx +79 -0
  35. package/components/island/island-tabs/examples.mdx +53 -0
  36. package/components/island/island-tabs/index.tsx +285 -0
  37. package/dist/blocks/activities/agenda/index.d.ts +2 -0
  38. package/dist/blocks/activities/agenda/index.js +21 -0
  39. package/dist/blocks/activities/now-playing/index.d.ts +2 -0
  40. package/dist/blocks/activities/now-playing/index.js +22 -0
  41. package/dist/blocks/activities/shelf/index.d.ts +2 -0
  42. package/dist/blocks/activities/shelf/index.js +14 -0
  43. package/dist/blocks/activities/timer/index.d.ts +2 -0
  44. package/dist/blocks/activities/timer/index.js +19 -0
  45. package/dist/blocks/app/expanded-island/index.d.ts +3 -0
  46. package/dist/blocks/app/expanded-island/index.js +10 -0
  47. package/dist/blocks/app/settings-window/index.d.ts +2 -0
  48. package/dist/blocks/app/settings-window/index.js +7 -0
  49. package/dist/blocks/system/controls/index.d.ts +2 -0
  50. package/dist/blocks/system/controls/index.js +10 -0
  51. package/dist/blocks/system/devices/index.d.ts +2 -0
  52. package/dist/blocks/system/devices/index.js +12 -0
  53. package/dist/blocks/system/power-alert/index.d.ts +2 -0
  54. package/dist/blocks/system/power-alert/index.js +9 -0
  55. package/dist/blocks/system/system-stats/index.d.ts +2 -0
  56. package/dist/blocks/system/system-stats/index.js +12 -0
  57. package/dist/components/indicators/battery-glyph/index.d.ts +2 -0
  58. package/dist/components/indicators/battery-glyph/index.js +9 -0
  59. package/dist/components/indicators/countdown/index.d.ts +2 -0
  60. package/dist/components/indicators/countdown/index.js +8 -0
  61. package/dist/components/indicators/equalizer/index.d.ts +2 -0
  62. package/dist/components/indicators/equalizer/index.js +7 -0
  63. package/dist/components/indicators/media-scrubber/index.d.ts +2 -0
  64. package/dist/components/indicators/media-scrubber/index.js +8 -0
  65. package/dist/components/island/island/index.d.ts +3 -0
  66. package/dist/components/island/island/index.js +10 -0
  67. package/dist/components/island/island-flash/index.d.ts +2 -0
  68. package/dist/components/island/island-flash/index.js +7 -0
  69. package/dist/components/island/island-tabs/index.d.ts +2 -0
  70. package/dist/components/island/island-tabs/index.js +9 -0
  71. package/dist/index.d.ts +21 -0
  72. package/dist/index.js +151 -0
  73. package/dist/lib/clock.d.ts +2 -0
  74. package/dist/lib/clock.js +14 -0
  75. package/dist/lib/geometry.d.ts +2 -0
  76. package/dist/lib/geometry.js +24 -0
  77. package/dist/lib/island-context.d.ts +3 -0
  78. package/dist/lib/island-context.js +8 -0
  79. package/dist/lib/motion.d.ts +21 -0
  80. package/dist/lib/motion.js +16 -0
  81. package/dist/shared/chunk-152gpyq3.d.ts +13 -0
  82. package/dist/shared/chunk-2f7zxrbk.js +65 -0
  83. package/dist/shared/chunk-2qpcsv5h.d.ts +45 -0
  84. package/dist/shared/chunk-2s4q6mt0.js +27 -0
  85. package/dist/shared/chunk-45gytfr1.d.ts +84 -0
  86. package/dist/shared/chunk-502rmtap.js +54 -0
  87. package/dist/shared/chunk-50ffk4r7.d.ts +69 -0
  88. package/dist/shared/chunk-52gb3g6r.d.ts +12 -0
  89. package/dist/shared/chunk-5en5aaj1.d.ts +33 -0
  90. package/dist/shared/chunk-5w0yck07.d.ts +32 -0
  91. package/dist/shared/chunk-6c1jbefs.d.ts +36 -0
  92. package/dist/shared/chunk-78w7qwp0.js +58 -0
  93. package/dist/shared/chunk-7hr53mby.js +116 -0
  94. package/dist/shared/chunk-9nhpg9t8.d.ts +47 -0
  95. package/dist/shared/chunk-b8jb1w72.js +145 -0
  96. package/dist/shared/chunk-cfzmfnyh.d.ts +63 -0
  97. package/dist/shared/chunk-cpewy6yg.js +178 -0
  98. package/dist/shared/chunk-d5qm9cps.js +10 -0
  99. package/dist/shared/chunk-e3e4s4ds.d.ts +77 -0
  100. package/dist/shared/chunk-enm6td0p.js +280 -0
  101. package/dist/shared/chunk-fvedaas2.d.ts +33 -0
  102. package/dist/shared/chunk-gb56m10p.js +39 -0
  103. package/dist/shared/chunk-gex38j8x.d.ts +82 -0
  104. package/dist/shared/chunk-hpsabfsd.d.ts +75 -0
  105. package/dist/shared/chunk-hrpxbqmx.d.ts +28 -0
  106. package/dist/shared/chunk-hwtxpzg0.js +69 -0
  107. package/dist/shared/chunk-mp1nx0ez.js +101 -0
  108. package/dist/shared/chunk-phb53x1f.js +252 -0
  109. package/dist/shared/chunk-r8esmjfs.d.ts +42 -0
  110. package/dist/shared/chunk-rcp1g9ca.js +70 -0
  111. package/dist/shared/chunk-rpfwv3pz.js +209 -0
  112. package/dist/shared/chunk-rr5e0g15.d.ts +35 -0
  113. package/dist/shared/chunk-rx9sphz2.js +266 -0
  114. package/dist/shared/chunk-s33y1pcq.js +305 -0
  115. package/dist/shared/chunk-sbnrhy5m.js +331 -0
  116. package/dist/shared/chunk-w48eyvfr.d.ts +56 -0
  117. package/dist/shared/chunk-wwjxs75m.js +74 -0
  118. package/dist/shared/chunk-xdeek16r.d.ts +58 -0
  119. package/dist/shared/chunk-xkzjk1tq.js +206 -0
  120. package/dist/shared/chunk-yngkkxz2.d.ts +88 -0
  121. package/dist/shared/chunk-zvh0d3qb.js +63 -0
  122. package/dist/styles.css +222 -0
  123. package/index.ts +21 -0
  124. package/lib/clock.ts +53 -0
  125. package/lib/geometry.ts +130 -0
  126. package/lib/island-context.tsx +24 -0
  127. package/lib/motion.ts +42 -0
  128. package/mock/activities.tsx +100 -0
  129. package/mock/artwork.tsx +25 -0
  130. package/mock/data.ts +153 -0
  131. package/mock/desktop.tsx +83 -0
  132. package/mock/fit.ts +26 -0
  133. package/mock/island-content.tsx +217 -0
  134. package/mock/scene.tsx +52 -0
  135. package/mock/settings.tsx +210 -0
  136. package/package.json +117 -4
@@ -0,0 +1,305 @@
1
+ "use client";
2
+
3
+ // blocks/app/settings-window/index.tsx
4
+ import Button from "@justanarthur/modo-ui/components/actions/button";
5
+ import List, { LIST_SWITCH } from "@justanarthur/modo-ui/components/data-display/list";
6
+ import StatusDot from "@justanarthur/modo-ui/components/feedback/status-dot";
7
+ import ChoiceList from "@justanarthur/modo-ui/components/inputs/choice-list";
8
+ import Switch from "@justanarthur/modo-ui/components/inputs/switch";
9
+ import Sidebar from "@justanarthur/modo-ui/components/navigation/sidebar";
10
+ import { useControllableState } from "@justanarthur/modo-ui/lib/use-controllable-state";
11
+ import { cn } from "@justanarthur/modo-ui/lib/utils";
12
+ import ScrollArea from "@justanarthur/modo-ui/primitives/layout/scroll-area";
13
+ import { Info, Puzzle, Settings2, ShieldCheck } from "lucide-react";
14
+ import { jsx, jsxs } from "react/jsx-runtime";
15
+ /*!
16
+ * Local addition: a notch app's settings window. Rebuilt from Just Notch's
17
+ * runtime (`settings/settings.tsx`) as a presentational block: preferences,
18
+ * plugins, permissions and the about rows come in as props.
19
+ */
20
+ var SCREENS = [
21
+ { value: "notched", label: "Notched screen only", note: "The built-in display" },
22
+ { value: "all", label: "All screens", note: "A virtual notch on the others" }
23
+ ];
24
+ function Page({ title, lead, children }) {
25
+ return /* @__PURE__ */ jsxs("section", {
26
+ className: "flex flex-col gap-4",
27
+ children: [
28
+ /* @__PURE__ */ jsxs("div", {
29
+ className: "flex flex-col gap-1",
30
+ children: [
31
+ /* @__PURE__ */ jsx("h2", {
32
+ className: "m-0 text-title weight-semibold text-foreground",
33
+ children: title
34
+ }),
35
+ lead && /* @__PURE__ */ jsx("p", {
36
+ className: "m-0 text-body text-muted-foreground",
37
+ children: lead
38
+ })
39
+ ]
40
+ }),
41
+ children
42
+ ]
43
+ });
44
+ }
45
+ function General({ preferences, onChange }) {
46
+ return /* @__PURE__ */ jsxs(Page, {
47
+ title: "General",
48
+ children: [
49
+ /* @__PURE__ */ jsx(List, {
50
+ children: /* @__PURE__ */ jsx(List.Section, {
51
+ title: "Startup",
52
+ children: /* @__PURE__ */ jsx(List.Row, {
53
+ label: "Launch at login",
54
+ description: "Starts the app when you log in to your Mac.",
55
+ children: /* @__PURE__ */ jsx(Switch, {
56
+ "aria-label": "Launch at login",
57
+ className: LIST_SWITCH,
58
+ checked: preferences.launchAtLogin,
59
+ onCheckedChange: (launchAtLogin) => onChange({ ...preferences, launchAtLogin })
60
+ })
61
+ })
62
+ })
63
+ }),
64
+ /* @__PURE__ */ jsxs("div", {
65
+ className: "flex flex-col gap-2",
66
+ children: [
67
+ /* @__PURE__ */ jsx("span", {
68
+ className: "text-caption text-muted-foreground",
69
+ children: "Show the island on"
70
+ }),
71
+ /* @__PURE__ */ jsx(ChoiceList, {
72
+ label: "Show the island on",
73
+ value: preferences.screens,
74
+ onValueChange: (screens) => onChange({ ...preferences, screens }),
75
+ options: SCREENS.map((screen) => ({
76
+ value: screen.value,
77
+ label: screen.label,
78
+ content: /* @__PURE__ */ jsxs("span", {
79
+ className: "flex min-w-0 flex-1 items-baseline justify-between gap-3",
80
+ children: [
81
+ /* @__PURE__ */ jsx("span", {
82
+ className: "truncate",
83
+ children: screen.label
84
+ }),
85
+ /* @__PURE__ */ jsx("span", {
86
+ className: "truncate text-caption text-muted-foreground",
87
+ children: screen.note
88
+ })
89
+ ]
90
+ })
91
+ }))
92
+ })
93
+ ]
94
+ })
95
+ ]
96
+ });
97
+ }
98
+ function Plugins({ plugins, enabled, onChange }) {
99
+ return /* @__PURE__ */ jsx(Page, {
100
+ title: "Plugins",
101
+ lead: "Each plugin adds activities and widgets to the island.",
102
+ children: plugins.length === 0 ? /* @__PURE__ */ jsx("p", {
103
+ className: "m-0 text-body text-muted-foreground",
104
+ children: "No plugins installed."
105
+ }) : /* @__PURE__ */ jsx(List, {
106
+ children: /* @__PURE__ */ jsx(List.Section, {
107
+ title: "Installed",
108
+ aside: `${plugins.filter((p) => enabled[p.id] ?? true).length} on`,
109
+ children: plugins.map((plugin) => {
110
+ const Icon = plugin.icon ?? Puzzle;
111
+ return /* @__PURE__ */ jsx(List.Row, {
112
+ label: /* @__PURE__ */ jsxs("span", {
113
+ className: "flex min-w-0 items-center gap-2",
114
+ children: [
115
+ /* @__PURE__ */ jsx(Icon, {
116
+ size: 16,
117
+ strokeWidth: 1.5,
118
+ className: "shrink-0 text-muted-foreground"
119
+ }),
120
+ /* @__PURE__ */ jsx("span", {
121
+ className: "truncate",
122
+ children: plugin.name
123
+ })
124
+ ]
125
+ }),
126
+ description: plugin.description,
127
+ children: /* @__PURE__ */ jsx(Switch, {
128
+ "aria-label": plugin.name,
129
+ className: LIST_SWITCH,
130
+ checked: enabled[plugin.id] ?? true,
131
+ onCheckedChange: (on) => onChange({ ...enabled, [plugin.id]: on })
132
+ })
133
+ }, plugin.id);
134
+ })
135
+ })
136
+ })
137
+ });
138
+ }
139
+ function Permissions({ permissions, onOpen }) {
140
+ return /* @__PURE__ */ jsx(Page, {
141
+ title: "Permissions",
142
+ lead: "What macOS lets the app read and control.",
143
+ children: /* @__PURE__ */ jsx(List, {
144
+ children: /* @__PURE__ */ jsx(List.Section, {
145
+ title: "Privacy & Security",
146
+ children: permissions.map((permission) => /* @__PURE__ */ jsx(List.Row, {
147
+ label: /* @__PURE__ */ jsxs("span", {
148
+ className: "flex min-w-0 items-center gap-2",
149
+ children: [
150
+ /* @__PURE__ */ jsx(StatusDot, {
151
+ status: permission.granted === undefined ? "running" : permission.granted ? "success" : "waiting",
152
+ label: permission.granted === undefined ? "Checking" : permission.granted ? "Granted" : "Not granted"
153
+ }),
154
+ /* @__PURE__ */ jsx("span", {
155
+ className: "truncate",
156
+ children: permission.label
157
+ })
158
+ ]
159
+ }),
160
+ description: permission.description,
161
+ children: permission.granted === false ? /* @__PURE__ */ jsx(Button, {
162
+ variant: "ghost",
163
+ size: "compact",
164
+ onClick: () => onOpen?.(permission.id),
165
+ children: "Open Settings"
166
+ }) : /* @__PURE__ */ jsx("span", {
167
+ className: "pr-3 text-caption text-muted-foreground",
168
+ children: permission.granted ? "Granted" : "Checking…"
169
+ })
170
+ }, permission.id))
171
+ })
172
+ })
173
+ });
174
+ }
175
+ function About({ rows }) {
176
+ return /* @__PURE__ */ jsx(Page, {
177
+ title: "About",
178
+ children: /* @__PURE__ */ jsx(List, {
179
+ children: rows.map((row) => /* @__PURE__ */ jsx(List.Row, {
180
+ label: /* @__PURE__ */ jsx("span", {
181
+ className: "text-muted-foreground",
182
+ children: row.label
183
+ }),
184
+ children: /* @__PURE__ */ jsx("span", {
185
+ className: "min-w-0 truncate pr-3 text-body text-foreground",
186
+ children: row.value
187
+ })
188
+ }, row.label))
189
+ })
190
+ });
191
+ }
192
+ var PAGES = [
193
+ { value: "general", label: "General", icon: Settings2 },
194
+ { value: "plugins", label: "Plugins", icon: Puzzle },
195
+ { value: "permissions", label: "Permissions", icon: ShieldCheck },
196
+ { value: "about", label: "About", icon: Info }
197
+ ];
198
+ function SettingsWindow2({
199
+ name = "Notch",
200
+ value,
201
+ defaultValue = "general",
202
+ onValueChange,
203
+ preferences: preferencesProp,
204
+ defaultPreferences = { launchAtLogin: true, screens: "notched" },
205
+ onPreferencesChange,
206
+ plugins = [],
207
+ enabled: enabledProp,
208
+ defaultEnabled = {},
209
+ onEnabledChange,
210
+ permissions = [],
211
+ onOpenPermission,
212
+ about = [],
213
+ className
214
+ }) {
215
+ const [page, setPage] = useControllableState(value, defaultValue, onValueChange);
216
+ const [preferences, setPreferences] = useControllableState(preferencesProp, defaultPreferences, onPreferencesChange);
217
+ const [enabled, setEnabled] = useControllableState(enabledProp, defaultEnabled, onEnabledChange);
218
+ const withSettings = plugins.filter((plugin) => plugin.settings !== undefined);
219
+ const plugin = withSettings.find((p) => `plugin:${p.id}` === page);
220
+ return /* @__PURE__ */ jsxs(Sidebar.Provider, {
221
+ className: cn("h-full min-h-0", className),
222
+ persist: false,
223
+ shortcut: null,
224
+ mobileBreakpoint: 0,
225
+ width: "13rem",
226
+ children: [
227
+ /* @__PURE__ */ jsx(Sidebar, {
228
+ className: "h-full",
229
+ collapsible: "none",
230
+ value: page,
231
+ onValueChange: setPage,
232
+ children: /* @__PURE__ */ jsxs(Sidebar.Content, {
233
+ children: [
234
+ /* @__PURE__ */ jsxs(Sidebar.Group, {
235
+ children: [
236
+ /* @__PURE__ */ jsx(Sidebar.GroupLabel, {
237
+ children: name
238
+ }),
239
+ /* @__PURE__ */ jsx(Sidebar.Menu, {
240
+ children: PAGES.map((item) => /* @__PURE__ */ jsx(Sidebar.MenuItem, {
241
+ children: /* @__PURE__ */ jsx(Sidebar.MenuButton, {
242
+ icon: item.icon,
243
+ value: item.value,
244
+ children: item.label
245
+ })
246
+ }, item.value))
247
+ })
248
+ ]
249
+ }),
250
+ withSettings.length > 0 && /* @__PURE__ */ jsxs(Sidebar.Group, {
251
+ children: [
252
+ /* @__PURE__ */ jsx(Sidebar.GroupLabel, {
253
+ children: "Plugin settings"
254
+ }),
255
+ /* @__PURE__ */ jsx(Sidebar.Menu, {
256
+ children: withSettings.map((p) => /* @__PURE__ */ jsx(Sidebar.MenuItem, {
257
+ children: /* @__PURE__ */ jsx(Sidebar.MenuButton, {
258
+ icon: p.icon,
259
+ value: `plugin:${p.id}`,
260
+ children: p.name
261
+ })
262
+ }, p.id))
263
+ })
264
+ ]
265
+ })
266
+ ]
267
+ })
268
+ }),
269
+ /* @__PURE__ */ jsx(Sidebar.Inset, {
270
+ className: "min-h-0 min-w-0",
271
+ children: /* @__PURE__ */ jsx(ScrollArea, {
272
+ className: "h-full",
273
+ viewportClassName: "scroll-fade",
274
+ children: /* @__PURE__ */ jsxs("div", {
275
+ className: "mx-auto flex w-full max-w-160 flex-col gap-8 p-8",
276
+ children: [
277
+ page === "general" && /* @__PURE__ */ jsx(General, {
278
+ preferences,
279
+ onChange: setPreferences
280
+ }),
281
+ page === "plugins" && /* @__PURE__ */ jsx(Plugins, {
282
+ plugins,
283
+ enabled,
284
+ onChange: setEnabled
285
+ }),
286
+ page === "permissions" && /* @__PURE__ */ jsx(Permissions, {
287
+ permissions,
288
+ onOpen: onOpenPermission
289
+ }),
290
+ page === "about" && /* @__PURE__ */ jsx(About, {
291
+ rows: about
292
+ }),
293
+ plugin && /* @__PURE__ */ jsx(Page, {
294
+ title: plugin.name,
295
+ lead: plugin.description,
296
+ children: plugin.settings
297
+ })
298
+ ]
299
+ })
300
+ }, page)
301
+ })
302
+ ]
303
+ });
304
+ }
305
+ export { SettingsWindow2 };
@@ -0,0 +1,331 @@
1
+ "use client";
2
+
3
+ import {
4
+ slotWidth2,
5
+ shapeFor2,
6
+ bubbleFor2,
7
+ islandPath2
8
+ } from "./chunk-zvh0d3qb.js";
9
+ import {
10
+ IslandContext2
11
+ } from "./chunk-d5qm9cps.js";
12
+ import {
13
+ shapeTransition2,
14
+ bubbleTransition2,
15
+ contentShown2,
16
+ contentHidden2,
17
+ contentEnter2,
18
+ contentLeave2
19
+ } from "./chunk-2s4q6mt0.js";
20
+
21
+ // components/island/island/index.tsx
22
+ import { GooLayer } from "@justanarthur/modo-ui/lib/goo-indicator";
23
+ import { useReduceMotion } from "@justanarthur/modo-ui/lib/reduced-motion";
24
+ import { SurfaceProvider } from "@justanarthur/modo-ui/lib/surface-context";
25
+ import { useControllableState } from "@justanarthur/modo-ui/lib/use-controllable-state";
26
+ import { cn } from "@justanarthur/modo-ui/lib/utils";
27
+ import { AnimatePresence, animate, motion, useMotionValue, useTransform } from "motion/react";
28
+ import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
29
+ import { jsx, jsxs } from "react/jsx-runtime";
30
+ /*!
31
+ * Local addition: the island of a notch app, the black outline that hangs
32
+ * from the top edge and grows out of the hardware notch. Rebuilt from Just
33
+ * Notch's runtime (`island/island.tsx`) as a presentational component: no
34
+ * host, no activity store; state, geometry and content come in as props.
35
+ */
36
+ var HOVER_INTENT_MS = 120;
37
+ var HOVER_LEAVE_MS = 400;
38
+ var OVERSHOOT = 24;
39
+ var GOO_BLUR = 6;
40
+ var INTERACTIVE = "button, a, input, select, textarea, label, [role=slider], [role=switch], [role=tab], [role=menuitem], [contenteditable]";
41
+ var isCollapsed = (state) => state === "idle" || state === "compact" || state === "split";
42
+ function Layer({ shape, top = 0, reduced, interactive, children }) {
43
+ const hidden = reduced ? { opacity: 0 } : contentHidden2;
44
+ return /* @__PURE__ */ jsx(motion.div, {
45
+ className: cn("absolute", interactive ? "pointer-events-auto" : "pointer-events-none"),
46
+ style: {
47
+ left: `calc(50% - ${shape.w / 2}px)`,
48
+ top: 0,
49
+ width: shape.w,
50
+ height: shape.h,
51
+ transformOrigin: "50% 0"
52
+ },
53
+ initial: hidden,
54
+ animate: reduced ? { opacity: 1 } : contentShown2,
55
+ exit: { ...hidden, transition: contentLeave2 },
56
+ transition: contentEnter2,
57
+ children: /* @__PURE__ */ jsx("div", {
58
+ className: "absolute inset-x-0 bottom-0",
59
+ style: { top },
60
+ children
61
+ })
62
+ });
63
+ }
64
+ function Island2({
65
+ state: stateProp,
66
+ defaultState = "idle",
67
+ onStateChange,
68
+ collapsedState,
69
+ expandOnHover = false,
70
+ notchWidth = 185,
71
+ notchHeight = 32,
72
+ panelWidth = 720,
73
+ panelHeight = 320,
74
+ leading,
75
+ trailing,
76
+ minimal,
77
+ expanded,
78
+ flash,
79
+ activity,
80
+ label = "Open the island",
81
+ className
82
+ }) {
83
+ const [state, setState] = useControllableState(stateProp, defaultState, onStateChange);
84
+ const reduced = useReduceMotion();
85
+ const root = useRef(null);
86
+ const [room, setRoom] = useState();
87
+ useLayoutEffect(() => {
88
+ const el = root.current;
89
+ if (!el)
90
+ return;
91
+ setRoom(el.clientWidth);
92
+ const observer = new ResizeObserver(([entry]) => entry && setRoom(entry.contentRect.width));
93
+ observer.observe(el);
94
+ return () => observer.disconnect();
95
+ }, []);
96
+ const geometry = useMemo(() => ({ notch: { width: notchWidth, height: notchHeight }, panel: { width: panelWidth, height: panelHeight } }), [notchWidth, notchHeight, panelWidth, panelHeight]);
97
+ const { notch } = geometry;
98
+ const shape = shapeFor2(state, geometry, room);
99
+ const split = state === "split";
100
+ const bubble = bubbleFor2(shape, notch, split);
101
+ const rest = useRef(isCollapsed(defaultState) ? defaultState : "idle");
102
+ if (isCollapsed(state))
103
+ rest.current = state;
104
+ const collapse = () => setState(collapsedState ?? rest.current);
105
+ const w = useMotionValue(shape.w);
106
+ const h = useMotionValue(shape.h);
107
+ const radius = useMotionValue(shape.radius);
108
+ const shoulder = useMotionValue(shape.shoulder);
109
+ const bubbleX = useMotionValue(bubble.x);
110
+ const bubbleR = useMotionValue(bubble.r);
111
+ const [moving, setMoving] = useState(false);
112
+ const [reserve, setReserve] = useState(shape.h);
113
+ const [goo, setGoo] = useState(null);
114
+ const [bubbleShown, setBubbleShown] = useState(split);
115
+ const d = useTransform(() => islandPath2(0, { w: w.get(), h: h.get(), radius: radius.get(), shoulder: shoulder.get() }));
116
+ const clipPath = useTransform(() => {
117
+ const side = `calc(50% - ${w.get() / 2}px)`;
118
+ const r = radius.get();
119
+ return `inset(0px ${side} calc(100% - ${h.get()}px) ${side} round 0px 0px ${r}px ${r}px)`;
120
+ });
121
+ const bodyX = useTransform(() => -w.get() / 2);
122
+ const bodyY = useTransform(() => -radius.get());
123
+ const bodyHeight = useTransform(() => h.get() + radius.get());
124
+ const bubbleLeft = useTransform(() => bubbleX.get() - bubbleR.get());
125
+ const bubbleTop = useTransform(() => notch.height / 2 - bubbleR.get());
126
+ const bubbleSize = useTransform(() => bubbleR.get() * 2);
127
+ const previous = useRef(state);
128
+ const token = useRef(0);
129
+ useLayoutEffect(() => {
130
+ const from = previous.current;
131
+ previous.current = state;
132
+ const run = ++token.current;
133
+ const values = [w, h, radius, shoulder, bubbleX, bubbleR];
134
+ const targets = [shape.w, shape.h, shape.radius, shape.shoulder, bubble.x, bubble.r];
135
+ if (from === state || reduced) {
136
+ for (const [i, value] of values.entries())
137
+ value.jump(targets[i]);
138
+ setMoving(false);
139
+ setGoo(null);
140
+ setBubbleShown(split);
141
+ setReserve(shape.h);
142
+ return;
143
+ }
144
+ const transition = shapeTransition2(from, state);
145
+ const splitChanged = from === "split" !== split;
146
+ const bubbleMove = splitChanged ? bubbleTransition2(split) : transition;
147
+ setMoving(true);
148
+ setReserve(Math.max(h.get(), shape.h) + OVERSHOOT);
149
+ if (splitChanged) {
150
+ const half = Math.max(w.get(), shape.w) / 2;
151
+ const reach = Math.max(half, bubbleFor2(shape, notch, true).x + bubble.r * 2);
152
+ const top = Math.max(radius.get(), shape.radius);
153
+ setGoo({ left: -reach, top: -top, width: reach * 2, height: Math.max(h.get(), shape.h) + top });
154
+ if (split)
155
+ setBubbleShown(true);
156
+ }
157
+ const controls = values.map((value, i) => animate(value, targets[i], i >= 4 ? bubbleMove : transition));
158
+ Promise.all(controls.map((c) => c.finished)).then(() => {
159
+ if (run !== token.current)
160
+ return;
161
+ setMoving(false);
162
+ setGoo(null);
163
+ setBubbleShown(split);
164
+ setReserve(shape.h);
165
+ });
166
+ }, [state, shape.w, shape.h, shape.radius, shape.shoulder, bubble.x, bubble.r, reduced]);
167
+ const hover = useRef(undefined);
168
+ useEffect(() => () => clearTimeout(hover.current), []);
169
+ const intend = (open) => {
170
+ if (!expandOnHover)
171
+ return;
172
+ clearTimeout(hover.current);
173
+ hover.current = setTimeout(() => {
174
+ if (open && isCollapsed(state))
175
+ setState("expanded");
176
+ if (!open && state === "expanded")
177
+ collapse();
178
+ }, open ? HOVER_INTENT_MS : HOVER_LEAVE_MS);
179
+ };
180
+ const open = state === "expanded";
181
+ useEffect(() => {
182
+ if (!open)
183
+ return;
184
+ const onKey = (event) => event.key === "Escape" && collapse();
185
+ window.addEventListener("keydown", onKey);
186
+ return () => window.removeEventListener("keydown", onKey);
187
+ });
188
+ const onClick = (event) => {
189
+ if (open || event.defaultPrevented)
190
+ return;
191
+ if (event.target instanceof Element && event.target.closest(INTERACTIVE))
192
+ return;
193
+ setState("expanded");
194
+ };
195
+ const slot = slotWidth2(notch);
196
+ const context = useMemo(() => ({ state, geometry, shape }), [state, geometry, shape.w, shape.h, shape.radius, shape.shoulder]);
197
+ let content = null;
198
+ if (state === "expanded" && expanded)
199
+ content = /* @__PURE__ */ jsx(Layer, {
200
+ shape,
201
+ reduced,
202
+ interactive: true,
203
+ children: expanded
204
+ }, "expanded");
205
+ else if (state === "flash" && flash)
206
+ content = /* @__PURE__ */ jsx(Layer, {
207
+ shape,
208
+ top: notch.height,
209
+ reduced,
210
+ interactive: true,
211
+ children: /* @__PURE__ */ jsx("div", {
212
+ className: "flex size-full items-center px-5 pb-1",
213
+ children: /* @__PURE__ */ jsx("div", {
214
+ className: "min-w-0 flex-1",
215
+ children: flash
216
+ })
217
+ })
218
+ }, `flash:${activity ?? ""}`);
219
+ else if ((state === "compact" || split) && (leading || trailing))
220
+ content = /* @__PURE__ */ jsxs(Layer, {
221
+ shape,
222
+ reduced,
223
+ interactive: false,
224
+ children: [
225
+ /* @__PURE__ */ jsx("div", {
226
+ className: "absolute inset-y-0 left-0 flex items-center justify-center",
227
+ style: { width: slot },
228
+ children: leading
229
+ }),
230
+ /* @__PURE__ */ jsx("div", {
231
+ className: "absolute inset-y-0 right-0 flex items-center justify-center",
232
+ style: { width: slot },
233
+ children: trailing
234
+ })
235
+ ]
236
+ }, `wings:${activity ?? "compact"}`);
237
+ return /* @__PURE__ */ jsx(IslandContext2.Provider, {
238
+ value: context,
239
+ children: /* @__PURE__ */ jsxs("div", {
240
+ ref: root,
241
+ "data-state": state,
242
+ className: cn("pointer-events-none relative w-full overflow-hidden", className),
243
+ style: { height: reserve },
244
+ onClick,
245
+ onPointerEnter: () => intend(true),
246
+ onPointerLeave: () => intend(false),
247
+ children: [
248
+ goo && /* @__PURE__ */ jsx("div", {
249
+ "aria-hidden": true,
250
+ className: "absolute top-0 left-1/2",
251
+ children: /* @__PURE__ */ jsxs(GooLayer, {
252
+ active: true,
253
+ blur: GOO_BLUR,
254
+ box: goo,
255
+ fill: "bg-ink",
256
+ children: [
257
+ /* @__PURE__ */ jsx(motion.div, {
258
+ className: "absolute top-0 left-0 bg-ink",
259
+ style: { x: bodyX, y: bodyY, width: w, height: bodyHeight, borderRadius: radius }
260
+ }),
261
+ /* @__PURE__ */ jsx(motion.div, {
262
+ className: "absolute top-0 left-0 rounded-full bg-ink",
263
+ style: { x: bubbleLeft, y: bubbleTop, width: bubbleSize, height: bubbleSize }
264
+ })
265
+ ]
266
+ })
267
+ }),
268
+ /* @__PURE__ */ jsx("svg", {
269
+ "aria-hidden": true,
270
+ className: "absolute top-0 left-1/2 overflow-visible",
271
+ width: "1",
272
+ height: "1",
273
+ children: /* @__PURE__ */ jsxs("g", {
274
+ className: "pointer-events-auto fill-ink",
275
+ children: [
276
+ /* @__PURE__ */ jsx(motion.path, {
277
+ d
278
+ }),
279
+ bubbleShown && /* @__PURE__ */ jsx(motion.circle, {
280
+ cx: bubbleX,
281
+ cy: notch.height / 2,
282
+ r: bubbleR
283
+ })
284
+ ]
285
+ })
286
+ }),
287
+ !open && /* @__PURE__ */ jsx("button", {
288
+ type: "button",
289
+ "aria-label": label,
290
+ "aria-expanded": false,
291
+ className: "pointer-events-auto absolute top-0 cursor-pointer outline-none focus-visible:ring-1 focus-visible:ring-focus-ring",
292
+ style: {
293
+ left: `calc(50% - ${shape.w / 2}px)`,
294
+ width: shape.w,
295
+ height: shape.h,
296
+ borderBottomLeftRadius: shape.radius,
297
+ borderBottomRightRadius: shape.radius
298
+ },
299
+ onClick: () => setState("expanded")
300
+ }),
301
+ /* @__PURE__ */ jsx(motion.div, {
302
+ className: "dark pointer-events-none absolute inset-0 text-foreground",
303
+ style: { clipPath: moving ? clipPath : "none" },
304
+ children: /* @__PURE__ */ jsx(SurfaceProvider, {
305
+ value: 1,
306
+ children: /* @__PURE__ */ jsx(AnimatePresence, {
307
+ initial: false,
308
+ children: content
309
+ })
310
+ })
311
+ }),
312
+ (split || bubbleShown) && /* @__PURE__ */ jsx(motion.div, {
313
+ className: "dark pointer-events-auto absolute top-0 left-1/2 flex items-center justify-center text-foreground",
314
+ style: { x: bubbleLeft, y: notch.height / 2 - bubble.r, width: bubble.r * 2, height: bubble.r * 2 },
315
+ children: /* @__PURE__ */ jsx(AnimatePresence, {
316
+ initial: false,
317
+ children: split && minimal && /* @__PURE__ */ jsx(motion.div, {
318
+ className: "flex size-full items-center justify-center",
319
+ initial: reduced ? { opacity: 0 } : contentHidden2,
320
+ animate: reduced ? { opacity: 1 } : contentShown2,
321
+ exit: { opacity: 0, transition: contentLeave2 },
322
+ transition: contentEnter2,
323
+ children: minimal
324
+ }, activity ?? "minimal")
325
+ })
326
+ })
327
+ ]
328
+ })
329
+ });
330
+ }
331
+ export { Island2 };
@@ -0,0 +1,56 @@
1
+ import { IconComponent } from "@justanarthur/modo-ui/lib/icon-context";
2
+ import { SizeVariant } from "@justanarthur/modo-ui/lib/size-context";
3
+ import { ReactNode } from "react";
4
+ import { JSX as JSX_1kxb } from "react";
5
+ interface IslandTab2 {
6
+ /** What selecting it reports. */
7
+ value: string;
8
+ /** Its name: the tab's accessible name, and the title a consumer shows for it. */
9
+ label: string;
10
+ /** Its glyph. */
11
+ icon: IconComponent;
12
+ }
13
+ interface IslandTabsProps2 {
14
+ /** The tabs, in order: they fill the left wing, then the right one. */
15
+ tabs: IslandTab2[];
16
+ /** The selected tab's value (controlled). */
17
+ value?: string;
18
+ /** The tab selected at first (uncontrolled). Defaults to the first tab. */
19
+ defaultValue?: string;
20
+ /** Called with the value of the tab a press or an arrow key selects. */
21
+ onValueChange?: (value: string) => void;
22
+ /** Called with the value of the tab under the pointer, or `null`, so a title can preview it. */
23
+ onHoverChange?: (value: string | null) => void;
24
+ /** Step on the size ladder. Defaults to the surrounding SizeProvider, else `'default'`. */
25
+ size?: SizeVariant;
26
+ /** The notch the strip leaves free, centered. Defaults to the enclosing Island's, else `185`. */
27
+ notchWidth?: number;
28
+ /** Content at the far right of the right wing, such as a settings button; the tabs keep clear of it. */
29
+ trailing?: ReactNode;
30
+ /** The tab list's accessible name. Defaults to `'Widgets'`. */
31
+ label?: string;
32
+ /** Classes for the root, which spans its container's width. */
33
+ className?: string;
34
+ }
35
+ type Element_12xgc = JSX_1kxb["Element"];
36
+ /**
37
+ * The open island's icon tabs, in both wings around the notch: the left
38
+ * wing's, a gap the width of the notch, then the right wing's.
39
+ *
40
+ * The tabs fill the left wing first and balance into the right one, keeping
41
+ * clear of the `trailing` content at its far end. The selected tab's pill is
42
+ * modo-ui's liquid indicator: it melts from tab to tab, across the notch too;
43
+ * a fluid hover highlight lights the tab under the pointer and the keyboard
44
+ * gets a focus ring that springs between tabs. Past what both wings hold the
45
+ * strip scrolls behind the notch, which hides the tabs passing under it; its
46
+ * outer edges fade with `scroll-fade-x` and a vertical wheel scrolls it
47
+ * sideways.
48
+ *
49
+ * The strip shows icons only. Show the selected tab's title yourself, or the
50
+ * hovered one's as a preview through `onHoverChange`. Arrow keys, Home and End
51
+ * move the selection. Inside an Island it reads the notch's width from it.
52
+ *
53
+ * @example {@include ./examples.mdx}
54
+ */
55
+ declare function IslandTabs2({ tabs, value: valueProp, defaultValue, onValueChange, onHoverChange, size: sizeProp, notchWidth, trailing, label, className }: IslandTabsProps2): Element_12xgc;
56
+ export { IslandTab2, IslandTabsProps2, IslandTabs2 };