@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,503 @@
|
|
|
1
|
+
import { c as e, d as t, i as n, l as r, o as i, r as a, s as o } from "./element-cZ85T_aa.js";
|
|
2
|
+
import { t as s } from "./class-map-C8HuhNzZ.js";
|
|
3
|
+
import { n as c } from "./element-with-slot-4J2o3SeU.js";
|
|
4
|
+
import "./icon-Co72KtgF.js";
|
|
5
|
+
import { t as l } from "./if-defined-Cjj8qN-Z.js";
|
|
6
|
+
import { n as u, t as d } from "./ref-RS8Uv6uC.js";
|
|
7
|
+
import { t as f } from "./input-element-Bw1s6NlF.js";
|
|
8
|
+
import "./input-wrapper-YfTmpSSY.js";
|
|
9
|
+
//#region ../../shared-utils/timepicker/time-utils.ts
|
|
10
|
+
var p = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && parseInt(e.slice(3), 10) <= 59, m = (e) => {
|
|
11
|
+
let [t, n] = e.split(":").map(Number);
|
|
12
|
+
return t * 60 + n;
|
|
13
|
+
}, h = (e) => e ? Math.max(1, Math.round(e / 60)) : 1, g = (e, t) => {
|
|
14
|
+
let n = e ? parseInt(String(e).split(":")[0], 10) : 0, r = t ? parseInt(String(t).split(":")[0], 10) : 23;
|
|
15
|
+
return Array.from({ length: r - n + 1 }, (e, t) => t + n);
|
|
16
|
+
}, _ = (e) => {
|
|
17
|
+
let t = h(e);
|
|
18
|
+
return Array.from({ length: Math.floor(60 / t) }, (e, n) => n * t);
|
|
19
|
+
}, v = (e, t, n, r) => {
|
|
20
|
+
let i = e === "" ? n === 1 ? 0 : 23 : parseInt(e, 10), a = t === "" ? n === 1 ? 0 : Math.floor(59 / r) * r : parseInt(t, 10);
|
|
21
|
+
return a += n * r, a > 59 ? (a = 0, i = (i + 1) % 24) : a < 0 && (a = Math.floor(59 / r) * r, i = (i - 1 + 24) % 24), {
|
|
22
|
+
hours: String(i).padStart(2, "0"),
|
|
23
|
+
minutes: String(a).padStart(2, "0")
|
|
24
|
+
};
|
|
25
|
+
}, y = class extends f {
|
|
26
|
+
constructor(...e) {
|
|
27
|
+
super(...e), this.hiddenInputRef = d(), this.hoursInputRef = d(), this.minutesInputRef = d(), this.buttonRef = d(), this.value = "", this.hidePicker = !1, this.stepArrows = !1, this._hours = "", this._minutes = "", this._isOpen = !1, this._hoursDigitCount = 0, this._hoursFirstDigit = -1, this._minutesDigitCount = 0, this._minutesFirstDigit = -1, this._hasFocus = !1, this._outsideClickHandler = (e) => {
|
|
28
|
+
this.contains(e.target) || this._closePopup();
|
|
29
|
+
}, this._handleComponentFocusIn = () => {
|
|
30
|
+
this._hasFocus || (this._hasFocus = !0, this.onFocus());
|
|
31
|
+
}, this._handleComponentFocusOut = (e) => {
|
|
32
|
+
this.contains(e.relatedTarget) || (this._hasFocus = !1, this.onBlur());
|
|
33
|
+
}, this._handleHoursKeydown = (e) => {
|
|
34
|
+
let t = e.target;
|
|
35
|
+
switch (e.key) {
|
|
36
|
+
case "ArrowUp": {
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
let t = this._hours === "" ? 0 : parseInt(this._hours, 10);
|
|
39
|
+
this._hours = String((t + 1) % 24).padStart(2, "0"), this._syncValueFromDisplay(), this.onInput();
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
case "ArrowDown": {
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
let t = this._hours === "" ? 0 : parseInt(this._hours, 10);
|
|
45
|
+
this._hours = String((t - 1 + 24) % 24).padStart(2, "0"), this._syncValueFromDisplay(), this.onInput();
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case "ArrowRight":
|
|
49
|
+
e.preventDefault(), this.minutesInputRef.value?.focus();
|
|
50
|
+
break;
|
|
51
|
+
case "Backspace":
|
|
52
|
+
case "Delete":
|
|
53
|
+
this._hoursDigitCount = 0, this._hoursFirstDigit = -1;
|
|
54
|
+
break;
|
|
55
|
+
case "Tab": break;
|
|
56
|
+
case "Enter": {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
let n = this.internals.form;
|
|
59
|
+
n ? n.requestSubmit() : t.blur();
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
default: if (/^\d$/.test(e.key)) {
|
|
63
|
+
e.preventDefault();
|
|
64
|
+
let t = parseInt(e.key, 10);
|
|
65
|
+
if (this._hoursDigitCount === 0) this._hoursFirstDigit = t, this._hours = String(t).padStart(2, "0"), this._hoursDigitCount = 1, this.onInput(), t >= 3 && (this._hoursFirstDigit = -1, this._hoursDigitCount = 0, this._syncValueFromDisplay(), this.minutesInputRef.value?.focus());
|
|
66
|
+
else {
|
|
67
|
+
let e = this._hoursFirstDigit * 10 + t;
|
|
68
|
+
this._hours = e <= 23 ? String(e).padStart(2, "0") : String(t).padStart(2, "0"), this._hoursFirstDigit = -1, this._hoursDigitCount = 0, this._syncValueFromDisplay(), this.onInput(), this.minutesInputRef.value?.focus();
|
|
69
|
+
}
|
|
70
|
+
} else e.preventDefault();
|
|
71
|
+
}
|
|
72
|
+
}, this._handleHoursBlur = () => {
|
|
73
|
+
this._hours !== "" && (this._hours = String(parseInt(this._hours, 10)).padStart(2, "0")), this._hoursDigitCount = 0, this._hoursFirstDigit = -1, this._syncValueFromDisplay();
|
|
74
|
+
}, this._handleMinutesKeydown = (e) => {
|
|
75
|
+
let t = e.target;
|
|
76
|
+
switch (e.key) {
|
|
77
|
+
case "ArrowUp": {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
let t = this._minutes === "" ? 0 : parseInt(this._minutes, 10);
|
|
80
|
+
this._minutes = String((t + this._minuteStep) % 60).padStart(2, "0"), this._syncValueFromDisplay(), this.onInput();
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
case "ArrowDown": {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
let t = this._minutes === "" ? 0 : parseInt(this._minutes, 10);
|
|
86
|
+
this._minutes = String((t - this._minuteStep + 60) % 60).padStart(2, "0"), this._syncValueFromDisplay(), this.onInput();
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
case "ArrowLeft":
|
|
90
|
+
e.preventDefault(), this.hoursInputRef.value?.focus();
|
|
91
|
+
break;
|
|
92
|
+
case "Backspace":
|
|
93
|
+
case "Delete":
|
|
94
|
+
this._minutesDigitCount = 0, this._minutesFirstDigit = -1;
|
|
95
|
+
break;
|
|
96
|
+
case "Tab": break;
|
|
97
|
+
case "Enter": {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
let n = this.internals.form;
|
|
100
|
+
n ? n.requestSubmit() : t.blur();
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
default: if (/^\d$/.test(e.key)) {
|
|
104
|
+
e.preventDefault();
|
|
105
|
+
let t = parseInt(e.key, 10);
|
|
106
|
+
if (this._minutesDigitCount === 0) this._minutesFirstDigit = t, this._minutes = String(t).padStart(2, "0"), this._minutesDigitCount = 1, this.onInput(), t >= 6 && (this._minutesFirstDigit = -1, this._minutesDigitCount = 0, this._syncValueFromDisplay());
|
|
107
|
+
else {
|
|
108
|
+
let e = this._minutesFirstDigit * 10 + t;
|
|
109
|
+
this._minutes = e <= 59 ? String(e).padStart(2, "0") : String(t).padStart(2, "0"), this._minutesFirstDigit = -1, this._minutesDigitCount = 0, this._syncValueFromDisplay(), this.onInput();
|
|
110
|
+
}
|
|
111
|
+
} else e.preventDefault();
|
|
112
|
+
}
|
|
113
|
+
}, this._handleMinutesBlur = () => {
|
|
114
|
+
this._minutes !== "" && (this._minutes = String(parseInt(this._minutes, 10)).padStart(2, "0")), this._minutesDigitCount = 0, this._minutesFirstDigit = -1, this._syncValueFromDisplay();
|
|
115
|
+
}, this._handlePopupKeydown = (e) => {
|
|
116
|
+
let t = document.activeElement, n = t.closest(".pkt-timepicker-popup__col");
|
|
117
|
+
if (!n) return;
|
|
118
|
+
let r = Array.from(n.querySelectorAll(".pkt-timepicker-popup__option")), i = r.indexOf(t), a = t.dataset.type ?? "";
|
|
119
|
+
switch (e.key) {
|
|
120
|
+
case "ArrowDown":
|
|
121
|
+
e.preventDefault(), this._focusOptionAndSync(r[Math.min(i + 1, r.length - 1)], a);
|
|
122
|
+
break;
|
|
123
|
+
case "ArrowUp":
|
|
124
|
+
e.preventDefault(), this._focusOptionAndSync(r[Math.max(i - 1, 0)], a);
|
|
125
|
+
break;
|
|
126
|
+
case "Home":
|
|
127
|
+
e.preventDefault(), this._focusOptionAndSync(r[0], a);
|
|
128
|
+
break;
|
|
129
|
+
case "End":
|
|
130
|
+
e.preventDefault(), this._focusOptionAndSync(r[r.length - 1], a);
|
|
131
|
+
break;
|
|
132
|
+
case "ArrowRight":
|
|
133
|
+
e.preventDefault(), a === "hour" && (this._focusOptionAndSync(t, a), this.updateComplete.then(() => {
|
|
134
|
+
this._scrollToSelected(), this._focusSelectedOrFirst("minute");
|
|
135
|
+
}));
|
|
136
|
+
break;
|
|
137
|
+
case "ArrowLeft":
|
|
138
|
+
e.preventDefault(), a === "minute" && (this._focusOptionAndSync(t, a), this.updateComplete.then(() => {
|
|
139
|
+
this._scrollToSelected(), this._focusSelectedOrFirst("hour");
|
|
140
|
+
}));
|
|
141
|
+
break;
|
|
142
|
+
case "Enter":
|
|
143
|
+
case " ":
|
|
144
|
+
e.preventDefault(), t.click();
|
|
145
|
+
break;
|
|
146
|
+
case "Escape":
|
|
147
|
+
e.preventDefault(), this._closePopup(), this.buttonRef.value?.focus();
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
get inputRef() {
|
|
153
|
+
return this.hiddenInputRef;
|
|
154
|
+
}
|
|
155
|
+
manageValidity(e) {
|
|
156
|
+
let t = this.hoursInputRef.value;
|
|
157
|
+
if (!t) return;
|
|
158
|
+
if (this.required && !this.value) {
|
|
159
|
+
this.internals.setValidity({ valueMissing: !0 }, n.forms.messages.required, t), this._setAriaInvalid(!0);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (!this.value) {
|
|
163
|
+
this.internals.setValidity({}), this._setAriaInvalid(!1);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
let r = m(this.value), i = h(this.step);
|
|
167
|
+
if (this.min && r < m(String(this.min))) {
|
|
168
|
+
this.internals.setValidity({ rangeUnderflow: !0 }, n.forms.messages.rangeUnderflowMin.replace("{min}", String(this.min)), t), this._setAriaInvalid(!0);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (this.max && r > m(String(this.max))) {
|
|
172
|
+
this.internals.setValidity({ rangeOverflow: !0 }, n.forms.messages.rangeOverflowMax.replace("{max}", String(this.max)), t), this._setAriaInvalid(!0);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (this.step && r % i !== 0) {
|
|
176
|
+
let e = i === 60 ? n.forms.messages.timeStepMismatchHour : i === 30 ? n.forms.messages.timeStepMismatchHalfHour : n.forms.messages.timeStepMismatch.replace("{step}", `${i}, ${i * 2}, ${i * 3}`);
|
|
177
|
+
this.internals.setValidity({ stepMismatch: !0 }, e, t), this._setAriaInvalid(!0);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
this.internals.setValidity({}), this._setAriaInvalid(!1);
|
|
181
|
+
}
|
|
182
|
+
_setAriaInvalid(e) {
|
|
183
|
+
if (!this.touched && e) return;
|
|
184
|
+
let t = this.hoursInputRef.value, n = this.minutesInputRef.value;
|
|
185
|
+
e ? (t?.setAttribute("aria-invalid", "true"), n?.setAttribute("aria-invalid", "true")) : (t?.removeAttribute("aria-invalid"), n?.removeAttribute("aria-invalid"));
|
|
186
|
+
}
|
|
187
|
+
connectedCallback() {
|
|
188
|
+
super.connectedCallback(), this.addEventListener("focusin", this._handleComponentFocusIn), this.addEventListener("focusout", this._handleComponentFocusOut), document.addEventListener("click", this._outsideClickHandler);
|
|
189
|
+
}
|
|
190
|
+
disconnectedCallback() {
|
|
191
|
+
super.disconnectedCallback(), this.removeEventListener("focusin", this._handleComponentFocusIn), this.removeEventListener("focusout", this._handleComponentFocusOut), document.removeEventListener("click", this._outsideClickHandler);
|
|
192
|
+
}
|
|
193
|
+
willUpdate(e) {
|
|
194
|
+
super.willUpdate(e), e.has("value") && this._syncDisplayFromValue();
|
|
195
|
+
}
|
|
196
|
+
updated(e) {
|
|
197
|
+
super.updated(e), this.classList.toggle("pkt-timepicker--stepper", this.stepArrows), this.classList.toggle("pkt-timepicker--fullwidth", this.fullwidth), e.has("step") && this.step !== null && !this._isValidStep(this.step) && console.warn(`pkt-timepicker: step="${this.step}" er ikke en gyldig verdi. Step må være et multiplum av 60 (hele minutter) eller nøyaktig 3600 (hel time).`);
|
|
198
|
+
}
|
|
199
|
+
formResetCallback() {
|
|
200
|
+
super.formResetCallback(), this._hours = "", this._minutes = "", this._isOpen = !1;
|
|
201
|
+
}
|
|
202
|
+
_isValidStep(e) {
|
|
203
|
+
return e === 3600 || e < 3600 && 3600 % e == 0 && e % 60 == 0;
|
|
204
|
+
}
|
|
205
|
+
_syncDisplayFromValue() {
|
|
206
|
+
let e = p(this.value) ? this.value.split(":") : null;
|
|
207
|
+
e ? (this._hours = e[0], this._minutes = e[1]) : (this._hours = "", this._minutes = "");
|
|
208
|
+
}
|
|
209
|
+
_syncValueFromDisplay() {
|
|
210
|
+
if (this._hours !== "" && this._minutes !== "") {
|
|
211
|
+
let e = `${this._hours}:${this._minutes}`;
|
|
212
|
+
e !== this.value && (this.value = e, this.onChange(e));
|
|
213
|
+
} else this.value !== "" && (this.value = "", this.onChange(""));
|
|
214
|
+
}
|
|
215
|
+
get _minuteStep() {
|
|
216
|
+
return h(this.step);
|
|
217
|
+
}
|
|
218
|
+
get _hourOptions() {
|
|
219
|
+
return g(this.min, this.max);
|
|
220
|
+
}
|
|
221
|
+
get _minuteOptions() {
|
|
222
|
+
return _(this.step);
|
|
223
|
+
}
|
|
224
|
+
_openPopup() {
|
|
225
|
+
this._isOpen = !0, this.updateComplete.then(() => {
|
|
226
|
+
this._scrollToSelected(), this._focusSelectedOrFirst("hour");
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
_closePopup() {
|
|
230
|
+
this._isOpen = !1, this._syncValueFromDisplay();
|
|
231
|
+
}
|
|
232
|
+
_togglePopup() {
|
|
233
|
+
this._isOpen ? this._closePopup() : this._openPopup();
|
|
234
|
+
}
|
|
235
|
+
_scrollToSelected() {
|
|
236
|
+
let e = this.querySelector(".pkt-timepicker-popup");
|
|
237
|
+
e && e.querySelectorAll(".pkt-timepicker-popup__col").forEach((e) => {
|
|
238
|
+
let t = e.querySelector(".pkt-timepicker-popup__option--selected");
|
|
239
|
+
t && t.scrollIntoView({ block: "center" });
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
_focusSelectedOrFirst(e) {
|
|
243
|
+
let t = this.querySelector(".pkt-timepicker-popup");
|
|
244
|
+
if (!t) return;
|
|
245
|
+
let n = t.querySelectorAll(".pkt-timepicker-popup__col"), r = e === "hour" ? n[0] : n[1];
|
|
246
|
+
if (!r) return;
|
|
247
|
+
let i = r.querySelector(".pkt-timepicker-popup__option--selected"), a = r.querySelector(".pkt-timepicker-popup__option");
|
|
248
|
+
(i || a)?.focus();
|
|
249
|
+
}
|
|
250
|
+
_handleOptionClick(e, t) {
|
|
251
|
+
let n = String(e).padStart(2, "0");
|
|
252
|
+
t === "hour" ? (this._hours = n, this.updateComplete.then(() => this._focusSelectedOrFirst("minute"))) : (this._minutes = n, this._closePopup(), this.buttonRef.value?.focus());
|
|
253
|
+
}
|
|
254
|
+
_focusOptionAndSync(e, t) {
|
|
255
|
+
if (!e) return;
|
|
256
|
+
let n = parseInt(e.dataset.value ?? "0", 10);
|
|
257
|
+
t === "hour" ? this._hours = String(n).padStart(2, "0") : this._minutes = String(n).padStart(2, "0"), e.focus();
|
|
258
|
+
}
|
|
259
|
+
_stepTime(e) {
|
|
260
|
+
let t = v(this._hours, this._minutes, e, this._minuteStep);
|
|
261
|
+
this._hours = t.hours, this._minutes = t.minutes, this._syncValueFromDisplay();
|
|
262
|
+
}
|
|
263
|
+
_renderOption(e, n) {
|
|
264
|
+
let r = String(e).padStart(2, "0"), i = e === (n === "hour" ? this._hours === "" ? NaN : parseInt(this._hours, 10) : this._minutes === "" ? NaN : parseInt(this._minutes, 10));
|
|
265
|
+
return t`
|
|
266
|
+
<button
|
|
267
|
+
class=${s({
|
|
268
|
+
"pkt-btn": !0,
|
|
269
|
+
"pkt-btn--tertiary": !0,
|
|
270
|
+
"pkt-btn--small": !0,
|
|
271
|
+
"pkt-btn--label-only": !0,
|
|
272
|
+
"pkt-timepicker-popup__option": !0,
|
|
273
|
+
"pkt-timepicker-popup__option--selected": i
|
|
274
|
+
})}
|
|
275
|
+
type="button"
|
|
276
|
+
role="option"
|
|
277
|
+
aria-selected=${i ? "true" : "false"}
|
|
278
|
+
tabindex=${i ? "0" : "-1"}
|
|
279
|
+
data-type=${n}
|
|
280
|
+
data-value=${e}
|
|
281
|
+
@click=${(t) => {
|
|
282
|
+
t.stopImmediatePropagation(), this._handleOptionClick(e, n);
|
|
283
|
+
}}
|
|
284
|
+
>
|
|
285
|
+
<span class="pkt-btn__text pkt-txt-14-light">${r}</span>
|
|
286
|
+
</button>
|
|
287
|
+
`;
|
|
288
|
+
}
|
|
289
|
+
_renderPopup() {
|
|
290
|
+
return t`
|
|
291
|
+
<div
|
|
292
|
+
class="pkt-timepicker-popup"
|
|
293
|
+
id=${this.id + "-popup"}
|
|
294
|
+
?hidden=${!this._isOpen}
|
|
295
|
+
role="group"
|
|
296
|
+
aria-label=${this.strings.timepicker?.selectTime ?? "Velg tidspunkt"}
|
|
297
|
+
@keydown=${this._handlePopupKeydown}
|
|
298
|
+
@focusout=${(e) => {
|
|
299
|
+
this.querySelector(".pkt-timepicker-popup")?.contains(e.relatedTarget) || this._closePopup();
|
|
300
|
+
}}
|
|
301
|
+
>
|
|
302
|
+
<div
|
|
303
|
+
class="pkt-timepicker-popup__col"
|
|
304
|
+
role="listbox"
|
|
305
|
+
aria-label=${this.strings.timepicker?.hours ?? "Timer"}
|
|
306
|
+
aria-orientation="vertical"
|
|
307
|
+
>
|
|
308
|
+
${this._hourOptions.map((e) => this._renderOption(e, "hour"))}
|
|
309
|
+
</div>
|
|
310
|
+
<div
|
|
311
|
+
class="pkt-timepicker-popup__col"
|
|
312
|
+
role="listbox"
|
|
313
|
+
aria-label=${this.strings.timepicker?.minutes ?? "Minutter"}
|
|
314
|
+
aria-orientation="vertical"
|
|
315
|
+
>
|
|
316
|
+
${this._minuteOptions.map((e) => this._renderOption(e, "minute"))}
|
|
317
|
+
</div>
|
|
318
|
+
</div>
|
|
319
|
+
`;
|
|
320
|
+
}
|
|
321
|
+
_renderContainer() {
|
|
322
|
+
let e = this.strings.timepicker?.hours ?? "Timer", n = this.strings.timepicker?.minutes ?? "Minutter", i = this.label ? `${e}, ${this.label}` : e, a = this.label ? `${n}, ${this.label}` : n;
|
|
323
|
+
return t`
|
|
324
|
+
<div
|
|
325
|
+
class="pkt-input__container"
|
|
326
|
+
@click=${(e) => {
|
|
327
|
+
e.target.closest("button, input") || this.hoursInputRef.value?.focus();
|
|
328
|
+
}}
|
|
329
|
+
>
|
|
330
|
+
${this.stepArrows ? t`
|
|
331
|
+
<button
|
|
332
|
+
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-timepicker__button pkt-timepicker__button--prev"
|
|
333
|
+
type="button"
|
|
334
|
+
aria-label=${this.strings.timepicker?.prevTime ?? "Forrige tidspunkt"}
|
|
335
|
+
?disabled=${this.disabled}
|
|
336
|
+
@click=${() => this._stepTime(-1)}
|
|
337
|
+
>
|
|
338
|
+
<pkt-icon name="chevron-thin-left"></pkt-icon>
|
|
339
|
+
<span class="pkt-btn__text"
|
|
340
|
+
>${this.strings.timepicker?.prevTime ?? "Forrige tidspunkt"}</span
|
|
341
|
+
>
|
|
342
|
+
</button>
|
|
343
|
+
` : r}
|
|
344
|
+
<input
|
|
345
|
+
${u(this.hoursInputRef)}
|
|
346
|
+
type="text"
|
|
347
|
+
inputmode="numeric"
|
|
348
|
+
maxlength="2"
|
|
349
|
+
size="2"
|
|
350
|
+
class="pkt-input pkt-timepicker__input"
|
|
351
|
+
id=${this.id + "-hours"}
|
|
352
|
+
data-min="0"
|
|
353
|
+
data-max="23"
|
|
354
|
+
.value=${this._hours}
|
|
355
|
+
placeholder="––"
|
|
356
|
+
aria-label=${i}
|
|
357
|
+
role="spinbutton"
|
|
358
|
+
aria-invalid=${this.hasError ? "true" : r}
|
|
359
|
+
aria-valuemin="0"
|
|
360
|
+
aria-valuemax="23"
|
|
361
|
+
aria-valuenow=${this._hours === "" ? r : this._hours}
|
|
362
|
+
aria-valuetext=${this._hours === "" ? r : `${this._hours} ${e.toLowerCase()}`}
|
|
363
|
+
autocomplete="off"
|
|
364
|
+
?disabled=${this.disabled}
|
|
365
|
+
@keydown=${this._handleHoursKeydown}
|
|
366
|
+
@blur=${this._handleHoursBlur}
|
|
367
|
+
@focus=${(e) => {
|
|
368
|
+
e.target.select(), e.stopImmediatePropagation();
|
|
369
|
+
}}
|
|
370
|
+
/>
|
|
371
|
+
<span class="pkt-timepicker__separator">:</span>
|
|
372
|
+
<input
|
|
373
|
+
${u(this.minutesInputRef)}
|
|
374
|
+
type="text"
|
|
375
|
+
inputmode="numeric"
|
|
376
|
+
maxlength="2"
|
|
377
|
+
size="2"
|
|
378
|
+
class="pkt-input pkt-timepicker__input"
|
|
379
|
+
id=${this.id + "-minutes"}
|
|
380
|
+
data-min="0"
|
|
381
|
+
data-max="59"
|
|
382
|
+
.value=${this._minutes}
|
|
383
|
+
placeholder="––"
|
|
384
|
+
aria-label=${a}
|
|
385
|
+
role="spinbutton"
|
|
386
|
+
aria-invalid=${this.hasError ? "true" : r}
|
|
387
|
+
aria-valuemin="0"
|
|
388
|
+
aria-valuemax="59"
|
|
389
|
+
aria-valuenow=${this._minutes === "" ? r : this._minutes}
|
|
390
|
+
aria-valuetext=${this._minutes === "" ? r : `${this._minutes} ${n.toLowerCase()}`}
|
|
391
|
+
autocomplete="off"
|
|
392
|
+
?disabled=${this.disabled}
|
|
393
|
+
@keydown=${this._handleMinutesKeydown}
|
|
394
|
+
@blur=${this._handleMinutesBlur}
|
|
395
|
+
@focus=${(e) => {
|
|
396
|
+
e.target.select(), e.stopImmediatePropagation();
|
|
397
|
+
}}
|
|
398
|
+
/>
|
|
399
|
+
${this.hidePicker && !this.stepArrows ? t`<pkt-icon
|
|
400
|
+
class="pkt-input-icon pkt-timepicker__icon"
|
|
401
|
+
name="clock"
|
|
402
|
+
aria-hidden="true"
|
|
403
|
+
></pkt-icon>` : r}
|
|
404
|
+
${!this.hidePicker && !this.stepArrows ? t`
|
|
405
|
+
<button
|
|
406
|
+
${u(this.buttonRef)}
|
|
407
|
+
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-timepicker__button"
|
|
408
|
+
type="button"
|
|
409
|
+
aria-label=${this.strings.timepicker?.openPicker ?? "Åpne tidspunkt-velger"}
|
|
410
|
+
aria-haspopup="listbox"
|
|
411
|
+
aria-expanded=${this._isOpen ? "true" : "false"}
|
|
412
|
+
aria-controls=${this.id + "-popup"}
|
|
413
|
+
?disabled=${this.disabled}
|
|
414
|
+
@click=${this._togglePopup}
|
|
415
|
+
>
|
|
416
|
+
<pkt-icon name="clock"></pkt-icon>
|
|
417
|
+
<span class="pkt-btn__text"
|
|
418
|
+
>${this.strings.timepicker?.openPicker ?? "Åpne tidspunkt-velger"}</span
|
|
419
|
+
>
|
|
420
|
+
</button>
|
|
421
|
+
` : r}
|
|
422
|
+
${this.stepArrows ? t`
|
|
423
|
+
<button
|
|
424
|
+
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-timepicker__button pkt-timepicker__button--next"
|
|
425
|
+
type="button"
|
|
426
|
+
aria-label=${this.strings.timepicker?.nextTime ?? "Neste tidspunkt"}
|
|
427
|
+
?disabled=${this.disabled}
|
|
428
|
+
@click=${() => this._stepTime(1)}
|
|
429
|
+
>
|
|
430
|
+
<pkt-icon name="chevron-thin-right"></pkt-icon>
|
|
431
|
+
<span class="pkt-btn__text"
|
|
432
|
+
>${this.strings.timepicker?.nextTime ?? "Neste tidspunkt"}</span
|
|
433
|
+
>
|
|
434
|
+
</button>
|
|
435
|
+
` : r}
|
|
436
|
+
<input
|
|
437
|
+
${u(this.hiddenInputRef)}
|
|
438
|
+
type="time"
|
|
439
|
+
hidden
|
|
440
|
+
name=${this.name || this.id}
|
|
441
|
+
id=${this.id + "-input"}
|
|
442
|
+
.value=${this.value}
|
|
443
|
+
min=${l(this.min ?? void 0)}
|
|
444
|
+
max=${l(this.max ?? void 0)}
|
|
445
|
+
step=${l(this.step ?? void 0)}
|
|
446
|
+
?required=${this.required}
|
|
447
|
+
?disabled=${this.disabled}
|
|
448
|
+
tabindex="-1"
|
|
449
|
+
/>
|
|
450
|
+
</div>
|
|
451
|
+
`;
|
|
452
|
+
}
|
|
453
|
+
render() {
|
|
454
|
+
return t`
|
|
455
|
+
<pkt-input-wrapper
|
|
456
|
+
label="${this.label}"
|
|
457
|
+
?disabled=${this.disabled}
|
|
458
|
+
?fullwidth=${this.fullwidth}
|
|
459
|
+
?hasError=${this.hasError}
|
|
460
|
+
?inline=${this.inline}
|
|
461
|
+
?optionalTag=${this.optionalTag}
|
|
462
|
+
?required=${this.required}
|
|
463
|
+
?requiredTag=${this.requiredTag}
|
|
464
|
+
useWrapper=${this.useWrapper}
|
|
465
|
+
.ariaDescribedBy=${this.ariaDescribedBy}
|
|
466
|
+
.errorMessage=${this.errorMessage}
|
|
467
|
+
.forId="${this.id + "-hours"}"
|
|
468
|
+
.helptext=${this.helptext}
|
|
469
|
+
.helptextDropdown=${this.helptextDropdown}
|
|
470
|
+
.helptextDropdownButton=${this.helptextDropdownButton}
|
|
471
|
+
.optionalText=${this.optionalText}
|
|
472
|
+
.requiredText=${this.requiredText}
|
|
473
|
+
.tagText=${this.tagText}
|
|
474
|
+
>
|
|
475
|
+
<div class="pkt-contents" slot="helptext">${c(this, "helptext")}</div>
|
|
476
|
+
${!this.hidePicker && !this.stepArrows ? t`
|
|
477
|
+
<div class="pkt-timepicker__anchor">
|
|
478
|
+
${this._renderContainer()} ${this._renderPopup()}
|
|
479
|
+
</div>
|
|
480
|
+
` : this._renderContainer()}
|
|
481
|
+
</pkt-input-wrapper>
|
|
482
|
+
`;
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
a([o({
|
|
486
|
+
type: String,
|
|
487
|
+
reflect: !0
|
|
488
|
+
})], y.prototype, "value", void 0), a([o({
|
|
489
|
+
type: Boolean,
|
|
490
|
+
reflect: !0,
|
|
491
|
+
attribute: "hide-picker"
|
|
492
|
+
})], y.prototype, "hidePicker", void 0), a([o({
|
|
493
|
+
type: Boolean,
|
|
494
|
+
reflect: !0,
|
|
495
|
+
attribute: "step-arrows"
|
|
496
|
+
})], y.prototype, "stepArrows", void 0), a([i()], y.prototype, "_hours", void 0), a([i()], y.prototype, "_minutes", void 0), a([i()], y.prototype, "_isOpen", void 0);
|
|
497
|
+
try {
|
|
498
|
+
e("pkt-timepicker")(y);
|
|
499
|
+
} catch {
|
|
500
|
+
console.warn("Forsøker å definere <pkt-timepicker>, men den er allerede definert");
|
|
501
|
+
}
|
|
502
|
+
//#endregion
|
|
503
|
+
export { y as t };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region ../../shared-utils/utils.ts
|
|
2
|
+
var e = () => ("00000000000000000" + (Math.random() * 0x10000000000000000).toString(16)).slice(-16), t = (e) => new Promise((t) => setTimeout(t, e)), n = () => {
|
|
3
|
+
let t = e(), n = e();
|
|
4
|
+
return t.slice(0, 8) + "-" + t.slice(8, 12) + "-4" + t.slice(13) + "-a" + n.slice(1, 4) + "-" + n.slice(4);
|
|
5
|
+
};
|
|
6
|
+
//#endregion
|
|
7
|
+
export { n, t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=()=>(`00000000000000000`+(Math.random()*0x10000000000000000).toString(16)).slice(-16),t=e=>new Promise(t=>setTimeout(t,e)),n=()=>{let t=e(),n=e();return t.slice(0,8)+`-`+t.slice(8,12)+`-4`+t.slice(13)+`-a`+n.slice(1,4)+`-`+n.slice(4)};Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "16.7.
|
|
3
|
+
"version": "16.7.4",
|
|
4
4
|
"description": "Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo Origo",
|
|
@@ -45,18 +45,18 @@
|
|
|
45
45
|
"@testing-library/jest-dom": "^6.6.3",
|
|
46
46
|
"@typescript-eslint/eslint-plugin": "^8.46.0",
|
|
47
47
|
"@typescript-eslint/parser": "^8.46.0",
|
|
48
|
-
"@vitest/ui": "^
|
|
48
|
+
"@vitest/ui": "^4.1.4",
|
|
49
49
|
"eslint": "^9.37.0",
|
|
50
50
|
"eslint-config-prettier": "^9.1.0",
|
|
51
51
|
"eslint-plugin-lit": "^2.1.1",
|
|
52
52
|
"jest-axe": "^9.0.0",
|
|
53
53
|
"jsdom": "^23.0.0",
|
|
54
54
|
"sass": "^1.78.0",
|
|
55
|
-
"typescript": "^
|
|
56
|
-
"vite": "^
|
|
55
|
+
"typescript": "^6.0.2",
|
|
56
|
+
"vite": "^8.0.8",
|
|
57
57
|
"vite-plugin-dts": "^4.2.1",
|
|
58
58
|
"vite-plugin-web-components-hmr": "^0.1.3",
|
|
59
|
-
"vitest": "^
|
|
59
|
+
"vitest": "^4.1.4"
|
|
60
60
|
},
|
|
61
61
|
"private": false,
|
|
62
62
|
"publishConfig": {
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
79
79
|
},
|
|
80
80
|
"license": "MIT",
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "f2b6bdd4aef8bad3b3aafedd850d8a5408b06efe"
|
|
82
82
|
}
|
|
@@ -171,7 +171,7 @@ describe('PktAlert', () => {
|
|
|
171
171
|
await alert.updateComplete
|
|
172
172
|
|
|
173
173
|
// The component uses the ariaLive property value that was set
|
|
174
|
-
expect(alert
|
|
174
|
+
expect(alert.ariaLiveAttr).toBe('assertive')
|
|
175
175
|
|
|
176
176
|
const alertDiv = alert.querySelector('.pkt-alert')
|
|
177
177
|
expect(alertDiv?.getAttribute('aria-live')).toBe('assertive')
|
|
@@ -18,7 +18,6 @@ export interface IPktAlert {
|
|
|
18
18
|
title?: string
|
|
19
19
|
date?: string | null
|
|
20
20
|
ariaLive?: TAriaLive | null
|
|
21
|
-
'aria-live'?: TAriaLive | null
|
|
22
21
|
compact?: boolean
|
|
23
22
|
role?: string
|
|
24
23
|
}
|
|
@@ -35,7 +34,8 @@ export class PktAlert extends PktElementWithSlot implements IPktAlert {
|
|
|
35
34
|
@property({ type: String, reflect: true }) skin: TAlertSkin = specs.props.skin
|
|
36
35
|
.default as TAlertSkin
|
|
37
36
|
@property({ type: String }) ariaLive: TAriaLive = specs.props.ariaLive.default as TAriaLive
|
|
38
|
-
@property({ type: String, reflect: true
|
|
37
|
+
@property({ type: String, reflect: true, attribute: 'aria-live' })
|
|
38
|
+
ariaLiveAttr: TAriaLive | null = null
|
|
39
39
|
@property({ type: Boolean, reflect: true }) closeAlert = specs.props.closeAlert.default
|
|
40
40
|
@property({ type: String, reflect: true }) date: string | null = null
|
|
41
41
|
@property({ type: String, reflect: true }) role: string = 'status'
|
|
@@ -46,12 +46,12 @@ export class PktAlert extends PktElementWithSlot implements IPktAlert {
|
|
|
46
46
|
|
|
47
47
|
connectedCallback(): void {
|
|
48
48
|
super.connectedCallback()
|
|
49
|
-
this
|
|
49
|
+
this.ariaLiveAttr = (this.getAttribute('aria-live') as TAriaLive) || this.ariaLive
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
|
|
53
53
|
if (name === 'ariaLive') {
|
|
54
|
-
this
|
|
54
|
+
this.ariaLiveAttr = value as TAriaLive
|
|
55
55
|
}
|
|
56
56
|
super.attributeChangedCallback(name, _old, value)
|
|
57
57
|
}
|
|
@@ -59,7 +59,7 @@ export class PktAlert extends PktElementWithSlot implements IPktAlert {
|
|
|
59
59
|
protected updated(_changedProperties: PropertyValues): void {
|
|
60
60
|
super.updated(_changedProperties)
|
|
61
61
|
if (_changedProperties.has('ariaLive')) {
|
|
62
|
-
this
|
|
62
|
+
this.ariaLiveAttr = this.ariaLive
|
|
63
63
|
}
|
|
64
64
|
if (_changedProperties.has('_isClosed')) {
|
|
65
65
|
updateClassAttribute(this, 'pkt-hide', this._isClosed)
|
|
@@ -83,7 +83,7 @@ export class PktAlert extends PktElementWithSlot implements IPktAlert {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
return html`
|
|
86
|
-
<div class=${classMap(classes)} aria-live=${this
|
|
86
|
+
<div class=${classMap(classes)} aria-live=${this.ariaLiveAttr}>
|
|
87
87
|
<div class=${classMap(gridClasses)}>
|
|
88
88
|
<pkt-icon
|
|
89
89
|
class="pkt-alert__icon"
|