@oslokommune/punkt-elements 16.25.0 → 16.25.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/dist/{alert-BkzC5mVu.js → alert-B5Y841vH.js} +1 -1
- package/dist/{alert-D_45dWPn.cjs → alert-C8OpU_Un.cjs} +1 -1
- package/dist/button-Bqk9wjme.cjs +27 -0
- package/dist/{button-CR-KWhTT.js → button-CAZEaEW9.js} +14 -13
- package/dist/{combobox-D-DY7YcW.js → combobox-BuBvoK-N.js} +1 -1
- package/dist/{combobox-x4tBGP3F.cjs → combobox-DJITmrnM.cjs} +1 -1
- package/dist/components/header/header-service.d.ts +1 -0
- package/dist/components/header/header.d.ts +1 -0
- package/dist/components/header/types.d.ts +2 -0
- package/dist/{consent-BFdURuBl.js → consent-CCesjQ_e.js} +1 -1
- package/dist/{consent-DVt6sMvB.cjs → consent-DkCihETp.cjs} +1 -1
- package/dist/{datepicker-Bs95HYGc.cjs → datepicker-ChEi_INm.cjs} +1 -1
- package/dist/{datepicker-DxkcKevq.js → datepicker-zOOhs9JK.js} +1 -1
- package/dist/{fileupload-bykWTtA6.js → fileupload-BBph8gH3.js} +2 -2
- package/dist/{fileupload-BLto9H17.cjs → fileupload-CGaJlMG9.cjs} +1 -1
- package/dist/{header-gOdqWZ-o.cjs → header-C6z1KhOR.cjs} +6 -5
- package/dist/{header-BdxslVug.js → header-C8dCoJpr.js} +14 -5
- package/dist/{input-wrapper-B6WowlWG.js → input-wrapper-C93MmOIg.js} +1 -1
- package/dist/{input-wrapper-Dhkt20WW.cjs → input-wrapper-CvtU-Ksb.cjs} +1 -1
- package/dist/{loader-gKdQpOOQ.js → loader-B3ToraVk.js} +8 -7
- package/dist/loader-CLf_Phfg.cjs +16 -0
- 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-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-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +13 -13
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-loader.cjs +1 -1
- package/dist/pkt-loader.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.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/{select-BIgFPp42.js → select-Dz3YiN7b.js} +1 -1
- package/dist/{select-DzZHv6Bz.cjs → select-z3hBSk02.cjs} +1 -1
- package/dist/{textarea-qHtkhelz.js → textarea-BxBfLk3N.js} +1 -1
- package/dist/{textarea-M_S9WK7s.cjs → textarea-rHlURXh5.cjs} +1 -1
- package/dist/{textinput-CZrBM-Fj.js → textinput-Bs8DwHwR.js} +1 -1
- package/dist/{textinput-C_6kvf87.cjs → textinput-DSYABvB6.cjs} +1 -1
- package/dist/{timepicker-O0iCeJyW.js → timepicker-Cb9pxkJa.js} +1 -1
- package/dist/{timepicker-WiYLAncb.cjs → timepicker-DVisPbGX.cjs} +1 -1
- package/package.json +2 -2
- package/src/components/button/button.ts +7 -3
- package/src/components/header/header-service.ts +9 -2
- package/src/components/header/header.ts +2 -0
- package/src/components/header/types.ts +2 -0
- package/src/components/loader/loader.ts +7 -3
- package/dist/button-Dwv11n6R.cjs +0 -27
- package/dist/loader-Uap9qDsV.cjs +0 -16
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,40 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
## [16.25.2](https://github.com/oslokommune/punkt/compare/16.25.1...16.25.2) (2026-06-16)
|
|
9
|
+
|
|
10
|
+
### ⚠ BREAKING CHANGES
|
|
11
|
+
Ingen
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
Ingen
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
Ingen
|
|
18
|
+
|
|
19
|
+
### Chores
|
|
20
|
+
Ingen
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [16.25.1](https://github.com/oslokommune/punkt/compare/16.25.0...16.25.1) (2026-06-16)
|
|
26
|
+
|
|
27
|
+
### ⚠ BREAKING CHANGES
|
|
28
|
+
Ingen
|
|
29
|
+
|
|
30
|
+
### Features
|
|
31
|
+
Ingen
|
|
32
|
+
|
|
33
|
+
### Bug Fixes
|
|
34
|
+
Ingen
|
|
35
|
+
|
|
36
|
+
### Chores
|
|
37
|
+
Ingen
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
|
|
8
42
|
## [16.25.0](https://github.com/oslokommune/punkt/compare/16.24.1...16.25.0) (2026-06-12)
|
|
9
43
|
|
|
10
44
|
### ⚠ BREAKING CHANGES
|
|
@@ -3,7 +3,7 @@ import { t as o } from "./class-map-DH9hlJny.js";
|
|
|
3
3
|
import { n as s, t as c } from "./element-with-slot-BVj9MXzi.js";
|
|
4
4
|
import { t as l } from "./classutils-lVbGcvjN.js";
|
|
5
5
|
import "./icon-LaKyBKON.js";
|
|
6
|
-
import "./button-
|
|
6
|
+
import "./button-CAZEaEW9.js";
|
|
7
7
|
var u = {
|
|
8
8
|
name: "pkt-alert",
|
|
9
9
|
react: "PktAlert",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require(`./element-CXAtr6Gu.cjs`),t=require(`./class-map-B8Ja0q7n.cjs`),n=require(`./element-with-slot-Cmxb9h4H.cjs`),r=require(`./classutils-CVTzKF0J.cjs`);require(`./icon-Dw6I0HDV.cjs`),require(`./button-
|
|
1
|
+
const e=require(`./element-CXAtr6Gu.cjs`),t=require(`./class-map-B8Ja0q7n.cjs`),n=require(`./element-with-slot-Cmxb9h4H.cjs`),r=require(`./classutils-CVTzKF0J.cjs`);require(`./icon-Dw6I0HDV.cjs`),require(`./button-Bqk9wjme.cjs`);var i={name:`pkt-alert`,react:`PktAlert`,"css-class":`pkt-alert`,"dark-mode":!0,isElement:!0,isPureReact:!0,events:{onClose:{description:`React: Klikk-event for 'Lukk'-knappen`},close:{description:`Vue: Klikk-event for 'Lukk'-knappen`}},props:{title:{name:`Tittel`,description:`Tittelen som vises øverst i på meldingen`,type:`string`,category:`contents`},skin:{name:`Utseende`,description:`Hvordan type melding er dette?`,type:[`info`,`success`,`warning`,`error`],default:`info`,category:`ui`},date:{name:`Sist oppdatert`,description:`Dato som vises nederst i på meldingen`,type:`string`,category:`contents`},ariaLive:{name:`aria-live`,description:`Hvordan skal skjermleseren lese opp meldingen?`,type:[`off`,`polite`,`assertive`],default:`polite`,category:`accessibility`},compact:{name:`Kompakt`,description:`Gjør meldingen mindre`,type:`boolean`,category:`ui`,default:!1},closeAlert:{name:`Vis 'Lukk'-knapp`,description:`Viser 'Lukk'-knappen`,type:`boolean`,default:!1,category:`ui`}},slots:{default:{description:`Innholdet i meldingen`}}},a=class extends n.t{constructor(){super(),this.compact=i.props.compact.default,this.title=``,this.skin=i.props.skin.default,this.ariaLive=i.props.ariaLive.default,this.ariaLiveAttr=null,this.closeAlert=i.props.closeAlert.default,this.date=null,this.role=`status`,this._isClosed=!1,this.close=e=>{this._isClosed=!0,this.dispatchEvent(new CustomEvent(`close`,{detail:{origin:e},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`on-close`,{detail:{origin:e},bubbles:!0,composed:!0}))},this._isClosed=!1}connectedCallback(){super.connectedCallback(),this.ariaLiveAttr=this.getAttribute(`aria-live`)||this.ariaLive}attributeChangedCallback(e,t,n){e===`ariaLive`&&(this.ariaLiveAttr=n),super.attributeChangedCallback(e,t,n)}updated(e){super.updated(e),e.has(`ariaLive`)&&(this.ariaLiveAttr=this.ariaLive),e.has(`_isClosed`)&&r.t(this,`pkt-hide`,this._isClosed)}render(){let r={"pkt-alert":!0,"pkt-alert--compact":this.compact,[`pkt-alert--${this.skin}`]:this.skin,"pkt-hide":this._isClosed},i={"pkt-alert__grid":!0,"pkt-alert__noTitle":!this.title,"pkt-alert__noDate":!this.date};return e.p`
|
|
2
2
|
<div class=${t.t(r)} aria-live=${this.ariaLiveAttr}>
|
|
3
3
|
<div class=${t.t(i)}>
|
|
4
4
|
<pkt-icon
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const e=require(`./element-CXAtr6Gu.cjs`),t=require(`./class-map-B8Ja0q7n.cjs`),n=require(`./element-with-slot-Cmxb9h4H.cjs`);require(`./icon-Dw6I0HDV.cjs`);const r=require(`./if-defined-LTjAScFG.cjs`);var i=`https://punkt-cdn.oslo.kommune.no/latest/animations/`;typeof window<`u`&&(window.pktAnimationPath=window.pktAnimationPath||i);var a=class extends n.t{constructor(...e){super(...e),this.iconName=`user`,this.secondIconName=`user`,this.mode=`light`,this.size=`medium`,this.fullWidth=!1,this.fullWidthOnMobile=!1,this.skin=`primary`,this.variant=`label-only`,this.state=`normal`,this.type=`button`,this.form=void 0,this.isLoading=!1,this.disabled=!1,this.loadingAnimationPath=typeof window<`u`?window.pktAnimationPath:i}connectedCallback(){super.connectedCallback(),this.addEventListener(`click`,e=>{(this.disabled||this.hasAttribute(`disabled`)||this.isLoading)&&(e.preventDefault(),e.stopImmediatePropagation())},!0),this.addEventListener(`keydown`,e=>{(this.disabled||this.hasAttribute(`disabled`)||this.isLoading)&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopImmediatePropagation())},!0)}attributeChangedCallback(e,t,n){super.attributeChangedCallback(e,t,n),e===`disabled`&&n===`false`&&(this.disabled=!1),(e===`isloading`||e===`isLoading`)&&n===`false`&&(this.isLoading=!1)}firstUpdated(e){super.firstUpdated(e),this.disabled===`false`&&(this.disabled=!1),this.isLoading===`false`&&(this.isLoading=!1)}render(){let i=this.form??this.getAttribute(`form`)??void 0;return e.p`
|
|
2
|
+
<button
|
|
3
|
+
class=${t.t({"pkt-btn":!0,[`pkt-btn--${this.size}`]:!!this.size,[`pkt-btn--${this.skin}`]:!!this.skin,[`pkt-btn--${this.variant}`]:!!this.variant,[`pkt-btn--${this.color}`]:!!this.color,[`pkt-btn--${this.state}`]:!!this.state,"pkt-btn--full":!!this.fullWidth,"pkt-btn--full-small":!!this.fullWidthOnMobile,"pkt-btn--disabled":!!this.disabled,"pkt-btn--isLoading":!!this.isLoading})}
|
|
4
|
+
type=${this.type}
|
|
5
|
+
?disabled=${!!this.disabled}
|
|
6
|
+
aria-busy=${r.t(this.isLoading?`true`:void 0)}
|
|
7
|
+
aria-disabled=${r.t(this.disabled||this.isLoading?`true`:void 0)}
|
|
8
|
+
form=${r.t(i)}
|
|
9
|
+
>
|
|
10
|
+
${this.isLoading?e.p`<pkt-icon
|
|
11
|
+
class="pkt-btn__icon pkt-btn__spinner"
|
|
12
|
+
name="spinner-blue"
|
|
13
|
+
path=${r.t(this.loadingAnimationPath)}
|
|
14
|
+
></pkt-icon>`:e.d}
|
|
15
|
+
${this.variant===`label-only`?e.d:e.p`<pkt-icon
|
|
16
|
+
class="pkt-btn__icon pkt-icon"
|
|
17
|
+
name=${this.iconName}
|
|
18
|
+
path=${r.t(this.iconPath)}
|
|
19
|
+
></pkt-icon>`}
|
|
20
|
+
<span class="pkt-btn__text">${n.n(this)}</span>
|
|
21
|
+
${this.variant===`icons-right-and-left`?e.p`<pkt-icon
|
|
22
|
+
class="pkt-btn__icon"
|
|
23
|
+
name=${this.secondIconName}
|
|
24
|
+
path=${r.t(this.secondIconPath)}
|
|
25
|
+
></pkt-icon>`:e.d}
|
|
26
|
+
</button>
|
|
27
|
+
`}};e.n([e.o({type:String})],a.prototype,`iconName`,void 0),e.n([e.o({type:String})],a.prototype,`secondIconName`,void 0),e.n([e.o({type:String})],a.prototype,`iconPath`,void 0),e.n([e.o({type:String})],a.prototype,`secondIconPath`,void 0),e.n([e.o({type:String})],a.prototype,`mode`,void 0),e.n([e.o({type:String})],a.prototype,`size`,void 0),e.n([e.o({type:Boolean,attribute:`full-width`})],a.prototype,`fullWidth`,void 0),e.n([e.o({type:Boolean,attribute:`full-width-on-mobile`})],a.prototype,`fullWidthOnMobile`,void 0),e.n([e.o({type:String})],a.prototype,`color`,void 0),e.n([e.o({type:String})],a.prototype,`skin`,void 0),e.n([e.o({type:String})],a.prototype,`variant`,void 0),e.n([e.o({type:String,reflect:!0})],a.prototype,`state`,void 0),e.n([e.o({type:String,reflect:!0})],a.prototype,`type`,void 0),e.n([e.o({type:String})],a.prototype,`form`,void 0),e.n([e.o({type:Boolean,reflect:!0})],a.prototype,`isLoading`,void 0),e.n([e.o({type:Boolean,reflect:!0})],a.prototype,`disabled`,void 0),e.n([e.o({type:String})],a.prototype,`loadingAnimationPath`,void 0);try{e.s(`pkt-button`)(a)}catch{console.warn(`Forsøker å definere <pkt-button>, men den er allerede definert`)}var o=a;Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return o}});
|
|
@@ -4,10 +4,11 @@ import { n as o, t as s } from "./element-with-slot-BVj9MXzi.js";
|
|
|
4
4
|
import "./icon-LaKyBKON.js";
|
|
5
5
|
import { t as c } from "./if-defined-VShASPdu.js";
|
|
6
6
|
//#region src/components/button/button.ts
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
var l = "https://punkt-cdn.oslo.kommune.no/latest/animations/";
|
|
8
|
+
typeof window < "u" && (window.pktAnimationPath = window.pktAnimationPath || l);
|
|
9
|
+
var u = class extends s {
|
|
9
10
|
constructor(...e) {
|
|
10
|
-
super(...e), this.iconName = "user", this.secondIconName = "user", this.mode = "light", this.size = "medium", this.fullWidth = !1, this.fullWidthOnMobile = !1, this.skin = "primary", this.variant = "label-only", this.state = "normal", this.type = "button", this.form = void 0, this.isLoading = !1, this.disabled = !1, this.loadingAnimationPath = window.pktAnimationPath;
|
|
11
|
+
super(...e), this.iconName = "user", this.secondIconName = "user", this.mode = "light", this.size = "medium", this.fullWidth = !1, this.fullWidthOnMobile = !1, this.skin = "primary", this.variant = "label-only", this.state = "normal", this.type = "button", this.form = void 0, this.isLoading = !1, this.disabled = !1, this.loadingAnimationPath = typeof window < "u" ? window.pktAnimationPath : l;
|
|
11
12
|
}
|
|
12
13
|
connectedCallback() {
|
|
13
14
|
super.connectedCallback(), this.addEventListener("click", (e) => {
|
|
@@ -64,32 +65,32 @@ var l = class extends s {
|
|
|
64
65
|
`;
|
|
65
66
|
}
|
|
66
67
|
};
|
|
67
|
-
t([n({ type: String })],
|
|
68
|
+
t([n({ type: String })], u.prototype, "iconName", void 0), t([n({ type: String })], u.prototype, "secondIconName", void 0), t([n({ type: String })], u.prototype, "iconPath", void 0), t([n({ type: String })], u.prototype, "secondIconPath", void 0), t([n({ type: String })], u.prototype, "mode", void 0), t([n({ type: String })], u.prototype, "size", void 0), t([n({
|
|
68
69
|
type: Boolean,
|
|
69
70
|
attribute: "full-width"
|
|
70
|
-
})],
|
|
71
|
+
})], u.prototype, "fullWidth", void 0), t([n({
|
|
71
72
|
type: Boolean,
|
|
72
73
|
attribute: "full-width-on-mobile"
|
|
73
|
-
})],
|
|
74
|
+
})], u.prototype, "fullWidthOnMobile", void 0), t([n({ type: String })], u.prototype, "color", void 0), t([n({ type: String })], u.prototype, "skin", void 0), t([n({ type: String })], u.prototype, "variant", void 0), t([n({
|
|
74
75
|
type: String,
|
|
75
76
|
reflect: !0
|
|
76
|
-
})],
|
|
77
|
+
})], u.prototype, "state", void 0), t([n({
|
|
77
78
|
type: String,
|
|
78
79
|
reflect: !0
|
|
79
|
-
})],
|
|
80
|
+
})], u.prototype, "type", void 0), t([n({ type: String })], u.prototype, "form", void 0), t([n({
|
|
80
81
|
type: Boolean,
|
|
81
82
|
reflect: !0
|
|
82
|
-
})],
|
|
83
|
+
})], u.prototype, "isLoading", void 0), t([n({
|
|
83
84
|
type: Boolean,
|
|
84
85
|
reflect: !0
|
|
85
|
-
})],
|
|
86
|
+
})], u.prototype, "disabled", void 0), t([n({ type: String })], u.prototype, "loadingAnimationPath", void 0);
|
|
86
87
|
try {
|
|
87
|
-
i("pkt-button")(
|
|
88
|
+
i("pkt-button")(u);
|
|
88
89
|
} catch {
|
|
89
90
|
console.warn("Forsøker å definere <pkt-button>, men den er allerede definert");
|
|
90
91
|
}
|
|
91
92
|
//#endregion
|
|
92
93
|
//#region src/components/button/index.ts
|
|
93
|
-
var
|
|
94
|
+
var d = u;
|
|
94
95
|
//#endregion
|
|
95
|
-
export {
|
|
96
|
+
export { u as n, d as t };
|
|
@@ -9,7 +9,7 @@ import { t as d } from "./repeat-CKIii8Mi.js";
|
|
|
9
9
|
import { a as f, c as p, i as m, o as h, r as g, s as _ } from "./listbox-DXMIBv3y.js";
|
|
10
10
|
import { t as v } from "./input-element-BrmkXIXi.js";
|
|
11
11
|
import { t as y } from "./pkt-options-controller-BTNtjEIS.js";
|
|
12
|
-
import "./input-wrapper-
|
|
12
|
+
import "./input-wrapper-C93MmOIg.js";
|
|
13
13
|
//#region ../../shared-utils/combobox/input-utils.ts
|
|
14
14
|
var b = (e, t, n) => {
|
|
15
15
|
switch (e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require(`./element-CXAtr6Gu.cjs`),t=require(`./class-map-B8Ja0q7n.cjs`),n=require(`./element-with-slot-Cmxb9h4H.cjs`);require(`./icon-Dw6I0HDV.cjs`);const r=require(`./if-defined-LTjAScFG.cjs`),i=require(`./ref-CBdWMlde.cjs`);require(`./tag-CBFz0R9N.cjs`);const a=require(`./repeat-CRRgmzVn.cjs`),o=require(`./listbox-DbEobJNx.cjs`),s=require(`./input-element-BHQVt4Q9.cjs`),c=require(`./pkt-options-controller-CBM8xHwR.cjs`);require(`./input-wrapper-Dhkt20WW.cjs`);var l=(e,t,n)=>{switch(e){case`,`:return n?`addValue`:null;case`Enter`:return`addValue`;case`Tab`:case`ArrowDown`:return t?null:`focusListbox`;case`Escape`:return`closeOptions`;default:return null}},u=(e,t,n,r,i)=>{if(!e)return{action:`none`,value:null};let a=o.i(n,e);return!t.includes(e)&&!a?r?{action:`addUserValue`,value:e}:i?{action:`none`,value:null}:{action:`removeValue`,value:t[0]}:a&&!t.includes(a.value)?{action:`selectOption`,value:a.value}:{action:`none`,value:null}},d=(e,t,n,r,i)=>e.trim().toLowerCase()?{...o.s(e,t,n,r),shouldRemoveValue:!1,shouldResetInput:!1}:{addValueText:null,userInfoMessage:``,shouldRemoveValue:!i&&!!t[0],shouldResetInput:!0},f=(e,t,n)=>{let r=o.i(t,e);return n===`label`&&r?.label?r.label:e},p={markOptionSelected(e,t){if(t){for(let n of e)if(n.value===t){n.selected=!0;break}}},markOptionDeselected(e,t){if(t){for(let n of e)if(n.value===t){n.selected=!1;break}}},markAllSelected(e){for(let t of e)t.selected=!0},markAllDeselected(e){for(let t of e)t.selected=!1},removeUserAddedOptions(e){return e.filter(e=>!e.userAdded)}},m={parseOptionsFromSlot(e){let t=[];return e.forEach(e=>{if(!e.textContent&&!e.getAttribute(`value`))return;let n={value:e.getAttribute(`value`)||e.textContent||``,label:e.textContent||e.getAttribute(`value`)||``};e.getAttribute(`data-prefix`)&&(n.prefix=e.getAttribute(`data-prefix`)||void 0),e.getAttribute(`tagskincolor`)&&(n.tagSkinColor=e.getAttribute(`tagskincolor`)),e.getAttribute(`description`)&&(n.description=e.getAttribute(`description`)||void 0),n.fulltext=o.r(n),t.push(n)}),t}},h={syncOptionsWithValues(e,t){let n=[...t];return e.forEach(e=>{e.value&&!e.label&&(e.label=e.value),e.selected&&!n.includes(e.value)&&n.push(e.value),e.fulltext=o.r(e),e.selected=e.selected||n.includes(e.value)}),{options:e,newValues:n}},mergeWithUserAdded(e,t){return[...t.filter(e=>e?.userAdded&&e.selected).filter(t=>!(Array.isArray(e)?e:[]).some(e=>e.value===t.value)),...e]}},g={name:`pkt-combobox`,react:`PktCombobox`,"css-class":`pkt-combobox`,isElement:!0,isPureReact:!0,props:{name:{type:`string`,name:`Navn`,description:`Navn som brukes i skjema ved innsending`,category:`tech`},id:{type:`string`,name:`ID`,description:`Unik ID for feltet`,category:`tech`},label:{type:`string`,name:`Etikett/label`,description:`Tekst som vises over feltet`,category:`contents`},placeholder:{name:`Hint`,description:`Spesifiserer en kort hint som beskriver forventet verdi av feltet.`,type:`string`,category:`contents`,required:!1},multiple:{type:`boolean`,name:`Flervalg`,default:!1,description:`Mulighet for å velge flere valg`,category:`functionality`},tagPlacement:{attribute:`tag-placement`,type:[`inside`,`outside`],name:`Plassering av tags i flervalg`,description:`Plassering av valgte verdier i feltet ved flervalg`,category:`functionality`,showIf:{multiple:!0}},maxlength:{type:`number`,name:`Maks antall i flervalg`,description:`Maks antall valg dersom flervalg er aktivert`,category:`functionality`,showIf:{multiple:!0}},typeahead:{type:`boolean`,name:`Typeahead`,default:!1,description:`Mulighet for automatisk utfylling av feltet fra listen over valg`,category:`functionality`},includeSearch:{attribute:`include-search`,type:`boolean`,name:`Inkluder søk`,description:`Mulighet for å søke etter valg inni dropdown`,category:`functionality`},allowUserInput:{attribute:`allow-user-input`,type:`boolean`,name:`Brukervalgte verdier`,description:`Mulighet for å skrive inn egne verdier`,category:`functionality`},searchPlaceholder:{attribute:`search-placeholder`,type:`string`,name:`Søke-plassholder`,description:`Plassholdertekst for søkefeltet i dropdown`,category:`contents`,showIf:{includeSearch:!0}},displayValueAs:{attribute:`display-value-as`,type:[`label`,`value`,`prefixAndValue`],name:`Visning av valgt verdi`,description:`Hvordan valgt verdi vises i feltet`,default:`label`,category:`ui`},value:{name:`Verdi`,type:`string`,description:`Valgt verdi. Streng ved enkelt valg, array av strenger ved flervalg.`,category:`tech`},helptext:{type:`string`,name:`Hjelpetekst`,description:`Hjelpetekst som vises over feltet`,category:`contents`},helptextDropdown:{type:`string`,name:`Utvidet hjelpetekst`,description:`Hjelpetekst som vises i en lukket boks man kan åpne`,category:`contents`},helptextDropdownButton:{type:`string`,name:`Knappetekst for hjelpetekst`,description:`Tekst som vises på knappen for å åpne/lukke utvidet hjelpetekst`,category:`contents`,default:`Les mer`},disabled:{type:`boolean`,name:`Deaktivert`,description:`Feltet er deaktivert`,category:`tech`},hasError:{type:`boolean`,name:`Feil`,description:`Feltet har en feil`,category:`ui`},errorMessage:{type:`string`,name:`Feilmelding`,description:`Tekst som vises under feltet ved feil`,category:`contents`},required:{type:`boolean`,name:`Påkrevd`,description:`Feltet må fylles ut`,category:`tech`},requiredTag:{type:`boolean`,name:`Påkrevd-merking`,description:`Viser en merking som indikerer at feltet er påkrevd`,category:`ui`},requiredText:{type:`string`,name:`Påkrevd-tekst`,description:`Tekst som vises i påkrevd-merkingen`,category:`contents`},optionalTag:{type:`boolean`,name:`Valgfritt-merking`,description:`Viser en merking som indikerer at feltet er valgfritt`,category:`ui`},optionalText:{type:`string`,name:`Valgfritt-tekst`,description:`Tekst som vises i valgfritt-merkingen`,category:`contents`},tagText:{type:`string`,name:`Tag-tekst`,description:`Tekst som vises i en tag ved siden av label`,category:`ui`},fullwidth:{type:`boolean`,name:`Full bredde`,description:`Skal feltet ta opp hele bredden?`,category:`ui`},defaultOptions:{attribute:`default-options`,name:`Initielle valg (default options)`,description:`Liste over valg som kan velges, om options sendes inn som array med objekter (denne vil ikke modifiseres ved endring innad i komponenten)`,type:`array`,default:[],previewDefault:[{value:`bfr`,label:`Frogner`},{value:`bgo`,label:`Gamle Oslo`},{value:`bgr`,label:`Grorud`},{value:`bxx`,label:`Andre bydeler`}],items:{type:`object`,properties:{value:{type:`string`,description:`Verdi som sendes ved valg`},label:{type:`string`,description:`Tekst som vises for valget`},prefix:{type:`string`,description:`Tekst som vises før valget`},description:{type:`string`,description:`Beskrivelse av valget`},disabled:{type:`boolean`,description:`Valget er deaktivert`},selected:{type:`boolean`,description:`Valget er valgt`},tagSkinColor:{type:[`blue`,`blue-dark`,`blue-light`,`green`,`red`,`yellow`,`beige`,`gray`,`grey`],description:`Farge på tag`}},required:[`value`]},category:`contents`},options:{name:`Valg`,type:`array`,description:`Liste over valg som kan velges, om options sendes inn som array med objekter`,default:[],items:{type:`object`,properties:{value:{type:`string`,description:`Verdi som sendes ved valg`},label:{type:`string`,description:`Tekst som vises for valget`},prefix:{type:`string`,description:`Tekst som vises før valget`},description:{type:`string`,description:`Beskrivelse av valget`},disabled:{type:`boolean`,description:`Valget er deaktivert`},selected:{type:`boolean`,description:`Valget er valgt`},tagSkinColor:{type:[`blue`,`blue-dark`,`blue-light`,`green`,`red`,`yellow`,`beige`,`gray`,`grey`],description:`Farge på tag`}},required:[`value`]},category:`contents`}},events:{change:{type:`Event`,description:`Returnerer valgt verdi som streng. Ved flervalg returneres kommaseparerte verdier.`},"value-change":{type:`CustomEvent`,description:`Returnerer valgt verdi. Ved enkeltvalg en streng, ved flervalg en <code>string[]</code>.`},search:{type:`CustomEvent`,description:`Returnerer søketeksten som streng i <code>event.detail</code> når brukeren skriver i søkefeltet`},toggleHelpText:{type:`CustomEvent`,description:`Returnerer <code>event.detail { isOpen: true }</code> eller <code>event.detail { isOpen: false }</code> når hjelpeteksten åpnes eller lukkes`}}},_=class extends s.t{constructor(){super(),this.value=``,this.options=[],this.defaultOptions=[],this.allowUserInput=!1,this.typeahead=!1,this.includeSearch=!1,this.searchPlaceholder=``,this.multiple=!1,this.maxlength=null,this.displayValueAs=g.props.displayValueAs.default,this.tagPlacement=null,this.isOpen=!1,this._options=[],this._value=[],this._isOptionsOpen=!1,this._userInfoMessage=``,this._addValueText=null,this._maxIsReached=!1,this._search=``,this._inputFocus=!1,this._internalValueSync=!1,this._optionsFromSlot=!1,this._lastSlotGeneration=0,this._suppressNextOpen=!1,this.inputRef=i.t(),this.triggerRef=i.t(),this.listboxRef=i.t(),this.optionsController=new c.t(this)}get _hasTextInput(){return this.typeahead||this.allowUserInput}get _selectionDescription(){if(!(!this.multiple||this._value.length===0))return`${this._value.length} valgt`}focusTrigger(){this._hasTextInput?this.inputRef.value?.focus():this.triggerRef.value?.focus()}parseValue(){return Array.isArray(this.value)?this.multiple?this.value:this.value.length>0?[this.value[0]]:[]:this.value&&this.multiple?this.value.split(`,`):this.value?[this.value]:[]}updateMaxReached(){this._maxIsReached=o.c(this._value.length,this.maxlength)}syncValueAndDispatch(e){let t=this._value,n=this.multiple?t.join(`,`):t[0]||``;if(n!==(Array.isArray(this.value)?this.value.join(`,`):String(this.value||``))&&(this._internalValueSync=!0,this.value=n),e?.join(`,`)!==t.join(`,`)){let e=this.multiple?[...t]:t[0]||``;this.onChange(e)}else t.length===0&&e&&e.length>0&&this.clearInputValue()}onChange(e){this.touched=!0,super.onChange(e)}valueChanged(){}};e.n([e.o({type:String,reflect:!0})],_.prototype,`value`,void 0),e.n([e.o({type:Array})],_.prototype,`options`,void 0),e.n([e.o({type:Array,attribute:`default-options`})],_.prototype,`defaultOptions`,void 0),e.n([e.o({type:Boolean,attribute:`allow-user-input`})],_.prototype,`allowUserInput`,void 0),e.n([e.o({type:Boolean})],_.prototype,`typeahead`,void 0),e.n([e.o({type:Boolean,attribute:`include-search`})],_.prototype,`includeSearch`,void 0),e.n([e.o({type:String,attribute:`search-placeholder`})],_.prototype,`searchPlaceholder`,void 0),e.n([e.o({type:Boolean})],_.prototype,`multiple`,void 0),e.n([e.o({type:Number})],_.prototype,`maxlength`,void 0),e.n([e.o({type:String,attribute:`display-value-as`})],_.prototype,`displayValueAs`,void 0),e.n([e.o({type:String,attribute:`tag-placement`})],_.prototype,`tagPlacement`,void 0),e.n([e.o({type:Boolean,attribute:`open`})],_.prototype,`isOpen`,void 0),e.n([e.a()],_.prototype,`_options`,void 0),e.n([e.a()],_.prototype,`_value`,void 0),e.n([e.a()],_.prototype,`_isOptionsOpen`,void 0),e.n([e.a()],_.prototype,`_userInfoMessage`,void 0),e.n([e.a()],_.prototype,`_addValueText`,void 0),e.n([e.a()],_.prototype,`_maxIsReached`,void 0),e.n([e.a()],_.prototype,`_search`,void 0),e.n([e.a()],_.prototype,`_inputFocus`,void 0);var v=class extends _{toggleValue(e){if(this.disabled)return;this.touched=!0,this._userInfoMessage=``,this._addValueText=null;let t=o.i(this.options,e)?.value||null,n=this._value.includes(e||t||``),r=!!t,i=this._options.find(t=>t.value===e)?.disabled||!1,a=!e?.trim(),s=!this.multiple,c=this.multiple,l=o.c(this._value.length,this.maxlength),u=!1,d=!0,f=``,p=``;i||(!r&&this.allowUserInput&&!a?(this.addNewUserValue(e),f=`Ny verdi lagt til`,u=c):!r&&!this.allowUserInput?(s&&this._value[0]&&this.removeValue(this._value[0]),d=!1,u=!0,f=`Ingen treff i søket`):n?(this.removeValue(t),u=!0,s&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(this.inputRef.value.value=``)):a&&s?(this.removeAllSelected(),u=!0):s?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(t),u=!1):c&&!l?(this.setSelected(t),u=!0):c&&l?(f=`Maks antall valg nådd`,d=!1,p=e):(s&&this.removeAllSelected(),f=`Ingen gyldig verdi valgt`,d=!1,u=!0,p=e),this._isOptionsOpen=u,u||(s&&this._hasTextInput&&(this._suppressNextOpen=!0),window.setTimeout(()=>{this.focusTrigger()},0)),this._userInfoMessage=f,this._search=p||``,this.resetComboboxInput(d),c&&this.updateMaxReached())}setSelected(e){if(!this._value.includes(e)){if(this.multiple&&o.c(this._value.length,this.maxlength)){this._userInfoMessage=`Maks antall valg nådd`;return}!this.multiple&&this.removeAllSelected(),this._value=e?[...this._value,e]:this._value,p.markOptionSelected(this._options,e),this.resetComboboxInput(!0)}}removeSelected(e){if(!e)return;this._value=this._value.filter(t=>t!==e);let t=o.i(this.options,e);t&&(p.markOptionDeselected(this.options,e),t.userAdded?(this._options=[...this._options.filter(t=>t.value!==e)],this.options=[...this.options.filter(t=>t.value!==e)]):this._options.some(t=>t.value===e)||(this._options=[...this._options,t]))}addAllOptions(){if(this.multiple){if(this.maxlength&&this._options.length>this.maxlength){this._userInfoMessage=`For mange valgt`;return}this._value=this._options.map(e=>e.value),p.markAllSelected(this._options),this.requestUpdate()}}removeAllSelected(){this._value=[],p.markAllDeselected(this._options),this._options=p.removeUserAddedOptions(this._options),this.requestUpdate()}addValue(){let e=this.inputRef.value?.value.trim()||``;if(this._search=e,e&&this._value.includes(e)){this.resetComboboxInput(!0),this._userInfoMessage=`Verdien er allerede valgt`;return}this.toggleValue(e)}removeValue(e){this._value=this.multiple?this._value.filter(t=>t!==e):[],this.removeSelected(e)}addNewUserValue(e){if(!e||e.trim()===``)return;if(!this.multiple)this._value[0]&&this.removeSelected(this._value[0]),this._value=[e];else if(!o.i(this.options,e)){if(o.c(this._value.length,this.maxlength))return;this._value=[...this._value,e]}let t={value:e,label:e,userAdded:!0,selected:!0};this.options=[t,...this.options],this._options=[t,...this._options],this.resetComboboxInput(!0),this.multiple||(this._isOptionsOpen=!1,this._hasTextInput&&(this._suppressNextOpen=!0),window.setTimeout(()=>{this.focusTrigger()},0)),this.requestUpdate()}resetComboboxInput(e=!0){this._addValueText=null,this.inputRef.value&&this.inputRef.value.type!==`hidden`&&e&&(this._search=``,this.multiple?this.inputRef.value.value=``:(this.inputRef.value.value=this._value[0]?f(this._value[0],this.options,this.displayValueAs):``,this._userInfoMessage=``)),this._options=[...this.options]}removeLastValue(e){if(this._value.length===0)return;e.preventDefault();let t=this._value[this._value.length-1];t&&this.removeSelected(t),this.updateMaxReached()}},y=class extends v{handleInput(e){if(e.stopPropagation(),e.stopImmediatePropagation(),this.disabled)return;this.touched=!0;let t=e.target;if(this._search=t.value,this.checkForMatches(),this.typeahead)if(this._search){let{filtered:n,suggestion:r}=o.o(this.options,this._search);this._options=n,e.inputType!==`deleteContentBackward`&&r?.label&&this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(t.value=r.label,window.setTimeout(()=>t.setSelectionRange(this._search.length,t.value.length),0),t.selectionDirection=`backward`)}else this._options=[...this.options]}handleFocus(){if(!this.disabled){if(this._suppressNextOpen){this._suppressNextOpen=!1,this._inputFocus=!0,this.requestUpdate();return}!this.multiple&&this._value[0]&&this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(this.inputRef.value.value=f(this._value[0],this.options,this.displayValueAs)),this._inputFocus=!0,this._search=``,this._options=[...this.options],this._isOptionsOpen=!0,this.onFocus(),this.requestUpdate()}}handleFocusOut(e){if(this.disabled||!this._isOptionsOpen)return;let t=e.relatedTarget;t?.closest(`pkt-combobox`)?.id===this.id||e.target?.getAttribute(`data-focusfix`)===this.id||t===this.inputRef.value||t===this.triggerRef.value||this.closeAndProcessInput()}closeAndProcessInput(){if(this._inputFocus=!1,this._addValueText=null,this._userInfoMessage=``,this._search=``,this.inputRef.value&&this.inputRef.value.type!==`hidden`){let e=this.inputRef.value.value;if(!this.multiple)if(!e)this._value[0]&&this.removeSelected(this._value[0]);else{let t=o.i(this.options,e);t&&t.value!==this._value[0]?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(t.value)):!t&&this.allowUserInput&&(this._value[0]&&this.removeSelected(this._value[0]),this.addNewUserValue(e))}else if(e!==``){let{action:t,value:n}=u(e,this._value,this.options,this.allowUserInput,this.multiple);switch(t){case`addUserValue`:this.addNewUserValue(n);break;case`selectOption`:this.setSelected(n);break;case`removeValue`:this.removeValue(n);break}}!this.multiple&&this._value[0]?this.inputRef.value.value=f(this._value[0],this.options,this.displayValueAs):this.inputRef.value.value=``}this._isOptionsOpen=!1,this.onBlur()}handleBlur(){this._inputFocus=!1,this.onBlur()}handleInputClick(e){if(this.disabled){e.preventDefault(),e.stopImmediatePropagation();return}this._hasTextInput?(this.inputRef.value?.focus(),this.requestUpdate()):(e.stopImmediatePropagation(),e.preventDefault(),this._isOptionsOpen=!this._isOptionsOpen,this._isOptionsOpen&&this.listboxRef.value?.focusFirstOrSelectedOption())}handlePlaceholderClick(e){this.disabled||(e.stopPropagation(),this._hasTextInput&&this.inputRef.value?(this.inputRef.value.focus(),this._inputFocus=!0,this.requestUpdate()):(this._isOptionsOpen=!this._isOptionsOpen,this.requestUpdate()))}handleSelectOnlyKeydown(e){if(!this.disabled)switch(e.key){case`Enter`:case` `:case`ArrowDown`:case`ArrowUp`:e.preventDefault(),this._isOptionsOpen?this._isOptionsOpen=!1:(this._isOptionsOpen=!0,this.listboxRef.value?.focusFirstOrSelectedOption());break;case`Escape`:this._isOptionsOpen&&=(e.preventDefault(),!1);break;case`Home`:case`End`:e.preventDefault(),this._isOptionsOpen||=!0,this.listboxRef.value?.focusFirstOrSelectedOption();break;case`ArrowLeft`:this.multiple&&this._value.length>0&&(e.preventDefault(),this.focusTag(this._value.length-1));break;case`Backspace`:case`Delete`:this.multiple&&this._value.length>0&&(e.preventDefault(),this.removeSelected(this._value[this._value.length-1]));break}}handleOptionToggled(e){this.toggleValue(e.detail)}handleSearch(e){e.stopPropagation(),this._search=e.detail.toLowerCase(),this.checkForMatches()}handleInputKeydown(e){if(e.key===`Backspace`){let t=!this.inputRef.value?.value;!this._search&&t&&this.multiple&&this._value.length>0&&this.removeLastValue(e);return}if(e.key===`ArrowLeft`&&this.multiple&&this._value.length>0){let t=this.inputRef.value;if(t&&t.selectionStart===0&&!t.value){e.preventDefault(),this.focusTag(this._value.length-1);return}}let t=l(e.key,e.shiftKey,this.multiple);if(t&&!(e.key===`Tab`&&!this._isOptionsOpen)){if(t===`focusListbox`&&e.key===`Tab`&&!this.listboxRef.value?.querySelector(`[role="option"]:not([data-disabled]), [data-type="new-option"]`)){this.closeAndProcessInput();return}switch(e.preventDefault(),t){case`addValue`:this.addValue();break;case`focusListbox`:this.listboxRef.value?.focusFirstOrSelectedOption();break;case`closeOptions`:this._isOptionsOpen=!1;break}}}handleTagRemove(e){this.removeSelected(e),this._hasTextInput&&this.inputRef.value&&(this._inputFocus=!0,this.inputRef.value.focus(),this.requestUpdate())}getInsideTags(){return Array.from(this.querySelectorAll(`.pkt-combobox__input .pkt-combobox__tag-list pkt-tag`))}focusTag(e){let t=this.getInsideTags();t.forEach((t,n)=>{t.buttonTabindex=n===e?0:-1}),(t[e]?.querySelector(`button`))?.focus()}resetTagTabindices(){this.getInsideTags().forEach(e=>{e.buttonTabindex=-1})}handleTagKeydown(e,t){e.stopPropagation();let n=()=>{this.resetTagTabindices(),this._hasTextInput&&this.inputRef.value?this.inputRef.value.focus():this.triggerRef.value?.focus()};switch(e.key){case`ArrowLeft`:e.preventDefault(),t>0&&this.focusTag(t-1);break;case`ArrowRight`:e.preventDefault(),t<this._value.length-1?this.focusTag(t+1):n();break;case`Backspace`:case`Delete`:e.preventDefault();{let e=this._value[t],r=t>=this._value.length-1?t-1:t;this.removeSelected(e),r>=0?(this.requestUpdate(),this.updateComplete.then(()=>this.focusTag(r))):n()}break;case`Tab`:this.resetTagTabindices();break;case`Escape`:e.preventDefault(),n();break}}checkForMatches(){let e=d(this.inputRef.value?.value||this._search||``,this._value,this.options,this.allowUserInput,this.multiple);if(e.shouldRemoveValue&&this.removeValue(this._value[0]),e.shouldResetInput){this.resetComboboxInput(!1);return}this._addValueText=e.addValueText,this._userInfoMessage=e.userInfoMessage}},b=class extends y{constructor(...e){super(...e),this.handleBodyClick=e=>{this._isOptionsOpen&&!this.contains(e.target)&&this.closeAndProcessInput()}}connectedCallback(){if(super.connectedCallback(),document?.body.addEventListener(`click`,this.handleBodyClick),this._options=[],this.defaultOptions&&this.defaultOptions.length&&(this.options=[...this.options?.filter(e=>e.userAdded)||[],...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=Array.isArray(this.options)?[...this.options]:[]),this.optionsController?.nodes&&this.optionsController.nodes.length){let e=m.parseOptionsFromSlot(this.optionsController.nodes);e.length&&(this.options=[...e],this._options=[...e],this._optionsFromSlot=!0,this._lastSlotGeneration=this.optionsController.generation)}}willUpdate(e){if(this._optionsFromSlot&&this.optionsController){let e=this.optionsController.generation;if(e!==this._lastSlotGeneration){this._lastSlotGeneration=e;let t=m.parseOptionsFromSlot(this.optionsController.nodes);this.options=[...this._options.filter(e=>e.userAdded),...t]}}super.willUpdate(e)}disconnectedCallback(){super.disconnectedCallback(),document?.body.removeEventListener(`click`,this.handleBodyClick)}firstUpdated(e){this.defaultValue!==null&&!this.value&&(this.value=this.defaultValue),super.firstUpdated(e)}updated(e){e.has(`isOpen`)&&(this._isOptionsOpen=this.isOpen);let t=e.has(`value`),n=e.has(`_value`);if(t&&this._internalValueSync)this._internalValueSync=!1,n&&this.syncValueAndDispatch(e.get(`_value`));else if(t){let e=[...this._value],t=this.parseValue();t.join(`,`)!==this._value.join(`,`)&&(this._value=t),this.updateMaxReached(),this.syncValueAndDispatch(e)}else n&&this.syncValueAndDispatch(e.get(`_value`));if(e.has(`defaultOptions`)&&this.defaultOptions.length&&(this.options=[...(Array.isArray(this.options)?this.options:[]).filter(e=>e.userAdded)||[],...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=Array.isArray(this.options)?[...this.options]:[]),e.has(`options`)){let t=e.get(`options`)||this._options||[],n=h.mergeWithUserAdded(this.options,t);this._options=n,n.length>this.options.length&&(this.options=n);let r=h.syncOptionsWithValues(this._options,this._value);if(this._options=r.options,r.newValues.length>this._value.length){let e=[...this._value];this._value=r.newValues,this.syncValueAndDispatch(e)}}if(e.has(`_search`)&&this.dispatchEvent(new CustomEvent(`search`,{detail:this._search,bubbles:!1})),!this._isOptionsOpen&&!this.multiple&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!==`hidden`){let e=this._value[0]?f(this._value[0],this.options,this.displayValueAs):``;this.inputRef.value.value!==e&&(this.inputRef.value.value=e)}super.updated(e)}formResetCallback(){this.touched=!1,this.value=this.defaultValue||(this.multiple,``),this._value=this.parseValue(),this._options=this._options.filter(e=>!e.userAdded).map(e=>({...e,selected:this._value.includes(e.value)})),this.options=this.options.filter(e=>!e.userAdded).map(e=>({...e,selected:this._value.includes(e.value)})),this._search=``,this._isOptionsOpen=!1,this._userInfoMessage=``,this._addValueText=null,this._inputFocus=!1,this.updateMaxReached(),this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(this.inputRef.value.value=``),this.internals.setFormValue(``),this.internals.ariaInvalid=`false`,this.requestUpdate()}attributeChangedCallback(e,t,n){if(e===`options`){this._options=Array.isArray(this.options)?[...this.options]:[];let e=h.syncOptionsWithValues(this._options,this._value);this._options=e.options,e.newValues.length>this._value.length&&(this._value=e.newValues),this._search=``}super.attributeChangedCallback(e,t,n)}render(){return e.p`
|
|
1
|
+
const e=require(`./element-CXAtr6Gu.cjs`),t=require(`./class-map-B8Ja0q7n.cjs`),n=require(`./element-with-slot-Cmxb9h4H.cjs`);require(`./icon-Dw6I0HDV.cjs`);const r=require(`./if-defined-LTjAScFG.cjs`),i=require(`./ref-CBdWMlde.cjs`);require(`./tag-CBFz0R9N.cjs`);const a=require(`./repeat-CRRgmzVn.cjs`),o=require(`./listbox-DbEobJNx.cjs`),s=require(`./input-element-BHQVt4Q9.cjs`),c=require(`./pkt-options-controller-CBM8xHwR.cjs`);require(`./input-wrapper-CvtU-Ksb.cjs`);var l=(e,t,n)=>{switch(e){case`,`:return n?`addValue`:null;case`Enter`:return`addValue`;case`Tab`:case`ArrowDown`:return t?null:`focusListbox`;case`Escape`:return`closeOptions`;default:return null}},u=(e,t,n,r,i)=>{if(!e)return{action:`none`,value:null};let a=o.i(n,e);return!t.includes(e)&&!a?r?{action:`addUserValue`,value:e}:i?{action:`none`,value:null}:{action:`removeValue`,value:t[0]}:a&&!t.includes(a.value)?{action:`selectOption`,value:a.value}:{action:`none`,value:null}},d=(e,t,n,r,i)=>e.trim().toLowerCase()?{...o.s(e,t,n,r),shouldRemoveValue:!1,shouldResetInput:!1}:{addValueText:null,userInfoMessage:``,shouldRemoveValue:!i&&!!t[0],shouldResetInput:!0},f=(e,t,n)=>{let r=o.i(t,e);return n===`label`&&r?.label?r.label:e},p={markOptionSelected(e,t){if(t){for(let n of e)if(n.value===t){n.selected=!0;break}}},markOptionDeselected(e,t){if(t){for(let n of e)if(n.value===t){n.selected=!1;break}}},markAllSelected(e){for(let t of e)t.selected=!0},markAllDeselected(e){for(let t of e)t.selected=!1},removeUserAddedOptions(e){return e.filter(e=>!e.userAdded)}},m={parseOptionsFromSlot(e){let t=[];return e.forEach(e=>{if(!e.textContent&&!e.getAttribute(`value`))return;let n={value:e.getAttribute(`value`)||e.textContent||``,label:e.textContent||e.getAttribute(`value`)||``};e.getAttribute(`data-prefix`)&&(n.prefix=e.getAttribute(`data-prefix`)||void 0),e.getAttribute(`tagskincolor`)&&(n.tagSkinColor=e.getAttribute(`tagskincolor`)),e.getAttribute(`description`)&&(n.description=e.getAttribute(`description`)||void 0),n.fulltext=o.r(n),t.push(n)}),t}},h={syncOptionsWithValues(e,t){let n=[...t];return e.forEach(e=>{e.value&&!e.label&&(e.label=e.value),e.selected&&!n.includes(e.value)&&n.push(e.value),e.fulltext=o.r(e),e.selected=e.selected||n.includes(e.value)}),{options:e,newValues:n}},mergeWithUserAdded(e,t){return[...t.filter(e=>e?.userAdded&&e.selected).filter(t=>!(Array.isArray(e)?e:[]).some(e=>e.value===t.value)),...e]}},g={name:`pkt-combobox`,react:`PktCombobox`,"css-class":`pkt-combobox`,isElement:!0,isPureReact:!0,props:{name:{type:`string`,name:`Navn`,description:`Navn som brukes i skjema ved innsending`,category:`tech`},id:{type:`string`,name:`ID`,description:`Unik ID for feltet`,category:`tech`},label:{type:`string`,name:`Etikett/label`,description:`Tekst som vises over feltet`,category:`contents`},placeholder:{name:`Hint`,description:`Spesifiserer en kort hint som beskriver forventet verdi av feltet.`,type:`string`,category:`contents`,required:!1},multiple:{type:`boolean`,name:`Flervalg`,default:!1,description:`Mulighet for å velge flere valg`,category:`functionality`},tagPlacement:{attribute:`tag-placement`,type:[`inside`,`outside`],name:`Plassering av tags i flervalg`,description:`Plassering av valgte verdier i feltet ved flervalg`,category:`functionality`,showIf:{multiple:!0}},maxlength:{type:`number`,name:`Maks antall i flervalg`,description:`Maks antall valg dersom flervalg er aktivert`,category:`functionality`,showIf:{multiple:!0}},typeahead:{type:`boolean`,name:`Typeahead`,default:!1,description:`Mulighet for automatisk utfylling av feltet fra listen over valg`,category:`functionality`},includeSearch:{attribute:`include-search`,type:`boolean`,name:`Inkluder søk`,description:`Mulighet for å søke etter valg inni dropdown`,category:`functionality`},allowUserInput:{attribute:`allow-user-input`,type:`boolean`,name:`Brukervalgte verdier`,description:`Mulighet for å skrive inn egne verdier`,category:`functionality`},searchPlaceholder:{attribute:`search-placeholder`,type:`string`,name:`Søke-plassholder`,description:`Plassholdertekst for søkefeltet i dropdown`,category:`contents`,showIf:{includeSearch:!0}},displayValueAs:{attribute:`display-value-as`,type:[`label`,`value`,`prefixAndValue`],name:`Visning av valgt verdi`,description:`Hvordan valgt verdi vises i feltet`,default:`label`,category:`ui`},value:{name:`Verdi`,type:`string`,description:`Valgt verdi. Streng ved enkelt valg, array av strenger ved flervalg.`,category:`tech`},helptext:{type:`string`,name:`Hjelpetekst`,description:`Hjelpetekst som vises over feltet`,category:`contents`},helptextDropdown:{type:`string`,name:`Utvidet hjelpetekst`,description:`Hjelpetekst som vises i en lukket boks man kan åpne`,category:`contents`},helptextDropdownButton:{type:`string`,name:`Knappetekst for hjelpetekst`,description:`Tekst som vises på knappen for å åpne/lukke utvidet hjelpetekst`,category:`contents`,default:`Les mer`},disabled:{type:`boolean`,name:`Deaktivert`,description:`Feltet er deaktivert`,category:`tech`},hasError:{type:`boolean`,name:`Feil`,description:`Feltet har en feil`,category:`ui`},errorMessage:{type:`string`,name:`Feilmelding`,description:`Tekst som vises under feltet ved feil`,category:`contents`},required:{type:`boolean`,name:`Påkrevd`,description:`Feltet må fylles ut`,category:`tech`},requiredTag:{type:`boolean`,name:`Påkrevd-merking`,description:`Viser en merking som indikerer at feltet er påkrevd`,category:`ui`},requiredText:{type:`string`,name:`Påkrevd-tekst`,description:`Tekst som vises i påkrevd-merkingen`,category:`contents`},optionalTag:{type:`boolean`,name:`Valgfritt-merking`,description:`Viser en merking som indikerer at feltet er valgfritt`,category:`ui`},optionalText:{type:`string`,name:`Valgfritt-tekst`,description:`Tekst som vises i valgfritt-merkingen`,category:`contents`},tagText:{type:`string`,name:`Tag-tekst`,description:`Tekst som vises i en tag ved siden av label`,category:`ui`},fullwidth:{type:`boolean`,name:`Full bredde`,description:`Skal feltet ta opp hele bredden?`,category:`ui`},defaultOptions:{attribute:`default-options`,name:`Initielle valg (default options)`,description:`Liste over valg som kan velges, om options sendes inn som array med objekter (denne vil ikke modifiseres ved endring innad i komponenten)`,type:`array`,default:[],previewDefault:[{value:`bfr`,label:`Frogner`},{value:`bgo`,label:`Gamle Oslo`},{value:`bgr`,label:`Grorud`},{value:`bxx`,label:`Andre bydeler`}],items:{type:`object`,properties:{value:{type:`string`,description:`Verdi som sendes ved valg`},label:{type:`string`,description:`Tekst som vises for valget`},prefix:{type:`string`,description:`Tekst som vises før valget`},description:{type:`string`,description:`Beskrivelse av valget`},disabled:{type:`boolean`,description:`Valget er deaktivert`},selected:{type:`boolean`,description:`Valget er valgt`},tagSkinColor:{type:[`blue`,`blue-dark`,`blue-light`,`green`,`red`,`yellow`,`beige`,`gray`,`grey`],description:`Farge på tag`}},required:[`value`]},category:`contents`},options:{name:`Valg`,type:`array`,description:`Liste over valg som kan velges, om options sendes inn som array med objekter`,default:[],items:{type:`object`,properties:{value:{type:`string`,description:`Verdi som sendes ved valg`},label:{type:`string`,description:`Tekst som vises for valget`},prefix:{type:`string`,description:`Tekst som vises før valget`},description:{type:`string`,description:`Beskrivelse av valget`},disabled:{type:`boolean`,description:`Valget er deaktivert`},selected:{type:`boolean`,description:`Valget er valgt`},tagSkinColor:{type:[`blue`,`blue-dark`,`blue-light`,`green`,`red`,`yellow`,`beige`,`gray`,`grey`],description:`Farge på tag`}},required:[`value`]},category:`contents`}},events:{change:{type:`Event`,description:`Returnerer valgt verdi som streng. Ved flervalg returneres kommaseparerte verdier.`},"value-change":{type:`CustomEvent`,description:`Returnerer valgt verdi. Ved enkeltvalg en streng, ved flervalg en <code>string[]</code>.`},search:{type:`CustomEvent`,description:`Returnerer søketeksten som streng i <code>event.detail</code> når brukeren skriver i søkefeltet`},toggleHelpText:{type:`CustomEvent`,description:`Returnerer <code>event.detail { isOpen: true }</code> eller <code>event.detail { isOpen: false }</code> når hjelpeteksten åpnes eller lukkes`}}},_=class extends s.t{constructor(){super(),this.value=``,this.options=[],this.defaultOptions=[],this.allowUserInput=!1,this.typeahead=!1,this.includeSearch=!1,this.searchPlaceholder=``,this.multiple=!1,this.maxlength=null,this.displayValueAs=g.props.displayValueAs.default,this.tagPlacement=null,this.isOpen=!1,this._options=[],this._value=[],this._isOptionsOpen=!1,this._userInfoMessage=``,this._addValueText=null,this._maxIsReached=!1,this._search=``,this._inputFocus=!1,this._internalValueSync=!1,this._optionsFromSlot=!1,this._lastSlotGeneration=0,this._suppressNextOpen=!1,this.inputRef=i.t(),this.triggerRef=i.t(),this.listboxRef=i.t(),this.optionsController=new c.t(this)}get _hasTextInput(){return this.typeahead||this.allowUserInput}get _selectionDescription(){if(!(!this.multiple||this._value.length===0))return`${this._value.length} valgt`}focusTrigger(){this._hasTextInput?this.inputRef.value?.focus():this.triggerRef.value?.focus()}parseValue(){return Array.isArray(this.value)?this.multiple?this.value:this.value.length>0?[this.value[0]]:[]:this.value&&this.multiple?this.value.split(`,`):this.value?[this.value]:[]}updateMaxReached(){this._maxIsReached=o.c(this._value.length,this.maxlength)}syncValueAndDispatch(e){let t=this._value,n=this.multiple?t.join(`,`):t[0]||``;if(n!==(Array.isArray(this.value)?this.value.join(`,`):String(this.value||``))&&(this._internalValueSync=!0,this.value=n),e?.join(`,`)!==t.join(`,`)){let e=this.multiple?[...t]:t[0]||``;this.onChange(e)}else t.length===0&&e&&e.length>0&&this.clearInputValue()}onChange(e){this.touched=!0,super.onChange(e)}valueChanged(){}};e.n([e.o({type:String,reflect:!0})],_.prototype,`value`,void 0),e.n([e.o({type:Array})],_.prototype,`options`,void 0),e.n([e.o({type:Array,attribute:`default-options`})],_.prototype,`defaultOptions`,void 0),e.n([e.o({type:Boolean,attribute:`allow-user-input`})],_.prototype,`allowUserInput`,void 0),e.n([e.o({type:Boolean})],_.prototype,`typeahead`,void 0),e.n([e.o({type:Boolean,attribute:`include-search`})],_.prototype,`includeSearch`,void 0),e.n([e.o({type:String,attribute:`search-placeholder`})],_.prototype,`searchPlaceholder`,void 0),e.n([e.o({type:Boolean})],_.prototype,`multiple`,void 0),e.n([e.o({type:Number})],_.prototype,`maxlength`,void 0),e.n([e.o({type:String,attribute:`display-value-as`})],_.prototype,`displayValueAs`,void 0),e.n([e.o({type:String,attribute:`tag-placement`})],_.prototype,`tagPlacement`,void 0),e.n([e.o({type:Boolean,attribute:`open`})],_.prototype,`isOpen`,void 0),e.n([e.a()],_.prototype,`_options`,void 0),e.n([e.a()],_.prototype,`_value`,void 0),e.n([e.a()],_.prototype,`_isOptionsOpen`,void 0),e.n([e.a()],_.prototype,`_userInfoMessage`,void 0),e.n([e.a()],_.prototype,`_addValueText`,void 0),e.n([e.a()],_.prototype,`_maxIsReached`,void 0),e.n([e.a()],_.prototype,`_search`,void 0),e.n([e.a()],_.prototype,`_inputFocus`,void 0);var v=class extends _{toggleValue(e){if(this.disabled)return;this.touched=!0,this._userInfoMessage=``,this._addValueText=null;let t=o.i(this.options,e)?.value||null,n=this._value.includes(e||t||``),r=!!t,i=this._options.find(t=>t.value===e)?.disabled||!1,a=!e?.trim(),s=!this.multiple,c=this.multiple,l=o.c(this._value.length,this.maxlength),u=!1,d=!0,f=``,p=``;i||(!r&&this.allowUserInput&&!a?(this.addNewUserValue(e),f=`Ny verdi lagt til`,u=c):!r&&!this.allowUserInput?(s&&this._value[0]&&this.removeValue(this._value[0]),d=!1,u=!0,f=`Ingen treff i søket`):n?(this.removeValue(t),u=!0,s&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(this.inputRef.value.value=``)):a&&s?(this.removeAllSelected(),u=!0):s?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(t),u=!1):c&&!l?(this.setSelected(t),u=!0):c&&l?(f=`Maks antall valg nådd`,d=!1,p=e):(s&&this.removeAllSelected(),f=`Ingen gyldig verdi valgt`,d=!1,u=!0,p=e),this._isOptionsOpen=u,u||(s&&this._hasTextInput&&(this._suppressNextOpen=!0),window.setTimeout(()=>{this.focusTrigger()},0)),this._userInfoMessage=f,this._search=p||``,this.resetComboboxInput(d),c&&this.updateMaxReached())}setSelected(e){if(!this._value.includes(e)){if(this.multiple&&o.c(this._value.length,this.maxlength)){this._userInfoMessage=`Maks antall valg nådd`;return}!this.multiple&&this.removeAllSelected(),this._value=e?[...this._value,e]:this._value,p.markOptionSelected(this._options,e),this.resetComboboxInput(!0)}}removeSelected(e){if(!e)return;this._value=this._value.filter(t=>t!==e);let t=o.i(this.options,e);t&&(p.markOptionDeselected(this.options,e),t.userAdded?(this._options=[...this._options.filter(t=>t.value!==e)],this.options=[...this.options.filter(t=>t.value!==e)]):this._options.some(t=>t.value===e)||(this._options=[...this._options,t]))}addAllOptions(){if(this.multiple){if(this.maxlength&&this._options.length>this.maxlength){this._userInfoMessage=`For mange valgt`;return}this._value=this._options.map(e=>e.value),p.markAllSelected(this._options),this.requestUpdate()}}removeAllSelected(){this._value=[],p.markAllDeselected(this._options),this._options=p.removeUserAddedOptions(this._options),this.requestUpdate()}addValue(){let e=this.inputRef.value?.value.trim()||``;if(this._search=e,e&&this._value.includes(e)){this.resetComboboxInput(!0),this._userInfoMessage=`Verdien er allerede valgt`;return}this.toggleValue(e)}removeValue(e){this._value=this.multiple?this._value.filter(t=>t!==e):[],this.removeSelected(e)}addNewUserValue(e){if(!e||e.trim()===``)return;if(!this.multiple)this._value[0]&&this.removeSelected(this._value[0]),this._value=[e];else if(!o.i(this.options,e)){if(o.c(this._value.length,this.maxlength))return;this._value=[...this._value,e]}let t={value:e,label:e,userAdded:!0,selected:!0};this.options=[t,...this.options],this._options=[t,...this._options],this.resetComboboxInput(!0),this.multiple||(this._isOptionsOpen=!1,this._hasTextInput&&(this._suppressNextOpen=!0),window.setTimeout(()=>{this.focusTrigger()},0)),this.requestUpdate()}resetComboboxInput(e=!0){this._addValueText=null,this.inputRef.value&&this.inputRef.value.type!==`hidden`&&e&&(this._search=``,this.multiple?this.inputRef.value.value=``:(this.inputRef.value.value=this._value[0]?f(this._value[0],this.options,this.displayValueAs):``,this._userInfoMessage=``)),this._options=[...this.options]}removeLastValue(e){if(this._value.length===0)return;e.preventDefault();let t=this._value[this._value.length-1];t&&this.removeSelected(t),this.updateMaxReached()}},y=class extends v{handleInput(e){if(e.stopPropagation(),e.stopImmediatePropagation(),this.disabled)return;this.touched=!0;let t=e.target;if(this._search=t.value,this.checkForMatches(),this.typeahead)if(this._search){let{filtered:n,suggestion:r}=o.o(this.options,this._search);this._options=n,e.inputType!==`deleteContentBackward`&&r?.label&&this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(t.value=r.label,window.setTimeout(()=>t.setSelectionRange(this._search.length,t.value.length),0),t.selectionDirection=`backward`)}else this._options=[...this.options]}handleFocus(){if(!this.disabled){if(this._suppressNextOpen){this._suppressNextOpen=!1,this._inputFocus=!0,this.requestUpdate();return}!this.multiple&&this._value[0]&&this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(this.inputRef.value.value=f(this._value[0],this.options,this.displayValueAs)),this._inputFocus=!0,this._search=``,this._options=[...this.options],this._isOptionsOpen=!0,this.onFocus(),this.requestUpdate()}}handleFocusOut(e){if(this.disabled||!this._isOptionsOpen)return;let t=e.relatedTarget;t?.closest(`pkt-combobox`)?.id===this.id||e.target?.getAttribute(`data-focusfix`)===this.id||t===this.inputRef.value||t===this.triggerRef.value||this.closeAndProcessInput()}closeAndProcessInput(){if(this._inputFocus=!1,this._addValueText=null,this._userInfoMessage=``,this._search=``,this.inputRef.value&&this.inputRef.value.type!==`hidden`){let e=this.inputRef.value.value;if(!this.multiple)if(!e)this._value[0]&&this.removeSelected(this._value[0]);else{let t=o.i(this.options,e);t&&t.value!==this._value[0]?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(t.value)):!t&&this.allowUserInput&&(this._value[0]&&this.removeSelected(this._value[0]),this.addNewUserValue(e))}else if(e!==``){let{action:t,value:n}=u(e,this._value,this.options,this.allowUserInput,this.multiple);switch(t){case`addUserValue`:this.addNewUserValue(n);break;case`selectOption`:this.setSelected(n);break;case`removeValue`:this.removeValue(n);break}}!this.multiple&&this._value[0]?this.inputRef.value.value=f(this._value[0],this.options,this.displayValueAs):this.inputRef.value.value=``}this._isOptionsOpen=!1,this.onBlur()}handleBlur(){this._inputFocus=!1,this.onBlur()}handleInputClick(e){if(this.disabled){e.preventDefault(),e.stopImmediatePropagation();return}this._hasTextInput?(this.inputRef.value?.focus(),this.requestUpdate()):(e.stopImmediatePropagation(),e.preventDefault(),this._isOptionsOpen=!this._isOptionsOpen,this._isOptionsOpen&&this.listboxRef.value?.focusFirstOrSelectedOption())}handlePlaceholderClick(e){this.disabled||(e.stopPropagation(),this._hasTextInput&&this.inputRef.value?(this.inputRef.value.focus(),this._inputFocus=!0,this.requestUpdate()):(this._isOptionsOpen=!this._isOptionsOpen,this.requestUpdate()))}handleSelectOnlyKeydown(e){if(!this.disabled)switch(e.key){case`Enter`:case` `:case`ArrowDown`:case`ArrowUp`:e.preventDefault(),this._isOptionsOpen?this._isOptionsOpen=!1:(this._isOptionsOpen=!0,this.listboxRef.value?.focusFirstOrSelectedOption());break;case`Escape`:this._isOptionsOpen&&=(e.preventDefault(),!1);break;case`Home`:case`End`:e.preventDefault(),this._isOptionsOpen||=!0,this.listboxRef.value?.focusFirstOrSelectedOption();break;case`ArrowLeft`:this.multiple&&this._value.length>0&&(e.preventDefault(),this.focusTag(this._value.length-1));break;case`Backspace`:case`Delete`:this.multiple&&this._value.length>0&&(e.preventDefault(),this.removeSelected(this._value[this._value.length-1]));break}}handleOptionToggled(e){this.toggleValue(e.detail)}handleSearch(e){e.stopPropagation(),this._search=e.detail.toLowerCase(),this.checkForMatches()}handleInputKeydown(e){if(e.key===`Backspace`){let t=!this.inputRef.value?.value;!this._search&&t&&this.multiple&&this._value.length>0&&this.removeLastValue(e);return}if(e.key===`ArrowLeft`&&this.multiple&&this._value.length>0){let t=this.inputRef.value;if(t&&t.selectionStart===0&&!t.value){e.preventDefault(),this.focusTag(this._value.length-1);return}}let t=l(e.key,e.shiftKey,this.multiple);if(t&&!(e.key===`Tab`&&!this._isOptionsOpen)){if(t===`focusListbox`&&e.key===`Tab`&&!this.listboxRef.value?.querySelector(`[role="option"]:not([data-disabled]), [data-type="new-option"]`)){this.closeAndProcessInput();return}switch(e.preventDefault(),t){case`addValue`:this.addValue();break;case`focusListbox`:this.listboxRef.value?.focusFirstOrSelectedOption();break;case`closeOptions`:this._isOptionsOpen=!1;break}}}handleTagRemove(e){this.removeSelected(e),this._hasTextInput&&this.inputRef.value&&(this._inputFocus=!0,this.inputRef.value.focus(),this.requestUpdate())}getInsideTags(){return Array.from(this.querySelectorAll(`.pkt-combobox__input .pkt-combobox__tag-list pkt-tag`))}focusTag(e){let t=this.getInsideTags();t.forEach((t,n)=>{t.buttonTabindex=n===e?0:-1}),(t[e]?.querySelector(`button`))?.focus()}resetTagTabindices(){this.getInsideTags().forEach(e=>{e.buttonTabindex=-1})}handleTagKeydown(e,t){e.stopPropagation();let n=()=>{this.resetTagTabindices(),this._hasTextInput&&this.inputRef.value?this.inputRef.value.focus():this.triggerRef.value?.focus()};switch(e.key){case`ArrowLeft`:e.preventDefault(),t>0&&this.focusTag(t-1);break;case`ArrowRight`:e.preventDefault(),t<this._value.length-1?this.focusTag(t+1):n();break;case`Backspace`:case`Delete`:e.preventDefault();{let e=this._value[t],r=t>=this._value.length-1?t-1:t;this.removeSelected(e),r>=0?(this.requestUpdate(),this.updateComplete.then(()=>this.focusTag(r))):n()}break;case`Tab`:this.resetTagTabindices();break;case`Escape`:e.preventDefault(),n();break}}checkForMatches(){let e=d(this.inputRef.value?.value||this._search||``,this._value,this.options,this.allowUserInput,this.multiple);if(e.shouldRemoveValue&&this.removeValue(this._value[0]),e.shouldResetInput){this.resetComboboxInput(!1);return}this._addValueText=e.addValueText,this._userInfoMessage=e.userInfoMessage}},b=class extends y{constructor(...e){super(...e),this.handleBodyClick=e=>{this._isOptionsOpen&&!this.contains(e.target)&&this.closeAndProcessInput()}}connectedCallback(){if(super.connectedCallback(),document?.body.addEventListener(`click`,this.handleBodyClick),this._options=[],this.defaultOptions&&this.defaultOptions.length&&(this.options=[...this.options?.filter(e=>e.userAdded)||[],...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=Array.isArray(this.options)?[...this.options]:[]),this.optionsController?.nodes&&this.optionsController.nodes.length){let e=m.parseOptionsFromSlot(this.optionsController.nodes);e.length&&(this.options=[...e],this._options=[...e],this._optionsFromSlot=!0,this._lastSlotGeneration=this.optionsController.generation)}}willUpdate(e){if(this._optionsFromSlot&&this.optionsController){let e=this.optionsController.generation;if(e!==this._lastSlotGeneration){this._lastSlotGeneration=e;let t=m.parseOptionsFromSlot(this.optionsController.nodes);this.options=[...this._options.filter(e=>e.userAdded),...t]}}super.willUpdate(e)}disconnectedCallback(){super.disconnectedCallback(),document?.body.removeEventListener(`click`,this.handleBodyClick)}firstUpdated(e){this.defaultValue!==null&&!this.value&&(this.value=this.defaultValue),super.firstUpdated(e)}updated(e){e.has(`isOpen`)&&(this._isOptionsOpen=this.isOpen);let t=e.has(`value`),n=e.has(`_value`);if(t&&this._internalValueSync)this._internalValueSync=!1,n&&this.syncValueAndDispatch(e.get(`_value`));else if(t){let e=[...this._value],t=this.parseValue();t.join(`,`)!==this._value.join(`,`)&&(this._value=t),this.updateMaxReached(),this.syncValueAndDispatch(e)}else n&&this.syncValueAndDispatch(e.get(`_value`));if(e.has(`defaultOptions`)&&this.defaultOptions.length&&(this.options=[...(Array.isArray(this.options)?this.options:[]).filter(e=>e.userAdded)||[],...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=Array.isArray(this.options)?[...this.options]:[]),e.has(`options`)){let t=e.get(`options`)||this._options||[],n=h.mergeWithUserAdded(this.options,t);this._options=n,n.length>this.options.length&&(this.options=n);let r=h.syncOptionsWithValues(this._options,this._value);if(this._options=r.options,r.newValues.length>this._value.length){let e=[...this._value];this._value=r.newValues,this.syncValueAndDispatch(e)}}if(e.has(`_search`)&&this.dispatchEvent(new CustomEvent(`search`,{detail:this._search,bubbles:!1})),!this._isOptionsOpen&&!this.multiple&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!==`hidden`){let e=this._value[0]?f(this._value[0],this.options,this.displayValueAs):``;this.inputRef.value.value!==e&&(this.inputRef.value.value=e)}super.updated(e)}formResetCallback(){this.touched=!1,this.value=this.defaultValue||(this.multiple,``),this._value=this.parseValue(),this._options=this._options.filter(e=>!e.userAdded).map(e=>({...e,selected:this._value.includes(e.value)})),this.options=this.options.filter(e=>!e.userAdded).map(e=>({...e,selected:this._value.includes(e.value)})),this._search=``,this._isOptionsOpen=!1,this._userInfoMessage=``,this._addValueText=null,this._inputFocus=!1,this.updateMaxReached(),this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(this.inputRef.value.value=``),this.internals.setFormValue(``),this.internals.ariaInvalid=`false`,this.requestUpdate()}attributeChangedCallback(e,t,n){if(e===`options`){this._options=Array.isArray(this.options)?[...this.options]:[];let e=h.syncOptionsWithValues(this._options,this._value);this._options=e.options,e.newValues.length>this._value.length&&(this._value=e.newValues),this._search=``}super.attributeChangedCallback(e,t,n)}render(){return e.p`
|
|
2
2
|
<pkt-input-wrapper
|
|
3
3
|
.label=${this.label}
|
|
4
4
|
.helptext=${this.helptext}
|
|
@@ -18,6 +18,8 @@ export interface IPktHeader {
|
|
|
18
18
|
hideLogo?: Booleanish;
|
|
19
19
|
/** Logo link URL */
|
|
20
20
|
logoLink?: string;
|
|
21
|
+
/** Override CDN path for the logo */
|
|
22
|
+
logoPath?: string;
|
|
21
23
|
/** Service name displayed in the header */
|
|
22
24
|
serviceName?: string;
|
|
23
25
|
/** Service link URL */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require(`./element-CXAtr6Gu.cjs`);require(`./icon-Dw6I0HDV.cjs`),require(`./button-
|
|
1
|
+
const e=require(`./element-CXAtr6Gu.cjs`);require(`./icon-Dw6I0HDV.cjs`),require(`./button-Bqk9wjme.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.p`<a href="#" class="pkt-link" @click=${this.openModal}>${this.triggerText}</a>`:this.triggerType===`footerlink`?e.p`<a href="#" class="pkt-footer__link" @click=${this.openModal}>
|
|
2
2
|
<pkt-icon name="chevron-right" class="pkt-footer__link-icon"></pkt-icon>
|
|
3
3
|
${this.triggerText}
|
|
4
4
|
</a>`:this.triggerType===`icon`?e.p`<pkt-button
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require(`./element-CXAtr6Gu.cjs`),t=require(`./class-map-B8Ja0q7n.cjs`),n=require(`./element-with-slot-Cmxb9h4H.cjs`);require(`./icon-Dw6I0HDV.cjs`);const r=require(`./if-defined-LTjAScFG.cjs`),i=require(`./ref-CBdWMlde.cjs`),a=require(`./converters-CkqZ02TI.cjs`);require(`./calendar-64LmbIdR.cjs`),require(`./tag-CBFz0R9N.cjs`);const o=require(`./repeat-CRRgmzVn.cjs`),s=require(`./utils-CjAbIttF.cjs`),c=require(`./input-element-BHQVt4Q9.cjs`);require(`./input-wrapper-
|
|
1
|
+
const e=require(`./element-CXAtr6Gu.cjs`),t=require(`./class-map-B8Ja0q7n.cjs`),n=require(`./element-with-slot-Cmxb9h4H.cjs`);require(`./icon-Dw6I0HDV.cjs`);const r=require(`./if-defined-LTjAScFG.cjs`),i=require(`./ref-CBdWMlde.cjs`),a=require(`./converters-CkqZ02TI.cjs`);require(`./calendar-64LmbIdR.cjs`),require(`./tag-CBFz0R9N.cjs`);const o=require(`./repeat-CRRgmzVn.cjs`),s=require(`./utils-CjAbIttF.cjs`),c=require(`./input-element-BHQVt4Q9.cjs`);require(`./input-wrapper-CvtU-Ksb.cjs`);var l={calendar:{buttonAltText:`Åpne kalender`}},u={calendar:{buttonAltText:`Åpne kalender`},generic:{from:`Fra`,to:`Til`}},d=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.p`
|
|
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.p` <pkt-tag
|
|
4
4
|
id=${this.idBase+t+`-tag`}
|
|
@@ -10,7 +10,7 @@ import "./tag-CzlnHhho.js";
|
|
|
10
10
|
import { t as C } from "./repeat-CKIii8Mi.js";
|
|
11
11
|
import { n as w, t as T } from "./utils-CUqCKGvp.js";
|
|
12
12
|
import { t as E } from "./input-element-BrmkXIXi.js";
|
|
13
|
-
import "./input-wrapper-
|
|
13
|
+
import "./input-wrapper-C93MmOIg.js";
|
|
14
14
|
//#region ../../shared-types/datepicker.ts
|
|
15
15
|
var D = { calendar: { buttonAltText: "Åpne kalender" } }, O = {
|
|
16
16
|
calendar: { buttonAltText: "Åpne kalender" },
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { a as e, n as t, o as n, p as r, s as i, t as a } from "./element-CduG0XyF.js";
|
|
2
2
|
import { t as o } from "./class-map-DH9hlJny.js";
|
|
3
|
-
import "./alert-
|
|
3
|
+
import "./alert-B5Y841vH.js";
|
|
4
4
|
import "./icon-LaKyBKON.js";
|
|
5
5
|
import { t as s } from "./if-defined-VShASPdu.js";
|
|
6
6
|
import { t as c } from "./converters-BQnj7OJE.js";
|
|
7
7
|
import { n as l } from "./utils-CUqCKGvp.js";
|
|
8
|
-
import "./input-wrapper-
|
|
8
|
+
import "./input-wrapper-C93MmOIg.js";
|
|
9
9
|
import "./modal-CWgeT-RP.js";
|
|
10
10
|
import "./progressbar-B0P_vmGD.js";
|
|
11
11
|
//#region ../../shared-types/fileupload.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require(`./element-CXAtr6Gu.cjs`),t=require(`./class-map-B8Ja0q7n.cjs`);require(`./alert-D_45dWPn.cjs`),require(`./icon-Dw6I0HDV.cjs`);const n=require(`./if-defined-LTjAScFG.cjs`),r=require(`./converters-CkqZ02TI.cjs`),i=require(`./utils-CjAbIttF.cjs`);require(`./input-wrapper-Dhkt20WW.cjs`),require(`./modal-CrYHKOmr.cjs`),require(`./progressbar-DADdvDl5.cjs`);var a={dropZoneDragMultiple:`Dra filer hit for å laste dem opp eller`,dropZoneDragSingle:`Dra en fil hit for å laste den opp eller`,dropZoneDragMultipleThumbnail:`Dra bilder hit for å laste dem opp eller`,dropZoneDragSingleThumbnail:`Dra et bilde hit for å laste det opp eller`,dropZoneDragActiveMultiple:`Slipp filene her`,dropZoneDragActiveSingle:`Slipp filen her`,dropZoneDragActiveMultipleThumbnail:`Slipp bildene her`,dropZoneDragActiveSingleThumbnail:`Slipp bildet her`,dropZoneOpenFileDialogMultiple:`velg filer`,dropZoneOpenFileDialogSingle:`velg en fil`,dropZoneOpenFileDialogMultipleThumbnail:`velg fra kamerarull`,dropZoneOpenFileDialogSingleThumbnail:`velg fra kamerarull`,supportedFormatsPrefix:`Format:`,invalidFormatDefault:e=>`Ugyldig filtype. Tillatte formater: ${e}`,sizeTooLargeDefault:e=>`Filen er for stor. Maks størrelse er ${e}.`,requiredMissing:`Du må laste opp minst én fil.`,genericValidationRejection:`Filen ble avvist av validering.`,unknownFilename:`Ukjent fil`,fileLabel:e=>e===1?`fil`:`filer`,srFileAdded:e=>`Filen «${e}» er lagt til`,srFilesAdded:e=>`${e} filer er lagt til`,srFilesUploadedOfTotal:(e,t,n)=>`${e} av ${t} ${n} lastet opp`,srFilesFailedOfTotal:(e,t,n)=>`Feil ved opplasting: ${e} av ${t} ${n} feilet`};function o(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 s(e){return e<1024?`${Math.round(e)} B`:e<1024*1024?`${Math.round(e/1024)} KB`:e<1024*1024*1024?`${Math.round(e/(1024*1024))} MB`:`${Math.round(e/(1024*1024*1024))} GB`}function c(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function l(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function u(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 d(e,t){let n=c(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>u(e,r,i))}function f(e,t){let n=(e??``).trim();if(n)return n;let r=c(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function p(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function m(e,t){let n=c(e);if(n.length>0)return n.map(p).join(`, `);let r=l(t);return r.length>0?r.map(p).join(`, `):``}function h(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function g(e,t){let n=c(t.allowedFormats);if(n.length>0&&!d(e,n)){let e=n.join(`, `),r=`Ugyldig filtype. Tillatte formater: ${e}`;return h(t.formatErrorMessage,r,{formats:e})}let r=o(t.maxFileSize);if(r!==void 0&&e.size>r){let e=s(r),n=`Filen er for stor. Maks størrelse er ${e}.`;return h(t.sizeErrorMessage,n,{maxSize:e})}if(t.onFileValidation){let n=t.onFileValidation(e);if(n)return n}return null}function _(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 v(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function y(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[v(e.progress)]-r[v(t.progress)])}function b(e){if(!e)return[];let t=[`a[href]:not([tabindex="-1"])`,`button:not([disabled]):not([tabindex="-1"])`,`input:not([disabled]):not([type="hidden"]):not([tabindex="-1"])`,`select:not([disabled]):not([tabindex="-1"])`,`textarea:not([disabled]):not([tabindex="-1"])`,`[tabindex]:not([tabindex="-1"])`].join(`, `);return Array.from(e.querySelectorAll(t)).filter(e=>!e.hasAttribute(`inert`))}function x(e,t){if(e.key!==`Tab`)return!1;let n=b(t);if(n.length===0)return e.preventDefault(),!0;let r=n[0],i=n[n.length-1],a=(t?.ownerDocument??document).activeElement,o=!!a&&n.includes(a);return e.shiftKey?!o||a===r?(e.preventDefault(),i.focus(),!0):!1:!o||a===i?(e.preventDefault(),r.focus(),!0):!1}function S(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function C(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function w(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 T(e,t=a.unknownFilename){return e.attributes?.targetFilename||e.file?.name||t}var E=class extends e.t{constructor(...e){super(...e),this.id=`pkt-fileupload-${i.n()}`,this.name=`files`,this.label=``,this.helptext=``,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.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.requiredSelectionMessage=a.requiredMissing,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 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:i.n(),file:e,attributes:{targetFilename:e.name}}));this.setAddedAnnouncement(n.length===1?a.srFileAdded(n[0].attributes.targetFilename):a.srFilesAdded(n.length));let r=this.getCurrentFiles(),o=this.multiple?[...r,...n]:[n[0]];this.commitFiles(o,`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 _(e)}formatFileSize(e){return s(e)}getResolvedAcceptValue(){return f(this.accept,this.allowedFormats)}getSupportedFormatsText(){return m(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return y(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=g(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?a.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}=w(this.getCurrentFiles(),this.transfers);return e===0||t===0?``:a.srFilesUploadedOfTotal(t,e,a.fileLabel(e))}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=w(this.getCurrentFiles(),this.transfers);return e===0||t===0?``:a.srFilesFailedOfTotal(t,e,a.fileLabel(e))}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.o({type:String})],E.prototype,`id`,void 0),e.n([e.o({type:String})],E.prototype,`name`,void 0),e.n([e.o({type:String})],E.prototype,`label`,void 0),e.n([e.o({type:String})],E.prototype,`helptext`,void 0),e.n([e.o({type:Boolean,reflect:!0})],E.prototype,`required`,void 0),e.n([e.o({type:Boolean,reflect:!0})],E.prototype,`multiple`,void 0),e.n([e.o({type:Boolean,reflect:!0})],E.prototype,`disabled`,void 0),e.n([e.o({type:Boolean,reflect:!0,attribute:`fullwidth`})],E.prototype,`fullwidth`,void 0),e.n([e.o({type:String,reflect:!0,attribute:`upload-strategy`})],E.prototype,`uploadStrategy`,void 0),e.n([e.o({type:String,reflect:!0,attribute:`item-renderer`})],E.prototype,`itemRenderer`,void 0),e.n([e.o({type:String})],E.prototype,`accept`,void 0),e.n([e.o({converter:r.t.csvToArray,attribute:`allowed-formats`})],E.prototype,`allowedFormats`,void 0),e.n([e.o({type:String,attribute:`format-error-message`})],E.prototype,`formatErrorMessage`,void 0),e.n([e.o({attribute:`max-file-size`})],E.prototype,`maxFileSize`,void 0),e.n([e.o({type:String,attribute:`size-error-message`})],E.prototype,`sizeErrorMessage`,void 0),e.n([e.o({attribute:!1})],E.prototype,`onFileValidation`,void 0),e.n([e.o({attribute:!1})],E.prototype,`transfers`,void 0),e.n([e.o({type:Boolean,attribute:`add-comments-enabled`})],E.prototype,`addCommentsEnabled`,void 0),e.n([e.o({type:Boolean,attribute:`rename-files-enabled`})],E.prototype,`renameFilesEnabled`,void 0),e.n([e.o({attribute:!1})],E.prototype,`extraOperations`,void 0),e.n([e.o({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],E.prototype,`enableImagePreview`,void 0),e.n([e.o({type:Boolean,attribute:`has-error`})],E.prototype,`hasError`,void 0),e.n([e.o({type:String,attribute:`error-message`})],E.prototype,`errorMessage`,void 0),e.n([e.o({type:Boolean,attribute:`optional-tag`})],E.prototype,`optionalTag`,void 0),e.n([e.o({type:Boolean,attribute:`required-tag`})],E.prototype,`requiredTag`,void 0),e.n([e.o({type:Number,attribute:`truncate-tail`})],E.prototype,`truncateTail`,void 0),e.n([e.o({attribute:!1})],E.prototype,`value`,void 0),e.n([e.o({attribute:!1})],E.prototype,`defaultValue`,void 0),e.n([e.a()],E.prototype,`files`,void 0),e.n([e.a()],E.prototype,`isDragActive`,void 0),e.n([e.a()],E.prototype,`validationErrorMessage`,void 0),e.n([e.a()],E.prototype,`addedAnnouncement`,void 0),e.n([e.a()],E.prototype,`thumbnailUrls`,void 0);var D=`comments`,O=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`)}`},k=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},A=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},j=e=>({id:`remove`,title:`Slett`,ariaLabel:`Slett fil`,onClick:({file:t})=>e(t.fileId)}),M=()=>({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.p`
|
|
1
|
+
const e=require(`./element-CXAtr6Gu.cjs`),t=require(`./class-map-B8Ja0q7n.cjs`);require(`./alert-C8OpU_Un.cjs`),require(`./icon-Dw6I0HDV.cjs`);const n=require(`./if-defined-LTjAScFG.cjs`),r=require(`./converters-CkqZ02TI.cjs`),i=require(`./utils-CjAbIttF.cjs`);require(`./input-wrapper-CvtU-Ksb.cjs`),require(`./modal-CrYHKOmr.cjs`),require(`./progressbar-DADdvDl5.cjs`);var a={dropZoneDragMultiple:`Dra filer hit for å laste dem opp eller`,dropZoneDragSingle:`Dra en fil hit for å laste den opp eller`,dropZoneDragMultipleThumbnail:`Dra bilder hit for å laste dem opp eller`,dropZoneDragSingleThumbnail:`Dra et bilde hit for å laste det opp eller`,dropZoneDragActiveMultiple:`Slipp filene her`,dropZoneDragActiveSingle:`Slipp filen her`,dropZoneDragActiveMultipleThumbnail:`Slipp bildene her`,dropZoneDragActiveSingleThumbnail:`Slipp bildet her`,dropZoneOpenFileDialogMultiple:`velg filer`,dropZoneOpenFileDialogSingle:`velg en fil`,dropZoneOpenFileDialogMultipleThumbnail:`velg fra kamerarull`,dropZoneOpenFileDialogSingleThumbnail:`velg fra kamerarull`,supportedFormatsPrefix:`Format:`,invalidFormatDefault:e=>`Ugyldig filtype. Tillatte formater: ${e}`,sizeTooLargeDefault:e=>`Filen er for stor. Maks størrelse er ${e}.`,requiredMissing:`Du må laste opp minst én fil.`,genericValidationRejection:`Filen ble avvist av validering.`,unknownFilename:`Ukjent fil`,fileLabel:e=>e===1?`fil`:`filer`,srFileAdded:e=>`Filen «${e}» er lagt til`,srFilesAdded:e=>`${e} filer er lagt til`,srFilesUploadedOfTotal:(e,t,n)=>`${e} av ${t} ${n} lastet opp`,srFilesFailedOfTotal:(e,t,n)=>`Feil ved opplasting: ${e} av ${t} ${n} feilet`};function o(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 s(e){return e<1024?`${Math.round(e)} B`:e<1024*1024?`${Math.round(e/1024)} KB`:e<1024*1024*1024?`${Math.round(e/(1024*1024))} MB`:`${Math.round(e/(1024*1024*1024))} GB`}function c(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function l(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function u(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 d(e,t){let n=c(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>u(e,r,i))}function f(e,t){let n=(e??``).trim();if(n)return n;let r=c(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function p(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function m(e,t){let n=c(e);if(n.length>0)return n.map(p).join(`, `);let r=l(t);return r.length>0?r.map(p).join(`, `):``}function h(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function g(e,t){let n=c(t.allowedFormats);if(n.length>0&&!d(e,n)){let e=n.join(`, `),r=`Ugyldig filtype. Tillatte formater: ${e}`;return h(t.formatErrorMessage,r,{formats:e})}let r=o(t.maxFileSize);if(r!==void 0&&e.size>r){let e=s(r),n=`Filen er for stor. Maks størrelse er ${e}.`;return h(t.sizeErrorMessage,n,{maxSize:e})}if(t.onFileValidation){let n=t.onFileValidation(e);if(n)return n}return null}function _(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 v(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function y(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[v(e.progress)]-r[v(t.progress)])}function b(e){if(!e)return[];let t=[`a[href]:not([tabindex="-1"])`,`button:not([disabled]):not([tabindex="-1"])`,`input:not([disabled]):not([type="hidden"]):not([tabindex="-1"])`,`select:not([disabled]):not([tabindex="-1"])`,`textarea:not([disabled]):not([tabindex="-1"])`,`[tabindex]:not([tabindex="-1"])`].join(`, `);return Array.from(e.querySelectorAll(t)).filter(e=>!e.hasAttribute(`inert`))}function x(e,t){if(e.key!==`Tab`)return!1;let n=b(t);if(n.length===0)return e.preventDefault(),!0;let r=n[0],i=n[n.length-1],a=(t?.ownerDocument??document).activeElement,o=!!a&&n.includes(a);return e.shiftKey?!o||a===r?(e.preventDefault(),i.focus(),!0):!1:!o||a===i?(e.preventDefault(),r.focus(),!0):!1}function S(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function C(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function w(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 T(e,t=a.unknownFilename){return e.attributes?.targetFilename||e.file?.name||t}var E=class extends e.t{constructor(...e){super(...e),this.id=`pkt-fileupload-${i.n()}`,this.name=`files`,this.label=``,this.helptext=``,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.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.requiredSelectionMessage=a.requiredMissing,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 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:i.n(),file:e,attributes:{targetFilename:e.name}}));this.setAddedAnnouncement(n.length===1?a.srFileAdded(n[0].attributes.targetFilename):a.srFilesAdded(n.length));let r=this.getCurrentFiles(),o=this.multiple?[...r,...n]:[n[0]];this.commitFiles(o,`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 _(e)}formatFileSize(e){return s(e)}getResolvedAcceptValue(){return f(this.accept,this.allowedFormats)}getSupportedFormatsText(){return m(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return y(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=g(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?a.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}=w(this.getCurrentFiles(),this.transfers);return e===0||t===0?``:a.srFilesUploadedOfTotal(t,e,a.fileLabel(e))}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=w(this.getCurrentFiles(),this.transfers);return e===0||t===0?``:a.srFilesFailedOfTotal(t,e,a.fileLabel(e))}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.o({type:String})],E.prototype,`id`,void 0),e.n([e.o({type:String})],E.prototype,`name`,void 0),e.n([e.o({type:String})],E.prototype,`label`,void 0),e.n([e.o({type:String})],E.prototype,`helptext`,void 0),e.n([e.o({type:Boolean,reflect:!0})],E.prototype,`required`,void 0),e.n([e.o({type:Boolean,reflect:!0})],E.prototype,`multiple`,void 0),e.n([e.o({type:Boolean,reflect:!0})],E.prototype,`disabled`,void 0),e.n([e.o({type:Boolean,reflect:!0,attribute:`fullwidth`})],E.prototype,`fullwidth`,void 0),e.n([e.o({type:String,reflect:!0,attribute:`upload-strategy`})],E.prototype,`uploadStrategy`,void 0),e.n([e.o({type:String,reflect:!0,attribute:`item-renderer`})],E.prototype,`itemRenderer`,void 0),e.n([e.o({type:String})],E.prototype,`accept`,void 0),e.n([e.o({converter:r.t.csvToArray,attribute:`allowed-formats`})],E.prototype,`allowedFormats`,void 0),e.n([e.o({type:String,attribute:`format-error-message`})],E.prototype,`formatErrorMessage`,void 0),e.n([e.o({attribute:`max-file-size`})],E.prototype,`maxFileSize`,void 0),e.n([e.o({type:String,attribute:`size-error-message`})],E.prototype,`sizeErrorMessage`,void 0),e.n([e.o({attribute:!1})],E.prototype,`onFileValidation`,void 0),e.n([e.o({attribute:!1})],E.prototype,`transfers`,void 0),e.n([e.o({type:Boolean,attribute:`add-comments-enabled`})],E.prototype,`addCommentsEnabled`,void 0),e.n([e.o({type:Boolean,attribute:`rename-files-enabled`})],E.prototype,`renameFilesEnabled`,void 0),e.n([e.o({attribute:!1})],E.prototype,`extraOperations`,void 0),e.n([e.o({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],E.prototype,`enableImagePreview`,void 0),e.n([e.o({type:Boolean,attribute:`has-error`})],E.prototype,`hasError`,void 0),e.n([e.o({type:String,attribute:`error-message`})],E.prototype,`errorMessage`,void 0),e.n([e.o({type:Boolean,attribute:`optional-tag`})],E.prototype,`optionalTag`,void 0),e.n([e.o({type:Boolean,attribute:`required-tag`})],E.prototype,`requiredTag`,void 0),e.n([e.o({type:Number,attribute:`truncate-tail`})],E.prototype,`truncateTail`,void 0),e.n([e.o({attribute:!1})],E.prototype,`value`,void 0),e.n([e.o({attribute:!1})],E.prototype,`defaultValue`,void 0),e.n([e.a()],E.prototype,`files`,void 0),e.n([e.a()],E.prototype,`isDragActive`,void 0),e.n([e.a()],E.prototype,`validationErrorMessage`,void 0),e.n([e.a()],E.prototype,`addedAnnouncement`,void 0),e.n([e.a()],E.prototype,`thumbnailUrls`,void 0);var D=`comments`,O=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`)}`},k=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},A=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},j=e=>({id:`remove`,title:`Slett`,ariaLabel:`Slett fil`,onClick:({file:t})=>e(t.fileId)}),M=()=>({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.p`
|
|
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-CXAtr6Gu.cjs`),t=require(`./class-map-B8Ja0q7n.cjs`),n=require(`./element-with-slot-Cmxb9h4H.cjs`);require(`./icon-Dw6I0HDV.cjs`);const r=require(`./if-defined-LTjAScFG.cjs`);require(`./button-
|
|
1
|
+
const e=require(`./element-CXAtr6Gu.cjs`),t=require(`./class-map-B8Ja0q7n.cjs`),n=require(`./element-with-slot-Cmxb9h4H.cjs`);require(`./icon-Dw6I0HDV.cjs`);const r=require(`./if-defined-LTjAScFG.cjs`);require(`./button-Bqk9wjme.cjs`);const i=require(`./ref-CBdWMlde.cjs`),a=require(`./booleanish-jJLlnr6-.cjs`);require(`./link-EZ0-lS3W.cjs`),require(`./textinput-DSYABvB6.cjs`);var o=e=>typeof e.target==`string`?{title:e.title,iconName:e.iconName,href:e.target}:{title:e.title,iconName:e.iconName,onClick:e.target},s=e=>o(e),c=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`})},l=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.p`
|
|
2
2
|
<pkt-link
|
|
3
3
|
icon-name=${n.iconName||e.d}
|
|
4
4
|
href=${n.href}
|
|
@@ -80,8 +80,8 @@ const e=require(`./element-CXAtr6Gu.cjs`),t=require(`./class-map-B8Ja0q7n.cjs`),
|
|
|
80
80
|
`:e.d}
|
|
81
81
|
</ul>
|
|
82
82
|
</nav>
|
|
83
|
-
`}};e.n([e.o({type:Object})],l.prototype,`user`,void 0),e.n([e.o({type:String,attribute:`formatted-last-logged-in`})],l.prototype,`formattedLastLoggedIn`,void 0),e.n([e.o({type:Object})],l.prototype,`representing`,void 0),e.n([e.o({type:Array,attribute:`user-menu`})],l.prototype,`userMenu`,void 0),e.n([e.o({type:Boolean,attribute:`can-change-representation`,converter:a.t})],l.prototype,`canChangeRepresentation`,void 0),e.n([e.o({type:Boolean,attribute:`logout-on-click`,converter:a.t})],l.prototype,`logoutOnClick`,void 0);try{e.s(`pkt-header-user-menu`)(l)}catch{console.warn(`Forsøker å definere <pkt-header-user-menu>, men den er allerede definert`)}var u=`https://punkt-cdn.oslo.kommune.no/latest/logos
|
|
84
|
-
<pkt-icon name="oslologo" aria-hidden="true" path=${
|
|
83
|
+
`}};e.n([e.o({type:Object})],l.prototype,`user`,void 0),e.n([e.o({type:String,attribute:`formatted-last-logged-in`})],l.prototype,`formattedLastLoggedIn`,void 0),e.n([e.o({type:Object})],l.prototype,`representing`,void 0),e.n([e.o({type:Array,attribute:`user-menu`})],l.prototype,`userMenu`,void 0),e.n([e.o({type:Boolean,attribute:`can-change-representation`,converter:a.t})],l.prototype,`canChangeRepresentation`,void 0),e.n([e.o({type:Boolean,attribute:`logout-on-click`,converter:a.t})],l.prototype,`logoutOnClick`,void 0);try{e.s(`pkt-header-user-menu`)(l)}catch{console.warn(`Forsøker å definere <pkt-header-user-menu>, men den er allerede definert`)}var u=`https://punkt-cdn.oslo.kommune.no/latest/logos/`;typeof window<`u`&&(window.pktLogoPath=window.pktLogoPath||u);var d=class extends n.t{constructor(...e){super(...e),this.logoPath=typeof window<`u`?window.pktLogoPath:u,this.searchPlaceholder=`Søk`,this.searchValue=``,this.mobileBreakpoint=768,this.tabletBreakpoint=1280,this.openedMenu=`none`,this.logOutButtonPlacement=`none`,this.position=`fixed`,this.scrollBehavior=`hide`,this.slotMenuVariant=`icon-only`,this.slotMenuText=`Meny`,this.hideLogo=!1,this.compact=!1,this.showSearch=!1,this.canChangeRepresentation=!1,this.hasLogOut=!1,this.isMobile=!1,this.isTablet=!1,this.openMenu=`none`,this.isHidden=!1,this.componentWidth=typeof window<`u`?window.innerWidth:0,this.alignSlotRight=!1,this.alignSearchRight=!1,this.headerRef=i.t(),this.userContainerRef=i.t(),this.slotContainerRef=i.t(),this.searchContainerRef=i.t(),this.slotContentRef=i.t(),this.searchMenuRef=i.t(),this.lastScrollPosition=0,this.savedScrollY=0,this.lastFocusedElement=null,this.shouldRestoreFocus=!1,this.handleScroll=()=>{if(!this.shouldHideOnScroll)return;let e=window.pageYOffset||document.documentElement.scrollTop;e<0||Math.abs(e-this.lastScrollPosition)<60||(this.isHidden=e>this.lastScrollPosition,this.lastScrollPosition=e)},this.handleClickOutside=e=>{let t=e.target;this.user&&this.openMenu===`user`&&!t.closest(`.pkt-header-service__user-container`)&&(this.openMenu=`none`),this.openMenu===`slot`&&!t.closest(`.pkt-header-service__slot-container`)&&(this.openMenu=`none`),this.openMenu===`search`&&!t.closest(`.pkt-header-service__search-container`)&&!t.closest(`.pkt-header-service__search-input`)&&(this.openMenu=`none`)},this.handleSlotContentClick=e=>{if(!this.isTablet||this.openMenu!==`slot`)return;let t=e.target.closest(`a[href], button, [role="link"], [role="button"], [role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]`);!t||!this.slotContentRef.value?.contains(t)||t.closest(`[data-pkt-header-keep-open]`)||t.disabled||t.getAttribute(`aria-disabled`)===`true`||(this.openMenu=`none`)},this.handleFocusOut=(e,t)=>{let n=e.relatedTarget,r;switch(t){case`user`:r=this.userContainerRef;break;case`slot`:r=this.slotContainerRef;break;case`search`:r=this.searchContainerRef;break;default:return}let i=r.value;i&&(!n||!i.contains(n))&&(this.openMenu=`none`)},this.handleEscapeKey=e=>{e.key===`Escape`&&this.openMenu!==`none`&&(e.preventDefault(),this.shouldRestoreFocus=!0,this.openMenu=`none`)}}connectedCallback(){super.connectedCallback(),this.setupScrollListener()}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver?.disconnect(),window.removeEventListener(`scroll`,this.handleScroll),this.unlockScroll()}firstUpdated(){this.setupResizeObserver()}updated(e){if(super.updated(e),e.has(`openedMenu`)&&this.openedMenu!==this.openMenu&&(this.openMenu=this.openedMenu),(e.has(`mobileBreakpoint`)||e.has(`tabletBreakpoint`))&&(this.updateIsMobile(),this.updateIsTablet()),e.has(`openMenu`)){let t=e.get(`openMenu`);this.openMenu!==`none`&&(t===`none`||t===void 0)?(document.addEventListener(`mousedown`,this.handleClickOutside),document.addEventListener(`keydown`,this.handleEscapeKey),(this.openMenu===`slot`||this.openMenu===`search`)&&requestAnimationFrame(()=>{this.checkDropdownAlignment(this.openMenu)})):this.openMenu===`none`&&t!==`none`&&(document.removeEventListener(`mousedown`,this.handleClickOutside),document.removeEventListener(`keydown`,this.handleEscapeKey),this.restoreFocus())}(e.has(`openMenu`)||e.has(`isMobile`))&&this.updateScrollLock()}setupResizeObserver(){let e=this.headerRef.value;e&&(this.componentWidth=e.offsetWidth,this.updateIsMobile(),this.updateIsTablet(),this.resizeObserver=new ResizeObserver(e=>{for(let t of e)t.borderBoxSize&&t.borderBoxSize.length>0?this.componentWidth=t.borderBoxSize[0].inlineSize:this.componentWidth=t.contentRect.width,this.updateIsMobile(),this.updateIsTablet()}),this.resizeObserver.observe(e))}updateIsMobile(){this.isMobile=this.componentWidth<this.mobileBreakpoint}updateIsTablet(){this.isTablet=this.componentWidth<this.tabletBreakpoint}updateScrollLock(){this.position===`fixed`&&this.isMobile&&this.openMenu!==`none`?this.lockScroll():this.unlockScroll()}lockScroll(){let e=document.body,t=document.documentElement;this.savedScrollY=window.scrollY||window.pageYOffset;let n=window.innerWidth-t.clientWidth;n>0&&(e.style.paddingRight=`${n}px`),e.style.position=`fixed`,e.style.top=`-${this.savedScrollY}px`,e.style.left=`0`,e.style.right=`0`,e.style.width=`100%`,e.style.overflow=`hidden`,t.classList.add(`is-scroll-locked`)}unlockScroll(){let e=document.body,t=document.documentElement;t.classList.contains(`is-scroll-locked`)&&(e.style.removeProperty(`position`),e.style.removeProperty(`top`),e.style.removeProperty(`left`),e.style.removeProperty(`right`),e.style.removeProperty(`width`),e.style.removeProperty(`overflow`),e.style.removeProperty(`padding-right`),t.classList.remove(`is-scroll-locked`),window.scrollTo({top:this.savedScrollY}))}setupScrollListener(){window.addEventListener(`scroll`,this.handleScroll)}restoreFocus(){this.shouldRestoreFocus&&this.lastFocusedElement&&document.contains(this.lastFocusedElement)&&this.lastFocusedElement.focus(),this.lastFocusedElement=null,this.shouldRestoreFocus=!1}checkDropdownAlignment(e){let t=e===`slot`?this.slotContainerRef:this.searchContainerRef,n=e===`slot`?this.slotContentRef:this.searchMenuRef;if(!t.value||!n.value||!this.isTablet||this.isMobile)return;let r=t.value.getBoundingClientRect(),i=n.value.offsetWidth,a=r.left+i>window.innerWidth;e===`slot`?this.alignSlotRight=a:this.alignSearchRight=a}handleMenuToggle(e){this.openMenu===`none`?(this.lastFocusedElement=document.activeElement,this.openMenu=e):this.openMenu=`none`}handleLogoClick(e){this.dispatchEvent(new CustomEvent(`logo-click`,{bubbles:!0,composed:!0,detail:{originalEvent:e}}))}handleServiceClick(e){this.dispatchEvent(new CustomEvent(`service-click`,{bubbles:!0,composed:!0,detail:{originalEvent:e}}))}handleLogout(){this.dispatchEvent(new CustomEvent(`log-out`,{bubbles:!0,composed:!0}))}handleSearch(e){this.dispatchEvent(new CustomEvent(`search`,{detail:{query:e},bubbles:!0,composed:!0}))}handleSearchChange(e){this.dispatchEvent(new CustomEvent(`search-change`,{detail:{query:e},bubbles:!0,composed:!0}))}handleSearchInputChange(e){let t=e.target.value;this.handleSearchChange(t)}handleSearchKeyDown(e){e.key===`Enter`&&this.handleSearch(e.target.value)}get formattedLastLoggedIn(){return c(this.user?.lastLoggedIn)}get isFixed(){return this.position===`fixed`}get shouldHideOnScroll(){return this.scrollBehavior===`hide`}get showLogoutInHeader(){return this.hasLogOut&&(this.logOutButtonPlacement===`header`||this.logOutButtonPlacement===`both`)}get showLogoutInUserMenu(){return this.hasLogOut&&(this.logOutButtonPlacement===`userMenu`||this.logOutButtonPlacement===`both`)}renderLogo(){if(this.hideLogo)return e.d;let t=e.p`
|
|
84
|
+
<pkt-icon name="oslologo" aria-hidden="true" path=${this.logoPath}></pkt-icon>
|
|
85
85
|
`;return this.logoLink&&typeof this.logoLink==`string`?e.p`
|
|
86
86
|
<span class="pkt-header-service__logo">
|
|
87
87
|
<a href=${this.logoLink} aria-label="Tilbake til forside" @click=${this.handleLogoClick}>
|
|
@@ -280,11 +280,12 @@ const e=require(`./element-CXAtr6Gu.cjs`),t=require(`./class-map-B8Ja0q7n.cjs`),
|
|
|
280
280
|
${n}
|
|
281
281
|
<div class=${t.t({"pkt-header-service-spacer":!0,"pkt-header-service-spacer--compact":this.compact,"pkt-header-service-spacer--has-user":!!this.user,"pkt-header-service-spacer--mobile":this.isMobile,"pkt-header-service-spacer--tablet":this.isTablet})}></div>
|
|
282
282
|
</div>
|
|
283
|
-
`:n}};e.n([e.o({type:String,attribute:`service-name`})],d.prototype,`serviceName`,void 0),e.n([e.o({type:String,attribute:`service-link`})],d.prototype,`serviceLink`,void 0),e.n([e.o({type:String,attribute:`logo-link`})],d.prototype,`logoLink`,void 0),e.n([e.o({type:String,attribute:`search-placeholder`})],d.prototype,`searchPlaceholder`,void 0),e.n([e.o({type:String,attribute:`search-value`})],d.prototype,`searchValue`,void 0),e.n([e.o({type:Number,attribute:`mobile-breakpoint`})],d.prototype,`mobileBreakpoint`,void 0),e.n([e.o({type:Number,attribute:`tablet-breakpoint`})],d.prototype,`tabletBreakpoint`,void 0),e.n([e.o({type:String,attribute:`opened-menu`})],d.prototype,`openedMenu`,void 0),e.n([e.o({type:String,attribute:`log-out-button-placement`})],d.prototype,`logOutButtonPlacement`,void 0),e.n([e.o({type:String})],d.prototype,`position`,void 0),e.n([e.o({type:String,attribute:`scroll-behavior`})],d.prototype,`scrollBehavior`,void 0),e.n([e.o({type:String,attribute:`slot-menu-variant`})],d.prototype,`slotMenuVariant`,void 0),e.n([e.o({type:String,attribute:`slot-menu-text`})],d.prototype,`slotMenuText`,void 0),e.n([e.o({type:Boolean,attribute:`hide-logo`,converter:a.t})],d.prototype,`hideLogo`,void 0),e.n([e.o({type:Boolean,converter:a.t})],d.prototype,`compact`,void 0),e.n([e.o({type:Boolean,attribute:`show-search`,converter:a.t})],d.prototype,`showSearch`,void 0),e.n([e.o({type:Boolean,attribute:`can-change-representation`,converter:a.t})],d.prototype,`canChangeRepresentation`,void 0),e.n([e.o({type:Boolean,attribute:`has-log-out`,converter:a.t})],d.prototype,`hasLogOut`,void 0),e.n([e.o({type:Object})],d.prototype,`user`,void 0),e.n([e.o({type:Array,attribute:`user-menu`})],d.prototype,`userMenu`,void 0),e.n([e.o({type:Object})],d.prototype,`representing`,void 0),e.n([e.a()],d.prototype,`isMobile`,void 0),e.n([e.a()],d.prototype,`isTablet`,void 0),e.n([e.a()],d.prototype,`openMenu`,void 0),e.n([e.a()],d.prototype,`isHidden`,void 0),e.n([e.a()],d.prototype,`componentWidth`,void 0),e.n([e.a()],d.prototype,`alignSlotRight`,void 0),e.n([e.a()],d.prototype,`alignSearchRight`,void 0);try{e.s(`pkt-header-service`)(d)}catch{console.warn(`Forsøker å definere <pkt-header-service>, men den er allerede definert`)}var f=class extends n.t{constructor(...e){super(...e),this.searchPlaceholder=`Søk`,this.searchValue=``,this.mobileBreakpoint=768,this.tabletBreakpoint=1280,this.openedMenu=`none`,this.logOutButtonPlacement=`none`,this.position=`fixed`,this.scrollBehavior=`hide`,this.slotMenuVariant=`icon-only`,this.slotMenuText=`Meny`,this.hideLogo=!1,this.compact=!1,this.showSearch=!1,this.canChangeRepresentation=!1,this.hasLogOut=!1}firstUpdated(e){super.firstUpdated(e),this.emitDeprecationWarnings()}emitDeprecationWarnings(){this.userMenuFooter!==void 0&&console.warn(`[PktHeader] userMenuFooter is deprecated. Use userMenu instead.`),this.userOptions!==void 0&&console.warn(`[PktHeader] userOptions is deprecated. Use userMenu instead.`)}get effectiveUserMenu(){let e=this.userMenu||[],t=this.userMenuFooter||[],n=this.userOptions||[];return t.length||n.length?[...e,...n,...t]:this.userMenu}render(){return e.p`
|
|
283
|
+
`:n}};e.n([e.o({type:String,attribute:`service-name`})],d.prototype,`serviceName`,void 0),e.n([e.o({type:String,attribute:`service-link`})],d.prototype,`serviceLink`,void 0),e.n([e.o({type:String,attribute:`logo-link`})],d.prototype,`logoLink`,void 0),e.n([e.o({type:String,attribute:`logo-path`})],d.prototype,`logoPath`,void 0),e.n([e.o({type:String,attribute:`search-placeholder`})],d.prototype,`searchPlaceholder`,void 0),e.n([e.o({type:String,attribute:`search-value`})],d.prototype,`searchValue`,void 0),e.n([e.o({type:Number,attribute:`mobile-breakpoint`})],d.prototype,`mobileBreakpoint`,void 0),e.n([e.o({type:Number,attribute:`tablet-breakpoint`})],d.prototype,`tabletBreakpoint`,void 0),e.n([e.o({type:String,attribute:`opened-menu`})],d.prototype,`openedMenu`,void 0),e.n([e.o({type:String,attribute:`log-out-button-placement`})],d.prototype,`logOutButtonPlacement`,void 0),e.n([e.o({type:String})],d.prototype,`position`,void 0),e.n([e.o({type:String,attribute:`scroll-behavior`})],d.prototype,`scrollBehavior`,void 0),e.n([e.o({type:String,attribute:`slot-menu-variant`})],d.prototype,`slotMenuVariant`,void 0),e.n([e.o({type:String,attribute:`slot-menu-text`})],d.prototype,`slotMenuText`,void 0),e.n([e.o({type:Boolean,attribute:`hide-logo`,converter:a.t})],d.prototype,`hideLogo`,void 0),e.n([e.o({type:Boolean,converter:a.t})],d.prototype,`compact`,void 0),e.n([e.o({type:Boolean,attribute:`show-search`,converter:a.t})],d.prototype,`showSearch`,void 0),e.n([e.o({type:Boolean,attribute:`can-change-representation`,converter:a.t})],d.prototype,`canChangeRepresentation`,void 0),e.n([e.o({type:Boolean,attribute:`has-log-out`,converter:a.t})],d.prototype,`hasLogOut`,void 0),e.n([e.o({type:Object})],d.prototype,`user`,void 0),e.n([e.o({type:Array,attribute:`user-menu`})],d.prototype,`userMenu`,void 0),e.n([e.o({type:Object})],d.prototype,`representing`,void 0),e.n([e.a()],d.prototype,`isMobile`,void 0),e.n([e.a()],d.prototype,`isTablet`,void 0),e.n([e.a()],d.prototype,`openMenu`,void 0),e.n([e.a()],d.prototype,`isHidden`,void 0),e.n([e.a()],d.prototype,`componentWidth`,void 0),e.n([e.a()],d.prototype,`alignSlotRight`,void 0),e.n([e.a()],d.prototype,`alignSearchRight`,void 0);try{e.s(`pkt-header-service`)(d)}catch{console.warn(`Forsøker å definere <pkt-header-service>, men den er allerede definert`)}var f=class extends n.t{constructor(...e){super(...e),this.searchPlaceholder=`Søk`,this.searchValue=``,this.mobileBreakpoint=768,this.tabletBreakpoint=1280,this.openedMenu=`none`,this.logOutButtonPlacement=`none`,this.position=`fixed`,this.scrollBehavior=`hide`,this.slotMenuVariant=`icon-only`,this.slotMenuText=`Meny`,this.hideLogo=!1,this.compact=!1,this.showSearch=!1,this.canChangeRepresentation=!1,this.hasLogOut=!1}firstUpdated(e){super.firstUpdated(e),this.emitDeprecationWarnings()}emitDeprecationWarnings(){this.userMenuFooter!==void 0&&console.warn(`[PktHeader] userMenuFooter is deprecated. Use userMenu instead.`),this.userOptions!==void 0&&console.warn(`[PktHeader] userOptions is deprecated. Use userMenu instead.`)}get effectiveUserMenu(){let e=this.userMenu||[],t=this.userMenuFooter||[],n=this.userOptions||[];return t.length||n.length?[...e,...n,...t]:this.userMenu}render(){return e.p`
|
|
284
284
|
<pkt-header-service
|
|
285
285
|
service-name=${r.t(this.serviceName)}
|
|
286
286
|
service-link=${r.t(this.serviceLink)}
|
|
287
287
|
logo-link=${r.t(this.logoLink)}
|
|
288
|
+
logo-path=${r.t(this.logoPath)}
|
|
288
289
|
search-placeholder=${this.searchPlaceholder}
|
|
289
290
|
search-value=${this.searchValue}
|
|
290
291
|
mobile-breakpoint=${this.mobileBreakpoint}
|
|
@@ -306,4 +307,4 @@ const e=require(`./element-CXAtr6Gu.cjs`),t=require(`./class-map-B8Ja0q7n.cjs`),
|
|
|
306
307
|
>
|
|
307
308
|
${this.hasSlotContent()?e.p`<div class="pkt-contents">${n.n(this)}</div>`:e.d}
|
|
308
309
|
</pkt-header-service>
|
|
309
|
-
`}};e.n([e.o({type:String,attribute:`service-name`})],f.prototype,`serviceName`,void 0),e.n([e.o({type:String,attribute:`service-link`})],f.prototype,`serviceLink`,void 0),e.n([e.o({type:String,attribute:`logo-link`})],f.prototype,`logoLink`,void 0),e.n([e.o({type:String,attribute:`search-placeholder`})],f.prototype,`searchPlaceholder`,void 0),e.n([e.o({type:String,attribute:`search-value`})],f.prototype,`searchValue`,void 0),e.n([e.o({type:Number,attribute:`mobile-breakpoint`})],f.prototype,`mobileBreakpoint`,void 0),e.n([e.o({type:Number,attribute:`tablet-breakpoint`})],f.prototype,`tabletBreakpoint`,void 0),e.n([e.o({type:String,attribute:`opened-menu`})],f.prototype,`openedMenu`,void 0),e.n([e.o({type:String,attribute:`log-out-button-placement`})],f.prototype,`logOutButtonPlacement`,void 0),e.n([e.o({type:String})],f.prototype,`position`,void 0),e.n([e.o({type:String,attribute:`scroll-behavior`})],f.prototype,`scrollBehavior`,void 0),e.n([e.o({type:String,attribute:`slot-menu-variant`})],f.prototype,`slotMenuVariant`,void 0),e.n([e.o({type:String,attribute:`slot-menu-text`})],f.prototype,`slotMenuText`,void 0),e.n([e.o({type:Boolean,attribute:`hide-logo`,converter:a.t})],f.prototype,`hideLogo`,void 0),e.n([e.o({type:Boolean,converter:a.t})],f.prototype,`compact`,void 0),e.n([e.o({type:Boolean,attribute:`show-search`,converter:a.t})],f.prototype,`showSearch`,void 0),e.n([e.o({type:Boolean,attribute:`can-change-representation`,converter:a.t})],f.prototype,`canChangeRepresentation`,void 0),e.n([e.o({type:Boolean,attribute:`has-log-out`,converter:a.t})],f.prototype,`hasLogOut`,void 0),e.n([e.o({type:Object})],f.prototype,`user`,void 0),e.n([e.o({type:Array,attribute:`user-menu`})],f.prototype,`userMenu`,void 0),e.n([e.o({type:Object})],f.prototype,`representing`,void 0),e.n([e.o({type:Array,attribute:`user-menu-footer`})],f.prototype,`userMenuFooter`,void 0),e.n([e.o({type:Array,attribute:`user-options`})],f.prototype,`userOptions`,void 0);try{e.s(`pkt-header`)(f)}catch{console.warn(`Forsøker å definere <pkt-header>, men den er allerede definert`)}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return f}});
|
|
310
|
+
`}};e.n([e.o({type:String,attribute:`service-name`})],f.prototype,`serviceName`,void 0),e.n([e.o({type:String,attribute:`service-link`})],f.prototype,`serviceLink`,void 0),e.n([e.o({type:String,attribute:`logo-link`})],f.prototype,`logoLink`,void 0),e.n([e.o({type:String,attribute:`logo-path`})],f.prototype,`logoPath`,void 0),e.n([e.o({type:String,attribute:`search-placeholder`})],f.prototype,`searchPlaceholder`,void 0),e.n([e.o({type:String,attribute:`search-value`})],f.prototype,`searchValue`,void 0),e.n([e.o({type:Number,attribute:`mobile-breakpoint`})],f.prototype,`mobileBreakpoint`,void 0),e.n([e.o({type:Number,attribute:`tablet-breakpoint`})],f.prototype,`tabletBreakpoint`,void 0),e.n([e.o({type:String,attribute:`opened-menu`})],f.prototype,`openedMenu`,void 0),e.n([e.o({type:String,attribute:`log-out-button-placement`})],f.prototype,`logOutButtonPlacement`,void 0),e.n([e.o({type:String})],f.prototype,`position`,void 0),e.n([e.o({type:String,attribute:`scroll-behavior`})],f.prototype,`scrollBehavior`,void 0),e.n([e.o({type:String,attribute:`slot-menu-variant`})],f.prototype,`slotMenuVariant`,void 0),e.n([e.o({type:String,attribute:`slot-menu-text`})],f.prototype,`slotMenuText`,void 0),e.n([e.o({type:Boolean,attribute:`hide-logo`,converter:a.t})],f.prototype,`hideLogo`,void 0),e.n([e.o({type:Boolean,converter:a.t})],f.prototype,`compact`,void 0),e.n([e.o({type:Boolean,attribute:`show-search`,converter:a.t})],f.prototype,`showSearch`,void 0),e.n([e.o({type:Boolean,attribute:`can-change-representation`,converter:a.t})],f.prototype,`canChangeRepresentation`,void 0),e.n([e.o({type:Boolean,attribute:`has-log-out`,converter:a.t})],f.prototype,`hasLogOut`,void 0),e.n([e.o({type:Object})],f.prototype,`user`,void 0),e.n([e.o({type:Array,attribute:`user-menu`})],f.prototype,`userMenu`,void 0),e.n([e.o({type:Object})],f.prototype,`representing`,void 0),e.n([e.o({type:Array,attribute:`user-menu-footer`})],f.prototype,`userMenuFooter`,void 0),e.n([e.o({type:Array,attribute:`user-options`})],f.prototype,`userOptions`,void 0);try{e.s(`pkt-header`)(f)}catch{console.warn(`Forsøker å definere <pkt-header>, men den er allerede definert`)}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return f}});
|