@altinn/altinn-components 0.68.10 → 0.68.15
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,147 +1,145 @@
|
|
|
1
1
|
import { jsx as F } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as
|
|
2
|
+
import { useRef as O, useMemo as v } from "react";
|
|
3
3
|
import "../index-p1eeF8LQ.js";
|
|
4
4
|
import "../tooltip-Caqi75cv.js";
|
|
5
5
|
import "../ToolbarSearch-BWqWKrm-.js";
|
|
6
6
|
import "../components/Typography/Link.js";
|
|
7
|
-
import { Button as
|
|
7
|
+
import { Button as Q } from "../components/Button/Button.js";
|
|
8
8
|
import "react-dom";
|
|
9
|
-
import { useIsDesktop as
|
|
9
|
+
import { useIsDesktop as X } from "./useIsDesktop.js";
|
|
10
10
|
import "../components/GlobalMenu/GlobalMenuBase.js";
|
|
11
11
|
import "../components/Snackbar/useSnackbar.js";
|
|
12
|
-
import { formatDisplayName as
|
|
13
|
-
import { formatDate as
|
|
14
|
-
import { formatOrgNo as
|
|
15
|
-
import { a as
|
|
16
|
-
const
|
|
12
|
+
import { formatDisplayName as R } from "../functions/name/name.js";
|
|
13
|
+
import { formatDate as Z } from "../functions/date/date.js";
|
|
14
|
+
import { formatOrgNo as H } from "../functions/orgno/orgno.js";
|
|
15
|
+
import { a as C, S as T } from "../HeartFill-CbQmSZr5.js";
|
|
16
|
+
const V = (e) => e === "Organization" ? "company" : "person", W = /* @__PURE__ */ new Map(), E = (e) => {
|
|
17
|
+
const o = e || "nb";
|
|
18
|
+
let i = W.get(o);
|
|
19
|
+
return i || (i = new Intl.Collator(o, { sensitivity: "base", ignorePunctuation: !0 }), W.set(o, i)), i;
|
|
20
|
+
}, _t = ({
|
|
17
21
|
partyListDTO: e = [],
|
|
18
22
|
favoriteAccountUuids: o,
|
|
19
|
-
currentAccountUuid:
|
|
20
|
-
selfAccountUuid:
|
|
21
|
-
isLoading:
|
|
23
|
+
currentAccountUuid: i,
|
|
24
|
+
selfAccountUuid: l,
|
|
25
|
+
isLoading: d = !1,
|
|
22
26
|
onSelectAccount: N,
|
|
23
|
-
virtualized:
|
|
24
|
-
onToggleFavorite:
|
|
25
|
-
languageCode:
|
|
26
|
-
showDeletedUnits:
|
|
27
|
+
virtualized: m = !1,
|
|
28
|
+
onToggleFavorite: h,
|
|
29
|
+
languageCode: n,
|
|
30
|
+
showDeletedUnits: a,
|
|
27
31
|
onShowDeletedUnitsChange: g
|
|
28
32
|
}) => {
|
|
29
|
-
const
|
|
30
|
-
u.current =
|
|
31
|
-
const _ =
|
|
32
|
-
_.current =
|
|
33
|
-
const
|
|
33
|
+
const p = X(), u = O(h);
|
|
34
|
+
u.current = h;
|
|
35
|
+
const _ = O(i);
|
|
36
|
+
_.current = i;
|
|
37
|
+
const I = v(() => {
|
|
34
38
|
if (!e || e.length === 0) return [];
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return [...e].sort(r);
|
|
40
|
-
}, [e, s]), $ = h(
|
|
41
|
-
() => e.some((i) => i.isDeleted || i.subunits?.some((r) => r.isDeleted)),
|
|
39
|
+
const r = E(n);
|
|
40
|
+
return [...e].sort((s, c) => r.compare(s.name, c.name));
|
|
41
|
+
}, [e, n]), D = v(
|
|
42
|
+
() => e.some((r) => r.isDeleted || r.subunits?.some((s) => s.isDeleted)),
|
|
42
43
|
[e]
|
|
43
|
-
),
|
|
44
|
-
() => e.reduce((
|
|
44
|
+
), K = v(
|
|
45
|
+
() => e.reduce((r, s) => r + 1 + (s.subunits?.length ?? 0), 0),
|
|
45
46
|
[e]
|
|
46
|
-
), [
|
|
47
|
-
if (
|
|
47
|
+
), P = o?.join(",") ?? "", B = v(() => new Set(P ? P.split(",") : []), [P]), [w, Y] = v(() => {
|
|
48
|
+
if (d || !I.length || !l)
|
|
48
49
|
return [
|
|
49
50
|
{ selfAccountItem: void 0, peopleAccountItems: [], organizationAccountItems: [], favoriteAccountItems: [] },
|
|
50
51
|
{}
|
|
51
52
|
];
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (t.partyUuid === d)
|
|
61
|
-
x = z(
|
|
62
|
-
s,
|
|
53
|
+
const r = (t) => B.has(t), s = (t) => !t.isDeleted || a !== !1 || t.partyUuid === _.current, c = G(n), y = E(n), A = (t, f) => y.compare(t.name, f.name);
|
|
54
|
+
let j;
|
|
55
|
+
const $ = [], U = [], S = [];
|
|
56
|
+
for (const t of I)
|
|
57
|
+
if (et(t.type)) {
|
|
58
|
+
if (t.partyUuid === l)
|
|
59
|
+
j = z(
|
|
60
|
+
n,
|
|
63
61
|
t,
|
|
64
62
|
"favorites",
|
|
65
63
|
!1,
|
|
66
64
|
u,
|
|
67
|
-
|
|
65
|
+
p,
|
|
68
66
|
void 0,
|
|
69
67
|
!0
|
|
70
68
|
);
|
|
71
|
-
else if (
|
|
72
|
-
const
|
|
73
|
-
|
|
69
|
+
else if (s(t) || r(t.partyUuid)) {
|
|
70
|
+
const f = z(
|
|
71
|
+
n,
|
|
74
72
|
t,
|
|
75
73
|
t.partyUuid,
|
|
76
74
|
r(t.partyUuid),
|
|
77
75
|
u,
|
|
78
|
-
|
|
76
|
+
p
|
|
79
77
|
);
|
|
80
|
-
|
|
78
|
+
$.push(f), r(t.partyUuid) && S.push({ ...f, groupId: "favorites" });
|
|
81
79
|
}
|
|
82
|
-
} else if (
|
|
83
|
-
if (
|
|
84
|
-
const
|
|
85
|
-
|
|
80
|
+
} else if (tt(t.type)) {
|
|
81
|
+
if (s(t) || r(t.partyUuid)) {
|
|
82
|
+
const f = z(
|
|
83
|
+
n,
|
|
86
84
|
t,
|
|
87
85
|
t.partyUuid,
|
|
88
86
|
r(t.partyUuid),
|
|
89
87
|
u,
|
|
90
|
-
|
|
88
|
+
p
|
|
91
89
|
);
|
|
92
|
-
|
|
90
|
+
s(t) && U.push(f), r(t.partyUuid) && S.push({ ...f, groupId: "favorites" });
|
|
93
91
|
}
|
|
94
92
|
if (t.subunits && t.subunits.length > 0) {
|
|
95
|
-
const
|
|
96
|
-
for (const b of
|
|
97
|
-
if (
|
|
98
|
-
const
|
|
99
|
-
|
|
93
|
+
const f = [...t.subunits].sort(A);
|
|
94
|
+
for (const b of f)
|
|
95
|
+
if (s(b) || r(b.partyUuid)) {
|
|
96
|
+
const M = z(
|
|
97
|
+
n,
|
|
100
98
|
b,
|
|
101
99
|
t.partyUuid,
|
|
102
100
|
r(b.partyUuid),
|
|
103
101
|
u,
|
|
104
|
-
|
|
102
|
+
p,
|
|
105
103
|
t
|
|
106
104
|
);
|
|
107
|
-
|
|
108
|
-
...
|
|
105
|
+
s(b) && U.push(M), r(b.partyUuid) && S.push({
|
|
106
|
+
...M,
|
|
109
107
|
groupId: "favorites"
|
|
110
108
|
});
|
|
111
109
|
}
|
|
112
110
|
}
|
|
113
111
|
}
|
|
114
|
-
const
|
|
112
|
+
const J = {
|
|
115
113
|
[U[0]?.groupId || "company"]: {
|
|
116
|
-
title:
|
|
114
|
+
title: c.account_orgs,
|
|
117
115
|
divider: !0
|
|
118
116
|
},
|
|
119
|
-
[
|
|
120
|
-
title:
|
|
117
|
+
[$[0]?.groupId || "person"]: {
|
|
118
|
+
title: c.account_persons,
|
|
121
119
|
divider: !0
|
|
122
120
|
},
|
|
123
121
|
favorites: {
|
|
124
|
-
title:
|
|
122
|
+
title: c.account_favorites,
|
|
125
123
|
divider: !0
|
|
126
124
|
}
|
|
127
125
|
};
|
|
128
|
-
return [{ selfAccountItem:
|
|
129
|
-
}, [
|
|
130
|
-
const { selfAccountItem:
|
|
131
|
-
return
|
|
132
|
-
}, [
|
|
133
|
-
if (
|
|
126
|
+
return [{ selfAccountItem: j, peopleAccountItems: $, organizationAccountItems: U, favoriteAccountItems: S }, J];
|
|
127
|
+
}, [I, l, B, d, n, p, a]), k = v(() => {
|
|
128
|
+
const { selfAccountItem: r, peopleAccountItems: s, organizationAccountItems: c, favoriteAccountItems: y } = w;
|
|
129
|
+
return r ? [r, ...y, ...s, ...c] : [];
|
|
130
|
+
}, [w]), [q, x] = v(() => {
|
|
131
|
+
if (k.length === 0)
|
|
134
132
|
return [[], void 0];
|
|
135
|
-
let
|
|
136
|
-
return [
|
|
137
|
-
if (
|
|
138
|
-
const A = { ...
|
|
139
|
-
return
|
|
133
|
+
let r;
|
|
134
|
+
return [k.map((c) => {
|
|
135
|
+
if (i === c.id) {
|
|
136
|
+
const A = { ...c, selected: !0 };
|
|
137
|
+
return r = A, A;
|
|
140
138
|
}
|
|
141
|
-
return
|
|
142
|
-
}),
|
|
143
|
-
}, [
|
|
144
|
-
return
|
|
139
|
+
return c.selected ? { ...c, selected: !1 } : c;
|
|
140
|
+
}), r];
|
|
141
|
+
}, [k, i]);
|
|
142
|
+
return d || !e || !x ? {
|
|
145
143
|
accountMenu: {
|
|
146
144
|
items: [],
|
|
147
145
|
groups: {},
|
|
@@ -150,89 +148,89 @@ const H = (e) => e === "Organization" ? "company" : "person", pt = ({
|
|
|
150
148
|
},
|
|
151
149
|
currentAccount: void 0
|
|
152
150
|
},
|
|
153
|
-
loading:
|
|
151
|
+
loading: d
|
|
154
152
|
} : {
|
|
155
153
|
accountMenu: {
|
|
156
|
-
items:
|
|
157
|
-
groups:
|
|
158
|
-
virtualized:
|
|
154
|
+
items: q,
|
|
155
|
+
groups: Y,
|
|
156
|
+
virtualized: m,
|
|
159
157
|
onSelectAccount: N,
|
|
160
|
-
currentAccount:
|
|
158
|
+
currentAccount: x
|
|
161
159
|
},
|
|
162
160
|
loading: !1,
|
|
163
|
-
showDeletedUnits:
|
|
164
|
-
onShowDeletedUnitsChange:
|
|
165
|
-
accountCount:
|
|
161
|
+
showDeletedUnits: D ? a : void 0,
|
|
162
|
+
onShowDeletedUnitsChange: D ? g : void 0,
|
|
163
|
+
accountCount: K
|
|
166
164
|
};
|
|
167
|
-
},
|
|
165
|
+
}, L = ({
|
|
168
166
|
partyUuid: e,
|
|
169
167
|
isFavorite: o,
|
|
170
|
-
toggleFavoriteRef:
|
|
171
|
-
texts:
|
|
168
|
+
toggleFavoriteRef: i,
|
|
169
|
+
texts: l
|
|
172
170
|
}) => /* @__PURE__ */ F(
|
|
173
|
-
|
|
171
|
+
Q,
|
|
174
172
|
{
|
|
175
173
|
rounded: !0,
|
|
176
174
|
variant: "ghost",
|
|
177
|
-
"aria-label": o ?
|
|
178
|
-
onClick: (
|
|
179
|
-
|
|
175
|
+
"aria-label": o ? l.remove_from_favorites : l.add_to_favorites,
|
|
176
|
+
onClick: (d) => {
|
|
177
|
+
d.stopPropagation(), i?.current?.(e);
|
|
180
178
|
},
|
|
181
179
|
size: "xs",
|
|
182
|
-
children: o ? /* @__PURE__ */ F(
|
|
180
|
+
children: o ? /* @__PURE__ */ F(C, {}) : /* @__PURE__ */ F(T, {})
|
|
183
181
|
}
|
|
184
|
-
), z = (e, o,
|
|
185
|
-
const
|
|
182
|
+
), z = (e, o, i, l, d, N, m, h) => {
|
|
183
|
+
const n = V(o?.type ?? ""), a = G(e), g = R({
|
|
186
184
|
fullName: o?.name,
|
|
187
|
-
type:
|
|
188
|
-
}),
|
|
189
|
-
fullName:
|
|
190
|
-
type:
|
|
185
|
+
type: n
|
|
186
|
+
}), p = m ? R({
|
|
187
|
+
fullName: m?.name,
|
|
188
|
+
type: V(m?.type ?? ""),
|
|
191
189
|
reverseNameOrder: !1
|
|
192
190
|
}) : void 0;
|
|
193
191
|
let u = "";
|
|
194
|
-
const _ =
|
|
192
|
+
const _ = n === "company" && m ? "subunit" : n;
|
|
195
193
|
switch (_) {
|
|
196
194
|
case "company":
|
|
197
|
-
u = `${
|
|
195
|
+
u = `${a.org_no}. ${H(o.organizationNumber)}`;
|
|
198
196
|
break;
|
|
199
197
|
case "person":
|
|
200
|
-
u = o?.dateOfBirth ? `${
|
|
198
|
+
u = o?.dateOfBirth ? `${a.birthdate}: ${Z(o?.dateOfBirth)}` : "";
|
|
201
199
|
break;
|
|
202
200
|
case "subunit":
|
|
203
|
-
u = `↳ ${
|
|
201
|
+
u = `↳ ${a.org_no}. ${H(o?.organizationNumber)}, ${a.subunit_of} ${p}`;
|
|
204
202
|
break;
|
|
205
203
|
default:
|
|
206
204
|
u = "";
|
|
207
205
|
}
|
|
208
|
-
const
|
|
209
|
-
|
|
206
|
+
const I = h ? void 0 : /* @__PURE__ */ F(
|
|
207
|
+
L,
|
|
210
208
|
{
|
|
211
209
|
partyUuid: o?.partyUuid,
|
|
212
|
-
isFavorite:
|
|
213
|
-
toggleFavoriteRef:
|
|
214
|
-
texts:
|
|
210
|
+
isFavorite: l,
|
|
211
|
+
toggleFavoriteRef: d,
|
|
212
|
+
texts: a
|
|
215
213
|
}
|
|
216
214
|
);
|
|
217
215
|
return {
|
|
218
216
|
id: o?.partyUuid,
|
|
219
217
|
icon: {
|
|
220
218
|
name: g,
|
|
221
|
-
type:
|
|
222
|
-
isParent: !
|
|
219
|
+
type: n,
|
|
220
|
+
isParent: !m,
|
|
223
221
|
isDeleted: o?.isDeleted
|
|
224
222
|
},
|
|
225
223
|
name: g,
|
|
226
224
|
description: u,
|
|
227
225
|
searchWords: _ === "person" ? [g, o?.dateOfBirth ?? ""] : [g, o?.organizationNumber ?? ""],
|
|
228
|
-
groupId:
|
|
226
|
+
groupId: i,
|
|
229
227
|
type: _,
|
|
230
228
|
selected: !1,
|
|
231
229
|
disabled: !!o?.onlyHierarchyElementWithNoAccess,
|
|
232
|
-
badge:
|
|
233
|
-
controls:
|
|
230
|
+
badge: h ? { label: a.you, color: "person" } : o.isDeleted && N ? { label: a.deleted, color: "neutral" } : void 0,
|
|
231
|
+
controls: I
|
|
234
232
|
};
|
|
235
|
-
},
|
|
233
|
+
}, tt = (e) => e === "Organization", et = (e) => e === "Person" || e === "SelfIdentified", G = (e) => {
|
|
236
234
|
switch (e) {
|
|
237
235
|
case "nn":
|
|
238
236
|
return {
|
|
@@ -276,5 +274,5 @@ const H = (e) => e === "Organization" ? "company" : "person", pt = ({
|
|
|
276
274
|
}
|
|
277
275
|
};
|
|
278
276
|
export {
|
|
279
|
-
|
|
277
|
+
_t as useAccountSelector
|
|
280
278
|
};
|
|
@@ -32,7 +32,11 @@ export interface AuthorizedParty {
|
|
|
32
32
|
export interface useAccountSelectorProps {
|
|
33
33
|
/** UUID of the user's own personal account */
|
|
34
34
|
selfAccountUuid?: string;
|
|
35
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Array of authorized parties that the user can act on behalf of.
|
|
37
|
+
* Pass a referentially stable array: a fresh reference on every render
|
|
38
|
+
* forces the full list to be re-sorted and rebuilt.
|
|
39
|
+
*/
|
|
36
40
|
partyListDTO?: AuthorizedParty[];
|
|
37
41
|
/** Array of parties (defined by their partyUUIDs) marked as favorites by the user */
|
|
38
42
|
favoriteAccountUuids?: string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@altinn/altinn-components",
|
|
3
|
-
"version": "0.68.
|
|
3
|
+
"version": "0.68.15",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@types/react": "^19.1.5",
|
|
46
46
|
"@types/react-dom": "^19.2.3",
|
|
47
47
|
"@vitejs/plugin-react-swc": "^3.11.0",
|
|
48
|
-
"@vitest/browser": "4.
|
|
48
|
+
"@vitest/browser": "4.1.8",
|
|
49
49
|
"@vitest/browser-playwright": "4.0.16",
|
|
50
50
|
"@vitest/coverage-v8": "^4.1.3",
|
|
51
51
|
"axe-core": "^4.10.3",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"storybook-addon-theme-provider": "^0.2.10",
|
|
62
62
|
"tsx": "^4.21.0",
|
|
63
63
|
"typescript": "^5.8.3",
|
|
64
|
-
"vite": "7.3.
|
|
64
|
+
"vite": "7.3.5",
|
|
65
65
|
"vite-plugin-dts": "^4.5.4",
|
|
66
66
|
"vite-plugin-lib-inject-css": "^2.2.2",
|
|
67
67
|
"vite-plugin-static-copy": "^2.3.2",
|