@altinn/altinn-components 0.53.0 → 0.53.1

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,104 +1,124 @@
1
- import { jsx as z } from "react/jsx-runtime";
2
- import { useMemo as G } from "react";
1
+ import { jsx as k } from "react/jsx-runtime";
2
+ import { useMemo as H } from "react";
3
3
  import "../index-p1eeF8LQ.js";
4
- import { Button as E } from "../components/Button/Button.js";
4
+ import { Button as M } from "../components/Button/Button.js";
5
5
  import "../components/RootProvider/RootProvider.js";
6
- import { useIsDesktop as R } from "./useIsDesktop.js";
6
+ import { useIsDesktop as G } from "./useIsDesktop.js";
7
7
  import "../components/Snackbar/useSnackbar.js";
8
- import { formatDisplayName as k } 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 N = (e) => e === "Organization" ? "company" : "person", rt = ({
8
+ import { formatDisplayName as S } from "../functions/name/name.js";
9
+ import { formatDate as E } from "../functions/date/date.js";
10
+ import { S as R, a as W } from "../HeartFill-CYSrJ_xK.js";
11
+ const x = (e) => e === "Organization" ? "company" : "person", et = ({
12
12
  partyListDTO: e = [],
13
13
  favoriteAccountUuids: o,
14
- currentAccountUuid: u,
15
- selfAccountUuid: d,
16
- isLoading: f = !1,
17
- onSelectAccount: p,
18
- isVirtualized: g = !1,
14
+ currentAccountUuid: f,
15
+ selfAccountUuid: l,
16
+ isLoading: d = !1,
17
+ onSelectAccount: b,
18
+ isVirtualized: I = !1,
19
19
  onToggleFavorite: r,
20
- languageCode: n
20
+ languageCode: i,
21
+ showDeletedUnits: u,
22
+ onShowDeletedUnitsChange: n
21
23
  }) => {
22
- const i = R(), [a, v, _] = G(() => {
23
- if (f || !e || !d)
24
+ const c = G(), [P, m, v] = H(() => {
25
+ if (d || !e || !l)
24
26
  return [[], {}, void 0];
25
- const s = (t) => o?.includes(t), m = S(n), h = n || "nb", I = (t, c) => t.name.localeCompare(c.name, h, {
27
+ const s = (t) => o?.includes(t), _ = (t) => !t.isDeleted || u !== !1, z = D(i), F = i || "nb", N = (t, a) => t.name.localeCompare(a.name, F, {
26
28
  sensitivity: "base",
27
29
  ignorePunctuation: !0
28
- }), x = e.find((t) => $(t.type) && t.partyUuid === d), O = [...e].filter((t) => $(t.type) && t.partyUuid !== d).sort(I), D = [...e].filter((t) => J(t.type)).sort(I), F = b(
29
- n,
30
- x,
31
- "favorites",
32
- u,
33
- !1,
34
- r,
35
- i,
36
- void 0,
37
- !0
38
- ), y = O?.map(
39
- (t) => b(
40
- n,
41
- t,
42
- t.partyUuid,
43
- u,
44
- s(t.partyUuid),
45
- r,
46
- i
47
- )
48
- ), l = [];
49
- for (const t of D) {
50
- const c = b(
51
- n,
52
- t,
53
- t.partyUuid,
54
- u,
55
- s(t.partyUuid),
56
- r,
57
- i
58
- );
59
- if (l.push(c), t.subunits && t.subunits.length > 0) {
60
- const V = [...t.subunits].sort(I);
61
- for (const P of V) {
62
- const w = b(
63
- n,
64
- P,
30
+ }), B = [...e].sort(N);
31
+ let A;
32
+ const U = [], y = [], g = [];
33
+ for (const t of B)
34
+ if (q(t.type)) {
35
+ if (t.partyUuid === l)
36
+ A = h(
37
+ i,
38
+ t,
39
+ "favorites",
40
+ f,
41
+ !1,
42
+ r,
43
+ c,
44
+ void 0,
45
+ !0
46
+ );
47
+ else if (_(t) || s(t.partyUuid)) {
48
+ const a = h(
49
+ i,
50
+ t,
65
51
  t.partyUuid,
66
- u,
67
- s(P.partyUuid),
52
+ f,
53
+ s(t.partyUuid),
68
54
  r,
55
+ c
56
+ );
57
+ U.push(a), s(t.partyUuid) && g.push({ ...a, groupId: "favorites" });
58
+ }
59
+ } else if (Y(t.type)) {
60
+ if (_(t) || s(t.partyUuid)) {
61
+ const a = h(
69
62
  i,
70
- t
63
+ t,
64
+ t.partyUuid,
65
+ f,
66
+ s(t.partyUuid),
67
+ r,
68
+ c
71
69
  );
72
- l.push(w);
70
+ _(t) && y.push(a), s(t.partyUuid) && g.push({ ...a, groupId: "favorites" });
71
+ }
72
+ if (t.subunits && t.subunits.length > 0) {
73
+ const a = [...t.subunits].sort(N);
74
+ for (const p of a)
75
+ if (_(p) || s(p.partyUuid)) {
76
+ const O = h(
77
+ i,
78
+ p,
79
+ t.partyUuid,
80
+ f,
81
+ s(p.partyUuid),
82
+ r,
83
+ c,
84
+ t
85
+ );
86
+ _(p) && y.push(O), s(p.partyUuid) && g.push({
87
+ ...O,
88
+ groupId: "favorites"
89
+ });
90
+ }
73
91
  }
74
92
  }
75
- }
76
- const U = y.reduce((t, c) => (s(c.id) && t.push({ ...c, groupId: "favorites" }), t), []), B = l.reduce((t, c) => (s(c.id) && t.push({ ...c, groupId: "favorites" }), t), []), j = [...U, ...B], A = [F, ...j, ...y, ...l], H = A.find((t) => t?.selected === !0), M = {
77
- [l[0]?.groupId || "company"]: {
78
- title: m.account_orgs,
93
+ if (A === void 0)
94
+ return [[], {}, void 0];
95
+ const $ = [A, ...g, ...U, ...y], V = $.find((t) => t?.selected === !0), j = {
96
+ [y[0]?.groupId || "company"]: {
97
+ title: z.account_orgs,
79
98
  divider: !0
80
99
  },
81
- [y[0]?.groupId || "person"]: {
82
- title: m.account_persons,
100
+ [U[0]?.groupId || "person"]: {
101
+ title: z.account_persons,
83
102
  divider: !0
84
103
  },
85
104
  favorites: {
86
- title: m.account_favorites,
105
+ title: z.account_favorites,
87
106
  divider: !0
88
107
  }
89
108
  };
90
- return [A, M, H];
109
+ return [$, j, V];
91
110
  }, [
92
111
  e,
93
- d,
112
+ l,
94
113
  o,
95
- u,
96
114
  f,
115
+ d,
97
116
  r,
98
- n,
99
- i
117
+ i,
118
+ c,
119
+ u
100
120
  ]);
101
- return f || !e || !_ ? {
121
+ return d || !e || !v ? {
102
122
  accountMenu: {
103
123
  items: [],
104
124
  groups: {},
@@ -107,71 +127,73 @@ const N = (e) => e === "Organization" ? "company" : "person", rt = ({
107
127
  },
108
128
  currentAccount: void 0
109
129
  },
110
- loading: f
130
+ loading: d
111
131
  } : {
112
132
  accountMenu: {
113
- items: a,
114
- groups: v,
115
- isVirtualized: g,
116
- onSelectAccount: p,
117
- currentAccount: _
133
+ items: P,
134
+ groups: m,
135
+ isVirtualized: I,
136
+ onSelectAccount: b,
137
+ currentAccount: v
118
138
  },
119
- loading: !1
139
+ loading: !1,
140
+ showDeletedUnits: u,
141
+ onShowDeletedUnitsChange: n
120
142
  };
121
- }, b = (e, o, u, d, f, p, g, r, n) => {
122
- const i = N(o?.type ?? ""), a = S(e), v = k({
143
+ }, h = (e, o, f, l, d, b, I, r, i) => {
144
+ const u = x(o?.type ?? ""), n = D(e), c = S({
123
145
  fullName: o?.name,
124
- type: i
125
- }), _ = r ? k({
146
+ type: u
147
+ }), P = r ? S({
126
148
  fullName: r?.name,
127
- type: N(r?.type ?? ""),
149
+ type: x(r?.type ?? ""),
128
150
  reverseNameOrder: !1
129
151
  }) : void 0;
130
- let s = "";
131
- const m = i === "company" && r ? "subunit" : i;
132
- switch (m) {
152
+ let m = "";
153
+ const v = u === "company" && r ? "subunit" : u;
154
+ switch (v) {
133
155
  case "company":
134
- s = `${a.org_no}: ${o.organizationNumber}`;
156
+ m = `${n.org_no}. ${o.organizationNumber}`;
135
157
  break;
136
158
  case "person":
137
- s = o?.dateOfBirth ? `${a.birthdate}: ${W(o?.dateOfBirth)}` : "";
159
+ m = o?.dateOfBirth ? `${n.birthdate}: ${E(o?.dateOfBirth)}` : "";
138
160
  break;
139
161
  case "subunit":
140
- s = `↳ ${a.org_no}: ${o?.organizationNumber}, ${a.subunit_of} ${_}`;
162
+ m = `↳ ${n.org_no}: ${o?.organizationNumber}, ${n.subunit_of} ${P}`;
141
163
  break;
142
164
  default:
143
- s = "";
165
+ m = "";
144
166
  }
145
167
  return {
146
168
  id: o?.partyUuid,
147
169
  icon: {
148
- name: v,
149
- type: i,
170
+ name: c,
171
+ type: u,
150
172
  isParent: !r,
151
173
  isDeleted: o?.isDeleted
152
174
  },
153
- name: v,
154
- description: s,
155
- groupId: u,
156
- type: m,
157
- selected: d === o?.partyUuid,
175
+ name: c,
176
+ description: m,
177
+ groupId: f,
178
+ type: v,
179
+ selected: l === o?.partyUuid,
158
180
  disabled: !!o?.onlyHierarchyElementWithNoAccess,
159
- badge: n ? { label: a.you, color: "person" } : o.isDeleted && g ? { label: a.deleted, color: "neutral" } : void 0,
160
- controls: !n && /* @__PURE__ */ z(
161
- E,
181
+ badge: i ? { label: n.you, color: "person" } : o.isDeleted && I ? { label: n.deleted, color: "neutral" } : void 0,
182
+ controls: !i && /* @__PURE__ */ k(
183
+ M,
162
184
  {
163
185
  rounded: !0,
164
186
  variant: "ghost",
165
- "aria-label": f ? a.remove_from_favorites : a.add_to_favorites,
166
- onClick: (h) => {
167
- p && (h.stopPropagation(), p(o?.partyUuid));
187
+ "aria-label": d ? n.remove_from_favorites : n.add_to_favorites,
188
+ onClick: (s) => {
189
+ b && (s.stopPropagation(), b(o?.partyUuid));
168
190
  },
169
191
  size: "xs",
170
- children: f ? /* @__PURE__ */ z(Y, {}) : /* @__PURE__ */ z(q, {})
192
+ children: d ? /* @__PURE__ */ k(R, {}) : /* @__PURE__ */ k(W, {})
171
193
  }
172
194
  )
173
195
  };
174
- }, J = (e) => e === "Organization", $ = (e) => e === "Person" || e === "SelfIdentified", S = (e) => {
196
+ }, Y = (e) => e === "Organization", q = (e) => e === "Person" || e === "SelfIdentified", D = (e) => {
175
197
  switch (e) {
176
198
  case "nn":
177
199
  return {
@@ -215,5 +237,5 @@ const N = (e) => e === "Organization" ? "company" : "person", rt = ({
215
237
  }
216
238
  };
217
239
  export {
218
- rt as useAccountSelector
240
+ et as useAccountSelector
219
241
  };
package/dist/index.js CHANGED
@@ -217,10 +217,10 @@ import { useAccountSelector as Dx } from "./hooks/useAccountSelector.js";
217
217
  import { formatDisplayName as Lx } from "./functions/name/name.js";
218
218
  import { formatDate as Sx } from "./functions/date/date.js";
219
219
  import { A as Ax } from "./alert-BzifOfXl.js";
220
- import { B as yx, C as Tx, a as hx, b as kx, D as Cx, L as Hx, c as Fx, d as Px, P as vx, e as wx, f as Gx, S as Ox, g as Ex, T as Nx, u as Rx } from "./textfield-C_c2H05R.js";
221
- import { B as zx, S as Qx } from "./button-BB5sYVKY.js";
222
- import { D as _x } from "./index-Q0EA2XB0.js";
223
- import { H as jx } from "./heading-C_XYsUfi.js";
220
+ import { B as yx, C as Tx, a as hx, b as kx, D as Cx, L as Hx, c as Fx, d as Px, P as vx, e as wx, S as Gx, f as Ox, T as Ex, u as Nx } from "./textfield-DAuYWtUj.js";
221
+ import { B as Ux, S as zx } from "./button-BB5sYVKY.js";
222
+ import { H as Vx, S as _x } from "./switch-Cemfhx0H.js";
223
+ import { D as jx } from "./index-Q0EA2XB0.js";
224
224
  import { P as Jx } from "./paragraph-BRiIBpbY.js";
225
225
  import { S as Xx } from "./index-DttADHE1.js";
226
226
  import { V as Zx } from "./index-z82sbSVU.js";
@@ -309,13 +309,13 @@ export {
309
309
  Yo as DropdownBase,
310
310
  Ax as DsAlert,
311
311
  yx as DsBadge,
312
- zx as DsButton,
312
+ Ux as DsButton,
313
313
  Tx as DsCheckbox,
314
314
  hx as DsChip,
315
315
  kx as DsCombobox,
316
- _x as DsDetails,
316
+ jx as DsDetails,
317
317
  Cx as DsDialog,
318
- jx as DsHeading,
318
+ Vx as DsHeading,
319
319
  Hx as DsLink,
320
320
  Fx as DsListItem,
321
321
  Px as DsListUnordered,
@@ -324,10 +324,10 @@ export {
324
324
  wx as DsPopover,
325
325
  Xx as DsSearch,
326
326
  Gx as DsSkeleton,
327
- Qx as DsSpinner,
328
- Ox as DsSwitch,
329
- Ex as DsTabs,
330
- Nx as DsTextfield,
327
+ zx as DsSpinner,
328
+ _x as DsSwitch,
329
+ Ox as DsTabs,
330
+ Ex as DsTextfield,
331
331
  Zx as DsValidationMessage,
332
332
  Ar as EndUserLabel,
333
333
  vp as Field,
@@ -477,7 +477,7 @@ export {
477
477
  jr as isIconProps,
478
478
  Dx as useAccountSelector,
479
479
  nx as useClickOutside,
480
- Rx as useDsPagination,
480
+ Nx as useDsPagination,
481
481
  lx as useEscapeKey,
482
482
  dx as useMenu,
483
483
  wt as useRootContext,
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { jsx as r, jsxs as l } from "react/jsx-runtime";
3
+ import { S as p } from "./index-D7FJjvrv.js";
4
+ import { c as h } from "./lite-1fxw3LjI.js";
5
+ import { forwardRef as n } from "react";
6
+ import { F as u } from "./index-z82sbSVU.js";
7
+ import { I as g } from "./input-wBv_FkEV.js";
8
+ import { L as w } from "./label-xTmTyPhk.js";
9
+ const F = n(function({ level: e = 2, className: a, asChild: i, ...t }, o) {
10
+ const s = i ? p : `h${e}`;
11
+ return r(s, { className: h("ds-heading", a), ref: o, ...t });
12
+ }), I = n(function({ "data-size": e, children: a, className: i, description: t, label: o, position: s, style: m, ...d }, f) {
13
+ return l(u, { className: i, "data-position": s, "data-size": e, style: m, children: [r(g, { type: "checkbox", role: "switch", ref: f, ...d }), !!o && r(w, { weight: "regular", children: o }), !!t && r("div", { "data-field": "description", children: t })] });
14
+ });
15
+ export {
16
+ F as H,
17
+ I as S
18
+ };