beez-ui 0.5.3 → 0.5.5
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 +8 -0
- package/README.md +66 -3
- 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/filter-query-bar.js +61 -48
- 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
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { c as _c } from "react/compiler-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Tooltip as TooltipPrimitive } from "radix-ui";
|
|
5
|
+
import { MotionSlot } from "../motion/motion-slot.js";
|
|
6
|
+
import { MotionPresence, MotionOpenProvider, useMotionOpenState } from "../motion/presence.js";
|
|
5
7
|
import { cn } from "../lib/utils.js";
|
|
6
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
9
|
function TooltipProvider(t0) {
|
|
@@ -34,7 +36,7 @@ function TooltipProvider(t0) {
|
|
|
34
36
|
return t2;
|
|
35
37
|
}
|
|
36
38
|
function Tooltip(t0) {
|
|
37
|
-
const $ = _c(
|
|
39
|
+
const $ = _c(9);
|
|
38
40
|
let props;
|
|
39
41
|
if ($[0] !== t0) {
|
|
40
42
|
({...props} = t0);
|
|
@@ -43,18 +45,36 @@ function Tooltip(t0) {
|
|
|
43
45
|
} else {
|
|
44
46
|
props = $[1];
|
|
45
47
|
}
|
|
48
|
+
const [motionOpen, setMotionOpen] = useMotionOpenState(props);
|
|
46
49
|
let t1;
|
|
47
|
-
if ($[2] !== props) {
|
|
50
|
+
if ($[2] !== motionOpen || $[3] !== props || $[4] !== setMotionOpen) {
|
|
48
51
|
t1 = /* @__PURE__ */ _jsx(TooltipPrimitive.Root, {
|
|
49
52
|
"data-slot": "tooltip",
|
|
50
|
-
...props
|
|
53
|
+
...props,
|
|
54
|
+
open: motionOpen,
|
|
55
|
+
onOpenChange: setMotionOpen
|
|
51
56
|
});
|
|
52
|
-
$[2] =
|
|
53
|
-
$[3] =
|
|
57
|
+
$[2] = motionOpen;
|
|
58
|
+
$[3] = props;
|
|
59
|
+
$[4] = setMotionOpen;
|
|
60
|
+
$[5] = t1;
|
|
54
61
|
} else {
|
|
55
|
-
t1 = $[
|
|
62
|
+
t1 = $[5];
|
|
56
63
|
}
|
|
57
|
-
|
|
64
|
+
let t2;
|
|
65
|
+
if ($[6] !== motionOpen || $[7] !== t1) {
|
|
66
|
+
t2 = /* @__PURE__ */ _jsx(MotionOpenProvider, {
|
|
67
|
+
scope: "tooltip",
|
|
68
|
+
open: motionOpen,
|
|
69
|
+
children: t1
|
|
70
|
+
});
|
|
71
|
+
$[6] = motionOpen;
|
|
72
|
+
$[7] = t1;
|
|
73
|
+
$[8] = t2;
|
|
74
|
+
} else {
|
|
75
|
+
t2 = $[8];
|
|
76
|
+
}
|
|
77
|
+
return t2;
|
|
58
78
|
}
|
|
59
79
|
function TooltipTrigger(t0) {
|
|
60
80
|
const $ = _c(4);
|
|
@@ -80,7 +100,7 @@ function TooltipTrigger(t0) {
|
|
|
80
100
|
return t1;
|
|
81
101
|
}
|
|
82
102
|
function TooltipContent(t0) {
|
|
83
|
-
const $ = _c(
|
|
103
|
+
const $ = _c(16);
|
|
84
104
|
let children;
|
|
85
105
|
let className;
|
|
86
106
|
let props;
|
|
@@ -99,38 +119,59 @@ function TooltipContent(t0) {
|
|
|
99
119
|
t1 = $[4];
|
|
100
120
|
}
|
|
101
121
|
const sideOffset = t1 === undefined ? 0 : t1;
|
|
102
|
-
|
|
122
|
+
const t2 = props.forceMount;
|
|
123
|
+
let t3;
|
|
103
124
|
if ($[5] !== className) {
|
|
104
|
-
|
|
125
|
+
t3 = cn("z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm ", className);
|
|
105
126
|
$[5] = className;
|
|
106
|
-
$[6] =
|
|
127
|
+
$[6] = t3;
|
|
107
128
|
} else {
|
|
108
|
-
|
|
129
|
+
t3 = $[6];
|
|
109
130
|
}
|
|
110
|
-
let
|
|
131
|
+
let t4;
|
|
111
132
|
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
112
|
-
|
|
113
|
-
$[7] =
|
|
133
|
+
t4 = /* @__PURE__ */ _jsx(TooltipPrimitive.Arrow, { className: "z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground" });
|
|
134
|
+
$[7] = t4;
|
|
114
135
|
} else {
|
|
115
|
-
|
|
136
|
+
t4 = $[7];
|
|
116
137
|
}
|
|
117
|
-
let
|
|
118
|
-
if ($[8] !== children || $[9] !== props || $[10] !== sideOffset || $[11] !==
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
138
|
+
let t5;
|
|
139
|
+
if ($[8] !== children || $[9] !== props || $[10] !== sideOffset || $[11] !== t3) {
|
|
140
|
+
t5 = /* @__PURE__ */ _jsx(MotionSlot, {
|
|
141
|
+
kind: "surface",
|
|
142
|
+
children: /* @__PURE__ */ _jsxs(TooltipPrimitive.Content, {
|
|
143
|
+
forceMount: true,
|
|
144
|
+
"data-slot": "tooltip-content",
|
|
145
|
+
sideOffset,
|
|
146
|
+
className: t3,
|
|
147
|
+
...props,
|
|
148
|
+
children: [children, t4]
|
|
149
|
+
})
|
|
150
|
+
});
|
|
126
151
|
$[8] = children;
|
|
127
152
|
$[9] = props;
|
|
128
153
|
$[10] = sideOffset;
|
|
129
|
-
$[11] =
|
|
130
|
-
$[12] =
|
|
154
|
+
$[11] = t3;
|
|
155
|
+
$[12] = t5;
|
|
156
|
+
} else {
|
|
157
|
+
t5 = $[12];
|
|
158
|
+
}
|
|
159
|
+
let t6;
|
|
160
|
+
if ($[13] !== props.forceMount || $[14] !== t5) {
|
|
161
|
+
t6 = /* @__PURE__ */ _jsx(TooltipPrimitive.Portal, {
|
|
162
|
+
forceMount: true,
|
|
163
|
+
children: /* @__PURE__ */ _jsx(MotionPresence, {
|
|
164
|
+
scope: "tooltip",
|
|
165
|
+
forceMount: t2,
|
|
166
|
+
children: t5
|
|
167
|
+
})
|
|
168
|
+
});
|
|
169
|
+
$[13] = props.forceMount;
|
|
170
|
+
$[14] = t5;
|
|
171
|
+
$[15] = t6;
|
|
131
172
|
} else {
|
|
132
|
-
|
|
173
|
+
t6 = $[15];
|
|
133
174
|
}
|
|
134
|
-
return
|
|
175
|
+
return t6;
|
|
135
176
|
}
|
|
136
177
|
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { c as _c } from "react/compiler-runtime";
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { motion } from "motion/react";
|
|
5
|
+
import { usePrefersReducedMotion } from "../hooks/use-prefers-reduced-motion.js";
|
|
5
6
|
import { cn } from "../lib/utils.js";
|
|
6
7
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
8
|
const motionElements = {
|
|
@@ -19,7 +20,7 @@ const motionElements = {
|
|
|
19
20
|
span: motion.span
|
|
20
21
|
};
|
|
21
22
|
export function TypingAnimation(t0) {
|
|
22
|
-
const $ = _c(
|
|
23
|
+
const $ = _c(67);
|
|
23
24
|
let children;
|
|
24
25
|
let className;
|
|
25
26
|
let deleteSpeed;
|
|
@@ -79,6 +80,8 @@ export function TypingAnimation(t0) {
|
|
|
79
80
|
const showCursor = t7 === undefined ? true : t7;
|
|
80
81
|
const blinkCursor = t8 === undefined ? true : t8;
|
|
81
82
|
const cursorStyle = t9 === undefined ? "line" : t9;
|
|
83
|
+
const shouldReduceMotion = usePrefersReducedMotion();
|
|
84
|
+
const wasReducedMotionRef = useRef(false);
|
|
82
85
|
const MotionComponent = motionElements[Component];
|
|
83
86
|
const [displayedText, setDisplayedText] = useState("");
|
|
84
87
|
const [currentWordIndex, setCurrentWordIndex] = useState(0);
|
|
@@ -154,11 +157,18 @@ export function TypingAnimation(t0) {
|
|
|
154
157
|
useEffect(t13, t14);
|
|
155
158
|
let t15;
|
|
156
159
|
let t16;
|
|
157
|
-
if ($[28] !== animationSourceKey) {
|
|
160
|
+
if ($[28] !== animationSourceKey || $[29] !== shouldReduceMotion || $[30] !== wordsToAnimate) {
|
|
158
161
|
t15 = () => {
|
|
159
|
-
if (
|
|
162
|
+
if (shouldReduceMotion) {
|
|
163
|
+
wasReducedMotionRef.current = true;
|
|
164
|
+
lastResetSourceKeyRef.current = animationSourceKey;
|
|
165
|
+
setDisplayedText(wordsToAnimate.join(" · "));
|
|
160
166
|
return;
|
|
161
167
|
}
|
|
168
|
+
if (lastResetSourceKeyRef.current === animationSourceKey && !wasReducedMotionRef.current) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
wasReducedMotionRef.current = false;
|
|
162
172
|
lastResetSourceKeyRef.current = animationSourceKey;
|
|
163
173
|
const resetTimeout = setTimeout(() => {
|
|
164
174
|
setDisplayedText("");
|
|
@@ -170,26 +180,35 @@ export function TypingAnimation(t0) {
|
|
|
170
180
|
clearTimeout(resetTimeout);
|
|
171
181
|
};
|
|
172
182
|
};
|
|
173
|
-
t16 = [
|
|
183
|
+
t16 = [
|
|
184
|
+
animationSourceKey,
|
|
185
|
+
shouldReduceMotion,
|
|
186
|
+
wordsToAnimate
|
|
187
|
+
];
|
|
174
188
|
$[28] = animationSourceKey;
|
|
175
|
-
$[29] =
|
|
176
|
-
$[30] =
|
|
189
|
+
$[29] = shouldReduceMotion;
|
|
190
|
+
$[30] = wordsToAnimate;
|
|
191
|
+
$[31] = t15;
|
|
192
|
+
$[32] = t16;
|
|
177
193
|
} else {
|
|
178
|
-
t15 = $[
|
|
179
|
-
t16 = $[
|
|
194
|
+
t15 = $[31];
|
|
195
|
+
t16 = $[32];
|
|
180
196
|
}
|
|
181
197
|
useEffect(t15, t16);
|
|
182
198
|
let t17;
|
|
183
199
|
let t18;
|
|
184
|
-
if ($[
|
|
200
|
+
if ($[33] !== currentCharIndex || $[34] !== currentWordIndex || $[35] !== delay || $[36] !== deletingSpeed || $[37] !== displayedText || $[38] !== hasMultipleWords || $[39] !== loop || $[40] !== pauseDelay || $[41] !== phase || $[42] !== shouldReduceMotion || $[43] !== shouldStart || $[44] !== typingSpeed || $[45] !== wordsToAnimate) {
|
|
185
201
|
t17 = () => {
|
|
202
|
+
if (shouldReduceMotion) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
186
205
|
let timeout = null;
|
|
187
206
|
if (shouldStart && wordsToAnimate.length > 0) {
|
|
188
207
|
const timeoutDelay = delay > 0 && displayedText === "" ? delay : phase === "typing" ? typingSpeed : phase === "deleting" ? deletingSpeed : pauseDelay;
|
|
189
208
|
timeout = setTimeout(() => {
|
|
190
209
|
const currentWord = wordsToAnimate[currentWordIndex] || "";
|
|
191
210
|
const graphemes = Array.from(currentWord);
|
|
192
|
-
|
|
211
|
+
bb136: switch (phase) {
|
|
193
212
|
case "typing": {
|
|
194
213
|
if (currentCharIndex < graphemes.length) {
|
|
195
214
|
setDisplayedText(graphemes.slice(0, currentCharIndex + 1).join(""));
|
|
@@ -202,11 +221,11 @@ export function TypingAnimation(t0) {
|
|
|
202
221
|
}
|
|
203
222
|
}
|
|
204
223
|
}
|
|
205
|
-
break
|
|
224
|
+
break bb136;
|
|
206
225
|
}
|
|
207
226
|
case "pause": {
|
|
208
227
|
setPhase("deleting");
|
|
209
|
-
break
|
|
228
|
+
break bb136;
|
|
210
229
|
}
|
|
211
230
|
case "deleting": {
|
|
212
231
|
if (currentCharIndex > 0) {
|
|
@@ -229,6 +248,7 @@ export function TypingAnimation(t0) {
|
|
|
229
248
|
};
|
|
230
249
|
t18 = [
|
|
231
250
|
shouldStart,
|
|
251
|
+
shouldReduceMotion,
|
|
232
252
|
phase,
|
|
233
253
|
currentCharIndex,
|
|
234
254
|
currentWordIndex,
|
|
@@ -241,39 +261,40 @@ export function TypingAnimation(t0) {
|
|
|
241
261
|
pauseDelay,
|
|
242
262
|
delay
|
|
243
263
|
];
|
|
244
|
-
$[
|
|
245
|
-
$[
|
|
246
|
-
$[
|
|
247
|
-
$[
|
|
248
|
-
$[
|
|
249
|
-
$[
|
|
250
|
-
$[
|
|
251
|
-
$[
|
|
252
|
-
$[
|
|
253
|
-
$[
|
|
254
|
-
$[
|
|
255
|
-
$[
|
|
256
|
-
$[
|
|
257
|
-
$[
|
|
264
|
+
$[33] = currentCharIndex;
|
|
265
|
+
$[34] = currentWordIndex;
|
|
266
|
+
$[35] = delay;
|
|
267
|
+
$[36] = deletingSpeed;
|
|
268
|
+
$[37] = displayedText;
|
|
269
|
+
$[38] = hasMultipleWords;
|
|
270
|
+
$[39] = loop;
|
|
271
|
+
$[40] = pauseDelay;
|
|
272
|
+
$[41] = phase;
|
|
273
|
+
$[42] = shouldReduceMotion;
|
|
274
|
+
$[43] = shouldStart;
|
|
275
|
+
$[44] = typingSpeed;
|
|
276
|
+
$[45] = wordsToAnimate;
|
|
277
|
+
$[46] = t17;
|
|
278
|
+
$[47] = t18;
|
|
258
279
|
} else {
|
|
259
|
-
t17 = $[
|
|
260
|
-
t18 = $[
|
|
280
|
+
t17 = $[46];
|
|
281
|
+
t18 = $[47];
|
|
261
282
|
}
|
|
262
283
|
useEffect(t17, t18);
|
|
263
284
|
let t19;
|
|
264
|
-
if ($[
|
|
285
|
+
if ($[48] !== currentWordIndex || $[49] !== wordsToAnimate) {
|
|
265
286
|
t19 = Array.from(wordsToAnimate[currentWordIndex] || "");
|
|
266
|
-
$[
|
|
267
|
-
$[
|
|
268
|
-
$[
|
|
287
|
+
$[48] = currentWordIndex;
|
|
288
|
+
$[49] = wordsToAnimate;
|
|
289
|
+
$[50] = t19;
|
|
269
290
|
} else {
|
|
270
|
-
t19 = $[
|
|
291
|
+
t19 = $[50];
|
|
271
292
|
}
|
|
272
293
|
const currentWordGraphemes = t19;
|
|
273
294
|
const isComplete = !loop && currentWordIndex === wordsToAnimate.length - 1 && currentCharIndex >= currentWordGraphemes.length && phase !== "deleting";
|
|
274
|
-
const shouldShowCursor = showCursor && !isComplete && (hasMultipleWords || loop || currentCharIndex < currentWordGraphemes.length);
|
|
295
|
+
const shouldShowCursor = showCursor && !shouldReduceMotion && !isComplete && (hasMultipleWords || loop || currentCharIndex < currentWordGraphemes.length);
|
|
275
296
|
let t20;
|
|
276
|
-
if ($[
|
|
297
|
+
if ($[51] !== cursorStyle) {
|
|
277
298
|
t20 = () => {
|
|
278
299
|
switch (cursorStyle) {
|
|
279
300
|
case "block": {
|
|
@@ -288,53 +309,54 @@ export function TypingAnimation(t0) {
|
|
|
288
309
|
}
|
|
289
310
|
}
|
|
290
311
|
};
|
|
291
|
-
$[
|
|
292
|
-
$[
|
|
312
|
+
$[51] = cursorStyle;
|
|
313
|
+
$[52] = t20;
|
|
293
314
|
} else {
|
|
294
|
-
t20 = $[
|
|
315
|
+
t20 = $[52];
|
|
295
316
|
}
|
|
296
317
|
const getCursorChar = t20;
|
|
297
318
|
const t21 = Component === "h1" && "text-3xl font-bold leading-tight md:text-4xl";
|
|
298
319
|
const t22 = Component === "span" && "inline-block";
|
|
299
320
|
let t23;
|
|
300
|
-
if ($[
|
|
321
|
+
if ($[53] !== className || $[54] !== t21 || $[55] !== t22) {
|
|
301
322
|
t23 = cn("tracking-[-0.02em]", t21, t22, className);
|
|
302
|
-
$[
|
|
303
|
-
$[
|
|
304
|
-
$[
|
|
305
|
-
$[
|
|
323
|
+
$[53] = className;
|
|
324
|
+
$[54] = t21;
|
|
325
|
+
$[55] = t22;
|
|
326
|
+
$[56] = t23;
|
|
306
327
|
} else {
|
|
307
|
-
t23 = $[
|
|
328
|
+
t23 = $[56];
|
|
308
329
|
}
|
|
309
330
|
let t24;
|
|
310
|
-
if ($[
|
|
331
|
+
if ($[57] !== blinkCursor || $[58] !== getCursorChar || $[59] !== shouldShowCursor) {
|
|
311
332
|
t24 = shouldShowCursor && /* @__PURE__ */ _jsx("span", {
|
|
312
333
|
className: cn("inline-block", blinkCursor && "animate-blink-cursor"),
|
|
313
334
|
children: getCursorChar()
|
|
314
335
|
});
|
|
315
|
-
$[
|
|
316
|
-
$[
|
|
317
|
-
$[
|
|
318
|
-
$[
|
|
336
|
+
$[57] = blinkCursor;
|
|
337
|
+
$[58] = getCursorChar;
|
|
338
|
+
$[59] = shouldShowCursor;
|
|
339
|
+
$[60] = t24;
|
|
319
340
|
} else {
|
|
320
|
-
t24 = $[
|
|
341
|
+
t24 = $[60];
|
|
321
342
|
}
|
|
322
343
|
let t25;
|
|
323
|
-
if ($[
|
|
344
|
+
if ($[61] !== MotionComponent || $[62] !== displayedText || $[63] !== props || $[64] !== t23 || $[65] !== t24) {
|
|
324
345
|
t25 = /* @__PURE__ */ _jsxs(MotionComponent, {
|
|
325
346
|
ref: elementRef,
|
|
347
|
+
"data-slot": "typing-animation",
|
|
326
348
|
className: t23,
|
|
327
349
|
...props,
|
|
328
350
|
children: [displayedText, t24]
|
|
329
351
|
});
|
|
330
|
-
$[
|
|
331
|
-
$[
|
|
332
|
-
$[
|
|
333
|
-
$[
|
|
334
|
-
$[
|
|
335
|
-
$[
|
|
352
|
+
$[61] = MotionComponent;
|
|
353
|
+
$[62] = displayedText;
|
|
354
|
+
$[63] = props;
|
|
355
|
+
$[64] = t23;
|
|
356
|
+
$[65] = t24;
|
|
357
|
+
$[66] = t25;
|
|
336
358
|
} else {
|
|
337
|
-
t25 = $[
|
|
359
|
+
t25 = $[66];
|
|
338
360
|
}
|
|
339
361
|
return t25;
|
|
340
362
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/** Reads motion preferences without changing the initial server/hydration markup. */
|
|
3
|
+
import { useSyncExternalStore } from "react";
|
|
4
|
+
import { REDUCED_MOTION_QUERY } from "../constants/motion.js";
|
|
5
|
+
/** Subscribes to preference changes, including browsers exposing the legacy media API. */
|
|
6
|
+
function subscribe(onChange) {
|
|
7
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return () => {};
|
|
8
|
+
const query = window.matchMedia(REDUCED_MOTION_QUERY);
|
|
9
|
+
if (typeof query.addEventListener === "function") {
|
|
10
|
+
query.addEventListener("change", onChange);
|
|
11
|
+
return () => query.removeEventListener("change", onChange);
|
|
12
|
+
}
|
|
13
|
+
query.addListener?.(onChange);
|
|
14
|
+
return () => query.removeListener?.(onChange);
|
|
15
|
+
}
|
|
16
|
+
/** Resolves the current browser setting while tolerating non-browser test environments. */
|
|
17
|
+
function getSnapshot() {
|
|
18
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(REDUCED_MOTION_QUERY).matches;
|
|
19
|
+
}
|
|
20
|
+
/** Keeps the initial client tree consistent with the server-rendered tree. */
|
|
21
|
+
function getServerSnapshot() {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
/** Returns a live preference for animations that cannot be controlled with CSS alone. */
|
|
25
|
+
export function usePrefersReducedMotion() {
|
|
26
|
+
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
27
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Animates the original primitive node with Motion, without adding DOM wrappers. */
|
|
2
|
+
import { type ReactElement, type ComponentProps } from "react";
|
|
3
|
+
import { Slot } from "radix-ui";
|
|
4
|
+
import { type MotionKind } from "./tokens.js";
|
|
5
|
+
/** Composes refs through Radix Slot and delegates gesture, entry and exit playback to Motion. */
|
|
6
|
+
export declare function MotionSlot({ children, kind, ref, ...props }: Omit<ComponentProps<typeof Slot.Root>, "children"> & {
|
|
7
|
+
children: ReactElement;
|
|
8
|
+
kind?: MotionKind;
|
|
9
|
+
}): import("react").JSX.Element;
|