beez-ui 0.5.3 → 0.5.4
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/CHANGELOG.md +4 -0
- package/README.md +63 -2
- package/dist/components/alert-dialog.js +72 -28
- package/dist/components/alert.js +9 -5
- package/dist/components/animated-theme-toggler.js +113 -97
- package/dist/components/avatar.js +22 -15
- package/dist/components/badge.js +9 -5
- package/dist/components/button.js +11 -7
- package/dist/components/card.js +9 -5
- package/dist/components/carousel.js +59 -55
- package/dist/components/checkbox.js +16 -9
- package/dist/components/dialog.js +77 -33
- package/dist/components/dropdown-menu.js +126 -49
- package/dist/components/form.js +16 -9
- package/dist/components/highlighter.js +18 -12
- package/dist/components/hover-card.js +60 -21
- package/dist/components/input-group.js +9 -5
- package/dist/components/input.js +9 -5
- package/dist/components/label.js +8 -4
- package/dist/components/link.d.ts +0 -1
- package/dist/components/link.js +28 -20
- package/dist/components/popover.js +66 -25
- package/dist/components/radio-group.js +16 -9
- package/dist/components/select.js +34 -24
- package/dist/components/separator.js +9 -5
- package/dist/components/sheet.js +78 -34
- package/dist/components/sidebar.js +21 -14
- package/dist/components/skeleton.js +8 -4
- package/dist/components/svgs/whatsappIcon.js +14 -9
- package/dist/components/switch.js +16 -9
- package/dist/components/table.js +8 -4
- package/dist/components/tabs.js +15 -8
- package/dist/components/textarea.js +8 -4
- package/dist/components/themed-toaster.js +61 -27
- package/dist/components/tooltip.js +70 -29
- package/dist/components/typing-animation.js +80 -58
- package/dist/constants/motion.d.ts +2 -0
- package/dist/constants/motion.js +2 -0
- package/dist/hooks/use-prefers-reduced-motion.d.ts +2 -0
- package/dist/hooks/use-prefers-reduced-motion.js +27 -0
- package/dist/motion/motion-slot.d.ts +9 -0
- package/dist/motion/motion-slot.js +353 -0
- package/dist/motion/presence.d.ts +33 -0
- package/dist/motion/presence.js +92 -0
- package/dist/motion/tokens.d.ts +13 -0
- package/dist/motion/tokens.js +17 -0
- package/dist/providers/beez-ui-provider.js +7 -3
- package/dist/styles.css +1 -1
- package/package.json +12 -4
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c as _c } from "react/compiler-runtime";
|
|
3
|
+
/** Animates the original primitive node with Motion, without adding DOM wrappers. */
|
|
4
|
+
import { useLayoutEffect, useState } from "react";
|
|
5
|
+
import { Slot } from "radix-ui";
|
|
6
|
+
import { animate, hover, press, usePresence, frame } from "motion/react";
|
|
7
|
+
import { usePrefersReducedMotion } from "../hooks/use-prefers-reduced-motion.js";
|
|
8
|
+
import { MOTION_EASE, MOTION_TIMING, MOTION_PRESS_SCALE, MOTION_SURFACE_DISTANCE, MOTION_PANEL_DISTANCE } from "./tokens.js";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
/** Checks the actual DOM state rather than intercepting the component's event handlers. */
|
|
11
|
+
function isEnabled(element) {
|
|
12
|
+
return !element.hasAttribute("disabled") && element.getAttribute("aria-disabled") !== "true" && !element.hasAttribute("data-disabled");
|
|
13
|
+
}
|
|
14
|
+
/** Computes a small offset toward the surface's originating edge. */
|
|
15
|
+
function entryTransform(element, kind) {
|
|
16
|
+
if (kind === "dialog") return "scale(0.985)";
|
|
17
|
+
const distance = kind === "sheet" ? MOTION_PANEL_DISTANCE : MOTION_SURFACE_DISTANCE;
|
|
18
|
+
const direction = element.getAttribute("data-side");
|
|
19
|
+
const offset = kind === "sheet" ? distance : -distance;
|
|
20
|
+
if (direction === "left") return `translateX(${-offset}px)`;
|
|
21
|
+
if (direction === "right") return `translateX(${offset}px)`;
|
|
22
|
+
if (direction === "top") return `translateY(${-offset}px)`;
|
|
23
|
+
return `translateY(${offset}px)`;
|
|
24
|
+
}
|
|
25
|
+
/** Uses explicit identity transforms so Motion never interprets a missing scale as zero. */
|
|
26
|
+
function restingTransform(element, kind) {
|
|
27
|
+
if (kind === "dialog") return "scale(1)";
|
|
28
|
+
const direction = element.getAttribute("data-side");
|
|
29
|
+
return direction === "left" || direction === "right" ? "translateX(0px)" : "translateY(0px)";
|
|
30
|
+
}
|
|
31
|
+
/** Composes refs through Radix Slot and delegates gesture, entry and exit playback to Motion. */
|
|
32
|
+
export function MotionSlot(t0) {
|
|
33
|
+
const $ = _c(21);
|
|
34
|
+
let children;
|
|
35
|
+
let props;
|
|
36
|
+
let ref;
|
|
37
|
+
let t1;
|
|
38
|
+
if ($[0] !== t0) {
|
|
39
|
+
({children, kind: t1, ref, ...props} = t0);
|
|
40
|
+
$[0] = t0;
|
|
41
|
+
$[1] = children;
|
|
42
|
+
$[2] = props;
|
|
43
|
+
$[3] = ref;
|
|
44
|
+
$[4] = t1;
|
|
45
|
+
} else {
|
|
46
|
+
children = $[1];
|
|
47
|
+
props = $[2];
|
|
48
|
+
ref = $[3];
|
|
49
|
+
t1 = $[4];
|
|
50
|
+
}
|
|
51
|
+
const kind = t1 === undefined ? "fade" : t1;
|
|
52
|
+
const [element, setElement] = useState(null);
|
|
53
|
+
let t2;
|
|
54
|
+
if ($[5] !== ref) {
|
|
55
|
+
t2 = (node) => {
|
|
56
|
+
setElement(node);
|
|
57
|
+
const cleanup = typeof ref === "function" ? ref(node) : undefined;
|
|
58
|
+
if (ref && typeof ref !== "function") {
|
|
59
|
+
ref.current = node;
|
|
60
|
+
}
|
|
61
|
+
return () => {
|
|
62
|
+
setElement(null);
|
|
63
|
+
if (typeof cleanup === "function") {
|
|
64
|
+
cleanup();
|
|
65
|
+
} else {
|
|
66
|
+
if (typeof ref === "function") {
|
|
67
|
+
ref(null);
|
|
68
|
+
} else {
|
|
69
|
+
if (ref) {
|
|
70
|
+
ref.current = null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
$[5] = ref;
|
|
77
|
+
$[6] = t2;
|
|
78
|
+
} else {
|
|
79
|
+
t2 = $[6];
|
|
80
|
+
}
|
|
81
|
+
const attach = t2;
|
|
82
|
+
const reduceMotion = usePrefersReducedMotion();
|
|
83
|
+
const [isPresent, safeToRemove] = usePresence();
|
|
84
|
+
let t3;
|
|
85
|
+
let t4;
|
|
86
|
+
if ($[7] !== element || $[8] !== isPresent || $[9] !== kind || $[10] !== reduceMotion || $[11] !== safeToRemove) {
|
|
87
|
+
t3 = () => {
|
|
88
|
+
let active = true;
|
|
89
|
+
if (!element) {
|
|
90
|
+
if (!isPresent) {
|
|
91
|
+
queueMicrotask(() => {
|
|
92
|
+
if (active) {
|
|
93
|
+
safeToRemove?.();
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return () => {
|
|
98
|
+
active = false;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const animations = new Set();
|
|
102
|
+
const cleanups = [];
|
|
103
|
+
const original = {
|
|
104
|
+
opacity: element.style.opacity,
|
|
105
|
+
transform: element.style.transform,
|
|
106
|
+
translate: element.style.translate,
|
|
107
|
+
boxShadow: element.style.boxShadow
|
|
108
|
+
};
|
|
109
|
+
const restore = function restore() {
|
|
110
|
+
element.style.opacity = original.opacity;
|
|
111
|
+
element.style.transform = original.transform;
|
|
112
|
+
element.style.translate = original.translate;
|
|
113
|
+
element.style.boxShadow = original.boxShadow;
|
|
114
|
+
};
|
|
115
|
+
const dispose = function dispose() {
|
|
116
|
+
active = false;
|
|
117
|
+
cleanups.forEach(_temp);
|
|
118
|
+
animations.forEach(_temp2);
|
|
119
|
+
restore();
|
|
120
|
+
};
|
|
121
|
+
if (reduceMotion || !isPresent && element.hasAttribute("data-beez-theme-menu")) {
|
|
122
|
+
if (!isPresent) {
|
|
123
|
+
queueMicrotask(() => {
|
|
124
|
+
if (active) {
|
|
125
|
+
safeToRemove?.();
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return dispose;
|
|
130
|
+
}
|
|
131
|
+
const play = function play(keyframes, duration, t5, t6) {
|
|
132
|
+
const remove = t5 === undefined ? false : t5;
|
|
133
|
+
const restoreOnComplete = t6 === undefined ? true : t6;
|
|
134
|
+
animations.forEach(_temp3);
|
|
135
|
+
animations.clear();
|
|
136
|
+
const animation_1 = animate(element, keyframes, {
|
|
137
|
+
duration,
|
|
138
|
+
ease: [...MOTION_EASE]
|
|
139
|
+
});
|
|
140
|
+
animations.add(animation_1);
|
|
141
|
+
animation_1.then(() => {
|
|
142
|
+
animations.delete(animation_1);
|
|
143
|
+
if (!active) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (remove) {
|
|
147
|
+
safeToRemove?.();
|
|
148
|
+
} else {
|
|
149
|
+
if (restoreOnComplete) {
|
|
150
|
+
frame.postRender(() => {
|
|
151
|
+
if (active && !animations.size) {
|
|
152
|
+
restore();
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
const isSurface = [
|
|
160
|
+
"surface",
|
|
161
|
+
"dialog",
|
|
162
|
+
"sheet",
|
|
163
|
+
"overlay"
|
|
164
|
+
].includes(kind);
|
|
165
|
+
if (!isPresent) {
|
|
166
|
+
if (!isSurface) {
|
|
167
|
+
queueMicrotask(() => {
|
|
168
|
+
if (active) {
|
|
169
|
+
safeToRemove?.();
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
return dispose;
|
|
173
|
+
}
|
|
174
|
+
const keyframes_0 = kind === "overlay" ? { opacity: [1, 0] } : {
|
|
175
|
+
opacity: [1, 0],
|
|
176
|
+
transform: [restingTransform(element, kind), entryTransform(element, kind)]
|
|
177
|
+
};
|
|
178
|
+
play(keyframes_0, MOTION_TIMING.exit, true);
|
|
179
|
+
return dispose;
|
|
180
|
+
}
|
|
181
|
+
if (isSurface) {
|
|
182
|
+
const keyframes_1 = kind === "overlay" ? { opacity: [0, 1] } : {
|
|
183
|
+
opacity: [0, 1],
|
|
184
|
+
transform: [entryTransform(element, kind), restingTransform(element, kind)]
|
|
185
|
+
};
|
|
186
|
+
play(keyframes_1, kind === "dialog" || kind === "sheet" ? MOTION_TIMING.panel : MOTION_TIMING.enter);
|
|
187
|
+
} else {
|
|
188
|
+
if (kind === "skeleton") {
|
|
189
|
+
animations.add(animate(element, { opacity: [
|
|
190
|
+
1,
|
|
191
|
+
.6,
|
|
192
|
+
1
|
|
193
|
+
] }, {
|
|
194
|
+
duration: MOTION_TIMING.skeleton,
|
|
195
|
+
repeat: Infinity,
|
|
196
|
+
ease: "easeInOut"
|
|
197
|
+
}));
|
|
198
|
+
} else {
|
|
199
|
+
if (kind === "selection") {
|
|
200
|
+
play({
|
|
201
|
+
opacity: [0, 1],
|
|
202
|
+
transform: ["scale(0.85)", "scale(1)"]
|
|
203
|
+
}, MOTION_TIMING.fast);
|
|
204
|
+
} else {
|
|
205
|
+
if (kind === "fade" || kind === "card" || kind === "row") {
|
|
206
|
+
play({ opacity: [0, 1] }, MOTION_TIMING.enter);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (kind === "press") {
|
|
212
|
+
cleanups.push(press(element, () => {
|
|
213
|
+
if (!isEnabled(element)) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
play({ transform: ["scale(1)", `scale(${MOTION_PRESS_SCALE})`] }, MOTION_TIMING.fast, false, false);
|
|
217
|
+
return () => play({ transform: [`scale(${MOTION_PRESS_SCALE})`, "scale(1)"] }, MOTION_TIMING.fast);
|
|
218
|
+
}));
|
|
219
|
+
}
|
|
220
|
+
if (kind === "card" || kind === "link" || kind === "icon") {
|
|
221
|
+
cleanups.push(hover(element, () => {
|
|
222
|
+
if (!isEnabled(element) || kind === "card" && !element.querySelector("a,button")) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (kind === "card") {
|
|
226
|
+
play({ boxShadow: "0 4px 16px rgba(0,0,0,0.08)" }, MOTION_TIMING.enter, false, false);
|
|
227
|
+
} else {
|
|
228
|
+
if (kind === "icon") {
|
|
229
|
+
play({ transform: ["rotate(0deg) scale(1)", "rotate(-3deg) scale(1.025)"] }, MOTION_TIMING.enter, false, false);
|
|
230
|
+
} else {
|
|
231
|
+
play({ opacity: .75 }, MOTION_TIMING.fast, false, false);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return () => {
|
|
235
|
+
if (kind === "card") {
|
|
236
|
+
play({ boxShadow: original.boxShadow || "0 0px 0px rgba(0,0,0,0)" }, MOTION_TIMING.fast);
|
|
237
|
+
} else {
|
|
238
|
+
if (kind === "icon") {
|
|
239
|
+
play({ transform: ["rotate(-3deg) scale(1.025)", "rotate(0deg) scale(1)"] }, MOTION_TIMING.fast);
|
|
240
|
+
} else {
|
|
241
|
+
play({ opacity: 1 }, MOTION_TIMING.fast);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
}));
|
|
246
|
+
}
|
|
247
|
+
if (kind === "field") {
|
|
248
|
+
const focus = () => {
|
|
249
|
+
if (isEnabled(element)) {
|
|
250
|
+
play({ opacity: [.94, 1] }, MOTION_TIMING.fast);
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
element.addEventListener("focusin", focus);
|
|
254
|
+
cleanups.push(() => element.removeEventListener("focusin", focus));
|
|
255
|
+
const observer = new MutationObserver(() => {
|
|
256
|
+
if (isEnabled(element) && !element.hasAttribute("hidden")) {
|
|
257
|
+
play({ opacity: [.94, 1] }, MOTION_TIMING.fast);
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
observer.observe(element, {
|
|
261
|
+
attributes: true,
|
|
262
|
+
attributeFilter: [
|
|
263
|
+
"data-state",
|
|
264
|
+
"aria-invalid",
|
|
265
|
+
"aria-selected",
|
|
266
|
+
"aria-checked",
|
|
267
|
+
"data-loading",
|
|
268
|
+
"data-error"
|
|
269
|
+
]
|
|
270
|
+
});
|
|
271
|
+
cleanups.push(() => observer.disconnect());
|
|
272
|
+
}
|
|
273
|
+
if (kind === "thumb") {
|
|
274
|
+
let previousTranslate = getComputedStyle(element).translate;
|
|
275
|
+
const observer_0 = new MutationObserver(() => {
|
|
276
|
+
const from = animations.size ? getComputedStyle(element).translate : previousTranslate;
|
|
277
|
+
animations.forEach(_temp4);
|
|
278
|
+
animations.clear();
|
|
279
|
+
element.style.translate = original.translate;
|
|
280
|
+
const to = getComputedStyle(element).translate;
|
|
281
|
+
previousTranslate = to;
|
|
282
|
+
if (from !== to) {
|
|
283
|
+
play({ translate: [from, to] }, MOTION_TIMING.enter);
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
observer_0.observe(element, {
|
|
287
|
+
attributes: true,
|
|
288
|
+
attributeFilter: ["data-state"]
|
|
289
|
+
});
|
|
290
|
+
cleanups.push(() => observer_0.disconnect());
|
|
291
|
+
}
|
|
292
|
+
return dispose;
|
|
293
|
+
};
|
|
294
|
+
t4 = [
|
|
295
|
+
element,
|
|
296
|
+
kind,
|
|
297
|
+
reduceMotion,
|
|
298
|
+
isPresent,
|
|
299
|
+
safeToRemove
|
|
300
|
+
];
|
|
301
|
+
$[7] = element;
|
|
302
|
+
$[8] = isPresent;
|
|
303
|
+
$[9] = kind;
|
|
304
|
+
$[10] = reduceMotion;
|
|
305
|
+
$[11] = safeToRemove;
|
|
306
|
+
$[12] = t3;
|
|
307
|
+
$[13] = t4;
|
|
308
|
+
} else {
|
|
309
|
+
t3 = $[12];
|
|
310
|
+
t4 = $[13];
|
|
311
|
+
}
|
|
312
|
+
useLayoutEffect(t3, t4);
|
|
313
|
+
let t5;
|
|
314
|
+
if ($[14] !== isPresent) {
|
|
315
|
+
t5 = isPresent ? {} : {
|
|
316
|
+
inert: true,
|
|
317
|
+
"aria-hidden": true
|
|
318
|
+
};
|
|
319
|
+
$[14] = isPresent;
|
|
320
|
+
$[15] = t5;
|
|
321
|
+
} else {
|
|
322
|
+
t5 = $[15];
|
|
323
|
+
}
|
|
324
|
+
let t6;
|
|
325
|
+
if ($[16] !== attach || $[17] !== children || $[18] !== props || $[19] !== t5) {
|
|
326
|
+
t6 = /* @__PURE__ */ _jsx(Slot.Root, {
|
|
327
|
+
...props,
|
|
328
|
+
ref: attach,
|
|
329
|
+
...t5,
|
|
330
|
+
children
|
|
331
|
+
});
|
|
332
|
+
$[16] = attach;
|
|
333
|
+
$[17] = children;
|
|
334
|
+
$[18] = props;
|
|
335
|
+
$[19] = t5;
|
|
336
|
+
$[20] = t6;
|
|
337
|
+
} else {
|
|
338
|
+
t6 = $[20];
|
|
339
|
+
}
|
|
340
|
+
return t6;
|
|
341
|
+
}
|
|
342
|
+
function _temp4(animation_2) {
|
|
343
|
+
return animation_2.cancel();
|
|
344
|
+
}
|
|
345
|
+
function _temp3(animation_0) {
|
|
346
|
+
return animation_0.cancel();
|
|
347
|
+
}
|
|
348
|
+
function _temp2(animation) {
|
|
349
|
+
return animation.cancel();
|
|
350
|
+
}
|
|
351
|
+
function _temp(cleanup_0) {
|
|
352
|
+
return cleanup_0();
|
|
353
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Shares visibility with portaled content while leaving interaction ownership with Radix. */
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
|
+
/** Separate contexts preserve correctly nested combinations such as menus inside tooltips. */
|
|
4
|
+
declare const OPEN_CONTEXTS: {
|
|
5
|
+
dialog: import("react").Context<boolean>;
|
|
6
|
+
"alert-dialog": import("react").Context<boolean>;
|
|
7
|
+
sheet: import("react").Context<boolean>;
|
|
8
|
+
"dropdown-menu": import("react").Context<boolean>;
|
|
9
|
+
"dropdown-sub": import("react").Context<boolean>;
|
|
10
|
+
popover: import("react").Context<boolean>;
|
|
11
|
+
"hover-card": import("react").Context<boolean>;
|
|
12
|
+
tooltip: import("react").Context<boolean>;
|
|
13
|
+
};
|
|
14
|
+
type MotionScope = keyof typeof OPEN_CONTEXTS;
|
|
15
|
+
/** Provides only the owning primitive's visibility, independently of other nested primitives. */
|
|
16
|
+
export declare function MotionOpenProvider({ scope, open, children, }: {
|
|
17
|
+
scope: MotionScope;
|
|
18
|
+
open: boolean;
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
}): import("react").JSX.Element;
|
|
21
|
+
/** Preserves the primitive's controlled/uncontrolled open contract. */
|
|
22
|
+
export declare function useMotionOpenState({ open, defaultOpen, onOpenChange, }: {
|
|
23
|
+
open?: boolean;
|
|
24
|
+
defaultOpen?: boolean;
|
|
25
|
+
onOpenChange?: (open: boolean) => void;
|
|
26
|
+
}): readonly [boolean, (open: boolean) => void];
|
|
27
|
+
/** Retains closing content until its Motion exit finishes; explicit forceMount remains caller-owned. */
|
|
28
|
+
export declare function MotionPresence({ scope, children, forceMount, }: {
|
|
29
|
+
scope: MotionScope;
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
forceMount?: boolean;
|
|
32
|
+
}): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null | undefined;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c as _c } from "react/compiler-runtime";
|
|
3
|
+
/** Shares visibility with portaled content while leaving interaction ownership with Radix. */
|
|
4
|
+
import { createContext, useContext, useState } from "react";
|
|
5
|
+
import { AnimatePresence } from "motion/react";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
/** Separate contexts preserve correctly nested combinations such as menus inside tooltips. */
|
|
8
|
+
const OPEN_CONTEXTS = {
|
|
9
|
+
dialog: createContext(true),
|
|
10
|
+
"alert-dialog": createContext(true),
|
|
11
|
+
sheet: createContext(true),
|
|
12
|
+
"dropdown-menu": createContext(true),
|
|
13
|
+
"dropdown-sub": createContext(true),
|
|
14
|
+
popover: createContext(true),
|
|
15
|
+
"hover-card": createContext(true),
|
|
16
|
+
tooltip: createContext(true)
|
|
17
|
+
};
|
|
18
|
+
/** Provides only the owning primitive's visibility, independently of other nested primitives. */
|
|
19
|
+
export function MotionOpenProvider(t0) {
|
|
20
|
+
const $ = _c(4);
|
|
21
|
+
const { scope, open, children } = t0;
|
|
22
|
+
const Context = OPEN_CONTEXTS[scope];
|
|
23
|
+
let t1;
|
|
24
|
+
if ($[0] !== Context.Provider || $[1] !== children || $[2] !== open) {
|
|
25
|
+
t1 = /* @__PURE__ */ _jsx(Context.Provider, {
|
|
26
|
+
value: open,
|
|
27
|
+
children
|
|
28
|
+
});
|
|
29
|
+
$[0] = Context.Provider;
|
|
30
|
+
$[1] = children;
|
|
31
|
+
$[2] = open;
|
|
32
|
+
$[3] = t1;
|
|
33
|
+
} else {
|
|
34
|
+
t1 = $[3];
|
|
35
|
+
}
|
|
36
|
+
return t1;
|
|
37
|
+
}
|
|
38
|
+
/** Preserves the primitive's controlled/uncontrolled open contract. */
|
|
39
|
+
export function useMotionOpenState(t0) {
|
|
40
|
+
const $ = _c(6);
|
|
41
|
+
const { open, defaultOpen: t1, onOpenChange } = t0;
|
|
42
|
+
const defaultOpen = t1 === undefined ? false : t1;
|
|
43
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
44
|
+
let t2;
|
|
45
|
+
if ($[0] !== onOpenChange || $[1] !== open) {
|
|
46
|
+
t2 = (nextOpen) => {
|
|
47
|
+
if (open === undefined) {
|
|
48
|
+
setInternalOpen(nextOpen);
|
|
49
|
+
}
|
|
50
|
+
onOpenChange?.(nextOpen);
|
|
51
|
+
};
|
|
52
|
+
$[0] = onOpenChange;
|
|
53
|
+
$[1] = open;
|
|
54
|
+
$[2] = t2;
|
|
55
|
+
} else {
|
|
56
|
+
t2 = $[2];
|
|
57
|
+
}
|
|
58
|
+
const setOpen = t2;
|
|
59
|
+
const t3 = open ?? internalOpen;
|
|
60
|
+
let t4;
|
|
61
|
+
if ($[3] !== setOpen || $[4] !== t3) {
|
|
62
|
+
t4 = [t3, setOpen];
|
|
63
|
+
$[3] = setOpen;
|
|
64
|
+
$[4] = t3;
|
|
65
|
+
$[5] = t4;
|
|
66
|
+
} else {
|
|
67
|
+
t4 = $[5];
|
|
68
|
+
}
|
|
69
|
+
return t4;
|
|
70
|
+
}
|
|
71
|
+
/** Retains closing content until its Motion exit finishes; explicit forceMount remains caller-owned. */
|
|
72
|
+
export function MotionPresence(t0) {
|
|
73
|
+
const $ = _c(2);
|
|
74
|
+
const { scope, children, forceMount } = t0;
|
|
75
|
+
const open = useContext(OPEN_CONTEXTS[scope]);
|
|
76
|
+
if (forceMount) {
|
|
77
|
+
return children;
|
|
78
|
+
}
|
|
79
|
+
const t1 = open ? children : null;
|
|
80
|
+
let t2;
|
|
81
|
+
if ($[0] !== t1) {
|
|
82
|
+
t2 = /* @__PURE__ */ _jsx(AnimatePresence, {
|
|
83
|
+
initial: false,
|
|
84
|
+
children: t1
|
|
85
|
+
});
|
|
86
|
+
$[0] = t1;
|
|
87
|
+
$[1] = t2;
|
|
88
|
+
} else {
|
|
89
|
+
t2 = $[1];
|
|
90
|
+
}
|
|
91
|
+
return t2;
|
|
92
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Defines the restrained timing and movement shared by Motion animations. */
|
|
2
|
+
export declare const MOTION_TIMING: {
|
|
3
|
+
readonly fast: 0.14;
|
|
4
|
+
readonly enter: 0.18;
|
|
5
|
+
readonly panel: 0.22;
|
|
6
|
+
readonly exit: 0.12;
|
|
7
|
+
readonly skeleton: 1.8;
|
|
8
|
+
};
|
|
9
|
+
export declare const MOTION_EASE: readonly [0.22, 1, 0.36, 1];
|
|
10
|
+
export declare const MOTION_PRESS_SCALE = 0.98;
|
|
11
|
+
export declare const MOTION_SURFACE_DISTANCE = 4;
|
|
12
|
+
export declare const MOTION_PANEL_DISTANCE = 12;
|
|
13
|
+
export type MotionKind = "press" | "fade" | "card" | "row" | "field" | "thumb" | "selection" | "skeleton" | "link" | "icon" | "surface" | "dialog" | "sheet" | "overlay";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Defines the restrained timing and movement shared by Motion animations. */
|
|
2
|
+
export const MOTION_TIMING = {
|
|
3
|
+
fast: .14,
|
|
4
|
+
enter: .18,
|
|
5
|
+
panel: .22,
|
|
6
|
+
exit: .12,
|
|
7
|
+
skeleton: 1.8
|
|
8
|
+
};
|
|
9
|
+
export const MOTION_EASE = [
|
|
10
|
+
.22,
|
|
11
|
+
1,
|
|
12
|
+
.36,
|
|
13
|
+
1
|
|
14
|
+
];
|
|
15
|
+
export const MOTION_PRESS_SCALE = .98;
|
|
16
|
+
export const MOTION_SURFACE_DISTANCE = 4;
|
|
17
|
+
export const MOTION_PANEL_DISTANCE = 12;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { c as _c } from "react/compiler-runtime";
|
|
3
3
|
/** Shares optional rendering adapters without importing a framework into the core. */
|
|
4
4
|
import { createContext, useContext } from "react";
|
|
5
|
+
import { MotionConfig } from "motion/react";
|
|
5
6
|
import { ThemeProvider } from "next-themes";
|
|
6
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
8
|
/** Native elements remain the implicit fallback for unconfigured adapters. */
|
|
@@ -28,9 +29,12 @@ export function BeezUIProvider(t0) {
|
|
|
28
29
|
const value = t2;
|
|
29
30
|
let t3;
|
|
30
31
|
if ($[3] !== children || $[4] !== value) {
|
|
31
|
-
t3 = /* @__PURE__ */ _jsx(
|
|
32
|
-
|
|
33
|
-
children
|
|
32
|
+
t3 = /* @__PURE__ */ _jsx(MotionConfig, {
|
|
33
|
+
reducedMotion: "user",
|
|
34
|
+
children: /* @__PURE__ */ _jsx(AdapterContext.Provider, {
|
|
35
|
+
value,
|
|
36
|
+
children
|
|
37
|
+
})
|
|
34
38
|
});
|
|
35
39
|
$[3] = children;
|
|
36
40
|
$[4] = value;
|