@oslokommune/punkt-elements 17.1.3 → 18.1.0
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-BeLvLPrB.js → accordion-CcUosZjL.js} +27 -27
- package/dist/{accordion-B3GBlvUC.cjs → accordion-k0pWTG1X.cjs} +5 -5
- package/dist/alert-BD8YVKia.cjs +35 -0
- package/dist/{alert-DKK_Tb9J.js → alert-Bmaly2Yo.js} +57 -52
- package/dist/{async-directive-BPf6K-V2.js → async-directive-COqx0IYj.js} +5 -5
- package/dist/{async-directive-Da7TJpnq.cjs → async-directive-DN2eg9gA.cjs} +1 -1
- package/dist/{backlink-D1y26pj3.js → backlink-C_ZO-ZbR.js} +9 -9
- package/dist/{backlink-CMmrKTe4.cjs → backlink-Ch64Pivx.cjs} +3 -3
- package/dist/base-elements/element.d.ts +13 -1
- package/dist/base-elements/input-element.d.ts +4 -2
- package/dist/{breadcrumbs-CcTQ3Grm.js → breadcrumbs-CF_gAbUk.js} +16 -16
- package/dist/{breadcrumbs-B6JGhJgC.cjs → breadcrumbs-CzzbardP.cjs} +7 -7
- package/dist/{button-2-OSPJkj.js → button-C1CQSASU.js} +28 -28
- package/dist/{button-CE97NQIk.cjs → button-CF3dNKeI.cjs} +7 -7
- package/dist/{calendar-kn4SrtJy.cjs → calendar-BxF81kB9.cjs} +28 -27
- package/dist/{calendar-pOW3R5Pw.js → calendar-DRmxORMc.js} +82 -68
- package/dist/{card-CETDFkxR.cjs → card-Cg1daj05.cjs} +26 -26
- package/dist/{card-zQ0eKRMV.js → card-W_Jb0Tlo.js} +44 -44
- package/dist/{checkbox-CQNr_sEg.cjs → checkbox-BHQv8lHq.cjs} +11 -11
- package/dist/{checkbox-CH7NpINF.js → checkbox-BQw2dMSX.js} +23 -23
- package/dist/{class-map-BeimMvPv.cjs → class-map-C33ixq7O.cjs} +1 -1
- package/dist/{class-map-CnWCnBSX.js → class-map-wh4Yi3oj.js} +3 -3
- package/dist/{combobox-Bvg0UO9w.cjs → combobox-BpZow9OU.cjs} +19 -18
- package/dist/{combobox-CRdYYlxu.js → combobox-C9wwnUfM.js} +55 -54
- package/dist/components/accordion/accordion.d.ts +2 -6
- package/dist/components/accordion/accordionitem.d.ts +2 -8
- package/dist/components/alert/alert.d.ts +2 -2
- package/dist/components/backlink/backlink.d.ts +4 -5
- package/dist/components/backlink/backlink.test.d.ts +1 -1
- package/dist/components/breadcrumbs/breadcrumbs.d.ts +6 -7
- package/dist/components/breadcrumbs/index.d.ts +1 -1
- package/dist/components/calendar/calendar.d.ts +21 -6
- package/dist/components/checkbox/checkbox.d.ts +4 -2
- package/dist/components/combobox/combobox-base.d.ts +2 -1
- package/dist/components/consent/strings.d.ts +1 -85
- package/dist/components/datepicker/datepicker-base.d.ts +0 -3
- package/dist/components/datepicker/datepicker-multiple.d.ts +0 -2
- package/dist/components/datepicker/datepicker-range.d.ts +0 -2
- package/dist/components/datepicker/datepicker-single.d.ts +0 -2
- package/dist/components/datepicker/datepicker-utils.d.ts +2 -1
- package/dist/components/fileupload/fileupload-base.d.ts +7 -4
- package/dist/components/fileupload/fileupload-types.d.ts +5 -43
- package/dist/components/header/header-service.d.ts +3 -1
- package/dist/components/header/header.d.ts +2 -1
- package/dist/components/helptext/helptext.d.ts +2 -1
- package/dist/components/index.d.ts +3 -1
- package/dist/components/input-wrapper/input-wrapper.d.ts +4 -2
- package/dist/components/radiobutton/radiobutton.d.ts +4 -2
- package/dist/components/searchinput/searchinput.d.ts +2 -1
- package/dist/{consent-CyY3RyoC.cjs → consent-CPtr7cBw.cjs} +5 -5
- package/dist/{consent-DZEkhgJ1.js → consent-D8MrqGKk.js} +10 -10
- package/dist/controllers/strings-controller.d.ts +27 -0
- package/dist/{datepicker-ButIas85.js → datepicker-D4YnAtWG.js} +104 -104
- package/dist/{datepicker-VTqSDQk5.cjs → datepicker-DaoumZT9.cjs} +38 -37
- package/dist/define-component-spec-BYOSeplU.js +6 -0
- package/dist/define-component-spec-DBNd2FJY.cjs +1 -0
- package/dist/{directive-helpers-CI8YZqku.js → directive-helpers-BWSAVe00.js} +1 -1
- package/dist/{directive-helpers-BlAV5EQD.cjs → directive-helpers-C6J4AkFk.cjs} +1 -1
- package/dist/docs/components/alert.d.ts +2 -3
- package/dist/docs/components/fileupload.d.ts +1 -0
- package/dist/element-DiFhBcIl.cjs +2 -0
- package/dist/{element-ChsFgr_B.js → element-WEzISABa.js} +241 -100
- package/dist/{element-with-slot-BvG9ctC-.js → element-with-slot-BKYUx4gb.js} +4 -4
- package/dist/{element-with-slot-Bj7nm7fO.cjs → element-with-slot-CBK4zrdN.cjs} +1 -1
- package/dist/{fileupload-D5IQ9HDe.js → fileupload-DEHSETw0.js} +340 -652
- package/dist/fileupload-DWu6FIMv.cjs +402 -0
- package/dist/{footer-DrR64HiK.js → footer-BJLEw6Ab.js} +91 -91
- package/dist/{footer-DbYQUYNR.cjs → footer-D_yYWkQ6.cjs} +32 -32
- package/dist/format-B8meU8Tm.cjs +1 -0
- package/dist/format-BTeSVkED.js +18 -0
- package/dist/{header-ClgIac6n.cjs → header-B7_4Cwaq.cjs} +84 -84
- package/dist/{header-KvJ1mGwA.js → header-DLVq7-dM.js} +267 -264
- package/dist/{header-menu-hVPXsb8g.js → header-menu-BsrrTjpT.js} +75 -75
- package/dist/{header-menu-BAsUNKSx.cjs → header-menu-m7nOOC1g.cjs} +24 -24
- package/dist/{heading-g-_IUB5T.js → heading-DSArgrDK.js} +16 -16
- package/dist/{heading-CFmiSuCQ.cjs → heading-_RPw2UW9.cjs} +1 -1
- package/dist/helptext-QMVsW5g6.cjs +27 -0
- package/dist/{helptext-DZng1D5i.js → helptext-dtVVufNH.js} +18 -19
- package/dist/{icon-D-LA22xD.js → icon-DEtOSWRK.js} +17 -17
- package/dist/{icon-9iwd2F2l.cjs → icon-DIavy2cB.cjs} +1 -1
- package/dist/{if-defined-CGzIlZ9-.js → if-defined-BmnvvxtR.js} +1 -1
- package/dist/if-defined-Dc3xFDaM.cjs +1 -0
- package/dist/input-element-DQY1Rpbp.cjs +1 -0
- package/dist/{input-element-DBMNBplu.js → input-element-IBypGOaV.js} +121 -120
- package/dist/input-wrapper-CQgAL1Br.js +308 -0
- package/dist/input-wrapper-mJZLVXy_.cjs +58 -0
- package/dist/link-DwLeY37f.js +131 -0
- package/dist/link-yk4IXDWm.cjs +7 -0
- package/dist/linkcard-BinKnxQF.cjs +13 -0
- package/dist/{linkcard-zqbg7Oqm.js → linkcard-D5DXpmXI.js} +16 -16
- package/dist/{listbox-Dc4rGdPi.cjs → listbox-C5zTRNAO.cjs} +15 -15
- package/dist/{listbox-va_E8afs.js → listbox-C8ooO8qZ.js} +100 -99
- package/dist/{loader-D_RDICnw.js → loader-C3HyayzL.js} +14 -14
- package/dist/{loader-CMUkVJmE.cjs → loader-DHF7M5Vn.cjs} +5 -5
- package/dist/{messagebox-Cv8LaSxv.cjs → messagebox-DqYf6VmQ.cjs} +5 -5
- package/dist/{messagebox-Cw-OWDya.js → messagebox-u8i3R5QA.js} +15 -15
- package/dist/{modal-BtInv031.cjs → modal-CnJ9y2TQ.cjs} +8 -8
- package/dist/{modal-D0t_X2dX.js → modal-V-jEe0aY.js} +20 -20
- package/dist/pkt-accordion.cjs +1 -1
- package/dist/pkt-accordion.js +1 -1
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +1 -1
- package/dist/pkt-backlink.cjs +1 -1
- package/dist/pkt-backlink.js +1 -1
- package/dist/pkt-breadcrumbs.cjs +1 -1
- package/dist/pkt-breadcrumbs.js +1 -1
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +1 -1
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +1 -1
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +1 -1
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-consent.cjs +1 -1
- package/dist/pkt-consent.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-fileupload.cjs +1 -1
- package/dist/pkt-fileupload.js +1 -1
- package/dist/pkt-footer.cjs +1 -1
- package/dist/pkt-footer.js +1 -1
- package/dist/pkt-header-menu.cjs +1 -1
- package/dist/pkt-header-menu.js +1 -1
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-heading.cjs +1 -1
- package/dist/pkt-heading.js +1 -1
- package/dist/pkt-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +1 -1
- package/dist/pkt-icon.cjs +1 -1
- package/dist/pkt-icon.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +35 -34
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-link.cjs +1 -1
- package/dist/pkt-link.js +1 -1
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +1 -1
- package/dist/pkt-listbox.cjs +1 -1
- package/dist/pkt-listbox.js +1 -1
- package/dist/pkt-loader.cjs +1 -1
- package/dist/pkt-loader.js +1 -1
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/{pkt-options-controller-C5EBX2T0.cjs → pkt-options-controller-BhMNCWcc.cjs} +1 -1
- package/dist/{pkt-options-controller-B77vH3PE.js → pkt-options-controller-CuQ6SClv.js} +1 -1
- package/dist/pkt-progressbar.cjs +1 -1
- package/dist/pkt-progressbar.js +1 -1
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +1 -1
- package/dist/pkt-searchinput.cjs +1 -1
- package/dist/pkt-searchinput.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/pkt-tabs.cjs +1 -1
- package/dist/pkt-tabs.js +1 -1
- package/dist/pkt-tag.cjs +1 -1
- package/dist/pkt-tag.js +1 -1
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +1 -1
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +1 -1
- package/dist/pkt-timepicker.cjs +1 -1
- package/dist/pkt-timepicker.js +1 -1
- package/dist/{progressbar-CbcfLerF.js → progressbar-DS4i8IWq.js} +21 -21
- package/dist/{progressbar-D5MmnQId.cjs → progressbar-DY5hxImR.cjs} +5 -5
- package/dist/{radiobutton-BUnf3EPi.js → radiobutton-BhvZztMZ.js} +24 -24
- package/dist/{radiobutton-DpsO1F-8.cjs → radiobutton-BswqwRnA.cjs} +8 -8
- package/dist/{ref-CQoEIIp0.cjs → ref-DZmN5Qgj.cjs} +1 -1
- package/dist/{ref-CWD6PjVd.js → ref-OU8ryfP6.js} +2 -2
- package/dist/{repeat-sY6B7fAT.cjs → repeat-DIa_g6WL.cjs} +1 -1
- package/dist/{repeat-C02g7d5S.js → repeat-Dx2H127b.js} +4 -4
- package/dist/{searchinput-DwnjsvJ1.js → searchinput-CJo1PpM7.js} +43 -43
- package/dist/searchinput-Cl46nW0r.cjs +60 -0
- package/dist/{select-DMre80qs.js → select-CBrjauXT.js} +21 -20
- package/dist/{select-BOJi6H6T.cjs → select-Dman8Skr.cjs} +4 -3
- package/dist/shared-strings/consent.d.ts +71 -0
- package/dist/shared-strings/format.d.ts +21 -0
- package/dist/shared-strings/index.d.ts +14 -0
- package/dist/shared-strings/nb.d.ts +121 -0
- package/dist/shared-strings/resolve.d.ts +12 -0
- package/dist/shared-strings/store.d.ts +27 -0
- package/dist/shared-strings/types.d.ts +40 -0
- package/dist/shared-types/accordion.d.ts +58 -0
- package/dist/shared-types/alert.d.ts +20 -0
- package/dist/shared-types/aria.d.ts +2 -1
- package/dist/shared-types/backlink.d.ts +23 -0
- package/dist/shared-types/breadcrumbs.d.ts +33 -0
- package/dist/shared-types/fileupload.d.ts +55 -28
- package/dist/shared-types/footer.d.ts +10 -0
- package/dist/shared-types/form-field.d.ts +45 -0
- package/dist/shared-types/header-footer.d.ts +2 -0
- package/dist/shared-types/index.d.ts +15 -6
- package/dist/shared-types/render-link.d.ts +22 -0
- package/dist/shared-types/skin.d.ts +2 -9
- package/dist/shared-utils/combobox/index.d.ts +1 -0
- package/dist/shared-utils/combobox/input-utils.d.ts +2 -1
- package/dist/shared-utils/combobox/messages.d.ts +7 -0
- package/dist/shared-utils/combobox/option-utils.d.ts +2 -1
- package/dist/shared-utils/combobox/selection-manager.d.ts +3 -2
- package/dist/{tabs-Cf9ai0FD.cjs → tabs-C1m5rSrR.cjs} +7 -7
- package/dist/{tabs-TvxgbrCF.js → tabs-Xu3mIedh.js} +32 -32
- package/dist/{tag-Ds6n1LIs.js → tag-Azkjhkeu.js} +33 -32
- package/dist/tag-BS6dDPxY.cjs +27 -0
- package/dist/tests/strings-override.test.d.ts +0 -0
- package/dist/{textarea-vfzIcXhX.js → textarea-D4qXcVGD.js} +30 -29
- package/dist/{textarea-BydiLM9Z.cjs → textarea-DftUkR6w.cjs} +3 -2
- package/dist/{textinput-DGdicNSx.cjs → textinput-Ar-1Sbqy.cjs} +13 -12
- package/dist/{textinput-CMP2jPP_.js → textinput-iCgwwNPU.js} +28 -27
- package/dist/{timepicker-ClwgYywH.js → timepicker-W6HVWtmA.js} +67 -64
- package/dist/timepicker-dpAF7h49.cjs +196 -0
- package/package.json +3 -3
- package/src/components/accordion/accordion.ts +2 -10
- package/src/components/accordion/accordionitem.ts +2 -9
- package/src/components/alert/alert.ts +19 -10
- package/src/components/backlink/backlink.test.ts +3 -3
- package/src/components/backlink/backlink.ts +5 -7
- package/src/components/breadcrumbs/breadcrumbs.ts +9 -10
- package/src/components/breadcrumbs/index.ts +1 -1
- package/src/components/calendar/calendar.ts +56 -26
- package/src/components/checkbox/checkbox.test.ts +0 -2
- package/src/components/checkbox/checkbox.ts +8 -4
- package/src/components/combobox/combobox-base.ts +2 -1
- package/src/components/combobox/combobox-value.ts +10 -9
- package/src/components/combobox/combobox.selection.test.ts +5 -1
- package/src/components/combobox/combobox.ts +4 -1
- package/src/components/consent/strings.ts +1 -125
- package/src/components/datepicker/date-tags.ts +4 -1
- package/src/components/datepicker/datepicker-base.ts +2 -6
- package/src/components/datepicker/datepicker-multiple.ts +0 -3
- package/src/components/datepicker/datepicker-range.ts +4 -7
- package/src/components/datepicker/datepicker-single.ts +0 -3
- package/src/components/datepicker/datepicker-utils.test.ts +5 -5
- package/src/components/datepicker/datepicker-utils.ts +6 -11
- package/src/components/datepicker/datepicker.ts +8 -1
- package/src/components/fileupload/fileupload-base.ts +29 -19
- package/src/components/fileupload/fileupload-renderers.ts +2 -1
- package/src/components/fileupload/fileupload-types.ts +5 -42
- package/src/components/fileupload/fileupload.test.ts +16 -0
- package/src/components/fileupload/fileupload.ts +19 -15
- package/src/components/header/header-global.ts +3 -3
- package/src/components/header/header-service.ts +13 -8
- package/src/components/header/header.ts +2 -1
- package/src/components/helptext/helptext.test.ts +1 -1
- package/src/components/helptext/helptext.ts +3 -3
- package/src/components/index.ts +10 -1
- package/src/components/input-wrapper/input-wrapper.ts +18 -10
- package/src/components/link/link.ts +8 -3
- package/src/components/listbox/listbox.ts +3 -3
- package/src/components/radiobutton/radiobutton.ts +8 -4
- package/src/components/searchinput/searchinput.ts +5 -3
- package/src/components/select/select.ts +1 -0
- package/src/components/tag/tag.ts +2 -1
- package/src/components/textarea/textarea.ts +1 -0
- package/src/components/textinput/textinput.ts +1 -0
- package/src/components/timepicker/timepicker.ts +23 -21
- package/dist/alert-Cs4Rmq_J.cjs +0 -33
- package/dist/element-BA8v6S7z.cjs +0 -2
- package/dist/fileupload-BeWiTAoW.cjs +0 -401
- package/dist/helptext-CTtKJcML.cjs +0 -27
- package/dist/if-defined-B89_ZeCj.cjs +0 -1
- package/dist/input-element-DYmQw-fH.cjs +0 -1
- package/dist/input-wrapper-BmxNvznr.js +0 -128
- package/dist/input-wrapper-D-fPaTbY.js +0 -176
- package/dist/input-wrapper-D5PR0rJn.cjs +0 -1
- package/dist/input-wrapper-Q-B-aBeb.cjs +0 -54
- package/dist/link-D-Eqm5KH.js +0 -98
- package/dist/link-DK7gvmnj.cjs +0 -7
- package/dist/linkcard-B29cmZqh.cjs +0 -13
- package/dist/searchinput-Bh975rjX.cjs +0 -60
- package/dist/tag-CzojNU7z.cjs +0 -27
- package/dist/timepicker-DYrnLHqN.cjs +0 -195
- package/dist/translations/no.json.d.ts +0 -94
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import "./
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import { t as
|
|
8
|
-
import "./input-
|
|
1
|
+
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-WEzISABa.js";
|
|
2
|
+
import { t as o } from "./class-map-wh4Yi3oj.js";
|
|
3
|
+
import { t as s } from "./format-BTeSVkED.js";
|
|
4
|
+
import { n as c } from "./element-with-slot-BKYUx4gb.js";
|
|
5
|
+
import "./icon-DEtOSWRK.js";
|
|
6
|
+
import { t as l } from "./if-defined-BmnvvxtR.js";
|
|
7
|
+
import { n as u, t as d } from "./ref-OU8ryfP6.js";
|
|
8
|
+
import { t as f } from "./input-element-IBypGOaV.js";
|
|
9
|
+
import "./input-wrapper-CQgAL1Br.js";
|
|
9
10
|
//#region ../../shared-utils/timepicker/time-utils.ts
|
|
10
11
|
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
12
|
let [t, n] = e.split(":").map(Number);
|
|
@@ -153,25 +154,26 @@ var p = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && p
|
|
|
153
154
|
manageValidity(e) {
|
|
154
155
|
let t = this.hoursInputRef.value;
|
|
155
156
|
if (!t) return;
|
|
157
|
+
let n = this.pktStrings.get("validation");
|
|
156
158
|
if (this.required && !this.value) {
|
|
157
|
-
this.internals.setValidity({ valueMissing: !0 },
|
|
159
|
+
this.internals.setValidity({ valueMissing: !0 }, n.valueMissing, t), this._setAriaInvalid(!0);
|
|
158
160
|
return;
|
|
159
161
|
}
|
|
160
162
|
if (!this.value) {
|
|
161
163
|
this.internals.setValidity({}), this._setAriaInvalid(!1);
|
|
162
164
|
return;
|
|
163
165
|
}
|
|
164
|
-
let
|
|
165
|
-
if (this.min &&
|
|
166
|
-
this.internals.setValidity({ rangeUnderflow: !0 },
|
|
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 }, s(n.rangeUnderflowMin, { min: String(this.min) }), t), this._setAriaInvalid(!0);
|
|
167
169
|
return;
|
|
168
170
|
}
|
|
169
|
-
if (this.max &&
|
|
170
|
-
this.internals.setValidity({ rangeOverflow: !0 },
|
|
171
|
+
if (this.max && r > m(String(this.max))) {
|
|
172
|
+
this.internals.setValidity({ rangeOverflow: !0 }, s(n.rangeOverflowMax, { max: String(this.max) }), t), this._setAriaInvalid(!0);
|
|
171
173
|
return;
|
|
172
174
|
}
|
|
173
|
-
if (this.step &&
|
|
174
|
-
let e =
|
|
175
|
+
if (this.step && r % i !== 0) {
|
|
176
|
+
let e = i === 60 ? n.timeStepMismatchHour : i === 30 ? n.timeStepMismatchHalfHour : s(n.timeStepMismatch, { step: `${i}, ${i * 2}, ${i * 3}` });
|
|
175
177
|
this.internals.setValidity({ stepMismatch: !0 }, e, t), this._setAriaInvalid(!0);
|
|
176
178
|
return;
|
|
177
179
|
}
|
|
@@ -262,40 +264,40 @@ var p = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && p
|
|
|
262
264
|
let t = v(this._hours, this._minutes, e, this._minuteStep);
|
|
263
265
|
this._hours = t.hours, this._minutes = t.minutes, this._syncValueFromDisplay();
|
|
264
266
|
}
|
|
265
|
-
_renderOption(
|
|
266
|
-
let
|
|
267
|
-
return
|
|
267
|
+
_renderOption(t, n) {
|
|
268
|
+
let r = String(t).padStart(2, "0"), i = t === (n === "hour" ? this._hours === "" ? NaN : parseInt(this._hours, 10) : this._minutes === "" ? NaN : parseInt(this._minutes, 10));
|
|
269
|
+
return e`
|
|
268
270
|
<button
|
|
269
|
-
class=${
|
|
271
|
+
class=${o({
|
|
270
272
|
"pkt-btn": !0,
|
|
271
273
|
"pkt-btn--tertiary": !0,
|
|
272
274
|
"pkt-btn--small": !0,
|
|
273
275
|
"pkt-btn--label-only": !0,
|
|
274
276
|
"pkt-timepicker-popup__option": !0,
|
|
275
|
-
"pkt-timepicker-popup__option--selected":
|
|
277
|
+
"pkt-timepicker-popup__option--selected": i
|
|
276
278
|
})}
|
|
277
279
|
type="button"
|
|
278
280
|
role="option"
|
|
279
|
-
aria-selected=${
|
|
280
|
-
tabindex=${
|
|
281
|
-
data-type=${
|
|
282
|
-
data-value=${
|
|
283
|
-
@click=${(
|
|
284
|
-
|
|
281
|
+
aria-selected=${i ? "true" : "false"}
|
|
282
|
+
tabindex=${i ? "0" : "-1"}
|
|
283
|
+
data-type=${n}
|
|
284
|
+
data-value=${t}
|
|
285
|
+
@click=${(e) => {
|
|
286
|
+
e.stopImmediatePropagation(), this._handleOptionClick(t, n);
|
|
285
287
|
}}
|
|
286
288
|
>
|
|
287
|
-
<span class="pkt-btn__text pkt-txt-14-light">${
|
|
289
|
+
<span class="pkt-btn__text pkt-txt-14-light">${r}</span>
|
|
288
290
|
</button>
|
|
289
291
|
`;
|
|
290
292
|
}
|
|
291
293
|
_renderPopup() {
|
|
292
|
-
return
|
|
294
|
+
return e`
|
|
293
295
|
<div
|
|
294
296
|
class="pkt-timepicker-popup"
|
|
295
297
|
id=${this.id + "-popup"}
|
|
296
298
|
?hidden=${!this._isOpen}
|
|
297
299
|
role="group"
|
|
298
|
-
aria-label=${this.
|
|
300
|
+
aria-label=${this.pktStrings.get("timepicker").selectTime}
|
|
299
301
|
@keydown=${this._handlePopupKeydown}
|
|
300
302
|
@focusout=${(e) => {
|
|
301
303
|
this.querySelector(".pkt-timepicker-popup")?.contains(e.relatedTarget) || this._closePopup();
|
|
@@ -304,7 +306,7 @@ var p = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && p
|
|
|
304
306
|
<div
|
|
305
307
|
class="pkt-timepicker-popup__col"
|
|
306
308
|
role="listbox"
|
|
307
|
-
aria-label=${this.
|
|
309
|
+
aria-label=${this.pktStrings.get("timepicker").hours}
|
|
308
310
|
aria-orientation="vertical"
|
|
309
311
|
>
|
|
310
312
|
${this._hourOptions.map((e) => this._renderOption(e, "hour"))}
|
|
@@ -312,7 +314,7 @@ var p = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && p
|
|
|
312
314
|
<div
|
|
313
315
|
class="pkt-timepicker-popup__col"
|
|
314
316
|
role="listbox"
|
|
315
|
-
aria-label=${this.
|
|
317
|
+
aria-label=${this.pktStrings.get("timepicker").minutes}
|
|
316
318
|
aria-orientation="vertical"
|
|
317
319
|
>
|
|
318
320
|
${this._minuteOptions.map((e) => this._renderOption(e, "minute"))}
|
|
@@ -321,28 +323,28 @@ var p = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && p
|
|
|
321
323
|
`;
|
|
322
324
|
}
|
|
323
325
|
_renderContainer() {
|
|
324
|
-
let
|
|
325
|
-
return
|
|
326
|
+
let t = this.pktStrings.get("timepicker").hours, r = this.pktStrings.get("timepicker").minutes, i = this.label ? `${t}, ${this.label}` : t, a = this.label ? `${r}, ${this.label}` : r;
|
|
327
|
+
return e`
|
|
326
328
|
<div
|
|
327
329
|
class="pkt-input__container pkt-input__container--${this.inputSize}"
|
|
328
330
|
@click=${(e) => {
|
|
329
331
|
e.target.closest("button, input") || this.hoursInputRef.value?.focus();
|
|
330
332
|
}}
|
|
331
333
|
>
|
|
332
|
-
${this.stepArrows ?
|
|
334
|
+
${this.stepArrows ? e`
|
|
333
335
|
<button
|
|
334
336
|
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-btn--${this.inputSize} pkt-timepicker__button pkt-timepicker__button--prev"
|
|
335
337
|
type="button"
|
|
336
|
-
aria-label=${this.
|
|
338
|
+
aria-label=${this.pktStrings.get("timepicker").prevTime}
|
|
337
339
|
?disabled=${this.disabled}
|
|
338
340
|
@click=${() => this._stepTime(-1)}
|
|
339
341
|
>
|
|
340
342
|
<pkt-icon name="chevron-thin-left"></pkt-icon>
|
|
341
343
|
<span class="pkt-btn__text"
|
|
342
|
-
>${this.
|
|
344
|
+
>${this.pktStrings.get("timepicker").prevTime}</span
|
|
343
345
|
>
|
|
344
346
|
</button>
|
|
345
|
-
` :
|
|
347
|
+
` : n}
|
|
346
348
|
<input
|
|
347
349
|
${u(this.hoursInputRef)}
|
|
348
350
|
type="text"
|
|
@@ -355,14 +357,14 @@ var p = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && p
|
|
|
355
357
|
data-max="23"
|
|
356
358
|
.value=${this._hours}
|
|
357
359
|
placeholder="––"
|
|
358
|
-
aria-label=${
|
|
360
|
+
aria-label=${i}
|
|
359
361
|
role="spinbutton"
|
|
360
|
-
aria-invalid=${this.hasError ? "true" :
|
|
361
|
-
aria-errormessage=${this.hasError ? `${this.id}-hours-error` :
|
|
362
|
+
aria-invalid=${this.hasError ? "true" : n}
|
|
363
|
+
aria-errormessage=${this.hasError ? `${this.id}-hours-error` : n}
|
|
362
364
|
aria-valuemin="0"
|
|
363
365
|
aria-valuemax="23"
|
|
364
|
-
aria-valuenow=${this._hours === "" ?
|
|
365
|
-
aria-valuetext=${this._hours === "" ?
|
|
366
|
+
aria-valuenow=${this._hours === "" ? n : this._hours}
|
|
367
|
+
aria-valuetext=${this._hours === "" ? n : `${this._hours} ${t.toLowerCase()}`}
|
|
366
368
|
autocomplete="off"
|
|
367
369
|
?disabled=${this.disabled}
|
|
368
370
|
@keydown=${this._handleHoursKeydown}
|
|
@@ -386,12 +388,12 @@ var p = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && p
|
|
|
386
388
|
placeholder="––"
|
|
387
389
|
aria-label=${a}
|
|
388
390
|
role="spinbutton"
|
|
389
|
-
aria-invalid=${this.hasError ? "true" :
|
|
390
|
-
aria-errormessage=${this.hasError ? `${this.id}-hours-error` :
|
|
391
|
+
aria-invalid=${this.hasError ? "true" : n}
|
|
392
|
+
aria-errormessage=${this.hasError ? `${this.id}-hours-error` : n}
|
|
391
393
|
aria-valuemin="0"
|
|
392
394
|
aria-valuemax="59"
|
|
393
|
-
aria-valuenow=${this._minutes === "" ?
|
|
394
|
-
aria-valuetext=${this._minutes === "" ?
|
|
395
|
+
aria-valuenow=${this._minutes === "" ? n : this._minutes}
|
|
396
|
+
aria-valuetext=${this._minutes === "" ? n : `${this._minutes} ${r.toLowerCase()}`}
|
|
395
397
|
autocomplete="off"
|
|
396
398
|
?disabled=${this.disabled}
|
|
397
399
|
@keydown=${this._handleMinutesKeydown}
|
|
@@ -400,17 +402,17 @@ var p = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && p
|
|
|
400
402
|
e.target.select(), e.stopImmediatePropagation();
|
|
401
403
|
}}
|
|
402
404
|
/>
|
|
403
|
-
${this.hidePicker && !this.stepArrows ?
|
|
405
|
+
${this.hidePicker && !this.stepArrows ? e`<pkt-icon
|
|
404
406
|
class="pkt-input-icon pkt-timepicker__icon"
|
|
405
407
|
name="clock"
|
|
406
408
|
aria-hidden="true"
|
|
407
|
-
></pkt-icon>` :
|
|
408
|
-
${!this.hidePicker && !this.stepArrows ?
|
|
409
|
+
></pkt-icon>` : n}
|
|
410
|
+
${!this.hidePicker && !this.stepArrows ? e`
|
|
409
411
|
<button
|
|
410
412
|
${u(this.buttonRef)}
|
|
411
413
|
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-btn--${this.inputSize} pkt-timepicker__button"
|
|
412
414
|
type="button"
|
|
413
|
-
aria-label=${this.
|
|
415
|
+
aria-label=${this.pktStrings.get("timepicker").openPicker}
|
|
414
416
|
aria-haspopup="listbox"
|
|
415
417
|
aria-expanded=${this._isOpen ? "true" : "false"}
|
|
416
418
|
aria-controls=${this.id + "-popup"}
|
|
@@ -419,24 +421,24 @@ var p = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && p
|
|
|
419
421
|
>
|
|
420
422
|
<pkt-icon name="clock"></pkt-icon>
|
|
421
423
|
<span class="pkt-btn__text"
|
|
422
|
-
>${this.
|
|
424
|
+
>${this.pktStrings.get("timepicker").openPicker}</span
|
|
423
425
|
>
|
|
424
426
|
</button>
|
|
425
|
-
` :
|
|
426
|
-
${this.stepArrows ?
|
|
427
|
+
` : n}
|
|
428
|
+
${this.stepArrows ? e`
|
|
427
429
|
<button
|
|
428
430
|
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-btn--${this.inputSize} pkt-timepicker__button pkt-timepicker__button--next"
|
|
429
431
|
type="button"
|
|
430
|
-
aria-label=${this.
|
|
432
|
+
aria-label=${this.pktStrings.get("timepicker").nextTime}
|
|
431
433
|
?disabled=${this.disabled}
|
|
432
434
|
@click=${() => this._stepTime(1)}
|
|
433
435
|
>
|
|
434
436
|
<pkt-icon name="chevron-thin-right"></pkt-icon>
|
|
435
437
|
<span class="pkt-btn__text"
|
|
436
|
-
>${this.
|
|
438
|
+
>${this.pktStrings.get("timepicker").nextTime}</span
|
|
437
439
|
>
|
|
438
440
|
</button>
|
|
439
|
-
` :
|
|
441
|
+
` : n}
|
|
440
442
|
<input
|
|
441
443
|
${u(this.hiddenInputRef)}
|
|
442
444
|
type="time"
|
|
@@ -455,8 +457,9 @@ var p = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && p
|
|
|
455
457
|
`;
|
|
456
458
|
}
|
|
457
459
|
render() {
|
|
458
|
-
return
|
|
460
|
+
return e`
|
|
459
461
|
<pkt-input-wrapper
|
|
462
|
+
.strings=${this.strings}
|
|
460
463
|
label="${this.label}"
|
|
461
464
|
?disabled=${this.disabled}
|
|
462
465
|
?fullwidth=${this.fullwidth}
|
|
@@ -479,7 +482,7 @@ var p = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && p
|
|
|
479
482
|
.size=${this.inputSize}
|
|
480
483
|
>
|
|
481
484
|
<div class="pkt-contents" slot="helptext">${c(this, "helptext")}</div>
|
|
482
|
-
${!this.hidePicker && !this.stepArrows ?
|
|
485
|
+
${!this.hidePicker && !this.stepArrows ? e`
|
|
483
486
|
<div class="pkt-timepicker__anchor">
|
|
484
487
|
${this._renderContainer()} ${this._renderPopup()}
|
|
485
488
|
</div>
|
|
@@ -488,20 +491,20 @@ var p = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && p
|
|
|
488
491
|
`;
|
|
489
492
|
}
|
|
490
493
|
};
|
|
491
|
-
|
|
494
|
+
i([a({
|
|
492
495
|
type: String,
|
|
493
496
|
reflect: !0
|
|
494
|
-
})], y.prototype, "value", void 0),
|
|
497
|
+
})], y.prototype, "value", void 0), i([a({
|
|
495
498
|
type: Boolean,
|
|
496
499
|
reflect: !0,
|
|
497
500
|
attribute: "hide-picker"
|
|
498
|
-
})], y.prototype, "hidePicker", void 0),
|
|
501
|
+
})], y.prototype, "hidePicker", void 0), i([a({
|
|
499
502
|
type: Boolean,
|
|
500
503
|
reflect: !0,
|
|
501
504
|
attribute: "step-arrows"
|
|
502
|
-
})], y.prototype, "stepArrows", void 0),
|
|
505
|
+
})], y.prototype, "stepArrows", void 0), i([r()], y.prototype, "_hours", void 0), i([r()], y.prototype, "_minutes", void 0), i([r()], y.prototype, "_isOpen", void 0);
|
|
503
506
|
try {
|
|
504
|
-
|
|
507
|
+
t("pkt-timepicker")(y);
|
|
505
508
|
} catch {
|
|
506
509
|
console.warn("Forsøker å definere <pkt-timepicker>, men den er allerede definert");
|
|
507
510
|
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
const e=require("./element-DiFhBcIl.cjs"),t=require("./class-map-C33ixq7O.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-CBK4zrdN.cjs");require("./icon-DIavy2cB.cjs");const i=require("./if-defined-Dc3xFDaM.cjs"),a=require("./ref-DZmN5Qgj.cjs"),o=require("./input-element-DQY1Rpbp.cjs");require("./input-wrapper-mJZLVXy_.cjs");var s=e=>/^\d{2}:\d{2}$/.test(e)&&parseInt(e.slice(0,2),10)<=23&&parseInt(e.slice(3),10)<=59,c=e=>{let[t,n]=e.split(`:`).map(Number);return t*60+n},l=e=>e?Math.max(1,Math.round(e/60)):1,u=(e,t)=>{let n=e?parseInt(String(e).split(`:`)[0],10):0,r=t?parseInt(String(t).split(`:`)[0],10):23;return Array.from({length:r-n+1},(e,t)=>t+n)},d=e=>{let t=l(e);return Array.from({length:Math.floor(60/t)},(e,n)=>n*t)},f=(e,t,n,r)=>{let i=e===``?n===1?0:23:parseInt(e,10),a=t===``?n===1?0:Math.floor(59/r)*r:parseInt(t,10);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),{hours:String(i).padStart(2,`0`),minutes:String(a).padStart(2,`0`)}},p=class extends o.t{constructor(...e){super(...e),this.hiddenInputRef=a.t(),this.hoursInputRef=a.t(),this.minutesInputRef=a.t(),this.buttonRef=a.t(),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=>{this.contains(e.target)||this._closePopup()},this._handleComponentFocusIn=()=>{this._hasFocus||(this._hasFocus=!0,this.onFocus())},this._handleComponentFocusOut=e=>{this.contains(e.relatedTarget)||(this._hasFocus=!1,this.onBlur())},this._handleHoursKeydown=e=>{let t=e.target;switch(e.key){case`ArrowUp`:{e.preventDefault();let t=this._hours===``?0:parseInt(this._hours,10);this._hours=String((t+1)%24).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowDown`:{e.preventDefault();let t=this._hours===``?0:parseInt(this._hours,10);this._hours=String((t-1+24)%24).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowRight`:e.preventDefault(),this.minutesInputRef.value?.focus();break;case`Backspace`:case`Delete`:this._hoursDigitCount=0,this._hoursFirstDigit=-1;break;case`Tab`:break;case`Enter`:{e.preventDefault();let n=this.internals.form;n?n.requestSubmit():t.blur();break}default:if(/^\d$/.test(e.key)){e.preventDefault();let t=parseInt(e.key,10);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());else{let e=this._hoursFirstDigit*10+t;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()}}else e.preventDefault()}},this._handleHoursBlur=()=>{this._hours!==``&&(this._hours=String(parseInt(this._hours,10)).padStart(2,`0`)),this._hoursDigitCount=0,this._hoursFirstDigit=-1,this._syncValueFromDisplay()},this._handleMinutesKeydown=e=>{let t=e.target;switch(e.key){case`ArrowUp`:{e.preventDefault();let t=this._minutes===``?0:parseInt(this._minutes,10);this._minutes=String((t+this._minuteStep)%60).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowDown`:{e.preventDefault();let t=this._minutes===``?0:parseInt(this._minutes,10);this._minutes=String((t-this._minuteStep+60)%60).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowLeft`:e.preventDefault(),this.hoursInputRef.value?.focus();break;case`Backspace`:case`Delete`:this._minutesDigitCount=0,this._minutesFirstDigit=-1;break;case`Tab`:break;case`Enter`:{e.preventDefault();let n=this.internals.form;n?n.requestSubmit():t.blur();break}default:if(/^\d$/.test(e.key)){e.preventDefault();let t=parseInt(e.key,10);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());else{let e=this._minutesFirstDigit*10+t;this._minutes=e<=59?String(e).padStart(2,`0`):String(t).padStart(2,`0`),this._minutesFirstDigit=-1,this._minutesDigitCount=0,this._syncValueFromDisplay(),this.onInput()}}else e.preventDefault()}},this._handleMinutesBlur=()=>{this._minutes!==``&&(this._minutes=String(parseInt(this._minutes,10)).padStart(2,`0`)),this._minutesDigitCount=0,this._minutesFirstDigit=-1,this._syncValueFromDisplay()},this._handlePopupKeydown=e=>{let t=document.activeElement,n=t.closest(`.pkt-timepicker-popup__col`);if(!n)return;let r=Array.from(n.querySelectorAll(`.pkt-timepicker-popup__option`)),i=r.indexOf(t),a=t.dataset.type??``;switch(e.key){case`ArrowDown`:e.preventDefault(),this._focusOptionAndSync(r[Math.min(i+1,r.length-1)],a);break;case`ArrowUp`:e.preventDefault(),this._focusOptionAndSync(r[Math.max(i-1,0)],a);break;case`Home`:e.preventDefault(),this._focusOptionAndSync(r[0],a);break;case`End`:e.preventDefault(),this._focusOptionAndSync(r[r.length-1],a);break;case`ArrowRight`:e.preventDefault(),a===`hour`&&(this._focusOptionAndSync(t,a),this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`minute`)}));break;case`ArrowLeft`:e.preventDefault(),a===`minute`&&(this._focusOptionAndSync(t,a),this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`hour`)}));break;case`Enter`:case` `:e.preventDefault(),t.click();break;case`Escape`:e.preventDefault(),this._closePopup(),this.buttonRef.value?.focus()}}}get inputRef(){return this.hiddenInputRef}manageValidity(e){let t=this.hoursInputRef.value;if(!t)return;let r=this.pktStrings.get(`validation`);if(this.required&&!this.value){this.internals.setValidity({valueMissing:!0},r.valueMissing,t),this._setAriaInvalid(!0);return}if(!this.value){this.internals.setValidity({}),this._setAriaInvalid(!1);return}let i=c(this.value),a=l(this.step);if(this.min&&i<c(String(this.min))){this.internals.setValidity({rangeUnderflow:!0},n.t(r.rangeUnderflowMin,{min:String(this.min)}),t),this._setAriaInvalid(!0);return}if(this.max&&i>c(String(this.max))){this.internals.setValidity({rangeOverflow:!0},n.t(r.rangeOverflowMax,{max:String(this.max)}),t),this._setAriaInvalid(!0);return}if(this.step&&i%a!==0){let e=a===60?r.timeStepMismatchHour:a===30?r.timeStepMismatchHalfHour:n.t(r.timeStepMismatch,{step:`${a}, ${a*2}, ${a*3}`});this.internals.setValidity({stepMismatch:!0},e,t),this._setAriaInvalid(!0);return}this.internals.setValidity({}),this._setAriaInvalid(!1)}_setAriaInvalid(e){if(!this.touched&&e)return;let t=this.hoursInputRef.value,n=this.minutesInputRef.value;if(e)t?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-invalid`,`true`);else{if(this.hasError)return;t?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-invalid`)}}connectedCallback(){super.connectedCallback(),this.addEventListener(`focusin`,this._handleComponentFocusIn),this.addEventListener(`focusout`,this._handleComponentFocusOut),document.addEventListener(`click`,this._outsideClickHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`focusin`,this._handleComponentFocusIn),this.removeEventListener(`focusout`,this._handleComponentFocusOut),document.removeEventListener(`click`,this._outsideClickHandler)}willUpdate(e){super.willUpdate(e),e.has(`value`)&&this._syncDisplayFromValue()}updated(e){super.updated(e),this.classList.add(`pkt-timepicker`),this.classList.toggle(`pkt-timepicker--stepper`,this.stepArrows),this.classList.toggle(`pkt-timepicker--fullwidth`,this.fullwidth),this.classList.toggle(`pkt-timepicker--medium`,this.inputSize===`medium`),this.classList.toggle(`pkt-timepicker--small`,this.inputSize===`small`),this.classList.toggle(`pkt-timepicker--xsmall`,this.inputSize===`xsmall`),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).`)}formResetCallback(){super.formResetCallback(),this._hours=``,this._minutes=``,this._isOpen=!1}_isValidStep(e){return e===3600||e<3600&&3600%e==0&&e%60==0}_syncDisplayFromValue(){let e=s(this.value)?this.value.split(`:`):null;e?(this._hours=e[0],this._minutes=e[1]):(this._hours=``,this._minutes=``)}_syncValueFromDisplay(){if(this._hours!==``&&this._minutes!==``){let e=`${this._hours}:${this._minutes}`;e!==this.value&&(this.value=e,this.onChange(e))}else this.value!==``&&(this.value=``,this.onChange(``))}get _minuteStep(){return l(this.step)}get _hourOptions(){return u(this.min,this.max)}get _minuteOptions(){return d(this.step)}_openPopup(){this._isOpen=!0,this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`hour`)})}_closePopup(){this._isOpen=!1,this._syncValueFromDisplay()}_togglePopup(){this._isOpen?this._closePopup():this._openPopup()}_scrollToSelected(){let e=this.querySelector(`.pkt-timepicker-popup`);e&&e.querySelectorAll(`.pkt-timepicker-popup__col`).forEach(e=>{let t=e.querySelector(`.pkt-timepicker-popup__option--selected`);t&&t.scrollIntoView({block:`center`})})}_focusSelectedOrFirst(e){let t=this.querySelector(`.pkt-timepicker-popup`);if(!t)return;let n=t.querySelectorAll(`.pkt-timepicker-popup__col`),r=e===`hour`?n[0]:n[1];if(!r)return;let i=r.querySelector(`.pkt-timepicker-popup__option--selected`),a=r.querySelector(`.pkt-timepicker-popup__option`);(i||a)?.focus()}_handleOptionClick(e,t){let n=String(e).padStart(2,`0`);t===`hour`?(this._hours=n,this.updateComplete.then(()=>this._focusSelectedOrFirst(`minute`))):(this._minutes=n,this._closePopup(),this.buttonRef.value?.focus())}_focusOptionAndSync(e,t){if(!e)return;let n=parseInt(e.dataset.value??`0`,10);t===`hour`?this._hours=String(n).padStart(2,`0`):this._minutes=String(n).padStart(2,`0`),e.focus()}_stepTime(e){let t=f(this._hours,this._minutes,e,this._minuteStep);this._hours=t.hours,this._minutes=t.minutes,this._syncValueFromDisplay()}_renderOption(n,r){let i=String(n).padStart(2,`0`),a=n===(r===`hour`?this._hours===``?NaN:parseInt(this._hours,10):this._minutes===``?NaN:parseInt(this._minutes,10));return e._`
|
|
2
|
+
<button
|
|
3
|
+
class=${t.t({"pkt-btn":!0,"pkt-btn--tertiary":!0,"pkt-btn--small":!0,"pkt-btn--label-only":!0,"pkt-timepicker-popup__option":!0,"pkt-timepicker-popup__option--selected":a})}
|
|
4
|
+
type="button"
|
|
5
|
+
role="option"
|
|
6
|
+
aria-selected=${a?`true`:`false`}
|
|
7
|
+
tabindex=${a?`0`:`-1`}
|
|
8
|
+
data-type=${r}
|
|
9
|
+
data-value=${n}
|
|
10
|
+
@click=${e=>{e.stopImmediatePropagation(),this._handleOptionClick(n,r)}}
|
|
11
|
+
>
|
|
12
|
+
<span class="pkt-btn__text pkt-txt-14-light">${i}</span>
|
|
13
|
+
</button>
|
|
14
|
+
`}_renderPopup(){return e._`
|
|
15
|
+
<div
|
|
16
|
+
class="pkt-timepicker-popup"
|
|
17
|
+
id=${this.id+`-popup`}
|
|
18
|
+
?hidden=${!this._isOpen}
|
|
19
|
+
role="group"
|
|
20
|
+
aria-label=${this.pktStrings.get(`timepicker`).selectTime}
|
|
21
|
+
@keydown=${this._handlePopupKeydown}
|
|
22
|
+
@focusout=${e=>{this.querySelector(`.pkt-timepicker-popup`)?.contains(e.relatedTarget)||this._closePopup()}}
|
|
23
|
+
>
|
|
24
|
+
<div
|
|
25
|
+
class="pkt-timepicker-popup__col"
|
|
26
|
+
role="listbox"
|
|
27
|
+
aria-label=${this.pktStrings.get(`timepicker`).hours}
|
|
28
|
+
aria-orientation="vertical"
|
|
29
|
+
>
|
|
30
|
+
${this._hourOptions.map(e=>this._renderOption(e,`hour`))}
|
|
31
|
+
</div>
|
|
32
|
+
<div
|
|
33
|
+
class="pkt-timepicker-popup__col"
|
|
34
|
+
role="listbox"
|
|
35
|
+
aria-label=${this.pktStrings.get(`timepicker`).minutes}
|
|
36
|
+
aria-orientation="vertical"
|
|
37
|
+
>
|
|
38
|
+
${this._minuteOptions.map(e=>this._renderOption(e,`minute`))}
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
`}_renderContainer(){let t=this.pktStrings.get(`timepicker`).hours,n=this.pktStrings.get(`timepicker`).minutes,r=this.label?`${t}, ${this.label}`:t,o=this.label?`${n}, ${this.label}`:n;return e._`
|
|
42
|
+
<div
|
|
43
|
+
class="pkt-input__container pkt-input__container--${this.inputSize}"
|
|
44
|
+
@click=${e=>{e.target.closest(`button, input`)||this.hoursInputRef.value?.focus()}}
|
|
45
|
+
>
|
|
46
|
+
${this.stepArrows?e._`
|
|
47
|
+
<button
|
|
48
|
+
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-btn--${this.inputSize} pkt-timepicker__button pkt-timepicker__button--prev"
|
|
49
|
+
type="button"
|
|
50
|
+
aria-label=${this.pktStrings.get(`timepicker`).prevTime}
|
|
51
|
+
?disabled=${this.disabled}
|
|
52
|
+
@click=${()=>this._stepTime(-1)}
|
|
53
|
+
>
|
|
54
|
+
<pkt-icon name="chevron-thin-left"></pkt-icon>
|
|
55
|
+
<span class="pkt-btn__text"
|
|
56
|
+
>${this.pktStrings.get(`timepicker`).prevTime}</span
|
|
57
|
+
>
|
|
58
|
+
</button>
|
|
59
|
+
`:e.h}
|
|
60
|
+
<input
|
|
61
|
+
${a.n(this.hoursInputRef)}
|
|
62
|
+
type="text"
|
|
63
|
+
inputmode="numeric"
|
|
64
|
+
maxlength="2"
|
|
65
|
+
size="2"
|
|
66
|
+
class="pkt-input pkt-input--${this.inputSize} pkt-timepicker__input"
|
|
67
|
+
id=${this.id+`-hours`}
|
|
68
|
+
data-min="0"
|
|
69
|
+
data-max="23"
|
|
70
|
+
.value=${this._hours}
|
|
71
|
+
placeholder="––"
|
|
72
|
+
aria-label=${r}
|
|
73
|
+
role="spinbutton"
|
|
74
|
+
aria-invalid=${this.hasError?`true`:e.h}
|
|
75
|
+
aria-errormessage=${this.hasError?`${this.id}-hours-error`:e.h}
|
|
76
|
+
aria-valuemin="0"
|
|
77
|
+
aria-valuemax="23"
|
|
78
|
+
aria-valuenow=${this._hours===``?e.h:this._hours}
|
|
79
|
+
aria-valuetext=${this._hours===``?e.h:`${this._hours} ${t.toLowerCase()}`}
|
|
80
|
+
autocomplete="off"
|
|
81
|
+
?disabled=${this.disabled}
|
|
82
|
+
@keydown=${this._handleHoursKeydown}
|
|
83
|
+
@blur=${this._handleHoursBlur}
|
|
84
|
+
@focus=${e=>{e.target.select(),e.stopImmediatePropagation()}}
|
|
85
|
+
/>
|
|
86
|
+
<span class="pkt-timepicker__separator">:</span>
|
|
87
|
+
<input
|
|
88
|
+
${a.n(this.minutesInputRef)}
|
|
89
|
+
type="text"
|
|
90
|
+
inputmode="numeric"
|
|
91
|
+
maxlength="2"
|
|
92
|
+
size="2"
|
|
93
|
+
class="pkt-input pkt-input--${this.inputSize} pkt-timepicker__input"
|
|
94
|
+
id=${this.id+`-minutes`}
|
|
95
|
+
data-min="0"
|
|
96
|
+
data-max="59"
|
|
97
|
+
.value=${this._minutes}
|
|
98
|
+
placeholder="––"
|
|
99
|
+
aria-label=${o}
|
|
100
|
+
role="spinbutton"
|
|
101
|
+
aria-invalid=${this.hasError?`true`:e.h}
|
|
102
|
+
aria-errormessage=${this.hasError?`${this.id}-hours-error`:e.h}
|
|
103
|
+
aria-valuemin="0"
|
|
104
|
+
aria-valuemax="59"
|
|
105
|
+
aria-valuenow=${this._minutes===``?e.h:this._minutes}
|
|
106
|
+
aria-valuetext=${this._minutes===``?e.h:`${this._minutes} ${n.toLowerCase()}`}
|
|
107
|
+
autocomplete="off"
|
|
108
|
+
?disabled=${this.disabled}
|
|
109
|
+
@keydown=${this._handleMinutesKeydown}
|
|
110
|
+
@blur=${this._handleMinutesBlur}
|
|
111
|
+
@focus=${e=>{e.target.select(),e.stopImmediatePropagation()}}
|
|
112
|
+
/>
|
|
113
|
+
${this.hidePicker&&!this.stepArrows?e._`<pkt-icon
|
|
114
|
+
class="pkt-input-icon pkt-timepicker__icon"
|
|
115
|
+
name="clock"
|
|
116
|
+
aria-hidden="true"
|
|
117
|
+
></pkt-icon>`:e.h}
|
|
118
|
+
${!this.hidePicker&&!this.stepArrows?e._`
|
|
119
|
+
<button
|
|
120
|
+
${a.n(this.buttonRef)}
|
|
121
|
+
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-btn--${this.inputSize} pkt-timepicker__button"
|
|
122
|
+
type="button"
|
|
123
|
+
aria-label=${this.pktStrings.get(`timepicker`).openPicker}
|
|
124
|
+
aria-haspopup="listbox"
|
|
125
|
+
aria-expanded=${this._isOpen?`true`:`false`}
|
|
126
|
+
aria-controls=${this.id+`-popup`}
|
|
127
|
+
?disabled=${this.disabled}
|
|
128
|
+
@click=${this._togglePopup}
|
|
129
|
+
>
|
|
130
|
+
<pkt-icon name="clock"></pkt-icon>
|
|
131
|
+
<span class="pkt-btn__text"
|
|
132
|
+
>${this.pktStrings.get(`timepicker`).openPicker}</span
|
|
133
|
+
>
|
|
134
|
+
</button>
|
|
135
|
+
`:e.h}
|
|
136
|
+
${this.stepArrows?e._`
|
|
137
|
+
<button
|
|
138
|
+
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-btn--${this.inputSize} pkt-timepicker__button pkt-timepicker__button--next"
|
|
139
|
+
type="button"
|
|
140
|
+
aria-label=${this.pktStrings.get(`timepicker`).nextTime}
|
|
141
|
+
?disabled=${this.disabled}
|
|
142
|
+
@click=${()=>this._stepTime(1)}
|
|
143
|
+
>
|
|
144
|
+
<pkt-icon name="chevron-thin-right"></pkt-icon>
|
|
145
|
+
<span class="pkt-btn__text"
|
|
146
|
+
>${this.pktStrings.get(`timepicker`).nextTime}</span
|
|
147
|
+
>
|
|
148
|
+
</button>
|
|
149
|
+
`:e.h}
|
|
150
|
+
<input
|
|
151
|
+
${a.n(this.hiddenInputRef)}
|
|
152
|
+
type="time"
|
|
153
|
+
hidden
|
|
154
|
+
name=${this.name||this.id}
|
|
155
|
+
id=${this.id+`-input`}
|
|
156
|
+
.value=${this.value}
|
|
157
|
+
min=${i.t(this.min??void 0)}
|
|
158
|
+
max=${i.t(this.max??void 0)}
|
|
159
|
+
step=${i.t(this.step??void 0)}
|
|
160
|
+
?required=${this.required}
|
|
161
|
+
?disabled=${this.disabled}
|
|
162
|
+
tabindex="-1"
|
|
163
|
+
/>
|
|
164
|
+
</div>
|
|
165
|
+
`}render(){return e._`
|
|
166
|
+
<pkt-input-wrapper
|
|
167
|
+
.strings=${this.strings}
|
|
168
|
+
label="${this.label}"
|
|
169
|
+
?disabled=${this.disabled}
|
|
170
|
+
?fullwidth=${this.fullwidth}
|
|
171
|
+
?hasError=${this.hasError}
|
|
172
|
+
?hasFieldset=${this.effectiveHasFieldset(!1)}
|
|
173
|
+
?inline=${this.inline}
|
|
174
|
+
?optionalTag=${this.optionalTag}
|
|
175
|
+
?required=${this.required}
|
|
176
|
+
?requiredTag=${this.requiredTag}
|
|
177
|
+
useWrapper=${this.useWrapper}
|
|
178
|
+
.ariaDescribedby=${this.ariaDescribedby}
|
|
179
|
+
.errorMessage=${this.errorMessage}
|
|
180
|
+
.forId="${this.id+`-hours`}"
|
|
181
|
+
.helptext=${this.helptext}
|
|
182
|
+
.helptextDropdown=${this.helptextDropdown}
|
|
183
|
+
.helptextDropdownButton=${this.helptextDropdownButton}
|
|
184
|
+
.optionalText=${this.optionalText}
|
|
185
|
+
.requiredText=${this.requiredText}
|
|
186
|
+
.tagText=${this.tagText}
|
|
187
|
+
.size=${this.inputSize}
|
|
188
|
+
>
|
|
189
|
+
<div class="pkt-contents" slot="helptext">${r.n(this,`helptext`)}</div>
|
|
190
|
+
${!this.hidePicker&&!this.stepArrows?e._`
|
|
191
|
+
<div class="pkt-timepicker__anchor">
|
|
192
|
+
${this._renderContainer()} ${this._renderPopup()}
|
|
193
|
+
</div>
|
|
194
|
+
`:this._renderContainer()}
|
|
195
|
+
</pkt-input-wrapper>
|
|
196
|
+
`}};e.n([e.u({type:String,reflect:!0})],p.prototype,`value`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`hide-picker`})],p.prototype,`hidePicker`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`step-arrows`})],p.prototype,`stepArrows`,void 0),e.n([e.l()],p.prototype,`_hours`,void 0),e.n([e.l()],p.prototype,`_minutes`,void 0),e.n([e.l()],p.prototype,`_isOpen`,void 0);try{e.d(`pkt-timepicker`)(p)}catch{console.warn(`Forsøker å definere <pkt-timepicker>, men den er allerede definert`)}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return p}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.1.0",
|
|
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",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@babel/plugin-transform-private-property-in-object": "^7.27.1",
|
|
42
42
|
"@babel/preset-env": "^7.28.3",
|
|
43
43
|
"@babel/preset-typescript": "^7.28.3",
|
|
44
|
-
"@oslokommune/punkt-assets": "^
|
|
44
|
+
"@oslokommune/punkt-assets": "^18.0.0",
|
|
45
45
|
"@testing-library/dom": "^10.4.1",
|
|
46
46
|
"@testing-library/jest-dom": "^6.9.1",
|
|
47
47
|
"@types/jest-axe": "^3.5.9",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"engines": {
|
|
84
84
|
"node": "^22.19.0 || ^24.0.0 || ^26.0.0"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "087459aca13f8ff3a34afc42f8e1cd73900d4896"
|
|
87
87
|
}
|
|
@@ -2,21 +2,13 @@ import { provide } from '@lit/context'
|
|
|
2
2
|
import { html, LitElement } from 'lit'
|
|
3
3
|
import { customElement, property, state } from 'lit/decorators.js'
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js'
|
|
5
|
-
import type { TAccordionSkin } from 'shared-types'
|
|
5
|
+
import type { IPktAccordionBase, TAccordionSkin } from 'shared-types'
|
|
6
6
|
|
|
7
7
|
import { accordionContext, type AccordionContext } from './accordion-context'
|
|
8
8
|
|
|
9
9
|
export type TPktAccordionSkin = TAccordionSkin
|
|
10
10
|
|
|
11
|
-
export interface IPktAccordion {
|
|
12
|
-
compact?: boolean
|
|
13
|
-
skin?: TPktAccordionSkin
|
|
14
|
-
ariaLabelledBy?: string
|
|
15
|
-
name?: string
|
|
16
|
-
/**
|
|
17
|
-
* @description A unique identifier to connect the accordion with a heading
|
|
18
|
-
*/
|
|
19
|
-
}
|
|
11
|
+
export interface IPktAccordion extends IPktAccordionBase {}
|
|
20
12
|
|
|
21
13
|
export class PktAccordion extends LitElement implements IPktAccordion {
|
|
22
14
|
// Properties
|
|
@@ -4,6 +4,7 @@ import { consume } from '@lit/context'
|
|
|
4
4
|
import { html, PropertyValues } from 'lit'
|
|
5
5
|
import { customElement, property } from 'lit/decorators.js'
|
|
6
6
|
import { createRef, Ref, ref } from 'lit/directives/ref.js'
|
|
7
|
+
import type { IPktAccordionItemBase } from 'shared-types'
|
|
7
8
|
import { TPktAccordionSkin } from './accordion'
|
|
8
9
|
import { accordionContext, type AccordionContext } from './accordion-context'
|
|
9
10
|
import { classMap } from 'lit/directives/class-map.js'
|
|
@@ -16,15 +17,7 @@ import { ifDefined } from 'lit/directives/if-defined.js'
|
|
|
16
17
|
* to override the automatic toggling
|
|
17
18
|
*/
|
|
18
19
|
|
|
19
|
-
export interface IPktAccordionItem {
|
|
20
|
-
defaultOpen?: boolean
|
|
21
|
-
id: string
|
|
22
|
-
title: string
|
|
23
|
-
skin?: TPktAccordionSkin
|
|
24
|
-
compact?: boolean
|
|
25
|
-
isOpen?: boolean
|
|
26
|
-
name?: string | undefined
|
|
27
|
-
}
|
|
20
|
+
export interface IPktAccordionItem extends IPktAccordionItemBase {}
|
|
28
21
|
|
|
29
22
|
export class PktAccordionItem extends PktElementWithSlot implements IPktAccordionItem {
|
|
30
23
|
@property({ type: Boolean }) defaultOpen: boolean = false
|