plainframe-ui 0.1.3 → 0.1.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/dist/index.js +15 -101
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2125,7 +2125,6 @@ import React8, {
|
|
|
2125
2125
|
isValidElement as isValidElement4,
|
|
2126
2126
|
cloneElement as cloneElement4,
|
|
2127
2127
|
useRef as useRef5,
|
|
2128
|
-
useLayoutEffect as useLayoutEffect2,
|
|
2129
2128
|
useEffect as useEffect3
|
|
2130
2129
|
} from "react";
|
|
2131
2130
|
import { css as emCss } from "@emotion/react";
|
|
@@ -2294,78 +2293,7 @@ var SubMenuContent = ({ children, css: userCss }) => {
|
|
|
2294
2293
|
const { open } = useSub();
|
|
2295
2294
|
const parentLevel = useContext3(LevelCtx);
|
|
2296
2295
|
const menuGap = useContext3(GapCtx);
|
|
2297
|
-
const clipRef = useRef5(null);
|
|
2298
2296
|
const innerRef = useRef5(null);
|
|
2299
|
-
const readyRef = useRef5(false);
|
|
2300
|
-
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
|
-
}, []);
|
|
2313
|
-
useLayoutEffect2(() => {
|
|
2314
|
-
const clip = clipRef.current;
|
|
2315
|
-
const inner = innerRef.current;
|
|
2316
|
-
if (!clip || !inner || !readyRef.current) return;
|
|
2317
|
-
const key = ++seqRef.current;
|
|
2318
|
-
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;
|
|
2321
|
-
clip.style.transition = "none";
|
|
2322
|
-
clip.style.overflow = "hidden";
|
|
2323
|
-
clip.style.maxHeight = `${current}px`;
|
|
2324
|
-
void clip.offsetHeight;
|
|
2325
|
-
clip.style.transition = `max-height ${dur}`;
|
|
2326
|
-
clip.style.maxHeight = `${target}px`;
|
|
2327
|
-
const onEnd = (e) => {
|
|
2328
|
-
if (e.target !== clip || e.propertyName !== "max-height") return;
|
|
2329
|
-
if (key !== seqRef.current) return;
|
|
2330
|
-
clip.style.transition = "none";
|
|
2331
|
-
if (open) {
|
|
2332
|
-
clip.style.maxHeight = "none";
|
|
2333
|
-
clip.style.overflow = "visible";
|
|
2334
|
-
} else {
|
|
2335
|
-
clip.style.maxHeight = "0px";
|
|
2336
|
-
clip.style.overflow = "hidden";
|
|
2337
|
-
}
|
|
2338
|
-
clip.removeEventListener("transitionend", onEnd);
|
|
2339
|
-
clip.removeEventListener("transitioncancel", onCancel);
|
|
2340
|
-
};
|
|
2341
|
-
const onCancel = () => {
|
|
2342
|
-
if (key !== seqRef.current) return;
|
|
2343
|
-
clip.removeEventListener("transitionend", onEnd);
|
|
2344
|
-
clip.removeEventListener("transitioncancel", onCancel);
|
|
2345
|
-
};
|
|
2346
|
-
clip.addEventListener("transitionend", onEnd);
|
|
2347
|
-
clip.addEventListener("transitioncancel", onCancel);
|
|
2348
|
-
return () => {
|
|
2349
|
-
clip.removeEventListener("transitionend", onEnd);
|
|
2350
|
-
clip.removeEventListener("transitioncancel", onCancel);
|
|
2351
|
-
};
|
|
2352
|
-
}, [open]);
|
|
2353
|
-
useLayoutEffect2(() => {
|
|
2354
|
-
const clip = clipRef.current;
|
|
2355
|
-
const inner = innerRef.current;
|
|
2356
|
-
if (!clip || !inner) return;
|
|
2357
|
-
const ro = new window.ResizeObserver(() => {
|
|
2358
|
-
if (!open) return;
|
|
2359
|
-
const h = inner.scrollHeight;
|
|
2360
|
-
if (clip.style.maxHeight !== "none") {
|
|
2361
|
-
clip.style.maxHeight = `${h}px`;
|
|
2362
|
-
}
|
|
2363
|
-
});
|
|
2364
|
-
if (ro) ro.observe(inner);
|
|
2365
|
-
return () => {
|
|
2366
|
-
ro && ro.disconnect();
|
|
2367
|
-
};
|
|
2368
|
-
}, [open]);
|
|
2369
2297
|
useEffect3(() => {
|
|
2370
2298
|
const root = innerRef.current;
|
|
2371
2299
|
if (!root) return;
|
|
@@ -2402,25 +2330,16 @@ var SubMenuContent = ({ children, css: userCss }) => {
|
|
|
2402
2330
|
});
|
|
2403
2331
|
}
|
|
2404
2332
|
}, [open]);
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
clip.style.overflow = open ? "visible" : "hidden";
|
|
2414
|
-
}
|
|
2415
|
-
};
|
|
2416
|
-
clip.addEventListener("focusin", onFocusIn);
|
|
2417
|
-
clip.addEventListener("focusout", onFocusOut);
|
|
2418
|
-
return () => {
|
|
2419
|
-
clip.removeEventListener("focusin", onFocusIn);
|
|
2420
|
-
clip.removeEventListener("focusout", onFocusOut);
|
|
2421
|
-
};
|
|
2422
|
-
}, [open]);
|
|
2333
|
+
const clipCss = emCss({
|
|
2334
|
+
display: "grid",
|
|
2335
|
+
gridTemplateRows: open ? "1fr" : "0fr",
|
|
2336
|
+
transition: "grid-template-rows 360ms cubic-bezier(.25,.8,.4,1)",
|
|
2337
|
+
overflow: "hidden",
|
|
2338
|
+
contain: "layout style",
|
|
2339
|
+
position: "relative"
|
|
2340
|
+
});
|
|
2423
2341
|
const innerCss = emCss({
|
|
2342
|
+
minHeight: 0,
|
|
2424
2343
|
width: "100%",
|
|
2425
2344
|
display: "flex",
|
|
2426
2345
|
flexDirection: "column",
|
|
@@ -2440,20 +2359,15 @@ var SubMenuContent = ({ children, css: userCss }) => {
|
|
|
2440
2359
|
"data-open": open ? "" : void 0,
|
|
2441
2360
|
className: "plainframe-ui-submenu-content",
|
|
2442
2361
|
css: [emCss({ width: "100%" }), userCss],
|
|
2443
|
-
children: /* @__PURE__ */ jsx9(
|
|
2362
|
+
children: /* @__PURE__ */ jsx9("div", { className: "plainframe-ui-submenu-clip", css: clipCss, children: /* @__PURE__ */ jsx9(
|
|
2444
2363
|
"div",
|
|
2445
2364
|
{
|
|
2446
|
-
ref:
|
|
2447
|
-
className: "plainframe-ui-submenu-
|
|
2448
|
-
css:
|
|
2449
|
-
|
|
2450
|
-
contain: "layout style",
|
|
2451
|
-
position: "relative",
|
|
2452
|
-
overflow: "hidden"
|
|
2453
|
-
}),
|
|
2454
|
-
children: /* @__PURE__ */ jsx9("div", { ref: innerRef, className: "plainframe-ui-submenu-inner", css: innerCss, children })
|
|
2365
|
+
ref: innerRef,
|
|
2366
|
+
className: "plainframe-ui-submenu-inner",
|
|
2367
|
+
css: innerCss,
|
|
2368
|
+
children
|
|
2455
2369
|
}
|
|
2456
|
-
)
|
|
2370
|
+
) })
|
|
2457
2371
|
}
|
|
2458
2372
|
) });
|
|
2459
2373
|
};
|