plainframe-ui 0.1.3 → 0.1.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/dist/index.js CHANGED
@@ -2296,34 +2296,34 @@ var SubMenuContent = ({ children, css: userCss }) => {
2296
2296
  const menuGap = useContext3(GapCtx);
2297
2297
  const clipRef = useRef5(null);
2298
2298
  const innerRef = useRef5(null);
2299
- const readyRef = useRef5(false);
2300
2299
  const seqRef = useRef5(0);
2301
- useLayoutEffect2(() => {
2302
- const clip = clipRef.current;
2303
- if (!clip) return;
2304
- if (open) {
2305
- clip.style.maxHeight = "none";
2306
- clip.style.overflow = "visible";
2307
- } else {
2308
- clip.style.maxHeight = "0px";
2309
- clip.style.overflow = "hidden";
2310
- }
2311
- readyRef.current = true;
2312
- }, []);
2300
+ const firstRef = useRef5(true);
2313
2301
  useLayoutEffect2(() => {
2314
2302
  const clip = clipRef.current;
2315
2303
  const inner = innerRef.current;
2316
- if (!clip || !inner || !readyRef.current) return;
2304
+ if (!clip || !inner) return;
2317
2305
  const key = ++seqRef.current;
2318
2306
  const dur = "360ms cubic-bezier(.25,.8,.4,1)";
2319
- const current = clip.style.maxHeight === "none" ? inner.scrollHeight : parseFloat(clip.style.maxHeight || "0") || 0;
2320
- const target = open ? inner.scrollHeight : 0;
2307
+ if (firstRef.current) {
2308
+ firstRef.current = false;
2309
+ clip.style.transition = "none";
2310
+ if (open) {
2311
+ clip.style.maxHeight = "none";
2312
+ clip.style.overflow = "visible";
2313
+ } else {
2314
+ clip.style.maxHeight = "0px";
2315
+ clip.style.overflow = "hidden";
2316
+ }
2317
+ return;
2318
+ }
2319
+ const from = open ? 0 : inner.scrollHeight;
2320
+ const to = open ? inner.scrollHeight : 0;
2321
2321
  clip.style.transition = "none";
2322
2322
  clip.style.overflow = "hidden";
2323
- clip.style.maxHeight = `${current}px`;
2323
+ clip.style.maxHeight = `${from}px`;
2324
2324
  void clip.offsetHeight;
2325
2325
  clip.style.transition = `max-height ${dur}`;
2326
- clip.style.maxHeight = `${target}px`;
2326
+ clip.style.maxHeight = `${to}px`;
2327
2327
  const onEnd = (e) => {
2328
2328
  if (e.target !== clip || e.propertyName !== "max-height") return;
2329
2329
  if (key !== seqRef.current) return;
@@ -2353,17 +2353,19 @@ var SubMenuContent = ({ children, css: userCss }) => {
2353
2353
  useLayoutEffect2(() => {
2354
2354
  const clip = clipRef.current;
2355
2355
  const inner = innerRef.current;
2356
- if (!clip || !inner) return;
2356
+ if (!clip || !inner || !window.ResizeObserver) return;
2357
2357
  const ro = new window.ResizeObserver(() => {
2358
2358
  if (!open) return;
2359
- const h = inner.scrollHeight;
2360
- if (clip.style.maxHeight !== "none") {
2361
- clip.style.maxHeight = `${h}px`;
2359
+ const isAnimating = clip.style.maxHeight !== "none" && (clip.style.transition || "").includes("max-height");
2360
+ if (isAnimating) {
2361
+ clip.style.transition = "none";
2362
+ clip.style.maxHeight = "none";
2363
+ clip.style.overflow = "visible";
2362
2364
  }
2363
2365
  });
2364
- if (ro) ro.observe(inner);
2366
+ ro.observe(inner);
2365
2367
  return () => {
2366
- ro && ro.disconnect();
2368
+ ro.disconnect();
2367
2369
  };
2368
2370
  }, [open]);
2369
2371
  useEffect3(() => {
@@ -2428,7 +2430,7 @@ var SubMenuContent = ({ children, css: userCss }) => {
2428
2430
  margin: 0,
2429
2431
  padding: 0,
2430
2432
  opacity: open ? 1 : 0,
2431
- transform: open ? "translateY(0) scale(1)" : "translateY(1rem) scale(0.95)",
2433
+ transform: open ? "translateY(0) scale(1)" : "translateY(16px) scale(0.96)",
2432
2434
  transition: "opacity 0.35s ease, transform 0.28s ease",
2433
2435
  pointerEvents: open ? "auto" : "none",
2434
2436
  willChange: "opacity, transform"