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