@oslokommune/punkt-react 20.2.1 → 20.2.3
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 +3 -3
- 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
|
@@ -1,197 +1,199 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../../shared-types/index.js";
|
|
3
3
|
import { DEFAULT_HEADER_FOOTER_URL as e } from "../../shared-types/header-footer.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
4
|
+
import { resolveOverride as t } from "../../shared-strings/resolve.js";
|
|
5
|
+
import { deriveSocialIcon as n, mapOdsIcon as r } from "../../shared-utils/header-footer/icon-map.js";
|
|
6
|
+
import { fetchHeaderFooterData as i } from "../../shared-utils/header-footer/fetch-header-footer-data.js";
|
|
7
|
+
import { selectLocaleData as a } from "../../shared-utils/header-footer/select-megamenu.js";
|
|
8
|
+
import { useElementWidth as o } from "../../hooks/useElementWidth.js";
|
|
9
|
+
import { usePktStrings as s } from "../../hooks/usePktStrings.js";
|
|
10
|
+
import { PktAccordion as c } from "../accordion/Accordion.js";
|
|
11
|
+
import { PktAccordionItem as l } from "../accordion/AccordionItem.js";
|
|
12
|
+
import { PktIcon as u } from "../icon/Icon.js";
|
|
13
|
+
import { PktStringsContext as d } from "../strings/PktStringsProvider.js";
|
|
14
|
+
import { useCallback as f, useContext as p, useEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
|
|
15
|
+
import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
|
|
14
16
|
// src/components/header-menu/HeaderMenu.tsx
|
|
15
|
-
var
|
|
16
|
-
let
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}, [
|
|
20
|
-
|
|
21
|
-
}, [
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
}, [
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}, [
|
|
28
|
-
if (
|
|
17
|
+
var x = ({ dataUrl: n = e, data: r, locale: c = "nb-NO", open: l = !1, mobileBreakpoint: u = 768, className: x, onDataLoaded: S, onDataError: D, ref: k, strings: A, ...j }) => {
|
|
18
|
+
let M = s(["header"], A).header, N = p(d), [P, F] = _("loading"), [I, L] = _(void 0), R = r ? "ready" : P, z = g(S), B = g(D);
|
|
19
|
+
m(() => {
|
|
20
|
+
z.current = S;
|
|
21
|
+
}, [S]), m(() => {
|
|
22
|
+
B.current = D;
|
|
23
|
+
}, [D]);
|
|
24
|
+
let V = g(null), H = f((e) => {
|
|
25
|
+
V.current = e, typeof k == "function" ? k(e) : k && (k.current = e);
|
|
26
|
+
}, [k]), U = o(V) < u;
|
|
27
|
+
m(() => {
|
|
28
|
+
r && z.current?.(r);
|
|
29
|
+
}, [r]), m(() => {
|
|
30
|
+
if (r) return;
|
|
29
31
|
let e = new AbortController();
|
|
30
|
-
return
|
|
31
|
-
e.signal.aborted || (
|
|
32
|
+
return i(n, e.signal).then((t) => {
|
|
33
|
+
e.signal.aborted || (L(t), F("ready"), z.current?.(t));
|
|
32
34
|
}).catch((e) => {
|
|
33
|
-
e.name !== "AbortError" && (
|
|
35
|
+
e.name !== "AbortError" && (F("error"), B.current?.(e));
|
|
34
36
|
}), () => e.abort();
|
|
35
|
-
}, [
|
|
36
|
-
let
|
|
37
|
+
}, [r, n]);
|
|
38
|
+
let W = r ?? I, G = h(() => a(W, c), [W, c]), K = [
|
|
37
39
|
"pkt-header-menu",
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
l && "pkt-header-menu--open",
|
|
41
|
+
x
|
|
40
42
|
].filter(Boolean).join(" ");
|
|
41
|
-
if (
|
|
42
|
-
...
|
|
43
|
-
ref:
|
|
44
|
-
className:
|
|
43
|
+
if (R === "loading") return /* @__PURE__ */ y("nav", {
|
|
44
|
+
...j,
|
|
45
|
+
ref: H,
|
|
46
|
+
className: K,
|
|
45
47
|
"aria-busy": "true",
|
|
46
|
-
children: /* @__PURE__ */
|
|
48
|
+
children: /* @__PURE__ */ y("p", {
|
|
47
49
|
className: "pkt-header-menu__loading",
|
|
48
|
-
children:
|
|
50
|
+
children: M.menuLoading
|
|
49
51
|
})
|
|
50
52
|
});
|
|
51
|
-
if (
|
|
52
|
-
...
|
|
53
|
-
ref:
|
|
54
|
-
className:
|
|
55
|
-
"aria-hidden": !
|
|
56
|
-
children: /* @__PURE__ */
|
|
53
|
+
if (R === "error" || !G) return /* @__PURE__ */ y("nav", {
|
|
54
|
+
...j,
|
|
55
|
+
ref: H,
|
|
56
|
+
className: K,
|
|
57
|
+
"aria-hidden": !l,
|
|
58
|
+
children: /* @__PURE__ */ y("p", {
|
|
57
59
|
className: "pkt-header-menu__error",
|
|
58
|
-
children:
|
|
60
|
+
children: M.menuLoadError
|
|
59
61
|
})
|
|
60
62
|
});
|
|
61
|
-
let { megamenu:
|
|
62
|
-
return /* @__PURE__ */
|
|
63
|
-
...
|
|
64
|
-
ref:
|
|
65
|
-
className:
|
|
66
|
-
"aria-label":
|
|
63
|
+
let { megamenu: q, i18n: J } = G, Y = t("header", "navAriaLabel", N, A) ?? (J?.navAriaLabel || M.navAriaLabel);
|
|
64
|
+
return /* @__PURE__ */ b("nav", {
|
|
65
|
+
...j,
|
|
66
|
+
ref: H,
|
|
67
|
+
className: K,
|
|
68
|
+
"aria-label": Y,
|
|
67
69
|
children: [
|
|
68
|
-
|
|
69
|
-
services:
|
|
70
|
-
sections:
|
|
71
|
-
}) : /* @__PURE__ */
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
buttons:
|
|
70
|
+
U ? /* @__PURE__ */ y(C, {
|
|
71
|
+
services: q.services,
|
|
72
|
+
sections: q.sections
|
|
73
|
+
}) : /* @__PURE__ */ b(v, { children: [
|
|
74
|
+
/* @__PURE__ */ y(w, { services: q.services }),
|
|
75
|
+
/* @__PURE__ */ y(T, {
|
|
76
|
+
buttons: q.buttons,
|
|
75
77
|
mobile: !1
|
|
76
78
|
}),
|
|
77
|
-
/* @__PURE__ */
|
|
79
|
+
/* @__PURE__ */ y(E, { sections: q.sections })
|
|
78
80
|
] }),
|
|
79
|
-
/* @__PURE__ */
|
|
80
|
-
buttons:
|
|
81
|
+
/* @__PURE__ */ y(T, {
|
|
82
|
+
buttons: q.buttons,
|
|
81
83
|
mobile: !0
|
|
82
84
|
}),
|
|
83
|
-
/* @__PURE__ */
|
|
84
|
-
links:
|
|
85
|
-
some:
|
|
85
|
+
/* @__PURE__ */ y(O, {
|
|
86
|
+
links: q.links,
|
|
87
|
+
some: q.some
|
|
86
88
|
})
|
|
87
89
|
]
|
|
88
90
|
});
|
|
89
|
-
},
|
|
91
|
+
}, S = ({ services: e }) => /* @__PURE__ */ y("ul", {
|
|
90
92
|
className: "pkt-header-menu__services-list",
|
|
91
|
-
children: e.links.map((e) => /* @__PURE__ */
|
|
93
|
+
children: e.links.map((e) => /* @__PURE__ */ y("li", {
|
|
92
94
|
className: "pkt-header-menu__service",
|
|
93
|
-
children: /* @__PURE__ */
|
|
95
|
+
children: /* @__PURE__ */ b("a", {
|
|
94
96
|
className: "pkt-header-menu__service-link",
|
|
95
97
|
href: e.url,
|
|
96
|
-
children: [/* @__PURE__ */
|
|
98
|
+
children: [/* @__PURE__ */ y(u, {
|
|
97
99
|
className: "pkt-header-menu__service-icon",
|
|
98
|
-
name:
|
|
100
|
+
name: r(e.icon),
|
|
99
101
|
"aria-hidden": "true"
|
|
100
|
-
}), /* @__PURE__ */
|
|
102
|
+
}), /* @__PURE__ */ y("span", {
|
|
101
103
|
className: "pkt-header-menu__service-text",
|
|
102
104
|
children: e.text
|
|
103
105
|
})]
|
|
104
106
|
})
|
|
105
107
|
}, e.url))
|
|
106
|
-
}),
|
|
108
|
+
}), C = ({ services: e, sections: t }) => /* @__PURE__ */ y("div", {
|
|
107
109
|
className: "pkt-header-menu__sections",
|
|
108
|
-
children: /* @__PURE__ */
|
|
110
|
+
children: /* @__PURE__ */ b(c, {
|
|
109
111
|
className: "pkt-header-menu__sections-inner",
|
|
110
112
|
skin: "plus-minus",
|
|
111
113
|
name: "header-menu-accordion",
|
|
112
|
-
children: [/* @__PURE__ */
|
|
114
|
+
children: [/* @__PURE__ */ y(l, {
|
|
113
115
|
className: "pkt-header-menu__section",
|
|
114
116
|
skin: "plus-minus",
|
|
115
117
|
id: "pkt-header-menu-services",
|
|
116
118
|
title: e.title,
|
|
117
|
-
children: /* @__PURE__ */
|
|
118
|
-
}), t.map((e, t) => /* @__PURE__ */
|
|
119
|
+
children: /* @__PURE__ */ y(S, { services: e })
|
|
120
|
+
}), t.map((e, t) => /* @__PURE__ */ y(l, {
|
|
119
121
|
className: "pkt-header-menu__section",
|
|
120
122
|
skin: "plus-minus",
|
|
121
123
|
id: `pkt-header-menu-section-${t}`,
|
|
122
124
|
title: e.title,
|
|
123
|
-
children: /* @__PURE__ */
|
|
125
|
+
children: /* @__PURE__ */ y(D, { links: e.links })
|
|
124
126
|
}, e.title))]
|
|
125
127
|
})
|
|
126
|
-
}),
|
|
128
|
+
}), w = ({ services: e }) => /* @__PURE__ */ b("div", {
|
|
127
129
|
className: "pkt-header-menu__services",
|
|
128
|
-
children: [/* @__PURE__ */
|
|
130
|
+
children: [/* @__PURE__ */ y("h2", {
|
|
129
131
|
className: "pkt-header-menu__services-title",
|
|
130
132
|
children: e.title
|
|
131
|
-
}), /* @__PURE__ */
|
|
132
|
-
}),
|
|
133
|
+
}), /* @__PURE__ */ y(S, { services: e })]
|
|
134
|
+
}), T = ({ buttons: e, mobile: t }) => {
|
|
133
135
|
if (!e || e.length === 0) return null;
|
|
134
|
-
let
|
|
135
|
-
return /* @__PURE__ */
|
|
136
|
-
className:
|
|
137
|
-
children: e.map((e) => /* @__PURE__ */
|
|
136
|
+
let n = ["pkt-header-menu__buttons", t && "pkt-header-menu__buttons--mobile"].filter(Boolean).join(" ");
|
|
137
|
+
return /* @__PURE__ */ y("div", {
|
|
138
|
+
className: n,
|
|
139
|
+
children: e.map((e) => /* @__PURE__ */ b("a", {
|
|
138
140
|
className: "pkt-btn pkt-btn--secondary pkt-btn--icon-right pkt-btn--small",
|
|
139
141
|
href: e.url,
|
|
140
|
-
children: [/* @__PURE__ */
|
|
142
|
+
children: [/* @__PURE__ */ y(u, {
|
|
141
143
|
className: "pkt-btn__icon",
|
|
142
|
-
name: e.iconName ?
|
|
144
|
+
name: e.iconName ? r(e.iconName) : "user",
|
|
143
145
|
"aria-hidden": "true"
|
|
144
|
-
}), /* @__PURE__ */
|
|
146
|
+
}), /* @__PURE__ */ y("span", {
|
|
145
147
|
className: "pkt-btn__text",
|
|
146
148
|
children: e.text
|
|
147
149
|
})]
|
|
148
150
|
}, e.url))
|
|
149
151
|
});
|
|
150
|
-
},
|
|
152
|
+
}, E = ({ sections: e }) => !e || e.length === 0 ? null : /* @__PURE__ */ y("div", {
|
|
151
153
|
className: "pkt-header-menu__sections",
|
|
152
|
-
children: /* @__PURE__ */
|
|
154
|
+
children: /* @__PURE__ */ y("div", {
|
|
153
155
|
className: "pkt-header-menu__sections-inner",
|
|
154
|
-
children: e.map((e) => /* @__PURE__ */
|
|
156
|
+
children: e.map((e) => /* @__PURE__ */ b("div", {
|
|
155
157
|
className: "pkt-header-menu__section",
|
|
156
|
-
children: [/* @__PURE__ */
|
|
158
|
+
children: [/* @__PURE__ */ y("h2", {
|
|
157
159
|
className: "pkt-header-menu__section-title",
|
|
158
160
|
children: e.title
|
|
159
|
-
}), /* @__PURE__ */
|
|
161
|
+
}), /* @__PURE__ */ y(D, { links: e.links })]
|
|
160
162
|
}, e.title))
|
|
161
163
|
})
|
|
162
|
-
}),
|
|
164
|
+
}), D = ({ links: e }) => /* @__PURE__ */ y("ul", {
|
|
163
165
|
className: "pkt-header-menu__section-list",
|
|
164
|
-
children: e.map((e) => /* @__PURE__ */
|
|
166
|
+
children: e.map((e) => /* @__PURE__ */ y("li", { children: /* @__PURE__ */ y("a", {
|
|
165
167
|
className: "pkt-header-menu__section-link",
|
|
166
168
|
href: e.url,
|
|
167
169
|
children: e.text
|
|
168
170
|
}) }, e.url))
|
|
169
|
-
}),
|
|
171
|
+
}), O = ({ links: e, some: t }) => {
|
|
170
172
|
let n = e && e.length > 0, r = t && t.length > 0;
|
|
171
|
-
return !n && !r ? null : /* @__PURE__ */
|
|
173
|
+
return !n && !r ? null : /* @__PURE__ */ b("div", {
|
|
172
174
|
className: "pkt-header-menu__footer",
|
|
173
|
-
children: [n && /* @__PURE__ */
|
|
175
|
+
children: [n && /* @__PURE__ */ y("ul", {
|
|
174
176
|
className: "pkt-header-menu__footer-list",
|
|
175
|
-
children: e.map((e) => /* @__PURE__ */
|
|
177
|
+
children: e.map((e) => /* @__PURE__ */ y("li", { children: /* @__PURE__ */ y("a", {
|
|
176
178
|
className: "pkt-header-menu__footer-link",
|
|
177
179
|
href: e.url,
|
|
178
180
|
children: e.text
|
|
179
181
|
}) }, e.url))
|
|
180
|
-
}), r && /* @__PURE__ */
|
|
182
|
+
}), r && /* @__PURE__ */ y("ul", {
|
|
181
183
|
className: "pkt-header-menu__footer-list pkt-header-menu__footer-list--social",
|
|
182
|
-
children: t.map((e) => /* @__PURE__ */
|
|
184
|
+
children: t.map((e) => /* @__PURE__ */ y(k, { entry: e }, e.url))
|
|
183
185
|
})]
|
|
184
186
|
});
|
|
185
|
-
},
|
|
186
|
-
let
|
|
187
|
-
return /* @__PURE__ */
|
|
187
|
+
}, k = ({ entry: e }) => {
|
|
188
|
+
let t = n(e.url, e.text);
|
|
189
|
+
return /* @__PURE__ */ y("li", { children: /* @__PURE__ */ y("a", {
|
|
188
190
|
className: "pkt-header-menu__social-link",
|
|
189
191
|
href: e.url,
|
|
190
192
|
"aria-label": e.text,
|
|
191
|
-
children:
|
|
192
|
-
name:
|
|
193
|
+
children: t ? /* @__PURE__ */ y(u, {
|
|
194
|
+
name: t,
|
|
193
195
|
"aria-hidden": "true"
|
|
194
|
-
}) : /* @__PURE__ */
|
|
196
|
+
}) : /* @__PURE__ */ y("span", { children: e.text })
|
|
195
197
|
}) });
|
|
196
198
|
};
|
|
197
|
-
export {
|
|
199
|
+
export { x as PktHeaderMenu };
|
|
@@ -12,7 +12,7 @@ export type { IPktDatepicker } from './datepicker/Datepicker';
|
|
|
12
12
|
export type { IPktFileUpload } from './fileupload/FileUpload';
|
|
13
13
|
export type { IPktFooter } from './footer/Footer';
|
|
14
14
|
export type { IPktFooterSimple } from './footerSimple/FooterSimple';
|
|
15
|
-
export type { IPktHeader } from './header/Header';
|
|
15
|
+
export type { IPktHeader, IPktHeaderGlobal, IPktHeaderProps } from './header/Header';
|
|
16
16
|
export type { IPktHeaderMenu } from './header-menu/HeaderMenu';
|
|
17
17
|
export type { IPktHeaderService } from './header/HeaderService';
|
|
18
18
|
export type { IPktInputWrapper } from './inputwrapper/InputWrapper';
|