@oslokommune/punkt-elements 19.18.4 → 19.18.5
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 +5 -0
- package/dist/{alert-CdfTJcT2.js → alert-BAaZIR3e.js} +2 -2
- package/dist/{alert-CBW94-ku.cjs → alert-Dy5N7qK-.cjs} +1 -1
- package/dist/{backlink-GIyyoDoi.cjs → backlink-BnWruRuj.cjs} +1 -1
- package/dist/{backlink-D3rkJWkd.js → backlink-Dlkyj0ns.js} +1 -1
- package/dist/{breadcrumbs-B4WdX4QR.js → breadcrumbs-Bfv8W2CF.js} +1 -1
- package/dist/{breadcrumbs-B7U57Zey.cjs → breadcrumbs-CyWtnx2B.cjs} +1 -1
- package/dist/{button-DdR_XzMY.cjs → button-BBFI3FuT.cjs} +1 -1
- package/dist/{button-DwcFG7bU.js → button-CF9k3ARf.js} +1 -1
- package/dist/{calendar-DGOwyX3o.js → calendar-BX3n3vhs.js} +1 -1
- package/dist/{calendar-DcenMWOQ.cjs → calendar-Dds9KFiE.cjs} +1 -1
- package/dist/{card-D4rpTD_e.js → card-Ddu0sQ0f.js} +2 -2
- package/dist/{card-CizBnD59.cjs → card-mi3VKIoy.cjs} +1 -1
- package/dist/{checkbox-group-C3CwgQIq.cjs → checkbox-group-BlBgrzKG.cjs} +1 -1
- package/dist/{checkbox-group-BCtUOlZp.js → checkbox-group-Dz1ypmbU.js} +1 -1
- package/dist/{combobox-CXdUSMaA.js → combobox-BAkblu9M.js} +3 -3
- package/dist/{combobox-Bfe2p8d8.cjs → combobox-DLDvyuDh.cjs} +1 -1
- package/dist/components/loader/loader.d.ts +5 -36
- package/dist/{consent-Chtz1yL0.js → consent-BTw6uqFf.js} +1 -1
- package/dist/{consent-Dhh207Zz.cjs → consent-DNHRe0zV.cjs} +1 -1
- package/dist/{datepicker-DQt_f4MP.js → datepicker-9dmdHweu.js} +4 -4
- package/dist/{datepicker-CGpQOyQb.cjs → datepicker-C7F1Yc5N.cjs} +1 -1
- package/dist/{fileupload-BrDtkw2A.cjs → fileupload-BLAQqG3-.cjs} +1 -1
- package/dist/{fileupload-_v5x0RrP.js → fileupload-D7nEdIgL.js} +5 -5
- package/dist/{footer-D4R-9si6.js → footer-DZ4aA6fj.js} +2 -2
- package/dist/{footer-QGnujLm9.cjs → footer-HFL2sjAY.cjs} +1 -1
- package/dist/{header-BnyUkagz.cjs → header-Cj08flhl.cjs} +1 -1
- package/dist/{header-CZUjgMNP.js → header-Cptdf4fW.js} +6 -6
- package/dist/{header-menu-D9ErtEEq.cjs → header-menu-De2DNAXd.cjs} +1 -1
- package/dist/{header-menu-Bxuz8rw9.js → header-menu-DxOSBiTJ.js} +1 -1
- package/dist/{helptext-BXryqHy5.js → helptext-BVYv8Lm9.js} +1 -1
- package/dist/{helptext-KrtUyA7H.cjs → helptext-BbrFE48Y.cjs} +1 -1
- package/dist/{icon-BVSiUQSL.js → icon-CUU42bZ0.js} +29 -28
- package/dist/icon-CrG6o7ZE.cjs +1 -0
- package/dist/{input-wrapper-7RSISZu6.js → input-wrapper-CHwWQgZP.js} +3 -3
- package/dist/{input-wrapper-DT9h0n2i.cjs → input-wrapper-QzdntWJX.cjs} +1 -1
- package/dist/{link-DL4dZoI5.js → link-BU6t5Tt9.js} +1 -1
- package/dist/{link-u69d_-Zh.cjs → link-a1ZK4J1j.cjs} +1 -1
- package/dist/{linkcard-B6N7xChn.cjs → linkcard-Cu4Rh71U.cjs} +1 -1
- package/dist/{linkcard-C_9NCgkD.js → linkcard-DM0CQbwD.js} +1 -1
- package/dist/loader-DwGMavG7.cjs +16 -0
- package/dist/{loader-DJGAd8c-.js → loader-Y8V3Q82X.js} +37 -9
- package/dist/{messagebox-YkknrtEM.cjs → messagebox-DR-s6tyr.cjs} +1 -1
- package/dist/{messagebox-V1Kszdop.js → messagebox-wJcXW5hI.js} +1 -1
- package/dist/{modal-BV77IiGH.js → modal-Dt35SMQH.js} +1 -1
- package/dist/{modal-i8CzjbyX.cjs → modal-DyaAoMeB.cjs} +1 -1
- package/dist/{option-group-element-BEGRouXw.cjs → option-group-element-CWjgrFwS.cjs} +1 -1
- package/dist/{option-group-element-CQViBzca.js → option-group-element-ZNyUoLcm.js} +1 -1
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +1 -1
- package/dist/pkt-backlink.cjs +1 -1
- package/dist/pkt-backlink.js +1 -1
- package/dist/pkt-breadcrumbs.cjs +1 -1
- package/dist/pkt-breadcrumbs.js +1 -1
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +1 -1
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +1 -1
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +1 -1
- package/dist/pkt-checkbox-group.cjs +1 -1
- package/dist/pkt-checkbox-group.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-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +1 -1
- package/dist/pkt-icon.cjs +1 -1
- package/dist/pkt-icon.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +34 -34
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-link.cjs +1 -1
- package/dist/pkt-link.js +1 -1
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +1 -1
- package/dist/pkt-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-progressbar.cjs +1 -1
- package/dist/pkt-progressbar.js +1 -1
- package/dist/pkt-radio-group.cjs +1 -1
- package/dist/pkt-radio-group.js +1 -1
- package/dist/pkt-searchinput.cjs +1 -1
- package/dist/pkt-searchinput.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/pkt-tabs.cjs +1 -1
- package/dist/pkt-tabs.js +1 -1
- package/dist/pkt-tag.cjs +1 -1
- package/dist/pkt-tag.js +1 -1
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +1 -1
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +1 -1
- package/dist/pkt-timepicker.cjs +1 -1
- package/dist/pkt-timepicker.js +1 -1
- package/dist/{progressbar-bamcqcZ2.js → progressbar-BukfOcRk.js} +1 -1
- package/dist/{progressbar-Do0ZPeMk.cjs → progressbar-YfHSPmqI.cjs} +1 -1
- package/dist/{radio-group-Dz3a7Dgq.js → radio-group-Bg6ODpT3.js} +1 -1
- package/dist/{radio-group-iv9QgcSe.cjs → radio-group-bpIEEMdL.cjs} +1 -1
- package/dist/{searchinput-zxHqZ-jG.js → searchinput-BV2C1VbN.js} +1 -1
- package/dist/{searchinput-B1m241pF.cjs → searchinput-DqD_iLxV.cjs} +1 -1
- package/dist/{select-BuikSUfZ.cjs → select-CHqM6kI-.cjs} +1 -1
- package/dist/{select-CN3d9HWQ.js → select-DKBfPgJB.js} +1 -1
- package/dist/shared-types/index.d.ts +2 -0
- package/dist/shared-types/loader.d.ts +48 -0
- package/dist/{tabs-ZhYxE5fX.js → tabs-B2RjklQl.js} +1 -1
- package/dist/{tabs-fXlMzPFJ.cjs → tabs-BcnYrmjU.cjs} +1 -1
- package/dist/{tag-Bv5JRS69.js → tag-BOTH9kMz.js} +1 -1
- package/dist/{tag-B2EEjkjD.cjs → tag-DrFK8Wq3.cjs} +1 -1
- package/dist/{textarea-Bb_DpiQc.cjs → textarea-B5OfR-QI.cjs} +1 -1
- package/dist/{textarea-BdeJyPFA.js → textarea-Du1Z9JUu.js} +2 -2
- package/dist/{textinput-B5xO_FmE.cjs → textinput-75MKBqas.cjs} +1 -1
- package/dist/{textinput-B1fKltx7.js → textinput-D_V3b327.js} +2 -2
- package/dist/{timepicker-CUxP-zLZ.js → timepicker-DVqTAxt0.js} +2 -2
- package/dist/{timepicker-CmSgKlJ4.cjs → timepicker-RxsG0mCF.cjs} +1 -1
- package/package.json +2 -2
- package/src/components/loader/loader.test.ts +32 -0
- package/src/components/loader/loader.ts +41 -48
- package/dist/icon-BsRlhXU2.cjs +0 -1
- package/dist/loader-l7CLjzgI.cjs +0 -16
|
@@ -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-B0Vp_OuR.cjs");require("./icon-BsRlhXU2.cjs");const i=require("./input-wrapper-DT9h0n2i.cjs"),a=require("./if-defined-CiML3MTM.cjs"),o=require("./ref-CB7e9nMY.cjs"),s=require("./input-element-D82laWtR.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-CrG6o7ZE.cjs");const i=require("./input-wrapper-QzdntWJX.cjs"),a=require("./if-defined-CiML3MTM.cjs"),o=require("./ref-CB7e9nMY.cjs"),s=require("./input-element-D82laWtR.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.5",
|
|
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",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"engines": {
|
|
79
79
|
"node": "^22.19.0 || ^24.0.0 || ^26.0.0"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "cb396444142fc6b2bdcabfcfaf500ef5003bc7e1"
|
|
82
82
|
}
|
|
@@ -102,6 +102,38 @@ describe('PktLoader', () => {
|
|
|
102
102
|
expect(loader.variant).toBe('blue')
|
|
103
103
|
expect(loader.delay).toBe(100)
|
|
104
104
|
})
|
|
105
|
+
|
|
106
|
+
const renderFromHtml = async (markup: string) => {
|
|
107
|
+
document.body.innerHTML = markup
|
|
108
|
+
const loader = document.querySelector('pkt-loader') as CustomElementFor<'pkt-loader'>
|
|
109
|
+
await loader.updateComplete
|
|
110
|
+
return loader
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
test('is-loading="false" skjuler loaderen', async () => {
|
|
114
|
+
const loader = await renderFromHtml('<pkt-loader is-loading="false"></pkt-loader>')
|
|
115
|
+
|
|
116
|
+
expect(loader.isLoading).toBe(false)
|
|
117
|
+
expect(loader.querySelector('.pkt-loader__spinner')).not.toBeInTheDocument()
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
test('det gamle isloading-attributtet virker fortsatt', async () => {
|
|
121
|
+
const loader = await renderFromHtml('<pkt-loader isloading="false"></pkt-loader>')
|
|
122
|
+
|
|
123
|
+
expect(loader.isLoading).toBe(false)
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
test('loading-animation-path og det gamle loadinganimationpath setter stien', async () => {
|
|
127
|
+
const kebab = await renderFromHtml(
|
|
128
|
+
'<pkt-loader loading-animation-path="/animasjoner/"></pkt-loader>',
|
|
129
|
+
)
|
|
130
|
+
expect(kebab.loadingAnimationPath).toBe('/animasjoner/')
|
|
131
|
+
|
|
132
|
+
const legacy = await renderFromHtml(
|
|
133
|
+
'<pkt-loader loadinganimationpath="/gamle-animasjoner/"></pkt-loader>',
|
|
134
|
+
)
|
|
135
|
+
expect(legacy.loadingAnimationPath).toBe('/gamle-animasjoner/')
|
|
136
|
+
})
|
|
105
137
|
})
|
|
106
138
|
|
|
107
139
|
describe('Size variants', () => {
|
|
@@ -3,65 +3,58 @@ import { classMap } from 'lit/directives/class-map.js'
|
|
|
3
3
|
import { customElement, property, state } from 'lit/decorators.js'
|
|
4
4
|
import { html, nothing } from 'lit'
|
|
5
5
|
import { slotContent } from '@/directives/slot-content'
|
|
6
|
-
import
|
|
6
|
+
import {
|
|
7
|
+
ANIMATION_DEFAULT_PATH,
|
|
8
|
+
booleanishConverter,
|
|
9
|
+
LOADER_DEFAULTS,
|
|
10
|
+
type IPktLoaderBase,
|
|
11
|
+
type TPktLoaderVariant,
|
|
12
|
+
type TPktSizeBase,
|
|
13
|
+
} from 'shared-types'
|
|
7
14
|
import '@/components/icon'
|
|
8
15
|
|
|
9
|
-
const defaultAnimationPath = 'https://punkt-cdn.oslo.kommune.no/latest/animations/'
|
|
10
|
-
|
|
11
16
|
// Allow global override of animation assets path
|
|
12
17
|
if (typeof window !== 'undefined') {
|
|
13
|
-
window.pktAnimationPath = window.pktAnimationPath ||
|
|
18
|
+
window.pktAnimationPath = window.pktAnimationPath || ANIMATION_DEFAULT_PATH
|
|
14
19
|
}
|
|
15
20
|
|
|
16
|
-
export type TPktLoaderVariant
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* Delay time is in milliseconds.
|
|
23
|
-
*/
|
|
24
|
-
delay?: number
|
|
25
|
-
/**
|
|
26
|
-
* The `inline` prop decides whether the loader should be displayed inline or not.
|
|
27
|
-
*/
|
|
28
|
-
inline?: boolean
|
|
29
|
-
/**
|
|
30
|
-
* The boolean 'isLoading' decides whether the loader or the children will be displayed.
|
|
31
|
-
* If set to false, the children will be displayed.
|
|
32
|
-
*/
|
|
33
|
-
isLoading?: boolean
|
|
34
|
-
/**
|
|
35
|
-
* The message to display when the loader is loading.
|
|
36
|
-
*/
|
|
37
|
-
message?: string | null
|
|
38
|
-
/**
|
|
39
|
-
* The size of the loader. Default is "medium".
|
|
40
|
-
*/
|
|
41
|
-
size?: TPktSizeBase
|
|
42
|
-
/**
|
|
43
|
-
* The variant of the loader. Default is "rainbow".
|
|
44
|
-
* "shapes" is the OSLO wave loader, "blue" a blue spinner.
|
|
45
|
-
*/
|
|
46
|
-
variant?: TPktLoaderVariant
|
|
47
|
-
/**
|
|
48
|
-
* Override path to loading animations.
|
|
49
|
-
*/
|
|
50
|
-
loadingAnimationPath?: string
|
|
51
|
-
}
|
|
21
|
+
export type { TPktLoaderVariant }
|
|
22
|
+
export type IPktLoader = IPktLoaderBase
|
|
23
|
+
|
|
24
|
+
// Lowercase names Lit generated before the kebab-case attributes existed.
|
|
25
|
+
const LEGACY_IS_LOADING = 'isloading'
|
|
26
|
+
const LEGACY_LOADING_ANIMATION_PATH = 'loadinganimationpath'
|
|
52
27
|
|
|
53
28
|
export class PktLoader extends PktElementWithSlot implements IPktLoader {
|
|
54
|
-
@property({ type: Number }) delay: number =
|
|
55
|
-
@property({ type: Boolean }) inline: boolean =
|
|
56
|
-
@property({ type: Boolean
|
|
57
|
-
|
|
58
|
-
@property({ type: String })
|
|
59
|
-
@property({ type: String })
|
|
60
|
-
@property({ type: String })
|
|
61
|
-
|
|
29
|
+
@property({ type: Number }) delay: number = LOADER_DEFAULTS.delay
|
|
30
|
+
@property({ type: Boolean }) inline: boolean = LOADER_DEFAULTS.inline
|
|
31
|
+
@property({ type: Boolean, attribute: 'is-loading', converter: booleanishConverter })
|
|
32
|
+
isLoading: boolean = LOADER_DEFAULTS.isLoading
|
|
33
|
+
@property({ type: String }) message: string | null = LOADER_DEFAULTS.message
|
|
34
|
+
@property({ type: String }) size: TPktSizeBase = LOADER_DEFAULTS.size
|
|
35
|
+
@property({ type: String }) variant: TPktLoaderVariant = LOADER_DEFAULTS.variant
|
|
36
|
+
@property({ type: String, attribute: 'loading-animation-path' })
|
|
37
|
+
loadingAnimationPath: string | undefined =
|
|
38
|
+
typeof window !== 'undefined' ? window.pktAnimationPath : ANIMATION_DEFAULT_PATH
|
|
62
39
|
|
|
63
40
|
@state() private _shouldDisplayLoader: boolean = false
|
|
64
41
|
|
|
42
|
+
static get observedAttributes(): string[] {
|
|
43
|
+
return [...super.observedAttributes, LEGACY_IS_LOADING, LEGACY_LOADING_ANIMATION_PATH]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
|
|
47
|
+
if (name === LEGACY_IS_LOADING) {
|
|
48
|
+
this.isLoading = booleanishConverter.fromAttribute(value)
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
if (name === LEGACY_LOADING_ANIMATION_PATH) {
|
|
52
|
+
this.loadingAnimationPath = value ?? undefined
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
super.attributeChangedCallback(name, _old, value)
|
|
56
|
+
}
|
|
57
|
+
|
|
65
58
|
connectedCallback() {
|
|
66
59
|
super.connectedCallback()
|
|
67
60
|
this._shouldDisplayLoader = this.delay === 0
|
package/dist/icon-BsRlhXU2.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs");require("./shared-types-BvRk9kiK.cjs");var t={name:``,path:`https://punkt-cdn.oslo.kommune.no/latest/icons/`},n=class extends e.p{constructor(t){if(super(t),this.it=e.h,t.type!==e.m.CHILD)throw Error(this.constructor.directiveName+`() can only be used in child bindings`)}render(t){if(t===e.h||t==null)return this._t=void 0,this.it=t;if(t===e.g)return t;if(typeof t!=`string`)throw Error(this.constructor.directiveName+`() called with a non-string value`);if(t===this.it)return this._t;this.it=t;let n=[t];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}};n.directiveName=`unsafeHTML`,n.resultType=1;var r=e.f(n),i=class extends n{};i.directiveName=`unsafeSVG`,i.resultType=2;var a=e.f(i);typeof window<`u`&&(window.pktFetch=window.pktFetch===void 0?fetch:window.pktFetch,window.pktIconPath=window.pktIconPath||t.path);var o=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"></svg>`,s={},c=2,l=1500,u=(()=>{try{return typeof Storage<`u`&&typeof sessionStorage<`u`}catch{return!1}})(),d=e=>window.pktFetch(e).then(t=>{if(!t.ok)throw Error(`Missing icon: `+e);return t.text()}),f=async(e,t=c)=>{try{return await d(e)}catch{return t>0?(await new Promise(e=>setTimeout(e,l)),f(e,t-1)):(console.error(`Failed to fetch icon: `+e),o)}},p=async(e,t)=>{let n=t+e+`.svg`;return u&&sessionStorage.getItem(n)?sessionStorage.getItem(n):n in s?s[n]:typeof window<`u`&&typeof window.pktFetch==`function`?(s[n]=f(n).then(e=>(e!==o&&u&&sessionStorage.setItem(n,e),delete s[n],e)),s[n]):o},m=class extends e.t{constructor(...e){super(...e),this.path=typeof window<`u`?window.pktIconPath:t.path,this.name=t.name,this.ariaHidden=null,this.ariaLabel=null,this.icon=a(o),this._updatedProps=[]}get effectiveAriaHidden(){return this.ariaHidden!==null&&this.ariaHidden!==void 0?this.ariaHidden===``||this.ariaHidden===`true`:!this.ariaLabel}get effectiveAriaLabel(){return this.effectiveAriaHidden?null:this.ariaLabel||this.name||null}connectedCallback(){super.connectedCallback(),this.classList.add(`pkt-icon`)}async attributeChangedCallback(e,t,n){super.attributeChangedCallback(e,t,n),(e===`name`||e===`path`)&&this.getIcon(this.name)}async updated(e){super.updated(e),(e.has(`name`)||e.has(`path`))&&this.getIcon(this.name),this.applyAriaToSvg()}applyAriaToSvg(){let e=this.querySelector(`svg`);if(!e)return;e.setAttribute(`aria-hidden`,String(this.effectiveAriaHidden));let t=this.effectiveAriaLabel;t?e.setAttribute(`aria-label`,t):e.removeAttribute(`aria-label`)}async getIcon(e=``){if(this._updatedProps.length>0){this.path||=typeof window<`u`?window.pktIconPath:t.path;try{this.icon=a(await p(this.name||``,this.path))}catch{this.icon=a(o)}this._updatedProps=[]}else this._updatedProps.includes(e)||this._updatedProps.push(e)}render(){return e._`${this.name&&this.icon}`}};e.n([e.u({type:String,reflect:!1})],m.prototype,`path`,void 0),e.n([e.u({type:String,reflect:!0})],m.prototype,`name`,void 0),e.n([e.u({type:String,attribute:`aria-hidden`,reflect:!0})],m.prototype,`ariaHidden`,void 0),e.n([e.u({type:String,attribute:`aria-label`,reflect:!0})],m.prototype,`ariaLabel`,void 0),e.n([e.u({type:SVGElement})],m.prototype,`icon`,void 0),e.n([e.u({type:Array,noAccessor:!0})],m.prototype,`_updatedProps`,void 0);try{e.d(`pkt-icon`)(m)}catch{console.warn(`Forsøker å definere <pkt-icon>, men den er allerede definert`)}var h=m;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return h}});
|
package/dist/loader-l7CLjzgI.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./element-with-slot-B0Vp_OuR.cjs");require("./icon-BsRlhXU2.cjs");var r=`https://punkt-cdn.oslo.kommune.no/latest/animations/`;typeof window<`u`&&(window.pktAnimationPath=window.pktAnimationPath||r);var i=class extends n.t{constructor(...e){super(...e),this.delay=0,this.inline=!1,this.isLoading=!0,this.message=null,this.size=`medium`,this.variant=`rainbow`,this.loadingAnimationPath=typeof window<`u`?window.pktAnimationPath:r,this._shouldDisplayLoader=!1}connectedCallback(){super.connectedCallback(),this._shouldDisplayLoader=this.delay===0,this.delay>0&&this.setupLoader()}updated(e){e.has(`delay`)&&this.setupLoader()}render(){let r=t.t({"pkt-loader":!0,[`pkt-loader--${this.inline?`inline`:`box`}`]:!0,[`pkt-loader--${this.size}`]:!0}),i=t.t({"pkt-contents":!0,"pkt-hide":this.isLoading});return e._`<div
|
|
2
|
-
role="status"
|
|
3
|
-
aria-live="polite"
|
|
4
|
-
aria-busy=${this.isLoading?`true`:`false`}
|
|
5
|
-
class=${r}
|
|
6
|
-
>
|
|
7
|
-
${this.isLoading&&this._shouldDisplayLoader?e._`<div class="pkt-loader__spinner">
|
|
8
|
-
<pkt-icon
|
|
9
|
-
name=${this.getVariant(this.variant)}
|
|
10
|
-
path=${this.loadingAnimationPath}
|
|
11
|
-
class="pkt-loader__svg pkt-loader__${this.variant}"
|
|
12
|
-
></pkt-icon>
|
|
13
|
-
${this.message&&e._`<p>${this.message}</p>`}
|
|
14
|
-
</div>`:e.h}
|
|
15
|
-
<div class=${i}>${n.i(this)}</div>
|
|
16
|
-
</div>`}getVariant(e){switch(e){case`blue`:return`spinner-blue`;case`rainbow`:return`spinner`;default:return`loader`}}setupLoader(){this.delay>0&&(this._shouldDisplayLoader=!1,setTimeout(()=>{this._shouldDisplayLoader=!0,this.requestUpdate()},this.delay))}};e.n([e.u({type:Number})],i.prototype,`delay`,void 0),e.n([e.u({type:Boolean})],i.prototype,`inline`,void 0),e.n([e.u({type:Boolean})],i.prototype,`isLoading`,void 0),e.n([e.u({type:String})],i.prototype,`message`,void 0),e.n([e.u({type:String})],i.prototype,`size`,void 0),e.n([e.u({type:String})],i.prototype,`variant`,void 0),e.n([e.u({type:String})],i.prototype,`loadingAnimationPath`,void 0),e.n([e.l()],i.prototype,`_shouldDisplayLoader`,void 0);try{e.d(`pkt-loader`)(i)}catch{console.warn(`Forsøker å definere <pkt-loader>, men den er allerede definert`)}var a=i;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
|