asma-ui-core 3.128.0 → 3.128.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.
- package/dist/components/utils/bottom-sheet/StyledBottomSheet.js +45 -44
- package/dist/components/utils/bottom-sheet/formatResultsLabel.js +6 -2
- package/dist/components/utils/bottom-sheet/sheetCopy.js +15 -0
- package/dist/components/utils/popover/PopoverAnatomy.js +10 -10
- package/dist/components/utils/popover/PopoverSheet.js +99 -97
- package/dist/src/components/utils/bottom-sheet/StyledBottomSheet.d.ts +5 -2
- package/dist/src/components/utils/bottom-sheet/formatResultsLabel.d.ts +4 -1
- package/dist/src/components/utils/bottom-sheet/sheetCopy.d.ts +11 -0
- package/dist/src/components/utils/popover/PopoverAnatomy.d.ts +5 -2
- package/dist/src/components/utils/popover/PopoverSheet.d.ts +5 -2
- package/package.json +1 -1
|
@@ -2,26 +2,27 @@ import { cn as l } from "../../../helpers/cn.js";
|
|
|
2
2
|
import { registerOpenModalDialog as z } from "../../../hooks/useTopLayer.hook.js";
|
|
3
3
|
import { CloseIcon as J } from "../../icons/close-icon/CloseIcon.js";
|
|
4
4
|
import { IndeterminateIcon as W } from "../../icons/indeterminate-icon/IndeterminateIcon.js";
|
|
5
|
-
import { StyledButton as
|
|
6
|
-
import { useShortViewportMediaQuery as
|
|
7
|
-
import { OverlayBackOwnerContext as
|
|
8
|
-
import { useDebouncedValue as
|
|
9
|
-
import { useFocusTrap as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
5
|
+
import { StyledButton as _ } from "../../inputs/button/StyledButton.js";
|
|
6
|
+
import { useShortViewportMediaQuery as Z } from "../../../hooks/useMediaQuery.hook.js";
|
|
7
|
+
import { OverlayBackOwnerContext as ee, isOverlayBackEnabled as j, requestCloseTopOverlayBack as y, useBackCloses as te } from "../../../hooks/useBackCloses.hook.js";
|
|
8
|
+
import { useDebouncedValue as re } from "../../../hooks/useDebouncedValue.hook.js";
|
|
9
|
+
import { useFocusTrap as oe } from "../../../hooks/useFocusTrap.hook.js";
|
|
10
|
+
import { SHEET_TEXT as ne } from "./sheetCopy.js";
|
|
11
|
+
import { formatResultsLabel as ae } from "./formatResultsLabel.js";
|
|
12
|
+
import { useBodyScrollLock as se } from "../../../hooks/useBodyScrollLock.hook.js";
|
|
13
|
+
import ie from "./StyledBottomSheet.module.js";
|
|
14
|
+
import { useDragToDismiss as le } from "./useDragToDismiss.hook.js";
|
|
15
|
+
import { useEffect as g, useId as ce, useLayoutEffect as de, useRef as c, useState as ue } from "react";
|
|
15
16
|
import { jsx as o, jsxs as u } from "react/jsx-runtime";
|
|
16
|
-
var
|
|
17
|
-
const
|
|
17
|
+
var me = 500, Oe = ({ dataTest: d, id: P, open: t, onClose: s, title: m, ariaLabel: q, children: $, viewResultsAction: E, resetAction: A, footerActions: H, resultCount: S, locale: k = "en", closeLabel: U = ne[k].close, className: V, registerBackClose: K = !0, ownerRef: G }) => {
|
|
18
|
+
const N = ce(), i = c(null), R = c(null), B = c(null), L = G ?? i, h = c(!1), [x, C] = ue(!1), Q = Z(), f = c(s), O = c(t);
|
|
18
19
|
g(() => {
|
|
19
|
-
f.current = s,
|
|
20
|
+
f.current = s, O.current = t;
|
|
20
21
|
}, [s, t]);
|
|
21
|
-
const { dragHandleProps:
|
|
22
|
+
const { dragHandleProps: X, dragOffset: I } = le(R, () => {
|
|
22
23
|
f.current("drag");
|
|
23
24
|
});
|
|
24
|
-
|
|
25
|
+
se(t), oe(t, i), g(() => {
|
|
25
26
|
if (!t) return;
|
|
26
27
|
const e = (r) => {
|
|
27
28
|
r.key === "Escape" && (h.current = !0, window.setTimeout(() => {
|
|
@@ -35,20 +36,20 @@ var de = 500, Le = ({ dataTest: d, id: T, open: t, onClose: s, title: m, ariaLab
|
|
|
35
36
|
return window.addEventListener("keydown", e, !0), window.addEventListener("keydown", n), () => {
|
|
36
37
|
window.removeEventListener("keydown", e, !0), window.removeEventListener("keydown", n);
|
|
37
38
|
};
|
|
38
|
-
}, [t]),
|
|
39
|
-
active: t &&
|
|
39
|
+
}, [t]), te({
|
|
40
|
+
active: t && K,
|
|
40
41
|
requestClose: () => f.current("escape"),
|
|
41
42
|
ownerRef: L
|
|
42
|
-
}),
|
|
43
|
+
}), de(() => {
|
|
43
44
|
const e = i.current;
|
|
44
45
|
if (!t || !e) return;
|
|
45
|
-
|
|
46
|
+
B.current = document.activeElement instanceof HTMLElement ? document.activeElement : null, e.open || e.showModal(), e.focus({ preventScroll: !0 });
|
|
46
47
|
const n = requestAnimationFrame(() => {
|
|
47
|
-
|
|
48
|
+
C(!0);
|
|
48
49
|
}), r = z(e);
|
|
49
50
|
return () => {
|
|
50
|
-
cancelAnimationFrame(n), r(),
|
|
51
|
-
const a =
|
|
51
|
+
cancelAnimationFrame(n), r(), C(!1), e.open && e.close();
|
|
52
|
+
const a = B.current;
|
|
52
53
|
a?.isConnected && a.focus({ preventScroll: !0 });
|
|
53
54
|
};
|
|
54
55
|
}, [t]), g(() => {
|
|
@@ -57,46 +58,46 @@ var de = 500, Le = ({ dataTest: d, id: T, open: t, onClose: s, title: m, ariaLab
|
|
|
57
58
|
let n = !1;
|
|
58
59
|
const r = () => {
|
|
59
60
|
requestAnimationFrame(() => {
|
|
60
|
-
n = !1,
|
|
61
|
+
n = !1, O.current && e.isConnected && !e.open && (e.showModal(), e.focus({ preventScroll: !0 }));
|
|
61
62
|
});
|
|
62
63
|
}, a = () => {
|
|
63
|
-
n || (n = !0,
|
|
64
|
+
n || (n = !0, j() && y(), r());
|
|
64
65
|
};
|
|
65
66
|
return e.addEventListener("close", a), () => e.removeEventListener("close", a);
|
|
66
67
|
}, [t]);
|
|
67
|
-
const
|
|
68
|
+
const D = ae(re(S, me), k);
|
|
68
69
|
if (!t) return null;
|
|
69
70
|
const Y = { close: () => {
|
|
70
71
|
s("action");
|
|
71
|
-
} }, p = (e) => typeof e == "function" ? e(Y) : e,
|
|
72
|
+
} }, p = (e) => typeof e == "function" ? e(Y) : e, T = S !== void 0, b = E !== void 0 ? p(E) : T ? /* @__PURE__ */ o(_, {
|
|
72
73
|
dataTest: `${d}-view-results`,
|
|
73
74
|
type: "button",
|
|
74
75
|
variant: "text",
|
|
75
76
|
onClick: () => {
|
|
76
77
|
s("viewResults");
|
|
77
78
|
},
|
|
78
|
-
children:
|
|
79
|
-
}) : void 0, F = p(
|
|
79
|
+
children: D
|
|
80
|
+
}) : void 0, F = p(A), v = p(H), w = !!(b ?? F), M = I > 0;
|
|
80
81
|
return /* @__PURE__ */ o("dialog", {
|
|
81
82
|
ref: i,
|
|
82
|
-
id:
|
|
83
|
+
id: P,
|
|
83
84
|
tabIndex: -1,
|
|
84
85
|
"aria-modal": "true",
|
|
85
|
-
"aria-labelledby": m ?
|
|
86
|
-
"aria-label": m ? void 0 :
|
|
86
|
+
"aria-labelledby": m ? N : void 0,
|
|
87
|
+
"aria-label": m ? void 0 : q,
|
|
87
88
|
"data-test": d,
|
|
88
89
|
"data-testid": d,
|
|
89
90
|
onCancel: (e) => {
|
|
90
91
|
if (e.cancelable && e.preventDefault(), !h.current) {
|
|
91
|
-
if (!
|
|
92
|
+
if (!j()) {
|
|
92
93
|
f.current("escape");
|
|
93
94
|
return;
|
|
94
95
|
}
|
|
95
96
|
y();
|
|
96
97
|
}
|
|
97
98
|
},
|
|
98
|
-
className: l(
|
|
99
|
-
children: /* @__PURE__ */ u(
|
|
99
|
+
className: l(ie.StyledBottomSheet, "fixed inset-0 m-0 h-full max-h-none w-full max-w-none flex-col items-center justify-end overflow-hidden border-0 bg-transparent p-0 outline-none open:flex"),
|
|
100
|
+
children: /* @__PURE__ */ u(ee.Provider, {
|
|
100
101
|
value: L,
|
|
101
102
|
children: [/* @__PURE__ */ o("div", {
|
|
102
103
|
"aria-hidden": "true",
|
|
@@ -106,19 +107,19 @@ var de = 500, Le = ({ dataTest: d, id: T, open: t, onClose: s, title: m, ariaLab
|
|
|
106
107
|
},
|
|
107
108
|
className: l("absolute inset-0 bg-[#626e7eb2] transition-opacity duration-[250ms] ease-out motion-reduce:duration-150", x ? "opacity-100" : "opacity-0")
|
|
108
109
|
}), /* @__PURE__ */ u("div", {
|
|
109
|
-
ref:
|
|
110
|
+
ref: R,
|
|
110
111
|
"data-state": x ? "open" : "closed",
|
|
111
|
-
style: M ? { transform: `translateY(${
|
|
112
|
-
className: l("relative box-border flex w-full max-w-[640px] flex-col border border-solid border-delta-300 bg-white text-delta-700 outline-none",
|
|
112
|
+
style: M ? { transform: `translateY(${I}px)` } : void 0,
|
|
113
|
+
className: l("relative box-border flex w-full max-w-[640px] flex-col border border-solid border-delta-300 bg-white text-delta-700 outline-none", Q ? "h-full max-h-none rounded-none" : "max-h-[90dvh] rounded-t-[28px]", !M && ["ease-out motion-safe:transition-transform motion-safe:duration-[250ms] motion-reduce:transition-opacity motion-reduce:duration-150", x ? "translate-y-0 opacity-100" : "motion-safe:translate-y-full motion-reduce:opacity-0"], V),
|
|
113
114
|
children: [
|
|
114
115
|
/* @__PURE__ */ u("div", {
|
|
115
116
|
className: "border-b-solid shrink-0 border-b border-delta-200 pb-2",
|
|
116
117
|
children: [/* @__PURE__ */ u("div", {
|
|
117
|
-
...
|
|
118
|
+
...X,
|
|
118
119
|
className: "relative flex h-12 touch-none items-center gap-2 px-2",
|
|
119
120
|
children: [
|
|
120
121
|
/* @__PURE__ */ o("div", { className: "min-w-0 flex-1" }),
|
|
121
|
-
/* @__PURE__ */ o(
|
|
122
|
+
/* @__PURE__ */ o(_, {
|
|
122
123
|
dataTest: `${d}-close`,
|
|
123
124
|
variant: "textGray",
|
|
124
125
|
type: "button",
|
|
@@ -140,26 +141,26 @@ var de = 500, Le = ({ dataTest: d, id: T, open: t, onClose: s, title: m, ariaLab
|
|
|
140
141
|
})
|
|
141
142
|
]
|
|
142
143
|
}), m && /* @__PURE__ */ o("div", {
|
|
143
|
-
id:
|
|
144
|
+
id: N,
|
|
144
145
|
className: "truncate px-4 text-lg font-semibold leading-7 text-delta-800",
|
|
145
146
|
children: m
|
|
146
147
|
})]
|
|
147
148
|
}),
|
|
148
149
|
/* @__PURE__ */ o("div", {
|
|
149
150
|
className: l("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto overscroll-contain pl-4 pr-2 pt-2", w || v ? "pb-2" : "pb-[max(0.5rem,env(safe-area-inset-bottom))]"),
|
|
150
|
-
children: p(
|
|
151
|
+
children: p($)
|
|
151
152
|
}),
|
|
152
153
|
w && /* @__PURE__ */ u("div", {
|
|
153
154
|
className: l("border-t-solid flex shrink-0 items-start border-t border-delta-200 bg-white p-1", b ? "justify-between" : "justify-end", "max-xs:flex-wrap max-xs:gap-y-2 max-xs:[&>:nth-child(2)]:ml-auto", !v && "pb-[max(0.25rem,env(safe-area-inset-bottom))]"),
|
|
154
155
|
children: [
|
|
155
156
|
b,
|
|
156
157
|
F,
|
|
157
|
-
|
|
158
|
+
T && /* @__PURE__ */ o("span", {
|
|
158
159
|
className: "sr-only",
|
|
159
160
|
role: "status",
|
|
160
161
|
"aria-live": "polite",
|
|
161
162
|
"aria-atomic": "true",
|
|
162
|
-
children:
|
|
163
|
+
children: D
|
|
163
164
|
})
|
|
164
165
|
]
|
|
165
166
|
}),
|
|
@@ -173,5 +174,5 @@ var de = 500, Le = ({ dataTest: d, id: T, open: t, onClose: s, title: m, ariaLab
|
|
|
173
174
|
});
|
|
174
175
|
};
|
|
175
176
|
export {
|
|
176
|
-
|
|
177
|
+
Oe as StyledBottomSheet
|
|
177
178
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { SHEET_TEXT as l } from "./sheetCopy.js";
|
|
2
|
+
var s = 9999, a = (r, t = "en") => {
|
|
3
|
+
const e = l[t];
|
|
4
|
+
return r == null ? e.showResults : r === 0 ? e.noMatches : r > s ? `${e.showResults} (${s}+)` : `${e.showResults} (${r})`;
|
|
5
|
+
};
|
|
2
6
|
export {
|
|
3
|
-
|
|
7
|
+
a as formatResultsLabel
|
|
4
8
|
};
|
|
@@ -2,11 +2,11 @@ import { cn as r } from "../../../helpers/cn.js";
|
|
|
2
2
|
import { CloseIcon as h } from "../../icons/close-icon/CloseIcon.js";
|
|
3
3
|
import { StyledButton as c } from "../../inputs/button/StyledButton.js";
|
|
4
4
|
import { useScrollGutter as u } from "./useScrollGutter.js";
|
|
5
|
-
import { useRef as
|
|
6
|
-
import { Fragment as
|
|
7
|
-
var _ = 40, j = "
|
|
8
|
-
const
|
|
9
|
-
return /* @__PURE__ */ o(
|
|
5
|
+
import { useRef as g } from "react";
|
|
6
|
+
import { Fragment as v, jsx as e, jsxs as o } 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-[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: s, title: a, titleId: m, children: x, viewResultsAction: t, resetAction: l, footerActions: n, closeLabel: p, onClose: f }) => {
|
|
8
|
+
const d = g(null), i = u(d);
|
|
9
|
+
return /* @__PURE__ */ o(v, { children: [
|
|
10
10
|
/* @__PURE__ */ o("div", {
|
|
11
11
|
className: "relative flex min-h-0 flex-1 flex-col",
|
|
12
12
|
children: [a && /* @__PURE__ */ e("div", {
|
|
@@ -14,9 +14,9 @@ var _ = 40, j = "relative box-border flex flex-col overflow-hidden rounded-lg bg
|
|
|
14
14
|
className: "shrink-0 truncate pb-1 pl-4 pr-10 pt-2 text-lg font-semibold leading-7 text-delta-800",
|
|
15
15
|
children: a
|
|
16
16
|
}), /* @__PURE__ */ e("div", {
|
|
17
|
-
ref:
|
|
18
|
-
className: r("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto py-2 pl-4 [scrollbar-gutter:stable]", !a &&
|
|
19
|
-
style: { paddingRight: Math.max(0, _ -
|
|
17
|
+
ref: d,
|
|
18
|
+
className: r("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto py-2 pl-4 [scrollbar-gutter:stable]", !a && i.overflows && "mt-10"),
|
|
19
|
+
style: { paddingRight: Math.max(0, _ - i.width) },
|
|
20
20
|
children: x
|
|
21
21
|
})]
|
|
22
22
|
}),
|
|
@@ -24,9 +24,9 @@ var _ = 40, j = "relative box-border flex flex-col overflow-hidden rounded-lg bg
|
|
|
24
24
|
className: r("flex shrink-0 items-start p-1", t ? "justify-between" : "justify-end", "max-xs:flex-wrap max-xs:gap-y-2 max-xs:[&>:last-child]:ml-auto"),
|
|
25
25
|
children: [t, l]
|
|
26
26
|
}),
|
|
27
|
-
|
|
27
|
+
n && /* @__PURE__ */ e("div", {
|
|
28
28
|
className: r("flex shrink-0 flex-col items-end p-3", (t ?? l) && "max-xs:pt-1"),
|
|
29
|
-
children:
|
|
29
|
+
children: n
|
|
30
30
|
}),
|
|
31
31
|
/* @__PURE__ */ e("div", {
|
|
32
32
|
className: "absolute right-0 top-0",
|
|
@@ -1,63 +1,64 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { firstTabbable as
|
|
3
|
-
import { TOP_LAYER_PROPS as
|
|
4
|
-
import { StyledButton as
|
|
5
|
-
import { useMobileMediaQuery as
|
|
6
|
-
import { OverlayBackOwnerContext as
|
|
7
|
-
import { useDebouncedValue as
|
|
8
|
-
import { useFocusTrap as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
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
|
-
},
|
|
19
|
-
const g =
|
|
20
|
-
|
|
21
|
-
}, [
|
|
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:
|
|
24
|
-
placement: `${
|
|
24
|
+
onOpenChange: y,
|
|
25
|
+
placement: `${T ?? "bottom"}-${de}`,
|
|
25
26
|
strategy: "fixed",
|
|
26
|
-
whileElementsMounted:
|
|
27
|
+
whileElementsMounted: ze,
|
|
27
28
|
middleware: [
|
|
28
|
-
|
|
29
|
-
...
|
|
29
|
+
Ge(8),
|
|
30
|
+
...pe || T ? [] : [Ve({
|
|
30
31
|
padding: 8,
|
|
31
32
|
crossAxis: !1,
|
|
32
33
|
flipAlignment: !1
|
|
33
34
|
})],
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
Qe({ padding: 8 }),
|
|
36
|
+
Je({
|
|
36
37
|
padding: 8,
|
|
37
38
|
apply({ availableHeight: e, rects: t }) {
|
|
38
|
-
|
|
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 &&
|
|
44
|
-
const F = Ie(
|
|
45
|
-
c.current = e,
|
|
46
|
-
}, []), ye =
|
|
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]),
|
|
49
|
+
}, [b]), G = f(null), O = N?.length ? N.join(",") : void 0, Q = f(O);
|
|
49
50
|
v(() => {
|
|
50
|
-
|
|
51
|
-
}, [
|
|
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) ||
|
|
55
|
-
const t =
|
|
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
|
-
}, []),
|
|
58
|
-
|
|
59
|
-
}, []), { getFloatingProps:
|
|
60
|
-
enabled: !
|
|
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
|
-
|
|
71
|
-
}, [
|
|
72
|
-
|
|
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 ||
|
|
78
|
+
if (!o || w) return;
|
|
78
79
|
const e = (t) => {
|
|
79
|
-
t.key !== "Escape" || t.defaultPrevented || t.isComposing || (t.preventDefault(), t.stopImmediatePropagation(),
|
|
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,
|
|
83
|
-
const [
|
|
83
|
+
}, [o, w]), Xe(o && n && r !== null, c);
|
|
84
|
+
const [Z, Te] = l(!1);
|
|
84
85
|
v(() => {
|
|
85
|
-
if (!r || n && !
|
|
86
|
+
if (!r || n && !Z) return;
|
|
86
87
|
const e = requestAnimationFrame(() => {
|
|
87
|
-
(n ?
|
|
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
|
-
|
|
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
|
|
104
|
-
(
|
|
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",
|
|
114
|
-
cancelAnimationFrame(e), document.removeEventListener("focusout",
|
|
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
|
|
123
|
+
const L = f(!1);
|
|
123
124
|
v(() => {
|
|
124
125
|
if (o) {
|
|
125
|
-
|
|
126
|
+
L.current = !0;
|
|
126
127
|
return;
|
|
127
128
|
}
|
|
128
|
-
if (!
|
|
129
|
-
|
|
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
|
|
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
|
-
|
|
149
|
+
le(_e(e.currentTarget));
|
|
149
150
|
const t = e.currentTarget.getBoundingClientRect(), a = t.left + t.width / 2 > window.innerWidth / 2;
|
|
150
|
-
|
|
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
|
-
},
|
|
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:
|
|
163
|
-
})), Ae = u ?
|
|
164
|
-
return
|
|
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:
|
|
172
|
-
ariaLabel:
|
|
173
|
-
viewResultsAction:
|
|
174
|
-
resetAction:
|
|
175
|
-
footerActions:
|
|
176
|
-
resultCount:
|
|
177
|
-
|
|
178
|
-
|
|
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
|
|
181
|
-
root:
|
|
182
|
+
})] }) : /* @__PURE__ */ ie(re, { children: [_(ee), o && /* @__PURE__ */ m(Ye, {
|
|
183
|
+
root: K,
|
|
182
184
|
children: /* @__PURE__ */ m("div", {
|
|
183
|
-
...
|
|
185
|
+
...Re(),
|
|
184
186
|
onFocusCapture: xe,
|
|
185
187
|
ref: ye,
|
|
186
188
|
id: g,
|
|
187
|
-
"data-placement":
|
|
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 &&
|
|
192
|
-
"aria-label": n && !
|
|
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 ?
|
|
196
|
+
...F ? Se : {},
|
|
195
197
|
style: {
|
|
196
198
|
...F ? Ce : {},
|
|
197
|
-
...
|
|
198
|
-
minWidth: u ? C :
|
|
199
|
-
width:
|
|
199
|
+
...ge,
|
|
200
|
+
minWidth: u ? C : me,
|
|
201
|
+
width: Oe,
|
|
200
202
|
maxWidth: Ae,
|
|
201
|
-
maxHeight:
|
|
203
|
+
maxHeight: ue
|
|
202
204
|
},
|
|
203
|
-
className:
|
|
204
|
-
children: /* @__PURE__ */ m(
|
|
205
|
+
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),
|
|
206
|
+
children: /* @__PURE__ */ m(We.Provider, {
|
|
205
207
|
value: c,
|
|
206
|
-
children: /* @__PURE__ */ m(
|
|
208
|
+
children: /* @__PURE__ */ m(Ke, {
|
|
207
209
|
dataTest: p,
|
|
208
|
-
title:
|
|
209
|
-
titleId:
|
|
210
|
-
viewResultsAction:
|
|
211
|
-
resetAction:
|
|
212
|
-
footerActions:
|
|
213
|
-
closeLabel:
|
|
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:
|
|
217
|
+
children: P(M)
|
|
216
218
|
})
|
|
217
219
|
})
|
|
218
220
|
})
|
|
219
221
|
})] });
|
|
220
222
|
};
|
|
221
223
|
export {
|
|
222
|
-
|
|
224
|
+
Pt as PopoverSheet
|
|
223
225
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReactNode, RefObject } from 'react';
|
|
2
|
+
import { UiCoreLocale } from '../../../helpers/uiCoreLocale';
|
|
2
3
|
import { PopoverSlot } from '../popover/PopoverSheet';
|
|
3
4
|
export type BottomSheetCloseReason = 'closeButton' | 'scrim' | 'escape' | 'drag' | 'viewResults' | 'action';
|
|
4
5
|
/** @figmaNode 9Q7C7JYPgnUSsrX1L8v40t#5354-169163 (Ad-Voca-concept · "_bottom sheet") */
|
|
@@ -37,8 +38,10 @@ export interface StyledBottomSheetProps {
|
|
|
37
38
|
* @figmaProp none — behavioral
|
|
38
39
|
*/
|
|
39
40
|
resultCount?: number | null;
|
|
40
|
-
/** @figmaProp none — a11y: accessible name of the close control */
|
|
41
|
+
/** @figmaProp none — a11y: accessible name of the close control; defaults to "Close" in `locale` */
|
|
41
42
|
closeLabel?: string;
|
|
43
|
+
/** Language of the default result and close labels; defaults to English. */
|
|
44
|
+
locale?: UiCoreLocale;
|
|
42
45
|
/** @figmaProp none — style escape hatch, applied to the sheet container */
|
|
43
46
|
className?: string;
|
|
44
47
|
/** Set `false` when a wrapper already owns the Back-close registration. */
|
|
@@ -60,4 +63,4 @@ export interface StyledBottomSheetProps {
|
|
|
60
63
|
* Focus moves to the sheet on open (so the title is announced first) and back to the trigger on
|
|
61
64
|
* close. `PopoverSheet` with `variant='action'` renders this automatically below 744px.
|
|
62
65
|
*/
|
|
63
|
-
export declare const StyledBottomSheet: ({ dataTest, id, open, onClose, title, ariaLabel, children, viewResultsAction, resetAction, footerActions, resultCount, closeLabel, className, registerBackClose, ownerRef, }: StyledBottomSheetProps) => JSX.Element | null;
|
|
66
|
+
export declare const StyledBottomSheet: ({ dataTest, id, open, onClose, title, ariaLabel, children, viewResultsAction, resetAction, footerActions, resultCount, locale, closeLabel, className, registerBackClose, ownerRef, }: StyledBottomSheetProps) => JSX.Element | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UiCoreLocale } from '../../../helpers/uiCoreLocale';
|
|
1
2
|
/**
|
|
2
3
|
* The label of the "Vis resultater (N)" dismiss control — one system-wide pattern, not per-screen copy.
|
|
3
4
|
*
|
|
@@ -5,5 +6,7 @@
|
|
|
5
6
|
* - `0` → `Ingen treff` (stays enabled — it is the way out of the sheet)
|
|
6
7
|
* - above 9999 → `Vis resultater (9999+)`, so the label keeps a fixed shape and never wraps
|
|
7
8
|
* - otherwise → `Vis resultater (N)`, parenthesised even for 1 to sidestep resultat/resultater
|
|
9
|
+
*
|
|
10
|
+
* English (`locale='en'`) reads `Show results (N)` and `No matches`.
|
|
8
11
|
*/
|
|
9
|
-
export declare const formatResultsLabel: (count: number | null | undefined) => string;
|
|
12
|
+
export declare const formatResultsLabel: (count: number | null | undefined, locale?: UiCoreLocale) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UiCoreLocale } from '../../../helpers/uiCoreLocale';
|
|
2
|
+
/**
|
|
3
|
+
* Default strings of `PopoverSheet` and `StyledBottomSheet`. English is the meaning column of the spec's copy table.
|
|
4
|
+
*
|
|
5
|
+
* @see asma-modules/_docs/ux/specs/spec-design-system-bottom-sheet.md:116 — Copy and label guidelines
|
|
6
|
+
*/
|
|
7
|
+
export declare const SHEET_TEXT: Record<UiCoreLocale, {
|
|
8
|
+
close: string;
|
|
9
|
+
showResults: string;
|
|
10
|
+
noMatches: string;
|
|
11
|
+
}>;
|
|
@@ -12,7 +12,10 @@ import { ReactNode } from 'react';
|
|
|
12
12
|
* The ring is not on this surface itself: an element's own inset shadow paints beneath its
|
|
13
13
|
* children, so the Close button's hover fill in the top-right corner covered it. `PopoverAnatomy`
|
|
14
14
|
* draws it as its last, absolutely positioned layer (`SURFACE_EDGE_CLASSNAME`), above the content.
|
|
15
|
-
*
|
|
15
|
+
* The surface carries no `position` class: utilities here ship `!important`, so `relative` beat
|
|
16
|
+
* Floating UI's inline `position: fixed`. Inside a modal `<dialog>` (no top layer to rescue it) the
|
|
17
|
+
* sheet then rendered off-screen and focusing it scrolled the dialog sideways. The caller's
|
|
18
|
+
* position (the sheet's inline `fixed`, the Gallery's `relative`) is that layer's containing block.
|
|
16
19
|
*
|
|
17
20
|
* `box-border` is load-bearing, not noise: this package builds Tailwind with `preflight: false`, so
|
|
18
21
|
* without it `box-sizing` falls back to `content-box` and a 472px max-width renders 474.
|
|
@@ -20,7 +23,7 @@ import { ReactNode } from 'react';
|
|
|
20
23
|
* Positioning (`z-index`, the floating transform, the top-layer props) deliberately stays with the
|
|
21
24
|
* caller, so the Gallery story can render the same surface statically in a grid.
|
|
22
25
|
*/
|
|
23
|
-
export declare const POPOVER_SURFACE_CLASSNAME = "
|
|
26
|
+
export declare const POPOVER_SURFACE_CLASSNAME = "box-border flex flex-col overflow-hidden rounded-lg bg-white text-delta-700 outline-none shadow-[0px_4px_40px_0px_#22213366]";
|
|
24
27
|
export interface PopoverAnatomyProps {
|
|
25
28
|
dataTest: string;
|
|
26
29
|
title?: ReactNode;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MouseEvent, ReactNode } from 'react';
|
|
2
|
+
import { UiCoreLocale } from '../../../helpers/uiCoreLocale';
|
|
2
3
|
/** Spread on the trigger element. The ref is handed over separately — `StyledButton` takes `refLink`. */
|
|
3
4
|
export interface PopoverTriggerProps {
|
|
4
5
|
onClick: (event: MouseEvent<HTMLElement>) => void;
|
|
@@ -52,8 +53,10 @@ export interface PopoverSheetProps {
|
|
|
52
53
|
* @figmaProp none — behavioral
|
|
53
54
|
*/
|
|
54
55
|
resultCount?: number | null;
|
|
55
|
-
/** @figmaProp none — a11y: accessible name of the close control */
|
|
56
|
+
/** @figmaProp none — a11y: accessible name of the close control; defaults to "Close" in `locale` */
|
|
56
57
|
closeLabel?: string;
|
|
58
|
+
/** Language of the default result and close labels; defaults to English. */
|
|
59
|
+
locale?: UiCoreLocale;
|
|
57
60
|
/** @figmaProp none — a11y: required when `variant='action'` and no `title` is given, so the dialog has a name */
|
|
58
61
|
ariaLabel?: string;
|
|
59
62
|
/** @figmaProp none — behavioral */
|
|
@@ -95,4 +98,4 @@ export interface PopoverSheetProps {
|
|
|
95
98
|
* Separate from {@link StyledPopover}, which stays as the MUI-parity positioning primitive its eight
|
|
96
99
|
* internal consumers still depend on; those migrate here gradually.
|
|
97
100
|
*/
|
|
98
|
-
export declare const PopoverSheet: ({ dataTest, renderTrigger, variant, title, children, viewResultsAction, resetAction, footerActions, resultCount, closeLabel, ariaLabel, onOpenChange, className, align, ignoreOutside, }: PopoverSheetProps) => JSX.Element;
|
|
101
|
+
export declare const PopoverSheet: ({ dataTest, renderTrigger, variant, title, children, viewResultsAction, resetAction, footerActions, resultCount, locale, closeLabel, ariaLabel, onOpenChange, className, align, ignoreOutside, }: PopoverSheetProps) => JSX.Element;
|