asma-ui-core 3.118.0 → 3.120.0

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