@altinn/altinn-components 0.46.3 → 0.46.5
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/Account/AccountMenu.js +22 -20
- package/dist/components/GlobalHeader/AccountSelector.js +26 -25
- package/dist/components/Menu/Menu.js +19 -16
- package/dist/components/Menu/MenuItemsVirtual.js +59 -55
- package/dist/hooks/useAccountSelector.js +99 -97
- package/dist/types/lib/components/Account/AccountMenu.d.ts +1 -1
- package/dist/types/lib/components/Account/AccountMenu.stories.d.ts +1 -1
- package/dist/types/lib/components/GlobalHeader/GlobalHeader.stories.d.ts +1 -0
- package/dist/types/lib/components/Menu/Menu.d.ts +1 -1
- package/dist/types/lib/components/Menu/Menu.stories.d.ts +1 -1
- package/dist/types/lib/components/Menu/MenuItems.d.ts +1 -0
- package/dist/types/lib/components/Menu/MenuItemsVirtual.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useState as
|
|
2
|
+
import { jsx as x } from "react/jsx-runtime";
|
|
3
|
+
import { useState as R, useEffect as S } from "react";
|
|
4
4
|
import "../../index-L8X2o7IH.js";
|
|
5
5
|
import "../RootProvider/RootProvider.js";
|
|
6
|
-
import { Menu as
|
|
6
|
+
import { Menu as j } from "../Menu/Menu.js";
|
|
7
7
|
import "../Snackbar/useSnackbar.js";
|
|
8
|
-
const
|
|
8
|
+
const k = (d) => `${d} hits`, D = ({
|
|
9
9
|
items: d = [],
|
|
10
10
|
groups: v = {},
|
|
11
11
|
search: t,
|
|
@@ -13,7 +13,8 @@ const j = (d) => `${d} hits`, B = ({
|
|
|
13
13
|
onSelectAccount: u,
|
|
14
14
|
currentAccount: e,
|
|
15
15
|
isVirtualized: L,
|
|
16
|
-
keyboardEvents: w
|
|
16
|
+
keyboardEvents: w,
|
|
17
|
+
scrollRefStyles: F
|
|
17
18
|
}) => {
|
|
18
19
|
var r;
|
|
19
20
|
const p = d.map((o) => ({
|
|
@@ -24,43 +25,44 @@ const j = (d) => `${d} hits`, B = ({
|
|
|
24
25
|
onClick: () => {
|
|
25
26
|
!o.disabled && (u == null || u(o.id));
|
|
26
27
|
}
|
|
27
|
-
})), [l, i] =
|
|
28
|
-
|
|
28
|
+
})), [l, i] = R("");
|
|
29
|
+
S(() => {
|
|
29
30
|
(t == null ? void 0 : t.value) !== void 0 && i(t.value);
|
|
30
31
|
}, [t == null ? void 0 : t.value]);
|
|
31
|
-
const
|
|
32
|
+
const b = C || ((o, a) => {
|
|
32
33
|
var g, f, s;
|
|
33
34
|
return ((g = o == null ? void 0 : o.name) == null ? void 0 : g.toLowerCase().includes(a.toLowerCase())) || ((s = (f = o == null ? void 0 : o.description) == null ? void 0 : f.toString()) == null ? void 0 : s.toLowerCase().includes(a.toLowerCase()));
|
|
34
|
-
}), n = l ? p.filter((o) =>
|
|
35
|
+
}), n = l ? p.filter((o) => b(o, l)).map((o) => ({
|
|
35
36
|
...o,
|
|
36
37
|
groupId: "search",
|
|
37
38
|
title: (o == null ? void 0 : o.title) || o.name,
|
|
38
39
|
highlightWords: [l]
|
|
39
|
-
})) : p,
|
|
40
|
+
})) : p, I = l ? {
|
|
40
41
|
search: {
|
|
41
|
-
title: ((r = t == null ? void 0 : t.getResultsLabel) == null ? void 0 : r.call(t, n.length)) ??
|
|
42
|
+
title: ((r = t == null ? void 0 : t.getResultsLabel) == null ? void 0 : r.call(t, n.length)) ?? k(n.length)
|
|
42
43
|
}
|
|
43
|
-
} : v,
|
|
44
|
+
} : v, M = {
|
|
44
45
|
name: "account-search",
|
|
45
46
|
value: l,
|
|
46
47
|
placeholder: (t == null ? void 0 : t.placeholder) ?? "Find account",
|
|
47
48
|
onChange: (o) => i(o.target.value),
|
|
48
49
|
onClear: () => i("")
|
|
49
|
-
},
|
|
50
|
+
}, c = [
|
|
50
51
|
...n.length > 0 ? n : [{ id: "search", groupId: "search", hidden: !0 }]
|
|
51
52
|
];
|
|
52
|
-
return /* @__PURE__ */
|
|
53
|
-
|
|
53
|
+
return /* @__PURE__ */ x(
|
|
54
|
+
j,
|
|
54
55
|
{
|
|
55
56
|
variant: "default",
|
|
56
|
-
search: t && !t.hidden ?
|
|
57
|
-
groups:
|
|
58
|
-
items:
|
|
57
|
+
search: t && !t.hidden ? M : void 0,
|
|
58
|
+
groups: I,
|
|
59
|
+
items: c,
|
|
59
60
|
isVirtualized: L,
|
|
60
|
-
keyboardEvents: w
|
|
61
|
+
keyboardEvents: w,
|
|
62
|
+
scrollRefStyles: F
|
|
61
63
|
}
|
|
62
64
|
);
|
|
63
65
|
};
|
|
64
66
|
export {
|
|
65
|
-
|
|
67
|
+
D as AccountMenu
|
|
66
68
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
2
|
+
import { jsx as a, jsxs as O } from "react/jsx-runtime";
|
|
3
3
|
import { c as g } from "../../index-L8X2o7IH.js";
|
|
4
|
-
import s, { forwardRef as v, useState as
|
|
4
|
+
import s, { forwardRef as v, useState as z, useEffect as j } from "react";
|
|
5
5
|
import { AccountMenu as C } from "../Account/AccountMenu.js";
|
|
6
6
|
import { Button as E } from "../Button/Button.js";
|
|
7
7
|
import { useRootContext as k } from "../RootProvider/RootProvider.js";
|
|
8
8
|
import "../Snackbar/useSnackbar.js";
|
|
9
9
|
import { SearchField as F } from "../Forms/SearchField.js";
|
|
10
10
|
import { S as N } from "../../Spinner-BDXfwXIh.js";
|
|
11
|
-
import { H as
|
|
11
|
+
import { H as R } from "../../Heading-By5DKz2H.js";
|
|
12
12
|
import { u as _ } from "../../useId-BVFxCjkq.js";
|
|
13
|
-
import '../../assets/AccountSelector.css';var
|
|
13
|
+
import '../../assets/AccountSelector.css';var M = function(e, i) {
|
|
14
14
|
var r = {};
|
|
15
15
|
for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && i.indexOf(t) < 0 && (r[t] = e[t]);
|
|
16
16
|
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -19,7 +19,7 @@ import '../../assets/AccountSelector.css';var R = function(e, i) {
|
|
|
19
19
|
return r;
|
|
20
20
|
};
|
|
21
21
|
const P = v((e, i) => {
|
|
22
|
-
var { title: r, titleId: t } = e, n =
|
|
22
|
+
var { title: r, titleId: t } = e, n = M(e, ["title", "titleId"]);
|
|
23
23
|
let l = _();
|
|
24
24
|
return l = r ? t || "title-" + l : void 0, s.createElement(
|
|
25
25
|
"svg",
|
|
@@ -45,10 +45,10 @@ const T = v((e, i) => {
|
|
|
45
45
|
r ? s.createElement("title", { id: l }, r) : null,
|
|
46
46
|
s.createElement("path", { fill: "currentColor", fillRule: "evenodd", d: "M3.75 12a8.25 8.25 0 1 1 16.5 0 8.25 8.25 0 0 1-16.5 0M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25m.53 6.72a.75.75 0 0 0-1.06 0l-3.5 3.5a.75.75 0 0 0 .53 1.28h7a.75.75 0 0 0 .53-1.28zM12 10.56l1.69 1.69h-3.38z", clipRule: "evenodd" })
|
|
47
47
|
);
|
|
48
|
-
}),
|
|
49
|
-
accountSelector:
|
|
50
|
-
heading:
|
|
51
|
-
searchSection:
|
|
48
|
+
}), H = "_accountSelector_1f74n_1", V = "_heading_1f74n_11", B = "_searchSection_1f74n_17", D = "_searchField_1f74n_22", K = "_accountMenu_1f74n_26", L = "_fullScreen_1f74n_34", U = "_virtualized_1f74n_38", W = "_btnIcon_1f74n_42", $ = "_spinner_1f74n_46", c = {
|
|
49
|
+
accountSelector: H,
|
|
50
|
+
heading: V,
|
|
51
|
+
searchSection: B,
|
|
52
52
|
searchField: D,
|
|
53
53
|
accountMenu: K,
|
|
54
54
|
fullScreen: L,
|
|
@@ -56,19 +56,19 @@ const T = v((e, i) => {
|
|
|
56
56
|
btnIcon: W,
|
|
57
57
|
spinner: $
|
|
58
58
|
}, ie = ({ accountMenu: e, forceOpenFullScreen: i, className: r, loading: t }) => {
|
|
59
|
-
const { currentId: n, openId: l, toggleId: u, languageCode: S } = k(),
|
|
60
|
-
|
|
61
|
-
i === !0 && !
|
|
62
|
-
}, [i,
|
|
59
|
+
const { currentId: n, openId: l, toggleId: u, languageCode: S } = k(), o = n === "accountFullscreen", [f, m] = z(""), { minimize: b, fullscreen: y, searchText: h, heading: w } = q(S);
|
|
60
|
+
j(() => {
|
|
61
|
+
i === !0 && !o && l("accountFullscreen");
|
|
62
|
+
}, [i, o, l]);
|
|
63
63
|
const x = () => {
|
|
64
|
-
l(
|
|
64
|
+
l(o ? "account" : "accountFullscreen");
|
|
65
65
|
}, I = (d) => {
|
|
66
66
|
var p;
|
|
67
|
-
(p = e.onSelectAccount) == null || p.call(e, d), u(
|
|
67
|
+
(p = e.onSelectAccount) == null || p.call(e, d), u(o ? "accountFullscreen" : "account");
|
|
68
68
|
};
|
|
69
|
-
return t ? /* @__PURE__ */
|
|
70
|
-
|
|
71
|
-
/* @__PURE__ */
|
|
69
|
+
return t ? /* @__PURE__ */ a(N, { "aria-hidden": !0, "data-color": "neutral", className: c.spinner }) : /* @__PURE__ */ O("div", { className: g(r, c.accountSelector), children: [
|
|
70
|
+
o && /* @__PURE__ */ a(R, { "data-size": "md", level: 2, className: c.heading, children: w }),
|
|
71
|
+
/* @__PURE__ */ a("div", { className: c.searchSection, children: /* @__PURE__ */ a(
|
|
72
72
|
F,
|
|
73
73
|
{
|
|
74
74
|
name: h,
|
|
@@ -79,32 +79,33 @@ const T = v((e, i) => {
|
|
|
79
79
|
className: c.searchField
|
|
80
80
|
}
|
|
81
81
|
) }),
|
|
82
|
-
/* @__PURE__ */
|
|
82
|
+
/* @__PURE__ */ a(
|
|
83
83
|
"div",
|
|
84
84
|
{
|
|
85
85
|
className: g(
|
|
86
86
|
c.accountMenu,
|
|
87
|
-
|
|
87
|
+
o && c.fullScreen,
|
|
88
88
|
e.isVirtualized && c.virtualized
|
|
89
89
|
),
|
|
90
|
-
children: /* @__PURE__ */
|
|
90
|
+
children: /* @__PURE__ */ a(
|
|
91
91
|
C,
|
|
92
92
|
{
|
|
93
93
|
...e,
|
|
94
94
|
onSelectAccount: I,
|
|
95
95
|
keyboardEvents: !1,
|
|
96
|
-
search: { hidden: !0, name: "", value: f }
|
|
96
|
+
search: { hidden: !0, name: "", value: f },
|
|
97
|
+
scrollRefStyles: !o && e.isVirtualized ? { maxHeight: "calc(40vh)" } : void 0
|
|
97
98
|
}
|
|
98
99
|
)
|
|
99
100
|
}
|
|
100
101
|
),
|
|
101
|
-
i !== !0 && /* @__PURE__ */
|
|
102
|
+
i !== !0 && /* @__PURE__ */ a(
|
|
102
103
|
E,
|
|
103
104
|
{
|
|
104
|
-
icon:
|
|
105
|
+
icon: o ? /* @__PURE__ */ a(T, { className: c.btnIcon, "aria-hidden": "true" }) : /* @__PURE__ */ a(P, { className: c.btnIcon, "aria-hidden": "true" }),
|
|
105
106
|
variant: "text",
|
|
106
107
|
onClick: x,
|
|
107
|
-
children:
|
|
108
|
+
children: o ? b : y
|
|
108
109
|
}
|
|
109
110
|
)
|
|
110
111
|
] });
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { MenuBase as
|
|
3
|
-
import { MenuItems as
|
|
4
|
-
import { MenuItemsVirtual as
|
|
5
|
-
const
|
|
2
|
+
import { MenuBase as h } from "./MenuBase.js";
|
|
3
|
+
import { MenuItems as w } from "./MenuItems.js";
|
|
4
|
+
import { MenuItemsVirtual as A } from "./MenuItemsVirtual.js";
|
|
5
|
+
const J = ({
|
|
6
6
|
color: m,
|
|
7
7
|
variant: n,
|
|
8
8
|
defaultItemColor: i,
|
|
@@ -11,34 +11,37 @@ const D = ({
|
|
|
11
11
|
defaultIconTheme: o,
|
|
12
12
|
groups: u,
|
|
13
13
|
items: x = [],
|
|
14
|
-
search:
|
|
15
|
-
isVirtualized:
|
|
16
|
-
keyboardEvents:
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
search: j,
|
|
15
|
+
isVirtualized: q,
|
|
16
|
+
keyboardEvents: B,
|
|
17
|
+
scrollRefStyles: f
|
|
18
|
+
}) => q ? /* @__PURE__ */ r(h, { color: m, variant: n, children: /* @__PURE__ */ r(
|
|
19
|
+
A,
|
|
19
20
|
{
|
|
20
|
-
search:
|
|
21
|
+
search: j,
|
|
21
22
|
items: x,
|
|
22
23
|
groups: u,
|
|
23
24
|
defaultItemSize: M,
|
|
24
25
|
defaultItemColor: i,
|
|
25
26
|
defaultItemVariant: p,
|
|
26
27
|
defaultIconTheme: o,
|
|
27
|
-
keyboardEvents:
|
|
28
|
+
keyboardEvents: B,
|
|
29
|
+
scrollRefStyles: f
|
|
28
30
|
}
|
|
29
|
-
) }) : /* @__PURE__ */ r(
|
|
30
|
-
|
|
31
|
+
) }) : /* @__PURE__ */ r(h, { color: m, variant: n, children: /* @__PURE__ */ r(
|
|
32
|
+
w,
|
|
31
33
|
{
|
|
32
|
-
search:
|
|
34
|
+
search: j,
|
|
33
35
|
items: x,
|
|
34
36
|
groups: u,
|
|
35
37
|
defaultItemSize: M,
|
|
36
38
|
defaultItemColor: i,
|
|
37
39
|
defaultItemVariant: p,
|
|
38
40
|
defaultIconTheme: o,
|
|
39
|
-
keyboardEvents:
|
|
41
|
+
keyboardEvents: B,
|
|
42
|
+
scrollRefStyles: f
|
|
40
43
|
}
|
|
41
44
|
) });
|
|
42
45
|
export {
|
|
43
|
-
|
|
46
|
+
J as Menu
|
|
44
47
|
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { u as
|
|
4
|
-
import { useRef as
|
|
2
|
+
import { jsx as m, jsxs as L } from "react/jsx-runtime";
|
|
3
|
+
import { u as k } from "../../index-D-VWMqlv.js";
|
|
4
|
+
import { useRef as R, useState as A, useEffect as y, useMemo as D } from "react";
|
|
5
5
|
import "../../index-L8X2o7IH.js";
|
|
6
|
-
import { useMenu as
|
|
6
|
+
import { useMenu as K } from "../../hooks/useMenu.js";
|
|
7
7
|
import "../RootProvider/RootProvider.js";
|
|
8
|
-
import { MenuItem as
|
|
9
|
-
import { MenuSearch as
|
|
10
|
-
import { MenuHeader as
|
|
11
|
-
import { MenuList as
|
|
8
|
+
import { MenuItem as V } from "./MenuItem.js";
|
|
9
|
+
import { MenuSearch as W } from "./MenuSearch.js";
|
|
10
|
+
import { MenuHeader as j } from "./MenuHeader.js";
|
|
11
|
+
import { MenuList as N, MenuListItem as U } from "./MenuBase.js";
|
|
12
12
|
import "../Snackbar/useSnackbar.js";
|
|
13
|
-
import '../../assets/MenuItemsVirtual.css';const
|
|
14
|
-
virtualScrollRef:
|
|
15
|
-
virtualMenuListItem:
|
|
16
|
-
},
|
|
17
|
-
level:
|
|
13
|
+
import '../../assets/MenuItemsVirtual.css';const Y = "_virtualScrollRef_nmoqo_1", F = "_virtualMenuListItem_nmoqo_8", M = {
|
|
14
|
+
virtualScrollRef: Y,
|
|
15
|
+
virtualMenuListItem: F
|
|
16
|
+
}, se = ({
|
|
17
|
+
level: E = 0,
|
|
18
18
|
search: g,
|
|
19
19
|
items: z,
|
|
20
20
|
groups: T = {},
|
|
@@ -22,83 +22,87 @@ import '../../assets/MenuItemsVirtual.css';const U = "_virtualScrollRef_nmoqo_1"
|
|
|
22
22
|
defaultItemColor: b,
|
|
23
23
|
defaultItemVariant: q,
|
|
24
24
|
defaultIconTheme: $,
|
|
25
|
-
keyboardEvents: f
|
|
25
|
+
keyboardEvents: f,
|
|
26
|
+
scrollRefStyles: H
|
|
26
27
|
}) => {
|
|
27
|
-
var
|
|
28
|
-
const
|
|
29
|
-
|
|
28
|
+
var w;
|
|
29
|
+
const c = R(null), x = (w = c.current) == null ? void 0 : w.getBoundingClientRect().top, [S, B] = A(window.innerHeight);
|
|
30
|
+
y(() => {
|
|
30
31
|
const n = () => {
|
|
31
|
-
|
|
32
|
+
B(window.innerHeight);
|
|
32
33
|
};
|
|
33
34
|
return window.addEventListener("resize", n), () => {
|
|
34
35
|
window.removeEventListener("resize", n);
|
|
35
36
|
};
|
|
36
37
|
}, []);
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
const I = D(() => x && S - x - 8 || 400, [S, x]), C = {
|
|
39
|
+
...{
|
|
40
|
+
maxHeight: I <= 300 ? 300 : I
|
|
41
|
+
},
|
|
42
|
+
...H
|
|
43
|
+
}, { menu: _ } = K({
|
|
40
44
|
items: z,
|
|
41
45
|
groups: T,
|
|
42
46
|
groupByKey: "groupId",
|
|
43
47
|
keyboardEvents: f,
|
|
44
|
-
ref:
|
|
45
|
-
}), v =
|
|
48
|
+
ref: c
|
|
49
|
+
}), v = _.flatMap((n, t) => {
|
|
46
50
|
var i;
|
|
47
|
-
const e = (n == null ? void 0 : n.props) || {}, { title: r } = e,
|
|
48
|
-
var
|
|
49
|
-
return !((
|
|
51
|
+
const e = (n == null ? void 0 : n.props) || {}, { title: r } = e, a = ((i = n == null ? void 0 : n.items) == null ? void 0 : i.filter((s) => {
|
|
52
|
+
var l;
|
|
53
|
+
return !((l = s.props) != null && l.hidden);
|
|
50
54
|
})) || [];
|
|
51
55
|
return [
|
|
52
|
-
...t > 0 ||
|
|
56
|
+
...t > 0 || E > 0 ? [{ type: "separator" }] : [],
|
|
53
57
|
...r ? [{ type: "title", title: r }] : [],
|
|
54
|
-
...
|
|
58
|
+
...a.map((s, l) => {
|
|
55
59
|
var p, o;
|
|
56
60
|
return {
|
|
57
61
|
type: "item",
|
|
58
62
|
itemProps: s.props || {},
|
|
59
63
|
active: s.active,
|
|
60
64
|
hasChildren: ((p = s.props) == null ? void 0 : p.expanded) && ((o = s.props) == null ? void 0 : o.items),
|
|
61
|
-
isLastItem:
|
|
65
|
+
isLastItem: l === a.length - 1
|
|
62
66
|
};
|
|
63
67
|
})
|
|
64
68
|
];
|
|
65
|
-
}), d =
|
|
69
|
+
}), d = k({
|
|
66
70
|
count: v.length,
|
|
67
71
|
gap: 8,
|
|
68
72
|
estimateSize: () => 44,
|
|
69
|
-
getScrollElement: () =>
|
|
73
|
+
getScrollElement: () => c.current
|
|
70
74
|
}), h = d.getVirtualItems();
|
|
71
|
-
|
|
75
|
+
y(() => {
|
|
72
76
|
var n, t, e;
|
|
73
77
|
for (const r of h) {
|
|
74
|
-
const
|
|
75
|
-
|
|
78
|
+
const a = ((n = c.current) == null ? void 0 : n.querySelector(`[data-index="${r.index}"]`)) ?? ((t = c.current) == null ? void 0 : t.querySelector(`[dataindex="${r.index}"]`)) ?? ((e = c.current) == null ? void 0 : e.querySelector(`[dataIndex="${r.index}"]`));
|
|
79
|
+
a && d.measureElement(a);
|
|
76
80
|
}
|
|
77
81
|
}, [h]);
|
|
78
|
-
const u =
|
|
79
|
-
return
|
|
82
|
+
const u = R(!1);
|
|
83
|
+
return y(() => {
|
|
80
84
|
const n = (r) => {
|
|
81
85
|
(r.key === "ArrowDown" || r.key === "ArrowUp") && (u.current = !0);
|
|
82
86
|
}, t = () => {
|
|
83
87
|
u.current = !1;
|
|
84
88
|
};
|
|
85
89
|
document.addEventListener("keydown", n, !0);
|
|
86
|
-
const e =
|
|
90
|
+
const e = c.current;
|
|
87
91
|
return e == null || e.addEventListener("wheel", t, { passive: !0 }), e == null || e.addEventListener("mousedown", t, !0), e == null || e.addEventListener("mousemove", t, !0), e == null || e.addEventListener("touchstart", t, { passive: !0 }), () => {
|
|
88
92
|
document.removeEventListener("keydown", n, !0), e == null || e.removeEventListener("wheel", t), e == null || e.removeEventListener("mousedown", t), e == null || e.removeEventListener("mousemove", t), e == null || e.removeEventListener("touchstart", t);
|
|
89
93
|
};
|
|
90
|
-
}, []),
|
|
94
|
+
}, []), y(() => {
|
|
91
95
|
if (!f || !u.current) return;
|
|
92
|
-
const n =
|
|
96
|
+
const n = c.current;
|
|
93
97
|
if (!n) return;
|
|
94
98
|
const t = 6, e = v.findIndex((o) => o.type === "item" && o.active);
|
|
95
99
|
if (e < 0) return;
|
|
96
|
-
const r = (o) => (n.querySelector(`[data-index="${o}"]`) || n.querySelector(`[dataindex="${o}"]`) || n.querySelector(`[dataIndex="${o}"]`)) ?? null,
|
|
97
|
-
if (!
|
|
100
|
+
const r = (o) => (n.querySelector(`[data-index="${o}"]`) || n.querySelector(`[dataindex="${o}"]`) || n.querySelector(`[dataIndex="${o}"]`)) ?? null, a = r(e);
|
|
101
|
+
if (!a) {
|
|
98
102
|
d.scrollToIndex(e, { align: "auto" }), u.current = !1;
|
|
99
103
|
return;
|
|
100
104
|
}
|
|
101
|
-
const i = n.getBoundingClientRect(), s =
|
|
105
|
+
const i = n.getBoundingClientRect(), s = a.getBoundingClientRect(), l = r(e - 1), p = r(e + 1);
|
|
102
106
|
if (p) {
|
|
103
107
|
const o = p.getBoundingClientRect();
|
|
104
108
|
if (o.bottom > i.bottom) {
|
|
@@ -106,16 +110,16 @@ import '../../assets/MenuItemsVirtual.css';const U = "_virtualScrollRef_nmoqo_1"
|
|
|
106
110
|
return;
|
|
107
111
|
}
|
|
108
112
|
}
|
|
109
|
-
if (
|
|
110
|
-
const o =
|
|
113
|
+
if (l) {
|
|
114
|
+
const o = l.getBoundingClientRect();
|
|
111
115
|
if (o.top < i.top) {
|
|
112
116
|
n.scrollTop -= i.top - o.top + t, u.current = !1;
|
|
113
117
|
return;
|
|
114
118
|
}
|
|
115
119
|
}
|
|
116
120
|
s.top < i.top + t ? n.scrollTop -= i.top + t - s.top : s.bottom > i.bottom - t && (n.scrollTop += s.bottom - (i.bottom - t)), u.current = !1;
|
|
117
|
-
}, [v, f, d]), /* @__PURE__ */
|
|
118
|
-
g && /* @__PURE__ */
|
|
121
|
+
}, [v, f, d]), /* @__PURE__ */ m(N, { children: /* @__PURE__ */ L("div", { ref: c, className: M.virtualScrollRef, style: C, children: [
|
|
122
|
+
g && /* @__PURE__ */ m(
|
|
119
123
|
"div",
|
|
120
124
|
{
|
|
121
125
|
style: {
|
|
@@ -124,10 +128,10 @@ import '../../assets/MenuItemsVirtual.css';const U = "_virtualScrollRef_nmoqo_1"
|
|
|
124
128
|
zIndex: 10,
|
|
125
129
|
marginTop: "-0.5rem"
|
|
126
130
|
},
|
|
127
|
-
children: /* @__PURE__ */
|
|
131
|
+
children: /* @__PURE__ */ m(W, { ...g })
|
|
128
132
|
}
|
|
129
133
|
),
|
|
130
|
-
/* @__PURE__ */
|
|
134
|
+
/* @__PURE__ */ m(
|
|
131
135
|
"div",
|
|
132
136
|
{
|
|
133
137
|
style: {
|
|
@@ -136,17 +140,17 @@ import '../../assets/MenuItemsVirtual.css';const U = "_virtualScrollRef_nmoqo_1"
|
|
|
136
140
|
},
|
|
137
141
|
children: h.map((n) => {
|
|
138
142
|
const t = v[n.index];
|
|
139
|
-
return t ? /* @__PURE__ */
|
|
140
|
-
|
|
143
|
+
return t ? /* @__PURE__ */ L(
|
|
144
|
+
U,
|
|
141
145
|
{
|
|
142
146
|
dataIndex: n.index,
|
|
143
|
-
className:
|
|
147
|
+
className: M.virtualMenuListItem,
|
|
144
148
|
style: { transform: `translateY(${n.start}px)` },
|
|
145
149
|
role: t.type === "separator" ? "separator" : void 0,
|
|
146
150
|
children: [
|
|
147
|
-
t.type === "title" && /* @__PURE__ */
|
|
148
|
-
t.type === "item" && /* @__PURE__ */
|
|
149
|
-
|
|
151
|
+
t.type === "title" && /* @__PURE__ */ m(j, { title: t.title }),
|
|
152
|
+
t.type === "item" && /* @__PURE__ */ m(
|
|
153
|
+
V,
|
|
150
154
|
{
|
|
151
155
|
...t.itemProps,
|
|
152
156
|
size: t.itemProps.size || P,
|
|
@@ -167,5 +171,5 @@ import '../../assets/MenuItemsVirtual.css';const U = "_virtualScrollRef_nmoqo_1"
|
|
|
167
171
|
] }) });
|
|
168
172
|
};
|
|
169
173
|
export {
|
|
170
|
-
|
|
174
|
+
se as MenuItemsVirtual
|
|
171
175
|
};
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useMemo as
|
|
1
|
+
import { jsx as E } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as K } from "react";
|
|
3
3
|
import "../index-L8X2o7IH.js";
|
|
4
|
-
import { IconButton as
|
|
4
|
+
import { IconButton as R } from "../components/Button/IconButton.js";
|
|
5
5
|
import "../components/RootProvider/RootProvider.js";
|
|
6
|
-
import { useIsDesktop as
|
|
6
|
+
import { useIsDesktop as U } from "./useIsDesktop.js";
|
|
7
7
|
import "../components/Snackbar/useSnackbar.js";
|
|
8
|
-
import { formatDisplayName as
|
|
9
|
-
import { formatDate as
|
|
10
|
-
import { S as
|
|
11
|
-
const
|
|
12
|
-
partyListDTO:
|
|
8
|
+
import { formatDisplayName as $ } from "../functions/name/name.js";
|
|
9
|
+
import { formatDate as W } from "../functions/date/date.js";
|
|
10
|
+
import { S as Y, a as q } from "../HeartFill-CYSrJ_xK.js";
|
|
11
|
+
const S = (t) => t === "Organization" ? "company" : "person", te = ({
|
|
12
|
+
partyListDTO: t = [],
|
|
13
13
|
favoriteAccountUuids: e,
|
|
14
14
|
currentAccountUuid: u,
|
|
15
|
-
selfAccountUuid:
|
|
16
|
-
isLoading:
|
|
17
|
-
onSelectAccount:
|
|
18
|
-
isVirtualized:
|
|
19
|
-
onToggleFavorite:
|
|
15
|
+
selfAccountUuid: m,
|
|
16
|
+
isLoading: f = !1,
|
|
17
|
+
onSelectAccount: _,
|
|
18
|
+
isVirtualized: h = !1,
|
|
19
|
+
onToggleFavorite: s,
|
|
20
20
|
languageCode: c
|
|
21
21
|
}) => {
|
|
22
|
-
const
|
|
23
|
-
var
|
|
24
|
-
if (
|
|
22
|
+
const r = U(), [i, b, a] = K(() => {
|
|
23
|
+
var A, N;
|
|
24
|
+
if (f || !t || !m)
|
|
25
25
|
return [[], {}, void 0];
|
|
26
|
-
const
|
|
26
|
+
const n = (o) => e == null ? void 0 : e.includes(o), l = D(c), I = t.find((o) => O(o.type) && o.partyUuid === m), z = t.filter((o) => O(o.type) && o.partyUuid !== m), B = t.filter((o) => J(o.type)), F = g(
|
|
27
27
|
c,
|
|
28
|
-
|
|
28
|
+
I,
|
|
29
29
|
"favorites",
|
|
30
30
|
u,
|
|
31
31
|
!1,
|
|
32
|
-
r,
|
|
33
32
|
s,
|
|
33
|
+
r,
|
|
34
34
|
void 0,
|
|
35
35
|
!0
|
|
36
|
-
),
|
|
37
|
-
(
|
|
36
|
+
), k = z == null ? void 0 : z.map(
|
|
37
|
+
(o) => g(
|
|
38
38
|
c,
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
o,
|
|
40
|
+
o.partyUuid,
|
|
41
41
|
u,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
n(o.partyUuid),
|
|
43
|
+
s,
|
|
44
|
+
r
|
|
45
45
|
)
|
|
46
|
-
),
|
|
47
|
-
for (const
|
|
48
|
-
const
|
|
46
|
+
), v = [];
|
|
47
|
+
for (const o of B) {
|
|
48
|
+
const d = g(
|
|
49
49
|
c,
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
o,
|
|
51
|
+
o.partyUuid,
|
|
52
52
|
u,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
n(o.partyUuid),
|
|
54
|
+
s,
|
|
55
|
+
r
|
|
56
56
|
);
|
|
57
|
-
if (
|
|
58
|
-
for (const
|
|
59
|
-
const
|
|
57
|
+
if (v.push(d), o.subunits && o.subunits.length > 0)
|
|
58
|
+
for (const P of o.subunits) {
|
|
59
|
+
const G = g(
|
|
60
60
|
c,
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
P,
|
|
62
|
+
o.partyUuid,
|
|
63
63
|
u,
|
|
64
|
-
|
|
65
|
-
r,
|
|
64
|
+
n(P.partyUuid),
|
|
66
65
|
s,
|
|
67
|
-
|
|
66
|
+
r,
|
|
67
|
+
o
|
|
68
68
|
);
|
|
69
|
-
|
|
69
|
+
v.push(G);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
const
|
|
73
|
-
[((
|
|
74
|
-
title:
|
|
72
|
+
const j = k.reduce((o, d) => (n(d.id) && o.push({ ...d, groupId: "favorites" }), o), []), H = v.reduce((o, d) => (n(d.id) && o.push({ ...d, groupId: "favorites" }), o), []), M = [...j, ...H], x = [F, ...M, ...k, ...v], V = x.find((o) => (o == null ? void 0 : o.selected) === !0), w = {
|
|
73
|
+
[((A = v[0]) == null ? void 0 : A.groupId) || "company"]: {
|
|
74
|
+
title: l.account_orgs,
|
|
75
75
|
divider: !0
|
|
76
76
|
},
|
|
77
|
-
[((
|
|
78
|
-
title:
|
|
77
|
+
[((N = k[0]) == null ? void 0 : N.groupId) || "person"]: {
|
|
78
|
+
title: l.account_persons,
|
|
79
79
|
divider: !0
|
|
80
80
|
},
|
|
81
81
|
favorites: {
|
|
82
|
-
title:
|
|
82
|
+
title: l.account_favorites,
|
|
83
83
|
divider: !0
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
|
-
return [
|
|
86
|
+
return [x, w, V];
|
|
87
87
|
}, [
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
t,
|
|
89
|
+
m,
|
|
90
90
|
e,
|
|
91
91
|
u,
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
f,
|
|
93
|
+
s,
|
|
94
94
|
c,
|
|
95
|
-
|
|
95
|
+
r
|
|
96
96
|
]);
|
|
97
|
-
return
|
|
97
|
+
return f || !t || !a ? {
|
|
98
98
|
accountMenu: {
|
|
99
99
|
items: [],
|
|
100
100
|
groups: {},
|
|
@@ -103,71 +103,73 @@ const P = (o) => o === "Organization" ? "company" : "person", ot = ({
|
|
|
103
103
|
},
|
|
104
104
|
currentAccount: void 0
|
|
105
105
|
},
|
|
106
|
-
loading:
|
|
106
|
+
loading: f
|
|
107
107
|
} : {
|
|
108
108
|
accountMenu: {
|
|
109
|
-
items:
|
|
110
|
-
groups:
|
|
111
|
-
isVirtualized:
|
|
112
|
-
onSelectAccount:
|
|
113
|
-
currentAccount:
|
|
109
|
+
items: i,
|
|
110
|
+
groups: b,
|
|
111
|
+
isVirtualized: h,
|
|
112
|
+
onSelectAccount: _,
|
|
113
|
+
currentAccount: a
|
|
114
114
|
},
|
|
115
115
|
loading: !1
|
|
116
116
|
};
|
|
117
|
-
},
|
|
118
|
-
const
|
|
119
|
-
fullName: e.name,
|
|
120
|
-
type:
|
|
121
|
-
}),
|
|
122
|
-
fullName:
|
|
123
|
-
type:
|
|
117
|
+
}, g = (t, e, u, m, f, _, h, s, c) => {
|
|
118
|
+
const r = S((e == null ? void 0 : e.type) ?? ""), i = D(t), b = $({
|
|
119
|
+
fullName: e == null ? void 0 : e.name,
|
|
120
|
+
type: r
|
|
121
|
+
}), a = s ? $({
|
|
122
|
+
fullName: s == null ? void 0 : s.name,
|
|
123
|
+
type: S((s == null ? void 0 : s.type) ?? ""),
|
|
124
124
|
reverseNameOrder: !1
|
|
125
125
|
}) : void 0;
|
|
126
|
-
let
|
|
127
|
-
const
|
|
128
|
-
switch (
|
|
126
|
+
let n = "";
|
|
127
|
+
const l = r === "company" && s ? "subunit" : r;
|
|
128
|
+
switch (l) {
|
|
129
129
|
case "company":
|
|
130
|
-
|
|
130
|
+
n = `${i.org_no}: ${e.organizationNumber}`;
|
|
131
131
|
break;
|
|
132
132
|
case "person":
|
|
133
|
-
|
|
133
|
+
n = e != null && e.dateOfBirth ? `${i.birthdate}: ${W(e == null ? void 0 : e.dateOfBirth)}` : "";
|
|
134
134
|
break;
|
|
135
135
|
case "subunit":
|
|
136
|
-
|
|
136
|
+
n = `↳ ${i.org_no}: ${e == null ? void 0 : e.organizationNumber}, ${i.subunit_of} ${a}`;
|
|
137
137
|
break;
|
|
138
|
+
default:
|
|
139
|
+
n = "";
|
|
138
140
|
}
|
|
139
141
|
return {
|
|
140
|
-
id: e.partyUuid,
|
|
142
|
+
id: e == null ? void 0 : e.partyUuid,
|
|
141
143
|
icon: {
|
|
142
|
-
name:
|
|
143
|
-
type:
|
|
144
|
-
isParent: !
|
|
145
|
-
isDeleted: e.isDeleted,
|
|
146
|
-
colorKey:
|
|
144
|
+
name: b,
|
|
145
|
+
type: r,
|
|
146
|
+
isParent: !s,
|
|
147
|
+
isDeleted: e == null ? void 0 : e.isDeleted,
|
|
148
|
+
colorKey: a ?? void 0
|
|
147
149
|
},
|
|
148
|
-
name:
|
|
149
|
-
description:
|
|
150
|
+
name: b,
|
|
151
|
+
description: n,
|
|
150
152
|
groupId: u,
|
|
151
|
-
type:
|
|
152
|
-
selected:
|
|
153
|
-
disabled: !!e.onlyHierarchyElementWithNoAccess,
|
|
154
|
-
badge: c ? { label:
|
|
155
|
-
controls: !c && /* @__PURE__ */
|
|
156
|
-
|
|
153
|
+
type: l,
|
|
154
|
+
selected: m === (e == null ? void 0 : e.partyUuid),
|
|
155
|
+
disabled: !!(e != null && e.onlyHierarchyElementWithNoAccess),
|
|
156
|
+
badge: c ? { label: i.you, color: "person" } : e.isDeleted && h ? { label: i.deleted, color: "neutral" } : void 0,
|
|
157
|
+
controls: !c && /* @__PURE__ */ E(
|
|
158
|
+
R,
|
|
157
159
|
{
|
|
158
160
|
rounded: !0,
|
|
159
161
|
variant: "text",
|
|
160
|
-
icon:
|
|
161
|
-
iconAltText:
|
|
162
|
-
onClick: (
|
|
163
|
-
|
|
162
|
+
icon: f ? Y : q,
|
|
163
|
+
iconAltText: f ? i.remove_from_favorites : i.add_to_favorites,
|
|
164
|
+
onClick: (I) => {
|
|
165
|
+
_ && (I.stopPropagation(), _(e == null ? void 0 : e.partyUuid));
|
|
164
166
|
},
|
|
165
167
|
size: "xs"
|
|
166
168
|
}
|
|
167
169
|
)
|
|
168
170
|
};
|
|
169
|
-
},
|
|
170
|
-
switch (
|
|
171
|
+
}, J = (t) => t === "Organization", O = (t) => t === "Person" || t === "SelfIdentified", D = (t) => {
|
|
172
|
+
switch (t) {
|
|
171
173
|
case "nn":
|
|
172
174
|
return {
|
|
173
175
|
account_orgs: "Virksemder",
|
|
@@ -210,5 +212,5 @@ const P = (o) => o === "Organization" ? "company" : "person", ot = ({
|
|
|
210
212
|
}
|
|
211
213
|
};
|
|
212
214
|
export {
|
|
213
|
-
|
|
215
|
+
te as useAccountSelector
|
|
214
216
|
};
|
|
@@ -18,4 +18,4 @@ export interface AccountMenuProps extends MenuProps {
|
|
|
18
18
|
scrollRefStyles?: CSSProperties;
|
|
19
19
|
keyboardEvents?: boolean;
|
|
20
20
|
}
|
|
21
|
-
export declare const AccountMenu: ({ items, groups, search, filterAccount, onSelectAccount, currentAccount, isVirtualized, keyboardEvents, }: AccountMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare const AccountMenu: ({ items, groups, search, filterAccount, onSelectAccount, currentAccount, isVirtualized, keyboardEvents, scrollRefStyles, }: AccountMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AccountMenuProps } from '..';
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: ({ items, groups, search, filterAccount, onSelectAccount, currentAccount, isVirtualized, keyboardEvents, }: AccountMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
component: ({ items, groups, search, filterAccount, onSelectAccount, currentAccount, isVirtualized, keyboardEvents, scrollRefStyles, }: AccountMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
tags: string[];
|
|
6
6
|
parameters: {};
|
|
7
7
|
args: AccountMenuProps;
|
|
@@ -25,3 +25,4 @@ export declare const ForcedFullScreenAccountSelection: () => import("react/jsx-r
|
|
|
25
25
|
export declare const WithCustomBadge: () => import("react/jsx-runtime").JSX.Element;
|
|
26
26
|
export declare const Loading: () => import("react/jsx-runtime").JSX.Element;
|
|
27
27
|
export declare const LoadingWithForcedFullScreenAccountSelection: () => import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare const WithVirtualizationEnabled: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,4 +7,4 @@ export interface MenuProps extends MenuItemsProps {
|
|
|
7
7
|
isVirtualized?: boolean;
|
|
8
8
|
keyboardEvents?: boolean;
|
|
9
9
|
}
|
|
10
|
-
export declare const Menu: ({ color, variant, defaultItemColor, defaultItemVariant, defaultItemSize, defaultIconTheme, groups, items, search, isVirtualized, keyboardEvents, }: MenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const Menu: ({ color, variant, defaultItemColor, defaultItemVariant, defaultItemSize, defaultIconTheme, groups, items, search, isVirtualized, keyboardEvents, scrollRefStyles, }: MenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StoryObj } from '@storybook/react-vite';
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: ({ color, variant, defaultItemColor, defaultItemVariant, defaultItemSize, defaultIconTheme, groups, items, search, isVirtualized, keyboardEvents, }: import('./Menu').MenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
component: ({ color, variant, defaultItemColor, defaultItemVariant, defaultItemSize, defaultIconTheme, groups, items, search, isVirtualized, keyboardEvents, scrollRefStyles, }: import('./Menu').MenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
parameters: {};
|
|
6
6
|
args: {};
|
|
7
7
|
};
|
|
@@ -23,5 +23,6 @@ export interface MenuItemsProps {
|
|
|
23
23
|
as?: ElementType;
|
|
24
24
|
keyboardEvents?: boolean;
|
|
25
25
|
onSelect?: () => void;
|
|
26
|
+
scrollRefStyles?: React.CSSProperties;
|
|
26
27
|
}
|
|
27
28
|
export declare const MenuItems: ({ level, expanded, search, items, groups, defaultItemSize, defaultItemColor, defaultItemVariant, defaultIconTheme, as, keyboardEvents, onSelect, }: MenuItemsProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { MenuItemsProps } from './MenuItems';
|
|
2
|
-
export declare const MenuItemsVirtual: ({ level, search, items, groups, defaultItemSize, defaultItemColor, defaultItemVariant, defaultIconTheme, keyboardEvents, }: MenuItemsProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const MenuItemsVirtual: ({ level, search, items, groups, defaultItemSize, defaultItemColor, defaultItemVariant, defaultIconTheme, keyboardEvents, scrollRefStyles: externalScrollRefStyles, }: MenuItemsProps) => import("react/jsx-runtime").JSX.Element;
|