@oslokommune/punkt-elements 19.9.0 → 19.10.1
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 +43 -0
- package/dist/{accordion-CMCCpxtz.cjs → accordion-BFKmnCDh.cjs} +1 -1
- package/dist/{accordion-Cp2o6wTY.js → accordion-BhCmUDoS.js} +1 -1
- package/dist/{alert-QfloIr-o.cjs → alert-BJPi5ylH.cjs} +1 -1
- package/dist/{alert-CAPiwi4F.js → alert-CUH_2zb2.js} +2 -2
- package/dist/{button-Dh97H-58.cjs → button-CWHqXdSG.cjs} +1 -1
- package/dist/{button-CeRr7oIn.js → button-DQ8rH8hx.js} +1 -1
- package/dist/{card-_PlgXmgZ.js → card-DfVOJCWA.js} +2 -2
- package/dist/{card--NuWdTbG.cjs → card-pJ0CDH2Y.cjs} +1 -1
- package/dist/{checkbox-QIcdn09A.cjs → checkbox-3z2uH8rd.cjs} +1 -1
- package/dist/{checkbox-G8k3vg85.js → checkbox-BEBBPgYW.js} +1 -1
- package/dist/{checkbox-group-DoueGGi5.js → checkbox-group-BiPX1EhY.js} +2 -2
- package/dist/{checkbox-group-nLazAkcg.cjs → checkbox-group-DRQmSHyN.cjs} +1 -1
- package/dist/{combobox-ClXhKwR9.cjs → combobox-C_SMnNsj.cjs} +1 -1
- package/dist/{combobox-Cz_rq7Mm.js → combobox-CdmzQtCh.js} +5 -5
- package/dist/components/index.d.ts +1 -0
- package/dist/components/radiobutton/index.d.ts +1 -0
- package/dist/components/radiobutton/radiobutton.d.ts +7 -2
- package/dist/{consent-DimzcQxt.cjs → consent-CkK9BZ7t.cjs} +1 -1
- package/dist/{consent-CZMxUavj.js → consent-eTXt052m.js} +1 -1
- package/dist/{datepicker-usIF9WY7.cjs → datepicker-BrQhahYy.cjs} +1 -1
- package/dist/{datepicker-C7ABsx7H.js → datepicker-DILpPWCY.js} +4 -4
- package/dist/directives/slot-content.d.ts +24 -11
- package/dist/element-with-slot-DOt8HbXA.cjs +1 -0
- package/dist/element-with-slot-U981OZM_.js +353 -0
- package/dist/{fileupload-BR9H6fET.js → fileupload-BZjZh8Mp.js} +3 -3
- package/dist/{fileupload-2uTFjd81.cjs → fileupload-l1d9UQf9.cjs} +1 -1
- package/dist/{footer-CyxRYvT-.cjs → footer-C8Zh-eUU.cjs} +1 -1
- package/dist/{footer-B3DMvo8-.js → footer-X5MBVUoo.js} +1 -1
- package/dist/{header-BKeSkfB7.js → header-DLH6Xx97.js} +5 -5
- package/dist/{header-Drj3lTrv.cjs → header-EvwDJXP-.cjs} +1 -1
- package/dist/{header-menu-buYE90FU.js → header-menu-0UtMd2_H.js} +1 -1
- package/dist/{header-menu-B_5hCNUl.cjs → header-menu-BqFpYI-V.cjs} +1 -1
- package/dist/{heading-DUYOvlxs.cjs → heading-DMHbL3xs.cjs} +1 -1
- package/dist/{heading-WBB5MO9i.js → heading-tWSLaRPD.js} +1 -1
- package/dist/{helptext-C7cyihnu.cjs → helptext-CGa1p-yd.cjs} +1 -1
- package/dist/{helptext-DadLkcoO.js → helptext-Dy2Ehs9W.js} +1 -1
- package/dist/{input-element-BBygBEei.js → input-element-BGbT4ICl.js} +1 -1
- package/dist/{input-element-C4SelHLD.cjs → input-element-kIrd5ABs.cjs} +1 -1
- package/dist/{input-wrapper-BT6B3Kco.cjs → input-wrapper-EvzyXMw-.cjs} +1 -1
- package/dist/{input-wrapper-DrSCuw6U.js → input-wrapper-Uks0spRR.js} +3 -3
- package/dist/{link-CVnIn74-.js → link-C0yBFscy.js} +1 -1
- package/dist/{link-CEP7w1et.cjs → link-CLdiz-ly.cjs} +1 -1
- package/dist/{linkcard-IWiVvRKy.js → linkcard-B5-p-YC4.js} +1 -1
- package/dist/{linkcard-D8vitdrQ.cjs → linkcard-v9UsV9Os.cjs} +1 -1
- package/dist/{loader-B0hFoBtF.cjs → loader-C4UfUu2u.cjs} +1 -1
- package/dist/{loader-CAsUPHjl.js → loader-DWvjIMsT.js} +1 -1
- package/dist/{messagebox-6_iNN5F3.js → messagebox-CJTqxfu3.js} +1 -1
- package/dist/{messagebox-C19L2Duq.cjs → messagebox-clOimkn7.cjs} +1 -1
- package/dist/{modal-CoEPzt4p.cjs → modal-BPweteoS.cjs} +1 -1
- package/dist/{modal-D7MolBXb.js → modal-Bm1daKaW.js} +1 -1
- package/dist/{option-group-element-BYS7s-is.cjs → option-group-element-2A4TBcp-.cjs} +1 -1
- package/dist/{option-group-element-BIuotbRu.js → option-group-element-Ber7NAlg.js} +2 -2
- 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-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 +36 -36
- 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-B3vVKnAG.cjs → pkt-options-controller-Ck_549wx.cjs} +1 -1
- package/dist/{pkt-options-controller-ClFrUWZK.js → pkt-options-controller-DTOlYR9b.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-kOzlGn8T.cjs → radio-group-9Szx2XyM.cjs} +1 -1
- package/dist/{radio-group-lhymYEZX.js → radio-group-CMtx_GRV.js} +9 -9
- package/dist/{radiobutton-CFd8TgV9.js → radiobutton-CYbvJ9y8.js} +20 -13
- package/dist/radiobutton-Dq2qkfi0.cjs +38 -0
- package/dist/{select-BowvpCNa.cjs → select-1nm17iN8.cjs} +1 -1
- package/dist/{select-B6CN2Ymq.js → select-DlgOxHIl.js} +4 -4
- package/dist/shared-types/index.d.ts +2 -0
- package/dist/shared-types/radiobutton.d.ts +46 -0
- package/dist/{tabs-Dm8xcPRs.cjs → tabs-8Y5PlmLl.cjs} +1 -1
- package/dist/{tabs-DZvtVA0y.js → tabs-D3pPS9us.js} +1 -1
- package/dist/{tag-DyVZrqOQ.cjs → tag-DOUsW7nS.cjs} +1 -1
- package/dist/{tag-C33BPIOm.js → tag-qHYIycl8.js} +1 -1
- package/dist/{textarea-hW0kV5gj.js → textarea-B3qIDyEQ.js} +3 -3
- package/dist/{textarea-DoH3Il8v.cjs → textarea-DkeCQKmM.cjs} +1 -1
- package/dist/{textinput-B6G4dVuL.js → textinput-CwvVRNsP.js} +3 -3
- package/dist/{textinput-CQknclmV.cjs → textinput-DibZCHh_.cjs} +1 -1
- package/dist/{timepicker-DB3gor6g.cjs → timepicker-CZ_1HVlF.cjs} +1 -1
- package/dist/{timepicker-Cd2QI6ua.js → timepicker-C_oG9W9Y.js} +3 -3
- package/package.json +2 -2
- package/src/components/heading/heading.test.ts +24 -0
- package/src/components/helptext/helptext-association.test.ts +36 -0
- package/src/components/index.ts +1 -0
- package/src/components/radiobutton/index.ts +1 -0
- package/src/components/radiobutton/radiobutton.ts +15 -6
- package/dist/element-with-slot-DDLS-aLw.js +0 -227
- package/dist/element-with-slot-DhiAuSjM.cjs +0 -1
- package/dist/radiobutton-BgHCcDJv.cjs +0 -38
|
@@ -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-DBugHPKM.js";
|
|
2
2
|
import { t as o } from "./class-map-Bf-QzUpN.js";
|
|
3
|
-
import { n as s } from "./element-with-slot-
|
|
3
|
+
import { n as s } from "./element-with-slot-U981OZM_.js";
|
|
4
4
|
import "./icon-Bao96Zb8.js";
|
|
5
5
|
import { t as c } from "./if-defined-O59_I-e-.js";
|
|
6
6
|
import { n as l, t as u } from "./ref-y_5qv9vU.js";
|
|
7
|
-
import { t as d } from "./input-element-
|
|
8
|
-
import { r as f } from "./input-wrapper-
|
|
7
|
+
import { t as d } from "./input-element-BGbT4ICl.js";
|
|
8
|
+
import { r as f } from "./input-wrapper-Uks0spRR.js";
|
|
9
9
|
//#region src/components/textinput/textinput.ts
|
|
10
10
|
var p = class extends d {
|
|
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-DOt8HbXA.cjs");require("./icon-jPhyZD1z.cjs");const r=require("./if-defined-CiML3MTM.cjs"),i=require("./ref-CB7e9nMY.cjs"),a=require("./input-element-kIrd5ABs.cjs"),o=require("./input-wrapper-EvzyXMw-.cjs");var s=class extends a.t{constructor(...e){super(...e),this.inputRef=i.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 a=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,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-DhiAuSjM.cjs");require("./icon-jPhyZD1z.cjs");const i=require("./if-defined-CiML3MTM.cjs"),a=require("./ref-CB7e9nMY.cjs"),o=require("./input-element-C4SelHLD.cjs"),s=require("./input-wrapper-BT6B3Kco.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 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=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);return}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);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)}_describedBy(){return s.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-DOt8HbXA.cjs");require("./icon-jPhyZD1z.cjs");const i=require("./if-defined-CiML3MTM.cjs"),a=require("./ref-CB7e9nMY.cjs"),o=require("./input-element-kIrd5ABs.cjs"),s=require("./input-wrapper-EvzyXMw-.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 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=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);return}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);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)}_describedBy(){return s.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"
|
|
@@ -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-DBugHPKM.js";
|
|
2
2
|
import { t as o } from "./class-map-Bf-QzUpN.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-U981OZM_.js";
|
|
5
5
|
import "./icon-Bao96Zb8.js";
|
|
6
6
|
import { t as l } from "./if-defined-O59_I-e-.js";
|
|
7
7
|
import { n as u, t as d } from "./ref-y_5qv9vU.js";
|
|
8
|
-
import { t as f } from "./input-element-
|
|
9
|
-
import { r as p } from "./input-wrapper-
|
|
8
|
+
import { t as f } from "./input-element-BGbT4ICl.js";
|
|
9
|
+
import { r as p } from "./input-wrapper-Uks0spRR.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);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.10.1",
|
|
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",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"engines": {
|
|
85
85
|
"node": "^22.19.0 || ^24.0.0 || ^26.0.0"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "d5a56dcc15c77b4d802345509652cf0deef4841d"
|
|
88
88
|
}
|
|
@@ -73,6 +73,30 @@ describe('PktHeading', () => {
|
|
|
73
73
|
document.body.innerHTML = ''
|
|
74
74
|
}
|
|
75
75
|
})
|
|
76
|
+
|
|
77
|
+
test('keeps its content when the level changes after rendering', async () => {
|
|
78
|
+
const container = await createHeading('level="2"', '<span class="text">Tittel</span>')
|
|
79
|
+
const heading = container.querySelector('pkt-heading') as PktHeading
|
|
80
|
+
await heading.updateComplete
|
|
81
|
+
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
82
|
+
|
|
83
|
+
const errors: unknown[] = []
|
|
84
|
+
const onError = (event: ErrorEvent) => {
|
|
85
|
+
errors.push(event.error)
|
|
86
|
+
event.preventDefault()
|
|
87
|
+
}
|
|
88
|
+
window.addEventListener('error', onError)
|
|
89
|
+
heading.level = 3
|
|
90
|
+
await heading.updateComplete
|
|
91
|
+
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
92
|
+
await heading.updateComplete
|
|
93
|
+
window.removeEventListener('error', onError)
|
|
94
|
+
|
|
95
|
+
expect(errors).toEqual([])
|
|
96
|
+
expect(heading.querySelectorAll('h1, h2, h3, h4, h5, h6')).toHaveLength(1)
|
|
97
|
+
expect(innerHeading(heading)?.tagName).toBe('H3')
|
|
98
|
+
expect(innerHeading(heading)?.querySelector('.text')?.textContent).toBe('Tittel')
|
|
99
|
+
})
|
|
76
100
|
})
|
|
77
101
|
|
|
78
102
|
describe('Properties and attributes', () => {
|
|
@@ -148,6 +148,42 @@ describe('helptext association', () => {
|
|
|
148
148
|
expectDescribedBySlot(host)
|
|
149
149
|
})
|
|
150
150
|
|
|
151
|
+
const createSlotted = (text: string) => {
|
|
152
|
+
const slotted = document.createElement('div')
|
|
153
|
+
slotted.setAttribute('slot', 'helptext')
|
|
154
|
+
slotted.className = 'slotted'
|
|
155
|
+
slotted.textContent = text
|
|
156
|
+
return slotted
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
test.each(slotCases)('%s %s shows slotted helptext a framework hides and shows again', async (tag, attrs) => {
|
|
160
|
+
const host = await mountWithSlot(tag, attrs, '<div slot="helptext" class="slotted">Hjelp fra slot</div>')
|
|
161
|
+
const slotted = host.querySelector('.slotted')!
|
|
162
|
+
const parent = slotted.parentNode!
|
|
163
|
+
const next = slotted.nextSibling
|
|
164
|
+
parent.removeChild(slotted)
|
|
165
|
+
const anchor = document.createComment('v-if')
|
|
166
|
+
parent.insertBefore(anchor, next)
|
|
167
|
+
await settle(host)
|
|
168
|
+
expect(host.querySelector('.pkt-inputwrapper__helptext')).toBeNull()
|
|
169
|
+
|
|
170
|
+
expect(anchor.parentNode).not.toBeNull()
|
|
171
|
+
anchor.parentNode!.insertBefore(createSlotted('Hjelp fra slot'), anchor.nextSibling)
|
|
172
|
+
anchor.remove()
|
|
173
|
+
await settle(host)
|
|
174
|
+
|
|
175
|
+
expectDescribedBySlot(host)
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
test.each(slotCases)('%s %s shows slotted helptext that a framework replaces', async (tag, attrs) => {
|
|
179
|
+
const host = await mountWithSlot(tag, attrs, '<div slot="helptext" class="slotted">Gammel</div>')
|
|
180
|
+
const slotted = host.querySelector('.slotted')!
|
|
181
|
+
slotted.parentNode!.replaceChild(createSlotted('Hjelp fra slot'), slotted)
|
|
182
|
+
await settle(host)
|
|
183
|
+
|
|
184
|
+
expectDescribedBySlot(host)
|
|
185
|
+
})
|
|
186
|
+
|
|
151
187
|
test.each(slotCases)('%s %s drops the link when slotted helptext is removed', async (tag, attrs) => {
|
|
152
188
|
const host = await mountWithSlot(tag, attrs, '<div slot="helptext" class="slotted">Hjelp fra slot</div>')
|
|
153
189
|
expectDescribedBySlot(host)
|
package/src/components/index.ts
CHANGED
|
@@ -32,6 +32,7 @@ export { PktMessagebox } from '@/components/messagebox'
|
|
|
32
32
|
export { PktModal } from '@/components/modal'
|
|
33
33
|
export { PktProgressbar } from '@/components/progressbar'
|
|
34
34
|
export { PktRadioButton } from '@/components/radiobutton'
|
|
35
|
+
export type { IPktRadioButton } from '@/components/radiobutton'
|
|
35
36
|
export { PktRadioGroup } from '@/components/radio-group'
|
|
36
37
|
// TODO: Avklar om RadioButton kan eksporteres som *kun* PktRadiobutton
|
|
37
38
|
export { PktRadioButton as PktRadiobutton } from '@/components/radiobutton'
|
|
@@ -7,7 +7,7 @@ import { Ref, createRef, ref } from 'lit/directives/ref.js'
|
|
|
7
7
|
import { html, nothing } from 'lit'
|
|
8
8
|
import { classMap } from 'lit/directives/class-map.js'
|
|
9
9
|
import { ElementProps } from '@/types/typeUtils'
|
|
10
|
-
import type
|
|
10
|
+
import { RADIOBUTTON_DEFAULTS, type IPktRadioButtonBase, type TPktInputSize } from 'shared-types'
|
|
11
11
|
|
|
12
12
|
type Props = ElementProps<
|
|
13
13
|
PktRadioButton,
|
|
@@ -21,21 +21,30 @@ type Props = ElementProps<
|
|
|
21
21
|
| 'requiredText'
|
|
22
22
|
>
|
|
23
23
|
|
|
24
|
-
export
|
|
24
|
+
export interface IPktRadioButton extends Omit<
|
|
25
|
+
IPktRadioButtonBase,
|
|
26
|
+
'form' | 'label' | 'checkHelptext' | 'checked'
|
|
27
|
+
> {
|
|
28
|
+
label?: string | null
|
|
29
|
+
checkHelptext?: string | null
|
|
30
|
+
checked?: boolean | string | null
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class PktRadioButton extends PktInputElement<Props> implements IPktRadioButton {
|
|
25
34
|
inputRef: Ref<HTMLInputElement> = createRef()
|
|
26
35
|
|
|
27
36
|
@property({ type: String, reflect: true }) value: string = ''
|
|
28
37
|
@property({ type: String }) checkHelptext: string | null = null
|
|
29
|
-
@property({ type: Boolean }) defaultChecked: boolean =
|
|
30
|
-
@property({ type: Boolean }) hasTile: boolean =
|
|
38
|
+
@property({ type: Boolean }) defaultChecked: boolean = RADIOBUTTON_DEFAULTS.defaultChecked
|
|
39
|
+
@property({ type: Boolean }) hasTile: boolean = RADIOBUTTON_DEFAULTS.hasTile
|
|
31
40
|
@property({ type: Boolean, reflect: true }) checked: boolean | string | null = null
|
|
32
41
|
@property({ type: String, reflect: true }) type: string = 'radio'
|
|
33
42
|
@property({ type: String, attribute: 'input-size' }) inputSize: TPktInputSize | undefined = undefined
|
|
34
43
|
@property({ type: String }) tagText: string | null = null
|
|
35
|
-
@property({ type: Boolean }) optionalTag: boolean =
|
|
44
|
+
@property({ type: Boolean }) optionalTag: boolean = RADIOBUTTON_DEFAULTS.optionalTag
|
|
36
45
|
/** @deprecated Bruk `strings={{ forms: { optional: '…' } }}` eller `setPktStrings()`. */
|
|
37
46
|
@property({ type: String }) optionalText?: string
|
|
38
|
-
@property({ type: Boolean }) requiredTag: boolean =
|
|
47
|
+
@property({ type: Boolean }) requiredTag: boolean = RADIOBUTTON_DEFAULTS.requiredTag
|
|
39
48
|
/** @deprecated Bruk `strings={{ forms: { required: '…' } }}` eller `setPktStrings()`. */
|
|
40
49
|
@property({ type: String }) requiredText?: string
|
|
41
50
|
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { f as e, g as t, m as n, t as r } from "./element-DBugHPKM.js";
|
|
2
|
-
import { t as i } from "./async-directive-yh8hG41Q.js";
|
|
3
|
-
//#region src/controllers/pkt-slot-utils.ts
|
|
4
|
-
function a(e) {
|
|
5
|
-
return e.classList && (e.classList.contains("_dialog_overlay") || e.classList.contains("backdrop")) ? !0 : typeof e.hasAttribute == "function" && e.hasAttribute("data-skip");
|
|
6
|
-
}
|
|
7
|
-
function o(e) {
|
|
8
|
-
return e.nodeName === "OPTION" || e.nodeName === "DATA";
|
|
9
|
-
}
|
|
10
|
-
function s(e) {
|
|
11
|
-
return e.nodeType === Node.TEXT_NODE && e.nodeValue?.trim() !== "";
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/directives/slot-content.ts
|
|
15
|
-
var c = /* @__PURE__ */ new WeakMap();
|
|
16
|
-
function l(e) {
|
|
17
|
-
let t = c.get(e);
|
|
18
|
-
return t || (t = new g(e), c.set(e, t)), t;
|
|
19
|
-
}
|
|
20
|
-
var u = Symbol("default");
|
|
21
|
-
function d(e) {
|
|
22
|
-
return e === void 0 ? u : e;
|
|
23
|
-
}
|
|
24
|
-
function f(e) {
|
|
25
|
-
return Array.isArray(e) ? e.map((e) => {
|
|
26
|
-
let t = e === null ? u : e;
|
|
27
|
-
return [t, t];
|
|
28
|
-
}) : Object.entries(e).map(([e, t]) => [e, t === null ? u : t]);
|
|
29
|
-
}
|
|
30
|
-
function p(e, t) {
|
|
31
|
-
return e.length === t.length && e.every(([e, n], r) => t[r][0] === e && t[r][1] === n);
|
|
32
|
-
}
|
|
33
|
-
function m(e, t) {
|
|
34
|
-
if (e.nodeType === Node.COMMENT_NODE) return !1;
|
|
35
|
-
if (e.nodeType === Node.TEXT_NODE) return s(e) ? (h(t, u, e), !0) : !1;
|
|
36
|
-
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
37
|
-
let n = e;
|
|
38
|
-
if (a(n) || o(n)) return !1;
|
|
39
|
-
if (n instanceof HTMLTemplateElement) {
|
|
40
|
-
let e = Array.from(n.content.childNodes), r = d(n.getAttribute("slot") ?? void 0);
|
|
41
|
-
for (let n of e) h(t, r, n);
|
|
42
|
-
return !0;
|
|
43
|
-
}
|
|
44
|
-
let r = n.getAttribute("slot");
|
|
45
|
-
return h(t, r === null ? u : d(r), e), !0;
|
|
46
|
-
}
|
|
47
|
-
return !1;
|
|
48
|
-
}
|
|
49
|
-
function h(e, t, n) {
|
|
50
|
-
let r = e.get(t);
|
|
51
|
-
r || (r = [], e.set(t, r)), r.push(n);
|
|
52
|
-
}
|
|
53
|
-
var g = class e {
|
|
54
|
-
static {
|
|
55
|
-
this.PLACEHOLDER_PREFIX = "pkt-slot";
|
|
56
|
-
}
|
|
57
|
-
constructor(e) {
|
|
58
|
-
this.observer = null, this.nodesBySlot = /* @__PURE__ */ new Map(), this.directives = /* @__PURE__ */ new Set(), this.observing = !1, this.trackedNodes = /* @__PURE__ */ new Set(), this.generation = 0, this.initialCollectionDone = !1, this.processingMutations = !1, this.placeholderToNode = /* @__PURE__ */ new Map(), this.nodeToPlaceholder = /* @__PURE__ */ new Map(), this.sources = /* @__PURE__ */ new Map(), this.subscribers = /* @__PURE__ */ new Set(), this.host = e;
|
|
59
|
-
}
|
|
60
|
-
collectNodes() {
|
|
61
|
-
if (this.initialCollectionDone) return;
|
|
62
|
-
this.initialCollectionDone = !0, this.generation++;
|
|
63
|
-
let e = Array.from(this.host.childNodes);
|
|
64
|
-
for (let t of e) m(t, this.nodesBySlot) && this.trackedNodes.add(t);
|
|
65
|
-
}
|
|
66
|
-
addDirective(e) {
|
|
67
|
-
this.directives.add(e), this.startObserving();
|
|
68
|
-
}
|
|
69
|
-
removeDirective(e) {
|
|
70
|
-
this.directives.delete(e), this.stopObservingIfUnused();
|
|
71
|
-
}
|
|
72
|
-
addSource(e, t, n) {
|
|
73
|
-
let r = this.sources.get(e);
|
|
74
|
-
r && r.manager === t && p(r.mapping, n) || (r && r.manager !== t && this.detachFrom(r.manager, e), this.sources.set(e, {
|
|
75
|
-
manager: t,
|
|
76
|
-
mapping: n
|
|
77
|
-
}), t.subscribers.add(this), t.startObserving(), this.handleChange());
|
|
78
|
-
}
|
|
79
|
-
removeSource(e) {
|
|
80
|
-
let t = this.sources.get(e);
|
|
81
|
-
t && (this.sources.delete(e), this.detachFrom(t.manager, e), this.handleChange());
|
|
82
|
-
}
|
|
83
|
-
getNodes(e) {
|
|
84
|
-
return this.nodesFor(d(e));
|
|
85
|
-
}
|
|
86
|
-
hasContent(e) {
|
|
87
|
-
return this.getNodes(e).length > 0;
|
|
88
|
-
}
|
|
89
|
-
ensurePlaceholder(t) {
|
|
90
|
-
if (this.nodeToPlaceholder.has(t)) return;
|
|
91
|
-
if (t.parentNode !== this.host) {
|
|
92
|
-
for (let { manager: e } of this.sources.values()) e.ensurePlaceholder(t);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
let n = document.createComment(e.PLACEHOLDER_PREFIX);
|
|
96
|
-
this.host.insertBefore(n, t), this.placeholderToNode.set(n, t), this.nodeToPlaceholder.set(t, n);
|
|
97
|
-
}
|
|
98
|
-
nodesFor(e) {
|
|
99
|
-
let t = this.nodesBySlot.get(e) ?? [];
|
|
100
|
-
if (this.sources.size === 0) return t;
|
|
101
|
-
let n = [];
|
|
102
|
-
for (let { manager: t, mapping: r } of this.sources.values()) for (let [i, a] of r) a === e && n.push(...t.nodesFor(i));
|
|
103
|
-
return n.length ? [...t, ...n] : t;
|
|
104
|
-
}
|
|
105
|
-
detachFrom(e, t) {
|
|
106
|
-
[...this.sources.entries()].some(([n, r]) => n !== t && r.manager === e) || (e.subscribers.delete(this), e.stopObservingIfUnused());
|
|
107
|
-
}
|
|
108
|
-
handleChange() {
|
|
109
|
-
this.generation++, this.notifyDirectives();
|
|
110
|
-
for (let e of this.subscribers) e.handleChange();
|
|
111
|
-
this.host.requestUpdate();
|
|
112
|
-
}
|
|
113
|
-
stopObservingIfUnused() {
|
|
114
|
-
this.directives.size === 0 && this.subscribers.size === 0 && this.stopObserving();
|
|
115
|
-
}
|
|
116
|
-
startObserving() {
|
|
117
|
-
this.observing || (this.observing = !0, setTimeout(() => {
|
|
118
|
-
!this.observing || typeof MutationObserver > "u" || (this.observer = new MutationObserver((e) => {
|
|
119
|
-
this.handleMutations(e);
|
|
120
|
-
}), this.observer.observe(this.host, {
|
|
121
|
-
childList: !0,
|
|
122
|
-
subtree: !0
|
|
123
|
-
}));
|
|
124
|
-
}, 0));
|
|
125
|
-
}
|
|
126
|
-
stopObserving() {
|
|
127
|
-
this.observing && (this.observing = !1, this.observer?.disconnect(), this.observer = null);
|
|
128
|
-
}
|
|
129
|
-
handleMutations(e) {
|
|
130
|
-
if (this.processingMutations) return;
|
|
131
|
-
this.processingMutations = !0;
|
|
132
|
-
let t = !1;
|
|
133
|
-
for (let n of e) {
|
|
134
|
-
for (let e of n.removedNodes) {
|
|
135
|
-
let n = this.placeholderToNode.get(e);
|
|
136
|
-
if (n) {
|
|
137
|
-
n.parentNode?.removeChild(n), this.trackedNodes.delete(n), this.removeFromSlots(n), this.placeholderToNode.delete(e), this.nodeToPlaceholder.delete(n), t = !0;
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
if (this.trackedNodes.has(e) && !this.host.contains(e)) {
|
|
141
|
-
this.trackedNodes.delete(e), this.removeFromSlots(e);
|
|
142
|
-
let n = this.nodeToPlaceholder.get(e);
|
|
143
|
-
n && (n.parentNode?.removeChild(n), this.placeholderToNode.delete(n), this.nodeToPlaceholder.delete(e)), t = !0;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
if (n.target === this.host) for (let e of n.addedNodes) this.placeholderToNode.has(e) || !this.trackedNodes.has(e) && this.isUserContent(e) && m(e, this.nodesBySlot) && (this.trackedNodes.add(e), t = !0);
|
|
147
|
-
}
|
|
148
|
-
t && this.handleChange(), this.observer?.takeRecords(), this.processingMutations = !1;
|
|
149
|
-
}
|
|
150
|
-
isUserContent(e) {
|
|
151
|
-
if (e.nodeType === Node.COMMENT_NODE) return !1;
|
|
152
|
-
if (e.nodeType === Node.TEXT_NODE) return s(e);
|
|
153
|
-
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
154
|
-
let t = e;
|
|
155
|
-
return !(a(t) || o(t));
|
|
156
|
-
}
|
|
157
|
-
return !1;
|
|
158
|
-
}
|
|
159
|
-
removeFromSlots(e) {
|
|
160
|
-
for (let [t, n] of this.nodesBySlot) {
|
|
161
|
-
let r = n.indexOf(e);
|
|
162
|
-
if (r !== -1) {
|
|
163
|
-
n.splice(r, 1), n.length === 0 && this.nodesBySlot.delete(t);
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
notifyDirectives() {
|
|
169
|
-
for (let e of this.directives) e.handleNodesChanged();
|
|
170
|
-
}
|
|
171
|
-
}, _ = e(class extends i {
|
|
172
|
-
constructor(e) {
|
|
173
|
-
if (super(e), this.manager = null, this.lastGeneration = -1, e.type !== n.CHILD) throw Error("slotContent() can only be used in child expressions");
|
|
174
|
-
}
|
|
175
|
-
render(e, n) {
|
|
176
|
-
return t;
|
|
177
|
-
}
|
|
178
|
-
update(e, [t, n]) {
|
|
179
|
-
return this.slotName = n, this.manager || (this.manager = l(t), this.manager.collectNodes(), this.manager.addDirective(this)), this.ensurePlaceholders(), this.getNodesOrNoChange();
|
|
180
|
-
}
|
|
181
|
-
handleNodesChanged() {
|
|
182
|
-
if (!this.isConnected || !this.manager) return;
|
|
183
|
-
this.ensurePlaceholders();
|
|
184
|
-
let e = this.getNodesOrNoChange();
|
|
185
|
-
e !== t && this.setValue(e);
|
|
186
|
-
}
|
|
187
|
-
ensurePlaceholders() {
|
|
188
|
-
if (!this.manager) return;
|
|
189
|
-
let e = this.manager.getNodes(this.slotName);
|
|
190
|
-
for (let t of e) this.manager.ensurePlaceholder(t);
|
|
191
|
-
}
|
|
192
|
-
disconnected() {
|
|
193
|
-
this.manager?.removeDirective(this), this.manager = null, this.lastGeneration = -1;
|
|
194
|
-
}
|
|
195
|
-
reconnected() {}
|
|
196
|
-
getNodesOrNoChange() {
|
|
197
|
-
if (!this.manager) return t;
|
|
198
|
-
let e = this.manager.generation;
|
|
199
|
-
return e === this.lastGeneration ? t : (this.lastGeneration = e, this.manager.getNodes(this.slotName));
|
|
200
|
-
}
|
|
201
|
-
}), v = e(class extends i {
|
|
202
|
-
constructor(e) {
|
|
203
|
-
if (super(e), this.target = null, this.source = null, this.mapping = [], e.type !== n.ELEMENT) throw Error("forwardSlots() can only be used as an element directive");
|
|
204
|
-
}
|
|
205
|
-
render(e, n) {
|
|
206
|
-
return t;
|
|
207
|
-
}
|
|
208
|
-
update(e, [n, r]) {
|
|
209
|
-
let i = l(e.element);
|
|
210
|
-
return this.target && this.target !== i && this.target.removeSource(this), this.target = i, this.source = l(n), this.source.collectNodes(), this.mapping = f(r), this.target.addSource(this, this.source, this.mapping), t;
|
|
211
|
-
}
|
|
212
|
-
disconnected() {
|
|
213
|
-
this.target?.removeSource(this);
|
|
214
|
-
}
|
|
215
|
-
reconnected() {
|
|
216
|
-
this.target && this.source && this.target.addSource(this, this.source, this.mapping);
|
|
217
|
-
}
|
|
218
|
-
}), y = class extends r {
|
|
219
|
-
connectedCallback() {
|
|
220
|
-
l(this).collectNodes(), super.connectedCallback();
|
|
221
|
-
}
|
|
222
|
-
hasSlotContent(e) {
|
|
223
|
-
return l(this).hasContent(e);
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
//#endregion
|
|
227
|
-
export { o as a, _ as i, v as n, l as r, y as t };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./async-directive-DpyKp6qv.cjs");function n(e){return e.classList&&(e.classList.contains(`_dialog_overlay`)||e.classList.contains(`backdrop`))?!0:typeof e.hasAttribute==`function`&&e.hasAttribute(`data-skip`)}function r(e){return e.nodeName===`OPTION`||e.nodeName===`DATA`}function i(e){return e.nodeType===Node.TEXT_NODE&&e.nodeValue?.trim()!==``}var a=new WeakMap;function o(e){let t=a.get(e);return t||(t=new p(e),a.set(e,t)),t}var s=Symbol(`default`);function c(e){return e===void 0?s:e}function l(e){return Array.isArray(e)?e.map(e=>{let t=e===null?s:e;return[t,t]}):Object.entries(e).map(([e,t])=>[e,t===null?s:t])}function u(e,t){return e.length===t.length&&e.every(([e,n],r)=>t[r][0]===e&&t[r][1]===n)}function d(e,t){if(e.nodeType===Node.COMMENT_NODE)return!1;if(e.nodeType===Node.TEXT_NODE)return i(e)?(f(t,s,e),!0):!1;if(e.nodeType===Node.ELEMENT_NODE){let i=e;if(n(i)||r(i))return!1;if(i instanceof HTMLTemplateElement){let e=Array.from(i.content.childNodes),n=c(i.getAttribute(`slot`)??void 0);for(let r of e)f(t,n,r);return!0}let a=i.getAttribute(`slot`);return f(t,a===null?s:c(a),e),!0}return!1}function f(e,t,n){let r=e.get(t);r||(r=[],e.set(t,r)),r.push(n)}var p=class e{static{this.PLACEHOLDER_PREFIX=`pkt-slot`}constructor(e){this.observer=null,this.nodesBySlot=new Map,this.directives=new Set,this.observing=!1,this.trackedNodes=new Set,this.generation=0,this.initialCollectionDone=!1,this.processingMutations=!1,this.placeholderToNode=new Map,this.nodeToPlaceholder=new Map,this.sources=new Map,this.subscribers=new Set,this.host=e}collectNodes(){if(this.initialCollectionDone)return;this.initialCollectionDone=!0,this.generation++;let e=Array.from(this.host.childNodes);for(let t of e)d(t,this.nodesBySlot)&&this.trackedNodes.add(t)}addDirective(e){this.directives.add(e),this.startObserving()}removeDirective(e){this.directives.delete(e),this.stopObservingIfUnused()}addSource(e,t,n){let r=this.sources.get(e);r&&r.manager===t&&u(r.mapping,n)||(r&&r.manager!==t&&this.detachFrom(r.manager,e),this.sources.set(e,{manager:t,mapping:n}),t.subscribers.add(this),t.startObserving(),this.handleChange())}removeSource(e){let t=this.sources.get(e);t&&(this.sources.delete(e),this.detachFrom(t.manager,e),this.handleChange())}getNodes(e){return this.nodesFor(c(e))}hasContent(e){return this.getNodes(e).length>0}ensurePlaceholder(t){if(this.nodeToPlaceholder.has(t))return;if(t.parentNode!==this.host){for(let{manager:e}of this.sources.values())e.ensurePlaceholder(t);return}let n=document.createComment(e.PLACEHOLDER_PREFIX);this.host.insertBefore(n,t),this.placeholderToNode.set(n,t),this.nodeToPlaceholder.set(t,n)}nodesFor(e){let t=this.nodesBySlot.get(e)??[];if(this.sources.size===0)return t;let n=[];for(let{manager:t,mapping:r}of this.sources.values())for(let[i,a]of r)a===e&&n.push(...t.nodesFor(i));return n.length?[...t,...n]:t}detachFrom(e,t){[...this.sources.entries()].some(([n,r])=>n!==t&&r.manager===e)||(e.subscribers.delete(this),e.stopObservingIfUnused())}handleChange(){this.generation++,this.notifyDirectives();for(let e of this.subscribers)e.handleChange();this.host.requestUpdate()}stopObservingIfUnused(){this.directives.size===0&&this.subscribers.size===0&&this.stopObserving()}startObserving(){this.observing||(this.observing=!0,setTimeout(()=>{!this.observing||typeof MutationObserver>`u`||(this.observer=new MutationObserver(e=>{this.handleMutations(e)}),this.observer.observe(this.host,{childList:!0,subtree:!0}))},0))}stopObserving(){this.observing&&(this.observing=!1,this.observer?.disconnect(),this.observer=null)}handleMutations(e){if(this.processingMutations)return;this.processingMutations=!0;let t=!1;for(let n of e){for(let e of n.removedNodes){let n=this.placeholderToNode.get(e);if(n){n.parentNode?.removeChild(n),this.trackedNodes.delete(n),this.removeFromSlots(n),this.placeholderToNode.delete(e),this.nodeToPlaceholder.delete(n),t=!0;continue}if(this.trackedNodes.has(e)&&!this.host.contains(e)){this.trackedNodes.delete(e),this.removeFromSlots(e);let n=this.nodeToPlaceholder.get(e);n&&(n.parentNode?.removeChild(n),this.placeholderToNode.delete(n),this.nodeToPlaceholder.delete(e)),t=!0}}if(n.target===this.host)for(let e of n.addedNodes)this.placeholderToNode.has(e)||!this.trackedNodes.has(e)&&this.isUserContent(e)&&d(e,this.nodesBySlot)&&(this.trackedNodes.add(e),t=!0)}t&&this.handleChange(),this.observer?.takeRecords(),this.processingMutations=!1}isUserContent(e){if(e.nodeType===Node.COMMENT_NODE)return!1;if(e.nodeType===Node.TEXT_NODE)return i(e);if(e.nodeType===Node.ELEMENT_NODE){let t=e;return!(n(t)||r(t))}return!1}removeFromSlots(e){for(let[t,n]of this.nodesBySlot){let r=n.indexOf(e);if(r!==-1){n.splice(r,1),n.length===0&&this.nodesBySlot.delete(t);return}}}notifyDirectives(){for(let e of this.directives)e.handleNodesChanged()}},m=class extends t.t{constructor(t){if(super(t),this.manager=null,this.lastGeneration=-1,t.type!==e.m.CHILD)throw Error(`slotContent() can only be used in child expressions`)}render(t,n){return e.g}update(e,[t,n]){return this.slotName=n,this.manager||(this.manager=o(t),this.manager.collectNodes(),this.manager.addDirective(this)),this.ensurePlaceholders(),this.getNodesOrNoChange()}handleNodesChanged(){if(!this.isConnected||!this.manager)return;this.ensurePlaceholders();let t=this.getNodesOrNoChange();t!==e.g&&this.setValue(t)}ensurePlaceholders(){if(!this.manager)return;let e=this.manager.getNodes(this.slotName);for(let t of e)this.manager.ensurePlaceholder(t)}disconnected(){this.manager?.removeDirective(this),this.manager=null,this.lastGeneration=-1}reconnected(){}getNodesOrNoChange(){if(!this.manager)return e.g;let t=this.manager.generation;return t===this.lastGeneration?e.g:(this.lastGeneration=t,this.manager.getNodes(this.slotName))}},h=e.f(m),g=class extends t.t{constructor(t){if(super(t),this.target=null,this.source=null,this.mapping=[],t.type!==e.m.ELEMENT)throw Error(`forwardSlots() can only be used as an element directive`)}render(t,n){return e.g}update(t,[n,r]){let i=o(t.element);return this.target&&this.target!==i&&this.target.removeSource(this),this.target=i,this.source=o(n),this.source.collectNodes(),this.mapping=l(r),this.target.addSource(this,this.source,this.mapping),e.g}disconnected(){this.target?.removeSource(this)}reconnected(){this.target&&this.source&&this.target.addSource(this,this.source,this.mapping)}},_=e.f(g),v=class extends e.t{connectedCallback(){o(this).collectNodes(),super.connectedCallback()}hasSlotContent(e){return o(this).hasContent(e)}};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return v}});
|
|
@@ -1,38 +0,0 @@
|
|
|
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-C4SelHLD.cjs");var a=n.n(Symbol(`pkt-radio-group-context`)),o=class extends i.t{constructor(...e){super(...e),this.inputRef=r.t(),this.value=``,this.checkHelptext=null,this.defaultChecked=!1,this.hasTile=!1,this.checked=null,this.type=`radio`,this.inputSize=void 0,this.tagText=null,this.optionalTag=!1,this.requiredTag=!1,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
|
-
${this.tagText?e._`<span class=${s+` pkt-tag--gray`}>${this.tagText}</span>`:e.h}
|
|
3
|
-
${this.optionalTag?e._`<span class=${s+` pkt-tag--blue-light`}
|
|
4
|
-
>${this.optionalText??c.optional}</span
|
|
5
|
-
>`:e.h}
|
|
6
|
-
${this.requiredTag?e._`<span class=${s+` pkt-tag--beige`}
|
|
7
|
-
>${this.requiredText??c.required}</span
|
|
8
|
-
>`:e.h}
|
|
9
|
-
`,u=this.id+`-check-label`,d=this.id+`-check-helptext`;return e._`
|
|
10
|
-
<div class="pkt-input-check${this.inputSize?` pkt-input-check--${this.inputSize}`:``}">
|
|
11
|
-
<div class=${i}>
|
|
12
|
-
<input
|
|
13
|
-
id=${this.id+`-internal`}
|
|
14
|
-
class=${a}
|
|
15
|
-
type="radio"
|
|
16
|
-
?disabled=${this.isDisabled}
|
|
17
|
-
form=""
|
|
18
|
-
name=${this.internalName}
|
|
19
|
-
${r.n(this.inputRef)}
|
|
20
|
-
@change=${this.toggleChecked}
|
|
21
|
-
@input=${this.handleInput}
|
|
22
|
-
@blur=${this.onBlur}
|
|
23
|
-
@focus=${this.onFocus}
|
|
24
|
-
?checked=${this.checked}
|
|
25
|
-
aria-labelledby=${this.label?u:e.h}
|
|
26
|
-
aria-describedby=${this.checkHelptext?d:e.h}
|
|
27
|
-
/>
|
|
28
|
-
${e._`
|
|
29
|
-
<label class=${o} for=${this.id+`-internal`}>
|
|
30
|
-
<span id=${u}>${this.label} ${l()}</span>
|
|
31
|
-
${this.checkHelptext?e._`<div id=${d} class="pkt-input-check__input-helptext">
|
|
32
|
-
${this.checkHelptext}
|
|
33
|
-
</div>`:e.h}
|
|
34
|
-
</label>
|
|
35
|
-
`}
|
|
36
|
-
</div>
|
|
37
|
-
</div>
|
|
38
|
-
`}handleInput(e){e.stopImmediatePropagation()}toggleChecked(e=null){e&&e.preventDefault(),e&&e.stopImmediatePropagation(),this.touched=!0,this.inputRef.value&&(this._checked=this.inputRef.value.matches(`:checked`),this.valueChecked(this._checked))}};e.n([e.u({type:String,reflect:!0})],o.prototype,`value`,void 0),e.n([e.u({type:String})],o.prototype,`checkHelptext`,void 0),e.n([e.u({type:Boolean})],o.prototype,`defaultChecked`,void 0),e.n([e.u({type:Boolean})],o.prototype,`hasTile`,void 0),e.n([e.u({type:Boolean,reflect:!0})],o.prototype,`checked`,void 0),e.n([e.u({type:String,reflect:!0})],o.prototype,`type`,void 0),e.n([e.u({type:String,attribute:`input-size`})],o.prototype,`inputSize`,void 0),e.n([e.u({type:String})],o.prototype,`tagText`,void 0),e.n([e.u({type:Boolean})],o.prototype,`optionalTag`,void 0),e.n([e.u({type:String})],o.prototype,`optionalText`,void 0),e.n([e.u({type:Boolean})],o.prototype,`requiredTag`,void 0),e.n([e.u({type:String})],o.prototype,`requiredText`,void 0),e.n([e.l()],o.prototype,`_checked`,void 0),e.n([n.t({context:a,subscribe:!0}),e.l()],o.prototype,`groupContext`,void 0);try{e.d(`pkt-radiobutton`)(o)}catch{console.warn(`Forsøker å definere <pkt-radiobutton>, men den er allerede definert`)}var s=o;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
|