@oslokommune/punkt-elements 19.18.1 → 19.18.2
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 +22 -0
- package/dist/{accordion-XX12Iouj.cjs → accordion-Ea61u8Xj.cjs} +1 -1
- package/dist/{accordion-GheghzDV.js → accordion-gEzU_AQC.js} +1 -1
- package/dist/{alert-gty76GoA.js → alert-B3ify6mt.js} +2 -2
- package/dist/{alert-SQdshv-F.cjs → alert-ByQC8-D1.cjs} +1 -1
- package/dist/{button-DMytp-Jt.cjs → button-DWXtPiAA.cjs} +1 -1
- package/dist/{button-Cf5ReNPj.js → button-U4r2XSv4.js} +1 -1
- package/dist/{calendar-xmCeJYlb.cjs → calendar-4S_k7_KN.cjs} +2 -2
- package/dist/{calendar-D5xCL3xC.js → calendar-C8maj_iv.js} +12 -14
- package/dist/{card-Dc9p91TY.cjs → card-CS0OoVjJ.cjs} +1 -1
- package/dist/{card-k-3UP5NP.js → card-yxsQ563N.js} +2 -2
- package/dist/{checkbox-C4faOikK.js → checkbox-A5B82H0n.js} +1 -1
- package/dist/{checkbox-CbogvdEA.cjs → checkbox-Cj3S0xJE.cjs} +1 -1
- package/dist/{checkbox-group-6vOqwCRi.js → checkbox-group-AVOtCLSB.js} +2 -2
- package/dist/{checkbox-group-YyhtneCi.cjs → checkbox-group-BFtLRclu.cjs} +1 -1
- package/dist/{combobox-D0J03ikb.js → combobox-CScZtqsn.js} +5 -5
- package/dist/{combobox-hbHEJIxp.cjs → combobox-rmrzvK3U.cjs} +1 -1
- package/dist/components/accordion/accordion.d.ts +3 -3
- package/dist/components/calendar/calendar.d.ts +1 -2
- package/dist/components/datepicker/datepicker-utils.d.ts +9 -3
- package/dist/{consent-hhwIP8m5.js → consent-JoGVWIB7.js} +1 -1
- package/dist/{consent-BCrPGLXe.cjs → consent-T0-aOOEh.cjs} +1 -1
- package/dist/{datepicker-BSQV2yhB.cjs → datepicker-BOi60ruU.cjs} +1 -1
- package/dist/{datepicker-ChGCD7Gf.js → datepicker-C8DQaZa8.js} +5 -5
- package/dist/directives/slot-content.d.ts +7 -1
- package/dist/{element-with-slot-gdQbNteD.cjs → element-with-slot-B0Vp_OuR.cjs} +1 -1
- package/dist/{element-with-slot-BP-IBGq0.js → element-with-slot-Dp2Gzv-Q.js} +8 -2
- package/dist/{fileupload-BKae4SiP.cjs → fileupload-Dov3DkmR.cjs} +1 -1
- package/dist/{fileupload-CAZrdubx.js → fileupload-jSc9M2Ok.js} +3 -3
- package/dist/{footer-JAQGiWJh.js → footer-BOIVSL59.js} +1 -1
- package/dist/{footer-wmH_UXCd.cjs → footer-MYZSMtmP.cjs} +1 -1
- package/dist/{header-bvY1RA0W.js → header-BCpCu0HP.js} +5 -5
- package/dist/{header-CB-CiwsK.cjs → header-CecwTgso.cjs} +1 -1
- package/dist/{header-menu-BJNxDdhj.js → header-menu-BEhnqxnw.js} +1 -1
- package/dist/{header-menu-BlvU5Y1U.cjs → header-menu-CkZjAxHb.cjs} +1 -1
- package/dist/{heading-CBxJ3UCj.cjs → heading--hGRDNX9.cjs} +1 -1
- package/dist/{heading-Br5s4zO0.js → heading-B1Ey3XzB.js} +1 -1
- package/dist/{helptext-B6xxUfvv.js → helptext-BXoDjtNs.js} +1 -1
- package/dist/{helptext-5_uOsEMN.cjs → helptext-DPqzGQeD.cjs} +1 -1
- package/dist/{input-element-CCV_e85v.cjs → input-element-BhbkMU20.cjs} +1 -1
- package/dist/{input-element-DhNSPDnG.js → input-element-JH4qPly5.js} +1 -1
- package/dist/{input-wrapper-D1RqTzm4.cjs → input-wrapper-Bekd6DGA.cjs} +1 -1
- package/dist/{input-wrapper-D-w6uRXZ.js → input-wrapper-BttEKK9G.js} +3 -3
- package/dist/{link-DzWPIXm1.js → link-Cb0ufHt0.js} +1 -1
- package/dist/{link-DW6O3Ko1.cjs → link-UEoCDWe-.cjs} +1 -1
- package/dist/{linkcard-Dda2K5te.js → linkcard-CD-tRZnz.js} +2 -2
- package/dist/{linkcard-EOwwQZeY.cjs → linkcard-Dmp8DOyg.cjs} +2 -2
- package/dist/{loader-DXKGCBqh.js → loader-B0p9ZrAa.js} +1 -1
- package/dist/{loader-CnsELZFa.cjs → loader-nd4WUR88.cjs} +1 -1
- package/dist/{messagebox-DPVRQ3PY.js → messagebox-B-DU7T5q.js} +1 -1
- package/dist/{messagebox-CIgUgKhu.cjs → messagebox-Bx9jEw4V.cjs} +1 -1
- package/dist/{modal-BWaMErv7.js → modal-Cv0uz8iY.js} +1 -1
- package/dist/{modal-Cp10a22a.cjs → modal-SFoXzth5.cjs} +1 -1
- package/dist/{option-group-element-d9TouZ2M.js → option-group-element-16F2MJlO.js} +2 -2
- package/dist/{option-group-element-D_UW097C.cjs → option-group-element-DHpno4pS.cjs} +1 -1
- 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-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-group.cjs +1 -1
- package/dist/pkt-checkbox-group.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-index.cjs +1 -1
- package/dist/pkt-index.js +30 -30
- 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-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-DcwERZzm.cjs → pkt-options-controller-C193xcN4.cjs} +1 -1
- package/dist/{pkt-options-controller-LiApNBoZ.js → pkt-options-controller-CH8U6zlw.js} +1 -1
- package/dist/pkt-radio-group.cjs +1 -1
- package/dist/pkt-radio-group.js +1 -1
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.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/{radio-group-B_NEwwP7.js → radio-group-CO3dzdOl.js} +2 -2
- package/dist/{radio-group-dQrEQ1pX.cjs → radio-group-S8Gg4Qaq.cjs} +1 -1
- package/dist/{radiobutton-DWZ4VgYg.js → radiobutton-BNsed-4-.js} +1 -1
- package/dist/{radiobutton-mXqSvSQE.cjs → radiobutton-CYlly_Zk.cjs} +1 -1
- package/dist/{select-DkO-UPUY.cjs → select-C74U9Tyl.cjs} +1 -1
- package/dist/{select-DhQk3S6t.js → select-C7r2Y7Bq.js} +4 -4
- package/dist/{tabs-DvVYDYVh.cjs → tabs-BsVUzKix.cjs} +1 -1
- package/dist/{tabs-Y2-2pD42.js → tabs-CxG9lgAB.js} +2 -2
- package/dist/{tag-BEFxzKsm.cjs → tag-BfFtiV5e.cjs} +1 -1
- package/dist/{tag-B9GawuIf.js → tag-BswfpmoV.js} +1 -1
- package/dist/{textarea-S0pRMEnT.js → textarea-5aOI1Qkq.js} +3 -3
- package/dist/{textarea-CEHqACey.cjs → textarea-VObZEvUw.cjs} +1 -1
- package/dist/{textinput-DkfjnDvX.js → textinput-DABFhf0d.js} +3 -3
- package/dist/{textinput-BdQ3FZ8R.cjs → textinput-Wd1yRQuN.cjs} +1 -1
- package/dist/{timepicker-DI3oiK4L.js → timepicker-Bfp365j8.js} +3 -3
- package/dist/{timepicker-BssDur6k.cjs → timepicker-Cc_7siiw.cjs} +1 -1
- package/package.json +5 -9
- package/src/components/accordion/accordion.ts +3 -3
- package/src/components/calendar/calendar.selection.test.ts +40 -0
- package/src/components/calendar/calendar.ts +5 -6
- package/src/components/consent/consent.test.ts +2 -0
- package/src/components/datepicker/datepicker-popup.ts +1 -1
- package/src/components/datepicker/datepicker-utils.ts +7 -5
- package/src/components/header/types.ts +0 -1
- package/src/components/linkcard/linkcard.ts +1 -1
- package/dist/base-elements/checkable-native-parity.test.d.ts +0 -0
- package/dist/base-elements/form-attribute.test.d.ts +0 -0
- package/dist/base-elements/form-disabled.test.d.ts +0 -0
- package/dist/base-elements/polyfill-form-value.test.d.ts +0 -0
- package/dist/components/accordion/accordion.test.d.ts +0 -0
- package/dist/components/alert/alert.test.d.ts +0 -14
- package/dist/components/backlink/backlink.test.d.ts +0 -10
- package/dist/components/breadcrumbs/breadcrumbs.test.d.ts +0 -0
- package/dist/components/button/button.test.d.ts +0 -22
- package/dist/components/calendar/calendar.accessibility.test.d.ts +0 -16
- package/dist/components/calendar/calendar.constraints.test.d.ts +0 -0
- package/dist/components/calendar/calendar.core.test.d.ts +0 -0
- package/dist/components/calendar/calendar.interaction.test.d.ts +0 -0
- package/dist/components/calendar/calendar.selection.test.d.ts +0 -0
- package/dist/components/card/card.test.d.ts +0 -22
- package/dist/components/checkbox/checkbox.test.d.ts +0 -24
- package/dist/components/checkbox-group/checkbox-group.test.d.ts +0 -0
- package/dist/components/combobox/combobox.accessibility.test.d.ts +0 -0
- package/dist/components/combobox/combobox.attributes.test.d.ts +0 -0
- package/dist/components/combobox/combobox.core.test.d.ts +0 -0
- package/dist/components/combobox/combobox.interaction.test.d.ts +0 -0
- package/dist/components/combobox/combobox.preselection.test.d.ts +0 -0
- package/dist/components/combobox/combobox.selection.test.d.ts +0 -0
- package/dist/components/consent/consent.test.d.ts +0 -16
- package/dist/components/datepicker/date-tags.test.d.ts +0 -12
- package/dist/components/datepicker/datepicker-popup.test.d.ts +0 -4
- package/dist/components/datepicker/datepicker-utils.test.d.ts +0 -1
- package/dist/components/datepicker/datepicker.accessibility.test.d.ts +0 -0
- package/dist/components/datepicker/datepicker.core.test.d.ts +0 -0
- package/dist/components/datepicker/datepicker.input.test.d.ts +0 -0
- package/dist/components/datepicker/datepicker.selection.test.d.ts +0 -0
- package/dist/components/datepicker/datepicker.validation.test.d.ts +0 -0
- package/dist/components/fileupload/fileupload.test.d.ts +0 -0
- package/dist/components/footer/footer.accessibility.test.d.ts +0 -0
- package/dist/components/footer/footer.test.d.ts +0 -0
- package/dist/components/header/header-global.accessibility.test.d.ts +0 -0
- package/dist/components/header/header-global.test.d.ts +0 -0
- package/dist/components/header/header-service.accessibility.test.d.ts +0 -0
- package/dist/components/header/header-service.test.d.ts +0 -18
- package/dist/components/header/header.test.d.ts +0 -0
- package/dist/components/header-menu/header-menu.test.d.ts +0 -0
- package/dist/components/heading/heading.test.d.ts +0 -0
- package/dist/components/helptext/helptext-association.test.d.ts +0 -0
- package/dist/components/helptext/helptext.test.d.ts +0 -0
- package/dist/components/icon/icon.test.d.ts +0 -12
- package/dist/components/input-wrapper/input-wrapper.test.d.ts +0 -32
- package/dist/components/input-wrapper/tri-state.test.d.ts +0 -0
- package/dist/components/input-wrapper/wrapper-parity.test.d.ts +0 -1
- package/dist/components/link/link.test.d.ts +0 -15
- package/dist/components/linkcard/linkcard.test.d.ts +0 -9
- package/dist/components/listbox/listbox.interaction.test.d.ts +0 -10
- package/dist/components/listbox/listbox.test.d.ts +0 -10
- package/dist/components/loader/loader.test.d.ts +0 -8
- package/dist/components/messagebox/messagebox.test.d.ts +0 -8
- package/dist/components/modal/modal.test.d.ts +0 -9
- package/dist/components/progressbar/progressbar.test.d.ts +0 -8
- package/dist/components/radio-group/radio-group.test.d.ts +0 -0
- package/dist/components/radiobutton/radiobutton.test.d.ts +0 -28
- package/dist/components/searchinput/searchinput.test.d.ts +0 -0
- package/dist/components/select/select.test.d.ts +0 -23
- package/dist/components/tabs/tabs.test.d.ts +0 -0
- package/dist/components/tag/tag.test.d.ts +0 -8
- package/dist/components/textarea/textarea.test.d.ts +0 -29
- package/dist/components/textinput/textinput.test.d.ts +0 -33
- package/dist/components/timepicker/timepicker.test.d.ts +0 -25
- package/dist/directives/slot-content.test.d.ts +0 -0
- package/dist/docs/backlink.d.ts +0 -4
- package/dist/docs/components/accordion.d.ts +0 -5
- package/dist/docs/components/alert.d.ts +0 -9
- package/dist/docs/components/backlink.d.ts +0 -4
- package/dist/docs/components/breadcrumbs.d.ts +0 -8
- package/dist/docs/components/button.d.ts +0 -10
- package/dist/docs/components/calendar.d.ts +0 -4
- package/dist/docs/components/card.d.ts +0 -27
- package/dist/docs/components/checkbox-group.d.ts +0 -13
- package/dist/docs/components/checkbox.d.ts +0 -8
- package/dist/docs/components/combobox.d.ts +0 -11
- package/dist/docs/components/comboboxdemo.d.ts +0 -4
- package/dist/docs/components/consent.d.ts +0 -4
- package/dist/docs/components/datepicker.d.ts +0 -4
- package/dist/docs/components/datepickermultiple.d.ts +0 -4
- package/dist/docs/components/event-log.d.ts +0 -20
- package/dist/docs/components/fileupload.d.ts +0 -28
- package/dist/docs/components/footer.d.ts +0 -9
- package/dist/docs/components/form-sizes.d.ts +0 -10
- package/dist/docs/components/form.d.ts +0 -9
- package/dist/docs/components/header-full.d.ts +0 -36
- package/dist/docs/components/header-global-full.d.ts +0 -20
- package/dist/docs/components/header-global.d.ts +0 -14
- package/dist/docs/components/header-menu.d.ts +0 -8
- package/dist/docs/components/header.d.ts +0 -18
- package/dist/docs/components/heading.d.ts +0 -12
- package/dist/docs/components/icon.d.ts +0 -4
- package/dist/docs/components/input-wrapper.d.ts +0 -4
- package/dist/docs/components/link.d.ts +0 -4
- package/dist/docs/components/linkcard.d.ts +0 -4
- package/dist/docs/components/loader.d.ts +0 -10
- package/dist/docs/components/messagebox.d.ts +0 -4
- package/dist/docs/components/modal.d.ts +0 -24
- package/dist/docs/components/progressbar.d.ts +0 -9
- package/dist/docs/components/radio-checkbox-sizes.d.ts +0 -10
- package/dist/docs/components/radio-group.d.ts +0 -13
- package/dist/docs/components/radiobutton.d.ts +0 -12
- package/dist/docs/components/searchinput.d.ts +0 -17
- package/dist/docs/components/select.d.ts +0 -13
- package/dist/docs/components/slot-internals.d.ts +0 -14
- package/dist/docs/components/slots.d.ts +0 -37
- package/dist/docs/components/switch.d.ts +0 -4
- package/dist/docs/components/tabs.d.ts +0 -35
- package/dist/docs/components/tag.d.ts +0 -4
- package/dist/docs/components/textarea.d.ts +0 -4
- package/dist/docs/components/textinput.d.ts +0 -5
- package/dist/docs/components/timepicker.d.ts +0 -4
- package/dist/docs/components/verifisering.d.ts +0 -15
- package/dist/docs/header.d.ts +0 -14
- package/dist/docs/punkt-docs.d.ts +0 -15
- package/dist/docs/tableOfContents.d.ts +0 -15
- package/dist/tests/component-registry.d.ts +0 -72
- package/dist/tests/option-contexts.d.ts +0 -7
- package/dist/tests/strings-override.test.d.ts +0 -0
- package/dist/tests/test-framework.d.ts +0 -29
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./consume-kEjgTrAp.cjs"),r=require("./ref-CB7e9nMY.cjs"),i=require("./input-element-
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./consume-kEjgTrAp.cjs"),r=require("./ref-CB7e9nMY.cjs"),i=require("./input-element-BhbkMU20.cjs");var a={defaultChecked:!1,hasTile:!1,disabled:!1,hasError:!1,requiredTag:!1,optionalTag:!1},o=n.n(Symbol(`pkt-radio-group-context`)),s=class extends i.t{constructor(...e){super(...e),this.inputRef=r.t(),this.value=``,this.checkHelptext=null,this.defaultChecked=a.defaultChecked,this.hasTile=a.hasTile,this.checked=null,this.type=`radio`,this.inputSize=void 0,this.tagText=null,this.optionalTag=a.optionalTag,this.requiredTag=a.requiredTag,this._checked=!1}connectedCallback(){super.connectedCallback()}attributeChangedCallback(e,t,n){e===`checked`&&(this._checked=this.checked===``||this.checked===`true`||this.checked===!0),super.attributeChangedCallback(e,t,n)}render(){let n=this.hasTile||!!this.groupContext?.hasTile,i=t.t({"pkt-input-check__input":!0,"pkt-input-check__input--tile":n,"pkt-input-check__input--tile-disabled":this.isDisabled&&n}),a=t.t({"pkt-input-check__input-checkbox":!0,"pkt-input-check__input-checkbox--error":this.hasError||!!this.groupContext?.hasError}),o=t.t({"pkt-input-check__input-label":!0,"pkt-input-check__input-label--disabled":this.isDisabled,"pkt-sr-only":this.hideLabel}),s=`pkt-tag pkt-tag--small pkt-tag--thin-text`,c=this.pktStrings.get(`forms`),l=()=>e._`
|
|
2
2
|
${this.tagText?e._`<span class=${s+` pkt-tag--gray`}>${this.tagText}</span>`:e.h}
|
|
3
3
|
${this.optionalTag?e._`<span class=${s+` pkt-tag--blue-light`}
|
|
4
4
|
>${this.optionalText??c.optional}</span
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./element-with-slot-
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./element-with-slot-B0Vp_OuR.cjs"),n=require("./input-wrapper-Bekd6DGA.cjs"),r=require("./if-defined-CiML3MTM.cjs"),i=require("./ref-CB7e9nMY.cjs"),a=require("./input-element-BhbkMU20.cjs"),o=require("./pkt-options-controller-C193xcN4.cjs");var s=class extends a.t{constructor(...e){super(...e),this._optionsProp=[],this._options=[]}get options(){return this._options.map(e=>({...e,selected:this.isOptionSelected(e)}))}set options(e){this._optionsProp=e,this.requestUpdate(`_optionsProp`,this._options)}isOptionSelected(e){return Array.isArray(this.value)?this.value.includes(e.value):e.value===this.value}findOptionByValue(e){return this._options.find(t=>t.value===e)}getSelectedOptions(){return this._options.filter(e=>this.isOptionSelected(e))}parseOptions(){let e=this._optionsProp.length>0,t=this.optionsController?.nodes?.length&&this.optionsController.nodes.length>0;e?this._options=this._optionsProp:t&&(this._options=this.optionsController.options)}willUpdate(e){super.willUpdate(e),this.parseOptions()}};e.n([e.u({type:Array,attribute:`options`})],s.prototype,`_optionsProp`,void 0),e.n([e.l()],s.prototype,`_options`,void 0);var c=class extends s{constructor(){super(),this.inputRef=i.t(),this.value=``,this.selectedIndex=-1,this.selectedOptions=void 0,this.optionsController=new o.t(this)}connectedCallback(){super.connectedCallback(),this.parseOptions(),this._options.forEach(e=>{e.selected&&!this.value&&(this.value=e.value)})}add(e,t){let n={value:e.value||e.text,label:e.text||e.value,selected:e.selected,disabled:e.disabled};if(t===void 0)this._options.push(n);else if(typeof t==`number`)this._options.splice(t,0,n);else{let e=t.value||t.text,r=this._options.findIndex(t=>t.value===e);r>=0?this._options.splice(r,0,n):this._options.push(n)}e.selected&&(this.value=e.value||e.text,this.selectedIndex=this._options.findIndex(e=>e.value===this.value)),this.requestUpdate()}remove(e){typeof e==`number`&&(this.selectedIndex===e&&(this.value=this._options[0]?.value||``),this._options.splice(e,1),this.requestUpdate())}item(e){return this.inputRef.value?.item(e)}namedItem(e){return this.inputRef.value?.namedItem(e)}showPicker(){this.inputRef.value&&`showPicker`in this.inputRef.value&&this.inputRef.value.showPicker()}attributeChangedCallback(e,t,n){e===`options`&&(this._options=n?JSON.parse(n):[]),e===`value`&&this.value!==t&&(this.selectedIndex=this.touched?this.returnNumberOrNull(this.inputRef.value?.selectedIndex):this._options.findIndex(e=>e.value===n),this.selectedOptions=this.inputRef.value?.selectedOptions,this.valueChanged(n,t)),super.attributeChangedCallback(e,t,n)}update(e){super.update(e),e.has(`_optionsProp`)&&this._optionsProp.length>0&&(this._options=this._optionsProp,this.requestUpdate(`_options`),!this.value&&this._options.length>0&&(this.value=this._options[0].value,this.selectedIndex=0)),e.has(`value`)&&this.value!==e.get(`value`)&&(this.selectedIndex=this.touched?this.returnNumberOrNull(this.inputRef.value?.selectedIndex):this._options.findIndex(e=>e.value===this.value),this.selectedOptions=this.inputRef.value?.selectedOptions,this.valueChanged(this.value,e.get(`value`))),e.has(`id`)&&!this.name&&this.id&&(this.name=this.id)}firstUpdated(e){super.firstUpdated(e),this.classList.add(`pkt-select`),this._optionsProp.length&&(this._options=this._optionsProp),!this.value&&this._options.length>0?(this.value=this._options[0].value,this.selectedIndex=0):this.selectedIndex=this._options.findIndex(e=>e.value===this.value),this.selectedOptions=this.inputRef.value?.selectedOptions}render(){let a=`pkt-input pkt-input--${this.inputSize} ${this.fullwidth?`pkt-input--fullwidth`:``}`;return e._`
|
|
2
2
|
<pkt-input-wrapper
|
|
3
3
|
${t.n(this,[`helptext`])}
|
|
4
4
|
.strings=${this.strings}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { _ as e, d as t, l as n, n as r, u as i } from "./element-ckeMVgMz.js";
|
|
2
|
-
import { n as a } from "./element-with-slot-
|
|
3
|
-
import { r as o } from "./input-wrapper-
|
|
2
|
+
import { n as a } from "./element-with-slot-Dp2Gzv-Q.js";
|
|
3
|
+
import { r as o } from "./input-wrapper-BttEKK9G.js";
|
|
4
4
|
import { t as s } from "./if-defined-D18nY_K_.js";
|
|
5
5
|
import { n as c, t as l } from "./ref-D4OwQYdf.js";
|
|
6
|
-
import { t as u } from "./input-element-
|
|
7
|
-
import { t as d } from "./pkt-options-controller-
|
|
6
|
+
import { t as u } from "./input-element-JH4qPly5.js";
|
|
7
|
+
import { t as d } from "./pkt-options-controller-CH8U6zlw.js";
|
|
8
8
|
//#region src/base-elements/options-input-element.ts
|
|
9
9
|
var f = class extends u {
|
|
10
10
|
constructor(...e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./element-with-slot-
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./element-with-slot-B0Vp_OuR.cjs"),n=require("./if-defined-CiML3MTM.cjs"),r=require("./consume-kEjgTrAp.cjs"),i=require("./provide-Cz18sYug.cjs"),a=require("./ref-CB7e9nMY.cjs");require("./tag-BfFtiV5e.cjs");var o=r.n(Symbol(`pkt-tabs-context`)),s=class extends t.t{constructor(...e){super(...e),this.arrowNav=!0,this.disableArrowNav=!1,this.separatorIconName=``,this.separatorIconPath=``,this.tabRefs=[],this.disabledMap={},this.tabCount=0,this.context={useArrowNav:this.useArrowNav,registerTab:this.registerTab.bind(this),handleClick:this.handleClick.bind(this),handleKeyUp:this.handleKeyUp.bind(this)}}get useArrowNav(){return this.arrowNav&&!this.disableArrowNav}willUpdate(e){(e.has(`arrowNav`)||e.has(`disableArrowNav`))&&(this.context={...this.context,useArrowNav:this.useArrowNav})}updated(){this.updateComplete.then(()=>this.syncSeparators())}syncSeparators(){let e=this.querySelector(`.pkt-tabs__list`);if(!e||(e.querySelectorAll(`.pkt-tabs__separator`).forEach(e=>e.remove()),!(this.separatorIconName||this.separatorIconPath)))return;let t=Array.from(e.children).filter(e=>!e.classList.contains(`pkt-tabs__separator`));for(let e=0;e<t.length-1;e++){let n=document.createElement(`span`);if(n.className=`pkt-tabs__separator`,n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`role`,`presentation`),this.separatorIconPath){let e=document.createElement(`img`);e.setAttribute(`src`,this.separatorIconPath),e.setAttribute(`alt`,``),e.setAttribute(`aria-hidden`,`true`),n.appendChild(e)}else if(this.separatorIconName){let e=document.createElement(`pkt-icon`);e.setAttribute(`name`,this.separatorIconName),e.classList.add(`pkt-tabs__separator-icon`),n.appendChild(e)}t[e].after(n)}}registerTab(e,t,n=!1){this.tabRefs[t]=e,this.disabledMap[t]=n,this.tabCount=Math.max(this.tabCount,t+1)}isTabDisabled(e){return!!this.disabledMap[e]}findEnabledIndex(e,t){let n=e+t;for(;n>=0&&n<this.tabCount;){if(!this.isTabDisabled(n))return n;n+=t}return null}handleClick(e){this.isTabDisabled(e)||this.dispatchEvent(new CustomEvent(`tab-selected`,{detail:{index:e},bubbles:!0,composed:!0}))}handleKeyUp(e,t){if(this.useArrowNav){if(e.key===`ArrowLeft`){e.preventDefault();let n=this.findEnabledIndex(t,-1);n!==null&&this.tabRefs[n]?.focus()}if(e.key===`ArrowRight`){e.preventDefault();let n=this.findEnabledIndex(t,1);n!==null&&this.tabRefs[n]?.focus()}(e.key===`Enter`||e.key===` `||e.key===`Spacebar`||e.key===`ArrowDown`)&&(e.preventDefault(),this.handleClick(t))}}render(){let n=this.useArrowNav?`tablist`:`navigation`,r=this.separatorIconName||this.separatorIconPath?`pkt-tabs pkt-tabs--with-separator`:`pkt-tabs`;return e._`
|
|
2
2
|
<div class=${r}>
|
|
3
3
|
<div class="pkt-tabs__list" role=${n}>${t.i(this)}</div>
|
|
4
4
|
</div>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { _ as e, d as t, l as n, n as r, u as i } from "./element-ckeMVgMz.js";
|
|
2
|
-
import { i as a, t as o } from "./element-with-slot-
|
|
2
|
+
import { i as a, t as o } from "./element-with-slot-Dp2Gzv-Q.js";
|
|
3
3
|
import { t as s } from "./if-defined-D18nY_K_.js";
|
|
4
4
|
import { n as c, t as l } from "./consume-Bp12si68.js";
|
|
5
5
|
import { t as u } from "./provide-_MnlMGnw.js";
|
|
6
6
|
import { n as d, t as f } from "./ref-D4OwQYdf.js";
|
|
7
|
-
import "./tag-
|
|
7
|
+
import "./tag-BswfpmoV.js";
|
|
8
8
|
//#region src/components/tabs/tabs-context.ts
|
|
9
9
|
var p = c(Symbol("pkt-tabs-context")), m = class extends o {
|
|
10
10
|
constructor(...e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-B0Vp_OuR.cjs");require("./icon-Dk8y6odR.cjs");const i=require("./if-defined-CiML3MTM.cjs");var a={name:`pkt-tag`,react:`PktTag`,"css-class":`pkt-tag`,isElement:!0,"dark-mode":!0,props:{size:{name:`Størrelse`,description:`Størrelsen på taggen`,required:!1,default:`medium`,type:[`small`,`medium`,`large`],category:`ui`},iconName:{name:`Ikon`,description:`Navnet på ikonet som skal vises i taggen`,type:`icon`,required:!1,category:`ui`},skin:{name:`Utseende`,description:`Utseendet til taggen`,required:!1,default:`blue`,type:[`blue`,`blue-light`,`blue-dark`,`green`,`red`,`beige`,`yellow`,`gray`],category:`ui`},closeTag:{name:`Lukk tag`,description:`Skal taggen ha en lukkeknapp?`,type:`boolean`,required:!1,default:!1,category:`ui`},textStyle:{name:`Tekststil`,description:`Stilen på teksten i taggen`,required:!1,default:`normal-text`,type:[`thin-text`,`normal-text`],category:`ui`},type:{name:`Type, dersom lukkeknapp`,description:`Type tag, brukes for å spesifisere om det er en knapp, submit eller reset`,required:!1,default:`button`,type:[`button`,`submit`,`reset`],category:`tech`},ariaLabel:{name:`aria-label`,description:`aria-label for taggen, brukes for tilgjengelighet`,type:`string`,required:!1,category:`accessibility`}},slots:{default:{description:`Teksten til tag`}}},o=class extends r.t{constructor(){super(),this.closeTag=a.props.closeTag.default,this.size=a.props.size.default,this.skin=a.props.skin.default,this.textStyle=null,this.iconName=void 0,this.type=a.props.type.default,this.ariaLabel=null,this.buttonTabindex=void 0,this._isClosed=!1,this._ariaDescription=null,this.close=e=>{this._isClosed=!0,this.dispatchEvent(new CustomEvent(`close`,{detail:{origin:e},bubbles:!1,composed:!0})),this.dispatchEvent(new CustomEvent(`on-close`,{detail:{origin:e},bubbles:!1,composed:!0}))},this._isClosed=!1}willUpdate(e){if(super.willUpdate(e),this.closeTag&&!this.ariaLabel){let e=r.r(this).getNodes().map(e=>e.textContent??``).join(``).trim();e&&(this._ariaDescription=n.t(this.pktStrings.get(`tag`).remove,{label:e}))}}render(){let n={"pkt-tag":!0,[`pkt-tag--${this.size}`]:!!this.size,[`pkt-tag--${this.skin}`]:!!this.skin,[`pkt-tag--${this.textStyle}`]:!!this.textStyle},a={"pkt-tag":!0,[`pkt-tag--${this.textStyle}`]:!!this.textStyle,[`pkt-tag--${this.size}`]:!!this.size,[`pkt-tag--${this.skin}`]:!!this.skin,"pkt-hide":this._isClosed};return this.closeTag?e._`
|
|
2
2
|
<button
|
|
3
3
|
class=${t.t(a)}
|
|
4
4
|
type=${this.type}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as e, d as t, l as n, n as r, u as i } from "./element-ckeMVgMz.js";
|
|
2
2
|
import { t as a } from "./class-map-BkEYw5uE.js";
|
|
3
3
|
import { t as o } from "./format-BTeSVkED.js";
|
|
4
|
-
import { i as s, r as c, t as l } from "./element-with-slot-
|
|
4
|
+
import { i as s, r as c, t as l } from "./element-with-slot-Dp2Gzv-Q.js";
|
|
5
5
|
import "./icon-D3XT49vM.js";
|
|
6
6
|
import { t as u } from "./if-defined-D18nY_K_.js";
|
|
7
7
|
var d = {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { _ as e, d as t, f as n, g as r, h as i, l as a, m as o, n as s, p as c, u as l } from "./element-ckeMVgMz.js";
|
|
2
2
|
import { t as u } from "./class-map-BkEYw5uE.js";
|
|
3
3
|
import { i as d, r as f } from "./directive-helpers-BAinC437.js";
|
|
4
|
-
import { n as p } from "./element-with-slot-
|
|
4
|
+
import { n as p } from "./element-with-slot-Dp2Gzv-Q.js";
|
|
5
5
|
import "./icon-D3XT49vM.js";
|
|
6
|
-
import { r as m } from "./input-wrapper-
|
|
6
|
+
import { r as m } from "./input-wrapper-BttEKK9G.js";
|
|
7
7
|
import { t as h } from "./if-defined-D18nY_K_.js";
|
|
8
8
|
import { n as g, t as _ } from "./ref-D4OwQYdf.js";
|
|
9
|
-
import { t as v } from "./input-element-
|
|
9
|
+
import { t as v } from "./input-element-JH4qPly5.js";
|
|
10
10
|
//#region ../../shared-types/textarea.ts
|
|
11
11
|
var y = {
|
|
12
12
|
autoComplete: "off",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./directive-helpers-Bv70GjQh.cjs"),r=require("./element-with-slot-
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./directive-helpers-Bv70GjQh.cjs"),r=require("./element-with-slot-B0Vp_OuR.cjs");require("./icon-Dk8y6odR.cjs");const i=require("./input-wrapper-Bekd6DGA.cjs"),a=require("./if-defined-CiML3MTM.cjs"),o=require("./ref-CB7e9nMY.cjs"),s=require("./input-element-BhbkMU20.cjs");var c={autoComplete:`off`,required:!1,readOnly:!1,requiredTag:!1,optionalTag:!1,hasError:!1,disabled:!1,inline:!1,fullwidth:!1,useWrapper:!0,inputSize:`medium`},l=e.f(class extends e.p{constructor(t){if(super(t),t.type!==e.m.PROPERTY&&t.type!==e.m.ATTRIBUTE&&t.type!==e.m.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!n.i(t))throw Error("`live` bindings can only contain a single expression")}render(e){return e}update(t,[r]){if(r===e.g||r===e.h)return r;let i=t.element,a=t.name;if(t.type===e.m.PROPERTY){if(r===i[a])return e.g}else if(t.type===e.m.BOOLEAN_ATTRIBUTE){if(!!r===i.hasAttribute(a))return e.g}else if(t.type===e.m.ATTRIBUTE&&i.getAttribute(a)===r+``)return e.g;return n.r(t),r}}),u=class extends s.t{constructor(...e){super(...e),this.inputRef=o.t(),this.value=``,this.autocomplete=c.autoComplete,this.rows=null,this.cols=null,this.counterCurrent=0}attributeChangedCallback(e,t,n){e===`value`&&this.value!==t&&(this.counterCurrent=n?n.length:0),super.attributeChangedCallback(e,t,n)}willUpdate(e){super.willUpdate(e),e.has(`value`)&&(this.counterCurrent=this.value?.length||0),e.has(`id`)&&!this.name&&this.id&&(this.name=this.id)}updated(e){super.updated(e),this.classList.add(`pkt-textinput`,`pkt-textarea`),e.has(`value`)&&this.valueChanged(this.value,e.get(`value`))}render(){let n=this.effectiveCounter(this.counterMaxLength>0),s=t.t({"pkt-input":!0,[`pkt-input--${this.inputSize}`]:!0,"pkt-input--fullwidth":this.fullwidth,"pkt-input--counter-error":n&&this.counterMaxLength>0&&this.value.length>this.counterMaxLength}),c=this.ariaLabelledby||`${this.id}-input-label`;return e._`<pkt-input-wrapper
|
|
2
2
|
${r.n(this,[`helptext`])}
|
|
3
3
|
.strings=${this.strings}
|
|
4
4
|
label=${this.label}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-ckeMVgMz.js";
|
|
2
2
|
import { t as o } from "./class-map-BkEYw5uE.js";
|
|
3
|
-
import { n as s } from "./element-with-slot-
|
|
3
|
+
import { n as s } from "./element-with-slot-Dp2Gzv-Q.js";
|
|
4
4
|
import "./icon-D3XT49vM.js";
|
|
5
|
-
import { r as c } from "./input-wrapper-
|
|
5
|
+
import { r as c } from "./input-wrapper-BttEKK9G.js";
|
|
6
6
|
import { t as l } from "./if-defined-D18nY_K_.js";
|
|
7
7
|
import { n as u, t as d } from "./ref-D4OwQYdf.js";
|
|
8
|
-
import { t as f } from "./input-element-
|
|
8
|
+
import { t as f } from "./input-element-JH4qPly5.js";
|
|
9
9
|
//#region src/components/textinput/textinput.ts
|
|
10
10
|
var p = class extends f {
|
|
11
11
|
constructor(...e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./element-with-slot-
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./element-with-slot-B0Vp_OuR.cjs");require("./icon-Dk8y6odR.cjs");const r=require("./input-wrapper-Bekd6DGA.cjs"),i=require("./if-defined-CiML3MTM.cjs"),a=require("./ref-CB7e9nMY.cjs"),o=require("./input-element-BhbkMU20.cjs");var s=class extends o.t{constructor(...e){super(...e),this.inputRef=a.t(),this.value=``,this.type=`text`,this.size=null,this.autocomplete=null,this.iconNameRight=null,this.prefix=null,this.suffix=null,this.omitSearchIcon=!1,this.counterCurrent=0}attributeChangedCallback(e,t,n){e===`value`&&this.value!==t&&(this.counterCurrent=n?n.length:0),super.attributeChangedCallback(e,t,n)}willUpdate(e){super.willUpdate(e),e.has(`value`)&&(this.counterCurrent=this.value?.length||0),e.has(`id`)&&!this.name&&this.id&&(this.name=this.id)}updated(e){super.updated(e),this.classList.add(`pkt-textinput`),e.has(`value`)&&this.valueChanged(this.value,e.get(`value`))}render(){let o=this.type===`search`&&!this.iconNameRight&&!this.omitSearchIcon,s=this.effectiveCounter(this.counterMaxLength>0),c=t.t({"pkt-input":!0,[`pkt-input--${this.inputSize}`]:!0,"pkt-input--fullwidth":this.fullwidth,"pkt-input--counter-error":s&&this.counterMaxLength>0&&this.value.length>this.counterMaxLength}),l=this.ariaLabelledby||`${this.id}-input-label`;return e._`
|
|
2
2
|
<pkt-input-wrapper
|
|
3
3
|
${n.n(this,[`helptext`])}
|
|
4
4
|
.strings=${this.strings}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-ckeMVgMz.js";
|
|
2
2
|
import { t as o } from "./class-map-BkEYw5uE.js";
|
|
3
3
|
import { t as s } from "./format-BTeSVkED.js";
|
|
4
|
-
import { n as c } from "./element-with-slot-
|
|
4
|
+
import { n as c } from "./element-with-slot-Dp2Gzv-Q.js";
|
|
5
5
|
import "./icon-D3XT49vM.js";
|
|
6
|
-
import { r as l } from "./input-wrapper-
|
|
6
|
+
import { r as l } from "./input-wrapper-BttEKK9G.js";
|
|
7
7
|
import { t as u } from "./if-defined-D18nY_K_.js";
|
|
8
8
|
import { n as d, t as f } from "./ref-D4OwQYdf.js";
|
|
9
|
-
import { t as p } from "./input-element-
|
|
9
|
+
import { t as p } from "./input-element-JH4qPly5.js";
|
|
10
10
|
//#region ../../shared-utils/timepicker/time-utils.ts
|
|
11
11
|
var m = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && parseInt(e.slice(3), 10) <= 59, h = (e) => {
|
|
12
12
|
let [t, n] = e.split(":").map(Number);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-gdQbNteD.cjs");require("./icon-Dk8y6odR.cjs");const i=require("./input-wrapper-D1RqTzm4.cjs"),a=require("./if-defined-CiML3MTM.cjs"),o=require("./ref-CB7e9nMY.cjs"),s=require("./input-element-CCV_e85v.cjs");var c=e=>/^\d{2}:\d{2}$/.test(e)&&parseInt(e.slice(0,2),10)<=23&&parseInt(e.slice(3),10)<=59,l=e=>{let[t,n]=e.split(`:`).map(Number);return t*60+n},u=e=>e?Math.max(1,Math.round(e/60)):1,d=(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)},f=e=>{let t=u(e);return Array.from({length:Math.floor(60/t)},(e,n)=>n*t)},p=(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`)}},m=class extends s.t{constructor(...e){super(...e),this.hiddenInputRef=o.t(),this.hoursInputRef=o.t(),this.minutesInputRef=o.t(),this.buttonRef=o.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=l(this.value),a=u(this.step);if(this.min&&i<l(String(this.min)))this.internals.setValidity({rangeUnderflow:!0},n.t(r.rangeUnderflowMin,{min:String(this.min)}),t),this._setAriaInvalid(!0);else if(this.max&&i>l(String(this.max)))this.internals.setValidity({rangeOverflow:!0},n.t(r.rangeOverflowMax,{max:String(this.max)}),t),this._setAriaInvalid(!0);else 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)}else this.internals.setValidity({}),this._setAriaInvalid(!1)}_describedBy(){return i.r({id:`${this.id}-hours`,hasHelptext:!!this.helptext||this.hasSlotContent(`helptext`),ariaDescribedby:this.ariaDescribedby})}_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=c(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 u(this.step)}get _hourOptions(){return d(this.min,this.max)}get _minuteOptions(){return f(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=p(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._`
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-B0Vp_OuR.cjs");require("./icon-Dk8y6odR.cjs");const i=require("./input-wrapper-Bekd6DGA.cjs"),a=require("./if-defined-CiML3MTM.cjs"),o=require("./ref-CB7e9nMY.cjs"),s=require("./input-element-BhbkMU20.cjs");var c=e=>/^\d{2}:\d{2}$/.test(e)&&parseInt(e.slice(0,2),10)<=23&&parseInt(e.slice(3),10)<=59,l=e=>{let[t,n]=e.split(`:`).map(Number);return t*60+n},u=e=>e?Math.max(1,Math.round(e/60)):1,d=(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)},f=e=>{let t=u(e);return Array.from({length:Math.floor(60/t)},(e,n)=>n*t)},p=(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`)}},m=class extends s.t{constructor(...e){super(...e),this.hiddenInputRef=o.t(),this.hoursInputRef=o.t(),this.minutesInputRef=o.t(),this.buttonRef=o.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=l(this.value),a=u(this.step);if(this.min&&i<l(String(this.min)))this.internals.setValidity({rangeUnderflow:!0},n.t(r.rangeUnderflowMin,{min:String(this.min)}),t),this._setAriaInvalid(!0);else if(this.max&&i>l(String(this.max)))this.internals.setValidity({rangeOverflow:!0},n.t(r.rangeOverflowMax,{max:String(this.max)}),t),this._setAriaInvalid(!0);else 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)}else this.internals.setValidity({}),this._setAriaInvalid(!1)}_describedBy(){return i.r({id:`${this.id}-hours`,hasHelptext:!!this.helptext||this.hasSlotContent(`helptext`),ariaDescribedby:this.ariaDescribedby})}_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=c(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 u(this.step)}get _hourOptions(){return d(this.min,this.max)}get _minuteOptions(){return f(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=p(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
2
|
<button
|
|
3
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
4
|
type="button"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "19.18.
|
|
3
|
+
"version": "19.18.2",
|
|
4
4
|
"description": "Komponentbiblioteket til Punkt, designsystem for Oslo kommune",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo kommune",
|
|
@@ -22,8 +22,9 @@
|
|
|
22
22
|
"test": "vitest",
|
|
23
23
|
"test:run": "vitest run",
|
|
24
24
|
"test:ui": "vitest --ui",
|
|
25
|
-
"
|
|
26
|
-
"lint
|
|
25
|
+
"check-browser-support": "node ../../scripts/check-browser-support.mjs dist",
|
|
26
|
+
"lint": "eslint 'src/**/*.ts'",
|
|
27
|
+
"lint:fix": "eslint 'src/**/*.ts' --fix",
|
|
27
28
|
"type-check": "tsc --noEmit",
|
|
28
29
|
"prepack": "npm run build"
|
|
29
30
|
},
|
|
@@ -33,11 +34,6 @@
|
|
|
33
34
|
"lit": "^3.3.3"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"@babel/plugin-transform-class-properties": "^7.28.3",
|
|
37
|
-
"@babel/plugin-transform-private-methods": "^7.28.3",
|
|
38
|
-
"@babel/plugin-transform-private-property-in-object": "^7.27.1",
|
|
39
|
-
"@babel/preset-env": "^7.28.3",
|
|
40
|
-
"@babel/preset-typescript": "^7.28.3",
|
|
41
37
|
"@lit-labs/router": "^0.1.4",
|
|
42
38
|
"@oslokommune/punkt-assets": "^19.14.2",
|
|
43
39
|
"@testing-library/dom": "^10.4.2",
|
|
@@ -83,5 +79,5 @@
|
|
|
83
79
|
"engines": {
|
|
84
80
|
"node": "^22.19.0 || ^24.0.0 || ^26.0.0"
|
|
85
81
|
},
|
|
86
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "365dcae5072b21d9508448b2d541932ae7dee859"
|
|
87
83
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { provide } from '@lit/context'
|
|
2
|
-
import { html, LitElement } from 'lit'
|
|
2
|
+
import { html, LitElement, PropertyValues } from 'lit'
|
|
3
3
|
import { customElement, property, state } from 'lit/decorators.js'
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js'
|
|
5
5
|
import type { IPktAccordionBase, TAccordionSkin } from 'shared-types'
|
|
@@ -25,13 +25,13 @@ export class PktAccordion extends LitElement implements IPktAccordion {
|
|
|
25
25
|
@state()
|
|
26
26
|
private context: AccordionContext = { skin: this.skin }
|
|
27
27
|
|
|
28
|
-
willUpdate(changedProperties:
|
|
28
|
+
willUpdate(changedProperties: PropertyValues) {
|
|
29
29
|
if (changedProperties.has('skin')) {
|
|
30
30
|
this.context = { ...this.context, skin: this.skin }
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
updated(changedProperties:
|
|
34
|
+
updated(changedProperties: PropertyValues) {
|
|
35
35
|
if (changedProperties.has('name')) {
|
|
36
36
|
this.updateAccordionItemNames()
|
|
37
37
|
}
|
|
@@ -270,4 +270,44 @@ describe('PktCalendar', () => {
|
|
|
270
270
|
expect(focusedElement).toHaveClass('pkt-calendar__date')
|
|
271
271
|
})
|
|
272
272
|
})
|
|
273
|
+
|
|
274
|
+
describe('Update cycle', () => {
|
|
275
|
+
const connectCalendar = (attributes: Record<string, string>) => {
|
|
276
|
+
const calendar = document.createElement('pkt-calendar') as PktCalendar
|
|
277
|
+
for (const [name, value] of Object.entries(attributes)) calendar.setAttribute(name, value)
|
|
278
|
+
document.body.appendChild(calendar)
|
|
279
|
+
return calendar
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
test('renders a selected date in a single update', async () => {
|
|
283
|
+
const calendar = connectCalendar({ selected: '2026-10-20' })
|
|
284
|
+
|
|
285
|
+
expect(await calendar.updateComplete).toBe(true)
|
|
286
|
+
expect(calendar.querySelector('[data-date="2026-10-20"]')).toHaveClass(
|
|
287
|
+
'pkt-calendar__date--selected',
|
|
288
|
+
)
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
test('settles in a single update when selected changes', async () => {
|
|
292
|
+
const container = await createCalendar('selected="2026-10-20"')
|
|
293
|
+
const calendar = container.querySelector('pkt-calendar') as PktCalendar
|
|
294
|
+
await calendar.updateComplete
|
|
295
|
+
|
|
296
|
+
calendar.selected = ['2026-12-24']
|
|
297
|
+
|
|
298
|
+
expect(await calendar.updateComplete).toBe(true)
|
|
299
|
+
expect(calendar.querySelector('[data-date="2026-12-24"]')).toHaveClass(
|
|
300
|
+
'pkt-calendar__date--selected',
|
|
301
|
+
)
|
|
302
|
+
})
|
|
303
|
+
|
|
304
|
+
test('renders a selected range in a single update', async () => {
|
|
305
|
+
const calendar = connectCalendar({ range: '', selected: '2026-10-10,2026-10-14' })
|
|
306
|
+
|
|
307
|
+
expect(await calendar.updateComplete).toBe(true)
|
|
308
|
+
expect(calendar.querySelector('[data-date="2026-10-12"]')).toHaveClass(
|
|
309
|
+
'pkt-calendar__date--in-range',
|
|
310
|
+
)
|
|
311
|
+
})
|
|
312
|
+
})
|
|
273
313
|
})
|
|
@@ -133,7 +133,6 @@ export class PktCalendar extends PktElement<IPktStringsProps<'dates' | 'calendar
|
|
|
133
133
|
// Internal state - navigation and display
|
|
134
134
|
@property({ type: Number }) private year: number = 0
|
|
135
135
|
@property({ type: Number }) private month: number = 0
|
|
136
|
-
@property({ type: Number }) private week: number = 0
|
|
137
136
|
@state() private currentmonthtouched: boolean = false
|
|
138
137
|
|
|
139
138
|
// Internal state - keyboard navigation and focus management
|
|
@@ -157,8 +156,8 @@ export class PktCalendar extends PktElement<IPktStringsProps<'dates' | 'calendar
|
|
|
157
156
|
super.disconnectedCallback()
|
|
158
157
|
}
|
|
159
158
|
|
|
160
|
-
|
|
161
|
-
super.
|
|
159
|
+
protected willUpdate(changedProperties: PropertyValues): void {
|
|
160
|
+
super.willUpdate(changedProperties)
|
|
162
161
|
if (changedProperties.has('selected')) {
|
|
163
162
|
this.convertSelected()
|
|
164
163
|
}
|
|
@@ -523,7 +522,7 @@ export class PktCalendar extends PktElement<IPktStringsProps<'dates' | 'calendar
|
|
|
523
522
|
this.tabIndexSet = 0
|
|
524
523
|
|
|
525
524
|
let dayCounter = 1
|
|
526
|
-
|
|
525
|
+
let week = dimensions.initialWeek
|
|
527
526
|
|
|
528
527
|
const rows: TemplateResult[] = []
|
|
529
528
|
|
|
@@ -532,9 +531,9 @@ export class PktCalendar extends PktElement<IPktStringsProps<'dates' | 'calendar
|
|
|
532
531
|
|
|
533
532
|
// Add week number if enabled
|
|
534
533
|
if (this.weeknumbers) {
|
|
535
|
-
cells.push(html`<td class="pkt-cal-week">${
|
|
534
|
+
cells.push(html`<td class="pkt-cal-week">${week}</td>`)
|
|
536
535
|
}
|
|
537
|
-
|
|
536
|
+
week++
|
|
538
537
|
|
|
539
538
|
// Render each day in the week
|
|
540
539
|
for (let j = 0; j < DAYS_PER_WEEK; j++) {
|
|
@@ -46,12 +46,14 @@ afterEach(() => {
|
|
|
46
46
|
existingStyles.remove()
|
|
47
47
|
}
|
|
48
48
|
// Clean up global variables
|
|
49
|
+
/* eslint-disable camelcase */
|
|
49
50
|
delete window.cookieBanner_googleAnalyticsId
|
|
50
51
|
;(window as any).cookieBanner_hotjarId = undefined
|
|
51
52
|
;(window as any).cookieBanner_devMode = undefined
|
|
52
53
|
;(window as any).cookieBanner_cookieDomain = undefined
|
|
53
54
|
;(window as any).cookieBanner_cookieSecure = undefined
|
|
54
55
|
;(window as any).cookieBanner_cookieExpiryDays = undefined
|
|
56
|
+
/* eslint-enable camelcase */
|
|
55
57
|
;(window as any).cookieBanner = undefined
|
|
56
58
|
;(window as any).__cookieEvents = undefined
|
|
57
59
|
})
|
|
@@ -102,7 +102,7 @@ export class PktDatepickerPopup extends PktElement {
|
|
|
102
102
|
addToSelected(e: Event, min?: string | null, max?: string | null) {
|
|
103
103
|
const cal = this.calendarRef.value as PktCalendar
|
|
104
104
|
if (cal && typeof calendarUtils.addToSelected === 'function') {
|
|
105
|
-
return calendarUtils.addToSelected(e, this.calendarRef as
|
|
105
|
+
return calendarUtils.addToSelected(e, this.calendarRef as Ref<PktCalendar>, min, max)
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
// Calendar not rendered yet — handle add directly
|
|
@@ -42,19 +42,21 @@ export const inputTypeUtils = {
|
|
|
42
42
|
getInputType: getDatepickerInputType,
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
type TFormOwner = { form?: Pick<HTMLFormElement, 'requestSubmit'> | null }
|
|
46
|
+
|
|
45
47
|
/**
|
|
46
48
|
* Form and validation utilities (Lit-specific — uses ElementInternals)
|
|
47
49
|
*/
|
|
48
50
|
export const formUtils = {
|
|
49
|
-
submitForm(element: HTMLElement): void {
|
|
50
|
-
const form =
|
|
51
|
+
submitForm(element: HTMLElement & { internals?: TFormOwner }): void {
|
|
52
|
+
const form = element.internals?.form
|
|
51
53
|
if (form) {
|
|
52
54
|
form.requestSubmit()
|
|
53
55
|
}
|
|
54
56
|
},
|
|
55
57
|
|
|
56
|
-
submitFormOrFallback(internals:
|
|
57
|
-
const form = internals?.form
|
|
58
|
+
submitFormOrFallback(internals: TFormOwner | null | undefined, fallbackAction: () => void): void {
|
|
59
|
+
const form = internals?.form
|
|
58
60
|
if (form) {
|
|
59
61
|
form.requestSubmit()
|
|
60
62
|
} else {
|
|
@@ -64,7 +66,7 @@ export const formUtils = {
|
|
|
64
66
|
|
|
65
67
|
validateDateInput(
|
|
66
68
|
input: HTMLInputElement,
|
|
67
|
-
internals:
|
|
69
|
+
internals: Pick<ElementInternals, 'setValidity'>,
|
|
68
70
|
min?: string | null,
|
|
69
71
|
max?: string | null,
|
|
70
72
|
messages?: Partial<TPktStrings['validation']>,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PktIconName } from '@oslokommune/punkt-assets/dist/icons/icon'
|
|
2
2
|
import { booleanishConverter, convertUserMenuItem as sharedConvertUserMenuItem } from 'shared-types'
|
|
3
|
-
/* eslint-disable no-duplicate-imports */
|
|
4
3
|
import type {
|
|
5
4
|
Booleanish,
|
|
6
5
|
User as SharedUser,
|
|
@@ -37,7 +37,7 @@ export class PktLinkCard extends PktElementWithSlot<IPktLinkCard> implements IPk
|
|
|
37
37
|
target=${this.openInNewTab ? '_blank' : '_self'}
|
|
38
38
|
rel=${ifDefined(this.openInNewTab ? 'noopener noreferrer' : undefined)}
|
|
39
39
|
>
|
|
40
|
-
${this.iconName && html`<pkt-icon class="pkt-link__icon" name="${this.iconName}"
|
|
40
|
+
${this.iconName && html`<pkt-icon class="pkt-link__icon" name="${this.iconName}"></pkt-icon>`}
|
|
41
41
|
${this.title && html`<div class=${titleClasses}>${this.title}</div>`}
|
|
42
42
|
${newTabLabel ? html`<span class="pkt-sr-only">${newTabLabel}</span>` : ''}
|
|
43
43
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { BaseTestConfig } from '../../tests/test-framework';
|
|
2
|
-
export interface AlertTestConfig extends BaseTestConfig {
|
|
3
|
-
skin?: string;
|
|
4
|
-
compact?: boolean;
|
|
5
|
-
title?: string;
|
|
6
|
-
date?: string;
|
|
7
|
-
closeAlert?: boolean;
|
|
8
|
-
ariaLive?: string;
|
|
9
|
-
size?: string;
|
|
10
|
-
}
|
|
11
|
-
export declare const createAlertTest: (config?: AlertTestConfig) => Promise<{
|
|
12
|
-
container: HTMLElement;
|
|
13
|
-
alert: import('./alert').PktAlert;
|
|
14
|
-
}>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BaseTestConfig } from '../../tests/test-framework';
|
|
2
|
-
export interface BacklinkTestConfig extends BaseTestConfig {
|
|
3
|
-
href?: string;
|
|
4
|
-
text?: string;
|
|
5
|
-
ariaLabel?: string | null;
|
|
6
|
-
}
|
|
7
|
-
export declare const createBacklinkTest: (config?: BacklinkTestConfig) => Promise<{
|
|
8
|
-
container: HTMLElement;
|
|
9
|
-
backlink: import('./backlink').PktBackLink;
|
|
10
|
-
}>;
|
|
File without changes
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BaseTestConfig } from '../../tests/test-framework';
|
|
2
|
-
export interface ButtonTestConfig extends BaseTestConfig {
|
|
3
|
-
size?: string;
|
|
4
|
-
skin?: string;
|
|
5
|
-
variant?: string;
|
|
6
|
-
color?: string;
|
|
7
|
-
type?: string;
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
isLoading?: boolean;
|
|
10
|
-
iconName?: string;
|
|
11
|
-
iconNameSecond?: string;
|
|
12
|
-
iconPath?: string;
|
|
13
|
-
secondIconPath?: string;
|
|
14
|
-
iconPosition?: string;
|
|
15
|
-
mode?: string;
|
|
16
|
-
form?: string;
|
|
17
|
-
content?: string;
|
|
18
|
-
}
|
|
19
|
-
export declare const createButtonTest: (config?: ButtonTestConfig) => Promise<{
|
|
20
|
-
container: HTMLElement;
|
|
21
|
-
button: import('./button').PktButton;
|
|
22
|
-
}>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { BaseTestConfig } from '../../tests/test-framework';
|
|
2
|
-
export interface CalendarTestConfig extends BaseTestConfig {
|
|
3
|
-
withcontrols?: boolean;
|
|
4
|
-
weeknumbers?: boolean;
|
|
5
|
-
multiple?: boolean;
|
|
6
|
-
range?: boolean;
|
|
7
|
-
earliest?: string;
|
|
8
|
-
latest?: string;
|
|
9
|
-
currentmonth?: string;
|
|
10
|
-
excludedates?: string;
|
|
11
|
-
excludeweekdays?: string;
|
|
12
|
-
}
|
|
13
|
-
export declare const createCalendarTest: (config?: CalendarTestConfig) => Promise<{
|
|
14
|
-
container: HTMLElement;
|
|
15
|
-
calendar: import('./calendar').PktCalendar;
|
|
16
|
-
}>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BaseTestConfig } from '../../tests/test-framework';
|
|
2
|
-
export interface CardTestConfig extends BaseTestConfig {
|
|
3
|
-
skin?: string;
|
|
4
|
-
layout?: string;
|
|
5
|
-
padding?: string;
|
|
6
|
-
borderOnHover?: boolean;
|
|
7
|
-
heading?: string;
|
|
8
|
-
subheading?: string;
|
|
9
|
-
headingLevel?: number;
|
|
10
|
-
href?: string;
|
|
11
|
-
linkText?: string;
|
|
12
|
-
image?: string;
|
|
13
|
-
imageAlt?: string;
|
|
14
|
-
tags?: string;
|
|
15
|
-
metaPrefix?: string;
|
|
16
|
-
metaLabel?: string;
|
|
17
|
-
metaDate?: string;
|
|
18
|
-
}
|
|
19
|
-
export declare const createCardTest: (config?: CardTestConfig) => Promise<{
|
|
20
|
-
container: HTMLElement;
|
|
21
|
-
card: import('./card').PktCard;
|
|
22
|
-
}>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { BaseTestConfig } from '../../tests/test-framework';
|
|
2
|
-
export interface CheckboxTestConfig extends BaseTestConfig {
|
|
3
|
-
id?: string;
|
|
4
|
-
name?: string;
|
|
5
|
-
label?: string;
|
|
6
|
-
checked?: boolean;
|
|
7
|
-
disabled?: boolean;
|
|
8
|
-
required?: boolean;
|
|
9
|
-
value?: string;
|
|
10
|
-
checkHelptext?: string;
|
|
11
|
-
hasTile?: boolean;
|
|
12
|
-
hasError?: boolean;
|
|
13
|
-
errorMessage?: string;
|
|
14
|
-
optionalTag?: boolean;
|
|
15
|
-
requiredTag?: boolean;
|
|
16
|
-
tagText?: string;
|
|
17
|
-
labelPosition?: string;
|
|
18
|
-
hideLabel?: boolean;
|
|
19
|
-
isSwitch?: boolean;
|
|
20
|
-
}
|
|
21
|
-
export declare const createCheckboxTest: (config?: CheckboxTestConfig) => Promise<{
|
|
22
|
-
container: HTMLElement;
|
|
23
|
-
checkbox: import('./checkbox').PktCheckbox;
|
|
24
|
-
}>;
|
|
File without changes
|