rk-designsystem 1.3.4 → 1.4.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,52 +1,58 @@
1
1
  "use client";
2
- import { jsxs as i, jsx as r, Fragment as ye } from "react/jsx-runtime";
3
- import E, { useState as L, useEffect as p, useMemo as $e } from "react";
4
- import { RedCrossLogo as Y } from "../../assets/logos/RedCrossLogo.js";
5
- import { useLanguageOptional as we } from "../../context/LanguageContext.js";
6
- import { Link as B } from "../Link/index.js";
7
- import { Button as D } from "../Button/index.js";
8
- import { Avatar as ke } from "../Avatar/index.js";
9
- import { Paragraph as j } from "../Paragraph/index.js";
10
- import { Search as T } from "../Search/index.js";
11
- import { Switch as M } from "../Switch/index.js";
12
- import { Dropdown as d } from "../Dropdown/index.js";
2
+ import { jsxs as o, jsx as r, Fragment as Te } from "react/jsx-runtime";
3
+ import C, { useState as E, useEffect as g, useMemo as Oe } from "react";
4
+ import { RedCrossLogo as ie } from "../../assets/logos/RedCrossLogo.js";
5
+ import { useLanguageOptional as Re } from "../../context/LanguageContext.js";
6
+ import { Link as D } from "../Link/index.js";
7
+ import { Button as K } from "../Button/index.js";
8
+ import { Avatar as Ie } from "../Avatar/index.js";
9
+ import { Paragraph as U } from "../Paragraph/index.js";
10
+ import { Search as W } from "../Search/index.js";
11
+ import { Switch as Q } from "../Switch/index.js";
12
+ import { Dropdown as c } from "../Dropdown/index.js";
13
13
  import n from "./styles.module.css.js";
