@oslokommune/punkt-elements 18.5.1 → 18.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/dist/{accordion-D814csFx.js → accordion-BI-Qiznz.js} +1 -1
- package/dist/{accordion-E0-pLzBq.cjs → accordion-NO9LYXaN.cjs} +2 -2
- package/dist/{alert-DNZtr3gd.js → alert-CayKowTW.js} +2 -2
- package/dist/{alert-DqM9l5as.cjs → alert-HFqn-cvb.cjs} +2 -2
- package/dist/base-elements/input-element.d.ts +2 -0
- package/dist/{button-jJfzE9C7.cjs → button-CIb0IxTg.cjs} +2 -2
- package/dist/{button-Drwt7Qe5.js → button-DWMHtdWk.js} +1 -1
- package/dist/{calendar-Cc0bjLPC.cjs → calendar-CA1mz04B.cjs} +1 -1
- package/dist/{calendar-iXilYFBa.js → calendar-CBghTpkZ.js} +10 -138
- package/dist/{card-BhmJZOGh.js → card-CwvUQj1a.js} +2 -2
- package/dist/{card-D-1JMn_h.cjs → card-b7jjKk6B.cjs} +2 -2
- package/dist/{checkbox--nYvm_Pc.cjs → checkbox-D6j7amKX.cjs} +1 -1
- package/dist/{checkbox-CZTR2qHf.js → checkbox-DcvKYDU2.js} +6 -3
- package/dist/{combobox-CRdBlMz1.cjs → combobox-BT1LB0gl.cjs} +2 -2
- package/dist/{combobox-BNstYIC5.js → combobox-CiT2YvLb.js} +5 -5
- package/dist/components/checkbox/checkbox.d.ts +1 -0
- package/dist/components/heading/heading.d.ts +1 -1
- package/dist/components/tabs/tabs.d.ts +2 -1
- package/dist/components/tag/tag.d.ts +1 -1
- package/dist/components/textarea/textarea.d.ts +1 -0
- package/dist/components/textinput/textinput.d.ts +1 -0
- package/dist/{consent-DaOFbopy.cjs → consent-D1SMUJLs.cjs} +1 -1
- package/dist/{consent-Yvw7gZI_.js → consent-Yt1MpkUy.js} +1 -1
- package/dist/{datepicker-DzTdWHkX.js → datepicker-CqWg6K2N.js} +6 -6
- package/dist/{datepicker-DjvL_Nb8.cjs → datepicker-DIgQrvbZ.cjs} +3 -3
- package/dist/{element-with-slot-MkibfzHp.cjs → element-with-slot-DgtT8lCH.cjs} +1 -1
- package/dist/{element-with-slot-COOwQUxM.js → element-with-slot-GwTT3WRD.js} +1 -1
- package/dist/{fileupload-B8Uhfx2d.js → fileupload-4nTdjPKw.js} +3 -3
- package/dist/{fileupload-BJVYPl8u.cjs → fileupload-BmT5nQX0.cjs} +1 -1
- package/dist/{footer-BGC5PkLa.cjs → footer-CLSihvYS.cjs} +1 -1
- package/dist/{footer-BPxKLaut.js → footer-YrlXRq7e.js} +1 -1
- package/dist/{header-BPzlBRhY.js → header-DU10rGhU.js} +5 -5
- package/dist/{header-CAqegPzW.cjs → header-DybJSDQQ.cjs} +3 -3
- package/dist/{header-menu-DWiPoQ58.js → header-menu-DKAcUFzh.js} +1 -1
- package/dist/{header-menu-DBy7Yrd_.cjs → header-menu-wcnhBSzs.cjs} +1 -1
- package/dist/{heading-NYqciBEJ.js → heading-C23xQS4l.js} +3 -3
- package/dist/heading-OfJKjUi2.cjs +1 -0
- package/dist/{helptext-mf-67-fv.js → helptext-DqdOdYRj.js} +1 -1
- package/dist/{helptext-BwDhf6VB.cjs → helptext-DyHzv2ZG.cjs} +2 -2
- package/dist/{input-element-KpXXnGi0.cjs → input-element-uajHIWAO.cjs} +1 -1
- package/dist/{input-element-DxHRTZ3K.js → input-element-zXKo9jpe.js} +7 -8
- package/dist/{input-wrapper-CS0qrYcm.cjs → input-wrapper-791L3L--.cjs} +3 -3
- package/dist/{input-wrapper-BetB7OLQ.js → input-wrapper-B4TCGGwj.js} +3 -3
- package/dist/{link-DXnoMJIo.cjs → link-BWAhHUku.cjs} +2 -2
- package/dist/{link-DkO7a3Fs.js → link-BvjWWWlc.js} +1 -1
- package/dist/{linkcard-aVKL5JPP.js → linkcard-6CbGf4I_.js} +1 -1
- package/dist/{linkcard-2l6z1M2U.cjs → linkcard-D6fRaZSc.cjs} +2 -2
- package/dist/{loader-D23kzlaR.cjs → loader-B5t78Yk7.cjs} +2 -2
- package/dist/{loader-CRVUJ-HU.js → loader-BS7EJqxD.js} +1 -1
- package/dist/{messagebox-CqI6_Ah7.js → messagebox-Bt0IvUlD.js} +1 -1
- package/dist/{messagebox-DP06cyqc.cjs → messagebox-DBVUz-DN.cjs} +2 -2
- package/dist/{modal-Bh0DGVfN.cjs → modal-C1g2fiUq.cjs} +2 -2
- package/dist/{modal-C7eV5vJr.js → modal-z5RzZ-fr.js} +1 -1
- package/dist/pkt-accordion.cjs +1 -1
- package/dist/pkt-accordion.js +1 -1
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +1 -1
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +1 -1
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +1 -1
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +1 -1
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-consent.cjs +1 -1
- package/dist/pkt-consent.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-fileupload.cjs +1 -1
- package/dist/pkt-fileupload.js +1 -1
- package/dist/pkt-footer.cjs +1 -1
- package/dist/pkt-footer.js +1 -1
- package/dist/pkt-header-menu.cjs +1 -1
- package/dist/pkt-header-menu.js +1 -1
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-heading.cjs +1 -1
- package/dist/pkt-heading.js +1 -1
- package/dist/pkt-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +28 -28
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-link.cjs +1 -1
- package/dist/pkt-link.js +1 -1
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +1 -1
- package/dist/pkt-loader.cjs +1 -1
- package/dist/pkt-loader.js +1 -1
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/{pkt-options-controller-CJPuBqvH.cjs → pkt-options-controller-AFYyv3-b.cjs} +1 -1
- package/dist/{pkt-options-controller-DNDUGQno.js → pkt-options-controller-DKkmDDzT.js} +1 -1
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/pkt-tabs.cjs +1 -1
- package/dist/pkt-tabs.js +1 -1
- package/dist/pkt-tag.cjs +1 -1
- package/dist/pkt-tag.js +1 -1
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +1 -1
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +1 -1
- package/dist/pkt-timepicker.cjs +1 -1
- package/dist/pkt-timepicker.js +1 -1
- package/dist/{radiobutton-C3nmL9rA.cjs → radiobutton-BuOLykKo.cjs} +1 -1
- package/dist/{radiobutton-B2e9Vyp8.js → radiobutton-Dr5OQ0IY.js} +1 -1
- package/dist/{select-qxjHJ8bu.cjs → select-Cc7c9dRd.cjs} +2 -2
- package/dist/{select-B7TvZGIL.js → select-Cd_saUE7.js} +4 -4
- package/dist/shared-types/calendar.d.ts +67 -0
- package/dist/shared-types/index.d.ts +2 -1
- package/dist/{tabs-C_tCCdBK.js → tabs-DHvCjUi4.js} +6 -3
- package/dist/{tabs-DBanbSG1.cjs → tabs-DqzPOdi9.cjs} +3 -3
- package/dist/{tag-BDlwKjgT.cjs → tag-Cojf4jgA.cjs} +3 -3
- package/dist/{tag-CdiDs9zb.js → tag-D2Xvsy1i.js} +18 -18
- package/dist/{textarea-YL6JYsB5.js → textarea-MJvpE_yV.js} +7 -4
- package/dist/{textarea-DgFwd2LY.cjs → textarea-xTcafucE.cjs} +2 -2
- package/dist/{textinput-CIxMtaIo.cjs → textinput-B4VnZzsa.cjs} +2 -2
- package/dist/{textinput-CrJYDOHb.js → textinput-Cr7Z9ilH.js} +7 -4
- package/dist/{timepicker-avaMu1hN.cjs → timepicker-85ViMBd6.cjs} +2 -2
- package/dist/{timepicker-BHWOqlr8.js → timepicker-srjt12dI.js} +3 -3
- package/package.json +2 -2
- package/src/components/calendar/calendar.ts +8 -9
- package/src/components/checkbox/checkbox.ts +5 -4
- package/src/components/datepicker/datepicker.ts +1 -1
- package/src/components/heading/heading.ts +9 -13
- package/src/components/tabs/tabs.ts +4 -1
- package/src/components/tag/tag.ts +8 -4
- package/src/components/textarea/textarea.ts +10 -4
- package/src/components/textinput/textinput.ts +10 -4
- package/dist/heading-BAoIzzJO.cjs +0 -1
|
@@ -25,6 +25,7 @@ export declare class PktCheckbox extends PktInputElement<Props> {
|
|
|
25
25
|
connectedCallback(): void;
|
|
26
26
|
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
27
27
|
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
28
|
+
protected willUpdate(changedProperties: PropertyValues): void;
|
|
28
29
|
protected updated(changedProperties: PropertyValues): void;
|
|
29
30
|
render(): import('lit-html').TemplateResult<1>;
|
|
30
31
|
private handleInput;
|
|
@@ -17,7 +17,7 @@ export declare class PktHeading extends PktElementWithSlot<IPktHeading> implemen
|
|
|
17
17
|
weight: TPktHeadingWeight | undefined;
|
|
18
18
|
visuallyHidden: boolean;
|
|
19
19
|
align: 'start' | 'center' | 'end' | undefined;
|
|
20
|
-
protected
|
|
20
|
+
protected willUpdate(_changedProperties: PropertyValues): void;
|
|
21
21
|
private get defaultSizeForLevel();
|
|
22
22
|
private get defaultWeightForLevel();
|
|
23
23
|
private get headingClasses();
|
|
@@ -16,7 +16,8 @@ export declare class PktTabs extends PktElementWithSlot<IPktTabs> implements IPk
|
|
|
16
16
|
private tabCount;
|
|
17
17
|
private get useArrowNav();
|
|
18
18
|
private context;
|
|
19
|
-
|
|
19
|
+
protected willUpdate(changedProperties: PropertyValues): void;
|
|
20
|
+
updated(): void;
|
|
20
21
|
private syncSeparators;
|
|
21
22
|
private registerTab;
|
|
22
23
|
private isTabDisabled;
|
|
@@ -36,7 +36,7 @@ export declare class PktTag extends PktElementWithSlot<IPktTag> implements IPktT
|
|
|
36
36
|
/**
|
|
37
37
|
* Lifecycle
|
|
38
38
|
*/
|
|
39
|
-
protected
|
|
39
|
+
protected willUpdate(_changedProperties: PropertyValues): void;
|
|
40
40
|
/**
|
|
41
41
|
* Element functions
|
|
42
42
|
*/
|
|
@@ -11,6 +11,7 @@ export declare class PktTextarea extends PktInputElement<Props> {
|
|
|
11
11
|
cols: number | null;
|
|
12
12
|
counterCurrent: number;
|
|
13
13
|
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
14
|
+
protected willUpdate(changedProperties: PropertyValues): void;
|
|
14
15
|
updated(changedProperties: PropertyValues): void;
|
|
15
16
|
render(): import('lit-html').TemplateResult<1>;
|
|
16
17
|
}
|
|
@@ -15,6 +15,7 @@ export declare class PktTextinput extends PktInputElement<Props> {
|
|
|
15
15
|
omitSearchIcon: boolean;
|
|
16
16
|
counterCurrent: number;
|
|
17
17
|
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
18
|
+
protected willUpdate(changedProperties: PropertyValues): void;
|
|
18
19
|
updated(changedProperties: PropertyValues): void;
|
|
19
20
|
render(): import('lit-html').TemplateResult<1>;
|
|
20
21
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-DRc10X2R.cjs");require("./button-
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs");require("./button-CIb0IxTg.cjs");var t={i18n:{nb:{contentPresentation:{title:`Oslo kommune bruker informasjonskapsler`,description:[`For at nettstedet skal fungere og være trygt, bruker Oslo kommune informasjonskapsler. Noen er teknisk nødvendige, mens andre sikrer ulik funksjonalitet.`,`Godtar du alle informasjonskapsler, tillater du også at vi samler inn data om statistikk og brukeradferd. Da hjelper du oss med å lage et bedre nettsted uten at du trenger å dele noe personlig informasjon med oss.`],buttons:{accept:`Godta alle`,reject:`Kun nødvendige`,settings:`Innstillinger for informasjonskapsler`}},contentSettings:{title:`Innstillinger for informasjonskapsler`,description:[`Her kan du velge hvilke typer informasjonskapsler du vil tillate. Tillatelsen gjelder i 90 dager. Husk at nødvendige informasjonskapsler ikke kan velges bort.`,`Du kan når som helst endre innstillingene og finne mer informasjon nederst på nettstedet under «Innstillinger for informasjonskapsler» og «Personvern og informasjonskapsler».`],buttons:{back:`Tilbake`,save:`Lagre innstillinger`}}},en:{contentPresentation:{title:`Before you visit Oslo kommune ...`,description:[`This website uses cookies to make improvements. In this context, we need your consent to measure the traffic on the website in relation to statistics and feedback.`,`To read more about what we use cookies for, go to our privacy declaration which you will find at the bottom of our websites.`],buttons:{accept:`Yes, I accept`,reject:`Only necessary`,settings:`Go to settings`}},contentSettings:{title:`Her kan du aktivt velge mellom ulike informasjonskapsler`,description:[`For å lese mer om hva vi bruker informasjonskapsler til gå til vår personvernserklering som du finner på våre nettsider`],buttons:{back:`Back`,save:`Save settings`}}}},cookies:[{name:`statistics`,defaultValue:null,i18n:{nb:{title:`Statistikk og analyse`,description:`Jeg godtar at Oslo kommune bruker informasjonskapsler til å innhente data om statistikk og brukeradferd.`,buttons:{yes:`Ja`,no:`Nei`}},en:{title:`Statistics and analytics`,description:`Select your preference for statistics and analytics`,buttons:{yes:`Yes`,no:`No`}}}},{name:`survey`,defaultValue:null,i18n:{nb:{title:`Skriftlige tilbakemeldinger`,description:`Jeg godtar at Oslo kommune bruker informasjonskapsler til å vise responsfelt og registrere tilbakemeldinger.`,buttons:{yes:`Ja`,no:`Nei`}},en:{title:`Survey`,description:`Select your preference for survey`,buttons:{yes:`Yes`,no:`No`}}}},{name:`functional`,defaultValue:!0,i18n:{nb:{title:`Funksjonelle informasjonskapsler`,description:`Jeg godtar at Oslo kommune bruker informasjonskapsler for å gjøre ulike funksjoner på nettstedet mulige (for eksempel skjemaer og barnehagevelger).`,buttons:{yes:`Ja`,no:`Nei`}},en:{title:`Functional cookies`,description:`For the website to function optimally, we recommend that you accept these cookies`,buttons:{yes:`Yes`,no:`No`}}}}]},n=null;function r(){return n||(n=new Promise((e,t)=>{if(document.querySelector(`#oslo-consent-script`)){e();return}let n=document.createElement(`script`);n.src=`https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.js`,n.id=`oslo-consent-script`,n.onload=()=>e(),n.onerror=t,document.head.appendChild(n);let r=document.createElement(`link`);r.href=`https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.css`,r.type=`text/css`,r.rel=`stylesheet`,r.id=`oslo-consent-styles`,document.head.appendChild(r)}),n)}var i=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}},a=e=>i(e.value).items.reduce((e,t)=>(e[t.name]=t.consent,e),{}),o=class extends e.t{constructor(...e){super(...e),this.devMode=!1,this.hotjarId=null,this.googleAnalyticsId=null,this.cookieDomain=null,this.cookieSecure=null,this.cookieExpiryDays=null,this.triggerType=`button`,this.triggerText=null,this.i18nLanguage=`nb`}connectedCallback(){super.connectedCallback();let e=this.i18nLanguage;this.triggerText=this.triggerText||t.i18n[e].contentPresentation.buttons.settings}disconnectedCallback(){super.disconnectedCallback(),this._cookieEventHandler&&window.__cookieEvents?.off(`CookieManager.setCookie`,this._cookieEventHandler)}returnJsonOrObject(e){return i(e)}emitCookieConsents(e){this.dispatchEvent(new CustomEvent(`toggle-consent`,{detail:a(e),bubbles:!0,cancelable:!1}))}async firstUpdated(e){window.cookieBanner_googleAnalyticsId=this.googleAnalyticsId,window.cookieBanner_hotjarId=this.hotjarId,this.cookieDomain&&(window.cookieBanner_cookieDomain=this.cookieDomain),this.cookieSecure&&(window.cookieBanner_cookieSecure=this.cookieSecure),this.cookieExpiryDays&&(window.cookieBanner_cookieExpiryDays=this.cookieExpiryDays),this.devMode&&(window.cookieBanner_devMode=this.devMode),await r(),this.triggerInit()}triggerInit(){window.document.dispatchEvent(new Event(`CookieBannerReady`,{bubbles:!0,cancelable:!0}));let e=window.cookieBanner,t=window.__cookieEvents;!e||!t||e.cookieConsent.validateConsentCookie().then(n=>{if(!n)return;let r=e.cookieConsent.getConsentCookie();window.setTimeout(()=>this.emitCookieConsents({value:r}),0),this._cookieEventHandler&&t.off(`CookieManager.setCookie`,this._cookieEventHandler),this._cookieEventHandler=e=>this.emitCookieConsents(e),t.on(`CookieManager.setCookie`,this._cookieEventHandler)})}openModal(e){e.preventDefault(),window.cookieBanner?.cookieConsent||this.triggerInit(),setTimeout(()=>window.cookieBanner?.openCookieModal())}render(){return this.triggerType===`link`?e._`<a href="#" class="pkt-link" aria-haspopup="dialog" @click=${this.openModal}
|
|
2
2
|
>${this.triggerText}</a
|
|
3
3
|
>`:this.triggerType===`footerlink`?e._`<a
|
|
4
4
|
href="#"
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { _ as e, d as t, h as n, l as r, n as i, s as a, t as o, u as s } from "./element-e2MAMNEP.js";
|
|
2
2
|
import { t as c } from "./class-map-BL_YL_Ed.js";
|
|
3
3
|
import { t as l } from "./if-defined-r8tKY4tG.js";
|
|
4
|
-
import {
|
|
4
|
+
import { r as ee } from "./element-with-slot-GwTT3WRD.js";
|
|
5
5
|
import "./icon-jEFbKTB_.js";
|
|
6
6
|
import { n as u, t as d } from "./ref-lE1mGUOL.js";
|
|
7
7
|
import { a as f, c as p, d as m, h, i as g, m as _, n as v, r as y, s as b, t as x, u as S } from "./converters-CkjLSYpa.js";
|
|
8
|
-
import "./calendar-
|
|
9
|
-
import "./tag-
|
|
8
|
+
import "./calendar-CBghTpkZ.js";
|
|
9
|
+
import "./tag-D2Xvsy1i.js";
|
|
10
10
|
import { t as C } from "./repeat-CCnTfedv.js";
|
|
11
11
|
import { n as w, t as T } from "./utils-BwF4QSrq.js";
|
|
12
|
-
import { t as E } from "./input-element-
|
|
13
|
-
import "./input-wrapper-
|
|
12
|
+
import { t as E } from "./input-element-zXKo9jpe.js";
|
|
13
|
+
import "./input-wrapper-B4TCGGwj.js";
|
|
14
14
|
//#region src/components/datepicker/date-tags.ts
|
|
15
15
|
var D = class extends o {
|
|
16
16
|
constructor(...e) {
|
|
@@ -1130,7 +1130,7 @@ var $ = class extends E {
|
|
|
1130
1130
|
i([s({
|
|
1131
1131
|
type: String,
|
|
1132
1132
|
reflect: !0
|
|
1133
|
-
})], $.prototype, "value", null), i([s({
|
|
1133
|
+
})], $.prototype, "value", null), i([r()], $.prototype, "_value", void 0), i([s({
|
|
1134
1134
|
type: String,
|
|
1135
1135
|
reflect: !0
|
|
1136
1136
|
})], $.prototype, "label", void 0), i([s({ type: String })], $.prototype, "dateformat", void 0), i([s({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./if-defined-BeVQnl3C.cjs"),r=require("./element-with-slot-
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./if-defined-BeVQnl3C.cjs"),r=require("./element-with-slot-DgtT8lCH.cjs");require("./icon-DBFTFd-J.cjs");const i=require("./ref-BkV4Cd8U.cjs"),a=require("./converters-BJ9Fe0kW.cjs");require("./calendar-CA1mz04B.cjs"),require("./tag-Cojf4jgA.cjs");const o=require("./repeat-uBgVG8Ch.cjs"),s=require("./utils-63cRpWut.cjs"),c=require("./input-element-uajHIWAO.cjs");require("./input-wrapper-791L3L--.cjs");var l=class extends e.t{constructor(...e){super(...e),this.dates=[],this.dateformat=`dd.MM.yyyy`,this.className=`pkt-datepicker__tags`,this.idBase=s.n()}render(){return this.classes={"pkt-date-tags":!0,[this.className]:!0},e._`
|
|
2
2
|
<div class=${t.t(this.classes)} aria-live="polite">
|
|
3
3
|
${Array.isArray(this.dates)&&this.dates[0]?o.t(a.h((this.dates??[]).filter(Boolean)),e=>e,t=>e._` <pkt-tag
|
|
4
4
|
id=${this.idBase+t+`-tag`}
|
|
@@ -261,7 +261,7 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
261
261
|
.ariaDescribedby=${this.ariaDescribedby}
|
|
262
262
|
.size=${this.inputSize}
|
|
263
263
|
>
|
|
264
|
-
<div class="pkt-contents" slot="helptext">${r.
|
|
264
|
+
<div class="pkt-contents" slot="helptext">${r.r(this,`helptext`)}</div>
|
|
265
265
|
${this.multiple?e._`<pkt-date-tags
|
|
266
266
|
.dates=${this._value}
|
|
267
267
|
dateformat=${this.dateformat}
|
|
@@ -274,4 +274,4 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
274
274
|
</div>
|
|
275
275
|
</pkt-input-wrapper>
|
|
276
276
|
${this.renderCalendar()}
|
|
277
|
-
`}handleCalendarPosition(){let e=this.multiple&&!!this.maxlength;E.handleCalendarPosition(this.popupRef,this.inputRef,e)}async showCalendar(){let e=this.datepickerPopupRef.value;if(this.calendarOpen=!0,e&&typeof e.show==`function`){e.show(),d()&&e.focusOnCurrentDate();return}await s.t(20),this.handleCalendarPosition(),d()&&this.calRef.value?.focusOnCurrentDate()}hideCalendar(){let e=this.datepickerPopupRef.value;if(this.calendarOpen=!1,e&&typeof e.hide==`function`)return e.hide()}async toggleCalendar(e){e.preventDefault();let t=this.datepickerPopupRef.value;if(t&&typeof t.toggle==`function`){let e=!!t.open;t.toggle(),this.calendarOpen=!e;return}this.calendarOpen?this.hideCalendar():this.showCalendar()}clearInputValue(){this._value=[],this.value=``,this.internals.setFormValue(this.value),this.dispatchEvent(new Event(`change`,{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`value-change`,{detail:this._value,bubbles:!0,composed:!0}))}};e.n([e.u({type:String,reflect:!0})],F.prototype,`value`,null),e.n([e.u({type:String,reflect:!0})],F.prototype,`label`,void 0),e.n([e.u({type:String})],F.prototype,`dateformat`,void 0),e.n([e.u({type:Boolean,reflect:!0})],F.prototype,`multiple`,void 0),e.n([e.u({type:Number,reflect:!0})],F.prototype,`maxlength`,void 0),e.n([e.u({type:Boolean,reflect:!0})],F.prototype,`range`,void 0),e.n([e.u({type:Boolean,attribute:`show-range-labels`})],F.prototype,`showRangeLabels`,void 0),e.n([e.u({type:String,reflect:!0})],F.prototype,`min`,void 0),e.n([e.u({type:String,reflect:!0})],F.prototype,`max`,void 0),e.n([e.u({type:Boolean})],F.prototype,`weeknumbers`,void 0),e.n([e.u({type:Boolean,reflect:!0})],F.prototype,`withcontrols`,void 0),e.n([e.u({converter:a.t.csvToArray})],F.prototype,`excludedates`,void 0),e.n([e.u({converter:a.t.csvToArray})],F.prototype,`excludeweekdays`,void 0),e.n([e.u({type:String})],F.prototype,`currentmonth`,void 0),e.n([e.u({type:String})],F.prototype,`today`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`calendar-open`})],F.prototype,`calendarOpen`,void 0),e.n([e.u({type:String})],F.prototype,`timezone`,void 0),e.n([e.l()],F.prototype,`inputClasses`,void 0);try{e.d(`pkt-datepicker`)(F)}catch{console.warn(`Forsøker å definere <pkt-datepicker>, men den er allerede definert`)}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return F}});
|
|
277
|
+
`}handleCalendarPosition(){let e=this.multiple&&!!this.maxlength;E.handleCalendarPosition(this.popupRef,this.inputRef,e)}async showCalendar(){let e=this.datepickerPopupRef.value;if(this.calendarOpen=!0,e&&typeof e.show==`function`){e.show(),d()&&e.focusOnCurrentDate();return}await s.t(20),this.handleCalendarPosition(),d()&&this.calRef.value?.focusOnCurrentDate()}hideCalendar(){let e=this.datepickerPopupRef.value;if(this.calendarOpen=!1,e&&typeof e.hide==`function`)return e.hide()}async toggleCalendar(e){e.preventDefault();let t=this.datepickerPopupRef.value;if(t&&typeof t.toggle==`function`){let e=!!t.open;t.toggle(),this.calendarOpen=!e;return}this.calendarOpen?this.hideCalendar():this.showCalendar()}clearInputValue(){this._value=[],this.value=``,this.internals.setFormValue(this.value),this.dispatchEvent(new Event(`change`,{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`value-change`,{detail:this._value,bubbles:!0,composed:!0}))}};e.n([e.u({type:String,reflect:!0})],F.prototype,`value`,null),e.n([e.l()],F.prototype,`_value`,void 0),e.n([e.u({type:String,reflect:!0})],F.prototype,`label`,void 0),e.n([e.u({type:String})],F.prototype,`dateformat`,void 0),e.n([e.u({type:Boolean,reflect:!0})],F.prototype,`multiple`,void 0),e.n([e.u({type:Number,reflect:!0})],F.prototype,`maxlength`,void 0),e.n([e.u({type:Boolean,reflect:!0})],F.prototype,`range`,void 0),e.n([e.u({type:Boolean,attribute:`show-range-labels`})],F.prototype,`showRangeLabels`,void 0),e.n([e.u({type:String,reflect:!0})],F.prototype,`min`,void 0),e.n([e.u({type:String,reflect:!0})],F.prototype,`max`,void 0),e.n([e.u({type:Boolean})],F.prototype,`weeknumbers`,void 0),e.n([e.u({type:Boolean,reflect:!0})],F.prototype,`withcontrols`,void 0),e.n([e.u({converter:a.t.csvToArray})],F.prototype,`excludedates`,void 0),e.n([e.u({converter:a.t.csvToArray})],F.prototype,`excludeweekdays`,void 0),e.n([e.u({type:String})],F.prototype,`currentmonth`,void 0),e.n([e.u({type:String})],F.prototype,`today`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`calendar-open`})],F.prototype,`calendarOpen`,void 0),e.n([e.u({type:String})],F.prototype,`timezone`,void 0),e.n([e.l()],F.prototype,`inputClasses`,void 0);try{e.d(`pkt-datepicker`)(F)}catch{console.warn(`Forsøker å definere <pkt-datepicker>, men den er allerede definert`)}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return F}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./element-DRc10X2R.cjs"),t=require("./async-directive-DlB0Sf4j.cjs");function n(e){return e.classList&&(e.classList.contains(`_dialog_overlay`)||e.classList.contains(`backdrop`))?!0:typeof e.hasAttribute==`function`&&e.hasAttribute(`data-skip`)}function r(e){return e.nodeName===`OPTION`||e.nodeName===`DATA`}function i(e){return e.nodeType===Node.TEXT_NODE&&e.nodeValue?.trim()!==``}var a=new WeakMap;function o(e){let t=a.get(e);return t||(t=new d(e),a.set(e,t)),t}var s=Symbol(`default`);function c(e){return e===void 0?s:e}function l(e,t){if(e.nodeType===Node.COMMENT_NODE)return!1;if(e.nodeType===Node.TEXT_NODE)return i(e)?(u(t,s,e),!0):!1;if(e.nodeType===Node.ELEMENT_NODE){let i=e;if(n(i)||r(i))return!1;if(i instanceof HTMLTemplateElement){let e=Array.from(i.content.childNodes),n=c(i.getAttribute(`slot`)??void 0);for(let r of e)u(t,n,r);return!0}let a=i.getAttribute(`slot`);return u(t,a===null?s:c(a),e),!0}return!1}function u(e,t,n){let r=e.get(t);r||(r=[],e.set(t,r)),r.push(n)}var d=class e{static{this.PLACEHOLDER_PREFIX=`pkt-slot`}constructor(e){this.observer=null,this.nodesBySlot=new Map,this.directives=new Set,this.observing=!1,this.trackedNodes=new Set,this.generation=0,this.initialCollectionDone=!1,this.processingMutations=!1,this.placeholderToNode=new Map,this.nodeToPlaceholder=new Map,this.host=e}collectNodes(){if(this.initialCollectionDone)return;this.initialCollectionDone=!0,this.generation++;let e=Array.from(this.host.childNodes);for(let t of e)l(t,this.nodesBySlot)&&this.trackedNodes.add(t)}addDirective(e){this.directives.add(e),this.startObserving()}removeDirective(e){this.directives.delete(e),this.directives.size===0&&this.stopObserving()}getNodes(e){return this.nodesBySlot.get(c(e))??[]}hasContent(e){return this.getNodes(e).length>0}ensurePlaceholder(t){if(this.nodeToPlaceholder.has(t)||t.parentNode!==this.host)return;let n=document.createComment(e.PLACEHOLDER_PREFIX);this.host.insertBefore(n,t),this.placeholderToNode.set(n,t),this.nodeToPlaceholder.set(t,n)}startObserving(){this.observing||(this.observing=!0,setTimeout(()=>{this.observing&&(this.observer=new MutationObserver(e=>{this.handleMutations(e)}),this.observer.observe(this.host,{childList:!0}))},0))}stopObserving(){this.observing&&(this.observing=!1,this.observer?.disconnect(),this.observer=null)}handleMutations(e){if(this.processingMutations)return;this.processingMutations=!0;let t=!1;for(let n of e)if(n.target===this.host){for(let e of n.removedNodes){let n=this.placeholderToNode.get(e);if(n){n.parentNode?.removeChild(n),this.trackedNodes.delete(n),this.removeFromSlots(n),this.placeholderToNode.delete(e),this.nodeToPlaceholder.delete(n),t=!0;continue}if(this.trackedNodes.has(e)){this.trackedNodes.delete(e),this.removeFromSlots(e);let n=this.nodeToPlaceholder.get(e);n&&(n.parentNode?.removeChild(n),this.placeholderToNode.delete(n),this.nodeToPlaceholder.delete(e)),t=!0}}for(let e of n.addedNodes)this.placeholderToNode.has(e)||!this.trackedNodes.has(e)&&this.isUserContent(e)&&l(e,this.nodesBySlot)&&(this.trackedNodes.add(e),t=!0)}t&&(this.generation++,this.notifyDirectives()),this.observer?.takeRecords(),this.processingMutations=!1}isUserContent(e){if(e.nodeType===Node.COMMENT_NODE)return!1;if(e.nodeType===Node.TEXT_NODE)return i(e);if(e.nodeType===Node.ELEMENT_NODE){let t=e;return!(n(t)||r(t))}return!1}removeFromSlots(e){for(let[t,n]of this.nodesBySlot){let r=n.indexOf(e);if(r!==-1){n.splice(r,1),n.length===0&&this.nodesBySlot.delete(t);return}}}notifyDirectives(){for(let e of this.directives)e.handleNodesChanged()}},f=class extends t.t{constructor(t){if(super(t),this.manager=null,this.lastGeneration=-1,t.type!==e.m.CHILD)throw Error(`slotContent() can only be used in child expressions`)}render(t,n){return e.g}update(e,[t,n]){return this.slotName=n,this.manager||(this.manager=o(t),this.manager.collectNodes(),this.manager.addDirective(this)),this.ensurePlaceholders(),this.getNodesOrNoChange()}handleNodesChanged(){if(!this.isConnected||!this.manager)return;this.ensurePlaceholders();let t=this.getNodesOrNoChange();t!==e.g&&this.setValue(t)}ensurePlaceholders(){if(!this.manager)return;let e=this.manager.getNodes(this.slotName);for(let t of e)this.manager.ensurePlaceholder(t)}disconnected(){this.manager?.removeDirective(this),this.manager=null,this.lastGeneration=-1}reconnected(){}getNodesOrNoChange(){if(!this.manager)return e.g;let t=this.manager.generation;return t===this.lastGeneration?e.g:(this.lastGeneration=t,this.manager.getNodes(this.slotName))}},p=e.f(f),m=class extends e.t{connectedCallback(){o(this).collectNodes(),super.connectedCallback()}hasSlotContent(e){return o(this).hasContent(e)}};Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs"),t=require("./async-directive-DlB0Sf4j.cjs");function n(e){return e.classList&&(e.classList.contains(`_dialog_overlay`)||e.classList.contains(`backdrop`))?!0:typeof e.hasAttribute==`function`&&e.hasAttribute(`data-skip`)}function r(e){return e.nodeName===`OPTION`||e.nodeName===`DATA`}function i(e){return e.nodeType===Node.TEXT_NODE&&e.nodeValue?.trim()!==``}var a=new WeakMap;function o(e){let t=a.get(e);return t||(t=new d(e),a.set(e,t)),t}var s=Symbol(`default`);function c(e){return e===void 0?s:e}function l(e,t){if(e.nodeType===Node.COMMENT_NODE)return!1;if(e.nodeType===Node.TEXT_NODE)return i(e)?(u(t,s,e),!0):!1;if(e.nodeType===Node.ELEMENT_NODE){let i=e;if(n(i)||r(i))return!1;if(i instanceof HTMLTemplateElement){let e=Array.from(i.content.childNodes),n=c(i.getAttribute(`slot`)??void 0);for(let r of e)u(t,n,r);return!0}let a=i.getAttribute(`slot`);return u(t,a===null?s:c(a),e),!0}return!1}function u(e,t,n){let r=e.get(t);r||(r=[],e.set(t,r)),r.push(n)}var d=class e{static{this.PLACEHOLDER_PREFIX=`pkt-slot`}constructor(e){this.observer=null,this.nodesBySlot=new Map,this.directives=new Set,this.observing=!1,this.trackedNodes=new Set,this.generation=0,this.initialCollectionDone=!1,this.processingMutations=!1,this.placeholderToNode=new Map,this.nodeToPlaceholder=new Map,this.host=e}collectNodes(){if(this.initialCollectionDone)return;this.initialCollectionDone=!0,this.generation++;let e=Array.from(this.host.childNodes);for(let t of e)l(t,this.nodesBySlot)&&this.trackedNodes.add(t)}addDirective(e){this.directives.add(e),this.startObserving()}removeDirective(e){this.directives.delete(e),this.directives.size===0&&this.stopObserving()}getNodes(e){return this.nodesBySlot.get(c(e))??[]}hasContent(e){return this.getNodes(e).length>0}ensurePlaceholder(t){if(this.nodeToPlaceholder.has(t)||t.parentNode!==this.host)return;let n=document.createComment(e.PLACEHOLDER_PREFIX);this.host.insertBefore(n,t),this.placeholderToNode.set(n,t),this.nodeToPlaceholder.set(t,n)}startObserving(){this.observing||(this.observing=!0,setTimeout(()=>{this.observing&&(this.observer=new MutationObserver(e=>{this.handleMutations(e)}),this.observer.observe(this.host,{childList:!0}))},0))}stopObserving(){this.observing&&(this.observing=!1,this.observer?.disconnect(),this.observer=null)}handleMutations(e){if(this.processingMutations)return;this.processingMutations=!0;let t=!1;for(let n of e)if(n.target===this.host){for(let e of n.removedNodes){let n=this.placeholderToNode.get(e);if(n){n.parentNode?.removeChild(n),this.trackedNodes.delete(n),this.removeFromSlots(n),this.placeholderToNode.delete(e),this.nodeToPlaceholder.delete(n),t=!0;continue}if(this.trackedNodes.has(e)){this.trackedNodes.delete(e),this.removeFromSlots(e);let n=this.nodeToPlaceholder.get(e);n&&(n.parentNode?.removeChild(n),this.placeholderToNode.delete(n),this.nodeToPlaceholder.delete(e)),t=!0}}for(let e of n.addedNodes)this.placeholderToNode.has(e)||!this.trackedNodes.has(e)&&this.isUserContent(e)&&l(e,this.nodesBySlot)&&(this.trackedNodes.add(e),t=!0)}t&&(this.generation++,this.notifyDirectives()),this.observer?.takeRecords(),this.processingMutations=!1}isUserContent(e){if(e.nodeType===Node.COMMENT_NODE)return!1;if(e.nodeType===Node.TEXT_NODE)return i(e);if(e.nodeType===Node.ELEMENT_NODE){let t=e;return!(n(t)||r(t))}return!1}removeFromSlots(e){for(let[t,n]of this.nodesBySlot){let r=n.indexOf(e);if(r!==-1){n.splice(r,1),n.length===0&&this.nodesBySlot.delete(t);return}}}notifyDirectives(){for(let e of this.directives)e.handleNodesChanged()}},f=class extends t.t{constructor(t){if(super(t),this.manager=null,this.lastGeneration=-1,t.type!==e.m.CHILD)throw Error(`slotContent() can only be used in child expressions`)}render(t,n){return e.g}update(e,[t,n]){return this.slotName=n,this.manager||(this.manager=o(t),this.manager.collectNodes(),this.manager.addDirective(this)),this.ensurePlaceholders(),this.getNodesOrNoChange()}handleNodesChanged(){if(!this.isConnected||!this.manager)return;this.ensurePlaceholders();let t=this.getNodesOrNoChange();t!==e.g&&this.setValue(t)}ensurePlaceholders(){if(!this.manager)return;let e=this.manager.getNodes(this.slotName);for(let t of e)this.manager.ensurePlaceholder(t)}disconnected(){this.manager?.removeDirective(this),this.manager=null,this.lastGeneration=-1}reconnected(){}getNodesOrNoChange(){if(!this.manager)return e.g;let t=this.manager.generation;return t===this.lastGeneration?e.g:(this.lastGeneration=t,this.manager.getNodes(this.slotName))}},p=e.f(f),m=class extends e.t{connectedCallback(){o(this).collectNodes(),super.connectedCallback()}hasSlotContent(e){return o(this).hasContent(e)}};Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return m}});
|
|
@@ -2,13 +2,13 @@ import { _ as e, d as t, l as n, n as r, s as i, t as a, u as o } from "./elemen
|
|
|
2
2
|
import { t as s } from "./class-map-BL_YL_Ed.js";
|
|
3
3
|
import { t as c } from "./if-defined-r8tKY4tG.js";
|
|
4
4
|
import { n as l, t as u } from "./format-BTeSVkED.js";
|
|
5
|
-
import "./alert-
|
|
5
|
+
import "./alert-CayKowTW.js";
|
|
6
6
|
import "./icon-jEFbKTB_.js";
|
|
7
7
|
import { t as d } from "./converters-CkjLSYpa.js";
|
|
8
8
|
import { n as f } from "./utils-BwF4QSrq.js";
|
|
9
|
-
import "./input-wrapper-
|
|
9
|
+
import "./input-wrapper-B4TCGGwj.js";
|
|
10
10
|
import { r as p } from "./focus-trap-DG3pEuyJ.js";
|
|
11
|
-
import "./modal-
|
|
11
|
+
import "./modal-z5RzZ-fr.js";
|
|
12
12
|
import "./progressbar-BPHLC7ce.js";
|
|
13
13
|
//#region ../../shared-utils/fileupload/size.ts
|
|
14
14
|
function m(e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./if-defined-BeVQnl3C.cjs"),r=require("./format-B8meU8Tm.cjs");require("./alert-DqM9l5as.cjs"),require("./icon-DBFTFd-J.cjs");const i=require("./converters-BJ9Fe0kW.cjs"),a=require("./utils-63cRpWut.cjs");require("./input-wrapper-CS0qrYcm.cjs");const o=require("./focus-trap-DSv4Ifqm.cjs");require("./modal-Bh0DGVfN.cjs"),require("./progressbar-BpcsDCnG.cjs");function s(e){if(e==null||e===``)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=String(e).trim(),n=Number(t);if(!Number.isNaN(n)&&n>0)return n;let r=t.match(/^(\d+(?:\.\d+)?)\s*(B|KB|MB|GB)$/i);if(!r){console.warn(`PktFileUpload: Invalid maxFileSize format "${t}". Use format like "5MB", "500KB", "1GB", or bytes.`);return}let i=parseFloat(r[1]);switch(r[2].toUpperCase()){case`B`:return i;case`KB`:return i*1024;case`MB`:return i*1024*1024;case`GB`:return i*1024*1024*1024;default:return}}function c(e){return e<1024?`${Math.round(e)} B`:e<1048576?`${Math.round(e/1024)} KB`:e<1073741824?`${Math.round(e/1048576)} MB`:`${Math.round(e/1073741824)} GB`}function l(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function u(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function d(e,t,n){let r=e.toLowerCase().replace(/^\./,``);if(r.includes(`/`)){if(r.endsWith(`/*`)){let e=r.replace(`/*`,``);return n.startsWith(`${e}/`)}return n===r}return t===r}function f(e,t){let n=l(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>d(e,r,i))}function p(e,t){let n=(e??``).trim();if(n)return n;let r=l(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function m(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function h(e,t){let n=l(e);if(n.length>0)return n.map(m).join(`, `);let r=u(t);return r.length>0?r.map(m).join(`, `):``}function g(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function _(t,n){let r=l(n.allowedFormats);if(r.length>0&&!f(t,r)){let t=r.join(`, `),i=e.s.fileupload.invalidFormat;return g(n.formatErrorMessage,i,{formats:t})}let i=s(n.maxFileSize);if(i!==void 0&&t.size>i){let t=c(i),r=e.s.fileupload.sizeTooLarge;return g(n.sizeErrorMessage,r,{maxSize:t})}if(n.onFileValidation){let e=n.onFileValidation(t);if(e)return e}return null}function v(e){let t=e.file;if(t?.type?.startsWith(`image/`))return!0;let n=e.attributes?.targetFilename||t?.name||``;return/\.(jpe?g|png|gif|webp|heic|heif|bmp|svg)$/i.test(n)}function y(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function b(e,t,n){let r={"in-progress":0,error:1,idle:2};return e.map(e=>{let r=t?.find(t=>t.fileId===e.fileId);return{...e,progress:r?.progress??(n===`form`?`done`:`queued`),errorMessage:r?.errorMessage,showProgress:r?.showProgress,lastProgress:r?.lastProgress}}).sort((e,t)=>r[y(e.progress)]-r[y(t.progress)])}function x(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function S(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function C(e,t){let n=e.length;if(n===0||!t||t.length===0)return{totalCount:n,uploadedCount:0,failedCount:0};let r=0,i=0;for(let n of e){let e=t.find(e=>e.fileId===n.fileId);e?.progress===`done`?r++:e?.progress===`error`&&i++}return{totalCount:n,uploadedCount:r,failedCount:i}}function w(t,n=e.s.fileupload.unknownFilename){return t.attributes?.targetFilename||t.file?.name||n}var T=class extends e.t{constructor(...e){super(...e),this.id=`pkt-fileupload-${a.n()}`,this.name=`files`,this.label=``,this.helptext=``,this.helptextDropdown=``,this.required=!1,this.multiple=!1,this.disabled=!1,this.fullwidth=!1,this.uploadStrategy=`form`,this.itemRenderer=`filename`,this.accept=``,this.allowedFormats=[],this.formatErrorMessage=``,this.sizeErrorMessage=``,this.transfers=[],this.addCommentsEnabled=!1,this.renameFilesEnabled=!1,this.extraOperations=[],this.enableImagePreview=!1,this.hasError=!1,this.errorMessage=``,this.optionalTag=!1,this.requiredTag=!1,this.tagText=null,this.truncateTail=4,this.files=[],this.isDragActive=!1,this.validationErrorMessage=null,this.addedAnnouncement=``,this.thumbnailUrls={},this.hasInitializedValue=!1,this.hasWarnedInvalidValueCombo=!1,this.thumbnailFileById=new Map,this.connectedForm=null,this.addedAnnouncementTimer=null,this.onNativeFileChange=e=>{let t=e.target;this.addFiles(t.files?Array.from(t.files):[]),this.uploadStrategy===`custom`&&(t.value=``)},this.openFileDialog=e=>{e.preventDefault(),e.stopPropagation(),!this.disabled&&this.querySelector(`#${this.id}-input`)?.click()},this.onDropZoneClick=e=>{this.disabled||e.target.closest(`.pkt-fileupload__drop-zone__placeholder__title__open-file-dialog`)||this.querySelector(`#${this.id}-input`)?.click()},this.onDragOver=e=>{e.preventDefault(),!this.disabled&&(this.isDragActive=!0)},this.onDragLeave=()=>{this.isDragActive=!1},this.onDrop=e=>{if(e.preventDefault(),this.isDragActive=!1,this.disabled)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this.addFiles(t)},this.onHostFormSubmit=e=>{!this.required||this.uploadStrategy!==`custom`||this.getCurrentFiles().length>0||(this.validationErrorMessage=this.requiredSelectionMessage,e.preventDefault())}}get requiredSelectionMessage(){return this.pktStrings.get(`fileupload`).requiredMissing}get isControlled(){return this.value!==void 0}get hasEffectiveError(){return!!this.validationErrorMessage||this.hasError||!!this.errorMessage.trim()}get effectiveErrorMessage(){return this.validationErrorMessage??this.errorMessage??``}get hasValidationError(){return!!this.validationErrorMessage}firstUpdated(e){super.firstUpdated?.(e),this.hasInitializedValue||=(this.files=this.value??this.defaultValue??[],this.syncThumbnailUrls(this.files),!0),this.value!==void 0&&this.defaultValue!==void 0&&this.warnInvalidValueCombo()}willUpdate(e){super.willUpdate(e),this.hasInitializedValue&&this.isControlled&&(e.has(`value`)||e.has(`itemRenderer`)||e.has(`enableImagePreview`))&&(this.files=this.value??[],this.syncThumbnailUrls(this.files))}updated(e){super.updated(e),(e.has(`uploadStrategy`)||e.has(`required`)||e.has(`value`))&&this.syncFormSubmitListener(),this.uploadStrategy===`form`&&(e.has(`value`)||e.has(`files`)||e.has(`uploadStrategy`))&&this.syncNativeInputFiles()}syncNativeInputFiles(){let e=this.querySelector(`#${this.id}-input`);if(!(!e||typeof DataTransfer>`u`))try{let t=new DataTransfer;for(let e of this.getCurrentFiles())e.file&&t.items.add(e.file);e.files=t.files}catch{}}warnInvalidValueCombo(){this.hasWarnedInvalidValueCombo||=(console.warn(`PktFileUpload: Både value og defaultValue er angitt. Komponenten kan være enten kontrollert eller ukontrollert, ikke begge. value vil bli prioritert.`),!0)}disconnectedCallback(){this.teardownFormSubmitListener(),this.addedAnnouncementTimer&&=(clearTimeout(this.addedAnnouncementTimer),null),super.disconnectedCallback(),this.revokeAllThumbnailUrls()}setAddedAnnouncement(e){this.addedAnnouncement=e,this.addedAnnouncementTimer&&clearTimeout(this.addedAnnouncementTimer),this.addedAnnouncementTimer=setTimeout(()=>{this.addedAnnouncement=``,this.addedAnnouncementTimer=null},1500)}connectedCallback(){super.connectedCallback(),this.syncFormSubmitListener()}addFiles(e){if(e.length===0)return;let t=this.multiple?e:[e[0]];for(let e of t){let t=this.validateFile(e);if(t){this.validationErrorMessage=t;return}}this.validationErrorMessage=null;let n=t.map(e=>({fileId:a.n(),file:e,attributes:{targetFilename:e.name}})),i=this.pktStrings.get(`fileupload`);this.setAddedAnnouncement(n.length===1?r.t(i.srFileAdded,{filename:n[0].attributes.targetFilename}):r.t(i.srFilesAdded,{count:n.length}));let o=this.getCurrentFiles(),s=this.multiple?[...o,...n]:[n[0]];this.commitFiles(s,`add`,n.map(e=>e.fileId)),this.uploadStrategy===`custom`&&n.forEach(e=>{this.dispatchEvent(new CustomEvent(`file-upload-requested`,{detail:{fileId:e.fileId,file:e.file,attributes:e.attributes},bubbles:!0,composed:!0}))})}getCurrentFiles(){return this.isControlled?this.value??[]:this.files}cancelTransfer(e){if(this.disabled)return;let t=this.getCurrentFiles().find(t=>t.fileId===e);t&&(this.removeFileItem(e),this.dispatchEvent(new CustomEvent(`transfer-cancelled`,{detail:{fileId:t.fileId,file:t.file,attributes:t.attributes},bubbles:!0,composed:!0})))}removeFileItem(e){if(this.disabled)return;let t=this.getCurrentFiles(),n=t.filter(t=>t.fileId!==e);n.length!==t.length&&this.commitFiles(n,`remove`,[e])}updateFileItem(e,t){let n=this.getCurrentFiles().map(n=>n.fileId===e?{...n,...t}:n);this.commitFiles(n,`update`,[e])}commitFiles(e,t,n){this.isControlled||(this.files=e,this.syncThumbnailUrls(e)),this.validationErrorMessage===this.requiredSelectionMessage&&e.length>0&&(this.validationErrorMessage=null),this.dispatchEvent(new CustomEvent(`files-changed`,{detail:{files:e,reason:t,changedFileIds:n},bubbles:!0,composed:!0}))}getThumbnailUrl(e){return this.thumbnailUrls[e.fileId]}getTransferProgress(e){let t=this.transfers.find(t=>t.fileId===e);return t?t.progress:this.uploadStrategy===`form`?`done`:`queued`}getTransferForFile(e){return this.transfers.find(t=>t.fileId===e)}isImageFile(e){return v(e)}formatFileSize(e){return c(e)}getResolvedAcceptValue(){return p(this.accept,this.allowedFormats)}getSupportedFormatsText(){return h(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return b(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=_(e,{allowedFormats:this.allowedFormats,maxFileSize:this.maxFileSize,formatErrorMessage:this.formatErrorMessage,sizeErrorMessage:this.sizeErrorMessage,onFileValidation:this.onFileValidation});if(t)return t;let n={file:e,errorMessage:null},r=new CustomEvent(`file-validate`,{detail:n,bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(r),n.errorMessage?n.errorMessage:r.defaultPrevented?this.pktStrings.get(`fileupload`).genericValidationRejection:null}syncThumbnailUrls(e){if(!(typeof URL<`u`&&typeof URL.createObjectURL==`function`&&typeof URL.revokeObjectURL==`function`)){this.thumbnailUrls={},this.thumbnailFileById.clear();return}let t=new Set(e.map(e=>e.fileId)),n={};for(let[e,n]of Object.entries(this.thumbnailUrls))t.has(e)||(URL.revokeObjectURL(n),this.thumbnailFileById.delete(e));for(let t of e){let e=this.thumbnailUrls[t.fileId],r=this.thumbnailFileById.get(t.fileId);if(!t.file||!this.isImageFile(t)){e&&(URL.revokeObjectURL(e),this.thumbnailFileById.delete(t.fileId));continue}if(e&&r===t.file){n[t.fileId]=e;continue}e&&r!==t.file&&URL.revokeObjectURL(e);let i=URL.createObjectURL(t.file);this.thumbnailFileById.set(t.fileId,t.file),n[t.fileId]=i}this.thumbnailUrls=n}revokeAllThumbnailUrls(){if(typeof URL>`u`||typeof URL.revokeObjectURL!=`function`){this.thumbnailUrls={},this.thumbnailFileById.clear();return}Object.values(this.thumbnailUrls).forEach(e=>URL.revokeObjectURL(e)),this.thumbnailUrls={},this.thumbnailFileById.clear()}getSrUploadedMessage(){if(this.addedAnnouncement)return this.addedAnnouncement;let{totalCount:e,uploadedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let n=this.pktStrings.get(`fileupload`);return r.t(n.srFilesUploadedOfTotal,{uploaded:t,total:e,label:r.n(e,n.fileLabelOne,n.fileLabelOther)})}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let n=this.pktStrings.get(`fileupload`);return r.t(n.srFilesFailedOfTotal,{failed:t,total:e,label:r.n(e,n.fileLabelOne,n.fileLabelOther)})}syncFormSubmitListener(){let e=this.closest(`form`);this.connectedForm!==e&&(this.teardownFormSubmitListener(),this.connectedForm=e,this.connectedForm&&this.connectedForm.addEventListener(`submit`,this.onHostFormSubmit))}teardownFormSubmitListener(){this.connectedForm&&=(this.connectedForm.removeEventListener(`submit`,this.onHostFormSubmit),null)}};e.n([e.u({type:String})],T.prototype,`id`,void 0),e.n([e.u({type:String})],T.prototype,`name`,void 0),e.n([e.u({type:String})],T.prototype,`label`,void 0),e.n([e.u({type:String})],T.prototype,`helptext`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown`})],T.prototype,`helptextDropdown`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown-button`})],T.prototype,`helptextDropdownButton`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`required`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`multiple`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`disabled`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`fullwidth`})],T.prototype,`fullwidth`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`upload-strategy`})],T.prototype,`uploadStrategy`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`item-renderer`})],T.prototype,`itemRenderer`,void 0),e.n([e.u({type:String})],T.prototype,`accept`,void 0),e.n([e.u({converter:i.t.csvToArray,attribute:`allowed-formats`})],T.prototype,`allowedFormats`,void 0),e.n([e.u({type:String,attribute:`format-error-message`})],T.prototype,`formatErrorMessage`,void 0),e.n([e.u({attribute:`max-file-size`})],T.prototype,`maxFileSize`,void 0),e.n([e.u({type:String,attribute:`size-error-message`})],T.prototype,`sizeErrorMessage`,void 0),e.n([e.u({attribute:!1})],T.prototype,`onFileValidation`,void 0),e.n([e.u({attribute:!1})],T.prototype,`transfers`,void 0),e.n([e.u({type:Boolean,attribute:`add-comments-enabled`})],T.prototype,`addCommentsEnabled`,void 0),e.n([e.u({type:Boolean,attribute:`rename-files-enabled`})],T.prototype,`renameFilesEnabled`,void 0),e.n([e.u({attribute:!1})],T.prototype,`extraOperations`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],T.prototype,`enableImagePreview`,void 0),e.n([e.u({type:Boolean,attribute:`has-error`})],T.prototype,`hasError`,void 0),e.n([e.u({type:String,attribute:`error-message`})],T.prototype,`errorMessage`,void 0),e.n([e.u({type:Boolean,attribute:`optional-tag`})],T.prototype,`optionalTag`,void 0),e.n([e.u({type:String,attribute:`optional-text`})],T.prototype,`optionalText`,void 0),e.n([e.u({type:Boolean,attribute:`required-tag`})],T.prototype,`requiredTag`,void 0),e.n([e.u({type:String,attribute:`required-text`})],T.prototype,`requiredText`,void 0),e.n([e.u({type:String,attribute:`tag-text`})],T.prototype,`tagText`,void 0),e.n([e.u({type:Number,attribute:`truncate-tail`})],T.prototype,`truncateTail`,void 0),e.n([e.u({attribute:!1})],T.prototype,`value`,void 0),e.n([e.u({attribute:!1})],T.prototype,`defaultValue`,void 0),e.n([e.l()],T.prototype,`files`,void 0),e.n([e.l()],T.prototype,`isDragActive`,void 0),e.n([e.l()],T.prototype,`validationErrorMessage`,void 0),e.n([e.l()],T.prototype,`addedAnnouncement`,void 0),e.n([e.l()],T.prototype,`thumbnailUrls`,void 0);var E=`comments`,D=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:`${String(t.getDate()).padStart(2,`0`)}.${String(t.getMonth()+1).padStart(2,`0`)}.${t.getFullYear()} kl. ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`},O=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},k=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},A=e=>({id:`remove`,title:`Slett`,ariaLabel:`Slett fil`,onClick:({file:t})=>e(t.fileId)}),j=()=>({id:`rename`,title:`Rediger`,ariaLabel:`Rediger filnavn`,renderInlineUI:t=>{let n=t.getAttribute(`targetFilename`)||t.file.attributes?.targetFilename||t.file.file?.name||``,r=`pkt-fileupload-rename-${t.file.fileId}`,i=()=>{let e=document.getElementById(r)?.value?.trim();e&&t.setAttribute(`targetFilename`,e),t.close()};return e._`
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./if-defined-BeVQnl3C.cjs"),r=require("./format-B8meU8Tm.cjs");require("./alert-HFqn-cvb.cjs"),require("./icon-DBFTFd-J.cjs");const i=require("./converters-BJ9Fe0kW.cjs"),a=require("./utils-63cRpWut.cjs");require("./input-wrapper-791L3L--.cjs");const o=require("./focus-trap-DSv4Ifqm.cjs");require("./modal-C1g2fiUq.cjs"),require("./progressbar-BpcsDCnG.cjs");function s(e){if(e==null||e===``)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=String(e).trim(),n=Number(t);if(!Number.isNaN(n)&&n>0)return n;let r=t.match(/^(\d+(?:\.\d+)?)\s*(B|KB|MB|GB)$/i);if(!r){console.warn(`PktFileUpload: Invalid maxFileSize format "${t}". Use format like "5MB", "500KB", "1GB", or bytes.`);return}let i=parseFloat(r[1]);switch(r[2].toUpperCase()){case`B`:return i;case`KB`:return i*1024;case`MB`:return i*1024*1024;case`GB`:return i*1024*1024*1024;default:return}}function c(e){return e<1024?`${Math.round(e)} B`:e<1048576?`${Math.round(e/1024)} KB`:e<1073741824?`${Math.round(e/1048576)} MB`:`${Math.round(e/1073741824)} GB`}function l(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function u(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function d(e,t,n){let r=e.toLowerCase().replace(/^\./,``);if(r.includes(`/`)){if(r.endsWith(`/*`)){let e=r.replace(`/*`,``);return n.startsWith(`${e}/`)}return n===r}return t===r}function f(e,t){let n=l(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>d(e,r,i))}function p(e,t){let n=(e??``).trim();if(n)return n;let r=l(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function m(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function h(e,t){let n=l(e);if(n.length>0)return n.map(m).join(`, `);let r=u(t);return r.length>0?r.map(m).join(`, `):``}function g(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function _(t,n){let r=l(n.allowedFormats);if(r.length>0&&!f(t,r)){let t=r.join(`, `),i=e.s.fileupload.invalidFormat;return g(n.formatErrorMessage,i,{formats:t})}let i=s(n.maxFileSize);if(i!==void 0&&t.size>i){let t=c(i),r=e.s.fileupload.sizeTooLarge;return g(n.sizeErrorMessage,r,{maxSize:t})}if(n.onFileValidation){let e=n.onFileValidation(t);if(e)return e}return null}function v(e){let t=e.file;if(t?.type?.startsWith(`image/`))return!0;let n=e.attributes?.targetFilename||t?.name||``;return/\.(jpe?g|png|gif|webp|heic|heif|bmp|svg)$/i.test(n)}function y(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function b(e,t,n){let r={"in-progress":0,error:1,idle:2};return e.map(e=>{let r=t?.find(t=>t.fileId===e.fileId);return{...e,progress:r?.progress??(n===`form`?`done`:`queued`),errorMessage:r?.errorMessage,showProgress:r?.showProgress,lastProgress:r?.lastProgress}}).sort((e,t)=>r[y(e.progress)]-r[y(t.progress)])}function x(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function S(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function C(e,t){let n=e.length;if(n===0||!t||t.length===0)return{totalCount:n,uploadedCount:0,failedCount:0};let r=0,i=0;for(let n of e){let e=t.find(e=>e.fileId===n.fileId);e?.progress===`done`?r++:e?.progress===`error`&&i++}return{totalCount:n,uploadedCount:r,failedCount:i}}function w(t,n=e.s.fileupload.unknownFilename){return t.attributes?.targetFilename||t.file?.name||n}var T=class extends e.t{constructor(...e){super(...e),this.id=`pkt-fileupload-${a.n()}`,this.name=`files`,this.label=``,this.helptext=``,this.helptextDropdown=``,this.required=!1,this.multiple=!1,this.disabled=!1,this.fullwidth=!1,this.uploadStrategy=`form`,this.itemRenderer=`filename`,this.accept=``,this.allowedFormats=[],this.formatErrorMessage=``,this.sizeErrorMessage=``,this.transfers=[],this.addCommentsEnabled=!1,this.renameFilesEnabled=!1,this.extraOperations=[],this.enableImagePreview=!1,this.hasError=!1,this.errorMessage=``,this.optionalTag=!1,this.requiredTag=!1,this.tagText=null,this.truncateTail=4,this.files=[],this.isDragActive=!1,this.validationErrorMessage=null,this.addedAnnouncement=``,this.thumbnailUrls={},this.hasInitializedValue=!1,this.hasWarnedInvalidValueCombo=!1,this.thumbnailFileById=new Map,this.connectedForm=null,this.addedAnnouncementTimer=null,this.onNativeFileChange=e=>{let t=e.target;this.addFiles(t.files?Array.from(t.files):[]),this.uploadStrategy===`custom`&&(t.value=``)},this.openFileDialog=e=>{e.preventDefault(),e.stopPropagation(),!this.disabled&&this.querySelector(`#${this.id}-input`)?.click()},this.onDropZoneClick=e=>{this.disabled||e.target.closest(`.pkt-fileupload__drop-zone__placeholder__title__open-file-dialog`)||this.querySelector(`#${this.id}-input`)?.click()},this.onDragOver=e=>{e.preventDefault(),!this.disabled&&(this.isDragActive=!0)},this.onDragLeave=()=>{this.isDragActive=!1},this.onDrop=e=>{if(e.preventDefault(),this.isDragActive=!1,this.disabled)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this.addFiles(t)},this.onHostFormSubmit=e=>{!this.required||this.uploadStrategy!==`custom`||this.getCurrentFiles().length>0||(this.validationErrorMessage=this.requiredSelectionMessage,e.preventDefault())}}get requiredSelectionMessage(){return this.pktStrings.get(`fileupload`).requiredMissing}get isControlled(){return this.value!==void 0}get hasEffectiveError(){return!!this.validationErrorMessage||this.hasError||!!this.errorMessage.trim()}get effectiveErrorMessage(){return this.validationErrorMessage??this.errorMessage??``}get hasValidationError(){return!!this.validationErrorMessage}firstUpdated(e){super.firstUpdated?.(e),this.hasInitializedValue||=(this.files=this.value??this.defaultValue??[],this.syncThumbnailUrls(this.files),!0),this.value!==void 0&&this.defaultValue!==void 0&&this.warnInvalidValueCombo()}willUpdate(e){super.willUpdate(e),this.hasInitializedValue&&this.isControlled&&(e.has(`value`)||e.has(`itemRenderer`)||e.has(`enableImagePreview`))&&(this.files=this.value??[],this.syncThumbnailUrls(this.files))}updated(e){super.updated(e),(e.has(`uploadStrategy`)||e.has(`required`)||e.has(`value`))&&this.syncFormSubmitListener(),this.uploadStrategy===`form`&&(e.has(`value`)||e.has(`files`)||e.has(`uploadStrategy`))&&this.syncNativeInputFiles()}syncNativeInputFiles(){let e=this.querySelector(`#${this.id}-input`);if(!(!e||typeof DataTransfer>`u`))try{let t=new DataTransfer;for(let e of this.getCurrentFiles())e.file&&t.items.add(e.file);e.files=t.files}catch{}}warnInvalidValueCombo(){this.hasWarnedInvalidValueCombo||=(console.warn(`PktFileUpload: Både value og defaultValue er angitt. Komponenten kan være enten kontrollert eller ukontrollert, ikke begge. value vil bli prioritert.`),!0)}disconnectedCallback(){this.teardownFormSubmitListener(),this.addedAnnouncementTimer&&=(clearTimeout(this.addedAnnouncementTimer),null),super.disconnectedCallback(),this.revokeAllThumbnailUrls()}setAddedAnnouncement(e){this.addedAnnouncement=e,this.addedAnnouncementTimer&&clearTimeout(this.addedAnnouncementTimer),this.addedAnnouncementTimer=setTimeout(()=>{this.addedAnnouncement=``,this.addedAnnouncementTimer=null},1500)}connectedCallback(){super.connectedCallback(),this.syncFormSubmitListener()}addFiles(e){if(e.length===0)return;let t=this.multiple?e:[e[0]];for(let e of t){let t=this.validateFile(e);if(t){this.validationErrorMessage=t;return}}this.validationErrorMessage=null;let n=t.map(e=>({fileId:a.n(),file:e,attributes:{targetFilename:e.name}})),i=this.pktStrings.get(`fileupload`);this.setAddedAnnouncement(n.length===1?r.t(i.srFileAdded,{filename:n[0].attributes.targetFilename}):r.t(i.srFilesAdded,{count:n.length}));let o=this.getCurrentFiles(),s=this.multiple?[...o,...n]:[n[0]];this.commitFiles(s,`add`,n.map(e=>e.fileId)),this.uploadStrategy===`custom`&&n.forEach(e=>{this.dispatchEvent(new CustomEvent(`file-upload-requested`,{detail:{fileId:e.fileId,file:e.file,attributes:e.attributes},bubbles:!0,composed:!0}))})}getCurrentFiles(){return this.isControlled?this.value??[]:this.files}cancelTransfer(e){if(this.disabled)return;let t=this.getCurrentFiles().find(t=>t.fileId===e);t&&(this.removeFileItem(e),this.dispatchEvent(new CustomEvent(`transfer-cancelled`,{detail:{fileId:t.fileId,file:t.file,attributes:t.attributes},bubbles:!0,composed:!0})))}removeFileItem(e){if(this.disabled)return;let t=this.getCurrentFiles(),n=t.filter(t=>t.fileId!==e);n.length!==t.length&&this.commitFiles(n,`remove`,[e])}updateFileItem(e,t){let n=this.getCurrentFiles().map(n=>n.fileId===e?{...n,...t}:n);this.commitFiles(n,`update`,[e])}commitFiles(e,t,n){this.isControlled||(this.files=e,this.syncThumbnailUrls(e)),this.validationErrorMessage===this.requiredSelectionMessage&&e.length>0&&(this.validationErrorMessage=null),this.dispatchEvent(new CustomEvent(`files-changed`,{detail:{files:e,reason:t,changedFileIds:n},bubbles:!0,composed:!0}))}getThumbnailUrl(e){return this.thumbnailUrls[e.fileId]}getTransferProgress(e){let t=this.transfers.find(t=>t.fileId===e);return t?t.progress:this.uploadStrategy===`form`?`done`:`queued`}getTransferForFile(e){return this.transfers.find(t=>t.fileId===e)}isImageFile(e){return v(e)}formatFileSize(e){return c(e)}getResolvedAcceptValue(){return p(this.accept,this.allowedFormats)}getSupportedFormatsText(){return h(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return b(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=_(e,{allowedFormats:this.allowedFormats,maxFileSize:this.maxFileSize,formatErrorMessage:this.formatErrorMessage,sizeErrorMessage:this.sizeErrorMessage,onFileValidation:this.onFileValidation});if(t)return t;let n={file:e,errorMessage:null},r=new CustomEvent(`file-validate`,{detail:n,bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(r),n.errorMessage?n.errorMessage:r.defaultPrevented?this.pktStrings.get(`fileupload`).genericValidationRejection:null}syncThumbnailUrls(e){if(!(typeof URL<`u`&&typeof URL.createObjectURL==`function`&&typeof URL.revokeObjectURL==`function`)){this.thumbnailUrls={},this.thumbnailFileById.clear();return}let t=new Set(e.map(e=>e.fileId)),n={};for(let[e,n]of Object.entries(this.thumbnailUrls))t.has(e)||(URL.revokeObjectURL(n),this.thumbnailFileById.delete(e));for(let t of e){let e=this.thumbnailUrls[t.fileId],r=this.thumbnailFileById.get(t.fileId);if(!t.file||!this.isImageFile(t)){e&&(URL.revokeObjectURL(e),this.thumbnailFileById.delete(t.fileId));continue}if(e&&r===t.file){n[t.fileId]=e;continue}e&&r!==t.file&&URL.revokeObjectURL(e);let i=URL.createObjectURL(t.file);this.thumbnailFileById.set(t.fileId,t.file),n[t.fileId]=i}this.thumbnailUrls=n}revokeAllThumbnailUrls(){if(typeof URL>`u`||typeof URL.revokeObjectURL!=`function`){this.thumbnailUrls={},this.thumbnailFileById.clear();return}Object.values(this.thumbnailUrls).forEach(e=>URL.revokeObjectURL(e)),this.thumbnailUrls={},this.thumbnailFileById.clear()}getSrUploadedMessage(){if(this.addedAnnouncement)return this.addedAnnouncement;let{totalCount:e,uploadedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let n=this.pktStrings.get(`fileupload`);return r.t(n.srFilesUploadedOfTotal,{uploaded:t,total:e,label:r.n(e,n.fileLabelOne,n.fileLabelOther)})}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let n=this.pktStrings.get(`fileupload`);return r.t(n.srFilesFailedOfTotal,{failed:t,total:e,label:r.n(e,n.fileLabelOne,n.fileLabelOther)})}syncFormSubmitListener(){let e=this.closest(`form`);this.connectedForm!==e&&(this.teardownFormSubmitListener(),this.connectedForm=e,this.connectedForm&&this.connectedForm.addEventListener(`submit`,this.onHostFormSubmit))}teardownFormSubmitListener(){this.connectedForm&&=(this.connectedForm.removeEventListener(`submit`,this.onHostFormSubmit),null)}};e.n([e.u({type:String})],T.prototype,`id`,void 0),e.n([e.u({type:String})],T.prototype,`name`,void 0),e.n([e.u({type:String})],T.prototype,`label`,void 0),e.n([e.u({type:String})],T.prototype,`helptext`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown`})],T.prototype,`helptextDropdown`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown-button`})],T.prototype,`helptextDropdownButton`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`required`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`multiple`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`disabled`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`fullwidth`})],T.prototype,`fullwidth`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`upload-strategy`})],T.prototype,`uploadStrategy`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`item-renderer`})],T.prototype,`itemRenderer`,void 0),e.n([e.u({type:String})],T.prototype,`accept`,void 0),e.n([e.u({converter:i.t.csvToArray,attribute:`allowed-formats`})],T.prototype,`allowedFormats`,void 0),e.n([e.u({type:String,attribute:`format-error-message`})],T.prototype,`formatErrorMessage`,void 0),e.n([e.u({attribute:`max-file-size`})],T.prototype,`maxFileSize`,void 0),e.n([e.u({type:String,attribute:`size-error-message`})],T.prototype,`sizeErrorMessage`,void 0),e.n([e.u({attribute:!1})],T.prototype,`onFileValidation`,void 0),e.n([e.u({attribute:!1})],T.prototype,`transfers`,void 0),e.n([e.u({type:Boolean,attribute:`add-comments-enabled`})],T.prototype,`addCommentsEnabled`,void 0),e.n([e.u({type:Boolean,attribute:`rename-files-enabled`})],T.prototype,`renameFilesEnabled`,void 0),e.n([e.u({attribute:!1})],T.prototype,`extraOperations`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],T.prototype,`enableImagePreview`,void 0),e.n([e.u({type:Boolean,attribute:`has-error`})],T.prototype,`hasError`,void 0),e.n([e.u({type:String,attribute:`error-message`})],T.prototype,`errorMessage`,void 0),e.n([e.u({type:Boolean,attribute:`optional-tag`})],T.prototype,`optionalTag`,void 0),e.n([e.u({type:String,attribute:`optional-text`})],T.prototype,`optionalText`,void 0),e.n([e.u({type:Boolean,attribute:`required-tag`})],T.prototype,`requiredTag`,void 0),e.n([e.u({type:String,attribute:`required-text`})],T.prototype,`requiredText`,void 0),e.n([e.u({type:String,attribute:`tag-text`})],T.prototype,`tagText`,void 0),e.n([e.u({type:Number,attribute:`truncate-tail`})],T.prototype,`truncateTail`,void 0),e.n([e.u({attribute:!1})],T.prototype,`value`,void 0),e.n([e.u({attribute:!1})],T.prototype,`defaultValue`,void 0),e.n([e.l()],T.prototype,`files`,void 0),e.n([e.l()],T.prototype,`isDragActive`,void 0),e.n([e.l()],T.prototype,`validationErrorMessage`,void 0),e.n([e.l()],T.prototype,`addedAnnouncement`,void 0),e.n([e.l()],T.prototype,`thumbnailUrls`,void 0);var E=`comments`,D=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:`${String(t.getDate()).padStart(2,`0`)}.${String(t.getMonth()+1).padStart(2,`0`)}.${t.getFullYear()} kl. ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`},O=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},k=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},A=e=>({id:`remove`,title:`Slett`,ariaLabel:`Slett fil`,onClick:({file:t})=>e(t.fileId)}),j=()=>({id:`rename`,title:`Rediger`,ariaLabel:`Rediger filnavn`,renderInlineUI:t=>{let n=t.getAttribute(`targetFilename`)||t.file.attributes?.targetFilename||t.file.file?.name||``,r=`pkt-fileupload-rename-${t.file.fileId}`,i=()=>{let e=document.getElementById(r)?.value?.trim();e&&t.setAttribute(`targetFilename`,e),t.close()};return e._`
|
|
2
2
|
<label for=${r} class="pkt-sr-only">Endre filnavn</label>
|
|
3
3
|
<input
|
|
4
4
|
id=${r}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-DRc10X2R.cjs"),t=require("./if-defined-BeVQnl3C.cjs");require("./consent-
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs"),t=require("./if-defined-BeVQnl3C.cjs");require("./consent-D1SMUJLs.cjs"),require("./icon-DBFTFd-J.cjs");const n=require("./booleanish-BF8l4scU.cjs"),r=require("./fetch-header-footer-data-CUKV0biS.cjs");var i=`oslo.kommune.no`,a=/\.(?:co|com|org|net|gov|edu|ac|kommune)\.[a-z]{2}$/i;function o(e){let t=e.toLowerCase().replace(/\.$/,``),n=t.split(`.`);return n.length<=2?t:n.slice(a.test(t)?-3:-2).join(`.`)}function s(e){if(!e)return;let t;try{t=new URL(e)}catch{return}if(t.protocol===`http:`||t.protocol===`https:`)return o(t.hostname.toLowerCase().replace(/\.$/,``))}function c(e,t=i){if(!e)return;let n;try{n=new URL(e)}catch{return}if(n.protocol!==`http:`&&n.protocol!==`https:`)return;let r=n.hostname.toLowerCase().replace(/\.$/,``),a=t.toLowerCase();if(!(r===a||r.endsWith(`.${a}`)))return o(r)}var l=`#cb-trigger`,u=class extends e.t{constructor(...e){super(...e),this.locale=`nb-NO`,this.skipGlobal=!1,this.openLinksInNewTab=!1,this.includeConsent=!1,this.hotjarId=null,this.googleAnalyticsId=null,this.devMode=!1,this.cookieDomain=null,this.cookieSecure=null,this.cookieExpiryDays=null}connectedCallback(){super.connectedCallback(),!this.data&&!this.skipGlobal&&this.loadData()}disconnectedCallback(){super.disconnectedCallback(),this.abortController?.abort()}updated(e){super.updated(e),e.has(`dataUrl`)&&e.get(`dataUrl`)!==void 0&&!this.data&&this.loadData()}async loadData(){this.abortController?.abort(),this.abortController=new AbortController;try{this.fetchedData=await r.t(this.dataUrl,this.abortController.signal)}catch(e){if(e.name===`AbortError`)return;console.warn(`Failed to fetch header/footer data:`,e),this.dispatchEvent(new CustomEvent(`data-error`,{detail:{error:e},bubbles:!0,composed:!0}))}}get globalFooterData(){return r.n(this.data??this.fetchedData,this.locale)?.footer}linkTarget(e){return e.openInNewTab||this.openLinksInNewTab?{target:`_blank`,rel:`noopener noreferrer`}:{target:`_self`}}renderLinkDomain(t,n=`pkt-footer__link-domain`){if(!t.external)return e.h;let r=s(t.href);return r?e._` <span class=${n}>(${r})</span>`:e.h}renderCustomLink(n){let{target:r,rel:i}=this.linkTarget(n);return e._`
|
|
2
2
|
<a href=${n.href} target=${r} rel=${t.t(i)}
|
|
3
3
|
>${n.text}${this.renderLinkDomain(n)}</a
|
|
4
4
|
>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as e, d as t, h as n, l as r, n as i, t as a, u as o } from "./element-e2MAMNEP.js";
|
|
2
2
|
import { t as s } from "./if-defined-r8tKY4tG.js";
|
|
3
|
-
import "./consent-
|
|
3
|
+
import "./consent-Yt1MpkUy.js";
|
|
4
4
|
import "./icon-jEFbKTB_.js";
|
|
5
5
|
import { t as c } from "./booleanish-OQJTYSrw.js";
|
|
6
6
|
import { n as l, r as u, t as d } from "./fetch-header-footer-data-Pc32etrk.js";
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { _ as e, d as t, h as n, l as r, n as i, t as a, u as o } from "./element-e2MAMNEP.js";
|
|
2
2
|
import { t as s } from "./class-map-BL_YL_Ed.js";
|
|
3
3
|
import { t as c } from "./if-defined-r8tKY4tG.js";
|
|
4
|
-
import {
|
|
4
|
+
import { r as l, t as u } from "./element-with-slot-GwTT3WRD.js";
|
|
5
5
|
import "./icon-jEFbKTB_.js";
|
|
6
|
-
import "./button-
|
|
6
|
+
import "./button-DWMHtdWk.js";
|
|
7
7
|
import { n as d, t as f } from "./ref-lE1mGUOL.js";
|
|
8
8
|
import { t as p } from "./booleanish-OQJTYSrw.js";
|
|
9
9
|
import { n as m, o as h, t as g } from "./fetch-header-footer-data-Pc32etrk.js";
|
|
10
10
|
import { n as _, t as v } from "./focus-trap-DG3pEuyJ.js";
|
|
11
11
|
import { n as y, t as b } from "./scroll-lock-DAbNKAUy.js";
|
|
12
|
-
import "./link-
|
|
13
|
-
import "./textinput-
|
|
12
|
+
import "./link-BvjWWWlc.js";
|
|
13
|
+
import "./textinput-Cr7Z9ilH.js";
|
|
14
14
|
import "./searchinput-DrUcPajl.js";
|
|
15
|
-
import "./header-menu-
|
|
15
|
+
import "./header-menu-DKAcUFzh.js";
|
|
16
16
|
//#region ../../shared-types/header.ts
|
|
17
17
|
var x = (e) => typeof e.target == "string" ? {
|
|
18
18
|
title: e.title,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./if-defined-BeVQnl3C.cjs"),r=require("./element-with-slot-
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./if-defined-BeVQnl3C.cjs"),r=require("./element-with-slot-DgtT8lCH.cjs");require("./icon-DBFTFd-J.cjs"),require("./button-CIb0IxTg.cjs");const i=require("./ref-BkV4Cd8U.cjs"),a=require("./booleanish-BF8l4scU.cjs"),o=require("./fetch-header-footer-data-CUKV0biS.cjs"),s=require("./focus-trap-DSv4Ifqm.cjs"),c=require("./scroll-lock-BN8lOhV5.cjs");require("./link-BWAhHUku.cjs"),require("./textinput-B4VnZzsa.cjs"),require("./searchinput-CiPB8xvh.cjs"),require("./header-menu-wcnhBSzs.cjs");var l=e=>typeof e.target==`string`?{title:e.title,iconName:e.iconName,href:e.target}:{title:e.title,iconName:e.iconName,onClick:e.target},u=e=>l(e),d=e=>{if(!e)return;let t=typeof e==`string`?new Date(e):e;if(!isNaN(t.getTime()))return t.toLocaleDateString(`nb-NO`,{day:`numeric`,month:`long`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})},f=class{constructor(e,t){this.isMobile=!1,this.isTablet=!1,this.isHidden=!1,this.pauseScrollHide=!1,this.componentWidth=typeof window<`u`?window.innerWidth:0,this.lastScrollPosition=0,this.scrollLockToken=c.t(),this.lastFocusedElement=null,this.shouldRestoreFocus=!1,this.handleScroll=()=>{if(this.getOptions().scrollBehavior!==`hide`||this.pauseScrollHide)return;let e=window.pageYOffset||document.documentElement.scrollTop;if(e<0||Math.abs(e-this.lastScrollPosition)<60)return;let t=e>this.lastScrollPosition;this.lastScrollPosition=e,t!==this.isHidden&&(this.isHidden=t,this.host.requestUpdate())},this.host=e,this.getOptions=t,e.addController(this)}hostConnected(){window.addEventListener(`scroll`,this.handleScroll)}hostDisconnected(){this.resizeObserver?.disconnect(),window.removeEventListener(`scroll`,this.handleScroll),c.n(this.scrollLockToken,!1)}observe(e){e&&(this.componentWidth=e.offsetWidth,this.refreshBreakpoints(),this.resizeObserver=new ResizeObserver(e=>{for(let t of e)this.componentWidth=t.borderBoxSize&&t.borderBoxSize.length>0?t.borderBoxSize[0].inlineSize:t.contentRect.width,this.refreshBreakpoints()}),this.resizeObserver.observe(e))}refreshBreakpoints(){let{mobileBreakpoint:e,tabletBreakpoint:t}=this.getOptions(),n=this.componentWidth<e,r=this.componentWidth<t;(n!==this.isMobile||r!==this.isTablet)&&(this.isMobile=n,this.isTablet=r,this.host.requestUpdate())}setScrollLock(e){c.n(this.scrollLockToken,e)}captureFocus(){this.lastFocusedElement=document.activeElement}flagRestoreFocus(){this.shouldRestoreFocus=!0}restoreFocus(){this.shouldRestoreFocus&&this.lastFocusedElement&&document.contains(this.lastFocusedElement)&&this.lastFocusedElement.focus(),this.lastFocusedElement=null,this.shouldRestoreFocus=!1}},p=class extends e.t{constructor(...e){super(...e),this.canChangeRepresentation=!1,this.logoutOnClick=!1}handleChangeRepresentation(){this.dispatchEvent(new CustomEvent(`change-representation`,{bubbles:!0,composed:!0}))}handleLogout(){this.dispatchEvent(new CustomEvent(`log-out`,{bubbles:!0,composed:!0}))}handleMenuItemClick(e){`onClick`in e&&typeof e.onClick==`function`&&e.onClick()}renderLinkOrButton(n,r){let i=`href`in n,a=t.t({"pkt-user-menu__link":!0,"pkt-link-button":!i,"pkt-link":!i,"pkt-link--icon-left":!i,[r||``]:!!r});return i?e._`
|
|
2
2
|
<pkt-link
|
|
3
3
|
icon-name=${n.iconName||e.h}
|
|
4
4
|
href=${n.href}
|
|
@@ -143,7 +143,7 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
143
143
|
@click=${this.handleSlotContentClick}
|
|
144
144
|
${i.n(this.slotContentRef)}
|
|
145
145
|
>
|
|
146
|
-
${r.
|
|
146
|
+
${r.r(this)}
|
|
147
147
|
</div>
|
|
148
148
|
</div>
|
|
149
149
|
`}renderSearch(){if(!this.showSearch)return e.h;if(this.isTablet){let n=t.t({"pkt-header-service__search-container":!0,"is-open":this.openMenu===`search`}),r=t.t({"pkt-header-service__mobile-menu":!0,"is-open":this.openMenu===`search`,"align-right":this.alignSearchRight});return e._`
|
|
@@ -460,6 +460,6 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
460
460
|
.userMenu=${this.effectiveUserMenu}
|
|
461
461
|
.representing=${this.representing}
|
|
462
462
|
>
|
|
463
|
-
${this.hasSlotContent()?e._`<div class="pkt-contents">${r.
|
|
463
|
+
${this.hasSlotContent()?e._`<div class="pkt-contents">${r.r(this)}</div>`:e.h}
|
|
464
464
|
</pkt-header-service>
|
|
465
465
|
`}};e.n([e.u({type:String})],S.prototype,`type`,void 0),e.n([e.u({type:String,attribute:`service-name`})],S.prototype,`serviceName`,void 0),e.n([e.u({type:String,attribute:`service-link`})],S.prototype,`serviceLink`,void 0),e.n([e.u({type:String,attribute:`logo-link`})],S.prototype,`logoLink`,void 0),e.n([e.u({type:String,attribute:`logo-path`})],S.prototype,`logoPath`,void 0),e.n([e.u({type:String,attribute:`search-placeholder`})],S.prototype,`searchPlaceholder`,void 0),e.n([e.u({type:String,attribute:`search-value`})],S.prototype,`searchValue`,void 0),e.n([e.u({type:Number,attribute:`mobile-breakpoint`})],S.prototype,`mobileBreakpoint`,void 0),e.n([e.u({type:Number,attribute:`tablet-breakpoint`})],S.prototype,`tabletBreakpoint`,void 0),e.n([e.u({type:String,attribute:`opened-menu`})],S.prototype,`openedMenu`,void 0),e.n([e.u({type:String,attribute:`log-out-button-placement`})],S.prototype,`logOutButtonPlacement`,void 0),e.n([e.u({type:String})],S.prototype,`position`,void 0),e.n([e.u({type:String,attribute:`scroll-behavior`})],S.prototype,`scrollBehavior`,void 0),e.n([e.u({type:String,attribute:`slot-menu-variant`})],S.prototype,`slotMenuVariant`,void 0),e.n([e.u({type:String,attribute:`slot-menu-text`})],S.prototype,`slotMenuText`,void 0),e.n([e.u({type:Boolean,attribute:`hide-logo`,converter:a.t})],S.prototype,`hideLogo`,void 0),e.n([e.u({type:Boolean,converter:a.t})],S.prototype,`compact`,void 0),e.n([e.u({type:Boolean,attribute:`show-search`,converter:a.t})],S.prototype,`showSearch`,void 0),e.n([e.u({type:Boolean,attribute:`can-change-representation`,converter:a.t})],S.prototype,`canChangeRepresentation`,void 0),e.n([e.u({type:Boolean,attribute:`has-log-out`,converter:a.t})],S.prototype,`hasLogOut`,void 0),e.n([e.u({type:Object})],S.prototype,`user`,void 0),e.n([e.u({type:Array,attribute:`user-menu`})],S.prototype,`userMenu`,void 0),e.n([e.u({type:Object})],S.prototype,`representing`,void 0),e.n([e.u({type:String,attribute:`data-url`})],S.prototype,`dataUrl`,void 0),e.n([e.u({type:Object,attribute:!1})],S.prototype,`data`,void 0),e.n([e.u({type:String})],S.prototype,`locale`,void 0),e.n([e.u({type:Boolean,attribute:`show-contact`,converter:a.t})],S.prototype,`showContact`,void 0),e.n([e.u({type:Array,attribute:`user-menu-footer`})],S.prototype,`userMenuFooter`,void 0),e.n([e.u({type:Array,attribute:`user-options`})],S.prototype,`userOptions`,void 0);try{e.d(`pkt-header`)(S)}catch{console.warn(`Forsøker å definere <pkt-header>, men den er allerede definert`)}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return S}});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as e, d as t, h as n, l as r, n as i, t as a, u as o } from "./element-e2MAMNEP.js";
|
|
2
2
|
import { t as s } from "./class-map-BL_YL_Ed.js";
|
|
3
3
|
import "./icon-jEFbKTB_.js";
|
|
4
|
-
import "./accordion-
|
|
4
|
+
import "./accordion-BI-Qiznz.js";
|
|
5
5
|
import { t as c } from "./booleanish-OQJTYSrw.js";
|
|
6
6
|
import { a as l, i as u, n as d, r as f, t as p } from "./fetch-header-footer-data-Pc32etrk.js";
|
|
7
7
|
//#region src/components/header-menu/header-menu.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs");require("./icon-DBFTFd-J.cjs"),require("./accordion-
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs");require("./icon-DBFTFd-J.cjs"),require("./accordion-NO9LYXaN.cjs");const n=require("./booleanish-BF8l4scU.cjs"),r=require("./fetch-header-footer-data-CUKV0biS.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">Laster meny…</p>
|
|
4
4
|
</nav>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { _ as e, d as t, n, u as r } from "./element-e2MAMNEP.js";
|
|
2
|
-
import {
|
|
2
|
+
import { r as i, t as a } from "./element-with-slot-GwTT3WRD.js";
|
|
3
3
|
//#region src/components/heading/heading.ts
|
|
4
4
|
var o = class extends a {
|
|
5
5
|
constructor(...e) {
|
|
6
6
|
super(...e), this.size = void 0, this.level = 2, this.weight = void 0, this.visuallyHidden = !1, this.align = void 0;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
super.
|
|
8
|
+
willUpdate(e) {
|
|
9
|
+
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);
|
|
10
10
|
}
|
|
11
11
|
get defaultSizeForLevel() {
|
|
12
12
|
switch (this.level) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs"),t=require("./element-with-slot-DgtT8lCH.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.r(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
1
|
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-e2MAMNEP.js";
|
|
2
2
|
import { t as o } from "./class-map-BL_YL_Ed.js";
|
|
3
|
-
import {
|
|
3
|
+
import { r as s, t as c } from "./element-with-slot-GwTT3WRD.js";
|
|
4
4
|
import { r as l } from "./icon-jEFbKTB_.js";
|
|
5
5
|
import { n as u } from "./utils-BwF4QSrq.js";
|
|
6
6
|
//#region src/components/helptext/helptext.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./element-with-slot-
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./element-with-slot-DgtT8lCH.cjs"),r=require("./icon-DBFTFd-J.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.r(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">
|