@altinn/altinn-components 0.44.4 → 0.45.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.
Files changed (163) hide show
  1. package/dist/ArrowUndo-hge1gMu8.js +24 -0
  2. package/dist/Button-B0t0vz2h.js +23 -0
  3. package/dist/Globe-BcPkcH4E.js +24 -0
  4. package/dist/Heading-By5DKz2H.js +12 -0
  5. package/dist/HeartFill-CYSrJ_xK.js +43 -0
  6. package/dist/PersonCircle-DlX_3kRO.js +24 -0
  7. package/dist/Spinner-BDXfwXIh.js +26 -0
  8. package/dist/assets/AccountMenuButton.css +1 -0
  9. package/dist/assets/AccountSelector.css +1 -0
  10. package/dist/assets/GlobalHeader.css +1 -0
  11. package/dist/assets/GlobalHeaderBase.css +1 -0
  12. package/dist/assets/GlobalMenuButton2.css +1 -0
  13. package/dist/assets/HeaderGroup2.css +1 -0
  14. package/dist/assets/HeaderLogo2.css +1 -0
  15. package/dist/assets/LayoutBody.css +1 -1
  16. package/dist/assets/NotificationItemBase.css +1 -0
  17. package/dist/assets/NotificationItemIcon.css +1 -0
  18. package/dist/assets/globalSearch.css +1 -0
  19. package/dist/components/Account/AccountListItemControls.js +22 -58
  20. package/dist/components/Account/AccountMenu.js +40 -36
  21. package/dist/components/Account/AccountMenuButton.js +131 -0
  22. package/dist/components/Account/AccountNotificationSettings.js +1 -1
  23. package/dist/components/Avatar/Avatar.js +23 -22
  24. package/dist/components/Bookmarks/BookmarksListItem.js +7 -9
  25. package/dist/components/Bookmarks/BookmarksSection.js +27 -23
  26. package/dist/components/Bookmarks/EditableBookmark.js +63 -78
  27. package/dist/components/Dashboard/DashboardHeader.js +1 -1
  28. package/dist/components/Dropdown/DrawerBase.js +17 -15
  29. package/dist/components/Dropdown/DropdownBase.js +14 -12
  30. package/dist/components/Dropdown/FloatingDropdown.js +6 -6
  31. package/dist/components/DsComponents/index.js +26 -22
  32. package/dist/components/Forms/Checkbox.js +1 -1
  33. package/dist/components/Forms/CheckboxOptions.js +1 -1
  34. package/dist/components/Forms/FieldBase.js +1 -1
  35. package/dist/components/Forms/FieldsetBase.js +1 -1
  36. package/dist/components/Forms/Radio.js +1 -1
  37. package/dist/components/Forms/RadioOptions.js +1 -1
  38. package/dist/components/Forms/SearchField.js +1 -1
  39. package/dist/components/Forms/SelectField.js +1 -1
  40. package/dist/components/Forms/Switch.js +1 -1
  41. package/dist/components/Forms/SwitchOptions.js +1 -1
  42. package/dist/components/Forms/TextField.js +1 -1
  43. package/dist/components/Forms/TextareaField.js +1 -1
  44. package/dist/components/GlobalHeader/AccountSelector.js +138 -0
  45. package/dist/components/GlobalHeader/DigdirLogomark.js +109 -0
  46. package/dist/components/GlobalHeader/GlobalHeader.js +117 -0
  47. package/dist/components/GlobalHeader/GlobalHeaderBase.js +22 -0
  48. package/dist/components/GlobalHeader/GlobalSearch.js +57 -0
  49. package/dist/components/GlobalHeader/GlobalSearchButton.js +53 -0
  50. package/dist/components/GlobalHeader/HeaderGroup.js +8 -0
  51. package/dist/components/GlobalHeader/HeaderLogo.js +17 -0
  52. package/dist/components/GlobalHeader/index.js +6 -0
  53. package/dist/components/GlobalMenu/BackButton.js +6 -24
  54. package/dist/components/GlobalMenu/EndUserLabel.js +10 -29
  55. package/dist/components/GlobalMenu/GlobalMenu.js +38 -61
  56. package/dist/components/GlobalMenu/GlobalMenuButton.js +69 -47
  57. package/dist/components/GlobalMenu/LocaleButton.js +12 -0
  58. package/dist/components/GlobalMenu/LocaleSwitcher.js +34 -0
  59. package/dist/components/GlobalMenu/index.js +6 -12
  60. package/dist/components/GlobalMenu_old/BackButton.js +11 -0
  61. package/dist/components/GlobalMenu_old/EndUserLabel.js +13 -0
  62. package/dist/components/GlobalMenu_old/GlobalMenu.js +75 -0
  63. package/dist/components/GlobalMenu_old/GlobalMenuBase.js +10 -0
  64. package/dist/components/GlobalMenu_old/GlobalMenuButton.js +58 -0
  65. package/dist/components/GlobalMenu_old/LogoutButton.js +14 -0
  66. package/dist/components/GlobalMenu_old/index.js +14 -0
  67. package/dist/components/Header/Header.js +25 -25
  68. package/dist/components/Header/LocaleButton.js +13 -30
  69. package/dist/components/Layout/Layout.js +25 -23
  70. package/dist/components/Layout/LayoutBody.js +1 -1
  71. package/dist/components/List/ListItemSelect.js +1 -1
  72. package/dist/components/Menu/MenuItem.js +1 -1
  73. package/dist/components/Menu/MenuSearch.js +2 -2
  74. package/dist/components/Notifications/NotificationItem.js +17 -0
  75. package/dist/components/Notifications/NotificationItemBase.js +86 -0
  76. package/dist/components/Notifications/NotificationItemControls.js +33 -0
  77. package/dist/components/Notifications/NotificationItemIcon.js +33 -0
  78. package/dist/components/Notifications/index.js +10 -0
  79. package/dist/components/RootProvider/RootProvider.js +42 -30
  80. package/dist/components/Searchbar/Searchbar.js +3 -3
  81. package/dist/components/Settings/BookmarksSettingsItem.js +1 -1
  82. package/dist/components/Settings/SettingsItem.js +22 -11
  83. package/dist/components/Toolbar/ToolbarAccountMenu.js +5 -5
  84. package/dist/components/Toolbar/ToolbarAdd.js +5 -5
  85. package/dist/components/Toolbar/ToolbarFilter.js +5 -5
  86. package/dist/components/Toolbar/ToolbarOptions.js +1 -1
  87. package/dist/components/Toolbar/ToolbarSearch.js +1 -1
  88. package/dist/components/index.js +305 -293
  89. package/dist/functions/date/date.js +16 -0
  90. package/dist/functions/date/date.spec.js +15 -0
  91. package/dist/functions/date/index.js +4 -0
  92. package/dist/functions/index.js +4 -2
  93. package/dist/globalSearch.module-Ejp7X0dO.js +9 -0
  94. package/dist/hooks/index.js +4 -2
  95. package/dist/hooks/useAccountSelector.js +214 -0
  96. package/dist/index-B6sKSsN9.js +2951 -0
  97. package/dist/index.js +304 -288
  98. package/dist/types/languageCode.js +1 -0
  99. package/dist/types/lib/components/Account/AccountMenu.d.ts +1 -1
  100. package/dist/types/lib/components/Account/AccountMenuButton.d.ts +11 -0
  101. package/dist/types/lib/components/Account/AccountMenuButton.stories.d.ts +31 -0
  102. package/dist/types/lib/components/Avatar/Avatar.d.ts +3 -1
  103. package/dist/types/lib/components/Avatar/Avatar.stories.d.ts +16 -1
  104. package/dist/types/lib/components/Bookmarks/BookmarksListItem.d.ts +1 -2
  105. package/dist/types/lib/components/Bookmarks/BookmarksListItem.stories.d.ts +1 -1
  106. package/dist/types/lib/components/Bookmarks/BookmarksSection.d.ts +3 -1
  107. package/dist/types/lib/components/Bookmarks/BookmarksSection.stories.d.ts +19 -1
  108. package/dist/types/lib/components/Bookmarks/EditableBookmark.d.ts +7 -3
  109. package/dist/types/lib/components/Dialog/SeenByLogItem.stories.d.ts +1 -0
  110. package/dist/types/lib/components/Dropdown/DrawerBase.d.ts +2 -1
  111. package/dist/types/lib/components/GlobalHeader/AccountSector.stories.d.ts +29 -0
  112. package/dist/types/lib/components/GlobalHeader/AccountSelector.d.ts +11 -0
  113. package/dist/types/lib/components/GlobalHeader/DigdirLogomark.d.ts +5 -0
  114. package/dist/types/lib/components/GlobalHeader/GlobalHeader.d.ts +20 -0
  115. package/dist/types/lib/components/GlobalHeader/GlobalHeader.stories.d.ts +27 -0
  116. package/dist/types/lib/components/GlobalHeader/GlobalHeaderBase.d.ts +9 -0
  117. package/dist/types/lib/components/GlobalHeader/GlobalSearch.d.ts +4 -0
  118. package/dist/types/lib/components/GlobalHeader/GlobalSearchButton.d.ts +4 -0
  119. package/dist/types/lib/components/GlobalHeader/HeaderGroup.d.ts +6 -0
  120. package/dist/types/lib/components/GlobalHeader/HeaderLogo.d.ts +10 -0
  121. package/dist/types/lib/components/GlobalHeader/index.d.ts +2 -0
  122. package/dist/types/lib/components/GlobalMenu/GlobalMenu.d.ts +3 -5
  123. package/dist/types/lib/components/GlobalMenu/GlobalMenu.stories.d.ts +6 -8
  124. package/dist/types/lib/components/GlobalMenu/GlobalMenuButton.d.ts +2 -3
  125. package/dist/types/lib/components/GlobalMenu/GlobalMenuButton.stories.d.ts +5 -9
  126. package/dist/types/lib/components/GlobalMenu/LocaleButton.d.ts +3 -0
  127. package/dist/types/lib/components/GlobalMenu/LocaleSwitcher.d.ts +7 -0
  128. package/dist/types/lib/components/GlobalMenu/index.d.ts +1 -4
  129. package/dist/types/lib/components/GlobalMenu_old/BackButton.d.ts +7 -0
  130. package/dist/types/lib/components/{GlobalMenu → GlobalMenu_old}/CurrentAccount.d.ts +1 -1
  131. package/dist/types/lib/components/GlobalMenu_old/EndUserLabel.d.ts +5 -0
  132. package/dist/types/lib/components/GlobalMenu_old/GlobalMenu.d.ts +18 -0
  133. package/dist/types/lib/components/GlobalMenu_old/GlobalMenu.stories.d.ts +30 -0
  134. package/dist/types/lib/components/GlobalMenu_old/GlobalMenuBase.d.ts +15 -0
  135. package/dist/types/lib/components/GlobalMenu_old/GlobalMenuButton.d.ts +13 -0
  136. package/dist/types/lib/components/GlobalMenu_old/GlobalMenuButton.stories.d.ts +19 -0
  137. package/dist/types/lib/components/GlobalMenu_old/LogoutButton.d.ts +7 -0
  138. package/dist/types/lib/components/GlobalMenu_old/index.d.ts +6 -0
  139. package/dist/types/lib/components/Header/Header.d.ts +2 -2
  140. package/dist/types/lib/components/Header/Header.stories.d.ts +2 -2
  141. package/dist/types/lib/components/Layout/Layout.d.ts +4 -2
  142. package/dist/types/lib/components/Layout/Layout.stories.d.ts +29 -5
  143. package/dist/types/lib/components/Notifications/NotificationItem.d.ts +7 -0
  144. package/dist/types/lib/components/Notifications/NotificationItemBase.d.ts +15 -0
  145. package/dist/types/lib/components/Notifications/NotificationItemControls.d.ts +10 -0
  146. package/dist/types/lib/components/Notifications/NotificationItemIcon.d.ts +11 -0
  147. package/dist/types/lib/components/Notifications/Notifications.stories.d.ts +10 -0
  148. package/dist/types/lib/components/Notifications/index.d.ts +4 -0
  149. package/dist/types/lib/components/RootProvider/RootProvider.d.ts +9 -4
  150. package/dist/types/lib/components/Settings/SettingsItem.d.ts +1 -1
  151. package/dist/types/lib/components/index.d.ts +2 -1
  152. package/dist/types/lib/functions/date/date.d.ts +6 -0
  153. package/dist/types/lib/functions/date/date.spec.d.ts +1 -0
  154. package/dist/types/lib/functions/date/index.d.ts +1 -0
  155. package/dist/types/lib/functions/index.d.ts +1 -0
  156. package/dist/types/lib/hooks/index.d.ts +1 -0
  157. package/dist/types/lib/hooks/useAccountSelector.d.ts +62 -0
  158. package/dist/types/lib/types/index.d.ts +1 -0
  159. package/dist/types/lib/types/languageCode.d.ts +1 -0
  160. package/dist/usePagination-cq1YWZkE.js +889 -0
  161. package/package.json +1 -1
  162. package/dist/usePagination-B24SmI8E.js +0 -3835
  163. /package/dist/components/{GlobalMenu → GlobalMenu_old}/CurrentAccount.js +0 -0
