@oslokommune/punkt-react 20.2.1 → 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.
- package/CHANGELOG.md +5 -0
- package/dist/components/header/HeaderGlobal.js +148 -146
- package/dist/components/header/HeaderService.js +2 -2
- package/dist/components/header/types.d.ts +26 -93
- package/dist/components/header-menu/HeaderMenu.js +108 -106
- package/dist/components/interfaces.d.ts +1 -1
- package/dist/punkt-react.cjs +1 -1
- package/dist/shared-strings/index.d.ts +1 -1
- package/dist/shared-strings/nb.d.ts +1 -0
- package/dist/shared-strings/nb.js +2 -1
- package/dist/shared-strings/resolve.d.ts +9 -0
- package/dist/shared-strings/resolve.js +9 -1
- package/dist/shared-types/header-footer.d.ts +0 -44
- package/dist/shared-types/header.d.ts +214 -10
- package/dist/shared-types/header.js +26 -0
- package/dist/shared-types/index.d.ts +3 -3
- package/dist/shared-types/index.js +24 -23
- package/package.json +2 -2
- package/src/components/header/HeaderGlobal.test.tsx +82 -0
- package/src/components/header/HeaderGlobal.tsx +35 -16
- package/src/components/header/HeaderService.tsx +12 -12
- package/src/components/header/types.ts +37 -97
- package/src/components/header-menu/HeaderMenu.test.tsx +14 -0
- package/src/components/header-menu/HeaderMenu.tsx +7 -2
- package/src/components/interfaces.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,11 @@ 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
|
+
|
|
8
13
|
## [20.2.1](https://github.com/oslokommune/punkt/compare/20.2.0...20.2.1) (2026-11-17)
|
|
9
14
|
|
|
10
15
|
### Bug Fixes
|
|
@@ -1,82 +1,84 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { __toESM as e } from "../../_virtual/_rolldown/runtime.js";
|
|
3
|
-
import {
|
|
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
|
|
7
|
-
import { selectLocaleData as
|
|
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
|
|
10
|
-
import { useScrollLock as
|
|
11
|
-
import { PktButton as
|
|
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
|
|
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
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
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
|
|
21
|
-
typeof window < "u" && (window.pktLogoPath = window.pktLogoPath ||
|
|
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 =
|
|
23
|
-
let
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}, [
|
|
27
|
-
|
|
28
|
-
}, [
|
|
29
|
-
let { setRef:
|
|
30
|
-
forwardedRef:
|
|
31
|
-
mobileBreakpoint:
|
|
32
|
-
tabletBreakpoint:
|
|
33
|
-
position:
|
|
34
|
-
scrollBehavior:
|
|
35
|
-
pauseScrollHide:
|
|
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
|
-
|
|
38
|
-
let
|
|
39
|
-
|
|
40
|
-
}, [
|
|
41
|
-
|
|
42
|
-
if (
|
|
43
|
-
let e = document.getElementById(
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
]),
|
|
50
|
-
C &&
|
|
51
|
-
}, [C]),
|
|
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
|
|
55
|
-
e.signal.aborted || (
|
|
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" && (
|
|
59
|
+
e.name !== "AbortError" && (P(!0), I.current?.(e));
|
|
58
60
|
}), () => e.abort();
|
|
59
61
|
}, [C, d]);
|
|
60
|
-
let
|
|
61
|
-
|
|
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
|
-
|
|
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" &&
|
|
68
|
+
e.key === "Escape" && M !== "none" && (e.preventDefault(), Pe(), N("none"));
|
|
67
69
|
};
|
|
68
|
-
if (
|
|
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
|
-
|
|
73
|
+
Fe();
|
|
72
74
|
}, [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
]),
|
|
77
|
-
if (
|
|
78
|
-
let e =
|
|
79
|
-
|
|
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
|
|
91
|
-
(
|
|
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
|
|
98
|
-
i.contains(t) ||
|
|
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
|
-
}, [
|
|
104
|
-
let
|
|
105
|
-
if (
|
|
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
|
-
}, [
|
|
111
|
-
|
|
112
|
-
}, [
|
|
113
|
-
className: (0,
|
|
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:
|
|
117
|
+
ref: Le,
|
|
116
118
|
children: [
|
|
117
|
-
/* @__PURE__ */
|
|
119
|
+
/* @__PURE__ */ h("div", {
|
|
118
120
|
className: "pkt-header-global__logo-area",
|
|
119
|
-
children:
|
|
121
|
+
children: de ? /* @__PURE__ */ h("span", {
|
|
120
122
|
className: "pkt-header-global__logo",
|
|
121
|
-
children: /* @__PURE__ */
|
|
122
|
-
href:
|
|
123
|
-
"aria-label":
|
|
124
|
-
onClick:
|
|
125
|
-
children: /* @__PURE__ */
|
|
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:
|
|
130
|
+
path: pe
|
|
129
131
|
})
|
|
130
132
|
})
|
|
131
|
-
}) : /* @__PURE__ */
|
|
133
|
+
}) : /* @__PURE__ */ h("span", {
|
|
132
134
|
className: "pkt-header-global__logo",
|
|
133
135
|
role: "img",
|
|
134
|
-
"aria-label":
|
|
135
|
-
children: /* @__PURE__ */
|
|
136
|
+
"aria-label": U.logoAlt,
|
|
137
|
+
children: /* @__PURE__ */ h(l, {
|
|
136
138
|
name: "oslologo",
|
|
137
139
|
"aria-hidden": "true",
|
|
138
|
-
path:
|
|
140
|
+
path: pe
|
|
139
141
|
})
|
|
140
142
|
})
|
|
141
143
|
}),
|
|
142
|
-
/* @__PURE__ */
|
|
144
|
+
/* @__PURE__ */ g("div", {
|
|
143
145
|
className: "pkt-header-global__content",
|
|
144
146
|
children: [
|
|
145
|
-
!Z && Q &&
|
|
147
|
+
!Z && Q && W && /* @__PURE__ */ h("div", {
|
|
146
148
|
className: "pkt-header-global__search",
|
|
147
|
-
children: /* @__PURE__ */
|
|
149
|
+
children: /* @__PURE__ */ h(u, {
|
|
148
150
|
appearance: "global",
|
|
149
|
-
inputSize:
|
|
151
|
+
inputSize: z ? "small" : "medium",
|
|
150
152
|
fullwidth: !0,
|
|
151
|
-
id:
|
|
152
|
-
name:
|
|
153
|
+
id: Ue,
|
|
154
|
+
name: W.input.name,
|
|
153
155
|
"aria-label": q,
|
|
154
|
-
placeholder:
|
|
155
|
-
action:
|
|
156
|
+
placeholder: Ve ?? W.input.placeholder,
|
|
157
|
+
action: W.endpoint,
|
|
156
158
|
method: "get",
|
|
157
|
-
onSearch:
|
|
159
|
+
onSearch: ge,
|
|
158
160
|
onChange: () => {}
|
|
159
161
|
})
|
|
160
162
|
}),
|
|
161
|
-
Z && Q && /* @__PURE__ */
|
|
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:
|
|
170
|
+
size: R ? "small" : "medium",
|
|
169
171
|
state: X ? "active" : "normal",
|
|
170
172
|
"aria-expanded": X,
|
|
171
173
|
"aria-controls": x,
|
|
172
|
-
onClick: () =>
|
|
174
|
+
onClick: () => H("search"),
|
|
173
175
|
children: q
|
|
174
176
|
}),
|
|
175
|
-
/* @__PURE__ */
|
|
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:
|
|
183
|
+
size: z ? "small" : "medium",
|
|
182
184
|
state: J ? "active" : "normal",
|
|
183
185
|
"aria-expanded": J,
|
|
184
186
|
"aria-controls": y,
|
|
185
|
-
disabled:
|
|
186
|
-
onClick: () =>
|
|
187
|
-
children:
|
|
187
|
+
disabled: We,
|
|
188
|
+
onClick: () => H("menu"),
|
|
189
|
+
children: He
|
|
188
190
|
}),
|
|
189
|
-
!Z &&
|
|
190
|
-
className: (0,
|
|
191
|
-
href:
|
|
192
|
-
children: /* @__PURE__ */
|
|
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:
|
|
196
|
+
children: G.text
|
|
195
197
|
})
|
|
196
198
|
})
|
|
197
199
|
]
|
|
198
200
|
}),
|
|
199
|
-
|
|
201
|
+
T && /* @__PURE__ */ h("div", {
|
|
200
202
|
className: "pkt-header-global__user",
|
|
201
|
-
children: /* @__PURE__ */
|
|
202
|
-
className: (0,
|
|
203
|
-
children: [/* @__PURE__ */
|
|
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:
|
|
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: () =>
|
|
212
|
-
children: [/* @__PURE__ */
|
|
213
|
+
onClick: () => H("user"),
|
|
214
|
+
children: [/* @__PURE__ */ g("span", {
|
|
213
215
|
className: "pkt-sr-only",
|
|
214
|
-
children: [
|
|
215
|
-
}), /* @__PURE__ */
|
|
216
|
+
children: [U.userMenuButton, " "]
|
|
217
|
+
}), /* @__PURE__ */ h("span", {
|
|
216
218
|
translate: "no",
|
|
217
|
-
children:
|
|
219
|
+
children: ye?.name || T.name
|
|
218
220
|
})]
|
|
219
|
-
}), Y && /* @__PURE__ */
|
|
221
|
+
}), Y && /* @__PURE__ */ h("div", {
|
|
220
222
|
className: "pkt-header-global__user-menu is-open",
|
|
221
|
-
children: /* @__PURE__ */
|
|
222
|
-
strings:
|
|
223
|
-
user:
|
|
224
|
-
formattedLastLoggedIn:
|
|
225
|
-
representing:
|
|
226
|
-
userMenu:
|
|
227
|
-
canChangeRepresentation:
|
|
228
|
-
changeRepresentation:
|
|
229
|
-
logoutOnClick:
|
|
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
|
-
}),
|
|
236
|
-
className: (0,
|
|
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:
|
|
239
|
-
data:
|
|
240
|
+
children: V ? /* @__PURE__ */ h(ne, {
|
|
241
|
+
data: B,
|
|
240
242
|
locale: w,
|
|
241
243
|
open: !0,
|
|
242
|
-
mobileBreakpoint:
|
|
243
|
-
strings:
|
|
244
|
-
}) : /* @__PURE__ */
|
|
244
|
+
mobileBreakpoint: O,
|
|
245
|
+
strings: j
|
|
246
|
+
}) : /* @__PURE__ */ h("nav", {
|
|
245
247
|
className: "pkt-header-menu pkt-header-menu--open",
|
|
246
|
-
children: /* @__PURE__ */
|
|
248
|
+
children: /* @__PURE__ */ h("p", {
|
|
247
249
|
className: "pkt-header-menu__error",
|
|
248
|
-
children:
|
|
250
|
+
children: U.menuLoadError
|
|
249
251
|
})
|
|
250
252
|
})
|
|
251
|
-
}), $ = X && Q &&
|
|
252
|
-
className: (0,
|
|
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__ */
|
|
256
|
+
children: /* @__PURE__ */ h("div", {
|
|
255
257
|
className: "pkt-header-global__search-panel-inner",
|
|
256
|
-
children: /* @__PURE__ */
|
|
258
|
+
children: /* @__PURE__ */ h(u, {
|
|
257
259
|
appearance: "global",
|
|
258
260
|
fullwidth: !0,
|
|
259
|
-
id:
|
|
260
|
-
name:
|
|
261
|
+
id: Ue,
|
|
262
|
+
name: W.input.name,
|
|
261
263
|
"aria-label": q,
|
|
262
|
-
placeholder:
|
|
263
|
-
action:
|
|
264
|
+
placeholder: Ve ?? W.input.placeholder,
|
|
265
|
+
action: W.endpoint,
|
|
264
266
|
method: "get",
|
|
265
|
-
onSearch:
|
|
267
|
+
onSearch: ge,
|
|
266
268
|
onChange: () => {},
|
|
267
269
|
autoFocus: !0
|
|
268
270
|
})
|
|
269
271
|
})
|
|
270
272
|
});
|
|
271
|
-
return
|
|
273
|
+
return Ae ? /* @__PURE__ */ g("div", {
|
|
272
274
|
className: "pkt-header-global-wrapper",
|
|
273
275
|
children: [
|
|
274
|
-
|
|
275
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
279
|
+
Ke
|
|
278
280
|
]
|
|
279
|
-
}) : /* @__PURE__ */
|
|
280
|
-
|
|
281
|
+
}) : /* @__PURE__ */ g(ue, { children: [
|
|
282
|
+
Ge,
|
|
281
283
|
$,
|
|
282
|
-
|
|
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 {
|
|
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 =
|
|
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,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
|
|
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
|
|
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
|
|
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 */
|