@oslokommune/punkt-react 20.2.0 → 20.2.2

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 (34) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/components/header/HeaderGlobal.js +148 -146
  3. package/dist/components/header/HeaderService.js +2 -2
  4. package/dist/components/header/types.d.ts +26 -93
  5. package/dist/components/header-menu/HeaderMenu.js +108 -106
  6. package/dist/components/interfaces.d.ts +3 -2
  7. package/dist/components/tabs/TabItem.d.ts +2 -10
  8. package/dist/components/tabs/TabItem.js +62 -60
  9. package/dist/components/tabs/Tabs.d.ts +4 -23
  10. package/dist/components/tabs/Tabs.js +38 -43
  11. package/dist/punkt-react.cjs +1 -1
  12. package/dist/shared-strings/index.d.ts +1 -1
  13. package/dist/shared-strings/nb.d.ts +1 -0
  14. package/dist/shared-strings/nb.js +2 -1
  15. package/dist/shared-strings/resolve.d.ts +9 -0
  16. package/dist/shared-strings/resolve.js +9 -1
  17. package/dist/shared-types/header-footer.d.ts +0 -44
  18. package/dist/shared-types/header.d.ts +214 -10
  19. package/dist/shared-types/header.js +26 -0
  20. package/dist/shared-types/index.d.ts +5 -3
  21. package/dist/shared-types/index.js +24 -22
  22. package/dist/shared-types/tabs.d.ts +66 -0
  23. package/dist/shared-types/tabs.js +12 -0
  24. package/package.json +2 -2
  25. package/src/components/header/HeaderGlobal.test.tsx +82 -0
  26. package/src/components/header/HeaderGlobal.tsx +35 -16
  27. package/src/components/header/HeaderService.tsx +12 -12
  28. package/src/components/header/types.ts +37 -97
  29. package/src/components/header-menu/HeaderMenu.test.tsx +14 -0
  30. package/src/components/header-menu/HeaderMenu.tsx +7 -2
  31. package/src/components/interfaces.ts +3 -2
  32. package/src/components/tabs/TabItem.tsx +18 -12
  33. package/src/components/tabs/Tabs.test.tsx +22 -0
  34. package/src/components/tabs/Tabs.tsx +10 -43
package/CHANGELOG.md CHANGED
@@ -5,6 +5,27 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
5
5
 
6
6
  ---
7
7
 