@@ -0,0 +1,16 @@
1
+ function e(r) {
2
+ if (r)
3
+ try {
4
+ const t = new Date(r);
5
+ return Number.isNaN(t.getTime()) ? r : t.toLocaleDateString("no-NO", {
6
+ day: "2-digit",
7
+ month: "2-digit",
8
+ year: "numeric"
9
+ });
10
+ } catch (t) {
11
+ return console.warn("Error formatting date:", t), r;
12
+ }
13
+ }
14
+ export {
15
+ e as formatDate
16
+ };
@@ -0,0 +1,15 @@
1
+ import { describe as d, test as o, expect as e } from "vitest";
2
+ import { formatDate as t } from "./date.js";
3
+ d("dateUtils", () => {
4
+ d("formatDate", () => {
5
+ o("should format ISO date to Norwegian DD.MM.YYYY format", () => {
6
+ e(t("1990-12-25")).toBe("25.12.1990"), e(t("2000-01-01")).toBe("01.01.2000"), e(t("1985-06-15")).toBe("15.06.1985");
7
+ }), o("should handle undefined input", () => {
8
+ e(t(void 0)).toBeUndefined();
9
+ }), o("should handle invalid date strings", () => {
10
+ e(t("invalid-date")).toBe("invalid-date"), e(t("")).toBe(void 0);
11
+ }), o("should handle edge cases", () => {
12
+ e(t("2024-02-29")).toBe("29.02.2024"), e(t("2023-12-31")).toBe("31.12.2023");
13
+ });
14
+ });
15
+ });
@@ -0,0 +1,4 @@
1
+ import { formatDate as t } from "./date.js";
2
+ export {
3
+ t as formatDate
4
+ };
@@ -1,4 +1,6 @@
1
- import { formatDisplayName as o } from "./name/name.js";
1
+ import { formatDisplayName as a } from "./name/name.js";
2
+ import { formatDate as t } from "./date/date.js";
2
3
  export {
3
- o as formatDisplayName
4
+ t as formatDate,
5
+ a as formatDisplayName
4
6
  };
