@justanarthur/modo-ui 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.
- package/LICENSE +21 -0
- package/LICENSE.beui +21 -0
- package/LICENSE.fluid-functionalism +21 -0
- package/LICENSE.motion-primitives +21 -0
- package/LICENSE.sileo +21 -0
- package/README.md +608 -2
- package/dist/base.css +994 -0
- package/dist/blocks/sidebar-app/index.d.ts +34 -0
- package/dist/blocks/sidebar-app/index.js +31 -0
- package/dist/components/badge/index.d.ts +59 -0
- package/dist/components/badge/index.js +16 -0
- package/dist/components/button/index.d.ts +59 -0
- package/dist/components/button/index.js +14 -0
- package/dist/components/card/index.d.ts +141 -0
- package/dist/components/card/index.js +42 -0
- package/dist/components/inputs/checkbox-group/index.d.ts +50 -0
- package/dist/components/inputs/checkbox-group/index.js +21 -0
- package/dist/components/inputs/color-picker/index.d.ts +137 -0
- package/dist/components/inputs/color-picker/index.js +35 -0
- package/dist/components/inputs/combobox/index.d.ts +161 -0
- package/dist/components/inputs/combobox/index.js +38 -0
- package/dist/components/inputs/date-time/calendar/index.d.ts +45 -0
- package/dist/components/inputs/date-time/calendar/index.js +18 -0
- package/dist/components/inputs/date-time/date-picker/index.d.ts +82 -0
- package/dist/components/inputs/date-time/date-picker/index.js +32 -0
- package/dist/components/inputs/date-time/date-range-picker/index.d.ts +64 -0
- package/dist/components/inputs/date-time/date-range-picker/index.js +31 -0
- package/dist/components/inputs/date-time/duration-picker/index.d.ts +57 -0
- package/dist/components/inputs/date-time/duration-picker/index.js +31 -0
- package/dist/components/inputs/date-time/month-picker/index.d.ts +57 -0
- package/dist/components/inputs/date-time/month-picker/index.js +30 -0
- package/dist/components/inputs/date-time/time-picker/index.d.ts +59 -0
- package/dist/components/inputs/date-time/time-picker/index.js +31 -0
- package/dist/components/inputs/input/index.d.ts +84 -0
- package/dist/components/inputs/input/index.js +19 -0
- package/dist/components/inputs/input-copy/index.d.ts +44 -0
- package/dist/components/inputs/input-copy/index.js +16 -0
- package/dist/components/inputs/input-message/index.d.ts +125 -0
- package/dist/components/inputs/input-message/index.js +25 -0
- package/dist/components/inputs/radio-group/index.d.ts +58 -0
- package/dist/components/inputs/radio-group/index.js +20 -0
- package/dist/components/inputs/search/index.d.ts +83 -0
- package/dist/components/inputs/search/index.js +25 -0
- package/dist/components/inputs/select/index.d.ts +105 -0
- package/dist/components/inputs/select/index.js +34 -0
- package/dist/components/inputs/slider/index.d.ts +108 -0
- package/dist/components/inputs/slider/index.js +14 -0
- package/dist/components/inputs/switch/index.d.ts +43 -0
- package/dist/components/inputs/switch/index.js +14 -0
- package/dist/components/navigation/accordion/index.d.ts +117 -0
- package/dist/components/navigation/accordion/index.js +28 -0
- package/dist/components/navigation/sidebar/index.d.ts +388 -0
- package/dist/components/navigation/sidebar/index.js +99 -0
- package/dist/components/navigation/tabs/index.d.ts +70 -0
- package/dist/components/navigation/tabs/index.js +23 -0
- package/dist/components/navigation/tabs-subtle/index.d.ts +73 -0
- package/dist/components/navigation/tabs-subtle/index.js +21 -0
- package/dist/components/overlays/alert-dialog/index.d.ts +67 -0
- package/dist/components/overlays/alert-dialog/index.js +22 -0
- package/dist/components/overlays/command/index.d.ts +121 -0
- package/dist/components/overlays/command/index.js +36 -0
- package/dist/components/overlays/context-menu/index.d.ts +97 -0
- package/dist/components/overlays/context-menu/index.js +29 -0
- package/dist/components/overlays/dialog/index.d.ts +130 -0
- package/dist/components/overlays/dialog/index.js +37 -0
- package/dist/components/overlays/dropdown/index.d.ts +222 -0
- package/dist/components/overlays/dropdown/index.js +44 -0
- package/dist/components/overlays/popover/index.d.ts +87 -0
- package/dist/components/overlays/popover/index.js +26 -0
- package/dist/components/overlays/preview-card/index.d.ts +75 -0
- package/dist/components/overlays/preview-card/index.js +19 -0
- package/dist/components/overlays/sheet/index.d.ts +67 -0
- package/dist/components/overlays/sheet/index.js +24 -0
- package/dist/components/overlays/toast/index.d.ts +107 -0
- package/dist/components/overlays/toast/index.js +21 -0
- package/dist/components/overlays/tooltip/index.d.ts +75 -0
- package/dist/components/overlays/tooltip/index.js +17 -0
- package/dist/components/table/index.d.ts +44 -0
- package/dist/components/table/index.js +26 -0
- package/dist/components/thinking-indicator/index.d.ts +32 -0
- package/dist/components/thinking-indicator/index.js +13 -0
- package/dist/index.d.ts +3926 -0
- package/dist/index.js +511 -0
- package/dist/preset.d.ts +104 -0
- package/dist/preset.js +124 -0
- package/dist/primitives/code/index.d.ts +23 -0
- package/dist/primitives/code/index.js +11 -0
- package/dist/primitives/craft/index.d.ts +31 -0
- package/dist/primitives/craft/index.js +11 -0
- package/dist/primitives/fluid-hover/index.d.ts +233 -0
- package/dist/primitives/fluid-hover/index.js +25 -0
- package/dist/primitives/morph/index.d.ts +127 -0
- package/dist/primitives/morph/index.js +19 -0
- package/dist/primitives/motion/index.d.ts +115 -0
- package/dist/primitives/motion/index.js +19 -0
- package/dist/primitives/scroll-area/index.d.ts +41 -0
- package/dist/primitives/scroll-area/index.js +12 -0
- package/dist/primitives/sizes/index.d.ts +128 -0
- package/dist/primitives/sizes/index.js +21 -0
- package/dist/primitives/surface/index.d.ts +69 -0
- package/dist/primitives/surface/index.js +17 -0
- package/dist/shared/components-0ke6xada.js +123 -0
- package/dist/shared/components-0q0sqfh4.js +146 -0
- package/dist/shared/components-0sn7ypjw.js +61 -0
- package/dist/shared/components-1j9791sn.js +345 -0
- package/dist/shared/components-1rfwbyyc.js +361 -0
- package/dist/shared/components-1v7rxytx.js +30 -0
- package/dist/shared/components-1xekx2hx.js +215 -0
- package/dist/shared/components-39jq9va1.js +86 -0
- package/dist/shared/components-3gae8nta.js +719 -0
- package/dist/shared/components-3k8xpnpq.js +1759 -0
- package/dist/shared/components-3ky44908.js +9 -0
- package/dist/shared/components-3mkepka5.js +111 -0
- package/dist/shared/components-3wk0w46f.js +667 -0
- package/dist/shared/components-4cnjmgex.js +124 -0
- package/dist/shared/components-59efxjd9.js +298 -0
- package/dist/shared/components-5xc2j8jz.js +159 -0
- package/dist/shared/components-62ybc7t2.js +496 -0
- package/dist/shared/components-66mv71kx.js +262 -0
- package/dist/shared/components-7ans7ce5.js +120 -0
- package/dist/shared/components-7btqt08d.js +270 -0
- package/dist/shared/components-7r3etddy.js +171 -0
- package/dist/shared/components-7x9kawxv.js +152 -0
- package/dist/shared/components-8fpr3s4p.js +292 -0
- package/dist/shared/components-9jvzzvt1.js +198 -0
- package/dist/shared/components-apdwtweq.js +484 -0
- package/dist/shared/components-asr5pg50.js +191 -0
- package/dist/shared/components-b2wyq2cq.js +232 -0
- package/dist/shared/components-c6s6b43g.js +15 -0
- package/dist/shared/components-ca2c898n.js +1828 -0
- package/dist/shared/components-cbxjn9p8.js +141 -0
- package/dist/shared/components-chacnk61.js +216 -0
- package/dist/shared/components-cv16mryv.js +62 -0
- package/dist/shared/components-ez65vtbq.js +110 -0
- package/dist/shared/components-ezxhrmer.js +17 -0
- package/dist/shared/components-gc5vtq2f.js +149 -0
- package/dist/shared/components-gf5s6ap9.js +42 -0
- package/dist/shared/components-gvr9w41t.js +193 -0
- package/dist/shared/components-h2dpcwgc.js +137 -0
- package/dist/shared/components-hawvy2qz.js +105 -0
- package/dist/shared/components-hqeq3w9q.js +375 -0
- package/dist/shared/components-jjw69c4c.js +28 -0
- package/dist/shared/components-jwst3vtj.js +346 -0
- package/dist/shared/components-kvr7f9hy.js +45 -0
- package/dist/shared/components-men63rwj.js +9 -0
- package/dist/shared/components-mhd39z7x.js +22 -0
- package/dist/shared/components-n7mjr357.js +26 -0
- package/dist/shared/components-ng72k97e.js +128 -0
- package/dist/shared/components-nh8tma1n.js +986 -0
- package/dist/shared/components-njzgqdwy.js +445 -0
- package/dist/shared/components-ny774h8p.js +293 -0
- package/dist/shared/components-q4daerx0.js +58 -0
- package/dist/shared/components-q5xj5c16.js +79 -0
- package/dist/shared/components-rr7a6ja9.js +160 -0
- package/dist/shared/components-s2bz1xpk.js +63 -0
- package/dist/shared/components-tqvarbfv.js +288 -0
- package/dist/shared/components-v6xp325t.js +304 -0
- package/dist/shared/components-v7wtz8hk.js +144 -0
- package/dist/shared/components-vc7vq5nz.js +32 -0
- package/dist/shared/components-vfbhxf5r.js +58 -0
- package/dist/shared/components-vynjtrk6.js +19 -0
- package/dist/shared/components-wvp1m52g.js +1200 -0
- package/dist/shared/components-yh3kwdhr.js +981 -0
- package/dist/shared/components-ytb2tefr.js +291 -0
- package/dist/shared/components-zfnmn5d4.js +220 -0
- package/dist/shared/components-zrkzcayz.js +141 -0
- package/dist/shared/components-zx6b6yby.js +42 -0
- package/dist/styles.css +1949 -0
- package/dist/tailwind.css +219 -0
- package/dist/tokens.css +345 -0
- package/package.json +103 -4
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useReduceMotion
|
|
3
|
+
} from "./components-men63rwj.js";
|
|
4
|
+
import {
|
|
5
|
+
spring2,
|
|
6
|
+
exitFallbackMs2
|
|
7
|
+
} from "./components-1v7rxytx.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: exitFallbackMs2(spring2[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 = (effect) => effect === "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, shape } = refs;
|
|
197
|
+
const { effect } = run.current;
|
|
198
|
+
const shaped = drawsShape(effect);
|
|
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) : effect === "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 = effect === "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(effect === "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 = effect === "slide" ? `translate(${rect.x}px, ${rect.y}px)` : "";
|
|
211
|
+
}
|
|
212
|
+
if (popup.current)
|
|
213
|
+
popup.current.style.opacity = effect === "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, from } = run.current;
|
|
232
|
+
const shaped = drawsShape(effect);
|
|
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(from, origin.current ?? {}, box, target);
|
|
236
|
+
const blur = effect === "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(from, 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 (effect === "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 = (popup) => {
|
|
268
|
+
returnTo.current = null;
|
|
269
|
+
run.current = { effect: resolved, from };
|
|
270
|
+
const first = !geometry.current;
|
|
271
|
+
if (first && refs.bg.current) {
|
|
272
|
+
const box = popup.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(popup)) {
|
|
280
|
+
progress.jump(1);
|
|
281
|
+
rest();
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
render(progress.get());
|
|
285
|
+
const { exit: _, ...enter } = spring2[timing(run.current.effect)];
|
|
286
|
+
controls = animate(progress, 1, {
|
|
287
|
+
...enter,
|
|
288
|
+
onUpdate: (p) => {
|
|
289
|
+
if (skip(popup))
|
|
290
|
+
controls?.complete();
|
|
291
|
+
render(p);
|
|
292
|
+
},
|
|
293
|
+
onComplete: rest
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
if (!first || skip(popup) || !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 = (popup) => {
|
|
312
|
+
returnTo.current = popup.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(popup)) {
|
|
323
|
+
progress.jump(0);
|
|
324
|
+
popup.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(popup, timing(run.current.effect));
|
|
332
|
+
measure();
|
|
333
|
+
render(progress.get());
|
|
334
|
+
let controls;
|
|
335
|
+
controls = animate(progress, 0, {
|
|
336
|
+
...spring2[timing(run.current.effect)].exit,
|
|
337
|
+
onUpdate: (p) => {
|
|
338
|
+
if (skip(popup))
|
|
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,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sizeMap2,
|
|
3
|
+
SizeContext
|
|
4
|
+
} from "./components-0sn7ypjw.js";
|
|
5
|
+
|
|
6
|
+
// primitives/sizes/index.tsx
|
|
7
|
+
import { useCallback, useMemo, useState } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
function SizeProvider2({
|
|
10
|
+
children,
|
|
11
|
+
size,
|
|
12
|
+
defaultSize = "default"
|
|
13
|
+
}) {
|
|
14
|
+
const [internalSize, setInternalSize] = useState(defaultSize);
|
|
15
|
+
const isControlled = size !== undefined;
|
|
16
|
+
const resolved = size ?? internalSize;
|
|
17
|
+
const setSize = useCallback((next) => {
|
|
18
|
+
if (isControlled)
|
|
19
|
+
return;
|
|
20
|
+
setInternalSize(next);
|
|
21
|
+
}, [isControlled]);
|
|
22
|
+
const value = useMemo(() => ({ size: resolved, setSize, classes: sizeMap2[resolved] }), [resolved, setSize]);
|
|
23
|
+
return /* @__PURE__ */ jsx(SizeContext.Provider, {
|
|
24
|
+
value,
|
|
25
|
+
children
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export { SizeProvider2 };
|