@oslokommune/punkt-elements 16.7.3 → 16.7.7
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 +35 -0
- package/dist/accordion-BB1JrONI.cjs +34 -0
- package/dist/accordion-nNH87Y60.js +130 -0
- package/dist/alert-BEEnTiCb.cjs +33 -0
- package/dist/alert-ePJuDtmm.js +171 -0
- package/dist/async-directive-B9P1Qa0k.cjs +1 -0
- package/dist/async-directive-CaQiqjyV.js +55 -0
- package/dist/backlink-Ba03LlbB.cjs +13 -0
- package/dist/backlink-CiwXrQYD.js +38 -0
- package/dist/booleanish-BmcOU-43.js +11 -0
- package/dist/booleanish-jJLlnr6-.cjs +1 -0
- package/dist/breadcrumbs-CD1zib3s.cjs +43 -0
- package/dist/breadcrumbs-CpuVqWhF.js +76 -0
- package/dist/button-BIpd1xJh.js +95 -0
- package/dist/button-D-TOBaJB.cjs +27 -0
- package/dist/calendar-BzEtOJla.js +2031 -0
- package/dist/calendar-E5jJLt8D.cjs +90 -0
- package/dist/card-BYJu1MYm.js +339 -0
- package/dist/card-CUFhMVim.cjs +87 -0
- package/dist/checkbox-BARDb9iV.cjs +31 -0
- package/dist/checkbox-Cspxcvt_.js +111 -0
- package/dist/class-map-C8HuhNzZ.js +27 -0
- package/dist/class-map-CJ-msbHs.cjs +1 -0
- package/dist/classutils-DEL164Ur.js +7 -0
- package/dist/classutils-z8YsPlOf.cjs +1 -0
- package/dist/combobox-BcdLZRDU.js +984 -0
- package/dist/combobox-CGbFTWq_.cjs +135 -0
- package/dist/consent-DeB_5sWH.js +197 -0
- package/dist/consent-hwu7pp3S.cjs +11 -0
- package/dist/datepicker-DpmlsnH_.cjs +273 -0
- package/dist/datepicker-OVd8pmnZ.js +1125 -0
- package/dist/dialog-polyfill.esm-1hPr0gl9.js +280 -0
- package/dist/dialog-polyfill.esm-D3Oinvk0.cjs +1 -0
- package/dist/directive-3THFsVew.js +28 -0
- package/dist/directive-CJ2giQBZ.cjs +1 -0
- package/dist/directive-helpers-D1QSxY17.cjs +1 -0
- package/dist/directive-helpers-Dkv2gKgs.js +25 -0
- package/dist/element-DjtxO-1r.cjs +2 -0
- package/dist/element-cZ85T_aa.js +693 -0
- package/dist/element-with-slot-4J2o3SeU.js +166 -0
- package/dist/element-with-slot-CWoTGA1B.cjs +1 -0
- package/dist/header-DWgPgGfS.cjs +304 -0
- package/dist/header-a6ztVNp3.js +782 -0
- package/dist/heading-BgSWIRii.cjs +1 -0
- package/dist/heading-DiQLPxdf.js +73 -0
- package/dist/helptext-CCBKKLus.js +65 -0
- package/dist/helptext-D-3QfZv5.cjs +24 -0
- package/dist/icon-Co72KtgF.js +86 -0
- package/dist/icon-Dr8sfT2X.cjs +1 -0
- package/dist/if-defined-Cjj8qN-Z.js +5 -0
- package/dist/if-defined-XKOD_t_V.cjs +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/input-element-B1yxcfz4.cjs +1 -0
- package/dist/input-element-Bw1s6NlF.js +643 -0
- package/dist/input-wrapper-BRuVELpK.cjs +54 -0
- package/dist/input-wrapper-CDyHTR1V.js +164 -0
- package/dist/input-wrapper-Dwd-_sKm.cjs +1 -0
- package/dist/input-wrapper-YfTmpSSY.js +117 -0
- package/dist/link-CKAFMz9j.js +89 -0
- package/dist/link-CyTCpI0k.cjs +7 -0
- package/dist/linkcard-B0KOGaGj.js +55 -0
- package/dist/linkcard-BE4-FewK.cjs +13 -0
- package/dist/listbox-DCA2JoPV.cjs +106 -0
- package/dist/listbox-DuBgTFvH.js +397 -0
- package/dist/loader-6kFZUErT.js +66 -0
- package/dist/loader-CX2rsC01.cjs +16 -0
- package/dist/messagebox-Cwlg5sOr.js +110 -0
- package/dist/messagebox-Din9X53b.cjs +13 -0
- package/dist/modal-C_wtsh9m.js +209 -0
- package/dist/modal-DS_wUOIv.cjs +36 -0
- package/dist/pkt-accordion.cjs +1 -1
- package/dist/pkt-accordion.js +2 -7
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +2 -5
- package/dist/pkt-backlink.cjs +1 -1
- package/dist/pkt-backlink.js +2 -5
- package/dist/pkt-breadcrumbs.cjs +1 -43
- package/dist/pkt-breadcrumbs.js +2 -81
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +2 -5
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +2 -5
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +2 -5
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +2 -5
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +2 -5
- package/dist/pkt-consent.cjs +1 -1
- package/dist/pkt-consent.js +2 -5
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +5 -9
- package/dist/pkt-header.cjs +1 -304
- package/dist/pkt-header.js +2 -861
- package/dist/pkt-heading.cjs +1 -1
- package/dist/pkt-heading.js +2 -5
- package/dist/pkt-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +2 -5
- package/dist/pkt-icon.cjs +1 -1
- package/dist/pkt-icon.js +2 -5
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +30 -66
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +2 -5
- package/dist/pkt-link.cjs +1 -1
- package/dist/pkt-link.js +2 -5
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +2 -5
- package/dist/pkt-listbox.cjs +1 -1
- package/dist/pkt-listbox.js +2 -5
- package/dist/pkt-loader.cjs +1 -1
- package/dist/pkt-loader.js +2 -5
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +2 -5
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +2 -5
- package/dist/pkt-options-controller-CRrI6WMk.js +43 -0
- package/dist/pkt-options-controller-CXUGx134.cjs +1 -0
- package/dist/pkt-progressbar.cjs +1 -1
- package/dist/pkt-progressbar.js +2 -5
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +2 -5
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +2 -5
- package/dist/pkt-tabs.cjs +1 -1
- package/dist/pkt-tabs.js +2 -7
- package/dist/pkt-tag.cjs +1 -1
- package/dist/pkt-tag.js +2 -5
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +2 -5
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +2 -5
- package/dist/pkt-timepicker.cjs +1 -191
- package/dist/pkt-timepicker.js +2 -560
- package/dist/progressbar-CdXtmOBb.cjs +17 -0
- package/dist/progressbar-Dy9AiYQz.js +113 -0
- package/dist/radiobutton-GOnpUbCW.cjs +31 -0
- package/dist/radiobutton-V_KPbup_.js +84 -0
- package/dist/ref-BaJ0mBT_.cjs +1 -0
- package/dist/ref-RS8Uv6uC.js +30 -0
- package/dist/repeat-Cepr3469.js +57 -0
- package/dist/repeat-CqcDYBxr.cjs +1 -0
- package/dist/select-BSAFd8Wa.js +164 -0
- package/dist/select-C2i8sOk5.cjs +49 -0
- package/dist/tabs-D8nL9rWx.cjs +37 -0
- package/dist/tabs-Y7utmJi9.js +318 -0
- package/dist/tag-DLthw5b4.cjs +27 -0
- package/dist/tag-VwykmuQR.js +179 -0
- package/dist/textarea-D7aGOyDf.cjs +46 -0
- package/dist/textarea-DYOBhJrN.js +115 -0
- package/dist/textinput-BUgntXnM.js +124 -0
- package/dist/textinput-DFh8_9cx.cjs +70 -0
- package/dist/timepicker-BIfE7KKJ.cjs +191 -0
- package/dist/timepicker-DaSwn1FA.js +503 -0
- package/dist/utils-CUqCKGvp.js +7 -0
- package/dist/utils-CjAbIttF.cjs +1 -0
- package/package.json +6 -6
- package/src/components/alert/alert.test.ts +1 -1
- package/src/components/alert/alert.ts +6 -6
- package/src/components/datepicker/datepicker-utils.test.ts +16 -23
- package/dist/accordionitem-_9AiCIvd.cjs +0 -34
- package/dist/accordionitem-dCfSrxh5.js +0 -140
- package/dist/alert-BtOk8yRH.cjs +0 -33
- package/dist/alert-DlY2_grU.js +0 -117
- package/dist/async-directive-CMzWMlZ5.js +0 -65
- package/dist/async-directive-DoMuclel.cjs +0 -5
- package/dist/backlink-Ce5Vldop.js +0 -49
- package/dist/backlink-y3dwjKPC.cjs +0 -13
- package/dist/booleanish-BKVonob4.cjs +0 -1
- package/dist/booleanish-C9R0tdXH.js +0 -11
- package/dist/button-B_TXwNzt.cjs +0 -27
- package/dist/button-BiY-wlKF.js +0 -139
- package/dist/calendar-B2pji2zn.cjs +0 -90
- package/dist/calendar-DhjQDC4C.js +0 -2140
- package/dist/card-BwMNB5Bb.cjs +0 -87
- package/dist/card-CGlmcMSR.js +0 -233
- package/dist/checkbox-BsJZYA26.js +0 -147
- package/dist/checkbox-CTY8f_qn.cjs +0 -31
- package/dist/class-map-CEnykyO_.js +0 -34
- package/dist/class-map-CsENJXf1.cjs +0 -5
- package/dist/classutils-BwNK82ZQ.cjs +0 -1
- package/dist/classutils-RQs1k6D9.js +0 -7
- package/dist/combobox-DSB5WOxg.js +0 -815
- package/dist/combobox-DbICIgKG.cjs +0 -135
- package/dist/consent-DkOQpbsg.cjs +0 -11
- package/dist/consent-SNWV_mMU.js +0 -175
- package/dist/datepicker-BEWl9iz3.cjs +0 -273
- package/dist/datepicker-euHyzXnb.js +0 -1170
- package/dist/dialog-polyfill.esm-CPKZe7AL.cjs +0 -1
- package/dist/dialog-polyfill.esm-CbjBMXAG.js +0 -395
- package/dist/directive-C7oCP5Bh.cjs +0 -5
- package/dist/directive-helpers-BP2WOx60.cjs +0 -5
- package/dist/directive-helpers-rm-28gIj.js +0 -38
- package/dist/directive-oAbCiebi.js +0 -27
- package/dist/element-CPpT3rFQ.js +0 -638
- package/dist/element-gR_VtSiD.cjs +0 -27
- package/dist/element-with-slot-Dqk6-TRR.js +0 -240
- package/dist/element-with-slot-ZX-up7jO.cjs +0 -1
- package/dist/heading-D2tVS6lS.js +0 -103
- package/dist/heading-DrzbgDb6.cjs +0 -1
- package/dist/helptext-BKtU4mas.js +0 -82
- package/dist/helptext-DcRC7wW2.cjs +0 -24
- package/dist/icon-CxQcIa5F.js +0 -105
- package/dist/icon-q81vqPK_.cjs +0 -9
- package/dist/if-defined-B0krMLad.js +0 -10
- package/dist/if-defined-BOW3ODSj.cjs +0 -5
- package/dist/input-element-8nLwuQS4.js +0 -837
- package/dist/input-element-DdVhUvva.cjs +0 -1
- package/dist/input-wrapper-Bs4CRNst.js +0 -181
- package/dist/input-wrapper-Bv9aqqVq.cjs +0 -54
- package/dist/input-wrapper-CDgenrYA.js +0 -6
- package/dist/input-wrapper-EoSAbU-U.cjs +0 -1
- package/dist/link-C0rl-86s.cjs +0 -7
- package/dist/link-Cdqgl60z.js +0 -55
- package/dist/linkcard-Dimu7Rlx.cjs +0 -13
- package/dist/linkcard-Lbq_UhjZ.js +0 -56
- package/dist/listbox-Bia4_tvN.js +0 -440
- package/dist/listbox-La2GZQei.cjs +0 -106
- package/dist/loader-D1ugDXGV.cjs +0 -16
- package/dist/loader-DyN6RGC5.js +0 -95
- package/dist/messagebox-BGMVm2t9.js +0 -71
- package/dist/messagebox-M0yIgCz9.cjs +0 -13
- package/dist/modal-CMO1RtIi.cjs +0 -36
- package/dist/modal-DjPQDE-Z.js +0 -156
- package/dist/pkt-options-controller-5LXbEzuk.cjs +0 -1
- package/dist/pkt-options-controller-B5YalfCb.js +0 -39
- package/dist/progressbar-BqlMzkM_.cjs +0 -21
- package/dist/progressbar-sbHDFC12.js +0 -162
- package/dist/radiobutton-5ZqVVtTT.cjs +0 -31
- package/dist/radiobutton-D8Ai8ETa.js +0 -113
- package/dist/ref-Bg_Swj5w.js +0 -42
- package/dist/ref-CL-Xk9Xm.cjs +0 -5
- package/dist/repeat-BD8TKgJb.js +0 -61
- package/dist/repeat-Cfq8CDlf.cjs +0 -5
- package/dist/select-De-n8on9.js +0 -230
- package/dist/select-dTWibR6_.cjs +0 -49
- package/dist/state-C_1EOo3D.js +0 -12
- package/dist/state-Dg-53wQ8.cjs +0 -5
- package/dist/tabitem-B9-jeV97.js +0 -334
- package/dist/tabitem-BnhzqfW3.cjs +0 -65
- package/dist/tag-CbwO8yvD.cjs +0 -27
- package/dist/tag-D4FI5t3y.js +0 -117
- package/dist/textarea-BmLaKzsc.cjs +0 -50
- package/dist/textarea-CMiSJaYL.js +0 -133
- package/dist/textinput-em9y4yrL.cjs +0 -70
- package/dist/textinput-r8udK0IX.js +0 -152
- package/dist/utils-DznhwRXm.js +0 -8
- package/dist/utils-byXsEz1u.cjs +0 -1
|
@@ -0,0 +1,782 @@
|
|
|
1
|
+
import { c as e, d as t, l as n, o as r, r as i, s as a, t as o } from "./element-cZ85T_aa.js";
|
|
2
|
+
import { t as s } from "./class-map-C8HuhNzZ.js";
|
|
3
|
+
import { n as c, t as l } from "./element-with-slot-4J2o3SeU.js";
|
|
4
|
+
import "./icon-Co72KtgF.js";
|
|
5
|
+
import { t as u } from "./if-defined-Cjj8qN-Z.js";
|
|
6
|
+
import "./button-BIpd1xJh.js";
|
|
7
|
+
import { n as d, t as f } from "./ref-RS8Uv6uC.js";
|
|
8
|
+
import { t as p } from "./booleanish-BmcOU-43.js";
|
|
9
|
+
import "./link-CKAFMz9j.js";
|
|
10
|
+
import "./textinput-BUgntXnM.js";
|
|
11
|
+
//#region ../../shared-types/header.ts
|
|
12
|
+
var m = (e) => typeof e.target == "string" ? {
|
|
13
|
+
title: e.title,
|
|
14
|
+
iconName: e.iconName,
|
|
15
|
+
href: e.target
|
|
16
|
+
} : {
|
|
17
|
+
title: e.title,
|
|
18
|
+
iconName: e.iconName,
|
|
19
|
+
onClick: e.target
|
|
20
|
+
}, h = (e) => m(e), g = (e) => {
|
|
21
|
+
if (!e) return;
|
|
22
|
+
let t = typeof e == "string" ? new Date(e) : e;
|
|
23
|
+
if (!isNaN(t.getTime())) return t.toLocaleDateString("nb-NO", {
|
|
24
|
+
day: "numeric",
|
|
25
|
+
month: "long",
|
|
26
|
+
year: "numeric",
|
|
27
|
+
hour: "2-digit",
|
|
28
|
+
minute: "2-digit"
|
|
29
|
+
});
|
|
30
|
+
}, _ = class extends o {
|
|
31
|
+
constructor(...e) {
|
|
32
|
+
super(...e), this.canChangeRepresentation = !1, this.logoutOnClick = !1;
|
|
33
|
+
}
|
|
34
|
+
handleChangeRepresentation() {
|
|
35
|
+
this.dispatchEvent(new CustomEvent("change-representation", {
|
|
36
|
+
bubbles: !0,
|
|
37
|
+
composed: !0
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
handleLogout() {
|
|
41
|
+
this.dispatchEvent(new CustomEvent("log-out", {
|
|
42
|
+
bubbles: !0,
|
|
43
|
+
composed: !0
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
handleMenuItemClick(e) {
|
|
47
|
+
"onClick" in e && typeof e.onClick == "function" && e.onClick();
|
|
48
|
+
}
|
|
49
|
+
renderLinkOrButton(e, r) {
|
|
50
|
+
let i = "href" in e, a = s({
|
|
51
|
+
"pkt-user-menu__link": !0,
|
|
52
|
+
"pkt-link-button": !i,
|
|
53
|
+
"pkt-link": !i,
|
|
54
|
+
"pkt-link--icon-left": !i,
|
|
55
|
+
[r || ""]: !!r
|
|
56
|
+
});
|
|
57
|
+
return i ? t`
|
|
58
|
+
<pkt-link
|
|
59
|
+
icon-name=${e.iconName || n}
|
|
60
|
+
href=${e.href}
|
|
61
|
+
aria-hidden="true"
|
|
62
|
+
class="pkt-user-menu__link ${r || ""}"
|
|
63
|
+
>
|
|
64
|
+
${e.title}
|
|
65
|
+
</pkt-link>
|
|
66
|
+
` : t`
|
|
67
|
+
<button class=${a} type="button" @click=${() => this.handleMenuItemClick(e)}>
|
|
68
|
+
${e.iconName ? t`<pkt-icon
|
|
69
|
+
name=${e.iconName}
|
|
70
|
+
class="pkt-link__icon"
|
|
71
|
+
aria-hidden="true"
|
|
72
|
+
></pkt-icon>` : n}
|
|
73
|
+
${e.title}
|
|
74
|
+
</button>
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
renderLinkSection(e) {
|
|
78
|
+
return t`
|
|
79
|
+
<ul class="pkt-user-menu__sublist">
|
|
80
|
+
${e.map((e) => t`
|
|
81
|
+
<li class="pkt-user-menu__subitem">${this.renderLinkOrButton(e)}</li>
|
|
82
|
+
`)}
|
|
83
|
+
</ul>
|
|
84
|
+
`;
|
|
85
|
+
}
|
|
86
|
+
render() {
|
|
87
|
+
let e = this.userMenu?.map(h);
|
|
88
|
+
return t`
|
|
89
|
+
<nav class="pkt-user-menu" aria-label="Meny for innlogget bruker">
|
|
90
|
+
<ul class="pkt-user-menu__list">
|
|
91
|
+
<!-- User section -->
|
|
92
|
+
${this.user ? t`
|
|
93
|
+
<li class="pkt-user-menu__item">
|
|
94
|
+
<div class="pkt-user-menu__label">Pålogget som</div>
|
|
95
|
+
<div class="pkt-user-menu__name" translate="no">${this.user.name}</div>
|
|
96
|
+
${this.formattedLastLoggedIn ? t`
|
|
97
|
+
<div class="pkt-user-menu__last-logged-in">
|
|
98
|
+
Sist pålogget: <time>${this.formattedLastLoggedIn}</time>
|
|
99
|
+
</div>
|
|
100
|
+
` : n}
|
|
101
|
+
</li>
|
|
102
|
+
` : n}
|
|
103
|
+
|
|
104
|
+
<!-- User menu items -->
|
|
105
|
+
${e && e.length > 0 ? t`
|
|
106
|
+
<li class="pkt-user-menu__item">${this.renderLinkSection(e)}</li>
|
|
107
|
+
` : n}
|
|
108
|
+
|
|
109
|
+
<!-- Representing section -->
|
|
110
|
+
${this.representing ? t`
|
|
111
|
+
<li class="pkt-user-menu__item">
|
|
112
|
+
<div class="pkt-user-menu__label">Representerer</div>
|
|
113
|
+
<div class="pkt-user-menu__name" translate="no">${this.representing.name}</div>
|
|
114
|
+
${this.representing.orgNumber ? t`<div class="pkt-user-menu__org-number">
|
|
115
|
+
Org.nr. ${this.representing.orgNumber}
|
|
116
|
+
</div>` : n}
|
|
117
|
+
${this.canChangeRepresentation ? t`
|
|
118
|
+
<ul class="pkt-user-menu__sublist mt-size-16">
|
|
119
|
+
<li class="pkt-user-menu__subitem">
|
|
120
|
+
${this.renderLinkOrButton({
|
|
121
|
+
title: "Endre organisasjon",
|
|
122
|
+
iconName: "cogwheel",
|
|
123
|
+
onClick: () => this.handleChangeRepresentation()
|
|
124
|
+
})}
|
|
125
|
+
</li>
|
|
126
|
+
</ul>
|
|
127
|
+
` : n}
|
|
128
|
+
</li>
|
|
129
|
+
` : n}
|
|
130
|
+
|
|
131
|
+
<!-- Change representation without representing object -->
|
|
132
|
+
${!this.representing && this.canChangeRepresentation ? t`
|
|
133
|
+
<li class="pkt-user-menu__item">
|
|
134
|
+
<ul class="pkt-user-menu__sublist">
|
|
135
|
+
<li class="pkt-user-menu__subitem">
|
|
136
|
+
${this.renderLinkOrButton({
|
|
137
|
+
title: "Endre organisasjon",
|
|
138
|
+
iconName: "cogwheel",
|
|
139
|
+
onClick: () => this.handleChangeRepresentation()
|
|
140
|
+
})}
|
|
141
|
+
</li>
|
|
142
|
+
</ul>
|
|
143
|
+
</li>
|
|
144
|
+
` : n}
|
|
145
|
+
|
|
146
|
+
<!-- Logout -->
|
|
147
|
+
${this.logoutOnClick ? t`
|
|
148
|
+
<li class="pkt-user-menu__item">
|
|
149
|
+
${this.renderLinkOrButton({
|
|
150
|
+
title: "Logg ut",
|
|
151
|
+
iconName: "exit",
|
|
152
|
+
onClick: () => this.handleLogout()
|
|
153
|
+
})}
|
|
154
|
+
</li>
|
|
155
|
+
` : n}
|
|
156
|
+
</ul>
|
|
157
|
+
</nav>
|
|
158
|
+
`;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
i([a({ type: Object })], _.prototype, "user", void 0), i([a({
|
|
162
|
+
type: String,
|
|
163
|
+
attribute: "formatted-last-logged-in"
|
|
164
|
+
})], _.prototype, "formattedLastLoggedIn", void 0), i([a({ type: Object })], _.prototype, "representing", void 0), i([a({
|
|
165
|
+
type: Array,
|
|
166
|
+
attribute: "user-menu"
|
|
167
|
+
})], _.prototype, "userMenu", void 0), i([a({
|
|
168
|
+
type: Boolean,
|
|
169
|
+
attribute: "can-change-representation",
|
|
170
|
+
converter: p
|
|
171
|
+
})], _.prototype, "canChangeRepresentation", void 0), i([a({
|
|
172
|
+
type: Boolean,
|
|
173
|
+
attribute: "logout-on-click",
|
|
174
|
+
converter: p
|
|
175
|
+
})], _.prototype, "logoutOnClick", void 0);
|
|
176
|
+
try {
|
|
177
|
+
e("pkt-header-user-menu")(_);
|
|
178
|
+
} catch {
|
|
179
|
+
console.warn("Forsøker å definere <pkt-header-user-menu>, men den er allerede definert");
|
|
180
|
+
}
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/components/header/header-service.ts
|
|
183
|
+
var v = "https://punkt-cdn.oslo.kommune.no/latest/logos/", y = class extends l {
|
|
184
|
+
constructor(...e) {
|
|
185
|
+
super(...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.isMobile = !1, this.isTablet = !1, this.openMenu = "none", this.isHidden = !1, this.componentWidth = typeof window < "u" ? window.innerWidth : 0, 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.lastScrollPosition = 0, this.savedScrollY = 0, this.lastFocusedElement = null, this.shouldRestoreFocus = !1, this.handleScroll = () => {
|
|
186
|
+
if (!this.shouldHideOnScroll) return;
|
|
187
|
+
let e = window.pageYOffset || document.documentElement.scrollTop;
|
|
188
|
+
e < 0 || Math.abs(e - this.lastScrollPosition) < 60 || (this.isHidden = e > this.lastScrollPosition, this.lastScrollPosition = e);
|
|
189
|
+
}, this.handleClickOutside = (e) => {
|
|
190
|
+
let t = e.target;
|
|
191
|
+
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");
|
|
192
|
+
}, this.handleFocusOut = (e, t) => {
|
|
193
|
+
let n = e.relatedTarget, r;
|
|
194
|
+
switch (t) {
|
|
195
|
+
case "user":
|
|
196
|
+
r = this.userContainerRef;
|
|
197
|
+
break;
|
|
198
|
+
case "slot":
|
|
199
|
+
r = this.slotContainerRef;
|
|
200
|
+
break;
|
|
201
|
+
case "search":
|
|
202
|
+
r = this.searchContainerRef;
|
|
203
|
+
break;
|
|
204
|
+
default: return;
|
|
205
|
+
}
|
|
206
|
+
let i = r.value;
|
|
207
|
+
i && (!n || !i.contains(n)) && (this.openMenu = "none");
|
|
208
|
+
}, this.handleEscapeKey = (e) => {
|
|
209
|
+
e.key === "Escape" && this.openMenu !== "none" && (e.preventDefault(), this.shouldRestoreFocus = !0, this.openMenu = "none");
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
connectedCallback() {
|
|
213
|
+
super.connectedCallback(), this.setupScrollListener();
|
|
214
|
+
}
|
|
215
|
+
disconnectedCallback() {
|
|
216
|
+
super.disconnectedCallback(), this.resizeObserver?.disconnect(), window.removeEventListener("scroll", this.handleScroll), this.unlockScroll();
|
|
217
|
+
}
|
|
218
|
+
firstUpdated() {
|
|
219
|
+
this.setupResizeObserver();
|
|
220
|
+
}
|
|
221
|
+
updated(e) {
|
|
222
|
+
if (super.updated(e), e.has("openedMenu") && this.openedMenu !== this.openMenu && (this.openMenu = this.openedMenu), (e.has("mobileBreakpoint") || e.has("tabletBreakpoint")) && (this.updateIsMobile(), this.updateIsTablet()), e.has("openMenu")) {
|
|
223
|
+
let t = e.get("openMenu");
|
|
224
|
+
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(() => {
|
|
225
|
+
this.checkDropdownAlignment(this.openMenu);
|
|
226
|
+
})) : this.openMenu === "none" && t !== "none" && (document.removeEventListener("mousedown", this.handleClickOutside), document.removeEventListener("keydown", this.handleEscapeKey), this.restoreFocus());
|
|
227
|
+
}
|
|
228
|
+
(e.has("openMenu") || e.has("isMobile")) && this.updateScrollLock();
|
|
229
|
+
}
|
|
230
|
+
setupResizeObserver() {
|
|
231
|
+
let e = this.headerRef.value;
|
|
232
|
+
e && (this.componentWidth = e.offsetWidth, this.updateIsMobile(), this.updateIsTablet(), this.resizeObserver = new ResizeObserver((e) => {
|
|
233
|
+
for (let t of e) t.borderBoxSize && t.borderBoxSize.length > 0 ? this.componentWidth = t.borderBoxSize[0].inlineSize : this.componentWidth = t.contentRect.width, this.updateIsMobile(), this.updateIsTablet();
|
|
234
|
+
}), this.resizeObserver.observe(e));
|
|
235
|
+
}
|
|
236
|
+
updateIsMobile() {
|
|
237
|
+
this.isMobile = this.componentWidth < this.mobileBreakpoint;
|
|
238
|
+
}
|
|
239
|
+
updateIsTablet() {
|
|
240
|
+
this.isTablet = this.componentWidth < this.tabletBreakpoint;
|
|
241
|
+
}
|
|
242
|
+
updateScrollLock() {
|
|
243
|
+
this.position === "fixed" && this.isMobile && this.openMenu !== "none" ? this.lockScroll() : this.unlockScroll();
|
|
244
|
+
}
|
|
245
|
+
lockScroll() {
|
|
246
|
+
let e = document.body, t = document.documentElement;
|
|
247
|
+
this.savedScrollY = window.scrollY || window.pageYOffset;
|
|
248
|
+
let n = window.innerWidth - t.clientWidth;
|
|
249
|
+
n > 0 && (e.style.paddingRight = `${n}px`), e.style.position = "fixed", e.style.top = `-${this.savedScrollY}px`, e.style.left = "0", e.style.right = "0", e.style.width = "100%", e.style.overflow = "hidden", t.classList.add("is-scroll-locked");
|
|
250
|
+
}
|
|
251
|
+
unlockScroll() {
|
|
252
|
+
let e = document.body, t = document.documentElement;
|
|
253
|
+
t.classList.contains("is-scroll-locked") && (e.style.removeProperty("position"), e.style.removeProperty("top"), e.style.removeProperty("left"), e.style.removeProperty("right"), e.style.removeProperty("width"), e.style.removeProperty("overflow"), e.style.removeProperty("padding-right"), t.classList.remove("is-scroll-locked"), window.scrollTo({ top: this.savedScrollY }));
|
|
254
|
+
}
|
|
255
|
+
setupScrollListener() {
|
|
256
|
+
window.addEventListener("scroll", this.handleScroll);
|
|
257
|
+
}
|
|
258
|
+
restoreFocus() {
|
|
259
|
+
this.shouldRestoreFocus && this.lastFocusedElement && document.contains(this.lastFocusedElement) && this.lastFocusedElement.focus(), this.lastFocusedElement = null, this.shouldRestoreFocus = !1;
|
|
260
|
+
}
|
|
261
|
+
checkDropdownAlignment(e) {
|
|
262
|
+
let t = e === "slot" ? this.slotContainerRef : this.searchContainerRef, n = e === "slot" ? this.slotContentRef : this.searchMenuRef;
|
|
263
|
+
if (!t.value || !n.value || !this.isTablet || this.isMobile) return;
|
|
264
|
+
let r = t.value.getBoundingClientRect(), i = n.value.offsetWidth, a = r.left + i > window.innerWidth;
|
|
265
|
+
e === "slot" ? this.alignSlotRight = a : this.alignSearchRight = a;
|
|
266
|
+
}
|
|
267
|
+
handleMenuToggle(e) {
|
|
268
|
+
this.openMenu === "none" ? (this.lastFocusedElement = document.activeElement, this.openMenu = e) : this.openMenu = "none";
|
|
269
|
+
}
|
|
270
|
+
handleLogoClick(e) {
|
|
271
|
+
this.dispatchEvent(new CustomEvent("logo-click", {
|
|
272
|
+
bubbles: !0,
|
|
273
|
+
composed: !0,
|
|
274
|
+
detail: { originalEvent: e }
|
|
275
|
+
}));
|
|
276
|
+
}
|
|
277
|
+
handleServiceClick(e) {
|
|
278
|
+
this.dispatchEvent(new CustomEvent("service-click", {
|
|
279
|
+
bubbles: !0,
|
|
280
|
+
composed: !0,
|
|
281
|
+
detail: { originalEvent: e }
|
|
282
|
+
}));
|
|
283
|
+
}
|
|
284
|
+
handleLogout() {
|
|
285
|
+
this.dispatchEvent(new CustomEvent("log-out", {
|
|
286
|
+
bubbles: !0,
|
|
287
|
+
composed: !0
|
|
288
|
+
}));
|
|
289
|
+
}
|
|
290
|
+
handleSearch(e) {
|
|
291
|
+
this.dispatchEvent(new CustomEvent("search", {
|
|
292
|
+
detail: { query: e },
|
|
293
|
+
bubbles: !0,
|
|
294
|
+
composed: !0
|
|
295
|
+
}));
|
|
296
|
+
}
|
|
297
|
+
handleSearchChange(e) {
|
|
298
|
+
this.dispatchEvent(new CustomEvent("search-change", {
|
|
299
|
+
detail: { query: e },
|
|
300
|
+
bubbles: !0,
|
|
301
|
+
composed: !0
|
|
302
|
+
}));
|
|
303
|
+
}
|
|
304
|
+
handleSearchInputChange(e) {
|
|
305
|
+
let t = e.target.value;
|
|
306
|
+
this.handleSearchChange(t);
|
|
307
|
+
}
|
|
308
|
+
handleSearchKeyDown(e) {
|
|
309
|
+
e.key === "Enter" && this.handleSearch(e.target.value);
|
|
310
|
+
}
|
|
311
|
+
get formattedLastLoggedIn() {
|
|
312
|
+
return g(this.user?.lastLoggedIn);
|
|
313
|
+
}
|
|
314
|
+
get isFixed() {
|
|
315
|
+
return this.position === "fixed";
|
|
316
|
+
}
|
|
317
|
+
get shouldHideOnScroll() {
|
|
318
|
+
return this.scrollBehavior === "hide";
|
|
319
|
+
}
|
|
320
|
+
get showLogoutInHeader() {
|
|
321
|
+
return this.hasLogOut && (this.logOutButtonPlacement === "header" || this.logOutButtonPlacement === "both");
|
|
322
|
+
}
|
|
323
|
+
get showLogoutInUserMenu() {
|
|
324
|
+
return this.hasLogOut && (this.logOutButtonPlacement === "userMenu" || this.logOutButtonPlacement === "both");
|
|
325
|
+
}
|
|
326
|
+
renderLogo() {
|
|
327
|
+
if (this.hideLogo) return n;
|
|
328
|
+
let e = t`
|
|
329
|
+
<pkt-icon name="oslologo" aria-hidden="true" path=${v}></pkt-icon>
|
|
330
|
+
`;
|
|
331
|
+
return this.logoLink && typeof this.logoLink == "string" ? t`
|
|
332
|
+
<span class="pkt-header-service__logo">
|
|
333
|
+
<a href=${this.logoLink} aria-label="Tilbake til forside" @click=${this.handleLogoClick}>
|
|
334
|
+
${e}
|
|
335
|
+
</a>
|
|
336
|
+
</span>
|
|
337
|
+
` : this.hasAttribute("logo-link") ? t`
|
|
338
|
+
<span class="pkt-header-service__logo">
|
|
339
|
+
<button
|
|
340
|
+
aria-label="Tilbake til forside"
|
|
341
|
+
class="pkt-link-button pkt-link pkt-header-service__logo-link"
|
|
342
|
+
@click=${this.handleLogoClick}
|
|
343
|
+
>
|
|
344
|
+
${e}
|
|
345
|
+
</button>
|
|
346
|
+
</span>
|
|
347
|
+
` : t`
|
|
348
|
+
<span class="pkt-header-service__logo" @click=${this.handleLogoClick}>${e}</span>
|
|
349
|
+
`;
|
|
350
|
+
}
|
|
351
|
+
renderServiceName() {
|
|
352
|
+
return this.serviceName ? this.serviceLink && typeof this.serviceLink == "string" ? t`
|
|
353
|
+
<span class="pkt-header-service__service-name">
|
|
354
|
+
<pkt-link
|
|
355
|
+
href=${this.serviceLink}
|
|
356
|
+
class="pkt-header-service__service-link"
|
|
357
|
+
@click=${this.handleServiceClick}
|
|
358
|
+
>
|
|
359
|
+
${this.serviceName}
|
|
360
|
+
</pkt-link>
|
|
361
|
+
</span>
|
|
362
|
+
` : this.hasAttribute("service-link") ? t`
|
|
363
|
+
<span class="pkt-header-service__service-name">
|
|
364
|
+
<button
|
|
365
|
+
class="pkt-link-button pkt-link pkt-header-service__service-link"
|
|
366
|
+
@click=${this.handleServiceClick}
|
|
367
|
+
>
|
|
368
|
+
${this.serviceName}
|
|
369
|
+
</button>
|
|
370
|
+
</span>
|
|
371
|
+
` : t`
|
|
372
|
+
<span class="pkt-header-service__service-name" @click=${this.handleServiceClick}>
|
|
373
|
+
<span class="pkt-header-service__service-link">${this.serviceName}</span>
|
|
374
|
+
</span>
|
|
375
|
+
` : n;
|
|
376
|
+
}
|
|
377
|
+
renderSlotContainer() {
|
|
378
|
+
if (!this.hasSlotContent()) return n;
|
|
379
|
+
let e = s({
|
|
380
|
+
"pkt-header-service__slot-container": !0,
|
|
381
|
+
"is-open": this.openMenu === "slot"
|
|
382
|
+
}), r = s({
|
|
383
|
+
"pkt-header-service__slot-content": !0,
|
|
384
|
+
"align-right": this.alignSlotRight
|
|
385
|
+
});
|
|
386
|
+
return t`
|
|
387
|
+
<div
|
|
388
|
+
class=${e}
|
|
389
|
+
@focusout=${(e) => this.handleFocusOut(e, "slot")}
|
|
390
|
+
${d(this.slotContainerRef)}
|
|
391
|
+
>
|
|
392
|
+
${this.isTablet && this.hasSlotContent() ? t`
|
|
393
|
+
<pkt-button
|
|
394
|
+
skin="secondary"
|
|
395
|
+
variant=${this.slotMenuVariant}
|
|
396
|
+
iconName="menu"
|
|
397
|
+
size=${this.isMobile ? "small" : "medium"}
|
|
398
|
+
state=${this.openMenu === "slot" ? "active" : "normal"}
|
|
399
|
+
@click=${() => this.handleMenuToggle("slot")}
|
|
400
|
+
aria-expanded=${this.openMenu === "slot"}
|
|
401
|
+
aria-controls="mobile-slot-menu"
|
|
402
|
+
aria-label="Åpne meny"
|
|
403
|
+
>
|
|
404
|
+
${this.slotMenuText}
|
|
405
|
+
</pkt-button>
|
|
406
|
+
` : n}
|
|
407
|
+
<div
|
|
408
|
+
class=${r}
|
|
409
|
+
id="mobile-slot-menu"
|
|
410
|
+
role=${this.isTablet ? "menu" : n}
|
|
411
|
+
aria-label=${this.isTablet ? "Meny" : n}
|
|
412
|
+
${d(this.slotContentRef)}
|
|
413
|
+
>
|
|
414
|
+
${c(this)}
|
|
415
|
+
</div>
|
|
416
|
+
</div>
|
|
417
|
+
`;
|
|
418
|
+
}
|
|
419
|
+
renderSearch() {
|
|
420
|
+
if (!this.showSearch) return n;
|
|
421
|
+
if (this.isTablet) {
|
|
422
|
+
let e = s({
|
|
423
|
+
"pkt-header-service__search-container": !0,
|
|
424
|
+
"is-open": this.openMenu === "search"
|
|
425
|
+
}), r = s({
|
|
426
|
+
"pkt-header-service__mobile-menu": !0,
|
|
427
|
+
"is-open": this.openMenu === "search",
|
|
428
|
+
"align-right": this.alignSearchRight
|
|
429
|
+
});
|
|
430
|
+
return t`
|
|
431
|
+
<div
|
|
432
|
+
class=${e}
|
|
433
|
+
@focusout=${(e) => this.handleFocusOut(e, "search")}
|
|
434
|
+
${d(this.searchContainerRef)}
|
|
435
|
+
>
|
|
436
|
+
<pkt-button
|
|
437
|
+
skin="secondary"
|
|
438
|
+
variant="icon-only"
|
|
439
|
+
iconName="magnifying-glass-big"
|
|
440
|
+
size=${this.isMobile ? "small" : "medium"}
|
|
441
|
+
@click=${() => this.handleMenuToggle("search")}
|
|
442
|
+
state=${this.openMenu === "search" ? "active" : "normal"}
|
|
443
|
+
aria-expanded=${this.openMenu === "search"}
|
|
444
|
+
aria-controls="mobile-search-menu"
|
|
445
|
+
aria-label="Åpne søkefelt"
|
|
446
|
+
>
|
|
447
|
+
Søk
|
|
448
|
+
</pkt-button>
|
|
449
|
+
<div class=${r} ${d(this.searchMenuRef)}>
|
|
450
|
+
${this.openMenu === "search" ? t`
|
|
451
|
+
<pkt-textinput
|
|
452
|
+
id="mobile-search-menu"
|
|
453
|
+
class="pkt-header-service__search-input"
|
|
454
|
+
type="search"
|
|
455
|
+
label="Søk"
|
|
456
|
+
useWrapper="false"
|
|
457
|
+
placeholder=${this.searchPlaceholder}
|
|
458
|
+
value=${this.searchValue}
|
|
459
|
+
autofocus
|
|
460
|
+
fullwidth
|
|
461
|
+
@input=${this.handleSearchInputChange}
|
|
462
|
+
@keydown=${(e) => {
|
|
463
|
+
e.key === "Enter" && this.handleSearch(e.target.value);
|
|
464
|
+
}}
|
|
465
|
+
></pkt-textinput>
|
|
466
|
+
` : n}
|
|
467
|
+
</div>
|
|
468
|
+
</div>
|
|
469
|
+
`;
|
|
470
|
+
}
|
|
471
|
+
return t`
|
|
472
|
+
<pkt-textinput
|
|
473
|
+
id="header-service-search"
|
|
474
|
+
class="pkt-header-service__search-input"
|
|
475
|
+
type="search"
|
|
476
|
+
label="Søk"
|
|
477
|
+
useWrapper="false"
|
|
478
|
+
placeholder=${this.searchPlaceholder}
|
|
479
|
+
value=${this.searchValue}
|
|
480
|
+
@input=${this.handleSearchInputChange}
|
|
481
|
+
@keydown=${this.handleSearchKeyDown}
|
|
482
|
+
></pkt-textinput>
|
|
483
|
+
`;
|
|
484
|
+
}
|
|
485
|
+
renderUserButton() {
|
|
486
|
+
if (!this.user) return n;
|
|
487
|
+
let e = s({
|
|
488
|
+
"pkt-header-service__user-menu": this.isMobile === !1,
|
|
489
|
+
"pkt-header-service__mobile-menu": this.isMobile === !0,
|
|
490
|
+
"is-open": this.openMenu === "user"
|
|
491
|
+
});
|
|
492
|
+
return t`
|
|
493
|
+
<div
|
|
494
|
+
class="pkt-header-service__user-container"
|
|
495
|
+
@focusout=${(e) => this.handleFocusOut(e, "user")}
|
|
496
|
+
${d(this.userContainerRef)}
|
|
497
|
+
>
|
|
498
|
+
<pkt-button
|
|
499
|
+
class=${s({
|
|
500
|
+
"pkt-header-service__user-button": !0,
|
|
501
|
+
"pkt-header-service__user-button--mobile": this.isMobile
|
|
502
|
+
})}
|
|
503
|
+
skin="secondary"
|
|
504
|
+
size=${this.isMobile ? "small" : "medium"}
|
|
505
|
+
state=${this.openMenu === "user" ? "active" : "normal"}
|
|
506
|
+
variant="icons-right-and-left"
|
|
507
|
+
iconName="user"
|
|
508
|
+
secondIconName=${this.openMenu === "user" ? "chevron-thin-up" : "chevron-thin-down"}
|
|
509
|
+
@click=${() => this.handleMenuToggle("user")}
|
|
510
|
+
>
|
|
511
|
+
<span class="pkt-sr-only">Brukermeny: </span>
|
|
512
|
+
<span>${this.representing?.name || this.user.name}</span>
|
|
513
|
+
</pkt-button>
|
|
514
|
+
${this.openMenu === "user" && this.user ? t`
|
|
515
|
+
<div class=${e}>
|
|
516
|
+
<pkt-header-user-menu
|
|
517
|
+
.user=${this.user}
|
|
518
|
+
formatted-last-logged-in=${this.formattedLastLoggedIn || n}
|
|
519
|
+
.representing=${this.representing}
|
|
520
|
+
.userMenu=${this.userMenu}
|
|
521
|
+
?can-change-representation=${this.canChangeRepresentation}
|
|
522
|
+
?logout-on-click=${this.showLogoutInUserMenu}
|
|
523
|
+
@change-representation=${() => this.dispatchEvent(new CustomEvent("change-representation", {
|
|
524
|
+
bubbles: !0,
|
|
525
|
+
composed: !0
|
|
526
|
+
}))}
|
|
527
|
+
@log-out=${this.handleLogout}
|
|
528
|
+
></pkt-header-user-menu>
|
|
529
|
+
</div>
|
|
530
|
+
` : n}
|
|
531
|
+
</div>
|
|
532
|
+
`;
|
|
533
|
+
}
|
|
534
|
+
renderHeader() {
|
|
535
|
+
let e = s({
|
|
536
|
+
"pkt-header-service": !0,
|
|
537
|
+
"pkt-header-service--compact": this.compact,
|
|
538
|
+
"pkt-header-service--mobile": this.isMobile,
|
|
539
|
+
"pkt-header-service--tablet": this.isTablet,
|
|
540
|
+
"pkt-header-service--fixed": this.isFixed,
|
|
541
|
+
"pkt-header-service--scroll-to-hide": this.shouldHideOnScroll,
|
|
542
|
+
"pkt-header-service--hidden": this.isHidden
|
|
543
|
+
}), r = s({
|
|
544
|
+
"pkt-header-service__logo-area": !0,
|
|
545
|
+
"pkt-header-service__logo-area--without-service": !this.serviceName
|
|
546
|
+
});
|
|
547
|
+
return t`
|
|
548
|
+
<header class=${e} ${d(this.headerRef)}>
|
|
549
|
+
<div class=${r}>${this.renderLogo()} ${this.renderServiceName()}</div>
|
|
550
|
+
|
|
551
|
+
${this.hasSlotContent() || this.showSearch || this.showLogoutInHeader ? t`<div class="pkt-header-service__content">
|
|
552
|
+
${this.renderSlotContainer()} ${this.renderSearch()}
|
|
553
|
+
${this.isTablet && this.showLogoutInHeader ? t`
|
|
554
|
+
<pkt-button
|
|
555
|
+
skin="secondary"
|
|
556
|
+
size=${this.isMobile ? "small" : "medium"}
|
|
557
|
+
variant="icon-only"
|
|
558
|
+
iconName="exit"
|
|
559
|
+
@click=${this.handleLogout}
|
|
560
|
+
>
|
|
561
|
+
Logg ut
|
|
562
|
+
</pkt-button>
|
|
563
|
+
` : n}
|
|
564
|
+
</div>` : n}
|
|
565
|
+
${this.user || !this.isTablet && this.showLogoutInHeader ? t`<div class="pkt-header-service__user">
|
|
566
|
+
${this.renderUserButton()}
|
|
567
|
+
${!this.isTablet && this.showLogoutInHeader ? t`
|
|
568
|
+
<pkt-button
|
|
569
|
+
skin="tertiary"
|
|
570
|
+
size="medium"
|
|
571
|
+
variant="icon-right"
|
|
572
|
+
iconName="exit"
|
|
573
|
+
@click=${this.handleLogout}
|
|
574
|
+
>
|
|
575
|
+
Logg ut
|
|
576
|
+
</pkt-button>
|
|
577
|
+
` : n}
|
|
578
|
+
</div>` : n}
|
|
579
|
+
</header>
|
|
580
|
+
`;
|
|
581
|
+
}
|
|
582
|
+
render() {
|
|
583
|
+
let e = this.renderHeader();
|
|
584
|
+
return this.isFixed ? t`
|
|
585
|
+
<div class="pkt-header-service-wrapper">
|
|
586
|
+
${e}
|
|
587
|
+
<div class=${s({
|
|
588
|
+
"pkt-header-service-spacer": !0,
|
|
589
|
+
"pkt-header-service-spacer--compact": this.compact,
|
|
590
|
+
"pkt-header-service-spacer--has-user": !!this.user,
|
|
591
|
+
"pkt-header-service-spacer--mobile": this.isMobile
|
|
592
|
+
})}></div>
|
|
593
|
+
</div>
|
|
594
|
+
` : e;
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
i([a({
|
|
598
|
+
type: String,
|
|
599
|
+
attribute: "service-name"
|
|
600
|
+
})], y.prototype, "serviceName", void 0), i([a({
|
|
601
|
+
type: String,
|
|
602
|
+
attribute: "service-link"
|
|
603
|
+
})], y.prototype, "serviceLink", void 0), i([a({
|
|
604
|
+
type: String,
|
|
605
|
+
attribute: "logo-link"
|
|
606
|
+
})], y.prototype, "logoLink", void 0), i([a({
|
|
607
|
+
type: String,
|
|
608
|
+
attribute: "search-placeholder"
|
|
609
|
+
})], y.prototype, "searchPlaceholder", void 0), i([a({
|
|
610
|
+
type: String,
|
|
611
|
+
attribute: "search-value"
|
|
612
|
+
})], y.prototype, "searchValue", void 0), i([a({
|
|
613
|
+
type: Number,
|
|
614
|
+
attribute: "mobile-breakpoint"
|
|
615
|
+
})], y.prototype, "mobileBreakpoint", void 0), i([a({
|
|
616
|
+
type: Number,
|
|
617
|
+
attribute: "tablet-breakpoint"
|
|
618
|
+
})], y.prototype, "tabletBreakpoint", void 0), i([a({
|
|
619
|
+
type: String,
|
|
620
|
+
attribute: "opened-menu"
|
|
621
|
+
})], y.prototype, "openedMenu", void 0), i([a({
|
|
622
|
+
type: String,
|
|
623
|
+
attribute: "log-out-button-placement"
|
|
624
|
+
})], y.prototype, "logOutButtonPlacement", void 0), i([a({ type: String })], y.prototype, "position", void 0), i([a({
|
|
625
|
+
type: String,
|
|
626
|
+
attribute: "scroll-behavior"
|
|
627
|
+
})], y.prototype, "scrollBehavior", void 0), i([a({
|
|
628
|
+
type: String,
|
|
629
|
+
attribute: "slot-menu-variant"
|
|
630
|
+
})], y.prototype, "slotMenuVariant", void 0), i([a({
|
|
631
|
+
type: String,
|
|
632
|
+
attribute: "slot-menu-text"
|
|
633
|
+
})], y.prototype, "slotMenuText", void 0), i([a({
|
|
634
|
+
type: Boolean,
|
|
635
|
+
attribute: "hide-logo",
|
|
636
|
+
converter: p
|
|
637
|
+
})], y.prototype, "hideLogo", void 0), i([a({
|
|
638
|
+
type: Boolean,
|
|
639
|
+
converter: p
|
|
640
|
+
})], y.prototype, "compact", void 0), i([a({
|
|
641
|
+
type: Boolean,
|
|
642
|
+
attribute: "show-search",
|
|
643
|
+
converter: p
|
|
644
|
+
})], y.prototype, "showSearch", void 0), i([a({
|
|
645
|
+
type: Boolean,
|
|
646
|
+
attribute: "can-change-representation",
|
|
647
|
+
converter: p
|
|
648
|
+
})], y.prototype, "canChangeRepresentation", void 0), i([a({
|
|
649
|
+
type: Boolean,
|
|
650
|
+
attribute: "has-log-out",
|
|
651
|
+
converter: p
|
|
652
|
+
})], y.prototype, "hasLogOut", void 0), i([a({ type: Object })], y.prototype, "user", void 0), i([a({
|
|
653
|
+
type: Array,
|
|
654
|
+
attribute: "user-menu"
|
|
655
|
+
})], y.prototype, "userMenu", void 0), i([a({ type: Object })], y.prototype, "representing", void 0), i([r()], y.prototype, "isMobile", void 0), i([r()], y.prototype, "isTablet", void 0), i([r()], y.prototype, "openMenu", void 0), i([r()], y.prototype, "isHidden", void 0), i([r()], y.prototype, "componentWidth", void 0), i([r()], y.prototype, "alignSlotRight", void 0), i([r()], y.prototype, "alignSearchRight", void 0);
|
|
656
|
+
try {
|
|
657
|
+
e("pkt-header-service")(y);
|
|
658
|
+
} catch {
|
|
659
|
+
console.warn("Forsøker å definere <pkt-header-service>, men den er allerede definert");
|
|
660
|
+
}
|
|
661
|
+
//#endregion
|
|
662
|
+
//#region src/components/header/header.ts
|
|
663
|
+
var b = class extends l {
|
|
664
|
+
constructor(...e) {
|
|
665
|
+
super(...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;
|
|
666
|
+
}
|
|
667
|
+
firstUpdated(e) {
|
|
668
|
+
super.firstUpdated(e), this.emitDeprecationWarnings();
|
|
669
|
+
}
|
|
670
|
+
emitDeprecationWarnings() {
|
|
671
|
+
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.");
|
|
672
|
+
}
|
|
673
|
+
get effectiveUserMenu() {
|
|
674
|
+
let e = this.userMenu || [], t = this.userMenuFooter || [], n = this.userOptions || [];
|
|
675
|
+
return t.length || n.length ? [
|
|
676
|
+
...e,
|
|
677
|
+
...n,
|
|
678
|
+
...t
|
|
679
|
+
] : this.userMenu;
|
|
680
|
+
}
|
|
681
|
+
render() {
|
|
682
|
+
return t`
|
|
683
|
+
<pkt-header-service
|
|
684
|
+
service-name=${u(this.serviceName)}
|
|
685
|
+
service-link=${u(this.serviceLink)}
|
|
686
|
+
logo-link=${u(this.logoLink)}
|
|
687
|
+
search-placeholder=${this.searchPlaceholder}
|
|
688
|
+
search-value=${this.searchValue}
|
|
689
|
+
mobile-breakpoint=${this.mobileBreakpoint}
|
|
690
|
+
tablet-breakpoint=${this.tabletBreakpoint}
|
|
691
|
+
opened-menu=${this.openedMenu}
|
|
692
|
+
log-out-button-placement=${this.logOutButtonPlacement}
|
|
693
|
+
position=${this.position}
|
|
694
|
+
scroll-behavior=${this.scrollBehavior}
|
|
695
|
+
slot-menu-variant=${this.slotMenuVariant}
|
|
696
|
+
slot-menu-text=${this.slotMenuText}
|
|
697
|
+
.hideLogo=${this.hideLogo}
|
|
698
|
+
.compact=${this.compact}
|
|
699
|
+
.showSearch=${this.showSearch}
|
|
700
|
+
.canChangeRepresentation=${this.canChangeRepresentation}
|
|
701
|
+
.hasLogOut=${this.hasLogOut}
|
|
702
|
+
.user=${this.user}
|
|
703
|
+
.userMenu=${this.effectiveUserMenu}
|
|
704
|
+
.representing=${this.representing}
|
|
705
|
+
>
|
|
706
|
+
${this.hasSlotContent() ? t`<div class="pkt-contents">${c(this)}</div>` : n}
|
|
707
|
+
</pkt-header-service>
|
|
708
|
+
`;
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
i([a({
|
|
712
|
+
type: String,
|
|
713
|
+
attribute: "service-name"
|
|
714
|
+
})], b.prototype, "serviceName", void 0), i([a({
|
|
715
|
+
type: String,
|
|
716
|
+
attribute: "service-link"
|
|
717
|
+
})], b.prototype, "serviceLink", void 0), i([a({
|
|
718
|
+
type: String,
|
|
719
|
+
attribute: "logo-link"
|
|
720
|
+
})], b.prototype, "logoLink", void 0), i([a({
|
|
721
|
+
type: String,
|
|
722
|
+
attribute: "search-placeholder"
|
|
723
|
+
})], b.prototype, "searchPlaceholder", void 0), i([a({
|
|
724
|
+
type: String,
|
|
725
|
+
attribute: "search-value"
|
|
726
|
+
})], b.prototype, "searchValue", void 0), i([a({
|
|
727
|
+
type: Number,
|
|
728
|
+
attribute: "mobile-breakpoint"
|
|
729
|
+
})], b.prototype, "mobileBreakpoint", void 0), i([a({
|
|
730
|
+
type: Number,
|
|
731
|
+
attribute: "tablet-breakpoint"
|
|
732
|
+
})], b.prototype, "tabletBreakpoint", void 0), i([a({
|
|
733
|
+
type: String,
|
|
734
|
+
attribute: "opened-menu"
|
|
735
|
+
})], b.prototype, "openedMenu", void 0), i([a({
|
|
736
|
+
type: String,
|
|
737
|
+
attribute: "log-out-button-placement"
|
|
738
|
+
})], b.prototype, "logOutButtonPlacement", void 0), i([a({ type: String })], b.prototype, "position", void 0), i([a({
|
|
739
|
+
type: String,
|
|
740
|
+
attribute: "scroll-behavior"
|
|
741
|
+
})], b.prototype, "scrollBehavior", void 0), i([a({
|
|
742
|
+
type: String,
|
|
743
|
+
attribute: "slot-menu-variant"
|
|
744
|
+
})], b.prototype, "slotMenuVariant", void 0), i([a({
|
|
745
|
+
type: String,
|
|
746
|
+
attribute: "slot-menu-text"
|
|
747
|
+
})], b.prototype, "slotMenuText", void 0), i([a({
|
|
748
|
+
type: Boolean,
|
|
749
|
+
attribute: "hide-logo",
|
|
750
|
+
converter: p
|
|
751
|
+
})], b.prototype, "hideLogo", void 0), i([a({
|
|
752
|
+
type: Boolean,
|
|
753
|
+
converter: p
|
|
754
|
+
})], b.prototype, "compact", void 0), i([a({
|
|
755
|
+
type: Boolean,
|
|
756
|
+
attribute: "show-search",
|
|
757
|
+
converter: p
|
|
758
|
+
})], b.prototype, "showSearch", void 0), i([a({
|
|
759
|
+
type: Boolean,
|
|
760
|
+
attribute: "can-change-representation",
|
|
761
|
+
converter: p
|
|
762
|
+
})], b.prototype, "canChangeRepresentation", void 0), i([a({
|
|
763
|
+
type: Boolean,
|
|
764
|
+
attribute: "has-log-out",
|
|
765
|
+
converter: p
|
|
766
|
+
})], b.prototype, "hasLogOut", void 0), i([a({ type: Object })], b.prototype, "user", void 0), i([a({
|
|
767
|
+
type: Array,
|
|
768
|
+
attribute: "user-menu"
|
|
769
|
+
})], b.prototype, "userMenu", void 0), i([a({ type: Object })], b.prototype, "representing", void 0), i([a({
|
|
770
|
+
type: Array,
|
|
771
|
+
attribute: "user-menu-footer"
|
|
772
|
+
})], b.prototype, "userMenuFooter", void 0), i([a({
|
|
773
|
+
type: Array,
|
|
774
|
+
attribute: "user-options"
|
|
775
|
+
})], b.prototype, "userOptions", void 0);
|
|
776
|
+
try {
|
|
777
|
+
e("pkt-header")(b);
|
|
778
|
+
} catch {
|
|
779
|
+
console.warn("Forsøker å definere <pkt-header>, men den er allerede definert");
|
|
780
|
+
}
|
|
781
|
+
//#endregion
|
|
782
|
+
export { g as i, y as n, _ as r, b as t };
|