@@ -0,0 +1,9 @@
1
+ import './assets/globalSearch.css';const t = "_globalSearch_gfstq_1", s = "_searchInput_gfstq_7", c = "_searchInputButton_gfstq_11", n = "_searchButton_gfstq_16", a = {
2
+ globalSearch: t,
3
+ searchInput: s,
4
+ searchInputButton: c,
5
+ searchButton: n
6
+ };
7
+ export {
8
+ a as s
9
+ };
@@ -1,8 +1,10 @@
1
1
  import { useClickOutside as r } from "./useClickOutside.js";
2
2
  import { useEscapeKey as u } from "./useEscapeKey.js";
3
- import { useMenu as t } from "./useMenu.js";
3
+ import { useMenu as c } from "./useMenu.js";
4
+ import { useAccountSelector as f } from "./useAccountSelector.js";
4
5
  export {
6
+ f as useAccountSelector,
5
7
  r as useClickOutside,
6
8
  u as useEscapeKey,
7
- t as useMenu
9
+ c as useMenu
8
10
  };
@@ -0,0 +1,214 @@
1
+ import { jsx as w } from "react/jsx-runtime";
2
+ import { useMemo as G } from "react";
3
+ import "../index-L8X2o7IH.js";
4
+ import { IconButton as E } from "../components/Button/IconButton.js";
5
+ import "../components/RootProvider/RootProvider.js";
6
+ import { useIsDesktop as K } from "./useIsDesktop.js";
7
+ import "../components/Snackbar/useSnackbar.js";
8
+ import { formatDisplayName as N } from "../functions/name/name.js";
9
+ import { formatDate as R } from "../functions/date/date.js";
10
+ import { S as U, a as W } from "../HeartFill-CYSrJ_xK.js";
11
+ const P = (o) => o === "Organization" ? "company" : "person", ot = ({
12
+ partyListDTO: o = [],
13
+ favoriteAccountUuids: e,
14
+ currentAccountUuid: u,
15
+ selfAccountUuid: d,
16
+ isLoading: a = !1,
17
+ onSelectAccount: v,
18
+ isVirtualized: g = !1,
19
+ onToggleFavorite: r,
20
+ languageCode: c
21
+ }) => {
22
+ const s = K(), [n, _, l] = G(() => {
23
+ var k, x;
24
+ if (a || !o || !d)
25
+ return [[], {}, void 0];
26
+ const i = (t) => e == null ? void 0 : e.includes(t), m = S(c), h = o.find((t) => $(t.type) && t.partyUuid === d), I = o.filter((t) => $(t.type) && t.partyUuid !== d), D = o.filter((t) => Y(t.type)), O = b(
27
+ c,
28
+ h,
29
+ "favorites",
30
+ u,
31
+ !1,
32
+ r,
33
+ s,
34
+ void 0,
35
+ !0
36
+ ), y = I == null ? void 0 : I.map(
37
+ (t) => b(
38
+ c,
39
+ t,
40
+ t.partyUuid,
41
+ u,
42
+ i(t.partyUuid),
43
+ r,
44
+ s
45
+ )
46
+ ), p = [];
47
+ for (const t of D) {
48
+ const f = b(
49
+ c,
50
+ t,
51
+ t.partyUuid,
52
+ u,
53
+ i(t.partyUuid),
54
+ r,
55
+ s
56
+ );
57
+ if (p.push(f), t.subunits && t.subunits.length > 0)
58
+ for (const A of t.subunits) {
59
+ const V = b(
60
+ c,
61
+ A,
62
+ t.partyUuid,
63
+ u,
64
+ i(A.partyUuid),
65
+ r,
66
+ s,
67
+ t
68
+ );
69
+ p.push(V);
70
+ }
71
+ }
72
+ const F = y.reduce((t, f) => (i(f.id) && t.push({ ...f, groupId: "favorites" }), t), []), j = p.reduce((t, f) => (i(f.id) && t.push({ ...f, groupId: "favorites" }), t), []), B = [...F, ...j], z = [O, ...B, ...y, ...p], H = z.find((t) => (t == null ? void 0 : t.selected) === !0), M = {
73
+ [((k = p[0]) == null ? void 0 : k.groupId) || "company"]: {
74
+ title: m.account_orgs,
75
+ divider: !0
76
+ },
77
+ [((x = y[0]) == null ? void 0 : x.groupId) || "person"]: {
78
+ title: m.account_persons,
79
+ divider: !0
80
+ },
81
+ favorites: {
82
+ title: m.account_favorites,
83
+ divider: !0
84
+ }
85
+ };
86
+ return [z, M, H];
87
+ }, [
88
+ o,
89
+ d,
90
+ e,
91
+ u,
92
+ a,
93
+ r,
94
+ c,
95
+ s
96
+ ]);
97
+ return a || !o || !l ? {
98
+ accountMenu: {
99
+ items: [],
100
+ groups: {},
101
+ isVirtualized: !1,
102
+ onSelectAccount: () => {
103
+ },
104
+ currentAccount: void 0
105
+ },
106
+ loading: a
107
+ } : {
108
+ accountMenu: {
109
+ items: n,
110
+ groups: _,
111
+ isVirtualized: g,
112
+ onSelectAccount: v,
113
+ currentAccount: l
114
+ },
115
+ loading: !1
116
+ };
117
+ }, b = (o, e, u, d, a, v, g, r, c) => {
118
+ const s = P((e == null ? void 0 : e.type) ?? ""), n = S(o), _ = N({
119
+ fullName: e.name,
120
+ type: s
121
+ }), l = r ? N({
122
+ fullName: r.name,
123
+ type: P(r.type ?? ""),
124
+ reverseNameOrder: !1
125
+ }) : void 0;
126
+ let i = "";
127
+ const m = s === "company" && r ? "subunit" : s;
128
+ switch (m) {
129
+ case "company":
130
+ i = `${n.org_no}: ${e.organizationNumber}`;
131
+ break;
132
+ case "person":
133
+ i = `${n.birthdate}: ${R(e.dateOfBirth)}`;
134
+ break;
135
+ case "subunit":
136
+ i = `↳ ${n.org_no}: ${e.organizationNumber}, ${n.subunit_of} ${l}`;
137
+ break;
138
+ }
139
+ return {
140
+ id: e.partyUuid,
141
+ icon: {
142
+ name: _,
143
+ type: s,
144
+ isParent: !r,
145
+ isDeleted: e.isDeleted,
146
+ colorKey: l ?? void 0
147
+ },
148
+ name: _,
149
+ description: i,
150
+ groupId: u,
151
+ type: m,
152
+ selected: d === e.partyUuid,
153
+ disabled: !!e.onlyHierarchyElementWithNoAccess,
154
+ badge: c ? { label: n.you, color: "person" } : e.isDeleted && g ? { label: n.deleted, color: "neutral" } : void 0,
155
+ controls: !c && /* @__PURE__ */ w(
156
+ E,
157
+ {
158
+ rounded: !0,
159
+ variant: "text",
160
+ icon: a ? U : W,
161
+ iconAltText: a ? n.remove_from_favorites : n.add_to_favorites,
162
+ onClick: (h) => {
163
+ v && (h.stopPropagation(), v(e.partyUuid));
164
+ },
165
+ size: "xs"
166
+ }
167
+ )
168
+ };
169
+ }, Y = (o) => o === "Organization", $ = (o) => o === "Person", S = (o) => {
170
+ switch (o) {
171
+ case "nn":
172
+ return {
173
+ account_orgs: "Virksemder",
174
+ account_persons: "Personar",
175
+ account_favorites: "Favorittar",
176
+ add_to_favorites: "Legg til i favorittar",
177
+ remove_from_favorites: "Fjern frå favorittar",
178
+ you: "Deg",
179
+ org_no: "Org.nr",
180
+ birthdate: "Født",
181
+ subunit_of: "undereining av",
182
+ deleted: "Sletta"
183
+ };
184
+ case "en":
185
+ return {
186
+ account_orgs: "Organizations",
187
+ account_persons: "Persons",
188
+ account_favorites: "Favorites",
189
+ add_to_favorites: "Add to favorites",
190
+ remove_from_favorites: "Remove from favorites",
191
+ you: "You",
192
+ org_no: "Org.no",
193
+ birthdate: "Born",
194
+ subunit_of: "subunit of",
195
+ deleted: "Deleted"
196
+ };
197
+ default:
198
+ return {
199
+ account_orgs: "Virksomheter",
200
+ account_persons: "Personer",
201
+ account_favorites: "Favoritter",
202
+ add_to_favorites: "Legg til i favorittar",
203
+ remove_from_favorites: "Fjern frå favorittar",
204
+ you: "Deg",
205
+ org_no: "Org.nr",
206
+ birthdate: "Født",
207
+ subunit_of: "underenhet av",
208
+ deleted: "Slettet"
209
+ };
210
+ }
211
+ };
212
+ export {
213
+ ot as useAccountSelector
214
+ };