@oslokommune/punkt-elements 20.0.5 → 20.1.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 +16 -0
- package/dist/{alert-DPtmkrJq.cjs → alert-0a5lX0pL.cjs} +1 -1
- package/dist/{alert-B00bIA5q.js → alert-ZrB-P881.js} +1 -1
- package/dist/button-CJzu0l5A.js +125 -0
- package/dist/button-DHVRpzpS.cjs +32 -0
- package/dist/{checkbox-group-DHi7HgkS.cjs → checkbox-group-BF29zyLd.cjs} +1 -1
- package/dist/{checkbox-group-D038oaif.js → checkbox-group-CRIV5CX0.js} +1 -1
- package/dist/{combobox-BR2qOS5z.js → combobox-CLVwmqkY.js} +2 -1
- package/dist/{combobox-Bn51heWm.cjs → combobox-otZu39eS.cjs} +2 -1
- package/dist/{consent-ifEcAAhG.cjs → consent-BOSXNt4Y.cjs} +1 -1
- package/dist/{consent-KrraWq7K.js → consent-DwppvYBR.js} +1 -1
- package/dist/{datepicker-Bt8zKLPK.cjs → datepicker-Cnrbqm62.cjs} +1 -1
- package/dist/{datepicker-BZpiJeLW.js → datepicker-DHdFA8Dx.js} +1 -1
- package/dist/{fileupload-A7RNV7ic.js → fileupload-BQw5nlzQ.js} +2 -2
- package/dist/{fileupload-Cw4xeUZn.cjs → fileupload-Cjde62AR.cjs} +1 -1
- package/dist/{footer-dnW2aMEr.cjs → footer-NQaQc2DH.cjs} +1 -1
- package/dist/{footer-HqNhiUa1.js → footer-SbOYv50e.js} +1 -1
- package/dist/{header-VOj1cfsA.js → header-CZnKVVt4.js} +2 -2
- package/dist/{header-CKGwNWBI.cjs → header-YbbGgmsD.cjs} +1 -1
- package/dist/{input-wrapper-CdH6RH0a.cjs → input-wrapper-CbYMk21W.cjs} +1 -1
- package/dist/{input-wrapper-C6BRd-cu.js → input-wrapper-DYg1VHPv.js} +1 -1
- package/dist/{option-group-element-C8oJxuQQ.js → option-group-element-DtSw52Dr.js} +1 -1
- package/dist/{option-group-element-_LrpXfK1.cjs → option-group-element-dN0ntPZk.cjs} +1 -1
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +1 -1
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +1 -1
- package/dist/pkt-checkbox-group.cjs +1 -1
- package/dist/pkt-checkbox-group.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-consent.cjs +1 -1
- package/dist/pkt-consent.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-fileupload.cjs +1 -1
- package/dist/pkt-fileupload.js +1 -1
- package/dist/pkt-footer.cjs +1 -1
- package/dist/pkt-footer.js +1 -1
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +15 -15
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-radio-group.cjs +1 -1
- package/dist/pkt-radio-group.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/{radio-group-Kr2BCSvg.js → radio-group-bRF8fnPW.js} +1 -1
- package/dist/{radio-group-RWgTs_uV.cjs → radio-group-u1IH7g-4.cjs} +1 -1
- package/dist/{select-CZ3L48N_.cjs → select-C7kAlSxs.cjs} +1 -1
- package/dist/{select-Curv4lWO.js → select-CXIEM2qY.js} +1 -1
- package/dist/shared-types/button.d.ts +13 -0
- package/dist/shared-types/index.d.ts +1 -1
- package/dist/{textarea-B1iUKCro.js → textarea-12le8b4I.js} +1 -1
- package/dist/{textarea-DbD7sOLV.cjs → textarea-CRcSfWgX.cjs} +1 -1
- package/dist/{textinput-CKbUvHNH.js → textinput-CC0zxUBT.js} +1 -1
- package/dist/{textinput-C_5jzdg3.cjs → textinput-Dooq2n8W.cjs} +1 -1
- package/dist/{timepicker-By-kvx3z.cjs → timepicker-BM4I5w-i.cjs} +1 -1
- package/dist/{timepicker-DkXpFBpQ.js → timepicker-Cz81VQu3.js} +1 -1
- package/package.json +2 -2
- package/src/components/button/button.ts +14 -14
- package/src/components/combobox/combobox.interaction.test.ts +23 -0
- package/src/components/combobox/combobox.ts +1 -0
- package/dist/button-BI1PsdE1.cjs +0 -32
- package/dist/button-Bd-0TYe7.js +0 -113
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
## [20.1.2](https://github.com/oslokommune/punkt/compare/20.1.1...20.1.2) (2026-11-11)
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
* Combobox mangler videresending av strings til listbox (#3823).
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## [20.1.0](https://github.com/oslokommune/punkt/compare/20.0.5...20.1.0) (2026-11-09)
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
* Button - bruk felles standardverdier (#3820).
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
|
|
8
24
|
## [20.0.5](https://github.com/oslokommune/punkt/compare/20.0.4...20.0.5) (2026-11-09)
|
|
9
25
|
|
|
10
26
|
---
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./class-map-C82GtM1w.cjs"),t=require("./element-CEarCnHH.cjs"),n=require("./element-with-slot-D_8fAzCW.cjs");require("./shared-types-BvRk9kiK.cjs");const r=require("./classutils-CbklAJDe.cjs"),i=require("./format-B8meU8Tm.cjs"),a=require("./define-component-spec-DBNd2FJY.cjs");require("./icon-5A378_yh.cjs"),require("./button-
|
|
1
|
+
const e=require("./class-map-C82GtM1w.cjs"),t=require("./element-CEarCnHH.cjs"),n=require("./element-with-slot-D_8fAzCW.cjs");require("./shared-types-BvRk9kiK.cjs");const r=require("./classutils-CbklAJDe.cjs"),i=require("./format-B8meU8Tm.cjs"),a=require("./define-component-spec-DBNd2FJY.cjs");require("./icon-5A378_yh.cjs"),require("./button-DHVRpzpS.cjs");var o=[`off`,`polite`,`assertive`],s=[`info`,`success`,`warning`,`error`],c=[`medium`,`small`,`xsmall`],l={compact:!1},u=a.t({name:`pkt-alert`,react:`PktAlert`,"css-class":`pkt-alert`,"dark-mode":!0,isElement:!0,isPureReact:!0,events:{onClose:{reactOnly:!0,description:`React: Klikk-event for 'Lukk'-knappen`},close:{elementsOnly:!0,description:`Elements: Klikk-event for 'Lukk'-knappen`},"on-close":{elementsOnly:!0,description:`Elements: Samme event som <code>close</code>, beholdt for eldre Vue-oppsett.`,deprecated:`Bruk <code>close</code>. <code>on-close</code> fjernes i en senere hovedversjon.`}},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:[...s],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:[...o],default:`polite`,category:`accessibility`},size:{name:`Størrelse`,description:`Endrer størrelsen på ulike elementer i alerten.`,type:[...c],default:`medium`,category:`ui`},closeAlert:{name:`Vis 'Lukk'-knapp`,description:`Viser 'Lukk'-knappen`,type:`boolean`,default:!1,category:`ui`},compact:{name:`Kompakt`,description:`Kompakt visning av alerten.`,deprecated:"Bruk `size` i stedet; uten eksplisitt `size` gir compact størrelsen 'small'.",type:`boolean`,category:`ui`,default:l.compact}},slots:{default:{description:`Innholdet i meldingen`}}}),d=class extends n.t{constructor(){super(),this.compact=l.compact,this.title=``,this.skin=u.props.skin.default,this.ariaLive=u.props.ariaLive.default,this.ariaLiveAttr=null,this.closeAlert=u.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`)&&e.get(`ariaLive`)!==void 0&&(this.ariaLiveAttr=this.ariaLive),e.has(`_isClosed`)&&r.t(this,`pkt-hide`,this._isClosed)}render(){let r=this.size??(this.compact?`small`:`medium`),a={"pkt-alert":!0,[`pkt-alert--${r}`]:!0,[`pkt-alert--${this.skin}`]:!0,"pkt-hide":this._isClosed},o={"pkt-alert__grid":!0,"pkt-alert__noTitle":!this.title,"pkt-alert__noDate":!this.date};return t._`
|
|
2
2
|
<div
|
|
3
3
|
class=${e.t(a)}
|
|
4
4
|
aria-live=${this.ariaLiveAttr}
|
|
@@ -6,7 +6,7 @@ import { t as l } from "./classutils-C4jETHHk.js";
|
|
|
6
6
|
import { t as u } from "./format-DwjTfa9h.js";
|
|
7
7
|
import { t as d } from "./define-component-spec-wHP10r2x.js";
|
|
8
8
|
import "./icon-CZDw42U7.js";
|
|
9
|
-
import "./button-
|
|
9
|
+
import "./button-CJzu0l5A.js";
|
|
10
10
|
// ../../shared-types/aria.ts
|
|
11
11
|
var f = [
|
|
12
12
|
"off",
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-Bwc-likm.js";
|
|
2
|
+
import { t as o } from "./class-map-C9n5CNC8.js";
|
|
3
|
+
import { i as s, t as c } from "./element-with-slot-47quDZRt.js";
|
|
4
|
+
import "./shared-types-BvRk9kiK.js";
|
|
5
|
+
import { i as l } from "./icon-CZDw42U7.js";
|
|
6
|
+
import { t as u } from "./if-defined-B3pYog2C.js";
|
|
7
|
+
// ../../shared-types/button.ts
|
|
8
|
+
var d = {
|
|
9
|
+
iconName: "user",
|
|
10
|
+
secondIconName: "user",
|
|
11
|
+
size: "medium",
|
|
12
|
+
fullWidth: !1,
|
|
13
|
+
fullWidthOnMobile: !1,
|
|
14
|
+
skin: "primary",
|
|
15
|
+
type: "button",
|
|
16
|
+
variant: "label-only",
|
|
17
|
+
isLoading: !1,
|
|
18
|
+
disabled: !1
|
|
19
|
+
}, f;
|
|
20
|
+
typeof window < "u" && (window.pktAnimationPath = window.pktAnimationPath || "https://punkt-cdn.oslo.kommune.no/latest/animations/");
|
|
21
|
+
var p = class t extends c {
|
|
22
|
+
constructor(...e) {
|
|
23
|
+
super(...e), this.iconName = d.iconName, this.secondIconName = d.secondIconName, this.size = d.size, this.fullWidth = d.fullWidth, this.fullWidthOnMobile = d.fullWidthOnMobile, this.skin = d.skin, this.variant = d.variant, this.state = void 0, this.type = d.type, this.form = void 0, this.isLoading = d.isLoading, this.disabled = d.disabled, this.loadingAnimationPath = typeof window < "u" ? window.pktAnimationPath : l, this.relocatedAria = {};
|
|
24
|
+
}
|
|
25
|
+
connectedCallback() {
|
|
26
|
+
super.connectedCallback(), this.addEventListener("click", (e) => {
|
|
27
|
+
(this.disabled || this.hasAttribute("disabled") || this.isLoading) && (e.preventDefault(), e.stopImmediatePropagation());
|
|
28
|
+
}, !0), this.addEventListener("keydown", (e) => {
|
|
29
|
+
(this.disabled || this.hasAttribute("disabled") || this.isLoading) && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.stopImmediatePropagation());
|
|
30
|
+
}, !0);
|
|
31
|
+
}
|
|
32
|
+
attributeChangedCallback(e, t, n) {
|
|
33
|
+
super.attributeChangedCallback(e, t, n), e === "disabled" && n === "false" && (this.disabled = !1), (e === "isloading" || e === "isLoading") && n === "false" && (this.isLoading = !1);
|
|
34
|
+
}
|
|
35
|
+
willUpdate(e) {
|
|
36
|
+
super.willUpdate(e);
|
|
37
|
+
let n = !1, r = { ...this.relocatedAria };
|
|
38
|
+
for (let e of t.relocatedAriaAttributes) {
|
|
39
|
+
let t = this.getAttribute(e);
|
|
40
|
+
t !== null && (r[e] = t, this.removeAttribute(e), n = !0);
|
|
41
|
+
}
|
|
42
|
+
n && (this.relocatedAria = r);
|
|
43
|
+
}
|
|
44
|
+
firstUpdated(e) {
|
|
45
|
+
super.firstUpdated(e), this.disabled === "false" && (this.disabled = !1), this.isLoading === "false" && (this.isLoading = !1);
|
|
46
|
+
}
|
|
47
|
+
render() {
|
|
48
|
+
let t = this.form ?? this.getAttribute("form") ?? void 0, r = {
|
|
49
|
+
"pkt-btn": !0,
|
|
50
|
+
[`pkt-btn--${this.size}`]: !!this.size,
|
|
51
|
+
[`pkt-btn--${this.skin}`]: !!this.skin,
|
|
52
|
+
[`pkt-btn--${this.variant}`]: !!this.variant,
|
|
53
|
+
[`pkt-btn--${this.color}`]: !!this.color,
|
|
54
|
+
[`pkt-btn--${this.state}`]: !!this.state,
|
|
55
|
+
"pkt-btn--full": !!this.fullWidth,
|
|
56
|
+
"pkt-btn--full-small": !!this.fullWidthOnMobile,
|
|
57
|
+
"pkt-btn--isLoading": !!this.isLoading
|
|
58
|
+
};
|
|
59
|
+
return e`
|
|
60
|
+
<button
|
|
61
|
+
class=${o(r)}
|
|
62
|
+
type=${this.type}
|
|
63
|
+
?disabled=${!!this.disabled}
|
|
64
|
+
aria-busy=${u(this.isLoading ? "true" : void 0)}
|
|
65
|
+
aria-disabled=${u(this.disabled || this.isLoading ? "true" : void 0)}
|
|
66
|
+
aria-haspopup=${u(this.relocatedAria["aria-haspopup"])}
|
|
67
|
+
aria-expanded=${u(this.relocatedAria["aria-expanded"])}
|
|
68
|
+
aria-controls=${u(this.relocatedAria["aria-controls"])}
|
|
69
|
+
aria-label=${u(this.relocatedAria["aria-label"])}
|
|
70
|
+
tabindex=${u(this.relocatedAria.tabindex)}
|
|
71
|
+
form=${u(t)}
|
|
72
|
+
>
|
|
73
|
+
${this.isLoading ? e`<pkt-icon
|
|
74
|
+
class="pkt-btn__icon pkt-btn__spinner"
|
|
75
|
+
name="spinner-blue"
|
|
76
|
+
path=${u(this.loadingAnimationPath)}
|
|
77
|
+
></pkt-icon>` : n}
|
|
78
|
+
${this.variant === "label-only" ? n : e`<pkt-icon
|
|
79
|
+
class="pkt-btn__icon pkt-icon"
|
|
80
|
+
name=${this.iconName}
|
|
81
|
+
path=${u(this.iconPath)}
|
|
82
|
+
></pkt-icon>`}
|
|
83
|
+
<span class="pkt-btn__text">${s(this)}</span>
|
|
84
|
+
${this.variant === "icons-right-and-left" ? e`<pkt-icon
|
|
85
|
+
class="pkt-btn__icon"
|
|
86
|
+
name=${this.secondIconName}
|
|
87
|
+
path=${u(this.secondIconPath)}
|
|
88
|
+
></pkt-icon>` : n}
|
|
89
|
+
</button>
|
|
90
|
+
`;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
f = p, f.relocatedAriaAttributes = [
|
|
94
|
+
"aria-haspopup",
|
|
95
|
+
"aria-expanded",
|
|
96
|
+
"aria-controls",
|
|
97
|
+
"aria-label",
|
|
98
|
+
"tabindex"
|
|
99
|
+
], i([a({ type: String })], p.prototype, "iconName", void 0), i([a({ type: String })], p.prototype, "secondIconName", void 0), i([a({ type: String })], p.prototype, "iconPath", void 0), i([a({ type: String })], p.prototype, "secondIconPath", void 0), i([a({ type: String })], p.prototype, "size", void 0), i([a({
|
|
100
|
+
type: Boolean,
|
|
101
|
+
attribute: "full-width"
|
|
102
|
+
})], p.prototype, "fullWidth", void 0), i([a({
|
|
103
|
+
type: Boolean,
|
|
104
|
+
attribute: "full-width-on-mobile"
|
|
105
|
+
})], p.prototype, "fullWidthOnMobile", void 0), i([a({ type: String })], p.prototype, "color", void 0), i([a({ type: String })], p.prototype, "skin", void 0), i([a({ type: String })], p.prototype, "variant", void 0), i([a({
|
|
106
|
+
type: String,
|
|
107
|
+
reflect: !0
|
|
108
|
+
})], p.prototype, "state", void 0), i([a({
|
|
109
|
+
type: String,
|
|
110
|
+
reflect: !0
|
|
111
|
+
})], p.prototype, "type", void 0), i([a({ type: String })], p.prototype, "form", void 0), i([a({
|
|
112
|
+
type: Boolean,
|
|
113
|
+
reflect: !0
|
|
114
|
+
})], p.prototype, "isLoading", void 0), i([a({
|
|
115
|
+
type: Boolean,
|
|
116
|
+
reflect: !0
|
|
117
|
+
})], p.prototype, "disabled", void 0), i([a({ type: String })], p.prototype, "loadingAnimationPath", void 0), i([r()], p.prototype, "relocatedAria", void 0);
|
|
118
|
+
try {
|
|
119
|
+
t("pkt-button")(p);
|
|
120
|
+
} catch {
|
|
121
|
+
console.warn("Forsøker å definere <pkt-button>, men den er allerede definert");
|
|
122
|
+
}
|
|
123
|
+
// src/components/button/index.ts
|
|
124
|
+
var m = p;
|
|
125
|
+
export { p as n, m as t };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const e=require("./element-CEarCnHH.cjs"),t=require("./class-map-C82GtM1w.cjs"),n=require("./element-with-slot-D_8fAzCW.cjs");require("./shared-types-BvRk9kiK.cjs");const r=require("./icon-5A378_yh.cjs"),i=require("./if-defined-Ci4ZQsgL.cjs");var a={iconName:`user`,secondIconName:`user`,size:`medium`,fullWidth:!1,fullWidthOnMobile:!1,skin:`primary`,type:`button`,variant:`label-only`,isLoading:!1,disabled:!1},o;typeof window<`u`&&(window.pktAnimationPath=window.pktAnimationPath||`https://punkt-cdn.oslo.kommune.no/latest/animations/`);var s=class o extends n.t{constructor(...e){super(...e),this.iconName=a.iconName,this.secondIconName=a.secondIconName,this.size=a.size,this.fullWidth=a.fullWidth,this.fullWidthOnMobile=a.fullWidthOnMobile,this.skin=a.skin,this.variant=a.variant,this.state=void 0,this.type=a.type,this.form=void 0,this.isLoading=a.isLoading,this.disabled=a.disabled,this.loadingAnimationPath=typeof window<`u`?window.pktAnimationPath:r.i,this.relocatedAria={}}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)}willUpdate(e){super.willUpdate(e);let t=!1,n={...this.relocatedAria};for(let e of o.relocatedAriaAttributes){let r=this.getAttribute(e);r!==null&&(n[e]=r,this.removeAttribute(e),t=!0)}t&&(this.relocatedAria=n)}firstUpdated(e){super.firstUpdated(e),this.disabled===`false`&&(this.disabled=!1),this.isLoading===`false`&&(this.isLoading=!1)}render(){let r=this.form??this.getAttribute(`form`)??void 0,a={"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--isLoading":!!this.isLoading};return e._`
|
|
2
|
+
<button
|
|
3
|
+
class=${t.t(a)}
|
|
4
|
+
type=${this.type}
|
|
5
|
+
?disabled=${!!this.disabled}
|
|
6
|
+
aria-busy=${i.t(this.isLoading?`true`:void 0)}
|
|
7
|
+
aria-disabled=${i.t(this.disabled||this.isLoading?`true`:void 0)}
|
|
8
|
+
aria-haspopup=${i.t(this.relocatedAria[`aria-haspopup`])}
|
|
9
|
+
aria-expanded=${i.t(this.relocatedAria[`aria-expanded`])}
|
|
10
|
+
aria-controls=${i.t(this.relocatedAria[`aria-controls`])}
|
|
11
|
+
aria-label=${i.t(this.relocatedAria[`aria-label`])}
|
|
12
|
+
tabindex=${i.t(this.relocatedAria.tabindex)}
|
|
13
|
+
form=${i.t(r)}
|
|
14
|
+
>
|
|
15
|
+
${this.isLoading?e._`<pkt-icon
|
|
16
|
+
class="pkt-btn__icon pkt-btn__spinner"
|
|
17
|
+
name="spinner-blue"
|
|
18
|
+
path=${i.t(this.loadingAnimationPath)}
|
|
19
|
+
></pkt-icon>`:e.h}
|
|
20
|
+
${this.variant===`label-only`?e.h:e._`<pkt-icon
|
|
21
|
+
class="pkt-btn__icon pkt-icon"
|
|
22
|
+
name=${this.iconName}
|
|
23
|
+
path=${i.t(this.iconPath)}
|
|
24
|
+
></pkt-icon>`}
|
|
25
|
+
<span class="pkt-btn__text">${n.i(this)}</span>
|
|
26
|
+
${this.variant===`icons-right-and-left`?e._`<pkt-icon
|
|
27
|
+
class="pkt-btn__icon"
|
|
28
|
+
name=${this.secondIconName}
|
|
29
|
+
path=${i.t(this.secondIconPath)}
|
|
30
|
+
></pkt-icon>`:e.h}
|
|
31
|
+
</button>
|
|
32
|
+
`}};o=s,o.relocatedAriaAttributes=[`aria-haspopup`,`aria-expanded`,`aria-controls`,`aria-label`,`tabindex`],e.n([e.u({type:String})],s.prototype,`iconName`,void 0),e.n([e.u({type:String})],s.prototype,`secondIconName`,void 0),e.n([e.u({type:String})],s.prototype,`iconPath`,void 0),e.n([e.u({type:String})],s.prototype,`secondIconPath`,void 0),e.n([e.u({type:String})],s.prototype,`size`,void 0),e.n([e.u({type:Boolean,attribute:`full-width`})],s.prototype,`fullWidth`,void 0),e.n([e.u({type:Boolean,attribute:`full-width-on-mobile`})],s.prototype,`fullWidthOnMobile`,void 0),e.n([e.u({type:String})],s.prototype,`color`,void 0),e.n([e.u({type:String})],s.prototype,`skin`,void 0),e.n([e.u({type:String})],s.prototype,`variant`,void 0),e.n([e.u({type:String,reflect:!0})],s.prototype,`state`,void 0),e.n([e.u({type:String,reflect:!0})],s.prototype,`type`,void 0),e.n([e.u({type:String})],s.prototype,`form`,void 0),e.n([e.u({type:Boolean,reflect:!0})],s.prototype,`isLoading`,void 0),e.n([e.u({type:Boolean,reflect:!0})],s.prototype,`disabled`,void 0),e.n([e.u({type:String})],s.prototype,`loadingAnimationPath`,void 0),e.n([e.l()],s.prototype,`relocatedAria`,void 0);try{e.d(`pkt-button`)(s)}catch{console.warn(`Forsøker å definere <pkt-button>, men den er allerede definert`)}var c=s;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return c}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./provide-Cz18sYug.cjs"),t=require("./element-CEarCnHH.cjs"),n=require("./option-group-element-
|
|
1
|
+
const e=require("./provide-Cz18sYug.cjs"),t=require("./element-CEarCnHH.cjs"),n=require("./option-group-element-dN0ntPZk.cjs"),r=require("./checkbox-Cg7wnn8U.cjs");var i=class extends n.t{constructor(...e){super(...e),this.optionSelector=`pkt-checkbox`,this.groupContext={name:``,hasTile:!1,hasError:!1},this.storedValue=null,this.validityApplied=!1}get value(){return this.options().filter(e=>n.n(e)&&!n.r(e)).map(n.i)}set value(e){let t=this.value;this.storedValue=Array.isArray(e)?e:e?e.split(`,`):[],this.applyStoredValue(this.options()),this.requestUpdate(`value`,t)}get hasStoredValue(){return this.storedValue!==null}storeCurrentValue(){this.storedValue=this.value}applyStoredValue(e){e.forEach(e=>{let t=!!this.storedValue?.includes(n.i(e));n.n(e)!==t&&(e.checked=t)})}syncValidity(){if(!this.required&&!this.validityApplied)return;this.validityApplied=this.required;let e=this.options(),t=this.required&&!e.some(e=>n.n(e)&&!n.r(e))?this.pktStrings.get(`validation`).checkboxGroupValueMissing:``;e.forEach(e=>e.setGroupValidity?.(t))}};t.n([e.t({context:r.r}),t.l()],i.prototype,`groupContext`,void 0),t.n([t.u({type:String})],i.prototype,`value`,null);try{t.d(`pkt-checkbox-group`)(i)}catch{console.warn(`Forsøker å definere <pkt-checkbox-group>, men den er allerede definert`)}var a=i;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as e } from "./provide-DFu2tSv_.js";
|
|
2
2
|
import { d as t, l as n, n as r, u as i } from "./element-Bwc-likm.js";
|
|
3
|
-
import { i as a, n as o, r as s, t as c } from "./option-group-element-
|
|
3
|
+
import { i as a, n as o, r as s, t as c } from "./option-group-element-DtSw52Dr.js";
|
|
4
4
|
import { r as l } from "./checkbox-XvlUQmg5.js";
|
|
5
5
|
// src/components/checkbox-group/checkbox-group.ts
|
|
6
6
|
var u = class extends c {
|
|
@@ -8,7 +8,7 @@ import { n as v } from "./element-with-slot-47quDZRt.js";
|
|
|
8
8
|
import { t as y } from "./input-element-DE0FzjgP.js";
|
|
9
9
|
import { t as b } from "./pkt-options-controller-Dz7DP0wC.js";
|
|
10
10
|
import { t as x } from "./format-DwjTfa9h.js";
|
|
11
|
-
import { r as S } from "./input-wrapper-
|
|
11
|
+
import { r as S } from "./input-wrapper-DYg1VHPv.js";
|
|
12
12
|
import "./icon-CZDw42U7.js";
|
|
13
13
|
import "./tag-HXcXopyA.js";
|
|
14
14
|
// ../../shared-types/combobox.ts
|
|
@@ -569,6 +569,7 @@ var M = class extends j {
|
|
|
569
569
|
|
|
570
570
|
<pkt-listbox
|
|
571
571
|
id="${this.id}-listbox"
|
|
572
|
+
.strings=${this.strings}
|
|
572
573
|
.options=${this._options}
|
|
573
574
|
.isOpen=${this._isOptionsOpen}
|
|
574
575
|
.searchPlaceholder=${this.searchPlaceholder}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-CEarCnHH.cjs"),t=require("./if-defined-Ci4ZQsgL.cjs"),n=require("./ref-C6VUWwmF.cjs"),r=require("./class-map-C82GtM1w.cjs"),i=require("./repeat-CjvNrcUr.cjs"),a=require("./listbox-Du8llYth.cjs"),o=require("./element-with-slot-D_8fAzCW.cjs"),s=require("./input-element-CfZIyfon.cjs"),c=require("./pkt-options-controller-WsHVdPJA.cjs"),l=require("./format-B8meU8Tm.cjs"),u=require("./input-wrapper-CdH6RH0a.cjs");require("./icon-5A378_yh.cjs"),require("./tag-BAikRN2Y.cjs");var d={multiple:!1,typeahead:!1,includeSearch:!1,allowUserInput:!1,displayValueAs:`label`,inputSize:`medium`,disabled:!1,hasError:!1,required:!1,requiredTag:!1,optionalTag:!1,fullwidth:!1,inline:!1,useWrapper:!0},f=(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}},p=(e,t,n,r,i)=>{if(!e)return{action:`none`,value:null};let o=a.i(n,e);return!t.includes(e)&&!o?r?{action:`addUserValue`,value:e}:i?{action:`none`,value:null}:{action:`removeValue`,value:t[0]}:o&&!t.includes(o.value)?{action:`selectOption`,value:o.value}:{action:`none`,value:null}},m=(e,t,n,r,i)=>e.trim().toLowerCase()?{...a.c(e,t,n,r),shouldRemoveValue:!1,shouldResetInput:!1}:{addValueText:null,userInfoMessage:``,shouldRemoveValue:!i&&!!t[0],shouldResetInput:!0},h=(e,t,n)=>{let r=a.i(t,e);return n===`label`&&r?.label?r.label:e},g={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)}},_={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=a.r(n),t.push(n)}),t}},v={cloneOptions(e){return Array.isArray(e)?e.map(e=>({...e})):[]},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=a.r(e),e.selected=e.selected||n.includes(e.value)}),{options:e,newValues:n}},mergeWithUserAdded(e,t,n){return[...t.filter(e=>e?.userAdded&&n.includes(e.value)).filter(t=>!(Array.isArray(e)?e:[]).some(e=>e.value===t.value)),...e]}},y=class extends s.t{constructor(){super(),this.value=``,this.options=[],this.defaultOptions=[],this.allowUserInput=d.allowUserInput,this.typeahead=d.typeahead,this.includeSearch=d.includeSearch,this.searchPlaceholder=null,this.multiple=d.multiple,this.maxlength=null,this.displayValueAs=d.displayValueAs,this.tagPlacement=null,this.isOpen=!1,this._options=[],this._value=[],this._isOptionsOpen=!1,this._userInfoMessage=``,this._messageValue=null,this._addValueText=null,this._maxIsReached=!1,this._search=``,this._inputFocus=!1,this._skipInputTab=!1,this._optionsFromSlot=!1,this._lastSlotGeneration=0,this._suppressNextOpen=!1,this.inputRef=n.t(),this.triggerRef=n.t(),this.listboxRef=n.t(),this._pendingDispatchFrom=null,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()}focusAfterCommit(){this._skipInputTab=!0;let e=this.inputRef.value;e&&e.type!==`hidden`&&e.setAttribute(`tabindex`,`-1`),this.triggerRef.value?.focus()}restoreInputTab(){this._skipInputTab=!1}parseValue(){return this.parseToValues(this.value)}parseToValues(e){return Array.isArray(e)?this.multiple?e:e.length>0?[e[0]]:[]:e&&this.multiple?e.split(`,`):e?[e]:[]}updateMaxReached(){this._maxIsReached=a.l(this._value.length,this.maxlength)}syncPublicValue(){let e=this.multiple?this._value.join(`,`):this._value[0]||``;e!==(Array.isArray(this.value)?this.value.join(`,`):String(this.value||``))&&(this.value=e)}dispatchValueChange(e){let t=this._value;if(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.u({type:String,reflect:!0})],y.prototype,`value`,void 0),e.n([e.u({type:Array})],y.prototype,`options`,void 0),e.n([e.u({type:Array,attribute:`default-options`})],y.prototype,`defaultOptions`,void 0),e.n([e.u({type:Boolean,attribute:`allow-user-input`})],y.prototype,`allowUserInput`,void 0),e.n([e.u({type:Boolean})],y.prototype,`typeahead`,void 0),e.n([e.u({type:Boolean,attribute:`include-search`})],y.prototype,`includeSearch`,void 0),e.n([e.u({type:String,attribute:`search-placeholder`})],y.prototype,`searchPlaceholder`,void 0),e.n([e.u({type:Boolean})],y.prototype,`multiple`,void 0),e.n([e.u({type:Number})],y.prototype,`maxlength`,void 0),e.n([e.u({type:String,attribute:`display-value-as`})],y.prototype,`displayValueAs`,void 0),e.n([e.u({type:String,attribute:`tag-placement`})],y.prototype,`tagPlacement`,void 0),e.n([e.u({type:Boolean,attribute:`open`})],y.prototype,`isOpen`,void 0),e.n([e.l()],y.prototype,`_options`,void 0),e.n([e.l()],y.prototype,`_value`,void 0),e.n([e.l()],y.prototype,`_isOptionsOpen`,void 0),e.n([e.l()],y.prototype,`_userInfoMessage`,void 0),e.n([e.l()],y.prototype,`_messageValue`,void 0),e.n([e.l()],y.prototype,`_addValueText`,void 0),e.n([e.l()],y.prototype,`_maxIsReached`,void 0),e.n([e.l()],y.prototype,`_search`,void 0),e.n([e.l()],y.prototype,`_inputFocus`,void 0),e.n([e.l()],y.prototype,`_skipInputTab`,void 0);var b=class extends y{toggleValue(e){if(this.isDisabled)return;this.touched=!0,this._userInfoMessage=``,this._addValueText=null;let t=a.i(this.options,e)?.value||null,n=this._value.includes(e||t||``),r=!!t,i=this._options.find(t=>t.value===e)?.disabled||!1,o=!e?.trim(),s=!this.multiple,c=this.multiple,l=a.l(this._value.length,this.maxlength),u=!1,d=!0,f=``,p=null,m=``;i||(!r&&this.allowUserInput&&!o?(this.addNewUserValue(e),f=`valueAdded`,u=c):!r&&!this.allowUserInput?(s&&this._value[0]&&this.removeValue(this._value[0]),d=!1,u=!0,f=`noResults`):n?(this.removeValue(t),u=!0,s&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(this.inputRef.value.value=``)):o&&s?(this.removeAllSelected(),u=!0):s?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(t),u=!1,f=`valueSelected`,p=this._hasTextInput?h(t||``,this.options,this.displayValueAs):a.s(a.i(this.options,t),this.displayValueAs)):c&&!l?(this.setSelected(t),u=!0):c&&l?(f=`maxSelected`,d=!1,m=e):(s&&this.removeAllSelected(),f=`noValidValue`,d=!1,u=!0,m=e),this._isOptionsOpen=u,u||window.setTimeout(()=>{this.focusAfterCommit()},0),this._search=m||``,this.resetComboboxInput(d),this._userInfoMessage=f,this._messageValue=p,c&&this.updateMaxReached())}setSelected(e){this._value.includes(e)||(this.multiple&&a.l(this._value.length,this.maxlength)?this._userInfoMessage=`maxSelected`:(!this.multiple&&this.removeAllSelected(),this._value=e?[...this._value,e]:this._value,g.markOptionSelected(this._options,e),this.resetComboboxInput(!0)))}removeSelected(e){if(!e)return;this._value=this._value.filter(t=>t!==e);let t=a.i(this.options,e);t&&(g.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.refreshOptionsFromValue():this._options=[...this._options,t])}addAllOptions(){this.multiple&&(this.maxlength&&this._options.length>this.maxlength?this._userInfoMessage=`tooManySelected`:(this._value=this._options.map(e=>e.value),g.markAllSelected(this._options),this.requestUpdate()))}removeAllSelected(){this._value=[],g.markAllDeselected(this._options),this._options=g.removeUserAddedOptions(this._options),this.requestUpdate()}addValue(){let e=this.inputRef.value?.value.trim()||``;this._search=e,e&&this._value.includes(e)?(this.resetComboboxInput(!0),this._userInfoMessage=`alreadySelected`):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(!a.i(this.options,e)){if(a.l(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,window.setTimeout(()=>{this.focusAfterCommit()},0)),this.requestUpdate()}refreshOptionsFromValue(){let e=v.cloneOptions(this.options);e.forEach(e=>e.selected=this._value.includes(e.value)),this._options=v.syncOptionsWithValues(e,this._value).options}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]?h(this._value[0],this.options,this.displayValueAs):``,this._userInfoMessage=``)),this.refreshOptionsFromValue()}removeLastValue(e){if(this._value.length===0)return;e.preventDefault();let t=this._value[this._value.length-1];t&&this.removeSelected(t),this.updateMaxReached()}},x=class extends b{handleInput(e){if(e.stopPropagation(),e.stopImmediatePropagation(),this.isDisabled)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}=a.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.refreshOptionsFromValue()}}handleFocus(){this.isDisabled||(this._skipInputTab=!1,this._suppressNextOpen?(this._suppressNextOpen=!1,this._inputFocus=!0,this.requestUpdate()):(!this.multiple&&this._value[0]&&this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(this.inputRef.value.value=h(this._value[0],this.options,this.displayValueAs)),this._inputFocus=!0,this._search=``,this.refreshOptionsFromValue(),this._isOptionsOpen=!0,this.onFocus(),this.requestUpdate()))}handleCloseOptions(){this._isOptionsOpen=!1,this._hasTextInput&&(this._suppressNextOpen=!0),this.focusTrigger()}handleFocusOut(e){if(this.isDisabled||!this._isOptionsOpen)return;let t=e.relatedTarget;t?.closest(`pkt-combobox`)?.id===this.id||e.target?.classList?.contains(`pkt-combobox__value`)||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=a.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}=p(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)}}!this.multiple&&this._value[0]?this.inputRef.value.value=h(this._value[0],this.options,this.displayValueAs):this.inputRef.value.value=``}this._isOptionsOpen=!1,this.onBlur()}handleBlur(){this._inputFocus=!1,this.onBlur()}handleInputClick(e){this.isDisabled?(e.preventDefault(),e.stopImmediatePropagation()):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.isDisabled||(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.isDisabled)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]))}}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=f(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();else switch(e.preventDefault(),t){case`addValue`:this.addValue();break;case`focusListbox`:this.listboxRef.value?.focusFirstOrSelectedOption();break;case`closeOptions`:this._isOptionsOpen=!1}}}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()}}checkForMatches(){let e=m(this.inputRef.value?.value||this._search||``,this._value,this.options,this.allowUserInput,this.multiple);e.shouldRemoveValue&&this.removeValue(this._value[0]),e.shouldResetInput?this.resetComboboxInput(!1):(this._addValueText=e.addValueText,this._userInfoMessage=e.userInfoMessage)}},S=class extends x{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){let e=this.options?.filter(e=>e.userAdded)||[];this.options=[...e,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=v.cloneOptions(this.options)}if(this.optionsController?.nodes&&this.optionsController.nodes.length){let e=_.parseOptionsFromSlot(this.optionsController.nodes);e.length&&(this.options=[...e],this._options=[...e],this._optionsFromSlot=!0,this._lastSlotGeneration=this.optionsController.generation)}}disconnectedCallback(){super.disconnectedCallback(),document?.body.removeEventListener(`click`,this.handleBodyClick)}firstUpdated(e){this.defaultValue!==null&&!this.value&&(this.value=this.defaultValue),super.firstUpdated(e)}willUpdate(e){if(this._optionsFromSlot&&this.optionsController){let e=this.optionsController.generation;if(e!==this._lastSlotGeneration){this._lastSlotGeneration=e;let t=_.parseOptionsFromSlot(this.optionsController.nodes),n=this._options.filter(e=>e.userAdded);this.options=[...n,...t]}}if(super.willUpdate(e),e.has(`isOpen`)&&(this._isOptionsOpen=this.isOpen),e.has(`defaultOptions`)&&this.defaultOptions.length){let e=(Array.isArray(this.options)?this.options:[]).filter(e=>e.userAdded)||[];this.options=[...e,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=v.cloneOptions(this.options)}let t=e.has(`value`),n=e.has(`_value`);if(t){let e=[...this._value],t=this.parseValue();t.join(`,`)!==this._value.join(`,`)&&(this._value=t,this._options.forEach(e=>e.selected=t.includes(e.value)),this._options=[...this._options]),this._pendingDispatchFrom??=e}else n&&(this._pendingDispatchFrom??=e.get(`_value`)??[]);if(e.has(`defaultValue`)&&this.defaultValue!=null&&!this._value.length){let e=this.parseToValues(this.defaultValue);e.length&&(this._pendingDispatchFrom??=[...this._value],this._value=e,this._options.forEach(t=>t.selected=e.includes(t.value)),this._options=[...this._options])}if(e.has(`options`)){let t=e.get(`options`)||this._options||[],n=v.mergeWithUserAdded(v.cloneOptions(this.options),t,this._value);this._options=n,n.length>this.options.length&&(this.options=n);let r=v.syncOptionsWithValues(this._options,this._value);this._options=r.options,r.newValues.length>this._value.length&&(this._pendingDispatchFrom??=[...this._value],this._value=r.newValues)}(t||n||e.has(`options`)||e.has(`defaultValue`))&&this.updateMaxReached(),this._pendingDispatchFrom&&this.syncPublicValue()}updated(e){if(this._pendingDispatchFrom){let e=this._pendingDispatchFrom;this._pendingDispatchFrom=null,this.dispatchValueChange(e)}if(e.has(`_search`)&&this.dispatchEvent(new CustomEvent(`search`,{detail:this._search,bubbles:!1})),!this._isOptionsOpen&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!==`hidden`){let e=!this.multiple&&this._value[0]?h(this._value[0],this.options,this.displayValueAs):``;this.inputRef.value.value!==e&&(this.inputRef.value.value=e)}this.classList.add(`pkt-combobox-component`),this.classList.toggle(`pkt-combobox-component--fullwidth`,!!this.fullwidth),super.updated(e)}formResetCallback(){this.touched=!1;let e=this.defaultValue||(this.multiple,``);this.value=e,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.setFormValue(``),this.internals.ariaInvalid=`false`,this.requestUpdate()}attributeChangedCallback(e,t,n){if(e===`options`){this._options=v.cloneOptions(this.options);let e=v.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._`
|
|
1
|
+
const e=require("./element-CEarCnHH.cjs"),t=require("./if-defined-Ci4ZQsgL.cjs"),n=require("./ref-C6VUWwmF.cjs"),r=require("./class-map-C82GtM1w.cjs"),i=require("./repeat-CjvNrcUr.cjs"),a=require("./listbox-Du8llYth.cjs"),o=require("./element-with-slot-D_8fAzCW.cjs"),s=require("./input-element-CfZIyfon.cjs"),c=require("./pkt-options-controller-WsHVdPJA.cjs"),l=require("./format-B8meU8Tm.cjs"),u=require("./input-wrapper-CbYMk21W.cjs");require("./icon-5A378_yh.cjs"),require("./tag-BAikRN2Y.cjs");var d={multiple:!1,typeahead:!1,includeSearch:!1,allowUserInput:!1,displayValueAs:`label`,inputSize:`medium`,disabled:!1,hasError:!1,required:!1,requiredTag:!1,optionalTag:!1,fullwidth:!1,inline:!1,useWrapper:!0},f=(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}},p=(e,t,n,r,i)=>{if(!e)return{action:`none`,value:null};let o=a.i(n,e);return!t.includes(e)&&!o?r?{action:`addUserValue`,value:e}:i?{action:`none`,value:null}:{action:`removeValue`,value:t[0]}:o&&!t.includes(o.value)?{action:`selectOption`,value:o.value}:{action:`none`,value:null}},m=(e,t,n,r,i)=>e.trim().toLowerCase()?{...a.c(e,t,n,r),shouldRemoveValue:!1,shouldResetInput:!1}:{addValueText:null,userInfoMessage:``,shouldRemoveValue:!i&&!!t[0],shouldResetInput:!0},h=(e,t,n)=>{let r=a.i(t,e);return n===`label`&&r?.label?r.label:e},g={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)}},_={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=a.r(n),t.push(n)}),t}},v={cloneOptions(e){return Array.isArray(e)?e.map(e=>({...e})):[]},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=a.r(e),e.selected=e.selected||n.includes(e.value)}),{options:e,newValues:n}},mergeWithUserAdded(e,t,n){return[...t.filter(e=>e?.userAdded&&n.includes(e.value)).filter(t=>!(Array.isArray(e)?e:[]).some(e=>e.value===t.value)),...e]}},y=class extends s.t{constructor(){super(),this.value=``,this.options=[],this.defaultOptions=[],this.allowUserInput=d.allowUserInput,this.typeahead=d.typeahead,this.includeSearch=d.includeSearch,this.searchPlaceholder=null,this.multiple=d.multiple,this.maxlength=null,this.displayValueAs=d.displayValueAs,this.tagPlacement=null,this.isOpen=!1,this._options=[],this._value=[],this._isOptionsOpen=!1,this._userInfoMessage=``,this._messageValue=null,this._addValueText=null,this._maxIsReached=!1,this._search=``,this._inputFocus=!1,this._skipInputTab=!1,this._optionsFromSlot=!1,this._lastSlotGeneration=0,this._suppressNextOpen=!1,this.inputRef=n.t(),this.triggerRef=n.t(),this.listboxRef=n.t(),this._pendingDispatchFrom=null,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()}focusAfterCommit(){this._skipInputTab=!0;let e=this.inputRef.value;e&&e.type!==`hidden`&&e.setAttribute(`tabindex`,`-1`),this.triggerRef.value?.focus()}restoreInputTab(){this._skipInputTab=!1}parseValue(){return this.parseToValues(this.value)}parseToValues(e){return Array.isArray(e)?this.multiple?e:e.length>0?[e[0]]:[]:e&&this.multiple?e.split(`,`):e?[e]:[]}updateMaxReached(){this._maxIsReached=a.l(this._value.length,this.maxlength)}syncPublicValue(){let e=this.multiple?this._value.join(`,`):this._value[0]||``;e!==(Array.isArray(this.value)?this.value.join(`,`):String(this.value||``))&&(this.value=e)}dispatchValueChange(e){let t=this._value;if(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.u({type:String,reflect:!0})],y.prototype,`value`,void 0),e.n([e.u({type:Array})],y.prototype,`options`,void 0),e.n([e.u({type:Array,attribute:`default-options`})],y.prototype,`defaultOptions`,void 0),e.n([e.u({type:Boolean,attribute:`allow-user-input`})],y.prototype,`allowUserInput`,void 0),e.n([e.u({type:Boolean})],y.prototype,`typeahead`,void 0),e.n([e.u({type:Boolean,attribute:`include-search`})],y.prototype,`includeSearch`,void 0),e.n([e.u({type:String,attribute:`search-placeholder`})],y.prototype,`searchPlaceholder`,void 0),e.n([e.u({type:Boolean})],y.prototype,`multiple`,void 0),e.n([e.u({type:Number})],y.prototype,`maxlength`,void 0),e.n([e.u({type:String,attribute:`display-value-as`})],y.prototype,`displayValueAs`,void 0),e.n([e.u({type:String,attribute:`tag-placement`})],y.prototype,`tagPlacement`,void 0),e.n([e.u({type:Boolean,attribute:`open`})],y.prototype,`isOpen`,void 0),e.n([e.l()],y.prototype,`_options`,void 0),e.n([e.l()],y.prototype,`_value`,void 0),e.n([e.l()],y.prototype,`_isOptionsOpen`,void 0),e.n([e.l()],y.prototype,`_userInfoMessage`,void 0),e.n([e.l()],y.prototype,`_messageValue`,void 0),e.n([e.l()],y.prototype,`_addValueText`,void 0),e.n([e.l()],y.prototype,`_maxIsReached`,void 0),e.n([e.l()],y.prototype,`_search`,void 0),e.n([e.l()],y.prototype,`_inputFocus`,void 0),e.n([e.l()],y.prototype,`_skipInputTab`,void 0);var b=class extends y{toggleValue(e){if(this.isDisabled)return;this.touched=!0,this._userInfoMessage=``,this._addValueText=null;let t=a.i(this.options,e)?.value||null,n=this._value.includes(e||t||``),r=!!t,i=this._options.find(t=>t.value===e)?.disabled||!1,o=!e?.trim(),s=!this.multiple,c=this.multiple,l=a.l(this._value.length,this.maxlength),u=!1,d=!0,f=``,p=null,m=``;i||(!r&&this.allowUserInput&&!o?(this.addNewUserValue(e),f=`valueAdded`,u=c):!r&&!this.allowUserInput?(s&&this._value[0]&&this.removeValue(this._value[0]),d=!1,u=!0,f=`noResults`):n?(this.removeValue(t),u=!0,s&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(this.inputRef.value.value=``)):o&&s?(this.removeAllSelected(),u=!0):s?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(t),u=!1,f=`valueSelected`,p=this._hasTextInput?h(t||``,this.options,this.displayValueAs):a.s(a.i(this.options,t),this.displayValueAs)):c&&!l?(this.setSelected(t),u=!0):c&&l?(f=`maxSelected`,d=!1,m=e):(s&&this.removeAllSelected(),f=`noValidValue`,d=!1,u=!0,m=e),this._isOptionsOpen=u,u||window.setTimeout(()=>{this.focusAfterCommit()},0),this._search=m||``,this.resetComboboxInput(d),this._userInfoMessage=f,this._messageValue=p,c&&this.updateMaxReached())}setSelected(e){this._value.includes(e)||(this.multiple&&a.l(this._value.length,this.maxlength)?this._userInfoMessage=`maxSelected`:(!this.multiple&&this.removeAllSelected(),this._value=e?[...this._value,e]:this._value,g.markOptionSelected(this._options,e),this.resetComboboxInput(!0)))}removeSelected(e){if(!e)return;this._value=this._value.filter(t=>t!==e);let t=a.i(this.options,e);t&&(g.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.refreshOptionsFromValue():this._options=[...this._options,t])}addAllOptions(){this.multiple&&(this.maxlength&&this._options.length>this.maxlength?this._userInfoMessage=`tooManySelected`:(this._value=this._options.map(e=>e.value),g.markAllSelected(this._options),this.requestUpdate()))}removeAllSelected(){this._value=[],g.markAllDeselected(this._options),this._options=g.removeUserAddedOptions(this._options),this.requestUpdate()}addValue(){let e=this.inputRef.value?.value.trim()||``;this._search=e,e&&this._value.includes(e)?(this.resetComboboxInput(!0),this._userInfoMessage=`alreadySelected`):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(!a.i(this.options,e)){if(a.l(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,window.setTimeout(()=>{this.focusAfterCommit()},0)),this.requestUpdate()}refreshOptionsFromValue(){let e=v.cloneOptions(this.options);e.forEach(e=>e.selected=this._value.includes(e.value)),this._options=v.syncOptionsWithValues(e,this._value).options}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]?h(this._value[0],this.options,this.displayValueAs):``,this._userInfoMessage=``)),this.refreshOptionsFromValue()}removeLastValue(e){if(this._value.length===0)return;e.preventDefault();let t=this._value[this._value.length-1];t&&this.removeSelected(t),this.updateMaxReached()}},x=class extends b{handleInput(e){if(e.stopPropagation(),e.stopImmediatePropagation(),this.isDisabled)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}=a.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.refreshOptionsFromValue()}}handleFocus(){this.isDisabled||(this._skipInputTab=!1,this._suppressNextOpen?(this._suppressNextOpen=!1,this._inputFocus=!0,this.requestUpdate()):(!this.multiple&&this._value[0]&&this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(this.inputRef.value.value=h(this._value[0],this.options,this.displayValueAs)),this._inputFocus=!0,this._search=``,this.refreshOptionsFromValue(),this._isOptionsOpen=!0,this.onFocus(),this.requestUpdate()))}handleCloseOptions(){this._isOptionsOpen=!1,this._hasTextInput&&(this._suppressNextOpen=!0),this.focusTrigger()}handleFocusOut(e){if(this.isDisabled||!this._isOptionsOpen)return;let t=e.relatedTarget;t?.closest(`pkt-combobox`)?.id===this.id||e.target?.classList?.contains(`pkt-combobox__value`)||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=a.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}=p(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)}}!this.multiple&&this._value[0]?this.inputRef.value.value=h(this._value[0],this.options,this.displayValueAs):this.inputRef.value.value=``}this._isOptionsOpen=!1,this.onBlur()}handleBlur(){this._inputFocus=!1,this.onBlur()}handleInputClick(e){this.isDisabled?(e.preventDefault(),e.stopImmediatePropagation()):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.isDisabled||(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.isDisabled)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]))}}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=f(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();else switch(e.preventDefault(),t){case`addValue`:this.addValue();break;case`focusListbox`:this.listboxRef.value?.focusFirstOrSelectedOption();break;case`closeOptions`:this._isOptionsOpen=!1}}}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()}}checkForMatches(){let e=m(this.inputRef.value?.value||this._search||``,this._value,this.options,this.allowUserInput,this.multiple);e.shouldRemoveValue&&this.removeValue(this._value[0]),e.shouldResetInput?this.resetComboboxInput(!1):(this._addValueText=e.addValueText,this._userInfoMessage=e.userInfoMessage)}},S=class extends x{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){let e=this.options?.filter(e=>e.userAdded)||[];this.options=[...e,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=v.cloneOptions(this.options)}if(this.optionsController?.nodes&&this.optionsController.nodes.length){let e=_.parseOptionsFromSlot(this.optionsController.nodes);e.length&&(this.options=[...e],this._options=[...e],this._optionsFromSlot=!0,this._lastSlotGeneration=this.optionsController.generation)}}disconnectedCallback(){super.disconnectedCallback(),document?.body.removeEventListener(`click`,this.handleBodyClick)}firstUpdated(e){this.defaultValue!==null&&!this.value&&(this.value=this.defaultValue),super.firstUpdated(e)}willUpdate(e){if(this._optionsFromSlot&&this.optionsController){let e=this.optionsController.generation;if(e!==this._lastSlotGeneration){this._lastSlotGeneration=e;let t=_.parseOptionsFromSlot(this.optionsController.nodes),n=this._options.filter(e=>e.userAdded);this.options=[...n,...t]}}if(super.willUpdate(e),e.has(`isOpen`)&&(this._isOptionsOpen=this.isOpen),e.has(`defaultOptions`)&&this.defaultOptions.length){let e=(Array.isArray(this.options)?this.options:[]).filter(e=>e.userAdded)||[];this.options=[...e,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=v.cloneOptions(this.options)}let t=e.has(`value`),n=e.has(`_value`);if(t){let e=[...this._value],t=this.parseValue();t.join(`,`)!==this._value.join(`,`)&&(this._value=t,this._options.forEach(e=>e.selected=t.includes(e.value)),this._options=[...this._options]),this._pendingDispatchFrom??=e}else n&&(this._pendingDispatchFrom??=e.get(`_value`)??[]);if(e.has(`defaultValue`)&&this.defaultValue!=null&&!this._value.length){let e=this.parseToValues(this.defaultValue);e.length&&(this._pendingDispatchFrom??=[...this._value],this._value=e,this._options.forEach(t=>t.selected=e.includes(t.value)),this._options=[...this._options])}if(e.has(`options`)){let t=e.get(`options`)||this._options||[],n=v.mergeWithUserAdded(v.cloneOptions(this.options),t,this._value);this._options=n,n.length>this.options.length&&(this.options=n);let r=v.syncOptionsWithValues(this._options,this._value);this._options=r.options,r.newValues.length>this._value.length&&(this._pendingDispatchFrom??=[...this._value],this._value=r.newValues)}(t||n||e.has(`options`)||e.has(`defaultValue`))&&this.updateMaxReached(),this._pendingDispatchFrom&&this.syncPublicValue()}updated(e){if(this._pendingDispatchFrom){let e=this._pendingDispatchFrom;this._pendingDispatchFrom=null,this.dispatchValueChange(e)}if(e.has(`_search`)&&this.dispatchEvent(new CustomEvent(`search`,{detail:this._search,bubbles:!1})),!this._isOptionsOpen&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!==`hidden`){let e=!this.multiple&&this._value[0]?h(this._value[0],this.options,this.displayValueAs):``;this.inputRef.value.value!==e&&(this.inputRef.value.value=e)}this.classList.add(`pkt-combobox-component`),this.classList.toggle(`pkt-combobox-component--fullwidth`,!!this.fullwidth),super.updated(e)}formResetCallback(){this.touched=!1;let e=this.defaultValue||(this.multiple,``);this.value=e,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.setFormValue(``),this.internals.ariaInvalid=`false`,this.requestUpdate()}attributeChangedCallback(e,t,n){if(e===`options`){this._options=v.cloneOptions(this.options);let e=v.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._`
|
|
2
2
|
<pkt-input-wrapper
|
|
3
3
|
${o.n(this,[`helptext`])}
|
|
4
4
|
.strings=${this.strings}
|
|
@@ -57,6 +57,7 @@ const e=require("./element-CEarCnHH.cjs"),t=require("./if-defined-Ci4ZQsgL.cjs")
|
|
|
57
57
|
|
|
58
58
|
<pkt-listbox
|
|
59
59
|
id="${this.id}-listbox"
|
|
60
|
+
.strings=${this.strings}
|
|
60
61
|
.options=${this._options}
|
|
61
62
|
.isOpen=${this._isOptionsOpen}
|
|
62
63
|
.searchPlaceholder=${this.searchPlaceholder}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-CEarCnHH.cjs");require("./shared-types-BvRk9kiK.cjs"),require("./button-
|
|
1
|
+
const e=require("./element-CEarCnHH.cjs");require("./shared-types-BvRk9kiK.cjs"),require("./button-DHVRpzpS.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={devMode:!1,i18nLanguage:`nb`,triggerType:`button`},r=null;function i(){return r||(r=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-v2.0.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-v2.0.0.css`,r.type=`text/css`,r.rel=`stylesheet`,r.id=`oslo-consent-styles`,document.head.appendChild(r)}),r)}var a=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}},o=e=>a(e.value).items.reduce((e,t)=>(e[t.name]=t.consent,e),{}),s=class extends e.t{constructor(...e){super(...e),this.devMode=n.devMode,this.hotjarId=null,this.googleAnalyticsId=null,this.cookieDomain=null,this.cookieSecure=null,this.cookieExpiryDays=null,this.triggerType=n.triggerType,this.triggerText=null,this.i18nLanguage=n.i18nLanguage}connectedCallback(){super.connectedCallback();let e=Object.prototype.hasOwnProperty.call(t.i18n,this.i18nLanguage)?this.i18nLanguage:`nb`;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 a(e)}emitCookieConsents(e){this.dispatchEvent(new CustomEvent(`toggle-consent`,{detail:o(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 i(),this.triggerInit()}triggerInit(){window.document.dispatchEvent(new Event(`CookieBannerReady`,{bubbles:!0,cancelable:!0}));let e=window.cookieBanner,t=window.__cookieEvents;e&&t&&e.cookieConsent.validateConsentCookie().then(n=>{if(!n)return;let r=e.cookieConsent.getConsentCookie();window.setTimeout(()=>this.emitCookieConsents({value:r}),0),this._cookieEventHandler&&t.off(`CookieManager.setCookie`,this._cookieEventHandler),this._cookieEventHandler=e=>this.emitCookieConsents(e),t.on(`CookieManager.setCookie`,this._cookieEventHandler)})}openModal(e){e.preventDefault(),window.cookieBanner?.cookieConsent||this.triggerInit(),setTimeout(()=>window.cookieBanner?.openCookieModal())}render(){return this.triggerType===`link`?e._`<a href="#" class="pkt-link" aria-haspopup="dialog" @click=${this.openModal}
|
|
2
2
|
>${this.triggerText}</a
|
|
3
3
|
>`:this.triggerType===`footerlink`?e._`<a
|
|
4
4
|
href="#"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-CEarCnHH.cjs"),t=require("./converters-Dp64-kF1.cjs"),n=require("./input-element-CfZIyfon.cjs"),r=require("./ref-C6VUWwmF.cjs");require("./calendar-xYEsKilS.cjs"),require("./icon-5A378_yh.cjs"),require("./input-wrapper-
|
|
1
|
+
const e=require("./element-CEarCnHH.cjs"),t=require("./converters-Dp64-kF1.cjs"),n=require("./input-element-CfZIyfon.cjs"),r=require("./ref-C6VUWwmF.cjs");require("./calendar-xYEsKilS.cjs"),require("./icon-5A378_yh.cjs"),require("./input-wrapper-CbYMk21W.cjs");const i=require("./class-map-C82GtM1w.cjs"),a=require("./repeat-CjvNrcUr.cjs");require("./tag-BAikRN2Y.cjs");const o=require("./utils-63cRpWut.cjs"),s=require("./if-defined-Ci4ZQsgL.cjs"),c=require("./element-with-slot-D_8fAzCW.cjs");var l=class extends e.t{constructor(...e){super(...e),this.dates=[],this.dateformat=`dd.MM.yyyy`,this.className=`pkt-datepicker__tags`,this.idBase=o.n()}render(){return this.classes={"pkt-date-tags":!0,[this.className]:!0},e._`
|
|
2
2
|
<div class=${i.t(this.classes)} aria-live="polite">
|
|
3
3
|
${Array.isArray(this.dates)&&this.dates[0]?a.t(t.h((this.dates??[]).filter(Boolean)),e=>e,n=>e._` <pkt-tag
|
|
4
4
|
id=${this.idBase+n+`-tag`}
|
|
@@ -4,7 +4,7 @@ import { t as te } from "./input-element-DE0FzjgP.js";
|
|
|
4
4
|
import { n as v, t as y } from "./ref-qE1RBrI7.js";
|
|
5
5
|
import "./calendar-CkAAgviq.js";
|
|
6
6
|
import "./icon-CZDw42U7.js";
|
|
7
|
-
import "./input-wrapper-
|
|
7
|
+
import "./input-wrapper-DYg1VHPv.js";
|
|
8
8
|
import { t as b } from "./class-map-C9n5CNC8.js";
|
|
9
9
|
import { t as x } from "./repeat-c2P6osbb.js";
|
|
10
10
|
import "./tag-HXcXopyA.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { _ as e, d as t, l as n, n as r, s as i, t as a, u as o } from "./element-Bwc-likm.js";
|
|
2
2
|
import { t as s } from "./class-map-C9n5CNC8.js";
|
|
3
3
|
import { n as c, t as l } from "./format-DwjTfa9h.js";
|
|
4
|
-
import "./alert-
|
|
4
|
+
import "./alert-ZrB-P881.js";
|
|
5
5
|
import "./icon-CZDw42U7.js";
|
|
6
|
-
import "./input-wrapper-
|
|
6
|
+
import "./input-wrapper-DYg1VHPv.js";
|
|
7
7
|
import "./progressbar-DlbkKRgP.js";
|
|
8
8
|
import { t as u } from "./if-defined-B3pYog2C.js";
|
|
9
9
|
import { t as d } from "./converters-v_GK06o3.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-CEarCnHH.cjs"),t=require("./class-map-C82GtM1w.cjs"),n=require("./format-B8meU8Tm.cjs");require("./alert-DPtmkrJq.cjs"),require("./icon-5A378_yh.cjs"),require("./input-wrapper-CdH6RH0a.cjs"),require("./progressbar-Wyq_Q1Ur.cjs");const r=require("./if-defined-Ci4ZQsgL.cjs"),i=require("./converters-Dp64-kF1.cjs"),a=require("./utils-63cRpWut.cjs"),o=require("./focus-trap-C9tsr-xL.cjs");require("./modal-B3rnE83a.cjs");function s(e){if(e==null||e===``)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=String(e).trim(),n=Number(t);if(!Number.isNaN(n)&&n>0)return n;let r=t.match(/^(\d+(?:\.\d+)?)\s*(B|KB|MB|GB)$/i);if(!r){console.warn(`PktFileUpload: Invalid maxFileSize format "${t}". Use format like "5MB", "500KB", "1GB", or bytes.`);return}let i=parseFloat(r[1]);switch(r[2].toUpperCase()){case`B`:return i;case`KB`:return i*1024;case`MB`:return i*1024*1024;case`GB`:return i*1024*1024*1024;default:return}}function c(e){return e<1024?`${Math.round(e)} B`:e<1048576?`${Math.round(e/1024)} KB`:e<1073741824?`${Math.round(e/1048576)} MB`:`${Math.round(e/1073741824)} GB`}function l(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function u(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function d(e,t,n){let r=e.toLowerCase().replace(/^\./,``);if(r.includes(`/`)){if(r.endsWith(`/*`)){let e=r.replace(`/*`,``);return n.startsWith(`${e}/`)}return n===r}return t===r}function f(e,t){let n=l(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>d(e,r,i))}function p(e,t){let n=(e??``).trim();if(n)return n;let r=l(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function m(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function h(e,t){let n=l(e);if(n.length>0)return n.map(m).join(`, `);let r=u(t);return r.length>0?r.map(m).join(`, `):``}function g(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function _(t,n){let r=l(n.allowedFormats);if(r.length>0&&!f(t,r)){let t=r.join(`, `),i=e.s.fileupload.invalidFormat;return g(n.formatErrorMessage,i,{formats:t})}let i=s(n.maxFileSize);if(i!==void 0&&t.size>i){let t=c(i),r=e.s.fileupload.sizeTooLarge;return g(n.sizeErrorMessage,r,{maxSize:t})}if(n.onFileValidation){let e=n.onFileValidation(t);if(e)return e}return null}function v(e){let t=e.file;if(t?.type?.startsWith(`image/`))return!0;let n=e.attributes?.targetFilename||t?.name||``;return/\.(jpe?g|png|gif|webp|heic|heif|bmp|svg)$/i.test(n)}function y(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function b(e,t,n){let r={"in-progress":0,error:1,idle:2};return e.map(e=>{let r=t?.find(t=>t.fileId===e.fileId);return{...e,progress:r?.progress??(n===`form`?`done`:`queued`),errorMessage:r?.errorMessage,showProgress:r?.showProgress,lastProgress:r?.lastProgress}}).sort((e,t)=>r[y(e.progress)]-r[y(t.progress)])}function x(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function S(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function C(e,t){let n=e.length;if(n===0||!t||t.length===0)return{totalCount:n,uploadedCount:0,failedCount:0};let r=0,i=0;for(let n of e){let e=t.find(e=>e.fileId===n.fileId);e?.progress===`done`?r++:e?.progress===`error`&&i++}return{totalCount:n,uploadedCount:r,failedCount:i}}function w(t,n=e.s.fileupload.unknownFilename){return t.attributes?.targetFilename||t.file?.name||n}var T=class extends e.t{constructor(...e){super(...e),this.id=`pkt-fileupload-${a.n()}`,this.name=`files`,this.label=``,this.helptext=``,this.helptextDropdown=``,this.required=!1,this.multiple=!1,this.disabled=!1,this.fullwidth=!1,this.uploadStrategy=`form`,this.itemRenderer=`filename`,this.accept=``,this.allowedFormats=[],this.formatErrorMessage=``,this.sizeErrorMessage=``,this.transfers=[],this.addCommentsEnabled=!1,this.renameFilesEnabled=!1,this.extraOperations=[],this.enableImagePreview=!1,this.hasError=!1,this.errorMessage=``,this.optionalTag=!1,this.requiredTag=!1,this.tagText=null,this.truncateTail=4,this.files=[],this.isDragActive=!1,this.validationErrorMessage=null,this.addedAnnouncement=``,this.thumbnailUrls={},this.hasInitializedValue=!1,this.hasWarnedInvalidValueCombo=!1,this.thumbnailFileById=new Map,this.connectedForm=null,this.addedAnnouncementTimer=null,this.onNativeFileChange=e=>{let t=e.target;this.addFiles(t.files?Array.from(t.files):[]),this.uploadStrategy===`custom`&&(t.value=``)},this.openFileDialog=e=>{e.preventDefault(),e.stopPropagation(),this.disabled||this.querySelector(`#${this.id}-input`)?.click()},this.onDropZoneClick=e=>{this.disabled||e.target.closest(`.pkt-fileupload__drop-zone__placeholder__title__open-file-dialog`)||this.querySelector(`#${this.id}-input`)?.click()},this.onDragOver=e=>{e.preventDefault(),this.disabled||(this.isDragActive=!0)},this.onDragLeave=()=>{this.isDragActive=!1},this.onDrop=e=>{if(e.preventDefault(),this.isDragActive=!1,this.disabled)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this.addFiles(t)},this.onHostFormSubmit=e=>{this.required&&this.uploadStrategy===`custom`&&(this.getCurrentFiles().length>0||(this.validationErrorMessage=this.requiredSelectionMessage,e.preventDefault()))}}get requiredSelectionMessage(){return this.pktStrings.get(`fileupload`).requiredMissing}get isControlled(){return this.value!==void 0}get hasEffectiveError(){return!!this.validationErrorMessage||this.hasError||!!this.errorMessage.trim()}get effectiveErrorMessage(){return this.validationErrorMessage??this.errorMessage??``}get hasValidationError(){return!!this.validationErrorMessage}firstUpdated(e){super.firstUpdated?.(e),this.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)):(this.files=this.value??this.defaultValue??[],this.syncThumbnailUrls(this.files),this.hasInitializedValue=!0)}updated(e){super.updated(e),(e.has(`uploadStrategy`)||e.has(`required`)||e.has(`value`)||e.has(`form`))&&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 r=t.map(e=>({fileId:a.n(),file:e,attributes:{targetFilename:e.name}})),i=this.pktStrings.get(`fileupload`);this.setAddedAnnouncement(r.length===1?n.t(i.srFileAdded,{filename:r[0].attributes.targetFilename}):n.t(i.srFilesAdded,{count:r.length}));let o=this.getCurrentFiles(),s=this.multiple?[...o,...r]:[r[0]];this.commitFiles(s,`add`,r.map(e=>e.fileId)),this.uploadStrategy===`custom`&&r.forEach(e=>{this.dispatchEvent(new CustomEvent(`file-upload-requested`,{detail:{fileId:e.fileId,file:e.file,attributes:e.attributes},bubbles:!0,composed:!0}))})}getCurrentFiles(){return this.isControlled?this.value??[]:this.files}cancelTransfer(e){if(this.disabled)return;let t=this.getCurrentFiles().find(t=>t.fileId===e);t&&(this.removeFileItem(e),this.dispatchEvent(new CustomEvent(`transfer-cancelled`,{detail:{fileId:t.fileId,file:t.file,attributes:t.attributes},bubbles:!0,composed:!0})))}removeFileItem(e){if(this.disabled)return;let t=this.getCurrentFiles(),n=t.filter(t=>t.fileId!==e);n.length!==t.length&&this.commitFiles(n,`remove`,[e])}updateFileItem(e,t){let n=this.getCurrentFiles().map(n=>n.fileId===e?{...n,...t}:n);this.commitFiles(n,`update`,[e])}commitFiles(e,t,n){this.isControlled||(this.files=e,this.syncThumbnailUrls(e)),this.validationErrorMessage===this.requiredSelectionMessage&&e.length>0&&(this.validationErrorMessage=null),this.dispatchEvent(new CustomEvent(`files-changed`,{detail:{files:e,reason:t,changedFileIds:n},bubbles:!0,composed:!0}))}getThumbnailUrl(e){return this.thumbnailUrls[e.fileId]}getTransferProgress(e){let t=this.transfers.find(t=>t.fileId===e);return t?t.progress:this.uploadStrategy===`form`?`done`:`queued`}getTransferForFile(e){return this.transfers.find(t=>t.fileId===e)}isImageFile(e){return v(e)}formatFileSize(e){return c(e)}getResolvedAcceptValue(){return p(this.accept,this.allowedFormats)}getSupportedFormatsText(){return h(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return b(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=_(e,{allowedFormats:this.allowedFormats,maxFileSize:this.maxFileSize,formatErrorMessage:this.formatErrorMessage,sizeErrorMessage:this.sizeErrorMessage,onFileValidation:this.onFileValidation});if(t)return t;let n={file:e,errorMessage:null},r=new CustomEvent(`file-validate`,{detail:n,bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(r),n.errorMessage?n.errorMessage:r.defaultPrevented?this.pktStrings.get(`fileupload`).genericValidationRejection:null}syncThumbnailUrls(e){if(typeof URL>`u`||typeof URL.createObjectURL!=`function`||typeof URL.revokeObjectURL!=`function`){this.thumbnailUrls={},this.thumbnailFileById.clear();return}let t=new Set(e.map(e=>e.fileId)),n={};for(let[e,n]of Object.entries(this.thumbnailUrls))t.has(e)||(URL.revokeObjectURL(n),this.thumbnailFileById.delete(e));for(let t of e){let e=this.thumbnailUrls[t.fileId],r=this.thumbnailFileById.get(t.fileId);if(!t.file||!this.isImageFile(t)){e&&(URL.revokeObjectURL(e),this.thumbnailFileById.delete(t.fileId));continue}if(e&&r===t.file){n[t.fileId]=e;continue}e&&r!==t.file&&URL.revokeObjectURL(e);let i=URL.createObjectURL(t.file);this.thumbnailFileById.set(t.fileId,t.file),n[t.fileId]=i}this.thumbnailUrls=n}revokeAllThumbnailUrls(){typeof URL>`u`||typeof URL.revokeObjectURL!=`function`?(this.thumbnailUrls={},this.thumbnailFileById.clear()):(Object.values(this.thumbnailUrls).forEach(e=>URL.revokeObjectURL(e)),this.thumbnailUrls={},this.thumbnailFileById.clear())}getSrUploadedMessage(){if(this.addedAnnouncement)return this.addedAnnouncement;let{totalCount:e,uploadedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let r=this.pktStrings.get(`fileupload`);return n.t(r.srFilesUploadedOfTotal,{uploaded:t,total:e,label:n.n(e,r.fileLabelOne,r.fileLabelOther)})}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let r=this.pktStrings.get(`fileupload`);return n.t(r.srFilesFailedOfTotal,{failed:t,total:e,label:n.n(e,r.fileLabelOne,r.fileLabelOther)})}get ownerForm(){if(this.form!==void 0){if(!this.form)return null;let e=this.ownerDocument?.getElementById(this.form);return e instanceof HTMLFormElement?e:null}return this.closest(`form`)}syncFormSubmitListener(){let e=this.ownerForm;this.connectedForm!==e&&(this.teardownFormSubmitListener(),this.connectedForm=e,this.connectedForm&&this.connectedForm.addEventListener(`submit`,this.onHostFormSubmit))}teardownFormSubmitListener(){this.connectedForm&&=(this.connectedForm.removeEventListener(`submit`,this.onHostFormSubmit),null)}};e.n([e.u({type:String})],T.prototype,`id`,void 0),e.n([e.u({type:String})],T.prototype,`name`,void 0),e.n([e.u({type:String,reflect:!0})],T.prototype,`form`,void 0),e.n([e.u({type:String})],T.prototype,`label`,void 0),e.n([e.u({type:String})],T.prototype,`helptext`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown`})],T.prototype,`helptextDropdown`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown-button`})],T.prototype,`helptextDropdownButton`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`required`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`multiple`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`disabled`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`fullwidth`})],T.prototype,`fullwidth`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`upload-strategy`})],T.prototype,`uploadStrategy`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`item-renderer`})],T.prototype,`itemRenderer`,void 0),e.n([e.u({type:String})],T.prototype,`accept`,void 0),e.n([e.u({converter:i.t.csvToArray,attribute:`allowed-formats`})],T.prototype,`allowedFormats`,void 0),e.n([e.u({type:String,attribute:`format-error-message`})],T.prototype,`formatErrorMessage`,void 0),e.n([e.u({attribute:`max-file-size`})],T.prototype,`maxFileSize`,void 0),e.n([e.u({type:String,attribute:`size-error-message`})],T.prototype,`sizeErrorMessage`,void 0),e.n([e.u({attribute:!1})],T.prototype,`onFileValidation`,void 0),e.n([e.u({attribute:!1})],T.prototype,`transfers`,void 0),e.n([e.u({type:Boolean,attribute:`add-comments-enabled`})],T.prototype,`addCommentsEnabled`,void 0),e.n([e.u({type:Boolean,attribute:`rename-files-enabled`})],T.prototype,`renameFilesEnabled`,void 0),e.n([e.u({attribute:!1})],T.prototype,`extraOperations`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],T.prototype,`enableImagePreview`,void 0),e.n([e.u({type:Boolean,attribute:`has-error`})],T.prototype,`hasError`,void 0),e.n([e.u({type:String,attribute:`error-message`})],T.prototype,`errorMessage`,void 0),e.n([e.u({type:Boolean,attribute:`optional-tag`})],T.prototype,`optionalTag`,void 0),e.n([e.u({type:String,attribute:`optional-text`})],T.prototype,`optionalText`,void 0),e.n([e.u({type:Boolean,attribute:`required-tag`})],T.prototype,`requiredTag`,void 0),e.n([e.u({type:String,attribute:`required-text`})],T.prototype,`requiredText`,void 0),e.n([e.u({type:String,attribute:`tag-text`})],T.prototype,`tagText`,void 0),e.n([e.u({type:Number,attribute:`truncate-tail`})],T.prototype,`truncateTail`,void 0),e.n([e.u({attribute:!1})],T.prototype,`value`,void 0),e.n([e.u({attribute:!1})],T.prototype,`defaultValue`,void 0),e.n([e.l()],T.prototype,`files`,void 0),e.n([e.l()],T.prototype,`isDragActive`,void 0),e.n([e.l()],T.prototype,`validationErrorMessage`,void 0),e.n([e.l()],T.prototype,`addedAnnouncement`,void 0),e.n([e.l()],T.prototype,`thumbnailUrls`,void 0);var E=`comments`,D=(e,t)=>{let r=new Date(e);if(Number.isNaN(r.getTime()))return e;let i=String(r.getDate()).padStart(2,`0`),a=String(r.getMonth()+1).padStart(2,`0`),o=r.getFullYear(),s=String(r.getHours()).padStart(2,`0`),c=String(r.getMinutes()).padStart(2,`0`);return n.t(t.commentTimestamp,{date:`${i}.${a}.${o}`,time:`${s}:${c}`})},O=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},k=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},A=(e,t)=>({id:`remove`,title:t.remove,ariaLabel:t.removeFile,onClick:({file:t})=>e(t.fileId)}),j=t=>({id:`rename`,title:t.rename,ariaLabel:t.renameFile,renderInlineUI:n=>{let r=n.getAttribute(`targetFilename`)||n.file.attributes?.targetFilename||n.file.file?.name||``,i=`pkt-fileupload-rename-${n.file.fileId}`,a=()=>{let e=document.getElementById(i)?.value?.trim();e&&n.setAttribute(`targetFilename`,e),n.close()};return e._`
|
|
1
|
+
const e=require("./element-CEarCnHH.cjs"),t=require("./class-map-C82GtM1w.cjs"),n=require("./format-B8meU8Tm.cjs");require("./alert-0a5lX0pL.cjs"),require("./icon-5A378_yh.cjs"),require("./input-wrapper-CbYMk21W.cjs"),require("./progressbar-Wyq_Q1Ur.cjs");const r=require("./if-defined-Ci4ZQsgL.cjs"),i=require("./converters-Dp64-kF1.cjs"),a=require("./utils-63cRpWut.cjs"),o=require("./focus-trap-C9tsr-xL.cjs");require("./modal-B3rnE83a.cjs");function s(e){if(e==null||e===``)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=String(e).trim(),n=Number(t);if(!Number.isNaN(n)&&n>0)return n;let r=t.match(/^(\d+(?:\.\d+)?)\s*(B|KB|MB|GB)$/i);if(!r){console.warn(`PktFileUpload: Invalid maxFileSize format "${t}". Use format like "5MB", "500KB", "1GB", or bytes.`);return}let i=parseFloat(r[1]);switch(r[2].toUpperCase()){case`B`:return i;case`KB`:return i*1024;case`MB`:return i*1024*1024;case`GB`:return i*1024*1024*1024;default:return}}function c(e){return e<1024?`${Math.round(e)} B`:e<1048576?`${Math.round(e/1024)} KB`:e<1073741824?`${Math.round(e/1048576)} MB`:`${Math.round(e/1073741824)} GB`}function l(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function u(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function d(e,t,n){let r=e.toLowerCase().replace(/^\./,``);if(r.includes(`/`)){if(r.endsWith(`/*`)){let e=r.replace(`/*`,``);return n.startsWith(`${e}/`)}return n===r}return t===r}function f(e,t){let n=l(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>d(e,r,i))}function p(e,t){let n=(e??``).trim();if(n)return n;let r=l(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function m(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function h(e,t){let n=l(e);if(n.length>0)return n.map(m).join(`, `);let r=u(t);return r.length>0?r.map(m).join(`, `):``}function g(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function _(t,n){let r=l(n.allowedFormats);if(r.length>0&&!f(t,r)){let t=r.join(`, `),i=e.s.fileupload.invalidFormat;return g(n.formatErrorMessage,i,{formats:t})}let i=s(n.maxFileSize);if(i!==void 0&&t.size>i){let t=c(i),r=e.s.fileupload.sizeTooLarge;return g(n.sizeErrorMessage,r,{maxSize:t})}if(n.onFileValidation){let e=n.onFileValidation(t);if(e)return e}return null}function v(e){let t=e.file;if(t?.type?.startsWith(`image/`))return!0;let n=e.attributes?.targetFilename||t?.name||``;return/\.(jpe?g|png|gif|webp|heic|heif|bmp|svg)$/i.test(n)}function y(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function b(e,t,n){let r={"in-progress":0,error:1,idle:2};return e.map(e=>{let r=t?.find(t=>t.fileId===e.fileId);return{...e,progress:r?.progress??(n===`form`?`done`:`queued`),errorMessage:r?.errorMessage,showProgress:r?.showProgress,lastProgress:r?.lastProgress}}).sort((e,t)=>r[y(e.progress)]-r[y(t.progress)])}function x(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function S(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function C(e,t){let n=e.length;if(n===0||!t||t.length===0)return{totalCount:n,uploadedCount:0,failedCount:0};let r=0,i=0;for(let n of e){let e=t.find(e=>e.fileId===n.fileId);e?.progress===`done`?r++:e?.progress===`error`&&i++}return{totalCount:n,uploadedCount:r,failedCount:i}}function w(t,n=e.s.fileupload.unknownFilename){return t.attributes?.targetFilename||t.file?.name||n}var T=class extends e.t{constructor(...e){super(...e),this.id=`pkt-fileupload-${a.n()}`,this.name=`files`,this.label=``,this.helptext=``,this.helptextDropdown=``,this.required=!1,this.multiple=!1,this.disabled=!1,this.fullwidth=!1,this.uploadStrategy=`form`,this.itemRenderer=`filename`,this.accept=``,this.allowedFormats=[],this.formatErrorMessage=``,this.sizeErrorMessage=``,this.transfers=[],this.addCommentsEnabled=!1,this.renameFilesEnabled=!1,this.extraOperations=[],this.enableImagePreview=!1,this.hasError=!1,this.errorMessage=``,this.optionalTag=!1,this.requiredTag=!1,this.tagText=null,this.truncateTail=4,this.files=[],this.isDragActive=!1,this.validationErrorMessage=null,this.addedAnnouncement=``,this.thumbnailUrls={},this.hasInitializedValue=!1,this.hasWarnedInvalidValueCombo=!1,this.thumbnailFileById=new Map,this.connectedForm=null,this.addedAnnouncementTimer=null,this.onNativeFileChange=e=>{let t=e.target;this.addFiles(t.files?Array.from(t.files):[]),this.uploadStrategy===`custom`&&(t.value=``)},this.openFileDialog=e=>{e.preventDefault(),e.stopPropagation(),this.disabled||this.querySelector(`#${this.id}-input`)?.click()},this.onDropZoneClick=e=>{this.disabled||e.target.closest(`.pkt-fileupload__drop-zone__placeholder__title__open-file-dialog`)||this.querySelector(`#${this.id}-input`)?.click()},this.onDragOver=e=>{e.preventDefault(),this.disabled||(this.isDragActive=!0)},this.onDragLeave=()=>{this.isDragActive=!1},this.onDrop=e=>{if(e.preventDefault(),this.isDragActive=!1,this.disabled)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this.addFiles(t)},this.onHostFormSubmit=e=>{this.required&&this.uploadStrategy===`custom`&&(this.getCurrentFiles().length>0||(this.validationErrorMessage=this.requiredSelectionMessage,e.preventDefault()))}}get requiredSelectionMessage(){return this.pktStrings.get(`fileupload`).requiredMissing}get isControlled(){return this.value!==void 0}get hasEffectiveError(){return!!this.validationErrorMessage||this.hasError||!!this.errorMessage.trim()}get effectiveErrorMessage(){return this.validationErrorMessage??this.errorMessage??``}get hasValidationError(){return!!this.validationErrorMessage}firstUpdated(e){super.firstUpdated?.(e),this.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)):(this.files=this.value??this.defaultValue??[],this.syncThumbnailUrls(this.files),this.hasInitializedValue=!0)}updated(e){super.updated(e),(e.has(`uploadStrategy`)||e.has(`required`)||e.has(`value`)||e.has(`form`))&&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 r=t.map(e=>({fileId:a.n(),file:e,attributes:{targetFilename:e.name}})),i=this.pktStrings.get(`fileupload`);this.setAddedAnnouncement(r.length===1?n.t(i.srFileAdded,{filename:r[0].attributes.targetFilename}):n.t(i.srFilesAdded,{count:r.length}));let o=this.getCurrentFiles(),s=this.multiple?[...o,...r]:[r[0]];this.commitFiles(s,`add`,r.map(e=>e.fileId)),this.uploadStrategy===`custom`&&r.forEach(e=>{this.dispatchEvent(new CustomEvent(`file-upload-requested`,{detail:{fileId:e.fileId,file:e.file,attributes:e.attributes},bubbles:!0,composed:!0}))})}getCurrentFiles(){return this.isControlled?this.value??[]:this.files}cancelTransfer(e){if(this.disabled)return;let t=this.getCurrentFiles().find(t=>t.fileId===e);t&&(this.removeFileItem(e),this.dispatchEvent(new CustomEvent(`transfer-cancelled`,{detail:{fileId:t.fileId,file:t.file,attributes:t.attributes},bubbles:!0,composed:!0})))}removeFileItem(e){if(this.disabled)return;let t=this.getCurrentFiles(),n=t.filter(t=>t.fileId!==e);n.length!==t.length&&this.commitFiles(n,`remove`,[e])}updateFileItem(e,t){let n=this.getCurrentFiles().map(n=>n.fileId===e?{...n,...t}:n);this.commitFiles(n,`update`,[e])}commitFiles(e,t,n){this.isControlled||(this.files=e,this.syncThumbnailUrls(e)),this.validationErrorMessage===this.requiredSelectionMessage&&e.length>0&&(this.validationErrorMessage=null),this.dispatchEvent(new CustomEvent(`files-changed`,{detail:{files:e,reason:t,changedFileIds:n},bubbles:!0,composed:!0}))}getThumbnailUrl(e){return this.thumbnailUrls[e.fileId]}getTransferProgress(e){let t=this.transfers.find(t=>t.fileId===e);return t?t.progress:this.uploadStrategy===`form`?`done`:`queued`}getTransferForFile(e){return this.transfers.find(t=>t.fileId===e)}isImageFile(e){return v(e)}formatFileSize(e){return c(e)}getResolvedAcceptValue(){return p(this.accept,this.allowedFormats)}getSupportedFormatsText(){return h(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return b(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=_(e,{allowedFormats:this.allowedFormats,maxFileSize:this.maxFileSize,formatErrorMessage:this.formatErrorMessage,sizeErrorMessage:this.sizeErrorMessage,onFileValidation:this.onFileValidation});if(t)return t;let n={file:e,errorMessage:null},r=new CustomEvent(`file-validate`,{detail:n,bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(r),n.errorMessage?n.errorMessage:r.defaultPrevented?this.pktStrings.get(`fileupload`).genericValidationRejection:null}syncThumbnailUrls(e){if(typeof URL>`u`||typeof URL.createObjectURL!=`function`||typeof URL.revokeObjectURL!=`function`){this.thumbnailUrls={},this.thumbnailFileById.clear();return}let t=new Set(e.map(e=>e.fileId)),n={};for(let[e,n]of Object.entries(this.thumbnailUrls))t.has(e)||(URL.revokeObjectURL(n),this.thumbnailFileById.delete(e));for(let t of e){let e=this.thumbnailUrls[t.fileId],r=this.thumbnailFileById.get(t.fileId);if(!t.file||!this.isImageFile(t)){e&&(URL.revokeObjectURL(e),this.thumbnailFileById.delete(t.fileId));continue}if(e&&r===t.file){n[t.fileId]=e;continue}e&&r!==t.file&&URL.revokeObjectURL(e);let i=URL.createObjectURL(t.file);this.thumbnailFileById.set(t.fileId,t.file),n[t.fileId]=i}this.thumbnailUrls=n}revokeAllThumbnailUrls(){typeof URL>`u`||typeof URL.revokeObjectURL!=`function`?(this.thumbnailUrls={},this.thumbnailFileById.clear()):(Object.values(this.thumbnailUrls).forEach(e=>URL.revokeObjectURL(e)),this.thumbnailUrls={},this.thumbnailFileById.clear())}getSrUploadedMessage(){if(this.addedAnnouncement)return this.addedAnnouncement;let{totalCount:e,uploadedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let r=this.pktStrings.get(`fileupload`);return n.t(r.srFilesUploadedOfTotal,{uploaded:t,total:e,label:n.n(e,r.fileLabelOne,r.fileLabelOther)})}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let r=this.pktStrings.get(`fileupload`);return n.t(r.srFilesFailedOfTotal,{failed:t,total:e,label:n.n(e,r.fileLabelOne,r.fileLabelOther)})}get ownerForm(){if(this.form!==void 0){if(!this.form)return null;let e=this.ownerDocument?.getElementById(this.form);return e instanceof HTMLFormElement?e:null}return this.closest(`form`)}syncFormSubmitListener(){let e=this.ownerForm;this.connectedForm!==e&&(this.teardownFormSubmitListener(),this.connectedForm=e,this.connectedForm&&this.connectedForm.addEventListener(`submit`,this.onHostFormSubmit))}teardownFormSubmitListener(){this.connectedForm&&=(this.connectedForm.removeEventListener(`submit`,this.onHostFormSubmit),null)}};e.n([e.u({type:String})],T.prototype,`id`,void 0),e.n([e.u({type:String})],T.prototype,`name`,void 0),e.n([e.u({type:String,reflect:!0})],T.prototype,`form`,void 0),e.n([e.u({type:String})],T.prototype,`label`,void 0),e.n([e.u({type:String})],T.prototype,`helptext`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown`})],T.prototype,`helptextDropdown`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown-button`})],T.prototype,`helptextDropdownButton`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`required`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`multiple`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`disabled`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`fullwidth`})],T.prototype,`fullwidth`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`upload-strategy`})],T.prototype,`uploadStrategy`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`item-renderer`})],T.prototype,`itemRenderer`,void 0),e.n([e.u({type:String})],T.prototype,`accept`,void 0),e.n([e.u({converter:i.t.csvToArray,attribute:`allowed-formats`})],T.prototype,`allowedFormats`,void 0),e.n([e.u({type:String,attribute:`format-error-message`})],T.prototype,`formatErrorMessage`,void 0),e.n([e.u({attribute:`max-file-size`})],T.prototype,`maxFileSize`,void 0),e.n([e.u({type:String,attribute:`size-error-message`})],T.prototype,`sizeErrorMessage`,void 0),e.n([e.u({attribute:!1})],T.prototype,`onFileValidation`,void 0),e.n([e.u({attribute:!1})],T.prototype,`transfers`,void 0),e.n([e.u({type:Boolean,attribute:`add-comments-enabled`})],T.prototype,`addCommentsEnabled`,void 0),e.n([e.u({type:Boolean,attribute:`rename-files-enabled`})],T.prototype,`renameFilesEnabled`,void 0),e.n([e.u({attribute:!1})],T.prototype,`extraOperations`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],T.prototype,`enableImagePreview`,void 0),e.n([e.u({type:Boolean,attribute:`has-error`})],T.prototype,`hasError`,void 0),e.n([e.u({type:String,attribute:`error-message`})],T.prototype,`errorMessage`,void 0),e.n([e.u({type:Boolean,attribute:`optional-tag`})],T.prototype,`optionalTag`,void 0),e.n([e.u({type:String,attribute:`optional-text`})],T.prototype,`optionalText`,void 0),e.n([e.u({type:Boolean,attribute:`required-tag`})],T.prototype,`requiredTag`,void 0),e.n([e.u({type:String,attribute:`required-text`})],T.prototype,`requiredText`,void 0),e.n([e.u({type:String,attribute:`tag-text`})],T.prototype,`tagText`,void 0),e.n([e.u({type:Number,attribute:`truncate-tail`})],T.prototype,`truncateTail`,void 0),e.n([e.u({attribute:!1})],T.prototype,`value`,void 0),e.n([e.u({attribute:!1})],T.prototype,`defaultValue`,void 0),e.n([e.l()],T.prototype,`files`,void 0),e.n([e.l()],T.prototype,`isDragActive`,void 0),e.n([e.l()],T.prototype,`validationErrorMessage`,void 0),e.n([e.l()],T.prototype,`addedAnnouncement`,void 0),e.n([e.l()],T.prototype,`thumbnailUrls`,void 0);var E=`comments`,D=(e,t)=>{let r=new Date(e);if(Number.isNaN(r.getTime()))return e;let i=String(r.getDate()).padStart(2,`0`),a=String(r.getMonth()+1).padStart(2,`0`),o=r.getFullYear(),s=String(r.getHours()).padStart(2,`0`),c=String(r.getMinutes()).padStart(2,`0`);return n.t(t.commentTimestamp,{date:`${i}.${a}.${o}`,time:`${s}:${c}`})},O=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},k=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},A=(e,t)=>({id:`remove`,title:t.remove,ariaLabel:t.removeFile,onClick:({file:t})=>e(t.fileId)}),j=t=>({id:`rename`,title:t.rename,ariaLabel:t.renameFile,renderInlineUI:n=>{let r=n.getAttribute(`targetFilename`)||n.file.attributes?.targetFilename||n.file.file?.name||``,i=`pkt-fileupload-rename-${n.file.fileId}`,a=()=>{let e=document.getElementById(i)?.value?.trim();e&&n.setAttribute(`targetFilename`,e),n.close()};return e._`
|
|
2
2
|
<label for=${i} class="pkt-sr-only">${t.renameInputLabel}</label>
|
|
3
3
|
<input
|
|
4
4
|
id=${i}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-CEarCnHH.cjs"),t=require("./if-defined-Ci4ZQsgL.cjs"),n=require("./booleanish-BF8l4scU.cjs"),r=require("./fetch-header-footer-data-CUKV0biS.cjs");require("./shared-types-BvRk9kiK.cjs"),require("./consent-
|
|
1
|
+
const e=require("./element-CEarCnHH.cjs"),t=require("./if-defined-Ci4ZQsgL.cjs"),n=require("./booleanish-BF8l4scU.cjs"),r=require("./fetch-header-footer-data-CUKV0biS.cjs");require("./shared-types-BvRk9kiK.cjs"),require("./consent-BOSXNt4Y.cjs"),require("./icon-5A378_yh.cjs");var i=`oslo.kommune.no`,a=/\.(?:co|com|org|net|gov|edu|ac|kommune)\.[a-z]{2}$/i;function o(e){let t=e.toLowerCase().replace(/\.$/,``),n=t.split(`.`);return n.length<=2?t:n.slice(a.test(t)?-3:-2).join(`.`)}function s(e){if(!e)return;let t;try{t=new URL(e)}catch{return}if(t.protocol===`http:`||t.protocol===`https:`)return o(t.hostname.toLowerCase().replace(/\.$/,``))}function c(e,t=i){if(!e)return;let n;try{n=new URL(e)}catch{return}if(n.protocol!==`http:`&&n.protocol!==`https:`)return;let r=n.hostname.toLowerCase().replace(/\.$/,``),a=t.toLowerCase();if(!(r===a||r.endsWith(`.${a}`)))return o(r)}var l=`#cb-trigger`,u=class extends e.t{constructor(...e){super(...e),this.locale=`nb-NO`,this.skipGlobal=!1,this.openLinksInNewTab=!1,this.includeConsent=!1,this.hotjarId=null,this.googleAnalyticsId=null,this.devMode=!1,this.cookieDomain=null,this.cookieSecure=null,this.cookieExpiryDays=null}connectedCallback(){super.connectedCallback(),!this.data&&!this.skipGlobal&&this.loadData()}disconnectedCallback(){super.disconnectedCallback(),this.abortController?.abort()}updated(e){super.updated(e),e.has(`dataUrl`)&&e.get(`dataUrl`)!==void 0&&!this.data&&this.loadData()}async loadData(){this.abortController?.abort(),this.abortController=new AbortController;try{this.fetchedData=await r.t(this.dataUrl,this.abortController.signal)}catch(e){if(e.name===`AbortError`)return;console.warn(`Failed to fetch header/footer data:`,e),this.dispatchEvent(new CustomEvent(`data-error`,{detail:{error:e},bubbles:!0,composed:!0}))}}get globalFooterData(){return r.n(this.data??this.fetchedData,this.locale)?.footer}linkTarget(e){return e.openInNewTab||this.openLinksInNewTab?{target:`_blank`,rel:`noopener noreferrer`}:{target:`_self`}}renderLinkDomain(t,n=`pkt-footer__link-domain`){if(!t.external)return e.h;let r=s(t.href);return r?e._` <span class=${n}>(${r})</span>`:e.h}renderCustomLink(n){let{target:r,rel:i}=this.linkTarget(n);return e._`
|
|
2
2
|
<a href=${n.href} target=${r} rel=${t.t(i)}
|
|
3
3
|
>${n.text}${this.renderLinkDomain(n)}</a
|
|
4
4
|
>
|
|
@@ -3,7 +3,7 @@ import { t as s } from "./if-defined-B3pYog2C.js";
|
|
|
3
3
|
import { t as c } from "./booleanish-CBa3Cr2h.js";
|
|
4
4
|
import { n as l, r as u, t as d } from "./fetch-header-footer-data-CPVt_P8s.js";
|
|
5
5
|
import "./shared-types-BvRk9kiK.js";
|
|
6
|
-
import "./consent-
|
|
6
|
+
import "./consent-DwppvYBR.js";
|
|
7
7
|
import "./icon-CZDw42U7.js";
|
|
8
8
|
// ../../shared-utils/header-footer/external-domain.ts
|
|
9
9
|
var f = "oslo.kommune.no", p = /\.(?:co|com|org|net|gov|edu|ac|kommune)\.[a-z]{2}$/i;
|
|
@@ -6,9 +6,9 @@ import { t as d } from "./booleanish-CBa3Cr2h.js";
|
|
|
6
6
|
import "./shared-types-BvRk9kiK.js";
|
|
7
7
|
import { n as f, o as p, t as m } from "./fetch-header-footer-data-CPVt_P8s.js";
|
|
8
8
|
import "./icon-CZDw42U7.js";
|
|
9
|
-
import "./
|
|
9
|
+
import "./button-CJzu0l5A.js";
|
|
10
|
+
import "./textinput-CC0zxUBT.js";
|
|
10
11
|
import { t as h } from "./if-defined-B3pYog2C.js";
|
|
11
|
-
import "./button-Bd-0TYe7.js";
|
|
12
12
|
import { n as g, t as _ } from "./ref-qE1RBrI7.js";
|
|
13
13
|
import { n as v, t as y } from "./focus-trap-C-PcFOw6.js";
|
|
14
14
|
import { n as b, t as x } from "./scroll-lock-C9jzbJ4E.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-CEarCnHH.cjs"),t=require("./class-map-C82GtM1w.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-D_8fAzCW.cjs"),i=require("./booleanish-BF8l4scU.cjs");require("./shared-types-BvRk9kiK.cjs");const a=require("./fetch-header-footer-data-CUKV0biS.cjs");require("./icon-5A378_yh.cjs"),require("./textinput-
|
|
1
|
+
const e=require("./element-CEarCnHH.cjs"),t=require("./class-map-C82GtM1w.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-D_8fAzCW.cjs"),i=require("./booleanish-BF8l4scU.cjs");require("./shared-types-BvRk9kiK.cjs");const a=require("./fetch-header-footer-data-CUKV0biS.cjs");require("./icon-5A378_yh.cjs"),require("./button-DHVRpzpS.cjs"),require("./textinput-Dooq2n8W.cjs");const o=require("./if-defined-Ci4ZQsgL.cjs"),s=require("./ref-C6VUWwmF.cjs"),c=require("./focus-trap-C9tsr-xL.cjs"),l=require("./scroll-lock-x0VxhKWZ.cjs");require("./link-lPrxhYq0.cjs"),require("./searchinput-D5l64Mkb.cjs"),require("./header-menu-BJMMwrCR.cjs");var u=e=>typeof e.target==`string`?{title:e.title,iconName:e.iconName,href:e.target}:{title:e.title,iconName:e.iconName,onClick:e.target},d=e=>u(e),f=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`})},p=class{constructor(e,t){this.isMobile=!1,this.isTablet=!1,this.isHidden=!1,this.pauseScrollHide=!1,this.componentWidth=typeof window<`u`?window.innerWidth:0,this.lastScrollPosition=0,this.scrollLockToken=l.t(),this.lastFocusedElement=null,this.shouldRestoreFocus=!1,this.initialWidthEstimated=!1,this.handleScroll=()=>{if(this.getOptions().scrollBehavior!==`hide`||this.pauseScrollHide)return;let e=window.pageYOffset||document.documentElement.scrollTop;if(e<0||Math.abs(e-this.lastScrollPosition)<60)return;let t=e>this.lastScrollPosition;this.lastScrollPosition=e,t!==this.isHidden&&(this.isHidden=t,this.host.requestUpdate())},this.host=e,this.getOptions=t,e.addController(this)}hostConnected(){window.addEventListener(`scroll`,this.handleScroll)}hostUpdate(){this.initialWidthEstimated||(this.initialWidthEstimated=!0,this.componentWidth=this.host.offsetWidth,this.applyBreakpoints())}hostDisconnected(){this.resizeObserver?.disconnect(),window.removeEventListener(`scroll`,this.handleScroll),l.n(this.scrollLockToken,!1)}observe(e){e&&(this.componentWidth=e.offsetWidth,this.refreshBreakpoints(),this.resizeObserver=new ResizeObserver(e=>{for(let t of e)this.componentWidth=t.borderBoxSize&&t.borderBoxSize.length>0?t.borderBoxSize[0].inlineSize:t.contentRect.width,this.refreshBreakpoints()}),this.resizeObserver.observe(e))}refreshBreakpoints(){this.applyBreakpoints()&&this.host.requestUpdate()}applyBreakpoints(){let{mobileBreakpoint:e,tabletBreakpoint:t}=this.getOptions(),n=this.componentWidth<e,r=this.componentWidth<t;return n===this.isMobile&&r===this.isTablet?!1:(this.isMobile=n,this.isTablet=r,!0)}setScrollLock(e){l.n(this.scrollLockToken,e)}captureFocus(){this.lastFocusedElement=document.activeElement}flagRestoreFocus(){this.shouldRestoreFocus=!0}restoreFocus(){this.shouldRestoreFocus&&this.lastFocusedElement&&document.contains(this.lastFocusedElement)&&this.lastFocusedElement.focus(),this.lastFocusedElement=null,this.shouldRestoreFocus=!1}},m=class extends e.t{constructor(...e){super(...e),this.canChangeRepresentation=!1,this.logoutOnClick=!1}handleChangeRepresentation(){this.dispatchEvent(new CustomEvent(`change-representation`,{bubbles:!0,composed:!0}))}handleLogout(){this.dispatchEvent(new CustomEvent(`log-out`,{bubbles:!0,composed:!0}))}handleMenuItemClick(e){`onClick`in e&&typeof e.onClick==`function`&&e.onClick()}renderLinkOrButton(n,r){let i=`href`in n,a=t.t({"pkt-user-menu__link":!0,"pkt-link-button":!i,"pkt-link":!i,"pkt-link--icon-left":!i,[r||``]:!!r});return i?e._`
|
|
2
2
|
<pkt-link
|
|
3
3
|
iconName=${n.iconName||e.h}
|
|
4
4
|
href=${n.href}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-CEarCnHH.cjs"),t=require("./format-B8meU8Tm.cjs"),n=require("./element-with-slot-D_8fAzCW.cjs"),r=require("./booleanish-BF8l4scU.cjs");require("./shared-types-BvRk9kiK.cjs"),require("./alert-
|
|
1
|
+
const e=require("./element-CEarCnHH.cjs"),t=require("./format-B8meU8Tm.cjs"),n=require("./element-with-slot-D_8fAzCW.cjs"),r=require("./booleanish-BF8l4scU.cjs");require("./shared-types-BvRk9kiK.cjs"),require("./alert-0a5lX0pL.cjs");const i=require("./icon-5A378_yh.cjs"),a=require("./if-defined-Ci4ZQsgL.cjs"),o=require("./utils-63cRpWut.cjs");require("./helptext-CQaNvbiv.cjs");const s=require("./focus-modality-controller-C1ocyv2J.cjs");var c={counter:!1,counterCurrent:0,counterPosition:`bottom`,optionalTag:!1,requiredTag:!1,hasError:!1,disabled:!1,inline:!1,hasFieldset:!1,layout:`vertical`,useWrapper:!0,size:`medium`},l=e=>{let t=[];return e.hasHelptext&&t.push(`${e.id}-helptext`),e.hasCounter&&t.push(`${e.id}-counter-status`),e.ariaDescribedby&&t.push(e.ariaDescribedby),t.length?t.join(` `):void 0},u=e=>`${e}-counter-status`,d=(e,t)=>!!t&&t>0&&(e??0)>t,f=class extends n.t{constructor(...e){super(...e),this.forId=o.n(),this.label=``,this.helptext=null,this.helptextDropdown=null,this.helptextDropdownButton=null,this.counter=c.counter,this.counterCurrent=c.counterCurrent,this.counterMaxLength=0,this.counterError=null,this.counterPosition=c.counterPosition,this.optionalTag=c.optionalTag,this.requiredTag=c.requiredTag,this.tagText=null,this.hasError=c.hasError,this.errorMessage=``,this.disabled=c.disabled,this.inline=c.inline,this.ariaDescribedby=void 0,this.hasFieldset=c.hasFieldset,this.layout=c.layout,this.role=null,this.useWrapper=c.useWrapper,this.size=c.size,this.focusModality=new s.t(this)}updated(e){super.updated(e),this.classList.add(`pkt-inputwrapper`),this.classList.toggle(`pkt-inputwrapper--error`,this.hasError),this.classList.toggle(`pkt-inputwrapper--disabled`,this.disabled),this.classList.toggle(`pkt-inputwrapper--inline`,this.inline),this.classList.toggle(`pkt-inputwrapper--medium`,this.size===`medium`),this.classList.toggle(`pkt-inputwrapper--small`,this.size===`small`),this.classList.toggle(`pkt-inputwrapper--xsmall`,this.size===`xsmall`),this.role?this.setAttribute(`aria-labelledby`,`${this.forId}-label`):this.removeAttribute(`aria-labelledby`)}render(){let r=`pkt-tag pkt-tag--small pkt-tag--thin-text`,o=!!this.helptext||this.hasSlotContent(`helptext`),s=new Set([this.ariaDescribedby||(o?`${this.forId}-helptext`:``),this.hasError&&this.errorMessage?`${this.forId}-error`:``].join(` `).split(` `).filter(Boolean)),c=s.size?[...s].join(` `):e.h,l=this.pktStrings.get(`forms`),f=()=>e._`
|
|
2
2
|
${this.tagText?e._`<span class=${r+` pkt-tag--gray`}>${this.tagText}</span>`:e.h}
|
|
3
3
|
${this.optionalTag?e._`<span class=${r+` pkt-tag--blue-pale`}
|
|
4
4
|
>${this.optionalText??l.optional}</span
|