@oslokommune/punkt-elements 16.7.3 → 16.7.4
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 +18 -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,397 @@
|
|
|
1
|
+
import { c as e, d as t, i as n, l as r, o as i, r as a, s as o, t as s } from "./element-cZ85T_aa.js";
|
|
2
|
+
import { t as c } from "./class-map-C8HuhNzZ.js";
|
|
3
|
+
import { t as l } from "./if-defined-Cjj8qN-Z.js";
|
|
4
|
+
import { t as u } from "./repeat-Cepr3469.js";
|
|
5
|
+
import { n as d } from "./utils-CUqCKGvp.js";
|
|
6
|
+
//#region ../../shared-utils/combobox/option-utils.ts
|
|
7
|
+
var f = (e, t) => t && (e.find((e) => e.value === t) || e.find((e) => e.label === t)) || null, p = (e, t) => {
|
|
8
|
+
if (!t) return -1;
|
|
9
|
+
let n = e.findIndex((e) => e.value === t);
|
|
10
|
+
return n >= 0 ? n : e.findIndex((e) => e.label === t);
|
|
11
|
+
}, m = (e, t) => {
|
|
12
|
+
if (!t) return [...e];
|
|
13
|
+
let n = t.toLowerCase();
|
|
14
|
+
return e.filter((e) => (e.fulltext || e.value + (e.label || "") + (e.prefix || "")).toLowerCase().includes(n));
|
|
15
|
+
}, h = (e) => e.value + (e.label || "") + (e.prefix || ""), g = (e, t) => t !== null && e >= t, _ = (e, t) => {
|
|
16
|
+
if (!t) return {
|
|
17
|
+
filtered: [...e],
|
|
18
|
+
suggestion: null
|
|
19
|
+
};
|
|
20
|
+
let n = t.toLowerCase(), r = e.filter((e) => e.fulltext?.toLowerCase().includes(n));
|
|
21
|
+
return {
|
|
22
|
+
filtered: r,
|
|
23
|
+
suggestion: r.find((e) => !e.selected && e.label?.toLowerCase().startsWith(n)) || null
|
|
24
|
+
};
|
|
25
|
+
}, v = (e, t, n, r) => {
|
|
26
|
+
if (!e.trim()) return {
|
|
27
|
+
addValueText: null,
|
|
28
|
+
userInfoMessage: ""
|
|
29
|
+
};
|
|
30
|
+
let i = e.trim().toLowerCase(), a = t.find((e) => e.toLowerCase() === i), o = n.filter((e) => e.label?.toLowerCase().includes(i) || e.value.toLowerCase().includes(i)), s = o.find((e) => e.label?.toLowerCase() === i || e.value.toLowerCase() === i);
|
|
31
|
+
return (o.length === 0 || !s) && r ? {
|
|
32
|
+
addValueText: e,
|
|
33
|
+
userInfoMessage: ""
|
|
34
|
+
} : o.length === 0 && !r ? {
|
|
35
|
+
addValueText: null,
|
|
36
|
+
userInfoMessage: "Ingen treff i søket"
|
|
37
|
+
} : a ? {
|
|
38
|
+
addValueText: null,
|
|
39
|
+
userInfoMessage: "Verdien er allerede valgt"
|
|
40
|
+
} : {
|
|
41
|
+
addValueText: null,
|
|
42
|
+
userInfoMessage: ""
|
|
43
|
+
};
|
|
44
|
+
}, y = (e) => /^[\p{L} ]$/u.test(e), b = (e = 500) => {
|
|
45
|
+
let t = "", n;
|
|
46
|
+
return {
|
|
47
|
+
append: (r) => (t += r.toLowerCase(), n !== void 0 && clearTimeout(n), n = setTimeout(() => {
|
|
48
|
+
t = "";
|
|
49
|
+
}, e), t),
|
|
50
|
+
reset: () => {
|
|
51
|
+
t = "", n !== void 0 && (clearTimeout(n), n = void 0);
|
|
52
|
+
},
|
|
53
|
+
getBuffer: () => t
|
|
54
|
+
};
|
|
55
|
+
}, x = (e, t) => {
|
|
56
|
+
let n = t.toLowerCase();
|
|
57
|
+
return e.findIndex((e) => e.textContent?.trim().toLowerCase().startsWith(n));
|
|
58
|
+
}, S = (e) => {
|
|
59
|
+
e.scrollIntoView({ block: "nearest" }), window.setTimeout(() => e.focus(), 0);
|
|
60
|
+
}, C = (e) => Array.from(e.querySelectorAll("[role=\"option\"]:not([data-disabled])") || []), w = (e) => {
|
|
61
|
+
let t = e.nextElementSibling;
|
|
62
|
+
t && S(t);
|
|
63
|
+
}, T = (e, t, n) => {
|
|
64
|
+
let r = e.previousElementSibling;
|
|
65
|
+
if (e.dataset.index === "0" && n) {
|
|
66
|
+
let e = t.querySelector("[role=\"searchbox\"]");
|
|
67
|
+
e && S(e);
|
|
68
|
+
} else r && S(r);
|
|
69
|
+
}, E = (e) => {
|
|
70
|
+
let t = C(e);
|
|
71
|
+
t[0] && S(t[0]);
|
|
72
|
+
}, D = (e) => {
|
|
73
|
+
let t = C(e), n = t[t.length - 1];
|
|
74
|
+
n && S(n);
|
|
75
|
+
}, O = (e, t) => {
|
|
76
|
+
if (t.disabled) return;
|
|
77
|
+
let n = C(e);
|
|
78
|
+
if (t.allowUserInput && t.customUserInput) {
|
|
79
|
+
let t = e.querySelector("[data-type=\"new-option\"]");
|
|
80
|
+
if (t) {
|
|
81
|
+
S(t);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
let r = n.find((e) => e.dataset.selected === "true");
|
|
86
|
+
if (r) {
|
|
87
|
+
S(r);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (t.includeSearch && !(document.activeElement instanceof HTMLInputElement)) {
|
|
91
|
+
let t = e.querySelector("[role=\"searchbox\"]");
|
|
92
|
+
if (t) {
|
|
93
|
+
window.setTimeout(() => t.focus(), 0);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
n[0] && S(n[0]);
|
|
98
|
+
}, k = class extends s {
|
|
99
|
+
constructor(...e) {
|
|
100
|
+
super(...e), this.id = d(), this.label = null, this.options = [], this.isOpen = !1, this.disabled = !1, this.includeSearch = !1, this.isMultiSelect = !1, this.allowUserInput = !1, this.maxIsReached = !1, this.customUserInput = null, this.searchPlaceholder = null, this.searchValue = null, this.maxLength = 0, this.userMessage = null, this._selectedOptions = 0, this.typeahead = b(), this._filteredOptions = [];
|
|
101
|
+
}
|
|
102
|
+
connectedCallback() {
|
|
103
|
+
super.connectedCallback(), this.includeSearch && !this.searchValue && (this.searchValue = ""), this.options.length > 0 && this.filterOptions(), this.setAttribute("tabindex", "-1"), this.addEventListener("focus", this.focusFirstOrSelectedOption);
|
|
104
|
+
}
|
|
105
|
+
disconnectedCallback() {
|
|
106
|
+
super.disconnectedCallback(), this.typeahead.reset();
|
|
107
|
+
}
|
|
108
|
+
updated(e) {
|
|
109
|
+
(e.has("options") || e.has("searchValue")) && this.filterOptions(), super.updated(e);
|
|
110
|
+
}
|
|
111
|
+
attributeChangedCallback(e, t, n) {
|
|
112
|
+
(e === "options" || e === "search-value") && this.filterOptions(), super.attributeChangedCallback(e, t, n);
|
|
113
|
+
}
|
|
114
|
+
get _hasOptions() {
|
|
115
|
+
return this._filteredOptions.length > 0 || this.options.length > 0;
|
|
116
|
+
}
|
|
117
|
+
render() {
|
|
118
|
+
return t`
|
|
119
|
+
<div
|
|
120
|
+
class=${c({
|
|
121
|
+
"pkt-listbox": !0,
|
|
122
|
+
"pkt-listbox__open": this.isOpen,
|
|
123
|
+
"pkt-txt-16-light": !0
|
|
124
|
+
})}
|
|
125
|
+
role=${l(this._hasOptions ? "listbox" : void 0)}
|
|
126
|
+
aria-multiselectable=${l(this._hasOptions && this.isMultiSelect ? "true" : void 0)}
|
|
127
|
+
aria-label=${l(this._hasOptions ? this.label ?? void 0 : void 0)}
|
|
128
|
+
>
|
|
129
|
+
<div class="pkt-listbox__banners">
|
|
130
|
+
${this.renderSearch()} ${this.renderMaximumReachedBanner()} ${this.renderUserMessage()}
|
|
131
|
+
${this.renderEmptyMessage()} ${this.renderNewOptionBanner()}
|
|
132
|
+
</div>
|
|
133
|
+
<ul class="pkt-listbox__options" role="presentation">
|
|
134
|
+
${this.renderList()}
|
|
135
|
+
</ul>
|
|
136
|
+
</div>
|
|
137
|
+
<div aria-live="polite" class="pkt-visually-hidden">${this.userMessage}</div>
|
|
138
|
+
`;
|
|
139
|
+
}
|
|
140
|
+
renderCheckboxOrCheckIcon(e, n) {
|
|
141
|
+
return this.isMultiSelect ? t`
|
|
142
|
+
<input
|
|
143
|
+
class="pkt-input-check__input-checkbox"
|
|
144
|
+
type="checkbox"
|
|
145
|
+
role="presentation"
|
|
146
|
+
tabindex="-1"
|
|
147
|
+
value=${e.value}
|
|
148
|
+
@change=${(e) => {
|
|
149
|
+
e.stopPropagation();
|
|
150
|
+
}}
|
|
151
|
+
.checked=${e.selected}
|
|
152
|
+
aria-labelledby=${this.id + "-option-label-" + n}
|
|
153
|
+
?disabled=${this.disabled || e.disabled || this.maxIsReached && !e.selected}
|
|
154
|
+
/>
|
|
155
|
+
` : e.selected ? t`<pkt-icon name="check-big"></pkt-icon>` : r;
|
|
156
|
+
}
|
|
157
|
+
renderEmptyMessage() {
|
|
158
|
+
return this.options.length > 0 || this._filteredOptions.length > 0 || this.userMessage ? r : t`<div class="pkt-listbox__banner pkt-listbox__banner--empty">
|
|
159
|
+
<pkt-icon
|
|
160
|
+
class="pkt-listbox__banner-icon"
|
|
161
|
+
name="exclamation-mark-circle"
|
|
162
|
+
size="large"
|
|
163
|
+
></pkt-icon>
|
|
164
|
+
Tom liste
|
|
165
|
+
</div>`;
|
|
166
|
+
}
|
|
167
|
+
renderList() {
|
|
168
|
+
return t`
|
|
169
|
+
${u(this._filteredOptions, (e) => e.value, (e, n) => t`
|
|
170
|
+
<li
|
|
171
|
+
@click=${() => {
|
|
172
|
+
this.toggleOption(e);
|
|
173
|
+
}}
|
|
174
|
+
aria-selected=${e.selected ? "true" : "false"}
|
|
175
|
+
@keydown=${this.handleOptionKeydown}
|
|
176
|
+
class=${c({
|
|
177
|
+
"pkt-listbox__option": !0,
|
|
178
|
+
"pkt-listbox__option--selected": !!(!this.isMultiSelect && e.selected),
|
|
179
|
+
"pkt-listbox__option--checkBox": this.isMultiSelect
|
|
180
|
+
})}
|
|
181
|
+
tabindex="${this.disabled || e.disabled ? "-1" : "0"}"
|
|
182
|
+
data-index=${n}
|
|
183
|
+
data-value=${e.value}
|
|
184
|
+
data-selected=${e.selected ? "true" : "false"}
|
|
185
|
+
?data-disabled=${this.disabled || e.disabled || this.maxIsReached && !e.selected}
|
|
186
|
+
aria-disabled=${this.disabled || e.disabled || this.maxIsReached && !e.selected ? "true" : "false"}
|
|
187
|
+
role="option"
|
|
188
|
+
id=${`${this.id}-${n}`}
|
|
189
|
+
>
|
|
190
|
+
${this.renderCheckboxOrCheckIcon(e, n)}
|
|
191
|
+
<span class="pkt-listbox__option-label" id=${this.id + "-option-label-" + n}>
|
|
192
|
+
${e.prefix ? t`<span class="pkt-listbox__option-prefix">${e.prefix}</span>` : r}
|
|
193
|
+
${e.label || e.value}
|
|
194
|
+
</span>
|
|
195
|
+
${e.description ? t`<span class="pkt-listbox__option-description pkt-txt-14-light"
|
|
196
|
+
>${e.description}</span
|
|
197
|
+
>` : r}
|
|
198
|
+
</li>
|
|
199
|
+
`)}
|
|
200
|
+
`;
|
|
201
|
+
}
|
|
202
|
+
renderNewOptionBanner() {
|
|
203
|
+
return this.allowUserInput && this.customUserInput ? t`
|
|
204
|
+
<div
|
|
205
|
+
class="pkt-listbox__banner pkt-listbox__banner--new-option pkt-listbox__option"
|
|
206
|
+
data-type="new-option"
|
|
207
|
+
data-value=${this.customUserInput}
|
|
208
|
+
data-selected="false"
|
|
209
|
+
tabindex="0"
|
|
210
|
+
@click=${() => this.toggleOption({ value: this.customUserInput || "" })}
|
|
211
|
+
@keydown=${this.handleOptionKeydown}
|
|
212
|
+
>
|
|
213
|
+
<pkt-icon class="pkt-listbox__banner-icon" name="plus-sign" size="large"></pkt-icon>
|
|
214
|
+
Legg til "${this.customUserInput}"
|
|
215
|
+
</div>
|
|
216
|
+
` : r;
|
|
217
|
+
}
|
|
218
|
+
renderMaximumReachedBanner() {
|
|
219
|
+
return this._selectedOptions = this.options.filter((e) => e.selected).length, this.isMultiSelect && this._selectedOptions > 0 && this.maxLength > 0 ? t`
|
|
220
|
+
<div class="pkt-listbox__banner pkt-listbox__banner--maximum-reached">
|
|
221
|
+
${this._selectedOptions} av maks ${this.maxLength} mulige er valgt.
|
|
222
|
+
</div>
|
|
223
|
+
` : r;
|
|
224
|
+
}
|
|
225
|
+
renderUserMessage() {
|
|
226
|
+
return this.userMessage ? t`<div class="pkt-listbox__banner pkt-listbox__banner--user-message">
|
|
227
|
+
<pkt-icon
|
|
228
|
+
class="pkt-listbox__banner-icon"
|
|
229
|
+
name="exclamation-mark-circle"
|
|
230
|
+
size="large"
|
|
231
|
+
></pkt-icon>
|
|
232
|
+
${this.userMessage}
|
|
233
|
+
</div>` : r;
|
|
234
|
+
}
|
|
235
|
+
renderSearch() {
|
|
236
|
+
return this.includeSearch ? t`
|
|
237
|
+
<div class="pkt-listbox__search">
|
|
238
|
+
<span class="pkt-listbox__search-icon">
|
|
239
|
+
<pkt-icon name="magnifying-glass-small" size="large"></pkt-icon>
|
|
240
|
+
</span>
|
|
241
|
+
<input
|
|
242
|
+
class="pkt-txt-16-light"
|
|
243
|
+
type="text"
|
|
244
|
+
aria-label="Søk i listen"
|
|
245
|
+
form=""
|
|
246
|
+
placeholder=${this.searchPlaceholder || n.forms.search.placeholder}
|
|
247
|
+
@input=${this.handleSearchInput}
|
|
248
|
+
@keydown=${this.handleSearchKeydown}
|
|
249
|
+
.value=${this.searchValue}
|
|
250
|
+
data-type="searchbox"
|
|
251
|
+
?disabled=${this.disabled}
|
|
252
|
+
?readonly=${this.disabled}
|
|
253
|
+
role="searchbox"
|
|
254
|
+
/>
|
|
255
|
+
</div>
|
|
256
|
+
` : r;
|
|
257
|
+
}
|
|
258
|
+
handleSearchInput(e) {
|
|
259
|
+
this.searchValue = e.target.value, this.dispatchEvent(new CustomEvent("search", {
|
|
260
|
+
detail: this.searchValue,
|
|
261
|
+
bubbles: !1
|
|
262
|
+
}));
|
|
263
|
+
}
|
|
264
|
+
handleSearchKeydown(e) {
|
|
265
|
+
switch (e.key) {
|
|
266
|
+
case "Enter":
|
|
267
|
+
e.preventDefault();
|
|
268
|
+
break;
|
|
269
|
+
case "ArrowUp":
|
|
270
|
+
case "Escape":
|
|
271
|
+
this.closeOptions(), e.preventDefault();
|
|
272
|
+
break;
|
|
273
|
+
case "ArrowDown":
|
|
274
|
+
this.focusFirstOrSelectedOption();
|
|
275
|
+
break;
|
|
276
|
+
case "Tab":
|
|
277
|
+
this.tabClose();
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
handleOptionKeydown(e) {
|
|
282
|
+
let t = e.currentTarget, n = t.dataset.value, r = t.dataset.type, i = t.dataset.selected === "true";
|
|
283
|
+
if (!(!C(this).length && (!this.customUserInput || !this.allowUserInput && this.customUserInput) && r !== "new-option" && r !== "searchbox")) switch (e.key) {
|
|
284
|
+
case " ":
|
|
285
|
+
case "Enter":
|
|
286
|
+
this.toggleOption(t), e.preventDefault();
|
|
287
|
+
break;
|
|
288
|
+
case "Backspace":
|
|
289
|
+
n && (i ? this.toggleOption(t) : this.closeOptions()), e.preventDefault();
|
|
290
|
+
break;
|
|
291
|
+
case "Escape":
|
|
292
|
+
this.closeOptions(), e.preventDefault();
|
|
293
|
+
break;
|
|
294
|
+
case "Tab":
|
|
295
|
+
this.tabClose();
|
|
296
|
+
break;
|
|
297
|
+
case "ArrowDown":
|
|
298
|
+
e.altKey ? D(this) : r === "searchbox" || r === "new-option" ? E(this) : w(t), e.preventDefault();
|
|
299
|
+
break;
|
|
300
|
+
case "ArrowUp":
|
|
301
|
+
if (e.altKey) E(this);
|
|
302
|
+
else if (t.dataset.index === "0" && this.includeSearch) {
|
|
303
|
+
let e = this.querySelector("[role=\"searchbox\"]");
|
|
304
|
+
e && e.focus();
|
|
305
|
+
} else if (t.dataset.index === "0" && this.customUserInput) {
|
|
306
|
+
let e = this.querySelector("[data-type=\"new-option\"]");
|
|
307
|
+
e && e.focus();
|
|
308
|
+
} else T(t, this, this.includeSearch);
|
|
309
|
+
e.preventDefault();
|
|
310
|
+
break;
|
|
311
|
+
case "Home":
|
|
312
|
+
E(this), e.preventDefault();
|
|
313
|
+
break;
|
|
314
|
+
case "End":
|
|
315
|
+
D(this), e.preventDefault();
|
|
316
|
+
break;
|
|
317
|
+
default:
|
|
318
|
+
(e.metaKey || e.ctrlKey) && e.key === "a" && (this.selectAll(), e.preventDefault()), y(e.key) && (this.handleTypeAhead(e.key), e.preventDefault());
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
focusFirstOrSelectedOption() {
|
|
323
|
+
O(this, {
|
|
324
|
+
disabled: this.disabled,
|
|
325
|
+
allowUserInput: this.allowUserInput,
|
|
326
|
+
customUserInput: this.customUserInput,
|
|
327
|
+
includeSearch: this.includeSearch
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
toggleOption(e) {
|
|
331
|
+
let t = e instanceof HTMLElement ? e.dataset.disabled : e.disabled;
|
|
332
|
+
if (this.disabled || t) return;
|
|
333
|
+
let n = e instanceof HTMLElement ? e.dataset.value : e.value;
|
|
334
|
+
this.dispatchEvent(new CustomEvent("option-toggle", {
|
|
335
|
+
detail: n,
|
|
336
|
+
bubbles: !1
|
|
337
|
+
}));
|
|
338
|
+
}
|
|
339
|
+
selectAll() {
|
|
340
|
+
this.dispatchEvent(new CustomEvent("select-all", { bubbles: !1 }));
|
|
341
|
+
}
|
|
342
|
+
closeOptions() {
|
|
343
|
+
this.dispatchEvent(new CustomEvent("close-options", { bubbles: !1 }));
|
|
344
|
+
}
|
|
345
|
+
tabClose() {
|
|
346
|
+
this.dispatchEvent(new CustomEvent("tab-close", { bubbles: !1 }));
|
|
347
|
+
}
|
|
348
|
+
filterOptions() {
|
|
349
|
+
this._filteredOptions = m(this.options, this.searchValue);
|
|
350
|
+
}
|
|
351
|
+
handleTypeAhead(e) {
|
|
352
|
+
let t = this.typeahead.append(e), n = C(this), r = x(n, t);
|
|
353
|
+
r >= 0 && S(n[r]);
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
a([o({ type: String })], k.prototype, "id", void 0), a([o({ type: String })], k.prototype, "label", void 0), a([o({ type: Array })], k.prototype, "options", void 0), a([o({
|
|
357
|
+
type: Boolean,
|
|
358
|
+
reflect: !0,
|
|
359
|
+
attribute: "is-open"
|
|
360
|
+
})], k.prototype, "isOpen", void 0), a([o({ type: Boolean })], k.prototype, "disabled", void 0), a([o({
|
|
361
|
+
type: Boolean,
|
|
362
|
+
attribute: "include-search"
|
|
363
|
+
})], k.prototype, "includeSearch", void 0), a([o({
|
|
364
|
+
type: Boolean,
|
|
365
|
+
attribute: "is-multi-select"
|
|
366
|
+
})], k.prototype, "isMultiSelect", void 0), a([o({
|
|
367
|
+
type: Boolean,
|
|
368
|
+
attribute: "allow-user-input"
|
|
369
|
+
})], k.prototype, "allowUserInput", void 0), a([o({
|
|
370
|
+
type: Boolean,
|
|
371
|
+
attribute: "max-is-reached"
|
|
372
|
+
})], k.prototype, "maxIsReached", void 0), a([o({
|
|
373
|
+
type: String,
|
|
374
|
+
attribute: "custom-user-input"
|
|
375
|
+
})], k.prototype, "customUserInput", void 0), a([o({
|
|
376
|
+
type: String,
|
|
377
|
+
attribute: "search-placeholder"
|
|
378
|
+
})], k.prototype, "searchPlaceholder", void 0), a([o({
|
|
379
|
+
type: String,
|
|
380
|
+
attribute: "search-value"
|
|
381
|
+
})], k.prototype, "searchValue", void 0), a([o({
|
|
382
|
+
type: Number,
|
|
383
|
+
attribute: "max-length"
|
|
384
|
+
})], k.prototype, "maxLength", void 0), a([o({
|
|
385
|
+
type: String,
|
|
386
|
+
attribute: "user-message"
|
|
387
|
+
})], k.prototype, "userMessage", void 0), a([i()], k.prototype, "_filteredOptions", void 0);
|
|
388
|
+
try {
|
|
389
|
+
e("pkt-listbox")(k);
|
|
390
|
+
} catch {
|
|
391
|
+
console.warn("Forsøker å definere <pkt-listbox>, men den er allerede definert");
|
|
392
|
+
}
|
|
393
|
+
//#endregion
|
|
394
|
+
//#region src/components/listbox/index.ts
|
|
395
|
+
var A = k;
|
|
396
|
+
//#endregion
|
|
397
|
+
export { p as a, g as c, f as i, k as n, _ as o, h as r, v as s, A as t };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { c as e, d as t, l as n, o as r, r as i, s as a } from "./element-cZ85T_aa.js";
|
|
2
|
+
import { t as o } from "./class-map-C8HuhNzZ.js";
|
|
3
|
+
import { n as s, t as c } from "./element-with-slot-4J2o3SeU.js";
|
|
4
|
+
import "./icon-Co72KtgF.js";
|
|
5
|
+
//#region src/components/loader/loader.ts
|
|
6
|
+
window.pktAnimationPath = window.pktAnimationPath || "https://punkt-cdn.oslo.kommune.no/latest/animations/";
|
|
7
|
+
var l = class extends c {
|
|
8
|
+
constructor(...e) {
|
|
9
|
+
super(...e), this.delay = 0, this.inline = !1, this.isLoading = !0, this.message = null, this.size = "medium", this.variant = "shapes", this.loadingAnimationPath = window.pktAnimationPath, this._shouldDisplayLoader = !1;
|
|
10
|
+
}
|
|
11
|
+
connectedCallback() {
|
|
12
|
+
super.connectedCallback(), this._shouldDisplayLoader = this.delay === 0, this.delay > 0 && this.setupLoader();
|
|
13
|
+
}
|
|
14
|
+
updated(e) {
|
|
15
|
+
e.has("delay") && this.setupLoader();
|
|
16
|
+
}
|
|
17
|
+
render() {
|
|
18
|
+
let e = o({
|
|
19
|
+
"pkt-loader": !0,
|
|
20
|
+
[`pkt-loader--${this.inline ? "inline" : "box"}`]: !0,
|
|
21
|
+
[`pkt-loader--${this.size}`]: !0
|
|
22
|
+
}), r = o({
|
|
23
|
+
"pkt-contents": !0,
|
|
24
|
+
"pkt-hide": this.isLoading
|
|
25
|
+
});
|
|
26
|
+
return t`<div
|
|
27
|
+
role="status"
|
|
28
|
+
aria-live="polite"
|
|
29
|
+
aria-busy=${this.isLoading ? "true" : "false"}
|
|
30
|
+
class=${e}
|
|
31
|
+
>
|
|
32
|
+
${this.isLoading && this._shouldDisplayLoader ? t`<div class="pkt-loader__spinner">
|
|
33
|
+
<pkt-icon
|
|
34
|
+
name=${this.getVariant(this.variant)}
|
|
35
|
+
path=${this.loadingAnimationPath}
|
|
36
|
+
class="pkt-loader__svg pkt-loader__${this.variant}"
|
|
37
|
+
></pkt-icon>
|
|
38
|
+
${this.message && t`<p>${this.message}</p>`}
|
|
39
|
+
</div>` : n}
|
|
40
|
+
<div class=${r}>${s(this)}</div>
|
|
41
|
+
</div>`;
|
|
42
|
+
}
|
|
43
|
+
getVariant(e) {
|
|
44
|
+
switch (e) {
|
|
45
|
+
case "blue": return "spinner-blue";
|
|
46
|
+
case "rainbow": return "spinner";
|
|
47
|
+
default: return "loader";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
setupLoader() {
|
|
51
|
+
this.delay > 0 && (this._shouldDisplayLoader = !1, setTimeout(() => {
|
|
52
|
+
this._shouldDisplayLoader = !0, this.requestUpdate();
|
|
53
|
+
}, this.delay));
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
i([a({ type: Number })], l.prototype, "delay", void 0), i([a({ type: Boolean })], l.prototype, "inline", void 0), i([a({ type: Boolean })], l.prototype, "isLoading", void 0), i([a({ type: String })], l.prototype, "message", void 0), i([a({ type: String })], l.prototype, "size", void 0), i([a({ type: String })], l.prototype, "variant", void 0), i([a({ type: String })], l.prototype, "loadingAnimationPath", void 0), i([r()], l.prototype, "_shouldDisplayLoader", void 0);
|
|
57
|
+
try {
|
|
58
|
+
e("pkt-loader")(l);
|
|
59
|
+
} catch {
|
|
60
|
+
console.warn("Forsøker å definere <pkt-loader>, men den er allerede definert");
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/components/loader/index.ts
|
|
64
|
+
var u = l;
|
|
65
|
+
//#endregion
|
|
66
|
+
export { l as n, u as t };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`),n=require(`./element-with-slot-CWoTGA1B.cjs`);require(`./icon-Dr8sfT2X.cjs`),window.pktAnimationPath=window.pktAnimationPath||`https://punkt-cdn.oslo.kommune.no/latest/animations/`;var r=class extends n.t{constructor(...e){super(...e),this.delay=0,this.inline=!1,this.isLoading=!0,this.message=null,this.size=`medium`,this.variant=`shapes`,this.loadingAnimationPath=window.pktAnimationPath,this._shouldDisplayLoader=!1}connectedCallback(){super.connectedCallback(),this._shouldDisplayLoader=this.delay===0,this.delay>0&&this.setupLoader()}updated(e){e.has(`delay`)&&this.setupLoader()}render(){let r=t.t({"pkt-loader":!0,[`pkt-loader--${this.inline?`inline`:`box`}`]:!0,[`pkt-loader--${this.size}`]:!0}),i=t.t({"pkt-contents":!0,"pkt-hide":this.isLoading});return e.d`<div
|
|
2
|
+
role="status"
|
|
3
|
+
aria-live="polite"
|
|
4
|
+
aria-busy=${this.isLoading?`true`:`false`}
|
|
5
|
+
class=${r}
|
|
6
|
+
>
|
|
7
|
+
${this.isLoading&&this._shouldDisplayLoader?e.d`<div class="pkt-loader__spinner">
|
|
8
|
+
<pkt-icon
|
|
9
|
+
name=${this.getVariant(this.variant)}
|
|
10
|
+
path=${this.loadingAnimationPath}
|
|
11
|
+
class="pkt-loader__svg pkt-loader__${this.variant}"
|
|
12
|
+
></pkt-icon>
|
|
13
|
+
${this.message&&e.d`<p>${this.message}</p>`}
|
|
14
|
+
</div>`:e.l}
|
|
15
|
+
<div class=${i}>${n.n(this)}</div>
|
|
16
|
+
</div>`}getVariant(e){switch(e){case`blue`:return`spinner-blue`;case`rainbow`:return`spinner`;default:return`loader`}}setupLoader(){this.delay>0&&(this._shouldDisplayLoader=!1,setTimeout(()=>{this._shouldDisplayLoader=!0,this.requestUpdate()},this.delay))}};e.r([e.s({type:Number})],r.prototype,`delay`,void 0),e.r([e.s({type:Boolean})],r.prototype,`inline`,void 0),e.r([e.s({type:Boolean})],r.prototype,`isLoading`,void 0),e.r([e.s({type:String})],r.prototype,`message`,void 0),e.r([e.s({type:String})],r.prototype,`size`,void 0),e.r([e.s({type:String})],r.prototype,`variant`,void 0),e.r([e.s({type:String})],r.prototype,`loadingAnimationPath`,void 0),e.r([e.o()],r.prototype,`_shouldDisplayLoader`,void 0);try{e.c(`pkt-loader`)(r)}catch{console.warn(`Forsøker å definere <pkt-loader>, men den er allerede definert`)}var i=r;Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return i}});
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { c as e, d as t, l as n, o as r, r as i, s as a } from "./element-cZ85T_aa.js";
|
|
2
|
+
import { t as o } from "./class-map-C8HuhNzZ.js";
|
|
3
|
+
import { n as s, t as c } from "./element-with-slot-4J2o3SeU.js";
|
|
4
|
+
import { t as l } from "./classutils-DEL164Ur.js";
|
|
5
|
+
import "./icon-Co72KtgF.js";
|
|
6
|
+
var u = {
|
|
7
|
+
name: "pkt-messagebox",
|
|
8
|
+
react: "PktMessagebox",
|
|
9
|
+
"css-class": "pkt-messagebox",
|
|
10
|
+
isElement: !0,
|
|
11
|
+
isPureReact: !0,
|
|
12
|
+
events: {
|
|
13
|
+
onClose: { description: "React: Event som trigges når meldingsboksen lukkes" },
|
|
14
|
+
"on-close": { description: "Vue: Event som trigges når meldingsboksen lukkes" }
|
|
15
|
+
},
|
|
16
|
+
props: {
|
|
17
|
+
title: {
|
|
18
|
+
name: "Tittel",
|
|
19
|
+
description: "Tittelen på meldingsboksen",
|
|
20
|
+
type: "string",
|
|
21
|
+
category: "contents"
|
|
22
|
+
},
|
|
23
|
+
skin: {
|
|
24
|
+
name: "Utseende",
|
|
25
|
+
description: "Velg farge på meldingsboksen",
|
|
26
|
+
type: [
|
|
27
|
+
"beige",
|
|
28
|
+
"blue",
|
|
29
|
+
"red",
|
|
30
|
+
"green"
|
|
31
|
+
],
|
|
32
|
+
category: "ui",
|
|
33
|
+
default: "beige"
|
|
34
|
+
},
|
|
35
|
+
compact: {
|
|
36
|
+
name: "Kompakt",
|
|
37
|
+
description: "Gjør meldingsboksen mindre",
|
|
38
|
+
type: "boolean",
|
|
39
|
+
category: "ui",
|
|
40
|
+
default: !1
|
|
41
|
+
},
|
|
42
|
+
closable: {
|
|
43
|
+
name: "Kan lukkes",
|
|
44
|
+
description: "Viser lukkeknapp",
|
|
45
|
+
type: "boolean",
|
|
46
|
+
category: "ui",
|
|
47
|
+
default: !1
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
slots: { default: { description: "Innholdet i meldingsboksen" } }
|
|
51
|
+
}, d = class extends c {
|
|
52
|
+
constructor() {
|
|
53
|
+
super(), this.closable = u.props.closable.default, this.compact = u.props.compact.default, this.title = "", this.skin = u.props.skin.default, this._isClosed = !1, this.close = (e) => {
|
|
54
|
+
this._isClosed = !0, this.dispatchEvent(new CustomEvent("close", {
|
|
55
|
+
detail: { origin: e },
|
|
56
|
+
bubbles: !0
|
|
57
|
+
})), this.dispatchEvent(new CustomEvent("on-close", {
|
|
58
|
+
detail: { origin: e },
|
|
59
|
+
bubbles: !0
|
|
60
|
+
}));
|
|
61
|
+
}, this._isClosed = !1;
|
|
62
|
+
}
|
|
63
|
+
updated(e) {
|
|
64
|
+
super.updated(e), e.has("_isClosed") && l(this, "pkt-hide", this._isClosed);
|
|
65
|
+
}
|
|
66
|
+
render() {
|
|
67
|
+
return t`<div class=${o({
|
|
68
|
+
"pkt-messagebox": !0,
|
|
69
|
+
"pkt-messagebox--compact": this.compact,
|
|
70
|
+
[`pkt-messagebox--${this.skin}`]: this.skin,
|
|
71
|
+
"pkt-messagebox--closable": this.closable,
|
|
72
|
+
"pkt-hide": this._isClosed
|
|
73
|
+
})}>
|
|
74
|
+
${this.closable ? t`<div class="pkt-messagebox__close">
|
|
75
|
+
<button
|
|
76
|
+
@click=${this.close}
|
|
77
|
+
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
78
|
+
aria-label="Lukk"
|
|
79
|
+
>
|
|
80
|
+
<pkt-icon name="close" class="pkt-link__icon"></pkt-icon>
|
|
81
|
+
</button>
|
|
82
|
+
</div>` : n}
|
|
83
|
+
${this.title ? t`<div class="pkt-messagebox__title">${this.title}</div>` : n}
|
|
84
|
+
<div class="pkt-messagebox__text">${s(this)}</div>
|
|
85
|
+
</div>`;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
i([a({
|
|
89
|
+
type: Boolean,
|
|
90
|
+
reflect: !0
|
|
91
|
+
})], d.prototype, "closable", void 0), i([a({
|
|
92
|
+
type: Boolean,
|
|
93
|
+
reflect: !0
|
|
94
|
+
})], d.prototype, "compact", void 0), i([a({
|
|
95
|
+
type: String,
|
|
96
|
+
reflect: !0
|
|
97
|
+
})], d.prototype, "title", void 0), i([a({
|
|
98
|
+
type: String,
|
|
99
|
+
reflect: !0
|
|
100
|
+
})], d.prototype, "skin", void 0), i([r()], d.prototype, "_isClosed", void 0);
|
|
101
|
+
try {
|
|
102
|
+
e("pkt-messagebox")(d);
|
|
103
|
+
} catch {
|
|
104
|
+
console.warn("Forsøker å definere <pkt-messagebox>, men den er allerede definert");
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/components/messagebox/index.ts
|
|
108
|
+
var f = d;
|
|
109
|
+
//#endregion
|
|
110
|
+
export { d as n, f as t };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`),n=require(`./element-with-slot-CWoTGA1B.cjs`),r=require(`./classutils-z8YsPlOf.cjs`);require(`./icon-Dr8sfT2X.cjs`);var i={name:`pkt-messagebox`,react:`PktMessagebox`,"css-class":`pkt-messagebox`,isElement:!0,isPureReact:!0,events:{onClose:{description:`React: Event som trigges når meldingsboksen lukkes`},"on-close":{description:`Vue: Event som trigges når meldingsboksen lukkes`}},props:{title:{name:`Tittel`,description:`Tittelen på meldingsboksen`,type:`string`,category:`contents`},skin:{name:`Utseende`,description:`Velg farge på meldingsboksen`,type:[`beige`,`blue`,`red`,`green`],category:`ui`,default:`beige`},compact:{name:`Kompakt`,description:`Gjør meldingsboksen mindre`,type:`boolean`,category:`ui`,default:!1},closable:{name:`Kan lukkes`,description:`Viser lukkeknapp`,type:`boolean`,category:`ui`,default:!1}},slots:{default:{description:`Innholdet i meldingsboksen`}}},a=class extends n.t{constructor(){super(),this.closable=i.props.closable.default,this.compact=i.props.compact.default,this.title=``,this.skin=i.props.skin.default,this._isClosed=!1,this.close=e=>{this._isClosed=!0,this.dispatchEvent(new CustomEvent(`close`,{detail:{origin:e},bubbles:!0})),this.dispatchEvent(new CustomEvent(`on-close`,{detail:{origin:e},bubbles:!0}))},this._isClosed=!1}updated(e){super.updated(e),e.has(`_isClosed`)&&r.t(this,`pkt-hide`,this._isClosed)}render(){return e.d`<div class=${t.t({"pkt-messagebox":!0,"pkt-messagebox--compact":this.compact,[`pkt-messagebox--${this.skin}`]:this.skin,"pkt-messagebox--closable":this.closable,"pkt-hide":this._isClosed})}>
|
|
2
|
+
${this.closable?e.d`<div class="pkt-messagebox__close">
|
|
3
|
+
<button
|
|
4
|
+
@click=${this.close}
|
|
5
|
+
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
6
|
+
aria-label="Lukk"
|
|
7
|
+
>
|
|
8
|
+
<pkt-icon name="close" class="pkt-link__icon"></pkt-icon>
|
|
9
|
+
</button>
|
|
10
|
+
</div>`:e.l}
|
|
11
|
+
${this.title?e.d`<div class="pkt-messagebox__title">${this.title}</div>`:e.l}
|
|
12
|
+
<div class="pkt-messagebox__text">${n.n(this)}</div>
|
|
13
|
+
</div>`}};e.r([e.s({type:Boolean,reflect:!0})],a.prototype,`closable`,void 0),e.r([e.s({type:Boolean,reflect:!0})],a.prototype,`compact`,void 0),e.r([e.s({type:String,reflect:!0})],a.prototype,`title`,void 0),e.r([e.s({type:String,reflect:!0})],a.prototype,`skin`,void 0),e.r([e.o()],a.prototype,`_isClosed`,void 0);try{e.c(`pkt-messagebox`)(a)}catch{console.warn(`Forsøker å definere <pkt-messagebox>, men den er allerede definert`)}var o=a;Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return o}});
|