asma-ui-core 3.51.1 → 3.52.0

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.
@@ -1,11 +1,11 @@
1
- import { cn as y } from "../../../helpers/cn.js";
2
- import { StyledPopover as S } from "../../utils/popover/StyledPopover.js";
3
- import { StyledMenuList as f } from "./StyledMenuList.js";
1
+ import { cn as S } from "../../../helpers/cn.js";
2
+ import { StyledPopover as f } from "../../utils/popover/StyledPopover.js";
3
+ import { StyledMenuList as u } from "./StyledMenuList.js";
4
4
  import { jsx as p } from "react/jsx-runtime";
5
- var u = {
5
+ var v = {
6
6
  border: "1px solid var(--colors-delta-300)",
7
7
  boxShadow: "0px 2px 4px 0px rgba(34, 33, 51, 0.15)"
8
- }, M = ({ open: a, anchorEl: o, onClose: t, anchorOrigin: l, transformOrigin: m, id: d, className: s, sx: x, classes: e, slotProps: r, autoFocus: i = !0, onClick: c, children: n }) => /* @__PURE__ */ p(S, {
8
+ }, h = ({ open: a, anchorEl: o, onClose: t, anchorOrigin: l, transformOrigin: m, id: d, className: s, sx: x, classes: e, slotProps: r, autoFocus: i = !0, onClick: c, children: n, keepMounted: y }) => /* @__PURE__ */ p(f, {
9
9
  open: a,
10
10
  anchorEl: o,
11
11
  onClose: t,
@@ -14,12 +14,13 @@ var u = {
14
14
  id: d,
15
15
  className: s,
16
16
  sx: x,
17
+ keepMounted: y,
17
18
  slotProps: { paper: {
18
- className: y("rounded", e?.paper, r?.paper?.className),
19
- sx: [u, r?.paper?.sx],
19
+ className: S("rounded", e?.paper, r?.paper?.className),
20
+ sx: [v, r?.paper?.sx],
20
21
  style: r?.paper?.style
21
22
  } },
22
- children: /* @__PURE__ */ p(f, {
23
+ children: /* @__PURE__ */ p(u, {
23
24
  autoFocus: i,
24
25
  className: e?.list,
25
26
  onClick: c,
@@ -27,5 +28,5 @@ var u = {
27
28
  })
28
29
  });
29
30
  export {
30
- M as StyledMenu
31
+ h as StyledMenu
31
32
  };
@@ -1,53 +1,68 @@
1
- import { cn as A } from "../../../helpers/cn.js";
2
- import { resolveSx as i } from "../../../helpers/sx.js";
3
- import { TOP_LAYER_PROPS as F, TOP_LAYER_RESET_STYLE as P, getOpenModalDialogAncestor as S, useTopLayerRef as h } from "../../../hooks/useTopLayer.hook.js";
4
- import { useMemo as l } from "react";
5
- import { jsx as s } from "react/jsx-runtime";
6
- import { FloatingPortal as w, autoUpdate as E, flip as L, offset as z, shift as D, useDismiss as M, useFloating as O, useInteractions as N, useMergeRefs as k } from "@floating-ui/react";
7
- var C = {
1
+ import { cn as E } from "../../../helpers/cn.js";
2
+ import { resolveSx as p } from "../../../helpers/sx.js";
3
+ import { TOP_LAYER_PROPS as F, TOP_LAYER_RESET_STYLE as O, getOpenModalDialogAncestor as L, useTopLayerRef as M } from "../../../hooks/useTopLayer.hook.js";
4
+ import { useEffect as z, useMemo as f, useState as D } from "react";
5
+ import { jsx as c } from "react/jsx-runtime";
6
+ import { FloatingPortal as N, autoUpdate as k, flip as C, offset as U, shift as Y, useDismiss as H, useFloating as K, useInteractions as $, useMergeRefs as j } from "@floating-ui/react";
7
+ var I = {
8
8
  vertical: "bottom",
9
9
  horizontal: "left"
10
- }, U = {
10
+ }, q = {
11
11
  vertical: "top",
12
12
  horizontal: "left"
13
- }, Y = (e, t) => `${t.vertical === "bottom" ? "top" : t.vertical === "top" ? "bottom" : e.vertical === "top" ? "top" : "bottom"}${e.horizontal === "left" ? "-start" : e.horizontal === "right" ? "-end" : ""}`, B = ({ open: e, anchorEl: t, onClose: p, anchorOrigin: r = C, transformOrigin: a = U, id: n, className: m, sx: f, slotProps: o, onClick: d, children: c }) => {
14
- const { refs: u, floatingStyles: g, context: v } = O({
13
+ }, B = (e, o) => `${o.vertical === "bottom" ? "top" : o.vertical === "top" ? "bottom" : e.vertical === "top" ? "top" : "bottom"}${e.horizontal === "left" ? "-start" : e.horizontal === "right" ? "-end" : ""}`, Z = ({ open: e, anchorEl: o, onClose: d, anchorOrigin: i = I, transformOrigin: l = q, id: u, className: m, sx: v, slotProps: a, onClick: g, children: h, keepMounted: y = !1 }) => {
14
+ const R = f(() => B(i, l), [i, l]), [n, _] = D(e);
15
+ e && !n && _(!0);
16
+ const r = e || y && n, { refs: s, floatingStyles: x, context: P } = K({
15
17
  open: e,
16
- placement: l(() => Y(r, a), [r, a]),
18
+ placement: R,
17
19
  strategy: "fixed",
18
- whileElementsMounted: E,
19
- elements: { reference: t ?? void 0 },
20
+ whileElementsMounted: k,
21
+ elements: { reference: o ?? void 0 },
20
22
  middleware: [
21
- z(4),
22
- L({ padding: 8 }),
23
- D({ padding: 8 })
23
+ U(4),
24
+ C({ padding: 8 }),
25
+ Y({ padding: 8 })
24
26
  ],
25
- onOpenChange: (y, T, b) => {
26
- y || p?.(T ?? {}, b === "escape-key" ? "escapeKeyDown" : "backdropClick");
27
+ onOpenChange: (t, b, A) => {
28
+ t || d?.(b ?? {}, A === "escape-key" ? "escapeKeyDown" : "backdropClick");
27
29
  }
28
- }), { getFloatingProps: R } = N([M(v, {
30
+ }), { getFloatingProps: w } = $([H(P, {
29
31
  outsidePress: !0,
30
32
  escapeKey: !0
31
- })]), _ = k([h(u.setFloating)]), x = l(() => e ? S(t) : void 0, [e, t]);
32
- return e ? /* @__PURE__ */ s(w, {
33
- root: x,
34
- children: /* @__PURE__ */ s("div", {
35
- ref: _,
36
- id: n,
33
+ })]), S = j([M(s.setFloating)]), T = f(() => r ? L(o) : void 0, [r, o]);
34
+ return z(() => {
35
+ if (!r) return;
36
+ const t = s.floating.current;
37
+ if (!(!t || typeof t.showPopover != "function"))
38
+ try {
39
+ e && !t.matches(":popover-open") && t.showPopover(), !e && t.matches(":popover-open") && t.hidePopover();
40
+ } catch {
41
+ }
42
+ }, [
43
+ e,
44
+ r,
45
+ s.floating
46
+ ]), r ? /* @__PURE__ */ c(N, {
47
+ root: T,
48
+ children: /* @__PURE__ */ c("div", {
49
+ ref: S,
50
+ id: u,
37
51
  ...F,
38
52
  style: {
39
- ...P,
40
- ...g,
41
- ...i(f),
42
- ...i(o?.paper?.sx),
43
- ...o?.paper?.style
53
+ ...O,
54
+ ...e ? x : {},
55
+ ...p(v),
56
+ ...p(a?.paper?.sx),
57
+ ...a?.paper?.style,
58
+ ...e ? null : { display: "none" }
44
59
  },
45
- ...R({ onClick: d }),
46
- className: A("z-[1300] overflow-auto rounded bg-white shadow-[0px_1px_12px_0px_rgba(0,0,0,0.15)]", m ?? "my-1", o?.paper?.className),
47
- children: c
60
+ ...e ? w({ onClick: g }) : {},
61
+ className: E("z-[1300] overflow-auto rounded bg-white shadow-[0px_1px_12px_0px_rgba(0,0,0,0.15)]", m ?? "my-1", a?.paper?.className),
62
+ children: h
48
63
  })
49
64
  }) : null;
50
65
  };
51
66
  export {
52
- B as StyledPopover
67
+ Z as StyledPopover
53
68
  };
@@ -1,5 +1,5 @@
1
- import { CSSProperties, ReactNode } from 'react';
2
1
  import { Placement } from '@floating-ui/react';
2
+ import { CSSProperties, ReactNode } from 'react';
3
3
  export interface PopperTransitionProps {
4
4
  in: boolean;
5
5
  onExited: () => void;
@@ -24,10 +24,12 @@ export interface MenuProps {
24
24
  autoFocus?: boolean;
25
25
  onClick?: (event: MouseEvent<HTMLUListElement>) => void;
26
26
  children?: ReactNode;
27
+ /** MUI `Menu` `keepMounted` parity — see `StyledPopover.keepMounted`. */
28
+ keepMounted?: boolean;
27
29
  }
28
30
  /**
29
31
  * Anchored menu (replaces MUI `Menu`) = `StyledPopover` + a keyboard-navigable `StyledMenuList`.
30
32
  * Public props (`open`/`anchorEl`/`onClose`/`anchorOrigin`/`classes`/`autoFocus`) preserved
31
33
  * (DEC-003). TASK-303.
32
34
  */
33
- export declare const StyledMenu: ({ open, anchorEl, onClose, anchorOrigin, transformOrigin, id, className, sx, classes, slotProps, autoFocus, onClick, children, }: MenuProps) => JSX.Element;
35
+ export declare const StyledMenu: ({ open, anchorEl, onClose, anchorOrigin, transformOrigin, id, className, sx, classes, slotProps, autoFocus, onClick, children, keepMounted, }: MenuProps) => JSX.Element;
@@ -22,6 +22,12 @@ export interface StyledPopoverProps {
22
22
  };
23
23
  onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
24
24
  children?: ReactNode;
25
+ /**
26
+ * MUI `keepMounted` parity: after the first open, keep children in the React tree while closed
27
+ * (hidden). Needed when a menu item owns a dialog — without this, closing the menu unmounts the
28
+ * dialog in the same tick it opens.
29
+ */
30
+ keepMounted?: boolean;
25
31
  }
26
32
  /**
27
33
  * @figmaNode none — no standalone Figma component
@@ -36,4 +42,4 @@ export interface StyledPopoverProps {
36
42
  * mapping to MUI's `onClose(event, reason)`. `anchorOrigin`/`transformOrigin`/`slotProps.paper`
37
43
  * preserved (DEC-003). TASK-302.
38
44
  */
39
- export declare const StyledPopover: ({ open, anchorEl, onClose, anchorOrigin, transformOrigin, id, className, sx, slotProps, onClick, children, }: StyledPopoverProps) => JSX.Element | null;
45
+ export declare const StyledPopover: ({ open, anchorEl, onClose, anchorOrigin, transformOrigin, id, className, sx, slotProps, onClick, children, keepMounted, }: StyledPopoverProps) => JSX.Element | null;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.51.1",
6
+ "version": "3.52.0",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",