asma-ui-core 3.64.1 → 3.64.2

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,51 +1,101 @@
1
- import { cn as n } from "../../../helpers/cn.js";
2
- import { resolveSx as f } from "../../../helpers/sx.js";
3
- import { getOpenModalDialogAncestor as w } from "../../../hooks/useTopLayer.hook.js";
4
- import { useFocusTrap as h } from "../../../hooks/useFocusTrap.hook.js";
5
- import { useEffect as b, useRef as k } from "react";
6
- import { jsx as m, jsxs as E } from "react/jsx-runtime";
7
- import { FloatingPortal as S } from "@floating-ui/react";
8
- var _ = {
1
+ import { cn as c } from "../../../helpers/cn.js";
2
+ import { resolveSx as m } from "../../../helpers/sx.js";
3
+ import { TOP_LAYER_PROPS as d, getOpenModalDialogAncestor as O, shouldUsePopoverTopLayer as b } from "../../../hooks/useTopLayer.hook.js";
4
+ import { useFocusTrap as T } from "../../../hooks/useFocusTrap.hook.js";
5
+ import { useEffect as S, useLayoutEffect as L, useRef as h } from "react";
6
+ import { jsx as v, jsxs as k } from "react/jsx-runtime";
7
+ import { FloatingPortal as A } from "@floating-ui/react";
8
+ var D = {
9
9
  left: "inset-y-0 left-0 h-full",
10
10
  right: "inset-y-0 right-0 h-full",
11
11
  top: "inset-x-0 top-0 w-full",
12
12
  bottom: "inset-x-0 bottom-0 w-full"
13
- }, D = {
13
+ }, N = {
14
14
  left: "-translate-x-full",
15
15
  right: "translate-x-full",
16
16
  top: "-translate-y-full",
17
17
  bottom: "translate-y-full"
18
- }, T = ({ open: t = !1, onClose: o, anchor: l = "left", variant: u = "temporary", hideBackdrop: d, className: c, sx: p, PaperProps: a, ModalProps: x, anchorEl: y, children: v }) => {
19
- const e = u === "temporary", g = w(y), i = k(null);
20
- return b(() => {
21
- if (!t || !e) return;
22
- const r = (s) => {
23
- s.key === "Escape" && o?.(s, "escapeKeyDown");
18
+ }, y = {
19
+ margin: 0,
20
+ border: "none",
21
+ padding: 0
22
+ }, U = {
23
+ ...y,
24
+ width: "auto",
25
+ height: "auto"
26
+ }, C = {
27
+ left: {
28
+ right: "auto",
29
+ width: "auto"
30
+ },
31
+ right: {
32
+ left: "auto",
33
+ width: "auto"
34
+ },
35
+ top: {
36
+ bottom: "auto",
37
+ height: "auto"
38
+ },
39
+ bottom: {
40
+ top: "auto",
41
+ height: "auto"
42
+ }
43
+ }, G = ({ open: o = !1, onClose: a, anchor: i = "left", variant: E = "temporary", hideBackdrop: _, className: g, sx: w, PaperProps: l, ModalProps: P, anchorEl: x, children: R }) => {
44
+ const e = E === "temporary", f = O(x), s = h(null), n = h(null), r = e && b(f), u = (t) => {
45
+ if (!(!t || !o || !r))
46
+ try {
47
+ typeof t.showPopover == "function" && !t.matches(":popover-open") && t.showPopover();
48
+ } catch {
49
+ }
50
+ };
51
+ return L(() => {
52
+ if (!(!o || !r))
53
+ for (const t of [n.current, s.current]) try {
54
+ if (!t || typeof t.showPopover != "function") continue;
55
+ t.matches(":popover-open") && t.hidePopover(), t.showPopover();
56
+ } catch {
57
+ }
58
+ }, [o, r]), S(() => {
59
+ if (!o || !e) return;
60
+ const t = (p) => {
61
+ p.key === "Escape" && a?.(p, "escapeKeyDown");
24
62
  };
25
- return document.addEventListener("keydown", r), () => document.removeEventListener("keydown", r);
63
+ return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
26
64
  }, [
27
- t,
65
+ o,
28
66
  e,
29
- o
30
- ]), h(t && e, i), e && !t && !x?.keepMounted ? null : /* @__PURE__ */ E(S, {
31
- root: g,
32
- children: [e && !d && t && /* @__PURE__ */ m("div", {
67
+ a
68
+ ]), T(o && e, s), e && !o && !P?.keepMounted ? null : /* @__PURE__ */ k(A, {
69
+ root: f,
70
+ children: [e && !_ && o && /* @__PURE__ */ v("div", {
71
+ ref: (t) => {
72
+ n.current = t, u(t);
73
+ },
74
+ ...r ? d : void 0,
33
75
  className: "fixed inset-0 z-[1200] bg-[#626e7eb2]",
34
- onClick: (r) => o?.(r, "backdropClick")
35
- }), /* @__PURE__ */ m("div", {
36
- ref: i,
76
+ style: r ? U : void 0,
77
+ onClick: (t) => a?.(t, "backdropClick")
78
+ }), /* @__PURE__ */ v("div", {
79
+ ref: (t) => {
80
+ s.current = t, u(t);
81
+ },
82
+ ...r ? d : void 0,
37
83
  role: e ? "dialog" : void 0,
38
- "aria-modal": e && t ? !0 : void 0,
39
- "aria-hidden": !t,
40
- className: n("fixed z-[1200] overflow-auto bg-white transition-transform duration-300", t && "shadow-[0px_4px_40px_0px_#22213366]", _[l], !t && n(D[l], "pointer-events-none"), c, a?.className),
84
+ "aria-modal": e && o ? !0 : void 0,
85
+ "aria-hidden": !o,
86
+ className: c("fixed z-[1200] overflow-auto bg-white transition-transform duration-300", o && "shadow-[0px_4px_40px_0px_#22213366]", D[i], !o && c(N[i], "pointer-events-none"), g, l?.className),
41
87
  style: {
42
- ...f(p),
43
- ...f(a?.sx)
88
+ ...r && {
89
+ ...y,
90
+ ...C[i]
91
+ },
92
+ ...m(w),
93
+ ...m(l?.sx)
44
94
  },
45
- children: v
95
+ children: R
46
96
  })]
47
97
  });
48
98
  };
49
99
  export {
50
- T as StyledDrawer
100
+ G as StyledDrawer
51
101
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.64.1",
6
+ "version": "3.64.2",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",