asma-ui-core 3.133.0 → 3.133.1

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,227 +1,244 @@
1
- import { cn as Le } from "../../../helpers/cn.js";
2
- import { firstTabbable as ne } from "../../../helpers/focusable.js";
3
- import { TOP_LAYER_PROPS as Me, TOP_LAYER_RESET_STYLE as Se, getOpenModalDialogAncestor as Ce, shouldUsePopoverTopLayer as Ie, useTopLayerRef as _e } from "../../../hooks/useTopLayer.hook.js";
1
+ import { cn as Me } from "../../../helpers/cn.js";
2
+ import { firstTabbable as re } from "../../../helpers/focusable.js";
3
+ import { TOP_LAYER_PROPS as Se, TOP_LAYER_RESET_STYLE as Ce, getOpenModalDialogAncestor as Ie, shouldUsePopoverTopLayer as _e, useTopLayerRef as We } from "../../../hooks/useTopLayer.hook.js";
4
4
  import { StyledButton as ke } from "../../inputs/button/StyledButton.js";
5
- import { OverlayBackOwnerContext as He, requestCloseTopOverlayBack as We, useBackCloses as Be } from "../../../hooks/useBackCloses.hook.js";
6
- import { isKeyboardModality as De, trackInputModality as qe } from "../../inputs/full-screen-picker/inputModality.js";
7
- import { useDebouncedValue as Xe } from "../../../hooks/useDebouncedValue.hook.js";
8
- import { useFocusTrap as $e } from "../../../hooks/useFocusTrap.hook.js";
9
- import { useMobileMediaQuery as Ke } from "../../../hooks/useMediaQuery.hook.js";
10
- import { SHEET_TEXT as Ne } from "../bottom-sheet/sheetCopy.js";
11
- import { formatResultsLabel as je } from "../bottom-sheet/formatResultsLabel.js";
12
- import { StyledBottomSheet as Ue } from "../bottom-sheet/StyledBottomSheet.js";
13
- import { PopoverAnatomy as Ve } from "./PopoverAnatomy.js";
14
- import { useCallback as d, useEffect as v, useId as Ye, useRef as f, useState as l } from "react";
15
- import { Fragment as re, jsx as m, jsxs as ie } from "react/jsx-runtime";
16
- import { FloatingPortal as ze, autoUpdate as Ge, flip as Qe, offset as Je, shift as Ze, size as et, useDismiss as tt, useFloating as ot, useInteractions as nt, useMergeRefs as rt } from "@floating-ui/react";
17
- var S = 240, it = {
5
+ import { OverlayBackOwnerContext as He, requestCloseTopOverlayBack as Be, useBackCloses as De } from "../../../hooks/useBackCloses.hook.js";
6
+ import { isKeyboardModality as qe, trackInputModality as Xe } from "../../inputs/full-screen-picker/inputModality.js";
7
+ import { useDebouncedValue as $e } from "../../../hooks/useDebouncedValue.hook.js";
8
+ import { useFocusTrap as Ke } from "../../../hooks/useFocusTrap.hook.js";
9
+ import { useMobileMediaQuery as Ne } from "../../../hooks/useMediaQuery.hook.js";
10
+ import { SHEET_TEXT as je } from "../bottom-sheet/sheetCopy.js";
11
+ import { formatResultsLabel as Ue } from "../bottom-sheet/formatResultsLabel.js";
12
+ import { StyledBottomSheet as Ve } from "../bottom-sheet/StyledBottomSheet.js";
13
+ import { PopoverAnatomy as Ye } from "./PopoverAnatomy.js";
14
+ import { useCallback as p, useEffect as b, useId as ze, useRef as g, useState as l } from "react";
15
+ import { Fragment as ie, jsx as h, jsxs as se } from "react/jsx-runtime";
16
+ import { FloatingPortal as Ge, autoUpdate as Qe, flip as Je, offset as Ze, shift as et, size as tt, useDismiss as ot, useFloating as nt, useInteractions as rt, useMergeRefs as it } from "@floating-ui/react";
17
+ var H = 240, st = {
18
18
  info: 472,
19
19
  action: 472
20
- }, se = 0.6, ae = "calc(100vw - 32px)", Rt = ({ dataTest: p, renderTrigger: C, variant: I = "info", title: y, children: _, viewResultsAction: k, resetAction: H, footerActions: W, resultCount: b, locale: R = "en", closeLabel: B = Ne[R].close, ariaLabel: D, onOpenChange: q, className: X, align: $ = "auto", ignoreOutside: K }) => {
21
- const g = Ye(), N = `${g}-title`, [o, ce] = l(!1), [j, le] = l(), [ue, U] = l(), [de, fe] = l("start"), [T, V] = l(), [me, Y] = l(S), u = Ke(), n = I === "action", pe = u && !n, E = u && n, w = d((e) => {
22
- ce(e), q?.(e);
23
- }, [q]), { refs: F, floatingStyles: ge, context: he, placement: z, isPositioned: ve } = ot({
24
- open: o,
25
- onOpenChange: w,
26
- placement: `${T ?? "bottom"}-${de}`,
20
+ }, ae = 0.6, ce = "calc(100vw - 32px)", at = () => {
21
+ let o;
22
+ return {
23
+ name: "holdAlignedEdge",
24
+ fn: ({ x: v, rects: w, placement: f }) => {
25
+ const u = f.endsWith("-end"), E = w.floating.width, { x, width: R } = w.reference;
26
+ return !(o !== void 0 && o.x >= x - 1 && o.x <= x + R + 1) || o?.atEnd !== u || o.viewportWidth !== window.innerWidth ? (o = {
27
+ x: u ? v + E : v,
28
+ atEnd: u,
29
+ viewportWidth: window.innerWidth
30
+ }, {}) : { x: u ? o.x - E : o.x };
31
+ },
32
+ release: () => {
33
+ o = void 0;
34
+ }
35
+ };
36
+ }, Tt = ({ dataTest: o, renderTrigger: v, variant: w = "info", title: f, children: u, viewResultsAction: E, resetAction: x, footerActions: R, resultCount: O, locale: M = "en", closeLabel: B = je[M].close, ariaLabel: D, onOpenChange: q, className: X, align: $ = "auto", ignoreOutside: K }) => {
37
+ const y = ze(), N = `${y}-title`, [n, le] = l(!1), [j, de] = l(), [ue, U] = l(), [fe, me] = l("start"), [S, V] = l(), [pe, Y] = l(H), [z] = l(at), m = Ne(), r = w === "action", ge = m && !r, A = m && r, T = p((e) => {
38
+ le(e), q?.(e);
39
+ }, [q]), { refs: C, floatingStyles: he, context: ve, placement: G, isPositioned: we } = nt({
40
+ open: n,
41
+ onOpenChange: T,
42
+ placement: `${S ?? "bottom"}-${fe}`,
27
43
  strategy: "fixed",
28
- whileElementsMounted: Ge,
44
+ whileElementsMounted: Qe,
29
45
  middleware: [
30
- Je(8),
31
- ...pe || T ? [] : [Qe({
46
+ Ze(8),
47
+ ...ge || S ? [] : [Je({
32
48
  padding: 8,
33
49
  crossAxis: !1,
34
50
  flipAlignment: !1
35
51
  })],
36
- Ze({ padding: 8 }),
37
- et({
52
+ z,
53
+ et({ padding: 8 }),
54
+ tt({
38
55
  padding: 8,
39
56
  apply({ availableHeight: e, rects: t }) {
40
- U(Math.min(e, Math.round(window.innerHeight * se))), u || Y((a) => Math.max(a, t.floating.width));
57
+ U(Math.min(e, Math.round(window.innerHeight * ae))), m || Y((c) => Math.max(c, t.floating.width));
41
58
  }
42
59
  })
43
60
  ]
44
61
  });
45
- o && ve && !T && V(z.startsWith("top") ? "top" : "bottom");
46
- const A = Ie(j), c = f(null), [r, ye] = l(null), Ee = d((e) => {
47
- c.current = e, ye(e);
48
- }, []), we = rt([_e(F.setFloating, A), Ee]), P = f(null), Pe = d((e) => {
49
- P.current = e, F.setReference(e);
50
- }, [F]), G = f(null), O = K?.length ? K.join(",") : void 0, Q = f(O);
51
- v(() => {
52
- Q.current = O;
53
- }, [O]);
54
- const h = d((e) => {
62
+ n && we && !S && V(G.startsWith("top") ? "top" : "bottom");
63
+ const I = _e(j), d = g(null), [i, Ee] = l(null), xe = p((e) => {
64
+ d.current = e, Ee(e);
65
+ }, []), ye = it([We(C.setFloating, I), xe]), F = g(null), Pe = p((e) => {
66
+ F.current = e, C.setReference(e);
67
+ }, [C]), Q = g(null), _ = K?.length ? K.join(",") : void 0, J = g(_);
68
+ b(() => {
69
+ J.current = _;
70
+ }, [_]);
71
+ const P = p((e) => {
55
72
  if (!(e instanceof Element)) return !1;
56
- if (c.current?.contains(e) || P.current?.contains(e) || G.current === e) return !0;
57
- const t = Q.current;
73
+ if (d.current?.contains(e) || F.current?.contains(e) || Q.current === e) return !0;
74
+ const t = J.current;
58
75
  return t !== void 0 && e.closest(t) !== null;
59
- }, []), J = f(null), xe = d((e) => {
60
- G.current = e.target, e.target instanceof HTMLElement && c.current?.contains(e.target) && (J.current = e.target);
61
- }, []), { getFloatingProps: be } = nt([tt(he, {
62
- enabled: !E,
76
+ }, []), Z = g(null), be = p((e) => {
77
+ Q.current = e.target, e.target instanceof HTMLElement && d.current?.contains(e.target) && (Z.current = e.target);
78
+ }, []), { getFloatingProps: Re } = rt([ot(ve, {
79
+ enabled: !A,
63
80
  escapeKey: !1,
64
81
  outsidePress: (e) => {
65
82
  const t = e.target;
66
83
  if (!(t instanceof Element)) return !0;
67
- if (h(t) || t.closest("[data-floating-ui-portal]")) return !1;
68
- const a = t.closest('dialog[open], [role="dialog"]');
69
- return !a || a.contains(c.current);
84
+ if (P(t) || t.closest("[data-floating-ui-portal]")) return !1;
85
+ const c = t.closest('dialog[open], [role="dialog"]');
86
+ return !c || c.contains(d.current);
70
87
  }
71
- })]), s = d(() => {
72
- w(!1);
73
- }, [w]);
74
- Be({
75
- active: o,
76
- requestClose: s,
77
- ownerRef: c
78
- }), v(() => {
79
- if (!o || E) return;
88
+ })]), a = p(() => {
89
+ T(!1);
90
+ }, [T]);
91
+ De({
92
+ active: n,
93
+ requestClose: a,
94
+ ownerRef: d
95
+ }), b(() => {
96
+ if (!n || A) return;
80
97
  const e = (t) => {
81
- t.key !== "Escape" || t.defaultPrevented || t.isComposing || (t.preventDefault(), t.stopImmediatePropagation(), We(t));
98
+ t.key !== "Escape" || t.defaultPrevented || t.isComposing || (t.preventDefault(), t.stopImmediatePropagation(), Be(t));
82
99
  };
83
100
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
84
- }, [o, E]), $e(o && n && r !== null, c);
85
- const [Z, Re] = l(!1);
86
- v(() => {
87
- if (!r || n && !Z) return;
101
+ }, [n, A]), Ke(n && r && i !== null, d);
102
+ const [ee, Ae] = l(!1);
103
+ b(() => {
104
+ if (!i || r && !ee) return;
88
105
  const e = requestAnimationFrame(() => {
89
- (n ? ne(r) : r)?.focus({ preventScroll: !0 });
106
+ (r ? re(i) : i)?.focus({ preventScroll: !0 });
90
107
  });
91
108
  return () => {
92
109
  cancelAnimationFrame(e);
93
110
  };
94
111
  }, [
112
+ i,
95
113
  r,
96
- n,
97
- Z
98
- ]), v(() => {
99
- if (!r) return;
114
+ ee
115
+ ]), b(() => {
116
+ if (!i) return;
100
117
  let e = 0;
101
118
  const t = () => {
102
119
  cancelAnimationFrame(e), e = requestAnimationFrame(() => {
103
- const i = document.activeElement;
104
- if (!r.isConnected || i && i !== document.body && h(i)) return;
105
- const M = J.current;
106
- (M?.isConnected && r.contains(M) ? M : ne(r) ?? r).focus({ preventScroll: !0 });
120
+ const s = document.activeElement;
121
+ if (!i.isConnected || s && s !== document.body && P(s)) return;
122
+ const k = Z.current;
123
+ (k?.isConnected && i.contains(k) ? k : re(i) ?? i).focus({ preventScroll: !0 });
107
124
  });
108
- }, a = (i) => {
109
- i.relatedTarget === null && s();
110
- }, te = (i) => {
111
- i.relatedTarget === null && h(i.target) && t();
112
- }, oe = (i) => {
113
- !r.isConnected || h(i.target) || (n ? t() : s());
125
+ }, c = (s) => {
126
+ s.relatedTarget === null && a();
127
+ }, oe = (s) => {
128
+ s.relatedTarget === null && P(s.target) && t();
129
+ }, ne = (s) => {
130
+ !i.isConnected || P(s.target) || (r ? t() : a());
114
131
  };
115
- return n ? document.addEventListener("focusout", te) : r.addEventListener("focusout", a), document.addEventListener("focusin", oe), () => {
116
- cancelAnimationFrame(e), document.removeEventListener("focusout", te), r.removeEventListener("focusout", a), document.removeEventListener("focusin", oe);
132
+ return r ? document.addEventListener("focusout", oe) : i.addEventListener("focusout", c), document.addEventListener("focusin", ne), () => {
133
+ cancelAnimationFrame(e), document.removeEventListener("focusout", oe), i.removeEventListener("focusout", c), document.removeEventListener("focusin", ne);
117
134
  };
118
135
  }, [
136
+ i,
119
137
  r,
120
- n,
121
- s,
122
- h
138
+ a,
139
+ P
123
140
  ]);
124
- const L = f(!1);
125
- v(() => {
126
- if (o) {
127
- qe(), L.current = !0;
141
+ const W = g(!1);
142
+ b(() => {
143
+ if (n) {
144
+ Xe(), W.current = !0;
128
145
  return;
129
146
  }
130
- if (!L.current) return;
131
- L.current = !1;
132
- const e = P.current;
147
+ if (!W.current) return;
148
+ W.current = !1;
149
+ const e = F.current;
133
150
  if (!e) return;
134
151
  const t = requestAnimationFrame(() => {
135
- document.activeElement === document.body && e.focus({ focusVisible: De() });
152
+ document.activeElement === document.body && e.focus({ focusVisible: qe() });
136
153
  });
137
154
  return () => {
138
155
  cancelAnimationFrame(t);
139
156
  };
140
- }, [o]);
141
- const ee = {
157
+ }, [n]);
158
+ const te = {
142
159
  ref: Pe,
143
- isOpen: o,
160
+ isOpen: n,
144
161
  triggerProps: {
145
162
  onClick: (e) => {
146
- if (o) {
147
- s();
163
+ if (n) {
164
+ a();
148
165
  return;
149
166
  }
150
- le(Ce(e.currentTarget));
151
- const t = e.currentTarget.getBoundingClientRect(), a = t.left + t.width / 2 > window.innerWidth / 2;
152
- fe($ === "auto" ? a ? "end" : "start" : $), V(void 0), Y(S), U(Math.round(window.innerHeight * se)), Re(e.detail === 0), w(!0);
167
+ de(Ie(e.currentTarget));
168
+ const t = e.currentTarget.getBoundingClientRect(), c = t.left + t.width / 2 > window.innerWidth / 2;
169
+ me($ === "auto" ? c ? "end" : "start" : $), V(void 0), z.release(), Y(H), U(Math.round(window.innerHeight * ae)), Ae(e.detail === 0), T(!0);
153
170
  },
154
- "aria-expanded": o,
155
- "aria-controls": o ? g : void 0,
156
- "aria-haspopup": n ? "dialog" : void 0,
157
- "aria-describedby": !n && o ? g : void 0
171
+ "aria-expanded": n,
172
+ "aria-controls": n ? y : void 0,
173
+ "aria-haspopup": r ? "dialog" : void 0,
174
+ "aria-describedby": !r && n ? y : void 0
158
175
  }
159
- }, x = (e) => typeof e == "function" ? e({ close: s }) : e, Te = Xe(b, 500), Fe = k ?? (b === void 0 ? void 0 : /* @__PURE__ */ m(ke, {
160
- dataTest: `${p}-view-results`,
176
+ }, L = (e) => typeof e == "function" ? e({ close: a }) : e, Te = $e(O, 500), Fe = E ?? (O === void 0 ? void 0 : /* @__PURE__ */ h(ke, {
177
+ dataTest: `${o}-view-results`,
161
178
  type: "button",
162
179
  variant: "text",
163
- onClick: s,
164
- children: je(Te, R)
165
- })), Ae = u ? ae : it[I], Oe = u ? ae : void 0;
166
- return E ? /* @__PURE__ */ ie(re, { children: [C(ee), /* @__PURE__ */ m(Ue, {
167
- id: g,
168
- dataTest: p,
169
- open: o,
170
- onClose: s,
180
+ onClick: a,
181
+ children: Ue(Te, M)
182
+ })), Le = m ? ce : st[w], Oe = m ? ce : void 0;
183
+ return A ? /* @__PURE__ */ se(ie, { children: [v(te), /* @__PURE__ */ h(Ve, {
184
+ id: y,
185
+ dataTest: o,
186
+ open: n,
187
+ onClose: a,
171
188
  registerBackClose: !1,
172
- ownerRef: c,
173
- triggerRef: P,
174
- title: y,
189
+ ownerRef: d,
190
+ triggerRef: F,
191
+ title: f,
175
192
  ariaLabel: D,
176
- viewResultsAction: k,
177
- resetAction: H,
178
- footerActions: W,
179
- resultCount: b,
180
- locale: R,
193
+ viewResultsAction: E,
194
+ resetAction: x,
195
+ footerActions: R,
196
+ resultCount: O,
197
+ locale: M,
181
198
  closeLabel: B,
182
199
  className: X,
183
- children: _
184
- })] }) : /* @__PURE__ */ ie(re, { children: [C(ee), o && /* @__PURE__ */ m(ze, {
200
+ children: u
201
+ })] }) : /* @__PURE__ */ se(ie, { children: [v(te), n && /* @__PURE__ */ h(Ge, {
185
202
  root: j,
186
- children: /* @__PURE__ */ m("div", {
187
- ...be(),
188
- onFocusCapture: xe,
189
- ref: we,
190
- id: g,
191
- "data-placement": z,
192
- "data-test": p,
193
- "data-testid": p,
194
- role: n ? "dialog" : void 0,
195
- "aria-labelledby": n && y ? N : void 0,
196
- "aria-label": n && !y ? D : void 0,
197
- tabIndex: n ? void 0 : -1,
198
- ...A ? Me : {},
203
+ children: /* @__PURE__ */ h("div", {
204
+ ...Re(),
205
+ onFocusCapture: be,
206
+ ref: ye,
207
+ id: y,
208
+ "data-placement": G,
209
+ "data-test": o,
210
+ "data-testid": o,
211
+ role: r ? "dialog" : void 0,
212
+ "aria-labelledby": r && f ? N : void 0,
213
+ "aria-label": r && !f ? D : void 0,
214
+ tabIndex: r ? void 0 : -1,
215
+ ...I ? Se : {},
199
216
  style: {
200
- ...A ? Se : {},
201
- ...ge,
202
- minWidth: u ? S : me,
217
+ ...I ? Ce : {},
218
+ ...he,
219
+ minWidth: m ? H : pe,
203
220
  width: Oe,
204
- maxWidth: Ae,
221
+ maxWidth: Le,
205
222
  maxHeight: ue
206
223
  },
207
- className: Le("z-[1300]", "box-border flex flex-col overflow-hidden rounded-lg bg-white text-delta-700 outline-none shadow-[0px_4px_40px_0px_#22213366]", X),
208
- children: /* @__PURE__ */ m(He.Provider, {
209
- value: c,
210
- children: /* @__PURE__ */ m(Ve, {
211
- dataTest: p,
212
- title: y,
224
+ className: Me("z-[1300]", "box-border flex flex-col overflow-hidden rounded-lg bg-white text-delta-700 outline-none shadow-[0px_4px_40px_0px_#22213366]", X),
225
+ children: /* @__PURE__ */ h(He.Provider, {
226
+ value: d,
227
+ children: /* @__PURE__ */ h(Ye, {
228
+ dataTest: o,
229
+ title: f,
213
230
  titleId: N,
214
- viewResultsAction: x(Fe),
215
- resetAction: x(H),
216
- footerActions: x(W),
231
+ viewResultsAction: L(Fe),
232
+ resetAction: L(x),
233
+ footerActions: L(R),
217
234
  closeLabel: B,
218
- onClose: s,
219
- children: x(_)
235
+ onClose: a,
236
+ children: L(u)
220
237
  })
221
238
  })
222
239
  })
223
240
  })] });
224
241
  };
225
242
  export {
226
- Rt as PopoverSheet
243
+ Tt as PopoverSheet
227
244
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.133.0",
6
+ "version": "3.133.1",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",