@oslokommune/punkt-elements 13.0.0 → 13.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/checkbox-CTRbpbye.js +120 -0
- package/dist/checkbox-wJ26voZd.cjs +30 -0
- package/dist/{combobox-DWYPzXj-.cjs → combobox-CijGa9Fr.cjs} +3 -2
- package/dist/{combobox-BREXxMeO.js → combobox-Cwg9Rkmz.js} +3 -2
- package/dist/{datepicker-SYeGnXRZ.cjs → datepicker-BhrUneAP.cjs} +2 -1
- package/dist/{datepicker-DH4ZFMxD.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-BND8tUg_.cjs → input-wrapper-CZ-a00V7.cjs} +16 -14
- 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-DGHoBmbb.js → select-CsgDatCa.js} +14 -13
- package/dist/{select-BwwF5Gki.cjs → select-DUeTm8ac.cjs} +11 -10
- package/dist/{textarea-BrW98O-a.js → textarea-BZL8Mkm0.js} +5 -4
- package/dist/{textarea-PHo1w92l.cjs → textarea-CPXsMFUq.cjs} +2 -1
- package/dist/{textinput-BrBGjHZc.js → textinput-DjPhmmkB.js} +3 -2
- package/dist/{textinput-CS0OHykQ.cjs → textinput-aNI5kibM.cjs} +2 -1
- package/package.json +3 -3
- 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 +14 -18
- package/src/components/radiobutton/radiobutton.ts +22 -1
- package/src/components/select/select.ts +1 -0
- package/src/components/textarea/textarea.ts +1 -0
- package/src/components/textinput/textinput.ts +1 -0
- package/dist/checkbox-CJ4tK9RC.cjs +0 -26
- package/dist/checkbox-cD_5LDzV.js +0 -101
- package/dist/input-wrapper-_Lk9HzHU.js +0 -190
- 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>
|
|
@@ -3,9 +3,9 @@ import { o as u } from "./if-defined-CmuO4Vz9.js";
|
|
|
3
3
|
import { r as f } from "./state-Bo2bck5_.js";
|
|
4
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-
|
|
6
|
+
import { P as x } from "./input-element-NnrDmp4r.js";
|
|
7
7
|
import { P as v } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
8
|
-
import "./input-wrapper-
|
|
8
|
+
import "./input-wrapper-Dr__Sxql.js";
|
|
9
9
|
import "./icon-CC1js8eR.js";
|
|
10
10
|
var y = Object.defineProperty, b = Object.getOwnPropertyDescriptor, o = (i, e, r, t) => {
|
|
11
11
|
for (var n = t > 1 ? void 0 : t ? b(e, r) : e, l = i.length - 1, c; l >= 0; l--)
|
|
@@ -51,6 +51,7 @@ 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
57
|
<div class="pkt-contents" ${m(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
@@ -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"),d=require("./input-element-
|
|
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>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.1.2",
|
|
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": "^13.0.0",
|
|
34
|
-
"@oslokommune/punkt-css": "^13.
|
|
34
|
+
"@oslokommune/punkt-css": "^13.1.2",
|
|
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": "cb98f3d45e891775f449eb4b78b3ae8cab40725f"
|
|
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'
|
|
@@ -81,6 +82,7 @@ export class PktInputWrapper extends PktElement<Props> {
|
|
|
81
82
|
@property({ type: String }) optionalText: string = specs.props.optionalText.default
|
|
82
83
|
@property({ type: Boolean }) requiredTag: boolean = specs.props.requiredTag.default
|
|
83
84
|
@property({ type: String }) requiredText: string = specs.props.requiredText.default
|
|
85
|
+
@property({ type: String }) tagText: string | null = null
|
|
84
86
|
@property({ type: Boolean }) hasError: boolean = specs.props.hasError.default
|
|
85
87
|
@property({ type: String }) errorMessage: string = ''
|
|
86
88
|
@property({ type: Boolean }) disabled: boolean = specs.props.disabled.default
|
|
@@ -103,13 +105,7 @@ export class PktInputWrapper extends PktElement<Props> {
|
|
|
103
105
|
'pkt-inputwrapper--inline': this.inline,
|
|
104
106
|
}
|
|
105
107
|
|
|
106
|
-
const tagClasses =
|
|
107
|
-
'pkt-tag': true,
|
|
108
|
-
'pkt-tag--small': true,
|
|
109
|
-
'pkt-tag--thin-text': true,
|
|
110
|
-
'pkt-tag--blue-light': this.optionalTag,
|
|
111
|
-
'pkt-tag--beige': !this.optionalTag && this.requiredTag,
|
|
112
|
-
}
|
|
108
|
+
const tagClasses = 'pkt-tag pkt-tag--small pkt-tag--thin-text'
|
|
113
109
|
|
|
114
110
|
const describedBy = this.ariaDescribedby
|
|
115
111
|
? this.ariaDescribedby
|
|
@@ -118,17 +114,17 @@ export class PktInputWrapper extends PktElement<Props> {
|
|
|
118
114
|
: nothing
|
|
119
115
|
|
|
120
116
|
const tagElement = () => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
>${this.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
+
`
|
|
132
128
|
}
|
|
133
129
|
|
|
134
130
|
const labelElement = () => {
|
|
@@ -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}
|
|
@@ -77,6 +77,7 @@ export class PktTextarea extends PktInputElement {
|
|
|
77
77
|
.helptextDropdownButton=${this.helptextDropdownButton}
|
|
78
78
|
.optionalText=${this.optionalText}
|
|
79
79
|
.requiredText=${this.requiredText}
|
|
80
|
+
.tagText=${this.tagText}
|
|
80
81
|
class="pkt-textarea"
|
|
81
82
|
>
|
|
82
83
|
<div class="pkt-contents" ${ref(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
@@ -98,6 +98,7 @@ export class PktTextinput extends PktInputElement<Props> {
|
|
|
98
98
|
.helptextDropdownButton=${this.helptextDropdownButton}
|
|
99
99
|
.optionalText=${this.optionalText}
|
|
100
100
|
.requiredText=${this.requiredText}
|
|
101
|
+
.tagText=${this.tagText}
|
|
101
102
|
class="pkt-textinput"
|
|
102
103
|
>
|
|
103
104
|
<div class="pkt-contents" ${ref(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
@@ -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);
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { E as n, x as r, n as s, a as d } from "./element-CgEWt74-.js";
|
|
2
|
-
import { P as k } from "./input-element-Cco4PA2M.js";
|
|
3
|
-
import { e as b, n as f } from "./ref-BBYSqgeW.js";
|
|
4
|
-
import { e as u } from "./class-map-BpTj9gtz.js";
|
|
5
|
-
var _ = Object.defineProperty, y = Object.getOwnPropertyDescriptor, i = (e, h, c, l) => {
|
|
6
|
-
for (var p = l > 1 ? void 0 : l ? y(h, c) : h, a = e.length - 1, o; a >= 0; a--)
|
|
7
|
-
(o = e[a]) && (p = (l ? o(h, c, p) : o(p)) || p);
|
|
8
|
-
return l && p && _(h, c, p), p;
|
|
9
|
-
};
|
|
10
|
-
let t = class extends k {
|
|
11
|
-
constructor() {
|
|
12
|
-
super(...arguments), this.inputRef = b(), 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";
|
|
13
|
-
}
|
|
14
|
-
connectedCallback() {
|
|
15
|
-
super.connectedCallback();
|
|
16
|
-
}
|
|
17
|
-
attributeChangedCallback(e, h, c) {
|
|
18
|
-
e === "defaultChecked" && !this.checked && (this.checked = this.defaultChecked), e === "checked" && (this.checked = this.checked === "" || this.checked === "true" || this.checked === !0), super.attributeChangedCallback(e, h, c);
|
|
19
|
-
}
|
|
20
|
-
firstUpdated(e) {
|
|
21
|
-
e.has("defaultChecked") && !this.checked && (this.checked = this.defaultChecked), super.firstUpdated(e);
|
|
22
|
-
}
|
|
23
|
-
render() {
|
|
24
|
-
const e = u({
|
|
25
|
-
"pkt-input-check__input": !0,
|
|
26
|
-
"pkt-input-check__input--tile": this.hasTile,
|
|
27
|
-
"pkt-input-check__input--tile-disabled": this.disabled && this.hasTile
|
|
28
|
-
}), h = u({
|
|
29
|
-
"pkt-input-check__input-checkbox": !0,
|
|
30
|
-
"pkt-input-check__input-checkbox--error": this.hasError
|
|
31
|
-
}), c = u({
|
|
32
|
-
"pkt-input-check__input-label": !0,
|
|
33
|
-
"pkt-input-check__input-label--disabled": this.disabled,
|
|
34
|
-
"pkt-input-check__input-label--left": this.labelPosition === "left",
|
|
35
|
-
"pkt-input-check__input-label--right": this.labelPosition === "right",
|
|
36
|
-
"pkt-sr-only": this.hideLabel
|
|
37
|
-
}), l = () => r`
|
|
38
|
-
<label class=${c} for=${this.id + "-internal"}>
|
|
39
|
-
${this.label}
|
|
40
|
-
${this.checkHelptext ? r`<div class="pkt-input-check__input-helptext">${this.checkHelptext}</div>` : n}
|
|
41
|
-
</label>
|
|
42
|
-
`;
|
|
43
|
-
return r`
|
|
44
|
-
<div class="pkt-input-check">
|
|
45
|
-
<div class=${e}>
|
|
46
|
-
${this.labelPosition === "left" ? l() : n}
|
|
47
|
-
<input
|
|
48
|
-
id=${this.id + "-internal"}
|
|
49
|
-
class=${h}
|
|
50
|
-
type="checkbox"
|
|
51
|
-
?disabled=${this.disabled}
|
|
52
|
-
name=${this.name + "-internal"}
|
|
53
|
-
${f(this.inputRef)}
|
|
54
|
-
@change=${this.toggleChecked}
|
|
55
|
-
@blur=${this.onBlur}
|
|
56
|
-
@focus=${this.onFocus}
|
|
57
|
-
?checked=${this.checked}
|
|
58
|
-
role=${this.isSwitch ? "switch" : "checkbox"}
|
|
59
|
-
/>
|
|
60
|
-
${this.labelPosition === "right" ? l() : n}
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
`;
|
|
64
|
-
}
|
|
65
|
-
toggleChecked(e) {
|
|
66
|
-
e.stopImmediatePropagation(), this.touched = !0, this.inputRef.value && (this.checked = this.inputRef.value.matches(":checked"), this.valueChecked(this.checked));
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
i([
|
|
70
|
-
s({ type: String, reflect: !0 })
|
|
71
|
-
], t.prototype, "value", 2);
|
|
72
|
-
i([
|
|
73
|
-
s({ type: String })
|
|
74
|
-
], t.prototype, "checkHelptext", 2);
|
|
75
|
-
i([
|
|
76
|
-
s({ type: Boolean })
|
|
77
|
-
], t.prototype, "defaultChecked", 2);
|
|
78
|
-
i([
|
|
79
|
-
s({ type: Boolean })
|
|
80
|
-
], t.prototype, "hasTile", 2);
|
|
81
|
-
i([
|
|
82
|
-
s({ type: Boolean })
|
|
83
|
-
], t.prototype, "isSwitch", 2);
|
|
84
|
-
i([
|
|
85
|
-
s({ type: String })
|
|
86
|
-
], t.prototype, "labelPosition", 2);
|
|
87
|
-
i([
|
|
88
|
-
s({ type: Boolean })
|
|
89
|
-
], t.prototype, "hideLabel", 2);
|
|
90
|
-
i([
|
|
91
|
-
s({ type: Boolean, reflect: !0 })
|
|
92
|
-
], t.prototype, "checked", 2);
|
|
93
|
-
i([
|
|
94
|
-
s({ type: String, reflect: !0 })
|
|
95
|
-
], t.prototype, "type", 2);
|
|
96
|
-
t = i([
|
|
97
|
-
d("pkt-checkbox")
|
|
98
|
-
], t);
|
|
99
|
-
export {
|
|
100
|
-
t as P
|
|
101
|
-
};
|