asma-ui-core 3.134.4 → 3.134.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.
@@ -3,139 +3,142 @@ import { resolveSx as R } from "../../../helpers/sx.js";
3
3
  import { tabbableWithin as y } from "../../../helpers/focusable.js";
4
4
  import { TOP_LAYER_PROPS as j, TOP_LAYER_RESET_STYLE as q, getOpenModalDialogAncestor as C, shouldUsePopoverTopLayer as G, useTopLayerRef as J } from "../../../hooks/useTopLayer.hook.js";
5
5
  import { OverlayBackOwnerContext as Q, useBackCloses as V } from "../../../hooks/useBackCloses.hook.js";
6
- import { useEffect as P, useMemo as X, useRef as Z, useState as w } from "react";
7
- import { jsx as x } from "react/jsx-runtime";
8
- import { FloatingPortal as ee, autoUpdate as te, flip as oe, offset as ne, shift as re, size as se, useDismiss as ie, useFloating as ae, useInteractions as ce, useMergeRefs as fe } from "@floating-ui/react";
9
- var ue = {
6
+ import { useEffect as x, useMemo as X, useRef as Z, useState as b } from "react";
7
+ import { jsx as P } from "react/jsx-runtime";
8
+ import { FloatingPortal as ee, autoUpdate as te, flip as oe, offset as ne, shift as re, size as se, useDismiss as ae, useFloating as ie, useInteractions as ce, useMergeRefs as fe } from "@floating-ui/react";
9
+ var le = {
10
10
  vertical: "bottom",
11
11
  horizontal: "left"
12
- }, le = {
12
+ }, ue = {
13
13
  vertical: "top",
14
14
  horizontal: "left"
15
- }, de = (t, o) => `${o.vertical === "bottom" ? "top" : o.vertical === "top" ? "bottom" : t.vertical === "top" ? "top" : "bottom"}${t.horizontal === "left" ? "-start" : t.horizontal === "right" ? "-end" : ""}`, be = ({ open: t, anchorEl: o, onClose: c, anchorOrigin: h = ue, transformOrigin: b = le, id: D, className: T, sx: K, slotProps: l, onClick: k, children: E, keepMounted: O = !1, tabIntoContent: d = !0, registerBackClose: S = !0 }) => {
16
- const _ = X(() => de(h, b), [h, b]), [L, F] = w(t), f = Z(!1), [M, H] = w();
17
- t && !L && F(!0);
18
- const m = t || O && L, p = C(o), [v, A] = w(p);
19
- o && v !== p && A(p);
20
- const { refs: i, floatingStyles: z, context: N } = ae({
21
- open: t,
22
- placement: _,
15
+ }, de = (o) => {
16
+ const t = getComputedStyle(o);
17
+ return t.boxSizing === "border-box" ? 0 : parseFloat(t.paddingTop) + parseFloat(t.paddingBottom) + parseFloat(t.borderTopWidth) + parseFloat(t.borderBottomWidth);
18
+ }, pe = (o, t) => `${t.vertical === "bottom" ? "top" : t.vertical === "top" ? "bottom" : o.vertical === "top" ? "top" : "bottom"}${o.horizontal === "left" ? "-start" : o.horizontal === "right" ? "-end" : ""}`, Le = ({ open: o, anchorEl: t, onClose: c, anchorOrigin: h = le, transformOrigin: w = ue, id: T, className: D, sx: F, slotProps: u, onClick: K, children: S, keepMounted: E = !1, tabIntoContent: d = !0, registerBackClose: k = !0 }) => {
19
+ const O = X(() => pe(h, w), [h, w]), [L, _] = b(o), f = Z(!1), [M, H] = b();
20
+ o && !L && _(!0);
21
+ const p = o || E && L, m = C(t), [g, z] = b(m);
22
+ t && g !== m && z(m);
23
+ const { refs: a, floatingStyles: A, context: B } = ie({
24
+ open: o,
25
+ placement: O,
23
26
  strategy: "fixed",
24
27
  whileElementsMounted: te,
25
- elements: { reference: o ?? void 0 },
28
+ elements: { reference: t ?? void 0 },
26
29
  middleware: [
27
30
  ne(4),
28
31
  oe({ padding: 8 }),
29
32
  re({ padding: 8 }),
30
33
  se({
31
34
  padding: 8,
32
- apply: ({ availableHeight: e }) => H(e)
35
+ apply: ({ availableHeight: e, elements: n }) => H(Math.max(0, e - de(n.floating)))
33
36
  })
34
37
  ],
35
- onOpenChange: (e, r, n) => {
36
- e || c?.(r ?? {}, n === "escape-key" ? "escapeKeyDown" : "backdropClick");
38
+ onOpenChange: (e, n, r) => {
39
+ e || c?.(n ?? {}, r === "escape-key" ? "escapeKeyDown" : "backdropClick");
37
40
  }
38
- }), { getFloatingProps: U } = ce([ie(N, {
41
+ }), { getFloatingProps: N } = ce([ae(B, {
39
42
  outsidePress: (e) => {
40
- const r = e.target;
41
- return !(o instanceof Element && r instanceof Node && o.contains(r));
43
+ const n = e.target;
44
+ return !(t instanceof Element && n instanceof Node && t.contains(n));
42
45
  },
43
46
  escapeKey: !0
44
47
  })]);
45
48
  V({
46
- active: t && S,
49
+ active: o && k,
47
50
  requestClose: (e) => c ? c(e ?? new Event("overlayBack"), "escapeKeyDown") : !1,
48
- ownerRef: i.floating
51
+ ownerRef: a.floating
49
52
  });
50
- const u = G(v), B = fe([J(i.setFloating, u)]);
51
- P(() => {
52
- if (!t) return;
53
- const e = o instanceof HTMLElement ? o : null, r = () => i.floating.current?.contains(document.activeElement) ?? !1;
54
- let n = r();
53
+ const l = G(g), U = fe([J(a.setFloating, l)]);
54
+ x(() => {
55
+ if (!o) return;
56
+ const e = t instanceof HTMLElement ? t : null, n = () => a.floating.current?.contains(document.activeElement) ?? !1;
57
+ let r = n();
55
58
  const s = () => {
56
- n = r();
59
+ r = n();
57
60
  };
58
61
  return document.addEventListener("focusin", s), () => {
59
62
  document.removeEventListener("focusin", s);
60
- const a = document.activeElement, g = !a || a === document.body || r();
61
- n && g && e?.isConnected && e.focus({ preventScroll: !0 });
63
+ const i = document.activeElement, v = !i || i === document.body || n();
64
+ r && v && e?.isConnected && e.focus({ preventScroll: !0 });
62
65
  };
63
66
  }, [
64
- t,
65
67
  o,
66
- i.floating
67
- ]), P(() => {
68
- if (!t) return;
69
- const e = (n) => {
70
- if (f.current = n.key === "Tab", !d || !f.current || n.shiftKey || n.defaultPrevented) return;
71
- const s = i.floating.current;
72
- if (!s || !(o instanceof Element) || !o.contains(document.activeElement)) return;
73
- const [a] = y(s);
74
- a && (n.preventDefault(), a.focus({ preventScroll: !0 }), f.current = !1);
75
- }, r = (n) => {
76
- const s = n.target, a = s instanceof Node && ((i.floating.current?.contains(s) ?? !1) || o instanceof Element && o.contains(s));
77
- f.current && !a && c?.(n, "tabKeyDown"), f.current = !1;
68
+ t,
69
+ a.floating
70
+ ]), x(() => {
71
+ if (!o) return;
72
+ const e = (r) => {
73
+ if (f.current = r.key === "Tab", !d || !f.current || r.shiftKey || r.defaultPrevented) return;
74
+ const s = a.floating.current;
75
+ if (!s || !(t instanceof Element) || !t.contains(document.activeElement)) return;
76
+ const [i] = y(s);
77
+ i && (r.preventDefault(), i.focus({ preventScroll: !0 }), f.current = !1);
78
+ }, n = (r) => {
79
+ const s = r.target, i = s instanceof Node && ((a.floating.current?.contains(s) ?? !1) || t instanceof Element && t.contains(s));
80
+ f.current && !i && c?.(r, "tabKeyDown"), f.current = !1;
78
81
  };
79
- return document.addEventListener("keydown", e, !0), document.addEventListener("focusin", r), () => {
80
- document.removeEventListener("keydown", e, !0), document.removeEventListener("focusin", r);
82
+ return document.addEventListener("keydown", e, !0), document.addEventListener("focusin", n), () => {
83
+ document.removeEventListener("keydown", e, !0), document.removeEventListener("focusin", n);
81
84
  };
82
85
  }, [
83
- t,
84
86
  o,
87
+ t,
85
88
  c,
86
- i.floating,
89
+ a.floating,
87
90
  d
88
91
  ]);
89
- const I = t ? U({
90
- onClick: k,
92
+ const W = o ? N({
93
+ onClick: K,
91
94
  onKeyDown: (e) => {
92
- if (e.key !== "Tab" || e.defaultPrevented || !(o instanceof HTMLElement)) return;
93
- const r = e.currentTarget, n = y(r), s = n.indexOf(document.activeElement);
94
- if (s === -1 || (e.shiftKey ? s !== 0 : s !== n.length - 1)) return;
95
+ if (e.key !== "Tab" || e.defaultPrevented || !(t instanceof HTMLElement)) return;
96
+ const n = e.currentTarget, r = y(n), s = r.indexOf(document.activeElement);
97
+ if (s === -1 || (e.shiftKey ? s !== 0 : s !== r.length - 1)) return;
95
98
  e.preventDefault();
96
- const a = y(document).filter((W) => !r.contains(W)), g = a[a.indexOf(o) + (e.shiftKey ? -1 : 1)], Y = (d && e.shiftKey ? void 0 : g) ?? o;
97
- f.current = !1, Y.focus({ preventScroll: !0 }), c?.(e, "tabKeyDown");
99
+ const i = y(document).filter((Y) => !n.contains(Y)), v = i[i.indexOf(t) + (e.shiftKey ? -1 : 1)], I = (d && e.shiftKey ? void 0 : v) ?? t;
100
+ f.current = !1, I.focus({ preventScroll: !0 }), c?.(e, "tabKeyDown");
98
101
  }
99
102
  }) : {};
100
- return P(() => {
101
- if (!m || !u) return;
102
- const e = i.floating.current;
103
+ return x(() => {
104
+ if (!p || !l) return;
105
+ const e = a.floating.current;
103
106
  if (!(!e || typeof e.showPopover != "function"))
104
107
  try {
105
- t && !e.matches(":popover-open") && e.showPopover(), !t && e.matches(":popover-open") && e.hidePopover();
108
+ o && !e.matches(":popover-open") && e.showPopover(), !o && e.matches(":popover-open") && e.hidePopover();
106
109
  } catch {
107
110
  }
108
111
  }, [
109
- t,
110
- m,
111
- u,
112
- i.floating
113
- ]), m ? /* @__PURE__ */ x(ee, {
114
- root: v,
115
- children: /* @__PURE__ */ x("div", {
116
- ref: B,
117
- id: D,
118
- ...u ? j : {},
112
+ o,
113
+ p,
114
+ l,
115
+ a.floating
116
+ ]), p ? /* @__PURE__ */ P(ee, {
117
+ root: g,
118
+ children: /* @__PURE__ */ P("div", {
119
+ ref: U,
120
+ id: T,
121
+ ...l ? j : {},
119
122
  style: {
120
- ...u ? q : {},
121
- ...t ? {
122
- ...z,
123
+ ...l ? q : {},
124
+ ...o ? {
125
+ ...A,
123
126
  maxHeight: M
124
127
  } : {},
125
- ...R(K),
126
- ...R(l?.paper?.sx),
127
- ...l?.paper?.style,
128
- ...t ? null : { display: "none" }
128
+ ...R(F),
129
+ ...R(u?.paper?.sx),
130
+ ...u?.paper?.style,
131
+ ...o ? null : { display: "none" }
129
132
  },
130
- ...I,
131
- className: $("z-[1300] overflow-auto rounded bg-white shadow-[0px_1px_12px_0px_rgba(0,0,0,0.15)]", T ?? "my-1", l?.paper?.className),
132
- children: /* @__PURE__ */ x(Q.Provider, {
133
- value: i.floating,
134
- children: E
133
+ ...W,
134
+ className: $("z-[1300] overflow-auto rounded bg-white shadow-[0px_1px_12px_0px_rgba(0,0,0,0.15)]", D ?? "my-1", u?.paper?.className),
135
+ children: /* @__PURE__ */ P(Q.Provider, {
136
+ value: a.floating,
137
+ children: S
135
138
  })
136
139
  })
137
140
  }) : null;
138
141
  };
139
142
  export {
140
- be as StyledPopover
143
+ Le as StyledPopover
141
144
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.134.4",
6
+ "version": "3.134.5",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",