8
+ ## [20.3.0](https://github.com/oslokommune/punkt/compare/20.2.1...20.3.0) (2026-11-17)
9
+
10
+ ---
11
+
12
+
13
+ ## [20.2.1](https://github.com/oslokommune/punkt/compare/20.2.0...20.2.1) (2026-11-17)
14
+
15
+ ### Bug Fixes
16
+ * Typesikre tabs-spec + piltastene finner alle faner (#3831). - Tabs og TabItem har spesifikasjon i TypeScript, med felles typer og
17
+ defaultverdier
18
+ - Piltastene kødder seg ikke lenger til når en fane fjernes eller
19
+ skjules
20
+ - arrow-nav, disable-arrow-nav og toggle-panels bruker booleanish
21
+
22
+ Har nå brukt `useDefault` sammen med `reflect` i Elements slik at
23
+ attributtene blir reflektert på elementet _kun_ når verdien ikke er
24
+ default.
25
+
26
+ ---
27
+
28
+
8
29
  ## [20.2.0](https://github.com/oslokommune/punkt/compare/20.1.7...20.2.0) (2026-11-17)
9
30
 
10
31
  ### Features
@@ -1,82 +1,84 @@
1
1
  "use client";
2
2
  import { __toESM as e } from "../../_virtual/_rolldown/runtime.js";
3
- import { DEFAULT_HEADER_LOGO_LINK as t } from "../../shared-types/header-footer.js";
3
+ import { HEADER_GLOBAL_DEFAULTS as t } from "../../shared-types/header.js";
4
4
  import { require_classnames as n } from "../../node_modules/classnames/index.js";
5
+ import { resolveOverride as r } from "../../shared-strings/resolve.js";
5
6
  import "../../shared-types/index.js";
6
- import { fetchHeaderFooterData as r } from "../../shared-utils/header-footer/fetch-header-footer-data.js";
7
- import { selectLocaleData as i } from "../../shared-utils/header-footer/select-megamenu.js";
7
+ import { fetchHeaderFooterData as i } from "../../shared-utils/header-footer/fetch-header-footer-data.js";
8
+ import { selectLocaleData as a } from "../../shared-utils/header-footer/select-megamenu.js";
8
9
  import { getDeepActiveElement as ee, getFocusableElementsDeep as te } from "../../shared-utils/focus-trap/index.js";
9
- import { useHeaderChrome as a } from "../../hooks/useHeaderChrome.js";
10
- import { useScrollLock as o } from "../../hooks/useScrollLock.js";
11
- import { PktButton as s } from "../button/Button.js";
10
+ import { useHeaderChrome as o } from "../../hooks/useHeaderChrome.js";
11
+ import { useScrollLock as s } from "../../hooks/useScrollLock.js";
12
+ import { PktButton as c } from "../button/Button.js";
12
13
  import { PktHeaderMenu as ne } from "../header-menu/HeaderMenu.js";
13
- import { PktHeaderUserMenu as c } from "../headerUserMenu/UserMenu.js";
14
+ import { PktHeaderUserMenu as re } from "../headerUserMenu/UserMenu.js";
14
15
  import { PktIcon as l } from "../icon/Icon.js";
15
16
  import { PktSearchInput as u } from "../searchinput/SearchInput.js";
16
- import { usePktStrings as re } from "../../hooks/usePktStrings.js";
17
- import { forwardRef as d, useCallback as f, useEffect as p, useLayoutEffect as ie, useMemo as ae, useRef as m, useState as h } from "react";
18
- import { Fragment as oe, jsx as g, jsxs as _ } from "react/jsx-runtime";
17
+ import { usePktStrings as ie } from "../../hooks/usePktStrings.js";
18
+ import { PktStringsContext as ae } from "../strings/PktStringsProvider.js";
19
+ import { forwardRef as d, useCallback as oe, useContext as se, useEffect as f, useLayoutEffect as ce, useMemo as le, useRef as p, useState as m } from "react";
20
+ import { Fragment as ue, jsx as h, jsxs as g } from "react/jsx-runtime";
19
21
  // src/components/header/HeaderGlobal.tsx
20
- var v = /* @__PURE__ */ e(n(), 1), se = "https://punkt-cdn.oslo.kommune.no/latest/logos/";
21
- typeof window < "u" && (window.pktLogoPath = window.pktLogoPath || se);
22
- var y = "pkt-header-global-menu", b = "pkt-header-global-menu-toggle", x = "pkt-header-global-search-panel", S = "pkt-header-global-search-toggle", C = d(({ className: e, "data-mode": n, dataUrl: d, data: C, locale: w = "nb-NO", logoLink: T = t, logoClick: ce, logoPath: E = typeof window < "u" ? window.pktLogoPath : se, showSearch: le = !0, searchPlaceholder: D, onSearch: ue, showContact: de = !0, user: O, userMenu: fe, representing: pe, canChangeRepresentation: me = !1, changeRepresentation: he, logOutButtonPlacement: ge = "none", logOut: _e, position: ve = "fixed", scrollBehavior: k = "hide", mobileBreakpoint: A = 768, tabletBreakpoint: ye = 1024, onDataLoaded: j, onDataError: M, strings: N }, be) => {
23
- let xe = k === "hide", [P, F] = h("none"), [Se, Ce] = h(void 0), [we, I] = h(!1), L = m(j), R = m(M);
24
- p(() => {
25
- L.current = j;
26
- }, [j]), p(() => {
27
- R.current = M;
28
- }, [M]);
29
- let { setRef: Te, isMobile: z, isTablet: B, isFixed: Ee, isSticky: De, hidden: Oe, captureFocus: ke, flagRestoreFocus: Ae, restoreFocus: je } = a({
30
- forwardedRef: be,
31
- mobileBreakpoint: A,
32
- tabletBreakpoint: ye,
33
- position: ve,
34
- scrollBehavior: k,
35
- pauseScrollHide: P !== "none"
22
+ var _ = /* @__PURE__ */ e(n(), 1), v = "https://punkt-cdn.oslo.kommune.no/latest/logos/";
23
+ typeof window < "u" && (window.pktLogoPath = window.pktLogoPath || v);
24
+ var y = "pkt-header-global-menu", b = "pkt-header-global-menu-toggle", x = "pkt-header-global-search-panel", S = "pkt-header-global-search-toggle", C = d(({ className: e, "data-mode": n, dataUrl: d, data: C, locale: w = t.locale, logoLink: de = t.logoLink, logoClick: fe, logoPath: pe = typeof window < "u" ? window.pktLogoPath : v, showSearch: me = t.showSearch, searchPlaceholder: he, onSearch: ge, showContact: _e = t.showContact, user: T, userMenu: ve, representing: ye, canChangeRepresentation: be = t.canChangeRepresentation, changeRepresentation: xe, logOutButtonPlacement: E = t.logOutButtonPlacement, logOut: Se, position: Ce = t.position, scrollBehavior: D = t.scrollBehavior, mobileBreakpoint: O = t.mobileBreakpoint, tabletBreakpoint: we = t.tabletBreakpoint, onDataLoaded: k, onDataError: A, strings: j }, Te) => {
25
+ let Ee = D === "hide", [M, N] = m("none"), [De, Oe] = m(void 0), [ke, P] = m(!1), F = p(k), I = p(A);
26
+ f(() => {
27
+ F.current = k;
28
+ }, [k]), f(() => {
29
+ I.current = A;
30
+ }, [A]);
31
+ let { setRef: L, isMobile: R, isTablet: z, isFixed: Ae, isSticky: je, hidden: Me, captureFocus: Ne, flagRestoreFocus: Pe, restoreFocus: Fe } = o({
32
+ forwardedRef: Te,
33
+ mobileBreakpoint: O,
34
+ tabletBreakpoint: we,
35
+ position: Ce,
36
+ scrollBehavior: D,
37
+ pauseScrollHide: M !== "none"
36
38
  });
37
- o(P === "menu" || P === "search");
38
- let Me = m(null), Ne = f((e) => {
39
- Me.current = e, Te(e);
40
- }, [Te]);
41
- ie(() => {
42
- if (P !== "menu" && P !== "search") return;
43
- let e = document.getElementById(P === "menu" ? y : x), t = Me.current?.getBoundingClientRect();
39
+ s(M === "menu" || M === "search");
40
+ let Ie = p(null), Le = oe((e) => {
41
+ Ie.current = e, L(e);
42
+ }, [L]);
43
+ ce(() => {
44
+ if (M !== "menu" && M !== "search") return;
45
+ let e = document.getElementById(M === "menu" ? y : x), t = Ie.current?.getBoundingClientRect();
44
46
  e && t && (e.style.setProperty("--pkt-header-global-top", `${t.top}px`), e.style.setProperty("--pkt-header-global-left", `${t.left}px`), e.style.setProperty("--pkt-header-global-width", `${t.width}px`));
45
47
  }, [
46
- P,
47
- z,
48
- B
49
- ]), p(() => {
50
- C && L.current?.(C);
51
- }, [C]), p(() => {
48
+ M,
49
+ R,
50
+ z
51
+ ]), f(() => {
52
+ C && F.current?.(C);
53
+ }, [C]), f(() => {
52
54
  if (C) return;
53
55
  let e = new AbortController();
54
- return r(d, e.signal).then((t) => {
55
- e.signal.aborted || (Ce(t), I(!1), L.current?.(t));
56
+ return i(d, e.signal).then((t) => {
57
+ e.signal.aborted || (Oe(t), P(!1), F.current?.(t));
56
58
  }).catch((e) => {
57
- e.name !== "AbortError" && (I(!0), R.current?.(e));
59
+ e.name !== "AbortError" && (P(!0), I.current?.(e));
58
60
  }), () => e.abort();
59
61
  }, [C, d]);
60
- let V = C ?? Se, H = ae(() => i(V, w), [V, w]);
61
- p(() => {
62
+ let B = C ?? De, V = le(() => a(B, w), [B, w]);
63
+ f(() => {
62
64
  let e = (e) => {
63
65
  let t = e.target;
64
- P === "user" && !t.closest(".pkt-header-global__user-container") && !t.closest(".pkt-header-global__user-menu") && F("none"), P === "menu" && !t.closest(".pkt-header-menu") && !t.closest(`#${b}`) && F("none"), P === "search" && !t.closest(".pkt-header-global__search-panel-inner") && !t.closest(`#${S}`) && F("none");
66
+ M === "user" && !t.closest(".pkt-header-global__user-container") && !t.closest(".pkt-header-global__user-menu") && N("none"), M === "menu" && !t.closest(".pkt-header-menu") && !t.closest(`#${b}`) && N("none"), M === "search" && !t.closest(".pkt-header-global__search-panel-inner") && !t.closest(`#${S}`) && N("none");
65
67
  }, t = (e) => {
66
- e.key === "Escape" && P !== "none" && (e.preventDefault(), Ae(), F("none"));
68
+ e.key === "Escape" && M !== "none" && (e.preventDefault(), Pe(), N("none"));
67
69
  };
68
- if (P !== "none") return document.addEventListener("mousedown", e), document.addEventListener("keydown", t), () => {
70
+ if (M !== "none") return document.addEventListener("mousedown", e), document.addEventListener("keydown", t), () => {
69
71
  document.removeEventListener("mousedown", e), document.removeEventListener("keydown", t);
70
72
  };
71
- je();
73
+ Fe();
72
74
  }, [
73
- P,
74
- je,
75
- Ae
76
- ]), p(() => {
77
- if (P !== "menu" && P !== "search") return;
78
- let e = P === "menu" ? y : x, t = P === "menu" ? b : S, n = () => document.getElementById(e), r = () => document.getElementById(t), i = (e) => {
79
- F("none"), (e.querySelector("button") ?? e).focus();
75
+ M,
76
+ Fe,
77
+ Pe
78
+ ]), f(() => {
79
+ if (M !== "menu" && M !== "search") return;
80
+ let e = M === "menu" ? y : x, t = M === "menu" ? b : S, n = () => document.getElementById(e), r = () => document.getElementById(t), i = (e) => {
81
+ N("none"), (e.querySelector("button") ?? e).focus();
80
82
  }, a = (e) => {
81
83
  if (e.key !== "Tab") return;
82
84
  let t = n(), a = r();
@@ -87,199 +89,199 @@ var y = "pkt-header-global-menu", b = "pkt-header-global-menu-toggle", x = "pkt-
87
89
  return;
88
90
  }
89
91
  if (o.length === 0) return;
90
- let ne = o[0], c = o[o.length - 1], l = !e.shiftKey && s === c, u = e.shiftKey && s === ne;
91
- (l || u) && (e.preventDefault(), i(a));
92
+ let c = o[0], ne = o[o.length - 1], re = !e.shiftKey && s === ne, l = e.shiftKey && s === c;
93
+ (re || l) && (e.preventDefault(), i(a));
92
94
  }, o = (e) => {
93
95
  let t = e.target;
94
96
  if (!t) return;
95
97
  let i = n();
96
98
  if (!i) return;
97
- let ee = r();
98
- i.contains(t) || ee?.contains(t) || F("none");
99
+ let a = r();
100
+ i.contains(t) || a?.contains(t) || N("none");
99
101
  };
100
102
  return document.addEventListener("keydown", a), document.addEventListener("focusin", o), () => {
101
103
  document.removeEventListener("keydown", a), document.removeEventListener("focusin", o);
102
104
  };
103
- }, [P]);
104
- let Pe = ae(() => {
105
- if (O?.lastLoggedIn) return typeof O.lastLoggedIn == "string" ? O.lastLoggedIn : new Date(O.lastLoggedIn).toLocaleString("nb-NO", {
105
+ }, [M]);
106
+ let Re = le(() => {
107
+ if (T?.lastLoggedIn) return typeof T.lastLoggedIn == "string" ? T.lastLoggedIn : new Date(T.lastLoggedIn).toLocaleString("nb-NO", {
106
108
  year: "numeric",
107
109
  month: "long",
108
110
  day: "numeric"
109
111
  });
110
- }, [O?.lastLoggedIn]), U = f((e) => {
111
- F((t) => t === e ? "none" : (ke(), e));
112
- }, [ke]), Fe = ge === "userMenu" || ge === "both", W = re(["header"], N).header, G = H?.search, K = H?.header?.contact, Ie = H?.i18n?.menu || W.menu, q = H?.i18n?.search || W.search, J = P === "menu", Y = P === "user", X = P === "search", Z = z, Q = !!(le && G), Le = G?.input.id || "pkt-header-global-search", Re = !H && !we, ze = /* @__PURE__ */ _("header", {
113
- className: (0, v.default)("pkt-header-global", z && "pkt-header-global--mobile", B && "pkt-header-global--tablet", Ee && "pkt-header-global--fixed", De && "pkt-header-global--sticky", xe && "pkt-header-global--scroll-to-hide", Oe && "pkt-header-global--hidden", e),
112
+ }, [T?.lastLoggedIn]), H = oe((e) => {
113
+ N((t) => t === e ? "none" : (Ne(), e));
114
+ }, [Ne]), ze = E === "userMenu" || E === "both", U = ie(["header"], j).header, Be = se(ae), Ve = he ?? r("header", "search", Be, j), W = V?.search, G = V?.header?.contact, K = (e, t) => r("header", e, Be, j) ?? (t || U[e]), He = K("menu", V?.i18n?.menu), q = K("search", V?.i18n?.search), J = M === "menu", Y = M === "user", X = M === "search", Z = R, Q = !!(me && W), Ue = W?.input.id || "pkt-header-global-search", We = !V && !ke, Ge = /* @__PURE__ */ g("header", {
115
+ className: (0, _.default)("pkt-header-global", R && "pkt-header-global--mobile", z && "pkt-header-global--tablet", Ae && "pkt-header-global--fixed", je && "pkt-header-global--sticky", Ee && "pkt-header-global--scroll-to-hide", Me && "pkt-header-global--hidden", e),
114
116
  "data-mode": n,
115
- ref: Ne,
117
+ ref: Le,
116
118
  children: [
117
- /* @__PURE__ */ g("div", {
119
+ /* @__PURE__ */ h("div", {
118
120
  className: "pkt-header-global__logo-area",
119
- children: T ? /* @__PURE__ */ g("span", {
121
+ children: de ? /* @__PURE__ */ h("span", {
120
122
  className: "pkt-header-global__logo",
121
- children: /* @__PURE__ */ g("a", {
122
- href: T,
123
- "aria-label": W.logoLabel,
124
- onClick: ce,
125
- children: /* @__PURE__ */ g(l, {
123
+ children: /* @__PURE__ */ h("a", {
124
+ href: de,
125
+ "aria-label": U.logoLabel,
126
+ onClick: fe,
127
+ children: /* @__PURE__ */ h(l, {
126
128
  name: "oslologo",
127
129
  "aria-hidden": "true",
128
- path: E
130
+ path: pe
129
131
  })
130
132
  })
131
- }) : /* @__PURE__ */ g("span", {
133
+ }) : /* @__PURE__ */ h("span", {
132
134
  className: "pkt-header-global__logo",
133
135
  role: "img",
134
- "aria-label": W.logoAlt,
135
- children: /* @__PURE__ */ g(l, {
136
+ "aria-label": U.logoAlt,
137
+ children: /* @__PURE__ */ h(l, {
136
138
  name: "oslologo",
137
139
  "aria-hidden": "true",
138
- path: E
140
+ path: pe
139
141
  })
140
142
  })
141
143
  }),
142
- /* @__PURE__ */ _("div", {
144
+ /* @__PURE__ */ g("div", {
143
145
  className: "pkt-header-global__content",
144
146
  children: [
145
- !Z && Q && G && /* @__PURE__ */ g("div", {
147
+ !Z && Q && W && /* @__PURE__ */ h("div", {
146
148
  className: "pkt-header-global__search",
147
- children: /* @__PURE__ */ g(u, {
149
+ children: /* @__PURE__ */ h(u, {
148
150
  appearance: "global",
149
- inputSize: B ? "small" : "medium",
151
+ inputSize: z ? "small" : "medium",
150
152
  fullwidth: !0,
151
- id: Le,
152
- name: G.input.name,
153
+ id: Ue,
154
+ name: W.input.name,
153
155
  "aria-label": q,
154
- placeholder: D ?? G.input.placeholder,
155
- action: G.endpoint,
156
+ placeholder: Ve ?? W.input.placeholder,
157
+ action: W.endpoint,
156
158
  method: "get",
157
- onSearch: ue,
159
+ onSearch: ge,
158
160
  onChange: () => {}
159
161
  })
160
162
  }),
161
- Z && Q && /* @__PURE__ */ g(s, {
163
+ Z && Q && /* @__PURE__ */ h(c, {
162
164
  id: S,
163
165
  className: "pkt-header-global__search-toggle",
164
166
  skin: "primary",
165
167
  color: X ? void 0 : "yellow",
166
168
  variant: "icon-only",
167
169
  iconName: X ? "close" : "magnifying-glass-big",
168
- size: z ? "small" : "medium",
170
+ size: R ? "small" : "medium",
169
171
  state: X ? "active" : "normal",
170
172
  "aria-expanded": X,
171
173
  "aria-controls": x,
172
- onClick: () => U("search"),
174
+ onClick: () => H("search"),
173
175
  children: q
174
176
  }),
175
- /* @__PURE__ */ g(s, {
177
+ /* @__PURE__ */ h(c, {
176
178
  id: b,
177
179
  className: "pkt-header-global__menu-toggle",
178
180
  skin: Z ? "tertiary" : "secondary",
179
181
  variant: Z ? "icon-only" : "icon-right",
180
182
  iconName: J ? "close" : "menu",
181
- size: B ? "small" : "medium",
183
+ size: z ? "small" : "medium",
182
184
  state: J ? "active" : "normal",
183
185
  "aria-expanded": J,
184
186
  "aria-controls": y,
185
- disabled: Re,
186
- onClick: () => U("menu"),
187
- children: Ie
187
+ disabled: We,
188
+ onClick: () => H("menu"),
189
+ children: He
188
190
  }),
189
- !Z && de && K && !O && /* @__PURE__ */ g("a", {
190
- className: (0, v.default)("pkt-header-global__contact", "pkt-btn", "pkt-btn--secondary", "pkt-btn--label-only", B ? "pkt-btn--small" : "pkt-btn--medium"),
191
- href: K.url,
192
- children: /* @__PURE__ */ g("span", {
191
+ !Z && _e && G && !T && /* @__PURE__ */ h("a", {
192
+ className: (0, _.default)("pkt-header-global__contact", "pkt-btn", "pkt-btn--secondary", "pkt-btn--label-only", z ? "pkt-btn--small" : "pkt-btn--medium"),
193
+ href: G.url,
194
+ children: /* @__PURE__ */ h("span", {
193
195
  className: "pkt-btn__text",
194
- children: K.text
196
+ children: G.text
195
197
  })
196
198
  })
197
199
  ]
198
200
  }),
199
- O && /* @__PURE__ */ g("div", {
201
+ T && /* @__PURE__ */ h("div", {
200
202
  className: "pkt-header-global__user",
201
- children: /* @__PURE__ */ _("div", {
202
- className: (0, v.default)("pkt-header-global__user-container", Y && "is-open"),
203
- children: [/* @__PURE__ */ _(s, {
203
+ children: /* @__PURE__ */ g("div", {
204
+ className: (0, _.default)("pkt-header-global__user-container", Y && "is-open"),
205
+ children: [/* @__PURE__ */ g(c, {
204
206
  className: "pkt-header-global__user-button",
205
207
  skin: "secondary",
206
- size: B ? "small" : "medium",
208
+ size: z ? "small" : "medium",
207
209
  state: Y ? "active" : "normal",
208
210
  variant: "icons-right-and-left",
209
211
  iconName: "user",
210
212
  secondIconName: Y ? "chevron-thin-up" : "chevron-thin-down",
211
- onClick: () => U("user"),
212
- children: [/* @__PURE__ */ _("span", {
213
+ onClick: () => H("user"),
214
+ children: [/* @__PURE__ */ g("span", {
213
215
  className: "pkt-sr-only",
214
- children: [W.userMenuButton, " "]
215
- }), /* @__PURE__ */ g("span", {
216
+ children: [U.userMenuButton, " "]
217
+ }), /* @__PURE__ */ h("span", {
216
218
  translate: "no",
217
- children: pe?.name || O.name
219
+ children: ye?.name || T.name
218
220
  })]
219
- }), Y && /* @__PURE__ */ g("div", {
221
+ }), Y && /* @__PURE__ */ h("div", {
220
222
  className: "pkt-header-global__user-menu is-open",
221
- children: /* @__PURE__ */ g(c, {
222
- strings: N,
223
- user: O,
224
- formattedLastLoggedIn: Pe,
225
- representing: pe,
226
- userMenu: fe,
227
- canChangeRepresentation: me,
228
- changeRepresentation: he,
229
- logoutOnClick: Fe ? _e : void 0
223
+ children: /* @__PURE__ */ h(re, {
224
+ strings: j,
225
+ user: T,
226
+ formattedLastLoggedIn: Re,
227
+ representing: ye,
228
+ userMenu: ve,
229
+ canChangeRepresentation: be,
230
+ changeRepresentation: xe,
231
+ logoutOnClick: ze ? Se : void 0
230
232
  })
231
233
  })]
232
234
  })
233
235
  })
234
236
  ]
235
- }), Be = J && /* @__PURE__ */ g("div", {
236
- className: (0, v.default)("pkt-header-global__menu", z && "pkt-header-global__menu--mobile", B && !z && "pkt-header-global__menu--tablet"),
237
+ }), Ke = J && /* @__PURE__ */ h("div", {
238
+ className: (0, _.default)("pkt-header-global__menu", R && "pkt-header-global__menu--mobile", z && !R && "pkt-header-global__menu--tablet"),
237
239
  id: y,
238
- children: H ? /* @__PURE__ */ g(ne, {
239
- data: V,
240
+ children: V ? /* @__PURE__ */ h(ne, {
241
+ data: B,
240
242
  locale: w,
241
243
  open: !0,
242
- mobileBreakpoint: A,
243
- strings: N
244
- }) : /* @__PURE__ */ g("nav", {
244
+ mobileBreakpoint: O,
245
+ strings: j
246
+ }) : /* @__PURE__ */ h("nav", {
245
247
  className: "pkt-header-menu pkt-header-menu--open",
246
- children: /* @__PURE__ */ g("p", {
248
+ children: /* @__PURE__ */ h("p", {
247
249
  className: "pkt-header-menu__error",
248
- children: W.menuLoadError
250
+ children: U.menuLoadError
249
251
  })
250
252
  })
251
- }), $ = X && Q && G && /* @__PURE__ */ g("div", {
252
- className: (0, v.default)("pkt-header-global__search-panel", z && "pkt-header-global__search-panel--mobile", B && !z && "pkt-header-global__search-panel--tablet"),
253
+ }), $ = X && Q && W && /* @__PURE__ */ h("div", {
254
+ className: (0, _.default)("pkt-header-global__search-panel", R && "pkt-header-global__search-panel--mobile", z && !R && "pkt-header-global__search-panel--tablet"),
253
255
  id: x,
254
- children: /* @__PURE__ */ g("div", {
256
+ children: /* @__PURE__ */ h("div", {
255
257
  className: "pkt-header-global__search-panel-inner",
256
- children: /* @__PURE__ */ g(u, {
258
+ children: /* @__PURE__ */ h(u, {
257
259
  appearance: "global",
258
260
  fullwidth: !0,
259
- id: Le,
260
- name: G.input.name,
261
+ id: Ue,
262
+ name: W.input.name,
261
263
  "aria-label": q,
262
- placeholder: D ?? G.input.placeholder,
263
- action: G.endpoint,
264
+ placeholder: Ve ?? W.input.placeholder,
265
+ action: W.endpoint,
264
266
  method: "get",
265
- onSearch: ue,
267
+ onSearch: ge,
266
268
  onChange: () => {},
267
269
  autoFocus: !0
268
270
  })
269
271
  })
270
272
  });
271
- return Ee ? /* @__PURE__ */ _("div", {
273
+ return Ae ? /* @__PURE__ */ g("div", {
272
274
  className: "pkt-header-global-wrapper",
273
275
  children: [
274
- ze,
275
- /* @__PURE__ */ g("div", { className: (0, v.default)("pkt-header-global-spacer", z && "pkt-header-global-spacer--mobile", B && !z && "pkt-header-global-spacer--tablet", O && "pkt-header-global-spacer--has-user") }),
276
+ Ge,
277
+ /* @__PURE__ */ h("div", { className: (0, _.default)("pkt-header-global-spacer", R && "pkt-header-global-spacer--mobile", z && !R && "pkt-header-global-spacer--tablet", T && "pkt-header-global-spacer--has-user") }),
276
278
  $,
277
- Be
279
+ Ke
278
280
  ]
279
- }) : /* @__PURE__ */ _(oe, { children: [
280
- ze,
281
+ }) : /* @__PURE__ */ g(ue, { children: [
282
+ Ge,
281
283
  $,
282
- Be
284
+ Ke
283
285
  ] });
284
286
  });
285
287
  C.displayName = "PktHeaderGlobal";
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { __toESM as e } from "../../_virtual/_rolldown/runtime.js";
3
- import { DEFAULT_HEADER_LOGO_LINK as t } from "../../shared-types/header-footer.js";
3
+ import { HEADER_SERVICE_DEFAULTS as t } from "../../shared-types/header.js";
4
4
  import { require_classnames as n } from "../../node_modules/classnames/index.js";
5
5
  import { useHeaderChrome as r } from "../../hooks/useHeaderChrome.js";
6
6
  import { useScrollLock as i } from "../../hooks/useScrollLock.js";
@@ -16,7 +16,7 @@ import { Fragment as ie, jsx as p, jsxs as m } from "react/jsx-runtime";
16
16
  // src/components/header/HeaderService.tsx
17
17
  var h = /* @__PURE__ */ e(n(), 1), g = "https://punkt-cdn.oslo.kommune.no/latest/logos/";
18
18
  typeof window < "u" && (window.pktLogoPath = window.pktLogoPath || g);
19
- var _ = c(({ mobileBreakpoint: e = 768, tabletBreakpoint: n = 1280, children: c, className: _, compact: v = !1, "data-mode": ae, logOutButtonPlacement: y = "none", logOut: b, openedMenu: x, showSearch: S = !1, onSearch: C, onSearchChange: w, searchValue: oe, searchPlaceholder: se, representing: T, serviceLink: E, serviceClick: D, serviceName: O, user: k, userMenu: ce, userMenuFooter: A, userOptions: j, canChangeRepresentation: le = !1, changeRepresentation: ue, hideLogo: de = !1, logoLink: M = t, logoClick: fe, logoPath: N = typeof window < "u" ? window.pktLogoPath : g, position: pe = "fixed", scrollBehavior: P = "hide", slotMenuVariant: me = "icon-only", slotMenuText: he, strings: F }, ge) => {
19
+ var _ = c(({ mobileBreakpoint: e = t.mobileBreakpoint, tabletBreakpoint: n = t.tabletBreakpoint, children: c, className: _, compact: v = t.compact, "data-mode": ae, logOutButtonPlacement: y = t.logOutButtonPlacement, logOut: b, openedMenu: x, showSearch: S = t.showSearch, onSearch: C, onSearchChange: w, searchValue: oe, searchPlaceholder: se, representing: T, serviceLink: E, serviceClick: D, serviceName: O, user: k, userMenu: ce, userMenuFooter: A, userOptions: j, canChangeRepresentation: le = t.canChangeRepresentation, changeRepresentation: ue, hideLogo: de = t.hideLogo, logoLink: M = t.logoLink, logoClick: fe, logoPath: N = typeof window < "u" ? window.pktLogoPath : g, position: pe = t.position, scrollBehavior: P = t.scrollBehavior, slotMenuVariant: me = t.slotMenuVariant, slotMenuText: he, strings: F }, ge) => {
20
20
  let _e = P === "hide";
21
21
  u(() => {
22
22
  A && console.warn("PktHeaderService: The \"userMenuFooter\" prop is deprecated and will be removed in a future version. Please use \"userMenu\" instead.");
@@ -1,120 +1,53 @@
1
1
  import { MouseEvent, ReactNode } from 'react';
2
- import { THeaderMenu, THeaderPosition, THeaderScrollBehavior, TLogOutButtonPlacement, TSlotMenuVariant, THeaderFooterApi, THeaderMenuLocale, IPktHeaderGlobal as ISharedPktHeaderGlobal } from '../../shared-types';
3
- import { IPktStringsProps } from '../../shared-strings';
4
- export type { THeaderMenu, THeaderPosition, THeaderScrollBehavior, TLogOutButtonPlacement, TSlotMenuVariant, THeaderFooterApi, THeaderMenuLocale, };
5
- /** Which header variant `<PktHeader>` renders. */
6
- export type THeaderType = 'service' | 'global';
7
- /** User object for header components */
8
- export interface User {
9
- name: string;
10
- /** @deprecated shortname is deprecated and will be removed in a future version */
11
- shortname?: string;
12
- lastLoggedIn?: string | Date;
13
- }
14
- /** Representing object for header components */
15
- export interface Representing {
16
- name: string;
17
- /** @deprecated shortname is deprecated and will be removed in a future version */
18
- shortname?: string;
19
- orgNumber?: string | number;
20
- }
21
- /** User menu item for header components */
22
- export interface UserMenuItem {
23
- iconName?: string;
24
- title: string;
25
- target: string | (() => void);
26
- }
27
- /** @deprecated Use UserMenuItem instead */
28
- export interface UserMenuFooterItem {
29
- title: string;
30
- target: string | (() => void);
31
- }
32
- export interface IPktHeader extends IPktStringsProps<'header'> {
33
- children?: ReactNode;
2
+ import { THeaderMenu, THeaderPosition, THeaderScrollBehavior, THeaderType, TLogOutButtonPlacement, TSlotMenuVariant, THeaderFooterApi, THeaderMenuLocale, User, Representing, UserMenuItem, UserMenuFooterItem, IPktHeaderServiceBase, IPktHeaderGlobalBase } from '../../shared-types';
3
+ export type { THeaderMenu, THeaderPosition, THeaderScrollBehavior, THeaderType, TLogOutButtonPlacement, TSlotMenuVariant, THeaderFooterApi, THeaderMenuLocale, User, Representing, UserMenuItem, UserMenuFooterItem, };
4
+ /**
5
+ * React-specific props both header variants share, on top of
6
+ * {@link IPktHeaderCommonBase} (in shared-types).
7
+ */
8
+ interface IPktHeaderReactCommon {
34
9
  /** Additional CSS class name(s) to apply to the header */
35
10
  className?: string;
36
11
  /** Set dark mode on the header */
37
12
  'data-mode'?: 'dark';
38
- /** Hide the Oslo logo. Default: false (logo is shown) */
39
- hideLogo?: boolean;
40
- /** Link URL for the logo. Pass an empty string to render the logo without a link */
41
- logoLink?: string;
42
- /** Override CDN path for the logo */
43
- logoPath?: string;
44
- /** Callback when logo is clicked */
13
+ /** Callback when the logo is clicked. Call `event.preventDefault()` to cancel navigation */
45
14
  logoClick?: (event: MouseEvent) => void;
46
- /** Name of the service displayed in the header */
47
- serviceName?: string;
48
- /** Link URL for the service name */
49
- serviceLink?: string;
15
+ /** Callback when the user clicks "Endre organisasjon" */
16
+ changeRepresentation?: () => void;
17
+ /** Callback when the user clicks logout. The logout button is only shown when this is set */
18
+ logOut?: () => void;
19
+ }
20
+ /**
21
+ * Props for the service Header component.
22
+ *
23
+ * Extends the framework-agnostic {@link IPktHeaderServiceBase} base
24
+ * (in shared-types) with React-specific callbacks, DOM props and
25
+ * deprecated props.
26
+ */
27
+ export interface IPktHeader extends IPktHeaderServiceBase, IPktHeaderReactCommon {
28
+ /** Which header variant to render. Use `IPktHeaderGlobal` for the global header. Narrowed to `'service'` in the next major */
29
+ type?: THeaderType;
30
+ children?: ReactNode;
50
31
  /** Callback when service name is clicked */
51
32
  serviceClick?: (event: MouseEvent) => void;
52
- /** Use compact header height */
53
- compact?: boolean;
54
- /** User object with name, shortname, and lastLoggedIn */
55
- user?: User;
56
- /** User menu items displayed in the dropdown */
57
- userMenu?: UserMenuItem[];
58
- /** Representing object with name, shortname, and orgNumber */
59
- representing?: Representing;
60
- /** Whether the user can change representation. Shows "Endre organisasjon" button */
61
- canChangeRepresentation?: boolean;
62
- /** Callback when user clicks "Endre organisasjon" */
63
- changeRepresentation?: () => void;
64
33
  /** @deprecated Use userMenu instead. Will show console.warn if used. */
65
34
  userMenuFooter?: UserMenuFooterItem[];
66
35
  /** @deprecated userOptions is no longer available. Use userMenu instead. */
67
36
  userOptions?: UserMenuItem[];
68
- /** Where to show the logout button: 'userMenu', 'header', 'both', or 'none' */
69
- logOutButtonPlacement?: TLogOutButtonPlacement;
70
- /** Callback when user clicks logout */
71
- logOut?: () => void;
72
- /** Show search input in the header */
73
- showSearch?: boolean;
74
37
  /** Callback when user submits search (presses Enter) */
75
38
  onSearch?: (query: string) => void;
76
39
  /** Callback when search input value changes */
77
40
  onSearchChange?: (query: string) => void;
78
- /** Controlled value for the search input */
79
- searchValue?: string;
80
- /** Placeholder text for the search input. Default: "Søk" */
81
- searchPlaceholder?: string;
82
- /** Custom breakpoint for responsive behavior (grid layout) in pixels. Default: 1024 */
83
- mobileBreakpoint?: number;
84
- /** Custom breakpoint for tablet responsive behavior (interaction pattern) in pixels. Default: 1280 */
85
- tabletBreakpoint?: number;
86
- /** Which menu is initially open */
87
- openedMenu?: THeaderMenu;
88
- /** Header position. 'fixed' fixes to top of viewport, 'relative' follows document flow. Default: 'fixed' */
89
- position?: THeaderPosition;
90
- /** Scroll behavior. 'hide' hides header on scroll down, 'none' keeps it visible. Default: 'hide' */
91
- scrollBehavior?: THeaderScrollBehavior;
92
- /** Variant for the slot menu button in tablet/mobile mode. Default: 'icon-only' */
93
- slotMenuVariant?: TSlotMenuVariant;
94
- /** Text for the slot menu button in tablet/mobile mode. Default: 'Meny' */
95
- slotMenuText?: string;
96
- /** Which header variant to render. Default: 'service' */
97
- type?: THeaderType;
98
41
  }
99
42
  /**
100
43
  * Props for the global (kommune-wide) Header component.
101
44
  *
102
- * Extends the framework-agnostic {@link ISharedPktHeaderGlobal} base
45
+ * Extends the framework-agnostic {@link IPktHeaderGlobalBase} base
103
46
  * (in shared-types) with React-specific callbacks and DOM props.
104
47
  */
105
- export interface IPktHeaderGlobal extends ISharedPktHeaderGlobal, IPktStringsProps<'header'> {
106
- /** Additional CSS class name(s) to apply to the header */
107
- className?: string;
108
- /** Set dark mode on the header */
109
- 'data-mode'?: 'dark';
110
- /** Callback when the logo is clicked */
111
- logoClick?: (event: MouseEvent) => void;
48
+ export interface IPktHeaderGlobal extends IPktHeaderGlobalBase, IPktHeaderReactCommon {
112
49
  /** Callback when the user submits search. When set, navigation is left to the consumer */
113
50
  onSearch?: (query: string) => void;
114
- /** Callback when the user clicks "Endre organisasjon" */
115
- changeRepresentation?: () => void;
116
- /** Callback when the user clicks logout */
117
- logOut?: () => void;
118
51
  /** Fired when the payload has been fetched (or `data` was supplied) */
119
52
  onDataLoaded?: (data: THeaderFooterApi) => void;
120
53
  /** Fired when the fetch fails */