asma-ui-core 3.98.1 → 3.98.2
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,6 +1,6 @@
|
|
|
1
1
|
import { cn as re } from "../../../helpers/cn.js";
|
|
2
2
|
import { firstTabbable as ne } from "../../../helpers/focusable.js";
|
|
3
|
-
import { TOP_LAYER_PROPS as ie, TOP_LAYER_RESET_STYLE as se, getOpenModalDialogAncestor as ae, shouldUsePopoverTopLayer as
|
|
3
|
+
import { TOP_LAYER_PROPS as ie, TOP_LAYER_RESET_STYLE as se, getOpenModalDialogAncestor as ae, shouldUsePopoverTopLayer as le, useTopLayerRef as ce } from "../../../hooks/useTopLayer.hook.js";
|
|
4
4
|
import { StyledButton as ue } from "../../inputs/button/StyledButton.js";
|
|
5
5
|
import { useMobileMediaQuery as de } from "../../../hooks/useMediaQuery.hook.js";
|
|
6
6
|
import { useDebouncedValue as fe } from "../../../hooks/useDebouncedValue.hook.js";
|
|
@@ -8,47 +8,47 @@ import { useFocusTrap as pe } from "../../../hooks/useFocusTrap.hook.js";
|
|
|
8
8
|
import { formatResultsLabel as me } from "../bottom-sheet/formatResultsLabel.js";
|
|
9
9
|
import { StyledBottomSheet as ge } from "../bottom-sheet/StyledBottomSheet.js";
|
|
10
10
|
import { PopoverAnatomy as ve } from "./PopoverAnatomy.js";
|
|
11
|
-
import { useCallback as
|
|
12
|
-
import { Fragment as N, jsx as
|
|
13
|
-
import { FloatingPortal as xe, autoUpdate as _e, flip as Pe, offset as be, shift as
|
|
14
|
-
var
|
|
11
|
+
import { useCallback as v, useEffect as y, useId as he, useRef as T, useState as h } from "react";
|
|
12
|
+
import { Fragment as N, jsx as l, jsxs as W } from "react/jsx-runtime";
|
|
13
|
+
import { FloatingPortal as xe, autoUpdate as _e, flip as Pe, offset as be, shift as Re, size as ye, useDismiss as Te, useFloating as Ee, useInteractions as Me, useMergeRefs as Se } from "@floating-ui/react";
|
|
14
|
+
var we = 240, Ae = {
|
|
15
15
|
info: 472,
|
|
16
16
|
action: 472
|
|
17
|
-
}, Fe = 0.6, B = "calc(100vw - 32px)", qe = ({ dataTest:
|
|
18
|
-
const a = he(), L = `${a}-title`, [o, X] =
|
|
17
|
+
}, Fe = 0.6, B = "calc(100vw - 32px)", Ie = (n, c, u) => _e(n, c, u, { elementResize: !1 }), qe = ({ dataTest: n, renderTrigger: c, variant: u = "info", title: d, children: E, viewResultsAction: M, resetAction: S, footerActions: w, resultCount: x, closeLabel: A = "Lukk", ariaLabel: F, onOpenChange: I, className: O }) => {
|
|
18
|
+
const a = he(), L = `${a}-title`, [o, X] = h(!1), [H, z] = h(), [U, Y] = h(), f = de(), t = u === "action", $ = f && !t, k = f && t, p = v((e) => {
|
|
19
19
|
X(e), I?.(e);
|
|
20
|
-
}, [I]), { refs:
|
|
20
|
+
}, [I]), { refs: _, floatingStyles: j, context: q } = Ee({
|
|
21
21
|
open: o,
|
|
22
|
-
onOpenChange:
|
|
22
|
+
onOpenChange: p,
|
|
23
23
|
placement: "bottom-start",
|
|
24
24
|
strategy: "fixed",
|
|
25
|
-
whileElementsMounted:
|
|
25
|
+
whileElementsMounted: Ie,
|
|
26
26
|
middleware: [
|
|
27
27
|
be(8),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
...$ ? [] : [Pe({ padding: 8 })],
|
|
29
|
+
Re({ padding: 8 }),
|
|
30
|
+
ye({
|
|
31
31
|
padding: 8,
|
|
32
32
|
apply({ availableHeight: e }) {
|
|
33
|
-
|
|
33
|
+
Y(Math.min(e, Math.round(window.innerHeight * Fe)));
|
|
34
34
|
}
|
|
35
35
|
})
|
|
36
36
|
]
|
|
37
|
-
}), { getFloatingProps: V } =
|
|
37
|
+
}), { getFloatingProps: V } = Me([Te(q, {
|
|
38
38
|
enabled: !k,
|
|
39
39
|
escapeKey: !0,
|
|
40
40
|
outsidePress: (e) => {
|
|
41
|
-
const
|
|
42
|
-
return !(
|
|
41
|
+
const s = m.current;
|
|
42
|
+
return !(s && e.target instanceof Node && s.contains(e.target));
|
|
43
43
|
}
|
|
44
|
-
})]),
|
|
44
|
+
})]), P = le(H), C = T(null), [r, G] = h(null), K = v((e) => {
|
|
45
45
|
C.current = e, G(e);
|
|
46
|
-
}, []), Q =
|
|
47
|
-
|
|
48
|
-
}, [
|
|
49
|
-
|
|
50
|
-
}, [
|
|
51
|
-
pe(o && t && r !== null, C),
|
|
46
|
+
}, []), Q = Se([ce(_.setFloating, P), K]), m = T(null), J = v((e) => {
|
|
47
|
+
m.current = e, _.setReference(e);
|
|
48
|
+
}, [_]), i = v(() => {
|
|
49
|
+
p(!1);
|
|
50
|
+
}, [p]);
|
|
51
|
+
pe(o && t && r !== null, C), y(() => {
|
|
52
52
|
if (!r) return;
|
|
53
53
|
const e = requestAnimationFrame(() => {
|
|
54
54
|
(t ? ne(r) : r)?.focus({ preventScroll: !0 });
|
|
@@ -56,11 +56,11 @@ var Me = 240, we = {
|
|
|
56
56
|
return () => {
|
|
57
57
|
cancelAnimationFrame(e);
|
|
58
58
|
};
|
|
59
|
-
}, [r, t]),
|
|
59
|
+
}, [r, t]), y(() => {
|
|
60
60
|
if (!r || t) return;
|
|
61
|
-
const e = (
|
|
62
|
-
const
|
|
63
|
-
|
|
61
|
+
const e = (s) => {
|
|
62
|
+
const R = s.relatedTarget;
|
|
63
|
+
R instanceof Node && (r.contains(R) || m.current?.contains(R)) || i();
|
|
64
64
|
};
|
|
65
65
|
return r.addEventListener("focusout", e), () => {
|
|
66
66
|
r.removeEventListener("focusout", e);
|
|
@@ -68,23 +68,23 @@ var Me = 240, we = {
|
|
|
68
68
|
}, [
|
|
69
69
|
r,
|
|
70
70
|
t,
|
|
71
|
-
|
|
71
|
+
i
|
|
72
72
|
]);
|
|
73
|
-
const
|
|
74
|
-
|
|
73
|
+
const b = T(!1);
|
|
74
|
+
y(() => {
|
|
75
75
|
if (o) {
|
|
76
|
-
|
|
76
|
+
b.current = !0;
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
|
-
if (!
|
|
80
|
-
|
|
81
|
-
const e =
|
|
79
|
+
if (!b.current) return;
|
|
80
|
+
b.current = !1;
|
|
81
|
+
const e = m.current;
|
|
82
82
|
if (!e) return;
|
|
83
|
-
const
|
|
83
|
+
const s = requestAnimationFrame(() => {
|
|
84
84
|
document.activeElement === document.body && e.focus();
|
|
85
85
|
});
|
|
86
86
|
return () => {
|
|
87
|
-
cancelAnimationFrame(
|
|
87
|
+
cancelAnimationFrame(s);
|
|
88
88
|
};
|
|
89
89
|
}, [o]);
|
|
90
90
|
const D = {
|
|
@@ -93,69 +93,69 @@ var Me = 240, we = {
|
|
|
93
93
|
triggerProps: {
|
|
94
94
|
onClick: (e) => {
|
|
95
95
|
if (o) {
|
|
96
|
-
|
|
96
|
+
i();
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
|
-
|
|
99
|
+
z(ae(e.currentTarget)), p(!0);
|
|
100
100
|
},
|
|
101
101
|
"aria-expanded": o,
|
|
102
102
|
"aria-controls": o ? a : void 0,
|
|
103
103
|
"aria-haspopup": t ? "dialog" : void 0,
|
|
104
104
|
"aria-describedby": !t && o ? a : void 0
|
|
105
105
|
}
|
|
106
|
-
},
|
|
107
|
-
dataTest: `${
|
|
106
|
+
}, g = (e) => typeof e == "function" ? e({ close: i }) : e, Z = fe(x, 500), ee = M ?? (x === void 0 ? void 0 : /* @__PURE__ */ l(ue, {
|
|
107
|
+
dataTest: `${n}-view-results`,
|
|
108
108
|
type: "button",
|
|
109
109
|
variant: "text",
|
|
110
|
-
onClick:
|
|
110
|
+
onClick: i,
|
|
111
111
|
children: me(Z)
|
|
112
|
-
})), te =
|
|
113
|
-
return k ? /* @__PURE__ */ W(N, { children: [
|
|
112
|
+
})), te = f ? B : Ae[u], oe = f ? B : void 0;
|
|
113
|
+
return k ? /* @__PURE__ */ W(N, { children: [c(D), /* @__PURE__ */ l(ge, {
|
|
114
114
|
id: a,
|
|
115
|
-
dataTest:
|
|
115
|
+
dataTest: n,
|
|
116
116
|
open: o,
|
|
117
|
-
onClose:
|
|
118
|
-
title:
|
|
117
|
+
onClose: i,
|
|
118
|
+
title: d,
|
|
119
119
|
ariaLabel: F,
|
|
120
|
-
viewResultsAction:
|
|
121
|
-
resetAction:
|
|
122
|
-
footerActions:
|
|
123
|
-
resultCount:
|
|
124
|
-
closeLabel:
|
|
120
|
+
viewResultsAction: M,
|
|
121
|
+
resetAction: S,
|
|
122
|
+
footerActions: w,
|
|
123
|
+
resultCount: x,
|
|
124
|
+
closeLabel: A,
|
|
125
125
|
className: O,
|
|
126
|
-
children:
|
|
127
|
-
})] }) : /* @__PURE__ */ W(N, { children: [
|
|
126
|
+
children: E
|
|
127
|
+
})] }) : /* @__PURE__ */ W(N, { children: [c(D), o && /* @__PURE__ */ l(xe, {
|
|
128
128
|
root: H,
|
|
129
|
-
children: /* @__PURE__ */
|
|
129
|
+
children: /* @__PURE__ */ l("div", {
|
|
130
130
|
...V(),
|
|
131
131
|
ref: Q,
|
|
132
132
|
id: a,
|
|
133
|
-
"data-test":
|
|
134
|
-
"data-testid":
|
|
133
|
+
"data-test": n,
|
|
134
|
+
"data-testid": n,
|
|
135
135
|
role: t ? "dialog" : void 0,
|
|
136
|
-
"aria-labelledby": t &&
|
|
137
|
-
"aria-label": t && !
|
|
136
|
+
"aria-labelledby": t && d ? L : void 0,
|
|
137
|
+
"aria-label": t && !d ? F : void 0,
|
|
138
138
|
tabIndex: t ? void 0 : -1,
|
|
139
|
-
...
|
|
139
|
+
...P ? ie : {},
|
|
140
140
|
style: {
|
|
141
|
-
...
|
|
142
|
-
...
|
|
143
|
-
minWidth:
|
|
141
|
+
...P ? se : {},
|
|
142
|
+
...j,
|
|
143
|
+
minWidth: we,
|
|
144
144
|
width: oe,
|
|
145
145
|
maxWidth: te,
|
|
146
|
-
maxHeight:
|
|
146
|
+
maxHeight: U
|
|
147
147
|
},
|
|
148
148
|
className: re("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]", O),
|
|
149
|
-
children: /* @__PURE__ */
|
|
150
|
-
dataTest:
|
|
151
|
-
title:
|
|
149
|
+
children: /* @__PURE__ */ l(ve, {
|
|
150
|
+
dataTest: n,
|
|
151
|
+
title: d,
|
|
152
152
|
titleId: L,
|
|
153
|
-
viewResultsAction:
|
|
154
|
-
resetAction:
|
|
155
|
-
footerActions:
|
|
156
|
-
closeLabel:
|
|
157
|
-
onClose:
|
|
158
|
-
children:
|
|
153
|
+
viewResultsAction: g(ee),
|
|
154
|
+
resetAction: g(S),
|
|
155
|
+
footerActions: g(w),
|
|
156
|
+
closeLabel: A,
|
|
157
|
+
onClose: i,
|
|
158
|
+
children: g(E)
|
|
159
159
|
})
|
|
160
160
|
})
|
|
161
161
|
})] });
|