@oslokommune/punkt-elements 16.26.7 → 17.0.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 +110 -0
- package/dist/accordion-CbXDxOho.cjs +47 -0
- package/dist/{accordion-CBdIk9gw.js → accordion-DEUHQ4JD.js} +45 -35
- package/dist/{alert-HHTGY0sp.js → alert-CbtVGrHD.js} +31 -17
- package/dist/{alert-B8dLsiTz.cjs → alert-CkUnbPdA.cjs} +5 -5
- package/dist/base-elements/input-element.d.ts +1 -0
- package/dist/button-Cod17rKo.js +115 -0
- package/dist/{button-B5tQpKeG.cjs → button-gvDXtBMC.cjs} +5 -2
- package/dist/{calendar-DIzGBdbh.cjs → calendar-BVXW8DqC.cjs} +1 -1
- package/dist/{calendar-CjlUA-Lb.js → calendar-CjC4qlh6.js} +1 -1
- package/dist/{checkbox-Bt_sC_90.cjs → checkbox-8uxbeU30.cjs} +1 -1
- package/dist/{checkbox-D03BC2Va.js → checkbox-DJDphhqz.js} +1 -1
- package/dist/{combobox-CoQBTWqL.js → combobox-Du5yr-xM.js} +16 -2
- package/dist/combobox-hKrbYLUe.cjs +136 -0
- package/dist/components/accordion/accordion-context.d.ts +7 -0
- package/dist/components/accordion/accordion.d.ts +2 -0
- package/dist/components/accordion/accordionitem.d.ts +1 -0
- package/dist/components/alert/alert.d.ts +5 -0
- package/dist/components/alert/alert.test.d.ts +1 -0
- package/dist/components/button/button.d.ts +4 -1
- package/dist/components/datepicker/datepicker-base.d.ts +2 -0
- package/dist/components/datepicker/datepicker-utils.d.ts +2 -2
- package/dist/components/footer/footer-base.d.ts +44 -0
- package/dist/components/footer/footer-simple.d.ts +20 -0
- package/dist/components/footer/footer.accessibility.test.d.ts +0 -0
- package/dist/components/footer/footer.d.ts +22 -0
- package/dist/components/footer/footer.test.d.ts +0 -0
- package/dist/components/footer/index.d.ts +3 -0
- package/dist/components/footer/types.d.ts +16 -0
- package/dist/components/header/header-chrome-controller.d.ts +44 -0
- package/dist/components/header/header-global.accessibility.test.d.ts +0 -0
- package/dist/components/header/header-global.d.ts +78 -0
- package/dist/components/header/header-global.test.d.ts +0 -0
- package/dist/components/header/header-service.accessibility.test.d.ts +0 -0
- package/dist/components/header/header-service.d.ts +6 -21
- package/dist/components/header/header-service.test.d.ts +1 -1
- package/dist/components/header/header.d.ts +11 -3
- package/dist/components/header/header.test.d.ts +0 -0
- package/dist/components/header/index.d.ts +2 -1
- package/dist/components/header/types.d.ts +28 -2
- package/dist/components/header-menu/header-menu.d.ts +4 -5
- package/dist/components/header-menu/types.d.ts +1 -1
- package/dist/components/index.d.ts +5 -3
- package/dist/components/input-wrapper/input-wrapper.d.ts +2 -0
- package/dist/components/input-wrapper/input-wrapper.test.d.ts +1 -0
- package/dist/components/searchinput/searchinput.d.ts +5 -0
- package/dist/components/select/index.d.ts +1 -1
- package/dist/components/select/select.d.ts +2 -2
- package/dist/components/select/select.test.d.ts +1 -0
- package/dist/components/textarea/textarea.test.d.ts +2 -0
- package/dist/components/textinput/textinput.test.d.ts +1 -0
- package/dist/components/timepicker/timepicker.d.ts +2 -0
- package/dist/components/timepicker/timepicker.test.d.ts +3 -0
- package/dist/consent--Nw43WFU.cjs +18 -0
- package/dist/{consent-D5sY6JK3.js → consent-B2hSTCGC.js} +14 -7
- package/dist/consume-BiOhrhEy.js +167 -0
- package/dist/consume-DKf5SmP9.cjs +1 -0
- package/dist/{converters-BKGBRBpS.js → converters-BBfsEJV5.js} +25 -25
- package/dist/{converters-9jHlXDyy.cjs → converters-Cd0fPEly.cjs} +1 -1
- package/dist/{datepicker-BE5Ll0W4.js → datepicker--Fq8q-J3.js} +30 -12
- package/dist/{datepicker-x4xM3KQz.cjs → datepicker-CEoBYTBU.cjs} +11 -7
- package/dist/docs/components/alert.d.ts +3 -0
- package/dist/docs/components/footer.d.ts +9 -0
- package/dist/docs/components/form-sizes.d.ts +10 -0
- package/dist/docs/components/header-global-full.d.ts +20 -0
- package/dist/docs/components/header-global.d.ts +14 -0
- package/dist/docs/components/searchinput.d.ts +6 -3
- package/dist/fetch-header-footer-data-Pc32etrk.js +88 -0
- package/dist/fetch-header-footer-data-xohWFmYC.cjs +1 -0
- package/dist/fileupload-CGKUJrlj.cjs +401 -0
- package/dist/{fileupload-2hf8YNhO.js → fileupload-D4gQN64T.js} +156 -176
- package/dist/focus-trap-DG3pEuyJ.js +60 -0
- package/dist/focus-trap-DSv4Ifqm.cjs +1 -0
- package/dist/footer-BIrJeRuZ.js +303 -0
- package/dist/footer-Ber-jqM1.cjs +114 -0
- package/dist/footer.d.ts +1 -0
- package/dist/header-BFk1an4z.cjs +465 -0
- package/dist/header-Deg_LGJo.js +1287 -0
- package/dist/header-menu-BHqK4QA6.cjs +126 -0
- package/dist/{header-menu-C8b5vd3n.js → header-menu-GFtJKM4j.js} +25 -97
- package/dist/{helptext-OfqH5npD.js → helptext-C_brWCIT.js} +1 -1
- package/dist/{helptext-eckq4JEX.cjs → helptext-Cq5rNaAC.cjs} +1 -1
- package/dist/{input-element-ZGOWsvKM.cjs → input-element-B0qLbEdF.cjs} +1 -1
- package/dist/{input-element-BFHpeoV8.js → input-element-C0RnXi-J.js} +5 -2
- package/dist/{input-wrapper-DwwE0JcO.js → input-wrapper-BweP6t3O.js} +12 -0
- package/dist/{input-wrapper-BRjQB4zM.cjs → input-wrapper-DPkkiG7S.cjs} +13 -11
- package/dist/{input-wrapper-DaA98B5l.js → input-wrapper-fWV5P4MN.js} +22 -15
- package/dist/{input-wrapper-LcZjpt0L.cjs → input-wrapper-wh3fWIhk.cjs} +1 -1
- package/dist/modal-CPnFteYS.cjs +35 -0
- package/dist/{modal-C6pScpdG.js → modal-xNK_wpHk.js} +11 -20
- package/dist/pkt-accordion.cjs +1 -1
- package/dist/pkt-accordion.js +1 -1
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +1 -1
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +1 -1
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +1 -1
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-consent.cjs +1 -1
- package/dist/pkt-consent.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-fileupload.cjs +1 -1
- package/dist/pkt-fileupload.js +1 -1
- package/dist/pkt-footer.cjs +1 -0
- package/dist/pkt-footer.js +2 -0
- package/dist/pkt-header-menu.cjs +1 -1
- package/dist/pkt-header-menu.js +1 -1
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +2 -2
- package/dist/pkt-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +27 -26
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +1 -1
- package/dist/pkt-searchinput.cjs +1 -1
- package/dist/pkt-searchinput.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/pkt-tabs.cjs +1 -1
- package/dist/pkt-tabs.js +1 -1
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +1 -1
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +1 -1
- package/dist/pkt-timepicker.cjs +1 -1
- package/dist/pkt-timepicker.js +1 -1
- package/dist/{radiobutton-DGO6H2Ki.js → radiobutton-C6htwDrT.js} +1 -1
- package/dist/{radiobutton-DY1WWepJ.cjs → radiobutton-DjWBoSHv.cjs} +1 -1
- package/dist/scroll-lock-BN8lOhV5.cjs +1 -0
- package/dist/scroll-lock-DAbNKAUy.js +18 -0
- package/dist/searchinput-CfUVfpqL.js +156 -0
- package/dist/searchinput-DGjeN1YI.cjs +60 -0
- package/dist/{select-D4_HQFkh.cjs → select-CZvAW7W2.cjs} +2 -1
- package/dist/{select-BwHUIlwQ.js → select-CsBXXbLP.js} +4 -3
- package/dist/setupTests.d.ts +0 -0
- package/dist/shared-types/footer.d.ts +95 -0
- package/dist/shared-types/{header-menu.d.ts → header-footer.d.ts} +51 -4
- package/dist/shared-types/header.d.ts +1 -1
- package/dist/shared-types/index.d.ts +6 -4
- package/dist/shared-types/searchinput.d.ts +2 -0
- package/dist/shared-types/select.d.ts +3 -2
- package/dist/shared-types/size.d.ts +4 -0
- package/dist/shared-types/timepicker.d.ts +0 -6
- package/dist/shared-utils/datepicker-utils.d.ts +5 -4
- package/dist/shared-utils/fileupload/focus-trap.d.ts +4 -10
- package/dist/shared-utils/focus-trap/index.d.ts +22 -0
- package/dist/shared-utils/{header-menu → header-footer}/example-data.d.ts +5 -4
- package/dist/shared-utils/header-footer/external-domain.d.ts +26 -0
- package/dist/shared-utils/{header-menu → header-footer}/fetch-header-footer-data.d.ts +6 -2
- package/dist/shared-utils/{header-menu → header-footer}/index.d.ts +2 -1
- package/dist/shared-utils/{header-menu → header-footer}/select-megamenu.d.ts +1 -1
- package/dist/shared-utils/scroll-lock/index.d.ts +24 -0
- package/dist/tabs-BqrKLCjd.js +214 -0
- package/dist/tabs-q62MK_-r.cjs +40 -0
- package/dist/{textarea-D6M7ZhtA.js → textarea-Cm392CEI.js} +5 -3
- package/dist/{textarea-Bt_Zs8gq.cjs → textarea-sTcZxOIB.cjs} +3 -2
- package/dist/{textinput-EDKjcUdg.cjs → textinput-DqJbTglM.cjs} +3 -2
- package/dist/{textinput-oU2EvFsi.js → textinput-TSPcBcih.js} +5 -3
- package/dist/{timepicker-CgOL2sd9.cjs → timepicker-CqFYMV8q.cjs} +8 -7
- package/dist/{timepicker-_G0V_HV3.js → timepicker-DWbgTDKq.js} +10 -9
- package/package.json +3 -3
- package/src/components/accordion/accordion-context.ts +8 -0
- package/src/components/accordion/accordion.test.ts +44 -0
- package/src/components/accordion/accordion.ts +13 -3
- package/src/components/accordion/accordionitem.ts +9 -1
- package/src/components/alert/alert.test.ts +51 -2
- package/src/components/alert/alert.ts +11 -5
- package/src/components/breadcrumbs/breadcrumbs.test.ts +11 -3
- package/src/components/button/button.test.ts +23 -0
- package/src/components/button/button.ts +28 -3
- package/src/components/combobox/combobox.core.test.ts +20 -0
- package/src/components/combobox/combobox.ts +2 -0
- package/src/components/consent/consent.test.ts +6 -3
- package/src/components/consent/consent.ts +15 -7
- package/src/components/datepicker/datepicker-base.ts +5 -1
- package/src/components/datepicker/datepicker-utils.test.ts +10 -0
- package/src/components/datepicker/datepicker.core.test.ts +17 -0
- package/src/components/datepicker/datepicker.ts +8 -0
- package/src/components/footer/footer-base.ts +238 -0
- package/src/components/footer/footer-simple.ts +71 -0
- package/src/components/footer/footer.accessibility.test.ts +66 -0
- package/src/components/footer/footer.test.ts +238 -0
- package/src/components/footer/footer.ts +81 -0
- package/src/components/footer/index.ts +4 -0
- package/src/components/footer/types.ts +21 -0
- package/src/components/header/header-chrome-controller.ts +123 -0
- package/src/components/header/header-global.accessibility.test.ts +110 -0
- package/src/components/header/header-global.test.ts +329 -0
- package/src/components/header/header-global.ts +648 -0
- package/src/components/header/header-service.accessibility.test.ts +79 -0
- package/src/components/header/header-service.test.ts +32 -12
- package/src/components/header/header-service.ts +38 -162
- package/src/components/header/header-user-menu.ts +0 -1
- package/src/components/header/header.test.ts +84 -0
- package/src/components/header/header.ts +52 -5
- package/src/components/header/index.ts +6 -0
- package/src/components/header/types.ts +38 -0
- package/src/components/header-menu/header-menu.test.ts +131 -10
- package/src/components/header-menu/header-menu.ts +23 -24
- package/src/components/header-menu/types.ts +1 -1
- package/src/components/index.ts +18 -2
- package/src/components/input-wrapper/input-wrapper.test.ts +45 -0
- package/src/components/input-wrapper/input-wrapper.ts +17 -9
- package/src/components/modal/modal.ts +8 -9
- package/src/components/searchinput/searchinput.test.ts +43 -0
- package/src/components/searchinput/searchinput.ts +29 -12
- package/src/components/select/index.ts +1 -1
- package/src/components/select/select.test.ts +28 -0
- package/src/components/select/select.ts +4 -3
- package/src/components/textarea/textarea.test.ts +16 -0
- package/src/components/textarea/textarea.ts +3 -1
- package/src/components/textinput/textinput.test.ts +28 -0
- package/src/components/textinput/textinput.ts +3 -1
- package/src/components/timepicker/timepicker.test.ts +26 -0
- package/src/components/timepicker/timepicker.ts +12 -6
- package/dist/accordion-FISAiAbX.cjs +0 -47
- package/dist/button-C_YzTSuU.js +0 -96
- package/dist/combobox-D6H9rWPV.cjs +0 -135
- package/dist/consent-X3wvhteO.cjs +0 -10
- package/dist/fileupload-BLVrslUX.cjs +0 -401
- package/dist/header-CFrsaq0c.cjs +0 -310
- package/dist/header-D_xvPR4R.js +0 -801
- package/dist/header-menu-DMdP_c6X.cjs +0 -126
- package/dist/modal-DKU7PnjJ.cjs +0 -35
- package/dist/searchinput-CyO5k4Q4.js +0 -148
- package/dist/searchinput-DG6YetL1.cjs +0 -60
- package/dist/shared-utils/modal-scroll-lock.d.ts +0 -10
- package/dist/tabs-CGo0ODPa.cjs +0 -40
- package/dist/tabs-ChdR0D1C.js +0 -379
- /package/dist/shared-utils/{header-menu → header-footer}/icon-map.d.ts +0 -0
|
@@ -0,0 +1,1287 @@
|
|
|
1
|
+
import { a as e, d as t, n, o as r, p as i, s as a, t as o } from "./element-BoJrqauR.js";
|
|
2
|
+
import { t as s } from "./class-map-CAQCRB1W.js";
|
|
3
|
+
import { n as c, t as l } from "./element-with-slot-mXLg8gg8.js";
|
|
4
|
+
import "./icon-DGFEIlco.js";
|
|
5
|
+
import { t as u } from "./if-defined-D0bnetLJ.js";
|
|
6
|
+
import "./button-Cod17rKo.js";
|
|
7
|
+
import { n as d, t as f } from "./ref-WGS0u7i2.js";
|
|
8
|
+
import { t as p } from "./booleanish-MfutDT_4.js";
|
|
9
|
+
import { n as m, o as h, t as g } from "./fetch-header-footer-data-Pc32etrk.js";
|
|
10
|
+
import { n as _, t as v } from "./focus-trap-DG3pEuyJ.js";
|
|
11
|
+
import { n as y, t as b } from "./scroll-lock-DAbNKAUy.js";
|
|
12
|
+
import "./link-FmkQvSQL.js";
|
|
13
|
+
import "./textinput-TSPcBcih.js";
|
|
14
|
+
import "./searchinput-CfUVfpqL.js";
|
|
15
|
+
import "./header-menu-GFtJKM4j.js";
|
|
16
|
+
//#region ../../shared-types/header.ts
|
|
17
|
+
var x = (e) => typeof e.target == "string" ? {
|
|
18
|
+
title: e.title,
|
|
19
|
+
iconName: e.iconName,
|
|
20
|
+
href: e.target
|
|
21
|
+
} : {
|
|
22
|
+
title: e.title,
|
|
23
|
+
iconName: e.iconName,
|
|
24
|
+
onClick: e.target
|
|
25
|
+
}, S = (e) => x(e), C = (e) => {
|
|
26
|
+
if (!e) return;
|
|
27
|
+
let t = typeof e == "string" ? new Date(e) : e;
|
|
28
|
+
if (!isNaN(t.getTime())) return t.toLocaleDateString("nb-NO", {
|
|
29
|
+
day: "numeric",
|
|
30
|
+
month: "long",
|
|
31
|
+
year: "numeric",
|
|
32
|
+
hour: "2-digit",
|
|
33
|
+
minute: "2-digit"
|
|
34
|
+
});
|
|
35
|
+
}, w = class {
|
|
36
|
+
constructor(e, t) {
|
|
37
|
+
this.isMobile = !1, this.isTablet = !1, this.isHidden = !1, this.pauseScrollHide = !1, this.componentWidth = typeof window < "u" ? window.innerWidth : 0, this.lastScrollPosition = 0, this.scrollLockToken = b(), this.lastFocusedElement = null, this.shouldRestoreFocus = !1, this.handleScroll = () => {
|
|
38
|
+
if (this.getOptions().scrollBehavior !== "hide" || this.pauseScrollHide) return;
|
|
39
|
+
let e = window.pageYOffset || document.documentElement.scrollTop;
|
|
40
|
+
if (e < 0 || Math.abs(e - this.lastScrollPosition) < 60) return;
|
|
41
|
+
let t = e > this.lastScrollPosition;
|
|
42
|
+
this.lastScrollPosition = e, t !== this.isHidden && (this.isHidden = t, this.host.requestUpdate());
|
|
43
|
+
}, this.host = e, this.getOptions = t, e.addController(this);
|
|
44
|
+
}
|
|
45
|
+
hostConnected() {
|
|
46
|
+
window.addEventListener("scroll", this.handleScroll);
|
|
47
|
+
}
|
|
48
|
+
hostDisconnected() {
|
|
49
|
+
this.resizeObserver?.disconnect(), window.removeEventListener("scroll", this.handleScroll), y(this.scrollLockToken, !1);
|
|
50
|
+
}
|
|
51
|
+
observe(e) {
|
|
52
|
+
e && (this.componentWidth = e.offsetWidth, this.refreshBreakpoints(), this.resizeObserver = new ResizeObserver((e) => {
|
|
53
|
+
for (let t of e) this.componentWidth = t.borderBoxSize && t.borderBoxSize.length > 0 ? t.borderBoxSize[0].inlineSize : t.contentRect.width, this.refreshBreakpoints();
|
|
54
|
+
}), this.resizeObserver.observe(e));
|
|
55
|
+
}
|
|
56
|
+
refreshBreakpoints() {
|
|
57
|
+
let { mobileBreakpoint: e, tabletBreakpoint: t } = this.getOptions(), n = this.componentWidth < e, r = this.componentWidth < t;
|
|
58
|
+
(n !== this.isMobile || r !== this.isTablet) && (this.isMobile = n, this.isTablet = r, this.host.requestUpdate());
|
|
59
|
+
}
|
|
60
|
+
setScrollLock(e) {
|
|
61
|
+
y(this.scrollLockToken, e);
|
|
62
|
+
}
|
|
63
|
+
captureFocus() {
|
|
64
|
+
this.lastFocusedElement = document.activeElement;
|
|
65
|
+
}
|
|
66
|
+
flagRestoreFocus() {
|
|
67
|
+
this.shouldRestoreFocus = !0;
|
|
68
|
+
}
|
|
69
|
+
restoreFocus() {
|
|
70
|
+
this.shouldRestoreFocus && this.lastFocusedElement && document.contains(this.lastFocusedElement) && this.lastFocusedElement.focus(), this.lastFocusedElement = null, this.shouldRestoreFocus = !1;
|
|
71
|
+
}
|
|
72
|
+
}, T = class extends o {
|
|
73
|
+
constructor(...e) {
|
|
74
|
+
super(...e), this.canChangeRepresentation = !1, this.logoutOnClick = !1;
|
|
75
|
+
}
|
|
76
|
+
handleChangeRepresentation() {
|
|
77
|
+
this.dispatchEvent(new CustomEvent("change-representation", {
|
|
78
|
+
bubbles: !0,
|
|
79
|
+
composed: !0
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
handleLogout() {
|
|
83
|
+
this.dispatchEvent(new CustomEvent("log-out", {
|
|
84
|
+
bubbles: !0,
|
|
85
|
+
composed: !0
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
handleMenuItemClick(e) {
|
|
89
|
+
"onClick" in e && typeof e.onClick == "function" && e.onClick();
|
|
90
|
+
}
|
|
91
|
+
renderLinkOrButton(e, n) {
|
|
92
|
+
let r = "href" in e, a = s({
|
|
93
|
+
"pkt-user-menu__link": !0,
|
|
94
|
+
"pkt-link-button": !r,
|
|
95
|
+
"pkt-link": !r,
|
|
96
|
+
"pkt-link--icon-left": !r,
|
|
97
|
+
[n || ""]: !!n
|
|
98
|
+
});
|
|
99
|
+
return r ? i`
|
|
100
|
+
<pkt-link
|
|
101
|
+
icon-name=${e.iconName || t}
|
|
102
|
+
href=${e.href}
|
|
103
|
+
class="pkt-user-menu__link ${n || ""}"
|
|
104
|
+
>
|
|
105
|
+
${e.title}
|
|
106
|
+
</pkt-link>
|
|
107
|
+
` : i`
|
|
108
|
+
<button class=${a} type="button" @click=${() => this.handleMenuItemClick(e)}>
|
|
109
|
+
${e.iconName ? i`<pkt-icon
|
|
110
|
+
name=${e.iconName}
|
|
111
|
+
class="pkt-link__icon"
|
|
112
|
+
aria-hidden="true"
|
|
113
|
+
></pkt-icon>` : t}
|
|
114
|
+
${e.title}
|
|
115
|
+
</button>
|
|
116
|
+
`;
|
|
117
|
+
}
|
|
118
|
+
renderLinkSection(e) {
|
|
119
|
+
return i`
|
|
120
|
+
<ul class="pkt-user-menu__sublist">
|
|
121
|
+
${e.map((e) => i`
|
|
122
|
+
<li class="pkt-user-menu__subitem">${this.renderLinkOrButton(e)}</li>
|
|
123
|
+
`)}
|
|
124
|
+
</ul>
|
|
125
|
+
`;
|
|
126
|
+
}
|
|
127
|
+
render() {
|
|
128
|
+
let e = this.userMenu?.map(S);
|
|
129
|
+
return i`
|
|
130
|
+
<nav class="pkt-user-menu" aria-label="Meny for innlogget bruker">
|
|
131
|
+
<ul class="pkt-user-menu__list">
|
|
132
|
+
<!-- User section -->
|
|
133
|
+
${this.user ? i`
|
|
134
|
+
<li class="pkt-user-menu__item">
|
|
135
|
+
<div class="pkt-user-menu__label">Pålogget som</div>
|
|
136
|
+
<div class="pkt-user-menu__name" translate="no">${this.user.name}</div>
|
|
137
|
+
${this.formattedLastLoggedIn ? i`
|
|
138
|
+
<div class="pkt-user-menu__last-logged-in">
|
|
139
|
+
Sist pålogget: <time>${this.formattedLastLoggedIn}</time>
|
|
140
|
+
</div>
|
|
141
|
+
` : t}
|
|
142
|
+
</li>
|
|
143
|
+
` : t}
|
|
144
|
+
|
|
145
|
+
<!-- User menu items -->
|
|
146
|
+
${e && e.length > 0 ? i`
|
|
147
|
+
<li class="pkt-user-menu__item">${this.renderLinkSection(e)}</li>
|
|
148
|
+
` : t}
|
|
149
|
+
|
|
150
|
+
<!-- Representing section -->
|
|
151
|
+
${this.representing ? i`
|
|
152
|
+
<li class="pkt-user-menu__item">
|
|
153
|
+
<div class="pkt-user-menu__label">Representerer</div>
|
|
154
|
+
<div class="pkt-user-menu__name" translate="no">${this.representing.name}</div>
|
|
155
|
+
${this.representing.orgNumber ? i`<div class="pkt-user-menu__org-number">
|
|
156
|
+
Org.nr. ${this.representing.orgNumber}
|
|
157
|
+
</div>` : t}
|
|
158
|
+
${this.canChangeRepresentation ? i`
|
|
159
|
+
<ul class="pkt-user-menu__sublist mt-size-16">
|
|
160
|
+
<li class="pkt-user-menu__subitem">
|
|
161
|
+
${this.renderLinkOrButton({
|
|
162
|
+
title: "Endre organisasjon",
|
|
163
|
+
iconName: "cogwheel",
|
|
164
|
+
onClick: () => this.handleChangeRepresentation()
|
|
165
|
+
})}
|
|
166
|
+
</li>
|
|
167
|
+
</ul>
|
|
168
|
+
` : t}
|
|
169
|
+
</li>
|
|
170
|
+
` : t}
|
|
171
|
+
|
|
172
|
+
<!-- Change representation without representing object -->
|
|
173
|
+
${!this.representing && this.canChangeRepresentation ? i`
|
|
174
|
+
<li class="pkt-user-menu__item">
|
|
175
|
+
<ul class="pkt-user-menu__sublist">
|
|
176
|
+
<li class="pkt-user-menu__subitem">
|
|
177
|
+
${this.renderLinkOrButton({
|
|
178
|
+
title: "Endre organisasjon",
|
|
179
|
+
iconName: "cogwheel",
|
|
180
|
+
onClick: () => this.handleChangeRepresentation()
|
|
181
|
+
})}
|
|
182
|
+
</li>
|
|
183
|
+
</ul>
|
|
184
|
+
</li>
|
|
185
|
+
` : t}
|
|
186
|
+
|
|
187
|
+
<!-- Logout -->
|
|
188
|
+
${this.logoutOnClick ? i`
|
|
189
|
+
<li class="pkt-user-menu__item">
|
|
190
|
+
${this.renderLinkOrButton({
|
|
191
|
+
title: "Logg ut",
|
|
192
|
+
iconName: "exit",
|
|
193
|
+
onClick: () => this.handleLogout()
|
|
194
|
+
})}
|
|
195
|
+
</li>
|
|
196
|
+
` : t}
|
|
197
|
+
</ul>
|
|
198
|
+
</nav>
|
|
199
|
+
`;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
n([r({ type: Object })], T.prototype, "user", void 0), n([r({
|
|
203
|
+
type: String,
|
|
204
|
+
attribute: "formatted-last-logged-in"
|
|
205
|
+
})], T.prototype, "formattedLastLoggedIn", void 0), n([r({ type: Object })], T.prototype, "representing", void 0), n([r({
|
|
206
|
+
type: Array,
|
|
207
|
+
attribute: "user-menu"
|
|
208
|
+
})], T.prototype, "userMenu", void 0), n([r({
|
|
209
|
+
type: Boolean,
|
|
210
|
+
attribute: "can-change-representation",
|
|
211
|
+
converter: p
|
|
212
|
+
})], T.prototype, "canChangeRepresentation", void 0), n([r({
|
|
213
|
+
type: Boolean,
|
|
214
|
+
attribute: "logout-on-click",
|
|
215
|
+
converter: p
|
|
216
|
+
})], T.prototype, "logoutOnClick", void 0);
|
|
217
|
+
try {
|
|
218
|
+
a("pkt-header-user-menu")(T);
|
|
219
|
+
} catch {
|
|
220
|
+
console.warn("Forsøker å definere <pkt-header-user-menu>, men den er allerede definert");
|
|
221
|
+
}
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region src/components/header/header-service.ts
|
|
224
|
+
var E = "https://punkt-cdn.oslo.kommune.no/latest/logos/";
|
|
225
|
+
typeof window < "u" && (window.pktLogoPath = window.pktLogoPath || E);
|
|
226
|
+
var D = class extends l {
|
|
227
|
+
constructor(...e) {
|
|
228
|
+
super(...e), this.logoLink = h, this.logoPath = typeof window < "u" ? window.pktLogoPath : E, this.searchPlaceholder = "Søk", this.searchValue = "", this.mobileBreakpoint = 768, this.tabletBreakpoint = 1280, this.openedMenu = "none", this.logOutButtonPlacement = "none", this.position = "fixed", this.scrollBehavior = "hide", this.slotMenuVariant = "icon-only", this.slotMenuText = "Meny", this.hideLogo = !1, this.compact = !1, this.showSearch = !1, this.canChangeRepresentation = !1, this.hasLogOut = !1, this.openMenu = "none", this.alignSlotRight = !1, this.alignSearchRight = !1, this.headerRef = f(), this.userContainerRef = f(), this.slotContainerRef = f(), this.searchContainerRef = f(), this.slotContentRef = f(), this.searchMenuRef = f(), this.chrome = new w(this, () => ({
|
|
229
|
+
mobileBreakpoint: this.mobileBreakpoint,
|
|
230
|
+
tabletBreakpoint: this.tabletBreakpoint,
|
|
231
|
+
position: this.position,
|
|
232
|
+
scrollBehavior: this.scrollBehavior
|
|
233
|
+
})), this.handleClickOutside = (e) => {
|
|
234
|
+
let t = e.target;
|
|
235
|
+
this.user && this.openMenu === "user" && !t.closest(".pkt-header-service__user-container") && (this.openMenu = "none"), this.openMenu === "slot" && !t.closest(".pkt-header-service__slot-container") && (this.openMenu = "none"), this.openMenu === "search" && !t.closest(".pkt-header-service__search-container") && !t.closest(".pkt-header-service__search-input") && (this.openMenu = "none");
|
|
236
|
+
}, this.handleSlotContentClick = (e) => {
|
|
237
|
+
if (!this.isTablet || this.openMenu !== "slot") return;
|
|
238
|
+
let t = e.target.closest("a[href], button, [role=\"link\"], [role=\"button\"], [role=\"menuitem\"], [role=\"menuitemradio\"], [role=\"menuitemcheckbox\"]");
|
|
239
|
+
!t || !this.slotContentRef.value?.contains(t) || t.closest("[data-pkt-header-keep-open]") || t.disabled || t.getAttribute("aria-disabled") === "true" || (this.openMenu = "none");
|
|
240
|
+
}, this.handleFocusOut = (e, t) => {
|
|
241
|
+
let n = e.relatedTarget, r;
|
|
242
|
+
switch (t) {
|
|
243
|
+
case "user":
|
|
244
|
+
r = this.userContainerRef;
|
|
245
|
+
break;
|
|
246
|
+
case "slot":
|
|
247
|
+
r = this.slotContainerRef;
|
|
248
|
+
break;
|
|
249
|
+
case "search":
|
|
250
|
+
r = this.searchContainerRef;
|
|
251
|
+
break;
|
|
252
|
+
default: return;
|
|
253
|
+
}
|
|
254
|
+
let i = r.value;
|
|
255
|
+
i && (!n || !i.contains(n)) && (this.openMenu = "none");
|
|
256
|
+
}, this.handleEscapeKey = (e) => {
|
|
257
|
+
e.key === "Escape" && this.openMenu !== "none" && (e.preventDefault(), this.chrome.flagRestoreFocus(), this.openMenu = "none");
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
get isMobile() {
|
|
261
|
+
return this.chrome.isMobile;
|
|
262
|
+
}
|
|
263
|
+
get isTablet() {
|
|
264
|
+
return this.chrome.isTablet;
|
|
265
|
+
}
|
|
266
|
+
get isHidden() {
|
|
267
|
+
return this.chrome.isHidden;
|
|
268
|
+
}
|
|
269
|
+
firstUpdated() {
|
|
270
|
+
this.chrome.observe(this.headerRef.value);
|
|
271
|
+
}
|
|
272
|
+
updated(e) {
|
|
273
|
+
if (super.updated(e), e.has("openedMenu") && this.openedMenu !== this.openMenu && (this.openMenu = this.openedMenu), (e.has("mobileBreakpoint") || e.has("tabletBreakpoint")) && this.chrome.refreshBreakpoints(), e.has("openMenu")) {
|
|
274
|
+
let t = e.get("openMenu");
|
|
275
|
+
this.openMenu !== "none" && (t === "none" || t === void 0) ? (document.addEventListener("mousedown", this.handleClickOutside), document.addEventListener("keydown", this.handleEscapeKey), (this.openMenu === "slot" || this.openMenu === "search") && requestAnimationFrame(() => {
|
|
276
|
+
this.checkDropdownAlignment(this.openMenu);
|
|
277
|
+
})) : this.openMenu === "none" && t !== "none" && (document.removeEventListener("mousedown", this.handleClickOutside), document.removeEventListener("keydown", this.handleEscapeKey), this.chrome.restoreFocus());
|
|
278
|
+
}
|
|
279
|
+
this.chrome.setScrollLock((this.isFixed || this.isSticky) && this.isMobile && this.openMenu !== "none");
|
|
280
|
+
}
|
|
281
|
+
checkDropdownAlignment(e) {
|
|
282
|
+
let t = e === "slot" ? this.slotContainerRef : this.searchContainerRef, n = e === "slot" ? this.slotContentRef : this.searchMenuRef;
|
|
283
|
+
if (!t.value || !n.value || !this.isTablet || this.isMobile) return;
|
|
284
|
+
let r = t.value.getBoundingClientRect(), i = n.value.offsetWidth, a = r.left + i > window.innerWidth;
|
|
285
|
+
e === "slot" ? this.alignSlotRight = a : this.alignSearchRight = a;
|
|
286
|
+
}
|
|
287
|
+
handleMenuToggle(e) {
|
|
288
|
+
this.openMenu === "none" ? (this.chrome.captureFocus(), this.openMenu = e) : this.openMenu = "none";
|
|
289
|
+
}
|
|
290
|
+
handleLogoClick(e) {
|
|
291
|
+
this.dispatchEvent(new CustomEvent("logo-click", {
|
|
292
|
+
bubbles: !0,
|
|
293
|
+
composed: !0,
|
|
294
|
+
detail: { originalEvent: e }
|
|
295
|
+
}));
|
|
296
|
+
}
|
|
297
|
+
handleServiceClick(e) {
|
|
298
|
+
this.dispatchEvent(new CustomEvent("service-click", {
|
|
299
|
+
bubbles: !0,
|
|
300
|
+
composed: !0,
|
|
301
|
+
detail: { originalEvent: e }
|
|
302
|
+
}));
|
|
303
|
+
}
|
|
304
|
+
handleLogout() {
|
|
305
|
+
this.dispatchEvent(new CustomEvent("log-out", {
|
|
306
|
+
bubbles: !0,
|
|
307
|
+
composed: !0
|
|
308
|
+
}));
|
|
309
|
+
}
|
|
310
|
+
handleSearch(e) {
|
|
311
|
+
this.dispatchEvent(new CustomEvent("search", {
|
|
312
|
+
detail: { query: e },
|
|
313
|
+
bubbles: !0,
|
|
314
|
+
composed: !0
|
|
315
|
+
}));
|
|
316
|
+
}
|
|
317
|
+
handleSearchChange(e) {
|
|
318
|
+
this.dispatchEvent(new CustomEvent("search-change", {
|
|
319
|
+
detail: { query: e },
|
|
320
|
+
bubbles: !0,
|
|
321
|
+
composed: !0
|
|
322
|
+
}));
|
|
323
|
+
}
|
|
324
|
+
handleSearchInputChange(e) {
|
|
325
|
+
let t = e.target.value;
|
|
326
|
+
this.handleSearchChange(t);
|
|
327
|
+
}
|
|
328
|
+
handleSearchKeyDown(e) {
|
|
329
|
+
e.key === "Enter" && this.handleSearch(e.target.value);
|
|
330
|
+
}
|
|
331
|
+
get formattedLastLoggedIn() {
|
|
332
|
+
return C(this.user?.lastLoggedIn);
|
|
333
|
+
}
|
|
334
|
+
get isFixed() {
|
|
335
|
+
return this.position === "fixed";
|
|
336
|
+
}
|
|
337
|
+
get isSticky() {
|
|
338
|
+
return this.position === "sticky";
|
|
339
|
+
}
|
|
340
|
+
get shouldHideOnScroll() {
|
|
341
|
+
return this.scrollBehavior === "hide";
|
|
342
|
+
}
|
|
343
|
+
get showLogoutInHeader() {
|
|
344
|
+
return this.hasLogOut && (this.logOutButtonPlacement === "header" || this.logOutButtonPlacement === "both");
|
|
345
|
+
}
|
|
346
|
+
get showLogoutInUserMenu() {
|
|
347
|
+
return this.hasLogOut && (this.logOutButtonPlacement === "userMenu" || this.logOutButtonPlacement === "both");
|
|
348
|
+
}
|
|
349
|
+
renderLogo() {
|
|
350
|
+
if (this.hideLogo) return t;
|
|
351
|
+
let e = i`
|
|
352
|
+
<pkt-icon name="oslologo" aria-hidden="true" path=${this.logoPath}></pkt-icon>
|
|
353
|
+
`;
|
|
354
|
+
return i`
|
|
355
|
+
<span class="pkt-header-service__logo">
|
|
356
|
+
<a href=${this.logoLink} aria-label="Tilbake til forside" @click=${this.handleLogoClick}>
|
|
357
|
+
${e}
|
|
358
|
+
</a>
|
|
359
|
+
</span>
|
|
360
|
+
`;
|
|
361
|
+
}
|
|
362
|
+
renderServiceName() {
|
|
363
|
+
return this.serviceName ? this.serviceLink && typeof this.serviceLink == "string" ? i`
|
|
364
|
+
<span class="pkt-header-service__service-name" translate="no">
|
|
365
|
+
<pkt-link
|
|
366
|
+
href=${this.serviceLink}
|
|
367
|
+
class="pkt-header-service__service-link"
|
|
368
|
+
@click=${this.handleServiceClick}
|
|
369
|
+
>
|
|
370
|
+
${this.serviceName}
|
|
371
|
+
</pkt-link>
|
|
372
|
+
</span>
|
|
373
|
+
` : this.hasAttribute("service-link") ? i`
|
|
374
|
+
<span class="pkt-header-service__service-name" translate="no">
|
|
375
|
+
<button
|
|
376
|
+
class="pkt-link-button pkt-link pkt-header-service__service-link"
|
|
377
|
+
@click=${this.handleServiceClick}
|
|
378
|
+
>
|
|
379
|
+
${this.serviceName}
|
|
380
|
+
</button>
|
|
381
|
+
</span>
|
|
382
|
+
` : i`
|
|
383
|
+
<span
|
|
384
|
+
class="pkt-header-service__service-name"
|
|
385
|
+
translate="no"
|
|
386
|
+
@click=${this.handleServiceClick}
|
|
387
|
+
>
|
|
388
|
+
<span class="pkt-header-service__service-link">${this.serviceName}</span>
|
|
389
|
+
</span>
|
|
390
|
+
` : t;
|
|
391
|
+
}
|
|
392
|
+
renderSlotContainer() {
|
|
393
|
+
if (!this.hasSlotContent()) return t;
|
|
394
|
+
let e = s({
|
|
395
|
+
"pkt-header-service__slot-container": !0,
|
|
396
|
+
"is-open": this.openMenu === "slot"
|
|
397
|
+
}), n = s({
|
|
398
|
+
"pkt-header-service__slot-content": !0,
|
|
399
|
+
"align-right": this.alignSlotRight
|
|
400
|
+
});
|
|
401
|
+
return i`
|
|
402
|
+
<div
|
|
403
|
+
class=${e}
|
|
404
|
+
@focusout=${(e) => this.handleFocusOut(e, "slot")}
|
|
405
|
+
${d(this.slotContainerRef)}
|
|
406
|
+
>
|
|
407
|
+
${this.isTablet && this.hasSlotContent() ? i`
|
|
408
|
+
<pkt-button
|
|
409
|
+
skin="secondary"
|
|
410
|
+
variant=${this.slotMenuVariant}
|
|
411
|
+
iconName="menu"
|
|
412
|
+
size=${this.isMobile ? "small" : "medium"}
|
|
413
|
+
state=${this.openMenu === "slot" ? "active" : "normal"}
|
|
414
|
+
@click=${() => this.handleMenuToggle("slot")}
|
|
415
|
+
aria-expanded=${this.openMenu === "slot"}
|
|
416
|
+
aria-controls="mobile-slot-menu"
|
|
417
|
+
aria-label="Åpne meny"
|
|
418
|
+
>
|
|
419
|
+
${this.slotMenuText}
|
|
420
|
+
</pkt-button>
|
|
421
|
+
` : t}
|
|
422
|
+
<div
|
|
423
|
+
class=${n}
|
|
424
|
+
id="mobile-slot-menu"
|
|
425
|
+
role=${this.isTablet ? "group" : t}
|
|
426
|
+
aria-label=${this.isTablet ? "Meny" : t}
|
|
427
|
+
@click=${this.handleSlotContentClick}
|
|
428
|
+
${d(this.slotContentRef)}
|
|
429
|
+
>
|
|
430
|
+
${c(this)}
|
|
431
|
+
</div>
|
|
432
|
+
</div>
|
|
433
|
+
`;
|
|
434
|
+
}
|
|
435
|
+
renderSearch() {
|
|
436
|
+
if (!this.showSearch) return t;
|
|
437
|
+
if (this.isTablet) {
|
|
438
|
+
let e = s({
|
|
439
|
+
"pkt-header-service__search-container": !0,
|
|
440
|
+
"is-open": this.openMenu === "search"
|
|
441
|
+
}), n = s({
|
|
442
|
+
"pkt-header-service__mobile-menu": !0,
|
|
443
|
+
"is-open": this.openMenu === "search",
|
|
444
|
+
"align-right": this.alignSearchRight
|
|
445
|
+
});
|
|
446
|
+
return i`
|
|
447
|
+
<div
|
|
448
|
+
class=${e}
|
|
449
|
+
@focusout=${(e) => this.handleFocusOut(e, "search")}
|
|
450
|
+
${d(this.searchContainerRef)}
|
|
451
|
+
>
|
|
452
|
+
<pkt-button
|
|
453
|
+
skin="secondary"
|
|
454
|
+
variant="icon-only"
|
|
455
|
+
iconName="magnifying-glass-big"
|
|
456
|
+
size=${this.isMobile ? "small" : "medium"}
|
|
457
|
+
@click=${() => this.handleMenuToggle("search")}
|
|
458
|
+
state=${this.openMenu === "search" ? "active" : "normal"}
|
|
459
|
+
aria-expanded=${this.openMenu === "search"}
|
|
460
|
+
aria-controls="mobile-search-menu"
|
|
461
|
+
aria-label="Åpne søkefelt"
|
|
462
|
+
>
|
|
463
|
+
Søk
|
|
464
|
+
</pkt-button>
|
|
465
|
+
<div class=${n} ${d(this.searchMenuRef)}>
|
|
466
|
+
${this.openMenu === "search" ? i`
|
|
467
|
+
<pkt-textinput
|
|
468
|
+
id="mobile-search-menu"
|
|
469
|
+
class="pkt-header-service__search-input"
|
|
470
|
+
type="search"
|
|
471
|
+
label="Søk"
|
|
472
|
+
useWrapper="false"
|
|
473
|
+
placeholder=${this.searchPlaceholder}
|
|
474
|
+
value=${this.searchValue}
|
|
475
|
+
autofocus
|
|
476
|
+
fullwidth
|
|
477
|
+
@input=${this.handleSearchInputChange}
|
|
478
|
+
@keydown=${(e) => {
|
|
479
|
+
e.key === "Enter" && this.handleSearch(e.target.value);
|
|
480
|
+
}}
|
|
481
|
+
></pkt-textinput>
|
|
482
|
+
` : t}
|
|
483
|
+
</div>
|
|
484
|
+
</div>
|
|
485
|
+
`;
|
|
486
|
+
}
|
|
487
|
+
return i`
|
|
488
|
+
<pkt-textinput
|
|
489
|
+
id="header-service-search"
|
|
490
|
+
class="pkt-header-service__search-input"
|
|
491
|
+
type="search"
|
|
492
|
+
label="Søk"
|
|
493
|
+
useWrapper="false"
|
|
494
|
+
placeholder=${this.searchPlaceholder}
|
|
495
|
+
value=${this.searchValue}
|
|
496
|
+
@input=${this.handleSearchInputChange}
|
|
497
|
+
@keydown=${this.handleSearchKeyDown}
|
|
498
|
+
></pkt-textinput>
|
|
499
|
+
`;
|
|
500
|
+
}
|
|
501
|
+
renderUserButton() {
|
|
502
|
+
if (!this.user) return t;
|
|
503
|
+
let e = s({
|
|
504
|
+
"pkt-header-service__user-menu": this.isMobile === !1,
|
|
505
|
+
"pkt-header-service__mobile-menu": this.isMobile === !0,
|
|
506
|
+
"is-open": this.openMenu === "user"
|
|
507
|
+
});
|
|
508
|
+
return i`
|
|
509
|
+
<div
|
|
510
|
+
class="pkt-header-service__user-container"
|
|
511
|
+
@focusout=${(e) => this.handleFocusOut(e, "user")}
|
|
512
|
+
${d(this.userContainerRef)}
|
|
513
|
+
>
|
|
514
|
+
<pkt-button
|
|
515
|
+
class=${s({
|
|
516
|
+
"pkt-header-service__user-button": !0,
|
|
517
|
+
"pkt-header-service__user-button--mobile": this.isMobile
|
|
518
|
+
})}
|
|
519
|
+
skin="secondary"
|
|
520
|
+
size=${this.isMobile ? "small" : "medium"}
|
|
521
|
+
state=${this.openMenu === "user" ? "active" : "normal"}
|
|
522
|
+
variant="icons-right-and-left"
|
|
523
|
+
iconName="user"
|
|
524
|
+
secondIconName=${this.openMenu === "user" ? "chevron-thin-up" : "chevron-thin-down"}
|
|
525
|
+
@click=${() => this.handleMenuToggle("user")}
|
|
526
|
+
>
|
|
527
|
+
<span class="pkt-sr-only">Brukermeny: </span>
|
|
528
|
+
<span translate="no">${this.representing?.name || this.user.name}</span>
|
|
529
|
+
</pkt-button>
|
|
530
|
+
${this.openMenu === "user" && this.user ? i`
|
|
531
|
+
<div class=${e}>
|
|
532
|
+
<pkt-header-user-menu
|
|
533
|
+
.user=${this.user}
|
|
534
|
+
formatted-last-logged-in=${this.formattedLastLoggedIn || t}
|
|
535
|
+
.representing=${this.representing}
|
|
536
|
+
.userMenu=${this.userMenu}
|
|
537
|
+
?can-change-representation=${this.canChangeRepresentation}
|
|
538
|
+
?logout-on-click=${this.showLogoutInUserMenu}
|
|
539
|
+
@change-representation=${() => this.dispatchEvent(new CustomEvent("change-representation", {
|
|
540
|
+
bubbles: !0,
|
|
541
|
+
composed: !0
|
|
542
|
+
}))}
|
|
543
|
+
@log-out=${this.handleLogout}
|
|
544
|
+
></pkt-header-user-menu>
|
|
545
|
+
</div>
|
|
546
|
+
` : t}
|
|
547
|
+
</div>
|
|
548
|
+
`;
|
|
549
|
+
}
|
|
550
|
+
renderHeader() {
|
|
551
|
+
let e = s({
|
|
552
|
+
"pkt-header-service": !0,
|
|
553
|
+
"pkt-header-service--compact": this.compact,
|
|
554
|
+
"pkt-header-service--mobile": this.isMobile,
|
|
555
|
+
"pkt-header-service--tablet": this.isTablet,
|
|
556
|
+
"pkt-header-service--fixed": this.isFixed,
|
|
557
|
+
"pkt-header-service--sticky": this.isSticky,
|
|
558
|
+
"pkt-header-service--scroll-to-hide": this.shouldHideOnScroll,
|
|
559
|
+
"pkt-header-service--hidden": this.isHidden
|
|
560
|
+
}), n = s({
|
|
561
|
+
"pkt-header-service__logo-area": !0,
|
|
562
|
+
"pkt-header-service__logo-area--without-service": !this.serviceName
|
|
563
|
+
});
|
|
564
|
+
return i`
|
|
565
|
+
<header class=${e} ${d(this.headerRef)}>
|
|
566
|
+
<div class=${n}>${this.renderLogo()} ${this.renderServiceName()}</div>
|
|
567
|
+
|
|
568
|
+
${this.hasSlotContent() || this.showSearch || this.showLogoutInHeader ? i`<div class="pkt-header-service__content">
|
|
569
|
+
${this.renderSlotContainer()} ${this.renderSearch()}
|
|
570
|
+
${this.isTablet && this.showLogoutInHeader ? i`
|
|
571
|
+
<pkt-button
|
|
572
|
+
skin="secondary"
|
|
573
|
+
size=${this.isMobile ? "small" : "medium"}
|
|
574
|
+
variant="icon-only"
|
|
575
|
+
iconName="exit"
|
|
576
|
+
@click=${this.handleLogout}
|
|
577
|
+
>
|
|
578
|
+
Logg ut
|
|
579
|
+
</pkt-button>
|
|
580
|
+
` : t}
|
|
581
|
+
</div>` : t}
|
|
582
|
+
${this.user || !this.isTablet && this.showLogoutInHeader ? i`<div class="pkt-header-service__user">
|
|
583
|
+
${this.renderUserButton()}
|
|
584
|
+
${!this.isTablet && this.showLogoutInHeader ? i`
|
|
585
|
+
<pkt-button
|
|
586
|
+
skin="tertiary"
|
|
587
|
+
size="medium"
|
|
588
|
+
variant="icon-right"
|
|
589
|
+
iconName="exit"
|
|
590
|
+
@click=${this.handleLogout}
|
|
591
|
+
>
|
|
592
|
+
Logg ut
|
|
593
|
+
</pkt-button>
|
|
594
|
+
` : t}
|
|
595
|
+
</div>` : t}
|
|
596
|
+
</header>
|
|
597
|
+
`;
|
|
598
|
+
}
|
|
599
|
+
render() {
|
|
600
|
+
let e = this.renderHeader();
|
|
601
|
+
return this.isFixed ? i`
|
|
602
|
+
<div class="pkt-header-service-wrapper">
|
|
603
|
+
${e}
|
|
604
|
+
<div class=${s({
|
|
605
|
+
"pkt-header-service-spacer": !0,
|
|
606
|
+
"pkt-header-service-spacer--compact": this.compact,
|
|
607
|
+
"pkt-header-service-spacer--has-user": !!this.user,
|
|
608
|
+
"pkt-header-service-spacer--mobile": this.isMobile,
|
|
609
|
+
"pkt-header-service-spacer--tablet": this.isTablet
|
|
610
|
+
})}></div>
|
|
611
|
+
</div>
|
|
612
|
+
` : e;
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
n([r({
|
|
616
|
+
type: String,
|
|
617
|
+
attribute: "service-name"
|
|
618
|
+
})], D.prototype, "serviceName", void 0), n([r({
|
|
619
|
+
type: String,
|
|
620
|
+
attribute: "service-link"
|
|
621
|
+
})], D.prototype, "serviceLink", void 0), n([r({
|
|
622
|
+
type: String,
|
|
623
|
+
attribute: "logo-link"
|
|
624
|
+
})], D.prototype, "logoLink", void 0), n([r({
|
|
625
|
+
type: String,
|
|
626
|
+
attribute: "logo-path"
|
|
627
|
+
})], D.prototype, "logoPath", void 0), n([r({
|
|
628
|
+
type: String,
|
|
629
|
+
attribute: "search-placeholder"
|
|
630
|
+
})], D.prototype, "searchPlaceholder", void 0), n([r({
|
|
631
|
+
type: String,
|
|
632
|
+
attribute: "search-value"
|
|
633
|
+
})], D.prototype, "searchValue", void 0), n([r({
|
|
634
|
+
type: Number,
|
|
635
|
+
attribute: "mobile-breakpoint"
|
|
636
|
+
})], D.prototype, "mobileBreakpoint", void 0), n([r({
|
|
637
|
+
type: Number,
|
|
638
|
+
attribute: "tablet-breakpoint"
|
|
639
|
+
})], D.prototype, "tabletBreakpoint", void 0), n([r({
|
|
640
|
+
type: String,
|
|
641
|
+
attribute: "opened-menu"
|
|
642
|
+
})], D.prototype, "openedMenu", void 0), n([r({
|
|
643
|
+
type: String,
|
|
644
|
+
attribute: "log-out-button-placement"
|
|
645
|
+
})], D.prototype, "logOutButtonPlacement", void 0), n([r({ type: String })], D.prototype, "position", void 0), n([r({
|
|
646
|
+
type: String,
|
|
647
|
+
attribute: "scroll-behavior"
|
|
648
|
+
})], D.prototype, "scrollBehavior", void 0), n([r({
|
|
649
|
+
type: String,
|
|
650
|
+
attribute: "slot-menu-variant"
|
|
651
|
+
})], D.prototype, "slotMenuVariant", void 0), n([r({
|
|
652
|
+
type: String,
|
|
653
|
+
attribute: "slot-menu-text"
|
|
654
|
+
})], D.prototype, "slotMenuText", void 0), n([r({
|
|
655
|
+
type: Boolean,
|
|
656
|
+
attribute: "hide-logo",
|
|
657
|
+
converter: p
|
|
658
|
+
})], D.prototype, "hideLogo", void 0), n([r({
|
|
659
|
+
type: Boolean,
|
|
660
|
+
converter: p
|
|
661
|
+
})], D.prototype, "compact", void 0), n([r({
|
|
662
|
+
type: Boolean,
|
|
663
|
+
attribute: "show-search",
|
|
664
|
+
converter: p
|
|
665
|
+
})], D.prototype, "showSearch", void 0), n([r({
|
|
666
|
+
type: Boolean,
|
|
667
|
+
attribute: "can-change-representation",
|
|
668
|
+
converter: p
|
|
669
|
+
})], D.prototype, "canChangeRepresentation", void 0), n([r({
|
|
670
|
+
type: Boolean,
|
|
671
|
+
attribute: "has-log-out",
|
|
672
|
+
converter: p
|
|
673
|
+
})], D.prototype, "hasLogOut", void 0), n([r({ type: Object })], D.prototype, "user", void 0), n([r({
|
|
674
|
+
type: Array,
|
|
675
|
+
attribute: "user-menu"
|
|
676
|
+
})], D.prototype, "userMenu", void 0), n([r({ type: Object })], D.prototype, "representing", void 0), n([e()], D.prototype, "openMenu", void 0), n([e()], D.prototype, "alignSlotRight", void 0), n([e()], D.prototype, "alignSearchRight", void 0);
|
|
677
|
+
try {
|
|
678
|
+
a("pkt-header-service")(D);
|
|
679
|
+
} catch {
|
|
680
|
+
console.warn("Forsøker å definere <pkt-header-service>, men den er allerede definert");
|
|
681
|
+
}
|
|
682
|
+
//#endregion
|
|
683
|
+
//#region src/components/header/header-global.ts
|
|
684
|
+
var O = "https://punkt-cdn.oslo.kommune.no/latest/logos/";
|
|
685
|
+
typeof window < "u" && (window.pktLogoPath = window.pktLogoPath || O);
|
|
686
|
+
var k = "pkt-header-global-menu", A = "pkt-header-global-menu-toggle", j = "pkt-header-global-search-panel", M = "pkt-header-global-search-toggle", N = class extends o {
|
|
687
|
+
constructor(...e) {
|
|
688
|
+
super(...e), this.locale = "nb-NO", this.logoLink = h, this.logoPath = typeof window < "u" ? window.pktLogoPath : O, this.position = "fixed", this.scrollBehavior = "hide", this.mobileBreakpoint = 768, this.tabletBreakpoint = 1024, this.logOutButtonPlacement = "none", this.showSearch = !0, this.showContact = !0, this.canChangeRepresentation = !1, this.hasLogOut = !1, this.openMenu = "none", this.loadError = !1, this.headerAnchor = {
|
|
689
|
+
top: 0,
|
|
690
|
+
left: 0,
|
|
691
|
+
width: 0
|
|
692
|
+
}, this.headerRef = f(), this.menuContainerRef = f(), this.userContainerRef = f(), this.chrome = new w(this, () => ({
|
|
693
|
+
mobileBreakpoint: this.mobileBreakpoint,
|
|
694
|
+
tabletBreakpoint: this.tabletBreakpoint,
|
|
695
|
+
position: this.position,
|
|
696
|
+
scrollBehavior: this.scrollBehavior
|
|
697
|
+
})), this.handleClickOutside = (e) => {
|
|
698
|
+
let t = e.target;
|
|
699
|
+
this.openMenu === "user" && !t.closest(".pkt-header-global__user-container") && !t.closest(".pkt-header-global__user-menu") && (this.openMenu = "none"), this.openMenu === "menu" && !t.closest(".pkt-header-menu") && !t.closest(`#${A}`) && (this.openMenu = "none"), this.openMenu === "search" && !t.closest(".pkt-header-global__search-panel-inner") && !t.closest(`#${M}`) && (this.openMenu = "none");
|
|
700
|
+
}, this.handleEscapeKey = (e) => {
|
|
701
|
+
e.key === "Escape" && this.openMenu !== "none" && (e.preventDefault(), this.chrome.flagRestoreFocus(), this.openMenu = "none");
|
|
702
|
+
}, this.handleOverlayKeydown = (e) => {
|
|
703
|
+
if (e.key !== "Tab") return;
|
|
704
|
+
let t = this.activeOverlay;
|
|
705
|
+
if (!t || !t.panel || !t.toggle) return;
|
|
706
|
+
let { panel: n, toggle: r } = t, i = _(n), a = v();
|
|
707
|
+
if (a && r.contains(a)) {
|
|
708
|
+
!e.shiftKey && i.length > 0 && (e.preventDefault(), i[0].focus());
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
if (i.length === 0) return;
|
|
712
|
+
let o = i[0], s = i[i.length - 1], c = !e.shiftKey && a === s, l = e.shiftKey && a === o;
|
|
713
|
+
(c || l) && (e.preventDefault(), this.openMenu = "none", this.focusToggle(r));
|
|
714
|
+
}, this.handleOverlayFocusIn = (e) => {
|
|
715
|
+
let t = this.activeOverlay;
|
|
716
|
+
if (!t || !t.panel) return;
|
|
717
|
+
let n = e.target;
|
|
718
|
+
n && (t.panel.contains(n) || t.toggle?.contains(n) || (this.openMenu = "none"));
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
get isMobile() {
|
|
722
|
+
return this.chrome.isMobile;
|
|
723
|
+
}
|
|
724
|
+
get isTablet() {
|
|
725
|
+
return this.chrome.isTablet;
|
|
726
|
+
}
|
|
727
|
+
get isHidden() {
|
|
728
|
+
return this.chrome.isHidden;
|
|
729
|
+
}
|
|
730
|
+
connectedCallback() {
|
|
731
|
+
super.connectedCallback(), this.classList.add("pkt-header-global-host"), this.data ? this.emitDataLoaded(this.data) : this.loadData();
|
|
732
|
+
}
|
|
733
|
+
disconnectedCallback() {
|
|
734
|
+
super.disconnectedCallback(), this.abortController?.abort(), document.removeEventListener("mousedown", this.handleClickOutside), document.removeEventListener("keydown", this.handleEscapeKey), document.removeEventListener("keydown", this.handleOverlayKeydown), document.removeEventListener("focusin", this.handleOverlayFocusIn);
|
|
735
|
+
}
|
|
736
|
+
firstUpdated() {
|
|
737
|
+
this.chrome.observe(this.headerRef.value);
|
|
738
|
+
}
|
|
739
|
+
willUpdate(e) {
|
|
740
|
+
if (super.willUpdate(e), this.openMenu === "menu" || this.openMenu === "search") {
|
|
741
|
+
let e = this.headerRef.value?.getBoundingClientRect();
|
|
742
|
+
e && (this.headerAnchor = {
|
|
743
|
+
top: e.top,
|
|
744
|
+
left: e.left,
|
|
745
|
+
width: e.width
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
get overlayAnchorStyle() {
|
|
750
|
+
let { top: e, left: t, width: n } = this.headerAnchor;
|
|
751
|
+
return `--pkt-header-global-top: ${e}px; --pkt-header-global-left: ${t}px; --pkt-header-global-width: ${n}px`;
|
|
752
|
+
}
|
|
753
|
+
updated(e) {
|
|
754
|
+
if (super.updated(e), (e.has("mobileBreakpoint") || e.has("tabletBreakpoint")) && this.chrome.refreshBreakpoints(), e.has("dataUrl") && e.get("dataUrl") !== void 0 && !this.data && this.loadData(), e.has("data") && this.data && this.emitDataLoaded(this.data), e.has("openMenu")) {
|
|
755
|
+
let t = e.get("openMenu");
|
|
756
|
+
this.openMenu !== "none" && (t === "none" || t === void 0) ? (document.addEventListener("mousedown", this.handleClickOutside), document.addEventListener("keydown", this.handleEscapeKey)) : this.openMenu === "none" && t && t !== "none" && (document.removeEventListener("mousedown", this.handleClickOutside), document.removeEventListener("keydown", this.handleEscapeKey), this.chrome.restoreFocus());
|
|
757
|
+
let n = t === "menu" || t === "search", r = this.openMenu === "menu" || this.openMenu === "search";
|
|
758
|
+
r && !n ? (document.addEventListener("keydown", this.handleOverlayKeydown), document.addEventListener("focusin", this.handleOverlayFocusIn)) : !r && n && (document.removeEventListener("keydown", this.handleOverlayKeydown), document.removeEventListener("focusin", this.handleOverlayFocusIn)), this.openMenu === "search" && t !== "search" && requestAnimationFrame(() => {
|
|
759
|
+
this.querySelector(`#${j} input`)?.focus();
|
|
760
|
+
}), this.chrome.pauseScrollHide = this.openMenu !== "none", this.chrome.setScrollLock(this.openMenu === "menu" || this.openMenu === "search");
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
async loadData() {
|
|
764
|
+
this.abortController?.abort(), this.abortController = new AbortController(), this.loadError = !1;
|
|
765
|
+
try {
|
|
766
|
+
let e = await g(this.dataUrl, this.abortController.signal);
|
|
767
|
+
this.fetchedData = e, this.emitDataLoaded(e);
|
|
768
|
+
} catch (e) {
|
|
769
|
+
if (e.name === "AbortError") return;
|
|
770
|
+
this.loadError = !0, this.dispatchEvent(new CustomEvent("data-error", {
|
|
771
|
+
detail: { error: e },
|
|
772
|
+
bubbles: !0,
|
|
773
|
+
composed: !0
|
|
774
|
+
}));
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
emitDataLoaded(e) {
|
|
778
|
+
this.dispatchEvent(new CustomEvent("data-loaded", {
|
|
779
|
+
detail: { data: e },
|
|
780
|
+
bubbles: !0,
|
|
781
|
+
composed: !0
|
|
782
|
+
}));
|
|
783
|
+
}
|
|
784
|
+
get effectiveData() {
|
|
785
|
+
return this.data ?? this.fetchedData;
|
|
786
|
+
}
|
|
787
|
+
get localeData() {
|
|
788
|
+
return m(this.effectiveData, this.locale);
|
|
789
|
+
}
|
|
790
|
+
get shouldHideOnScroll() {
|
|
791
|
+
return this.scrollBehavior === "hide";
|
|
792
|
+
}
|
|
793
|
+
get isFixed() {
|
|
794
|
+
return this.position === "fixed";
|
|
795
|
+
}
|
|
796
|
+
get isSticky() {
|
|
797
|
+
return this.position === "sticky";
|
|
798
|
+
}
|
|
799
|
+
toggleMenu(e) {
|
|
800
|
+
this.openMenu === e ? this.openMenu = "none" : (this.chrome.captureFocus(), this.openMenu = e);
|
|
801
|
+
}
|
|
802
|
+
get activeOverlay() {
|
|
803
|
+
return this.openMenu === "menu" ? {
|
|
804
|
+
panel: this.menuContainerRef.value ?? null,
|
|
805
|
+
toggle: this.querySelector(`#${A}`)
|
|
806
|
+
} : this.openMenu === "search" ? {
|
|
807
|
+
panel: this.querySelector(`#${j}`),
|
|
808
|
+
toggle: this.querySelector(`#${M}`)
|
|
809
|
+
} : null;
|
|
810
|
+
}
|
|
811
|
+
focusToggle(e) {
|
|
812
|
+
(e?.querySelector("button") ?? e)?.focus();
|
|
813
|
+
}
|
|
814
|
+
handleSearch(e) {
|
|
815
|
+
this.dispatchEvent(new CustomEvent("search", {
|
|
816
|
+
detail: { query: e },
|
|
817
|
+
bubbles: !0,
|
|
818
|
+
composed: !0
|
|
819
|
+
}));
|
|
820
|
+
}
|
|
821
|
+
handleLogout() {
|
|
822
|
+
this.dispatchEvent(new CustomEvent("log-out", {
|
|
823
|
+
bubbles: !0,
|
|
824
|
+
composed: !0
|
|
825
|
+
}));
|
|
826
|
+
}
|
|
827
|
+
handleChangeRepresentation() {
|
|
828
|
+
this.dispatchEvent(new CustomEvent("change-representation", {
|
|
829
|
+
bubbles: !0,
|
|
830
|
+
composed: !0
|
|
831
|
+
}));
|
|
832
|
+
}
|
|
833
|
+
get formattedLastLoggedIn() {
|
|
834
|
+
return C(this.user?.lastLoggedIn);
|
|
835
|
+
}
|
|
836
|
+
get showLogoutInUserMenu() {
|
|
837
|
+
return this.hasLogOut && (this.logOutButtonPlacement === "userMenu" || this.logOutButtonPlacement === "both");
|
|
838
|
+
}
|
|
839
|
+
handleLogoClick(e) {
|
|
840
|
+
this.dispatchEvent(new CustomEvent("logo-click", {
|
|
841
|
+
bubbles: !0,
|
|
842
|
+
composed: !0,
|
|
843
|
+
detail: { originalEvent: e }
|
|
844
|
+
}));
|
|
845
|
+
}
|
|
846
|
+
renderLogo() {
|
|
847
|
+
let e = i`
|
|
848
|
+
<pkt-icon name="oslologo" aria-hidden="true" path=${u(this.logoPath)}></pkt-icon>
|
|
849
|
+
`;
|
|
850
|
+
return i`
|
|
851
|
+
<span class="pkt-header-global__logo">
|
|
852
|
+
<a href=${this.logoLink} aria-label="Til hovedsiden" @click=${this.handleLogoClick}>
|
|
853
|
+
${e}
|
|
854
|
+
</a>
|
|
855
|
+
</span>
|
|
856
|
+
`;
|
|
857
|
+
}
|
|
858
|
+
renderSearch(e) {
|
|
859
|
+
if (!this.showSearch) return t;
|
|
860
|
+
let n = e.search;
|
|
861
|
+
if (!n) return t;
|
|
862
|
+
let r = this.searchPlaceholder ?? n.input.placeholder;
|
|
863
|
+
return i`
|
|
864
|
+
<div class="pkt-header-global__search">
|
|
865
|
+
<pkt-searchinput
|
|
866
|
+
appearance="global"
|
|
867
|
+
input-size=${this.isTablet ? "small" : "medium"}
|
|
868
|
+
fullwidth
|
|
869
|
+
id=${n.input.id || "pkt-header-global-search"}
|
|
870
|
+
name=${u(n.input.name)}
|
|
871
|
+
placeholder=${u(r)}
|
|
872
|
+
aria-label=${u(e.i18n?.search)}
|
|
873
|
+
action=${n.endpoint}
|
|
874
|
+
method="get"
|
|
875
|
+
@pkt-search=${(e) => this.handleSearch(e.detail.value)}
|
|
876
|
+
></pkt-searchinput>
|
|
877
|
+
</div>
|
|
878
|
+
`;
|
|
879
|
+
}
|
|
880
|
+
renderContact(e) {
|
|
881
|
+
if (!this.showContact || this.user) return t;
|
|
882
|
+
let n = e.header?.contact, r = s({
|
|
883
|
+
"pkt-header-global__contact": !0,
|
|
884
|
+
"pkt-btn": !0,
|
|
885
|
+
"pkt-btn--secondary": !0,
|
|
886
|
+
"pkt-btn--label-only": !0,
|
|
887
|
+
"pkt-btn--small": this.isMobile || this.isTablet,
|
|
888
|
+
"pkt-btn--medium": !this.isMobile && !this.isTablet
|
|
889
|
+
});
|
|
890
|
+
return n ? i`
|
|
891
|
+
<a class=${r} href=${n.url}>
|
|
892
|
+
<span class="pkt-btn__text">${n.text}</span>
|
|
893
|
+
</a>
|
|
894
|
+
` : t;
|
|
895
|
+
}
|
|
896
|
+
get isLoading() {
|
|
897
|
+
return !this.localeData && !this.loadError;
|
|
898
|
+
}
|
|
899
|
+
renderMenuToggle(e) {
|
|
900
|
+
let t = e?.i18n?.menu || "Meny", n = this.openMenu === "menu";
|
|
901
|
+
return i`
|
|
902
|
+
<pkt-button
|
|
903
|
+
id=${A}
|
|
904
|
+
class="pkt-header-global__menu-toggle"
|
|
905
|
+
skin=${this.isMobile ? "tertiary" : "secondary"}
|
|
906
|
+
variant=${this.isMobile ? "icon-only" : "icon-right"}
|
|
907
|
+
iconName=${n ? "close" : "menu"}
|
|
908
|
+
size=${this.isTablet ? "small" : "medium"}
|
|
909
|
+
state=${n ? "active" : "normal"}
|
|
910
|
+
aria-expanded=${n}
|
|
911
|
+
aria-controls=${k}
|
|
912
|
+
?disabled=${this.isLoading}
|
|
913
|
+
@click=${() => this.toggleMenu("menu")}
|
|
914
|
+
>
|
|
915
|
+
${t}
|
|
916
|
+
</pkt-button>
|
|
917
|
+
`;
|
|
918
|
+
}
|
|
919
|
+
renderSearchToggle(e) {
|
|
920
|
+
if (!this.showSearch || !e.search) return t;
|
|
921
|
+
let n = this.openMenu === "search";
|
|
922
|
+
return i`
|
|
923
|
+
<pkt-button
|
|
924
|
+
id=${M}
|
|
925
|
+
class="pkt-header-global__search-toggle"
|
|
926
|
+
skin="primary"
|
|
927
|
+
color=${u(n ? void 0 : "yellow")}
|
|
928
|
+
variant="icon-only"
|
|
929
|
+
iconName=${n ? "close" : "magnifying-glass-big"}
|
|
930
|
+
size=${this.isMobile ? "small" : "medium"}
|
|
931
|
+
state=${n ? "active" : "normal"}
|
|
932
|
+
aria-expanded=${n}
|
|
933
|
+
aria-controls=${j}
|
|
934
|
+
@click=${() => this.toggleMenu("search")}
|
|
935
|
+
>
|
|
936
|
+
${e.i18n?.search || "Søk"}
|
|
937
|
+
</pkt-button>
|
|
938
|
+
`;
|
|
939
|
+
}
|
|
940
|
+
renderSearchPanel(e) {
|
|
941
|
+
let n = e.search;
|
|
942
|
+
if (this.openMenu !== "search" || !this.showSearch || !n) return t;
|
|
943
|
+
let r = this.searchPlaceholder ?? n.input.placeholder;
|
|
944
|
+
return i`
|
|
945
|
+
<div class=${s({
|
|
946
|
+
"pkt-header-global__search-panel": !0,
|
|
947
|
+
[`pkt-header-global__search-panel--${this.overlayBreakpointClass}`]: !!this.overlayBreakpointClass
|
|
948
|
+
})} id=${j} style=${this.overlayAnchorStyle}>
|
|
949
|
+
<div class="pkt-header-global__search-panel-inner">
|
|
950
|
+
<pkt-searchinput
|
|
951
|
+
appearance="global"
|
|
952
|
+
fullwidth
|
|
953
|
+
id=${n.input.id || "pkt-header-global-search"}
|
|
954
|
+
name=${u(n.input.name)}
|
|
955
|
+
placeholder=${u(r)}
|
|
956
|
+
aria-label=${u(e.i18n?.search || "Søk")}
|
|
957
|
+
action=${n.endpoint}
|
|
958
|
+
method="get"
|
|
959
|
+
@pkt-search=${(e) => this.handleSearch(e.detail.value)}
|
|
960
|
+
></pkt-searchinput>
|
|
961
|
+
</div>
|
|
962
|
+
</div>
|
|
963
|
+
`;
|
|
964
|
+
}
|
|
965
|
+
renderUser() {
|
|
966
|
+
if (!this.user) return t;
|
|
967
|
+
let e = this.openMenu === "user", n = s({
|
|
968
|
+
"pkt-header-global__user-menu": !0,
|
|
969
|
+
"is-open": e
|
|
970
|
+
});
|
|
971
|
+
return i`
|
|
972
|
+
<div class="pkt-header-global__user">
|
|
973
|
+
<div
|
|
974
|
+
class="pkt-header-global__user-container ${e ? "is-open" : ""}"
|
|
975
|
+
${d(this.userContainerRef)}
|
|
976
|
+
>
|
|
977
|
+
<pkt-button
|
|
978
|
+
class="pkt-header-global__user-button"
|
|
979
|
+
skin="secondary"
|
|
980
|
+
size=${this.isTablet ? "small" : "medium"}
|
|
981
|
+
state=${e ? "active" : "normal"}
|
|
982
|
+
variant="icons-right-and-left"
|
|
983
|
+
iconName="user"
|
|
984
|
+
secondIconName=${e ? "chevron-thin-up" : "chevron-thin-down"}
|
|
985
|
+
@click=${() => this.toggleMenu("user")}
|
|
986
|
+
>
|
|
987
|
+
<span class="pkt-sr-only">Brukermeny: </span>
|
|
988
|
+
<span translate="no">${this.representing?.name || this.user.name}</span>
|
|
989
|
+
</pkt-button>
|
|
990
|
+
${e ? i`
|
|
991
|
+
<div class=${n}>
|
|
992
|
+
<pkt-header-user-menu
|
|
993
|
+
.user=${this.user}
|
|
994
|
+
formatted-last-logged-in=${this.formattedLastLoggedIn || t}
|
|
995
|
+
.representing=${this.representing}
|
|
996
|
+
.userMenu=${this.userMenu}
|
|
997
|
+
?can-change-representation=${this.canChangeRepresentation}
|
|
998
|
+
?logout-on-click=${this.showLogoutInUserMenu}
|
|
999
|
+
@change-representation=${() => this.handleChangeRepresentation()}
|
|
1000
|
+
@log-out=${() => this.handleLogout()}
|
|
1001
|
+
></pkt-header-user-menu>
|
|
1002
|
+
</div>
|
|
1003
|
+
` : t}
|
|
1004
|
+
</div>
|
|
1005
|
+
</div>
|
|
1006
|
+
`;
|
|
1007
|
+
}
|
|
1008
|
+
get overlayBreakpointClass() {
|
|
1009
|
+
return this.isMobile ? "mobile" : this.isTablet ? "tablet" : "";
|
|
1010
|
+
}
|
|
1011
|
+
renderMenu() {
|
|
1012
|
+
return this.openMenu === "menu" ? i`
|
|
1013
|
+
<div
|
|
1014
|
+
class=${s({
|
|
1015
|
+
"pkt-header-global__menu": !0,
|
|
1016
|
+
[`pkt-header-global__menu--${this.overlayBreakpointClass}`]: !!this.overlayBreakpointClass
|
|
1017
|
+
})}
|
|
1018
|
+
id=${k}
|
|
1019
|
+
style=${this.overlayAnchorStyle}
|
|
1020
|
+
${d(this.menuContainerRef)}
|
|
1021
|
+
>
|
|
1022
|
+
${this.localeData ? i`
|
|
1023
|
+
<pkt-header-menu
|
|
1024
|
+
.data=${this.effectiveData}
|
|
1025
|
+
locale=${this.locale}
|
|
1026
|
+
open
|
|
1027
|
+
mobile-breakpoint=${this.mobileBreakpoint}
|
|
1028
|
+
></pkt-header-menu>
|
|
1029
|
+
` : i`
|
|
1030
|
+
<nav class="pkt-header-menu pkt-header-menu--open">
|
|
1031
|
+
<p class="pkt-header-menu__error">Kunne ikke laste meny.</p>
|
|
1032
|
+
</nav>
|
|
1033
|
+
`}
|
|
1034
|
+
</div>
|
|
1035
|
+
` : t;
|
|
1036
|
+
}
|
|
1037
|
+
renderHeader() {
|
|
1038
|
+
let e = s({
|
|
1039
|
+
"pkt-header-global": !0,
|
|
1040
|
+
"pkt-header-global--mobile": this.isMobile,
|
|
1041
|
+
"pkt-header-global--tablet": this.isTablet,
|
|
1042
|
+
"pkt-header-global--fixed": this.isFixed,
|
|
1043
|
+
"pkt-header-global--sticky": this.isSticky,
|
|
1044
|
+
"pkt-header-global--scroll-to-hide": this.shouldHideOnScroll,
|
|
1045
|
+
"pkt-header-global--hidden": this.isHidden
|
|
1046
|
+
}), n = this.localeData, r = this.isMobile;
|
|
1047
|
+
return i`
|
|
1048
|
+
<header class=${e} ${d(this.headerRef)}>
|
|
1049
|
+
<div class="pkt-header-global__logo-area">${this.renderLogo()}</div>
|
|
1050
|
+
<div class="pkt-header-global__content">
|
|
1051
|
+
${!r && n ? this.renderSearch(n) : t}
|
|
1052
|
+
${r && n ? this.renderSearchToggle(n) : t}
|
|
1053
|
+
${this.renderMenuToggle(n)}
|
|
1054
|
+
${!r && n ? this.renderContact(n) : t}
|
|
1055
|
+
</div>
|
|
1056
|
+
${this.renderUser()}
|
|
1057
|
+
</header>
|
|
1058
|
+
`;
|
|
1059
|
+
}
|
|
1060
|
+
render() {
|
|
1061
|
+
let e = this.renderHeader(), n = this.localeData, r = this.renderMenu(), a = n ? this.renderSearchPanel(n) : t;
|
|
1062
|
+
return this.isFixed ? i`
|
|
1063
|
+
<div class="pkt-header-global-wrapper">
|
|
1064
|
+
${e}
|
|
1065
|
+
<div class=${s({
|
|
1066
|
+
"pkt-header-global-spacer": !0,
|
|
1067
|
+
"pkt-header-global-spacer--mobile": this.isMobile,
|
|
1068
|
+
"pkt-header-global-spacer--tablet": this.isTablet && !this.isMobile,
|
|
1069
|
+
"pkt-header-global-spacer--has-user": !!this.user
|
|
1070
|
+
})}></div>
|
|
1071
|
+
${a}${r}
|
|
1072
|
+
</div>
|
|
1073
|
+
` : i`${e}${a}${r}`;
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
n([r({
|
|
1077
|
+
type: String,
|
|
1078
|
+
attribute: "data-url"
|
|
1079
|
+
})], N.prototype, "dataUrl", void 0), n([r({
|
|
1080
|
+
type: Object,
|
|
1081
|
+
attribute: !1
|
|
1082
|
+
})], N.prototype, "data", void 0), n([r({ type: String })], N.prototype, "locale", void 0), n([r({
|
|
1083
|
+
type: String,
|
|
1084
|
+
attribute: "logo-link"
|
|
1085
|
+
})], N.prototype, "logoLink", void 0), n([r({
|
|
1086
|
+
type: String,
|
|
1087
|
+
attribute: "logo-path"
|
|
1088
|
+
})], N.prototype, "logoPath", void 0), n([r({
|
|
1089
|
+
type: String,
|
|
1090
|
+
attribute: "search-placeholder"
|
|
1091
|
+
})], N.prototype, "searchPlaceholder", void 0), n([r({ type: String })], N.prototype, "position", void 0), n([r({
|
|
1092
|
+
type: String,
|
|
1093
|
+
attribute: "scroll-behavior"
|
|
1094
|
+
})], N.prototype, "scrollBehavior", void 0), n([r({
|
|
1095
|
+
type: Number,
|
|
1096
|
+
attribute: "mobile-breakpoint"
|
|
1097
|
+
})], N.prototype, "mobileBreakpoint", void 0), n([r({
|
|
1098
|
+
type: Number,
|
|
1099
|
+
attribute: "tablet-breakpoint"
|
|
1100
|
+
})], N.prototype, "tabletBreakpoint", void 0), n([r({
|
|
1101
|
+
type: String,
|
|
1102
|
+
attribute: "log-out-button-placement"
|
|
1103
|
+
})], N.prototype, "logOutButtonPlacement", void 0), n([r({
|
|
1104
|
+
type: Boolean,
|
|
1105
|
+
attribute: "show-search",
|
|
1106
|
+
converter: p
|
|
1107
|
+
})], N.prototype, "showSearch", void 0), n([r({
|
|
1108
|
+
type: Boolean,
|
|
1109
|
+
attribute: "show-contact",
|
|
1110
|
+
converter: p
|
|
1111
|
+
})], N.prototype, "showContact", void 0), n([r({
|
|
1112
|
+
type: Boolean,
|
|
1113
|
+
attribute: "can-change-representation",
|
|
1114
|
+
converter: p
|
|
1115
|
+
})], N.prototype, "canChangeRepresentation", void 0), n([r({
|
|
1116
|
+
type: Boolean,
|
|
1117
|
+
attribute: "has-log-out",
|
|
1118
|
+
converter: p
|
|
1119
|
+
})], N.prototype, "hasLogOut", void 0), n([r({ type: Object })], N.prototype, "user", void 0), n([r({
|
|
1120
|
+
type: Array,
|
|
1121
|
+
attribute: "user-menu"
|
|
1122
|
+
})], N.prototype, "userMenu", void 0), n([r({ type: Object })], N.prototype, "representing", void 0), n([e()], N.prototype, "openMenu", void 0), n([e()], N.prototype, "fetchedData", void 0), n([e()], N.prototype, "loadError", void 0), n([e()], N.prototype, "headerAnchor", void 0);
|
|
1123
|
+
try {
|
|
1124
|
+
a("pkt-header-global")(N);
|
|
1125
|
+
} catch {
|
|
1126
|
+
console.warn("Forsøker å definere <pkt-header-global>, men den er allerede definert");
|
|
1127
|
+
}
|
|
1128
|
+
//#endregion
|
|
1129
|
+
//#region src/components/header/header.ts
|
|
1130
|
+
var P = class extends l {
|
|
1131
|
+
constructor(...e) {
|
|
1132
|
+
super(...e), this.type = "service", this.searchPlaceholder = "Søk", this.searchValue = "", this.mobileBreakpoint = 768, this.tabletBreakpoint = 1280, this.openedMenu = "none", this.logOutButtonPlacement = "none", this.position = "fixed", this.scrollBehavior = "hide", this.slotMenuVariant = "icon-only", this.slotMenuText = "Meny", this.hideLogo = !1, this.compact = !1, this.canChangeRepresentation = !1, this.hasLogOut = !1, this.showContact = !0;
|
|
1133
|
+
}
|
|
1134
|
+
firstUpdated(e) {
|
|
1135
|
+
super.firstUpdated(e), this.emitDeprecationWarnings();
|
|
1136
|
+
}
|
|
1137
|
+
emitDeprecationWarnings() {
|
|
1138
|
+
this.userMenuFooter !== void 0 && console.warn("[PktHeader] userMenuFooter is deprecated. Use userMenu instead."), this.userOptions !== void 0 && console.warn("[PktHeader] userOptions is deprecated. Use userMenu instead.");
|
|
1139
|
+
}
|
|
1140
|
+
get effectiveUserMenu() {
|
|
1141
|
+
let e = this.userMenu || [], t = this.userMenuFooter || [], n = this.userOptions || [];
|
|
1142
|
+
return t.length || n.length ? [
|
|
1143
|
+
...e,
|
|
1144
|
+
...n,
|
|
1145
|
+
...t
|
|
1146
|
+
] : this.userMenu;
|
|
1147
|
+
}
|
|
1148
|
+
renderGlobal() {
|
|
1149
|
+
return i`
|
|
1150
|
+
<pkt-header-global
|
|
1151
|
+
data-url=${u(this.dataUrl)}
|
|
1152
|
+
locale=${u(this.locale)}
|
|
1153
|
+
logo-link=${u(this.logoLink)}
|
|
1154
|
+
logo-path=${u(this.logoPath)}
|
|
1155
|
+
search-placeholder=${u(this.hasAttribute("search-placeholder") ? this.searchPlaceholder : void 0)}
|
|
1156
|
+
mobile-breakpoint=${u(this.hasAttribute("mobile-breakpoint") ? this.mobileBreakpoint : void 0)}
|
|
1157
|
+
tablet-breakpoint=${u(this.hasAttribute("tablet-breakpoint") ? this.tabletBreakpoint : void 0)}
|
|
1158
|
+
log-out-button-placement=${this.logOutButtonPlacement}
|
|
1159
|
+
position=${this.position}
|
|
1160
|
+
scroll-behavior=${this.scrollBehavior}
|
|
1161
|
+
.data=${this.data}
|
|
1162
|
+
.showSearch=${this.showSearch ?? !0}
|
|
1163
|
+
.showContact=${this.showContact}
|
|
1164
|
+
.canChangeRepresentation=${this.canChangeRepresentation}
|
|
1165
|
+
.hasLogOut=${this.hasLogOut}
|
|
1166
|
+
.user=${this.user}
|
|
1167
|
+
.userMenu=${this.effectiveUserMenu}
|
|
1168
|
+
.representing=${this.representing}
|
|
1169
|
+
></pkt-header-global>
|
|
1170
|
+
`;
|
|
1171
|
+
}
|
|
1172
|
+
render() {
|
|
1173
|
+
return this.type === "global" ? this.renderGlobal() : i`
|
|
1174
|
+
<pkt-header-service
|
|
1175
|
+
service-name=${u(this.serviceName)}
|
|
1176
|
+
service-link=${u(this.serviceLink)}
|
|
1177
|
+
logo-link=${u(this.logoLink)}
|
|
1178
|
+
logo-path=${u(this.logoPath)}
|
|
1179
|
+
search-placeholder=${this.searchPlaceholder}
|
|
1180
|
+
search-value=${this.searchValue}
|
|
1181
|
+
mobile-breakpoint=${this.mobileBreakpoint}
|
|
1182
|
+
tablet-breakpoint=${this.tabletBreakpoint}
|
|
1183
|
+
opened-menu=${this.openedMenu}
|
|
1184
|
+
log-out-button-placement=${this.logOutButtonPlacement}
|
|
1185
|
+
position=${this.position}
|
|
1186
|
+
scroll-behavior=${this.scrollBehavior}
|
|
1187
|
+
slot-menu-variant=${this.slotMenuVariant}
|
|
1188
|
+
slot-menu-text=${this.slotMenuText}
|
|
1189
|
+
.hideLogo=${this.hideLogo}
|
|
1190
|
+
.compact=${this.compact}
|
|
1191
|
+
.showSearch=${this.showSearch ?? !1}
|
|
1192
|
+
.canChangeRepresentation=${this.canChangeRepresentation}
|
|
1193
|
+
.hasLogOut=${this.hasLogOut}
|
|
1194
|
+
.user=${this.user}
|
|
1195
|
+
.userMenu=${this.effectiveUserMenu}
|
|
1196
|
+
.representing=${this.representing}
|
|
1197
|
+
>
|
|
1198
|
+
${this.hasSlotContent() ? i`<div class="pkt-contents">${c(this)}</div>` : t}
|
|
1199
|
+
</pkt-header-service>
|
|
1200
|
+
`;
|
|
1201
|
+
}
|
|
1202
|
+
};
|
|
1203
|
+
n([r({ type: String })], P.prototype, "type", void 0), n([r({
|
|
1204
|
+
type: String,
|
|
1205
|
+
attribute: "service-name"
|
|
1206
|
+
})], P.prototype, "serviceName", void 0), n([r({
|
|
1207
|
+
type: String,
|
|
1208
|
+
attribute: "service-link"
|
|
1209
|
+
})], P.prototype, "serviceLink", void 0), n([r({
|
|
1210
|
+
type: String,
|
|
1211
|
+
attribute: "logo-link"
|
|
1212
|
+
})], P.prototype, "logoLink", void 0), n([r({
|
|
1213
|
+
type: String,
|
|
1214
|
+
attribute: "logo-path"
|
|
1215
|
+
})], P.prototype, "logoPath", void 0), n([r({
|
|
1216
|
+
type: String,
|
|
1217
|
+
attribute: "search-placeholder"
|
|
1218
|
+
})], P.prototype, "searchPlaceholder", void 0), n([r({
|
|
1219
|
+
type: String,
|
|
1220
|
+
attribute: "search-value"
|
|
1221
|
+
})], P.prototype, "searchValue", void 0), n([r({
|
|
1222
|
+
type: Number,
|
|
1223
|
+
attribute: "mobile-breakpoint"
|
|
1224
|
+
})], P.prototype, "mobileBreakpoint", void 0), n([r({
|
|
1225
|
+
type: Number,
|
|
1226
|
+
attribute: "tablet-breakpoint"
|
|
1227
|
+
})], P.prototype, "tabletBreakpoint", void 0), n([r({
|
|
1228
|
+
type: String,
|
|
1229
|
+
attribute: "opened-menu"
|
|
1230
|
+
})], P.prototype, "openedMenu", void 0), n([r({
|
|
1231
|
+
type: String,
|
|
1232
|
+
attribute: "log-out-button-placement"
|
|
1233
|
+
})], P.prototype, "logOutButtonPlacement", void 0), n([r({ type: String })], P.prototype, "position", void 0), n([r({
|
|
1234
|
+
type: String,
|
|
1235
|
+
attribute: "scroll-behavior"
|
|
1236
|
+
})], P.prototype, "scrollBehavior", void 0), n([r({
|
|
1237
|
+
type: String,
|
|
1238
|
+
attribute: "slot-menu-variant"
|
|
1239
|
+
})], P.prototype, "slotMenuVariant", void 0), n([r({
|
|
1240
|
+
type: String,
|
|
1241
|
+
attribute: "slot-menu-text"
|
|
1242
|
+
})], P.prototype, "slotMenuText", void 0), n([r({
|
|
1243
|
+
type: Boolean,
|
|
1244
|
+
attribute: "hide-logo",
|
|
1245
|
+
converter: p
|
|
1246
|
+
})], P.prototype, "hideLogo", void 0), n([r({
|
|
1247
|
+
type: Boolean,
|
|
1248
|
+
converter: p
|
|
1249
|
+
})], P.prototype, "compact", void 0), n([r({
|
|
1250
|
+
type: Boolean,
|
|
1251
|
+
attribute: "show-search",
|
|
1252
|
+
converter: p
|
|
1253
|
+
})], P.prototype, "showSearch", void 0), n([r({
|
|
1254
|
+
type: Boolean,
|
|
1255
|
+
attribute: "can-change-representation",
|
|
1256
|
+
converter: p
|
|
1257
|
+
})], P.prototype, "canChangeRepresentation", void 0), n([r({
|
|
1258
|
+
type: Boolean,
|
|
1259
|
+
attribute: "has-log-out",
|
|
1260
|
+
converter: p
|
|
1261
|
+
})], P.prototype, "hasLogOut", void 0), n([r({ type: Object })], P.prototype, "user", void 0), n([r({
|
|
1262
|
+
type: Array,
|
|
1263
|
+
attribute: "user-menu"
|
|
1264
|
+
})], P.prototype, "userMenu", void 0), n([r({ type: Object })], P.prototype, "representing", void 0), n([r({
|
|
1265
|
+
type: String,
|
|
1266
|
+
attribute: "data-url"
|
|
1267
|
+
})], P.prototype, "dataUrl", void 0), n([r({
|
|
1268
|
+
type: Object,
|
|
1269
|
+
attribute: !1
|
|
1270
|
+
})], P.prototype, "data", void 0), n([r({ type: String })], P.prototype, "locale", void 0), n([r({
|
|
1271
|
+
type: Boolean,
|
|
1272
|
+
attribute: "show-contact",
|
|
1273
|
+
converter: p
|
|
1274
|
+
})], P.prototype, "showContact", void 0), n([r({
|
|
1275
|
+
type: Array,
|
|
1276
|
+
attribute: "user-menu-footer"
|
|
1277
|
+
})], P.prototype, "userMenuFooter", void 0), n([r({
|
|
1278
|
+
type: Array,
|
|
1279
|
+
attribute: "user-options"
|
|
1280
|
+
})], P.prototype, "userOptions", void 0);
|
|
1281
|
+
try {
|
|
1282
|
+
a("pkt-header")(P);
|
|
1283
|
+
} catch {
|
|
1284
|
+
console.warn("Forsøker å definere <pkt-header>, men den er allerede definert");
|
|
1285
|
+
}
|
|
1286
|
+
//#endregion
|
|
1287
|
+
export { C as a, T as i, N as n, D as r, P as t };
|