plainframe-ui 0.1.4 → 0.1.6

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 CHANGED
@@ -1060,7 +1060,6 @@ declare const Rotate: React.FC<RotateProps>;
1060
1060
  type Align$1 = "left" | "center" | "right";
1061
1061
  type Variant$4 = "subtle" | "outlined" | "ghost";
1062
1062
  type SelectProps<T = unknown> = {
1063
- /** optional controlled value(s); if omitted, trigger text is derived from child selection props */
1064
1063
  value?: T | T[];
1065
1064
  defaultValue?: T | T[];
1066
1065
  onChange?: (value: T | T[]) => void;
@@ -1080,15 +1079,12 @@ type SelectProps<T = unknown> = {
1080
1079
  labelCss?: Interpolation<Theme>;
1081
1080
  triggerCss?: Interpolation<Theme>;
1082
1081
  menuCss?: Interpolation<Theme>;
1083
- /** you pass real MenuItem / MenuRadioItem / MenuCheckboxItem (and optional MenuRadioGroup) here */
1084
1082
  children: React.ReactNode;
1085
1083
  className?: string;
1086
1084
  menuSize?: "sm" | "md";
1087
- /** custom trigger renderer (receives the resolved label text or array of labels) */
1088
1085
  triggerRender?: (selected: string | string[] | undefined) => React.ReactNode;
1089
1086
  };
1090
- declare function Select<T = unknown>({ value, defaultValue, onChange, // not wired here; your Menu components should manage selection & call you
1091
- label, placeholder, startIcon, endIcon, disabled, size, variant, fullWidth, width, menuAlign, menuWidth, menuMaxHeight, wrapperCss, labelCss, triggerCss, menuCss, children, className, menuSize, triggerRender, }: SelectProps<T>): JSX.Element;
1087
+ declare function Select<T = unknown>({ value, defaultValue, onChange, label, placeholder, startIcon, endIcon, disabled, size, variant, fullWidth, width, menuAlign, menuWidth, menuMaxHeight, wrapperCss, labelCss, triggerCss, menuCss, children, className, menuSize, triggerRender, }: SelectProps<T>): JSX.Element;
1092
1088
 
1093
1089
  /** @jsxImportSource @emotion/react */
1094
1090
 
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,80 +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 seqRef = useRef5(0);
2300
- const firstRef = useRef5(true);
2301
- useLayoutEffect2(() => {
2302
- const clip = clipRef.current;
2303
- const inner = innerRef.current;
2304
- if (!clip || !inner) return;
2305
- const key = ++seqRef.current;
2306
- const dur = "360ms cubic-bezier(.25,.8,.4,1)";
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
- clip.style.transition = "none";
2322
- clip.style.overflow = "hidden";
2323
- clip.style.maxHeight = `${from}px`;
2324
- void clip.offsetHeight;
2325
- clip.style.transition = `max-height ${dur}`;
2326
- clip.style.maxHeight = `${to}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 || !window.ResizeObserver) return;
2357
- const ro = new window.ResizeObserver(() => {
2358
- if (!open) return;
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";
2364
- }
2365
- });
2366
- ro.observe(inner);
2367
- return () => {
2368
- ro.disconnect();
2369
- };
2370
- }, [open]);
2371
2297
  useEffect3(() => {
2372
2298
  const root = innerRef.current;
2373
2299
  if (!root) return;
@@ -2404,25 +2330,16 @@ var SubMenuContent = ({ children, css: userCss }) => {
2404
2330
  });
2405
2331
  }
2406
2332
  }, [open]);
2407
- useEffect3(() => {
2408
- const clip = clipRef.current;
2409
- if (!clip) return;
2410
- const onFocusIn = () => {
2411
- clip.style.overflow = "visible";
2412
- };
2413
- const onFocusOut = (e) => {
2414
- if (!clip.contains(e.relatedTarget)) {
2415
- clip.style.overflow = open ? "visible" : "hidden";
2416
- }
2417
- };
2418
- clip.addEventListener("focusin", onFocusIn);
2419
- clip.addEventListener("focusout", onFocusOut);
2420
- return () => {
2421
- clip.removeEventListener("focusin", onFocusIn);
2422
- clip.removeEventListener("focusout", onFocusOut);
2423
- };
2424
- }, [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
+ });
2425
2341
  const innerCss = emCss({
2342
+ minHeight: 0,
2426
2343
  width: "100%",
2427
2344
  display: "flex",
2428
2345
  flexDirection: "column",
@@ -2430,7 +2347,7 @@ var SubMenuContent = ({ children, css: userCss }) => {
2430
2347
  margin: 0,
2431
2348
  padding: 0,
2432
2349
  opacity: open ? 1 : 0,
2433
- transform: open ? "translateY(0) scale(1)" : "translateY(16px) scale(0.96)",
2350
+ transform: open ? "translateY(0) scale(1)" : "translateY(1rem) scale(0.95)",
2434
2351
  transition: "opacity 0.35s ease, transform 0.28s ease",
2435
2352
  pointerEvents: open ? "auto" : "none",
2436
2353
  willChange: "opacity, transform"
@@ -2442,20 +2359,15 @@ var SubMenuContent = ({ children, css: userCss }) => {
2442
2359
  "data-open": open ? "" : void 0,
2443
2360
  className: "plainframe-ui-submenu-content",
2444
2361
  css: [emCss({ width: "100%" }), userCss],
2445
- children: /* @__PURE__ */ jsx9(
2362
+ children: /* @__PURE__ */ jsx9("div", { className: "plainframe-ui-submenu-clip", css: clipCss, children: /* @__PURE__ */ jsx9(
2446
2363
  "div",
2447
2364
  {
2448
- ref: clipRef,
2449
- className: "plainframe-ui-submenu-clip",
2450
- css: emCss({
2451
- willChange: "max-height",
2452
- contain: "layout style",
2453
- position: "relative",
2454
- overflow: "hidden"
2455
- }),
2456
- 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
2457
2369
  }
2458
- )
2370
+ ) })
2459
2371
  }
2460
2372
  ) });
2461
2373
  };
@@ -6046,9 +5958,8 @@ var Button = React20.memo(React20.forwardRef(({
6046
5958
  }, ref) => {
6047
5959
  const theme = usePlainframeUITheme();
6048
5960
  const focusRing = useFocusRing();
6049
- const normalizedVariant = variant === "ghost-destructive" ? "ghost-destructive" : variant;
6050
5961
  const S = useMemo10(() => getSize3(theme, size), [theme, size]);
6051
- const vis = useMemo10(() => resolveVisuals(theme, normalizedVariant), [theme, normalizedVariant]);
5962
+ const vis = useMemo10(() => resolveVisuals(theme, variant), [theme, variant]);
6052
5963
  const isIconOnly = useMemo10(
6053
5964
  () => !startIcon && !endIcon && !hasText(children) && React20.Children.count(children) === 1,
6054
5965
  [startIcon, endIcon, children]
@@ -6232,7 +6143,7 @@ var Button = React20.memo(React20.forwardRef(({
6232
6143
  {
6233
6144
  ref,
6234
6145
  type: "type" in props && props.type ? props.type : "button",
6235
- "data-variant": normalizedVariant,
6146
+ "data-variant": variant,
6236
6147
  className: ["plainframe-ui-button", className || ""].join(" ").trim(),
6237
6148
  css: [
6238
6149
  rootBase,
@@ -9865,12 +9776,10 @@ var RadioItem = ({
9865
9776
  fontSize: theme.fontSizes.md,
9866
9777
  fontWeight: 500,
9867
9778
  padding: theme.spacing.sm,
9868
- // Hover applies to the CIRCLE only if NOT checked
9869
9779
  "&:hover .plainframe-ui-radio-circle-outer": isDisabled || isChecked ? {} : {
9870
9780
  background: hoverCircleBg,
9871
9781
  boxShadow: variant === "outlined" ? `inset 0 0 0 ${theme.componentHeights.border} ${stroke}` : "none"
9872
9782
  },
9873
- // Focus ring hint on circle
9874
9783
  "&:focus-visible .plainframe-ui-radio-circle-outer": {
9875
9784
  outline: "none",
9876
9785
  filter: "brightness(1.06)"
@@ -10098,7 +10007,6 @@ function Select({
10098
10007
  value,
10099
10008
  defaultValue,
10100
10009
  onChange,
10101
- // not wired here; your Menu components should manage selection & call you
10102
10010
  label,
10103
10011
  placeholder = "Select\u2026",
10104
10012
  startIcon,