asma-ui-core 3.51.0 → 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,23 +1,23 @@
1
1
  import { cn as n } from "../../../helpers/cn.js";
2
- import { resolveSx as M } from "../../../helpers/sx.js";
3
- import { ChevronRightIcon as V } from "../../icons/chevron-right-icon/ChevronRightIcon.js";
4
- import { ChevronLeftIcon as _ } from "../../icons/chevron-left-icon/ChevronLeftIcon.js";
2
+ import { resolveSx as K } from "../../../helpers/sx.js";
3
+ import { ChevronRightIcon as M } from "../../icons/chevron-right-icon/ChevronRightIcon.js";
4
+ import { ChevronLeftIcon as V } from "../../icons/chevron-left-icon/ChevronLeftIcon.js";
5
5
  import { consumerOverrides as q } from "../../../helpers/classOverride.js";
6
6
  import { TabsContext as z } from "./TabsContext.js";
7
- import { Children as F, cloneElement as G, isValidElement as J, useCallback as u, useLayoutEffect as Q, useMemo as U, useRef as E, useState as A } from "react";
7
+ import { Children as F, cloneElement as G, isValidElement as J, useCallback as b, useLayoutEffect as Q, useMemo as U, useRef as E, useState as A } from "react";
8
8
  import { jsx as l, jsxs as B } from "react/jsx-runtime";