14
- import { ChevronDownIcon as Z, XMarkIcon as _, MagnifyingGlassIcon as P, MenuHamburgerIcon as ze, HeartIcon as Le } from "@navikt/aksel-icons";
15
- import { searchIndex as Ne } from "../../utils/search-index.js";
16
- function Ce($) {
17
- return $.split(/\s+/).map((e) => e[0] ?? "").join("").slice(0, 2).toUpperCase();
14
+ import { ChevronDownIcon as oe, XMarkIcon as se, MagnifyingGlassIcon as le, MenuHamburgerIcon as Se, HeartIcon as De } from "@navikt/aksel-icons";
15
+ const de = 'a[href], button, input, select, textarea, [tabindex]:not([tabindex="-1"])';
16
+ function We(w) {
17
+ return w.split(/\s+/).map((e) => e[0] ?? "").join("").slice(0, 2).toUpperCase();
18
18
  }
19
- const Ue = ({
20
- variant: $ = "default",
19
+ const Ae = [], Pe = ({
20
+ variant: w = "default",
21
21
  "data-color": e = "primary-color-red",
22
- activePage: ee,
23
- setPage: m,
24
- children: te,
25
- showUser: ne = !0,
26
- showSearch: re = !0,
27
- showLogin: ae = !0,
28
- showCta: oe = !1,
29
- ctaLabel: ie,
30
- ctaIcon: q = /* @__PURE__ */ r(Le, { "aria-hidden": !0 }),
31
- onCtaClick: le,
32
- showThemeToggle: se = !1,
33
- secondaryLogo: de = !1,
34
- secondaryLogoSrc: A,
35
- secondaryLogoSrcDark: F,
36
- secondaryLogoAlt: ce = "Secondary Logo",
37
- navItems: x,
38
- showNavItems: H = !0,
39
- showMenuButton: he = !0,
40
- showHeaderExtension: I = !1,
41
- showModeToggle: w = !1,
42
- showLanguageSwitch: N = !1,
43
- extensionColor: U,
44
- userName: O,
45
- userInitials: ue,
46
- userAvatarSrc: R,
47
- onUserClick: k
22
+ activePage: ce,
23
+ setPage: f,
24
+ children: he,
25
+ // All three OFF by default: the old defaults showed a placeholder user,
26
+ // a dead login link and a search box over data the consumer never
27
+ // provided, on every page that dropped in a bare <Header />.
28
+ showUser: ue = !1,
29
+ showSearch: me = !1,
30
+ showLogin: fe = !1,
31
+ loginHref: V,
32
+ onLoginClick: _,
33
+ searchItems: G = Ae,
34
+ showCta: ge = !1,
35
+ ctaLabel: pe,
36
+ ctaIcon: X = /* @__PURE__ */ r(De, { "aria-hidden": !0 }),
37
+ onCtaClick: ve,
38
+ showThemeToggle: xe = !1,
39
+ secondaryLogo: be = !1,
40
+ secondaryLogoSrc: Y,
41
+ secondaryLogoSrcDark: J,
42
+ secondaryLogoAlt: ye = "Secondary Logo",
43
+ navItems: b,
44
+ showNavItems: P = !0,
45
+ showMenuButton: $e = !0,
46
+ showHeaderExtension: A = !1,
47
+ showModeToggle: k = !1,
48
+ showLanguageSwitch: B = !1,
49
+ extensionColor: Z,
50
+ userName: M,
51
+ userInitials: we,
52
+ userAvatarSrc: j,
53
+ onUserClick: z
48
54
  }) => {
49
- const [s, z] = L(!1), [c, f] = L(!1), K = E.useRef(null), Q = E.useRef(null), G = E.useRef(null), X = E.useRef(null), [h, b] = L(""), [v, me] = L(() => {
55
+ const [l, L] = E(!1), [h, v] = E(!1), T = C.useRef(null), ee = C.useRef(null), q = C.useRef(null), te = C.useRef(null), [u, y] = E(""), [x, ke] = E(() => {
50
56
  var t;
51
57
  if (typeof document < "u") {
52
58
  const a = document.documentElement.getAttribute("data-color-scheme");
@@ -54,238 +60,257 @@ const Ue = ({
54
60
  if ((t = window.matchMedia) != null && t.call(window, "(prefers-color-scheme: dark)").matches) return "dark";
55
61
  }
56
62
  return "light";
57
- }), { language: J, setLanguage: C, t: l } = we(), [g, ge] = L(!1), pe = w && (I && !g || g);
58
- p(() => {
63
+ }), { language: ne, setLanguage: O, t: s } = Re(), [m, ze] = E(!1), Le = k && (A && !m || m);
64
+ g(() => {
59
65
  const t = "rk-header-inline-styles";
60
66
  if (typeof document > "u" || document.getElementById(t)) return;
61
- const a = Ee(n), o = document.createElement("style");
62
- o.id = t, o.textContent = a, document.head.prepend(o);
63
- }, []), p(() => {
64
- z(!1), f(!1), b("");
65
- }, [ee]), p(() => {
66
- if (!(typeof document > "u") && s && g) {
67
+ const a = Me(n), i = document.createElement("style");
68
+ i.id = t, i.textContent = a, document.head.prepend(i);
69
+ }, []), g(() => {
70
+ L(!1), v(!1), y("");
71
+ }, [ce]), g(() => {
72
+ if (!(typeof document > "u") && l && m) {
67
73
  const t = document.body.style.overflow;
68
74
  return document.body.style.overflow = "hidden", () => {
69
75
  document.body.style.overflow = t;
70
76
  };
71
77
  }
72
- }, [s, g]), p(() => {
78
+ }, [l, m]), g(() => {
73
79
  if (typeof window > "u" || typeof window.matchMedia > "u") return;
74
- const t = window.matchMedia("(max-width: 850px)"), a = (o) => ge("matches" in o ? o.matches : t.matches);
80
+ const t = window.matchMedia("(max-width: 850px)"), a = (i) => ze("matches" in i ? i.matches : t.matches);
75
81
  return a(t), t.addEventListener ? t.addEventListener("change", a) : t.addListener(a), () => {
76
82
  t.removeEventListener ? t.removeEventListener("change", a) : t.removeListener(a);
77
83
  };
78
- }, []), p(() => {
84
+ }, []), g(() => {
79
85
  if (typeof document > "u") return;
80
86
  const t = document.querySelector(`.${n.header}`);
81
87
  if (!t) return;
82
88
  const a = () => {
83
- const u = t.offsetHeight;
84
- document.documentElement.style.setProperty("--header-height-mobile", `${u}px`);
89
+ const d = t.offsetHeight;
90
+ document.documentElement.style.setProperty("--header-height-mobile", `${d}px`);
85
91
  };
86
92
  a(), window.addEventListener("resize", a);
87
- const o = new ResizeObserver(() => {
93
+ const i = new ResizeObserver(() => {
88
94
  a();
89
95
  });
90
- return o.observe(t), () => {
91
- window.removeEventListener("resize", a), o.disconnect();
96
+ return i.observe(t), () => {
97
+ window.removeEventListener("resize", a), i.disconnect();
92
98
  };
93
- }, [g]), p(() => {
99
+ }, [m]), g(() => {
94
100
  if (typeof document > "u") return;
95
101
  const t = document.querySelector(`.${n.logoWrapper}`);
96
102
  if (!t) return;
97
103
  const a = () => {
98
- const o = t.offsetWidth;
99
- document.documentElement.style.setProperty("--rk-logo-width", `${o}px`);
104
+ const i = t.offsetWidth;
105
+ document.documentElement.style.setProperty("--rk-logo-width", `${i}px`);
100
106
  };
101
107
  return a(), window.addEventListener("resize", a), () => window.removeEventListener("resize", a);
102
- }, [g]), p(() => {
103
- if (typeof document > "u" || !c) {
108
+ }, [m]), g(() => {
109
+ if (typeof document > "u" || !h) {
104
110
  document.documentElement.style.setProperty("--rk-search-overlay-height", "0px");
105
111
  return;
106
112
  }
107
113
  const t = document.querySelector(`.${n.searchOverlay}`);
108
114
  if (!t) return;
109
115
  const a = () => {
110
- const u = t.offsetHeight;
111
- document.documentElement.style.setProperty("--rk-search-overlay-height", `${u}px`);
116
+ const d = t.offsetHeight;
117
+ document.documentElement.style.setProperty("--rk-search-overlay-height", `${d}px`);
112
118
  };
113
119
  requestAnimationFrame(a), window.addEventListener("resize", a);
114
- const o = new ResizeObserver(a);
115
- return o.observe(t), () => {
116
- window.removeEventListener("resize", a), o.disconnect();
120
+ const i = new ResizeObserver(a);
121
+ return i.observe(t), () => {
122
+ window.removeEventListener("resize", a), i.disconnect();
117
123
  };
118
- }, [c]), p(() => {
119
- if (!s && !c) return;
124
+ }, [h]), g(() => {
125
+ if (!l && !h) return;
120
126
  const t = (a) => {
121
- var o, u;
122
- a.key === "Escape" && (s && (z(!1), (o = K.current) == null || o.focus()), c && (f(!1), (u = Q.current) == null || u.focus()));
127
+ var i, d;
128
+ a.key === "Escape" && (l && (L(!1), (i = T.current) == null || i.focus()), h && (v(!1), (d = ee.current) == null || d.focus()));
123
129
  };
124
130
  return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
125
- }, [s, c]), p(() => {
126
- var t, a, o;
127
- c ? (t = X.current) == null || t.focus() : s && ((o = (a = G.current) == null ? void 0 : a.querySelector('a[href], button, input, select, [tabindex]:not([tabindex="-1"])')) == null || o.focus());
128
- }, [s, c]);
129
- const S = () => {
130
- const t = v === "light" ? "dark" : "light";
131
- me(t), document.documentElement.setAttribute("data-color-scheme", t);
132
- }, fe = (t) => {
133
- m && (t.preventDefault(), m("home")), z(!1), f(!1);
134
- }, ve = () => {
135
- z(!s), c && f(!1), !s && typeof document < "u" && requestAnimationFrame(() => {
131
+ }, [l, h]), g(() => {
132
+ var t, a, i;
133
+ h ? (t = te.current) == null || t.focus() : l && ((i = (a = q.current) == null ? void 0 : a.querySelector(de)) == null || i.focus());
134
+ }, [l, h]), g(() => {
135
+ if (!l || !m) return;
136
+ const t = (a) => {
137
+ if (a.key !== "Tab") return;
138
+ const i = q.current;
139
+ if (!i) return;
140
+ const d = (p) => typeof p.checkVisibility == "function" ? p.checkVisibility() : p.offsetParent !== null, N = Array.from(i.querySelectorAll(de)).filter(
141
+ (p) => !p.hasAttribute("disabled") && p.getAttribute("aria-hidden") !== "true" && d(p)
142
+ ), R = [T.current, ...N].filter((p) => !!p), I = R[0], H = R[R.length - 1];
143
+ if (!I || !H) return;
144
+ const S = document.activeElement;
145
+ (a.shiftKey ? S === I : S === H) ? (a.preventDefault(), (a.shiftKey ? H : I).focus()) : (!S || !R.includes(S)) && (a.preventDefault(), I.focus());
146
+ };
147
+ return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
148
+ }, [l, m]);
149
+ const re = C.useRef(!1);
150
+ g(() => {
151
+ var t;
152
+ re.current && !l && typeof document < "u" && (!document.activeElement || document.activeElement === document.body) && ((t = T.current) == null || t.focus()), re.current = l;
153
+ }, [l]);
154
+ const F = () => {
155
+ const t = x === "light" ? "dark" : "light";
156
+ ke(t), document.documentElement.setAttribute("data-color-scheme", t);
157
+ }, Ne = (t) => {
158
+ f && (t.preventDefault(), f("home")), L(!1), v(!1);
159
+ }, Ce = () => {
160
+ L(!l), h && v(!1), !l && typeof document < "u" && requestAnimationFrame(() => {
136
161
  const t = document.querySelector(`.${n.header}`);
137
162
  if (t) {
138
163
  const a = t.offsetHeight;
139
164
  document.documentElement.style.setProperty("--header-height-mobile", `${a}px`);
140
165
  }
141
166
  });
142
- }, xe = () => {
143
- f(!c), s && z(!1);
144
- }, y = $e(() => {
145
- if (!h.trim()) return [];
146
- const t = h.toLowerCase();
147
- return Ne.filter((a) => a.title.toLowerCase().includes(t)).sort((a, o) => {
148
- const u = a.title.toLowerCase().startsWith(t) ? 0 : 1, W = o.title.toLowerCase().startsWith(t) ? 0 : 1;
149
- return u - W;
167
+ }, Ee = () => {
168
+ v(!h), l && L(!1);
169
+ }, $ = Oe(() => {
170
+ if (!u.trim()) return [];
171
+ const t = u.toLowerCase();
172
+ return G.filter((a) => a.title.toLowerCase().includes(t)).sort((a, i) => {
173
+ const d = a.title.toLowerCase().startsWith(t) ? 0 : 1, N = i.title.toLowerCase().startsWith(t) ? 0 : 1;
174
+ return d - N;
150
175
  });
151
- }, [h]), V = () => {
152
- !m || !h.trim() || (m(`search/${encodeURIComponent(h.trim())}`), f(!1), b(""));
153
- }, be = (t) => {
154
- m && m(t), f(!1), b("");
176
+ }, [u, G]), ae = () => {
177
+ !f || !u.trim() || (f(`search/${encodeURIComponent(u.trim())}`), v(!1), y(""));
178
+ }, Be = (t) => {
179
+ f && f(t), v(!1), y("");
155
180
  };
156
181
  return (
157
182
  // The attribute sets a real Digdir theme scope, so the extension CSS can
158
183
  // use scope-relative variables (--ds-color-base-default etc.) and any
159
184
  // scope themes it correctly. Legacy 'primary' aliases to the scope it
160
185
  // always meant.
161
- /* @__PURE__ */ i("header", { className: n.header, "data-open": s ? "true" : "false", "data-color": e === "primary" ? "primary-color-red" : e, "data-variant": $, "data-header-extension": I ? "true" : "false", children: [
162
- I && /* @__PURE__ */ r("div", { className: `${n.headerExtension}${U === "tinted" ? ` ${n.headerExtensionTinted}` : ""}`, "data-color-scheme": "light", "data-extension-color": U, children: /* @__PURE__ */ i("div", { className: n.extensionContentWrapper, children: [
163
- w && /* @__PURE__ */ r("div", { className: n.extensionContent, children: /* @__PURE__ */ r(
164
- M,
186
+ /* @__PURE__ */ o("header", { className: n.header, "data-open": l ? "true" : "false", "data-color": e === "primary" ? "primary-color-red" : e, "data-variant": w, "data-header-extension": A ? "true" : "false", children: [
187
+ A && /* @__PURE__ */ r("div", { className: `${n.headerExtension}${Z === "tinted" ? ` ${n.headerExtensionTinted}` : ""}`, "data-color-scheme": "light", "data-extension-color": Z, children: /* @__PURE__ */ o("div", { className: n.extensionContentWrapper, children: [
188
+ k && /* @__PURE__ */ r("div", { className: n.extensionContent, children: /* @__PURE__ */ r(
189
+ Q,
165
190
  {
166
191
  "data-size": "sm",
167
- checked: v === "dark",
168
- onChange: S,
169
- label: l("header.darkMode"),
192
+ checked: x === "dark",
193
+ onChange: F,
194
+ label: s("header.darkMode"),
170
195
  color: "neutral",
171
196
  "data-color-scheme": "light"
172
197
  }
173
198
  ) }),
174
- w && N && /* @__PURE__ */ r("div", { className: n.extensionDivider }),
175
- N && /* @__PURE__ */ i("div", { className: n.languageSwitch, children: [
176
- /* @__PURE__ */ r("span", { className: n.languageLabel, children: l("header.language") }),
177
- /* @__PURE__ */ i(d.TriggerContext, { children: [
178
- /* @__PURE__ */ i(
179
- d.Trigger,
199
+ k && B && /* @__PURE__ */ r("div", { className: n.extensionDivider }),
200
+ B && /* @__PURE__ */ o("div", { className: n.languageSwitch, children: [
201
+ /* @__PURE__ */ r("span", { className: n.languageLabel, children: s("header.language") }),
202
+ /* @__PURE__ */ o(c.TriggerContext, { children: [
203
+ /* @__PURE__ */ o(
204
+ c.Trigger,
180
205
  {
181
206
  className: n.languageLink,
182
- "aria-label": l("header.selectLanguage"),
207
+ "aria-label": s("header.selectLanguage"),
183
208
  style: { background: "transparent", border: "none", padding: 0, cursor: "pointer", font: "inherit" },
184
209
  children: [
185
- J,
210
+ ne,
186
211
  " ",
187
- /* @__PURE__ */ r(Z, { "aria-hidden": !0 })
212
+ /* @__PURE__ */ r(oe, { "aria-hidden": !0 })
188
213
  ]
189
214
  }
190
215
  ),
191
216
  /* @__PURE__ */ r(
192
- d,
217
+ c,
193
218
  {
194
- "data-color-scheme": v,
219
+ "data-color-scheme": x,
195
220
  placement: "bottom-end",
196
- children: /* @__PURE__ */ i(d.List, { children: [
197
- /* @__PURE__ */ r(d.Item, { children: /* @__PURE__ */ r(d.Button, { onClick: () => C("NO"), children: "Norsk (NO)" }) }),
198
- /* @__PURE__ */ r(d.Item, { children: /* @__PURE__ */ r(d.Button, { onClick: () => C("EN"), children: "English (EN)" }) })
221
+ children: /* @__PURE__ */ o(c.List, { children: [
222
+ /* @__PURE__ */ r(c.Item, { children: /* @__PURE__ */ r(c.Button, { onClick: () => O("NO"), children: "Norsk (NO)" }) }),
223
+ /* @__PURE__ */ r(c.Item, { children: /* @__PURE__ */ r(c.Button, { onClick: () => O("EN"), children: "English (EN)" }) })
199
224
  ] })
200
225
  }
201
226
  )
202
227
  ] })
203
228
  ] })
204
229
  ] }) }),
205
- /* @__PURE__ */ i("div", { className: n.headerInner, children: [
206
- /* @__PURE__ */ i("div", { className: n.logoWrapper, children: [
230
+ /* @__PURE__ */ o("div", { className: n.headerInner, children: [
231
+ /* @__PURE__ */ o("div", { className: n.logoWrapper, children: [
207
232
  /* @__PURE__ */ r(
208
- B,
233
+ D,
209
234
  {
210
235
  href: "/",
211
236
  className: `${n.logo} ${n.primaryLogo}`,
212
- "aria-label": l("header.homeAriaLabel"),
213
- onClick: fe,
214
- children: /* @__PURE__ */ r(Y, { className: n.redCrossLogo })
237
+ "aria-label": s("header.homeAriaLabel"),
238
+ onClick: Ne,
239
+ children: /* @__PURE__ */ r(ie, { className: n.redCrossLogo })
215
240
  }
216
241
  ),
217
- de && /* @__PURE__ */ r("div", { className: n.secondaryLogoWrapper, children: A ? /* @__PURE__ */ r(
242
+ be && /* @__PURE__ */ r("div", { className: n.secondaryLogoWrapper, children: Y ? /* @__PURE__ */ r(
218
243
  "img",
219
244
  {
220
- src: v === "dark" && F ? F : A,
221
- alt: ce,
245
+ src: x === "dark" && J ? J : Y,
246
+ alt: ye,
222
247
  className: n.secondaryLogo
223
248
  }
224
249
  ) : /* @__PURE__ */ r("div", { className: n.slotComponent, children: /* @__PURE__ */ r("div", { className: n.slotContainer, children: /* @__PURE__ */ r("p", { className: n.slotText, children: "SLOT" }) }) }) })
225
250
  ] }),
226
- H && x && x.length > 0 && !g && /* @__PURE__ */ r("nav", { className: n.navItems, children: x.map((t, a) => /* @__PURE__ */ r(
227
- B,
251
+ P && b && b.length > 0 && !m && /* @__PURE__ */ r("nav", { className: n.navItems, children: b.map((t, a) => /* @__PURE__ */ r(
252
+ D,
228
253
  {
229
254
  href: t.href,
230
255
  className: n.navLink,
231
- onClick: (o) => {
232
- m && (o.preventDefault(), m(t.href));
256
+ onClick: (i) => {
257
+ f && (i.preventDefault(), f(t.href));
233
258
  },
234
259
  children: t.label
235
260
  },
236
261
  a
237
262
  )) }),
238
- /* @__PURE__ */ i("div", { className: n.actions, children: [
239
- oe && // data-color="main" was removed here and on the search/menu buttons below:
263
+ /* @__PURE__ */ o("div", { className: n.actions, children: [
264
+ ge && // data-color="main" was removed here and on the search/menu buttons below:
240
265
  // "main" matches no theme scope, so the buttons always inherited the
241
266
  // ancestor scope — now they do so explicitly. data-color is
242
267
  // compile-checked against the real scopes since 1.4.0.
243
- /* @__PURE__ */ i(
244
- D,
268
+ /* @__PURE__ */ o(
269
+ K,
245
270
  {
246
271
  variant: "primary",
247
272
  "data-size": "md",
248
273
  className: n.ctaButton,
249
- onClick: le,
274
+ onClick: ve,
250
275
  children: [
251
- q,
252
- /* @__PURE__ */ r("span", { className: q ? n.buttonText : void 0, children: ie || l("header.supportUs") })
276
+ X,
277
+ /* @__PURE__ */ r("span", { className: X ? n.buttonText : void 0, children: pe || s("header.supportUs") })
253
278
  ]
254
279
  }
255
280
  ),
256
- se && !pe && /* @__PURE__ */ r("div", { className: n.themeToggle, children: /* @__PURE__ */ r(
257
- M,
281
+ xe && !Le && /* @__PURE__ */ r("div", { className: n.themeToggle, children: /* @__PURE__ */ r(
282
+ Q,
258
283
  {
259
- checked: v === "dark",
260
- onChange: S,
261
- "aria-label": l("header.toggleTheme")
284
+ checked: x === "dark",
285
+ onChange: F,
286
+ "aria-label": s("header.toggleTheme")
262
287
  }
263
288
  ) }),
264
- ne && (() => {
265
- const t = O ?? "Frodo Baggins", a = ue ?? (O ? Ce(O) : "FB"), o = !!k;
266
- return /* @__PURE__ */ i(
289
+ ue && M && (() => {
290
+ const t = M, a = we ?? We(M), i = !!z;
291
+ return /* @__PURE__ */ o(
267
292
  "div",
268
293
  {
269
294
  className: n.userInfo,
270
- onClick: k,
271
- role: o ? "button" : void 0,
272
- tabIndex: o ? 0 : void 0,
273
- onKeyDown: o ? (u) => {
274
- (u.key === "Enter" || u.key === " ") && (u.preventDefault(), k == null || k());
295
+ onClick: z,
296
+ role: i ? "button" : void 0,
297
+ tabIndex: i ? 0 : void 0,
298
+ onKeyDown: i ? (d) => {
299
+ (d.key === "Enter" || d.key === " ") && (d.preventDefault(), z == null || z());
275
300
  } : void 0,
276
- style: o ? { cursor: "pointer" } : void 0,
301
+ style: i ? { cursor: "pointer" } : void 0,
277
302
  children: [
278
- /* @__PURE__ */ r(j, { "data-size": "md", className: n.userName, children: t }),
303
+ /* @__PURE__ */ r(U, { "data-size": "md", className: n.userName, children: t }),
279
304
  /* @__PURE__ */ r(
280
- ke,
305
+ Ie,
281
306
  {
282
307
  "aria-label": t,
283
308
  variant: "circle",
284
- initials: R ? void 0 : a,
285
- children: R ? /* @__PURE__ */ r(
309
+ initials: j ? void 0 : a,
310
+ children: j ? /* @__PURE__ */ r(
286
311
  "img",
287
312
  {
288
- src: R,
313
+ src: j,
289
314
  alt: "",
290
315
  style: { width: "100%", height: "100%", objectFit: "cover" }
291
316
  }
@@ -296,176 +321,186 @@ const Ue = ({
296
321
  }
297
322
  );
298
323
  })(),
299
- ae && /* @__PURE__ */ i("a", { href: "#", className: n.loginLink, children: [
300
- /* @__PURE__ */ r(j, { "data-size": "md", className: n.loginText, children: l("header.login") }),
301
- /* @__PURE__ */ r("div", { className: n.underline })
302
- ] }),
303
- re && /* @__PURE__ */ r("div", { className: n.searchButtonWrapper, children: /* @__PURE__ */ i(
304
- D,
324
+ fe && /* @__PURE__ */ o(
325
+ "a",
305
326
  {
306
- ref: Q,
327
+ href: V ?? "#",
328
+ className: n.loginLink,
329
+ onClick: _ ? (t) => {
330
+ V || t.preventDefault(), _();
331
+ } : void 0,
332
+ children: [
333
+ /* @__PURE__ */ r(U, { "data-size": "md", className: n.loginText, children: s("header.login") }),
334
+ /* @__PURE__ */ r("div", { className: n.underline })
335
+ ]
336
+ }
337
+ ),
338
+ me && /* @__PURE__ */ r("div", { className: n.searchButtonWrapper, children: /* @__PURE__ */ o(
339
+ K,
340
+ {
341
+ ref: ee,
307
342
  variant: "secondary",
308
343
  "data-size": "md",
309
- onClick: xe,
310
- "aria-expanded": c,
311
- "aria-label": l(c ? "header.closeSearch" : "header.openSearch"),
344
+ onClick: Ee,
345
+ "aria-expanded": h,
346
+ "aria-label": s(h ? "header.closeSearch" : "header.openSearch"),
312
347
  children: [
313
- c ? /* @__PURE__ */ r(_, { "aria-hidden": !0 }) : /* @__PURE__ */ r(P, { "aria-hidden": !0 }),
314
- /* @__PURE__ */ r("span", { className: n.buttonText, children: l(c ? "header.close" : "header.search") })
348
+ h ? /* @__PURE__ */ r(se, { "aria-hidden": !0 }) : /* @__PURE__ */ r(le, { "aria-hidden": !0 }),
349
+ /* @__PURE__ */ r("span", { className: n.buttonText, children: s(h ? "header.close" : "header.search") })
315
350
  ]
316
351
  }
317
352
  ) }),
318
- (he || g) && /* @__PURE__ */ i(
319
- D,
353
+ ($e || m) && /* @__PURE__ */ o(
354
+ K,
320
355
  {
321
- ref: K,
356
+ ref: T,
322
357
  variant: "primary",
323
358
  "data-size": "md",
324
- onClick: ve,
325
- "aria-expanded": s,
326
- "aria-label": l(s ? "header.closeMenu" : "header.openMenu"),
359
+ onClick: Ce,
360
+ "aria-expanded": l,
361
+ "aria-label": s(l ? "header.closeMenu" : "header.openMenu"),
327
362
  className: n.menuButton,
328
363
  children: [
329
- s ? /* @__PURE__ */ r(_, { "aria-hidden": !0 }) : /* @__PURE__ */ r(ze, { "aria-hidden": !0 }),
330
- /* @__PURE__ */ r("span", { className: n.buttonText, children: l(s ? "header.close" : "header.menu") })
364
+ l ? /* @__PURE__ */ r(se, { "aria-hidden": !0 }) : /* @__PURE__ */ r(Se, { "aria-hidden": !0 }),
365
+ /* @__PURE__ */ r("span", { className: n.buttonText, children: s(l ? "header.close" : "header.menu") })
331
366
  ]
332
367
  }
333
368
  )
334
369
  ] })
335
370
  ] }),
336
- s && /* @__PURE__ */ r("div", { className: n.menuOverlay, ref: G, children: /* @__PURE__ */ i("div", { className: n.menuContent, children: [
371
+ l && /* @__PURE__ */ r("div", { className: n.menuOverlay, ref: q, children: /* @__PURE__ */ o("div", { className: n.menuContent, children: [
337
372
  /* @__PURE__ */ r("div", { className: n.menuLeftColumn }),
338
- /* @__PURE__ */ i("div", { className: n.menuRightColumn, children: [
339
- g && (N || w) && /* @__PURE__ */ i("div", { className: n.menuUtilities, children: [
340
- N && /* @__PURE__ */ i("div", { className: n.languageSwitch, children: [
341
- /* @__PURE__ */ r("span", { className: n.languageLabel, children: l("header.language") }),
342
- /* @__PURE__ */ i(d.TriggerContext, { children: [
343
- /* @__PURE__ */ i(
344
- d.Trigger,
373
+ /* @__PURE__ */ o("div", { className: n.menuRightColumn, children: [
374
+ m && (B || k) && /* @__PURE__ */ o("div", { className: n.menuUtilities, children: [
375
+ B && /* @__PURE__ */ o("div", { className: n.languageSwitch, children: [
376
+ /* @__PURE__ */ r("span", { className: n.languageLabel, children: s("header.language") }),
377
+ /* @__PURE__ */ o(c.TriggerContext, { children: [
378
+ /* @__PURE__ */ o(
379
+ c.Trigger,
345
380
  {
346
381
  className: n.languageLink,
347
- "aria-label": l("header.selectLanguage"),
382
+ "aria-label": s("header.selectLanguage"),
348
383
  style: { background: "transparent", border: "none", padding: 0, cursor: "pointer", font: "inherit" },
349
384
  children: [
350
- J,
385
+ ne,
351
386
  " ",
352
- /* @__PURE__ */ r(Z, { "aria-hidden": !0 })
387
+ /* @__PURE__ */ r(oe, { "aria-hidden": !0 })
353
388
  ]
354
389
  }
355
390
  ),
356
391
  /* @__PURE__ */ r(
357
- d,
392
+ c,
358
393
  {
359
- "data-color-scheme": v,
394
+ "data-color-scheme": x,
360
395
  placement: "bottom-start",
361
- children: /* @__PURE__ */ i(d.List, { children: [
362
- /* @__PURE__ */ r(d.Item, { children: /* @__PURE__ */ r(d.Button, { onClick: () => C("NO"), children: "Norsk (NO)" }) }),
363
- /* @__PURE__ */ r(d.Item, { children: /* @__PURE__ */ r(d.Button, { onClick: () => C("EN"), children: "English (EN)" }) })
396
+ children: /* @__PURE__ */ o(c.List, { children: [
397
+ /* @__PURE__ */ r(c.Item, { children: /* @__PURE__ */ r(c.Button, { onClick: () => O("NO"), children: "Norsk (NO)" }) }),
398
+ /* @__PURE__ */ r(c.Item, { children: /* @__PURE__ */ r(c.Button, { onClick: () => O("EN"), children: "English (EN)" }) })
364
399
  ] })
365
400
  }
366
401
  )
367
402
  ] })
368
403
  ] }),
369
- w && /* @__PURE__ */ r("div", { className: n.extensionContent, children: /* @__PURE__ */ r(
370
- M,
404
+ k && /* @__PURE__ */ r("div", { className: n.extensionContent, children: /* @__PURE__ */ r(
405
+ Q,
371
406
  {
372
407
  "data-size": "sm",
373
- checked: v === "dark",
374
- onChange: S,
375
- label: l("header.darkMode"),
408
+ checked: x === "dark",
409
+ onChange: F,
410
+ label: s("header.darkMode"),
376
411
  color: "neutral",
377
412
  "data-color-scheme": "light"
378
413
  }
379
414
  ) })
380
415
  ] }),
381
- /* @__PURE__ */ i("div", { className: n.slotContent, children: [
382
- te,
383
- g && H && x && x.length > 0 && /* @__PURE__ */ r("nav", { className: n.navList, children: x.map((t, a) => /* @__PURE__ */ r(
384
- B,
416
+ /* @__PURE__ */ o("div", { className: n.slotContent, children: [
417
+ he,
418
+ m && P && b && b.length > 0 && /* @__PURE__ */ r("nav", { className: n.navList, children: b.map((t, a) => /* @__PURE__ */ r(
419
+ D,
385
420
  {
386
421
  href: t.href,
387
422
  className: n.navLink,
388
- onClick: (o) => {
389
- m && (o.preventDefault(), m(t.href));
423
+ onClick: (i) => {
424
+ f && (i.preventDefault(), f(t.href));
390
425
  },
391
426
  children: t.label
392
427
  },
393
428
  a
394
429
  )) })
395
430
  ] }),
396
- g && /* @__PURE__ */ r("div", { className: n.menuBrand, children: /* @__PURE__ */ r(Y, { className: n.redCrossLogo }) })
431
+ m && /* @__PURE__ */ r("div", { className: n.menuBrand, children: /* @__PURE__ */ r(ie, { className: n.redCrossLogo }) })
397
432
  ] })
398
433
  ] }) }),
399
- c && /* @__PURE__ */ r("div", { className: n.searchOverlay, children: /* @__PURE__ */ i("div", { className: n.searchContent, children: [
400
- /* @__PURE__ */ i(T, { children: [
434
+ h && /* @__PURE__ */ r("div", { className: n.searchOverlay, children: /* @__PURE__ */ o("div", { className: n.searchContent, children: [
435
+ /* @__PURE__ */ o(W, { children: [
401
436
  /* @__PURE__ */ r(
402
- T.Input,
437
+ W.Input,
403
438
  {
404
- ref: X,
405
- "aria-label": l("header.search"),
406
- placeholder: l("header.searchPlaceholder"),
407
- value: h,
408
- onChange: (t) => b(t.target.value),
439
+ ref: te,
440
+ "aria-label": s("header.search"),
441
+ placeholder: s("header.searchPlaceholder"),
442
+ value: u,
443
+ onChange: (t) => y(t.target.value),
409
444
  onKeyDown: (t) => {
410
- t.key === "Enter" && V();
445
+ t.key === "Enter" && ae();
411
446
  }
412
447
  }
413
448
  ),
414
- /* @__PURE__ */ r(T.Button, { "aria-label": l("header.search"), onClick: V }),
415
- /* @__PURE__ */ r(T.ClearButton, { onClick: () => b(""), "aria-label": l("header.clearSearch") })
449
+ /* @__PURE__ */ r(W.Button, { "aria-label": s("header.search"), onClick: ae }),
450
+ /* @__PURE__ */ r(W.ClearButton, { onClick: () => y(""), "aria-label": s("header.clearSearch") })
416
451
  ] }),
417
- h && /* @__PURE__ */ r("div", { role: "status", className: "ds-sr-only", children: y.length > 0 ? l("header.suggestionCount").replace("{count}", String(Math.min(y.length, 5))) : `${l("header.noResults")} ${h}` }),
418
- h && /* @__PURE__ */ r("div", { className: n.searchResults, children: y.length > 0 ? /* @__PURE__ */ i("div", { className: n.suggestionsSection, children: [
419
- /* @__PURE__ */ r("h3", { className: n.suggestionsTitle, children: l("header.suggestions") }),
420
- /* @__PURE__ */ r("ul", { className: n.resultList, children: y.slice(0, 5).map((t) => /* @__PURE__ */ r("li", { className: n.resultItem, children: /* @__PURE__ */ i(
452
+ u && /* @__PURE__ */ r("div", { role: "status", className: "ds-sr-only", children: $.length > 0 ? s("header.suggestionCount").replace("{count}", String(Math.min($.length, 5))) : `${s("header.noResults")} ${u}` }),
453
+ u && /* @__PURE__ */ r("div", { className: n.searchResults, children: $.length > 0 ? /* @__PURE__ */ o("div", { className: n.suggestionsSection, children: [
454
+ /* @__PURE__ */ r("h3", { className: n.suggestionsTitle, children: s("header.suggestions") }),
455
+ /* @__PURE__ */ r("ul", { className: n.resultList, children: $.slice(0, 5).map((t) => /* @__PURE__ */ r("li", { className: n.resultItem, children: /* @__PURE__ */ o(
421
456
  "button",
422
457
  {
423
458
  className: n.resultLink,
424
- onClick: () => be(t.path),
459
+ onClick: () => Be(t.path),
425
460
  children: [
426
- /* @__PURE__ */ r("span", { className: n.suggestionIcon, children: /* @__PURE__ */ r(P, { "aria-hidden": !0 }) }),
461
+ /* @__PURE__ */ r("span", { className: n.suggestionIcon, children: /* @__PURE__ */ r(le, { "aria-hidden": !0 }) }),
427
462
  /* @__PURE__ */ r("span", { className: n.suggestionText, children: (() => {
428
- const a = t.title.toLowerCase().indexOf(h.toLowerCase());
463
+ const a = t.title.toLowerCase().indexOf(u.toLowerCase());
429
464
  if (a === -1) return /* @__PURE__ */ r("span", { className: n.remainingText, children: t.title });
430
- const o = t.title.slice(0, a), u = t.title.slice(a, a + h.length), W = t.title.slice(a + h.length);
431
- return /* @__PURE__ */ i(ye, { children: [
432
- /* @__PURE__ */ r("span", { className: n.remainingText, children: o }),
433
- /* @__PURE__ */ r("span", { className: n.highlightedText, children: u }),
434
- /* @__PURE__ */ r("span", { className: n.remainingText, children: W })
465
+ const i = t.title.slice(0, a), d = t.title.slice(a, a + u.length), N = t.title.slice(a + u.length);
466
+ return /* @__PURE__ */ o(Te, { children: [
467
+ /* @__PURE__ */ r("span", { className: n.remainingText, children: i }),
468
+ /* @__PURE__ */ r("span", { className: n.highlightedText, children: d }),
469
+ /* @__PURE__ */ r("span", { className: n.remainingText, children: N })
435
470
  ] });
436
471
  })() })
437
472
  ]
438
473
  }
439
474
  ) }, t.id)) }),
440
- y.length > 5 && /* @__PURE__ */ i(
441
- B,
475
+ $.length > 5 && /* @__PURE__ */ o(
476
+ D,
442
477
  {
443
478
  href: "#",
444
479
  "data-color": "neutral",
445
480
  className: n.viewAllLink,
446
481
  onClick: (t) => {
447
- t.preventDefault(), m && m(`search/${encodeURIComponent(h)}`), f(!1), b("");
482
+ t.preventDefault(), f && f(`search/${encodeURIComponent(u)}`), v(!1), y("");
448
483
  },
449
484
  children: [
450
- l("header.viewAll"),
485
+ s("header.viewAll"),
451
486
  " (",
452
- y.length,
487
+ $.length,
453
488
  ")"
454
489
  ]
455
490
  }
456
491
  )
457
- ] }) : /* @__PURE__ */ r("div", { className: n.noResults, children: /* @__PURE__ */ i(j, { children: [
458
- l("header.noResults"),
492
+ ] }) : /* @__PURE__ */ r("div", { className: n.noResults, children: /* @__PURE__ */ o(U, { children: [
493
+ s("header.noResults"),
459
494
  ' "',
460
- h,
495
+ u,
461
496
  '"'
462
497
  ] }) }) })
463
498
  ] }) })
464
499
  ] })
465
500
  );
466
501
  };
467
- function Ee($) {
468
- const e = $;
502
+ function Me(w) {
503
+ const e = w;
469
504
  return `
470
505
  .${e.header} {
471
506
  --rk-header-extension-height: 44px;
@@ -543,7 +578,7 @@ function Ee($) {
543
578
  .${e.extensionDivider} { width: 1px; height: 18px; background-color: rgba(247,233,232,1); }
544
579
  .${e.languageSwitch} { display: flex; align-items: center; gap: var(--ds-size-2); }
545
580
  .${e.languageLabel} { font-size: var(--ds-font-size-3); color: #ECECEC; }
546
- .${e.languageLink} { color: white !important; text-decoration: none; display: flex; align-items: center; gap: 4px; }
581
+ .${e.languageLink} { color: white !important; text-decoration: none; display: flex; align-items: center; gap: var(--ds-size-1, 4px); }
547
582
  .${e.header}[data-color] .${e.languageLabel} { color: var(--ds-color-base-contrast-subtle); }
548
583
  .${e.header}[data-color] .${e.languageLink} { color: var(--ds-color-base-contrast-default) !important; }
549
584
  .${e.languageSwitch} [popover] { margin-top: 0 !important; background-color: var(--ds-color-neutral-background-default) !important; position: fixed !important; overflow: visible; z-index: 20000 !important; }
@@ -564,7 +599,7 @@ function Ee($) {
564
599
  .${e.header}[data-variant="compact"] .${e.redCrossLogo} { color: var(--ds-color-neutral-text-default); }
565
600
  .${e.secondaryLogoWrapper} { display: flex; align-items: center; justify-content: center; height: 100%; padding: 0 var(--ds-size-6); background-color: var(--ds-color-neutral-background-default); }
566
601
  .${e.secondaryLogo} { height: 24px; width: auto; display: block; }
567
- .${e.navItems} { display: flex; gap: 40px; align-items: center; margin-left: 24px; flex-grow: 1; justify-content: center; }
602
+ .${e.navItems} { display: flex; gap: 40px; align-items: center; margin-left: var(--ds-size-6, 24px); flex-grow: 1; justify-content: center; }
568
603
  .${e.navLink} { color: var(--ds-color-primary-color-red-text-default); font-family: inherit; font-size: var(--ds-font-size-3); text-decoration: none; font-weight: var(--ds-font-weight-regular); letter-spacing: 0.09px; }
569
604
  .${e.navLink}:hover { text-decoration: underline; }
570
605
  .${e.actions} { display: flex; align-items: center; gap: var(--ds-size-6); flex-shrink: 0; margin-left: auto; }
@@ -597,7 +632,7 @@ function Ee($) {
597
632
  }
598
633
  .${e.menuContent} { max-width: 1364px; margin: 0 auto; display: flex; flex-direction: row; align-items: stretch; box-sizing: border-box; }
599
634
  .${e.menuLeftColumn} { width: calc(217px + var(--ds-size-6)); flex-shrink: 0; display: flex; }
600
- .${e.menuRightColumn} { flex: 1; display: flex; flex-direction: column; padding: 48px 24px 80px 24px; gap: 24px; }
635
+ .${e.menuRightColumn} { flex: 1; display: flex; flex-direction: column; padding: var(--ds-size-12, 48px) var(--ds-size-6, 24px) 80px var(--ds-size-6, 24px); gap: var(--ds-size-6, 24px); }
601
636
  .${e.slotContent} { width: 100%; padding: var(--ds-size-10) 0; text-align: left; color: var(--ds-color-neutral-text-subtle); font-size: var(--ds-font-size-3); border-radius: var(--ds-border-radius-md); display: flex; flex-direction: column; gap: var(--ds-size-4); align-items: flex-start; }
602
637
  .${e.navList} { display: flex; flex-direction: column; gap: var(--ds-size-3); align-items: flex-start; }
603
638
  .${e.menuBrand} { display: none; }
@@ -652,5 +687,5 @@ function Ee($) {
652
687
  `;
653
688
  }
654
689
  export {
655
- Ue as Header
690
+ Pe as Header
656
691
  };