@evinvest/uikit 0.1.0 → 0.1.2
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.d.ts +5 -8
- package/dist/index.js +20 -40
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -105,14 +105,11 @@ declare function useFloating(opts: {
|
|
|
105
105
|
declare function useFocusScope(enabled: boolean): React.RefObject<HTMLDivElement | null>;
|
|
106
106
|
|
|
107
107
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* Usage: spread `{ ref, ...(isPresent ? {} : {}) }` and render only while
|
|
115
|
-
* `isPresent`. The Rust mirror toggles `data-state` without deferring unmount.
|
|
108
|
+
* Tracks whether an overlay should be mounted. Mount/unmount steps in lockstep
|
|
109
|
+
* with `present`: enter animations (`data-[state=open]:animate-in`) still play
|
|
110
|
+
* on mount, but the kit intentionally does **not** defer unmount for an exit
|
|
111
|
+
* animation — deferring made portaled overlays flicker on close. Pass `ref`
|
|
112
|
+
* through to the animated node (kept for API stability / future use).
|
|
116
113
|
*/
|
|
117
114
|
declare function usePresence(present: boolean): {
|
|
118
115
|
isPresent: boolean;
|
package/dist/index.js
CHANGED
|
@@ -64,12 +64,10 @@ function useControllableState(opts) {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
// src/primitives/portal.tsx
|
|
67
|
-
import
|
|
67
|
+
import "react";
|
|
68
68
|
import { createPortal } from "react-dom";
|
|
69
69
|
function Portal({ children, container }) {
|
|
70
|
-
|
|
71
|
-
React3.useEffect(() => setMounted(true), []);
|
|
72
|
-
if (!mounted) return null;
|
|
70
|
+
if (typeof document === "undefined") return null;
|
|
73
71
|
const target = container ?? document.body;
|
|
74
72
|
return createPortal(children, target);
|
|
75
73
|
}
|
|
@@ -160,12 +158,21 @@ function useFloating(opts) {
|
|
|
160
158
|
setStyle({ position: "fixed", top: Math.round(top), left: Math.round(left) });
|
|
161
159
|
setResolved({ side: placed, align });
|
|
162
160
|
}
|
|
161
|
+
let frame = 0;
|
|
162
|
+
function schedule() {
|
|
163
|
+
if (frame) return;
|
|
164
|
+
frame = requestAnimationFrame(() => {
|
|
165
|
+
frame = 0;
|
|
166
|
+
update();
|
|
167
|
+
});
|
|
168
|
+
}
|
|
163
169
|
update();
|
|
164
|
-
window.addEventListener("scroll",
|
|
165
|
-
window.addEventListener("resize",
|
|
170
|
+
window.addEventListener("scroll", schedule, true);
|
|
171
|
+
window.addEventListener("resize", schedule);
|
|
166
172
|
return () => {
|
|
167
|
-
|
|
168
|
-
window.removeEventListener("
|
|
173
|
+
if (frame) cancelAnimationFrame(frame);
|
|
174
|
+
window.removeEventListener("scroll", schedule, true);
|
|
175
|
+
window.removeEventListener("resize", schedule);
|
|
169
176
|
};
|
|
170
177
|
}, [open, side, align, offset, anchorRef]);
|
|
171
178
|
return { floatingRef, style, side: resolved.side, align: resolved.align };
|
|
@@ -219,34 +226,7 @@ function useFocusScope(enabled) {
|
|
|
219
226
|
import * as React7 from "react";
|
|
220
227
|
function usePresence(present) {
|
|
221
228
|
const ref = React7.useRef(null);
|
|
222
|
-
|
|
223
|
-
React7.useEffect(() => {
|
|
224
|
-
const node = ref.current;
|
|
225
|
-
if (present) {
|
|
226
|
-
setIsPresent(true);
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
if (!node) {
|
|
230
|
-
setIsPresent(false);
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
const styles = getComputedStyle(node);
|
|
234
|
-
const hasAnim = styles.animationName && styles.animationName !== "none" || parseFloat(styles.transitionDuration) > 0;
|
|
235
|
-
if (!hasAnim) {
|
|
236
|
-
setIsPresent(false);
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
function done() {
|
|
240
|
-
setIsPresent(false);
|
|
241
|
-
}
|
|
242
|
-
node.addEventListener("animationend", done);
|
|
243
|
-
node.addEventListener("transitionend", done);
|
|
244
|
-
return () => {
|
|
245
|
-
node.removeEventListener("animationend", done);
|
|
246
|
-
node.removeEventListener("transitionend", done);
|
|
247
|
-
};
|
|
248
|
-
}, [present]);
|
|
249
|
-
return { isPresent: present || isPresent, ref };
|
|
229
|
+
return { isPresent: present, ref };
|
|
250
230
|
}
|
|
251
231
|
|
|
252
232
|
// src/primitives/use-roving-focus.ts
|
|
@@ -2485,7 +2465,7 @@ function Slider({
|
|
|
2485
2465
|
event.currentTarget.releasePointerCapture?.(event.pointerId);
|
|
2486
2466
|
};
|
|
2487
2467
|
const rangeStyle = orientation === "vertical" ? { height: `${percent}%` } : { width: `${percent}%` };
|
|
2488
|
-
const thumbStyle = orientation === "vertical" ? { bottom: `${percent}
|
|
2468
|
+
const thumbStyle = orientation === "vertical" ? { position: "absolute", bottom: `${percent}%`, left: "50%", transform: "translate(-50%, 50%)" } : { position: "absolute", left: `${percent}%`, top: "50%", transform: "translate(-50%, -50%)" };
|
|
2489
2469
|
return /* @__PURE__ */ jsxs5(
|
|
2490
2470
|
"span",
|
|
2491
2471
|
{
|
|
@@ -2494,6 +2474,9 @@ function Slider({
|
|
|
2494
2474
|
"data-disabled": disabled || void 0,
|
|
2495
2475
|
className: cn(ROOT_BASE2, className),
|
|
2496
2476
|
...props,
|
|
2477
|
+
onPointerDown,
|
|
2478
|
+
onPointerMove,
|
|
2479
|
+
onPointerUp,
|
|
2497
2480
|
children: [
|
|
2498
2481
|
/* @__PURE__ */ jsx31(
|
|
2499
2482
|
"span",
|
|
@@ -2502,9 +2485,6 @@ function Slider({
|
|
|
2502
2485
|
"data-slot": "slider-track",
|
|
2503
2486
|
"data-orientation": orientation,
|
|
2504
2487
|
className: TRACK_BASE,
|
|
2505
|
-
onPointerDown,
|
|
2506
|
-
onPointerMove,
|
|
2507
|
-
onPointerUp,
|
|
2508
2488
|
children: /* @__PURE__ */ jsx31(
|
|
2509
2489
|
"span",
|
|
2510
2490
|
{
|