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