@oslokommune/punkt-elements 12.43.2 → 13.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/dist/checkbox-CTRbpbye.js +120 -0
- package/dist/checkbox-wJ26voZd.cjs +30 -0
- package/dist/{combobox-Cv6i7BEk.cjs → combobox-CijGa9Fr.cjs} +3 -2
- package/dist/{combobox-kWGI4RHI.js → combobox-Cwg9Rkmz.js} +3 -2
- package/dist/{datepicker-BJe92Vor.cjs → datepicker-BhrUneAP.cjs} +2 -1
- package/dist/{datepicker-LpbYHx8L.js → datepicker-CEfh3TTA.js} +3 -2
- package/dist/index.d.ts +14 -1
- package/dist/{input-element-CHjLWeKt.cjs → input-element-C4xJoM-X.cjs} +1 -1
- package/dist/{input-element-Cco4PA2M.js → input-element-NnrDmp4r.js} +14 -11
- package/dist/{input-wrapper-BxZf8wEP.cjs → input-wrapper-CZ-a00V7.cjs} +19 -15
- package/dist/input-wrapper-Dr__Sxql.js +189 -0
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +8 -8
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +1 -1
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +1 -1
- package/dist/radiobutton-CWxiIVfA.js +111 -0
- package/dist/radiobutton-CdT6v1oq.cjs +31 -0
- package/dist/{select-BaLHLuvH.js → select-CsgDatCa.js} +14 -13
- package/dist/{select-CFpdOlDE.cjs → select-DUeTm8ac.cjs} +11 -10
- package/dist/{textarea-EIFo7GZz.js → textarea-BZL8Mkm0.js} +5 -4
- package/dist/{textarea-CViiuZdR.cjs → textarea-CPXsMFUq.cjs} +2 -1
- package/dist/{textinput-BHS7b-Jt.js → textinput-DjPhmmkB.js} +26 -25
- package/dist/{textinput-_ZdyMA9O.cjs → textinput-aNI5kibM.cjs} +7 -6
- package/package.json +4 -4
- package/src/components/checkbox/checkbox.ts +22 -1
- package/src/components/combobox/combobox.ts +2 -0
- package/src/components/datepicker/datepicker.ts +1 -0
- package/src/components/input-wrapper/input-wrapper.ts +20 -20
- package/src/components/radiobutton/radiobutton.ts +22 -1
- package/src/components/select/select.ts +1 -0
- package/src/components/textarea/textarea.ts +4 -8
- package/src/components/textinput/textinput.ts +14 -28
- package/dist/checkbox-CJ4tK9RC.cjs +0 -26
- package/dist/checkbox-cD_5LDzV.js +0 -101
- package/dist/input-wrapper-gz7ppKrK.js +0 -188
- package/dist/radiobutton-0vVqu-GU.cjs +0 -27
- package/dist/radiobutton-BcFRJFvI.js +0 -92
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const r=require("./element-6DBpyGQm.cjs"),p=require("./state-DPobt-Yz.cjs"),h=require("./ref-iJtiv3o2.cjs"),
|
|
1
|
+
"use strict";const r=require("./element-6DBpyGQm.cjs"),p=require("./state-DPobt-Yz.cjs"),h=require("./ref-iJtiv3o2.cjs"),l=require("./if-defined-Cni-RHLS.cjs"),d=require("./input-element-C4xJoM-X.cjs"),c=require("./pkt-options-controller-CiuBG6Lt.cjs"),v=require("./pkt-slot-controller-BzddBp7z.cjs");require("./input-wrapper-CZ-a00V7.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,o=u.length-1,n;o>=0;o--)(n=u[o])&&(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,o;(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=(o=this.inputRef.value)==null?void 0:o.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,o;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=(o=this.inputRef.value)==null?void 0:o.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}
|
|
@@ -8,22 +8,23 @@
|
|
|
8
8
|
?optionalTag=${this.optionalTag}
|
|
9
9
|
?requiredTag=${this.requiredTag}
|
|
10
10
|
?useWrapper=${this.useWrapper}
|
|
11
|
-
ariaDescribedBy=${
|
|
11
|
+
ariaDescribedBy=${l.o(this.ariaDescribedBy)}
|
|
12
12
|
class="pkt-select"
|
|
13
|
-
errorMessage=${
|
|
13
|
+
errorMessage=${l.o(this.errorMessage)}
|
|
14
14
|
forId=${this.id+"-input"}
|
|
15
|
-
helptext=${
|
|
16
|
-
helptextDropdown=${
|
|
17
|
-
helptextDropdownButton=${
|
|
18
|
-
label=${
|
|
19
|
-
optionalText=${
|
|
20
|
-
requiredText=${
|
|
15
|
+
helptext=${l.o(this.helptext)}
|
|
16
|
+
helptextDropdown=${l.o(this.helptextDropdown)}
|
|
17
|
+
helptextDropdownButton=${l.o(this.helptextDropdownButton)}
|
|
18
|
+
label=${l.o(this.label)}
|
|
19
|
+
optionalText=${l.o(this.optionalText)}
|
|
20
|
+
requiredText=${l.o(this.requiredText)}
|
|
21
|
+
tagText=${l.o(this.tagText)}
|
|
21
22
|
>
|
|
22
23
|
<select
|
|
23
24
|
class=${t}
|
|
24
25
|
aria-invalid=${this.hasError}
|
|
25
26
|
aria-errormessage=${`${this.id}-error`}
|
|
26
|
-
aria-labelledby=${
|
|
27
|
+
aria-labelledby=${l.o(this.ariaLabelledby)}
|
|
27
28
|
?disabled=${this.disabled}
|
|
28
29
|
id=${this.id+"-input"}
|
|
29
30
|
name=${(this.name||this.id)+"-input"}
|
|
@@ -3,18 +3,18 @@ import { o as u } from "./if-defined-CmuO4Vz9.js";
|
|
|
3
3
|
import { r as x } from "./state-Bo2bck5_.js";
|
|
4
4
|
import { e as m, n as c } from "./ref-BBYSqgeW.js";
|
|
5
5
|
import { e as v } from "./class-map-BpTj9gtz.js";
|
|
6
|
-
import { e as
|
|
6
|
+
import { e as T, i as b, t as a } from "./directive-oAbCiebi.js";
|
|
7
7
|
import { f as y, m as w } from "./directive-helpers-r-kOS_Mf.js";
|
|
8
|
-
import { P as C } from "./input-element-
|
|
8
|
+
import { P as C } from "./input-element-NnrDmp4r.js";
|
|
9
9
|
import { P as E } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
10
|
-
import "./input-wrapper-
|
|
10
|
+
import "./input-wrapper-Dr__Sxql.js";
|
|
11
11
|
import "./icon-CC1js8eR.js";
|
|
12
12
|
/**
|
|
13
13
|
* @license
|
|
14
14
|
* Copyright 2020 Google LLC
|
|
15
15
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
16
|
*/
|
|
17
|
-
const P =
|
|
17
|
+
const P = T(class extends b {
|
|
18
18
|
constructor(t) {
|
|
19
19
|
if (super(t), t.type !== a.PROPERTY && t.type !== a.ATTRIBUTE && t.type !== a.BOOLEAN_ATTRIBUTE) throw Error("The `live` directive is not allowed on child or event bindings");
|
|
20
20
|
if (!y(t)) throw Error("`live` bindings can only contain a single expression");
|
|
@@ -75,6 +75,7 @@ let o = class extends C {
|
|
|
75
75
|
.helptextDropdownButton=${this.helptextDropdownButton}
|
|
76
76
|
.optionalText=${this.optionalText}
|
|
77
77
|
.requiredText=${this.requiredText}
|
|
78
|
+
.tagText=${this.tagText}
|
|
78
79
|
class="pkt-textarea"
|
|
79
80
|
>
|
|
80
81
|
<div class="pkt-contents" ${c(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const s=require("./element-6DBpyGQm.cjs"),p=require("./if-defined-Cni-RHLS.cjs"),c=require("./state-DPobt-Yz.cjs"),l=require("./ref-iJtiv3o2.cjs"),$=require("./class-map-BBG2gMX4.cjs"),a=require("./directive-C7oCP5Bh.cjs"),d=require("./directive-helpers-BBbxqP2W.cjs"),x=require("./input-element-
|
|
1
|
+
"use strict";const s=require("./element-6DBpyGQm.cjs"),p=require("./if-defined-Cni-RHLS.cjs"),c=require("./state-DPobt-Yz.cjs"),l=require("./ref-iJtiv3o2.cjs"),$=require("./class-map-BBG2gMX4.cjs"),a=require("./directive-C7oCP5Bh.cjs"),d=require("./directive-helpers-BBbxqP2W.cjs"),x=require("./input-element-C4xJoM-X.cjs"),T=require("./pkt-slot-controller-BzddBp7z.cjs");require("./input-wrapper-CZ-a00V7.cjs");require("./icon-B_ryAy4Q.cjs");/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2020 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
.helptextDropdownButton=${this.helptextDropdownButton}
|
|
23
23
|
.optionalText=${this.optionalText}
|
|
24
24
|
.requiredText=${this.requiredText}
|
|
25
|
+
.tagText=${this.tagText}
|
|
25
26
|
class="pkt-textarea"
|
|
26
27
|
>
|
|
27
28
|
<div class="pkt-contents" ${l.n(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import { E as p, x as h, n as a, a as $ } from "./element-CgEWt74-.js";
|
|
2
2
|
import { o as u } from "./if-defined-CmuO4Vz9.js";
|
|
3
3
|
import { r as f } from "./state-Bo2bck5_.js";
|
|
4
|
-
import { e as
|
|
4
|
+
import { e as d, n as m } from "./ref-BBYSqgeW.js";
|
|
5
5
|
import { e as g } from "./class-map-BpTj9gtz.js";
|
|
6
|
-
import { P as x } from "./input-element-
|
|
7
|
-
import { P as
|
|
8
|
-
import "./input-wrapper-
|
|
6
|
+
import { P as x } from "./input-element-NnrDmp4r.js";
|
|
7
|
+
import { P as v } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
8
|
+
import "./input-wrapper-Dr__Sxql.js";
|
|
9
9
|
import "./icon-CC1js8eR.js";
|
|
10
|
-
var
|
|
11
|
-
for (var n = t > 1 ? void 0 : t ? b(
|
|
12
|
-
(c =
|
|
13
|
-
return t && n &&
|
|
10
|
+
var y = Object.defineProperty, b = Object.getOwnPropertyDescriptor, o = (i, e, r, t) => {
|
|
11
|
+
for (var n = t > 1 ? void 0 : t ? b(e, r) : e, l = i.length - 1, c; l >= 0; l--)
|
|
12
|
+
(c = i[l]) && (n = (t ? c(e, r, n) : c(n)) || n);
|
|
13
|
+
return t && n && y(e, r, n), n;
|
|
14
14
|
};
|
|
15
15
|
let s = class extends x {
|
|
16
16
|
constructor() {
|
|
17
|
-
super(), this.inputRef =
|
|
17
|
+
super(), this.inputRef = d(), this.helptextSlot = d(), 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 v(this, this.helptextSlot);
|
|
18
18
|
}
|
|
19
|
-
attributeChangedCallback(
|
|
20
|
-
|
|
19
|
+
attributeChangedCallback(i, e, r) {
|
|
20
|
+
i === "value" && this.value !== e && (this.counterCurrent = r ? r.length : 0, this.valueChanged(r, e)), super.attributeChangedCallback(i, e, r);
|
|
21
21
|
}
|
|
22
|
-
updated(
|
|
23
|
-
var
|
|
24
|
-
super.updated(
|
|
22
|
+
updated(i) {
|
|
23
|
+
var e;
|
|
24
|
+
super.updated(i), i.has("value") && (this.counterCurrent = ((e = this.value) == null ? void 0 : e.length) || 0, this.valueChanged(this.value, i.get("value"))), i.has("id") && !this.name && this.id && (this.name = this.id);
|
|
25
25
|
}
|
|
26
26
|
render() {
|
|
27
|
-
const
|
|
27
|
+
const i = this.type === "search" && !this.iconNameRight && !this.omitSearchIcon, e = g({
|
|
28
28
|
"pkt-input": !0,
|
|
29
29
|
"pkt-input--fullwidth": this.fullwidth,
|
|
30
30
|
"pkt-input--counter-error": this.counter && this.counterMaxLength && this.value.length && this.value.length > this.counterMaxLength
|
|
@@ -51,25 +51,26 @@ let s = class extends x {
|
|
|
51
51
|
.helptextDropdownButton=${this.helptextDropdownButton}
|
|
52
52
|
.optionalText=${this.optionalText}
|
|
53
53
|
.requiredText=${this.requiredText}
|
|
54
|
+
.tagText=${this.tagText}
|
|
54
55
|
class="pkt-textinput"
|
|
55
56
|
>
|
|
56
|
-
<div class="pkt-contents" ${
|
|
57
|
+
<div class="pkt-contents" ${m(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
57
58
|
<div class="pkt-input__container">
|
|
58
59
|
${this.prefix ? h`<div class="pkt-input-prefix">${this.prefix}</div>` : p}
|
|
59
60
|
<input
|
|
60
|
-
${
|
|
61
|
-
class=${
|
|
61
|
+
${m(this.inputRef)}
|
|
62
|
+
class=${e}
|
|
62
63
|
type=${this.type}
|
|
63
64
|
name=${(this.name || this.id) + "-input"}
|
|
64
65
|
id=${this.id + "-input"}
|
|
65
66
|
placeholder=${u(this.placeholder)}
|
|
66
67
|
aria-labelledby=${r}
|
|
67
68
|
autocomplete=${this.autocomplete || "off"}
|
|
68
|
-
minlength=${u(this.minlength)}
|
|
69
|
-
maxlength=${u(this.maxlength)}
|
|
70
|
-
min=${u(this.min)}
|
|
71
|
-
max=${u(this.max)}
|
|
72
|
-
step=${u(this.step)}
|
|
69
|
+
minlength=${u(this.minlength || void 0)}
|
|
70
|
+
maxlength=${u(this.maxlength || void 0)}
|
|
71
|
+
min=${u(this.min || void 0)}
|
|
72
|
+
max=${u(this.max || void 0)}
|
|
73
|
+
step=${u(this.step || void 0)}
|
|
73
74
|
?readonly=${this.readonly}
|
|
74
75
|
size=${this.size || p}
|
|
75
76
|
.value=${this.value}
|
|
@@ -102,13 +103,13 @@ let s = class extends x {
|
|
|
102
103
|
class="pkt-input-suffix-icon"
|
|
103
104
|
name=${this.iconNameRight}
|
|
104
105
|
></pkt-icon>` : p}
|
|
105
|
-
${
|
|
106
|
+
${i ? h`<pkt-icon
|
|
106
107
|
class="pkt-input-suffix-icon"
|
|
107
108
|
name="magnifying-glass-big"
|
|
108
109
|
></pkt-icon>` : p}
|
|
109
110
|
</div>` : p}
|
|
110
111
|
${!this.suffix && this.iconNameRight ? h`<pkt-icon class="pkt-input-icon" name=${this.iconNameRight}></pkt-icon>` : p}
|
|
111
|
-
${!this.suffix &&
|
|
112
|
+
${!this.suffix && i ? h`<pkt-icon class="pkt-input-icon" name="magnifying-glass-big"></pkt-icon>` : p}
|
|
112
113
|
</div>
|
|
113
114
|
</pkt-input-wrapper>
|
|
114
115
|
`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const t=require("./element-6DBpyGQm.cjs"),a=require("./if-defined-Cni-RHLS.cjs"),l=require("./state-DPobt-Yz.cjs"),h=require("./ref-iJtiv3o2.cjs"),c=require("./class-map-BBG2gMX4.cjs"),
|
|
1
|
+
"use strict";const t=require("./element-6DBpyGQm.cjs"),a=require("./if-defined-Cni-RHLS.cjs"),l=require("./state-DPobt-Yz.cjs"),h=require("./ref-iJtiv3o2.cjs"),c=require("./class-map-BBG2gMX4.cjs"),d=require("./input-element-C4xJoM-X.cjs"),x=require("./pkt-slot-controller-BzddBp7z.cjs");require("./input-wrapper-CZ-a00V7.cjs");require("./icon-B_ryAy4Q.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 d.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 x.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}
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
.helptextDropdownButton=${this.helptextDropdownButton}
|
|
21
21
|
.optionalText=${this.optionalText}
|
|
22
22
|
.requiredText=${this.requiredText}
|
|
23
|
+
.tagText=${this.tagText}
|
|
23
24
|
class="pkt-textinput"
|
|
24
25
|
>
|
|
25
26
|
<div class="pkt-contents" ${h.n(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
@@ -34,11 +35,11 @@
|
|
|
34
35
|
placeholder=${a.o(this.placeholder)}
|
|
35
36
|
aria-labelledby=${n}
|
|
36
37
|
autocomplete=${this.autocomplete||"off"}
|
|
37
|
-
minlength=${a.o(this.minlength)}
|
|
38
|
-
maxlength=${a.o(this.maxlength)}
|
|
39
|
-
min=${a.o(this.min)}
|
|
40
|
-
max=${a.o(this.max)}
|
|
41
|
-
step=${a.o(this.step)}
|
|
38
|
+
minlength=${a.o(this.minlength||void 0)}
|
|
39
|
+
maxlength=${a.o(this.maxlength||void 0)}
|
|
40
|
+
min=${a.o(this.min||void 0)}
|
|
41
|
+
max=${a.o(this.max||void 0)}
|
|
42
|
+
step=${a.o(this.step||void 0)}
|
|
42
43
|
?readonly=${this.readonly}
|
|
43
44
|
size=${this.size||t.E}
|
|
44
45
|
.value=${this.value}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.1.0",
|
|
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",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"urlpattern-polyfill": "^10.0.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@oslokommune/punkt-assets": "^
|
|
34
|
-
"@oslokommune/punkt-css": "^
|
|
33
|
+
"@oslokommune/punkt-assets": "^13.0.0",
|
|
34
|
+
"@oslokommune/punkt-css": "^13.0.0",
|
|
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": "eec066758ede7f850bc9f4683957baee56e7abc5"
|
|
62
62
|
}
|
|
@@ -18,6 +18,11 @@ export class PktCheckbox extends PktInputElement {
|
|
|
18
18
|
@property({ type: Boolean }) hideLabel: boolean = false
|
|
19
19
|
@property({ type: Boolean, reflect: true }) checked: boolean | string | null = null
|
|
20
20
|
@property({ type: String, reflect: true }) type: string = 'checkbox'
|
|
21
|
+
@property({ type: String }) tagText: string | null = null
|
|
22
|
+
@property({ type: Boolean }) optionalTag: boolean = false
|
|
23
|
+
@property({ type: String }) optionalText: string = 'Valgfritt'
|
|
24
|
+
@property({ type: Boolean }) requiredTag: boolean = false
|
|
25
|
+
@property({ type: String }) requiredText: string = 'Må fylles ut'
|
|
21
26
|
|
|
22
27
|
connectedCallback() {
|
|
23
28
|
super.connectedCallback()
|
|
@@ -60,10 +65,26 @@ export class PktCheckbox extends PktInputElement {
|
|
|
60
65
|
'pkt-sr-only': this.hideLabel,
|
|
61
66
|
})
|
|
62
67
|
|
|
68
|
+
const tagClasses = 'pkt-tag pkt-tag--small pkt-tag--thin-text'
|
|
69
|
+
|
|
70
|
+
const tags = () => {
|
|
71
|
+
return html`
|
|
72
|
+
${this.tagText
|
|
73
|
+
? html`<span class=${tagClasses + ' pkt-tag--gray'}>${this.tagText}</span>`
|
|
74
|
+
: nothing}
|
|
75
|
+
${this.optionalTag
|
|
76
|
+
? html`<span class=${tagClasses + ' pkt-tag--blue-light'}>${this.optionalText}</span>`
|
|
77
|
+
: nothing}
|
|
78
|
+
${this.requiredTag
|
|
79
|
+
? html`<span class=${tagClasses + ' pkt-tag--beige'}>${this.requiredText}</span>`
|
|
80
|
+
: nothing}
|
|
81
|
+
`
|
|
82
|
+
}
|
|
83
|
+
|
|
63
84
|
const labelAndHelptext = () => {
|
|
64
85
|
return html`
|
|
65
86
|
<label class=${labelClasses} for=${this.id + '-internal'}>
|
|
66
|
-
${this.label}
|
|
87
|
+
${this.label} ${tags()}
|
|
67
88
|
${this.checkHelptext
|
|
68
89
|
? html`<div class="pkt-input-check__input-helptext">${this.checkHelptext}</div>`
|
|
69
90
|
: nothing}
|
|
@@ -55,6 +55,7 @@ export interface IPktCombobox {
|
|
|
55
55
|
requiredText?: string
|
|
56
56
|
searchPlaceholder?: string
|
|
57
57
|
tagPlacement?: TPktComboboxTagPlacement | null
|
|
58
|
+
tagText?: string | null
|
|
58
59
|
value?: string | string[]
|
|
59
60
|
}
|
|
60
61
|
|
|
@@ -248,6 +249,7 @@ export class PktCombobox extends PktInputElement implements IPktCombobox {
|
|
|
248
249
|
.optionalText=${this.optionalText}
|
|
249
250
|
?requiredTag=${this.requiredTag}
|
|
250
251
|
.requiredText=${this.requiredText}
|
|
252
|
+
.tagText=${this.tagText}
|
|
251
253
|
?useWrapper=${this.useWrapper}
|
|
252
254
|
.forId=${this.allowUserInput || this.typeahead ? this.id + '-input' : this.id + '-arrow'}
|
|
253
255
|
class="pkt-combobox__wrapper"
|
|
@@ -552,6 +552,7 @@ export class PktDatepicker extends PktInputElement {
|
|
|
552
552
|
?useWrapper=${this.useWrapper}
|
|
553
553
|
.optionalText=${this.optionalText}
|
|
554
554
|
.requiredText=${this.requiredText}
|
|
555
|
+
.tagText=${this.tagText}
|
|
555
556
|
.errorMessage=${this.errorMessage}
|
|
556
557
|
.helptext=${this.helptext}
|
|
557
558
|
.helptextDropdown=${this.helptextDropdown}
|
|
@@ -27,6 +27,7 @@ type Props = ElementProps<
|
|
|
27
27
|
| 'optionalText'
|
|
28
28
|
| 'requiredTag'
|
|
29
29
|
| 'requiredText'
|
|
30
|
+
| 'tagText'
|
|
30
31
|
| 'hasError'
|
|
31
32
|
| 'errorMessage'
|
|
32
33
|
| 'disabled'
|
|
@@ -74,12 +75,14 @@ export class PktInputWrapper extends PktElement<Props> {
|
|
|
74
75
|
@property({ type: Boolean }) counter: boolean = specs.props.counter.default
|
|
75
76
|
@property({ type: Number }) counterCurrent: number = 0
|
|
76
77
|
@property({ type: Number }) counterMaxLength: number = 0
|
|
78
|
+
|
|
77
79
|
@property({ type: String }) counterError: string | null = null
|
|
78
80
|
@property({ type: String, reflect: false }) counterPosition: TCounterPosition = 'bottom'
|
|
79
81
|
@property({ type: Boolean }) optionalTag: boolean = specs.props.optionalTag.default
|
|
80
82
|
@property({ type: String }) optionalText: string = specs.props.optionalText.default
|
|
81
83
|
@property({ type: Boolean }) requiredTag: boolean = specs.props.requiredTag.default
|
|
82
84
|
@property({ type: String }) requiredText: string = specs.props.requiredText.default
|
|
85
|
+
@property({ type: String }) tagText: string | null = null
|
|
83
86
|
@property({ type: Boolean }) hasError: boolean = specs.props.hasError.default
|
|
84
87
|
@property({ type: String }) errorMessage: string = ''
|
|
85
88
|
@property({ type: Boolean }) disabled: boolean = specs.props.disabled.default
|
|
@@ -102,13 +105,7 @@ export class PktInputWrapper extends PktElement<Props> {
|
|
|
102
105
|
'pkt-inputwrapper--inline': this.inline,
|
|
103
106
|
}
|
|
104
107
|
|
|
105
|
-
const tagClasses =
|
|
106
|
-
'pkt-tag': true,
|
|
107
|
-
'pkt-tag--small': true,
|
|
108
|
-
'pkt-tag--thin-text': true,
|
|
109
|
-
'pkt-tag--blue-light': this.optionalTag,
|
|
110
|
-
'pkt-tag--beige': !this.optionalTag && this.requiredTag,
|
|
111
|
-
}
|
|
108
|
+
const tagClasses = 'pkt-tag pkt-tag--small pkt-tag--thin-text'
|
|
112
109
|
|
|
113
110
|
const describedBy = this.ariaDescribedby
|
|
114
111
|
? this.ariaDescribedby
|
|
@@ -117,17 +114,17 @@ export class PktInputWrapper extends PktElement<Props> {
|
|
|
117
114
|
: nothing
|
|
118
115
|
|
|
119
116
|
const tagElement = () => {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
>${this.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
117
|
+
return html`
|
|
118
|
+
${this.tagText
|
|
119
|
+
? html`<span class=${tagClasses + ' pkt-tag--gray'}>${this.tagText}</span>`
|
|
120
|
+
: nothing}
|
|
121
|
+
${this.optionalTag
|
|
122
|
+
? html`<span class=${tagClasses + ' pkt-tag--blue-light'}>${this.optionalText}</span>`
|
|
123
|
+
: nothing}
|
|
124
|
+
${this.requiredTag
|
|
125
|
+
? html`<span class=${tagClasses + ' pkt-tag--beige'}>${this.requiredText}</span>`
|
|
126
|
+
: nothing}
|
|
127
|
+
`
|
|
131
128
|
}
|
|
132
129
|
|
|
133
130
|
const labelElement = () => {
|
|
@@ -209,11 +206,14 @@ export class PktInputWrapper extends PktElement<Props> {
|
|
|
209
206
|
}
|
|
210
207
|
|
|
211
208
|
const inputContent = () => {
|
|
209
|
+
//prettier-ignore
|
|
212
210
|
return html`
|
|
213
|
-
${labelElement()}
|
|
211
|
+
${labelElement()}
|
|
212
|
+
${helptextElement()}
|
|
214
213
|
${this.counterPosition === 'top' ? counterElement() : nothing}
|
|
215
214
|
<div class="pkt-contents" ${ref(this.defaultSlot)}></div>
|
|
216
|
-
${this.counterPosition === 'bottom' ? counterElement() : nothing}
|
|
215
|
+
${this.counterPosition === 'bottom' ? counterElement() : nothing}
|
|
216
|
+
${errorElement()}
|
|
217
217
|
`
|
|
218
218
|
}
|
|
219
219
|
|
|
@@ -15,6 +15,11 @@ export class PktRadioButton extends PktInputElement {
|
|
|
15
15
|
@property({ type: Boolean }) hasTile: boolean = false
|
|
16
16
|
@property({ type: Boolean, reflect: true }) checked: boolean | string | null = null
|
|
17
17
|
@property({ type: String, reflect: true }) type: string = 'radio'
|
|
18
|
+
@property({ type: String }) tagText: string | null = null
|
|
19
|
+
@property({ type: Boolean }) optionalTag: boolean = false
|
|
20
|
+
@property({ type: String }) optionalText: string = 'Valgfritt'
|
|
21
|
+
@property({ type: Boolean }) requiredTag: boolean = false
|
|
22
|
+
@property({ type: String }) requiredText: string = 'Må fylles ut'
|
|
18
23
|
|
|
19
24
|
@state() _checked: boolean = false
|
|
20
25
|
|
|
@@ -50,10 +55,26 @@ export class PktRadioButton extends PktInputElement {
|
|
|
50
55
|
'pkt-sr-only': this.hideLabel,
|
|
51
56
|
})
|
|
52
57
|
|
|
58
|
+
const tagClasses = 'pkt-tag pkt-tag--small pkt-tag--thin-text'
|
|
59
|
+
|
|
60
|
+
const tags = () => {
|
|
61
|
+
return html`
|
|
62
|
+
${this.tagText
|
|
63
|
+
? html`<span class=${tagClasses + ' pkt-tag--gray'}>${this.tagText}</span>`
|
|
64
|
+
: nothing}
|
|
65
|
+
${this.optionalTag
|
|
66
|
+
? html`<span class=${tagClasses + ' pkt-tag--blue-light'}>${this.optionalText}</span>`
|
|
67
|
+
: nothing}
|
|
68
|
+
${this.requiredTag
|
|
69
|
+
? html`<span class=${tagClasses + ' pkt-tag--beige'}>${this.requiredText}</span>`
|
|
70
|
+
: nothing}
|
|
71
|
+
`
|
|
72
|
+
}
|
|
73
|
+
|
|
53
74
|
const labelAndHelptext = () => {
|
|
54
75
|
return html`
|
|
55
76
|
<label class=${labelClasses} for=${this.id + '-internal'}>
|
|
56
|
-
${this.label}
|
|
77
|
+
${this.label} ${tags()}
|
|
57
78
|
${this.checkHelptext
|
|
58
79
|
? html`<div class="pkt-input-check__input-helptext">${this.checkHelptext}</div>`
|
|
59
80
|
: nothing}
|
|
@@ -199,6 +199,7 @@ export class PktSelect extends PktInputElement implements IPktSelect {
|
|
|
199
199
|
label=${ifDefined(this.label)}
|
|
200
200
|
optionalText=${ifDefined(this.optionalText)}
|
|
201
201
|
requiredText=${ifDefined(this.requiredText)}
|
|
202
|
+
tagText=${ifDefined(this.tagText)}
|
|
202
203
|
>
|
|
203
204
|
<select
|
|
204
205
|
class=${inputClass}
|
|
@@ -15,14 +15,9 @@ export class PktTextarea extends PktInputElement {
|
|
|
15
15
|
private inputRef: Ref<HTMLTextAreaElement> = createRef()
|
|
16
16
|
private helptextSlot: Ref<HTMLElement> = createRef()
|
|
17
17
|
|
|
18
|
-
@property({ type: String, reflect: true })
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
@property({ type: String })
|
|
22
|
-
autocomplete: string = 'off'
|
|
23
|
-
|
|
24
|
-
@property({ type: Number })
|
|
25
|
-
rows: number | null = null
|
|
18
|
+
@property({ type: String, reflect: true }) value: string = ''
|
|
19
|
+
@property({ type: String }) autocomplete: string = 'off'
|
|
20
|
+
@property({ type: Number }) rows: number | null = null
|
|
26
21
|
|
|
27
22
|
@state() counterCurrent = 0
|
|
28
23
|
|
|
@@ -82,6 +77,7 @@ export class PktTextarea extends PktInputElement {
|
|
|
82
77
|
.helptextDropdownButton=${this.helptextDropdownButton}
|
|
83
78
|
.optionalText=${this.optionalText}
|
|
84
79
|
.requiredText=${this.requiredText}
|
|
80
|
+
.tagText=${this.tagText}
|
|
85
81
|
class="pkt-textarea"
|
|
86
82
|
>
|
|
87
83
|
<div class="pkt-contents" ${ref(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
@@ -27,29 +27,14 @@ export class PktTextinput extends PktInputElement<Props> {
|
|
|
27
27
|
private inputRef: Ref<HTMLTextAreaElement> = createRef()
|
|
28
28
|
private helptextSlot: Ref<HTMLElement> = createRef()
|
|
29
29
|
|
|
30
|
-
@property({ type: String, reflect: true })
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
@property({ type: String })
|
|
34
|
-
type: string =
|
|
35
|
-
|
|
36
|
-
@property({ type:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
@property({ type: String })
|
|
40
|
-
autocomplete: string | null = null
|
|
41
|
-
|
|
42
|
-
@property({ type: String })
|
|
43
|
-
iconNameRight: string | null = null
|
|
44
|
-
|
|
45
|
-
@property({ type: String })
|
|
46
|
-
prefix: string | null = null
|
|
47
|
-
|
|
48
|
-
@property({ type: String })
|
|
49
|
-
suffix: string | null = null
|
|
50
|
-
|
|
51
|
-
@property({ type: Boolean })
|
|
52
|
-
omitSearchIcon: boolean = false
|
|
30
|
+
@property({ type: String, reflect: true }) value: string = ''
|
|
31
|
+
@property({ type: String }) type: string = 'text'
|
|
32
|
+
@property({ type: Number }) size: number | null = null
|
|
33
|
+
@property({ type: String }) autocomplete: string | null = null
|
|
34
|
+
@property({ type: String }) iconNameRight: string | null = null
|
|
35
|
+
@property({ type: String }) prefix: string | null = null
|
|
36
|
+
@property({ type: String }) suffix: string | null = null
|
|
37
|
+
@property({ type: Boolean }) omitSearchIcon: boolean = false
|
|
53
38
|
|
|
54
39
|
@state() counterCurrent = 0
|
|
55
40
|
|
|
@@ -113,6 +98,7 @@ export class PktTextinput extends PktInputElement<Props> {
|
|
|
113
98
|
.helptextDropdownButton=${this.helptextDropdownButton}
|
|
114
99
|
.optionalText=${this.optionalText}
|
|
115
100
|
.requiredText=${this.requiredText}
|
|
101
|
+
.tagText=${this.tagText}
|
|
116
102
|
class="pkt-textinput"
|
|
117
103
|
>
|
|
118
104
|
<div class="pkt-contents" ${ref(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
@@ -127,11 +113,11 @@ export class PktTextinput extends PktInputElement<Props> {
|
|
|
127
113
|
placeholder=${ifDefined(this.placeholder)}
|
|
128
114
|
aria-labelledby=${labelledBy}
|
|
129
115
|
autocomplete=${this.autocomplete || 'off'}
|
|
130
|
-
minlength=${ifDefined(this.minlength)}
|
|
131
|
-
maxlength=${ifDefined(this.maxlength)}
|
|
132
|
-
min=${ifDefined(this.min)}
|
|
133
|
-
max=${ifDefined(this.max)}
|
|
134
|
-
step=${ifDefined(this.step)}
|
|
116
|
+
minlength=${ifDefined(this.minlength || undefined)}
|
|
117
|
+
maxlength=${ifDefined(this.maxlength || undefined)}
|
|
118
|
+
min=${ifDefined(this.min || undefined)}
|
|
119
|
+
max=${ifDefined(this.max || undefined)}
|
|
120
|
+
step=${ifDefined(this.step || undefined)}
|
|
135
121
|
?readonly=${this.readonly}
|
|
136
122
|
size=${this.size || nothing}
|
|
137
123
|
.value=${this.value}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("./element-6DBpyGQm.cjs"),a=require("./input-element-CHjLWeKt.cjs"),k=require("./ref-iJtiv3o2.cjs"),o=require("./class-map-BBG2gMX4.cjs");var r=Object.defineProperty,u=Object.getOwnPropertyDescriptor,c=(l,t,s,h)=>{for(var i=h>1?void 0:h?u(t,s):t,n=l.length-1,p;n>=0;n--)(p=l[n])&&(i=(h?p(t,s,i):p(i))||i);return h&&i&&r(t,s,i),i};exports.PktCheckbox=class extends a.PktInputElement{constructor(){super(...arguments),this.inputRef=k.e(),this.value="",this.checkHelptext=null,this.defaultChecked=!1,this.hasTile=!1,this.isSwitch=!1,this.labelPosition="right",this.hideLabel=!1,this.checked=null,this.type="checkbox"}connectedCallback(){super.connectedCallback()}attributeChangedCallback(t,s,h){t==="defaultChecked"&&!this.checked&&(this.checked=this.defaultChecked),t==="checked"&&(this.checked=this.checked===""||this.checked==="true"||this.checked===!0),super.attributeChangedCallback(t,s,h)}firstUpdated(t){t.has("defaultChecked")&&!this.checked&&(this.checked=this.defaultChecked),super.firstUpdated(t)}render(){const t=o.e({"pkt-input-check__input":!0,"pkt-input-check__input--tile":this.hasTile,"pkt-input-check__input--tile-disabled":this.disabled&&this.hasTile}),s=o.e({"pkt-input-check__input-checkbox":!0,"pkt-input-check__input-checkbox--error":this.hasError}),h=o.e({"pkt-input-check__input-label":!0,"pkt-input-check__input-label--disabled":this.disabled,"pkt-input-check__input-label--left":this.labelPosition==="left","pkt-input-check__input-label--right":this.labelPosition==="right","pkt-sr-only":this.hideLabel}),i=()=>e.x`
|
|
2
|
-
<label class=${h} for=${this.id+"-internal"}>
|
|
3
|
-
${this.label}
|
|
4
|
-
${this.checkHelptext?e.x`<div class="pkt-input-check__input-helptext">${this.checkHelptext}</div>`:e.E}
|
|
5
|
-
</label>
|
|
6
|
-
`;return e.x`
|
|
7
|
-
<div class="pkt-input-check">
|
|
8
|
-
<div class=${t}>
|
|
9
|
-
${this.labelPosition==="left"?i():e.E}
|
|
10
|
-
<input
|
|
11
|
-
id=${this.id+"-internal"}
|
|
12
|
-
class=${s}
|
|
13
|
-
type="checkbox"
|
|
14
|
-
?disabled=${this.disabled}
|
|
15
|
-
name=${this.name+"-internal"}
|
|
16
|
-
${k.n(this.inputRef)}
|
|
17
|
-
@change=${this.toggleChecked}
|
|
18
|
-
@blur=${this.onBlur}
|
|
19
|
-
@focus=${this.onFocus}
|
|
20
|
-
?checked=${this.checked}
|
|
21
|
-
role=${this.isSwitch?"switch":"checkbox"}
|
|
22
|
-
/>
|
|
23
|
-
${this.labelPosition==="right"?i():e.E}
|
|
24
|
-
</div>
|
|
25
|
-
</div>
|
|
26
|
-
`}toggleChecked(t){t.stopImmediatePropagation(),this.touched=!0,this.inputRef.value&&(this.checked=this.inputRef.value.matches(":checked"),this.valueChecked(this.checked))}};c([e.n({type:String,reflect:!0})],exports.PktCheckbox.prototype,"value",2);c([e.n({type:String})],exports.PktCheckbox.prototype,"checkHelptext",2);c([e.n({type:Boolean})],exports.PktCheckbox.prototype,"defaultChecked",2);c([e.n({type:Boolean})],exports.PktCheckbox.prototype,"hasTile",2);c([e.n({type:Boolean})],exports.PktCheckbox.prototype,"isSwitch",2);c([e.n({type:String})],exports.PktCheckbox.prototype,"labelPosition",2);c([e.n({type:Boolean})],exports.PktCheckbox.prototype,"hideLabel",2);c([e.n({type:Boolean,reflect:!0})],exports.PktCheckbox.prototype,"checked",2);c([e.n({type:String,reflect:!0})],exports.PktCheckbox.prototype,"type",2);exports.PktCheckbox=c([e.t("pkt-checkbox")],exports.PktCheckbox);
|