@oslokommune/punkt-elements 19.4.0 → 19.5.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 +13 -0
- package/dist/{accordion-CZ0O4c0_.cjs → accordion-5lSFQToJ.cjs} +6 -6
- package/dist/{accordion-DFcdonl-.js → accordion-BJh6X1Ek.js} +6 -6
- package/dist/{alert-BhvjSA5X.js → alert-C0PiYnot.js} +29 -36
- package/dist/alert-IaZzEgyI.cjs +39 -0
- package/dist/{backlink-Bw6IcRIo.cjs → backlink-BRqhwUr2.cjs} +1 -1
- package/dist/{backlink-DIdgvE2j.js → backlink-BslFewn-.js} +1 -1
- package/dist/{breadcrumbs-BfgCx3Xj.js → breadcrumbs-Cr3GugPv.js} +1 -1
- package/dist/{breadcrumbs-C10K1XLP.cjs → breadcrumbs-DG4i5UCh.cjs} +1 -1
- package/dist/{button-B5rWxfei.js → button-B78im4wB.js} +16 -16
- package/dist/button-BNVTj7nB.cjs +32 -0
- package/dist/{calendar-U8xkRdgF.js → calendar-BLaRXUBl.js} +1 -1
- package/dist/{calendar-D-Ow5DAp.cjs → calendar-TcxvS-1_.cjs} +1 -1
- package/dist/{card-D2YYPZr5.js → card-CYKhPUNI.js} +12 -12
- package/dist/{card-DW1uklP6.cjs → card-CaLEuumN.cjs} +10 -10
- package/dist/{checkbox-C0zLtnCI.cjs → checkbox-DIyi1Cya.cjs} +1 -1
- package/dist/{checkbox-B2O0fkh9.js → checkbox-DKeErDb5.js} +1 -1
- package/dist/{combobox-DpXTwNr4.js → combobox-BKnHg_-E.js} +30 -30
- package/dist/{combobox-BgduqUpf.cjs → combobox-C7FUvv5T.cjs} +22 -22
- package/dist/components/alert/alert.d.ts +0 -2
- package/dist/{consent-CbJG04C1.js → consent-CleJMbVH.js} +1 -1
- package/dist/{consent-DxpJLExu.cjs → consent-Dl-R0iC3.cjs} +1 -1
- package/dist/{datepicker-BLBimRTT.js → datepicker-COFEJpB4.js} +10 -10
- package/dist/{datepicker-53rj_Qqx.cjs → datepicker-CeUpoQuG.cjs} +27 -27
- package/dist/directives/slot-content.d.ts +36 -1
- package/dist/element-with-slot-D7sTqOr3.cjs +1 -0
- package/dist/{element-with-slot-FD826ooP.js → element-with-slot-DQv0cbbD.js} +80 -21
- package/dist/{fileupload-BxfBFhFt.js → fileupload-CUPl41uN.js} +32 -32
- package/dist/{fileupload-4wgr4iAi.cjs → fileupload-CaZGBvZr.cjs} +21 -21
- package/dist/{footer-CBkKAuvh.js → footer-DdLls3F-.js} +14 -14
- package/dist/{footer-DOp_9VdY.cjs → footer-vy9NqT65.cjs} +9 -9
- package/dist/{header-Cs4t2XMM.cjs → header-CgP3-6-b.cjs} +50 -50
- package/dist/{header-CF-Re0nT.js → header-Cq6INZmI.js} +56 -56
- package/dist/{header-menu-C9k9xG9V.js → header-menu-ANj5nL2M.js} +2 -2
- package/dist/{header-menu-BnqZagI6.cjs → header-menu-BfkCp8jw.cjs} +1 -1
- package/dist/{heading-BRHCV_5J.js → heading-CUrZvkrM.js} +1 -1
- package/dist/{heading-u9Arof4p.cjs → heading-zoz-QZJ9.cjs} +1 -1
- package/dist/{helptext-DYgeTMtA.cjs → helptext-BCkwSz1m.cjs} +2 -2
- package/dist/{helptext-sRC8EJqL.js → helptext-DCT_9dw1.js} +2 -2
- package/dist/icon-Dnv6LtPC.cjs +1 -0
- package/dist/{icon-DmRyYNlY.js → icon-JigbxxF7.js} +16 -12
- package/dist/{input-element-B1BntJeJ.js → input-element-5hsxasU3.js} +1 -1
- package/dist/{input-element-W6Gklt2E.cjs → input-element-Ctkz5fQk.cjs} +1 -1
- package/dist/{input-wrapper-CSPPa4uc.cjs → input-wrapper-Cf__-4E-.cjs} +28 -28
- package/dist/{input-wrapper-C1zXIKBU.js → input-wrapper-DACDx6Ie.js} +45 -45
- package/dist/{link-DcxVUj8s.js → link-CmZwAw5u.js} +2 -2
- package/dist/link-LO_5_La8.cjs +7 -0
- package/dist/{linkcard-MJFR7FLT.js → linkcard-CQluSyJJ.js} +8 -8
- package/dist/{linkcard-CWeR6t2a.cjs → linkcard-UKsxADrP.cjs} +3 -3
- package/dist/{listbox-DEzd-dxF.js → listbox-Ct9jIV_5.js} +8 -8
- package/dist/{listbox-BoBwzL4p.cjs → listbox-g-vHHLkD.cjs} +20 -20
- package/dist/{loader-SJ6NauNT.cjs → loader-C_PH05aw.cjs} +2 -2
- package/dist/{loader-CqFQoJlM.js → loader-DzctJ9jW.js} +2 -2
- package/dist/{messagebox-DsKi_rKn.js → messagebox-DPFBuisE.js} +2 -2
- package/dist/messagebox-JWKMJEFc.cjs +13 -0
- package/dist/{modal-DaerHpVi.cjs → modal-BymjMIJi.cjs} +2 -2
- package/dist/{modal-CJqe6y-V.js → modal-CELmA0-8.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-backlink.cjs +1 -1
- package/dist/pkt-backlink.js +1 -1
- package/dist/pkt-breadcrumbs.cjs +1 -1
- package/dist/pkt-breadcrumbs.js +1 -1
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +1 -1
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +1 -1
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +1 -1
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-consent.cjs +1 -1
- package/dist/pkt-consent.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-fileupload.cjs +1 -1
- package/dist/pkt-fileupload.js +1 -1
- package/dist/pkt-footer.cjs +1 -1
- package/dist/pkt-footer.js +1 -1
- package/dist/pkt-header-menu.cjs +1 -1
- package/dist/pkt-header-menu.js +1 -1
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-heading.cjs +1 -1
- package/dist/pkt-heading.js +1 -1
- package/dist/pkt-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +1 -1
- package/dist/pkt-icon.cjs +1 -1
- package/dist/pkt-icon.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +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-listbox.cjs +1 -1
- package/dist/pkt-listbox.js +1 -1
- package/dist/pkt-loader.cjs +1 -1
- package/dist/pkt-loader.js +1 -1
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/{pkt-options-controller-Dz-rYCG1.cjs → pkt-options-controller-CpEZcomb.cjs} +1 -1
- package/dist/{pkt-options-controller-sUzxHa5A.js → pkt-options-controller-D7l18Iw0.js} +1 -1
- package/dist/pkt-progressbar.cjs +1 -1
- package/dist/pkt-progressbar.js +1 -1
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +1 -1
- package/dist/pkt-searchinput.cjs +1 -1
- package/dist/pkt-searchinput.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/pkt-tabs.cjs +1 -1
- package/dist/pkt-tabs.js +1 -1
- package/dist/pkt-tag.cjs +1 -1
- package/dist/pkt-tag.js +1 -1
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +1 -1
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +1 -1
- package/dist/pkt-timepicker.cjs +1 -1
- package/dist/pkt-timepicker.js +1 -1
- package/dist/{progressbar-BrVlAcQI.cjs → progressbar-CIXNSwTy.cjs} +2 -3
- package/dist/{progressbar-Bd0DjiAb.js → progressbar-DH5lIBpx.js} +6 -4
- package/dist/{radiobutton-B0V-jSEX.js → radiobutton-DP791tUe.js} +1 -1
- package/dist/{radiobutton-Cv1BlwLV.cjs → radiobutton-oEYrBiT6.cjs} +1 -1
- package/dist/{searchinput-7-VVdkss.cjs → searchinput-CbClDE-d.cjs} +1 -1
- package/dist/{searchinput-CgzigmiI.js → searchinput-Co8tcq-l.js} +1 -1
- package/dist/{select-BbcGPmPs.js → select-B97S4g1v.js} +18 -18
- package/dist/{select---PCiwmy.cjs → select-QobXCtIL.cjs} +13 -13
- package/dist/shared-types/icon.d.ts +39 -0
- package/dist/shared-types/index.d.ts +2 -0
- package/dist/{tabs-B134M9k2.js → tabs-B8blHQrL.js} +18 -18
- package/dist/{tabs-Dw9E06fL.cjs → tabs-CjX-GWvM.cjs} +15 -15
- package/dist/tag-B5dUg7AD.cjs +27 -0
- package/dist/{tag-wYnHhHLK.js → tag-Bns7Xj1O.js} +11 -11
- package/dist/{textarea-BcgVLLTt.js → textarea-DgW0hRV5.js} +17 -17
- package/dist/{textarea-pA_xv8lI.cjs → textarea-ZMbtZNp3.cjs} +10 -10
- package/dist/{textinput-Czz2affL.cjs → textinput-DfT_1aGb.cjs} +10 -10
- package/dist/{textinput-Dpj1X5yr.js → textinput-s-qz2xSC.js} +15 -15
- package/dist/{timepicker-BwDZkSpo.cjs → timepicker-BAa_VEnf.cjs} +10 -10
- package/dist/{timepicker-CfQMZlaP.js → timepicker-Crj4isb9.js} +16 -16
- package/package.json +2 -2
- package/src/components/alert/alert.test.ts +15 -0
- package/src/components/alert/alert.ts +0 -12
- package/src/components/combobox/combobox.ts +3 -3
- package/src/components/datepicker/datepicker.ts +5 -5
- package/src/components/helptext/helptext-association.test.ts +79 -0
- package/src/components/icon/icon.ts +6 -6
- package/src/components/input-wrapper/input-wrapper.test.ts +49 -0
- package/src/components/input-wrapper/input-wrapper.ts +6 -4
- package/src/components/progressbar/progressbar.test.ts +19 -0
- package/src/components/progressbar/progressbar.ts +2 -6
- package/src/components/select/select.ts +3 -3
- package/src/components/textarea/textarea.ts +3 -3
- package/src/components/textinput/textinput.ts +3 -3
- package/src/components/timepicker/timepicker.ts +3 -3
- package/dist/alert-D1bQjZ7C.cjs +0 -40
- package/dist/button-CmNrMH-c.cjs +0 -32
- package/dist/element-with-slot-2PHu2w7O.cjs +0 -1
- package/dist/icon-CoBsgGUR.cjs +0 -1
- package/dist/link-EMsHusF7.cjs +0 -7
- package/dist/messagebox-D5GYIdjE.cjs +0 -13
- package/dist/tag-HTYKd-iG.cjs +0 -27
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),n=require("./booleanish-BF8l4scU.cjs"),r=require("./fetch-header-footer-data-CUKV0biS.cjs");require("./icon-
|
|
1
|
+
const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),n=require("./booleanish-BF8l4scU.cjs"),r=require("./fetch-header-footer-data-CUKV0biS.cjs");require("./icon-Dnv6LtPC.cjs"),require("./accordion-5lSFQToJ.cjs");var i=class extends e.t{constructor(...e){super(...e),this.dataUrl=r.a,this.locale=`nb-NO`,this.open=!1,this.mobileBreakpoint=768,this.loadState=`idle`,this.isMobile=!1,this.menuWidth=0}connectedCallback(){super.connectedCallback(),this.classList.add(`pkt-header-menu`),this.updateOpenClass(),this.observeWidth(),this.data?(this.loadState=`ready`,this.dispatchEvent(new CustomEvent(`data-loaded`,{detail:{data:this.data},bubbles:!0,composed:!0}))):this.loadData()}updateOpenClass(){this.classList.toggle(`pkt-header-menu--open`,!!this.open)}disconnectedCallback(){super.disconnectedCallback(),this.abortController?.abort(),this.resizeObserver?.disconnect(),this.resizeObserver=void 0}updated(e){super.updated(e),e.has(`open`)&&this.updateOpenClass(),e.has(`mobileBreakpoint`)&&e.get(`mobileBreakpoint`)!==void 0&&this.refreshIsMobile(),e.has(`dataUrl`)&&e.get(`dataUrl`)!==void 0&&!this.data&&this.loadData(),e.has(`data`)&&e.get(`data`)!==void 0&&this.data&&(this.loadState=`ready`,this.dispatchEvent(new CustomEvent(`data-loaded`,{detail:{data:this.data},bubbles:!0,composed:!0})))}observeWidth(){typeof ResizeObserver>`u`||(this.menuWidth=this.offsetWidth,this.refreshIsMobile(),this.resizeObserver=new ResizeObserver(e=>{for(let t of e)this.menuWidth=t.borderBoxSize&&t.borderBoxSize.length>0?t.borderBoxSize[0].inlineSize:t.contentRect.width,this.refreshIsMobile()}),this.resizeObserver.observe(this))}refreshIsMobile(){this.isMobile=this.menuWidth<this.mobileBreakpoint}async loadData(){this.abortController?.abort(),this.abortController=new AbortController,this.loadState=`loading`;try{let e=await r.t(this.dataUrl,this.abortController.signal);this.fetchedData=e,this.loadState=`ready`,this.dispatchEvent(new CustomEvent(`data-loaded`,{detail:{data:e},bubbles:!0,composed:!0}))}catch(e){if(e.name===`AbortError`)return;this.loadState=`error`,this.dispatchEvent(new CustomEvent(`data-error`,{detail:{error:e},bubbles:!0,composed:!0}))}}get effectiveData(){return this.data??this.fetchedData}get localeData(){return r.n(this.effectiveData,this.locale)}render(){if(this.loadState===`loading`)return e._`
|
|
2
2
|
<nav aria-busy="true">
|
|
3
3
|
<p class="pkt-header-menu__loading">${this.pktStrings.get(`header`).menuLoading}</p>
|
|
4
4
|
</nav>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as e, d as t, n, u as r } from "./element-mwwC2Rra.js";
|
|
2
|
-
import {
|
|
2
|
+
import { i, t as a } from "./element-with-slot-DQv0cbbD.js";
|
|
3
3
|
//#region src/components/heading/heading.ts
|
|
4
4
|
var o = class extends a {
|
|
5
5
|
constructor(...e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./element-BOmr9YLv.cjs"),t=require("./element-with-slot-
|
|
1
|
+
const e=require("./element-BOmr9YLv.cjs"),t=require("./element-with-slot-D7sTqOr3.cjs");var n=class extends t.t{constructor(...e){super(...e),this.size=void 0,this.level=2,this.weight=void 0,this.visuallyHidden=!1,this.align=void 0}willUpdate(e){super.willUpdate(e),e.has(`level`)&&(this.level<1||this.level>6)&&console.warn(`Invalid heading level: ${this.level}. Must be between 1 and 6.`),this.size===void 0&&(this.size=this.defaultSizeForLevel),this.weight===void 0&&(this.weight=this.defaultWeightForLevel)}get defaultSizeForLevel(){switch(this.level){case 1:return`xlarge`;case 2:return`large`;case 3:return`medium`;case 4:return`small`;case 5:case 6:return`xsmall`;default:return`medium`}}get defaultWeightForLevel(){switch(this.level){case 1:case 2:return`regular`;case 3:case 4:case 5:case 6:return`medium`;default:return`medium`}}get headingClasses(){return[`pkt-heading`,this.size&&`pkt-heading--${this.size}`,this.weight&&`pkt-heading--fw-${this.weight}`,this.visuallyHidden&&`pkt-sr-only`,this.align&&`pkt-heading--${this.align}`].filter(Boolean).join(` `)}render(){let n=this.headingClasses,r=t.i(this);switch(this.level>=1&&this.level<=6?this.level:2){case 1:return e._`<h1 class=${n}>${r}</h1>`;case 2:return e._`<h2 class=${n}>${r}</h2>`;case 3:return e._`<h3 class=${n}>${r}</h3>`;case 4:return e._`<h4 class=${n}>${r}</h4>`;case 5:return e._`<h5 class=${n}>${r}</h5>`;case 6:return e._`<h6 class=${n}>${r}</h6>`;default:return e._`<h2 class=${n}>${r}</h2>`}}};e.n([e.u({type:String,reflect:!0})],n.prototype,`size`,void 0),e.n([e.u({type:Number,reflect:!0})],n.prototype,`level`,void 0),e.n([e.u({type:String,reflect:!0})],n.prototype,`weight`,void 0),e.n([e.u({type:Boolean,reflect:!0})],n.prototype,`visuallyHidden`,void 0),e.n([e.u({type:String,reflect:!0})],n.prototype,`align`,void 0);try{e.d(`pkt-heading`)(n)}catch{console.warn(`Forsøker å definere <pkt-heading>, men den er allerede definert`)}var r=n;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),n=require("./element-with-slot-
|
|
1
|
+
const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),n=require("./element-with-slot-D7sTqOr3.cjs"),r=require("./icon-Dnv6LtPC.cjs"),i=require("./utils-63cRpWut.cjs");var a=class extends n.t{constructor(...e){super(...e),this.forId=i.n(),this.helptext=``,this.helptextDropdown=``,this.isHelpTextOpen=!1}render(){let i=()=>{let e=!this.isHelpTextOpen;this.isHelpTextOpen=e,this.dispatchEvent(new CustomEvent(`toggleHelpText`,{bubbles:!0,detail:{isOpen:e}}))},a=t.t({"pkt-inputwrapper__helptext-container":!0,"pkt-inputwrapper__has-helptext":this.helptext||this.helptextDropdown||this.hasSlotContent()});return e._`${e._`<div class="${a}">
|
|
2
2
|
<div class="pkt-inputwrapper__helptext" id="${this.forId}-helptext">
|
|
3
|
-
<div class="pkt-contents">${n.
|
|
3
|
+
<div class="pkt-contents">${n.i(this)}</div>
|
|
4
4
|
${this.helptext?e._`<span>${r.r(this.helptext)}</span>`:e.h}
|
|
5
5
|
</div>
|
|
6
6
|
${this.helptextDropdown?e._`<div class="pkt-inputwrapper__helptext-expandable">
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-mwwC2Rra.js";
|
|
2
2
|
import { t as o } from "./class-map-C4hdfSfY.js";
|
|
3
|
-
import {
|
|
4
|
-
import { r as l } from "./icon-
|
|
3
|
+
import { i as s, t as c } from "./element-with-slot-DQv0cbbD.js";
|
|
4
|
+
import { r as l } from "./icon-JigbxxF7.js";
|
|
5
5
|
import { n as u } from "./utils-BwF4QSrq.js";
|
|
6
6
|
//#region src/components/helptext/helptext.ts
|
|
7
7
|
var d = class extends c {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./element-BOmr9YLv.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=typeof Storage<`u`&&typeof sessionStorage<`u`,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}});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { _ as e, d as t, f as n, g as r, h as i, m as a, n as o, p as s, t as c, u as l } from "./element-mwwC2Rra.js";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
var u = {
|
|
3
|
+
name: "",
|
|
4
|
+
path: "https://punkt-cdn.oslo.kommune.no/latest/icons/"
|
|
5
|
+
}, d = class extends s {
|
|
4
6
|
constructor(e) {
|
|
5
7
|
if (super(e), this.it = i, e.type !== a.CHILD) throw Error(this.constructor.directiveName + "() can only be used in child bindings");
|
|
6
8
|
}
|
|
@@ -18,11 +20,13 @@ var u = class extends s {
|
|
|
18
20
|
};
|
|
19
21
|
}
|
|
20
22
|
};
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
-
|
|
23
|
+
d.directiveName = "unsafeHTML", d.resultType = 1;
|
|
24
|
+
var f = n(d), p = class extends d {};
|
|
25
|
+
p.directiveName = "unsafeSVG", p.resultType = 2;
|
|
26
|
+
var m = n(p);
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/components/icon/icon.ts
|
|
29
|
+
typeof window < "u" && (window.pktFetch = window.pktFetch === void 0 ? fetch : window.pktFetch, window.pktIconPath = window.pktIconPath || u.path);
|
|
26
30
|
var h = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\"></svg>", g = {}, _ = 2, v = 1500, y = typeof Storage < "u" && typeof sessionStorage < "u", b = (e) => window.pktFetch(e).then((t) => {
|
|
27
31
|
if (!t.ok) throw Error("Missing icon: " + e);
|
|
28
32
|
return t.text();
|
|
@@ -37,7 +41,7 @@ var h = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\"></svg>"
|
|
|
37
41
|
return y && sessionStorage.getItem(n) ? sessionStorage.getItem(n) : n in g ? g[n] : typeof window < "u" && typeof window.pktFetch == "function" ? (g[n] = x(n).then((e) => (e !== h && y && sessionStorage.setItem(n, e), delete g[n], e)), g[n]) : h;
|
|
38
42
|
}, C = class extends c {
|
|
39
43
|
constructor(...e) {
|
|
40
|
-
super(...e), this.path = typeof window < "u" ? window.pktIconPath :
|
|
44
|
+
super(...e), this.path = typeof window < "u" ? window.pktIconPath : u.path, this.name = u.name, this.ariaHidden = null, this.ariaLabel = null, this.icon = m(h), this._updatedProps = [];
|
|
41
45
|
}
|
|
42
46
|
get effectiveAriaHidden() {
|
|
43
47
|
return this.ariaHidden !== null && this.ariaHidden !== void 0 ? this.ariaHidden === "" || this.ariaHidden === "true" : !this.ariaLabel;
|
|
@@ -63,11 +67,11 @@ var h = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\"></svg>"
|
|
|
63
67
|
}
|
|
64
68
|
async getIcon(e = "") {
|
|
65
69
|
if (this._updatedProps.length > 0) {
|
|
66
|
-
this.path ||= typeof window < "u" ? window.pktIconPath :
|
|
70
|
+
this.path ||= typeof window < "u" ? window.pktIconPath : u.path;
|
|
67
71
|
try {
|
|
68
|
-
this.icon =
|
|
72
|
+
this.icon = m(await S(this.name || "", this.path));
|
|
69
73
|
} catch {
|
|
70
|
-
this.icon =
|
|
74
|
+
this.icon = m(h);
|
|
71
75
|
}
|
|
72
76
|
this._updatedProps = [];
|
|
73
77
|
} else this._updatedProps.includes(e) || this._updatedProps.push(e);
|
|
@@ -103,4 +107,4 @@ try {
|
|
|
103
107
|
//#region src/components/icon/index.ts
|
|
104
108
|
var w = C;
|
|
105
109
|
//#endregion
|
|
106
|
-
export { C as n,
|
|
110
|
+
export { C as n, f as r, w as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as e, u as t } from "./element-mwwC2Rra.js";
|
|
2
2
|
import { t as n } from "./format-BTeSVkED.js";
|
|
3
|
-
import { t as r } from "./element-with-slot-
|
|
3
|
+
import { t as r } from "./element-with-slot-DQv0cbbD.js";
|
|
4
4
|
import { n as i, t as a } from "./booleanish-OQJTYSrw.js";
|
|
5
5
|
import { n as o } from "./utils-BwF4QSrq.js";
|
|
6
6
|
//#region ../../node_modules/element-internals-polyfill/dist/maps.js
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./element-BOmr9YLv.cjs"),t=require("./format-B8meU8Tm.cjs"),n=require("./element-with-slot-2PHu2w7O.cjs"),r=require("./booleanish-BF8l4scU.cjs"),i=require("./utils-63cRpWut.cjs");var a=new WeakMap,o=new WeakMap,s=new WeakMap,c=new WeakMap,l=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakMap,p=new WeakMap,m=new WeakMap,h=new WeakMap,g=new WeakMap,_=new WeakMap,v=new WeakMap,y=new WeakMap,b=(e,t,n)=>{e.getAttribute(t)!==n&&e.setAttribute(t,n)},x=(e,t)=>{e.toggleAttribute(`internals-disabled`,t),t?b(e,`aria-disabled`,`true`):e.removeAttribute(`aria-disabled`),e.formDisabledCallback&&e.formDisabledCallback.apply(e,[t])},S=e=>{s.get(e).forEach(e=>{e.remove()}),s.set(e,[])},C=(e,t)=>{let n=document.createElement(`input`);return n.type=`hidden`,n.name=e.getAttribute(`name`),e.after(n),s.get(t).push(n),n},w=(e,t)=>{if(t.length){let n=Array.from(t);n.forEach(t=>t.addEventListener(`click`,e.click.bind(e)));let[r]=n,i=r.id;r.id||=(i=`${r.htmlFor}_Label`,i),b(e,`aria-labelledby`,i)}},T=e=>{let t=Array.from(e.elements).filter(e=>!e.tagName.includes(`-`)&&e.validity).map(e=>e.validity.valid),n=f.get(e)||[],r=Array.from(n).filter(e=>e.isConnected).map(e=>c.get(e).validity.valid),i=[...t,...r].includes(!1);e.toggleAttribute(`internals-invalid`,i),e.toggleAttribute(`internals-valid`,!i)},ee=e=>{T(O(e.target))},E=e=>{T(O(e.target))},te=e=>{let t=[`button[type=submit]`,`input[type=submit]`,`button:not([type])`].map(e=>`${e}:not([disabled])`).map(t=>`${t}:not([form])${e.id?`,${t}[form='${e.id}']`:``}`).join(`,`);e.addEventListener(`click`,n=>{if(n.target.closest(t)){let t=f.get(e);if(e.noValidate)return;t.size&&Array.from(t).reverse().map(e=>c.get(e).reportValidity()).includes(!1)&&n.preventDefault()}})},ne=e=>{let t=f.get(e.target);t&&t.size&&t.forEach(e=>{e.constructor.formAssociated&&e.formResetCallback&&e.formResetCallback.apply(e)})},D=(e,t,n)=>{if(t){let r=f.get(t);if(r)r.add(e);else{let n=new Set;n.add(e),f.set(t,n),te(t),t.addEventListener(`reset`,ne),t.addEventListener(`input`,ee),t.addEventListener(`change`,E)}u.set(t,{ref:e,internals:n}),e.constructor.formAssociated&&e.formAssociatedCallback&&setTimeout(()=>{e.formAssociatedCallback.apply(e,[t])},0),T(t)}},O=e=>{let t=e.parentNode;return t&&t.tagName!==`FORM`&&(t=O(t)),t},k=(e,t,n=DOMException)=>{if(!e.constructor.formAssociated)throw new n(t)},A=(e,t,n)=>{let r=f.get(e);return r&&r.size&&r.forEach(e=>{c.get(e)[n]()||(t=!1)}),t},j=e=>{let t=!1;if(e.constructor.formAssociated){let n=c.get(e);n===void 0&&(e.attachInternals(),n=c.get(e),t=!0);let{labels:r,form:i}=n;w(e,r),D(e,i,n)}return t};function M(){return typeof MutationObserver<`u`}var N={ariaAtomic:`aria-atomic`,ariaAutoComplete:`aria-autocomplete`,ariaBrailleLabel:`aria-braillelabel`,ariaBrailleRoleDescription:`aria-brailleroledescription`,ariaBusy:`aria-busy`,ariaChecked:`aria-checked`,ariaColCount:`aria-colcount`,ariaColIndex:`aria-colindex`,ariaColIndexText:`aria-colindextext`,ariaColSpan:`aria-colspan`,ariaCurrent:`aria-current`,ariaDescription:`aria-description`,ariaDisabled:`aria-disabled`,ariaExpanded:`aria-expanded`,ariaHasPopup:`aria-haspopup`,ariaHidden:`aria-hidden`,ariaInvalid:`aria-invalid`,ariaKeyShortcuts:`aria-keyshortcuts`,ariaLabel:`aria-label`,ariaLevel:`aria-level`,ariaLive:`aria-live`,ariaModal:`aria-modal`,ariaMultiLine:`aria-multiline`,ariaMultiSelectable:`aria-multiselectable`,ariaOrientation:`aria-orientation`,ariaPlaceholder:`aria-placeholder`,ariaPosInSet:`aria-posinset`,ariaPressed:`aria-pressed`,ariaReadOnly:`aria-readonly`,ariaRelevant:`aria-relevant`,ariaRequired:`aria-required`,ariaRoleDescription:`aria-roledescription`,ariaRowCount:`aria-rowcount`,ariaRowIndex:`aria-rowindex`,ariaRowIndexText:`aria-rowindextext`,ariaRowSpan:`aria-rowspan`,ariaSelected:`aria-selected`,ariaSetSize:`aria-setsize`,ariaSort:`aria-sort`,ariaValueMax:`aria-valuemax`,ariaValueMin:`aria-valuemin`,ariaValueNow:`aria-valuenow`,ariaValueText:`aria-valuetext`,role:`role`},P=(e,t)=>{for(let n in N){t[n]=null;let r=null,i=N[n];Object.defineProperty(t,n,{get(){return r},set(n){r=n,e.isConnected?b(e,i,n):m.set(e,t)}})}},re=(e,t)=>{s.set(t,[]),R.observe?.(e,L)};function F(e){let t=c.get(e),{form:n}=t;D(e,n,t),w(e,t.labels)}var I=(e,t=!1)=>{let n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(e){return c.has(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}}),r=n.nextNode(),i=!t||e.disabled;for(;r;)r.formDisabledCallback&&i&&x(r,e.disabled),r=n.nextNode()},L={attributes:!0,attributeFilter:[`disabled`,`name`]},R=M()?new MutationObserver(e=>{for(let t of e){let e=t.target;if(t.attributeName===`disabled`&&(e.constructor.formAssociated?x(e,e.hasAttribute(`disabled`)):e.localName===`fieldset`&&I(e)),t.attributeName===`name`&&e.constructor.formAssociated){let t=c.get(e),n=p.get(e);t.setFormValue(n)}}}):{};function z(e){e.forEach(e=>{let{addedNodes:t,removedNodes:n}=e,r=Array.from(t),i=Array.from(n);r.forEach(e=>{if(c.has(e)&&e.constructor.formAssociated&&F(e),m.has(e)){let t=m.get(e);Object.keys(N).filter(e=>t[e]!==null).forEach(n=>{b(e,N[n],t[n])}),m.delete(e)}if(y.has(e)){let t=y.get(e);b(e,`internals-valid`,t.validity.valid.toString()),b(e,`internals-invalid`,(!t.validity.valid).toString()),b(e,`aria-invalid`,(!t.validity.valid).toString()),y.delete(e)}if(e.localName===`form`){let t=f.get(e),n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(e){return c.has(e)&&e.constructor.formAssociated&&!(t&&t.has(e))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}}),r=n.nextNode();for(;r;)F(r),r=n.nextNode()}e.localName===`fieldset`&&(R.observe?.(e,L),I(e,!0))}),i.forEach(e=>{let t=c.get(e);t&&s.get(t)&&S(t),d.has(e)&&d.get(e).disconnect()})})}function ie(e){e.forEach(e=>{let{removedNodes:t}=e;t.forEach(t=>{let n=_.get(e.target);c.has(t)&&j(t),n.disconnect()})})}var ae=e=>{let t=new MutationObserver(ie);window?.ShadyDOM?.inUse&&e.mode&&e.host&&(e=e.host),t.observe?.(e,{childList:!0}),_.set(e,t)};M()&&new MutationObserver(z);var B={childList:!0,subtree:!0},oe=class{constructor(){this.badInput=!1,this.customError=!1,this.patternMismatch=!1,this.rangeOverflow=!1,this.rangeUnderflow=!1,this.stepMismatch=!1,this.tooLong=!1,this.tooShort=!1,this.typeMismatch=!1,this.valid=!0,this.valueMissing=!1,Object.seal(this)}},se=e=>(e.badInput=!1,e.customError=!1,e.patternMismatch=!1,e.rangeOverflow=!1,e.rangeUnderflow=!1,e.stepMismatch=!1,e.tooLong=!1,e.tooShort=!1,e.typeMismatch=!1,e.valid=!0,e.valueMissing=!1,e),ce=(e,t,n)=>(e.valid=le(t),Object.keys(t).forEach(n=>e[n]=t[n]),n&&T(n),e),le=e=>{let t=!0;for(let n in e)n!==`valid`&&e[n]!==!1&&(t=!1);return t},V=new WeakMap;function H(e,t){e.toggleAttribute(t,!0),e.part&&e.part.add(t)}var U=class extends Set{static get isPolyfilled(){return!0}constructor(e){if(super(),!e||!e.tagName||e.tagName.indexOf(`-`)===-1)throw TypeError(`Illegal constructor`);V.set(this,e)}add(e){if(!/^--/.test(e)||typeof e!=`string`)throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${e} must start with '--'.`);let t=super.add(e),n=V.get(this),r=`state${e}`;return n.isConnected?H(n,r):setTimeout(()=>{H(n,r)}),t}clear(){for(let[e]of this.entries())this.delete(e);super.clear()}delete(e){let t=super.delete(e),n=V.get(this);return n.isConnected?(n.toggleAttribute(`state${e}`,!1),n.part&&n.part.remove(`state${e}`)):setTimeout(()=>{n.toggleAttribute(`state${e}`,!1),n.part&&n.part.remove(`state${e}`)}),t}},ue=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},W=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},G,de=class{constructor(e){G.set(this,void 0),ue(this,G,e,`f`);for(let t=0;t<e.length;t++){let n=e[t];this[t]=n,n.hasAttribute(`name`)&&(this[n.getAttribute(`name`)]=n)}Object.freeze(this)}get length(){return W(this,G,`f`).length}[(G=new WeakMap,Symbol.iterator)](){return W(this,G,`f`)[Symbol.iterator]()}item(e){return this[e]==null?null:this[e]}namedItem(e){return this[e]==null?null:this[e]}};function fe(){let e=HTMLFormElement.prototype.checkValidity;HTMLFormElement.prototype.checkValidity=n;let t=HTMLFormElement.prototype.reportValidity;HTMLFormElement.prototype.reportValidity=r;function n(...t){let n=e.apply(this,t);return A(this,n,`checkValidity`)}function r(...e){let n=t.apply(this,e);return A(this,n,`reportValidity`)}let{get:i}=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,`elements`);Object.defineProperty(HTMLFormElement.prototype,"elements",{get(...e){let t=i.call(this,...e),n=Array.from(f.get(this)||[]);return n.length===0?t:new de(Array.from(t).concat(n).sort((e,t)=>e.compareDocumentPosition?e.compareDocumentPosition(t)&2?1:-1:0))}})}var K=class{static get isPolyfilled(){return!0}constructor(e){if(!e||!e.tagName||e.tagName.indexOf(`-`)===-1)throw TypeError(`Illegal constructor`);let t=e.getRootNode(),n=new oe;this.states=new U(e),a.set(this,e),o.set(this,n),c.set(e,this),P(e,this),re(e,this),Object.seal(this),t instanceof DocumentFragment&&ae(t)}checkValidity(){let e=a.get(this);if(k(e,`Failed to execute 'checkValidity' on 'ElementInternals': The target element is not a form-associated custom element.`),!this.willValidate)return!0;let t=o.get(this);if(!t.valid){let t=new Event(`invalid`,{bubbles:!1,cancelable:!0,composed:!1});e.dispatchEvent(t)}return t.valid}get form(){let e=a.get(this);k(e,`Failed to read the 'form' property from 'ElementInternals': The target element is not a form-associated custom element.`);let t;return e.constructor.formAssociated===!0&&(t=O(e)),t}get labels(){let e=a.get(this);k(e,`Failed to read the 'labels' property from 'ElementInternals': The target element is not a form-associated custom element.`);let t=e.getAttribute(`id`),n=e.getRootNode();return n&&t?n.querySelectorAll(`[for="${t}"]`):[]}reportValidity(){let e=a.get(this);if(k(e,`Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.`),!this.willValidate)return!0;let t=this.checkValidity(),n=g.get(this);if(n&&!e.constructor.formAssociated)throw new DOMException(`Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.`);return!t&&n&&(e.focus(),n.focus()),t}setFormValue(e){let t=a.get(this);if(k(t,`Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element.`),S(this),e!=null&&!(e instanceof FormData)){if(t.getAttribute(`name`)){let n=C(t,this);n.value=e}}else e!=null&&e instanceof FormData&&Array.from(e).reverse().forEach(([e,n])=>{if(typeof n==`string`){let r=C(t,this);r.name=e,r.value=n}});p.set(t,e)}setValidity(e,t,n){let r=a.get(this);if(k(r,`Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element.`),!e)throw TypeError(`Failed to execute 'setValidity' on 'ElementInternals': 1 argument required, but only 0 present.`);g.set(this,n);let i=o.get(this),s={};for(let t in e)s[t]=e[t];Object.keys(s).length===0&&se(i);let c={...i,...s};delete c.valid;let{valid:u}=ce(i,c,this.form);if(!u&&!t)throw new DOMException(`Failed to execute 'setValidity' on 'ElementInternals': The second argument should not be empty if one or more flags in the first argument are true.`);l.set(this,u?``:t),r.isConnected?(r.toggleAttribute(`internals-invalid`,!u),r.toggleAttribute(`internals-valid`,u),b(r,`aria-invalid`,`${!u}`)):y.set(r,this)}get shadowRoot(){let e=a.get(this);return h.get(e)||null}get validationMessage(){return k(a.get(this),`Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element.`),l.get(this)}get validity(){return k(a.get(this),`Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element.`),o.get(this)}get willValidate(){let e=a.get(this);return k(e,`Failed to read the 'willValidate' property from 'ElementInternals': The target element is not a form-associated custom element.`),!(e.matches(`:disabled`)||e.disabled||e.hasAttribute(`disabled`)||e.hasAttribute(`readonly`))}};function pe(){if(typeof window>`u`||!window.ElementInternals||!HTMLElement.prototype.attachInternals)return!1;class e extends HTMLElement{constructor(){super(),this.internals=this.attachInternals()}}let t=`element-internals-feature-detection-${Math.random().toString(36).replace(/[^a-z]+/g,``)}`;customElements.define(t,e);let n=new e;return[`shadowRoot`,`form`,`willValidate`,`validity`,`validationMessage`,`labels`,`setFormValue`,`setValidity`,`checkValidity`,`reportValidity`].every(e=>e in n.internals)}var q=!1,J=!1;function Y(e){J||(J=!0,window.CustomStateSet=U,e&&(HTMLElement.prototype.attachInternals=function(...t){let n=e.call(this,t);return n.states=new U(this),n}))}function me(e=!0){let t=!1;if(!q){if(q=!0,typeof window<`u`&&(window.ElementInternals=K),typeof CustomElementRegistry<`u`){let e=CustomElementRegistry.prototype.define;CustomElementRegistry.prototype.define=function(n,r,i){if(r.formAssociated){let e=r.prototype.connectedCallback;r.prototype.connectedCallback=function(){v.has(this)||(v.set(this,!0),this.hasAttribute(`disabled`)&&x(this,!0)),e?.apply(this),t=j(this)}}e.call(this,n,r,i)}}if(typeof HTMLElement<`u`&&(HTMLElement.prototype.attachInternals=function(){if(!this.tagName)return{};if(this.tagName.indexOf(`-`)===-1)throw Error(`Failed to execute 'attachInternals' on 'HTMLElement': Unable to attach ElementInternals to non-custom elements.`);if(c.has(this)&&!t)throw new DOMException(`DOMException: Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.`);return new K(this)}),typeof Element<`u`){function n(...t){let n=e.apply(this,t);if(h.set(this,n),M()){let e=new MutationObserver(z);window.ShadyDOM?e.observe(this,B):e.observe(n,B),d.set(this,e)}return n}let e=Element.prototype.attachShadow;Element.prototype.attachShadow=n}M()&&typeof document<`u`&&new MutationObserver(z).observe(document.documentElement,B),typeof HTMLFormElement<`u`&&fe(),(e||typeof window<`u`&&!window.CustomStateSet)&&Y()}}customElements.polyfillWrapFlushCallback||(pe()?typeof window<`u`&&!window.CustomStateSet&&Y(HTMLElement.prototype.attachInternals):me(!1));var X=`on`,Z=`--checked`,Q=`,`,$=class extends n.t{static get formAssociated(){return!0}get form(){let e=this.getAttribute(`form`);if(e!==null){if(!e)return null;let t=this.getRootNode(),n=typeof t.getElementById==`function`?t.getElementById(e):this.ownerDocument?.getElementById(e);return n instanceof HTMLFormElement?n:null}return this.internals?.form??this.closest(`form`)}get ariaDescribedBy(){return this.ariaDescribedby}set ariaDescribedBy(e){this.ariaDescribedby=e}effectiveCounter(e){return this.counter??e}effectiveHasFieldset(e){return this.hasFieldset??e}constructor(){super(),this.defaultValue=null,this.disabled=!1,this.readonly=!1,this.required=!1,this.max=null,this.maxlength=null,this.min=null,this.minlength=null,this.step=null,this.ariaDescribedby=null,this.ariaLabelledby=null,this.name=``,this.pattern=null,this.placeholder=null,this.id=i.n(),this.counter=null,this.hasError=!1,this.inline=!1,this.hasFieldset=null,this.optionalTag=!1,this.requiredTag=!1,this.skipForwardTestid=!1,this.useWrapper=!0,this.fullwidth=!1,this.counterMaxLength=0,this.errorMessage=``,this.helptext=``,this.helptextDropdown=``,this.helptextDropdownButton=null,this.label=null,this.tagText=null,this.inputSize=`medium`,this.dataTestid=``,this.touched=!1,this._initialized=!1,this._didInitDerivedState=!1,this.internals=this.attachInternals()}manageValidity(e){if(!e){console.warn(`manageValidity called without valid input element`);return}let n=this.pktStrings.get(`validation`);this.required&&!this.value?this.internals.setValidity({valueMissing:!0},n.valueMissing,e):e.validity?.typeMismatch||e.validity?.badInput?this.internals.setValidity({typeMismatch:!0},n.typeMismatch,e):e.validity?.patternMismatch?this.internals.setValidity({patternMismatch:!0},n.patternMismatch,e):e.validity?.tooShort||this.minlength&&this.minlength>0&&this.value.length<this.minlength?this.internals.setValidity({tooShort:!0},n.tooShort,e):e.validity?.tooLong||this.maxlength&&this.maxlength>0&&this.value.length>this.maxlength?this.internals.setValidity({tooLong:!0},n.tooLong,e):e.validity?.rangeUnderflow?this.internals.setValidity({rangeUnderflow:!0},this.min?t.t(n.rangeUnderflowMin,{min:this.min.toString()}):n.rangeUnderflow,e):e.validity?.stepMismatch?this.internals.setValidity({stepMismatch:!0},n.typeMismatch,e):e.validity?.rangeOverflow?this.internals.setValidity({rangeOverflow:!0},this.max?t.t(n.rangeOverflowMax,{max:this.max.toString()}):n.rangeOverflow,e):e.validity?.customError?this.internals.setValidity({customError:!0},e.validationMessage,e):this.internals.setValidity({})}setFormValue(e){if(this.internals){if(Array.isArray(e)){let t=new FormData;e.forEach(e=>{t.append(this.name,e)}),this.internals.setFormValue(t)}else this.internals.setFormValue(e)}}radioGroupMembers(){let e=this.getRootNode();if(typeof e.querySelectorAll!=`function`)return[];let t=this.form;return Array.from(e.querySelectorAll(`pkt-radiobutton, input[type="radio"]`)).filter(e=>e!==this&&e.getAttribute(`name`)===this.name&&e.form===t)}coordinateRadioGroup(){!this.name||this.type!==`radio`||this.radioGroupMembers().forEach(e=>{if(e.getAttribute(`value`)===this.value)return;let t=e;t.checked&&(t.checked=!1,t.internals&&(t.internals.setFormValue(null),t.internals.states?.delete(Z)))})}valueChecked(e){if(this.touched){if(this.type===`radio`&&this.coordinateRadioGroup(),typeof e==`string`?(this.checked=e===`true`,this.internals.ariaChecked=String(e===`true`)):typeof e==`boolean`&&(this.checked=e,this.internals.ariaChecked=String(e)),this.checked){let e=(typeof this.value==`string`?this.value:``)||X;this.internals.setFormValue(e),this.internals.states.add(Z)}else this.internals.setFormValue(null),this.internals.states.delete(Z);this.dispatchChangeEvents(this.checked),this.internals.reportValidity()}}valueChanged(e,t){let n=e;if(typeof n==`number`||typeof n==`boolean`)e=String(n);else if(n!=null&&typeof n!=`string`&&!Array.isArray(n)){let e=typeof n==`object`?n?.constructor?.name??`object`:typeof n;console.warn(`${this.localName}: value må være en streng eller et tall, men fikk ${e}. Verdien ignoreres. For dato-/tidsfelt, send en ISO-formatert streng (f.eks. "2026-07-09" eller "13:45").`)}(t!==this.value||t!==this._value)&&(typeof e==`string`?((this.multiple||this.range)&&e.includes(Q)&&(e=e.split(Q)),this.value=e,this._value=Array.isArray(e)?e:[e]):Array.isArray(e)?(this.value=this.multiple||this.range?e:e[0],this._value=e):(this.value=``,this._value=[]),(!this.value||this.value.length===0)&&t&&t.length!==0?this.clearInputValue():this.value&&this.value.toString()!==t?.toString()&&this.onChange(this.value))}dispatchChangeEvents(e){this.dispatchEvent(new Event(`change`,{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`value-change`,{detail:e,bubbles:!0,composed:!0}))}clearInputValue(){let e=this.multiple||this.range?[]:``;this.value=e,this.setFormValue(e),this.dispatchChangeEvents(e)}onFocus(){this.dispatchEvent(new FocusEvent(`focus`,{bubbles:!0,composed:!0}))}onBlur(){this.dispatchEvent(new FocusEvent(`blur`,{bubbles:!0,composed:!0}))}onInput(){this.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0}))}normalizeValue(e){return(this.range||this.multiple)&&typeof e==`string`&&e.includes(Q)?e.split(Q):!this.multiple&&!this.range&&Array.isArray(e)?e[0]||``:e}validate(){this.inputRef?.value&&this.manageValidity(this.inputRef.value),this.inputRefTo?.value&&this.manageValidity(this.inputRefTo.value)}onChange(e){if(this.touched=!0,typeof e!=`string`&&!Array.isArray(e))return;let t=this.normalizeValue(e);this.setFormValue(t),this.validate(),this._initialized&&this.dispatchChangeEvents(t)}formResetCallback(){if(this.touched=!1,this._options&&this._options.length&&this._options.forEach(e=>{`selected`in e&&(e.selected=!1)}),this.checked!==void 0)this.checked=!1,this.internals.ariaChecked=`false`,this.internals.setFormValue(``),this.inputRef?.value&&`checked`in this.inputRef.value&&(this.inputRef.value.checked=!1),this.valueChecked(this.checked);else{this.internals.setFormValue(``);let e=this.defaultValue||(this.multiple||this.range?[]:``);this.value=e,this._value=Array.isArray(e)?e:[e],this.valueChanged(this.value,null)}this.internals.ariaInvalid=`false`}updated(e){super.updated(e),e.has(`dataTestid`)&&this.dataTestid&&this.inputRef.value&&(this.skipForwardTestid?this.hasAttribute(`data-testid`)||this.setAttribute(`data-testid`,this.dataTestid):(this.inputRef.value.dataset.testid=this.dataTestid,this.removeAttribute(`data-testid`)))}willUpdate(e){super.willUpdate(e),!this._didInitDerivedState&&(this._didInitDerivedState=!0,this.defaultChecked&&(this.checked=!0),this.id&&!this.name&&(this.name=this.id),this.value&&this.defaultValue===null&&(this.defaultValue=this.value),this.defaultValue!==null&&!this.value&&this.valueChanged(this.defaultValue,null))}firstUpdated(e){if(super.firstUpdated(e),this.value&&this.defaultValue===null&&(this.defaultValue=this.value),this.defaultValue!==null&&!this.value&&this.valueChanged(this.defaultValue,null),this.defaultChecked&&(this.internals.ariaChecked=`true`),this.required&&(this.internals.ariaRequired=`true`),this.disabled&&(this.internals.ariaDisabled=`true`),this.checked!==void 0){let e=this.checked===``||this.checked===`true`||this.checked===!0;this.internals.ariaChecked=String(e);let t=e?(typeof this.value==`string`?this.value:``)||X:null;this.internals.setFormValue(t)}else this.setFormValue(this.value);this.inputRef&&this.inputRef.value&&(this.inputRef.value.setAttribute(`form`,``),this.manageValidity(this.inputRef.value)),this.inputRefTo&&this.inputRefTo.value&&(this.inputRefTo.value.setAttribute(`form`,``),this.manageValidity(this.inputRefTo.value)),this.updateComplete.then(()=>{this._initialized=!0})}};e.n([e.u({type:Boolean,reflect:!0})],$.prototype,`checked`,void 0),e.n([e.u({type:Boolean})],$.prototype,`defaultChecked`,void 0),e.n([e.u({type:Boolean})],$.prototype,`multiple`,void 0),e.n([e.u({type:Boolean})],$.prototype,`range`,void 0),e.n([e.u({type:String,reflect:!0})],$.prototype,`type`,void 0),e.n([e.u()],$.prototype,`defaultValue`,void 0),e.n([e.u({type:Boolean,reflect:!0})],$.prototype,`disabled`,void 0),e.n([e.u({type:Boolean,reflect:!0})],$.prototype,`readonly`,void 0),e.n([e.u({type:Boolean,reflect:!0})],$.prototype,`required`,void 0),e.n([e.u({reflect:!0,converter:{fromAttribute:e=>e,toAttribute:e=>e?.toString()??null}})],$.prototype,`max`,void 0),e.n([e.u({type:Number,reflect:!0})],$.prototype,`maxlength`,void 0),e.n([e.u({reflect:!0,converter:{fromAttribute:e=>e,toAttribute:e=>e?.toString()??null}})],$.prototype,`min`,void 0),e.n([e.u({type:Number,reflect:!0})],$.prototype,`minlength`,void 0),e.n([e.u({type:Number,reflect:!0})],$.prototype,`step`,void 0),e.n([e.u({type:String,attribute:`aria-describedby`})],$.prototype,`ariaDescribedby`,void 0),e.n([e.u({type:String,attribute:`aria-labelledby`})],$.prototype,`ariaLabelledby`,void 0),e.n([e.u({type:String,reflect:!0})],$.prototype,`name`,void 0),e.n([e.u({type:String,reflect:!0})],$.prototype,`pattern`,void 0),e.n([e.u({type:String,reflect:!0})],$.prototype,`placeholder`,void 0),e.n([e.u({type:String,reflect:!0})],$.prototype,`id`,void 0),e.n([e.u({type:Boolean,converter:r.n})],$.prototype,`counter`,void 0),e.n([e.u({type:Boolean})],$.prototype,`hasError`,void 0),e.n([e.u({type:Boolean})],$.prototype,`inline`,void 0),e.n([e.u({type:Boolean,converter:r.n})],$.prototype,`hasFieldset`,void 0),e.n([e.u({type:Boolean})],$.prototype,`optionalTag`,void 0),e.n([e.u({type:Boolean})],$.prototype,`requiredTag`,void 0),e.n([e.u({type:Boolean})],$.prototype,`skipForwardTestid`,void 0),e.n([e.u({type:Boolean,reflect:!0,converter:r.t})],$.prototype,`useWrapper`,void 0),e.n([e.u({type:Boolean,reflect:!0})],$.prototype,`fullwidth`,void 0),e.n([e.u({type:Number})],$.prototype,`counterMaxLength`,void 0),e.n([e.u({type:String})],$.prototype,`errorMessage`,void 0),e.n([e.u({type:String})],$.prototype,`helptext`,void 0),e.n([e.u({type:String})],$.prototype,`helptextDropdown`,void 0),e.n([e.u({type:String,reflect:!1})],$.prototype,`helptextDropdownButton`,void 0),e.n([e.u({type:String})],$.prototype,`label`,void 0),e.n([e.u({type:String,reflect:!1})],$.prototype,`optionalText`,void 0),e.n([e.u({type:String,reflect:!1})],$.prototype,`requiredText`,void 0),e.n([e.u({type:String,reflect:!1})],$.prototype,`tagText`,void 0),e.n([e.u({type:String,attribute:`input-size`})],$.prototype,`inputSize`,void 0),e.n([e.u({type:String,attribute:`data-testid`})],$.prototype,`dataTestid`,void 0),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return $}});
|
|
1
|
+
const e=require("./element-BOmr9YLv.cjs"),t=require("./format-B8meU8Tm.cjs"),n=require("./element-with-slot-D7sTqOr3.cjs"),r=require("./booleanish-BF8l4scU.cjs"),i=require("./utils-63cRpWut.cjs");var a=new WeakMap,o=new WeakMap,s=new WeakMap,c=new WeakMap,l=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakMap,p=new WeakMap,m=new WeakMap,h=new WeakMap,g=new WeakMap,_=new WeakMap,v=new WeakMap,y=new WeakMap,b=(e,t,n)=>{e.getAttribute(t)!==n&&e.setAttribute(t,n)},x=(e,t)=>{e.toggleAttribute(`internals-disabled`,t),t?b(e,`aria-disabled`,`true`):e.removeAttribute(`aria-disabled`),e.formDisabledCallback&&e.formDisabledCallback.apply(e,[t])},S=e=>{s.get(e).forEach(e=>{e.remove()}),s.set(e,[])},C=(e,t)=>{let n=document.createElement(`input`);return n.type=`hidden`,n.name=e.getAttribute(`name`),e.after(n),s.get(t).push(n),n},w=(e,t)=>{if(t.length){let n=Array.from(t);n.forEach(t=>t.addEventListener(`click`,e.click.bind(e)));let[r]=n,i=r.id;r.id||=(i=`${r.htmlFor}_Label`,i),b(e,`aria-labelledby`,i)}},T=e=>{let t=Array.from(e.elements).filter(e=>!e.tagName.includes(`-`)&&e.validity).map(e=>e.validity.valid),n=f.get(e)||[],r=Array.from(n).filter(e=>e.isConnected).map(e=>c.get(e).validity.valid),i=[...t,...r].includes(!1);e.toggleAttribute(`internals-invalid`,i),e.toggleAttribute(`internals-valid`,!i)},ee=e=>{T(O(e.target))},E=e=>{T(O(e.target))},te=e=>{let t=[`button[type=submit]`,`input[type=submit]`,`button:not([type])`].map(e=>`${e}:not([disabled])`).map(t=>`${t}:not([form])${e.id?`,${t}[form='${e.id}']`:``}`).join(`,`);e.addEventListener(`click`,n=>{if(n.target.closest(t)){let t=f.get(e);if(e.noValidate)return;t.size&&Array.from(t).reverse().map(e=>c.get(e).reportValidity()).includes(!1)&&n.preventDefault()}})},ne=e=>{let t=f.get(e.target);t&&t.size&&t.forEach(e=>{e.constructor.formAssociated&&e.formResetCallback&&e.formResetCallback.apply(e)})},D=(e,t,n)=>{if(t){let r=f.get(t);if(r)r.add(e);else{let n=new Set;n.add(e),f.set(t,n),te(t),t.addEventListener(`reset`,ne),t.addEventListener(`input`,ee),t.addEventListener(`change`,E)}u.set(t,{ref:e,internals:n}),e.constructor.formAssociated&&e.formAssociatedCallback&&setTimeout(()=>{e.formAssociatedCallback.apply(e,[t])},0),T(t)}},O=e=>{let t=e.parentNode;return t&&t.tagName!==`FORM`&&(t=O(t)),t},k=(e,t,n=DOMException)=>{if(!e.constructor.formAssociated)throw new n(t)},A=(e,t,n)=>{let r=f.get(e);return r&&r.size&&r.forEach(e=>{c.get(e)[n]()||(t=!1)}),t},j=e=>{let t=!1;if(e.constructor.formAssociated){let n=c.get(e);n===void 0&&(e.attachInternals(),n=c.get(e),t=!0);let{labels:r,form:i}=n;w(e,r),D(e,i,n)}return t};function M(){return typeof MutationObserver<`u`}var N={ariaAtomic:`aria-atomic`,ariaAutoComplete:`aria-autocomplete`,ariaBrailleLabel:`aria-braillelabel`,ariaBrailleRoleDescription:`aria-brailleroledescription`,ariaBusy:`aria-busy`,ariaChecked:`aria-checked`,ariaColCount:`aria-colcount`,ariaColIndex:`aria-colindex`,ariaColIndexText:`aria-colindextext`,ariaColSpan:`aria-colspan`,ariaCurrent:`aria-current`,ariaDescription:`aria-description`,ariaDisabled:`aria-disabled`,ariaExpanded:`aria-expanded`,ariaHasPopup:`aria-haspopup`,ariaHidden:`aria-hidden`,ariaInvalid:`aria-invalid`,ariaKeyShortcuts:`aria-keyshortcuts`,ariaLabel:`aria-label`,ariaLevel:`aria-level`,ariaLive:`aria-live`,ariaModal:`aria-modal`,ariaMultiLine:`aria-multiline`,ariaMultiSelectable:`aria-multiselectable`,ariaOrientation:`aria-orientation`,ariaPlaceholder:`aria-placeholder`,ariaPosInSet:`aria-posinset`,ariaPressed:`aria-pressed`,ariaReadOnly:`aria-readonly`,ariaRelevant:`aria-relevant`,ariaRequired:`aria-required`,ariaRoleDescription:`aria-roledescription`,ariaRowCount:`aria-rowcount`,ariaRowIndex:`aria-rowindex`,ariaRowIndexText:`aria-rowindextext`,ariaRowSpan:`aria-rowspan`,ariaSelected:`aria-selected`,ariaSetSize:`aria-setsize`,ariaSort:`aria-sort`,ariaValueMax:`aria-valuemax`,ariaValueMin:`aria-valuemin`,ariaValueNow:`aria-valuenow`,ariaValueText:`aria-valuetext`,role:`role`},P=(e,t)=>{for(let n in N){t[n]=null;let r=null,i=N[n];Object.defineProperty(t,n,{get(){return r},set(n){r=n,e.isConnected?b(e,i,n):m.set(e,t)}})}},re=(e,t)=>{s.set(t,[]),R.observe?.(e,L)};function F(e){let t=c.get(e),{form:n}=t;D(e,n,t),w(e,t.labels)}var I=(e,t=!1)=>{let n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(e){return c.has(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}}),r=n.nextNode(),i=!t||e.disabled;for(;r;)r.formDisabledCallback&&i&&x(r,e.disabled),r=n.nextNode()},L={attributes:!0,attributeFilter:[`disabled`,`name`]},R=M()?new MutationObserver(e=>{for(let t of e){let e=t.target;if(t.attributeName===`disabled`&&(e.constructor.formAssociated?x(e,e.hasAttribute(`disabled`)):e.localName===`fieldset`&&I(e)),t.attributeName===`name`&&e.constructor.formAssociated){let t=c.get(e),n=p.get(e);t.setFormValue(n)}}}):{};function z(e){e.forEach(e=>{let{addedNodes:t,removedNodes:n}=e,r=Array.from(t),i=Array.from(n);r.forEach(e=>{if(c.has(e)&&e.constructor.formAssociated&&F(e),m.has(e)){let t=m.get(e);Object.keys(N).filter(e=>t[e]!==null).forEach(n=>{b(e,N[n],t[n])}),m.delete(e)}if(y.has(e)){let t=y.get(e);b(e,`internals-valid`,t.validity.valid.toString()),b(e,`internals-invalid`,(!t.validity.valid).toString()),b(e,`aria-invalid`,(!t.validity.valid).toString()),y.delete(e)}if(e.localName===`form`){let t=f.get(e),n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(e){return c.has(e)&&e.constructor.formAssociated&&!(t&&t.has(e))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}}),r=n.nextNode();for(;r;)F(r),r=n.nextNode()}e.localName===`fieldset`&&(R.observe?.(e,L),I(e,!0))}),i.forEach(e=>{let t=c.get(e);t&&s.get(t)&&S(t),d.has(e)&&d.get(e).disconnect()})})}function ie(e){e.forEach(e=>{let{removedNodes:t}=e;t.forEach(t=>{let n=_.get(e.target);c.has(t)&&j(t),n.disconnect()})})}var ae=e=>{let t=new MutationObserver(ie);window?.ShadyDOM?.inUse&&e.mode&&e.host&&(e=e.host),t.observe?.(e,{childList:!0}),_.set(e,t)};M()&&new MutationObserver(z);var B={childList:!0,subtree:!0},oe=class{constructor(){this.badInput=!1,this.customError=!1,this.patternMismatch=!1,this.rangeOverflow=!1,this.rangeUnderflow=!1,this.stepMismatch=!1,this.tooLong=!1,this.tooShort=!1,this.typeMismatch=!1,this.valid=!0,this.valueMissing=!1,Object.seal(this)}},se=e=>(e.badInput=!1,e.customError=!1,e.patternMismatch=!1,e.rangeOverflow=!1,e.rangeUnderflow=!1,e.stepMismatch=!1,e.tooLong=!1,e.tooShort=!1,e.typeMismatch=!1,e.valid=!0,e.valueMissing=!1,e),ce=(e,t,n)=>(e.valid=le(t),Object.keys(t).forEach(n=>e[n]=t[n]),n&&T(n),e),le=e=>{let t=!0;for(let n in e)n!==`valid`&&e[n]!==!1&&(t=!1);return t},V=new WeakMap;function H(e,t){e.toggleAttribute(t,!0),e.part&&e.part.add(t)}var U=class extends Set{static get isPolyfilled(){return!0}constructor(e){if(super(),!e||!e.tagName||e.tagName.indexOf(`-`)===-1)throw TypeError(`Illegal constructor`);V.set(this,e)}add(e){if(!/^--/.test(e)||typeof e!=`string`)throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${e} must start with '--'.`);let t=super.add(e),n=V.get(this),r=`state${e}`;return n.isConnected?H(n,r):setTimeout(()=>{H(n,r)}),t}clear(){for(let[e]of this.entries())this.delete(e);super.clear()}delete(e){let t=super.delete(e),n=V.get(this);return n.isConnected?(n.toggleAttribute(`state${e}`,!1),n.part&&n.part.remove(`state${e}`)):setTimeout(()=>{n.toggleAttribute(`state${e}`,!1),n.part&&n.part.remove(`state${e}`)}),t}},ue=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},W=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},G,de=class{constructor(e){G.set(this,void 0),ue(this,G,e,`f`);for(let t=0;t<e.length;t++){let n=e[t];this[t]=n,n.hasAttribute(`name`)&&(this[n.getAttribute(`name`)]=n)}Object.freeze(this)}get length(){return W(this,G,`f`).length}[(G=new WeakMap,Symbol.iterator)](){return W(this,G,`f`)[Symbol.iterator]()}item(e){return this[e]==null?null:this[e]}namedItem(e){return this[e]==null?null:this[e]}};function fe(){let e=HTMLFormElement.prototype.checkValidity;HTMLFormElement.prototype.checkValidity=n;let t=HTMLFormElement.prototype.reportValidity;HTMLFormElement.prototype.reportValidity=r;function n(...t){let n=e.apply(this,t);return A(this,n,`checkValidity`)}function r(...e){let n=t.apply(this,e);return A(this,n,`reportValidity`)}let{get:i}=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,`elements`);Object.defineProperty(HTMLFormElement.prototype,"elements",{get(...e){let t=i.call(this,...e),n=Array.from(f.get(this)||[]);return n.length===0?t:new de(Array.from(t).concat(n).sort((e,t)=>e.compareDocumentPosition?e.compareDocumentPosition(t)&2?1:-1:0))}})}var K=class{static get isPolyfilled(){return!0}constructor(e){if(!e||!e.tagName||e.tagName.indexOf(`-`)===-1)throw TypeError(`Illegal constructor`);let t=e.getRootNode(),n=new oe;this.states=new U(e),a.set(this,e),o.set(this,n),c.set(e,this),P(e,this),re(e,this),Object.seal(this),t instanceof DocumentFragment&&ae(t)}checkValidity(){let e=a.get(this);if(k(e,`Failed to execute 'checkValidity' on 'ElementInternals': The target element is not a form-associated custom element.`),!this.willValidate)return!0;let t=o.get(this);if(!t.valid){let t=new Event(`invalid`,{bubbles:!1,cancelable:!0,composed:!1});e.dispatchEvent(t)}return t.valid}get form(){let e=a.get(this);k(e,`Failed to read the 'form' property from 'ElementInternals': The target element is not a form-associated custom element.`);let t;return e.constructor.formAssociated===!0&&(t=O(e)),t}get labels(){let e=a.get(this);k(e,`Failed to read the 'labels' property from 'ElementInternals': The target element is not a form-associated custom element.`);let t=e.getAttribute(`id`),n=e.getRootNode();return n&&t?n.querySelectorAll(`[for="${t}"]`):[]}reportValidity(){let e=a.get(this);if(k(e,`Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.`),!this.willValidate)return!0;let t=this.checkValidity(),n=g.get(this);if(n&&!e.constructor.formAssociated)throw new DOMException(`Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.`);return!t&&n&&(e.focus(),n.focus()),t}setFormValue(e){let t=a.get(this);if(k(t,`Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element.`),S(this),e!=null&&!(e instanceof FormData)){if(t.getAttribute(`name`)){let n=C(t,this);n.value=e}}else e!=null&&e instanceof FormData&&Array.from(e).reverse().forEach(([e,n])=>{if(typeof n==`string`){let r=C(t,this);r.name=e,r.value=n}});p.set(t,e)}setValidity(e,t,n){let r=a.get(this);if(k(r,`Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element.`),!e)throw TypeError(`Failed to execute 'setValidity' on 'ElementInternals': 1 argument required, but only 0 present.`);g.set(this,n);let i=o.get(this),s={};for(let t in e)s[t]=e[t];Object.keys(s).length===0&&se(i);let c={...i,...s};delete c.valid;let{valid:u}=ce(i,c,this.form);if(!u&&!t)throw new DOMException(`Failed to execute 'setValidity' on 'ElementInternals': The second argument should not be empty if one or more flags in the first argument are true.`);l.set(this,u?``:t),r.isConnected?(r.toggleAttribute(`internals-invalid`,!u),r.toggleAttribute(`internals-valid`,u),b(r,`aria-invalid`,`${!u}`)):y.set(r,this)}get shadowRoot(){let e=a.get(this);return h.get(e)||null}get validationMessage(){return k(a.get(this),`Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element.`),l.get(this)}get validity(){return k(a.get(this),`Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element.`),o.get(this)}get willValidate(){let e=a.get(this);return k(e,`Failed to read the 'willValidate' property from 'ElementInternals': The target element is not a form-associated custom element.`),!(e.matches(`:disabled`)||e.disabled||e.hasAttribute(`disabled`)||e.hasAttribute(`readonly`))}};function pe(){if(typeof window>`u`||!window.ElementInternals||!HTMLElement.prototype.attachInternals)return!1;class e extends HTMLElement{constructor(){super(),this.internals=this.attachInternals()}}let t=`element-internals-feature-detection-${Math.random().toString(36).replace(/[^a-z]+/g,``)}`;customElements.define(t,e);let n=new e;return[`shadowRoot`,`form`,`willValidate`,`validity`,`validationMessage`,`labels`,`setFormValue`,`setValidity`,`checkValidity`,`reportValidity`].every(e=>e in n.internals)}var q=!1,J=!1;function Y(e){J||(J=!0,window.CustomStateSet=U,e&&(HTMLElement.prototype.attachInternals=function(...t){let n=e.call(this,t);return n.states=new U(this),n}))}function me(e=!0){let t=!1;if(!q){if(q=!0,typeof window<`u`&&(window.ElementInternals=K),typeof CustomElementRegistry<`u`){let e=CustomElementRegistry.prototype.define;CustomElementRegistry.prototype.define=function(n,r,i){if(r.formAssociated){let e=r.prototype.connectedCallback;r.prototype.connectedCallback=function(){v.has(this)||(v.set(this,!0),this.hasAttribute(`disabled`)&&x(this,!0)),e?.apply(this),t=j(this)}}e.call(this,n,r,i)}}if(typeof HTMLElement<`u`&&(HTMLElement.prototype.attachInternals=function(){if(!this.tagName)return{};if(this.tagName.indexOf(`-`)===-1)throw Error(`Failed to execute 'attachInternals' on 'HTMLElement': Unable to attach ElementInternals to non-custom elements.`);if(c.has(this)&&!t)throw new DOMException(`DOMException: Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.`);return new K(this)}),typeof Element<`u`){function n(...t){let n=e.apply(this,t);if(h.set(this,n),M()){let e=new MutationObserver(z);window.ShadyDOM?e.observe(this,B):e.observe(n,B),d.set(this,e)}return n}let e=Element.prototype.attachShadow;Element.prototype.attachShadow=n}M()&&typeof document<`u`&&new MutationObserver(z).observe(document.documentElement,B),typeof HTMLFormElement<`u`&&fe(),(e||typeof window<`u`&&!window.CustomStateSet)&&Y()}}customElements.polyfillWrapFlushCallback||(pe()?typeof window<`u`&&!window.CustomStateSet&&Y(HTMLElement.prototype.attachInternals):me(!1));var X=`on`,Z=`--checked`,Q=`,`,$=class extends n.t{static get formAssociated(){return!0}get form(){let e=this.getAttribute(`form`);if(e!==null){if(!e)return null;let t=this.getRootNode(),n=typeof t.getElementById==`function`?t.getElementById(e):this.ownerDocument?.getElementById(e);return n instanceof HTMLFormElement?n:null}return this.internals?.form??this.closest(`form`)}get ariaDescribedBy(){return this.ariaDescribedby}set ariaDescribedBy(e){this.ariaDescribedby=e}effectiveCounter(e){return this.counter??e}effectiveHasFieldset(e){return this.hasFieldset??e}constructor(){super(),this.defaultValue=null,this.disabled=!1,this.readonly=!1,this.required=!1,this.max=null,this.maxlength=null,this.min=null,this.minlength=null,this.step=null,this.ariaDescribedby=null,this.ariaLabelledby=null,this.name=``,this.pattern=null,this.placeholder=null,this.id=i.n(),this.counter=null,this.hasError=!1,this.inline=!1,this.hasFieldset=null,this.optionalTag=!1,this.requiredTag=!1,this.skipForwardTestid=!1,this.useWrapper=!0,this.fullwidth=!1,this.counterMaxLength=0,this.errorMessage=``,this.helptext=``,this.helptextDropdown=``,this.helptextDropdownButton=null,this.label=null,this.tagText=null,this.inputSize=`medium`,this.dataTestid=``,this.touched=!1,this._initialized=!1,this._didInitDerivedState=!1,this.internals=this.attachInternals()}manageValidity(e){if(!e){console.warn(`manageValidity called without valid input element`);return}let n=this.pktStrings.get(`validation`);this.required&&!this.value?this.internals.setValidity({valueMissing:!0},n.valueMissing,e):e.validity?.typeMismatch||e.validity?.badInput?this.internals.setValidity({typeMismatch:!0},n.typeMismatch,e):e.validity?.patternMismatch?this.internals.setValidity({patternMismatch:!0},n.patternMismatch,e):e.validity?.tooShort||this.minlength&&this.minlength>0&&this.value.length<this.minlength?this.internals.setValidity({tooShort:!0},n.tooShort,e):e.validity?.tooLong||this.maxlength&&this.maxlength>0&&this.value.length>this.maxlength?this.internals.setValidity({tooLong:!0},n.tooLong,e):e.validity?.rangeUnderflow?this.internals.setValidity({rangeUnderflow:!0},this.min?t.t(n.rangeUnderflowMin,{min:this.min.toString()}):n.rangeUnderflow,e):e.validity?.stepMismatch?this.internals.setValidity({stepMismatch:!0},n.typeMismatch,e):e.validity?.rangeOverflow?this.internals.setValidity({rangeOverflow:!0},this.max?t.t(n.rangeOverflowMax,{max:this.max.toString()}):n.rangeOverflow,e):e.validity?.customError?this.internals.setValidity({customError:!0},e.validationMessage,e):this.internals.setValidity({})}setFormValue(e){if(this.internals){if(Array.isArray(e)){let t=new FormData;e.forEach(e=>{t.append(this.name,e)}),this.internals.setFormValue(t)}else this.internals.setFormValue(e)}}radioGroupMembers(){let e=this.getRootNode();if(typeof e.querySelectorAll!=`function`)return[];let t=this.form;return Array.from(e.querySelectorAll(`pkt-radiobutton, input[type="radio"]`)).filter(e=>e!==this&&e.getAttribute(`name`)===this.name&&e.form===t)}coordinateRadioGroup(){!this.name||this.type!==`radio`||this.radioGroupMembers().forEach(e=>{if(e.getAttribute(`value`)===this.value)return;let t=e;t.checked&&(t.checked=!1,t.internals&&(t.internals.setFormValue(null),t.internals.states?.delete(Z)))})}valueChecked(e){if(this.touched){if(this.type===`radio`&&this.coordinateRadioGroup(),typeof e==`string`?(this.checked=e===`true`,this.internals.ariaChecked=String(e===`true`)):typeof e==`boolean`&&(this.checked=e,this.internals.ariaChecked=String(e)),this.checked){let e=(typeof this.value==`string`?this.value:``)||X;this.internals.setFormValue(e),this.internals.states.add(Z)}else this.internals.setFormValue(null),this.internals.states.delete(Z);this.dispatchChangeEvents(this.checked),this.internals.reportValidity()}}valueChanged(e,t){let n=e;if(typeof n==`number`||typeof n==`boolean`)e=String(n);else if(n!=null&&typeof n!=`string`&&!Array.isArray(n)){let e=typeof n==`object`?n?.constructor?.name??`object`:typeof n;console.warn(`${this.localName}: value må være en streng eller et tall, men fikk ${e}. Verdien ignoreres. For dato-/tidsfelt, send en ISO-formatert streng (f.eks. "2026-07-09" eller "13:45").`)}(t!==this.value||t!==this._value)&&(typeof e==`string`?((this.multiple||this.range)&&e.includes(Q)&&(e=e.split(Q)),this.value=e,this._value=Array.isArray(e)?e:[e]):Array.isArray(e)?(this.value=this.multiple||this.range?e:e[0],this._value=e):(this.value=``,this._value=[]),(!this.value||this.value.length===0)&&t&&t.length!==0?this.clearInputValue():this.value&&this.value.toString()!==t?.toString()&&this.onChange(this.value))}dispatchChangeEvents(e){this.dispatchEvent(new Event(`change`,{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`value-change`,{detail:e,bubbles:!0,composed:!0}))}clearInputValue(){let e=this.multiple||this.range?[]:``;this.value=e,this.setFormValue(e),this.dispatchChangeEvents(e)}onFocus(){this.dispatchEvent(new FocusEvent(`focus`,{bubbles:!0,composed:!0}))}onBlur(){this.dispatchEvent(new FocusEvent(`blur`,{bubbles:!0,composed:!0}))}onInput(){this.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0}))}normalizeValue(e){return(this.range||this.multiple)&&typeof e==`string`&&e.includes(Q)?e.split(Q):!this.multiple&&!this.range&&Array.isArray(e)?e[0]||``:e}validate(){this.inputRef?.value&&this.manageValidity(this.inputRef.value),this.inputRefTo?.value&&this.manageValidity(this.inputRefTo.value)}onChange(e){if(this.touched=!0,typeof e!=`string`&&!Array.isArray(e))return;let t=this.normalizeValue(e);this.setFormValue(t),this.validate(),this._initialized&&this.dispatchChangeEvents(t)}formResetCallback(){if(this.touched=!1,this._options&&this._options.length&&this._options.forEach(e=>{`selected`in e&&(e.selected=!1)}),this.checked!==void 0)this.checked=!1,this.internals.ariaChecked=`false`,this.internals.setFormValue(``),this.inputRef?.value&&`checked`in this.inputRef.value&&(this.inputRef.value.checked=!1),this.valueChecked(this.checked);else{this.internals.setFormValue(``);let e=this.defaultValue||(this.multiple||this.range?[]:``);this.value=e,this._value=Array.isArray(e)?e:[e],this.valueChanged(this.value,null)}this.internals.ariaInvalid=`false`}updated(e){super.updated(e),e.has(`dataTestid`)&&this.dataTestid&&this.inputRef.value&&(this.skipForwardTestid?this.hasAttribute(`data-testid`)||this.setAttribute(`data-testid`,this.dataTestid):(this.inputRef.value.dataset.testid=this.dataTestid,this.removeAttribute(`data-testid`)))}willUpdate(e){super.willUpdate(e),!this._didInitDerivedState&&(this._didInitDerivedState=!0,this.defaultChecked&&(this.checked=!0),this.id&&!this.name&&(this.name=this.id),this.value&&this.defaultValue===null&&(this.defaultValue=this.value),this.defaultValue!==null&&!this.value&&this.valueChanged(this.defaultValue,null))}firstUpdated(e){if(super.firstUpdated(e),this.value&&this.defaultValue===null&&(this.defaultValue=this.value),this.defaultValue!==null&&!this.value&&this.valueChanged(this.defaultValue,null),this.defaultChecked&&(this.internals.ariaChecked=`true`),this.required&&(this.internals.ariaRequired=`true`),this.disabled&&(this.internals.ariaDisabled=`true`),this.checked!==void 0){let e=this.checked===``||this.checked===`true`||this.checked===!0;this.internals.ariaChecked=String(e);let t=e?(typeof this.value==`string`?this.value:``)||X:null;this.internals.setFormValue(t)}else this.setFormValue(this.value);this.inputRef&&this.inputRef.value&&(this.inputRef.value.setAttribute(`form`,``),this.manageValidity(this.inputRef.value)),this.inputRefTo&&this.inputRefTo.value&&(this.inputRefTo.value.setAttribute(`form`,``),this.manageValidity(this.inputRefTo.value)),this.updateComplete.then(()=>{this._initialized=!0})}};e.n([e.u({type:Boolean,reflect:!0})],$.prototype,`checked`,void 0),e.n([e.u({type:Boolean})],$.prototype,`defaultChecked`,void 0),e.n([e.u({type:Boolean})],$.prototype,`multiple`,void 0),e.n([e.u({type:Boolean})],$.prototype,`range`,void 0),e.n([e.u({type:String,reflect:!0})],$.prototype,`type`,void 0),e.n([e.u()],$.prototype,`defaultValue`,void 0),e.n([e.u({type:Boolean,reflect:!0})],$.prototype,`disabled`,void 0),e.n([e.u({type:Boolean,reflect:!0})],$.prototype,`readonly`,void 0),e.n([e.u({type:Boolean,reflect:!0})],$.prototype,`required`,void 0),e.n([e.u({reflect:!0,converter:{fromAttribute:e=>e,toAttribute:e=>e?.toString()??null}})],$.prototype,`max`,void 0),e.n([e.u({type:Number,reflect:!0})],$.prototype,`maxlength`,void 0),e.n([e.u({reflect:!0,converter:{fromAttribute:e=>e,toAttribute:e=>e?.toString()??null}})],$.prototype,`min`,void 0),e.n([e.u({type:Number,reflect:!0})],$.prototype,`minlength`,void 0),e.n([e.u({type:Number,reflect:!0})],$.prototype,`step`,void 0),e.n([e.u({type:String,attribute:`aria-describedby`})],$.prototype,`ariaDescribedby`,void 0),e.n([e.u({type:String,attribute:`aria-labelledby`})],$.prototype,`ariaLabelledby`,void 0),e.n([e.u({type:String,reflect:!0})],$.prototype,`name`,void 0),e.n([e.u({type:String,reflect:!0})],$.prototype,`pattern`,void 0),e.n([e.u({type:String,reflect:!0})],$.prototype,`placeholder`,void 0),e.n([e.u({type:String,reflect:!0})],$.prototype,`id`,void 0),e.n([e.u({type:Boolean,converter:r.n})],$.prototype,`counter`,void 0),e.n([e.u({type:Boolean})],$.prototype,`hasError`,void 0),e.n([e.u({type:Boolean})],$.prototype,`inline`,void 0),e.n([e.u({type:Boolean,converter:r.n})],$.prototype,`hasFieldset`,void 0),e.n([e.u({type:Boolean})],$.prototype,`optionalTag`,void 0),e.n([e.u({type:Boolean})],$.prototype,`requiredTag`,void 0),e.n([e.u({type:Boolean})],$.prototype,`skipForwardTestid`,void 0),e.n([e.u({type:Boolean,reflect:!0,converter:r.t})],$.prototype,`useWrapper`,void 0),e.n([e.u({type:Boolean,reflect:!0})],$.prototype,`fullwidth`,void 0),e.n([e.u({type:Number})],$.prototype,`counterMaxLength`,void 0),e.n([e.u({type:String})],$.prototype,`errorMessage`,void 0),e.n([e.u({type:String})],$.prototype,`helptext`,void 0),e.n([e.u({type:String})],$.prototype,`helptextDropdown`,void 0),e.n([e.u({type:String,reflect:!1})],$.prototype,`helptextDropdownButton`,void 0),e.n([e.u({type:String})],$.prototype,`label`,void 0),e.n([e.u({type:String,reflect:!1})],$.prototype,`optionalText`,void 0),e.n([e.u({type:String,reflect:!1})],$.prototype,`requiredText`,void 0),e.n([e.u({type:String,reflect:!1})],$.prototype,`tagText`,void 0),e.n([e.u({type:String,attribute:`input-size`})],$.prototype,`inputSize`,void 0),e.n([e.u({type:String,attribute:`data-testid`})],$.prototype,`dataTestid`,void 0),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return $}});
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
const e=require("./element-BOmr9YLv.cjs"),t=require("./
|
|
2
|
-
${this.tagText?e._`<span class=${
|
|
3
|
-
${this.optionalTag?e._`<span class=${
|
|
4
|
-
>${this.optionalText??
|
|
1
|
+
const e=require("./element-BOmr9YLv.cjs"),t=require("./format-B8meU8Tm.cjs"),n=require("./element-with-slot-D7sTqOr3.cjs"),r=require("./booleanish-BF8l4scU.cjs");require("./alert-IaZzEgyI.cjs");const i=require("./icon-Dnv6LtPC.cjs"),a=require("./if-defined-2mkIDgOm.cjs"),o=require("./utils-63cRpWut.cjs");require("./helptext-BCkwSz1m.cjs");const s=require("./focus-modality-controller-C1ocyv2J.cjs");var c=e=>{let t=[];return e.hasHelptext&&t.push(`${e.id}-helptext`),e.hasCounter&&t.push(`${e.id}-counter-status`),e.ariaDescribedby&&t.push(e.ariaDescribedby),t.length?t.join(` `):void 0},l=e=>`${e}-counter-status`,u=(e,t)=>!!t&&t>0&&(e??0)>t,d={name:`pkt-input-wrapper`,react:`PktInputWrapper`,"css-class":`pkt-inputwrapper`,isElement:!0,isPureReact:!0,"dark-mode":!0,events:{toggleHelpText:{description:`Event for å vise eller skjule hjelpetekst i dropdown`}},slots:{default:{description:`Innholdet i input-wrapperen, som kan være et skjemaelement eller en annen komponent`}},props:{forId:{name:`For ID`,description:`Id-en til skjemaelementet som dette wrapper rundt`,type:`string`,required:!0,category:`tech`},label:{name:`Merkelapp`,description:`Merkelapp for skjemaelementet`,type:`string`,required:!0,category:`contents`},helptext:{name:`Hjelpetekst`,description:`Hjelpetekst for skjemaelementet`,type:`string`,category:`contents`},helptextDropdown:{name:`Hjelpetekst i dropdown`,description:`Hjelpetekst som vises i ekspanderende felt`,type:`string`,category:`contents`},helptextDropdownButton:{name:`Tekst i hjelpetekst-knapp`,description:`Tekst som vises i knappen for å vise hjelpetekst i dropdown`,default:`Les mer <span class='pkt-sr-only'>om feltet</span>`,type:`string`,category:`contents`},ariaDescribedby:{name:`aria-describedby`,description:`Id-en til elementet som beskriver skjemaelementet`,type:`string`,category:`accessibility`},counter:{name:`Teller`,description:`Teller for antall tegn i skjemaelementet`,type:`boolean`,default:!1,category:`ui`},counterCurrent:{name:`Tellerverdi`,description:`Tellerens nåværende verdi`,type:`number`,category:`ui`,showIf:{counter:!0}},counterMaxLength:{name:`Maks tegn i teller`,description:`Maks antall tegn som kan skrives i skjemaelementet`,type:`number`,category:`ui`,showIf:{counter:!0}},counterPosition:{name:`Tellerplassering`,description:`Telleren sin plassering i forhold til elementet`,type:[`top`,`bottom`],default:`bottom`,category:`ui`,showIf:{counter:!0}},optionalTag:{name:`Vise valgfritt-merking`,description:`Viser en merking som indikerer at feltet er valgfritt`,type:`boolean`,default:!1,category:`ui`},optionalText:{name:`Valgfritt-tekst`,description:`Tekst som vises i valgfritt-merkingen`,type:`string`,default:`Valgfritt`,category:`contents`},requiredTag:{name:`Vise påkrevd-merking`,description:`Viser en merking som indikerer at feltet er påkrevd`,type:`boolean`,default:!1,category:`ui`},requiredText:{name:`Påkrevd-tekst`,description:`Tekst som vises i påkrevd-merkingen`,type:`string`,default:`Må fylles ut`,category:`contents`},tagText:{type:`string`,name:`Tag-tekst`,description:`Tekst som vises i en tag ved siden av label`,category:`ui`},hasError:{name:`Feil`,description:`Indikerer at skjemaelementet har en feil`,type:`boolean`,default:!1,category:`ui`},errorMessage:{name:`Feilmelding`,description:`Feilmelding som vises når skjemaelementet har en feil`,type:`string`,category:`contents`},disabled:{name:`Deaktivert`,description:`Indikerer at skjemaelementet er deaktivert`,type:`boolean`,default:!1,category:`tech`},inline:{name:`Inline`,description:`Indikerer at skjemaelementet skal flyte sammen med sidens innhold`,type:`boolean`,default:!1,category:`ui`},hasFieldset:{name:`Er fieldset`,description:`Indikerer at innholdet er et fieldset`,type:`boolean`,default:!1,category:`ui`},useWrapper:{name:`Bruk wrapper`,description:`Indikerer om skjemaelementet skal bruke en wrapper`,type:`boolean`,displayAsFalse:!0,default:!0,category:`ui`},role:{name:`Rolle`,description:`ARIA-rolle på wrapperen. Settes ikke som standard. Bruk hasFieldset for reelle grupper.`,type:`string`,default:null,category:`accessibility`},size:{name:`Størrelse`,description:`Visuell størrelse. small: kompakt wrapper og felt (42px). xsmall: samme wrapper som small, felt 36px.`,attribute:`input-wrapper-size`,type:[`small`,`medium`,`xsmall`],default:`medium`,category:`ui`}}},f=class extends n.t{constructor(...e){super(...e),this.forId=o.n(),this.label=``,this.helptext=null,this.helptextDropdown=null,this.helptextDropdownButton=null,this.counter=d.props.counter.default,this.counterCurrent=0,this.counterMaxLength=0,this.counterError=null,this.counterPosition=`bottom`,this.optionalTag=d.props.optionalTag.default,this.requiredTag=d.props.requiredTag.default,this.tagText=null,this.hasError=d.props.hasError.default,this.errorMessage=``,this.disabled=d.props.disabled.default,this.inline=d.props.inline.default,this.ariaDescribedby=void 0,this.hasFieldset=d.props.hasFieldset.default,this.role=null,this.useWrapper=d.props.useWrapper.default,this.size=`medium`,this.focusModality=new s.t(this)}updated(e){super.updated(e),this.classList.add(`pkt-inputwrapper`),this.classList.toggle(`pkt-inputwrapper--error`,this.hasError),this.classList.toggle(`pkt-inputwrapper--disabled`,this.disabled),this.classList.toggle(`pkt-inputwrapper--inline`,this.inline),this.classList.toggle(`pkt-inputwrapper--medium`,this.size===`medium`),this.classList.toggle(`pkt-inputwrapper--small`,this.size===`small`),this.classList.toggle(`pkt-inputwrapper--xsmall`,this.size===`xsmall`),this.role?this.setAttribute(`aria-labelledby`,`${this.forId}-label`):this.removeAttribute(`aria-labelledby`)}render(){let r=`pkt-tag pkt-tag--small pkt-tag--thin-text`,o=!!this.helptext||this.hasSlotContent(`helptext`),s=this.ariaDescribedby?this.ariaDescribedby:o?`${this.forId}-helptext`:e.h,c=this.pktStrings.get(`forms`),d=()=>e._`
|
|
2
|
+
${this.tagText?e._`<span class=${r+` pkt-tag--gray`}>${this.tagText}</span>`:e.h}
|
|
3
|
+
${this.optionalTag?e._`<span class=${r+` pkt-tag--blue-light`}
|
|
4
|
+
>${this.optionalText??c.optional}</span
|
|
5
5
|
>`:e.h}
|
|
6
|
-
${this.requiredTag?e._`<span class=${
|
|
7
|
-
>${this.requiredText??
|
|
6
|
+
${this.requiredTag?e._`<span class=${r+` pkt-tag--beige`}
|
|
7
|
+
>${this.requiredText??c.required}</span
|
|
8
8
|
>`:e.h}
|
|
9
|
-
`,
|
|
9
|
+
`,f=()=>this.useWrapper?this.hasFieldset?e._`<legend
|
|
10
10
|
class="pkt-inputwrapper__legend"
|
|
11
11
|
id="${this.forId}-label"
|
|
12
12
|
@click=${this.handleLabelClick}
|
|
13
13
|
>
|
|
14
|
-
${this.label} ${
|
|
14
|
+
${this.label} ${d()}
|
|
15
15
|
</legend>`:e._`<label
|
|
16
16
|
class="pkt-inputwrapper__label"
|
|
17
17
|
for="${this.forId}"
|
|
18
18
|
id="${this.forId}-label"
|
|
19
19
|
@click=${this.handleLabelClick}
|
|
20
|
-
>${this.label}${
|
|
20
|
+
>${this.label}${d()}</label
|
|
21
21
|
>`:e._`<label for="${this.forId}" class="pkt-sr-only" id="${this.forId}-label">
|
|
22
22
|
${this.label}
|
|
23
|
-
</label>`,
|
|
23
|
+
</label>`,p=()=>!o&&!this.helptextDropdown?e.h:e._`
|
|
24
24
|
<pkt-helptext
|
|
25
|
-
|
|
25
|
+
${n.n(this,{helptext:null})}
|
|
26
|
+
class="${a.t(this.useWrapper?void 0:`pkt-hide`)}"
|
|
26
27
|
.forId=${this.forId}
|
|
27
28
|
.helptext=${this.helptext}
|
|
28
29
|
.helptextDropdown=${this.helptextDropdown}
|
|
29
|
-
.helptextDropdownButton=${this.helptextDropdownButton??
|
|
30
|
+
.helptextDropdownButton=${this.helptextDropdownButton??c.readMore}
|
|
30
31
|
@toggleHelpText=${e=>{this.toggleDropdown(e)}}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
`,p=()=>{if(!this.counter)return e.h;let t=u(this.counterCurrent,this.counterMaxLength);return e._`<div class="pkt-input__counter" aria-hidden="true">
|
|
32
|
+
></pkt-helptext>
|
|
33
|
+
`,m=()=>{if(!this.counter)return e.h;let n=u(this.counterCurrent,this.counterMaxLength);return e._`<div class="pkt-input__counter" aria-hidden="true">
|
|
34
34
|
${this.counterError?this.counterError:e.h} ${this.counterCurrent||0}
|
|
35
35
|
${this.counterMaxLength?`/${this.counterMaxLength}`:e.h}
|
|
36
36
|
</div>
|
|
37
37
|
<div class="pkt-sr-only" id=${l(this.forId)} aria-live="polite">
|
|
38
|
-
${t
|
|
39
|
-
</div>`},
|
|
38
|
+
${n?t.t(this.pktStrings.get(`validation`).counterExceeded,{current:this.counterCurrent??0,max:this.counterMaxLength}):``}
|
|
39
|
+
</div>`},h=()=>{if(this.hasError&&this.errorMessage){let t=this.size===`medium`?`small`:`xsmall`;return e._`<div class="pkt-inputwrapper__alert-wrapper">
|
|
40
40
|
<pkt-alert
|
|
41
41
|
skin="error"
|
|
42
42
|
.size=${t}
|
|
@@ -45,15 +45,15 @@ const e=require("./element-BOmr9YLv.cjs"),t=require("./if-defined-2mkIDgOm.cjs")
|
|
|
45
45
|
aria-live="assertive"
|
|
46
46
|
aria-atomic="true"
|
|
47
47
|
>
|
|
48
|
-
${
|
|
48
|
+
${i.r(this.errorMessage)}
|
|
49
49
|
</pkt-alert>
|
|
50
|
-
</div>`}return e.h},
|
|
51
|
-
${
|
|
52
|
-
${
|
|
53
|
-
${this.counterPosition===`top`?
|
|
54
|
-
<div class="pkt-contents">${
|
|
55
|
-
${this.counterPosition===`bottom`?
|
|
56
|
-
${
|
|
57
|
-
`;return this.hasFieldset?e._`<fieldset class="pkt-inputwrapper__fieldset" aria-describedby="${
|
|
58
|
-
${
|
|
59
|
-
</fieldset>`:e._`<div class="pkt-inputwrapper__fieldset">${
|
|
50
|
+
</div>`}return e.h},g=()=>e._`
|
|
51
|
+
${f()}
|
|
52
|
+
${p()}
|
|
53
|
+
${this.counterPosition===`top`?m():e.h}
|
|
54
|
+
<div class="pkt-contents">${n.i(this)}</div>
|
|
55
|
+
${this.counterPosition===`bottom`?m():e.h}
|
|
56
|
+
${h()}
|
|
57
|
+
`;return this.hasFieldset?e._`<fieldset class="pkt-inputwrapper__fieldset" aria-describedby="${s}">
|
|
58
|
+
${g()}
|
|
59
|
+
</fieldset>`:e._`<div class="pkt-inputwrapper__fieldset">${g()}</div>`}toggleDropdown(e){this.dispatchEvent(new CustomEvent(`toggleHelpText`,{bubbles:!1,detail:{isOpen:e.detail.isOpen}}))}handleLabelClick(){this.dispatchEvent(new CustomEvent(`labelClick`,{bubbles:!0,composed:!0,detail:`label clicked`}))}};e.n([e.u({type:String})],f.prototype,`forId`,void 0),e.n([e.u({type:String})],f.prototype,`label`,void 0),e.n([e.u({type:String})],f.prototype,`helptext`,void 0),e.n([e.u({type:String})],f.prototype,`helptextDropdown`,void 0),e.n([e.u({type:String})],f.prototype,`helptextDropdownButton`,void 0),e.n([e.u({type:Boolean})],f.prototype,`counter`,void 0),e.n([e.u({type:Number})],f.prototype,`counterCurrent`,void 0),e.n([e.u({type:Number})],f.prototype,`counterMaxLength`,void 0),e.n([e.u({type:String})],f.prototype,`counterError`,void 0),e.n([e.u({type:String,reflect:!1})],f.prototype,`counterPosition`,void 0),e.n([e.u({type:Boolean})],f.prototype,`optionalTag`,void 0),e.n([e.u({type:String})],f.prototype,`optionalText`,void 0),e.n([e.u({type:Boolean})],f.prototype,`requiredTag`,void 0),e.n([e.u({type:String})],f.prototype,`requiredText`,void 0),e.n([e.u({type:String})],f.prototype,`tagText`,void 0),e.n([e.u({type:Boolean})],f.prototype,`hasError`,void 0),e.n([e.u({type:String})],f.prototype,`errorMessage`,void 0),e.n([e.u({type:Boolean})],f.prototype,`disabled`,void 0),e.n([e.u({type:Boolean})],f.prototype,`inline`,void 0),e.n([e.u({type:String})],f.prototype,`ariaDescribedby`,void 0),e.n([e.u({type:Boolean})],f.prototype,`hasFieldset`,void 0),e.n([e.u({type:String,reflect:!0})],f.prototype,`role`,void 0),e.n([e.u({type:Boolean,reflect:!0,converter:r.t})],f.prototype,`useWrapper`,void 0),e.n([e.u({type:String,attribute:`input-wrapper-size`})],f.prototype,`size`,void 0);try{e.d(`pkt-input-wrapper`)(f)}catch{console.warn(`Forsøker å definere <pkt-input-wrapper>, men den er allerede definert`)}var p=f;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return p}});
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { _ as e, d as t, h as n, n as r, u as i } from "./element-mwwC2Rra.js";
|
|
2
|
-
import { t as a } from "./
|
|
3
|
-
import {
|
|
4
|
-
import { r as s, t as c } from "./element-with-slot-FD826ooP.js";
|
|
2
|
+
import { t as a } from "./format-BTeSVkED.js";
|
|
3
|
+
import { i as o, n as s, t as c } from "./element-with-slot-DQv0cbbD.js";
|
|
5
4
|
import { t as l } from "./booleanish-OQJTYSrw.js";
|
|
6
|
-
import "./alert-
|
|
7
|
-
import { r as u } from "./icon-
|
|
8
|
-
import {
|
|
9
|
-
import "./
|
|
10
|
-
import
|
|
5
|
+
import "./alert-C0PiYnot.js";
|
|
6
|
+
import { r as u } from "./icon-JigbxxF7.js";
|
|
7
|
+
import { t as d } from "./if-defined-Bebu3LXY.js";
|
|
8
|
+
import { n as f } from "./utils-BwF4QSrq.js";
|
|
9
|
+
import "./helptext-DCT_9dw1.js";
|
|
10
|
+
import { t as p } from "./focus-modality-controller-Dc2S-KqR.js";
|
|
11
11
|
//#region ../../shared-utils/forms/described-by.ts
|
|
12
|
-
var
|
|
12
|
+
var m = (e) => {
|
|
13
13
|
let t = [];
|
|
14
14
|
return e.hasHelptext && t.push(`${e.id}-helptext`), e.hasCounter && t.push(`${e.id}-counter-status`), e.ariaDescribedby && t.push(e.ariaDescribedby), t.length ? t.join(" ") : void 0;
|
|
15
|
-
},
|
|
15
|
+
}, h = (e) => `${e}-counter-status`, g = (e, t) => !!t && t > 0 && (e ?? 0) > t, _ = {
|
|
16
16
|
name: "pkt-input-wrapper",
|
|
17
17
|
react: "PktInputWrapper",
|
|
18
18
|
"css-class": "pkt-inputwrapper",
|
|
@@ -186,62 +186,62 @@ var p = (e) => {
|
|
|
186
186
|
category: "ui"
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
},
|
|
189
|
+
}, v = class extends c {
|
|
190
190
|
constructor(...e) {
|
|
191
|
-
super(...e), this.forId =
|
|
191
|
+
super(...e), this.forId = f(), this.label = "", this.helptext = null, this.helptextDropdown = null, this.helptextDropdownButton = null, this.counter = _.props.counter.default, this.counterCurrent = 0, this.counterMaxLength = 0, this.counterError = null, this.counterPosition = "bottom", this.optionalTag = _.props.optionalTag.default, this.requiredTag = _.props.requiredTag.default, this.tagText = null, this.hasError = _.props.hasError.default, this.errorMessage = "", this.disabled = _.props.disabled.default, this.inline = _.props.inline.default, this.ariaDescribedby = void 0, this.hasFieldset = _.props.hasFieldset.default, this.role = null, this.useWrapper = _.props.useWrapper.default, this.size = "medium", this.focusModality = new p(this);
|
|
192
192
|
}
|
|
193
193
|
updated(e) {
|
|
194
194
|
super.updated(e), this.classList.add("pkt-inputwrapper"), this.classList.toggle("pkt-inputwrapper--error", this.hasError), this.classList.toggle("pkt-inputwrapper--disabled", this.disabled), this.classList.toggle("pkt-inputwrapper--inline", this.inline), this.classList.toggle("pkt-inputwrapper--medium", this.size === "medium"), this.classList.toggle("pkt-inputwrapper--small", this.size === "small"), this.classList.toggle("pkt-inputwrapper--xsmall", this.size === "xsmall"), this.role ? this.setAttribute("aria-labelledby", `${this.forId}-label`) : this.removeAttribute("aria-labelledby");
|
|
195
195
|
}
|
|
196
196
|
render() {
|
|
197
|
-
let t = "pkt-tag pkt-tag--small pkt-tag--thin-text", r = this.ariaDescribedby ? this.ariaDescribedby :
|
|
197
|
+
let t = "pkt-tag pkt-tag--small pkt-tag--thin-text", r = !!this.helptext || this.hasSlotContent("helptext"), i = this.ariaDescribedby ? this.ariaDescribedby : r ? `${this.forId}-helptext` : n, c = this.pktStrings.get("forms"), l = () => e`
|
|
198
198
|
${this.tagText ? e`<span class=${t + " pkt-tag--gray"}>${this.tagText}</span>` : n}
|
|
199
199
|
${this.optionalTag ? e`<span class=${t + " pkt-tag--blue-light"}
|
|
200
|
-
>${this.optionalText ??
|
|
200
|
+
>${this.optionalText ?? c.optional}</span
|
|
201
201
|
>` : n}
|
|
202
202
|
${this.requiredTag ? e`<span class=${t + " pkt-tag--beige"}
|
|
203
|
-
>${this.requiredText ??
|
|
203
|
+
>${this.requiredText ?? c.required}</span
|
|
204
204
|
>` : n}
|
|
205
|
-
`,
|
|
205
|
+
`, f = () => this.useWrapper ? this.hasFieldset ? e`<legend
|
|
206
206
|
class="pkt-inputwrapper__legend"
|
|
207
207
|
id="${this.forId}-label"
|
|
208
208
|
@click=${this.handleLabelClick}
|
|
209
209
|
>
|
|
210
|
-
${this.label} ${
|
|
210
|
+
${this.label} ${l()}
|
|
211
211
|
</legend>` : e`<label
|
|
212
212
|
class="pkt-inputwrapper__label"
|
|
213
213
|
for="${this.forId}"
|
|
214
214
|
id="${this.forId}-label"
|
|
215
215
|
@click=${this.handleLabelClick}
|
|
216
|
-
>${this.label}${
|
|
216
|
+
>${this.label}${l()}</label
|
|
217
217
|
>` : e`<label for="${this.forId}" class="pkt-sr-only" id="${this.forId}-label">
|
|
218
218
|
${this.label}
|
|
219
|
-
</label>`,
|
|
219
|
+
</label>`, p = () => !r && !this.helptextDropdown ? n : e`
|
|
220
220
|
<pkt-helptext
|
|
221
|
-
|
|
221
|
+
${s(this, { helptext: null })}
|
|
222
|
+
class="${d(this.useWrapper ? void 0 : "pkt-hide")}"
|
|
222
223
|
.forId=${this.forId}
|
|
223
224
|
.helptext=${this.helptext}
|
|
224
225
|
.helptextDropdown=${this.helptextDropdown}
|
|
225
|
-
.helptextDropdownButton=${this.helptextDropdownButton ??
|
|
226
|
+
.helptextDropdownButton=${this.helptextDropdownButton ?? c.readMore}
|
|
226
227
|
@toggleHelpText=${(e) => {
|
|
227
228
|
this.toggleDropdown(e);
|
|
228
229
|
}}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
`, f = () => {
|
|
230
|
+
></pkt-helptext>
|
|
231
|
+
`, m = () => {
|
|
232
232
|
if (!this.counter) return n;
|
|
233
|
-
let t =
|
|
233
|
+
let t = g(this.counterCurrent, this.counterMaxLength);
|
|
234
234
|
return e`<div class="pkt-input__counter" aria-hidden="true">
|
|
235
235
|
${this.counterError ? this.counterError : n} ${this.counterCurrent || 0}
|
|
236
236
|
${this.counterMaxLength ? `/${this.counterMaxLength}` : n}
|
|
237
237
|
</div>
|
|
238
|
-
<div class="pkt-sr-only" id=${
|
|
239
|
-
${t ?
|
|
238
|
+
<div class="pkt-sr-only" id=${h(this.forId)} aria-live="polite">
|
|
239
|
+
${t ? a(this.pktStrings.get("validation").counterExceeded, {
|
|
240
240
|
current: this.counterCurrent ?? 0,
|
|
241
241
|
max: this.counterMaxLength
|
|
242
242
|
}) : ""}
|
|
243
243
|
</div>`;
|
|
244
|
-
},
|
|
244
|
+
}, _ = () => {
|
|
245
245
|
if (this.hasError && this.errorMessage) {
|
|
246
246
|
let t = this.size === "medium" ? "small" : "xsmall";
|
|
247
247
|
return e`<div class="pkt-inputwrapper__alert-wrapper">
|
|
@@ -258,17 +258,17 @@ var p = (e) => {
|
|
|
258
258
|
</div>`;
|
|
259
259
|
}
|
|
260
260
|
return n;
|
|
261
|
-
},
|
|
262
|
-
${
|
|
263
|
-
${d()}
|
|
264
|
-
${this.counterPosition === "top" ? f() : n}
|
|
265
|
-
<div class="pkt-contents">${s(this)}</div>
|
|
266
|
-
${this.counterPosition === "bottom" ? f() : n}
|
|
261
|
+
}, v = () => e`
|
|
262
|
+
${f()}
|
|
267
263
|
${p()}
|
|
264
|
+
${this.counterPosition === "top" ? m() : n}
|
|
265
|
+
<div class="pkt-contents">${o(this)}</div>
|
|
266
|
+
${this.counterPosition === "bottom" ? m() : n}
|
|
267
|
+
${_()}
|
|
268
268
|
`;
|
|
269
|
-
return this.hasFieldset ? e`<fieldset class="pkt-inputwrapper__fieldset" aria-describedby="${
|
|
270
|
-
${
|
|
271
|
-
</fieldset>` : e`<div class="pkt-inputwrapper__fieldset">${
|
|
269
|
+
return this.hasFieldset ? e`<fieldset class="pkt-inputwrapper__fieldset" aria-describedby="${i}">
|
|
270
|
+
${v()}
|
|
271
|
+
</fieldset>` : e`<div class="pkt-inputwrapper__fieldset">${v()}</div>`;
|
|
272
272
|
}
|
|
273
273
|
toggleDropdown(e) {
|
|
274
274
|
this.dispatchEvent(new CustomEvent("toggleHelpText", {
|
|
@@ -284,27 +284,27 @@ var p = (e) => {
|
|
|
284
284
|
}));
|
|
285
285
|
}
|
|
286
286
|
};
|
|
287
|
-
r([i({ type: String })],
|
|
287
|
+
r([i({ type: String })], v.prototype, "forId", void 0), r([i({ type: String })], v.prototype, "label", void 0), r([i({ type: String })], v.prototype, "helptext", void 0), r([i({ type: String })], v.prototype, "helptextDropdown", void 0), r([i({ type: String })], v.prototype, "helptextDropdownButton", void 0), r([i({ type: Boolean })], v.prototype, "counter", void 0), r([i({ type: Number })], v.prototype, "counterCurrent", void 0), r([i({ type: Number })], v.prototype, "counterMaxLength", void 0), r([i({ type: String })], v.prototype, "counterError", void 0), r([i({
|
|
288
288
|
type: String,
|
|
289
289
|
reflect: !1
|
|
290
|
-
})],
|
|
290
|
+
})], v.prototype, "counterPosition", void 0), r([i({ type: Boolean })], v.prototype, "optionalTag", void 0), r([i({ type: String })], v.prototype, "optionalText", void 0), r([i({ type: Boolean })], v.prototype, "requiredTag", void 0), r([i({ type: String })], v.prototype, "requiredText", void 0), r([i({ type: String })], v.prototype, "tagText", void 0), r([i({ type: Boolean })], v.prototype, "hasError", void 0), r([i({ type: String })], v.prototype, "errorMessage", void 0), r([i({ type: Boolean })], v.prototype, "disabled", void 0), r([i({ type: Boolean })], v.prototype, "inline", void 0), r([i({ type: String })], v.prototype, "ariaDescribedby", void 0), r([i({ type: Boolean })], v.prototype, "hasFieldset", void 0), r([i({
|
|
291
291
|
type: String,
|
|
292
292
|
reflect: !0
|
|
293
|
-
})],
|
|
293
|
+
})], v.prototype, "role", void 0), r([i({
|
|
294
294
|
type: Boolean,
|
|
295
295
|
reflect: !0,
|
|
296
296
|
converter: l
|
|
297
|
-
})],
|
|
297
|
+
})], v.prototype, "useWrapper", void 0), r([i({
|
|
298
298
|
type: String,
|
|
299
299
|
attribute: "input-wrapper-size"
|
|
300
|
-
})],
|
|
300
|
+
})], v.prototype, "size", void 0);
|
|
301
301
|
try {
|
|
302
|
-
t("pkt-input-wrapper")(
|
|
302
|
+
t("pkt-input-wrapper")(v);
|
|
303
303
|
} catch {
|
|
304
304
|
console.warn("Forsøker å definere <pkt-input-wrapper>, men den er allerede definert");
|
|
305
305
|
}
|
|
306
306
|
//#endregion
|
|
307
307
|
//#region src/components/input-wrapper/index.ts
|
|
308
|
-
var
|
|
308
|
+
var y = v;
|
|
309
309
|
//#endregion
|
|
310
|
-
export {
|
|
310
|
+
export { v as n, m as r, y as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { _ as e, d as t, h as n, n as r, u as i } from "./element-mwwC2Rra.js";
|
|
2
2
|
import { t as a } from "./class-map-C4hdfSfY.js";
|
|
3
|
-
import {
|
|
3
|
+
import { i as o, t as s } from "./element-with-slot-DQv0cbbD.js";
|
|
4
|
+
import "./icon-JigbxxF7.js";
|
|
4
5
|
import { t as c } from "./define-component-spec-BYOSeplU.js";
|
|
5
|
-
import "./icon-DmRyYNlY.js";
|
|
6
6
|
//#endregion
|
|
7
7
|
//#region src/components/link/link.ts
|
|
8
8
|
var l = c({
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),n=require("./element-with-slot-D7sTqOr3.cjs");require("./icon-Dnv6LtPC.cjs");const r=require("./define-component-spec-DBNd2FJY.cjs");var i={href:{type:`string`,description:`Mål-URL for lenken.`,required:!0,reactOnly:!0},className:{type:`string`,description:`CSS-klasser Punkt har satt på lenken.`,required:!0,reactOnly:!0},children:{type:`ReactNode`,description:`Innhold/label som skal rendres inni lenken.`,required:!0,reactOnly:!0},props:{type:`AnchorHTMLAttributes<HTMLAnchorElement>`,description:`Resten av anchor-attributter (f.eks. <code>onClick</code>, <code>aria-*</code>) som skal spreades på lenken.`,required:!0,reactOnly:!0}},a={name:`Egendefinert lenkekomponent`,description:`React: Funksjon for å rendre en egendefinert lenkekomponent (f.eks. Next.js Link eller React Router Link). Mottar et <code>IRenderLink</code>-objekt med href, className, children og props. Standard er et vanlig <code><a></code>-element.`,type:`(args: IRenderLink) => ReactNode`,relatedTypes:[`IRenderLink`],category:`tech`,reactOnly:!0},o={IRenderLink:{title:`IRenderLink`,description:`Objektet som sendes til <code>renderLink</code> i Link, BackLink og Breadcrumbs. Kun React — brukes til å bytte ut standard <code><a></code> med f.eks. Next.js Link eller React Router Link.`,properties:i}},s=r.t({name:`pkt-link`,react:`PktLink`,"css-class":`pkt-link`,"dark-mode":!0,isElement:!0,props:{href:{name:`URL`,description:`URL til lenken`,type:`string`,default:`#`,category:`contents`},target:{name:`Mål`,description:`Mål for lenken`,type:[`_blank`,`_self`,`_parent`,`_top`],default:`_self`,category:`tech`},iconName:{name:`Ikon`,description:`Ikon som skal vises ved siden av lenketeksten`,type:`icon`,category:`ui`},iconPosition:{name:`Ikonposisjon`,description:`Posisjonen til ikonet i forhold til lenketeksten`,type:[`left`,`right`],category:`ui`},renderLink:a},types:{...o},slots:{default:{description:`Innholdet i lenken`}}}).props,c=class extends n.t{constructor(...e){super(...e),this.href=s.href.default,this.iconName=void 0,this.iconPosition=void 0,this.external=!1,this.target=s.target.default}render(){let r={"pkt-link":!0,"pkt-link--icon-left":!!this.iconName&&this.iconPosition===`left`||!!(this.iconName&&!this.iconPosition),"pkt-link--icon-right":!!this.iconName&&this.iconPosition===`right`,"pkt-link--external":this.external},i=this.target&&this.target!==`_self`?this.target:e.h;return e._`<a
|
|
2
|
+
class=${t.t(r)}
|
|
3
|
+
href=${this.href}
|
|
4
|
+
target=${i}
|
|
5
|
+
.rel=${this.external?`noopener noreferrer`:e.h}
|
|
6
|
+
>${this.iconName?e._`<pkt-icon name=${this.iconName} class="pkt-link__icon"></pkt-icon>`:``}${n.i(this)}</a
|
|
7
|
+
>`}};e.n([e.u({type:String,reflect:!0})],c.prototype,`href`,void 0),e.n([e.u({type:String,reflect:!0})],c.prototype,`iconName`,void 0),e.n([e.u({type:String,reflect:!0})],c.prototype,`iconPosition`,void 0),e.n([e.u({type:Boolean,reflect:!0})],c.prototype,`external`,void 0),e.n([e.u({type:String,reflect:!0})],c.prototype,`target`,void 0);try{e.d(`pkt-link`)(c)}catch{console.warn(`Forsøker å definere <pkt-link>, men den er allerede definert`)}var l=c;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
|