@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
package/dist/pkt-timepicker.js
CHANGED
|
@@ -1,560 +1,2 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
|
|
3
|
-
import { e as m, n as _ } from "./ref-Bg_Swj5w.js";
|
|
4
|
-
import { o as k } from "./if-defined-B0krMLad.js";
|
|
5
|
-
import { e as F } from "./class-map-CEnykyO_.js";
|
|
6
|
-
import { P as A } from "./input-element-8nLwuQS4.js";
|
|
7
|
-
import { s as C } from "./element-with-slot-Dqk6-TRR.js";
|
|
8
|
-
import "./icon-CxQcIa5F.js";
|
|
9
|
-
import "./input-wrapper-Bs4CRNst.js";
|
|
10
|
-
const O = (a) => /^\d{2}:\d{2}$/.test(a) && parseInt(a.slice(0, 2), 10) <= 23 && parseInt(a.slice(3), 10) <= 59, f = (a) => {
|
|
11
|
-
const [t, e] = a.split(":").map(Number);
|
|
12
|
-
return t * 60 + e;
|
|
13
|
-
}, g = (a) => a ? Math.max(1, Math.round(a / 60)) : 1, T = (a, t) => {
|
|
14
|
-
const e = a ? parseInt(String(a).split(":")[0], 10) : 0, s = t ? parseInt(String(t).split(":")[0], 10) : 23;
|
|
15
|
-
return Array.from({ length: s - e + 1 }, (i, n) => n + e);
|
|
16
|
-
}, M = (a) => {
|
|
17
|
-
const t = g(a);
|
|
18
|
-
return Array.from({ length: Math.floor(60 / t) }, (e, s) => s * t);
|
|
19
|
-
}, V = (a, t, e, s) => {
|
|
20
|
-
let r = a !== "" ? parseInt(a, 10) : e === 1 ? 0 : 23, o = t !== "" ? parseInt(t, 10) : e === 1 ? 0 : Math.floor(59 / s) * s;
|
|
21
|
-
return o += e * s, o > 59 ? (o = 0, r = (r + 1) % 24) : o < 0 && (o = Math.floor(59 / s) * s, r = (r - 1 + 24) % 24), {
|
|
22
|
-
hours: String(r).padStart(2, "0"),
|
|
23
|
-
minutes: String(o).padStart(2, "0")
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
var P = Object.defineProperty, d = (a, t, e, s) => {
|
|
27
|
-
for (var i = void 0, n = a.length - 1, r; n >= 0; n--)
|
|
28
|
-
(r = a[n]) && (i = r(t, e, i) || i);
|
|
29
|
-
return i && P(t, e, i), i;
|
|
30
|
-
};
|
|
31
|
-
class l extends A {
|
|
32
|
-
constructor() {
|
|
33
|
-
super(...arguments), this.hiddenInputRef = m(), this.hoursInputRef = m(), this.minutesInputRef = m(), this.buttonRef = m(), 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 = (t) => {
|
|
34
|
-
this.contains(t.target) || this._closePopup();
|
|
35
|
-
}, this._handleComponentFocusIn = () => {
|
|
36
|
-
this._hasFocus || (this._hasFocus = !0, this.onFocus());
|
|
37
|
-
}, this._handleComponentFocusOut = (t) => {
|
|
38
|
-
this.contains(t.relatedTarget) || (this._hasFocus = !1, this.onBlur());
|
|
39
|
-
}, this._handleHoursKeydown = (t) => {
|
|
40
|
-
var s, i, n;
|
|
41
|
-
const e = t.target;
|
|
42
|
-
switch (t.key) {
|
|
43
|
-
case "ArrowUp": {
|
|
44
|
-
t.preventDefault();
|
|
45
|
-
const r = this._hours !== "" ? parseInt(this._hours, 10) : 0;
|
|
46
|
-
this._hours = String((r + 1) % 24).padStart(2, "0"), this._syncValueFromDisplay(), this.onInput();
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
case "ArrowDown": {
|
|
50
|
-
t.preventDefault();
|
|
51
|
-
const r = this._hours !== "" ? parseInt(this._hours, 10) : 0;
|
|
52
|
-
this._hours = String((r - 1 + 24) % 24).padStart(2, "0"), this._syncValueFromDisplay(), this.onInput();
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
case "ArrowRight":
|
|
56
|
-
t.preventDefault(), (s = this.minutesInputRef.value) == null || s.focus();
|
|
57
|
-
break;
|
|
58
|
-
case "Backspace":
|
|
59
|
-
case "Delete":
|
|
60
|
-
this._hoursDigitCount = 0, this._hoursFirstDigit = -1;
|
|
61
|
-
break;
|
|
62
|
-
case "Tab":
|
|
63
|
-
break;
|
|
64
|
-
case "Enter": {
|
|
65
|
-
t.preventDefault();
|
|
66
|
-
const r = this.internals.form;
|
|
67
|
-
r ? r.requestSubmit() : e.blur();
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
default:
|
|
71
|
-
if (/^\d$/.test(t.key)) {
|
|
72
|
-
t.preventDefault();
|
|
73
|
-
const r = parseInt(t.key, 10);
|
|
74
|
-
if (this._hoursDigitCount === 0)
|
|
75
|
-
this._hoursFirstDigit = r, this._hours = String(r).padStart(2, "0"), this._hoursDigitCount = 1, this.onInput(), r >= 3 && (this._hoursFirstDigit = -1, this._hoursDigitCount = 0, this._syncValueFromDisplay(), (i = this.minutesInputRef.value) == null || i.focus());
|
|
76
|
-
else {
|
|
77
|
-
const o = this._hoursFirstDigit * 10 + r;
|
|
78
|
-
this._hours = o <= 23 ? String(o).padStart(2, "0") : String(r).padStart(2, "0"), this._hoursFirstDigit = -1, this._hoursDigitCount = 0, this._syncValueFromDisplay(), this.onInput(), (n = this.minutesInputRef.value) == null || n.focus();
|
|
79
|
-
}
|
|
80
|
-
} else
|
|
81
|
-
t.preventDefault();
|
|
82
|
-
}
|
|
83
|
-
}, this._handleHoursBlur = () => {
|
|
84
|
-
this._hours !== "" && (this._hours = String(parseInt(this._hours, 10)).padStart(2, "0")), this._hoursDigitCount = 0, this._hoursFirstDigit = -1, this._syncValueFromDisplay();
|
|
85
|
-
}, this._handleMinutesKeydown = (t) => {
|
|
86
|
-
var s;
|
|
87
|
-
const e = t.target;
|
|
88
|
-
switch (t.key) {
|
|
89
|
-
case "ArrowUp": {
|
|
90
|
-
t.preventDefault();
|
|
91
|
-
const i = this._minutes !== "" ? parseInt(this._minutes, 10) : 0;
|
|
92
|
-
this._minutes = String((i + this._minuteStep) % 60).padStart(2, "0"), this._syncValueFromDisplay(), this.onInput();
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
case "ArrowDown": {
|
|
96
|
-
t.preventDefault();
|
|
97
|
-
const i = this._minutes !== "" ? parseInt(this._minutes, 10) : 0;
|
|
98
|
-
this._minutes = String((i - this._minuteStep + 60) % 60).padStart(2, "0"), this._syncValueFromDisplay(), this.onInput();
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
case "ArrowLeft":
|
|
102
|
-
t.preventDefault(), (s = this.hoursInputRef.value) == null || s.focus();
|
|
103
|
-
break;
|
|
104
|
-
case "Backspace":
|
|
105
|
-
case "Delete":
|
|
106
|
-
this._minutesDigitCount = 0, this._minutesFirstDigit = -1;
|
|
107
|
-
break;
|
|
108
|
-
case "Tab":
|
|
109
|
-
break;
|
|
110
|
-
case "Enter": {
|
|
111
|
-
t.preventDefault();
|
|
112
|
-
const i = this.internals.form;
|
|
113
|
-
i ? i.requestSubmit() : e.blur();
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
default:
|
|
117
|
-
if (/^\d$/.test(t.key)) {
|
|
118
|
-
t.preventDefault();
|
|
119
|
-
const i = parseInt(t.key, 10);
|
|
120
|
-
if (this._minutesDigitCount === 0)
|
|
121
|
-
this._minutesFirstDigit = i, this._minutes = String(i).padStart(2, "0"), this._minutesDigitCount = 1, this.onInput(), i >= 6 && (this._minutesFirstDigit = -1, this._minutesDigitCount = 0, this._syncValueFromDisplay());
|
|
122
|
-
else {
|
|
123
|
-
const n = this._minutesFirstDigit * 10 + i;
|
|
124
|
-
this._minutes = n <= 59 ? String(n).padStart(2, "0") : String(i).padStart(2, "0"), this._minutesFirstDigit = -1, this._minutesDigitCount = 0, this._syncValueFromDisplay(), this.onInput();
|
|
125
|
-
}
|
|
126
|
-
} else
|
|
127
|
-
t.preventDefault();
|
|
128
|
-
}
|
|
129
|
-
}, this._handleMinutesBlur = () => {
|
|
130
|
-
this._minutes !== "" && (this._minutes = String(parseInt(this._minutes, 10)).padStart(2, "0")), this._minutesDigitCount = 0, this._minutesFirstDigit = -1, this._syncValueFromDisplay();
|
|
131
|
-
}, this._handlePopupKeydown = (t) => {
|
|
132
|
-
var o;
|
|
133
|
-
const e = document.activeElement, s = e.closest(".pkt-timepicker-popup__col");
|
|
134
|
-
if (!s) return;
|
|
135
|
-
const i = Array.from(s.querySelectorAll(".pkt-timepicker-popup__option")), n = i.indexOf(e), r = e.dataset.type ?? "";
|
|
136
|
-
switch (t.key) {
|
|
137
|
-
case "ArrowDown":
|
|
138
|
-
t.preventDefault(), this._focusOptionAndSync(i[Math.min(n + 1, i.length - 1)], r);
|
|
139
|
-
break;
|
|
140
|
-
case "ArrowUp":
|
|
141
|
-
t.preventDefault(), this._focusOptionAndSync(i[Math.max(n - 1, 0)], r);
|
|
142
|
-
break;
|
|
143
|
-
case "Home":
|
|
144
|
-
t.preventDefault(), this._focusOptionAndSync(i[0], r);
|
|
145
|
-
break;
|
|
146
|
-
case "End":
|
|
147
|
-
t.preventDefault(), this._focusOptionAndSync(i[i.length - 1], r);
|
|
148
|
-
break;
|
|
149
|
-
case "ArrowRight":
|
|
150
|
-
t.preventDefault(), r === "hour" && (this._focusOptionAndSync(e, r), this.updateComplete.then(() => {
|
|
151
|
-
this._scrollToSelected(), this._focusSelectedOrFirst("minute");
|
|
152
|
-
}));
|
|
153
|
-
break;
|
|
154
|
-
case "ArrowLeft":
|
|
155
|
-
t.preventDefault(), r === "minute" && (this._focusOptionAndSync(e, r), this.updateComplete.then(() => {
|
|
156
|
-
this._scrollToSelected(), this._focusSelectedOrFirst("hour");
|
|
157
|
-
}));
|
|
158
|
-
break;
|
|
159
|
-
case "Enter":
|
|
160
|
-
case " ":
|
|
161
|
-
t.preventDefault(), e.click();
|
|
162
|
-
break;
|
|
163
|
-
case "Escape":
|
|
164
|
-
t.preventDefault(), this._closePopup(), (o = this.buttonRef.value) == null || o.focus();
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Exposes hiddenInputRef as inputRef so the base class validate() method
|
|
171
|
-
* triggers our manageValidity override automatically after every onChange call.
|
|
172
|
-
* The hidden input itself is never used for reporting — see manageValidity below.
|
|
173
|
-
*/
|
|
174
|
-
get inputRef() {
|
|
175
|
-
return this.hiddenInputRef;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Overrides the base class manageValidity to solve a focusability problem:
|
|
179
|
-
* the browser requires the third argument to setValidity (the "anchor") to be
|
|
180
|
-
* a visible, focusable element — it focuses that element when navigating to an
|
|
181
|
-
* invalid field. Our hidden input[type=time] cannot receive focus, so passing it
|
|
182
|
-
* as the anchor would silently fail with "form control is not focusable".
|
|
183
|
-
*/
|
|
184
|
-
manageValidity(t) {
|
|
185
|
-
const e = this.hoursInputRef.value;
|
|
186
|
-
if (!e) return;
|
|
187
|
-
if (this.required && !this.value) {
|
|
188
|
-
this.internals.setValidity({ valueMissing: !0 }, c.forms.messages.required, e), this._setAriaInvalid(!0);
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
if (!this.value) {
|
|
192
|
-
this.internals.setValidity({}), this._setAriaInvalid(!1);
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
const s = f(this.value), i = g(this.step);
|
|
196
|
-
if (this.min && s < f(String(this.min))) {
|
|
197
|
-
this.internals.setValidity(
|
|
198
|
-
{ rangeUnderflow: !0 },
|
|
199
|
-
c.forms.messages.rangeUnderflowMin.replace("{min}", String(this.min)),
|
|
200
|
-
e
|
|
201
|
-
), this._setAriaInvalid(!0);
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
if (this.max && s > f(String(this.max))) {
|
|
205
|
-
this.internals.setValidity(
|
|
206
|
-
{ rangeOverflow: !0 },
|
|
207
|
-
c.forms.messages.rangeOverflowMax.replace("{max}", String(this.max)),
|
|
208
|
-
e
|
|
209
|
-
), this._setAriaInvalid(!0);
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
if (this.step && s % i !== 0) {
|
|
213
|
-
const n = i === 60 ? c.forms.messages.timeStepMismatchHour : i === 30 ? c.forms.messages.timeStepMismatchHalfHour : c.forms.messages.timeStepMismatch.replace(
|
|
214
|
-
"{step}",
|
|
215
|
-
`${i}, ${i * 2}, ${i * 3}`
|
|
216
|
-
);
|
|
217
|
-
this.internals.setValidity({ stepMismatch: !0 }, n, e), this._setAriaInvalid(!0);
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
this.internals.setValidity({}), this._setAriaInvalid(!1);
|
|
221
|
-
}
|
|
222
|
-
_setAriaInvalid(t) {
|
|
223
|
-
if (!this.touched && t) return;
|
|
224
|
-
const e = this.hoursInputRef.value, s = this.minutesInputRef.value;
|
|
225
|
-
t ? (e == null || e.setAttribute("aria-invalid", "true"), s == null || s.setAttribute("aria-invalid", "true")) : (e == null || e.removeAttribute("aria-invalid"), s == null || s.removeAttribute("aria-invalid"));
|
|
226
|
-
}
|
|
227
|
-
connectedCallback() {
|
|
228
|
-
super.connectedCallback(), this.addEventListener("focusin", this._handleComponentFocusIn), this.addEventListener("focusout", this._handleComponentFocusOut), document.addEventListener("click", this._outsideClickHandler);
|
|
229
|
-
}
|
|
230
|
-
disconnectedCallback() {
|
|
231
|
-
super.disconnectedCallback(), this.removeEventListener("focusin", this._handleComponentFocusIn), this.removeEventListener("focusout", this._handleComponentFocusOut), document.removeEventListener("click", this._outsideClickHandler);
|
|
232
|
-
}
|
|
233
|
-
willUpdate(t) {
|
|
234
|
-
super.willUpdate(t), t.has("value") && this._syncDisplayFromValue();
|
|
235
|
-
}
|
|
236
|
-
updated(t) {
|
|
237
|
-
super.updated(t), this.classList.toggle("pkt-timepicker--stepper", this.stepArrows), this.classList.toggle("pkt-timepicker--fullwidth", this.fullwidth), t.has("step") && this.step !== null && !this._isValidStep(this.step) && console.warn(
|
|
238
|
-
`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).`
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
formResetCallback() {
|
|
242
|
-
super.formResetCallback(), this._hours = "", this._minutes = "", this._isOpen = !1;
|
|
243
|
-
}
|
|
244
|
-
_isValidStep(t) {
|
|
245
|
-
return t === 3600 || t < 3600 && 3600 % t === 0 && t % 60 === 0;
|
|
246
|
-
}
|
|
247
|
-
_syncDisplayFromValue() {
|
|
248
|
-
const t = O(this.value) ? this.value.split(":") : null;
|
|
249
|
-
t ? (this._hours = t[0], this._minutes = t[1]) : (this._hours = "", this._minutes = "");
|
|
250
|
-
}
|
|
251
|
-
_syncValueFromDisplay() {
|
|
252
|
-
if (this._hours !== "" && this._minutes !== "") {
|
|
253
|
-
const t = `${this._hours}:${this._minutes}`;
|
|
254
|
-
t !== this.value && (this.value = t, this.onChange(t));
|
|
255
|
-
} else this.value !== "" && (this.value = "", this.onChange(""));
|
|
256
|
-
}
|
|
257
|
-
get _minuteStep() {
|
|
258
|
-
return g(this.step);
|
|
259
|
-
}
|
|
260
|
-
get _hourOptions() {
|
|
261
|
-
return T(this.min, this.max);
|
|
262
|
-
}
|
|
263
|
-
get _minuteOptions() {
|
|
264
|
-
return M(this.step);
|
|
265
|
-
}
|
|
266
|
-
_openPopup() {
|
|
267
|
-
this._isOpen = !0, this.updateComplete.then(() => {
|
|
268
|
-
this._scrollToSelected(), this._focusSelectedOrFirst("hour");
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
_closePopup() {
|
|
272
|
-
this._isOpen = !1, this._syncValueFromDisplay();
|
|
273
|
-
}
|
|
274
|
-
_togglePopup() {
|
|
275
|
-
this._isOpen ? this._closePopup() : this._openPopup();
|
|
276
|
-
}
|
|
277
|
-
_scrollToSelected() {
|
|
278
|
-
const t = this.querySelector(".pkt-timepicker-popup");
|
|
279
|
-
t && t.querySelectorAll(".pkt-timepicker-popup__col").forEach((e) => {
|
|
280
|
-
const s = e.querySelector(".pkt-timepicker-popup__option--selected");
|
|
281
|
-
s && s.scrollIntoView({ block: "center" });
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
_focusSelectedOrFirst(t) {
|
|
285
|
-
var o;
|
|
286
|
-
const e = this.querySelector(".pkt-timepicker-popup");
|
|
287
|
-
if (!e) return;
|
|
288
|
-
const s = e.querySelectorAll(".pkt-timepicker-popup__col"), i = t === "hour" ? s[0] : s[1];
|
|
289
|
-
if (!i) return;
|
|
290
|
-
const n = i.querySelector(
|
|
291
|
-
".pkt-timepicker-popup__option--selected"
|
|
292
|
-
), r = i.querySelector(".pkt-timepicker-popup__option");
|
|
293
|
-
(o = n || r) == null || o.focus();
|
|
294
|
-
}
|
|
295
|
-
_handleOptionClick(t, e) {
|
|
296
|
-
var i;
|
|
297
|
-
const s = String(t).padStart(2, "0");
|
|
298
|
-
e === "hour" ? (this._hours = s, this.updateComplete.then(() => this._focusSelectedOrFirst("minute"))) : (this._minutes = s, this._closePopup(), (i = this.buttonRef.value) == null || i.focus());
|
|
299
|
-
}
|
|
300
|
-
_focusOptionAndSync(t, e) {
|
|
301
|
-
if (!t) return;
|
|
302
|
-
const s = parseInt(t.dataset.value ?? "0", 10);
|
|
303
|
-
e === "hour" ? this._hours = String(s).padStart(2, "0") : this._minutes = String(s).padStart(2, "0"), t.focus();
|
|
304
|
-
}
|
|
305
|
-
_stepTime(t) {
|
|
306
|
-
const e = V(this._hours, this._minutes, t, this._minuteStep);
|
|
307
|
-
this._hours = e.hours, this._minutes = e.minutes, this._syncValueFromDisplay();
|
|
308
|
-
}
|
|
309
|
-
_renderOption(t, e) {
|
|
310
|
-
const s = String(t).padStart(2, "0"), i = e === "hour" ? this._hours !== "" ? parseInt(this._hours, 10) : NaN : this._minutes !== "" ? parseInt(this._minutes, 10) : NaN, n = t === i;
|
|
311
|
-
return u`
|
|
312
|
-
<button
|
|
313
|
-
class=${F({
|
|
314
|
-
"pkt-btn": !0,
|
|
315
|
-
"pkt-btn--tertiary": !0,
|
|
316
|
-
"pkt-btn--small": !0,
|
|
317
|
-
"pkt-btn--label-only": !0,
|
|
318
|
-
"pkt-timepicker-popup__option": !0,
|
|
319
|
-
"pkt-timepicker-popup__option--selected": n
|
|
320
|
-
})}
|
|
321
|
-
type="button"
|
|
322
|
-
role="option"
|
|
323
|
-
aria-selected=${n ? "true" : "false"}
|
|
324
|
-
tabindex=${n ? "0" : "-1"}
|
|
325
|
-
data-type=${e}
|
|
326
|
-
data-value=${t}
|
|
327
|
-
@click=${(r) => {
|
|
328
|
-
r.stopImmediatePropagation(), this._handleOptionClick(t, e);
|
|
329
|
-
}}
|
|
330
|
-
>
|
|
331
|
-
<span class="pkt-btn__text pkt-txt-14-light">${s}</span>
|
|
332
|
-
</button>
|
|
333
|
-
`;
|
|
334
|
-
}
|
|
335
|
-
_renderPopup() {
|
|
336
|
-
var t, e, s;
|
|
337
|
-
return u`
|
|
338
|
-
<div
|
|
339
|
-
class="pkt-timepicker-popup"
|
|
340
|
-
id=${this.id + "-popup"}
|
|
341
|
-
?hidden=${!this._isOpen}
|
|
342
|
-
role="group"
|
|
343
|
-
aria-label=${((t = this.strings.timepicker) == null ? void 0 : t.selectTime) ?? "Velg tidspunkt"}
|
|
344
|
-
@keydown=${this._handlePopupKeydown}
|
|
345
|
-
@focusout=${(i) => {
|
|
346
|
-
var n;
|
|
347
|
-
(n = this.querySelector(".pkt-timepicker-popup")) != null && n.contains(i.relatedTarget) || this._closePopup();
|
|
348
|
-
}}
|
|
349
|
-
>
|
|
350
|
-
<div
|
|
351
|
-
class="pkt-timepicker-popup__col"
|
|
352
|
-
role="listbox"
|
|
353
|
-
aria-label=${((e = this.strings.timepicker) == null ? void 0 : e.hours) ?? "Timer"}
|
|
354
|
-
aria-orientation="vertical"
|
|
355
|
-
>
|
|
356
|
-
${this._hourOptions.map((i) => this._renderOption(i, "hour"))}
|
|
357
|
-
</div>
|
|
358
|
-
<div
|
|
359
|
-
class="pkt-timepicker-popup__col"
|
|
360
|
-
role="listbox"
|
|
361
|
-
aria-label=${((s = this.strings.timepicker) == null ? void 0 : s.minutes) ?? "Minutter"}
|
|
362
|
-
aria-orientation="vertical"
|
|
363
|
-
>
|
|
364
|
-
${this._minuteOptions.map((i) => this._renderOption(i, "minute"))}
|
|
365
|
-
</div>
|
|
366
|
-
</div>
|
|
367
|
-
`;
|
|
368
|
-
}
|
|
369
|
-
_renderContainer() {
|
|
370
|
-
var n, r, o, $, y, S, D, w;
|
|
371
|
-
const t = ((n = this.strings.timepicker) == null ? void 0 : n.hours) ?? "Timer", e = ((r = this.strings.timepicker) == null ? void 0 : r.minutes) ?? "Minutter", s = this.label ? `${t}, ${this.label}` : t, i = this.label ? `${e}, ${this.label}` : e;
|
|
372
|
-
return u`
|
|
373
|
-
<div
|
|
374
|
-
class="pkt-input__container"
|
|
375
|
-
@click=${(h) => {
|
|
376
|
-
var x;
|
|
377
|
-
h.target.closest("button, input") || (x = this.hoursInputRef.value) == null || x.focus();
|
|
378
|
-
}}
|
|
379
|
-
>
|
|
380
|
-
${this.stepArrows ? u`
|
|
381
|
-
<button
|
|
382
|
-
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-timepicker__button pkt-timepicker__button--prev"
|
|
383
|
-
type="button"
|
|
384
|
-
aria-label=${((o = this.strings.timepicker) == null ? void 0 : o.prevTime) ?? "Forrige tidspunkt"}
|
|
385
|
-
?disabled=${this.disabled}
|
|
386
|
-
@click=${() => this._stepTime(-1)}
|
|
387
|
-
>
|
|
388
|
-
<pkt-icon name="chevron-thin-left"></pkt-icon>
|
|
389
|
-
<span class="pkt-btn__text"
|
|
390
|
-
>${(($ = this.strings.timepicker) == null ? void 0 : $.prevTime) ?? "Forrige tidspunkt"}</span
|
|
391
|
-
>
|
|
392
|
-
</button>
|
|
393
|
-
` : p}
|
|
394
|
-
<input
|
|
395
|
-
${_(this.hoursInputRef)}
|
|
396
|
-
type="text"
|
|
397
|
-
inputmode="numeric"
|
|
398
|
-
maxlength="2"
|
|
399
|
-
size="2"
|
|
400
|
-
class="pkt-input pkt-timepicker__input"
|
|
401
|
-
id=${this.id + "-hours"}
|
|
402
|
-
data-min="0"
|
|
403
|
-
data-max="23"
|
|
404
|
-
.value=${this._hours}
|
|
405
|
-
placeholder="––"
|
|
406
|
-
aria-label=${s}
|
|
407
|
-
role="spinbutton"
|
|
408
|
-
aria-invalid=${this.hasError ? "true" : p}
|
|
409
|
-
aria-valuemin="0"
|
|
410
|
-
aria-valuemax="23"
|
|
411
|
-
aria-valuenow=${this._hours !== "" ? this._hours : p}
|
|
412
|
-
aria-valuetext=${this._hours !== "" ? `${this._hours} ${t.toLowerCase()}` : p}
|
|
413
|
-
autocomplete="off"
|
|
414
|
-
?disabled=${this.disabled}
|
|
415
|
-
@keydown=${this._handleHoursKeydown}
|
|
416
|
-
@blur=${this._handleHoursBlur}
|
|
417
|
-
@focus=${(h) => {
|
|
418
|
-
h.target.select(), h.stopImmediatePropagation();
|
|
419
|
-
}}
|
|
420
|
-
/>
|
|
421
|
-
<span class="pkt-timepicker__separator">:</span>
|
|
422
|
-
<input
|
|
423
|
-
${_(this.minutesInputRef)}
|
|
424
|
-
type="text"
|
|
425
|
-
inputmode="numeric"
|
|
426
|
-
maxlength="2"
|
|
427
|
-
size="2"
|
|
428
|
-
class="pkt-input pkt-timepicker__input"
|
|
429
|
-
id=${this.id + "-minutes"}
|
|
430
|
-
data-min="0"
|
|
431
|
-
data-max="59"
|
|
432
|
-
.value=${this._minutes}
|
|
433
|
-
placeholder="––"
|
|
434
|
-
aria-label=${i}
|
|
435
|
-
role="spinbutton"
|
|
436
|
-
aria-invalid=${this.hasError ? "true" : p}
|
|
437
|
-
aria-valuemin="0"
|
|
438
|
-
aria-valuemax="59"
|
|
439
|
-
aria-valuenow=${this._minutes !== "" ? this._minutes : p}
|
|
440
|
-
aria-valuetext=${this._minutes !== "" ? `${this._minutes} ${e.toLowerCase()}` : p}
|
|
441
|
-
autocomplete="off"
|
|
442
|
-
?disabled=${this.disabled}
|
|
443
|
-
@keydown=${this._handleMinutesKeydown}
|
|
444
|
-
@blur=${this._handleMinutesBlur}
|
|
445
|
-
@focus=${(h) => {
|
|
446
|
-
h.target.select(), h.stopImmediatePropagation();
|
|
447
|
-
}}
|
|
448
|
-
/>
|
|
449
|
-
${this.hidePicker && !this.stepArrows ? u`<pkt-icon
|
|
450
|
-
class="pkt-input-icon pkt-timepicker__icon"
|
|
451
|
-
name="clock"
|
|
452
|
-
aria-hidden="true"
|
|
453
|
-
></pkt-icon>` : p}
|
|
454
|
-
${!this.hidePicker && !this.stepArrows ? u`
|
|
455
|
-
<button
|
|
456
|
-
${_(this.buttonRef)}
|
|
457
|
-
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-timepicker__button"
|
|
458
|
-
type="button"
|
|
459
|
-
aria-label=${((y = this.strings.timepicker) == null ? void 0 : y.openPicker) ?? "Åpne tidspunkt-velger"}
|
|
460
|
-
aria-haspopup="listbox"
|
|
461
|
-
aria-expanded=${this._isOpen ? "true" : "false"}
|
|
462
|
-
aria-controls=${this.id + "-popup"}
|
|
463
|
-
?disabled=${this.disabled}
|
|
464
|
-
@click=${this._togglePopup}
|
|
465
|
-
>
|
|
466
|
-
<pkt-icon name="clock"></pkt-icon>
|
|
467
|
-
<span class="pkt-btn__text"
|
|
468
|
-
>${((S = this.strings.timepicker) == null ? void 0 : S.openPicker) ?? "Åpne tidspunkt-velger"}</span
|
|
469
|
-
>
|
|
470
|
-
</button>
|
|
471
|
-
` : p}
|
|
472
|
-
${this.stepArrows ? u`
|
|
473
|
-
<button
|
|
474
|
-
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-timepicker__button pkt-timepicker__button--next"
|
|
475
|
-
type="button"
|
|
476
|
-
aria-label=${((D = this.strings.timepicker) == null ? void 0 : D.nextTime) ?? "Neste tidspunkt"}
|
|
477
|
-
?disabled=${this.disabled}
|
|
478
|
-
@click=${() => this._stepTime(1)}
|
|
479
|
-
>
|
|
480
|
-
<pkt-icon name="chevron-thin-right"></pkt-icon>
|
|
481
|
-
<span class="pkt-btn__text"
|
|
482
|
-
>${((w = this.strings.timepicker) == null ? void 0 : w.nextTime) ?? "Neste tidspunkt"}</span
|
|
483
|
-
>
|
|
484
|
-
</button>
|
|
485
|
-
` : p}
|
|
486
|
-
<input
|
|
487
|
-
${_(this.hiddenInputRef)}
|
|
488
|
-
type="time"
|
|
489
|
-
hidden
|
|
490
|
-
name=${this.name || this.id}
|
|
491
|
-
id=${this.id + "-input"}
|
|
492
|
-
.value=${this.value}
|
|
493
|
-
min=${k(this.min ?? void 0)}
|
|
494
|
-
max=${k(this.max ?? void 0)}
|
|
495
|
-
step=${k(this.step ?? void 0)}
|
|
496
|
-
?required=${this.required}
|
|
497
|
-
?disabled=${this.disabled}
|
|
498
|
-
tabindex="-1"
|
|
499
|
-
/>
|
|
500
|
-
</div>
|
|
501
|
-
`;
|
|
502
|
-
}
|
|
503
|
-
render() {
|
|
504
|
-
return u`
|
|
505
|
-
<pkt-input-wrapper
|
|
506
|
-
label="${this.label}"
|
|
507
|
-
?disabled=${this.disabled}
|
|
508
|
-
?fullwidth=${this.fullwidth}
|
|
509
|
-
?hasError=${this.hasError}
|
|
510
|
-
?inline=${this.inline}
|
|
511
|
-
?optionalTag=${this.optionalTag}
|
|
512
|
-
?required=${this.required}
|
|
513
|
-
?requiredTag=${this.requiredTag}
|
|
514
|
-
useWrapper=${this.useWrapper}
|
|
515
|
-
.ariaDescribedBy=${this.ariaDescribedBy}
|
|
516
|
-
.errorMessage=${this.errorMessage}
|
|
517
|
-
.forId="${this.id + "-hours"}"
|
|
518
|
-
.helptext=${this.helptext}
|
|
519
|
-
.helptextDropdown=${this.helptextDropdown}
|
|
520
|
-
.helptextDropdownButton=${this.helptextDropdownButton}
|
|
521
|
-
.optionalText=${this.optionalText}
|
|
522
|
-
.requiredText=${this.requiredText}
|
|
523
|
-
.tagText=${this.tagText}
|
|
524
|
-
>
|
|
525
|
-
<div class="pkt-contents" slot="helptext">${C(this, "helptext")}</div>
|
|
526
|
-
${!this.hidePicker && !this.stepArrows ? u`
|
|
527
|
-
<div class="pkt-timepicker__anchor">
|
|
528
|
-
${this._renderContainer()} ${this._renderPopup()}
|
|
529
|
-
</div>
|
|
530
|
-
` : this._renderContainer()}
|
|
531
|
-
</pkt-input-wrapper>
|
|
532
|
-
`;
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
d([
|
|
536
|
-
b({ type: String, reflect: !0 })
|
|
537
|
-
], l.prototype, "value");
|
|
538
|
-
d([
|
|
539
|
-
b({ type: Boolean, reflect: !0, attribute: "hide-picker" })
|
|
540
|
-
], l.prototype, "hidePicker");
|
|
541
|
-
d([
|
|
542
|
-
b({ type: Boolean, reflect: !0, attribute: "step-arrows" })
|
|
543
|
-
], l.prototype, "stepArrows");
|
|
544
|
-
d([
|
|
545
|
-
v()
|
|
546
|
-
], l.prototype, "_hours");
|
|
547
|
-
d([
|
|
548
|
-
v()
|
|
549
|
-
], l.prototype, "_minutes");
|
|
550
|
-
d([
|
|
551
|
-
v()
|
|
552
|
-
], l.prototype, "_isOpen");
|
|
553
|
-
try {
|
|
554
|
-
I("pkt-timepicker")(l);
|
|
555
|
-
} catch {
|
|
556
|
-
console.warn("Forsøker å definere <pkt-timepicker>, men den er allerede definert");
|
|
557
|
-
}
|
|
558
|
-
export {
|
|
559
|
-
l as PktTimepicker
|
|
560
|
-
};
|
|
1
|
+
import { t as e } from "./timepicker-DaSwn1FA.js";
|
|
2
|
+
export { e as PktTimepicker };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./directive-CJ2giQBZ.cjs`),n=require(`./class-map-CJ-msbHs.cjs`);require(`./icon-Dr8sfT2X.cjs`);const r=require(`./ref-BaJ0mBT_.cjs`),i=require(`./utils-CjAbIttF.cjs`);var a=`important`,o=` !`+a,s=t.t(class extends t.n{constructor(e){if(super(e),e.type!==t.r.ATTRIBUTE||e.name!==`style`||e.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce((t,n)=>{let r=e[n];return r==null?t:t+`${n=n.includes(`-`)?n:n.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,`-$&`).toLowerCase()}:${r};`},``)}update(t,[n]){let{style:r}=t.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(n)),this.render(n);for(let e of this.ft)n[e]??(this.ft.delete(e),e.includes(`-`)?r.removeProperty(e):r[e]=null);for(let e in n){let t=n[e];if(t!=null){this.ft.add(e);let n=typeof t==`string`&&t.endsWith(o);e.includes(`-`)||n?r.setProperty(e,n?t.slice(0,-11):t,n?a:``):r[e]=t}}return e.u}}),c=class extends e.t{constructor(){super(),this.ariaLabel=null,this.ariaLabelledby=null,this.ariaValueText=null,this.ariaLive=`polite`,this.id=i.n(),this.role=`progressbar`,this.skin=`dark-blue`,this.statusPlacement=`following`,this.statusType=`none`,this.title=``,this.titlePosition=`left`,this.valueCurrent=0,this.valueMax=100,this.valueMin=0,this.labelWidth=0,this.progressbarId=this.id,this.computedAriaLabelledby=null,this.computedAriaValueText=``,this.labelRef=r.t(),this.progressBarRef=r.t()}firstUpdated(e){super.firstUpdated(e),this.setComputedValues(),this.syncAttributes()}updated(e){super.updated(e),e.has(`valueCurrent`)&&this.labelRef.value&&(this.labelWidth=this.labelRef.value.getBoundingClientRect().width||0),e.has(`id`)&&this.id&&(this.progressBarId=this.id),(e.has(`statusType`)||e.has(`id`)||e.has(`ariaLabelledby`))&&(this.progressbarId=this.id||i.n(),this.computedAriaLabelledby=this.ariaLabelledby||`${this.progressbarId}-title`),(e.has(`ariaValueText`)||e.has(`valueCurrent`)||e.has(`valueMax`))&&(this.computedAriaValueText=this.statusType===`fraction`&&!this.ariaValueText?`${this.valueCurrent} av ${this.valueMax-this.valueMin}`:this.ariaValueText||``),this.syncAttributes()}render(){let t=this.statusType!==`none`,i=this.valueMax-this.valueMin,a=this.valueCurrent/i*100,o=this.statusType===`fraction`?Math.round(a):Math.round((this.valueCurrent-this.valueMin)/(this.valueMax-this.valueMin)*100),c=`${this.valueCurrent} av ${i}`,l=n.t({"pkt-progressbar__bar":!0,[`pkt-progressbar__bar--${this.skin}`]:!!this.skin}),u=n.t({"pkt-progressbar__title":!0,"pkt-progressbar__title-center":this.titlePosition===`center`}),d=n.t({"pkt-progressbar__status":!0,"pkt-progressbar__status--center":this.statusPlacement===`center`}),f=n.t({"pkt-progressbar__status-placement--following":this.statusPlacement===`following`,"pkt-progressbar__status-placement--center":this.statusPlacement===`center`,"pkt-progressbar__status-placement--left":this.statusPlacement===`left`});return e.d` <div
|
|
2
|
+
class="pkt-progressbar__container"
|
|
3
|
+
.ref=${this.progressBarRef}
|
|
4
|
+
style=${s({"--pkt-progress-label-width":`${this.labelWidth}px`,"--pkt-progress-width":`${o}%`})}
|
|
5
|
+
>
|
|
6
|
+
${this.title?e.d`<p id=${`${this.progressBarId}-title`} class=${u}>${this.title}</p>`:e.l}
|
|
7
|
+
|
|
8
|
+
<div class="pkt-progressbar__bar-wrapper">
|
|
9
|
+
<div class=${l}></div>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
${t?e.d`<div class=${d}>
|
|
13
|
+
<span class=${f} ${r.n(this.labelRef)}>
|
|
14
|
+
${this.statusType===`percentage`?`${o}%`:c}
|
|
15
|
+
</span>
|
|
16
|
+
</div>`:e.l}
|
|
17
|
+
</div>`}setComputedValues(){this.progressbarId=this.id||i.n(),this.computedAriaLabelledby=this.ariaLabelledby||`${this.progressbarId}-title`,this.computedAriaValueText=this.statusType===`fraction`&&!this.ariaValueText?`${this.valueCurrent} av ${this.valueMax-this.valueMin}`:this.ariaValueText||``}syncAttributes(){this._handleAttribute(`aria-live`,this.ariaLive),this._handleAttribute(`aria-valuenow`,this.valueCurrent),this._handleAttribute(`aria-valuemin`,this.valueMin),this._handleAttribute(`aria-valuemax`,this.valueMax),this._handleAttribute(`aria-valuetext`,this.computedAriaValueText),this._handleAttribute(`aria-label`,this.ariaLabel),this._handleAttribute(`role`,this.role),this._handleAttribute(`aria-atomic`,`true`),this._handleAttribute(`id`,this.progressbarId),this.ariaLabel||this._handleAttribute(`aria-labelledby`,this.computedAriaLabelledby)}_handleAttribute(e,t){t==null||t===``?this.removeAttribute(e):this.setAttribute(e,String(t))}};e.r([e.s({type:String})],c.prototype,`ariaLabel`,void 0),e.r([e.s({type:String,reflect:!0})],c.prototype,`ariaLabelledby`,void 0),e.r([e.s({type:String,reflect:!0})],c.prototype,`ariaValueText`,void 0),e.r([e.s({type:String})],c.prototype,`ariaLive`,void 0),e.r([e.s({type:String,reflect:!0})],c.prototype,`id`,void 0),e.r([e.s({type:String})],c.prototype,`role`,void 0),e.r([e.s({type:String})],c.prototype,`skin`,void 0),e.r([e.s({type:String})],c.prototype,`statusPlacement`,void 0),e.r([e.s({type:String})],c.prototype,`statusType`,void 0),e.r([e.s({type:String,reflect:!0})],c.prototype,`title`,void 0),e.r([e.s({type:String})],c.prototype,`titlePosition`,void 0),e.r([e.s({type:Number,reflect:!0})],c.prototype,`valueCurrent`,void 0),e.r([e.s({type:Number})],c.prototype,`valueMax`,void 0),e.r([e.s({type:Number})],c.prototype,`valueMin`,void 0),e.r([e.o()],c.prototype,`labelWidth`,void 0),e.r([e.o()],c.prototype,`progressbarId`,void 0),e.r([e.o()],c.prototype,`computedAriaLabelledby`,void 0),e.r([e.o()],c.prototype,`computedAriaValueText`,void 0);try{e.c(`pkt-progressbar`)(c)}catch{console.warn(`Forsøker å definere <pkt-progressbar>, men den er allerede definert`)}var l=c;Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return l}});
|