@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.
@@ -1,11 +1,11 @@
1
1
  "use client";
2
- import { jsx as c } from "react/jsx-runtime";
3
- import { useState as x, useEffect as R } from "react";
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 S } from "../Menu/Menu.js";
6
+ import { Menu as j } from "../Menu/Menu.js";
7
7
  import "../Snackbar/useSnackbar.js";
8
- const j = (d) => `${d} hits`, B = ({
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] = x("");
28
- R(() => {
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 F = C || ((o, a) => {
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) => F(o, l)).map((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, b = l ? {
40
+ })) : p, I = l ? {
40
41
  search: {
41
- title: ((r = t == null ? void 0 : t.getResultsLabel) == null ? void 0 : r.call(t, n.length)) ?? j(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, I = {
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
- }, M = [
50
+ }, c = [
50
51
  ...n.length > 0 ? n : [{ id: "search", groupId: "search", hidden: !0 }]
51
52
  ];
52
- return /* @__PURE__ */ c(
53
- S,
53
+ return /* @__PURE__ */ x(
54
+ j,
54
55
  {
55
56
  variant: "default",
56
- search: t && !t.hidden ? I : void 0,
57
- groups: b,
58
- items: M,
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
- B as AccountMenu
67
+ D as AccountMenu
66
68
  };
@@ -1,16 +1,16 @@
1
1
  "use client";
2
- import { jsx as o, jsxs as O } from "react/jsx-runtime";
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 j, useEffect as z } from "react";
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 M } from "../../Heading-By5DKz2H.js";
11
+ import { H as R } from "../../Heading-By5DKz2H.js";
12
12
  import { u as _ } from "../../useId-BVFxCjkq.js";
13
- import '../../assets/AccountSelector.css';var R = function(e, i) {
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 = R(e, ["title", "titleId"]);
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
- }), B = "_accountSelector_1f74n_1", H = "_heading_1f74n_11", V = "_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: B,
50
- heading: H,
51
- searchSection: V,
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(), a = n === "accountFullscreen", [f, m] = j(""), { minimize: b, fullscreen: w, searchText: h, heading: y } = q(S);
60
- z(() => {
61
- i === !0 && !a && l("accountFullscreen");
62
- }, [i, a, l]);
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(a ? "account" : "accountFullscreen");
64
+ l(o ? "account" : "accountFullscreen");
65
65
  }, I = (d) => {
66
66
  var p;
67
- (p = e.onSelectAccount) == null || p.call(e, d), u(a ? "accountFullscreen" : "account");
67
+ (p = e.onSelectAccount) == null || p.call(e, d), u(o ? "accountFullscreen" : "account");
68
68
  };
69
- return t ? /* @__PURE__ */ o(N, { "aria-hidden": !0, "data-color": "neutral", className: c.spinner }) : /* @__PURE__ */ O("div", { className: g(r, c.accountSelector), children: [
70
- a && /* @__PURE__ */ o(M, { "data-size": "md", level: 2, className: c.heading, children: y }),
71
- /* @__PURE__ */ o("div", { className: c.searchSection, children: /* @__PURE__ */ o(
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__ */ o(
82
+ /* @__PURE__ */ a(
83
83
  "div",
84
84
  {
85
85
  className: g(
86
86
  c.accountMenu,
87
- a && c.fullScreen,
87
+ o && c.fullScreen,
88
88
  e.isVirtualized && c.virtualized
89
89
  ),
90
- children: /* @__PURE__ */ o(
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__ */ o(
102
+ i !== !0 && /* @__PURE__ */ a(
102
103
  E,
103
104
  {
104
- icon: a ? /* @__PURE__ */ o(T, { className: c.btnIcon, "aria-hidden": "true" }) : /* @__PURE__ */ o(P, { className: c.btnIcon, "aria-hidden": "true" }),
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: a ? b : w
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 s } from "./MenuBase.js";
3
- import { MenuItems as c } from "./MenuItems.js";
4
- import { MenuItemsVirtual as h } from "./MenuItemsVirtual.js";
5
- const D = ({
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: f,
15
- isVirtualized: B,
16
- keyboardEvents: j
17
- }) => B ? /* @__PURE__ */ r(s, { color: m, variant: n, children: /* @__PURE__ */ r(
18
- h,
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: f,
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: j
28
+ keyboardEvents: B,
29
+ scrollRefStyles: f
28
30
  }
29
- ) }) : /* @__PURE__ */ r(s, { color: m, variant: n, children: /* @__PURE__ */ r(
30
- c,
31
+ ) }) : /* @__PURE__ */ r(h, { color: m, variant: n, children: /* @__PURE__ */ r(
32
+ w,
31
33
  {
32
- search: f,
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: j
41
+ keyboardEvents: B,
42
+ scrollRefStyles: f
40
43
  }
41
44
  ) });
42
45
  export {
43
- D as Menu
46
+ J as Menu
44
47
  };
@@ -1,20 +1,20 @@
1
1
  "use client";
2
- import { jsx as l, jsxs as S } from "react/jsx-runtime";
3
- import { u as _ } from "../../index-D-VWMqlv.js";
4
- import { useRef as M, useState as k, useEffect as x, useMemo as A } from "react";
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 D } from "../../hooks/useMenu.js";
6
+ import { useMenu as K } from "../../hooks/useMenu.js";
7
7
  import "../RootProvider/RootProvider.js";
8
- import { MenuItem as K } from "./MenuItem.js";
9
- import { MenuSearch as V } from "./MenuSearch.js";
10
- import { MenuHeader as W } from "./MenuHeader.js";
11
- import { MenuList as j, MenuListItem as N } from "./MenuBase.js";
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 U = "_virtualScrollRef_nmoqo_1", Y = "_virtualMenuListItem_nmoqo_8", E = {
14
- virtualScrollRef: U,
15
- virtualMenuListItem: Y
16
- }, re = ({
17
- level: R = 0,
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 L;
28
- const a = M(null), y = (L = a.current) == null ? void 0 : L.getBoundingClientRect().top, [I, H] = k(window.innerHeight);
29
- x(() => {
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
- H(window.innerHeight);
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 w = A(() => y && I - y - 8 || 400, [I, y]), B = {
38
- maxHeight: w <= 300 ? 300 : w
39
- }, { menu: C } = D({
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: a
45
- }), v = C.flatMap((n, t) => {
48
+ ref: c
49
+ }), v = _.flatMap((n, t) => {
46
50
  var i;
47
- const e = (n == null ? void 0 : n.props) || {}, { title: r } = e, c = ((i = n == null ? void 0 : n.items) == null ? void 0 : i.filter((s) => {
48
- var m;
49
- return !((m = s.props) != null && m.hidden);
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 || R > 0 ? [{ type: "separator" }] : [],
56
+ ...t > 0 || E > 0 ? [{ type: "separator" }] : [],
53
57
  ...r ? [{ type: "title", title: r }] : [],
54
- ...c.map((s, m) => {
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: m === c.length - 1
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: () => a.current
73
+ getScrollElement: () => c.current
70
74
  }), h = d.getVirtualItems();
71
- x(() => {
75
+ y(() => {
72
76
  var n, t, e;
73
77
  for (const r of h) {
74
- const c = ((n = a.current) == null ? void 0 : n.querySelector(`[data-index="${r.index}"]`)) ?? ((t = a.current) == null ? void 0 : t.querySelector(`[dataindex="${r.index}"]`)) ?? ((e = a.current) == null ? void 0 : e.querySelector(`[dataIndex="${r.index}"]`));
75
- c && d.measureElement(c);
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 = M(!1);
79
- return x(() => {
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 = a.current;
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
- }, []), x(() => {
94
+ }, []), y(() => {
91
95
  if (!f || !u.current) return;
92
- const n = a.current;
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, c = r(e);
97
- if (!c) {
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 = c.getBoundingClientRect(), m = r(e - 1), p = r(e + 1);
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 (m) {
110
- const o = m.getBoundingClientRect();
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__ */ l(j, { children: /* @__PURE__ */ S("div", { ref: a, className: E.virtualScrollRef, style: B, children: [
118
- g && /* @__PURE__ */ l(
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__ */ l(V, { ...g })
131
+ children: /* @__PURE__ */ m(W, { ...g })
128
132
  }
129
133
  ),
130
- /* @__PURE__ */ l(
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__ */ S(
140
- N,
143
+ return t ? /* @__PURE__ */ L(
144
+ U,
141
145
  {
142
146
  dataIndex: n.index,
143
- className: E.virtualMenuListItem,
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__ */ l(W, { title: t.title }),
148
- t.type === "item" && /* @__PURE__ */ l(
149
- K,
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
- re as MenuItemsVirtual
174
+ se as MenuItemsVirtual
171
175
  };
@@ -1,100 +1,100 @@
1
- import { jsx as w } from "react/jsx-runtime";
2
- import { useMemo as G } from "react";
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 E } from "../components/Button/IconButton.js";
4
+ import { IconButton as R } from "../components/Button/IconButton.js";
5
5
  import "../components/RootProvider/RootProvider.js";
6
- import { useIsDesktop as K } from "./useIsDesktop.js";
6
+ import { useIsDesktop as U } from "./useIsDesktop.js";
7
7
  import "../components/Snackbar/useSnackbar.js";
8
- import { formatDisplayName as N } from "../functions/name/name.js";
9
- import { formatDate as R } from "../functions/date/date.js";
10
- import { S as U, a as W } from "../HeartFill-CYSrJ_xK.js";
11
- const P = (o) => o === "Organization" ? "company" : "person", ot = ({
12
- partyListDTO: o = [],
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: d,
16
- isLoading: a = !1,
17
- onSelectAccount: v,
18
- isVirtualized: g = !1,
19
- onToggleFavorite: r,
15
+ selfAccountUuid: m,
16
+ isLoading: f = !1,
17
+ onSelectAccount: _,
18
+ isVirtualized: h = !1,
19
+ onToggleFavorite: s,
20
20
  languageCode: c
21
21
  }) => {
22
- const s = K(), [n, _, l] = G(() => {
23
- var k, x;
24
- if (a || !o || !d)
22
+ const r = U(), [i, b, a] = K(() => {
23
+ var A, N;
24
+ if (f || !t || !m)
25
25
  return [[], {}, void 0];
26
- const i = (t) => e == null ? void 0 : e.includes(t), m = S(c), h = o.find((t) => $(t.type) && t.partyUuid === d), I = o.filter((t) => $(t.type) && t.partyUuid !== d), D = o.filter((t) => Y(t.type)), O = b(
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
- h,
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
- ), y = I == null ? void 0 : I.map(
37
- (t) => b(
36
+ ), k = z == null ? void 0 : z.map(
37
+ (o) => g(
38
38
  c,
39
- t,
40
- t.partyUuid,
39
+ o,
40
+ o.partyUuid,
41
41
  u,
42
- i(t.partyUuid),
43
- r,
44
- s
42
+ n(o.partyUuid),
43
+ s,
44
+ r
45
45
  )
46
- ), p = [];
47
- for (const t of D) {
48
- const f = b(
46
+ ), v = [];
47
+ for (const o of B) {
48
+ const d = g(
49
49
  c,
50
- t,
51
- t.partyUuid,
50
+ o,
51
+ o.partyUuid,
52
52
  u,
53
- i(t.partyUuid),
54
- r,
55
- s
53
+ n(o.partyUuid),
54
+ s,
55
+ r
56
56
  );
57
- if (p.push(f), t.subunits && t.subunits.length > 0)
58
- for (const A of t.subunits) {
59
- const V = b(
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
- A,
62
- t.partyUuid,
61
+ P,
62
+ o.partyUuid,
63
63
  u,
64
- i(A.partyUuid),
65
- r,
64
+ n(P.partyUuid),
66
65
  s,
67
- t
66
+ r,
67
+ o
68
68
  );
69
- p.push(V);
69
+ v.push(G);
70
70
  }
71
71
  }
72
- const F = y.reduce((t, f) => (i(f.id) && t.push({ ...f, groupId: "favorites" }), t), []), j = p.reduce((t, f) => (i(f.id) && t.push({ ...f, groupId: "favorites" }), t), []), B = [...F, ...j], z = [O, ...B, ...y, ...p], H = z.find((t) => (t == null ? void 0 : t.selected) === !0), M = {
73
- [((k = p[0]) == null ? void 0 : k.groupId) || "company"]: {
74
- title: m.account_orgs,
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
- [((x = y[0]) == null ? void 0 : x.groupId) || "person"]: {
78
- title: m.account_persons,
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: m.account_favorites,
82
+ title: l.account_favorites,
83
83
  divider: !0
84
84
  }
85
85
  };
86
- return [z, M, H];
86
+ return [x, w, V];
87
87
  }, [
88
- o,
89
- d,
88
+ t,
89
+ m,
90
90
  e,
91
91
  u,
92
- a,
93
- r,
92
+ f,
93
+ s,
94
94
  c,
95
- s
95
+ r
96
96
  ]);
97
- return a || !o || !l ? {
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: a
106
+ loading: f
107
107
  } : {
108
108
  accountMenu: {
109
- items: n,
110
- groups: _,
111
- isVirtualized: g,
112
- onSelectAccount: v,
113
- currentAccount: l
109
+ items: i,
110
+ groups: b,
111
+ isVirtualized: h,
112
+ onSelectAccount: _,
113
+ currentAccount: a
114
114
  },
115
115
  loading: !1
116
116
  };
117
- }, b = (o, e, u, d, a, v, g, r, c) => {
118
- const s = P((e == null ? void 0 : e.type) ?? ""), n = S(o), _ = N({
119
- fullName: e.name,
120
- type: s
121
- }), l = r ? N({
122
- fullName: r.name,
123
- type: P(r.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 i = "";
127
- const m = s === "company" && r ? "subunit" : s;
128
- switch (m) {
126
+ let n = "";
127
+ const l = r === "company" && s ? "subunit" : r;
128
+ switch (l) {
129
129
  case "company":
130
- i = `${n.org_no}: ${e.organizationNumber}`;
130
+ n = `${i.org_no}: ${e.organizationNumber}`;
131
131
  break;
132
132
  case "person":
133
- i = `${n.birthdate}: ${R(e.dateOfBirth)}`;
133
+ n = e != null && e.dateOfBirth ? `${i.birthdate}: ${W(e == null ? void 0 : e.dateOfBirth)}` : "";
134
134
  break;
135
135
  case "subunit":
136
- i = `↳ ${n.org_no}: ${e.organizationNumber}, ${n.subunit_of} ${l}`;
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: s,
144
- isParent: !r,
145
- isDeleted: e.isDeleted,
146
- colorKey: l ?? void 0
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: i,
150
+ name: b,
151
+ description: n,
150
152
  groupId: u,
151
- type: m,
152
- selected: d === e.partyUuid,
153
- disabled: !!e.onlyHierarchyElementWithNoAccess,
154
- badge: c ? { label: n.you, color: "person" } : e.isDeleted && g ? { label: n.deleted, color: "neutral" } : void 0,
155
- controls: !c && /* @__PURE__ */ w(
156
- E,
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: a ? U : W,
161
- iconAltText: a ? n.remove_from_favorites : n.add_to_favorites,
162
- onClick: (h) => {
163
- v && (h.stopPropagation(), v(e.partyUuid));
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
- }, Y = (o) => o === "Organization", $ = (o) => o === "Person", S = (o) => {
170
- switch (o) {
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
- ot as useAccountSelector
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altinn/altinn-components",
3
- "version": "0.46.3",
3
+ "version": "0.46.5",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",