@altinn/altinn-components 0.66.1 → 0.67.0

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 +1 @@
1
- ._accountSelector_stjza_1{display:flex;flex-direction:column;align-items:center;padding:1rem 0;max-width:1000px;margin:0 auto;--horizontal-padding: .7rem}._heading_stjza_11{margin-bottom:.5rem;width:100%;padding:0 var(--horizontal-padding)}._searchSection_stjza_17{position:sticky;z-index:2;top:1rem;width:100%;padding:.5rem var(--horizontal-padding);display:flex;align-items:center;gap:1rem;margin-bottom:.75rem;background-color:#fff}._searchField_stjza_30{width:50%}._accountMenu_stjza_34{height:fit-content;width:100%;overflow-y:auto;margin-bottom:1rem;padding:0 var(--horizontal-padding)}._accountMenu_stjza_34._virtualized_stjza_42{overflow-y:hidden}._btnIcon_stjza_47{font-size:1.5rem}._spinner_stjza_51{margin:auto;width:100%;overflow:hidden}@media(max-width:1023px){._accountSelector_stjza_1{--horizontal-padding: .1rem}._searchField_stjza_30{width:100%}._searchSection_stjza_17{flex-direction:column;align-items:stretch;gap:.5rem}}
1
+ ._accountSelector_ttjvg_1{display:flex;flex-direction:column;align-items:center;padding:1rem 0;max-width:1000px;margin:0 auto;--horizontal-padding: .7rem}._heading_ttjvg_11{margin-bottom:.5rem;width:100%;padding:0 var(--horizontal-padding)}._searchSection_ttjvg_17{position:sticky;z-index:2;top:0;width:100%;padding:1rem var(--horizontal-padding) .5rem;display:flex;align-items:center;gap:1rem;margin-bottom:.75rem;background-color:#fff}._searchField_ttjvg_30{width:50%}._accountMenu_ttjvg_34{height:fit-content;width:100%;overflow-y:auto;margin-bottom:1rem;padding:0 var(--horizontal-padding)}._accountMenu_ttjvg_34._virtualized_ttjvg_42{overflow-y:hidden}._btnIcon_ttjvg_47{font-size:1.5rem}._spinner_ttjvg_51{margin:auto;width:100%;overflow:hidden}@media(max-width:1023px){._accountSelector_ttjvg_1{--horizontal-padding: .1rem}._searchField_ttjvg_30{width:100%}._searchSection_ttjvg_17{flex-direction:column;align-items:stretch;gap:.5rem}}
@@ -1,96 +1,97 @@
1
- import { jsx as c, jsxs as g } from "react/jsx-runtime";
2
- import { c as p } from "../../index-p1eeF8LQ.js";
3
- import { useState as o, useRef as C, useEffect as v } from "react";
4
- import { AccountMenu as T } from "../Account/AccountMenu.js";
5
- import { r as y, H as F } from "../../tooltip-Ct39-719.js";
1
+ import { jsx as a, jsxs as p } from "react/jsx-runtime";
2
+ import { c as _ } from "../../index-p1eeF8LQ.js";
3
+ import { useState as i, useRef as R, useEffect as b } from "react";
4
+ import { AccountMenu as y } from "../Account/AccountMenu.js";
5
+ import { r as F, H as I } from "../../tooltip-Ct39-719.js";
6
6
  import "../Typography/Link.js";
7
7
  import "../Button/Button.js";
8
8
  import "react-dom";
9
- import { w as H, S as R } from "../../ToolbarSearch-DFYx6gIb.js";
9
+ import { w as E, S as M } from "../../ToolbarSearch-DFYx6gIb.js";
10
10
  import "../GlobalMenu/GlobalMenuBase.js";
11
11
  import "../Snackbar/useSnackbar.js";
12
- import { Switch as I } from "../Forms/Switch.js";
13
- import '../../assets/AccountSelector.css';const M = "_accountSelector_stjza_1", E = "_heading_stjza_11", V = "_searchSection_stjza_17", $ = "_searchField_stjza_30", K = "_accountMenu_stjza_34", O = "_virtualized_stjza_42", W = "_spinner_stjza_51", a = {
14
- accountSelector: M,
15
- heading: E,
16
- searchSection: V,
17
- searchField: $,
18
- accountMenu: K,
19
- virtualized: O,
20
- spinner: W
21
- }, ae = ({
12
+ import { Switch as O } from "../Forms/Switch.js";
13
+ import '../../assets/AccountSelector.css';const V = "_accountSelector_ttjvg_1", W = "_heading_ttjvg_11", $ = "_searchSection_ttjvg_17", K = "_searchField_ttjvg_30", U = "_accountMenu_ttjvg_34", X = "_virtualized_ttjvg_42", q = "_spinner_ttjvg_51", c = {
14
+ accountSelector: V,
15
+ heading: W,
16
+ searchSection: $,
17
+ searchField: K,
18
+ accountMenu: U,
19
+ virtualized: X,
20
+ spinner: q
21
+ }, B = 5, oe = ({
22
22
  accountMenu: e,
23
23
  forceOpenFullScreen: n,
24
24
  className: r,
25
- loading: _,
25
+ loading: A,
26
26
  showDeletedUnits: l,
27
- onShowDeletedUnitsChange: b,
28
- isFullScreen: z
27
+ onShowDeletedUnitsChange: w,
28
+ isFullScreen: x,
29
+ accountCount: j
29
30
  }) => {
30
- const { closeAll: u, languageCode: d, currentId: x } = H(), s = x === "account" || !!n, [h, m] = o(""), [j, S] = o(n), [k, w] = o(0), f = C(s);
31
- v(() => {
32
- s && !f.current && w((t) => t + 1), f.current = s;
33
- }, [s]), v(() => {
34
- !n && j && u(), S(n);
31
+ const { closeAll: u, languageCode: d, currentId: k } = E(), s = k === "account" || !!n, h = (j ?? e.items.length) > B, g = l !== void 0, [m, v] = i(""), [C, S] = i(n), [N, T] = i(0), f = R(s);
32
+ b(() => {
33
+ s && !f.current && T((t) => t + 1), f.current = s;
34
+ }, [s]), b(() => {
35
+ !n && C && u(), S(n);
35
36
  }, [n]);
36
- const { searchText: i, heading: A, switchLabel: N } = q(d), L = (t) => {
37
+ const { searchText: o, heading: z, switchLabel: L } = D(d), H = (t) => {
37
38
  e.onSelectAccount?.(t), u(), S(!1);
38
39
  };
39
- return _ ? /* @__PURE__ */ c(y, { "aria-hidden": !0, "data-color": "neutral", className: a.spinner }) : /* @__PURE__ */ g("div", { className: p(r, a.accountSelector), children: [
40
- /* @__PURE__ */ c(F, { "data-size": "sm", level: 2, className: a.heading, id: "account-selector-heading", children: A }),
41
- /* @__PURE__ */ g("div", { className: a.searchSection, children: [
42
- /* @__PURE__ */ c(
43
- R,
40
+ return A ? /* @__PURE__ */ a(F, { "aria-hidden": !0, "data-color": "neutral", className: c.spinner }) : /* @__PURE__ */ p("div", { className: _(r, c.accountSelector), children: [
41
+ /* @__PURE__ */ a(I, { "data-size": "sm", level: 2, className: c.heading, id: "account-selector-heading", children: z }),
42
+ (h || g) && /* @__PURE__ */ p("div", { className: c.searchSection, children: [
43
+ h && /* @__PURE__ */ a(
44
+ M,
44
45
  {
45
46
  size: "sm",
46
47
  "aria-labelledby": "account-selector-heading",
47
- label: i,
48
+ label: o,
48
49
  hideLabel: !0,
49
- name: i,
50
- placeholder: i,
51
- value: h,
52
- onChange: (t) => m(t.target.value),
53
- onClear: () => m(""),
54
- className: a.searchField
50
+ name: o,
51
+ placeholder: o,
52
+ value: m,
53
+ onChange: (t) => v(t.target.value),
54
+ onClear: () => v(""),
55
+ className: c.searchField
55
56
  }
56
57
  ),
57
- l !== void 0 && /* @__PURE__ */ c(
58
- I,
58
+ g && /* @__PURE__ */ a(
59
+ O,
59
60
  {
60
61
  size: "sm",
61
62
  checked: l,
62
- onChange: (t) => b?.(t.target.checked),
63
- label: N
63
+ onChange: (t) => w?.(t.target.checked),
64
+ label: L
64
65
  }
65
66
  )
66
67
  ] }),
67
- /* @__PURE__ */ c(
68
+ /* @__PURE__ */ a(
68
69
  "div",
69
70
  {
70
- className: p(
71
- a.accountMenu,
72
- z && a.fullScreen,
73
- e.virtualized && a.virtualized
71
+ className: _(
72
+ c.accountMenu,
73
+ x && c.fullScreen,
74
+ e.virtualized && c.virtualized
74
75
  ),
75
- children: /* @__PURE__ */ c(
76
- T,
76
+ children: /* @__PURE__ */ a(
77
+ y,
77
78
  {
78
79
  ...e,
79
- onSelectAccount: L,
80
+ onSelectAccount: H,
80
81
  keyboardEvents: !1,
81
82
  search: {
82
83
  hidden: !0,
83
84
  name: "",
84
- value: h,
85
- getResultsLabel: (t) => B(t, d)
85
+ value: m,
86
+ getResultsLabel: (t) => G(t, d)
86
87
  }
87
88
  },
88
- k
89
+ N
89
90
  )
90
91
  }
91
92
  )
92
93
  ] });
93
- }, q = (e) => {
94
+ }, D = (e) => {
94
95
  switch (e) {
95
96
  case "nn":
96
97
  return {
@@ -111,10 +112,10 @@ import '../../assets/AccountSelector.css';const M = "_accountSelector_stjza_1",
111
112
  switchLabel: "Vis slettede"
112
113
  };
113
114
  }
114
- }, B = (e, n) => {
115
+ }, G = (e, n) => {
115
116
  const r = n === "nb" || n === "nn";
116
117
  return e === 0 ? r ? "Ingen treff" : "No hits" : r ? `${e} treff` : e === 1 ? "1 hit" : `${e} hits`;
117
118
  };
118
119
  export {
119
- ae as AccountSelector
120
+ oe as AccountSelector
120
121
  };
@@ -3,13 +3,13 @@ import { jsx as n, jsxs as i, Fragment as O } from "react/jsx-runtime";
3
3
  import { useState as v } from "react";
4
4
  import { useIsDesktop as F } from "../../hooks/useIsDesktop.js";
5
5
  import { AccountSelector as b } from "../AccountSelector/AccountSelector.js";
6
- import { GlobalMenu as w } from "../GlobalMenu/GlobalMenu.js";
6
+ import { GlobalMenu as C } from "../GlobalMenu/GlobalMenu.js";
7
7
  import "../../index-p1eeF8LQ.js";
8
8
  import "../../tooltip-Ct39-719.js";
9
9
  import "../Typography/Link.js";
10
10
  import "../Button/Button.js";
11
11
  import "react-dom";
12
- import { w as C } from "../../ToolbarSearch-DFYx6gIb.js";
12
+ import { w } from "../../ToolbarSearch-DFYx6gIb.js";
13
13
  import { GlobalMenuButton as D } from "./GlobalMenuButton.js";
14
14
  import { GlobalAccountButton as M } from "./GlobalAccountButton.js";
15
15
  import "../Snackbar/useSnackbar.js";
@@ -31,11 +31,11 @@ import '../../assets/GlobalHeader.css';const T = "_header_17ppp_1", k = "_contai
31
31
  badge: f,
32
32
  onLoginClick: g
33
33
  }) => {
34
- const { currentId: o, toggleId: l, closeAll: a } = C(), h = () => {
34
+ const { currentId: o, toggleId: l, closeAll: a } = w(), h = () => {
35
35
  o !== "account" && window.scrollTo({ top: 0, behavior: "instant" }), l("account");
36
36
  }, _ = () => {
37
37
  l("menu");
38
- }, c = o === "account" || e?.forceOpenFullScreen || !1, [p, x] = v(!1), A = F();
38
+ }, p = o === "account" || e?.forceOpenFullScreen || !1, [c, x] = v(!1), A = F();
39
39
  return /* @__PURE__ */ n("header", { className: t.header, "data-current-id": o, children: /* @__PURE__ */ n("div", { className: t.container, children: /* @__PURE__ */ i("nav", { className: t.nav, "aria-label": "hovednavigasjon", children: [
40
40
  /* @__PURE__ */ n(I, { ...u, badge: f, className: t.logo }),
41
41
  e && /* @__PURE__ */ i(O, { children: [
@@ -44,7 +44,7 @@ import '../../assets/GlobalHeader.css';const T = "_header_17ppp_1", k = "_contai
44
44
  {
45
45
  currentAccount: e.accountMenu?.currentAccount,
46
46
  onClick: e.accountMenu?.currentAccount ? h : g,
47
- expanded: c,
47
+ expanded: p,
48
48
  loading: e.loading,
49
49
  disabled: e.forceOpenFullScreen
50
50
  }
@@ -53,12 +53,12 @@ import '../../assets/GlobalHeader.css';const T = "_header_17ppp_1", k = "_contai
53
53
  N,
54
54
  {
55
55
  id: "header-account",
56
- open: c,
56
+ open: p,
57
57
  onClose: a,
58
58
  closedBy: e?.forceOpenFullScreen ? "none" : "any",
59
- expanded: e?.forceOpenFullScreen || p,
60
- onToggle: () => x(!p),
61
- expandable: e.accountMenu.items.length > H,
59
+ expanded: e?.forceOpenFullScreen || c,
60
+ onToggle: () => x(!c),
61
+ expandable: (e.accountCount ?? e.accountMenu.items.length) > H,
62
62
  children: /* @__PURE__ */ n(b, { ...e, forceOpenFullScreen: e.forceOpenFullScreen })
63
63
  }
64
64
  )
@@ -79,7 +79,7 @@ import '../../assets/GlobalHeader.css';const T = "_header_17ppp_1", k = "_contai
79
79
  }
80
80
  ),
81
81
  children: /* @__PURE__ */ n(
82
- w,
82
+ C,
83
83
  {
84
84
  ...r,
85
85
  menu: A ? s || r?.menu : d || r?.menu,
@@ -1,112 +1,118 @@
1
- import { jsx as S } from "react/jsx-runtime";
2
- import { useRef as x, useMemo as z } from "react";
1
+ import { jsx as F } from "react/jsx-runtime";
2
+ import { useRef as R, useMemo as h } from "react";
3
3
  import "../index-p1eeF8LQ.js";
4
4
  import "../tooltip-Ct39-719.js";
5
5
  import "../ToolbarSearch-DFYx6gIb.js";
6
6
  import "../components/Typography/Link.js";
7
- import { Button as G } from "../components/Button/Button.js";
7
+ import { Button as q } from "../components/Button/Button.js";
8
8
  import "react-dom";
9
- import { useIsDesktop as Y } from "./useIsDesktop.js";
9
+ import { useIsDesktop as J } from "./useIsDesktop.js";
10
10
  import "../components/GlobalMenu/GlobalMenuBase.js";
11
11
  import "../components/Snackbar/useSnackbar.js";
12
- import { formatDisplayName as R } from "../functions/name/name.js";
13
- import { formatDate as q } from "../functions/date/date.js";
14
- import { formatOrgNo as j } from "../functions/orgno/orgno.js";
15
- import { a as J, S as K } from "../HeartFill-CbQmSZr5.js";
16
- const H = (o) => o === "Organization" ? "company" : "person", dt = ({
17
- partyListDTO: o = [],
18
- favoriteAccountUuids: e,
12
+ import { formatDisplayName as j } from "../functions/name/name.js";
13
+ import { formatDate as K } from "../functions/date/date.js";
14
+ import { formatOrgNo as w } from "../functions/orgno/orgno.js";
15
+ import { a as Q, S as X } from "../HeartFill-CbQmSZr5.js";
16
+ const H = (e) => e === "Organization" ? "company" : "person", pt = ({
17
+ partyListDTO: e = [],
18
+ favoriteAccountUuids: o,
19
19
  currentAccountUuid: f,
20
- selfAccountUuid: m,
21
- isLoading: d = !1,
20
+ selfAccountUuid: d,
21
+ isLoading: m = !1,
22
22
  onSelectAccount: N,
23
23
  virtualized: p = !1,
24
- onToggleFavorite: h,
25
- languageCode: n,
26
- showDeletedUnits: i,
27
- onShowDeletedUnitsChange: _
24
+ onToggleFavorite: I,
25
+ languageCode: s,
26
+ showDeletedUnits: c,
27
+ onShowDeletedUnitsChange: g
28
28
  }) => {
29
- const v = Y(), c = x(h);
30
- c.current = h;
31
- const g = x(f);
32
- g.current = f;
33
- const y = z(() => {
34
- if (!o || o.length === 0) return [];
35
- const a = n || "nb", s = (r, l) => r.name.localeCompare(l.name, a, {
29
+ const v = J(), u = R(I);
30
+ u.current = I;
31
+ const _ = R(f);
32
+ _.current = f;
33
+ const y = h(() => {
34
+ if (!e || e.length === 0) return [];
35
+ const i = s || "nb", r = (n, l) => n.name.localeCompare(l.name, i, {
36
36
  sensitivity: "base",
37
37
  ignorePunctuation: !0
38
38
  });
39
- return [...o].sort(s);
40
- }, [o, n]), [O, V] = z(() => {
41
- if (d || !y.length || !m)
39
+ return [...e].sort(r);
40
+ }, [e, s]), $ = h(
41
+ () => e.some((i) => i.isDeleted || i.subunits?.some((r) => r.isDeleted)),
42
+ [e]
43
+ ), V = h(
44
+ () => e.reduce((i, r) => i + 1 + (r.subunits?.length ?? 0), 0),
45
+ [e]
46
+ ), [D, W] = h(() => {
47
+ if (m || !y.length || !d)
42
48
  return [
43
49
  { selfAccountItem: void 0, peopleAccountItems: [], organizationAccountItems: [], favoriteAccountItems: [] },
44
50
  {}
45
51
  ];
46
- const a = new Set(e), s = (t) => a.has(t), r = (t) => !t.isDeleted || i !== !1 || t.partyUuid === g.current, l = M(n), I = n || "nb", w = (t, u) => t.name.localeCompare(u.name, I, {
52
+ const i = new Set(o), r = (t) => i.has(t), n = (t) => !t.isDeleted || c !== !1 || t.partyUuid === _.current, l = M(s), A = s || "nb", G = (t, a) => t.name.localeCompare(a.name, A, {
47
53
  sensitivity: "base",
48
54
  ignorePunctuation: !0
49
55
  });
50
- let B;
51
- const k = [], A = [], U = [];
56
+ let x;
57
+ const k = [], U = [], S = [];
52
58
  for (const t of y)
53
- if (X(t.type)) {
54
- if (t.partyUuid === m)
55
- B = F(
56
- n,
59
+ if (T(t.type)) {
60
+ if (t.partyUuid === d)
61
+ x = z(
62
+ s,
57
63
  t,
58
64
  "favorites",
59
65
  !1,
60
- c,
66
+ u,
61
67
  v,
62
68
  void 0,
63
69
  !0
64
70
  );
65
- else if (r(t) || s(t.partyUuid)) {
66
- const u = F(
67
- n,
71
+ else if (n(t) || r(t.partyUuid)) {
72
+ const a = z(
73
+ s,
68
74
  t,
69
75
  t.partyUuid,
70
- s(t.partyUuid),
71
- c,
76
+ r(t.partyUuid),
77
+ u,
72
78
  v
73
79
  );
74
- k.push(u), s(t.partyUuid) && U.push({ ...u, groupId: "favorites" });
80
+ k.push(a), r(t.partyUuid) && S.push({ ...a, groupId: "favorites" });
75
81
  }
76
- } else if (T(t.type)) {
77
- if (r(t) || s(t.partyUuid)) {
78
- const u = F(
79
- n,
82
+ } else if (C(t.type)) {
83
+ if (n(t) || r(t.partyUuid)) {
84
+ const a = z(
85
+ s,
80
86
  t,
81
87
  t.partyUuid,
82
- s(t.partyUuid),
83
- c,
88
+ r(t.partyUuid),
89
+ u,
84
90
  v
85
91
  );
86
- r(t) && A.push(u), s(t.partyUuid) && U.push({ ...u, groupId: "favorites" });
92
+ n(t) && U.push(a), r(t.partyUuid) && S.push({ ...a, groupId: "favorites" });
87
93
  }
88
94
  if (t.subunits && t.subunits.length > 0) {
89
- const u = [...t.subunits].sort(w);
90
- for (const b of u)
91
- if (r(b) || s(b.partyUuid)) {
92
- const D = F(
93
- n,
95
+ const a = [...t.subunits].sort(G);
96
+ for (const b of a)
97
+ if (n(b) || r(b.partyUuid)) {
98
+ const O = z(
99
+ s,
94
100
  b,
95
101
  t.partyUuid,
96
- s(b.partyUuid),
97
- c,
102
+ r(b.partyUuid),
103
+ u,
98
104
  v,
99
105
  t
100
106
  );
101
- r(b) && A.push(D), s(b.partyUuid) && U.push({
102
- ...D,
107
+ n(b) && U.push(O), r(b.partyUuid) && S.push({
108
+ ...O,
103
109
  groupId: "favorites"
104
110
  });
105
111
  }
106
112
  }
107
113
  }
108
- const E = {
109
- [A[0]?.groupId || "company"]: {
114
+ const Y = {
115
+ [U[0]?.groupId || "company"]: {
110
116
  title: l.account_orgs,
111
117
  divider: !0
112
118
  },
@@ -119,23 +125,23 @@ const H = (o) => o === "Organization" ? "company" : "person", dt = ({
119
125
  divider: !0
120
126
  }
121
127
  };
122
- return [{ selfAccountItem: B, peopleAccountItems: k, organizationAccountItems: A, favoriteAccountItems: U }, E];
123
- }, [y, m, e, d, n, v, i]), P = z(() => {
124
- const { selfAccountItem: a, peopleAccountItems: s, organizationAccountItems: r, favoriteAccountItems: l } = O;
125
- return a ? [a, ...l, ...s, ...r] : [];
126
- }, [O]), [W, $] = z(() => {
128
+ return [{ selfAccountItem: x, peopleAccountItems: k, organizationAccountItems: U, favoriteAccountItems: S }, Y];
129
+ }, [y, d, o, m, s, v, c]), P = h(() => {
130
+ const { selfAccountItem: i, peopleAccountItems: r, organizationAccountItems: n, favoriteAccountItems: l } = D;
131
+ return i ? [i, ...l, ...r, ...n] : [];
132
+ }, [D]), [E, B] = h(() => {
127
133
  if (P.length === 0)
128
134
  return [[], void 0];
129
- let a;
130
- return [P.map((r) => {
131
- if (f === r.id) {
132
- const I = { ...r, selected: !0 };
133
- return a = I, I;
135
+ let i;
136
+ return [P.map((n) => {
137
+ if (f === n.id) {
138
+ const A = { ...n, selected: !0 };
139
+ return i = A, A;
134
140
  }
135
- return r.selected ? { ...r, selected: !1 } : r;
136
- }), a];
141
+ return n.selected ? { ...n, selected: !1 } : n;
142
+ }), i];
137
143
  }, [P, f]);
138
- return d || !o || !$ ? {
144
+ return m || !e || !B ? {
139
145
  accountMenu: {
140
146
  items: [],
141
147
  groups: {},
@@ -144,89 +150,90 @@ const H = (o) => o === "Organization" ? "company" : "person", dt = ({
144
150
  },
145
151
  currentAccount: void 0
146
152
  },
147
- loading: d
153
+ loading: m
148
154
  } : {
149
155
  accountMenu: {
150
- items: W,
151
- groups: V,
156
+ items: E,
157
+ groups: W,
152
158
  virtualized: p,
153
159
  onSelectAccount: N,
154
- currentAccount: $
160
+ currentAccount: B
155
161
  },
156
162
  loading: !1,
157
- showDeletedUnits: i,
158
- onShowDeletedUnitsChange: _
163
+ showDeletedUnits: $ ? c : void 0,
164
+ onShowDeletedUnitsChange: $ ? g : void 0,
165
+ accountCount: V
159
166
  };
160
- }, Q = ({
161
- partyUuid: o,
162
- isFavorite: e,
167
+ }, Z = ({
168
+ partyUuid: e,
169
+ isFavorite: o,
163
170
  toggleFavoriteRef: f,
164
- texts: m
165
- }) => /* @__PURE__ */ S(
166
- G,
171
+ texts: d
172
+ }) => /* @__PURE__ */ F(
173
+ q,
167
174
  {
168
175
  rounded: !0,
169
176
  variant: "ghost",
170
- "aria-label": e ? m.remove_from_favorites : m.add_to_favorites,
171
- onClick: (d) => {
172
- d.stopPropagation(), f?.current?.(o);
177
+ "aria-label": o ? d.remove_from_favorites : d.add_to_favorites,
178
+ onClick: (m) => {
179
+ m.stopPropagation(), f?.current?.(e);
173
180
  },
174
181
  size: "xs",
175
- children: e ? /* @__PURE__ */ S(J, {}) : /* @__PURE__ */ S(K, {})
182
+ children: o ? /* @__PURE__ */ F(Q, {}) : /* @__PURE__ */ F(X, {})
176
183
  }
177
- ), F = (o, e, f, m, d, N, p, h) => {
178
- const n = H(e?.type ?? ""), i = M(o), _ = R({
179
- fullName: e?.name,
180
- type: n
181
- }), v = p ? R({
184
+ ), z = (e, o, f, d, m, N, p, I) => {
185
+ const s = H(o?.type ?? ""), c = M(e), g = j({
186
+ fullName: o?.name,
187
+ type: s
188
+ }), v = p ? j({
182
189
  fullName: p?.name,
183
190
  type: H(p?.type ?? ""),
184
191
  reverseNameOrder: !1
185
192
  }) : void 0;
186
- let c = "";
187
- const g = n === "company" && p ? "subunit" : n;
188
- switch (g) {
193
+ let u = "";
194
+ const _ = s === "company" && p ? "subunit" : s;
195
+ switch (_) {
189
196
  case "company":
190
- c = `${i.org_no}. ${j(e.organizationNumber)}`;
197
+ u = `${c.org_no}. ${w(o.organizationNumber)}`;
191
198
  break;
192
199
  case "person":
193
- c = e?.dateOfBirth ? `${i.birthdate}: ${q(e?.dateOfBirth)}` : "";
200
+ u = o?.dateOfBirth ? `${c.birthdate}: ${K(o?.dateOfBirth)}` : "";
194
201
  break;
195
202
  case "subunit":
196
- c = `↳ ${i.org_no}. ${j(e?.organizationNumber)}, ${i.subunit_of} ${v}`;
203
+ u = `↳ ${c.org_no}. ${w(o?.organizationNumber)}, ${c.subunit_of} ${v}`;
197
204
  break;
198
205
  default:
199
- c = "";
206
+ u = "";
200
207
  }
201
- const y = h ? void 0 : /* @__PURE__ */ S(
202
- Q,
208
+ const y = I ? void 0 : /* @__PURE__ */ F(
209
+ Z,
203
210
  {
204
- partyUuid: e?.partyUuid,
205
- isFavorite: m,
206
- toggleFavoriteRef: d,
207
- texts: i
211
+ partyUuid: o?.partyUuid,
212
+ isFavorite: d,
213
+ toggleFavoriteRef: m,
214
+ texts: c
208
215
  }
209
216
  );
210
217
  return {
211
- id: e?.partyUuid,
218
+ id: o?.partyUuid,
212
219
  icon: {
213
- name: _,
214
- type: n,
220
+ name: g,
221
+ type: s,
215
222
  isParent: !p,
216
- isDeleted: e?.isDeleted
223
+ isDeleted: o?.isDeleted
217
224
  },
218
- name: _,
219
- description: c,
220
- searchWords: g === "person" ? [_, e?.dateOfBirth ?? ""] : [_, e?.organizationNumber ?? ""],
225
+ name: g,
226
+ description: u,
227
+ searchWords: _ === "person" ? [g, o?.dateOfBirth ?? ""] : [g, o?.organizationNumber ?? ""],
221
228
  groupId: f,
222
- type: g,
229
+ type: _,
223
230
  selected: !1,
224
- disabled: !!e?.onlyHierarchyElementWithNoAccess,
225
- badge: h ? { label: i.you, color: "person" } : e.isDeleted && N ? { label: i.deleted, color: "neutral" } : void 0,
231
+ disabled: !!o?.onlyHierarchyElementWithNoAccess,
232
+ badge: I ? { label: c.you, color: "person" } : o.isDeleted && N ? { label: c.deleted, color: "neutral" } : void 0,
226
233
  controls: y
227
234
  };
228
- }, T = (o) => o === "Organization", X = (o) => o === "Person" || o === "SelfIdentified", M = (o) => {
229
- switch (o) {
235
+ }, C = (e) => e === "Organization", T = (e) => e === "Person" || e === "SelfIdentified", M = (e) => {
236
+ switch (e) {
230
237
  case "nn":
231
238
  return {
232
239
  account_orgs: "Virksemder",
@@ -269,5 +276,5 @@ const H = (o) => o === "Organization" ? "company" : "person", dt = ({
269
276
  }
270
277
  };
271
278
  export {
272
- dt as useAccountSelector
279
+ pt as useAccountSelector
273
280
  };
@@ -13,5 +13,13 @@ export interface AccountSelectorProps {
13
13
  onShowDeletedUnitsChange?: (newValue: boolean) => void;
14
14
  /** Show in fullscreen*/
15
15
  isFullScreen?: boolean;
16
+ /**
17
+ * Total number of accounts the user has, including deleted ones. Used to
18
+ * decide whether to show the search field, so the decision stays stable when
19
+ * the user toggles deleted accounts on/off (toggling only changes how many
20
+ * accounts are currently listed, not how many the user actually has).
21
+ * Falls back to the number of currently listed accounts when not provided.
22
+ */
23
+ accountCount?: number;
16
24
  }
17
- export declare const AccountSelector: ({ accountMenu, forceOpenFullScreen, className, loading, showDeletedUnits, onShowDeletedUnitsChange, isFullScreen, }: AccountSelectorProps) => import("react/jsx-runtime").JSX.Element;
25
+ export declare const AccountSelector: ({ accountMenu, forceOpenFullScreen, className, loading, showDeletedUnits, onShowDeletedUnitsChange, isFullScreen, accountCount, }: AccountSelectorProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { AccountSelectorProps } from './AccountSelector';
2
2
  declare const meta: {
3
3
  title: string;
4
- component: ({ accountMenu, forceOpenFullScreen, className, loading, showDeletedUnits, onShowDeletedUnitsChange, isFullScreen, }: AccountSelectorProps) => import("react/jsx-runtime").JSX.Element;
4
+ component: ({ accountMenu, forceOpenFullScreen, className, loading, showDeletedUnits, onShowDeletedUnitsChange, isFullScreen, accountCount, }: AccountSelectorProps) => import("react/jsx-runtime").JSX.Element;
5
5
  tags: string[];
6
6
  parameters: {
7
7
  layout: string;
@@ -27,3 +27,8 @@ export default meta;
27
27
  export declare const WithAccounts: (args: AccountSelectorProps) => import("react/jsx-runtime").JSX.Element;
28
28
  export declare const NoAccounts: (args: AccountSelectorProps) => import("react/jsx-runtime").JSX.Element;
29
29
  export declare const Loading: (args: AccountSelectorProps) => import("react/jsx-runtime").JSX.Element;
30
+ export declare const UsingUseAccountHook: (args: AccountSelectorProps) => import("react/jsx-runtime").JSX.Element;
31
+ export declare const ThreeAccounts: (args: AccountSelectorProps) => import("react/jsx-runtime").JSX.Element;
32
+ export declare const FourAccountsOneDeleted: (args: AccountSelectorProps) => import("react/jsx-runtime").JSX.Element;
33
+ export declare const SixAccountsThreeDeleted: (args: AccountSelectorProps) => import("react/jsx-runtime").JSX.Element;
34
+ export declare const TenAccountsNoneDeleted: (args: AccountSelectorProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,49 @@
1
+ import { LayoutProps } from '../';
2
+ interface LayoutStoryArgs extends LayoutProps {
3
+ forceOpenFullScreen?: boolean | undefined;
4
+ }
5
+ /**
6
+ * AccountSelector demos rendered inside a full Layout, so you can see how the
7
+ * selector behaves alongside the header, sidebar and global menu. The same
8
+ * cases are available as standalone-component stories under Layout/AccountSelector.
9
+ */
10
+ declare const meta: {
11
+ title: string;
12
+ component: ({ banner, color, theme, header, footer, sidebar, content, children, skipLink, breadcrumbs, }: LayoutProps) => import("react/jsx-runtime").JSX.Element;
13
+ parameters: {
14
+ layout: string;
15
+ };
16
+ args: {
17
+ theme: "subtle";
18
+ skipLink: {
19
+ href: string;
20
+ color: import('..').Color;
21
+ size: import('..').Size;
22
+ children: string;
23
+ };
24
+ header: import('..').GlobalHeaderProps;
25
+ footer: import('..').FooterProps;
26
+ sidebar: {
27
+ menu: import('..').MenuProps;
28
+ };
29
+ children: import("react/jsx-runtime").JSX.Element;
30
+ color: "company";
31
+ forceOpenFullScreen: undefined;
32
+ };
33
+ argTypes: {
34
+ color: {
35
+ control: "select";
36
+ options: string[];
37
+ };
38
+ forceOpenFullScreen: {
39
+ control: "select";
40
+ options: (boolean | undefined)[];
41
+ };
42
+ };
43
+ };
44
+ export default meta;
45
+ export declare const UsingUseAccountHook: (args: LayoutStoryArgs) => import("react/jsx-runtime").JSX.Element;
46
+ export declare const ThreeAccounts: (args: LayoutStoryArgs) => import("react/jsx-runtime").JSX.Element;
47
+ export declare const FourAccountsOneDeleted: (args: LayoutStoryArgs) => import("react/jsx-runtime").JSX.Element;
48
+ export declare const SixAccountsThreeDeleted: (args: LayoutStoryArgs) => import("react/jsx-runtime").JSX.Element;
49
+ export declare const TenAccountsNoneDeleted: (args: LayoutStoryArgs) => import("react/jsx-runtime").JSX.Element;
@@ -38,7 +38,6 @@ declare const meta: {
38
38
  };
39
39
  export default meta;
40
40
  export declare const Preview: (args: LayoutStoryArgs) => import("react/jsx-runtime").JSX.Element;
41
- export declare const UsingUseAccountHook: (args: LayoutStoryArgs) => import("react/jsx-runtime").JSX.Element;
42
41
  export declare const LogInView: (args: LayoutStoryArgs) => import("react/jsx-runtime").JSX.Element;
43
42
  export declare const WithEnglishLanguage: (args: LayoutStoryArgs) => import("react/jsx-runtime").JSX.Element;
44
43
  export declare const StickySidebar: (args: LayoutStoryArgs) => 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.66.1",
3
+ "version": "0.67.0",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",