@justanarthur/modo-ui 0.0.0-stage → 0.1.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 (172) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSE.beui +21 -0
  3. package/LICENSE.fluid-functionalism +21 -0
  4. package/LICENSE.motion-primitives +21 -0
  5. package/LICENSE.sileo +21 -0
  6. package/README.md +608 -2
  7. package/dist/base.css +994 -0
  8. package/dist/blocks/sidebar-app/index.d.ts +34 -0
  9. package/dist/blocks/sidebar-app/index.js +34 -0
  10. package/dist/components/badge/index.d.ts +59 -0
  11. package/dist/components/badge/index.js +18 -0
  12. package/dist/components/button/index.d.ts +59 -0
  13. package/dist/components/button/index.js +16 -0
  14. package/dist/components/card/index.d.ts +141 -0
  15. package/dist/components/card/index.js +44 -0
  16. package/dist/components/inputs/checkbox-group/index.d.ts +50 -0
  17. package/dist/components/inputs/checkbox-group/index.js +23 -0
  18. package/dist/components/inputs/color-picker/index.d.ts +137 -0
  19. package/dist/components/inputs/color-picker/index.js +37 -0
  20. package/dist/components/inputs/combobox/index.d.ts +161 -0
  21. package/dist/components/inputs/combobox/index.js +41 -0
  22. package/dist/components/inputs/date-time/calendar/index.d.ts +45 -0
  23. package/dist/components/inputs/date-time/calendar/index.js +20 -0
  24. package/dist/components/inputs/date-time/date-picker/index.d.ts +82 -0
  25. package/dist/components/inputs/date-time/date-picker/index.js +34 -0
  26. package/dist/components/inputs/date-time/date-range-picker/index.d.ts +64 -0
  27. package/dist/components/inputs/date-time/date-range-picker/index.js +33 -0
  28. package/dist/components/inputs/date-time/duration-picker/index.d.ts +57 -0
  29. package/dist/components/inputs/date-time/duration-picker/index.js +33 -0
  30. package/dist/components/inputs/date-time/month-picker/index.d.ts +57 -0
  31. package/dist/components/inputs/date-time/month-picker/index.js +32 -0
  32. package/dist/components/inputs/date-time/time-picker/index.d.ts +59 -0
  33. package/dist/components/inputs/date-time/time-picker/index.js +33 -0
  34. package/dist/components/inputs/input/index.d.ts +84 -0
  35. package/dist/components/inputs/input/index.js +20 -0
  36. package/dist/components/inputs/input-copy/index.d.ts +44 -0
  37. package/dist/components/inputs/input-copy/index.js +18 -0
  38. package/dist/components/inputs/input-message/index.d.ts +125 -0
  39. package/dist/components/inputs/input-message/index.js +27 -0
  40. package/dist/components/inputs/radio-group/index.d.ts +58 -0
  41. package/dist/components/inputs/radio-group/index.js +22 -0
  42. package/dist/components/inputs/search/index.d.ts +83 -0
  43. package/dist/components/inputs/search/index.js +28 -0
  44. package/dist/components/inputs/select/index.d.ts +105 -0
  45. package/dist/components/inputs/select/index.js +37 -0
  46. package/dist/components/inputs/slider/index.d.ts +108 -0
  47. package/dist/components/inputs/slider/index.js +16 -0
  48. package/dist/components/inputs/switch/index.d.ts +43 -0
  49. package/dist/components/inputs/switch/index.js +16 -0
  50. package/dist/components/navigation/accordion/index.d.ts +117 -0
  51. package/dist/components/navigation/accordion/index.js +30 -0
  52. package/dist/components/navigation/sidebar/index.d.ts +388 -0
  53. package/dist/components/navigation/sidebar/index.js +101 -0
  54. package/dist/components/navigation/tabs/index.d.ts +70 -0
  55. package/dist/components/navigation/tabs/index.js +25 -0
  56. package/dist/components/navigation/tabs-subtle/index.d.ts +73 -0
  57. package/dist/components/navigation/tabs-subtle/index.js +23 -0
  58. package/dist/components/overlays/alert-dialog/index.d.ts +67 -0
  59. package/dist/components/overlays/alert-dialog/index.js +24 -0
  60. package/dist/components/overlays/command/index.d.ts +121 -0
  61. package/dist/components/overlays/command/index.js +39 -0
  62. package/dist/components/overlays/context-menu/index.d.ts +97 -0
  63. package/dist/components/overlays/context-menu/index.js +32 -0
  64. package/dist/components/overlays/dialog/index.d.ts +130 -0
  65. package/dist/components/overlays/dialog/index.js +39 -0
  66. package/dist/components/overlays/dropdown/index.d.ts +222 -0
  67. package/dist/components/overlays/dropdown/index.js +47 -0
  68. package/dist/components/overlays/popover/index.d.ts +87 -0
  69. package/dist/components/overlays/popover/index.js +28 -0
  70. package/dist/components/overlays/preview-card/index.d.ts +75 -0
  71. package/dist/components/overlays/preview-card/index.js +21 -0
  72. package/dist/components/overlays/sheet/index.d.ts +67 -0
  73. package/dist/components/overlays/sheet/index.js +26 -0
  74. package/dist/components/overlays/toast/index.d.ts +107 -0
  75. package/dist/components/overlays/toast/index.js +23 -0
  76. package/dist/components/overlays/tooltip/index.d.ts +75 -0
  77. package/dist/components/overlays/tooltip/index.js +19 -0
  78. package/dist/components/table/index.d.ts +44 -0
  79. package/dist/components/table/index.js +28 -0
  80. package/dist/components/thinking-indicator/index.d.ts +32 -0
  81. package/dist/components/thinking-indicator/index.js +15 -0
  82. package/dist/index.d.ts +3926 -0
  83. package/dist/index.js +513 -0
  84. package/dist/preset.d.ts +104 -0
  85. package/dist/preset.js +124 -0
  86. package/dist/primitives/code/index.d.ts +23 -0
  87. package/dist/primitives/code/index.js +12 -0
  88. package/dist/primitives/craft/index.d.ts +31 -0
  89. package/dist/primitives/craft/index.js +13 -0
  90. package/dist/primitives/fluid-hover/index.d.ts +233 -0
  91. package/dist/primitives/fluid-hover/index.js +27 -0
  92. package/dist/primitives/morph/index.d.ts +127 -0
  93. package/dist/primitives/morph/index.js +21 -0
  94. package/dist/primitives/motion/index.d.ts +115 -0
  95. package/dist/primitives/motion/index.js +20 -0
  96. package/dist/primitives/scroll-area/index.d.ts +41 -0
  97. package/dist/primitives/scroll-area/index.js +13 -0
  98. package/dist/primitives/sizes/index.d.ts +128 -0
  99. package/dist/primitives/sizes/index.js +22 -0
  100. package/dist/primitives/surface/index.d.ts +69 -0
  101. package/dist/primitives/surface/index.js +18 -0
  102. package/dist/shared/components-0f0as45n.js +17 -0
  103. package/dist/shared/components-40j34hdb.js +986 -0
  104. package/dist/shared/components-4hh0gm0v.js +292 -0
  105. package/dist/shared/components-4xxddc44.js +15 -0
  106. package/dist/shared/components-4xxtggzp.js +110 -0
  107. package/dist/shared/components-54nf2x99.js +293 -0
  108. package/dist/shared/components-5pkcfprd.js +232 -0
  109. package/dist/shared/components-5vxtcp88.js +9 -0
  110. package/dist/shared/components-5zry9te1.js +152 -0
  111. package/dist/shared/components-61ckf42z.js +220 -0
  112. package/dist/shared/components-6hzwfmfd.js +58 -0
  113. package/dist/shared/components-6phwsry6.js +361 -0
  114. package/dist/shared/components-6t6nr33r.js +86 -0
  115. package/dist/shared/components-6y1th6k4.js +111 -0
  116. package/dist/shared/components-74c20v2f.js +32 -0
  117. package/dist/shared/components-7cqq1sqy.js +193 -0
  118. package/dist/shared/components-7gv95yfy.js +496 -0
  119. package/dist/shared/components-7nww01w4.js +375 -0
  120. package/dist/shared/components-7zp99w5d.js +62 -0
  121. package/dist/shared/components-8hk9ve3r.js +1200 -0
  122. package/dist/shared/components-8hzbsfbd.js +123 -0
  123. package/dist/shared/components-9p8s8n5q.js +171 -0
  124. package/dist/shared/components-aaq3yk4f.js +304 -0
  125. package/dist/shared/components-bf2d9k02.js +484 -0
  126. package/dist/shared/components-bkvb6nem.js +63 -0
  127. package/dist/shared/components-brnzrp2t.js +262 -0
  128. package/dist/shared/components-csxz9f52.js +42 -0
  129. package/dist/shared/components-de8xsm9y.js +22 -0
  130. package/dist/shared/components-dg0w8g5p.js +26 -0
  131. package/dist/shared/components-dphg9gjr.js +42 -0
  132. package/dist/shared/components-e46kf6cp.js +298 -0
  133. package/dist/shared/components-ed7cmssr.js +105 -0
  134. package/dist/shared/components-ess3ch6w.js +137 -0
  135. package/dist/shared/components-gjfrycb5.js +984 -0
  136. package/dist/shared/components-gndm6am4.js +128 -0
  137. package/dist/shared/components-hjkrv00c.js +191 -0
  138. package/dist/shared/components-hzfp4tjb.js +270 -0
  139. package/dist/shared/components-j65qt1mq.js +719 -0
  140. package/dist/shared/components-jw16snbn.js +19 -0
  141. package/dist/shared/components-jxgznftn.js +146 -0
  142. package/dist/shared/components-kf2ehztc.js +216 -0
  143. package/dist/shared/components-kpbcms10.js +9 -0
  144. package/dist/shared/components-m5br529r.js +141 -0
  145. package/dist/shared/components-nn6xezy2.js +1828 -0
  146. package/dist/shared/components-nnnd2xef.js +9 -0
  147. package/dist/shared/components-p2vmyfe1.js +345 -0
  148. package/dist/shared/components-peg09pzs.js +79 -0
  149. package/dist/shared/components-r22vtgqc.js +45 -0
  150. package/dist/shared/components-r2gke5p6.js +1759 -0
  151. package/dist/shared/components-r43mqnd6.js +160 -0
  152. package/dist/shared/components-r4jt6hgd.js +58 -0
  153. package/dist/shared/components-rc63qsy6.js +159 -0
  154. package/dist/shared/components-s3yfvfkr.js +149 -0
  155. package/dist/shared/components-s5pkbjx1.js +445 -0
  156. package/dist/shared/components-tad5h7ta.js +346 -0
  157. package/dist/shared/components-taxmgbnh.js +120 -0
  158. package/dist/shared/components-tm88ghva.js +215 -0
  159. package/dist/shared/components-v7es8aan.js +144 -0
  160. package/dist/shared/components-vb033rns.js +28 -0
  161. package/dist/shared/components-vc1k7yv2.js +30 -0
  162. package/dist/shared/components-vktws5r6.js +667 -0
  163. package/dist/shared/components-x2xyckd5.js +198 -0
  164. package/dist/shared/components-x3rz4cyn.js +61 -0
  165. package/dist/shared/components-xszag63d.js +141 -0
  166. package/dist/shared/components-y3cqdrgy.js +291 -0
  167. package/dist/shared/components-zvb11ker.js +288 -0
  168. package/dist/shared/components-zx2hr57f.js +124 -0
  169. package/dist/styles.css +1949 -0
  170. package/dist/tailwind.css +219 -0
  171. package/dist/tokens.css +345 -0
  172. package/package.json +102 -3
