asma-ui-core 3.134.4 → 3.134.6
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/formatResultsLabel.js +5 -5
- package/dist/components/utils/bottom-sheet/sheetCopy.js +4 -4
- package/dist/components/utils/popover/StyledPopover.js +84 -81
- package/dist/src/components/utils/bottom-sheet/formatResultsLabel.d.ts +1 -1
- package/dist/src/components/utils/bottom-sheet/sheetCopy.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { SHEET_TEXT as
|
|
2
|
-
var
|
|
3
|
-
const
|
|
4
|
-
return
|
|
1
|
+
import { SHEET_TEXT as i } from "./sheetCopy.js";
|
|
2
|
+
var t = 9999, v = (e, s = "en") => {
|
|
3
|
+
const r = i[s];
|
|
4
|
+
return e == null ? r.viewResults : e === 0 ? r.noMatches : e > t ? `${r.viewResults} (${t}+)` : `${r.viewResults} (${e})`;
|
|
5
5
|
};
|
|
6
6
|
export {
|
|
7
|
-
|
|
7
|
+
v as formatResultsLabel
|
|
8
8
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
1
|
+
var e = {
|
|
2
2
|
no: {
|
|
3
3
|
close: "Lukk",
|
|
4
|
-
|
|
4
|
+
viewResults: "Vis resultater",
|
|
5
5
|
noMatches: "Ingen treff"
|
|
6
6
|
},
|
|
7
7
|
en: {
|
|
8
8
|
close: "Close",
|
|
9
|
-
|
|
9
|
+
viewResults: "View results",
|
|
10
10
|
noMatches: "No matches"
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
export {
|
|
14
|
-
|
|
14
|
+
e as SHEET_TEXT
|
|
15
15
|
};
|
|
@@ -3,139 +3,142 @@ import { resolveSx as R } from "../../../helpers/sx.js";
|
|
|
3
3
|
import { tabbableWithin as y } from "../../../helpers/focusable.js";
|
|
4
4
|
import { TOP_LAYER_PROPS as j, TOP_LAYER_RESET_STYLE as q, getOpenModalDialogAncestor as C, shouldUsePopoverTopLayer as G, useTopLayerRef as J } from "../../../hooks/useTopLayer.hook.js";
|
|
5
5
|
import { OverlayBackOwnerContext as Q, useBackCloses as V } from "../../../hooks/useBackCloses.hook.js";
|
|
6
|
-
import { useEffect as
|
|
7
|
-
import { jsx as
|
|
8
|
-
import { FloatingPortal as ee, autoUpdate as te, flip as oe, offset as ne, shift as re, size as se, useDismiss as
|
|
9
|
-
var
|
|
6
|
+
import { useEffect as x, useMemo as X, useRef as Z, useState as b } from "react";
|
|
7
|
+
import { jsx as P } from "react/jsx-runtime";
|
|
8
|
+
import { FloatingPortal as ee, autoUpdate as te, flip as oe, offset as ne, shift as re, size as se, useDismiss as ae, useFloating as ie, useInteractions as ce, useMergeRefs as fe } from "@floating-ui/react";
|
|
9
|
+
var le = {
|
|
10
10
|
vertical: "bottom",
|
|
11
11
|
horizontal: "left"
|
|
12
|
-
},
|
|
12
|
+
}, ue = {
|
|
13
13
|
vertical: "top",
|
|
14
14
|
horizontal: "left"
|
|
15
|
-
}, de = (
|
|
16
|
-
const
|
|
17
|
-
t
|
|
18
|
-
|
|
19
|
-
o
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
}, de = (o) => {
|
|
16
|
+
const t = getComputedStyle(o);
|
|
17
|
+
return t.boxSizing === "border-box" ? 0 : parseFloat(t.paddingTop) + parseFloat(t.paddingBottom) + parseFloat(t.borderTopWidth) + parseFloat(t.borderBottomWidth);
|
|
18
|
+
}, pe = (o, t) => `${t.vertical === "bottom" ? "top" : t.vertical === "top" ? "bottom" : o.vertical === "top" ? "top" : "bottom"}${o.horizontal === "left" ? "-start" : o.horizontal === "right" ? "-end" : ""}`, Le = ({ open: o, anchorEl: t, onClose: c, anchorOrigin: h = le, transformOrigin: w = ue, id: T, className: D, sx: F, slotProps: u, onClick: K, children: S, keepMounted: E = !1, tabIntoContent: d = !0, registerBackClose: k = !0 }) => {
|
|
19
|
+
const O = X(() => pe(h, w), [h, w]), [L, _] = b(o), f = Z(!1), [M, H] = b();
|
|
20
|
+
o && !L && _(!0);
|
|
21
|
+
const p = o || E && L, m = C(t), [g, z] = b(m);
|
|
22
|
+
t && g !== m && z(m);
|
|
23
|
+
const { refs: a, floatingStyles: A, context: B } = ie({
|
|
24
|
+
open: o,
|
|
25
|
+
placement: O,
|
|
23
26
|
strategy: "fixed",
|
|
24
27
|
whileElementsMounted: te,
|
|
25
|
-
elements: { reference:
|
|
28
|
+
elements: { reference: t ?? void 0 },
|
|
26
29
|
middleware: [
|
|
27
30
|
ne(4),
|
|
28
31
|
oe({ padding: 8 }),
|
|
29
32
|
re({ padding: 8 }),
|
|
30
33
|
se({
|
|
31
34
|
padding: 8,
|
|
32
|
-
apply: ({ availableHeight: e }) => H(e)
|
|
35
|
+
apply: ({ availableHeight: e, elements: n }) => H(Math.max(0, e - de(n.floating)))
|
|
33
36
|
})
|
|
34
37
|
],
|
|
35
|
-
onOpenChange: (e,
|
|
36
|
-
e || c?.(
|
|
38
|
+
onOpenChange: (e, n, r) => {
|
|
39
|
+
e || c?.(n ?? {}, r === "escape-key" ? "escapeKeyDown" : "backdropClick");
|
|
37
40
|
}
|
|
38
|
-
}), { getFloatingProps:
|
|
41
|
+
}), { getFloatingProps: N } = ce([ae(B, {
|
|
39
42
|
outsidePress: (e) => {
|
|
40
|
-
const
|
|
41
|
-
return !(
|
|
43
|
+
const n = e.target;
|
|
44
|
+
return !(t instanceof Element && n instanceof Node && t.contains(n));
|
|
42
45
|
},
|
|
43
46
|
escapeKey: !0
|
|
44
47
|
})]);
|
|
45
48
|
V({
|
|
46
|
-
active:
|
|
49
|
+
active: o && k,
|
|
47
50
|
requestClose: (e) => c ? c(e ?? new Event("overlayBack"), "escapeKeyDown") : !1,
|
|
48
|
-
ownerRef:
|
|
51
|
+
ownerRef: a.floating
|
|
49
52
|
});
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
if (!
|
|
53
|
-
const e =
|
|
54
|
-
let
|
|
53
|
+
const l = G(g), U = fe([J(a.setFloating, l)]);
|
|
54
|
+
x(() => {
|
|
55
|
+
if (!o) return;
|
|
56
|
+
const e = t instanceof HTMLElement ? t : null, n = () => a.floating.current?.contains(document.activeElement) ?? !1;
|
|
57
|
+
let r = n();
|
|
55
58
|
const s = () => {
|
|
56
|
-
|
|
59
|
+
r = n();
|
|
57
60
|
};
|
|
58
61
|
return document.addEventListener("focusin", s), () => {
|
|
59
62
|
document.removeEventListener("focusin", s);
|
|
60
|
-
const
|
|
61
|
-
|
|
63
|
+
const i = document.activeElement, v = !i || i === document.body || n();
|
|
64
|
+
r && v && e?.isConnected && e.focus({ preventScroll: !0 });
|
|
62
65
|
};
|
|
63
66
|
}, [
|
|
64
|
-
t,
|
|
65
67
|
o,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
t,
|
|
69
|
+
a.floating
|
|
70
|
+
]), x(() => {
|
|
71
|
+
if (!o) return;
|
|
72
|
+
const e = (r) => {
|
|
73
|
+
if (f.current = r.key === "Tab", !d || !f.current || r.shiftKey || r.defaultPrevented) return;
|
|
74
|
+
const s = a.floating.current;
|
|
75
|
+
if (!s || !(t instanceof Element) || !t.contains(document.activeElement)) return;
|
|
76
|
+
const [i] = y(s);
|
|
77
|
+
i && (r.preventDefault(), i.focus({ preventScroll: !0 }), f.current = !1);
|
|
78
|
+
}, n = (r) => {
|
|
79
|
+
const s = r.target, i = s instanceof Node && ((a.floating.current?.contains(s) ?? !1) || t instanceof Element && t.contains(s));
|
|
80
|
+
f.current && !i && c?.(r, "tabKeyDown"), f.current = !1;
|
|
78
81
|
};
|
|
79
|
-
return document.addEventListener("keydown", e, !0), document.addEventListener("focusin",
|
|
80
|
-
document.removeEventListener("keydown", e, !0), document.removeEventListener("focusin",
|
|
82
|
+
return document.addEventListener("keydown", e, !0), document.addEventListener("focusin", n), () => {
|
|
83
|
+
document.removeEventListener("keydown", e, !0), document.removeEventListener("focusin", n);
|
|
81
84
|
};
|
|
82
85
|
}, [
|
|
83
|
-
t,
|
|
84
86
|
o,
|
|
87
|
+
t,
|
|
85
88
|
c,
|
|
86
|
-
|
|
89
|
+
a.floating,
|
|
87
90
|
d
|
|
88
91
|
]);
|
|
89
|
-
const
|
|
90
|
-
onClick:
|
|
92
|
+
const W = o ? N({
|
|
93
|
+
onClick: K,
|
|
91
94
|
onKeyDown: (e) => {
|
|
92
|
-
if (e.key !== "Tab" || e.defaultPrevented || !(
|
|
93
|
-
const
|
|
94
|
-
if (s === -1 || (e.shiftKey ? s !== 0 : s !==
|
|
95
|
+
if (e.key !== "Tab" || e.defaultPrevented || !(t instanceof HTMLElement)) return;
|
|
96
|
+
const n = e.currentTarget, r = y(n), s = r.indexOf(document.activeElement);
|
|
97
|
+
if (s === -1 || (e.shiftKey ? s !== 0 : s !== r.length - 1)) return;
|
|
95
98
|
e.preventDefault();
|
|
96
|
-
const
|
|
97
|
-
f.current = !1,
|
|
99
|
+
const i = y(document).filter((Y) => !n.contains(Y)), v = i[i.indexOf(t) + (e.shiftKey ? -1 : 1)], I = (d && e.shiftKey ? void 0 : v) ?? t;
|
|
100
|
+
f.current = !1, I.focus({ preventScroll: !0 }), c?.(e, "tabKeyDown");
|
|
98
101
|
}
|
|
99
102
|
}) : {};
|
|
100
|
-
return
|
|
101
|
-
if (!
|
|
102
|
-
const e =
|
|
103
|
+
return x(() => {
|
|
104
|
+
if (!p || !l) return;
|
|
105
|
+
const e = a.floating.current;
|
|
103
106
|
if (!(!e || typeof e.showPopover != "function"))
|
|
104
107
|
try {
|
|
105
|
-
|
|
108
|
+
o && !e.matches(":popover-open") && e.showPopover(), !o && e.matches(":popover-open") && e.hidePopover();
|
|
106
109
|
} catch {
|
|
107
110
|
}
|
|
108
111
|
}, [
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
]),
|
|
114
|
-
root:
|
|
115
|
-
children: /* @__PURE__ */
|
|
116
|
-
ref:
|
|
117
|
-
id:
|
|
118
|
-
...
|
|
112
|
+
o,
|
|
113
|
+
p,
|
|
114
|
+
l,
|
|
115
|
+
a.floating
|
|
116
|
+
]), p ? /* @__PURE__ */ P(ee, {
|
|
117
|
+
root: g,
|
|
118
|
+
children: /* @__PURE__ */ P("div", {
|
|
119
|
+
ref: U,
|
|
120
|
+
id: T,
|
|
121
|
+
...l ? j : {},
|
|
119
122
|
style: {
|
|
120
|
-
...
|
|
121
|
-
...
|
|
122
|
-
...
|
|
123
|
+
...l ? q : {},
|
|
124
|
+
...o ? {
|
|
125
|
+
...A,
|
|
123
126
|
maxHeight: M
|
|
124
127
|
} : {},
|
|
125
|
-
...R(
|
|
126
|
-
...R(
|
|
127
|
-
...
|
|
128
|
-
...
|
|
128
|
+
...R(F),
|
|
129
|
+
...R(u?.paper?.sx),
|
|
130
|
+
...u?.paper?.style,
|
|
131
|
+
...o ? null : { display: "none" }
|
|
129
132
|
},
|
|
130
|
-
...
|
|
131
|
-
className: $("z-[1300] overflow-auto rounded bg-white shadow-[0px_1px_12px_0px_rgba(0,0,0,0.15)]",
|
|
132
|
-
children: /* @__PURE__ */
|
|
133
|
-
value:
|
|
134
|
-
children:
|
|
133
|
+
...W,
|
|
134
|
+
className: $("z-[1300] overflow-auto rounded bg-white shadow-[0px_1px_12px_0px_rgba(0,0,0,0.15)]", D ?? "my-1", u?.paper?.className),
|
|
135
|
+
children: /* @__PURE__ */ P(Q.Provider, {
|
|
136
|
+
value: a.floating,
|
|
137
|
+
children: S
|
|
135
138
|
})
|
|
136
139
|
})
|
|
137
140
|
}) : null;
|
|
138
141
|
};
|
|
139
142
|
export {
|
|
140
|
-
|
|
143
|
+
Le as StyledPopover
|
|
141
144
|
};
|
|
@@ -7,6 +7,6 @@ import { UiCoreLocale } from '../../../helpers/uiCoreLocale';
|
|
|
7
7
|
* - above 9999 → `Vis resultater (9999+)`, so the label keeps a fixed shape and never wraps
|
|
8
8
|
* - otherwise → `Vis resultater (N)`, parenthesised even for 1 to sidestep resultat/resultater
|
|
9
9
|
*
|
|
10
|
-
* English (`locale='en'`) reads `
|
|
10
|
+
* English (`locale='en'`) reads `View results (N)` and `No matches`.
|
|
11
11
|
*/
|
|
12
12
|
export declare const formatResultsLabel: (count: number | null | undefined, locale?: UiCoreLocale) => string;
|