asma-ui-core 3.88.0 → 3.89.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.
@@ -9,9 +9,9 @@ import { ArrowShrinkIcon as me } from "../../icons/arrow-shrink-icon/ArrowShrink
9
9
  import { firstTabbable as he } from "../../../helpers/focusable.js";
10
10
  import { StyledTooltip as f } from "../../data-display/tooltip/StyledTooltip.js";
11
11
  import { StyledButton as l } from "../../inputs/button/StyledButton.js";
12
- import { StyledMenu as fe } from "../../navigation/menu/StyledMenu.js";
13
- import { StyledMenuItem as ue } from "../../navigation/menu/StyledMenuItem.js";
14
- import { useFocusTrap as ve } from "../../../hooks/useFocusTrap.hook.js";
12
+ import { useFocusTrap as fe } from "../../../hooks/useFocusTrap.hook.js";
13
+ import { StyledMenu as ue } from "../../navigation/menu/StyledMenu.js";
14
+ import { StyledMenuItem as ve } from "../../navigation/menu/StyledMenuItem.js";
15
15
  import H from "./MinimizableDialog.module.js";
16
16
  import { useToggleMenuVisibility as pe } from "../../../hooks/useToggleMenuVisibility.hook.js";
17
17
  import J from "clsx";
@@ -19,7 +19,7 @@ import { useLayoutEffect as be, useRef as Q, useState as T } from "react";
19
19
  import { Fragment as M, jsx as e, jsxs as t } from "react/jsx-runtime";
