@altinn/altinn-components 0.48.3 → 0.49.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,7 +1,7 @@
1
1
  "use client";
2
- import { jsx as a, jsxs as k } from "react/jsx-runtime";
3
- import { c as _ } from "../../index-L8X2o7IH.js";
4
- import s, { forwardRef as w, useState as b, useEffect as y } from "react";
2
+ import { jsx as a, jsxs as C } from "react/jsx-runtime";
3
+ import { c as b } from "../../index-L8X2o7IH.js";
4
+ import s, { forwardRef as x, useState as w, useEffect as y } from "react";
5
5
  import { useIsDesktop as F } from "../../hooks/useIsDesktop.js";
6
6
  import { AccountMenu as N } from "../Account/AccountMenu.js";
7
7
  import { Button as R } from "../Button/Button.js";
@@ -9,83 +9,83 @@ import { useRootContext as A } from "../RootProvider/RootProvider.js";
9
9
  import "../Snackbar/useSnackbar.js";
10
10
  import { SearchField as M } from "../Forms/SearchField.js";
11
11
  import { S as P } from "../../Spinner-BDXfwXIh.js";
12
- import { H as T } from "../../Heading-By5DKz2H.js";
13
- import { u as x } from "../../useId-BVFxCjkq.js";
14
- import '../../assets/AccountSelector.css';var H = function(e, i) {
12
+ import { H } from "../../Heading-By5DKz2H.js";
13
+ import { u as I } from "../../useId-BVFxCjkq.js";
14
+ import '../../assets/AccountSelector.css';var T = function(e, l) {
15
15
  var r = {};
16
- for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && i.indexOf(t) < 0 && (r[t] = e[t]);
16
+ for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && l.indexOf(t) < 0 && (r[t] = e[t]);
17
17
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
18
18
  for (var n = 0, t = Object.getOwnPropertySymbols(e); n < t.length; n++)
19
- i.indexOf(t[n]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[n]) && (r[t[n]] = e[t[n]]);
19
+ l.indexOf(t[n]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[n]) && (r[t[n]] = e[t[n]]);
20
20
  return r;
21
21
  };
22
- const V = w((e, i) => {
23
- var { title: r, titleId: t } = e, n = H(e, ["title", "titleId"]);
24
- let l = x();
25
- return l = r ? t || "title-" + l : void 0, s.createElement(
22
+ const V = x((e, l) => {
23
+ var { title: r, titleId: t } = e, n = T(e, ["title", "titleId"]);
24
+ let i = I();
25
+ return i = r ? t || "title-" + i : void 0, s.createElement(
26
26
  "svg",
27
- Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24", focusable: !1, role: "img", ref: i, "aria-labelledby": l }, n),
28
- r ? s.createElement("title", { id: l }, r) : null,
27
+ Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24", focusable: !1, role: "img", ref: l, "aria-labelledby": i }, n),
28
+ r ? s.createElement("title", { id: i }, r) : null,
29
29
  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.25m4.03 9.28-3.5 3.5a.75.75 0 0 1-1.06 0l-3.5-3.5a.75.75 0 0 1 .53-1.28h7a.75.75 0 0 1 .53 1.28m-2.34.22h-3.38L12 13.44z", clipRule: "evenodd" })
30
30
  );
31
31
  });
32
- var B = function(e, i) {
32
+ var B = function(e, l) {
33
33
  var r = {};
34
- for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && i.indexOf(t) < 0 && (r[t] = e[t]);
34
+ for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && l.indexOf(t) < 0 && (r[t] = e[t]);
35
35
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
36
36
  for (var n = 0, t = Object.getOwnPropertySymbols(e); n < t.length; n++)
37
- i.indexOf(t[n]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[n]) && (r[t[n]] = e[t[n]]);
37
+ l.indexOf(t[n]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[n]) && (r[t[n]] = e[t[n]]);
38
38
  return r;
39
39
  };
40
- const D = w((e, i) => {
40
+ const D = x((e, l) => {
41
41
  var { title: r, titleId: t } = e, n = B(e, ["title", "titleId"]);
42
- let l = x();
43
- return l = r ? t || "title-" + l : void 0, s.createElement(
42
+ let i = I();
43
+ return i = r ? t || "title-" + i : void 0, s.createElement(
44
44
  "svg",
45
- Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24", focusable: !1, role: "img", ref: i, "aria-labelledby": l }, n),
46
- r ? s.createElement("title", { id: l }, r) : null,
45
+ Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24", focusable: !1, role: "img", ref: l, "aria-labelledby": i }, n),
46
+ r ? s.createElement("title", { id: i }, r) : null,
47
47
  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" })
48
48
  );
49
- }), K = "_accountSelector_1f74n_1", L = "_heading_1f74n_11", U = "_searchSection_1f74n_17", W = "_searchField_1f74n_22", $ = "_accountMenu_1f74n_26", q = "_fullScreen_1f74n_34", G = "_virtualized_1f74n_38", J = "_btnIcon_1f74n_42", Q = "_spinner_1f74n_46", c = {
50
- accountSelector: K,
51
- heading: L,
52
- searchSection: U,
53
- searchField: W,
54
- accountMenu: $,
49
+ }), L = "_accountSelector_1f74n_1", $ = "_heading_1f74n_11", K = "_searchSection_1f74n_17", U = "_searchField_1f74n_22", W = "_accountMenu_1f74n_26", q = "_fullScreen_1f74n_34", G = "_virtualized_1f74n_38", J = "_btnIcon_1f74n_42", Q = "_spinner_1f74n_46", c = {
50
+ accountSelector: L,
51
+ heading: $,
52
+ searchSection: K,
53
+ searchField: U,
54
+ accountMenu: W,
55
55
  fullScreen: q,
56
56
  virtualized: G,
57
57
  btnIcon: J,
58
58
  spinner: Q
59
- }, de = ({ accountMenu: e, forceOpenFullScreen: i, className: r, loading: t }) => {
60
- const { currentId: n, openId: l, closeAll: m, languageCode: I } = A(), u = F(), o = n === "accountFullscreen", [h, p] = b(""), [d, v] = b(i);
59
+ }, de = ({ accountMenu: e, forceOpenFullScreen: l, className: r, loading: t }) => {
60
+ const { currentId: n, openId: i, closeAll: m, languageCode: h } = A(), f = F(), o = n === "accountFullscreen", [p, g] = w(""), [d, v] = w(l);
61
61
  y(() => {
62
- !i && d && o && m(), v(i);
63
- }, [i]), y(() => {
64
- (d === !0 && !o || !u && n === "account") && l("accountFullscreen");
65
- }, [d, o, u, n, l]);
66
- const { minimize: O, fullscreen: z, searchText: g, heading: j } = X(I), C = () => {
67
- l(o ? "account" : "accountFullscreen");
68
- }, E = (f) => {
69
- var S;
70
- (S = e.onSelectAccount) == null || S.call(e, f), m(), v(!1);
62
+ !l && d && o && m(), v(l);
63
+ }, [l]), y(() => {
64
+ (d === !0 && !o || !f && n === "account") && i("accountFullscreen");
65
+ }, [d, o, f, n, i]);
66
+ const { minimize: O, fullscreen: z, searchText: S, heading: j } = X(h), E = () => {
67
+ i(o ? "account" : "accountFullscreen");
68
+ }, k = (u) => {
69
+ var _;
70
+ (_ = e.onSelectAccount) == null || _.call(e, u), m(), v(!1);
71
71
  };
72
- return t ? /* @__PURE__ */ a(P, { "aria-hidden": !0, "data-color": "neutral", className: c.spinner }) : /* @__PURE__ */ k("div", { className: _(r, c.accountSelector), children: [
73
- o && /* @__PURE__ */ a(T, { "data-size": "md", level: 2, className: c.heading, children: j }),
72
+ return t ? /* @__PURE__ */ a(P, { "aria-hidden": !0, "data-color": "neutral", className: c.spinner }) : /* @__PURE__ */ C("div", { className: b(r, c.accountSelector), children: [
73
+ o && /* @__PURE__ */ a(H, { "data-size": "md", level: 2, className: c.heading, children: j }),
74
74
  /* @__PURE__ */ a("div", { className: c.searchSection, children: /* @__PURE__ */ a(
75
75
  M,
76
76
  {
77
- name: g,
78
- placeholder: g,
79
- value: h,
80
- onChange: (f) => p(f.target.value),
81
- onClear: () => p(""),
77
+ name: S,
78
+ placeholder: S,
79
+ value: p,
80
+ onChange: (u) => g(u.target.value),
81
+ onClear: () => g(""),
82
82
  className: c.searchField
83
83
  }
84
84
  ) }),
85
85
  /* @__PURE__ */ a(
86
86
  "div",
87
87
  {
88
- className: _(
88
+ className: b(
89
89
  c.accountMenu,
90
90
  o && c.fullScreen,
91
91
  e.isVirtualized && c.virtualized
@@ -94,20 +94,25 @@ const D = w((e, i) => {
94
94
  N,
95
95
  {
96
96
  ...e,
97
- onSelectAccount: E,
97
+ onSelectAccount: k,
98
98
  keyboardEvents: !1,
99
- search: { hidden: !0, name: "", value: h },
99
+ search: {
100
+ hidden: !0,
101
+ name: "",
102
+ value: p,
103
+ getResultsLabel: (u) => Y(u, h)
104
+ },
100
105
  scrollRefStyles: !o && e.isVirtualized ? { maxHeight: "calc(40vh)" } : void 0
101
106
  }
102
107
  )
103
108
  }
104
109
  ),
105
- d !== !0 && u && /* @__PURE__ */ a(
110
+ d !== !0 && f && /* @__PURE__ */ a(
106
111
  R,
107
112
  {
108
113
  icon: o ? /* @__PURE__ */ a(D, { className: c.btnIcon, "aria-hidden": "true" }) : /* @__PURE__ */ a(V, { className: c.btnIcon, "aria-hidden": "true" }),
109
114
  variant: "text",
110
- onClick: C,
115
+ onClick: E,
111
116
  children: o ? O : z
112
117
  }
113
118
  )
@@ -136,6 +141,9 @@ const D = w((e, i) => {
136
141
  heading: "Hvem vil du representere?"
137
142
  };
138
143
  }
144
+ }, Y = (e, l) => {
145
+ const r = l === "nb" || l === "nn";
146
+ return e === 0 ? r ? "Ingen treff" : "No hits" : r ? `${e} treff` : e === 1 ? "1 hit" : `${e} hits`;
139
147
  };
140
148
  export {
141
149
  de as AccountSelector
@@ -1,100 +1,105 @@
1
- import { jsx as E } from "react/jsx-runtime";
2
- import { useMemo as K } from "react";
1
+ import { jsx as U } from "react/jsx-runtime";
2
+ import { useMemo as W } from "react";
3
3
  import "../index-L8X2o7IH.js";
4
- import { IconButton as R } from "../components/Button/IconButton.js";
4
+ import { IconButton as Y } from "../components/Button/IconButton.js";
5
5
  import "../components/RootProvider/RootProvider.js";
6
- import { useIsDesktop as U } from "./useIsDesktop.js";
6
+ import { useIsDesktop as q } from "./useIsDesktop.js";
7
7
  import "../components/Snackbar/useSnackbar.js";
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 = ({
8
+ import { formatDisplayName as S } from "../functions/name/name.js";
9
+ import { formatDate as J } from "../functions/date/date.js";
10
+ import { S as Q, a as X } from "../HeartFill-CYSrJ_xK.js";
11
+ const O = (t) => t === "Organization" ? "company" : "person", ro = ({
12
12
  partyListDTO: t = [],
13
- favoriteAccountUuids: e,
14
- currentAccountUuid: u,
13
+ favoriteAccountUuids: o,
14
+ currentAccountUuid: f,
15
15
  selfAccountUuid: m,
16
- isLoading: f = !1,
16
+ isLoading: d = !1,
17
17
  onSelectAccount: _,
18
18
  isVirtualized: h = !1,
19
19
  onToggleFavorite: s,
20
- languageCode: c
20
+ languageCode: r
21
21
  }) => {
22
- const r = U(), [i, b, a] = K(() => {
22
+ const i = q(), [c, b, l] = W(() => {
23
23
  var A, N;
24
- if (f || !t || !m)
24
+ if (d || !t || !m)
25
25
  return [[], {}, void 0];
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
- c,
28
- I,
26
+ const n = (e) => o == null ? void 0 : o.includes(e), a = F(r), I = r || "nb", z = (e, u) => e.name.localeCompare(u.name, I, {
27
+ sensitivity: "base",
28
+ ignorePunctuation: !0
29
+ }), B = t.find((e) => D(e.type) && e.partyUuid === m), P = [...t].filter((e) => D(e.type) && e.partyUuid !== m).sort(z), j = [...t].filter((e) => Z(e.type)).sort(z), H = g(
30
+ r,
31
+ B,
29
32
  "favorites",
30
- u,
33
+ f,
31
34
  !1,
32
35
  s,
33
- r,
36
+ i,
34
37
  void 0,
35
38
  !0
36
- ), k = z == null ? void 0 : z.map(
37
- (o) => g(
38
- c,
39
- o,
40
- o.partyUuid,
41
- u,
42
- n(o.partyUuid),
39
+ ), k = P == null ? void 0 : P.map(
40
+ (e) => g(
41
+ r,
42
+ e,
43
+ e.partyUuid,
44
+ f,
45
+ n(e.partyUuid),
43
46
  s,
44
- r
47
+ i
45
48
  )
46
49
  ), v = [];
47
- for (const o of B) {
48
- const d = g(
49
- c,
50
- o,
51
- o.partyUuid,
52
- u,
53
- n(o.partyUuid),
50
+ for (const e of j) {
51
+ const u = g(
52
+ r,
53
+ e,
54
+ e.partyUuid,
55
+ f,
56
+ n(e.partyUuid),
54
57
  s,
55
- r
58
+ i
56
59
  );
57
- if (v.push(d), o.subunits && o.subunits.length > 0)
58
- for (const P of o.subunits) {
59
- const G = g(
60
- c,
61
- P,
62
- o.partyUuid,
63
- u,
64
- n(P.partyUuid),
65
- s,
60
+ if (v.push(u), e.subunits && e.subunits.length > 0) {
61
+ const K = [...e.subunits].sort(z);
62
+ for (const $ of K) {
63
+ const R = g(
66
64
  r,
67
- o
65
+ $,
66
+ e.partyUuid,
67
+ f,
68
+ n($.partyUuid),
69
+ s,
70
+ i,
71
+ e
68
72
  );
69
- v.push(G);
73
+ v.push(R);
70
74
  }
75
+ }
71
76
  }
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 = {
77
+ const M = k.reduce((e, u) => (n(u.id) && e.push({ ...u, groupId: "favorites" }), e), []), V = v.reduce((e, u) => (n(u.id) && e.push({ ...u, groupId: "favorites" }), e), []), w = [...M, ...V], x = [H, ...w, ...k, ...v], G = x.find((e) => (e == null ? void 0 : e.selected) === !0), E = {
73
78
  [((A = v[0]) == null ? void 0 : A.groupId) || "company"]: {
74
- title: l.account_orgs,
79
+ title: a.account_orgs,
75
80
  divider: !0
76
81
  },
77
82
  [((N = k[0]) == null ? void 0 : N.groupId) || "person"]: {
78
- title: l.account_persons,
83
+ title: a.account_persons,
79
84
  divider: !0
80
85
  },
81
86
  favorites: {
82
- title: l.account_favorites,
87
+ title: a.account_favorites,
83
88
  divider: !0
84
89
  }
85
90
  };
86
- return [x, w, V];
91
+ return [x, E, G];
87
92
  }, [
88
93
  t,
89
94
  m,
90
- e,
91
- u,
95
+ o,
92
96
  f,
97
+ d,
93
98
  s,
94
- c,
95
- r
99
+ r,
100
+ i
96
101
  ]);
97
- return f || !t || !a ? {
102
+ return d || !t || !l ? {
98
103
  accountMenu: {
99
104
  items: [],
100
105
  groups: {},
@@ -103,72 +108,72 @@ const S = (t) => t === "Organization" ? "company" : "person", te = ({
103
108
  },
104
109
  currentAccount: void 0
105
110
  },
106
- loading: f
111
+ loading: d
107
112
  } : {
108
113
  accountMenu: {
109
- items: i,
114
+ items: c,
110
115
  groups: b,
111
116
  isVirtualized: h,
112
117
  onSelectAccount: _,
113
- currentAccount: a
118
+ currentAccount: l
114
119
  },
115
120
  loading: !1
116
121
  };
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
+ }, g = (t, o, f, m, d, _, h, s, r) => {
123
+ const i = O((o == null ? void 0 : o.type) ?? ""), c = F(t), b = S({
124
+ fullName: o == null ? void 0 : o.name,
125
+ type: i
126
+ }), l = s ? S({
122
127
  fullName: s == null ? void 0 : s.name,
123
- type: S((s == null ? void 0 : s.type) ?? ""),
128
+ type: O((s == null ? void 0 : s.type) ?? ""),
124
129
  reverseNameOrder: !1
125
130
  }) : void 0;
126
131
  let n = "";
127
- const l = r === "company" && s ? "subunit" : r;
128
- switch (l) {
132
+ const a = i === "company" && s ? "subunit" : i;
133
+ switch (a) {
129
134
  case "company":
130
- n = `${i.org_no}: ${e.organizationNumber}`;
135
+ n = `${c.org_no}: ${o.organizationNumber}`;
131
136
  break;
132
137
  case "person":
133
- n = e != null && e.dateOfBirth ? `${i.birthdate}: ${W(e == null ? void 0 : e.dateOfBirth)}` : "";
138
+ n = o != null && o.dateOfBirth ? `${c.birthdate}: ${J(o == null ? void 0 : o.dateOfBirth)}` : "";
134
139
  break;
135
140
  case "subunit":
136
- n = `↳ ${i.org_no}: ${e == null ? void 0 : e.organizationNumber}, ${i.subunit_of} ${a}`;
141
+ n = `↳ ${c.org_no}: ${o == null ? void 0 : o.organizationNumber}, ${c.subunit_of} ${l}`;
137
142
  break;
138
143
  default:
139
144
  n = "";
140
145
  }
141
146
  return {
142
- id: e == null ? void 0 : e.partyUuid,
147
+ id: o == null ? void 0 : o.partyUuid,
143
148
  icon: {
144
149
  name: b,
145
- type: r,
150
+ type: i,
146
151
  isParent: !s,
147
- isDeleted: e == null ? void 0 : e.isDeleted,
148
- colorKey: a ?? void 0
152
+ isDeleted: o == null ? void 0 : o.isDeleted,
153
+ colorKey: l ?? void 0
149
154
  },
150
155
  name: b,
151
156
  description: n,
152
- groupId: u,
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
+ groupId: f,
158
+ type: a,
159
+ selected: m === (o == null ? void 0 : o.partyUuid),
160
+ disabled: !!(o != null && o.onlyHierarchyElementWithNoAccess),
161
+ badge: r ? { label: c.you, color: "person" } : o.isDeleted && h ? { label: c.deleted, color: "neutral" } : void 0,
162
+ controls: !r && /* @__PURE__ */ U(
163
+ Y,
159
164
  {
160
165
  rounded: !0,
161
166
  variant: "text",
162
- icon: f ? Y : q,
163
- iconAltText: f ? i.remove_from_favorites : i.add_to_favorites,
167
+ icon: d ? Q : X,
168
+ iconAltText: d ? c.remove_from_favorites : c.add_to_favorites,
164
169
  onClick: (I) => {
165
- _ && (I.stopPropagation(), _(e == null ? void 0 : e.partyUuid));
170
+ _ && (I.stopPropagation(), _(o == null ? void 0 : o.partyUuid));
166
171
  },
167
172
  size: "xs"
168
173
  }
169
174
  )
170
175
  };
171
- }, J = (t) => t === "Organization", O = (t) => t === "Person" || t === "SelfIdentified", D = (t) => {
176
+ }, Z = (t) => t === "Organization", D = (t) => t === "Person" || t === "SelfIdentified", F = (t) => {
172
177
  switch (t) {
173
178
  case "nn":
174
179
  return {
@@ -212,5 +217,5 @@ const S = (t) => t === "Organization" ? "company" : "person", te = ({
212
217
  }
213
218
  };
214
219
  export {
215
- te as useAccountSelector
220
+ ro as useAccountSelector
216
221
  };
@@ -1,6 +1,7 @@
1
+ import { ReactNode } from 'react';
1
2
  import { SettingsItemProps } from '..';
2
3
  export interface SettingsGroupProps {
3
- title?: string;
4
+ title?: string | ReactNode;
4
5
  }
5
6
  export interface SettingsListProps {
6
7
  items: SettingsItemProps[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altinn/altinn-components",
3
- "version": "0.48.3",
3
+ "version": "0.49.0",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",