@oslokommune/punkt-elements 19.10.0 → 19.10.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 +40 -0
- package/dist/{accordion-CMCCpxtz.cjs → accordion-BFKmnCDh.cjs} +1 -1
- package/dist/{accordion-Cp2o6wTY.js → accordion-BhCmUDoS.js} +1 -1
- package/dist/{alert-QfloIr-o.cjs → alert-BJPi5ylH.cjs} +1 -1
- package/dist/{alert-CAPiwi4F.js → alert-CUH_2zb2.js} +2 -2
- package/dist/{button-Dh97H-58.cjs → button-CWHqXdSG.cjs} +1 -1
- package/dist/{button-CeRr7oIn.js → button-DQ8rH8hx.js} +1 -1
- package/dist/{card-_PlgXmgZ.js → card-DfVOJCWA.js} +2 -2
- package/dist/{card--NuWdTbG.cjs → card-pJ0CDH2Y.cjs} +1 -1
- package/dist/{checkbox-QIcdn09A.cjs → checkbox-3z2uH8rd.cjs} +1 -1
- package/dist/{checkbox-G8k3vg85.js → checkbox-BEBBPgYW.js} +1 -1
- package/dist/{checkbox-group-DoueGGi5.js → checkbox-group-BiPX1EhY.js} +2 -2
- package/dist/{checkbox-group-nLazAkcg.cjs → checkbox-group-DRQmSHyN.cjs} +1 -1
- package/dist/{combobox-ClXhKwR9.cjs → combobox-C_SMnNsj.cjs} +1 -1
- package/dist/{combobox-Cz_rq7Mm.js → combobox-CdmzQtCh.js} +5 -5
- package/dist/{consent-DimzcQxt.cjs → consent-CkK9BZ7t.cjs} +1 -1
- package/dist/{consent-CZMxUavj.js → consent-eTXt052m.js} +1 -1
- package/dist/{datepicker-usIF9WY7.cjs → datepicker-BrQhahYy.cjs} +1 -1
- package/dist/{datepicker-C7ABsx7H.js → datepicker-DILpPWCY.js} +4 -4
- package/dist/directives/slot-content.d.ts +24 -11
- package/dist/docs/punkt-docs.d.ts +3 -0
- package/dist/docs/tableOfContents.d.ts +15 -0
- package/dist/element-with-slot-DOt8HbXA.cjs +1 -0
- package/dist/element-with-slot-U981OZM_.js +353 -0
- package/dist/{fileupload-BR9H6fET.js → fileupload-BZjZh8Mp.js} +3 -3
- package/dist/{fileupload-2uTFjd81.cjs → fileupload-l1d9UQf9.cjs} +1 -1
- package/dist/{footer-CyxRYvT-.cjs → footer-C8Zh-eUU.cjs} +1 -1
- package/dist/{footer-B3DMvo8-.js → footer-X5MBVUoo.js} +1 -1
- package/dist/{header-BKeSkfB7.js → header-DLH6Xx97.js} +5 -5
- package/dist/{header-Drj3lTrv.cjs → header-EvwDJXP-.cjs} +1 -1
- package/dist/{header-menu-buYE90FU.js → header-menu-0UtMd2_H.js} +1 -1
- package/dist/{header-menu-B_5hCNUl.cjs → header-menu-BqFpYI-V.cjs} +1 -1
- package/dist/{heading-DUYOvlxs.cjs → heading-DMHbL3xs.cjs} +1 -1
- package/dist/{heading-WBB5MO9i.js → heading-tWSLaRPD.js} +1 -1
- package/dist/{helptext-C7cyihnu.cjs → helptext-CGa1p-yd.cjs} +1 -1
- package/dist/{helptext-DadLkcoO.js → helptext-Dy2Ehs9W.js} +1 -1
- package/dist/{input-element-BBygBEei.js → input-element-BGbT4ICl.js} +1 -1
- package/dist/{input-element-C4SelHLD.cjs → input-element-kIrd5ABs.cjs} +1 -1
- package/dist/{input-wrapper-BT6B3Kco.cjs → input-wrapper-EvzyXMw-.cjs} +1 -1
- package/dist/{input-wrapper-DrSCuw6U.js → input-wrapper-Uks0spRR.js} +3 -3
- package/dist/{link-CVnIn74-.js → link-C0yBFscy.js} +1 -1
- package/dist/{link-CEP7w1et.cjs → link-CLdiz-ly.cjs} +1 -1
- package/dist/{linkcard-IWiVvRKy.js → linkcard-B5-p-YC4.js} +1 -1
- package/dist/{linkcard-D8vitdrQ.cjs → linkcard-v9UsV9Os.cjs} +1 -1
- package/dist/{loader-B0hFoBtF.cjs → loader-C4UfUu2u.cjs} +1 -1
- package/dist/{loader-CAsUPHjl.js → loader-DWvjIMsT.js} +1 -1
- package/dist/{messagebox-6_iNN5F3.js → messagebox-CJTqxfu3.js} +1 -1
- package/dist/{messagebox-C19L2Duq.cjs → messagebox-clOimkn7.cjs} +1 -1
- package/dist/{modal-CoEPzt4p.cjs → modal-BPweteoS.cjs} +1 -1
- package/dist/{modal-D7MolBXb.js → modal-Bm1daKaW.js} +1 -1
- package/dist/{option-group-element-BYS7s-is.cjs → option-group-element-2A4TBcp-.cjs} +1 -1
- package/dist/{option-group-element-BIuotbRu.js → option-group-element-Ber7NAlg.js} +2 -2
- package/dist/pkt-accordion.cjs +1 -1
- package/dist/pkt-accordion.js +1 -1
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +1 -1
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +1 -1
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +1 -1
- package/dist/pkt-checkbox-group.cjs +1 -1
- package/dist/pkt-checkbox-group.js +1 -1
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-consent.cjs +1 -1
- package/dist/pkt-consent.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-fileupload.cjs +1 -1
- package/dist/pkt-fileupload.js +1 -1
- package/dist/pkt-footer.cjs +1 -1
- package/dist/pkt-footer.js +1 -1
- package/dist/pkt-header-menu.cjs +1 -1
- package/dist/pkt-header-menu.js +1 -1
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-heading.cjs +1 -1
- package/dist/pkt-heading.js +1 -1
- package/dist/pkt-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +29 -29
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-link.cjs +1 -1
- package/dist/pkt-link.js +1 -1
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +1 -1
- package/dist/pkt-loader.cjs +1 -1
- package/dist/pkt-loader.js +1 -1
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/{pkt-options-controller-B3vVKnAG.cjs → pkt-options-controller-Ck_549wx.cjs} +1 -1
- package/dist/{pkt-options-controller-ClFrUWZK.js → pkt-options-controller-DTOlYR9b.js} +1 -1
- package/dist/pkt-radio-group.cjs +1 -1
- package/dist/pkt-radio-group.js +1 -1
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/pkt-tabs.cjs +1 -1
- package/dist/pkt-tabs.js +1 -1
- package/dist/pkt-tag.cjs +1 -1
- package/dist/pkt-tag.js +1 -1
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +1 -1
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +1 -1
- package/dist/pkt-timepicker.cjs +1 -1
- package/dist/pkt-timepicker.js +1 -1
- package/dist/{radio-group-C-8C0-Py.cjs → radio-group-9Szx2XyM.cjs} +1 -1
- package/dist/{radio-group-BzV_JhgJ.js → radio-group-CMtx_GRV.js} +2 -2
- package/dist/{radiobutton-bkTAD5PV.js → radiobutton-CYbvJ9y8.js} +1 -1
- package/dist/{radiobutton-_089zFBB.cjs → radiobutton-Dq2qkfi0.cjs} +1 -1
- package/dist/{select-BowvpCNa.cjs → select-1nm17iN8.cjs} +1 -1
- package/dist/{select-B6CN2Ymq.js → select-DlgOxHIl.js} +4 -4
- package/dist/shared-utils/heading-ids.d.ts +12 -0
- package/dist/{tabs-Dm8xcPRs.cjs → tabs-8Y5PlmLl.cjs} +1 -1
- package/dist/{tabs-DZvtVA0y.js → tabs-D3pPS9us.js} +1 -1
- package/dist/{tag-DyVZrqOQ.cjs → tag-DOUsW7nS.cjs} +1 -1
- package/dist/{tag-C33BPIOm.js → tag-qHYIycl8.js} +1 -1
- package/dist/{textarea-hW0kV5gj.js → textarea-B3qIDyEQ.js} +3 -3
- package/dist/{textarea-DoH3Il8v.cjs → textarea-DkeCQKmM.cjs} +1 -1
- package/dist/{textinput-B6G4dVuL.js → textinput-CwvVRNsP.js} +3 -3
- package/dist/{textinput-CQknclmV.cjs → textinput-DibZCHh_.cjs} +1 -1
- package/dist/{timepicker-DB3gor6g.cjs → timepicker-CZ_1HVlF.cjs} +1 -1
- package/dist/{timepicker-Cd2QI6ua.js → timepicker-C_oG9W9Y.js} +3 -3
- package/package.json +2 -2
- package/src/components/heading/heading.test.ts +24 -0
- package/src/components/helptext/helptext-association.test.ts +36 -0
- package/dist/element-with-slot-DDLS-aLw.js +0 -227
- package/dist/element-with-slot-DhiAuSjM.cjs +0 -1
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { f as e, g as t, m as n, t as r } from "./element-DBugHPKM.js";
|
|
2
|
+
import { t as i } from "./async-directive-yh8hG41Q.js";
|
|
3
|
+
//#region src/controllers/pkt-slot-utils.ts
|
|
4
|
+
function a(e) {
|
|
5
|
+
return e.classList && (e.classList.contains("_dialog_overlay") || e.classList.contains("backdrop")) ? !0 : typeof e.hasAttribute == "function" && e.hasAttribute("data-skip");
|
|
6
|
+
}
|
|
7
|
+
function o(e) {
|
|
8
|
+
return e.nodeName === "OPTION" || e.nodeName === "DATA";
|
|
9
|
+
}
|
|
10
|
+
function s(e) {
|
|
11
|
+
return e.nodeType === Node.TEXT_NODE && e.nodeValue?.trim() !== "";
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/directives/slot-content.ts
|
|
15
|
+
var c = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap();
|
|
16
|
+
function u(e) {
|
|
17
|
+
let t = c.get(e);
|
|
18
|
+
return t || (t = new y(e), c.set(e, t)), t;
|
|
19
|
+
}
|
|
20
|
+
var d = Symbol("default");
|
|
21
|
+
function f(e) {
|
|
22
|
+
return e === void 0 ? d : e;
|
|
23
|
+
}
|
|
24
|
+
function p(e) {
|
|
25
|
+
return Array.isArray(e) ? e.map((e) => {
|
|
26
|
+
let t = e === null ? d : e;
|
|
27
|
+
return [t, t];
|
|
28
|
+
}) : Object.entries(e).map(([e, t]) => [e, t === null ? d : t]);
|
|
29
|
+
}
|
|
30
|
+
function m(e, t) {
|
|
31
|
+
return e.length === t.length && e.every(([e, n], r) => t[r][0] === e && t[r][1] === n);
|
|
32
|
+
}
|
|
33
|
+
function h(e, t) {
|
|
34
|
+
if (e.nodeType === Node.COMMENT_NODE) return !1;
|
|
35
|
+
if (e.nodeType === Node.TEXT_NODE) return s(e) ? (v(t, d, e), !0) : !1;
|
|
36
|
+
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
37
|
+
let n = e;
|
|
38
|
+
if (a(n) || o(n)) return !1;
|
|
39
|
+
if (n instanceof HTMLTemplateElement) {
|
|
40
|
+
let e = Array.from(n.content.childNodes), r = f(n.getAttribute("slot") ?? void 0);
|
|
41
|
+
for (let n of e) v(t, r, n);
|
|
42
|
+
return !0;
|
|
43
|
+
}
|
|
44
|
+
return v(t, g(e), e), !0;
|
|
45
|
+
}
|
|
46
|
+
return !1;
|
|
47
|
+
}
|
|
48
|
+
function g(e) {
|
|
49
|
+
if (e.nodeType !== Node.ELEMENT_NODE) return d;
|
|
50
|
+
let t = e.getAttribute("slot");
|
|
51
|
+
return t === null ? d : f(t);
|
|
52
|
+
}
|
|
53
|
+
function _(e, t) {
|
|
54
|
+
return e.node.compareDocumentPosition(t.node) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
|
|
55
|
+
}
|
|
56
|
+
function v(e, t, n) {
|
|
57
|
+
let r = e.get(t);
|
|
58
|
+
r || (r = [], e.set(t, r)), r.push(n);
|
|
59
|
+
}
|
|
60
|
+
var y = class e {
|
|
61
|
+
static {
|
|
62
|
+
this.PLACEHOLDER_PREFIX = "pkt-slot";
|
|
63
|
+
}
|
|
64
|
+
constructor(e) {
|
|
65
|
+
this.observer = null, this.nodesBySlot = /* @__PURE__ */ new Map(), this.directives = /* @__PURE__ */ new Set(), this.observing = !1, this.trackedNodes = /* @__PURE__ */ new Set(), this.generation = 0, this.initialCollectionDone = !1, this.processingMutations = !1, this.placeholderToNode = /* @__PURE__ */ new Map(), this.nodeToPlaceholder = /* @__PURE__ */ new Map(), this.sources = /* @__PURE__ */ new Map(), this.subscribers = /* @__PURE__ */ new Set(), this.followsHostRenders = !1, this.wantsObserver = !1, this.host = e, typeof e.addController == "function" && (this.followsHostRenders = !0, e.addController({
|
|
66
|
+
hostConnected: () => {
|
|
67
|
+
this.wantsObserver && this.startObserving();
|
|
68
|
+
},
|
|
69
|
+
hostDisconnected: () => this.stopObservingIfUnused(),
|
|
70
|
+
hostUpdate: () => {
|
|
71
|
+
e.hasUpdated || this.collectLateChildren(), this.flushMutations(!1);
|
|
72
|
+
},
|
|
73
|
+
hostUpdated: () => this.flushMutations(!0)
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
collectNodes() {
|
|
77
|
+
if (this.initialCollectionDone) return;
|
|
78
|
+
this.initialCollectionDone = !0, this.generation++;
|
|
79
|
+
let e = Array.from(this.host.childNodes);
|
|
80
|
+
for (let t of e) h(t, this.nodesBySlot) && this.track(t);
|
|
81
|
+
}
|
|
82
|
+
collectLateChildren() {
|
|
83
|
+
if (this.initialCollectionDone) for (let e of Array.from(this.host.childNodes)) this.trackedNodes.has(e) || !this.isUserContent(e) || (e instanceof HTMLTemplateElement ? h(e, this.nodesBySlot) : this.insertInSlotOrder(e), this.track(e), this.generation++);
|
|
84
|
+
}
|
|
85
|
+
addDirective(e) {
|
|
86
|
+
this.directives.add(e), this.startObserving();
|
|
87
|
+
}
|
|
88
|
+
removeDirective(e) {
|
|
89
|
+
this.directives.delete(e), this.stopObservingIfUnused();
|
|
90
|
+
}
|
|
91
|
+
addSource(e, t, n) {
|
|
92
|
+
let r = this.sources.get(e);
|
|
93
|
+
r && r.manager === t && m(r.mapping, n) || (r && r.manager !== t && this.detachFrom(r.manager, e), this.sources.set(e, {
|
|
94
|
+
manager: t,
|
|
95
|
+
mapping: n
|
|
96
|
+
}), t.subscribers.add(this), t.startObserving(), this.handleChange());
|
|
97
|
+
}
|
|
98
|
+
removeSource(e) {
|
|
99
|
+
let t = this.sources.get(e);
|
|
100
|
+
t && (this.sources.delete(e), this.detachFrom(t.manager, e), this.handleChange());
|
|
101
|
+
}
|
|
102
|
+
getNodes(e) {
|
|
103
|
+
return this.nodesFor(f(e));
|
|
104
|
+
}
|
|
105
|
+
hasContent(e) {
|
|
106
|
+
return this.getNodes(e).length > 0;
|
|
107
|
+
}
|
|
108
|
+
ensurePlaceholder(t) {
|
|
109
|
+
if (this.nodeToPlaceholder.has(t)) return;
|
|
110
|
+
if (t.parentNode !== this.host) {
|
|
111
|
+
for (let { manager: e } of this.sources.values()) e.ensurePlaceholder(t);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
let n = document.createComment(e.PLACEHOLDER_PREFIX);
|
|
115
|
+
this.host.insertBefore(n, t), this.placeholderToNode.set(n, t), this.nodeToPlaceholder.set(t, n);
|
|
116
|
+
}
|
|
117
|
+
nodesFor(e) {
|
|
118
|
+
let t = this.nodesBySlot.get(e) ?? [];
|
|
119
|
+
if (this.sources.size === 0) return t;
|
|
120
|
+
let n = [];
|
|
121
|
+
for (let { manager: t, mapping: r } of this.sources.values()) for (let [i, a] of r) a === e && n.push(...t.nodesFor(i));
|
|
122
|
+
return n.length ? [...t, ...n] : t;
|
|
123
|
+
}
|
|
124
|
+
detachFrom(e, t) {
|
|
125
|
+
[...this.sources.entries()].some(([n, r]) => n !== t && r.manager === e) || (e.subscribers.delete(this), e.stopObservingIfUnused());
|
|
126
|
+
}
|
|
127
|
+
handleChange() {
|
|
128
|
+
this.generation++, this.notifyDirectives();
|
|
129
|
+
for (let e of this.subscribers) e.handleChange();
|
|
130
|
+
this.host.requestUpdate();
|
|
131
|
+
}
|
|
132
|
+
stopObservingIfUnused() {
|
|
133
|
+
let e = this.directives.size === 0 && this.subscribers.size === 0;
|
|
134
|
+
(!this.host.isConnected || e && !this.followsHostRenders) && this.stopObserving();
|
|
135
|
+
}
|
|
136
|
+
startObserving() {
|
|
137
|
+
if (this.wantsObserver = !0, this.observing) return;
|
|
138
|
+
this.observing = !0;
|
|
139
|
+
let e = () => {
|
|
140
|
+
!this.observing || typeof MutationObserver > "u" || (this.observer = new MutationObserver((e) => {
|
|
141
|
+
this.handleMutations(e);
|
|
142
|
+
}), this.observer.observe(this.host, {
|
|
143
|
+
childList: !0,
|
|
144
|
+
subtree: !0
|
|
145
|
+
}));
|
|
146
|
+
};
|
|
147
|
+
this.followsHostRenders ? e() : setTimeout(e, 0);
|
|
148
|
+
}
|
|
149
|
+
flushMutations(e) {
|
|
150
|
+
if (this.processingMutations) return;
|
|
151
|
+
let t = this.observer?.takeRecords();
|
|
152
|
+
t?.length && this.handleMutations(t, e);
|
|
153
|
+
}
|
|
154
|
+
stopObserving() {
|
|
155
|
+
this.observing && (this.observing = !1, this.observer?.disconnect(), this.observer = null);
|
|
156
|
+
}
|
|
157
|
+
handleMutations(e, t = !1) {
|
|
158
|
+
if (this.processingMutations) return;
|
|
159
|
+
this.processingMutations = !0;
|
|
160
|
+
let n = !1, r = [], i = /* @__PURE__ */ new Map(), a = [];
|
|
161
|
+
for (let o of e) {
|
|
162
|
+
for (let e of o.removedNodes) {
|
|
163
|
+
let a = this.placeholderToNode.get(e);
|
|
164
|
+
if (a) {
|
|
165
|
+
if (this.placeholderToNode.delete(e), this.nodeToPlaceholder.delete(a), t) continue;
|
|
166
|
+
a.parentNode?.removeChild(a), this.untrack(a), this.removeFromSlots(a), n = !0;
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (this.trackedNodes.has(e) && !this.host.contains(e) && !t) {
|
|
170
|
+
this.untrack(e), this.removeFromSlots(e);
|
|
171
|
+
let t = this.nodeToPlaceholder.get(e);
|
|
172
|
+
if (t && (this.placeholderToNode.delete(t), this.nodeToPlaceholder.delete(e), r.push(t), o.target !== this.host)) {
|
|
173
|
+
let e = i.get(o.target) ?? [];
|
|
174
|
+
e.push(t), i.set(o.target, e);
|
|
175
|
+
}
|
|
176
|
+
n = !0;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (o.target !== this.host) {
|
|
180
|
+
o.addedNodes.length && a.push(o);
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
if (!t) for (let e of o.addedNodes) this.placeholderToNode.has(e) || !this.trackedNodes.has(e) && this.isUserContent(e) && (e instanceof HTMLTemplateElement ? h(e, this.nodesBySlot) : this.insertInSlotOrder(e), this.track(e), n = !0);
|
|
184
|
+
}
|
|
185
|
+
i.size && this.adoptNodesInParts(a, i) && (n = !0);
|
|
186
|
+
for (let e of r) e.parentNode?.removeChild(e);
|
|
187
|
+
n && this.handleChange(), this.observer?.takeRecords(), this.processingMutations = !1;
|
|
188
|
+
}
|
|
189
|
+
adoptNodesInParts(t, n) {
|
|
190
|
+
let r = /* @__PURE__ */ new Set();
|
|
191
|
+
for (let e of t) n.has(e.target) && e.addedNodes.forEach((e) => r.add(e));
|
|
192
|
+
if (r.size === 0) return !1;
|
|
193
|
+
let i = this.reachableParts(), a = [];
|
|
194
|
+
for (let e of r) {
|
|
195
|
+
if (!e.parentNode || !n.has(e.parentNode) || l.has(e) || this.placeholderToNode.has(e)) continue;
|
|
196
|
+
let t = i.find((t) => t.contains(e));
|
|
197
|
+
if (!t) continue;
|
|
198
|
+
let r = this.hostPositionFor(e, t, n);
|
|
199
|
+
r && a.push({
|
|
200
|
+
node: e,
|
|
201
|
+
before: r.before
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
if (a.length === 0) return !1;
|
|
205
|
+
let o = !1;
|
|
206
|
+
for (let { node: t, before: n } of a.sort(_)) if (this.isUserContent(t) && !(t instanceof HTMLTemplateElement)) {
|
|
207
|
+
let r = document.createComment(e.PLACEHOLDER_PREFIX);
|
|
208
|
+
this.host.insertBefore(r, n), this.placeholderToNode.set(r, t), this.nodeToPlaceholder.set(t, r), this.insertInSlotOrder(t), this.track(t), o = !0;
|
|
209
|
+
} else this.host.insertBefore(t, n);
|
|
210
|
+
return o;
|
|
211
|
+
}
|
|
212
|
+
hostPositionFor(e, t, n) {
|
|
213
|
+
let { startNode: r, endNode: i } = t.bounds();
|
|
214
|
+
for (let t = e.nextSibling; t && t !== i; t = t.nextSibling) {
|
|
215
|
+
let e = this.placeholderOf(t);
|
|
216
|
+
if (e) return { before: e };
|
|
217
|
+
}
|
|
218
|
+
for (let t = e.previousSibling; t && t !== r; t = t.previousSibling) {
|
|
219
|
+
let e = this.placeholderOf(t);
|
|
220
|
+
if (e) return { before: e.nextSibling };
|
|
221
|
+
}
|
|
222
|
+
let a = e.parentNode ? n.get(e.parentNode) : void 0;
|
|
223
|
+
return a ? { before: a[0] } : null;
|
|
224
|
+
}
|
|
225
|
+
placeholderOf(e) {
|
|
226
|
+
return this.trackedNodes.has(e) ? this.nodeToPlaceholder.get(e) : void 0;
|
|
227
|
+
}
|
|
228
|
+
reachableParts(e = /* @__PURE__ */ new Set()) {
|
|
229
|
+
if (e.has(this)) return [];
|
|
230
|
+
e.add(this);
|
|
231
|
+
let t = [...this.directives];
|
|
232
|
+
for (let n of this.subscribers) t.push(...n.reachableParts(e));
|
|
233
|
+
return t;
|
|
234
|
+
}
|
|
235
|
+
insertInSlotOrder(e) {
|
|
236
|
+
let t = g(e), n = this.nodesBySlot.get(t) ?? [];
|
|
237
|
+
this.nodesBySlot.set(t, n);
|
|
238
|
+
let r = this.nodeToPlaceholder.get(e) ?? e, i = (e) => {
|
|
239
|
+
let t = this.nodeToPlaceholder.get(e) ?? e;
|
|
240
|
+
return !!(r.compareDocumentPosition(t) & Node.DOCUMENT_POSITION_FOLLOWING);
|
|
241
|
+
};
|
|
242
|
+
if (n.length === 0 || !i(n[n.length - 1])) {
|
|
243
|
+
n.push(e);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
n.splice(n.findIndex(i), 0, e);
|
|
247
|
+
}
|
|
248
|
+
track(e) {
|
|
249
|
+
this.trackedNodes.add(e), l.set(e, this);
|
|
250
|
+
}
|
|
251
|
+
untrack(e) {
|
|
252
|
+
this.trackedNodes.delete(e), l.get(e) === this && l.delete(e);
|
|
253
|
+
}
|
|
254
|
+
isUserContent(e) {
|
|
255
|
+
if (e.nodeType === Node.COMMENT_NODE) return !1;
|
|
256
|
+
if (e.nodeType === Node.TEXT_NODE) return s(e);
|
|
257
|
+
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
258
|
+
let t = e;
|
|
259
|
+
return !(a(t) || o(t));
|
|
260
|
+
}
|
|
261
|
+
return !1;
|
|
262
|
+
}
|
|
263
|
+
removeFromSlots(e) {
|
|
264
|
+
for (let [t, n] of this.nodesBySlot) {
|
|
265
|
+
let r = n.indexOf(e);
|
|
266
|
+
if (r !== -1) {
|
|
267
|
+
n.splice(r, 1), n.length === 0 && this.nodesBySlot.delete(t);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
notifyDirectives() {
|
|
273
|
+
for (let e of this.directives) e.handleNodesChanged();
|
|
274
|
+
}
|
|
275
|
+
}, b = e(class extends i {
|
|
276
|
+
constructor(e) {
|
|
277
|
+
if (super(e), this.manager = null, this.host = null, this.part = null, this.lastGeneration = -1, e.type !== n.CHILD) throw Error("slotContent() can only be used in child expressions");
|
|
278
|
+
}
|
|
279
|
+
render(e, n) {
|
|
280
|
+
return t;
|
|
281
|
+
}
|
|
282
|
+
update(e, [n, r]) {
|
|
283
|
+
return this.part = e, this.host = n, this.slotName = r, this.manager || (this.manager = u(n), this.manager.collectNodes(), this.manager.addDirective(this)), this.placeNodes(), t;
|
|
284
|
+
}
|
|
285
|
+
handleNodesChanged() {
|
|
286
|
+
!this.isConnected || !this.manager || this.placeNodes();
|
|
287
|
+
}
|
|
288
|
+
disconnected() {
|
|
289
|
+
this.manager?.removeDirective(this), this.manager = null, this.lastGeneration = -1;
|
|
290
|
+
}
|
|
291
|
+
reconnected() {
|
|
292
|
+
this.host && (this.manager = u(this.host), this.manager.addDirective(this), this.placeNodes());
|
|
293
|
+
}
|
|
294
|
+
contains(e) {
|
|
295
|
+
let t = this.parentOfPart();
|
|
296
|
+
return this.isConnected && !!t && this.isInsidePart(e, t);
|
|
297
|
+
}
|
|
298
|
+
bounds() {
|
|
299
|
+
return {
|
|
300
|
+
startNode: this.part?.startNode ?? null,
|
|
301
|
+
endNode: this.part?.endNode ?? null
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
parentOfPart() {
|
|
305
|
+
return this.part ? this.part.startNode ? this.part.startNode.parentNode : this.part.parentNode : null;
|
|
306
|
+
}
|
|
307
|
+
placeNodes() {
|
|
308
|
+
if (!this.manager || !this.part) return;
|
|
309
|
+
let e = this.manager.generation;
|
|
310
|
+
if (e === this.lastGeneration) return;
|
|
311
|
+
this.lastGeneration = e;
|
|
312
|
+
let t = this.manager.getNodes(this.slotName);
|
|
313
|
+
for (let e of t) this.manager.ensurePlaceholder(e);
|
|
314
|
+
let n = this.parentOfPart();
|
|
315
|
+
if (!n) return;
|
|
316
|
+
let r = this.part.endNode;
|
|
317
|
+
for (let e = t.length - 1; e >= 0; e--) {
|
|
318
|
+
let i = t[e];
|
|
319
|
+
this.isInsidePart(i, n) || n.insertBefore(i, r), r = i;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
isInsidePart(e, t) {
|
|
323
|
+
if (!this.part || e.parentNode !== t) return !1;
|
|
324
|
+
let { startNode: n, endNode: r } = this.part, i = !n || !!(n.compareDocumentPosition(e) & Node.DOCUMENT_POSITION_FOLLOWING), a = !r || !!(e.compareDocumentPosition(r) & Node.DOCUMENT_POSITION_FOLLOWING);
|
|
325
|
+
return i && a;
|
|
326
|
+
}
|
|
327
|
+
}), x = e(class extends i {
|
|
328
|
+
constructor(e) {
|
|
329
|
+
if (super(e), this.target = null, this.source = null, this.mapping = [], e.type !== n.ELEMENT) throw Error("forwardSlots() can only be used as an element directive");
|
|
330
|
+
}
|
|
331
|
+
render(e, n) {
|
|
332
|
+
return t;
|
|
333
|
+
}
|
|
334
|
+
update(e, [n, r]) {
|
|
335
|
+
let i = u(e.element);
|
|
336
|
+
return this.target && this.target !== i && this.target.removeSource(this), this.target = i, this.source = u(n), this.source.collectNodes(), this.mapping = p(r), this.target.addSource(this, this.source, this.mapping), t;
|
|
337
|
+
}
|
|
338
|
+
disconnected() {
|
|
339
|
+
this.target?.removeSource(this);
|
|
340
|
+
}
|
|
341
|
+
reconnected() {
|
|
342
|
+
this.target && this.source && this.target.addSource(this, this.source, this.mapping);
|
|
343
|
+
}
|
|
344
|
+
}), S = class extends r {
|
|
345
|
+
connectedCallback() {
|
|
346
|
+
u(this).collectNodes(), super.connectedCallback();
|
|
347
|
+
}
|
|
348
|
+
hasSlotContent(e) {
|
|
349
|
+
return u(this).hasContent(e);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
//#endregion
|
|
353
|
+
export { o as a, b as i, x as n, u as r, S as t };
|
|
@@ -1,14 +1,14 @@
|
|
|
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-DBugHPKM.js";
|
|
2
2
|
import { t as s } from "./class-map-Bf-QzUpN.js";
|
|
3
3
|
import { n as c, t as l } from "./format-BTeSVkED.js";
|
|
4
|
-
import "./alert-
|
|
4
|
+
import "./alert-CUH_2zb2.js";
|
|
5
5
|
import "./icon-Bao96Zb8.js";
|
|
6
6
|
import { t as u } from "./if-defined-O59_I-e-.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-Uks0spRR.js";
|
|
10
10
|
import { r as p } from "./focus-trap-DG3pEuyJ.js";
|
|
11
|
-
import "./modal-
|
|
11
|
+
import "./modal-Bm1daKaW.js";
|
|
12
12
|
import "./progressbar-DZHiq7B0.js";
|
|
13
13
|
//#region ../../shared-utils/fileupload/size.ts
|
|
14
14
|
function m(e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./format-B8meU8Tm.cjs");require("./alert-QfloIr-o.cjs"),require("./icon-jPhyZD1z.cjs");const r=require("./if-defined-CiML3MTM.cjs"),i=require("./converters-BJ9Fe0kW.cjs"),a=require("./utils-63cRpWut.cjs");require("./input-wrapper-BT6B3Kco.cjs");const o=require("./focus-trap-DSv4Ifqm.cjs");require("./modal-CoEPzt4p.cjs"),require("./progressbar-CnX4fFfR.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`)||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(){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 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-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./format-B8meU8Tm.cjs");require("./alert-BJPi5ylH.cjs"),require("./icon-jPhyZD1z.cjs");const r=require("./if-defined-CiML3MTM.cjs"),i=require("./converters-BJ9Fe0kW.cjs"),a=require("./utils-63cRpWut.cjs");require("./input-wrapper-EvzyXMw-.cjs");const o=require("./focus-trap-DSv4Ifqm.cjs");require("./modal-BPweteoS.cjs"),require("./progressbar-CnX4fFfR.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`)||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(){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 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-C6WTyJFE.cjs");require("./consent-
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs");require("./consent-CkK9BZ7t.cjs");const t=require("./booleanish-BF8l4scU.cjs"),n=require("./fetch-header-footer-data-CUKV0biS.cjs");require("./icon-jPhyZD1z.cjs");const r=require("./if-defined-CiML3MTM.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 n.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 n.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(t){let{target:n,rel:i}=this.linkTarget(t);return e._`
|
|
2
2
|
<a href=${t.href} target=${n} rel=${r.t(i)}
|
|
3
3
|
>${t.text}${this.renderLinkDomain(t)}</a
|
|
4
4
|
>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as e, d as t, h as n, l as r, n as i, t as a, u as o } from "./element-DBugHPKM.js";
|
|
2
|
-
import "./consent-
|
|
2
|
+
import "./consent-eTXt052m.js";
|
|
3
3
|
import { t as s } from "./booleanish-OQJTYSrw.js";
|
|
4
4
|
import { n as c, r as l, t as u } from "./fetch-header-footer-data-Pc32etrk.js";
|
|
5
5
|
import "./icon-Bao96Zb8.js";
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { _ as e, d as t, h as n, l as r, n as i, t as a, u as o } from "./element-DBugHPKM.js";
|
|
2
2
|
import { t as s } from "./class-map-Bf-QzUpN.js";
|
|
3
3
|
import { t as c } from "./format-BTeSVkED.js";
|
|
4
|
-
import { i as l, t as u } from "./element-with-slot-
|
|
4
|
+
import { i as l, t as u } from "./element-with-slot-U981OZM_.js";
|
|
5
5
|
import { t as d } from "./booleanish-OQJTYSrw.js";
|
|
6
6
|
import { n as f, o as p, t as m } from "./fetch-header-footer-data-Pc32etrk.js";
|
|
7
7
|
import "./icon-Bao96Zb8.js";
|
|
8
8
|
import { t as h } from "./if-defined-O59_I-e-.js";
|
|
9
|
-
import "./button-
|
|
9
|
+
import "./button-DQ8rH8hx.js";
|
|
10
10
|
import { n as g, t as _ } from "./ref-y_5qv9vU.js";
|
|
11
11
|
import { n as v, t as y } from "./focus-trap-DG3pEuyJ.js";
|
|
12
12
|
import { n as b, t as x } from "./scroll-lock-DAbNKAUy.js";
|
|
13
|
-
import "./link-
|
|
14
|
-
import "./textinput-
|
|
13
|
+
import "./link-C0yBFscy.js";
|
|
14
|
+
import "./textinput-CwvVRNsP.js";
|
|
15
15
|
import "./searchinput-Bkcr3Fby.js";
|
|
16
|
-
import "./header-menu-
|
|
16
|
+
import "./header-menu-0UtMd2_H.js";
|
|
17
17
|
//#region ../../shared-types/header.ts
|
|
18
18
|
var S = (e) => typeof e.target == "string" ? {
|
|
19
19
|
title: e.title,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-DOt8HbXA.cjs"),i=require("./booleanish-BF8l4scU.cjs"),a=require("./fetch-header-footer-data-CUKV0biS.cjs");require("./icon-jPhyZD1z.cjs");const o=require("./if-defined-CiML3MTM.cjs");require("./button-CWHqXdSG.cjs");const s=require("./ref-CB7e9nMY.cjs"),c=require("./focus-trap-DSv4Ifqm.cjs"),l=require("./scroll-lock-BN8lOhV5.cjs");require("./link-CLdiz-ly.cjs"),require("./textinput-DibZCHh_.cjs"),require("./searchinput-Mdc9Ihld.cjs"),require("./header-menu-BqFpYI-V.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.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),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(){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){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}
|
|
@@ -3,7 +3,7 @@ import { t as s } from "./class-map-Bf-QzUpN.js";
|
|
|
3
3
|
import { t as c } from "./booleanish-OQJTYSrw.js";
|
|
4
4
|
import { a as l, i as u, n as d, r as f, t as p } from "./fetch-header-footer-data-Pc32etrk.js";
|
|
5
5
|
import "./icon-Bao96Zb8.js";
|
|
6
|
-
import "./accordion-
|
|
6
|
+
import "./accordion-BhCmUDoS.js";
|
|
7
7
|
//#region src/components/header-menu/header-menu.ts
|
|
8
8
|
var m = class extends a {
|
|
9
9
|
constructor(...e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./booleanish-BF8l4scU.cjs"),r=require("./fetch-header-footer-data-CUKV0biS.cjs");require("./icon-jPhyZD1z.cjs"),require("./accordion-
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./booleanish-BF8l4scU.cjs"),r=require("./fetch-header-footer-data-CUKV0biS.cjs");require("./icon-jPhyZD1z.cjs"),require("./accordion-BFKmnCDh.cjs");var i=class extends e.t{constructor(...e){super(...e),this.dataUrl=r.a,this.locale=`nb-NO`,this.open=!1,this.mobileBreakpoint=768,this.loadState=`idle`,this.isMobile=!1,this.menuWidth=0}connectedCallback(){super.connectedCallback(),this.classList.add(`pkt-header-menu`),this.updateOpenClass(),this.observeWidth(),this.data?(this.loadState=`ready`,this.dispatchEvent(new CustomEvent(`data-loaded`,{detail:{data:this.data},bubbles:!0,composed:!0}))):this.loadData()}updateOpenClass(){this.classList.toggle(`pkt-header-menu--open`,!!this.open)}disconnectedCallback(){super.disconnectedCallback(),this.abortController?.abort(),this.resizeObserver?.disconnect(),this.resizeObserver=void 0}updated(e){super.updated(e),e.has(`open`)&&this.updateOpenClass(),e.has(`mobileBreakpoint`)&&e.get(`mobileBreakpoint`)!==void 0&&this.refreshIsMobile(),e.has(`dataUrl`)&&e.get(`dataUrl`)!==void 0&&!this.data&&this.loadData(),e.has(`data`)&&e.get(`data`)!==void 0&&this.data&&(this.loadState=`ready`,this.dispatchEvent(new CustomEvent(`data-loaded`,{detail:{data:this.data},bubbles:!0,composed:!0})))}observeWidth(){typeof ResizeObserver>`u`||(this.menuWidth=this.offsetWidth,this.refreshIsMobile(),this.resizeObserver=new ResizeObserver(e=>{for(let t of e)this.menuWidth=t.borderBoxSize&&t.borderBoxSize.length>0?t.borderBoxSize[0].inlineSize:t.contentRect.width,this.refreshIsMobile()}),this.resizeObserver.observe(this))}refreshIsMobile(){this.isMobile=this.menuWidth<this.mobileBreakpoint}async loadData(){this.abortController?.abort(),this.abortController=new AbortController,this.loadState=`loading`;try{let e=await r.t(this.dataUrl,this.abortController.signal);this.fetchedData=e,this.loadState=`ready`,this.dispatchEvent(new CustomEvent(`data-loaded`,{detail:{data:e},bubbles:!0,composed:!0}))}catch(e){if(e.name===`AbortError`)return;this.loadState=`error`,this.dispatchEvent(new CustomEvent(`data-error`,{detail:{error:e},bubbles:!0,composed:!0}))}}get effectiveData(){return this.data??this.fetchedData}get localeData(){return r.n(this.effectiveData,this.locale)}render(){if(this.loadState===`loading`)return e._`
|
|
2
2
|
<nav aria-busy="true">
|
|
3
3
|
<p class="pkt-header-menu__loading">${this.pktStrings.get(`header`).menuLoading}</p>
|
|
4
4
|
</nav>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./element-with-slot-
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./element-with-slot-DOt8HbXA.cjs");var n=class extends t.t{constructor(...e){super(...e),this.size=void 0,this.level=2,this.weight=void 0,this.visuallyHidden=!1,this.align=void 0}willUpdate(e){super.willUpdate(e),e.has(`level`)&&(this.level<1||this.level>6)&&console.warn(`Invalid heading level: ${this.level}. Must be between 1 and 6.`),this.size===void 0&&(this.size=this.defaultSizeForLevel),this.weight===void 0&&(this.weight=this.defaultWeightForLevel)}get defaultSizeForLevel(){switch(this.level){case 1:return`xlarge`;case 2:return`large`;case 3:return`medium`;case 4:return`small`;case 5:case 6:return`xsmall`;default:return`medium`}}get defaultWeightForLevel(){switch(this.level){case 1:case 2:return`regular`;case 3:case 4:case 5:case 6:return`medium`;default:return`medium`}}get headingClasses(){return[`pkt-heading`,this.size&&`pkt-heading--${this.size}`,this.weight&&`pkt-heading--fw-${this.weight}`,this.visuallyHidden&&`pkt-sr-only`,this.align&&`pkt-heading--${this.align}`].filter(Boolean).join(` `)}render(){let n=this.headingClasses,r=t.i(this);switch(this.level>=1&&this.level<=6?this.level:2){case 1:return e._`<h1 class=${n}>${r}</h1>`;case 2:return e._`<h2 class=${n}>${r}</h2>`;case 3:return e._`<h3 class=${n}>${r}</h3>`;case 4:return e._`<h4 class=${n}>${r}</h4>`;case 5:return e._`<h5 class=${n}>${r}</h5>`;case 6:return e._`<h6 class=${n}>${r}</h6>`;default:return e._`<h2 class=${n}>${r}</h2>`}}};e.n([e.u({type:String,reflect:!0})],n.prototype,`size`,void 0),e.n([e.u({type:Number,reflect:!0})],n.prototype,`level`,void 0),e.n([e.u({type:String,reflect:!0})],n.prototype,`weight`,void 0),e.n([e.u({type:Boolean,reflect:!0})],n.prototype,`visuallyHidden`,void 0),e.n([e.u({type:String,reflect:!0})],n.prototype,`align`,void 0);try{e.d(`pkt-heading`)(n)}catch{console.warn(`Forsøker å definere <pkt-heading>, men den er allerede definert`)}var r=n;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as e, d as t, n, u as r } from "./element-DBugHPKM.js";
|
|
2
|
-
import { i, t as a } from "./element-with-slot-
|
|
2
|
+
import { i, t as a } from "./element-with-slot-U981OZM_.js";
|
|
3
3
|
//#region src/components/heading/heading.ts
|
|
4
4
|
var o = class extends a {
|
|
5
5
|
constructor(...e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./element-with-slot-
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./element-with-slot-DOt8HbXA.cjs"),r=require("./icon-jPhyZD1z.cjs"),i=require("./utils-63cRpWut.cjs");var a=class extends n.t{constructor(...e){super(...e),this.forId=i.n(),this.helptext=``,this.helptextDropdown=``,this.isHelpTextOpen=!1}render(){let i=()=>{let e=!this.isHelpTextOpen;this.isHelpTextOpen=e,this.dispatchEvent(new CustomEvent(`toggleHelpText`,{bubbles:!0,detail:{isOpen:e}}))},a=t.t({"pkt-inputwrapper__helptext-container":!0,"pkt-inputwrapper__has-helptext":this.helptext||this.helptextDropdown||this.hasSlotContent()});return e._`${e._`<div class="${a}">
|
|
2
2
|
<div class="pkt-inputwrapper__helptext" id="${this.forId}-helptext">
|
|
3
3
|
<div class="pkt-contents">${n.i(this)}</div>
|
|
4
4
|
${this.helptext?e._`<span>${r.r(this.helptext)}</span>`:e.h}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-DBugHPKM.js";
|
|
2
2
|
import { t as o } from "./class-map-Bf-QzUpN.js";
|
|
3
|
-
import { i as s, t as c } from "./element-with-slot-
|
|
3
|
+
import { i as s, t as c } from "./element-with-slot-U981OZM_.js";
|
|
4
4
|
import { r as l } from "./icon-Bao96Zb8.js";
|
|
5
5
|
import { n as u } from "./utils-BwF4QSrq.js";
|
|
6
6
|
//#region src/components/helptext/helptext.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { l as e, n as t, u as n } from "./element-DBugHPKM.js";
|
|
2
2
|
import { t as r } from "./format-BTeSVkED.js";
|
|
3
|
-
import { t as i } from "./element-with-slot-
|
|
3
|
+
import { t as i } from "./element-with-slot-U981OZM_.js";
|
|
4
4
|
import { n as a, t as o } from "./booleanish-OQJTYSrw.js";
|
|
5
5
|
import { n as s } from "./utils-BwF4QSrq.js";
|
|
6
6
|
//#region ../../node_modules/element-internals-polyfill/dist/maps.js
|