20
20
  var Oe = ({ onCloseText: u = "", onMinimizeText: j = "", onExpandText: C = "", onFullScreenText: F = "", showCloseIcon: _ = !0, showMinimizeIcon: W = !0, showExpandIcon: X = !0, showFullScreenIcon: Y = !0, title: s, label: g, children: x, open: E, onClose: w, className: G = "", primaryButtonText: y, primaryButtonLoading: k = !1, secondaryButtonText: c, onPrimaryButtonClick: v, onSecondaryButtonClick: p, dataTest: S, actionNode: Z, extraActions: n, extraActionsText: m, btnContainerClassName: D, footerClassName: P, footerInfo: L, locale: r = "en", enableFullscreen: B = !0, fullScreenState: R, handleFullScreenState: q }) => {
21
21
  const [i, ee] = T(!1), [O, te] = T(!1), { open: ie, anchorEl: le, handleOpen: re, handleClose: ne } = pe(), b = Q(null), z = Q(null), d = R ?? O, a = d && !i;
22
- if (ve(E && a, b, w), be(() => {
22
+ if (fe(E && a, b, w), be(() => {
23
23
  b.current?.toggleAttribute("inert", i), z.current?.toggleAttribute("inert", !i);
24
24
  }, [i]), !E) return null;
25
25
  const de = a ? {
@@ -184,11 +184,11 @@ var Oe = ({ onCloseText: u = "", onMinimizeText: j = "", onExpandText: C = "", o
184
184
  }),
185
185
  onClick: re,
186
186
  children: m
187
- }), /* @__PURE__ */ e(fe, {
187
+ }), /* @__PURE__ */ e(ue, {
188
188
  open: ie,
189
189
  anchorEl: le,
190
190
  onClose: ne,
191
- children: n.map((o) => /* @__PURE__ */ e(ue, {
191
+ children: n.map((o) => /* @__PURE__ */ e(ve, {
192
192
  className: o.className,
193
193
  onClick: o.onClick,
194
194
  children: o.label
@@ -0,0 +1,46 @@
1
+ import { cn as p } from "../../../helpers/cn.js";
2
+ import { CloseIcon as m } from "../../icons/close-icon/CloseIcon.js";
3
+ import { StyledButton as f } from "../../inputs/button/StyledButton.js";
4
+ import { Fragment as c, jsx as e, jsxs as r } from "react/jsx-runtime";
5
+ var y = "box-border flex flex-col overflow-hidden rounded-lg border border-solid border-delta-300 bg-white text-delta-700 outline-none shadow-[0px_4px_40px_0px_#22213366]", u = ({ dataTest: d, title: t, titleId: i, children: n, viewResultsAction: l, resetAction: a, footerActions: o, closeLabel: s, onClose: x }) => /* @__PURE__ */ r(c, { children: [
6
+ /* @__PURE__ */ r("div", {
7
+ className: "relative flex min-h-0 flex-1 flex-col",
8
+ children: [
9
+ t && /* @__PURE__ */ e("div", {
10
+ id: i,
11
+ className: "shrink-0 truncate pb-1 pl-4 pr-10 pt-2 text-lg font-semibold leading-7 text-delta-800",
12
+ children: t
13
+ }),
14
+ /* @__PURE__ */ e("div", {
15
+ className: "flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto py-2 pl-4 pr-10",
16
+ children: n
17
+ }),
18
+ /* @__PURE__ */ e("div", {
19
+ className: "absolute right-0 top-0",
20
+ children: /* @__PURE__ */ e(f, {
21
+ dataTest: `${d}-close`,
22
+ variant: "textGray",
23
+ type: "button",
24
+ "aria-label": s,
25
+ onClick: x,
26
+ startIcon: /* @__PURE__ */ e(m, {
27
+ width: 24,
28
+ height: 24
29
+ })
30
+ })
31
+ })
32
+ ]
33
+ }),
34
+ (l ?? a) && /* @__PURE__ */ r("div", {
35
+ className: p("flex shrink-0 items-start p-1", l ? "justify-between" : "justify-end"),
36
+ children: [l, a]
37
+ }),
38
+ o && /* @__PURE__ */ e("div", {
39
+ className: "flex shrink-0 flex-col items-end p-3",
40
+ children: o
41
+ })
42
+ ] });
43
+ export {
44
+ y as POPOVER_SURFACE_CLASSNAME,
45
+ u as PopoverAnatomy
46
+ };
@@ -0,0 +1,140 @@
1
+ import { cn as K } from "../../../helpers/cn.js";
2
+ import { firstTabbable as Q } from "../../../helpers/focusable.js";
3
+ import { TOP_LAYER_PROPS as J, TOP_LAYER_RESET_STYLE as Z, getOpenModalDialogAncestor as ee, shouldUsePopoverTopLayer as te, useTopLayerRef as re } from "../../../hooks/useTopLayer.hook.js";
4
+ import { useMobileMediaQuery as oe } from "../../../hooks/useMediaQuery.hook.js";
5
+ import { useFocusTrap as ne } from "../../../hooks/useFocusTrap.hook.js";
6
+ import { PopoverAnatomy as ie } from "./PopoverAnatomy.js";
7
+ import { useCallback as d, useEffect as P, useId as se, useRef as b, useState as u } from "react";
8
+ import { Fragment as ae, jsx as _, jsxs as ce } from "react/jsx-runtime";
9
+ import { FloatingPortal as le, autoUpdate as de, flip as ue, offset as fe, shift as pe, size as ge, useDismiss as me, useFloating as ve, useInteractions as he, useMergeRefs as xe } from "@floating-ui/react";
10
+ var Pe = 240, be = {
11
+ info: 360,
12
+ action: 400
13
+ }, _e = 0.6, M = "calc(100vw - 32px)", Se = ({ dataTest: f, renderTrigger: F, variant: A = "info", title: p, children: I, viewResultsAction: O, resetAction: w, footerActions: L, closeLabel: S = "Lukk", ariaLabel: H, onOpenChange: R, className: k }) => {
14
+ const s = se(), T = `${s}-title`, [r, C] = u(!1), [y, N] = u(), [D, W] = u(), g = oe(), t = A === "action", X = g && !t, a = d((e) => {
15
+ C(e), R?.(e);
16
+ }, [R]), { refs: m, floatingStyles: U, context: Y } = ve({
17
+ open: r,
18
+ onOpenChange: a,
19
+ placement: "bottom-start",
20
+ strategy: "fixed",
21
+ whileElementsMounted: de,
22
+ middleware: [
23
+ fe(8),
24
+ ...X ? [] : [ue({ padding: 8 })],
25
+ pe({ padding: 8 }),
26
+ ge({
27
+ padding: 8,
28
+ apply({ availableHeight: e }) {
29
+ W(Math.min(e, Math.round(window.innerHeight * _e)));
30
+ }
31
+ })
32
+ ]
33
+ }), { getFloatingProps: j } = he([me(Y, {
34
+ escapeKey: !0,
35
+ outsidePress: (e) => {
36
+ const n = c.current;
37
+ return !(n && e.target instanceof Node && n.contains(e.target));
38
+ }
39
+ })]), v = te(y), E = b(null), [o, q] = u(null), z = d((e) => {
40
+ E.current = e, q(e);
41
+ }, []), B = xe([re(m.setFloating, v), z]), c = b(null), V = d((e) => {
42
+ c.current = e, m.setReference(e);
43
+ }, [m]), i = d(() => {
44
+ a(!1);
45
+ }, [a]);
46
+ ne(r && t && o !== null, E), P(() => {
47
+ if (!o) return;
48
+ const e = requestAnimationFrame(() => {
49
+ (t ? Q(o) : o)?.focus({ preventScroll: !0 });
50
+ });
51
+ return () => {
52
+ cancelAnimationFrame(e);
53
+ };
54
+ }, [o, t]), P(() => {
55
+ if (!o || t) return;
56
+ const e = (n) => {
57
+ const x = n.relatedTarget;
58
+ x instanceof Node && (o.contains(x) || c.current?.contains(x)) || i();
59
+ };
60
+ return o.addEventListener("focusout", e), () => {
61
+ o.removeEventListener("focusout", e);
62
+ };
63
+ }, [
64
+ o,
65
+ t,
66
+ i
67
+ ]);
68
+ const h = b(!1);
69
+ P(() => {
70
+ if (r) {
71
+ h.current = !0;
72
+ return;
73
+ }
74
+ if (!h.current) return;
75
+ h.current = !1;
76
+ const e = c.current;
77
+ if (!e) return;
78
+ const n = requestAnimationFrame(() => {
79
+ document.activeElement === document.body && e.focus();
80
+ });
81
+ return () => {
82
+ cancelAnimationFrame(n);
83
+ };
84
+ }, [r]);
85
+ const $ = {
86
+ ref: V,
87
+ isOpen: r,
88
+ triggerProps: {
89
+ onClick: (e) => {
90
+ if (r) {
91
+ i();
92
+ return;
93
+ }
94
+ N(ee(e.currentTarget)), a(!0);
95
+ },
96
+ "aria-expanded": r,
97
+ "aria-controls": r ? s : void 0,
98
+ "aria-haspopup": t ? "dialog" : void 0,
99
+ "aria-describedby": !t && r ? s : void 0
100
+ }
101
+ }, l = (e) => typeof e == "function" ? e({ close: i }) : e, G = g ? M : be[A];
102
+ return /* @__PURE__ */ ce(ae, { children: [F($), r && /* @__PURE__ */ _(le, {
103
+ root: y,
104
+ children: /* @__PURE__ */ _("div", {
105
+ ...j(),
106
+ ref: B,
107
+ id: s,
108
+ "data-test": f,
109
+ "data-testid": f,
110
+ role: t ? "dialog" : void 0,
111
+ "aria-labelledby": t && p ? T : void 0,
112
+ "aria-label": t && !p ? H : void 0,
113
+ tabIndex: t ? void 0 : -1,
114
+ ...v ? J : {},
115
+ style: {
116
+ ...v ? Z : {},
117
+ ...U,
118
+ minWidth: Pe,
119
+ width: g ? M : void 0,
120
+ maxWidth: G,
121
+ maxHeight: D
122
+ },
123
+ className: K("z-[1300]", "box-border flex flex-col overflow-hidden rounded-lg border border-solid border-delta-300 bg-white text-delta-700 outline-none shadow-[0px_4px_40px_0px_#22213366]", k),
124
+ children: /* @__PURE__ */ _(ie, {
125
+ dataTest: f,
126
+ title: p,
127
+ titleId: T,
128
+ viewResultsAction: l(O),
129
+ resetAction: l(w),
130
+ footerActions: l(L),
131
+ closeLabel: S,
132
+ onClose: i,
133
+ children: l(I)
134
+ })
135
+ })
136
+ })] });
137
+ };
138
+ export {
139
+ Se as StyledPopoverV2
140
+ };