@particle-academy/react-fancy 4.4.5 → 4.4.7
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/dist/index.cjs +38 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +38 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2569,7 +2569,22 @@ var Button = react.forwardRef(
|
|
|
2569
2569
|
trailingElements
|
|
2570
2570
|
] });
|
|
2571
2571
|
const safeHref = sanitizeHref(href);
|
|
2572
|
-
const buttonEl = safeHref && !disabled ?
|
|
2572
|
+
const buttonEl = safeHref && !disabled ? (
|
|
2573
|
+
// Anchor mode forwards the same rest props as the <button> branch so
|
|
2574
|
+
// onClick / target / rel / ref / ARIA / data-* reach the <a> (issue #7).
|
|
2575
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2576
|
+
"a",
|
|
2577
|
+
{
|
|
2578
|
+
ref,
|
|
2579
|
+
href: safeHref,
|
|
2580
|
+
className: classes,
|
|
2581
|
+
"data-react-fancy-button": "",
|
|
2582
|
+
"data-react-fancy-action": "",
|
|
2583
|
+
...props,
|
|
2584
|
+
children: content
|
|
2585
|
+
}
|
|
2586
|
+
)
|
|
2587
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2573
2588
|
"button",
|
|
2574
2589
|
{
|
|
2575
2590
|
ref,
|
|
@@ -3341,6 +3356,28 @@ function useFloatingPosition(anchorRef, floatingRef, options = {}) {
|
|
|
3341
3356
|
react.useEffect(() => {
|
|
3342
3357
|
if (enabled) update();
|
|
3343
3358
|
});
|
|
3359
|
+
react.useEffect(() => {
|
|
3360
|
+
if (!enabled) return;
|
|
3361
|
+
let raf = 0;
|
|
3362
|
+
let ro = null;
|
|
3363
|
+
const tick = () => {
|
|
3364
|
+
const el = floatingRef.current;
|
|
3365
|
+
if (el) {
|
|
3366
|
+
update();
|
|
3367
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
3368
|
+
ro = new ResizeObserver(() => update());
|
|
3369
|
+
ro.observe(el);
|
|
3370
|
+
}
|
|
3371
|
+
} else {
|
|
3372
|
+
raf = requestAnimationFrame(tick);
|
|
3373
|
+
}
|
|
3374
|
+
};
|
|
3375
|
+
raf = requestAnimationFrame(tick);
|
|
3376
|
+
return () => {
|
|
3377
|
+
cancelAnimationFrame(raf);
|
|
3378
|
+
ro?.disconnect();
|
|
3379
|
+
};
|
|
3380
|
+
}, [enabled, update, floatingRef]);
|
|
3344
3381
|
react.useEffect(() => {
|
|
3345
3382
|
if (!enabled) {
|
|
3346
3383
|
setPosition(
|