9
- var I = 120, le = ({ value: i, onChange: m, variant: g = "standard", scrollButtons: w = "auto", centered: j, size: b = "default", className: x, sx: N, children: y }) => {
10
- const a = E(null), d = E(/* @__PURE__ */ new Map()), [h, O] = A({
9
+ var I = 120, le = ({ value: i, onChange: m, variant: g = "standard", scrollButtons: w = "auto", centered: j, size: h = "default", className: p, sx: N, children: x }) => {
10
+ const a = E(null), c = E(/* @__PURE__ */ new Map()), [u, O] = A({
11
11
  left: 0,
12
12
  width: 0,
13
13
  disabled: !1
14
- }), [c, W] = A({
14
+ }), [d, W] = A({
15
15
  left: !1,
16
16
  right: !1
17
- }), p = g === "scrollable", v = u((e, t) => {
18
- t ? d.current.set(e, t) : d.current.delete(e);
19
- }, []), S = u((e, t) => m?.(e, t), [m]), f = u(() => {
20
- const e = d.current.get(i), t = a.current;
17
+ }), y = g === "scrollable", v = b((e, t) => {
18
+ t ? c.current.set(e, t) : c.current.delete(e);
19
+ }, []), S = b((e, t) => m?.(e, t), [m]), f = b(() => {
20
+ const e = c.current.get(i), t = a.current;
21
21
  if (e && O({
22
22
  left: e.offsetLeft,
23
23
  width: e.offsetWidth,
@@ -36,13 +36,13 @@ var I = 120, le = ({ value: i, onChange: m, variant: g = "standard", scrollButto
36
36
  if (!e) return;
37
37
  const t = new ResizeObserver(f);
38
38
  return t.observe(e), () => t.disconnect();
39
- }, [f, y]);
39
+ }, [f, x]);
40
40
  const k = (e) => {
41
41
  a.current?.scrollBy({
42
42
  left: e,
43
43
  behavior: "smooth"
44
44
  });
45
- }, D = (e) => {
45
+ }, _ = (e) => {
46
46
  if (![
47
47
  "ArrowRight",
48
48
  "ArrowLeft",
@@ -50,35 +50,35 @@ var I = 120, le = ({ value: i, onChange: m, variant: g = "standard", scrollButto
50
50
  "End"
51
51
  ].includes(e.key)) return;
52
52
  e.preventDefault();
53
- const t = Array.from(d.current.values()).filter((s) => !s.disabled);
53
+ const t = Array.from(c.current.values()).filter((s) => !s.disabled);
54
54
  if (t.length === 0) return;
55
55
  const o = t.findIndex((s) => s === document.activeElement);
56
56
  let r = o;
57
57
  e.key === "ArrowRight" ? r = (o + 1) % t.length : e.key === "ArrowLeft" ? r = (o - 1 + t.length) % t.length : e.key === "Home" ? r = 0 : e.key === "End" && (r = t.length - 1), t[r]?.focus();
58
- }, L = p && w !== !1, R = w === !0, P = L && (R || c.left), T = L && (R || c.right), H = q(x, "padding-x"), K = U(() => ({
58
+ }, L = y && w !== !1, R = w === !0, D = L && (R || d.left), P = L && (R || d.right), T = q(p, "padding-x"), H = U(() => ({
59
59
  value: i,
60
- size: b,
60
+ size: h,
61
61
  onSelect: S,
62
62
  register: v
63
63
  }), [
64
64
  i,
65
- b,
65
+ h,
66
66
  S,
67
67
  v
68
68
  ]), C = "flex h-10 w-10 shrink-0 items-center justify-center self-center rounded-[10%] border border-solid border-delta-500 text-delta-700 transition-colors hover:bg-gama-50 disabled:invisible";
69
69
  return /* @__PURE__ */ l(z.Provider, {
70
- value: K,
70
+ value: H,
71
71
  children: /* @__PURE__ */ B("div", {
72
- className: n("relative flex items-center rounded-t-lg bg-white", !H && "px-4", x),
73
- style: M(N),
72
+ className: n("relative flex items-center rounded-t-lg bg-white", !T && "px-4", p),
73
+ style: K(N),
74
74
  children: [
75
- P && /* @__PURE__ */ l("button", {
75
+ D && /* @__PURE__ */ l("button", {
76
76
  type: "button",
77
77
  "aria-label": "scroll tabs left",
78
78
  className: n(C, "mr-2"),
79
- disabled: !c.left,
79
+ disabled: !d.left,
80
80
  onClick: () => k(-I),
81
- children: /* @__PURE__ */ l(_, {
81
+ children: /* @__PURE__ */ l(V, {
82
82
  width: 24,
83
83
  height: 24
84
84
  })
@@ -87,25 +87,25 @@ var I = 120, le = ({ value: i, onChange: m, variant: g = "standard", scrollButto
87
87
  ref: a,
88
88
  role: "tablist",
89
89
  "aria-orientation": "horizontal",
90
- onKeyDown: D,
90
+ onKeyDown: _,
91
91
  onScroll: f,
92
- className: n("relative flex border-x-0 border-b border-t-0 border-solid border-delta-200 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden", p ? "flex-1 overflow-x-auto" : "w-full", g === "fullWidth" && "[&>*]:flex-1", j && "justify-center", b === "small" && "min-h-9"),
93
- children: [F.map(y, (e, t) => J(e) ? G(e, { index: t }) : e), /* @__PURE__ */ l("span", {
92
+ className: n("relative flex bg-[linear-gradient(to_top,var(--colors-delta-200)_1px,transparent_1px)] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden", y ? "flex-1 overflow-x-auto" : "w-full", g === "fullWidth" && "[&>*]:flex-1", j && "justify-center", h === "small" && "min-h-9"),
93
+ children: [F.map(x, (e, t) => J(e) ? G(e, { index: t }) : e), /* @__PURE__ */ l("span", {
94
94
  "aria-hidden": !0,
95
- className: n("absolute bottom-0 h-0.5 transition-all duration-300", h.disabled ? "bg-delta-300" : "bg-gama-500"),
95
+ className: n("absolute bottom-0 h-0.5 transition-all duration-300", u.disabled ? "bg-delta-300" : "bg-gama-500"),
96
96
  style: {
97
- left: h.left,
98
- width: h.width
97
+ left: u.left,
98
+ width: u.width
99
99
  }
100
100
  })]
101
101
  }),
102
- T && /* @__PURE__ */ l("button", {
102
+ P && /* @__PURE__ */ l("button", {
103
103
  type: "button",
104
104
  "aria-label": "scroll tabs right",
105
105
  className: n(C, "ml-2"),
106
- disabled: !c.right,
106
+ disabled: !d.right,
107
107
  onClick: () => k(I),
108
- children: /* @__PURE__ */ l(V, {
108
+ children: /* @__PURE__ */ l(M, {
109
109
  width: 24,
110
110
  height: 24
111
111
  })
@@ -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.0",
6
+ "version": "3.52.0",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",