@@ -0,0 +1,375 @@
1
+ import {
2
+ useReduceMotion
3
+ } from "./components-nnnd2xef.js";
4
+ import {
5
+ exitFallbackMs,
6
+ spring
7
+ } from "./components-vc1k7yv2.js";
8
+
9
+ // lib/use-morph.ts
10
+ import { animate, clamp, useMotionValue } from "motion/react";
11
+ import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
12
+ var GOO_MATRIX = "1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 22 -10";
13
+ var GOO_BLUR_RATIO = 0.5;
14
+ var GOO_SURFACE_BLUR = 8;
15
+ var GOO_RELEASE = 0.3;
16
+ var GOO_SETTLE = 0.1;
17
+ var lerp = (a, b, t) => a + (b - a) * t;
18
+ var drawsShape = (effect) => effect === "goo" || effect === "morph";
19
+ function lerpRect(a, b, t) {
20
+ return {
21
+ x: lerp(a.x, b.x, t),
22
+ y: lerp(a.y, b.y, t),
23
+ w: lerp(a.w, b.w, t),
24
+ h: lerp(a.h, b.h, t),
25
+ r: lerp(a.r, b.r, t)
26
+ };
27
+ }
28
+ function clampRect(rect) {
29
+ const w = Math.max(0, rect.w);
30
+ const h = Math.max(0, rect.h);
31
+ return { x: rect.x, y: rect.y, w, h, r: Math.max(0, Math.min(rect.r, w / 2, h / 2)) };
32
+ }
33
+ function roundedRectPath({ x, y, w, h, r }) {
34
+ const n = (value) => value.toFixed(3);
35
+ const arc = `A${n(r)} ${n(r)} 0 0 1`;
36
+ return `M${n(x + r)} ${n(y)}` + `H${n(x + w - r)}${arc} ${n(x + w)} ${n(y + r)}` + `V${n(y + h - r)}${arc} ${n(x + w - r)} ${n(y + h)}` + `H${n(x + r)}${arc} ${n(x)} ${n(y + h - r)}` + `V${n(y + r)}${arc} ${n(x + r)} ${n(y)}Z`;
37
+ }
38
+ function radiusOf(el, width, height) {
39
+ const value = getComputedStyle(el).borderTopLeftRadius;
40
+ const r = value.endsWith("%") ? Number.parseFloat(value) / 100 * width : Number.parseFloat(value);
41
+ return Math.min(r || 0, width / 2, height / 2);
42
+ }
43
+ function onScreen(rect) {
44
+ return rect.width > 0 && rect.height > 0 && rect.bottom > 0 && rect.right > 0 && rect.top < innerHeight && rect.left < innerWidth;
45
+ }
46
+ function sourceElement(from, origin) {
47
+ if (from === "trigger")
48
+ return origin.trigger;
49
+ if (typeof from === "object")
50
+ return from.current ?? undefined;
51
+ }
52
+ function sourceRect(from, origin, box, target) {
53
+ const local = (x, y, w, h, r) => ({
54
+ x: x - box.left,
55
+ y: y - box.top,
56
+ w,
57
+ h,
58
+ r
59
+ });
60
+ const center = { x: target.w / 2, y: target.h / 2, w: 0, h: 0, r: target.r };
61
+ if (from === "center")
62
+ return center;
63
+ if (from === "top")
64
+ return local(box.left, 0, box.width, 0, 0);
65
+ if (from === "bottom")
66
+ return local(box.left, innerHeight, box.width, 0, 0);
67
+ if (from === "left")
68
+ return local(0, box.top, 0, box.height, 0);
69
+ if (from === "right")
70
+ return local(innerWidth, box.top, 0, box.height, 0);
71
+ if (from === "pointer") {
72
+ const trigger = origin.trigger?.getBoundingClientRect();
73
+ const point = origin.point ?? (trigger && { x: trigger.left + trigger.width / 2, y: trigger.top + trigger.height / 2 });
74
+ const d = target.r;
75
+ return point ? local(point.x - d / 2, point.y - d / 2, d, d, d / 2) : center;
76
+ }
77
+ const el = sourceElement(from, origin);
78
+ if (!el)
79
+ return center;
80
+ const rect = el.getBoundingClientRect();
81
+ if (!onScreen(rect))
82
+ return center;
83
+ return local(rect.left, rect.top, rect.width, rect.height, radiusOf(el, rect.width, rect.height));
84
+ }
85
+ function slideOffset(from, source, target, box) {
86
+ if (from === "left")
87
+ return { x: -box.right, y: 0 };
88
+ if (from === "right")
89
+ return { x: innerWidth - box.left, y: 0 };
90
+ if (from === "top")
91
+ return { x: 0, y: -box.bottom };
92
+ if (from === "bottom")
93
+ return { x: 0, y: innerHeight - box.top };
94
+ return { x: source.x + source.w / 2 - target.w / 2, y: source.y + source.h / 2 - target.h / 2 };
95
+ }
96
+ function layerBox(source, target, pad) {
97
+ const x = Math.min(source.x, target.x) - pad;
98
+ const y = Math.min(source.y, target.y) - pad;
99
+ const w = Math.max(source.x + source.w, target.x + target.w) + pad - x;
100
+ const h = Math.max(source.y + source.h, target.y + target.h) + pad - y;
101
+ return { x, y, w, h, r: 0 };
102
+ }
103
+ function overlaps(a, b) {
104
+ return a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h;
105
+ }
106
+ function place(el, { x, y, w, h, r }) {
107
+ if (!el)
108
+ return;
109
+ el.style.inset = "auto";
110
+ el.style.left = `${x}px`;
111
+ el.style.top = `${y}px`;
112
+ el.style.width = `${w}px`;
113
+ el.style.height = `${h}px`;
114
+ el.style.borderRadius = `${r}px`;
115
+ }
116
+ function within(rect, layer) {
117
+ return { ...rect, x: rect.x - layer.x, y: rect.y - layer.y };
118
+ }
119
+ function insetClip(rect, box) {
120
+ const right = box.w - rect.x - rect.w;
121
+ const bottom = box.h - rect.y - rect.h;
122
+ return `inset(${rect.y}px ${right}px ${bottom}px ${rect.x}px round ${rect.r}px)`;
123
+ }
124
+ function opensInPlace({ effect, hideSource = false }) {
125
+ return effect === "morph" && hideSource;
126
+ }
127
+ function inPlaceOffset({ side, anchor }) {
128
+ return side === "top" || side === "bottom" ? -anchor.height : -anchor.width;
129
+ }
130
+ function holdExit(el, tier) {
131
+ return el.animate(null, { duration: exitFallbackMs(spring[tier]) });
132
+ }
133
+ function returnFocus(trigger) {
134
+ requestAnimationFrame(() => requestAnimationFrame(() => {
135
+ const active = document.activeElement;
136
+ if (!trigger.isConnected || active === trigger)
137
+ return;
138
+ if (active && active !== document.body && !active.contains(trigger))
139
+ return;
140
+ trigger.focus({ preventScroll: true });
141
+ }));
142
+ }
143
+ function pressPoint(event) {
144
+ if (event && "touches" in event) {
145
+ const { touches, changedTouches } = event;
146
+ const touch = touches[0] ?? changedTouches[0];
147
+ return touch && { x: touch.clientX, y: touch.clientY };
148
+ }
149
+ if (!(event instanceof MouseEvent))
150
+ return;
151
+ if (event.type === "click" && event.detail === 0)
152
+ return;
153
+ return { x: event.clientX, y: event.clientY };
154
+ }
155
+ function useMorphOrigin() {
156
+ const origin = useRef({});
157
+ const capture = useCallback((details) => {
158
+ const { trigger, event } = details;
159
+ origin.current = {
160
+ trigger: trigger instanceof HTMLElement ? trigger : origin.current.trigger,
161
+ point: pressPoint(event)
162
+ };
163
+ }, []);
164
+ return { origin, capture };
165
+ }
166
+ function useMorph(open, origin, { from = "trigger", effect = "goo", hideSource = false, tier = "slow", exit, instant } = {}, onExited) {
167
+ const reduced = useReduceMotion();
168
+ const resolve = (wanted) => reduced ? "fade" : wanted;
169
+ const resolved = resolve(effect);
170
+ const timing = (effect2) => effect2 === "goo" ? "goo" : tier;
171
+ const progress = useMotionValue(0);
172
+ const gooId = `morph-goo-${useId().replace(/:/g, "")}`;
173
+ const geometry = useRef(null);
174
+ const run = useRef({ effect: resolved, from });
175
+ const targetRadius = useRef(0);
176
+ const hidden = useRef(null);
177
+ const exited = useRef(onExited);
178
+ exited.current = onExited;
179
+ const returnTo = useRef(null);
180
+ const [popup, setPopup] = useState(null);
181
+ const refs = {
182
+ popup: useRef(null),
183
+ shapes: useRef(null),
184
+ blur: useRef(null),
185
+ outline: useRef(null),
186
+ copy: useRef(null),
187
+ shape: useRef(null),
188
+ bg: useRef(null),
189
+ shadow: useRef(null),
190
+ content: useRef(null)
191
+ };
192
+ const render = (p) => {
193
+ const g = geometry.current;
194
+ if (!g)
195
+ return;
196
+ const { bg, content, shadow, popup: popup2, shape } = refs;
197
+ const { effect: effect2 } = run.current;
198
+ const shaped = drawsShape(effect2);
199
+ const slide = { ...g.target, x: g.offset.x * (1 - p), y: g.offset.y * (1 - p) };
200
+ const rect = clampRect(shaped ? lerpRect(g.source, g.target, p) : effect2 === "slide" ? slide : g.target);
201
+ place(shaped ? shape.current : bg.current, shaped ? within(rect, g.layer) : rect);
202
+ place(shadow.current, rect);
203
+ const melting = effect2 === "goo" ? clamp(0, 1, (1 - p) / GOO_RELEASE) : 0;
204
+ refs.blur.current?.setAttribute("stdDeviation", String(g.blur * melting));
205
+ refs.outline.current?.setAttribute("flood-opacity", String(melting * clamp(0, 1, p / GOO_SETTLE)));
206
+ if (shadow.current)
207
+ shadow.current.style.opacity = String(effect2 === "goo" ? 1 - melting : clamp(0, 1, p));
208
+ if (content.current) {
209
+ content.current.style.clipPath = shaped ? insetClip(rect, g.target) : "";
210
+ content.current.style.transform = effect2 === "slide" ? `translate(${rect.x}px, ${rect.y}px)` : "";
211
+ }
212
+ if (popup2.current)
213
+ popup2.current.style.opacity = effect2 === "fade" ? String(p) : "";
214
+ };
215
+ const rest = () => {
216
+ refs.bg.current?.removeAttribute("style");
217
+ refs.shadow.current?.removeAttribute("style");
218
+ if (refs.shapes.current)
219
+ refs.shapes.current.style.display = "";
220
+ if (refs.content.current) {
221
+ refs.content.current.style.clipPath = "";
222
+ refs.content.current.style.transform = "";
223
+ }
224
+ if (refs.popup.current)
225
+ refs.popup.current.style.opacity = "";
226
+ };
227
+ const measure = () => {
228
+ const el = refs.popup.current;
229
+ if (!el)
230
+ return;
231
+ const { effect: effect2, from: from2 } = run.current;
232
+ const shaped = drawsShape(effect2);
233
+ const box = el.getBoundingClientRect();
234
+ const target = { x: 0, y: 0, w: box.width, h: box.height, r: targetRadius.current };
235
+ const source = sourceRect(from2, origin.current ?? {}, box, target);
236
+ const blur = effect2 === "goo" ? Math.max(GOO_SURFACE_BLUR, target.r * GOO_BLUR_RATIO) : 0;
237
+ const layer = layerBox(source, target, blur * 3);
238
+ geometry.current = { source, target, layer, offset: slideOffset(from2, source, target, box), blur };
239
+ const { shapes, copy, bg } = refs;
240
+ if (bg.current)
241
+ bg.current.style.opacity = shaped ? "0" : "";
242
+ if (!shapes.current)
243
+ return;
244
+ shapes.current.style.display = shaped ? "block" : "";
245
+ if (!shaped)
246
+ return;
247
+ place(shapes.current, { ...layer, r: 0 });
248
+ if (effect2 === "goo")
249
+ place(copy.current, within(source, layer));
250
+ const cut = source.w > 0 && source.h > 0 && !hideSource && !overlaps(source, target);
251
+ shapes.current.style.clipPath = cut ? `path(evenodd, "${roundedRectPath({ ...layer, x: 0, y: 0 })} ${roundedRectPath(within(source, layer))}")` : "";
252
+ };
253
+ const reveal = () => {
254
+ if (!hidden.current)
255
+ return;
256
+ hidden.current.el.style.opacity = hidden.current.opacity;
257
+ hidden.current = null;
258
+ };
259
+ const hide = (el) => {
260
+ if (!hideSource || !el || hidden.current?.el === el)
261
+ return;
262
+ reveal();
263
+ hidden.current = { el, opacity: el.style.opacity };
264
+ el.style.opacity = "0";
265
+ };
266
+ const skip = (el) => instant?.(el);
267
+ const opening = (popup2) => {
268
+ returnTo.current = null;
269
+ run.current = { effect: resolved, from };
270
+ const first = !geometry.current;
271
+ if (first && refs.bg.current) {
272
+ const box = popup2.getBoundingClientRect();
273
+ targetRadius.current = radiusOf(refs.bg.current, box.width, box.height);
274
+ }
275
+ let controls;
276
+ const begin = () => {
277
+ measure();
278
+ hide(sourceElement(from, origin.current ?? {}));
279
+ if (skip(popup2)) {
280
+ progress.jump(1);
281
+ rest();
282
+ return;
283
+ }
284
+ render(progress.get());
285
+ const { exit: _, ...enter } = spring[timing(run.current.effect)];
286
+ controls = animate(progress, 1, {
287
+ ...enter,
288
+ onUpdate: (p) => {
289
+ if (skip(popup2))
290
+ controls?.complete();
291
+ render(p);
292
+ },
293
+ onComplete: rest
294
+ });
295
+ };
296
+ if (!first || skip(popup2) || !refs.bg.current) {
297
+ begin();
298
+ return () => controls?.stop();
299
+ }
300
+ refs.bg.current.style.opacity = "0";
301
+ if (refs.shadow.current)
302
+ refs.shadow.current.style.opacity = "0";
303
+ if (refs.content.current)
304
+ refs.content.current.style.clipPath = "inset(50%)";
305
+ const frame = requestAnimationFrame(begin);
306
+ return () => {
307
+ cancelAnimationFrame(frame);
308
+ controls?.stop();
309
+ };
310
+ };
311
+ const closing = (popup2) => {
312
+ returnTo.current = popup2.contains(document.activeElement) ? origin.current?.trigger ?? null : null;
313
+ if (!geometry.current) {
314
+ exited.current?.();
315
+ return;
316
+ }
317
+ const done = () => {
318
+ reveal();
319
+ geometry.current = null;
320
+ exited.current?.();
321
+ };
322
+ if (skip(popup2)) {
323
+ progress.jump(0);
324
+ popup2.style.opacity = "0";
325
+ done();
326
+ return;
327
+ }
328
+ run.current = { effect: resolve(exit?.effect ?? effect), from: exit?.from ?? from };
329
+ if (exit)
330
+ progress.jump(1);
331
+ const hold = holdExit(popup2, timing(run.current.effect));
332
+ measure();
333
+ render(progress.get());
334
+ let controls;
335
+ controls = animate(progress, 0, {
336
+ ...spring[timing(run.current.effect)].exit,
337
+ onUpdate: (p) => {
338
+ if (skip(popup2))
339
+ controls?.complete();
340
+ render(p);
341
+ },
342
+ onComplete: () => {
343
+ hold.finish();
344
+ done();
345
+ }
346
+ });
347
+ return () => {
348
+ controls?.stop();
349
+ hold.cancel();
350
+ };
351
+ };
352
+ useLayoutEffect(() => {
353
+ if (!popup) {
354
+ reveal();
355
+ progress.jump(0);
356
+ if (geometry.current && !open)
357
+ exited.current?.();
358
+ geometry.current = null;
359
+ return;
360
+ }
361
+ return open ? opening(popup) : closing(popup);
362
+ }, [open, popup]);
363
+ useEffect(() => reveal, []);
364
+ const popupRef = useCallback((node) => {
365
+ refs.popup.current = node;
366
+ setPopup(node);
367
+ if (node || !returnTo.current)
368
+ return;
369
+ returnFocus(returnTo.current);
370
+ returnTo.current = null;
371
+ }, []);
372
+ return { refs, popupRef, popup, gooId, effect: resolved, progress };
373
+ }
374
+
375
+ export { GOO_MATRIX, GOO_BLUR_RATIO, opensInPlace, inPlaceOffset, holdExit, useMorphOrigin, useMorph };
@@ -0,0 +1,62 @@
1
+ // lib/shape-context.tsx
2
+ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ var shapeMap = {
5
+ pill: {
6
+ variant: "pill",
7
+ item: "rounded-[20px]",
8
+ bg: "rounded-[20px]",
9
+ focusRing: "rounded-[22px]",
10
+ mergedBg: "rounded-2xl",
11
+ container: "rounded-3xl",
12
+ button: "rounded-[20px]",
13
+ input: "rounded-[20px]",
14
+ bgRadius: 20,
15
+ mergedRadius: 16
16
+ },
17
+ rounded: {
18
+ variant: "rounded",
19
+ item: "rounded-lg",
20
+ bg: "rounded-lg",
21
+ focusRing: "rounded-[10px]",
22
+ mergedBg: "rounded-lg",
23
+ container: "rounded-xl",
24
+ button: "rounded-lg",
25
+ input: "rounded-lg",
26
+ bgRadius: 8,
27
+ mergedRadius: 8
28
+ }
29
+ };
30
+ var ShapeContext = createContext(null);
31
+ function useShape() {
32
+ const ctx = useContext(ShapeContext);
33
+ if (!ctx)
34
+ return shapeMap.rounded;
35
+ return ctx.classes;
36
+ }
37
+ function ShapeProvider({ children, defaultShape = "rounded" }) {
38
+ const [shape, setShapeState] = useState(defaultShape);
39
+ const transitionTimeoutRef = useRef(null);
40
+ const transitionShape = useCallback((callback) => {
41
+ const root = document.documentElement;
42
+ root.classList.add("transitioning");
43
+ root.offsetHeight;
44
+ callback();
45
+ if (transitionTimeoutRef.current)
46
+ clearTimeout(transitionTimeoutRef.current);
47
+ transitionTimeoutRef.current = setTimeout(() => root.classList.remove("transitioning"), 200);
48
+ }, []);
49
+ const setShape = useCallback((next) => {
50
+ transitionShape(() => setShapeState(next));
51
+ }, [transitionShape]);
52
+ useEffect(() => {
53
+ document.documentElement.style.setProperty("--shape-input-radius", `${shapeMap[shape].bgRadius}px`);
54
+ }, [shape]);
55
+ const value = useMemo(() => ({ shape, setShape, classes: shapeMap[shape] }), [shape, setShape]);
56
+ return /* @__PURE__ */ jsx(ShapeContext.Provider, {
57
+ value,
58
+ children
59
+ });
60
+ }
61
+
62
+ export { shapeMap, useShape, ShapeProvider };