@oslokommune/punkt-elements 18.6.0 → 18.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/dist/card-CsSNvjZV.cjs +64 -0
- package/dist/card-PXDm9JXv.js +182 -0
- package/dist/{checkbox-D6j7amKX.cjs → checkbox-CMu4pF8-.cjs} +1 -1
- package/dist/{checkbox-DcvKYDU2.js → checkbox-DReZOEy2.js} +1 -1
- package/dist/{combobox-BT1LB0gl.cjs → combobox-BZm_12qR.cjs} +1 -1
- package/dist/{combobox-CiT2YvLb.js → combobox-DcBFiuwP.js} +2 -2
- package/dist/components/datepicker/datepicker-base.d.ts +4 -0
- package/dist/components/datepicker/datepicker.d.ts +3 -1
- package/dist/{datepicker-CqWg6K2N.js → datepicker-DboWQcrh.js} +58 -29
- package/dist/{datepicker-DIgQrvbZ.cjs → datepicker-NSWMVoGi.cjs} +22 -5
- package/dist/{fileupload-BmT5nQX0.cjs → fileupload-BYVtnSaI.cjs} +1 -1
- package/dist/{fileupload-4nTdjPKw.js → fileupload-CqxWUH0y.js} +1 -1
- package/dist/{header-DU10rGhU.js → header-DsaPCLjJ.js} +1 -1
- package/dist/{header-DybJSDQQ.cjs → header-DzVHM7gZ.cjs} +1 -1
- package/dist/{input-element-zXKo9jpe.js → input-element-BiUfK_gU.js} +8 -8
- package/dist/{input-element-uajHIWAO.cjs → input-element-kvI_5er5.cjs} +1 -1
- package/dist/{input-wrapper-B4TCGGwj.js → input-wrapper-Bwh720ke.js} +4 -4
- package/dist/{input-wrapper-791L3L--.cjs → input-wrapper-wyvCnWPp.cjs} +2 -2
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +1 -1
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-fileupload.cjs +1 -1
- package/dist/pkt-fileupload.js +1 -1
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +14 -14
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +1 -1
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +1 -1
- package/dist/pkt-timepicker.cjs +1 -1
- package/dist/pkt-timepicker.js +1 -1
- package/dist/{radiobutton-BuOLykKo.cjs → radiobutton-B6pzZQZV.cjs} +1 -1
- package/dist/{radiobutton-Dr5OQ0IY.js → radiobutton-bGdAEz26.js} +1 -1
- package/dist/{select-Cd_saUE7.js → select-D7r2s7Cw.js} +2 -2
- package/dist/{select-Cc7c9dRd.cjs → select-ay8WHI7p.cjs} +1 -1
- package/dist/shared-types/card.d.ts +86 -0
- package/dist/shared-types/index.d.ts +4 -1
- package/dist/shared-types/layout.d.ts +2 -1
- package/dist/shared-types/skin.d.ts +1 -4
- package/dist/{textarea-MJvpE_yV.js → textarea-CzAL8e6L.js} +2 -2
- package/dist/{textarea-xTcafucE.cjs → textarea-s4IDLsBi.cjs} +1 -1
- package/dist/{textinput-B4VnZzsa.cjs → textinput-B9w4jhIP.cjs} +1 -1
- package/dist/{textinput-Cr7Z9ilH.js → textinput-DT3HR9eU.js} +2 -2
- package/dist/{timepicker-srjt12dI.js → timepicker-BE0UouVr.js} +2 -2
- package/dist/{timepicker-85ViMBd6.cjs → timepicker-C-Ip5Jgl.cjs} +1 -1
- package/package.json +2 -2
- package/src/components/card/card.ts +19 -16
- package/src/components/datepicker/datepicker-base.ts +14 -0
- package/src/components/datepicker/datepicker-multiple.ts +3 -0
- package/src/components/datepicker/datepicker-range.ts +6 -0
- package/src/components/datepicker/datepicker-single.ts +3 -1
- package/src/components/datepicker/datepicker.accessibility.test.ts +24 -3
- package/src/components/datepicker/datepicker.ts +63 -63
- package/dist/card-CwvUQj1a.js +0 -360
- package/dist/card-b7jjKk6B.cjs +0 -64
|
@@ -9,8 +9,8 @@ import "./calendar-CBghTpkZ.js";
|
|
|
9
9
|
import "./tag-D2Xvsy1i.js";
|
|
10
10
|
import { t as C } from "./repeat-CCnTfedv.js";
|
|
11
11
|
import { n as w, t as T } from "./utils-BwF4QSrq.js";
|
|
12
|
-
import { t as E } from "./input-element-
|
|
13
|
-
import "./input-wrapper-
|
|
12
|
+
import { t as E } from "./input-element-BiUfK_gU.js";
|
|
13
|
+
import "./input-wrapper-Bwh720ke.js";
|
|
14
14
|
//#region src/components/datepicker/date-tags.ts
|
|
15
15
|
var D = class extends o {
|
|
16
16
|
constructor(...e) {
|
|
@@ -529,7 +529,13 @@ try {
|
|
|
529
529
|
//#region src/components/datepicker/datepicker-base.ts
|
|
530
530
|
var Y = class extends o {
|
|
531
531
|
constructor(...e) {
|
|
532
|
-
super(...e), this.inputType = "date", this.id = "", this.readonly = !1, this.disabled = !1, this.inputClasses = {}, this.inputSize = "medium", this.inputRef = d(), this.btnRef = d();
|
|
532
|
+
super(...e), this.inputType = "date", this.id = "", this.readonly = !1, this.disabled = !1, this.inputClasses = {}, this.inputSize = "medium", this.hasError = !1, this.hasHelptext = !1, this.inputRef = d(), this.btnRef = d();
|
|
533
|
+
}
|
|
534
|
+
get describedBy() {
|
|
535
|
+
return this.hasHelptext ? `${this.id}-input-helptext` : void 0;
|
|
536
|
+
}
|
|
537
|
+
get errorMessageId() {
|
|
538
|
+
return this.hasError ? `${this.id}-input-error` : void 0;
|
|
533
539
|
}
|
|
534
540
|
get inputElement() {
|
|
535
541
|
return this.inputRef.value;
|
|
@@ -596,7 +602,7 @@ var Y = class extends o {
|
|
|
596
602
|
return this;
|
|
597
603
|
}
|
|
598
604
|
};
|
|
599
|
-
i([s({ type: String })], Y.prototype, "inputType", void 0), i([s({ type: String })], Y.prototype, "id", void 0), i([s({ type: String })], Y.prototype, "min", void 0), i([s({ type: String })], Y.prototype, "max", void 0), i([s({ type: String })], Y.prototype, "placeholder", void 0), i([s({ type: Boolean })], Y.prototype, "readonly", void 0), i([s({ type: Boolean })], Y.prototype, "disabled", void 0), i([s({ type: Object })], Y.prototype, "inputClasses", void 0), i([s({ type: String })], Y.prototype, "inputSize", void 0), i([s({ type: Object })], Y.prototype, "internals", void 0);
|
|
605
|
+
i([s({ type: String })], Y.prototype, "inputType", void 0), i([s({ type: String })], Y.prototype, "id", void 0), i([s({ type: String })], Y.prototype, "min", void 0), i([s({ type: String })], Y.prototype, "max", void 0), i([s({ type: String })], Y.prototype, "placeholder", void 0), i([s({ type: Boolean })], Y.prototype, "readonly", void 0), i([s({ type: Boolean })], Y.prototype, "disabled", void 0), i([s({ type: Object })], Y.prototype, "inputClasses", void 0), i([s({ type: String })], Y.prototype, "inputSize", void 0), i([s({ type: Object })], Y.prototype, "internals", void 0), i([s({ type: Boolean })], Y.prototype, "hasError", void 0), i([s({ type: Boolean })], Y.prototype, "hasHelptext", void 0);
|
|
600
606
|
//#endregion
|
|
601
607
|
//#region src/components/datepicker/datepicker-single.ts
|
|
602
608
|
var X = class extends Y {
|
|
@@ -622,7 +628,9 @@ var X = class extends Y {
|
|
|
622
628
|
max=${l(this.max)}
|
|
623
629
|
placeholder=${l(this.placeholder)}
|
|
624
630
|
?readonly=${this.isInputReadonly}
|
|
625
|
-
aria-describedby
|
|
631
|
+
aria-describedby=${l(this.describedBy)}
|
|
632
|
+
aria-invalid=${this.hasError}
|
|
633
|
+
aria-errormessage=${l(this.errorMessageId)}
|
|
626
634
|
@click=${(e) => {
|
|
627
635
|
e.preventDefault(), this.dispatchToggleCalendar(e);
|
|
628
636
|
}}
|
|
@@ -675,6 +683,9 @@ var Z = class extends Y {
|
|
|
675
683
|
<div class="pkt-input__container">
|
|
676
684
|
${this.showRangeLabels ? e` <div class="pkt-input-prefix">${this.pktStrings.get("generic").from}</div> ` : n}
|
|
677
685
|
<input
|
|
686
|
+
aria-describedby=${l(this.describedBy)}
|
|
687
|
+
aria-invalid=${this.hasError}
|
|
688
|
+
aria-errormessage=${l(this.errorMessageId)}
|
|
678
689
|
class=${c(this.inputClasses)}
|
|
679
690
|
.type=${this.inputType}
|
|
680
691
|
id="${this.id}-input"
|
|
@@ -719,6 +730,9 @@ var Z = class extends Y {
|
|
|
719
730
|
</div>
|
|
720
731
|
${this.showRangeLabels ? n : e` <div class="pkt-input-separator">–</div> `}
|
|
721
732
|
<input
|
|
733
|
+
aria-describedby=${l(this.describedBy)}
|
|
734
|
+
aria-invalid=${this.hasError}
|
|
735
|
+
aria-errormessage=${l(this.errorMessageId)}
|
|
722
736
|
class=${c(this.inputClasses)}
|
|
723
737
|
.type=${this.inputType}
|
|
724
738
|
id="${this.id}-to"
|
|
@@ -789,6 +803,9 @@ var Q = class extends Y {
|
|
|
789
803
|
return e`
|
|
790
804
|
<div class="pkt-input__container">
|
|
791
805
|
<input
|
|
806
|
+
aria-describedby=${l(this.describedBy)}
|
|
807
|
+
aria-invalid=${this.hasError}
|
|
808
|
+
aria-errormessage=${l(this.errorMessageId)}
|
|
792
809
|
class=${c(this.inputClasses)}
|
|
793
810
|
.type=${this.inputType}
|
|
794
811
|
id="${this.id}-input"
|
|
@@ -831,9 +848,9 @@ try {
|
|
|
831
848
|
}
|
|
832
849
|
//#endregion
|
|
833
850
|
//#region src/components/datepicker/datepicker.ts
|
|
834
|
-
var $ = class extends E {
|
|
851
|
+
var $ = class t extends E {
|
|
835
852
|
constructor(...e) {
|
|
836
|
-
super(...e), this._valueProperty = "", this.
|
|
853
|
+
super(...e), this._valueProperty = "", this.datepickerPopupRef = d(), this._value = [], this.label = "Datovelger", this.dateformat = O.props.dateformat.default, this.multiple = O.props.multiple.default, this.maxlength = null, this.range = O.props.range.default, this.showRangeLabels = !1, this.min = null, this.max = null, this.weeknumbers = O.props.weeknumbers.default, this.withcontrols = O.props.withcontrols.default, this.excludedates = [], this.excludeweekdays = [], this.currentmonth = null, this.today = null, this.calendarOpen = !1, this.timezone = "Europe/Oslo", this.inputClasses = {}, this.calRef = d(), this.popupRef = d(), this.singleInputRef = d(), this.rangeInputRef = d(), this.multipleInputRef = d(), this.addToSelected = (e) => {
|
|
837
854
|
let t = this.datepickerPopupRef.value;
|
|
838
855
|
return t && typeof t.addToSelected == "function" ? t.addToSelected(e, this.min, this.max) : W.addToSelected(e, this.calRef, this.min, this.max);
|
|
839
856
|
};
|
|
@@ -842,8 +859,8 @@ var $ = class extends E {
|
|
|
842
859
|
return this._valueProperty;
|
|
843
860
|
}
|
|
844
861
|
set value(e) {
|
|
845
|
-
let t = this._valueProperty;
|
|
846
|
-
|
|
862
|
+
let t = this._valueProperty, n = Array.isArray(e) ? e.join(",") : e || "";
|
|
863
|
+
n !== t && (this._valueProperty = n, this.requestUpdate("value", t));
|
|
847
864
|
}
|
|
848
865
|
get inputType() {
|
|
849
866
|
return H.getInputType();
|
|
@@ -858,32 +875,38 @@ var $ = class extends E {
|
|
|
858
875
|
this.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
859
876
|
}
|
|
860
877
|
valueChanged(e, t) {
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
}
|
|
869
|
-
this._value = r;
|
|
870
|
-
let i = v(r);
|
|
871
|
-
if (this._valueProperty !== i && (this._valueProperty = i), this.range && r.length < 2) return;
|
|
872
|
-
super.valueChanged(i, t);
|
|
873
|
-
} finally {
|
|
874
|
-
this._valueProcessing = !1;
|
|
875
|
-
}
|
|
878
|
+
e !== t && (this.value = e ?? "", this.deriveValue(t));
|
|
879
|
+
}
|
|
880
|
+
deriveValue(e) {
|
|
881
|
+
let t = y(this._valueProperty), n = this.multiple && t.length > 1 ? V.filterSelectableDates(t, this.min, this.max, this.excludedates, this.excludeweekdays) : t;
|
|
882
|
+
if (this.range && !V.validateRangeOrder(n)) {
|
|
883
|
+
this._valueProperty = "", super.valueChanged("", e), this._value = [];
|
|
884
|
+
return;
|
|
876
885
|
}
|
|
886
|
+
this._valueProperty = v(n), this.range && n.length === 1 || super.valueChanged(this._valueProperty, e), this._value = n;
|
|
877
887
|
}
|
|
878
888
|
attributeChangedCallback(e, t, n) {
|
|
879
889
|
e === "excludedates" && typeof this.excludedates == "string" && (this.excludedates = y(n || "")), e === "excludeweekdays" && typeof this.excludeweekdays == "string" && (this.excludeweekdays = y(n || "")), super.attributeChangedCallback(e, t, n);
|
|
880
890
|
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
891
|
+
static {
|
|
892
|
+
this.DERIVED_FROM = [
|
|
893
|
+
"value",
|
|
894
|
+
"multiple",
|
|
895
|
+
"range",
|
|
896
|
+
"min",
|
|
897
|
+
"max",
|
|
898
|
+
"excludedates",
|
|
899
|
+
"excludeweekdays"
|
|
900
|
+
];
|
|
901
|
+
}
|
|
902
|
+
willUpdate(e) {
|
|
903
|
+
if (super.willUpdate(e), t.DERIVED_FROM.some((t) => e.has(t))) {
|
|
904
|
+
let t = e.get("value");
|
|
905
|
+
this.deriveValue(Array.isArray(t) ? t.join(",") : t ?? null);
|
|
885
906
|
}
|
|
886
|
-
|
|
907
|
+
}
|
|
908
|
+
updated(e) {
|
|
909
|
+
this.classList.add("pkt-datepicker"), this.classList.toggle("pkt-datepicker--fullwidth", this.fullwidth), this.classList.toggle("pkt-datepicker--medium", this.inputSize === "medium"), this.classList.toggle("pkt-datepicker--small", this.inputSize === "small"), this.classList.toggle("pkt-datepicker--xsmall", this.inputSize === "xsmall"), super.updated(e);
|
|
887
910
|
}
|
|
888
911
|
get inputRef() {
|
|
889
912
|
return { value: this.currentInputElement };
|
|
@@ -917,6 +940,8 @@ var $ = class extends E {
|
|
|
917
940
|
.inputClasses=${this.inputClasses}
|
|
918
941
|
.inputSize=${this.inputSize}
|
|
919
942
|
.internals=${this.internals}
|
|
943
|
+
.hasError=${this.hasError}
|
|
944
|
+
.hasHelptext=${!!(this.helptext || this.helptextDropdown)}
|
|
920
945
|
.strings=${this.strings}
|
|
921
946
|
@toggle-calendar=${(e) => this.toggleCalendar(e.detail)}
|
|
922
947
|
@input-change=${() => this.onInput()}
|
|
@@ -951,6 +976,8 @@ var $ = class extends E {
|
|
|
951
976
|
.inputClasses=${this.inputClasses}
|
|
952
977
|
.inputSize=${this.inputSize}
|
|
953
978
|
.internals=${this.internals}
|
|
979
|
+
.hasError=${this.hasError}
|
|
980
|
+
.hasHelptext=${!!(this.helptext || this.helptextDropdown)}
|
|
954
981
|
.strings=${this.strings}
|
|
955
982
|
@toggle-calendar=${(e) => this.toggleCalendar(e.detail)}
|
|
956
983
|
@input-change=${() => this.onInput()}
|
|
@@ -1003,6 +1030,8 @@ var $ = class extends E {
|
|
|
1003
1030
|
.inputClasses=${this.inputClasses}
|
|
1004
1031
|
.inputSize=${this.inputSize}
|
|
1005
1032
|
.internals=${this.internals}
|
|
1033
|
+
.hasError=${this.hasError}
|
|
1034
|
+
.hasHelptext=${!!(this.helptext || this.helptextDropdown)}
|
|
1006
1035
|
.strings=${this.strings}
|
|
1007
1036
|
@toggle-calendar=${(e) => this.toggleCalendar(e.detail)}
|
|
1008
1037
|
@input-change=${() => this.onInput()}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./if-defined-BeVQnl3C.cjs"),r=require("./element-with-slot-DgtT8lCH.cjs");require("./icon-DBFTFd-J.cjs");const i=require("./ref-BkV4Cd8U.cjs"),a=require("./converters-BJ9Fe0kW.cjs");require("./calendar-CA1mz04B.cjs"),require("./tag-Cojf4jgA.cjs");const o=require("./repeat-uBgVG8Ch.cjs"),s=require("./utils-63cRpWut.cjs"),c=require("./input-element-
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./if-defined-BeVQnl3C.cjs"),r=require("./element-with-slot-DgtT8lCH.cjs");require("./icon-DBFTFd-J.cjs");const i=require("./ref-BkV4Cd8U.cjs"),a=require("./converters-BJ9Fe0kW.cjs");require("./calendar-CA1mz04B.cjs"),require("./tag-Cojf4jgA.cjs");const o=require("./repeat-uBgVG8Ch.cjs"),s=require("./utils-63cRpWut.cjs"),c=require("./input-element-kvI_5er5.cjs");require("./input-wrapper-wyvCnWPp.cjs");var l=class extends e.t{constructor(...e){super(...e),this.dates=[],this.dateformat=`dd.MM.yyyy`,this.className=`pkt-datepicker__tags`,this.idBase=s.n()}render(){return this.classes={"pkt-date-tags":!0,[this.className]:!0},e._`
|
|
2
2
|
<div class=${t.t(this.classes)} aria-live="polite">
|
|
3
3
|
${Array.isArray(this.dates)&&this.dates[0]?o.t(a.h((this.dates??[]).filter(Boolean)),e=>e,t=>e._` <pkt-tag
|
|
4
4
|
id=${this.idBase+t+`-tag`}
|
|
@@ -35,7 +35,7 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
35
35
|
@close=${()=>{this.hide(),this.dispatchEvent(new CustomEvent(`close`,{bubbles:!0,composed:!0}))}}
|
|
36
36
|
></pkt-calendar>`:e.h}
|
|
37
37
|
</div>
|
|
38
|
-
`}};e.n([e.u({type:Boolean,reflect:!0})],A.prototype,`open`,void 0),e.n([e.u({type:Boolean})],A.prototype,`multiple`,void 0),e.n([e.u({type:Boolean})],A.prototype,`range`,void 0),e.n([e.u({type:Boolean})],A.prototype,`weeknumbers`,void 0),e.n([e.u({type:Boolean})],A.prototype,`withcontrols`,void 0),e.n([e.u({type:Number})],A.prototype,`maxMultiple`,void 0),e.n([e.u({type:Array})],A.prototype,`selected`,void 0),e.n([e.u({type:String})],A.prototype,`earliest`,void 0),e.n([e.u({type:String})],A.prototype,`latest`,void 0),e.n([e.u({type:Array})],A.prototype,`excludedates`,void 0),e.n([e.u({type:Array})],A.prototype,`excludeweekdays`,void 0),e.n([e.u({type:String})],A.prototype,`currentmonth`,void 0),e.n([e.u({type:String})],A.prototype,`today`,void 0),e.n([e.l()],A.prototype,`_hasBeenOpened`,void 0);try{e.d(`pkt-datepicker-popup`)(A)}catch{console.warn(`Forsøker å definere <pkt-datepicker-popup>, men den er allerede definert`)}var j=class extends e.t{constructor(...e){super(...e),this.inputType=`date`,this.id=``,this.readonly=!1,this.disabled=!1,this.inputClasses={},this.inputSize=`medium`,this.inputRef=i.t(),this.btnRef=i.t()}get inputElement(){return this.inputRef.value}get buttonElement(){return this.btnRef.value}get isInputReadonly(){return this.readonly||this.inputType===`text`}dispatchToggleCalendar(e){this.readonly||this.dispatchEvent(new CustomEvent(`toggle-calendar`,{detail:e,bubbles:!0,composed:!0}))}dispatchInput(e){this.dispatchEvent(new CustomEvent(`input-change`,{detail:e,bubbles:!0,composed:!0}))}dispatchFocus(){this.dispatchEvent(new CustomEvent(`input-focus`,{bubbles:!0,composed:!0}))}dispatchBlur(e){this.dispatchEvent(new CustomEvent(`input-blur`,{detail:e,bubbles:!0,composed:!0}))}dispatchChange(e){this.dispatchEvent(new CustomEvent(`input-changed`,{detail:e,bubbles:!0,composed:!0}))}renderCalendarButton(){return e._`
|
|
38
|
+
`}};e.n([e.u({type:Boolean,reflect:!0})],A.prototype,`open`,void 0),e.n([e.u({type:Boolean})],A.prototype,`multiple`,void 0),e.n([e.u({type:Boolean})],A.prototype,`range`,void 0),e.n([e.u({type:Boolean})],A.prototype,`weeknumbers`,void 0),e.n([e.u({type:Boolean})],A.prototype,`withcontrols`,void 0),e.n([e.u({type:Number})],A.prototype,`maxMultiple`,void 0),e.n([e.u({type:Array})],A.prototype,`selected`,void 0),e.n([e.u({type:String})],A.prototype,`earliest`,void 0),e.n([e.u({type:String})],A.prototype,`latest`,void 0),e.n([e.u({type:Array})],A.prototype,`excludedates`,void 0),e.n([e.u({type:Array})],A.prototype,`excludeweekdays`,void 0),e.n([e.u({type:String})],A.prototype,`currentmonth`,void 0),e.n([e.u({type:String})],A.prototype,`today`,void 0),e.n([e.l()],A.prototype,`_hasBeenOpened`,void 0);try{e.d(`pkt-datepicker-popup`)(A)}catch{console.warn(`Forsøker å definere <pkt-datepicker-popup>, men den er allerede definert`)}var j=class extends e.t{constructor(...e){super(...e),this.inputType=`date`,this.id=``,this.readonly=!1,this.disabled=!1,this.inputClasses={},this.inputSize=`medium`,this.hasError=!1,this.hasHelptext=!1,this.inputRef=i.t(),this.btnRef=i.t()}get describedBy(){return this.hasHelptext?`${this.id}-input-helptext`:void 0}get errorMessageId(){return this.hasError?`${this.id}-input-error`:void 0}get inputElement(){return this.inputRef.value}get buttonElement(){return this.btnRef.value}get isInputReadonly(){return this.readonly||this.inputType===`text`}dispatchToggleCalendar(e){this.readonly||this.dispatchEvent(new CustomEvent(`toggle-calendar`,{detail:e,bubbles:!0,composed:!0}))}dispatchInput(e){this.dispatchEvent(new CustomEvent(`input-change`,{detail:e,bubbles:!0,composed:!0}))}dispatchFocus(){this.dispatchEvent(new CustomEvent(`input-focus`,{bubbles:!0,composed:!0}))}dispatchBlur(e){this.dispatchEvent(new CustomEvent(`input-blur`,{detail:e,bubbles:!0,composed:!0}))}dispatchChange(e){this.dispatchEvent(new CustomEvent(`input-changed`,{detail:e,bubbles:!0,composed:!0}))}renderCalendarButton(){return e._`
|
|
39
39
|
<button
|
|
40
40
|
class="${t.t(D.getButtonClasses(this.inputSize))}"
|
|
41
41
|
type="button"
|
|
@@ -47,7 +47,7 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
47
47
|
<pkt-icon name="calendar"></pkt-icon>
|
|
48
48
|
<span class="pkt-btn__text">${this.pktStrings.get(`datepicker`).openPicker}</span>
|
|
49
49
|
</button>
|
|
50
|
-
`}createRenderRoot(){return this}};e.n([e.u({type:String})],j.prototype,`inputType`,void 0),e.n([e.u({type:String})],j.prototype,`id`,void 0),e.n([e.u({type:String})],j.prototype,`min`,void 0),e.n([e.u({type:String})],j.prototype,`max`,void 0),e.n([e.u({type:String})],j.prototype,`placeholder`,void 0),e.n([e.u({type:Boolean})],j.prototype,`readonly`,void 0),e.n([e.u({type:Boolean})],j.prototype,`disabled`,void 0),e.n([e.u({type:Object})],j.prototype,`inputClasses`,void 0),e.n([e.u({type:String})],j.prototype,`inputSize`,void 0),e.n([e.u({type:Object})],j.prototype,`internals`,void 0);var M=class extends j{constructor(...e){super(...e),this.value=``}dispatchManageValidity(e){this.dispatchEvent(new CustomEvent(`manage-validity`,{detail:e,bubbles:!0,composed:!0}))}render(){return e._`
|
|
50
|
+
`}createRenderRoot(){return this}};e.n([e.u({type:String})],j.prototype,`inputType`,void 0),e.n([e.u({type:String})],j.prototype,`id`,void 0),e.n([e.u({type:String})],j.prototype,`min`,void 0),e.n([e.u({type:String})],j.prototype,`max`,void 0),e.n([e.u({type:String})],j.prototype,`placeholder`,void 0),e.n([e.u({type:Boolean})],j.prototype,`readonly`,void 0),e.n([e.u({type:Boolean})],j.prototype,`disabled`,void 0),e.n([e.u({type:Object})],j.prototype,`inputClasses`,void 0),e.n([e.u({type:String})],j.prototype,`inputSize`,void 0),e.n([e.u({type:Object})],j.prototype,`internals`,void 0),e.n([e.u({type:Boolean})],j.prototype,`hasError`,void 0),e.n([e.u({type:Boolean})],j.prototype,`hasHelptext`,void 0);var M=class extends j{constructor(...e){super(...e),this.value=``}dispatchManageValidity(e){this.dispatchEvent(new CustomEvent(`manage-validity`,{detail:e,bubbles:!0,composed:!0}))}render(){return e._`
|
|
51
51
|
<div class="pkt-input__container">
|
|
52
52
|
<input
|
|
53
53
|
class="${t.t(this.inputClasses)}"
|
|
@@ -58,7 +58,9 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
58
58
|
max=${n.t(this.max)}
|
|
59
59
|
placeholder=${n.t(this.placeholder)}
|
|
60
60
|
?readonly=${this.isInputReadonly}
|
|
61
|
-
aria-describedby
|
|
61
|
+
aria-describedby=${n.t(this.describedBy)}
|
|
62
|
+
aria-invalid=${this.hasError}
|
|
63
|
+
aria-errormessage=${n.t(this.errorMessageId)}
|
|
62
64
|
@click=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
|
|
63
65
|
@touchend=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
|
|
64
66
|
?disabled=${this.disabled}
|
|
@@ -75,6 +77,9 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
75
77
|
<div class="pkt-input__container">
|
|
76
78
|
${this.showRangeLabels?e._` <div class="pkt-input-prefix">${this.pktStrings.get(`generic`).from}</div> `:e.h}
|
|
77
79
|
<input
|
|
80
|
+
aria-describedby=${n.t(this.describedBy)}
|
|
81
|
+
aria-invalid=${this.hasError}
|
|
82
|
+
aria-errormessage=${n.t(this.errorMessageId)}
|
|
78
83
|
class=${t.t(this.inputClasses)}
|
|
79
84
|
.type=${this.inputType}
|
|
80
85
|
id="${this.id}-input"
|
|
@@ -99,6 +104,9 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
99
104
|
</div>
|
|
100
105
|
${this.showRangeLabels?e.h:e._` <div class="pkt-input-separator">–</div> `}
|
|
101
106
|
<input
|
|
107
|
+
aria-describedby=${n.t(this.describedBy)}
|
|
108
|
+
aria-invalid=${this.hasError}
|
|
109
|
+
aria-errormessage=${n.t(this.errorMessageId)}
|
|
102
110
|
class=${t.t(this.inputClasses)}
|
|
103
111
|
.type=${this.inputType}
|
|
104
112
|
id="${this.id}-to"
|
|
@@ -123,6 +131,9 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
123
131
|
`}};e.n([e.u({type:Array})],N.prototype,`value`,void 0),e.n([e.u({type:String})],N.prototype,`label`,void 0),e.n([e.u({type:Boolean})],N.prototype,`showRangeLabels`,void 0);try{e.d(`pkt-datepicker-range`)(N)}catch{console.warn(`Forsøker å definere <pkt-datepicker-range>, men den er allerede definert`)}var P=class extends j{constructor(...e){super(...e),this.value=[]}get isInputDisabled(){return this.disabled||this.maxlength!==void 0&&this.maxlength!==null&&this.value.length>=this.maxlength}dispatchAddToSelected(e){this.dispatchEvent(new CustomEvent(`add-to-selected`,{detail:e,bubbles:!0,composed:!0}))}render(){return e._`
|
|
124
132
|
<div class="pkt-input__container">
|
|
125
133
|
<input
|
|
134
|
+
aria-describedby=${n.t(this.describedBy)}
|
|
135
|
+
aria-invalid=${this.hasError}
|
|
136
|
+
aria-errormessage=${n.t(this.errorMessageId)}
|
|
126
137
|
class=${t.t(this.inputClasses)}
|
|
127
138
|
.type=${this.inputType}
|
|
128
139
|
id="${this.id}-input"
|
|
@@ -142,7 +153,7 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
142
153
|
/>
|
|
143
154
|
${this.renderCalendarButton()}
|
|
144
155
|
</div>
|
|
145
|
-
`}};e.n([e.u({type:Array})],P.prototype,`value`,void 0),e.n([e.u({type:Number})],P.prototype,`maxlength`,void 0);try{e.d(`pkt-datepicker-multiple`)(P)}catch{console.warn(`Forsøker å definere <pkt-datepicker-multiple>, men den er allerede definert`)}var F=class extends c.t{constructor(...e){super(...e),this._valueProperty=``,this.
|
|
156
|
+
`}};e.n([e.u({type:Array})],P.prototype,`value`,void 0),e.n([e.u({type:Number})],P.prototype,`maxlength`,void 0);try{e.d(`pkt-datepicker-multiple`)(P)}catch{console.warn(`Forsøker å definere <pkt-datepicker-multiple>, men den er allerede definert`)}var F=class t extends c.t{constructor(...e){super(...e),this._valueProperty=``,this.datepickerPopupRef=i.t(),this._value=[],this.label=`Datovelger`,this.dateformat=u.props.dateformat.default,this.multiple=u.props.multiple.default,this.maxlength=null,this.range=u.props.range.default,this.showRangeLabels=!1,this.min=null,this.max=null,this.weeknumbers=u.props.weeknumbers.default,this.withcontrols=u.props.withcontrols.default,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.today=null,this.calendarOpen=!1,this.timezone=`Europe/Oslo`,this.inputClasses={},this.calRef=i.t(),this.popupRef=i.t(),this.singleInputRef=i.t(),this.rangeInputRef=i.t(),this.multipleInputRef=i.t(),this.addToSelected=e=>{let t=this.datepickerPopupRef.value;return t&&typeof t.addToSelected==`function`?t.addToSelected(e,this.min,this.max):E.addToSelected(e,this.calRef,this.min,this.max)}}get value(){return this._valueProperty}set value(e){let t=this._valueProperty,n=Array.isArray(e)?e.join(`,`):e||``;n!==t&&(this._valueProperty=n,this.requestUpdate(`value`,t))}get inputType(){return w.getInputType()}connectedCallback(){super.connectedCallback(),this.timezone&&this.timezone!==window.pktTz&&(window.pktTz=this.timezone)}disconnectedCallback(){super.disconnectedCallback()}onInput(){this.dispatchEvent(new Event(`input`,{bubbles:!0}))}valueChanged(e,t){e!==t&&(this.value=e??``,this.deriveValue(t))}deriveValue(e){let t=a.r(this._valueProperty),n=this.multiple&&t.length>1?C.filterSelectableDates(t,this.min,this.max,this.excludedates,this.excludeweekdays):t;if(this.range&&!C.validateRangeOrder(n)){this._valueProperty=``,super.valueChanged(``,e),this._value=[];return}this._valueProperty=a.n(n),this.range&&n.length===1||super.valueChanged(this._valueProperty,e),this._value=n}attributeChangedCallback(e,t,n){e===`excludedates`&&typeof this.excludedates==`string`&&(this.excludedates=a.r(n||``)),e===`excludeweekdays`&&typeof this.excludeweekdays==`string`&&(this.excludeweekdays=a.r(n||``)),super.attributeChangedCallback(e,t,n)}static{this.DERIVED_FROM=[`value`,`multiple`,`range`,`min`,`max`,`excludedates`,`excludeweekdays`]}willUpdate(e){if(super.willUpdate(e),t.DERIVED_FROM.some(t=>e.has(t))){let t=e.get(`value`);this.deriveValue(Array.isArray(t)?t.join(`,`):t??null)}}updated(e){this.classList.add(`pkt-datepicker`),this.classList.toggle(`pkt-datepicker--fullwidth`,this.fullwidth),this.classList.toggle(`pkt-datepicker--medium`,this.inputSize===`medium`),this.classList.toggle(`pkt-datepicker--small`,this.inputSize===`small`),this.classList.toggle(`pkt-datepicker--xsmall`,this.inputSize===`xsmall`),super.updated(e)}get inputRef(){return{value:this.currentInputElement}}get inputRefTo(){return{value:this.currentInputElementTo}}get currentInputElement(){return this.multiple?this.multipleInputRef.value?.inputElement:this.range?this.rangeInputRef.value?.inputElement:this.singleInputRef.value?.inputElement}get currentInputElementTo(){if(this.range)return this.rangeInputRef.value?.inputElementTo}get currentButtonElement(){return this.multiple?this.multipleInputRef.value?.buttonElement:this.range?this.rangeInputRef.value?.buttonElement:this.singleInputRef.value?.buttonElement}get btnRef(){return{value:this.currentButtonElement}}renderInput(){return e._`
|
|
146
157
|
<pkt-datepicker-single
|
|
147
158
|
.value=${this._value[0]??``}
|
|
148
159
|
.inputType=${this.inputType}
|
|
@@ -155,6 +166,8 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
155
166
|
.inputClasses=${this.inputClasses}
|
|
156
167
|
.inputSize=${this.inputSize}
|
|
157
168
|
.internals=${this.internals}
|
|
169
|
+
.hasError=${this.hasError}
|
|
170
|
+
.hasHelptext=${!!(this.helptext||this.helptextDropdown)}
|
|
158
171
|
.strings=${this.strings}
|
|
159
172
|
@toggle-calendar=${e=>this.toggleCalendar(e.detail)}
|
|
160
173
|
@input-change=${()=>this.onInput()}
|
|
@@ -180,6 +193,8 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
180
193
|
.inputClasses=${this.inputClasses}
|
|
181
194
|
.inputSize=${this.inputSize}
|
|
182
195
|
.internals=${this.internals}
|
|
196
|
+
.hasError=${this.hasError}
|
|
197
|
+
.hasHelptext=${!!(this.helptext||this.helptextDropdown)}
|
|
183
198
|
.strings=${this.strings}
|
|
184
199
|
@toggle-calendar=${e=>this.toggleCalendar(e.detail)}
|
|
185
200
|
@input-change=${()=>this.onInput()}
|
|
@@ -206,6 +221,8 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
206
221
|
.inputClasses=${this.inputClasses}
|
|
207
222
|
.inputSize=${this.inputSize}
|
|
208
223
|
.internals=${this.internals}
|
|
224
|
+
.hasError=${this.hasError}
|
|
225
|
+
.hasHelptext=${!!(this.helptext||this.helptextDropdown)}
|
|
209
226
|
.strings=${this.strings}
|
|
210
227
|
@toggle-calendar=${e=>this.toggleCalendar(e.detail)}
|
|
211
228
|
@input-change=${()=>this.onInput()}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./if-defined-BeVQnl3C.cjs"),r=require("./format-B8meU8Tm.cjs");require("./alert-HFqn-cvb.cjs"),require("./icon-DBFTFd-J.cjs");const i=require("./converters-BJ9Fe0kW.cjs"),a=require("./utils-63cRpWut.cjs");require("./input-wrapper-791L3L--.cjs");const o=require("./focus-trap-DSv4Ifqm.cjs");require("./modal-C1g2fiUq.cjs"),require("./progressbar-BpcsDCnG.cjs");function s(e){if(e==null||e===``)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=String(e).trim(),n=Number(t);if(!Number.isNaN(n)&&n>0)return n;let r=t.match(/^(\d+(?:\.\d+)?)\s*(B|KB|MB|GB)$/i);if(!r){console.warn(`PktFileUpload: Invalid maxFileSize format "${t}". Use format like "5MB", "500KB", "1GB", or bytes.`);return}let i=parseFloat(r[1]);switch(r[2].toUpperCase()){case`B`:return i;case`KB`:return i*1024;case`MB`:return i*1024*1024;case`GB`:return i*1024*1024*1024;default:return}}function c(e){return e<1024?`${Math.round(e)} B`:e<1048576?`${Math.round(e/1024)} KB`:e<1073741824?`${Math.round(e/1048576)} MB`:`${Math.round(e/1073741824)} GB`}function l(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function u(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function d(e,t,n){let r=e.toLowerCase().replace(/^\./,``);if(r.includes(`/`)){if(r.endsWith(`/*`)){let e=r.replace(`/*`,``);return n.startsWith(`${e}/`)}return n===r}return t===r}function f(e,t){let n=l(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>d(e,r,i))}function p(e,t){let n=(e??``).trim();if(n)return n;let r=l(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function m(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function h(e,t){let n=l(e);if(n.length>0)return n.map(m).join(`, `);let r=u(t);return r.length>0?r.map(m).join(`, `):``}function g(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function _(t,n){let r=l(n.allowedFormats);if(r.length>0&&!f(t,r)){let t=r.join(`, `),i=e.s.fileupload.invalidFormat;return g(n.formatErrorMessage,i,{formats:t})}let i=s(n.maxFileSize);if(i!==void 0&&t.size>i){let t=c(i),r=e.s.fileupload.sizeTooLarge;return g(n.sizeErrorMessage,r,{maxSize:t})}if(n.onFileValidation){let e=n.onFileValidation(t);if(e)return e}return null}function v(e){let t=e.file;if(t?.type?.startsWith(`image/`))return!0;let n=e.attributes?.targetFilename||t?.name||``;return/\.(jpe?g|png|gif|webp|heic|heif|bmp|svg)$/i.test(n)}function y(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function b(e,t,n){let r={"in-progress":0,error:1,idle:2};return e.map(e=>{let r=t?.find(t=>t.fileId===e.fileId);return{...e,progress:r?.progress??(n===`form`?`done`:`queued`),errorMessage:r?.errorMessage,showProgress:r?.showProgress,lastProgress:r?.lastProgress}}).sort((e,t)=>r[y(e.progress)]-r[y(t.progress)])}function x(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function S(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function C(e,t){let n=e.length;if(n===0||!t||t.length===0)return{totalCount:n,uploadedCount:0,failedCount:0};let r=0,i=0;for(let n of e){let e=t.find(e=>e.fileId===n.fileId);e?.progress===`done`?r++:e?.progress===`error`&&i++}return{totalCount:n,uploadedCount:r,failedCount:i}}function w(t,n=e.s.fileupload.unknownFilename){return t.attributes?.targetFilename||t.file?.name||n}var T=class extends e.t{constructor(...e){super(...e),this.id=`pkt-fileupload-${a.n()}`,this.name=`files`,this.label=``,this.helptext=``,this.helptextDropdown=``,this.required=!1,this.multiple=!1,this.disabled=!1,this.fullwidth=!1,this.uploadStrategy=`form`,this.itemRenderer=`filename`,this.accept=``,this.allowedFormats=[],this.formatErrorMessage=``,this.sizeErrorMessage=``,this.transfers=[],this.addCommentsEnabled=!1,this.renameFilesEnabled=!1,this.extraOperations=[],this.enableImagePreview=!1,this.hasError=!1,this.errorMessage=``,this.optionalTag=!1,this.requiredTag=!1,this.tagText=null,this.truncateTail=4,this.files=[],this.isDragActive=!1,this.validationErrorMessage=null,this.addedAnnouncement=``,this.thumbnailUrls={},this.hasInitializedValue=!1,this.hasWarnedInvalidValueCombo=!1,this.thumbnailFileById=new Map,this.connectedForm=null,this.addedAnnouncementTimer=null,this.onNativeFileChange=e=>{let t=e.target;this.addFiles(t.files?Array.from(t.files):[]),this.uploadStrategy===`custom`&&(t.value=``)},this.openFileDialog=e=>{e.preventDefault(),e.stopPropagation(),!this.disabled&&this.querySelector(`#${this.id}-input`)?.click()},this.onDropZoneClick=e=>{this.disabled||e.target.closest(`.pkt-fileupload__drop-zone__placeholder__title__open-file-dialog`)||this.querySelector(`#${this.id}-input`)?.click()},this.onDragOver=e=>{e.preventDefault(),!this.disabled&&(this.isDragActive=!0)},this.onDragLeave=()=>{this.isDragActive=!1},this.onDrop=e=>{if(e.preventDefault(),this.isDragActive=!1,this.disabled)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this.addFiles(t)},this.onHostFormSubmit=e=>{!this.required||this.uploadStrategy!==`custom`||this.getCurrentFiles().length>0||(this.validationErrorMessage=this.requiredSelectionMessage,e.preventDefault())}}get requiredSelectionMessage(){return this.pktStrings.get(`fileupload`).requiredMissing}get isControlled(){return this.value!==void 0}get hasEffectiveError(){return!!this.validationErrorMessage||this.hasError||!!this.errorMessage.trim()}get effectiveErrorMessage(){return this.validationErrorMessage??this.errorMessage??``}get hasValidationError(){return!!this.validationErrorMessage}firstUpdated(e){super.firstUpdated?.(e),this.hasInitializedValue||=(this.files=this.value??this.defaultValue??[],this.syncThumbnailUrls(this.files),!0),this.value!==void 0&&this.defaultValue!==void 0&&this.warnInvalidValueCombo()}willUpdate(e){super.willUpdate(e),this.hasInitializedValue&&this.isControlled&&(e.has(`value`)||e.has(`itemRenderer`)||e.has(`enableImagePreview`))&&(this.files=this.value??[],this.syncThumbnailUrls(this.files))}updated(e){super.updated(e),(e.has(`uploadStrategy`)||e.has(`required`)||e.has(`value`))&&this.syncFormSubmitListener(),this.uploadStrategy===`form`&&(e.has(`value`)||e.has(`files`)||e.has(`uploadStrategy`))&&this.syncNativeInputFiles()}syncNativeInputFiles(){let e=this.querySelector(`#${this.id}-input`);if(!(!e||typeof DataTransfer>`u`))try{let t=new DataTransfer;for(let e of this.getCurrentFiles())e.file&&t.items.add(e.file);e.files=t.files}catch{}}warnInvalidValueCombo(){this.hasWarnedInvalidValueCombo||=(console.warn(`PktFileUpload: Både value og defaultValue er angitt. Komponenten kan være enten kontrollert eller ukontrollert, ikke begge. value vil bli prioritert.`),!0)}disconnectedCallback(){this.teardownFormSubmitListener(),this.addedAnnouncementTimer&&=(clearTimeout(this.addedAnnouncementTimer),null),super.disconnectedCallback(),this.revokeAllThumbnailUrls()}setAddedAnnouncement(e){this.addedAnnouncement=e,this.addedAnnouncementTimer&&clearTimeout(this.addedAnnouncementTimer),this.addedAnnouncementTimer=setTimeout(()=>{this.addedAnnouncement=``,this.addedAnnouncementTimer=null},1500)}connectedCallback(){super.connectedCallback(),this.syncFormSubmitListener()}addFiles(e){if(e.length===0)return;let t=this.multiple?e:[e[0]];for(let e of t){let t=this.validateFile(e);if(t){this.validationErrorMessage=t;return}}this.validationErrorMessage=null;let n=t.map(e=>({fileId:a.n(),file:e,attributes:{targetFilename:e.name}})),i=this.pktStrings.get(`fileupload`);this.setAddedAnnouncement(n.length===1?r.t(i.srFileAdded,{filename:n[0].attributes.targetFilename}):r.t(i.srFilesAdded,{count:n.length}));let o=this.getCurrentFiles(),s=this.multiple?[...o,...n]:[n[0]];this.commitFiles(s,`add`,n.map(e=>e.fileId)),this.uploadStrategy===`custom`&&n.forEach(e=>{this.dispatchEvent(new CustomEvent(`file-upload-requested`,{detail:{fileId:e.fileId,file:e.file,attributes:e.attributes},bubbles:!0,composed:!0}))})}getCurrentFiles(){return this.isControlled?this.value??[]:this.files}cancelTransfer(e){if(this.disabled)return;let t=this.getCurrentFiles().find(t=>t.fileId===e);t&&(this.removeFileItem(e),this.dispatchEvent(new CustomEvent(`transfer-cancelled`,{detail:{fileId:t.fileId,file:t.file,attributes:t.attributes},bubbles:!0,composed:!0})))}removeFileItem(e){if(this.disabled)return;let t=this.getCurrentFiles(),n=t.filter(t=>t.fileId!==e);n.length!==t.length&&this.commitFiles(n,`remove`,[e])}updateFileItem(e,t){let n=this.getCurrentFiles().map(n=>n.fileId===e?{...n,...t}:n);this.commitFiles(n,`update`,[e])}commitFiles(e,t,n){this.isControlled||(this.files=e,this.syncThumbnailUrls(e)),this.validationErrorMessage===this.requiredSelectionMessage&&e.length>0&&(this.validationErrorMessage=null),this.dispatchEvent(new CustomEvent(`files-changed`,{detail:{files:e,reason:t,changedFileIds:n},bubbles:!0,composed:!0}))}getThumbnailUrl(e){return this.thumbnailUrls[e.fileId]}getTransferProgress(e){let t=this.transfers.find(t=>t.fileId===e);return t?t.progress:this.uploadStrategy===`form`?`done`:`queued`}getTransferForFile(e){return this.transfers.find(t=>t.fileId===e)}isImageFile(e){return v(e)}formatFileSize(e){return c(e)}getResolvedAcceptValue(){return p(this.accept,this.allowedFormats)}getSupportedFormatsText(){return h(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return b(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=_(e,{allowedFormats:this.allowedFormats,maxFileSize:this.maxFileSize,formatErrorMessage:this.formatErrorMessage,sizeErrorMessage:this.sizeErrorMessage,onFileValidation:this.onFileValidation});if(t)return t;let n={file:e,errorMessage:null},r=new CustomEvent(`file-validate`,{detail:n,bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(r),n.errorMessage?n.errorMessage:r.defaultPrevented?this.pktStrings.get(`fileupload`).genericValidationRejection:null}syncThumbnailUrls(e){if(!(typeof URL<`u`&&typeof URL.createObjectURL==`function`&&typeof URL.revokeObjectURL==`function`)){this.thumbnailUrls={},this.thumbnailFileById.clear();return}let t=new Set(e.map(e=>e.fileId)),n={};for(let[e,n]of Object.entries(this.thumbnailUrls))t.has(e)||(URL.revokeObjectURL(n),this.thumbnailFileById.delete(e));for(let t of e){let e=this.thumbnailUrls[t.fileId],r=this.thumbnailFileById.get(t.fileId);if(!t.file||!this.isImageFile(t)){e&&(URL.revokeObjectURL(e),this.thumbnailFileById.delete(t.fileId));continue}if(e&&r===t.file){n[t.fileId]=e;continue}e&&r!==t.file&&URL.revokeObjectURL(e);let i=URL.createObjectURL(t.file);this.thumbnailFileById.set(t.fileId,t.file),n[t.fileId]=i}this.thumbnailUrls=n}revokeAllThumbnailUrls(){if(typeof URL>`u`||typeof URL.revokeObjectURL!=`function`){this.thumbnailUrls={},this.thumbnailFileById.clear();return}Object.values(this.thumbnailUrls).forEach(e=>URL.revokeObjectURL(e)),this.thumbnailUrls={},this.thumbnailFileById.clear()}getSrUploadedMessage(){if(this.addedAnnouncement)return this.addedAnnouncement;let{totalCount:e,uploadedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let n=this.pktStrings.get(`fileupload`);return r.t(n.srFilesUploadedOfTotal,{uploaded:t,total:e,label:r.n(e,n.fileLabelOne,n.fileLabelOther)})}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let n=this.pktStrings.get(`fileupload`);return r.t(n.srFilesFailedOfTotal,{failed:t,total:e,label:r.n(e,n.fileLabelOne,n.fileLabelOther)})}syncFormSubmitListener(){let e=this.closest(`form`);this.connectedForm!==e&&(this.teardownFormSubmitListener(),this.connectedForm=e,this.connectedForm&&this.connectedForm.addEventListener(`submit`,this.onHostFormSubmit))}teardownFormSubmitListener(){this.connectedForm&&=(this.connectedForm.removeEventListener(`submit`,this.onHostFormSubmit),null)}};e.n([e.u({type:String})],T.prototype,`id`,void 0),e.n([e.u({type:String})],T.prototype,`name`,void 0),e.n([e.u({type:String})],T.prototype,`label`,void 0),e.n([e.u({type:String})],T.prototype,`helptext`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown`})],T.prototype,`helptextDropdown`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown-button`})],T.prototype,`helptextDropdownButton`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`required`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`multiple`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`disabled`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`fullwidth`})],T.prototype,`fullwidth`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`upload-strategy`})],T.prototype,`uploadStrategy`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`item-renderer`})],T.prototype,`itemRenderer`,void 0),e.n([e.u({type:String})],T.prototype,`accept`,void 0),e.n([e.u({converter:i.t.csvToArray,attribute:`allowed-formats`})],T.prototype,`allowedFormats`,void 0),e.n([e.u({type:String,attribute:`format-error-message`})],T.prototype,`formatErrorMessage`,void 0),e.n([e.u({attribute:`max-file-size`})],T.prototype,`maxFileSize`,void 0),e.n([e.u({type:String,attribute:`size-error-message`})],T.prototype,`sizeErrorMessage`,void 0),e.n([e.u({attribute:!1})],T.prototype,`onFileValidation`,void 0),e.n([e.u({attribute:!1})],T.prototype,`transfers`,void 0),e.n([e.u({type:Boolean,attribute:`add-comments-enabled`})],T.prototype,`addCommentsEnabled`,void 0),e.n([e.u({type:Boolean,attribute:`rename-files-enabled`})],T.prototype,`renameFilesEnabled`,void 0),e.n([e.u({attribute:!1})],T.prototype,`extraOperations`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],T.prototype,`enableImagePreview`,void 0),e.n([e.u({type:Boolean,attribute:`has-error`})],T.prototype,`hasError`,void 0),e.n([e.u({type:String,attribute:`error-message`})],T.prototype,`errorMessage`,void 0),e.n([e.u({type:Boolean,attribute:`optional-tag`})],T.prototype,`optionalTag`,void 0),e.n([e.u({type:String,attribute:`optional-text`})],T.prototype,`optionalText`,void 0),e.n([e.u({type:Boolean,attribute:`required-tag`})],T.prototype,`requiredTag`,void 0),e.n([e.u({type:String,attribute:`required-text`})],T.prototype,`requiredText`,void 0),e.n([e.u({type:String,attribute:`tag-text`})],T.prototype,`tagText`,void 0),e.n([e.u({type:Number,attribute:`truncate-tail`})],T.prototype,`truncateTail`,void 0),e.n([e.u({attribute:!1})],T.prototype,`value`,void 0),e.n([e.u({attribute:!1})],T.prototype,`defaultValue`,void 0),e.n([e.l()],T.prototype,`files`,void 0),e.n([e.l()],T.prototype,`isDragActive`,void 0),e.n([e.l()],T.prototype,`validationErrorMessage`,void 0),e.n([e.l()],T.prototype,`addedAnnouncement`,void 0),e.n([e.l()],T.prototype,`thumbnailUrls`,void 0);var E=`comments`,D=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:`${String(t.getDate()).padStart(2,`0`)}.${String(t.getMonth()+1).padStart(2,`0`)}.${t.getFullYear()} kl. ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`},O=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},k=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},A=e=>({id:`remove`,title:`Slett`,ariaLabel:`Slett fil`,onClick:({file:t})=>e(t.fileId)}),j=()=>({id:`rename`,title:`Rediger`,ariaLabel:`Rediger filnavn`,renderInlineUI:t=>{let n=t.getAttribute(`targetFilename`)||t.file.attributes?.targetFilename||t.file.file?.name||``,r=`pkt-fileupload-rename-${t.file.fileId}`,i=()=>{let e=document.getElementById(r)?.value?.trim();e&&t.setAttribute(`targetFilename`,e),t.close()};return e._`
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./if-defined-BeVQnl3C.cjs"),r=require("./format-B8meU8Tm.cjs");require("./alert-HFqn-cvb.cjs"),require("./icon-DBFTFd-J.cjs");const i=require("./converters-BJ9Fe0kW.cjs"),a=require("./utils-63cRpWut.cjs");require("./input-wrapper-wyvCnWPp.cjs");const o=require("./focus-trap-DSv4Ifqm.cjs");require("./modal-C1g2fiUq.cjs"),require("./progressbar-BpcsDCnG.cjs");function s(e){if(e==null||e===``)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=String(e).trim(),n=Number(t);if(!Number.isNaN(n)&&n>0)return n;let r=t.match(/^(\d+(?:\.\d+)?)\s*(B|KB|MB|GB)$/i);if(!r){console.warn(`PktFileUpload: Invalid maxFileSize format "${t}". Use format like "5MB", "500KB", "1GB", or bytes.`);return}let i=parseFloat(r[1]);switch(r[2].toUpperCase()){case`B`:return i;case`KB`:return i*1024;case`MB`:return i*1024*1024;case`GB`:return i*1024*1024*1024;default:return}}function c(e){return e<1024?`${Math.round(e)} B`:e<1048576?`${Math.round(e/1024)} KB`:e<1073741824?`${Math.round(e/1048576)} MB`:`${Math.round(e/1073741824)} GB`}function l(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function u(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function d(e,t,n){let r=e.toLowerCase().replace(/^\./,``);if(r.includes(`/`)){if(r.endsWith(`/*`)){let e=r.replace(`/*`,``);return n.startsWith(`${e}/`)}return n===r}return t===r}function f(e,t){let n=l(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>d(e,r,i))}function p(e,t){let n=(e??``).trim();if(n)return n;let r=l(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function m(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function h(e,t){let n=l(e);if(n.length>0)return n.map(m).join(`, `);let r=u(t);return r.length>0?r.map(m).join(`, `):``}function g(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function _(t,n){let r=l(n.allowedFormats);if(r.length>0&&!f(t,r)){let t=r.join(`, `),i=e.s.fileupload.invalidFormat;return g(n.formatErrorMessage,i,{formats:t})}let i=s(n.maxFileSize);if(i!==void 0&&t.size>i){let t=c(i),r=e.s.fileupload.sizeTooLarge;return g(n.sizeErrorMessage,r,{maxSize:t})}if(n.onFileValidation){let e=n.onFileValidation(t);if(e)return e}return null}function v(e){let t=e.file;if(t?.type?.startsWith(`image/`))return!0;let n=e.attributes?.targetFilename||t?.name||``;return/\.(jpe?g|png|gif|webp|heic|heif|bmp|svg)$/i.test(n)}function y(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function b(e,t,n){let r={"in-progress":0,error:1,idle:2};return e.map(e=>{let r=t?.find(t=>t.fileId===e.fileId);return{...e,progress:r?.progress??(n===`form`?`done`:`queued`),errorMessage:r?.errorMessage,showProgress:r?.showProgress,lastProgress:r?.lastProgress}}).sort((e,t)=>r[y(e.progress)]-r[y(t.progress)])}function x(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function S(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function C(e,t){let n=e.length;if(n===0||!t||t.length===0)return{totalCount:n,uploadedCount:0,failedCount:0};let r=0,i=0;for(let n of e){let e=t.find(e=>e.fileId===n.fileId);e?.progress===`done`?r++:e?.progress===`error`&&i++}return{totalCount:n,uploadedCount:r,failedCount:i}}function w(t,n=e.s.fileupload.unknownFilename){return t.attributes?.targetFilename||t.file?.name||n}var T=class extends e.t{constructor(...e){super(...e),this.id=`pkt-fileupload-${a.n()}`,this.name=`files`,this.label=``,this.helptext=``,this.helptextDropdown=``,this.required=!1,this.multiple=!1,this.disabled=!1,this.fullwidth=!1,this.uploadStrategy=`form`,this.itemRenderer=`filename`,this.accept=``,this.allowedFormats=[],this.formatErrorMessage=``,this.sizeErrorMessage=``,this.transfers=[],this.addCommentsEnabled=!1,this.renameFilesEnabled=!1,this.extraOperations=[],this.enableImagePreview=!1,this.hasError=!1,this.errorMessage=``,this.optionalTag=!1,this.requiredTag=!1,this.tagText=null,this.truncateTail=4,this.files=[],this.isDragActive=!1,this.validationErrorMessage=null,this.addedAnnouncement=``,this.thumbnailUrls={},this.hasInitializedValue=!1,this.hasWarnedInvalidValueCombo=!1,this.thumbnailFileById=new Map,this.connectedForm=null,this.addedAnnouncementTimer=null,this.onNativeFileChange=e=>{let t=e.target;this.addFiles(t.files?Array.from(t.files):[]),this.uploadStrategy===`custom`&&(t.value=``)},this.openFileDialog=e=>{e.preventDefault(),e.stopPropagation(),!this.disabled&&this.querySelector(`#${this.id}-input`)?.click()},this.onDropZoneClick=e=>{this.disabled||e.target.closest(`.pkt-fileupload__drop-zone__placeholder__title__open-file-dialog`)||this.querySelector(`#${this.id}-input`)?.click()},this.onDragOver=e=>{e.preventDefault(),!this.disabled&&(this.isDragActive=!0)},this.onDragLeave=()=>{this.isDragActive=!1},this.onDrop=e=>{if(e.preventDefault(),this.isDragActive=!1,this.disabled)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this.addFiles(t)},this.onHostFormSubmit=e=>{!this.required||this.uploadStrategy!==`custom`||this.getCurrentFiles().length>0||(this.validationErrorMessage=this.requiredSelectionMessage,e.preventDefault())}}get requiredSelectionMessage(){return this.pktStrings.get(`fileupload`).requiredMissing}get isControlled(){return this.value!==void 0}get hasEffectiveError(){return!!this.validationErrorMessage||this.hasError||!!this.errorMessage.trim()}get effectiveErrorMessage(){return this.validationErrorMessage??this.errorMessage??``}get hasValidationError(){return!!this.validationErrorMessage}firstUpdated(e){super.firstUpdated?.(e),this.hasInitializedValue||=(this.files=this.value??this.defaultValue??[],this.syncThumbnailUrls(this.files),!0),this.value!==void 0&&this.defaultValue!==void 0&&this.warnInvalidValueCombo()}willUpdate(e){super.willUpdate(e),this.hasInitializedValue&&this.isControlled&&(e.has(`value`)||e.has(`itemRenderer`)||e.has(`enableImagePreview`))&&(this.files=this.value??[],this.syncThumbnailUrls(this.files))}updated(e){super.updated(e),(e.has(`uploadStrategy`)||e.has(`required`)||e.has(`value`))&&this.syncFormSubmitListener(),this.uploadStrategy===`form`&&(e.has(`value`)||e.has(`files`)||e.has(`uploadStrategy`))&&this.syncNativeInputFiles()}syncNativeInputFiles(){let e=this.querySelector(`#${this.id}-input`);if(!(!e||typeof DataTransfer>`u`))try{let t=new DataTransfer;for(let e of this.getCurrentFiles())e.file&&t.items.add(e.file);e.files=t.files}catch{}}warnInvalidValueCombo(){this.hasWarnedInvalidValueCombo||=(console.warn(`PktFileUpload: Både value og defaultValue er angitt. Komponenten kan være enten kontrollert eller ukontrollert, ikke begge. value vil bli prioritert.`),!0)}disconnectedCallback(){this.teardownFormSubmitListener(),this.addedAnnouncementTimer&&=(clearTimeout(this.addedAnnouncementTimer),null),super.disconnectedCallback(),this.revokeAllThumbnailUrls()}setAddedAnnouncement(e){this.addedAnnouncement=e,this.addedAnnouncementTimer&&clearTimeout(this.addedAnnouncementTimer),this.addedAnnouncementTimer=setTimeout(()=>{this.addedAnnouncement=``,this.addedAnnouncementTimer=null},1500)}connectedCallback(){super.connectedCallback(),this.syncFormSubmitListener()}addFiles(e){if(e.length===0)return;let t=this.multiple?e:[e[0]];for(let e of t){let t=this.validateFile(e);if(t){this.validationErrorMessage=t;return}}this.validationErrorMessage=null;let n=t.map(e=>({fileId:a.n(),file:e,attributes:{targetFilename:e.name}})),i=this.pktStrings.get(`fileupload`);this.setAddedAnnouncement(n.length===1?r.t(i.srFileAdded,{filename:n[0].attributes.targetFilename}):r.t(i.srFilesAdded,{count:n.length}));let o=this.getCurrentFiles(),s=this.multiple?[...o,...n]:[n[0]];this.commitFiles(s,`add`,n.map(e=>e.fileId)),this.uploadStrategy===`custom`&&n.forEach(e=>{this.dispatchEvent(new CustomEvent(`file-upload-requested`,{detail:{fileId:e.fileId,file:e.file,attributes:e.attributes},bubbles:!0,composed:!0}))})}getCurrentFiles(){return this.isControlled?this.value??[]:this.files}cancelTransfer(e){if(this.disabled)return;let t=this.getCurrentFiles().find(t=>t.fileId===e);t&&(this.removeFileItem(e),this.dispatchEvent(new CustomEvent(`transfer-cancelled`,{detail:{fileId:t.fileId,file:t.file,attributes:t.attributes},bubbles:!0,composed:!0})))}removeFileItem(e){if(this.disabled)return;let t=this.getCurrentFiles(),n=t.filter(t=>t.fileId!==e);n.length!==t.length&&this.commitFiles(n,`remove`,[e])}updateFileItem(e,t){let n=this.getCurrentFiles().map(n=>n.fileId===e?{...n,...t}:n);this.commitFiles(n,`update`,[e])}commitFiles(e,t,n){this.isControlled||(this.files=e,this.syncThumbnailUrls(e)),this.validationErrorMessage===this.requiredSelectionMessage&&e.length>0&&(this.validationErrorMessage=null),this.dispatchEvent(new CustomEvent(`files-changed`,{detail:{files:e,reason:t,changedFileIds:n},bubbles:!0,composed:!0}))}getThumbnailUrl(e){return this.thumbnailUrls[e.fileId]}getTransferProgress(e){let t=this.transfers.find(t=>t.fileId===e);return t?t.progress:this.uploadStrategy===`form`?`done`:`queued`}getTransferForFile(e){return this.transfers.find(t=>t.fileId===e)}isImageFile(e){return v(e)}formatFileSize(e){return c(e)}getResolvedAcceptValue(){return p(this.accept,this.allowedFormats)}getSupportedFormatsText(){return h(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return b(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=_(e,{allowedFormats:this.allowedFormats,maxFileSize:this.maxFileSize,formatErrorMessage:this.formatErrorMessage,sizeErrorMessage:this.sizeErrorMessage,onFileValidation:this.onFileValidation});if(t)return t;let n={file:e,errorMessage:null},r=new CustomEvent(`file-validate`,{detail:n,bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(r),n.errorMessage?n.errorMessage:r.defaultPrevented?this.pktStrings.get(`fileupload`).genericValidationRejection:null}syncThumbnailUrls(e){if(!(typeof URL<`u`&&typeof URL.createObjectURL==`function`&&typeof URL.revokeObjectURL==`function`)){this.thumbnailUrls={},this.thumbnailFileById.clear();return}let t=new Set(e.map(e=>e.fileId)),n={};for(let[e,n]of Object.entries(this.thumbnailUrls))t.has(e)||(URL.revokeObjectURL(n),this.thumbnailFileById.delete(e));for(let t of e){let e=this.thumbnailUrls[t.fileId],r=this.thumbnailFileById.get(t.fileId);if(!t.file||!this.isImageFile(t)){e&&(URL.revokeObjectURL(e),this.thumbnailFileById.delete(t.fileId));continue}if(e&&r===t.file){n[t.fileId]=e;continue}e&&r!==t.file&&URL.revokeObjectURL(e);let i=URL.createObjectURL(t.file);this.thumbnailFileById.set(t.fileId,t.file),n[t.fileId]=i}this.thumbnailUrls=n}revokeAllThumbnailUrls(){if(typeof URL>`u`||typeof URL.revokeObjectURL!=`function`){this.thumbnailUrls={},this.thumbnailFileById.clear();return}Object.values(this.thumbnailUrls).forEach(e=>URL.revokeObjectURL(e)),this.thumbnailUrls={},this.thumbnailFileById.clear()}getSrUploadedMessage(){if(this.addedAnnouncement)return this.addedAnnouncement;let{totalCount:e,uploadedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let n=this.pktStrings.get(`fileupload`);return r.t(n.srFilesUploadedOfTotal,{uploaded:t,total:e,label:r.n(e,n.fileLabelOne,n.fileLabelOther)})}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let n=this.pktStrings.get(`fileupload`);return r.t(n.srFilesFailedOfTotal,{failed:t,total:e,label:r.n(e,n.fileLabelOne,n.fileLabelOther)})}syncFormSubmitListener(){let e=this.closest(`form`);this.connectedForm!==e&&(this.teardownFormSubmitListener(),this.connectedForm=e,this.connectedForm&&this.connectedForm.addEventListener(`submit`,this.onHostFormSubmit))}teardownFormSubmitListener(){this.connectedForm&&=(this.connectedForm.removeEventListener(`submit`,this.onHostFormSubmit),null)}};e.n([e.u({type:String})],T.prototype,`id`,void 0),e.n([e.u({type:String})],T.prototype,`name`,void 0),e.n([e.u({type:String})],T.prototype,`label`,void 0),e.n([e.u({type:String})],T.prototype,`helptext`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown`})],T.prototype,`helptextDropdown`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown-button`})],T.prototype,`helptextDropdownButton`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`required`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`multiple`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`disabled`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`fullwidth`})],T.prototype,`fullwidth`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`upload-strategy`})],T.prototype,`uploadStrategy`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`item-renderer`})],T.prototype,`itemRenderer`,void 0),e.n([e.u({type:String})],T.prototype,`accept`,void 0),e.n([e.u({converter:i.t.csvToArray,attribute:`allowed-formats`})],T.prototype,`allowedFormats`,void 0),e.n([e.u({type:String,attribute:`format-error-message`})],T.prototype,`formatErrorMessage`,void 0),e.n([e.u({attribute:`max-file-size`})],T.prototype,`maxFileSize`,void 0),e.n([e.u({type:String,attribute:`size-error-message`})],T.prototype,`sizeErrorMessage`,void 0),e.n([e.u({attribute:!1})],T.prototype,`onFileValidation`,void 0),e.n([e.u({attribute:!1})],T.prototype,`transfers`,void 0),e.n([e.u({type:Boolean,attribute:`add-comments-enabled`})],T.prototype,`addCommentsEnabled`,void 0),e.n([e.u({type:Boolean,attribute:`rename-files-enabled`})],T.prototype,`renameFilesEnabled`,void 0),e.n([e.u({attribute:!1})],T.prototype,`extraOperations`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],T.prototype,`enableImagePreview`,void 0),e.n([e.u({type:Boolean,attribute:`has-error`})],T.prototype,`hasError`,void 0),e.n([e.u({type:String,attribute:`error-message`})],T.prototype,`errorMessage`,void 0),e.n([e.u({type:Boolean,attribute:`optional-tag`})],T.prototype,`optionalTag`,void 0),e.n([e.u({type:String,attribute:`optional-text`})],T.prototype,`optionalText`,void 0),e.n([e.u({type:Boolean,attribute:`required-tag`})],T.prototype,`requiredTag`,void 0),e.n([e.u({type:String,attribute:`required-text`})],T.prototype,`requiredText`,void 0),e.n([e.u({type:String,attribute:`tag-text`})],T.prototype,`tagText`,void 0),e.n([e.u({type:Number,attribute:`truncate-tail`})],T.prototype,`truncateTail`,void 0),e.n([e.u({attribute:!1})],T.prototype,`value`,void 0),e.n([e.u({attribute:!1})],T.prototype,`defaultValue`,void 0),e.n([e.l()],T.prototype,`files`,void 0),e.n([e.l()],T.prototype,`isDragActive`,void 0),e.n([e.l()],T.prototype,`validationErrorMessage`,void 0),e.n([e.l()],T.prototype,`addedAnnouncement`,void 0),e.n([e.l()],T.prototype,`thumbnailUrls`,void 0);var E=`comments`,D=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:`${String(t.getDate()).padStart(2,`0`)}.${String(t.getMonth()+1).padStart(2,`0`)}.${t.getFullYear()} kl. ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`},O=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},k=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},A=e=>({id:`remove`,title:`Slett`,ariaLabel:`Slett fil`,onClick:({file:t})=>e(t.fileId)}),j=()=>({id:`rename`,title:`Rediger`,ariaLabel:`Rediger filnavn`,renderInlineUI:t=>{let n=t.getAttribute(`targetFilename`)||t.file.attributes?.targetFilename||t.file.file?.name||``,r=`pkt-fileupload-rename-${t.file.fileId}`,i=()=>{let e=document.getElementById(r)?.value?.trim();e&&t.setAttribute(`targetFilename`,e),t.close()};return e._`
|
|
2
2
|
<label for=${r} class="pkt-sr-only">Endre filnavn</label>
|
|
3
3
|
<input
|
|
4
4
|
id=${r}
|
|
@@ -6,7 +6,7 @@ import "./alert-CayKowTW.js";
|
|
|
6
6
|
import "./icon-jEFbKTB_.js";
|
|
7
7
|
import { t as d } from "./converters-CkjLSYpa.js";
|
|
8
8
|
import { n as f } from "./utils-BwF4QSrq.js";
|
|
9
|
-
import "./input-wrapper-
|
|
9
|
+
import "./input-wrapper-Bwh720ke.js";
|
|
10
10
|
import { r as p } from "./focus-trap-DG3pEuyJ.js";
|
|
11
11
|
import "./modal-z5RzZ-fr.js";
|
|
12
12
|
import "./progressbar-BPHLC7ce.js";
|
|
@@ -10,7 +10,7 @@ import { n as m, o as h, t as g } from "./fetch-header-footer-data-Pc32etrk.js";
|
|
|
10
10
|
import { n as _, t as v } from "./focus-trap-DG3pEuyJ.js";
|
|
11
11
|
import { n as y, t as b } from "./scroll-lock-DAbNKAUy.js";
|
|
12
12
|
import "./link-BvjWWWlc.js";
|
|
13
|
-
import "./textinput-
|
|
13
|
+
import "./textinput-DT3HR9eU.js";
|
|
14
14
|
import "./searchinput-DrUcPajl.js";
|
|
15
15
|
import "./header-menu-DKAcUFzh.js";
|
|
16
16
|
//#region ../../shared-types/header.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./if-defined-BeVQnl3C.cjs"),r=require("./element-with-slot-DgtT8lCH.cjs");require("./icon-DBFTFd-J.cjs"),require("./button-CIb0IxTg.cjs");const i=require("./ref-BkV4Cd8U.cjs"),a=require("./booleanish-BF8l4scU.cjs"),o=require("./fetch-header-footer-data-CUKV0biS.cjs"),s=require("./focus-trap-DSv4Ifqm.cjs"),c=require("./scroll-lock-BN8lOhV5.cjs");require("./link-BWAhHUku.cjs"),require("./textinput-
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./if-defined-BeVQnl3C.cjs"),r=require("./element-with-slot-DgtT8lCH.cjs");require("./icon-DBFTFd-J.cjs"),require("./button-CIb0IxTg.cjs");const i=require("./ref-BkV4Cd8U.cjs"),a=require("./booleanish-BF8l4scU.cjs"),o=require("./fetch-header-footer-data-CUKV0biS.cjs"),s=require("./focus-trap-DSv4Ifqm.cjs"),c=require("./scroll-lock-BN8lOhV5.cjs");require("./link-BWAhHUku.cjs"),require("./textinput-B9w4jhIP.cjs"),require("./searchinput-CiPB8xvh.cjs"),require("./header-menu-wcnhBSzs.cjs");var l=e=>typeof e.target==`string`?{title:e.title,iconName:e.iconName,href:e.target}:{title:e.title,iconName:e.iconName,onClick:e.target},u=e=>l(e),d=e=>{if(!e)return;let t=typeof e==`string`?new Date(e):e;if(!isNaN(t.getTime()))return t.toLocaleDateString(`nb-NO`,{day:`numeric`,month:`long`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})},f=class{constructor(e,t){this.isMobile=!1,this.isTablet=!1,this.isHidden=!1,this.pauseScrollHide=!1,this.componentWidth=typeof window<`u`?window.innerWidth:0,this.lastScrollPosition=0,this.scrollLockToken=c.t(),this.lastFocusedElement=null,this.shouldRestoreFocus=!1,this.handleScroll=()=>{if(this.getOptions().scrollBehavior!==`hide`||this.pauseScrollHide)return;let e=window.pageYOffset||document.documentElement.scrollTop;if(e<0||Math.abs(e-this.lastScrollPosition)<60)return;let t=e>this.lastScrollPosition;this.lastScrollPosition=e,t!==this.isHidden&&(this.isHidden=t,this.host.requestUpdate())},this.host=e,this.getOptions=t,e.addController(this)}hostConnected(){window.addEventListener(`scroll`,this.handleScroll)}hostDisconnected(){this.resizeObserver?.disconnect(),window.removeEventListener(`scroll`,this.handleScroll),c.n(this.scrollLockToken,!1)}observe(e){e&&(this.componentWidth=e.offsetWidth,this.refreshBreakpoints(),this.resizeObserver=new ResizeObserver(e=>{for(let t of e)this.componentWidth=t.borderBoxSize&&t.borderBoxSize.length>0?t.borderBoxSize[0].inlineSize:t.contentRect.width,this.refreshBreakpoints()}),this.resizeObserver.observe(e))}refreshBreakpoints(){let{mobileBreakpoint:e,tabletBreakpoint:t}=this.getOptions(),n=this.componentWidth<e,r=this.componentWidth<t;(n!==this.isMobile||r!==this.isTablet)&&(this.isMobile=n,this.isTablet=r,this.host.requestUpdate())}setScrollLock(e){c.n(this.scrollLockToken,e)}captureFocus(){this.lastFocusedElement=document.activeElement}flagRestoreFocus(){this.shouldRestoreFocus=!0}restoreFocus(){this.shouldRestoreFocus&&this.lastFocusedElement&&document.contains(this.lastFocusedElement)&&this.lastFocusedElement.focus(),this.lastFocusedElement=null,this.shouldRestoreFocus=!1}},p=class extends e.t{constructor(...e){super(...e),this.canChangeRepresentation=!1,this.logoutOnClick=!1}handleChangeRepresentation(){this.dispatchEvent(new CustomEvent(`change-representation`,{bubbles:!0,composed:!0}))}handleLogout(){this.dispatchEvent(new CustomEvent(`log-out`,{bubbles:!0,composed:!0}))}handleMenuItemClick(e){`onClick`in e&&typeof e.onClick==`function`&&e.onClick()}renderLinkOrButton(n,r){let i=`href`in n,a=t.t({"pkt-user-menu__link":!0,"pkt-link-button":!i,"pkt-link":!i,"pkt-link--icon-left":!i,[r||``]:!!r});return i?e._`
|
|
2
2
|
<pkt-link
|
|
3
3
|
icon-name=${n.iconName||e.h}
|
|
4
4
|
href=${n.href}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as e, u as t } from "./element-e2MAMNEP.js";
|
|
2
2
|
import { t as n } from "./format-BTeSVkED.js";
|
|
3
3
|
import { t as r } from "./element-with-slot-GwTT3WRD.js";
|
|
4
|
-
import { n as i } from "./
|
|
5
|
-
import { n as
|
|
4
|
+
import { n as i, t as a } from "./booleanish-OQJTYSrw.js";
|
|
5
|
+
import { n as o } from "./utils-BwF4QSrq.js";
|
|
6
6
|
//#region ../../node_modules/element-internals-polyfill/dist/maps.js
|
|
7
7
|
var s = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), ee = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new WeakMap(), x = (e, t, n) => {
|
|
8
8
|
e.getAttribute(t) !== n && e.setAttribute(t, n);
|
|
@@ -479,7 +479,7 @@ var X = "on", Z = "--checked", Q = ",", $ = class extends r {
|
|
|
479
479
|
return this.hasFieldset ?? e;
|
|
480
480
|
}
|
|
481
481
|
constructor() {
|
|
482
|
-
super(), this.defaultValue = null, this.disabled = !1, this.readonly = !1, this.required = !1, this.max = null, this.maxlength = null, this.min = null, this.minlength = null, this.step = null, this.ariaDescribedby = null, this.ariaLabelledby = null, this.name = "", this.pattern = null, this.placeholder = null, this.id =
|
|
482
|
+
super(), this.defaultValue = null, this.disabled = !1, this.readonly = !1, this.required = !1, this.max = null, this.maxlength = null, this.min = null, this.minlength = null, this.step = null, this.ariaDescribedby = null, this.ariaLabelledby = null, this.name = "", this.pattern = null, this.placeholder = null, this.id = o(), this.counter = null, this.hasError = !1, this.inline = !1, this.hasFieldset = null, this.optionalTag = !1, this.requiredTag = !1, this.skipForwardTestid = !1, this.useWrapper = !0, this.fullwidth = !1, this.counterMaxLength = 0, this.errorMessage = "", this.helptext = "", this.helptextDropdown = "", this.helptextDropdownButton = null, this.label = null, this.tagText = null, this.inputSize = "medium", this.dataTestid = "", this.touched = !1, this._initialized = !1, this._didInitDerivedState = !1, this.internals = this.attachInternals();
|
|
483
483
|
}
|
|
484
484
|
manageValidity(e) {
|
|
485
485
|
if (!e) {
|
|
@@ -585,7 +585,7 @@ var X = "on", Z = "--checked", Q = ",", $ = class extends r {
|
|
|
585
585
|
super.updated(e), e.has("dataTestid") && this.dataTestid && this.inputRef.value && (this.skipForwardTestid ? this.hasAttribute("data-testid") || this.setAttribute("data-testid", this.dataTestid) : (this.inputRef.value.dataset.testid = this.dataTestid, this.removeAttribute("data-testid")));
|
|
586
586
|
}
|
|
587
587
|
willUpdate(e) {
|
|
588
|
-
super.willUpdate(e), !this._didInitDerivedState && (this._didInitDerivedState = !0, this.form ||= this.internals.form || this.closest("form"), this.defaultChecked && (this.checked = !0), this.id && !this.name && (this.name = this.id));
|
|
588
|
+
super.willUpdate(e), !this._didInitDerivedState && (this._didInitDerivedState = !0, this.form ||= this.internals.form || this.closest("form"), this.defaultChecked && (this.checked = !0), this.id && !this.name && (this.name = this.id), this.value && this.defaultValue === null && (this.defaultValue = this.value), this.defaultValue !== null && !this.value && this.valueChanged(this.defaultValue, null));
|
|
589
589
|
}
|
|
590
590
|
firstUpdated(e) {
|
|
591
591
|
if (super.firstUpdated(e), this.value && this.defaultValue === null && (this.defaultValue = this.value), this.defaultValue !== null && !this.value && this.valueChanged(this.defaultValue, null), this.defaultChecked && (this.internals.ariaChecked = "true"), this.required && (this.internals.ariaRequired = "true"), this.disabled && (this.internals.ariaDisabled = "true"), this.checked !== void 0) {
|
|
@@ -605,7 +605,7 @@ e([t({
|
|
|
605
605
|
})], $.prototype, "checked", void 0), e([t({ type: Boolean })], $.prototype, "defaultChecked", void 0), e([t({ type: Boolean })], $.prototype, "multiple", void 0), e([t({ type: Boolean })], $.prototype, "range", void 0), e([t({
|
|
606
606
|
type: String,
|
|
607
607
|
reflect: !0
|
|
608
|
-
})], $.prototype, "type", void 0), e([t(
|
|
608
|
+
})], $.prototype, "type", void 0), e([t()], $.prototype, "defaultValue", void 0), e([t({
|
|
609
609
|
type: Boolean,
|
|
610
610
|
reflect: !0
|
|
611
611
|
})], $.prototype, "disabled", void 0), e([t({
|
|
@@ -655,14 +655,14 @@ e([t({
|
|
|
655
655
|
reflect: !0
|
|
656
656
|
})], $.prototype, "id", void 0), e([t({
|
|
657
657
|
type: Boolean,
|
|
658
|
-
converter:
|
|
658
|
+
converter: i
|
|
659
659
|
})], $.prototype, "counter", void 0), e([t({ type: Boolean })], $.prototype, "hasError", void 0), e([t({ type: Boolean })], $.prototype, "inline", void 0), e([t({
|
|
660
660
|
type: Boolean,
|
|
661
|
-
converter:
|
|
661
|
+
converter: i
|
|
662
662
|
})], $.prototype, "hasFieldset", void 0), e([t({ type: Boolean })], $.prototype, "optionalTag", void 0), e([t({ type: Boolean })], $.prototype, "requiredTag", void 0), e([t({ type: Boolean })], $.prototype, "skipForwardTestid", void 0), e([t({
|
|
663
663
|
type: Boolean,
|
|
664
664
|
reflect: !0,
|
|
665
|
-
converter:
|
|
665
|
+
converter: a
|
|
666
666
|
})], $.prototype, "useWrapper", void 0), e([t({
|
|
667
667
|
type: Boolean,
|
|
668
668
|
reflect: !0
|