@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,889 @@
1
+ "use client";
2
+ import { jsx as s, jsxs as T, Fragment as de } from "react/jsx-runtime";
3
+ import { c as I } from "./lite-1fxw3LjI.js";
4
+ import ve, { forwardRef as v, useState as U, createContext as oe, useRef as j, useEffect as F, useContext as D, useId as re, version as yt, useMemo as G, isValidElement as xt, memo as Ct, useCallback as vt, Children as Me } from "react";
5
+ import { S as E, a as wt } from "./index-D8Pn8SCu.js";
6
+ import { u as kt, S as It } from "./Spinner-BDXfwXIh.js";
7
+ import { u as J } from "./useMergeRefs-DOnoWyUH.js";
8
+ import { B as ue } from "./Button-B0t0vz2h.js";
9
+ import { F as ce, V as Ne, a as Ot, b as Nt, c as Ke } from "./index-CnWc2FNH.js";
10
+ import { I as me } from "./Input-B_w6SBmg.js";
11
+ import { L as X } from "./Label-9elsbqMH.js";
12
+ import { T as _t } from "./Textarea-BBstVlPT.js";
13
+ import { a as Ve, c as St, o as Tt, f as Et, s as Pt, C as W, u as _e, b as Ue, d as le, p as R, r as Ie, e as Se, i as Dt, g as Rt, h as Lt, j as Ft, k as zt, l as At, m as $t, n as Bt, q as jt, t as Mt, v as ae, F as Kt, w as Vt, x as Ut } from "./index-B6sKSsN9.js";
14
+ import { u as qt } from "./index-D-VWMqlv.js";
15
+ import { S as Ht } from "./XMark-tKk6aExO.js";
16
+ import { P as Oe } from "./Paragraph-Bm-eoPYv.js";
17
+ import { S as Xt, a as Yt } from "./ChevronUp-_BBfEirx.js";
18
+ import { u as Wt } from "./useId-BVFxCjkq.js";
19
+ import { S as Gt } from "./Checkmark-Byz_C9x4.js";
20
+ import { flushSync as Jt } from "react-dom";
21
+ var Qt = function(t, n) {
22
+ var e = {};
23
+ for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && n.indexOf(o) < 0 && (e[o] = t[o]);
24
+ if (t != null && typeof Object.getOwnPropertySymbols == "function")
25
+ for (var r = 0, o = Object.getOwnPropertySymbols(t); r < o.length; r++)
26
+ n.indexOf(o[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, o[r]) && (e[o[r]] = t[o[r]]);
27
+ return e;
28
+ };
29
+ const Zt = v((t, n) => {
30
+ var { title: e, titleId: o } = t, r = Qt(t, ["title", "titleId"]);
31
+ let i = Wt();
32
+ return i = e ? o || "title-" + i : void 0, ve.createElement(
33
+ "svg",
34
+ 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: n, "aria-labelledby": i }, r),
35
+ e ? ve.createElement("title", { id: i }, e) : null,
36
+ ve.createElement("path", { fill: "currentColor", fillRule: "evenodd", d: "M12 2.25A4.75 4.75 0 0 0 7.25 7v2.25H7A1.75 1.75 0 0 0 5.25 11v9c0 .414.336.75.75.75h12a.75.75 0 0 0 .75-.75v-9A1.75 1.75 0 0 0 17 9.25h-.25V7A4.75 4.75 0 0 0 12 2.25m3.25 7V7a3.25 3.25 0 0 0-6.5 0v2.25zM12 13a1.5 1.5 0 0 0-.75 2.8V17a.75.75 0 0 0 1.5 0v-1.2A1.5 1.5 0 0 0 12 13", clipRule: "evenodd" })
37
+ );
38
+ }), en = v(function({ className: n, count: e, maxCount: o, variant: r = "base", ...i }, c) {
39
+ return s("span", { className: I("ds-badge", n), "data-count": e && o && e > o ? `${o}+` : e, "data-variant": r, ref: c, ...i });
40
+ }), tn = v(function({ className: n, overlap: e = "rectangle", placement: o = "top-right", ...r }, i) {
41
+ return s("span", { className: I("ds-badge--position", n), "data-overlap": e, "data-placement": o, ref: i, ...r });
42
+ }), nn = Object.assign(en, { Position: tn });
43
+ nn.Position.displayName = "Badge.Position";
44
+ const on = v(({ asChild: t, className: n, ...e }, o) => s(t ? E : "a", { className: I("ds-link", n), ref: o, ...e }));
45
+ on.displayName = "Link";
46
+ const Zn = v(function({ asChild: n, className: e, height: o, style: r, variant: i = "rectangle", width: c, ...a }, l) {
47
+ const u = n ? E : "span", g = i === "text", b = kt("ds-skeleton-opacity-fade"), f = J([b, l]);
48
+ return s(u, { "aria-hidden": "true", className: I("ds-skeleton", e), "data-text": g ? "-".repeat(Number(c) || 1) : void 0, "data-variant": i, ref: f, style: g ? r : { width: c, height: o, ...r }, ...a });
49
+ }), eo = v(function({ asChild: n, ...e }, o) {
50
+ return s(n ? E : "li", { ...e, ref: o });
51
+ }), qe = (t, { asChild: n, className: e, ...o }, r) => s(n ? E : t, { className: I("ds-list", e), ref: r, ...o }), to = v(function(n, e) {
52
+ return qe("ul", n, e);
53
+ });
54
+ v(function(n, e) {
55
+ return qe("ol", n, e);
56
+ });
57
+ const He = v(function({ asChild: n, className: e, ...o }, r) {
58
+ return s(n ? E : "button", { className: I("ds-chip", e), type: n ? void 0 : "button", ref: r, ...o });
59
+ }), Xe = v(function(n, e) {
60
+ return s(He, { "data-removable": !0, ref: e, ...n });
61
+ }), Ye = v(function({ asChild: n, children: e, className: o, "data-size": r, "data-color": i, ...c }, a) {
62
+ const l = c.type ?? "checkbox";
63
+ return T(n ? E : "label", { className: I("ds-chip", o), "data-size": r, "data-color": i, ref: a, children: [s(me, { ...c, type: l }), s(wt, { children: e })] });
64
+ }), rn = v(function(n, e) {
65
+ return s(Ye, { ref: e, type: "radio", ...n });
66
+ }), fe = {
67
+ Button: He,
68
+ Checkbox: Ye,
69
+ Radio: rn,
70
+ Removable: Xe
71
+ };
72
+ fe.Button.displayName = "Chip.Button";
73
+ fe.Checkbox.displayName = "Chip.Checkbox";
74
+ fe.Radio.displayName = "Chip.Radio";
75
+ fe.Removable.displayName = "Chip.Removable";
76
+ const sn = v(function({ "aria-label": n = "Sidenavigering", asChild: e, className: o, ...r }, i) {
77
+ return s(e ? E : "nav", { "aria-label": n, className: I("ds-pagination", o), ref: i, ...r });
78
+ }), an = v(function(n, e) {
79
+ return s(ue, { ref: e, ...n });
80
+ }), cn = v(function({ asChild: n, className: e, ...o }, r) {
81
+ return s(n ? E : "li", { ref: r, ...o });
82
+ }), ln = v(function({ asChild: n, ...e }, o) {
83
+ return s(n ? E : "ul", { ref: o, ...e });
84
+ }), Te = Object.assign(sn, {
85
+ List: ln,
86
+ Item: cn,
87
+ Button: an
88
+ });
89
+ Te.List.displayName = "Pagination.List";
90
+ Te.Item.displayName = "Pagination.Item";
91
+ Te.Button.displayName = "Pagination.Button";
92
+ const no = v(function({ "data-size": n, className: e, style: o, children: r, label: i, description: c, error: a, ...l }, u) {
93
+ return T(ce, { "data-size": n, className: e, style: o, children: [s(me, { type: "checkbox", ref: u, ...l }), !!i && s(X, { weight: "regular", children: i }), !!c && s("div", { "data-field": "description", children: c }), !!a && s(Ne, { children: a })] });
94
+ }), oo = v(function({ "data-size": n, children: e, className: o, description: r, label: i, position: c, style: a, ...l }, u) {
95
+ return T(ce, { className: o, "data-position": c, "data-size": n, style: a, children: [s(me, { type: "checkbox", role: "switch", ref: u, ...l }), !!i && s(X, { weight: "regular", children: i }), !!r && s("div", { "data-field": "description", children: r })] });
96
+ }), ro = v(function({ label: n, description: e, error: o, multiline: r, prefix: i, suffix: c, "data-size": a, counter: l, style: u, className: g, ...b }, f) {
97
+ return T(ce, { className: g, "data-size": a, style: u, children: [!!n && s(X, { children: n }), !!e && s(Ot, { children: e }), T(Nt, { children: [i === void 0 || s(Ke, { children: i }), r === !0 ? s(_t, { ref: f, "aria-invalid": !!o || void 0, ...b }) : s(me, { ref: f, "aria-invalid": !!o || void 0, ...b }), c === void 0 || s(Ke, { children: c })] }), !!o && s(Ne, { children: o }), !!l && s(ce.Counter, { ...typeof l == "number" ? { limit: l } : l })] });
98
+ }), be = oe({}), dn = v(function({ value: n, defaultValue: e, className: o, onChange: r, ...i }, c) {
99
+ const a = n !== void 0, [l, u] = U(e);
100
+ let g = r;
101
+ return a || (g = (b) => {
102
+ u(b), r == null || r(b);
103
+ }, n = l), s(be.Provider, { value: {
104
+ value: n,
105
+ defaultValue: e,
106
+ onChange: g
107
+ }, children: s("div", { className: I("ds-tabs", o), ref: c, ...i }) });
108
+ }), We = oe({
109
+ elements: { current: /* @__PURE__ */ new Map() },
110
+ getOrderedItems: () => [],
111
+ setFocusableValue: () => {
112
+ },
113
+ onShiftTab: () => {
114
+ },
115
+ focusableValue: null,
116
+ orientation: "horizontal"
117
+ }), un = v(({ activeValue: t, asChild: n, orientation: e = "horizontal", onBlur: o, onFocus: r, ...i }, c) => {
118
+ const a = n ? E : "div", [l, u] = U(null), [g, b] = U(!1), f = j(/* @__PURE__ */ new Map()), h = j(null), x = J([c, h]), w = () => {
119
+ if (!h.current)
120
+ return [];
121
+ const d = Array.from(h.current.querySelectorAll("[data-roving-tabindex-item]"));
122
+ return Array.from(f.current).sort((y, m) => d.indexOf(y[1]) - d.indexOf(m[1])).map(([y, m]) => ({ value: y, element: m }));
123
+ };
124
+ return F(() => {
125
+ u(t ?? null);
126
+ }, [t]), s(We.Provider, { value: {
127
+ elements: f,
128
+ getOrderedItems: w,
129
+ focusableValue: l,
130
+ setFocusableValue: u,
131
+ onShiftTab: () => {
132
+ b(!0);
133
+ },
134
+ orientation: e
135
+ }, children: s(a, { ...i, tabIndex: g ? -1 : 0, onBlur: (d) => {
136
+ o == null || o(d), b(!1), u(t ?? null);
137
+ }, onFocus: (d) => {
138
+ var m, p, C;
139
+ if (r == null || r(d), d.target !== d.currentTarget)
140
+ return;
141
+ const y = w();
142
+ y.length !== 0 && (l != null ? (m = f.current.get(l)) == null || m.focus() : t != null ? (p = f.current.get(t)) == null || p.focus() : (C = y.at(0)) == null || C.element.focus());
143
+ }, ref: x }) });
144
+ }), mn = v(function({ children: n, ...e }, o) {
145
+ const { value: r } = D(be);
146
+ return s(un, { role: "tablist", activeValue: r, orientation: "ambiguous", ref: o, ...e, children: n });
147
+ }), fn = v(function({ children: n, value: e, ...o }, r) {
148
+ const { value: i } = D(be), c = e === i, [a, l] = U(!1), u = j(null), g = J([r, u]);
149
+ return F(() => {
150
+ if (!u.current)
151
+ return;
152
+ const b = u.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
153
+ l(b.length > 0);
154
+ }, [n]), s(de, { children: c && s("div", { ref: g, role: "tabpanel", tabIndex: a ? void 0 : 0, ...o, children: n }) });
155
+ }), bn = (t) => {
156
+ const { elements: n, getOrderedItems: e, setFocusableValue: o, focusableValue: r, onShiftTab: i, orientation: c } = D(We);
157
+ return {
158
+ getOrderedItems: e,
159
+ isFocusable: r === t,
160
+ orientation: c,
161
+ getRovingProps: (a) => ({
162
+ ...a,
163
+ ref: (l) => {
164
+ l ? n.current.set(t, l) : n.current.delete(t);
165
+ },
166
+ onKeyDown: (l) => {
167
+ var u;
168
+ if ((u = a == null ? void 0 : a.onKeyDown) == null || u.call(a, l), l.shiftKey && l.key === "Tab") {
169
+ i();
170
+ return;
171
+ }
172
+ },
173
+ onFocus: (l) => {
174
+ var u;
175
+ (u = a == null ? void 0 : a.onFocus) == null || u.call(a, l), o(t);
176
+ },
177
+ "data-roving-tabindex-item": !0,
178
+ tabIndex: r === t ? 0 : -1
179
+ })
180
+ };
181
+ };
182
+ function we(t, n) {
183
+ const e = t.findIndex((o) => o.value === n);
184
+ return t.at(e === t.length - 1 ? 0 : e + 1);
185
+ }
186
+ function ke(t, n) {
187
+ const e = t.findIndex((o) => o.value === n);
188
+ return t.at(e === 0 ? -1 : e - 1);
189
+ }
190
+ const pn = v(({ value: t, asChild: n, ...e }, o) => {
191
+ const r = n ? E : "div", i = t ?? (typeof e.children == "string" ? e.children : ""), { getOrderedItems: c, getRovingProps: a, orientation: l } = bn(i), u = a({
192
+ onKeyDown: (b) => {
193
+ var x;
194
+ (x = e == null ? void 0 : e.onKeyDown) == null || x.call(e, b);
195
+ const f = c();
196
+ let h;
197
+ switch (l) {
198
+ case "horizontal":
199
+ b.key === "ArrowRight" && (h = we(f, i)), b.key === "ArrowLeft" && (h = ke(f, i));
200
+ break;
201
+ case "vertical":
202
+ b.key === "ArrowDown" && (h = we(f, i)), b.key === "ArrowUp" && (h = ke(f, i));
203
+ break;
204
+ case "ambiguous":
205
+ ["ArrowRight", "ArrowDown"].includes(b.key) && (h = we(f, i)), ["ArrowLeft", "ArrowUp"].includes(b.key) && (h = ke(f, i));
206
+ }
207
+ b.key === "Home" && (h = f[0]), b.key === "End" && (h = f[f.length - 1]), h && (b.preventDefault(), h.element.focus());
208
+ }
209
+ }), g = J([o, u.ref]);
210
+ return s(r, { ...e, ...u, ref: g, children: e.children });
211
+ }), hn = v(function({ value: n, id: e, ...o }, r) {
212
+ const i = D(be), c = e ?? `tab-${re()}`;
213
+ return s(pn, { value: n, ...o, asChild: !0, children: s("button", { ...o, "aria-selected": i.value === n, id: c, onClick: () => {
214
+ var a;
215
+ return (a = i.onChange) == null ? void 0 : a.call(i, n);
216
+ }, ref: r, role: "tab", type: "button" }) });
217
+ }), Ee = Object.assign(dn, {
218
+ List: mn,
219
+ Tab: hn,
220
+ Panel: fn
221
+ });
222
+ Ee.Tab.displayName = "Tabs.Tab";
223
+ Ee.List.displayName = "Tabs.List";
224
+ Ee.Panel.displayName = "Tabs.Panel";
225
+ const Ge = ({ children: t }) => {
226
+ const n = re(), [e, o] = U(n);
227
+ return s(Pe.Provider, { value: { popoverId: e, setPopoverId: o }, children: t });
228
+ };
229
+ Ge.displayName = "PopoverTriggerContext";
230
+ const Pe = oe({}), gn = v(function({ id: n, className: e, onClose: o, onOpen: r, open: i, variant: c = "default", placement: a = "top", autoPlacement: l = !0, asChild: u = !1, ...g }, b) {
231
+ const f = u ? E : "div", h = j(null), x = J([h, b]), { popoverId: w, setPopoverId: d } = D(Pe), [y, m] = U(!1), p = i ?? y;
232
+ return F(() => {
233
+ var L;
234
+ const C = h.current, O = ($) => {
235
+ var Y;
236
+ const z = $.target, K = (Y = z == null ? void 0 : z.closest) == null ? void 0 : Y.call(z, `[popovertarget="${C == null ? void 0 : C.id}"]`), B = !K && !(C != null && C.contains(z));
237
+ K && ($.preventDefault(), m((S) => !S), r == null || r()), B && (m(!1), o == null || o());
238
+ }, _ = ($) => {
239
+ $.key !== "Escape" || !p || ($.preventDefault(), m(!1), o == null || o());
240
+ };
241
+ return (L = C == null ? void 0 : C.togglePopover) == null || L.call(C, p), document.addEventListener("click", O, !0), document.addEventListener("keydown", _), () => {
242
+ document.removeEventListener("click", O, !0), document.removeEventListener("keydown", _);
243
+ };
244
+ }, [p]), F(() => {
245
+ const C = h.current, O = document.querySelector(`[popovertarget="${C == null ? void 0 : C.id}"]`);
246
+ if (C && O && p)
247
+ return Ve(O, C, () => {
248
+ St(O, C, {
249
+ placement: a,
250
+ strategy: "fixed",
251
+ middleware: [
252
+ Tt((_) => {
253
+ const L = getComputedStyle(_.elements.floating, "::before");
254
+ return parseFloat(L.height);
255
+ }),
256
+ ...l ? [Et({ fallbackAxisSideDirection: "start" }), Pt()] : [],
257
+ yn
258
+ ]
259
+ }).then(({ x: _, y: L }) => {
260
+ C.style.translate = `${_}px ${L}px`;
261
+ });
262
+ });
263
+ }, [p, a, n, l]), F(() => {
264
+ n && (d == null || d(n));
265
+ }, [n]), s(f, { className: I("ds-popover", e), id: n || w, popover: "manual", "data-variant": c, ref: x, ...g });
266
+ }), yn = {
267
+ name: "ArrowPseudoElement",
268
+ fn(t) {
269
+ const { elements: n, rects: e, placement: o } = t;
270
+ let r = `${Math.round(e.reference.width / 2 + e.reference.x - t.x)}px`, i = `${Math.round(e.reference.height / 2 + e.reference.y - t.y)}px`;
271
+ switch (e.reference.width > e.floating.width && (r = `${Math.round(e.floating.width / 2)}px`), e.reference.height > e.floating.height && (i = `${Math.round(e.floating.height / 2)}px`), o.split("-")[0]) {
272
+ case "top":
273
+ i = "100%";
274
+ break;
275
+ case "right":
276
+ r = "0";
277
+ break;
278
+ case "bottom":
279
+ i = "0";
280
+ break;
281
+ case "left":
282
+ r = "100%";
283
+ break;
284
+ }
285
+ return n.floating.setAttribute("data-placement", o.split("-")[0]), n.floating.style.setProperty("--ds-popover-arrow-x", r), n.floating.style.setProperty("--ds-popover-arrow-y", i), t;
286
+ }
287
+ }, xn = v(function({ id: n, inline: e, asChild: o, ...r }, i) {
288
+ const { popoverId: c } = D(Pe), a = o ? E : e ? "button" : ue, l = Object.assign({
289
+ [yt.startsWith("19") ? "popoverTarget" : "popovertarget"]: c,
290
+ ...e ? {
291
+ "data-popover": "inline"
292
+ } : {}
293
+ }, r);
294
+ return s(a, { ref: i, ...l });
295
+ }), Je = Object.assign(gn, {
296
+ TriggerContext: Ge,
297
+ Trigger: xn
298
+ });
299
+ Je.TriggerContext.displayName = "Popover.TriggerContext";
300
+ Je.Trigger.displayName = "Popover.Trigger";
301
+ const De = oe({
302
+ current: null
303
+ }), Qe = ({ children: t }) => {
304
+ const n = j(null);
305
+ return s(De.Provider, { value: n, children: t });
306
+ };
307
+ Qe.displayName = "DialogTriggerContext";
308
+ const Cn = v(function({ asChild: n, children: e, className: o, closeButton: r = "Lukk dialogvindu", closedby: i = "closerequest", modal: c = !0, onClose: a, open: l, ...u }, g) {
309
+ const b = D(De), f = j(null), h = n ? E : "dialog", x = J([b, g, f]), w = c ? "showModal" : "show";
310
+ return F(() => {
311
+ var d;
312
+ return (d = f.current) == null ? void 0 : d[l ? w : "close"]();
313
+ }, [l]), F(() => {
314
+ const d = f.current, y = (p) => {
315
+ var L;
316
+ const { clientY: C, clientX: O, target: _ } = p;
317
+ if (p instanceof KeyboardEvent)
318
+ return i === "none" && p.key === "Escape" && p.preventDefault();
319
+ if (!((L = window.getSelection()) != null && L.toString()) && d && _ === d && i === "any") {
320
+ const { top: $, left: z, right: K, bottom: B } = d.getBoundingClientRect();
321
+ $ <= C && C <= B && z <= O && O <= K || d == null || d.close();
322
+ }
323
+ }, m = () => {
324
+ const p = d == null ? void 0 : d.querySelector("[autofocus]");
325
+ document.activeElement !== p && (p == null || p.focus());
326
+ };
327
+ return d == null || d.addEventListener("animationend", m), d == null || d.addEventListener("click", y), d == null || d.addEventListener("keydown", y), () => {
328
+ d == null || d.removeEventListener("animationend", m), d == null || d.removeEventListener("click", y), d == null || d.removeEventListener("keydown", y);
329
+ };
330
+ }, [i]), F(() => {
331
+ var y;
332
+ const d = (m) => a == null ? void 0 : a(m);
333
+ return (y = f.current) == null || y.addEventListener("close", d), () => {
334
+ var m;
335
+ return (m = f.current) == null ? void 0 : m.removeEventListener("close", d);
336
+ };
337
+ }, [a]), T(h, { className: I("ds-dialog", o), ref: x, "data-modal": c, ...u, children: [r !== !1 && s("form", { method: "dialog", children: s(ue, { "aria-label": r, autoFocus: !0, "data-color": "neutral", icon: !0, name: "close", type: "submit", variant: "tertiary" }) }), e] });
338
+ }), vn = v(function({ asChild: n, className: e, ...o }, r) {
339
+ return s(n ? E : "div", { className: I("ds-dialog__block", e), ref: r, ...o });
340
+ }), wn = v(function({ asChild: n, ...e }, o) {
341
+ const r = D(De);
342
+ return s(n ? E : ue, { "aria-haspopup": "dialog", onClick: () => {
343
+ var a, l, u;
344
+ ((a = r.current) == null ? void 0 : a.getAttribute("data-modal")) === "true" ? (l = r.current) == null || l.showModal() : (u = r.current) == null || u.show();
345
+ }, ref: o, ...e });
346
+ }), Re = Object.assign(Cn, {
347
+ Block: vn,
348
+ TriggerContext: Qe,
349
+ Trigger: wn
350
+ });
351
+ Re.Block.displayName = "Dialog.Block";
352
+ Re.TriggerContext.displayName = "Dialog.TriggerContext";
353
+ Re.Trigger.displayName = "Dialog.Trigger";
354
+ const kn = oe(null), In = (t, n) => {
355
+ const e = D(kn), o = re(), r = t.id ?? `${n}-${o}`, i = t.errorId ?? `${n}-error-${o}`, c = `${n}-description-${o}`, a = t.size ?? (e == null ? void 0 : e.size) ?? "md", l = (e == null ? void 0 : e.disabled) || (t == null ? void 0 : t.disabled), u = !l && !!(t.error || e != null && e.error);
356
+ return {
357
+ hasError: u,
358
+ errorId: i,
359
+ descriptionId: c,
360
+ size: a,
361
+ inputProps: {
362
+ id: r,
363
+ disabled: l,
364
+ "aria-invalid": u ? !0 : void 0,
365
+ "aria-describedby": I(t["aria-describedby"], !!(t != null && t.description) && typeof (t == null ? void 0 : t.description) == "string" && c, u && !(e != null && e.error) && i, u && !!(e != null && e.error) && (e == null ? void 0 : e.errorId)) || void 0
366
+ }
367
+ };
368
+ }, Ze = ({ size: t, error: n, formFieldProps: e }) => s("div", { className: "ds-combobox__error-message", id: e.errorId, "aria-live": "polite", "aria-relevant": "additions removals", children: n && s(Ne, { "data-size": t, children: n }) });
369
+ Ze.displayName = "ComboboxError";
370
+ const et = () => {
371
+ const t = D(W);
372
+ if (!t)
373
+ throw new Error("ComboboxContext is missing");
374
+ const { size: n, readOnly: e, disabled: o, selectedOptions: r, chipSrLabel: i, handleSelectOption: c, inputRef: a } = t;
375
+ return s(de, { children: Object.keys(r).map((l) => s(Xe, { "data-size": n, disabled: o, onKeyDown: (u) => {
376
+ var g;
377
+ e || o || u.key === "Enter" && (u.stopPropagation(), c({
378
+ option: r[l],
379
+ remove: !0
380
+ }), (g = a == null ? void 0 : a.current) == null || g.focus());
381
+ }, onClick: () => {
382
+ e || o || c({
383
+ option: r[l],
384
+ remove: !0
385
+ });
386
+ }, "aria-label": i(r[l]), children: r[l].label }, l)) });
387
+ };
388
+ et.displayName = "ComboboxChips";
389
+ const tt = v((t, n) => {
390
+ const e = D(W);
391
+ if (!e)
392
+ throw new Error("ComboboxContext is missing");
393
+ const { readOnly: o, disabled: r, clearButtonLabel: i, handleSelectOption: c } = e;
394
+ return s("button", { ...t, ref: n, disabled: r, className: I("ds-combobox__clear-button", "ds-focus"), onClick: () => {
395
+ o || r || c({ option: null, clear: !0 });
396
+ }, onKeyDown: (a) => {
397
+ o || r || a.key === "Enter" && (a.stopPropagation(), c({ option: null, clear: !0 }));
398
+ }, type: "button", "aria-label": i, children: s(Ht, { fontSize: "1.5em", title: "Clear selection" }) });
399
+ });
400
+ tt.displayName = "ComboboxClearButton";
401
+ const nt = ({ hideClearButton: t, listId: n, error: e, hideChips: o, handleKeyDown: r, ...i }) => {
402
+ const c = D(W), a = _e(), l = j(null);
403
+ if (!c)
404
+ throw new Error("ComboboxContext is missing");
405
+ const u = (P) => {
406
+ a == null || a({ type: "SET_ACTIVE_INDEX", payload: P });
407
+ }, { forwareddRef: g, readOnly: b, disabled: f, open: h, inputRef: x, refs: w, inputValue: d, multiple: y, selectedOptions: m, formFieldProps: p, htmlSize: C, options: O, setOpen: _, getReferenceProps: L, setInputValue: $, handleSelectOption: z, size: K } = c, B = Ue([g, x]), Y = (P) => {
408
+ const A = P.target.value;
409
+ $(A), u(0);
410
+ for (const V of Object.values(O))
411
+ if (V.label.toLowerCase() === A.toLowerCase()) {
412
+ if (m[R(V.value)])
413
+ continue;
414
+ z({ option: V });
415
+ }
416
+ }, S = !t && Object.keys(m).length > 0, Q = L({
417
+ ref: w == null ? void 0 : w.setReference,
418
+ role: null,
419
+ "aria-controls": null,
420
+ "aria-expanded": null,
421
+ "aria-haspopup": null,
422
+ /* If we click the wrapper, toggle open, set index to first option, and focus the input */
423
+ onClick(P) {
424
+ var A, V;
425
+ f || b || (A = l.current) != null && A.contains(P.target) || (_(!h), u(0), (V = x.current) == null || V.focus());
426
+ },
427
+ /* Handles list navigation */
428
+ onKeyDown: r,
429
+ // preventDefault on keydown to avoid sending in form
430
+ onKeyPress(P) {
431
+ P.key === "Enter" && P.preventDefault();
432
+ }
433
+ });
434
+ return s(Oe, { "data-size": K, asChild: !0, children: T("div", { ...Q, "aria-disabled": f ? "true" : void 0, className: I("ds-textfield__input", "ds-combobox__input__wrapper", b && "ds-combobox--readonly", e && "ds-combobox--error"), children: [T("div", { className: "ds-combobox__chip-and-input", children: [y && !o && s(et, {}), s(Oe, { "data-size": K, asChild: !0, children: s("input", { ref: B, "aria-activedescendant": Q["aria-activedescendant"], readOnly: b, "aria-autocomplete": "list", role: "combobox", "aria-expanded": h, "aria-controls": h ? n : void 0, autoComplete: "off", size: C, value: d, ...le(["style", "className"], i), ...p.inputProps, className: "ds-combobox__input", onChange: (P) => {
435
+ var A;
436
+ Y(P), !h && _(!0), (A = i.onChange) == null || A.call(i, P);
437
+ } }) })] }), S && s(tt, { ref: l }), s("div", { className: "ds-combobox__arrow", children: h ? s(Xt, { title: "arrow up", fontSize: "1.5em" }) : s(Yt, { title: "arrow down", fontSize: "1.5em" }) })] }) });
438
+ };
439
+ nt.displayName = "ComboboxInput";
440
+ const ot = ({ label: t, description: n, hideLabel: e, size: o, readOnly: r, formFieldProps: i }) => T(de, { children: [t && T(X, { "data-size": o, htmlFor: i.inputProps.id, className: I("ds-combobox__label", e && "ds-sr-only"), children: [r && s(Zt, { "aria-hidden": !0, className: "ds-combobox__readonly__icon" }), t] }), n && s(Oe, { asChild: !0, "data-size": o, children: s("div", { id: i.descriptionId, className: I("ds-combobox__description", e && "ds-sr-only"), children: n }) })] });
441
+ ot.displayName = "ComboboxLabel";
442
+ const rt = ({ selectedOptions: t, multiple: n, name: e }) => {
443
+ const o = Object.keys(t).map((r) => Ie(r));
444
+ return s("select", { name: e, multiple: n, style: { display: "none" }, value: n ? o : o[0], onChange: () => {
445
+ }, children: o.map((r) => s("option", { value: r }, r)) });
446
+ };
447
+ rt.displayName = "ComboboxNative";
448
+ const it = v(({ children: t, className: n, ...e }, o) => s("span", { className: I("ds-combobox__option__description", n), ref: o, ...e, children: t }));
449
+ it.displayName = "ComboboxOptionDescription";
450
+ const st = ({ multiple: t, selected: n }) => s("div", { className: I(t && "ds-combobox__option__icon-wrapper", n && "ds-combobox__option__icon-wrapper--selected"), children: n && s(Gt, { className: "ds-combobox__option__icon-wrapper__icon", "aria-hidden": !0 }) });
451
+ st.displayName = "SelectedIcon";
452
+ function Le(t, n = 50) {
453
+ const e = j(null);
454
+ return F(() => () => {
455
+ e.current && clearTimeout(e.current);
456
+ }, []), (...r) => {
457
+ e.current && clearTimeout(e.current), e.current = window.setTimeout(() => {
458
+ t(...r);
459
+ }, n);
460
+ };
461
+ }
462
+ const On = ({ id: t, ref: n, value: e }) => {
463
+ const o = re(), r = t || o, i = D(W), { activeIndex: c } = Se(), a = _e();
464
+ if (!i)
465
+ throw new Error("ComboboxOption must be used within a Combobox");
466
+ const { selectedOptions: l, onOptionClick: u, setListRef: g, customIds: b, filteredOptions: f } = i, h = G(() => f.indexOf(R(String(e))) + b.length, [b.length, f, e]), x = Ue([
467
+ (m) => {
468
+ g(h, m);
469
+ },
470
+ n
471
+ ]);
472
+ if (h === -1)
473
+ throw new Error("Internal error: ComboboxOption did not find index");
474
+ const w = l[R(e)], d = c === h;
475
+ F(() => {
476
+ d && (a == null || a({ type: "SET_ACTIVE_INDEX", payload: h }));
477
+ }, [o, t, a, d, h]);
478
+ const y = Le(() => u(e), 50);
479
+ return {
480
+ id: r,
481
+ ref: x,
482
+ selected: w,
483
+ active: d,
484
+ onOptionClick: y
485
+ };
486
+ }, Fe = Ct(v(({ value: t, description: n, children: e, className: o, ...r }, i) => {
487
+ const c = re(), { id: a, ref: l, selected: u, active: g, onOptionClick: b } = On({
488
+ id: r.id,
489
+ ref: i,
490
+ value: t
491
+ }), f = D(W);
492
+ if (!f)
493
+ throw new Error("ComboboxOption must be used within a Combobox");
494
+ const { size: h, multiple: x, getItemProps: w } = f, d = w();
495
+ return s(X, { "data-size": "md", asChild: !0, children: T("button", {
496
+ ref: l,
497
+ id: a,
498
+ // biome-ignore lint/a11y/useSemanticElements: biome wants me to use the <option> element
499
+ role: "option",
500
+ type: "button",
501
+ "aria-selected": !!u,
502
+ "aria-labelledby": c,
503
+ tabIndex: -1,
504
+ onClick: (y) => {
505
+ var m;
506
+ b(), (m = r.onClick) == null || m.call(r, y);
507
+ },
508
+ className: I("ds-combobox__option", g && "ds-combobox__option--active", x && "ds-combobox__option--multiple", o),
509
+ ...le(["displayValue"], r),
510
+ ...le(["onClick", "onPointerLeave"], d),
511
+ children: [s(X, { asChild: !0, "data-size": h, children: s("span", { children: s(st, { multiple: x, selected: !!u }) }) }), T(X, { className: "ds-combobox__option__label", "data-size": h, id: c, children: [e, n && s(it, { children: n })] })]
512
+ }) });
513
+ }));
514
+ Fe.displayName = "ComboboxOption";
515
+ function Nn(t) {
516
+ return xt(t) && t.type === Fe;
517
+ }
518
+ const _n = (t) => !!t;
519
+ function Sn({ children: t, inputValue: n, multiple: e, filter: o = (i, c) => c.label.toLowerCase().startsWith(i.toLowerCase()), initialValue: r }) {
520
+ const i = vt(o, [o]), { optionsChildren: c, customIds: a, restChildren: l, interactiveChildren: u } = G(() => Me.toArray(t).reduce((m, p) => {
521
+ if (Nn(p))
522
+ m.optionsChildren.push(p);
523
+ else if (m.restChildren.push(p), Dt(p)) {
524
+ const C = p;
525
+ if (m.interactiveChildren.push(C), !C.props.id)
526
+ throw new Error("If ComboboxCustom is interactive, it must have an id");
527
+ m.customIds.push(C.props.id);
528
+ }
529
+ return m;
530
+ }, {
531
+ optionsChildren: [],
532
+ customIds: [],
533
+ restChildren: [],
534
+ interactiveChildren: []
535
+ }), [t]), g = G(() => {
536
+ const d = [], y = {};
537
+ return c.map((m) => {
538
+ const p = m.props;
539
+ let C = p.displayValue || "";
540
+ if (!p.displayValue) {
541
+ let O = "";
542
+ Me.forEach(p.children, (_) => {
543
+ if (typeof _ == "string")
544
+ O += _;
545
+ else
546
+ throw new Error("If ComboboxOption is not a string, it must have a displayValue prop");
547
+ }), C = O;
548
+ }
549
+ d.includes(p.value) && console.warn(`Combobox has multiple options with the same value: ${p.value}`), d.push(p.value), y[R(String(p.value))] = {
550
+ value: String(p.value),
551
+ label: C,
552
+ displayValue: p.displayValue,
553
+ description: p.description
554
+ };
555
+ }), y;
556
+ }, [c]), b = G(() => ((r == null ? void 0 : r.map((d) => R(d))) || []).reduce((d, y) => {
557
+ const m = g[y];
558
+ return _n(m) && (d[y] = m), d;
559
+ }, {}), [r, g]), [f, h] = U(b), { filteredOptions: x, filteredOptionsChildren: w } = G(() => {
560
+ const d = [], y = Object.keys(g).map((m, p) => {
561
+ if (!e && Object.keys(f).length === 1 || e && f[m] || i(n, g[m]))
562
+ return d.push(m), c[p];
563
+ }).filter((m) => m);
564
+ return { filteredOptions: d, filteredOptionsChildren: y };
565
+ }, [
566
+ i,
567
+ n,
568
+ e,
569
+ g,
570
+ c,
571
+ f
572
+ ]);
573
+ return {
574
+ filteredOptionsChildren: w,
575
+ filteredOptions: x,
576
+ restChildren: l,
577
+ options: g,
578
+ customIds: a,
579
+ selectedOptions: f,
580
+ interactiveChildren: u,
581
+ setSelectedOptions: h
582
+ };
583
+ }
584
+ const Tn = ({ readOnly: t, disabled: n, interactiveChildren: e, filteredOptions: o, inputValue: r, selectedOptions: i, multiple: c, open: a, options: l, setOpen: u, handleSelectOption: g }) => {
585
+ const { activeIndex: b } = Se();
586
+ return Le((x) => {
587
+ if (!(t || n) && x)
588
+ switch (x.key) {
589
+ case "ArrowDown":
590
+ if (x.preventDefault(), a)
591
+ break;
592
+ u(!0);
593
+ break;
594
+ case "ArrowUp":
595
+ if (x.preventDefault(), b !== 0)
596
+ break;
597
+ u(!1);
598
+ break;
599
+ case "Enter": {
600
+ if (x.preventDefault(), !a)
601
+ break;
602
+ if (b <= e.length - 1) {
603
+ const y = e[b];
604
+ if (y.props.onSelect) {
605
+ y == null || y.props.onSelect();
606
+ return;
607
+ }
608
+ }
609
+ const w = b - e.length, d = o[w];
610
+ g({ option: l[d] });
611
+ break;
612
+ }
613
+ case "Backspace":
614
+ if (!c) {
615
+ const w = Object.keys(i).pop();
616
+ w && g({
617
+ option: i[w],
618
+ remove: !0
619
+ });
620
+ break;
621
+ }
622
+ if (r === "" && c) {
623
+ const w = Object.keys(i).pop();
624
+ w && g({
625
+ option: i[w],
626
+ remove: !0
627
+ });
628
+ }
629
+ break;
630
+ }
631
+ }, 20);
632
+ }, En = ({ listRef: t }) => {
633
+ const [n, e] = U(!1), { activeIndex: o } = Se(), r = _e(), { refs: i, floatingStyles: c, context: a } = Rt({
634
+ open: n,
635
+ onOpenChange: (x) => {
636
+ x || r == null || r({ type: "SET_ACTIVE_INDEX", payload: 0 }), Jt(() => {
637
+ i.floating.current && !x && (i.floating.current.scrollTop = 0), setTimeout(() => {
638
+ e(x);
639
+ }, 1);
640
+ });
641
+ },
642
+ whileElementsMounted: (x, w, d) => (Ve(x, w, d), () => {
643
+ w.scrollTop = 0;
644
+ }),
645
+ middleware: [
646
+ $t({ padding: 10 }),
647
+ Bt({
648
+ apply({ rects: x, elements: w }) {
649
+ requestAnimationFrame(() => {
650
+ Object.assign(w.floating.style, {
651
+ width: `${x.reference.width}px`,
652
+ maxHeight: "200px"
653
+ });
654
+ });
655
+ }
656
+ }),
657
+ jt(10)
658
+ ]
659
+ }), l = Lt(a, { role: "listbox" }), u = Ft(a), g = zt(a, {
660
+ listRef: t,
661
+ activeIndex: o,
662
+ virtual: !0,
663
+ scrollItemIntoView: !0,
664
+ enabled: n,
665
+ focusItemOnHover: !0,
666
+ onNavigate: (x) => {
667
+ r == null || r({ type: "SET_ACTIVE_INDEX", payload: x || 0 });
668
+ }
669
+ }), { getReferenceProps: b, getFloatingProps: f, getItemProps: h } = At([l, u, g]);
670
+ return {
671
+ open: n,
672
+ setOpen: e,
673
+ activeIndex: o,
674
+ refs: i,
675
+ floatingStyles: c,
676
+ context: a,
677
+ getReferenceProps: b,
678
+ getFloatingProps: f,
679
+ getItemProps: h
680
+ };
681
+ }, Pn = v(({ value: t, initialValue: n = [], onValueChange: e, label: o, hideLabel: r = !1, description: i, multiple: c = !1, disabled: a = !1, readOnly: l = !1, hideChips: u = !1, clearButtonLabel: g = "Fjern alt", hideClearButton: b = !1, error: f, errorId: h, id: x, name: w, portal: d = !0, htmlSize: y = 0, virtual: m = !1, children: p, style: C, size: O = "md", loading: _, loadingLabel: L = "Laster...", filter: $, chipSrLabel: z = (S) => "Slett " + S.label, className: K, ...B }, Y) => {
682
+ const S = j(null), Q = j(null), P = j([]), [A, V] = U(B.inputValue || "");
683
+ F(() => {
684
+ typeof B.inputValue == "string" && V(B.inputValue);
685
+ }, [B.inputValue]);
686
+ const { selectedOptions: Z, options: q, restChildren: lt, interactiveChildren: dt, customIds: ut, filteredOptionsChildren: he, filteredOptions: ze, setSelectedOptions: ee } = Sn({
687
+ children: p,
688
+ inputValue: A,
689
+ filter: $,
690
+ multiple: c,
691
+ initialValue: n
692
+ }), { open: ge, setOpen: ye, refs: ie, floatingStyles: mt, context: Ae, getReferenceProps: ft, getFloatingProps: bt, getItemProps: pt } = En({
693
+ listRef: P
694
+ }), te = In({
695
+ disabled: a,
696
+ error: f,
697
+ errorId: h,
698
+ size: O,
699
+ description: i,
700
+ id: x
701
+ }, "combobox");
702
+ F(() => {
703
+ if (t && t.length > 0 && !c) {
704
+ const N = q[R(t[0])];
705
+ S.current && ae(S.current, (N == null ? void 0 : N.label) || "");
706
+ }
707
+ }, [c, t, q]), F(() => {
708
+ if (t && Object.keys(q).length >= 0) {
709
+ const N = t.map((k) => q[R(k)]);
710
+ ee(N.reduce((k, ne) => (k[R(ne.value)] = ne, k), {}));
711
+ }
712
+ }, [c, t, q, ee]);
713
+ const xe = Le((N) => {
714
+ var $e, Be;
715
+ const { option: k, clear: ne, remove: gt } = N;
716
+ if (ne) {
717
+ ee({}), S.current && ae(S.current, ""), e == null || e([]);
718
+ return;
719
+ }
720
+ if (!k)
721
+ return;
722
+ if (gt) {
723
+ const M = { ...Z };
724
+ delete M[R(k.value)], ee(M), e == null || e(Object.keys(M).map((se) => Ie(se)));
725
+ return;
726
+ }
727
+ const H = { ...Z };
728
+ if (c)
729
+ H[R(k.value)] ? delete H[R(k.value)] : H[R(k.value)] = k, S.current && ae(S.current, ""), ($e = S.current) == null || $e.focus();
730
+ else {
731
+ for (const M of Object.keys(H))
732
+ delete H[M];
733
+ H[R(k.value)] = k, S.current && ae(S.current, (k == null ? void 0 : k.label) || ""), setTimeout(() => {
734
+ var M, se, je;
735
+ (je = S.current) == null || je.setSelectionRange(((M = k == null ? void 0 : k.label) == null ? void 0 : M.length) || 0, ((se = k == null ? void 0 : k.label) == null ? void 0 : se.length) || 0);
736
+ }, 0);
737
+ }
738
+ ee(H), e == null || e(Object.keys(H).map((M) => Ie(M))), !c && ye(!1), (Be = ie.domReference.current) == null || Be.focus();
739
+ }, 50), ht = Tn({
740
+ filteredOptions: ze,
741
+ selectedOptions: Z,
742
+ readOnly: te.readOnly || !1,
743
+ disabled: a,
744
+ multiple: c,
745
+ inputValue: A,
746
+ options: q,
747
+ open: ge,
748
+ interactiveChildren: dt,
749
+ setOpen: ye,
750
+ handleSelectOption: xe
751
+ }), Ce = qt({
752
+ count: Object.keys(he).length,
753
+ getScrollElement: () => m ? ie.floating.current : null,
754
+ estimateSize: () => 70,
755
+ measureElement: (N) => N.getBoundingClientRect().height,
756
+ overscan: 7
757
+ });
758
+ return T(W.Provider, { value: {
759
+ size: O,
760
+ options: q,
761
+ selectedOptions: Z,
762
+ multiple: c,
763
+ disabled: a,
764
+ readOnly: l,
765
+ open: ge,
766
+ inputRef: S,
767
+ refs: ie,
768
+ inputValue: A,
769
+ formFieldProps: te,
770
+ htmlSize: y,
771
+ clearButtonLabel: g,
772
+ customIds: ut,
773
+ filteredOptions: ze,
774
+ setInputValue: V,
775
+ setOpen: ye,
776
+ getReferenceProps: ft,
777
+ getItemProps: pt,
778
+ /* Recieves the value of the option, and searches for it in our values lookup */
779
+ onOptionClick: (N) => {
780
+ if (l || a)
781
+ return;
782
+ const k = q[R(N)];
783
+ xe({ option: k });
784
+ },
785
+ handleSelectOption: xe,
786
+ chipSrLabel: z,
787
+ listRef: P,
788
+ forwareddRef: Y,
789
+ setListRef: (N, k) => {
790
+ P.current[N] = k;
791
+ }
792
+ }, children: [T("div", { className: I("ds-combobox", `ds-combobox--${O}`, a && "ds-combobox__disabled", K), style: C, ref: Q, children: [w && s(rt, { name: w, selectedOptions: Z, multiple: c }), s(ot, { label: o, description: i, size: O, readOnly: l, hideLabel: r, formFieldProps: te }), s(nt, { ...le(["inputValue"], B), hideClearButton: b, listId: Ae.floatingId || "", error: f, hideChips: u, handleKeyDown: ht, "aria-busy": _ }), s(Ze, { size: O, error: f, formFieldProps: te })] }), ge && s(Kt, { root: d ? null : Q, children: s(Vt, { context: Ae, initialFocus: -1, visuallyHiddenDismiss: !0, children: T("div", { "aria-labelledby": te.inputProps.id, "aria-autocomplete": "list", tabIndex: -1, ...bt({
793
+ ref: ie.setFloating,
794
+ style: {
795
+ ...mt
796
+ }
797
+ }), className: I("ds-combobox__options-wrapper", `ds-combobox--${O}`), children: [m && s("div", { style: {
798
+ height: `${Ce.getTotalSize()}px`,
799
+ width: "100%",
800
+ position: "relative"
801
+ }, children: Ce.getVirtualItems().map((N) => s("div", { ref: Ce.measureElement, "data-index": N.index, style: {
802
+ position: "absolute",
803
+ top: 0,
804
+ left: 0,
805
+ width: "100%",
806
+ transform: `translateY(${N.start}px)`
807
+ }, children: he[N.index] }, N.index)) }), _ ? T(Ut, { className: "ds-combobox__loading", children: [s(It, { "aria-label": "Laster", "data-size": "sm" }), L] }) : T(de, { children: [lt, !m && he] })] }) }) })] });
808
+ }), at = v((t, n) => s(Mt, { children: s(Pn, { ...t, ref: n }) }));
809
+ at.displayName = "Combobox";
810
+ const ct = v(({ children: t, className: n, ...e }, o) => {
811
+ const r = D(W);
812
+ if (!r)
813
+ throw new Error("ComboboxEmpty must be used within a Combobox");
814
+ const { filteredOptions: i, size: c } = r;
815
+ return i.length === 0 && s(X, { "data-size": c, asChild: !0, children: s("div", { ref: o, className: I("ds-combobox__empty", n), ...e, children: t }) });
816
+ });
817
+ ct.displayName = "ComboboxEmpty";
818
+ const pe = at;
819
+ pe.Option = Fe;
820
+ pe.Empty = ct;
821
+ pe.Option.displayName = "Combobox.Option";
822
+ pe.Empty.displayName = "Combobox.Empty";
823
+ const Dn = (t, n, e) => {
824
+ const o = (e - 1) / 2, r = Math.min(Math.max(t - Math.floor(o), 1), n - e + 1), i = Math.min(Math.max(t + Math.ceil(o), e), n), c = Array.from({ length: i + 1 - r }, (a, l) => l + r);
825
+ return e > 4 && r > 1 && c.splice(0, 2, 1, 0), e > 3 && i < n && c.splice(-2, 2, 0, n), c;
826
+ }, io = ({ currentPage: t = 1, setCurrentPage: n, onChange: e, totalPages: o = 1, showPages: r = 7 }) => G(() => {
827
+ const i = t < o, c = t !== 1, a = (l) => (u) => {
828
+ if (l < 1 || l > o)
829
+ return u.preventDefault();
830
+ e == null || e(u, l), u.defaultPrevented || n == null || n(l);
831
+ };
832
+ return {
833
+ /** Number of steps */
834
+ pages: Dn(t, o, r).map((l, u) => ({
835
+ /**
836
+ * Page number or "ellipsis" for the ellipsis item
837
+ */
838
+ page: l || "ellipsis",
839
+ /**
840
+ * Unique key for the item
841
+ */
842
+ itemKey: l ? `page-${l}` : `ellipsis-${u}`,
843
+ // React key utility
844
+ /**
845
+ * Properties to spread on Pagination.Button
846
+ */
847
+ buttonProps: l ? {
848
+ "aria-current": l === t ? "page" : void 0,
849
+ onClick: a(l),
850
+ variant: l === t ? "primary" : "tertiary"
851
+ } : null
852
+ })),
853
+ /** Properties to spread on Pagination.Button used for previous naviagation */
854
+ prevButtonProps: {
855
+ "aria-disabled": !c,
856
+ // Using aria-disabled to support all HTML elements because of potential asChild
857
+ onClick: a(t - 1),
858
+ variant: "tertiary"
859
+ },
860
+ /** Properties to spread on Pagination.Button used for next naviagation */
861
+ nextButtonProps: {
862
+ "aria-disabled": !i,
863
+ // Using aria-disabled to support all HTML elements because of potential asChild
864
+ onClick: a(t + 1),
865
+ variant: "tertiary"
866
+ },
867
+ /** Indication if previous page action should be shown or not */
868
+ hasPrev: c,
869
+ /** Indication if next page action should be shown or not */
870
+ hasNext: i
871
+ };
872
+ }, [t, o, r]);
873
+ export {
874
+ nn as B,
875
+ no as C,
876
+ Re as D,
877
+ on as L,
878
+ Te as P,
879
+ oo as S,
880
+ ro as T,
881
+ fe as a,
882
+ pe as b,
883
+ eo as c,
884
+ to as d,
885
+ Je as e,
886
+ Zn as f,
887
+ Ee as g,
888
+ io as u
889
+ };