@oslokommune/punkt-elements 12.42.7 → 12.42.9
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/{accordionitem-Dz6jwPpb.cjs → accordionitem-C4NQFQHo.cjs} +1 -1
- package/dist/{accordionitem-DkE9or0K.js → accordionitem-aQHOrGzf.js} +1 -1
- package/dist/{alert-BY97zZYx.cjs → alert-DUWuhtFC.cjs} +1 -1
- package/dist/{alert-oh7nc3ip.js → alert-sBHt7DSh.js} +1 -1
- package/dist/{button-OLSvT2Im.js → button-B4Oe8Ar0.js} +62 -47
- package/dist/button-BT-FRGMk.cjs +19 -0
- package/dist/{card-BxHlJq4J.js → card-0Kf9L0A_.js} +2 -2
- package/dist/{card-CmdIb2X9.cjs → card-CXhVAeOG.cjs} +1 -1
- package/dist/{combobox-hYeZxIku.js → combobox-CsFDvh8U.js} +4 -4
- package/dist/{combobox-CZJrOopi.cjs → combobox-Dq7F5v-u.cjs} +1 -1
- package/dist/{consent-ChCTj6FB.js → consent-B17ZIuwm.js} +1 -1
- package/dist/{consent-B7w1--m7.cjs → consent-CILYIgC-.cjs} +1 -1
- package/dist/{datepicker-Cf45KOxr.js → datepicker-Cz6seIz1.js} +3 -3
- package/dist/{datepicker-CE5oM9D3.cjs → datepicker-DOf9XK9v.cjs} +1 -1
- package/dist/{heading-Bxonbv8M.js → heading-CGGKEZve.js} +1 -1
- package/dist/{heading-CxJ0IqpU.cjs → heading-Cmh5bbTl.cjs} +1 -1
- package/dist/helptext-BG_b6ytC.js +87 -0
- package/dist/helptext-CC3qLmEz.cjs +24 -0
- package/dist/index.d.ts +3 -2
- package/dist/{input-wrapper-DnyRiuHR.js → input-wrapper-CC_R5w7V.js} +61 -68
- package/dist/input-wrapper-Dk0rKRlz.cjs +53 -0
- package/dist/{link-Qj1bJCPw.js → link-C9X0huxP.js} +1 -1
- package/dist/{link-BWJrqWi7.cjs → link-qTz-qNVI.cjs} +1 -1
- package/dist/{linkcard-Byt10fUI.js → linkcard-Bhk2ttou.js} +1 -1
- package/dist/{linkcard-0KLDuaGM.cjs → linkcard-CaBz6i7A.cjs} +1 -1
- package/dist/{loader--5h6NKGl.cjs → loader-BqYcg8Di.cjs} +1 -1
- package/dist/{loader-xkMMWgaj.js → loader-DMp859px.js} +1 -1
- package/dist/{messagebox-IJOkv427.cjs → messagebox-Do_nAUo3.cjs} +1 -1
- package/dist/{messagebox-BLTBG8nD.js → messagebox-_1f12rDq.js} +1 -1
- package/dist/{modal-CBURcXBd.cjs → modal-C1inKvts.cjs} +1 -1
- package/dist/{modal-C6ljjVs6.js → modal-C3kEgTMj.js} +1 -1
- package/dist/pkt-accordion.cjs +1 -1
- package/dist/pkt-accordion.js +2 -2
- 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-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-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 +20 -20
- 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-CZO1nxZ8.js +39 -0
- package/dist/pkt-options-controller-CiuBG6Lt.cjs +1 -0
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/{pkt-slot-controller-DtDaD9q_.js → pkt-slot-controller-BPGj-LC5.js} +39 -28
- package/dist/pkt-slot-controller-BzddBp7z.cjs +1 -0
- 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/{select-BNGnC2U9.cjs → select-BkVSXR5K.cjs} +1 -1
- package/dist/{select-Drl_8-OU.js → select-BlL8T2BX.js} +18 -18
- package/dist/{tag-lU4vz70a.cjs → tag-DrbI0ng3.cjs} +1 -1
- package/dist/{tag-CX-zbR-7.js → tag-m7OTZaCG.js} +1 -1
- package/dist/{textarea-DcpZnWkt.cjs → textarea-Dc1sUaxx.cjs} +1 -1
- package/dist/{textarea-CctE69uw.js → textarea-Dk8hQMD2.js} +2 -2
- package/dist/{textinput-BAPxDvKu.js → textinput-6Ip-0aVY.js} +2 -2
- package/dist/{textinput-DcES1ibY.cjs → textinput-DuLZ26DB.cjs} +1 -1
- package/package.json +3 -3
- package/src/components/button/button.ts +28 -2
- package/src/components/helptext/helptext.ts +13 -1
- package/src/components/input-wrapper/input-wrapper.ts +1 -10
- package/src/components/select/select.ts +1 -1
- package/dist/button-KzBZ-Bff.cjs +0 -19
- package/dist/helptext-AqNI_oFG.cjs +0 -24
- package/dist/helptext-DBearL3P.js +0 -78
- package/dist/input-wrapper-Uw7_cZ4w.cjs +0 -53
- package/dist/pkt-options-controller-C_Yl_3P6.js +0 -39
- package/dist/pkt-options-controller-ftMgG5DP.cjs +0 -1
- package/dist/pkt-slot-controller-Da-RgXfS.cjs +0 -1
package/dist/pkt-link.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./link-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./link-qTz-qNVI.cjs"),t=e.PktLink;Object.defineProperty(exports,"PktLink",{enumerable:!0,get:()=>e.PktLink});exports.default=t;
|
package/dist/pkt-link.js
CHANGED
package/dist/pkt-linkcard.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./linkcard-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./linkcard-CaBz6i7A.cjs"),t=e.PktLinkCard;Object.defineProperty(exports,"PktLinkCard",{enumerable:!0,get:()=>e.PktLinkCard});exports.default=t;
|
package/dist/pkt-linkcard.js
CHANGED
package/dist/pkt-loader.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./loader
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./loader-BqYcg8Di.cjs"),t=e.PktLoader;Object.defineProperty(exports,"PktLoader",{enumerable:!0,get:()=>e.PktLoader});exports.default=t;
|
package/dist/pkt-loader.js
CHANGED
package/dist/pkt-messagebox.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./messagebox-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./messagebox-Do_nAUo3.cjs"),t=e.PktMessagebox;Object.defineProperty(exports,"PktMessagebox",{enumerable:!0,get:()=>e.PktMessagebox});exports.default=t;
|
package/dist/pkt-messagebox.js
CHANGED
package/dist/pkt-modal.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./modal-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./modal-C1inKvts.cjs"),t=e.PktModal;Object.defineProperty(exports,"PktModal",{enumerable:!0,get:()=>e.PktModal});exports.default=t;
|
package/dist/pkt-modal.js
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { i as r } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
2
|
+
class o {
|
|
3
|
+
constructor(t) {
|
|
4
|
+
this.nodes = [], this.options = [], this.host = t, this.host.addController(this), this.nodes = [], this.options = [], this.observer = new MutationObserver((e) => this.handleMutations(e));
|
|
5
|
+
}
|
|
6
|
+
hostConnected() {
|
|
7
|
+
Array.from(this.host.childNodes).forEach((t) => {
|
|
8
|
+
(t.nodeName === "OPTION" || t.nodeName === "DATA") && this.addNode(t);
|
|
9
|
+
}), this.observer.observe(this.host, { childList: !0, subtree: !1, attributes: !0 });
|
|
10
|
+
}
|
|
11
|
+
hostDisconnected() {
|
|
12
|
+
this.observer.disconnect();
|
|
13
|
+
}
|
|
14
|
+
addNode(t) {
|
|
15
|
+
(t.nodeName === "OPTION" || t.nodeName === "DATA") && (t.hasAttribute("hidden") && !t.hasAttribute("data-skip") && t.setAttribute("data-hidden", "true"), !t.hasAttribute("hidden") && t.hasAttribute("data-skip") && t.hasAttribute("data-hidden") && t.removeAttribute("data-hidden"), t.setAttribute("class", "pkt-hide"), t.setAttribute("data-skip", "true"), t.setAttribute("hidden", "true"), this.nodes.push(t));
|
|
16
|
+
}
|
|
17
|
+
createOptions() {
|
|
18
|
+
this.options = this.nodes.map((t) => ({
|
|
19
|
+
value: t.hasAttribute("value") ? t.getAttribute("value") ?? "" : t.textContent ?? "",
|
|
20
|
+
label: t.textContent || t.getAttribute("value") || "",
|
|
21
|
+
selected: t.hasAttribute("selected"),
|
|
22
|
+
disabled: t.hasAttribute("disabled"),
|
|
23
|
+
hidden: t.hasAttribute("data-hidden")
|
|
24
|
+
})), this.host.setAttribute("options", JSON.stringify(this.options));
|
|
25
|
+
}
|
|
26
|
+
handleMutations(t) {
|
|
27
|
+
let e = !1;
|
|
28
|
+
t.forEach((s) => {
|
|
29
|
+
s.type === "childList" && (s.addedNodes.forEach((i) => {
|
|
30
|
+
r(i) && (this.addNode(i), e = !0);
|
|
31
|
+
}), s.removedNodes.forEach((i) => {
|
|
32
|
+
r(i) && (this.nodes = this.nodes.filter((h) => h !== i), e = !0);
|
|
33
|
+
})), s.type === "attributes" && r(s.target) && (this.addNode(s.target), e = !0);
|
|
34
|
+
}), e && this.createOptions();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
o as P
|
|
39
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=require("./pkt-slot-controller-BzddBp7z.cjs");class a{constructor(t){this.nodes=[],this.options=[],this.host=t,this.host.addController(this),this.nodes=[],this.options=[],this.observer=new MutationObserver(e=>this.handleMutations(e))}hostConnected(){Array.from(this.host.childNodes).forEach(t=>{(t.nodeName==="OPTION"||t.nodeName==="DATA")&&this.addNode(t)}),this.observer.observe(this.host,{childList:!0,subtree:!1,attributes:!0})}hostDisconnected(){this.observer.disconnect()}addNode(t){(t.nodeName==="OPTION"||t.nodeName==="DATA")&&(t.hasAttribute("hidden")&&!t.hasAttribute("data-skip")&&t.setAttribute("data-hidden","true"),!t.hasAttribute("hidden")&&t.hasAttribute("data-skip")&&t.hasAttribute("data-hidden")&&t.removeAttribute("data-hidden"),t.setAttribute("class","pkt-hide"),t.setAttribute("data-skip","true"),t.setAttribute("hidden","true"),this.nodes.push(t))}createOptions(){this.options=this.nodes.map(t=>({value:t.hasAttribute("value")?t.getAttribute("value")??"":t.textContent??"",label:t.textContent||t.getAttribute("value")||"",selected:t.hasAttribute("selected"),disabled:t.hasAttribute("disabled"),hidden:t.hasAttribute("data-hidden")})),this.host.setAttribute("options",JSON.stringify(this.options))}handleMutations(t){let e=!1;t.forEach(s=>{s.type==="childList"&&(s.addedNodes.forEach(i=>{r.isOptionElement(i)&&(this.addNode(i),e=!0)}),s.removedNodes.forEach(i=>{r.isOptionElement(i)&&(this.nodes=this.nodes.filter(h=>h!==i),e=!0)})),s.type==="attributes"&&r.isOptionElement(s.target)&&(this.addNode(s.target),e=!0)}),e&&this.createOptions()}}exports.PktOptionsSlotController=a;
|
package/dist/pkt-select.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./select-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./select-BkVSXR5K.cjs"),t=e.PktSelect;Object.defineProperty(exports,"PktSelect",{enumerable:!0,get:()=>e.PktSelect});exports.default=t;
|
package/dist/pkt-select.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
function
|
|
1
|
+
function c(e, s) {
|
|
2
2
|
return s.some((t) => t.value === e);
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function r(e) {
|
|
5
5
|
return e.classList && (e.classList.contains("_dialog_overlay") || e.classList.contains("backdrop")) ? !0 : typeof e.hasAttribute == "function" && e.hasAttribute("data-skip");
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function a(e) {
|
|
8
8
|
return e.nodeName === "OPTION" || e.nodeName === "DATA";
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return e.nodeType === Node.ELEMENT_NODE && !
|
|
10
|
+
function p(e, s) {
|
|
11
|
+
return e.nodeType === Node.ELEMENT_NODE && !c(e, s);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function d(e) {
|
|
14
14
|
var s;
|
|
15
15
|
return e.nodeType === Node.TEXT_NODE && ((s = e.nodeValue) == null ? void 0 : s.trim()) !== "";
|
|
16
16
|
}
|
|
17
|
-
class
|
|
17
|
+
class N {
|
|
18
18
|
constructor(s, ...t) {
|
|
19
|
-
this.nodes = [], this.filledSlots = /* @__PURE__ */ new Set(), this.skipOptions = !1, this.updatingSlots = !1, this.host = s, this.host.addController(this), this.slots = t, this.nodes = [], this.observer = new MutationObserver((
|
|
19
|
+
this.nodes = [], this.filledSlots = /* @__PURE__ */ new Set(), this.skipOptions = !1, this.updatingSlots = !1, this.host = s, this.host.addController(this), this.slots = t, this.nodes = [], this.observer = new MutationObserver((l) => this.handleMutations(l)), this.contentObserver = new MutationObserver((l) => this.handleSlotMutations(l));
|
|
20
20
|
}
|
|
21
21
|
hostConnected() {
|
|
22
22
|
this.updateNodes(), this.observer.observe(this.host, { childList: !0 }), this.contentObserver.observe(this.host, { childList: !0, subtree: !0 });
|
|
@@ -30,7 +30,7 @@ class c {
|
|
|
30
30
|
// ********* UPDATE NODES *********
|
|
31
31
|
updateNodes() {
|
|
32
32
|
this.nodes = [], Array.from(this.host.childNodes).forEach((t) => {
|
|
33
|
-
|
|
33
|
+
r(t) || a(t) && this.skipOptions || (!c(t, this.slots) || d(t)) && this.nodes.push(t);
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
// ********* UPDATE SLOTS *********
|
|
@@ -40,43 +40,54 @@ class c {
|
|
|
40
40
|
const s = /* @__PURE__ */ new Set();
|
|
41
41
|
this.slots.forEach((t) => {
|
|
42
42
|
if (!t.value) return;
|
|
43
|
-
const
|
|
44
|
-
|
|
43
|
+
const l = t.value.getAttribute("name");
|
|
44
|
+
Array.from(t.value.childNodes).some((o) => {
|
|
45
|
+
var u, f;
|
|
46
|
+
if (o.nodeType === Node.COMMENT_NODE) return !1;
|
|
47
|
+
if (o.nodeType === Node.TEXT_NODE) return !!((u = o.textContent) != null && u.trim());
|
|
48
|
+
if (o.nodeType === Node.ELEMENT_NODE) {
|
|
49
|
+
if (r(o)) return !1;
|
|
50
|
+
if ((f = o.textContent) != null && f.trim()) return !0;
|
|
51
|
+
}
|
|
52
|
+
return !1;
|
|
53
|
+
}) && s.add(l);
|
|
54
|
+
const n = this.nodes.flatMap(
|
|
55
|
+
(o) => d(o) || o.getAttribute && o.getAttribute("slot") == l && !r(o) ? o : []
|
|
45
56
|
).filter(
|
|
46
|
-
(
|
|
57
|
+
(o) => t.value && !t.value.contains(o) && !o.contains(t.value)
|
|
47
58
|
);
|
|
48
|
-
if (
|
|
49
|
-
if (
|
|
59
|
+
if (n.length > 0)
|
|
60
|
+
if (typeof t.value.replaceChildren != "function") {
|
|
50
61
|
for (; t.value.firstChild; )
|
|
51
62
|
t.value.removeChild(t.value.firstChild);
|
|
52
|
-
t.value.append(...
|
|
63
|
+
t.value.append(...n);
|
|
53
64
|
} else
|
|
54
|
-
t.value.replaceChildren(...
|
|
55
|
-
}), (this.filledSlots.size !== s.size || ![...this.filledSlots].every((t) => s.has(t))) && (this.filledSlots = s, this.host.
|
|
65
|
+
t.value.replaceChildren(...n);
|
|
66
|
+
}), (this.filledSlots.size !== s.size || ![...this.filledSlots].every((t) => s.has(t))) && (this.filledSlots = s, typeof this.host.updateSlots == "function" && this.host.updateSlots(this.filledSlots)), this.updatingSlots = !1;
|
|
56
67
|
}
|
|
57
68
|
// ********* HANDLE MUTATIONS *********
|
|
58
69
|
handleMutations(s) {
|
|
59
70
|
let t = !1;
|
|
60
|
-
s.forEach((
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}),
|
|
64
|
-
|
|
71
|
+
s.forEach((l) => {
|
|
72
|
+
l.type === "childList" && (l.addedNodes.forEach((i) => {
|
|
73
|
+
r(i) || a(i) && this.skipOptions || (p(i, this.slots) || d(i)) && (this.nodes.push(i), t = !0);
|
|
74
|
+
}), l.removedNodes.forEach((i) => {
|
|
75
|
+
r(i) || a(i) && this.skipOptions || (this.nodes = this.nodes.filter((h) => h !== i), t = !0);
|
|
65
76
|
}));
|
|
66
77
|
}), t && this.updateSlots();
|
|
67
78
|
}
|
|
68
79
|
handleSlotMutations(s) {
|
|
69
80
|
let t = !1;
|
|
70
|
-
s.forEach((
|
|
71
|
-
const i =
|
|
81
|
+
s.forEach((l) => {
|
|
82
|
+
const i = l.target.parentElement;
|
|
72
83
|
if (i != null && i.hasAttribute("slot")) {
|
|
73
|
-
const h = i.getAttribute("slot"),
|
|
74
|
-
|
|
84
|
+
const h = i.getAttribute("slot"), n = i.hasChildNodes();
|
|
85
|
+
n && !this.filledSlots.has(h) ? (this.filledSlots.add(h), t = !0) : !n && this.filledSlots.has(h) && (this.filledSlots.delete(h), t = !0);
|
|
75
86
|
}
|
|
76
87
|
}), t && typeof this.host.updateSlots == "function" && this.host.updateSlots(this.filledSlots);
|
|
77
88
|
}
|
|
78
89
|
}
|
|
79
90
|
export {
|
|
80
|
-
|
|
81
|
-
|
|
91
|
+
N as P,
|
|
92
|
+
a as i
|
|
82
93
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function c(e,s){return s.some(t=>t.value===e)}function h(e){return e.classList&&(e.classList.contains("_dialog_overlay")||e.classList.contains("backdrop"))?!0:typeof e.hasAttribute=="function"&&e.hasAttribute("data-skip")}function a(e){return e.nodeName==="OPTION"||e.nodeName==="DATA"}function p(e,s){return e.nodeType===Node.ELEMENT_NODE&&!c(e,s)}function d(e){var s;return e.nodeType===Node.TEXT_NODE&&((s=e.nodeValue)==null?void 0:s.trim())!==""}class N{constructor(s,...t){this.nodes=[],this.filledSlots=new Set,this.skipOptions=!1,this.updatingSlots=!1,this.host=s,this.host.addController(this),this.slots=t,this.nodes=[],this.observer=new MutationObserver(l=>this.handleMutations(l)),this.contentObserver=new MutationObserver(l=>this.handleSlotMutations(l))}hostConnected(){this.updateNodes(),this.observer.observe(this.host,{childList:!0}),this.contentObserver.observe(this.host,{childList:!0,subtree:!0})}hostDisconnected(){this.observer.disconnect(),this.contentObserver.disconnect()}hostUpdated(){this.updateSlots()}updateNodes(){this.nodes=[],Array.from(this.host.childNodes).forEach(t=>{h(t)||a(t)&&this.skipOptions||(!c(t,this.slots)||d(t))&&this.nodes.push(t)})}updateSlots(){if(this.updatingSlots)return;this.updatingSlots=!0;const s=new Set;this.slots.forEach(t=>{if(!t.value)return;const l=t.value.getAttribute("name");Array.from(t.value.childNodes).some(o=>{var u,f;if(o.nodeType===Node.COMMENT_NODE)return!1;if(o.nodeType===Node.TEXT_NODE)return!!((u=o.textContent)!=null&&u.trim());if(o.nodeType===Node.ELEMENT_NODE){if(h(o))return!1;if((f=o.textContent)!=null&&f.trim())return!0}return!1})&&s.add(l);const r=this.nodes.flatMap(o=>d(o)||o.getAttribute&&o.getAttribute("slot")==l&&!h(o)?o:[]).filter(o=>t.value&&!t.value.contains(o)&&!o.contains(t.value));if(r.length>0)if(typeof t.value.replaceChildren!="function"){for(;t.value.firstChild;)t.value.removeChild(t.value.firstChild);t.value.append(...r)}else t.value.replaceChildren(...r)}),(this.filledSlots.size!==s.size||![...this.filledSlots].every(t=>s.has(t)))&&(this.filledSlots=s,typeof this.host.updateSlots=="function"&&this.host.updateSlots(this.filledSlots)),this.updatingSlots=!1}handleMutations(s){let t=!1;s.forEach(l=>{l.type==="childList"&&(l.addedNodes.forEach(i=>{h(i)||a(i)&&this.skipOptions||(p(i,this.slots)||d(i))&&(this.nodes.push(i),t=!0)}),l.removedNodes.forEach(i=>{h(i)||a(i)&&this.skipOptions||(this.nodes=this.nodes.filter(n=>n!==i),t=!0)}))}),t&&this.updateSlots()}handleSlotMutations(s){let t=!1;s.forEach(l=>{const i=l.target.parentElement;if(i!=null&&i.hasAttribute("slot")){const n=i.getAttribute("slot"),r=i.hasChildNodes();r&&!this.filledSlots.has(n)?(this.filledSlots.add(n),t=!0):!r&&this.filledSlots.has(n)&&(this.filledSlots.delete(n),t=!0)}}),t&&typeof this.host.updateSlots=="function"&&this.host.updateSlots(this.filledSlots)}}exports.PktSlotController=N;exports.isOptionElement=a;
|
package/dist/pkt-tag.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./tag-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./tag-DrbI0ng3.cjs"),t=e.PktTag;Object.defineProperty(exports,"PktTag",{enumerable:!0,get:()=>e.PktTag});exports.default=t;
|
package/dist/pkt-tag.js
CHANGED
package/dist/pkt-textarea.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./textarea-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./textarea-Dc1sUaxx.cjs"),t=e.PktTextarea;Object.defineProperty(exports,"PktTextarea",{enumerable:!0,get:()=>e.PktTextarea});exports.default=t;
|
package/dist/pkt-textarea.js
CHANGED
package/dist/pkt-textinput.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./textinput-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./textinput-DuLZ26DB.cjs"),t=e.PktTextinput;Object.defineProperty(exports,"PktTextinput",{enumerable:!0,get:()=>e.PktTextinput});exports.default=t;
|
package/dist/pkt-textinput.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const r=require("./element-90YeMNbV.cjs"),p=require("./state-D-Recv7U.cjs"),h=require("./ref-B-w1vCo8.cjs"),o=require("./if-defined-C8eotHpL.cjs"),d=require("./input-element-CInrWeac.cjs"),c=require("./pkt-options-controller-
|
|
1
|
+
"use strict";const r=require("./element-90YeMNbV.cjs"),p=require("./state-D-Recv7U.cjs"),h=require("./ref-B-w1vCo8.cjs"),o=require("./if-defined-C8eotHpL.cjs"),d=require("./input-element-CInrWeac.cjs"),c=require("./pkt-options-controller-CiuBG6Lt.cjs"),v=require("./pkt-slot-controller-BzddBp7z.cjs");require("./input-wrapper-Dk0rKRlz.cjs");var f=Object.defineProperty,b=Object.getOwnPropertyDescriptor,a=(u,t,e,s)=>{for(var i=s>1?void 0:s?b(t,e):t,l=u.length-1,n;l>=0;l--)(n=u[l])&&(i=(s?n(t,e,i):n(i))||i);return s&&i&&f(t,e,i),i};exports.PktSelect=class extends d.PktInputElement{constructor(){super(),this.inputRef=h.e(),this.helptextSlot=h.e(),this.options=[],this.value="",this._options=[],this.selectedIndex=-1,this.selectedOptions=void 0,this.optionsController=new c.PktOptionsSlotController(this),this.slotController=new v.PktSlotController(this,this.helptextSlot),this.slotController.skipOptions=!0}connectedCallback(){super.connectedCallback();const t=this.options.length>0,e=this.optionsController.nodes.length&&this.optionsController.nodes.length>0;!t&&e?this.optionsController.nodes.forEach(s=>{const i={value:s.hasAttribute("value")?s.getAttribute("value")??"":s.textContent??"",label:s.textContent||s.getAttribute("value")||"",disabled:s.hasAttribute("disabled"),hidden:s.hasAttribute("data-hidden")};s.getAttribute("selected")&&!this.value&&(this.value=i.value),this._options.push(i)}):(this._options=this.options,this._options.forEach(s=>{s.selected&&!this.value&&(this.value=s.value)}))}add(t,e){var s,i,l;(s=this.inputRef.value)==null||s.add(t,e),this._options.push({value:t.value||t.text,label:t.text||t.value,selected:t.selected,disabled:t.disabled}),t.selected&&(this.value=t.value||t.text,this.selectedIndex=this.returnNumberOrNull((i=this.inputRef.value)==null?void 0:i.selectedIndex),this.selectedOptions=(l=this.inputRef.value)==null?void 0:l.selectedOptions),this.requestUpdate()}remove(t){var e,s;typeof t=="number"&&(this.selectedIndex===t&&(this.value=((e=this._options[0])==null?void 0:e.value)||""),(s=this.inputRef.value)==null||s.remove(t))}item(t){var e;return(e=this.inputRef.value)==null?void 0:e.item(t)}namedItem(t){var e;return(e=this.inputRef.value)==null?void 0:e.namedItem(t)}showPicker(){var t;(t=this.inputRef.value)==null||t.showPicker()}attributeChangedCallback(t,e,s){var i,l;t==="options"&&(this._options=s?JSON.parse(s):[]),t==="value"&&this.value!==e&&(this.selectedIndex=this.touched?this.returnNumberOrNull((i=this.inputRef.value)==null?void 0:i.selectedIndex):this.options.findIndex(n=>n.value===s),this.selectedOptions=(l=this.inputRef.value)==null?void 0:l.selectedOptions,this.valueChanged(s,e)),super.attributeChangedCallback(t,e,s)}update(t){var e,s;super.update(t),t.has("value")&&this.value!==t.get("value")&&(this.selectedIndex=this.touched?this.returnNumberOrNull((e=this.inputRef.value)==null?void 0:e.selectedIndex):this.options.findIndex(i=>i.value===this.value),this.selectedOptions=(s=this.inputRef.value)==null?void 0:s.selectedOptions,this.valueChanged(this.value,t.get("value"))),t.has("id")&&!this.name&&this.id&&(this.name=this.id)}firstUpdated(t){var e;super.firstUpdated(t),this.options.length&&(this._options=this.options),!this.value&&this._options.length>0?(this.value=this._options[0].value,this.selectedIndex=0):this.selectedIndex=this._options.findIndex(s=>s.value===this.value),this.selectedOptions=(e=this.inputRef.value)==null?void 0:e.selectedOptions}render(){const t=`pkt-input ${this.fullwidth?"pkt-input--fullwidth":""}`;return r.x`
|
|
2
2
|
<pkt-input-wrapper
|
|
3
3
|
?counter=${this.counter}
|
|
4
4
|
?disabled=${this.disabled}
|
|
@@ -3,15 +3,15 @@ import { r as f } from "./state-BxrO4zNJ.js";
|
|
|
3
3
|
import { e as u, n as d } from "./ref-DnSbnXsj.js";
|
|
4
4
|
import { o } from "./if-defined-Cj-3Kdsr.js";
|
|
5
5
|
import { P as b } from "./input-element-BEvaQK4g.js";
|
|
6
|
-
import { P as $ } from "./pkt-options-controller-
|
|
7
|
-
import { P as x } from "./pkt-slot-controller-
|
|
8
|
-
import "./input-wrapper-
|
|
9
|
-
var m = Object.defineProperty, g = Object.getOwnPropertyDescriptor,
|
|
10
|
-
for (var l = i > 1 ? void 0 : i ? g(e, s) : e,
|
|
11
|
-
(r = t[
|
|
6
|
+
import { P as $ } from "./pkt-options-controller-CZO1nxZ8.js";
|
|
7
|
+
import { P as x } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
8
|
+
import "./input-wrapper-CC_R5w7V.js";
|
|
9
|
+
var m = Object.defineProperty, g = Object.getOwnPropertyDescriptor, h = (t, e, s, i) => {
|
|
10
|
+
for (var l = i > 1 ? void 0 : i ? g(e, s) : e, a = t.length - 1, r; a >= 0; a--)
|
|
11
|
+
(r = t[a]) && (l = (i ? r(e, s, l) : r(l)) || l);
|
|
12
12
|
return i && l && m(e, s, l), l;
|
|
13
13
|
};
|
|
14
|
-
let
|
|
14
|
+
let n = class extends b {
|
|
15
15
|
constructor() {
|
|
16
16
|
super(), this.inputRef = u(), this.helptextSlot = u(), this.options = [], this.value = "", this._options = [], this.selectedIndex = -1, this.selectedOptions = void 0, this.optionsController = new $(this), this.slotController = new x(this, this.helptextSlot), this.slotController.skipOptions = !0;
|
|
17
17
|
}
|
|
@@ -24,7 +24,7 @@ let h = class extends b {
|
|
|
24
24
|
value: s.hasAttribute("value") ? s.getAttribute("value") ?? "" : s.textContent ?? "",
|
|
25
25
|
label: s.textContent || s.getAttribute("value") || "",
|
|
26
26
|
disabled: s.hasAttribute("disabled"),
|
|
27
|
-
hidden: s.hasAttribute("hidden")
|
|
27
|
+
hidden: s.hasAttribute("data-hidden")
|
|
28
28
|
};
|
|
29
29
|
s.getAttribute("selected") && !this.value && (this.value = i.value), this._options.push(i);
|
|
30
30
|
}) : (this._options = this.options, this._options.forEach((s) => {
|
|
@@ -63,7 +63,7 @@ let h = class extends b {
|
|
|
63
63
|
}
|
|
64
64
|
attributeChangedCallback(t, e, s) {
|
|
65
65
|
var i, l;
|
|
66
|
-
t === "options" && (this._options = s ? JSON.parse(s) : []), t === "value" && this.value !== e && (this.selectedIndex = this.touched ? this.returnNumberOrNull((i = this.inputRef.value) == null ? void 0 : i.selectedIndex) : this.options.findIndex((
|
|
66
|
+
t === "options" && (this._options = s ? JSON.parse(s) : []), t === "value" && this.value !== e && (this.selectedIndex = this.touched ? this.returnNumberOrNull((i = this.inputRef.value) == null ? void 0 : i.selectedIndex) : this.options.findIndex((a) => a.value === s), this.selectedOptions = (l = this.inputRef.value) == null ? void 0 : l.selectedOptions, this.valueChanged(s, e)), super.attributeChangedCallback(t, e, s);
|
|
67
67
|
}
|
|
68
68
|
update(t) {
|
|
69
69
|
var e, s;
|
|
@@ -138,18 +138,18 @@ let h = class extends b {
|
|
|
138
138
|
return t == null || isNaN(t) ? null : t;
|
|
139
139
|
}
|
|
140
140
|
};
|
|
141
|
-
|
|
141
|
+
h([
|
|
142
142
|
c({ type: Array })
|
|
143
|
-
],
|
|
144
|
-
|
|
143
|
+
], n.prototype, "options", 2);
|
|
144
|
+
h([
|
|
145
145
|
c({ type: String })
|
|
146
|
-
],
|
|
147
|
-
|
|
146
|
+
], n.prototype, "value", 2);
|
|
147
|
+
h([
|
|
148
148
|
f()
|
|
149
|
-
],
|
|
150
|
-
|
|
149
|
+
], n.prototype, "_options", 2);
|
|
150
|
+
n = h([
|
|
151
151
|
v("pkt-select")
|
|
152
|
-
],
|
|
152
|
+
], n);
|
|
153
153
|
export {
|
|
154
|
-
|
|
154
|
+
n as P
|
|
155
155
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const u=require("./class-map-DWDPOqjO.cjs"),t=require("./element-90YeMNbV.cjs"),k=require("./state-D-Recv7U.cjs"),g=require("./pkt-slot-controller-
|
|
1
|
+
"use strict";const u=require("./class-map-DWDPOqjO.cjs"),t=require("./element-90YeMNbV.cjs"),k=require("./state-D-Recv7U.cjs"),g=require("./pkt-slot-controller-BzddBp7z.cjs"),c=require("./ref-B-w1vCo8.cjs");require("./icon-B1_BRNqf.cjs");const h=require("./if-defined-C8eotHpL.cjs"),f={closeTag:{default:!1},size:{default:"medium"},skin:{default:"blue"},type:{default:"button"}},r={props:f};var d=Object.defineProperty,y=Object.getOwnPropertyDescriptor,i=(n,e,o,a)=>{for(var s=a>1?void 0:a?y(e,o):e,l=n.length-1,p;l>=0;l--)(p=n[l])&&(s=(a?p(e,o,s):p(s))||s);return a&&s&&d(e,o,s),s};exports.PktTag=class extends t.PktElement{constructor(){super(),this.defaultSlot=c.e(),this.closeTag=r.props.closeTag.default,this.size=r.props.size.default,this.skin=r.props.skin.default,this.textStyle=null,this.iconName=void 0,this.type=r.props.type.default,this.ariaLabel=null,this._isClosed=!1,this._ariaDescription=null,this.close=e=>{this._isClosed=!0,this.dispatchEvent(new CustomEvent("close",{detail:{origin:e},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("on-close",{detail:{origin:e},bubbles:!0,composed:!0}))},this.slotController=new g.PktSlotController(this,this.defaultSlot),this._isClosed=!1}firstUpdated(e){var o,a;if(super.firstUpdated(e),this.closeTag&&!this.ariaLabel){const s=(a=(o=this.defaultSlot.value)==null?void 0:o.textContent)==null?void 0:a.trim();s&&(this._ariaDescription=`Klikk for å fjerne ${s}`)}}render(){const e={"pkt-tag":!0,[`pkt-tag--${this.size}`]:!!this.size,[`pkt-tag--${this.skin}`]:!!this.skin,[`pkt-tag--${this.textStyle}`]:!!this.textStyle},o={"pkt-tag":!0,"pkt-btn":!0,"pkt-btn--tertiary":!0,[`pkt-tag--${this.textStyle}`]:!!this.textStyle,[`pkt-tag--${this.size}`]:!!this.size,[`pkt-tag--${this.skin}`]:!!this.skin,"pkt-btn--icons-right-and-left":this.closeTag&&!!this.iconName,"pkt-hide":this._isClosed};return this.closeTag?t.x`
|
|
2
2
|
<button
|
|
3
3
|
class=${u.e(o)}
|
|
4
4
|
type=${this.type}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { e as u } from "./class-map-m7ZCZ49w.js";
|
|
2
2
|
import { P as m, x as l, n as r, a as g } from "./element-gAd63VwC.js";
|
|
3
3
|
import { r as k } from "./state-BxrO4zNJ.js";
|
|
4
|
-
import { P as y } from "./pkt-slot-controller-
|
|
4
|
+
import { P as y } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
5
5
|
import { e as b, n as f } from "./ref-DnSbnXsj.js";
|
|
6
6
|
import "./icon-CO1TLSs5.js";
|
|
7
7
|
import { o as d } from "./if-defined-Cj-3Kdsr.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const s=require("./element-90YeMNbV.cjs"),p=require("./if-defined-C8eotHpL.cjs"),c=require("./state-D-Recv7U.cjs"),l=require("./ref-B-w1vCo8.cjs"),$=require("./class-map-DWDPOqjO.cjs"),a=require("./directive-C7oCP5Bh.cjs"),d=require("./directive-helpers-v9b0v7lu.cjs"),x=require("./input-element-CInrWeac.cjs"),T=require("./pkt-slot-controller-
|
|
1
|
+
"use strict";const s=require("./element-90YeMNbV.cjs"),p=require("./if-defined-C8eotHpL.cjs"),c=require("./state-D-Recv7U.cjs"),l=require("./ref-B-w1vCo8.cjs"),$=require("./class-map-DWDPOqjO.cjs"),a=require("./directive-C7oCP5Bh.cjs"),d=require("./directive-helpers-v9b0v7lu.cjs"),x=require("./input-element-CInrWeac.cjs"),T=require("./pkt-slot-controller-BzddBp7z.cjs");require("./input-wrapper-Dk0rKRlz.cjs");require("./icon-B1_BRNqf.cjs");/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2020 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -6,8 +6,8 @@ import { e as v } from "./class-map-m7ZCZ49w.js";
|
|
|
6
6
|
import { e as b, i as T, t as a } from "./directive-oAbCiebi.js";
|
|
7
7
|
import { f as y, m as w } from "./directive-helpers--4ibN__v.js";
|
|
8
8
|
import { P as C } from "./input-element-BEvaQK4g.js";
|
|
9
|
-
import { P as E } from "./pkt-slot-controller-
|
|
10
|
-
import "./input-wrapper-
|
|
9
|
+
import { P as E } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
10
|
+
import "./input-wrapper-CC_R5w7V.js";
|
|
11
11
|
import "./icon-CO1TLSs5.js";
|
|
12
12
|
/**
|
|
13
13
|
* @license
|
|
@@ -4,8 +4,8 @@ import { r as f } from "./state-BxrO4zNJ.js";
|
|
|
4
4
|
import { e as m, n as d } from "./ref-DnSbnXsj.js";
|
|
5
5
|
import { e as g } from "./class-map-m7ZCZ49w.js";
|
|
6
6
|
import { P as x } from "./input-element-BEvaQK4g.js";
|
|
7
|
-
import { P as y } from "./pkt-slot-controller-
|
|
8
|
-
import "./input-wrapper-
|
|
7
|
+
import { P as y } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
8
|
+
import "./input-wrapper-CC_R5w7V.js";
|
|
9
9
|
import "./icon-CO1TLSs5.js";
|
|
10
10
|
var v = Object.defineProperty, b = Object.getOwnPropertyDescriptor, o = (e, i, r, t) => {
|
|
11
11
|
for (var n = t > 1 ? void 0 : t ? b(i, r) : i, l = e.length - 1, c; l >= 0; l--)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const t=require("./element-90YeMNbV.cjs"),a=require("./if-defined-C8eotHpL.cjs"),l=require("./state-D-Recv7U.cjs"),h=require("./ref-B-w1vCo8.cjs"),c=require("./class-map-DWDPOqjO.cjs"),x=require("./input-element-CInrWeac.cjs"),d=require("./pkt-slot-controller-
|
|
1
|
+
"use strict";const t=require("./element-90YeMNbV.cjs"),a=require("./if-defined-C8eotHpL.cjs"),l=require("./state-D-Recv7U.cjs"),h=require("./ref-B-w1vCo8.cjs"),c=require("./class-map-DWDPOqjO.cjs"),x=require("./input-element-CInrWeac.cjs"),d=require("./pkt-slot-controller-BzddBp7z.cjs");require("./input-wrapper-Dk0rKRlz.cjs");require("./icon-B1_BRNqf.cjs");var $=Object.defineProperty,f=Object.getOwnPropertyDescriptor,r=(u,i,s,n)=>{for(var e=n>1?void 0:n?f(i,s):i,o=u.length-1,p;o>=0;o--)(p=u[o])&&(e=(n?p(i,s,e):p(e))||e);return n&&e&&$(i,s,e),e};exports.PktTextinput=class extends x.PktInputElement{constructor(){super(),this.inputRef=h.e(),this.helptextSlot=h.e(),this.value="",this.type="text",this.size=null,this.autocomplete=null,this.iconNameRight=null,this.prefix=null,this.suffix=null,this.omitSearchIcon=!1,this.counterCurrent=0,this.slotController=new d.PktSlotController(this,this.helptextSlot)}attributeChangedCallback(i,s,n){i==="value"&&this.value!==s&&(this.counterCurrent=n?n.length:0,this.valueChanged(n,s)),super.attributeChangedCallback(i,s,n)}updated(i){var s;super.updated(i),i.has("value")&&(this.counterCurrent=((s=this.value)==null?void 0:s.length)||0,this.valueChanged(this.value,i.get("value"))),i.has("id")&&!this.name&&this.id&&(this.name=this.id)}render(){const i=this.type==="search"&&!this.iconNameRight&&!this.omitSearchIcon,s=c.e({"pkt-input":!0,"pkt-input--fullwidth":this.fullwidth,"pkt-input--counter-error":this.counter&&this.counterMaxLength&&this.value.length&&this.value.length>this.counterMaxLength}),n=this.ariaLabelledby||`${this.id}-input-label`;return t.x`
|
|
2
2
|
<pkt-input-wrapper
|
|
3
3
|
label="${this.label}"
|
|
4
4
|
?counter=${this.counter}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "12.42.
|
|
3
|
+
"version": "12.42.9",
|
|
4
4
|
"description": "Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo Origo",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@oslokommune/punkt-assets": "^12.39.2",
|
|
34
|
-
"@oslokommune/punkt-css": "^12.42.
|
|
34
|
+
"@oslokommune/punkt-css": "^12.42.9",
|
|
35
35
|
"sass": "^1.78.0",
|
|
36
36
|
"typescript": "^5.6.2",
|
|
37
37
|
"vite": "^5.4.18",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
59
59
|
},
|
|
60
60
|
"license": "MIT",
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "b1c84b3a7403e934703bd982d6dec86f1aa11131"
|
|
62
62
|
}
|
|
@@ -70,7 +70,7 @@ export class PktButton extends PktElement<IPktButton> implements IPktButton {
|
|
|
70
70
|
@property({ type: String }) skin: TPktButtonSkin = 'primary'
|
|
71
71
|
@property({ type: String }) variant: TPktButtonVariant = 'label-only'
|
|
72
72
|
@property({ type: String, reflect: true }) state?: TPktButtonState = 'normal'
|
|
73
|
-
@property({ type: String }) type: TPktButtonType = 'button'
|
|
73
|
+
@property({ type: String, reflect: true }) type: TPktButtonType = 'button'
|
|
74
74
|
@property({ type: String }) form: string | undefined = undefined
|
|
75
75
|
@property({ type: Boolean, reflect: true }) isLoading: Booleanish = false
|
|
76
76
|
@property({ type: Boolean, reflect: true }) disabled: Booleanish = false
|
|
@@ -78,6 +78,32 @@ export class PktButton extends PktElement<IPktButton> implements IPktButton {
|
|
|
78
78
|
|
|
79
79
|
// Lifecycle
|
|
80
80
|
|
|
81
|
+
connectedCallback(): void {
|
|
82
|
+
super.connectedCallback()
|
|
83
|
+
this.addEventListener(
|
|
84
|
+
'click',
|
|
85
|
+
(e) => {
|
|
86
|
+
if (this.disabled || this.hasAttribute('disabled') || this.isLoading) {
|
|
87
|
+
e.preventDefault()
|
|
88
|
+
e.stopImmediatePropagation()
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
true,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
this.addEventListener(
|
|
95
|
+
'keydown',
|
|
96
|
+
(e) => {
|
|
97
|
+
if (!(this.disabled || this.hasAttribute('disabled') || this.isLoading)) return
|
|
98
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
99
|
+
e.preventDefault()
|
|
100
|
+
e.stopImmediatePropagation()
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
true,
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
81
107
|
attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
|
|
82
108
|
super.attributeChangedCallback(name, _old, value)
|
|
83
109
|
// Convert strings to booleans
|
|
@@ -122,7 +148,7 @@ export class PktButton extends PktElement<IPktButton> implements IPktButton {
|
|
|
122
148
|
type=${this.type}
|
|
123
149
|
?disabled=${!!this.disabled}
|
|
124
150
|
aria-busy=${ifDefined(this.isLoading ? 'true' : undefined)}
|
|
125
|
-
aria-disabled=${ifDefined(this.disabled ? 'true' : undefined)}
|
|
151
|
+
aria-disabled=${ifDefined(this.disabled || this.isLoading ? 'true' : undefined)}
|
|
126
152
|
form=${ifDefined(formId)}
|
|
127
153
|
>
|
|
128
154
|
${this.isLoading
|
|
@@ -32,6 +32,12 @@ export class PktHelptext extends PktElement {
|
|
|
32
32
|
|
|
33
33
|
@state() isHelpTextOpen: boolean = false
|
|
34
34
|
|
|
35
|
+
@state() filledSlots: Set<string | null | undefined> = new Set()
|
|
36
|
+
|
|
37
|
+
updateSlots(filledSlots: Set<string | null | undefined>) {
|
|
38
|
+
this.filledSlots = new Set(filledSlots)
|
|
39
|
+
}
|
|
40
|
+
|
|
35
41
|
render() {
|
|
36
42
|
const toggleDropdown = () => {
|
|
37
43
|
const isOpen = !this.isHelpTextOpen
|
|
@@ -44,6 +50,12 @@ export class PktHelptext extends PktElement {
|
|
|
44
50
|
)
|
|
45
51
|
}
|
|
46
52
|
|
|
53
|
+
const helptextClasses = classMap({
|
|
54
|
+
'pkt-inputwrapper__helptext-container': true,
|
|
55
|
+
'pkt-inputwrapper__has-helptext':
|
|
56
|
+
this.helptext || this.helptextDropdown || this.filledSlots.size > 0,
|
|
57
|
+
})
|
|
58
|
+
|
|
47
59
|
const helptextDropdown = () => {
|
|
48
60
|
if (this.helptextDropdown) {
|
|
49
61
|
return html`<div class="pkt-inputwrapper__helptext-expandable">
|
|
@@ -74,7 +86,7 @@ export class PktHelptext extends PktElement {
|
|
|
74
86
|
}
|
|
75
87
|
|
|
76
88
|
const helptextElement = () => {
|
|
77
|
-
return html`<div class="
|
|
89
|
+
return html`<div class="${helptextClasses}">
|
|
78
90
|
<div class="pkt-inputwrapper__helptext" id="${this.forId}-helptext">
|
|
79
91
|
<div class="pkt-contents" ${ref(this.defaultSlot)} name="helptext"></div>
|
|
80
92
|
${this.helptext && unsafeHTML(this.helptext)}
|
|
@@ -5,7 +5,7 @@ import { ifDefined } from 'lit/directives/if-defined.js'
|
|
|
5
5
|
import { html, nothing, PropertyValues } from 'lit'
|
|
6
6
|
import { unsafeHTML } from 'lit/directives/unsafe-html.js'
|
|
7
7
|
import { classMap } from 'lit/directives/class-map.js'
|
|
8
|
-
import { customElement, property
|
|
8
|
+
import { customElement, property } from 'lit/decorators.js'
|
|
9
9
|
import { ElementProps } from '@/types/typeUtils'
|
|
10
10
|
import { uuidish } from '@/utils/stringutils'
|
|
11
11
|
import specs from 'componentSpecs/input-wrapper.json'
|
|
@@ -57,7 +57,6 @@ const booleanishConverter = {
|
|
|
57
57
|
export class PktInputWrapper extends PktElement<Props> {
|
|
58
58
|
defaultSlot: Ref<HTMLElement> = createRef()
|
|
59
59
|
helptextSlot: Ref<HTMLElement> = createRef()
|
|
60
|
-
@state() hasHelptextSlot: boolean = true
|
|
61
60
|
|
|
62
61
|
constructor() {
|
|
63
62
|
super()
|
|
@@ -91,11 +90,6 @@ export class PktInputWrapper extends PktElement<Props> {
|
|
|
91
90
|
@property({ type: Boolean, reflect: true, converter: booleanishConverter })
|
|
92
91
|
useWrapper: Booleanish = specs.props.useWrapper.default
|
|
93
92
|
|
|
94
|
-
public updateSlots(filledSlots: Set<string | null | undefined>): void {
|
|
95
|
-
this.hasHelptextSlot = filledSlots.has('helptext')
|
|
96
|
-
this.requestUpdate()
|
|
97
|
-
}
|
|
98
|
-
|
|
99
93
|
protected updated(changedProperties: PropertyValues): void {
|
|
100
94
|
super.updated(changedProperties)
|
|
101
95
|
}
|
|
@@ -169,9 +163,6 @@ export class PktInputWrapper extends PktElement<Props> {
|
|
|
169
163
|
}
|
|
170
164
|
|
|
171
165
|
const helptextElement = () => {
|
|
172
|
-
if (!this.helptext && !this.hasHelptextSlot && !this.helptextDropdown) {
|
|
173
|
-
return nothing
|
|
174
|
-
}
|
|
175
166
|
return html`
|
|
176
167
|
<pkt-helptext
|
|
177
168
|
class="${ifDefined(!this.useWrapper ? 'pkt-hide' : undefined)}"
|
|
@@ -74,7 +74,7 @@ export class PktSelect extends PktInputElement implements IPktSelect {
|
|
|
74
74
|
: (node.textContent ?? ''),
|
|
75
75
|
label: node.textContent || node.getAttribute('value') || '',
|
|
76
76
|
disabled: node.hasAttribute('disabled'),
|
|
77
|
-
hidden: node.hasAttribute('hidden'),
|
|
77
|
+
hidden: node.hasAttribute('data-hidden'),
|
|
78
78
|
}
|
|
79
79
|
if (node.getAttribute('selected') && !this.value) {
|
|
80
80
|
this.value = option.value
|