@altinn/altinn-components 0.38.20 → 0.39.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
- ._avatar_13ch2_1{position:relative;overflow:hidden;box-sizing:border-box}._avatar_13ch2_1[data-shape=circle]{border-radius:50%}._avatar_13ch2_1[data-shape=square]{border-radius:5%}._avatar_13ch2_1[data-variant=outline]{border:1px solid}._avatar_13ch2_1[data-outline=true]{outline:1px solid #ffffff;box-sizing:border-box}._shape_13ch2_25{display:block;font-size:1em;width:1em;height:1em}._label_13ch2_32{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;justify-content:center;align-items:center;overflow:hidden;font-size:.575em}._image_13ch2_42{display:block;width:100%;height:100%}
1
+ ._avatar_1j6yz_1{position:relative;overflow:hidden;box-sizing:border-box}._avatar_1j6yz_1[data-shape=circle]{border-radius:50%}._avatar_1j6yz_1[data-shape=square]{border-radius:5%}._avatar_1j6yz_1[data-outline=true]{outline:1px solid #ffffff;box-sizing:border-box}._shape_1j6yz_21{display:block;font-size:1em;width:1em;height:1em}._shape_1j6yz_21[data-variant=outline]{border:1px solid}._label_1j6yz_32{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;justify-content:center;align-items:center;overflow:hidden;font-size:.575em}._image_1j6yz_42{display:block;width:100%;height:100%}
@@ -1,30 +1,30 @@
1
1
  "use client";
2
- import { jsx as e, jsxs as x } from "react/jsx-runtime";
3
- import { c as j } from "../../index-L8X2o7IH.js";
4
- import { useState as A } from "react";
5
- import { Skeleton as E } from "../Skeleton/Skeleton.js";
6
- import { fromStringToColor as I } from "./color.js";
7
- import '../../assets/Avatar.css';const y = "_avatar_13ch2_1", q = "_shape_13ch2_25", z = "_label_13ch2_32", H = "_image_13ch2_42", r = {
8
- avatar: y,
9
- shape: q,
10
- label: z,
2
+ import { jsx as e, jsxs as N } from "react/jsx-runtime";
3
+ import { c as S } from "../../index-L8X2o7IH.js";
4
+ import { useState as k } from "react";
5
+ import { Skeleton as x } from "../Skeleton/Skeleton.js";
6
+ import { fromStringToColor as A } from "./color.js";
7
+ import '../../assets/Avatar.css';const E = "_avatar_1j6yz_1", I = "_shape_1j6yz_21", q = "_label_1j6yz_32", H = "_image_1j6yz_42", r = {
8
+ avatar: E,
9
+ shape: I,
10
+ label: q,
11
11
  image: H
12
12
  }, F = (a) => typeof a == "object" && a !== null && "name" in a, G = ({
13
13
  type: a = "person",
14
- size: h,
14
+ size: d,
15
15
  name: l = "Avatar",
16
- shape: d,
17
- color: u,
16
+ shape: u,
17
+ color: h,
18
18
  variant: o = "solid",
19
- outline: c = !0,
19
+ outline: n = !0,
20
20
  imageUrl: s,
21
21
  imageUrlAlt: _,
22
22
  customLabel: g,
23
- loading: n,
23
+ loading: c,
24
24
  className: b,
25
25
  style: i = {}
26
26
  }) => {
27
- const [f, v] = A(!1), C = d || a === "person" ? "circle" : "square", N = u || a === "person" ? "light" : "dark", { backgroundColor: p, foregroundColor: m } = I(l, N), S = (l[0] ?? "").toUpperCase(), t = s && !f, k = !n && !t ? {
27
+ const [f, v] = k(!1), j = u || a === "person" ? "circle" : "square", y = h || a === "person" ? "light" : "dark", { backgroundColor: p, foregroundColor: m } = A(l, y), C = (l[0] ?? "").toUpperCase(), t = s && !f, z = !c && !t ? {
28
28
  ...i,
29
29
  backgroundColor: o === "outline" ? m : p,
30
30
  color: o === "outline" ? p : m
@@ -32,15 +32,14 @@ import '../../assets/Avatar.css';const y = "_avatar_13ch2_1", q = "_shape_13ch2_
32
32
  return /* @__PURE__ */ e(
33
33
  "div",
34
34
  {
35
- className: j(r.avatar, { [r.outline]: c }, b),
36
- style: k,
37
- "data-variant": o,
38
- "data-shape": C,
39
- "data-size": h,
40
- "data-outline": c,
35
+ className: S(r.avatar, { [r.outline]: n }, b),
36
+ style: z,
37
+ "data-shape": j,
38
+ "data-size": d,
39
+ "data-outline": n,
41
40
  "aria-hidden": !0,
42
- children: /* @__PURE__ */ x(E, { loading: n, className: r.shape, variant: "circle", children: [
43
- /* @__PURE__ */ e("div", { className: r.shape, children: t && /* @__PURE__ */ e(
41
+ children: /* @__PURE__ */ N(x, { loading: c, className: r.shape, variant: "circle", children: [
42
+ /* @__PURE__ */ e("div", { className: r.shape, "data-variant": o, children: t && /* @__PURE__ */ e(
44
43
  "img",
45
44
  {
46
45
  src: s,
@@ -51,7 +50,7 @@ import '../../assets/Avatar.css';const y = "_avatar_13ch2_1", q = "_shape_13ch2_
51
50
  }
52
51
  }
53
52
  ) }),
54
- !t && /* @__PURE__ */ e("span", { className: r.label, children: g || S })
53
+ !t && /* @__PURE__ */ e("span", { className: r.label, children: g || C })
55
54
  ] })
56
55
  }
57
56
  );
@@ -1,36 +1,37 @@
1
1
  "use client";
2
- import { jsx as r } from "react/jsx-runtime";
3
- import { c } from "../../index-L8X2o7IH.js";
2
+ import { jsx as l } from "react/jsx-runtime";
3
+ import { c as s } from "../../index-L8X2o7IH.js";
4
4
  import { useMemo as f } from "react";
5
5
  import { Avatar as h } from "./Avatar.js";
6
- import '../../assets/AvatarGroup.css';const A = "_group_1ts6c_1", _ = "_item_1ts6c_10", s = {
6
+ import '../../assets/AvatarGroup.css';const A = "_group_1ts6c_1", _ = "_item_1ts6c_10", n = {
7
7
  group: A,
8
8
  item: _
9
- }, G = (e) => typeof e == "object" && e !== null && "items" in e, L = ({
10
- items: e = [],
11
- maxItemsCount: l = 4,
12
- defaultType: n,
13
- size: i,
9
+ }, L = (o) => typeof o == "object" && o !== null && "items" in o, N = ({
10
+ items: o = [],
11
+ maxItemsCount: r = 4,
12
+ defaultType: i,
13
+ size: c,
14
14
  className: m,
15
15
  style: u
16
16
  }) => {
17
- const o = f(() => e.slice(0, l), [e, l]);
18
- return e.length === 0 ? /* @__PURE__ */ r("div", { className: s.avatarGroup }) : /* @__PURE__ */ r("ul", { className: c(s.group, m), "data-size": i, "data-count": o == null ? void 0 : o.length, style: u, children: o.map((t, p) => {
19
- const g = p === l - 1, d = t.customLabel || g ? e.length.toString() : void 0;
20
- return /* @__PURE__ */ r("li", { className: c(s.item), children: /* @__PURE__ */ r(
17
+ const t = f(() => o.slice(0, r), [o, r]);
18
+ return o.length === 0 ? /* @__PURE__ */ l("div", { className: n.avatarGroup }) : /* @__PURE__ */ l("ul", { className: s(n.group, m), "data-size": c, "data-count": t == null ? void 0 : t.length, style: u, children: t.map((e, p) => {
19
+ const g = p === r - 1, d = e.customLabel || g ? o.length.toString() : void 0;
20
+ return /* @__PURE__ */ l("li", { className: s(n.item), children: /* @__PURE__ */ l(
21
21
  h,
22
22
  {
23
- name: t.name,
23
+ name: e.name,
24
24
  customLabel: d,
25
- imageUrl: t.imageUrl,
26
- imageUrlAlt: t.imageUrlAlt,
27
- type: (t == null ? void 0 : t.type) || n,
25
+ imageUrl: e.imageUrl,
26
+ imageUrlAlt: e.imageUrlAlt,
27
+ type: (e == null ? void 0 : e.type) || i,
28
+ variant: e == null ? void 0 : e.variant,
28
29
  outline: !0
29
30
  }
30
- ) }, t.name);
31
+ ) }, e.name);
31
32
  }) });
32
33
  };
33
34
  export {
34
- L as AvatarGroup,
35
- G as isAvatarGroupProps
35
+ N as AvatarGroup,
36
+ L as isAvatarGroupProps
36
37
  };
@@ -1,60 +1,83 @@
1
- import { jsx as e, jsxs as o } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as d } from "react/jsx-runtime";
2
2
  import "../../index-L8X2o7IH.js";
3
3
  import "react";
4
- import { Badge as _ } from "../Badge/Badge.js";
4
+ import { Badge as p } from "../Badge/Badge.js";
5
5
  import "../RootProvider/RootProvider.js";
6
- import { MenuItem as b } from "./MenuItem.js";
6
+ import { MenuItem as _ } from "./MenuItem.js";
7
7
  import "../Snackbar/useSnackbar.js";
8
- import { S as n } from "../../Checkmark-Byz_C9x4.js";
9
- import '../../assets/MenuOption.css';const f = "_label_zw85f_1", u = "_title_zw85f_13", x = "_radio_zw85f_19", N = "_checkbox_zw85f_20", k = "_icon_zw85f_53", a = {
10
- label: f,
11
- title: u,
12
- radio: x,
13
- checkbox: N,
14
- icon: k
15
- }, E = ({
16
- size: r = "md",
17
- type: i,
18
- name: w,
19
- active: l,
20
- value: z,
8
+ import { S as h } from "../../Checkmark-Byz_C9x4.js";
9
+ import '../../assets/MenuOption.css';const w = "_label_zw85f_1", k = "_title_zw85f_13", z = "_radio_zw85f_19", v = "_checkbox_zw85f_20", I = "_icon_zw85f_53", a = {
10
+ label: w,
11
+ title: k,
12
+ radio: z,
13
+ checkbox: v,
14
+ icon: I
15
+ }, D = ({
16
+ size: o = "md",
17
+ type: f,
18
+ name: M,
19
+ active: n,
20
+ value: j,
21
21
  label: c,
22
- badge: t,
23
- checked: s = !1,
24
- disabled: m,
25
- onMouseEnter: v,
26
- onClick: d,
27
- role: p,
28
- ...h
29
- }) => /* @__PURE__ */ e(
30
- b,
31
- {
32
- disabled: m,
33
- selected: s,
34
- size: r,
35
- as: "div",
36
- active: l,
37
- tabIndex: -1,
38
- onClick: d,
39
- role: p,
40
- label: /* @__PURE__ */ e(() => {
41
- switch (i) {
42
- case "checkbox":
43
- return /* @__PURE__ */ o("span", { className: a.label, children: [
44
- /* @__PURE__ */ e("span", { className: a.checkbox, "data-checked": s, children: /* @__PURE__ */ e(n, { className: a.icon, "aria-hidden": !0 }) }),
45
- /* @__PURE__ */ e("span", { className: a.title, children: c })
46
- ] });
47
- case "radio":
48
- return /* @__PURE__ */ o("span", { className: a.label, children: [
49
- /* @__PURE__ */ e("span", { className: a.radio, "data-checked": s, children: /* @__PURE__ */ e(n, { className: a.icon, "aria-hidden": !0 }) }),
50
- /* @__PURE__ */ e("span", { className: a.title, children: c })
51
- ] });
52
- }
53
- }, {}),
54
- controls: t && /* @__PURE__ */ e(_, { ...t }),
55
- ...h
56
- }
57
- );
22
+ title: u,
23
+ description: x,
24
+ icon: b,
25
+ badge: s,
26
+ checked: t = !1,
27
+ disabled: r,
28
+ onMouseEnter: S,
29
+ onClick: i,
30
+ role: l,
31
+ ...m
32
+ }) => {
33
+ const N = () => {
34
+ switch (f) {
35
+ case "checkbox":
36
+ return /* @__PURE__ */ d("span", { className: a.label, children: [
37
+ /* @__PURE__ */ e("span", { className: a.checkbox, "data-checked": t, children: /* @__PURE__ */ e(h, { className: a.icon, "aria-hidden": !0 }) }),
38
+ /* @__PURE__ */ e("span", { className: a.title, children: c })
39
+ ] });
40
+ case "radio":
41
+ return /* @__PURE__ */ d("span", { className: a.label, children: [
42
+ /* @__PURE__ */ e("span", { className: a.radio, "data-checked": t, children: /* @__PURE__ */ e(h, { className: a.icon, "aria-hidden": !0 }) }),
43
+ /* @__PURE__ */ e("span", { className: a.title, children: c })
44
+ ] });
45
+ }
46
+ };
47
+ return c ? /* @__PURE__ */ e(
48
+ _,
49
+ {
50
+ disabled: r,
51
+ selected: t,
52
+ size: o,
53
+ as: "div",
54
+ active: n,
55
+ tabIndex: -1,
56
+ onClick: i,
57
+ role: l,
58
+ label: /* @__PURE__ */ e(N, {}),
59
+ controls: s && /* @__PURE__ */ e(p, { ...s }),
60
+ ...m
61
+ }
62
+ ) : /* @__PURE__ */ e(
63
+ _,
64
+ {
65
+ disabled: r,
66
+ selected: t,
67
+ size: o,
68
+ as: "div",
69
+ active: n,
70
+ tabIndex: -1,
71
+ onClick: i,
72
+ role: l,
73
+ icon: b,
74
+ title: u,
75
+ description: x,
76
+ controls: s && /* @__PURE__ */ e(p, { ...s }),
77
+ ...m
78
+ }
79
+ );
80
+ };
58
81
  export {
59
- E as MenuOption
82
+ D as MenuOption
60
83
  };
@@ -32,12 +32,12 @@ const G = ({
32
32
  return /* @__PURE__ */ v(N, { children: [
33
33
  l && P ? /* @__PURE__ */ e(m, { role: "separator" }) : "",
34
34
  d && /* @__PURE__ */ e(m, { children: /* @__PURE__ */ e(w, { title: d }) }),
35
- t == null ? void 0 : t.items.filter((r) => {
36
- var o;
37
- return !((o = r.props) != null && o.hidden);
38
- }).map((r, o) => {
35
+ t == null ? void 0 : t.items.filter((o) => {
36
+ var i;
37
+ return !((i = o.props) != null && i.hidden);
38
+ }).map((o, i) => {
39
39
  var h;
40
- const { active: A, onMouseEnter: F } = r, { groupId: u, onClick: E, value: f, checked: M, type: b, ...i } = r.props || {}, { expanded: H } = i, x = i.name || k, y = b || u && ((h = a[u]) == null ? void 0 : h.optionType) || L;
40
+ const { active: A, onMouseEnter: F } = o, { groupId: u, onClick: E, value: f, checked: M, type: b, ...r } = o.props || {}, { expanded: H } = r, x = r.name || k, y = b || u && ((h = a[u]) == null ? void 0 : h.optionType) || L;
41
41
  return /* @__PURE__ */ e(
42
42
  m,
43
43
  {
@@ -49,10 +49,11 @@ const G = ({
49
49
  children: /* @__PURE__ */ e(
50
50
  S,
51
51
  {
52
+ ...r,
52
53
  active: A,
53
54
  tabIndex: p ? -1 : 0,
54
- label: i.label,
55
- badge: i.badge,
55
+ label: r.label,
56
+ badge: r.badge,
56
57
  name: x,
57
58
  type: y,
58
59
  value: f,
@@ -67,7 +68,7 @@ const G = ({
67
68
  }
68
69
  )
69
70
  },
70
- o
71
+ i
71
72
  );
72
73
  })
73
74
  ] }, l);
@@ -0,0 +1,4 @@
1
+ import { formatDisplayName as o } from "./name/name.js";
2
+ export {
3
+ o as formatDisplayName
4
+ };
@@ -0,0 +1,4 @@
1
+ import { formatDisplayName as o } from "./name.js";
2
+ export {
3
+ o as formatDisplayName
4
+ };
@@ -0,0 +1,16 @@
1
+ const l = ({ fullName: n, type: a, reverseNameOrder: i }) => {
2
+ if (!n) return "";
3
+ const p = ["enk", "as", "da", "sa", "asa", "ba", "ans", "sti", "nuf"], r = n.toLowerCase().split(" ");
4
+ let t = r.map((s, e) => {
5
+ const c = e === r.length - 1;
6
+ return a === "company" && c && p.includes(s) ? s.toUpperCase() : s.split("-").map((o) => o.charAt(0).toUpperCase() + o.slice(1)).join("-");
7
+ });
8
+ if (a === "person" && i && t.length > 1) {
9
+ const [s, ...e] = t;
10
+ t = [...e, s];
11
+ }
12
+ return t.join(" ");
13
+ };
14
+ export {
15
+ l as formatDisplayName
16
+ };
@@ -0,0 +1,21 @@
1
+ import { describe as s, it as e, expect as t } from "vitest";
2
+ import { formatDisplayName as a } from "./name.js";
3
+ s("formatDisplayName", () => {
4
+ e("formats a simple person name", () => {
5
+ t(a({ fullName: "TEST TESTESEN", type: "person" })).toBe("Test Testesen");
6
+ }), e("formats a person name with reordering (surname first)", () => {
7
+ t(a({ fullName: "TESTESEN TEST", type: "person", reverseNameOrder: !0 })).toBe(
8
+ "Test Testesen"
9
+ );
10
+ }), e("formats a person name with hyphenated last name", () => {
11
+ t(a({ fullName: "TEST TESTY-TEST", type: "person" })).toBe("Test Testy-Test");
12
+ }), e("formats a company name and uppercases legal entity suffix", () => {
13
+ t(a({ fullName: "test as", type: "company" })).toBe("Test AS");
14
+ }), e("formats a company name and uppercases legal entity suffix", () => {
15
+ t(a({ fullName: "WORK AS FRIENDS AS", type: "company" })).toBe("Work As Friends AS");
16
+ }), e("handles company names with hyphenation and suffix", () => {
17
+ t(a({ fullName: "test testy-test da", type: "company" })).toBe("Test Testy-Test DA");
18
+ }), e("returns empty string for empty input", () => {
19
+ t(a({ fullName: "", type: "person" })).toBe("");
20
+ });
21
+ });
package/dist/index.js CHANGED
@@ -9,13 +9,13 @@ import { AccountList as B } from "./components/Account/AccountList.js";
9
9
  import { AccountNotificationSettings as S } from "./components/Account/AccountNotificationSettings.js";
10
10
  import { Badge as b } from "./components/Badge/Badge.js";
11
11
  import { Banner as M, BannerColorEnum as k } from "./components/Banner/Banner.js";
12
- import { BookmarksListItem as y } from "./components/Bookmarks/BookmarksListItem.js";
12
+ import { BookmarksListItem as T } from "./components/Bookmarks/BookmarksListItem.js";
13
13
  import { EditableBookmark as H } from "./components/Bookmarks/EditableBookmark.js";
14
14
  import { BookmarksSection as P } from "./components/Bookmarks/BookmarksSection.js";
15
15
  import { BookmarksSettingsItem as v } from "./components/Bookmarks/BookmarksSettingsItem.js";
16
16
  import { BookmarksSettingsSection as G } from "./components/Bookmarks/BookmarksSettingsSection.js";
17
17
  import { BookmarksSettingsModal as O } from "./components/Bookmarks/BookmarksSettingsModal.js";
18
- import { ButtonBase as U } from "./components/Button/ButtonBase.js";
18
+ import { ButtonBase as N } from "./components/Button/ButtonBase.js";
19
19
  import { ButtonLabel as Q } from "./components/Button/ButtonLabel.js";
20
20
  import { ButtonIcon as j } from "./components/Button/ButtonIcon.js";
21
21
  import { Button as K } from "./components/Button/Button.js";
@@ -35,14 +35,14 @@ import { DialogContact as Bo } from "./components/Dialog/DialogContact.js";
35
35
  import { DialogHistory as So } from "./components/Dialog/DialogHistory.js";
36
36
  import { DialogHistorySegment as bo } from "./components/Dialog/DialogHistorySegment.js";
37
37
  import { DialogHistoryItem as Mo } from "./components/Dialog/DialogHistoryItem.js";
38
- import { DialogList as To } from "./components/Dialog/DialogList.js";
38
+ import { DialogList as yo } from "./components/Dialog/DialogList.js";
39
39
  import { DialogListGroup as ho } from "./components/Dialog/DialogListGroup.js";
40
40
  import { DialogListItem as Co } from "./components/Dialog/DialogListItem.js";
41
41
  import { DialogMetadata as Fo } from "./components/Dialog/DialogMetadata.js";
42
42
  import { DialogByline as wo } from "./components/Dialog/DialogByline.js";
43
43
  import { DialogActions as Eo } from "./components/Dialog/DialogActions.js";
44
44
  import { DialogActivityLog as Ro } from "./components/Dialog/DialogActivityLog.js";
45
- import { DialogSeenBy as No } from "./components/Dialog/DialogSeenBy.js";
45
+ import { DialogSeenBy as Uo } from "./components/Dialog/DialogSeenBy.js";
46
46
  import { DialogSelect as Vo } from "./components/Dialog/DialogSelect.js";
47
47
  import { DialogStatus as zo, DialogStatusEnum as Ko } from "./components/Dialog/DialogStatus.js";
48
48
  import { DialogAttachments as Jo } from "./components/Dialog/DialogAttachments.js";
@@ -62,13 +62,13 @@ import { Footer as Lr } from "./components/Footer/Footer.js";
62
62
  import { CurrentAccount as Ir } from "./components/GlobalMenu/CurrentAccount.js";
63
63
  import { BackButton as Ar } from "./components/GlobalMenu/BackButton.js";
64
64
  import { LogoutButton as kr } from "./components/GlobalMenu/LogoutButton.js";
65
- import { EndUserLabel as yr } from "./components/GlobalMenu/EndUserLabel.js";
65
+ import { EndUserLabel as Tr } from "./components/GlobalMenu/EndUserLabel.js";
66
66
  import { GlobalMenu as Hr } from "./components/GlobalMenu/GlobalMenu.js";
67
67
  import { GlobalMenuButton as Pr } from "./components/GlobalMenu/GlobalMenuButton.js";
68
68
  import { Header as vr } from "./components/Header/Header.js";
69
69
  import { HeaderBase as Gr } from "./components/Header/HeaderBase.js";
70
70
  import { HeaderLogo as Or } from "./components/Header/HeaderLogo.js";
71
- import { HeaderButton as Ur } from "./components/Header/HeaderButton.js";
71
+ import { HeaderButton as Nr } from "./components/Header/HeaderButton.js";
72
72
  import { HeaderGroup as Qr } from "./components/Header/HeaderGroup.js";
73
73
  import { HeaderSearch as jr } from "./components/Header/HeaderSearch.js";
74
74
  import { LocaleButton as Kr } from "./components/Header/LocaleButton.js";
@@ -88,13 +88,13 @@ import { ActionFooter as Be } from "./components/LayoutAction/ActionFooter.js";
88
88
  import { LayoutAction as Se } from "./components/LayoutAction/LayoutAction.js";
89
89
  import { ListItemBase as be } from "./components/List/ListItemBase.js";
90
90
  import { ListItemLink as Me } from "./components/List/ListItemLink.js";
91
- import { ListItemHeader as Te } from "./components/List/ListItemHeader.js";
91
+ import { ListItemHeader as ye } from "./components/List/ListItemHeader.js";
92
92
  import { ListItemLabel as he, isHeadingProps as He } from "./components/List/ListItemLabel.js";
93
93
  import { ListItemIcon as Pe } from "./components/List/ListItemIcon.js";
94
94
  import { ListItemControls as ve } from "./components/List/ListItemControls.js";
95
95
  import { ListItemSelect as Ge } from "./components/List/ListItemSelect.js";
96
96
  import { ListItem as Oe } from "./components/List/ListItem.js";
97
- import { List as Ue } from "./components/List/List.js";
97
+ import { List as Ne } from "./components/List/List.js";
98
98
  import { MenuItemBase as Qe } from "./components/Menu/MenuItemBase.js";
99
99
  import { MenuItemLabel as je, getAriaLabelFromTitle as ze } from "./components/Menu/MenuItemLabel.js";
100
100
  import { MenuItemIcon as qe } from "./components/Menu/MenuItemIcon.js";
@@ -113,13 +113,13 @@ import { MetaItemLabel as Bt } from "./components/Metadata/MetaItemLabel.js";
113
113
  import { MetaItem as St } from "./components/Metadata/MetaItem.js";
114
114
  import { MetaProgress as bt } from "./components/Metadata/MetaProgress.js";
115
115
  import { MetaTimestamp as Mt } from "./components/Metadata/MetaTimestamp.js";
116
- import { MetaListItem as Tt, Metadata as yt } from "./components/Metadata/Metadata.js";
116
+ import { MetaListItem as yt, Metadata as Tt } from "./components/Metadata/Metadata.js";
117
117
  import { RootProvider as Ht, useRootContext as Ct } from "./components/RootProvider/RootProvider.js";
118
118
  import { SearchItem as Ft } from "./components/Search/SearchItem.js";
119
119
  import { Searchbar as wt } from "./components/Searchbar/Searchbar.js";
120
120
  import { SearchbarBase as Et } from "./components/Searchbar/SearchbarBase.js";
121
121
  import { SearchbarField as Rt } from "./components/Searchbar/SearchbarField.js";
122
- import { AutocompleteBase as Nt } from "./components/Searchbar/AutocompleteBase.js";
122
+ import { AutocompleteBase as Ut } from "./components/Searchbar/AutocompleteBase.js";
123
123
  import { AutocompleteGroup as Vt } from "./components/Searchbar/AutocompleteGroup.js";
124
124
  import { Autocomplete as zt } from "./components/Searchbar/Autocomplete.js";
125
125
  import { AutocompleteItem as qt } from "./components/Searchbar/AutocompleteItem.js";
@@ -137,14 +137,14 @@ import { TimelineHeader as Bm } from "./components/Timeline/TimelineHeader.js";
137
137
  import { TimelineFooter as Sm } from "./components/Timeline/TimelineFooter.js";
138
138
  import { TimelineIcon as bm } from "./components/Timeline/TimelineIcon.js";
139
139
  import { TimelineLink as Mm } from "./components/Timeline/TimelineLink.js";
140
- import { ToolbarBase as Tm } from "./components/Toolbar/ToolbarBase.js";
140
+ import { ToolbarBase as ym } from "./components/Toolbar/ToolbarBase.js";
141
141
  import { ToolbarButton as hm } from "./components/Toolbar/ToolbarButton.js";
142
142
  import { Toolbar as Cm } from "./components/Toolbar/Toolbar.js";
143
143
  import { ToolbarSearch as Fm } from "./components/Toolbar/ToolbarSearch.js";
144
144
  import { ToolbarFilterBase as wm } from "./components/Toolbar/ToolbarFilterBase.js";
145
145
  import { ToolbarFilter as Em } from "./components/Toolbar/ToolbarFilter.js";
146
146
  import { ToolbarDaterange as Rm } from "./components/Toolbar/ToolbarDaterange.js";
147
- import { PageBase as Nm } from "./components/Page/PageBase.js";
147
+ import { PageBase as Um } from "./components/Page/PageBase.js";
148
148
  import { PageNav as Vm } from "./components/Page/PageNav.js";
149
149
  import { PageMenu as zm } from "./components/Page/PageMenu.js";
150
150
  import { PageTabs as qm } from "./components/Page/PageTabs.js";
@@ -164,13 +164,13 @@ import { Typography as La } from "./components/Typography/Typography.js";
164
164
  import { Heading as Ia } from "./components/Typography/Heading.js";
165
165
  import { ResourceListItem as Aa } from "./components/ResourceListItem/ResourceListItem.js";
166
166
  import { AccessAreaListItem as ka } from "./components/AccessAreaListItem/AccessAreaListItem.js";
167
- import { AccessPackageListItem as ya } from "./components/AccessPackageListItem/AccessPackageListItem.js";
167
+ import { AccessPackageListItem as Ta } from "./components/AccessPackageListItem/AccessPackageListItem.js";
168
168
  import { UserListItem as Ha } from "./components/UserListItem/UserListItem.js";
169
169
  import { Field as Pa } from "./components/Forms/Field.js";
170
170
  import { Fieldset as va } from "./components/Forms/Fieldset.js";
171
171
  import { Legend as Ga } from "./components/Forms/Legend.js";
172
172
  import { Label as Oa } from "./components/Forms/Label.js";
173
- import { Input as Ua } from "./components/Forms/Input.js";
173
+ import { Input as Na } from "./components/Forms/Input.js";
174
174
  import { Textarea as Qa } from "./components/Forms/Textarea.js";
175
175
  import { Select as ja } from "./components/Forms/Select.js";
176
176
  import { Radio as Ka } from "./components/Forms/Radio.js";
@@ -191,13 +191,13 @@ import { SettingsItem as Lp } from "./components/Settings/SettingsItem.js";
191
191
  import { SettingsList as Ip } from "./components/Settings/SettingsList.js";
192
192
  import { SettingsModal as Ap } from "./components/Settings/SettingsModal.js";
193
193
  import { DashboardHeader as kp } from "./components/Dashboard/DashboardHeader.js";
194
- import { DashboardCard as yp } from "./components/Dashboard/DashboardCard.js";
194
+ import { DashboardCard as Tp } from "./components/Dashboard/DashboardCard.js";
195
195
  import { DashboardIcon as Hp } from "./components/Dashboard/DashboardIcon.js";
196
196
  import { ActivityLog as Pp } from "./components/ActivityLog/ActivityLog.js";
197
197
  import { ActivityLogSegment as vp } from "./components/ActivityLog/ActivityLogSegment.js";
198
198
  import { ActivityLogItem as Gp } from "./components/ActivityLog/ActivityLogItem.js";
199
199
  import { ArticleHeader as Op } from "./components/Article/ArticleHeader.js";
200
- import { ArticleContact as Up } from "./components/Article/ArticleContact.js";
200
+ import { ArticleContact as Np } from "./components/Article/ArticleContact.js";
201
201
  import { Article as Qp } from "./components/Article/Article.js";
202
202
  import { ModalBase as jp } from "./components/Modal/ModalBase.js";
203
203
  import { ModalHeader as Kp } from "./components/Modal/ModalHeader.js";
@@ -207,13 +207,14 @@ import { Modal as Zp } from "./components/Modal/Modal.js";
207
207
  import { useClickOutside as $p } from "./hooks/useClickOutside.js";
208
208
  import { useEscapeKey as rx } from "./hooks/useEscapeKey.js";
209
209
  import { useMenu as tx } from "./hooks/useMenu.js";
210
- import { A as ax, B as px, a as xx, C as fx, b as ix, c as sx, D as nx, H as cx, L as lx, d as ux, e as dx, P as gx, f as Dx, g as Bx, h as Lx, i as Sx, S as Ix, j as bx, T as Ax, u as Mx } from "./usePagination-Bdiq8ITD.js";
211
- import { D as Tx } from "./index-D3Rt9ate.js";
212
- import { P as hx } from "./Paragraph-Bm-eoPYv.js";
213
- import { V as Cx } from "./index-CnWc2FNH.js";
210
+ import { formatDisplayName as ax } from "./functions/name/name.js";
211
+ import { A as xx, B as fx, a as ix, C as sx, b as nx, c as cx, D as lx, H as ux, L as dx, d as gx, e as Dx, P as Bx, f as Lx, g as Sx, h as Ix, i as bx, S as Ax, j as Mx, T as kx, u as yx } from "./usePagination-Bdiq8ITD.js";
212
+ import { D as hx } from "./index-D3Rt9ate.js";
213
+ import { P as Cx } from "./Paragraph-Bm-eoPYv.js";
214
+ import { V as Fx } from "./index-CnWc2FNH.js";
214
215
  export {
215
216
  ka as AccessAreaListItem,
216
- ya as AccessPackageListItem,
217
+ Ta as AccessPackageListItem,
217
218
  sa as AccordionSection,
218
219
  B as AccountList,
219
220
  g as AccountListItem,
@@ -225,12 +226,12 @@ export {
225
226
  Gp as ActivityLogItem,
226
227
  vp as ActivityLogSegment,
227
228
  Qp as Article,
228
- Up as ArticleContact,
229
+ Np as ArticleContact,
229
230
  Op as ArticleHeader,
230
231
  m as AttachmentLink,
231
232
  p as AttachmentList,
232
233
  zt as Autocomplete,
233
- Nt as AutocompleteBase,
234
+ Ut as AutocompleteBase,
234
235
  Vt as AutocompleteGroup,
235
236
  qt as AutocompleteItem,
236
237
  f as Avatar,
@@ -240,7 +241,7 @@ export {
240
241
  b as Badge,
241
242
  M as Banner,
242
243
  k as BannerColorEnum,
243
- y as BookmarksListItem,
244
+ T as BookmarksListItem,
244
245
  P as BookmarksSection,
245
246
  v as BookmarksSettingsItem,
246
247
  O as BookmarksSettingsModal,
@@ -248,7 +249,7 @@ export {
248
249
  oa as Breadcrumbs,
249
250
  ea as BreadcrumbsLink,
250
251
  K as Button,
251
- U as ButtonBase,
252
+ N as ButtonBase,
252
253
  $ as ButtonGroup,
253
254
  j as ButtonIcon,
254
255
  Q as ButtonLabel,
@@ -261,7 +262,7 @@ export {
261
262
  pa as ContactSection,
262
263
  to as ContextMenu,
263
264
  Ir as CurrentAccount,
264
- yp as DashboardCard,
265
+ Tp as DashboardCard,
265
266
  kp as DashboardHeader,
266
267
  Hp as DashboardIcon,
267
268
  ao as Dialog,
@@ -276,12 +277,12 @@ export {
276
277
  Mo as DialogHistoryItem,
277
278
  bo as DialogHistorySegment,
278
279
  xo as DialogLayout,
279
- To as DialogList,
280
+ yo as DialogList,
280
281
  ho as DialogListGroup,
281
282
  Co as DialogListItem,
282
283
  Fo as DialogMetadata,
283
284
  go as DialogSection,
284
- No as DialogSeenBy,
285
+ Uo as DialogSeenBy,
285
286
  Vo as DialogSelect,
286
287
  zo as DialogStatus,
287
288
  Ko as DialogStatusEnum,
@@ -294,30 +295,30 @@ export {
294
295
  ir as DrawerHeader,
295
296
  Dr as DrawerOrDropdown,
296
297
  tr as DropdownBase,
297
- ax as DsAlert,
298
- px as DsBadge,
299
- xx as DsButton,
300
- fx as DsCheckbox,
301
- ix as DsChip,
302
- sx as DsCombobox,
303
- Tx as DsDetails,
304
- nx as DsDialog,
305
- cx as DsHeading,
306
- lx as DsLink,
307
- ux as DsListItem,
308
- dx as DsListUnordered,
309
- gx as DsPagination,
310
- hx as DsParagraph,
311
- Dx as DsPopover,
312
- Bx as DsSearch,
313
- Lx as DsSkeleton,
314
- Sx as DsSpinner,
315
- Ix as DsSwitch,
316
- bx as DsTabs,
317
- Ax as DsTextfield,
318
- Cx as DsValidationMessage,
298
+ xx as DsAlert,
299
+ fx as DsBadge,
300
+ ix as DsButton,
301
+ sx as DsCheckbox,
302
+ nx as DsChip,
303
+ cx as DsCombobox,
304
+ hx as DsDetails,
305
+ lx as DsDialog,
306
+ ux as DsHeading,
307
+ dx as DsLink,
308
+ gx as DsListItem,
309
+ Dx as DsListUnordered,
310
+ Bx as DsPagination,
311
+ Cx as DsParagraph,
312
+ Lx as DsPopover,
313
+ Sx as DsSearch,
314
+ Ix as DsSkeleton,
315
+ bx as DsSpinner,
316
+ Ax as DsSwitch,
317
+ Mx as DsTabs,
318
+ kx as DsTextfield,
319
+ Fx as DsValidationMessage,
319
320
  H as EditableBookmark,
320
- yr as EndUserLabel,
321
+ Tr as EndUserLabel,
321
322
  Pa as Field,
322
323
  Za as FieldBase,
323
324
  va as Fieldset,
@@ -330,7 +331,7 @@ export {
330
331
  _m as Grid,
331
332
  vr as Header,
332
333
  Gr as HeaderBase,
333
- Ur as HeaderButton,
334
+ Nr as HeaderButton,
334
335
  Qr as HeaderGroup,
335
336
  Or as HeaderLogo,
336
337
  jr as HeaderSearch,
@@ -338,7 +339,7 @@ export {
338
339
  Xr as Icon,
339
340
  X as IconButton,
340
341
  me as IconOrAvatar,
341
- Ua as Input,
342
+ Na as Input,
342
343
  Oa as Label,
343
344
  ue as Layout,
344
345
  Se as LayoutAction,
@@ -347,11 +348,11 @@ export {
347
348
  se as LayoutContent,
348
349
  ce as LayoutSidebar,
349
350
  Ga as Legend,
350
- Ue as List,
351
+ Ne as List,
351
352
  Oe as ListItem,
352
353
  be as ListItemBase,
353
354
  ve as ListItemControls,
354
- Te as ListItemHeader,
355
+ ye as ListItemHeader,
355
356
  Pe as ListItemIcon,
356
357
  he as ListItemLabel,
357
358
  Me as ListItemLink,
@@ -377,17 +378,17 @@ export {
377
378
  ut as MetaItemBase,
378
379
  gt as MetaItemIcon,
379
380
  Bt as MetaItemLabel,
380
- Tt as MetaListItem,
381
+ yt as MetaListItem,
381
382
  bt as MetaProgress,
382
383
  Mt as MetaTimestamp,
383
- yt as Metadata,
384
+ Tt as Metadata,
384
385
  Zp as Modal,
385
386
  jp as ModalBase,
386
387
  Xp as ModalBody,
387
388
  Kp as ModalHeader,
388
389
  Jp as ModalIcon,
389
390
  ip as OptionsBase,
390
- Nm as PageBase,
391
+ Um as PageBase,
391
392
  Wm as PageDetails,
392
393
  zm as PageMenu,
393
394
  Vm as PageNav,
@@ -437,7 +438,7 @@ export {
437
438
  gm as TimelineSection,
438
439
  sm as TimelineSegment,
439
440
  Cm as Toolbar,
440
- Tm as ToolbarBase,
441
+ ym as ToolbarBase,
441
442
  hm as ToolbarButton,
442
443
  Rm as ToolbarDaterange,
443
444
  Em as ToolbarFilter,
@@ -449,13 +450,14 @@ export {
449
450
  da as TransmissionTypeEnum,
450
451
  La as Typography,
451
452
  Ha as UserListItem,
453
+ ax as formatDisplayName,
452
454
  ze as getAriaLabelFromTitle,
453
455
  c as isAvatarGroupProps,
454
456
  i as isAvatarProps,
455
457
  He as isHeadingProps,
456
458
  Yr as isIconProps,
457
459
  $p as useClickOutside,
458
- Mx as useDsPagination,
460
+ yx as useDsPagination,
459
461
  rx as useEscapeKey,
460
462
  tx as useMenu,
461
463
  Ct as useRootContext,
@@ -8,6 +8,8 @@ export type AvatarVariant = 'solid' | 'outline';
8
8
  * Props for the Avatar component.
9
9
  */
10
10
  export interface AvatarProps {
11
+ /** Optional Id */
12
+ id?: string;
11
13
  /** The name to display in the avatar. */
12
14
  name: string;
13
15
  /** The type of avatar. */
@@ -1,9 +1,12 @@
1
- import { BadgeProps } from '..';
1
+ import { BadgeProps, MenuItemProps } from '..';
2
2
  import { MenuItemBaseProps, MenuItemSize } from './MenuItemBase';
3
3
  export type MenuOptionType = 'checkbox' | 'radio';
4
4
  export interface MenuOptionProps extends MenuItemBaseProps {
5
5
  value: string | number;
6
6
  label: string;
7
+ icon?: MenuItemProps['icon'];
8
+ title?: MenuItemProps['title'];
9
+ description?: MenuItemProps['description'];
7
10
  groupId?: string;
8
11
  size?: MenuItemSize;
9
12
  name?: string;
@@ -14,4 +17,4 @@ export interface MenuOptionProps extends MenuItemBaseProps {
14
17
  hidden?: boolean;
15
18
  role?: string;
16
19
  }
17
- export declare const MenuOption: ({ size, type, name, active, value, label, badge, checked, disabled, onMouseEnter, onClick, role, ...rest }: MenuOptionProps) => import("react/jsx-runtime").JSX.Element;
20
+ export declare const MenuOption: ({ size, type, name, active, value, label, title, description, icon, badge, checked, disabled, onMouseEnter, onClick, role, ...rest }: MenuOptionProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from './name';
@@ -0,0 +1 @@
1
+ export * from './name.ts';
@@ -0,0 +1,22 @@
1
+ interface FormatDisplayNameInput {
2
+ /** Full name of person or company */
3
+ fullName: string;
4
+ /** Entity type: Whether this is a person or a company */
5
+ type: 'person' | 'company';
6
+ /** For persons: switch order of first/last name */
7
+ reverseNameOrder?: boolean;
8
+ }
9
+ /**
10
+ * Formats a display name for a person or company by applying title casing,
11
+ * normalizing hyphenated words, and (for companies) uppercasing known legal
12
+ * entity suffixes.
13
+ *
14
+ * For persons, you can optionally reorder the name by moving the first word
15
+ * (often a surname) to the end.
16
+ *
17
+ * @param {FormatDisplayNameInput} input - The input object with full name, entity type, and options.
18
+ * @returns {string} The formatted display name.
19
+ *
20
+ */
21
+ export declare const formatDisplayName: ({ fullName, type, reverseNameOrder }: FormatDisplayNameInput) => string;
22
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,3 @@
1
1
  export * from './components';
2
2
  export * from './hooks';
3
+ export * from './functions';
@@ -0,0 +1,10 @@
1
+ declare const meta: {
2
+ title: string;
3
+ tags: string[];
4
+ parameters: {};
5
+ args: {};
6
+ };
7
+ export default meta;
8
+ export declare const CompanyDashboard: () => import("react/jsx-runtime").JSX.Element;
9
+ export declare const PersonDashboard: () => import("react/jsx-runtime").JSX.Element;
10
+ export declare const UserDashboard: () => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import { ChangeEvent } from 'react';
2
- import { SettingsListProps, SettingsModalProps, AccountListItemProps } from '../../components';
2
+ import { UseSettingsProps } from '../../../examples';
3
+ import { SettingsModalProps, AccountListItemProps } from '../../components';
3
4
  declare const meta: {
4
5
  title: string;
5
6
  tags: string[];
@@ -13,6 +14,12 @@ interface ContactProfileModalProps extends SettingsModalProps {
13
14
  readOnly?: boolean;
14
15
  items?: AccountListItemProps[];
15
16
  }
17
+ interface SettingsValueModalProps extends SettingsModalProps {
18
+ value?: string;
19
+ }
20
+ export declare const CompanyInfoModal: ({ open, onClose, }: SettingsModalProps) => import("react/jsx-runtime").JSX.Element;
21
+ export declare const CompanyEmailSettingsModal: ({ title, icon, value, open, onClose, }: SettingsValueModalProps) => import("react/jsx-runtime").JSX.Element;
22
+ export declare const CompanyPhoneSettingsModal: ({ title, icon, value, open, onClose, }: SettingsValueModalProps) => import("react/jsx-runtime").JSX.Element;
16
23
  export declare const ContactProfileModal: ({ title, icon, type, value, readOnly, items, open, onClose, }: ContactProfileModalProps) => import("react/jsx-runtime").JSX.Element;
17
24
  export declare const PhoneSettingsModal: ({ open, onClose, }: SettingsModalProps) => import("react/jsx-runtime").JSX.Element;
18
25
  export declare const EmailSettingsModal: ({ open, onClose, }: SettingsModalProps) => import("react/jsx-runtime").JSX.Element;
@@ -23,11 +30,10 @@ interface LocaleSettingsModal extends SettingsModalProps {
23
30
  value?: string;
24
31
  }
25
32
  export declare const LocaleSettingsModal: ({ open, onClose, value, onChange, }: LocaleSettingsModal) => import("react/jsx-runtime").JSX.Element;
26
- interface SearchSettingsProps {
27
- title?: string;
28
- groups?: SettingsListProps["groups"];
29
- }
30
- export declare const SearchSettings: ({ title, groups }: SearchSettingsProps) => import("react/jsx-runtime").JSX.Element;
33
+ export declare const SearchSettings: ({ query, groups }: UseSettingsProps) => import("react/jsx-runtime").JSX.Element;
31
34
  export declare const AlertSettings: () => import("react/jsx-runtime").JSX.Element;
32
- export declare const AllSettings: () => import("react/jsx-runtime").JSX.Element;
35
+ export declare const AccountSettings: () => import("react/jsx-runtime").JSX.Element;
36
+ export declare const PersonSettings: () => import("react/jsx-runtime").JSX.Element;
37
+ export declare const CompanySettings: () => import("react/jsx-runtime").JSX.Element;
38
+ export declare const AdminSettings: () => import("react/jsx-runtime").JSX.Element;
33
39
  export declare const DashboardSettings: () => 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.38.20",
3
+ "version": "0.39.0",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",
@@ -39,6 +39,7 @@
39
39
  "@storybook/addon-themes": "^9.0.4",
40
40
  "@storybook/react-vite": "^9.0.4",
41
41
  "@storybook/test-runner": "^0.22.0",
42
+ "@testing-library/react": "^16.3.0",
42
43
  "@types/react": "^19.1.5",
43
44
  "@types/react-dom": "^18.3.7",
44
45
  "@vitejs/plugin-react-swc": "^3.9.0",
@@ -55,7 +56,8 @@
55
56
  "vite": "^5.4.19",
56
57
  "vite-plugin-dts": "^4.5.4",
57
58
  "vite-plugin-lib-inject-css": "^2.2.2",
58
- "vite-plugin-static-copy": "^2.3.1"
59
+ "vite-plugin-static-copy": "^2.3.1",
60
+ "vitest": "^3.2.4"
59
61
  },
60
62
  "peerDependencies": {
61
63
  "react": ">=18.3.1 || ^19.0.0",
@@ -65,7 +67,7 @@
65
67
  "**/*.*": "biome check --staged --no-errors-on-unmatched --write"
66
68
  },
67
69
  "scripts": {
68
- "test": "echo \"Error: no test specified\" && exit 1",
70
+ "test": "vitest run",
69
71
  "storybook": "storybook dev -p 6006",
70
72
  "typecheck": "tsc --noEmit",
71
73
  "build": "tsc && vite build",
@@ -1,17 +0,0 @@
1
- import { SettingsModalProps } from '../../components';
2
- declare const meta: {
3
- title: string;
4
- tags: string[];
5
- parameters: {};
6
- args: {};
7
- };
8
- export default meta;
9
- export declare const CompanyEmailSettingsModal: ({ open, onClose, }: SettingsModalProps) => import("react/jsx-runtime").JSX.Element;
10
- export declare const CompanyPhoneSettingsModal: ({ open, onClose, }: SettingsModalProps) => import("react/jsx-runtime").JSX.Element;
11
- export declare const DashboardSettings: () => import("react/jsx-runtime").JSX.Element;
12
- export declare const AlertSettings: () => import("react/jsx-runtime").JSX.Element;
13
- export declare const CompanySettingsX: () => import("react/jsx-runtime").JSX.Element;
14
- export declare const AccountantSettings: () => import("react/jsx-runtime").JSX.Element;
15
- export declare const RoleSettings: () => import("react/jsx-runtime").JSX.Element;
16
- export declare const SearchSettings: () => import("react/jsx-runtime").JSX.Element;
17
- export declare const AdminSettings: () => import("react/jsx-runtime").JSX.Element;