@oslokommune/punkt-elements 12.26.2 → 12.27.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.
Files changed (72) hide show
  1. package/dist/{alert-MKb7NX3r.js → alert-BvN80UkI.js} +1 -1
  2. package/dist/{alert-3DZNN48_.cjs → alert-uNzcOJR9.cjs} +1 -1
  3. package/dist/{card-CtipjQuP.cjs → card-BaxqXP-k.cjs} +1 -1
  4. package/dist/{card-ClWsCQfD.js → card-Br6A74Q1.js} +2 -2
  5. package/dist/{datepicker-B2W8ra1B.cjs → datepicker-BC0e34ws.cjs} +16 -15
  6. package/dist/{datepicker-BVI4szRk.js → datepicker-ONV4HuJt.js} +84 -82
  7. package/dist/helptext-DHfBEO42.js +78 -0
  8. package/dist/helptext-xUdEGuNQ.cjs +24 -0
  9. package/dist/index.d.ts +19 -6
  10. package/dist/input-wrapper-DeCY6nta.cjs +50 -0
  11. package/dist/input-wrapper-Df18_PvD.js +172 -0
  12. package/dist/{link-B3PDtnXT.js → link-0N9wG5l8.js} +1 -1
  13. package/dist/{link-BnL83t0x.cjs → link-I_LKEBVK.cjs} +1 -1
  14. package/dist/{linkcard-C4q7HCwY.js → linkcard-BJeRbpq_.js} +1 -1
  15. package/dist/{linkcard-RyOjvpmF.cjs → linkcard-ClXGVwdJ.cjs} +1 -1
  16. package/dist/{messagebox-BDfhozc3.js → messagebox-C5M56R8f.js} +1 -1
  17. package/dist/{messagebox-CuM1y2P_.cjs → messagebox-CC3j63Wp.cjs} +1 -1
  18. package/dist/{modal-gLMGJSSY.cjs → modal-BkchlKkL.cjs} +1 -1
  19. package/dist/{modal-CYv8Qk0Y.js → modal-PKDnp91S.js} +1 -1
  20. package/dist/pkt-alert.cjs +1 -1
  21. package/dist/pkt-alert.js +1 -1
  22. package/dist/pkt-card.cjs +1 -1
  23. package/dist/pkt-card.js +1 -1
  24. package/dist/pkt-datepicker.cjs +1 -1
  25. package/dist/pkt-datepicker.js +1 -1
  26. package/dist/pkt-helptext.cjs +1 -1
  27. package/dist/pkt-helptext.js +1 -1
  28. package/dist/pkt-index.cjs +1 -1
  29. package/dist/pkt-index.js +14 -14
  30. package/dist/pkt-input-wrapper.cjs +1 -1
  31. package/dist/pkt-input-wrapper.js +1 -1
  32. package/dist/pkt-link.cjs +1 -1
  33. package/dist/pkt-link.js +1 -1
  34. package/dist/pkt-linkcard.cjs +1 -1
  35. package/dist/pkt-linkcard.js +1 -1
  36. package/dist/pkt-messagebox.cjs +1 -1
  37. package/dist/pkt-messagebox.js +1 -1
  38. package/dist/pkt-modal.cjs +1 -1
  39. package/dist/pkt-modal.js +1 -1
  40. package/dist/pkt-select.cjs +1 -1
  41. package/dist/pkt-select.js +1 -1
  42. package/dist/pkt-slot-controller-Clbye6cM.js +85 -0
  43. package/dist/pkt-slot-controller-Oc32unDk.cjs +1 -0
  44. package/dist/pkt-tag.cjs +1 -1
  45. package/dist/pkt-tag.js +1 -1
  46. package/dist/pkt-textarea.cjs +1 -1
  47. package/dist/pkt-textarea.js +1 -1
  48. package/dist/pkt-textinput.cjs +1 -1
  49. package/dist/pkt-textinput.js +1 -1
  50. package/dist/select-DFlu7Eq6.cjs +48 -0
  51. package/dist/{select-BJr30hL7.js → select-DVyh7z8C.js} +60 -43
  52. package/dist/{tag-nAMwKi6B.cjs → tag-DGywzHJ5.cjs} +1 -1
  53. package/dist/{tag-CPLBzyiV.js → tag-W9Lf1doW.js} +1 -1
  54. package/dist/{textarea-Da-bIu5d.js → textarea-80zuPTTD.js} +35 -33
  55. package/dist/textarea-WWRAA1LV.cjs +49 -0
  56. package/dist/{textinput-C9pkRR6S.cjs → textinput-CE5AzOur.cjs} +4 -3
  57. package/dist/{textinput-Buj2CAKl.js → textinput-CZIE3v3S.js} +44 -42
  58. package/package.json +3 -3
  59. package/src/components/datepicker/datepicker.ts +8 -0
  60. package/src/components/helptext/helptext.ts +41 -35
  61. package/src/components/input-wrapper/input-wrapper.ts +28 -19
  62. package/src/components/select/select.ts +41 -8
  63. package/src/components/textarea/textarea.ts +9 -1
  64. package/src/components/textinput/textinput.ts +10 -1
  65. package/dist/helptext-CNgXo34f.js +0 -75
  66. package/dist/helptext-XPScYIkx.cjs +0 -23
  67. package/dist/input-wrapper-CWvzXs6X.js +0 -160
  68. package/dist/input-wrapper-nvacN4EY.cjs +0 -48
  69. package/dist/pkt-slot-controller-BEDVscvU.cjs +0 -1
  70. package/dist/pkt-slot-controller-DhwCJd_0.js +0 -67
  71. package/dist/select-B19JEWYw.cjs +0 -44
  72. package/dist/textarea-D7uvC79V.cjs +0 -48
@@ -0,0 +1,49 @@
1
+ "use strict";const r=require("./element-B0UgldHm.cjs"),u=require("./state-CG-binsl.cjs"),n=require("./ref-DDYBJ4EB.cjs"),p=require("./class-map-aeZWY44S.cjs"),d=require("./input-element-Dnda8hac.cjs"),c=require("./pkt-slot-controller-Oc32unDk.cjs");require("./input-wrapper-DeCY6nta.cjs");require("./icon-PWn7rnfg.cjs");/**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */const $=r.e(class extends r.i{constructor(i){if(super(i),i.type!==r.t$1.PROPERTY&&i.type!==r.t$1.ATTRIBUTE&&i.type!==r.t$1.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!n.f(i))throw Error("`live` bindings can only contain a single expression")}render(i){return i}update(i,[e]){if(e===r.T||e===r.E)return e;const s=i.element,t=i.name;if(i.type===r.t$1.PROPERTY){if(e===s[t])return r.T}else if(i.type===r.t$1.BOOLEAN_ATTRIBUTE){if(!!e===s.hasAttribute(t))return r.T}else if(i.type===r.t$1.ATTRIBUTE&&s.getAttribute(t)===e+"")return r.T;return n.m(i),e}});var x=Object.defineProperty,T=Object.getOwnPropertyDescriptor,o=(i,e,s,t)=>{for(var a=t>1?void 0:t?T(e,s):e,l=i.length-1,h;l>=0;l--)(h=i[l])&&(a=(t?h(e,s,a):h(a))||a);return t&&a&&x(e,s,a),a};exports.PktTextarea=class extends d.PktInputElement{constructor(){super(),this.inputRef=n.e(),this.helptextSlot=n.e(),this.value="",this.autocomplete="off",this.placeholder="",this.rows=null,this.counterCurrent=0,this.slotController=new c.PktSlotController(this,this.helptextSlot)}attributeChangedCallback(e,s,t){e==="value"&&this.value!==s&&(this.counterCurrent=t?t.length:0,this.valueChanged(t,s)),super.attributeChangedCallback(e,s,t)}updated(e){var s;super.updated(e),e.has("value")&&(this.counterCurrent=((s=this.value)==null?void 0:s.length)||0,this.valueChanged(this.value,e.get("value"))),e.has("id")&&!this.name&&this.id&&(this.name=this.id)}render(){const e=p.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}),s=this.ariaLabelledby||`${this.id}-input-label`;return r.x`<pkt-input-wrapper
6
+ label=${this.label}
7
+ ?counter=${this.counter}
8
+ ?disabled=${this.disabled}
9
+ ?hasError=${this.hasError}
10
+ ?inline=${this.inline}
11
+ ?optionalTag=${this.optionalTag}
12
+ ?required=${this.required}
13
+ ?requiredTag=${this.requiredTag}
14
+ ?useWrapper=${this.useWrapper}
15
+ .ariaDescribedBy=${this.ariaDescribedBy}
16
+ .counterCurrent=${this.counterCurrent}
17
+ .counterMaxLength=${this.counterMaxLength}
18
+ .errorMessage=${this.errorMessage}
19
+ .forId="${this.id+"-input"}"
20
+ .helptext=${this.helptext}
21
+ .helptextDropdown=${this.helptextDropdown}
22
+ .helptextDropdownButton=${this.helptextDropdownButton}
23
+ .optionalText=${this.optionalText}
24
+ .requiredText=${this.requiredText}
25
+ class="pkt-textarea"
26
+ >
27
+ <div class="pkt-contents" ${n.n(this.helptextSlot)} name="helptext" slot="helptext"></div>
28
+ <textarea
29
+ ${n.n(this.inputRef)}
30
+ class=${e}
31
+ id=${this.id+"-input"}
32
+ name=${(this.name||this.id)+"-input"}
33
+ placeholder=${this.placeholder??r.E}
34
+ .value=${$(this.value)}
35
+ minlength=${this.minlength||r.E}
36
+ maxlength=${this.maxlength||r.E}
37
+ ?readonly=${this.readonly}
38
+ autocomplete=${this.autocomplete}
39
+ aria-labelledby=${s}
40
+ aria-invalid=${this.hasError}
41
+ aria-errormessage=${`${this.id}-error`}
42
+ rows=${this.rows}
43
+ ?disabled=${this.disabled}
44
+ @input=${t=>{this.value=t.target.value,this.onInput(),t.stopImmediatePropagation()}}
45
+ @change=${t=>{t.stopImmediatePropagation()}}
46
+ @focus=${t=>{this.onFocus(),t.stopImmediatePropagation()}}
47
+ @blur=${t=>{this.value=t.target.value,this.onBlur(),t.stopImmediatePropagation()}}
48
+ ></textarea>
49
+ </pkt-input-wrapper>`}};o([r.n({type:String,reflect:!0})],exports.PktTextarea.prototype,"value",2);o([r.n({type:String})],exports.PktTextarea.prototype,"autocomplete",2);o([r.n({type:String})],exports.PktTextarea.prototype,"placeholder",2);o([r.n({type:Number})],exports.PktTextarea.prototype,"rows",2);o([u.r()],exports.PktTextarea.prototype,"counterCurrent",2);exports.PktTextarea=o([r.t("pkt-textarea")],exports.PktTextarea);
@@ -1,4 +1,4 @@
1
- "use strict";const t=require("./element-B0UgldHm.cjs"),h=require("./state-CG-binsl.cjs"),o=require("./ref-DDYBJ4EB.cjs"),l=require("./class-map-aeZWY44S.cjs"),c=require("./input-element-Dnda8hac.cjs");require("./input-wrapper-nvacN4EY.cjs");require("./icon-PWn7rnfg.cjs");var d=Object.defineProperty,x=Object.getOwnPropertyDescriptor,r=(p,i,n,s)=>{for(var e=s>1?void 0:s?x(i,n):i,a=p.length-1,u;a>=0;a--)(u=p[a])&&(e=(s?u(i,n,e):u(e))||e);return s&&e&&d(i,n,e),e};exports.PktTextinput=class extends c.PktInputElement{constructor(){super(...arguments),this.value="",this.type="text",this.size=null,this.autocomplete="off",this.iconNameRight=null,this.prefix=null,this.suffix=null,this.omitSearchIcon=!1,this.counterCurrent=0,this.inputRef=o.e()}attributeChangedCallback(i,n,s){i==="value"&&this.value!==n&&(this.counterCurrent=s?s.length:0,this.valueChanged(s,n)),super.attributeChangedCallback(i,n,s)}updated(i){var n;super.updated(i),i.has("value")&&(this.counterCurrent=((n=this.value)==null?void 0:n.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,n=l.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}),s=this.ariaLabelledby||`${this.id}-input-label`;return t.x`
1
+ "use strict";const t=require("./element-B0UgldHm.cjs"),u=require("./state-CG-binsl.cjs"),p=require("./ref-DDYBJ4EB.cjs"),l=require("./class-map-aeZWY44S.cjs"),c=require("./input-element-Dnda8hac.cjs"),x=require("./pkt-slot-controller-Oc32unDk.cjs");require("./input-wrapper-DeCY6nta.cjs");require("./icon-PWn7rnfg.cjs");var d=Object.defineProperty,$=Object.getOwnPropertyDescriptor,r=(o,i,n,s)=>{for(var e=s>1?void 0:s?$(i,n):i,a=o.length-1,h;a>=0;a--)(h=o[a])&&(e=(s?h(i,n,e):h(e))||e);return s&&e&&d(i,n,e),e};exports.PktTextinput=class extends c.PktInputElement{constructor(){super(),this.inputRef=p.e(),this.helptextSlot=p.e(),this.value="",this.type="text",this.size=null,this.autocomplete="off",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,n,s){i==="value"&&this.value!==n&&(this.counterCurrent=s?s.length:0,this.valueChanged(s,n)),super.attributeChangedCallback(i,n,s)}updated(i){var n;super.updated(i),i.has("value")&&(this.counterCurrent=((n=this.value)==null?void 0:n.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,n=l.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}),s=this.ariaLabelledby||`${this.id}-input-label`;return t.x`
2
2
  <pkt-input-wrapper
3
3
  label="${this.label}"
4
4
  ?counter=${this.counter}
@@ -21,10 +21,11 @@
21
21
  .requiredText=${this.requiredText}
22
22
  class="pkt-textinput"
23
23
  >
24
+ <div class="pkt-contents" ${p.n(this.helptextSlot)} name="helptext" slot="helptext"></div>
24
25
  <div class="pkt-input__container">
25
26
  ${this.prefix?t.x`<div class="pkt-input-prefix">${this.prefix}</div>`:t.E}
26
27
  <input
27
- ${o.n(this.inputRef)}
28
+ ${p.n(this.inputRef)}
28
29
  class=${n}
29
30
  type=${this.type}
30
31
  name=${(this.name||this.id)+"-input"}
@@ -60,4 +61,4 @@
60
61
  ${!this.suffix&&i?t.x`<pkt-icon class="pkt-input-icon" name="magnifying-glass-big"></pkt-icon>`:t.E}
61
62
  </div>
62
63
  </pkt-input-wrapper>
63
- `}};r([t.n({type:String,reflect:!0})],exports.PktTextinput.prototype,"value",2);r([t.n({type:String})],exports.PktTextinput.prototype,"type",2);r([t.n({type:Number})],exports.PktTextinput.prototype,"size",2);r([t.n({type:String})],exports.PktTextinput.prototype,"autocomplete",2);r([t.n({type:String})],exports.PktTextinput.prototype,"iconNameRight",2);r([t.n({type:String})],exports.PktTextinput.prototype,"prefix",2);r([t.n({type:String})],exports.PktTextinput.prototype,"suffix",2);r([t.n({type:Boolean})],exports.PktTextinput.prototype,"omitSearchIcon",2);r([h.r()],exports.PktTextinput.prototype,"counterCurrent",2);exports.PktTextinput=r([t.t("pkt-textinput")],exports.PktTextinput);
64
+ `}};r([t.n({type:String,reflect:!0})],exports.PktTextinput.prototype,"value",2);r([t.n({type:String})],exports.PktTextinput.prototype,"type",2);r([t.n({type:Number})],exports.PktTextinput.prototype,"size",2);r([t.n({type:String})],exports.PktTextinput.prototype,"autocomplete",2);r([t.n({type:String})],exports.PktTextinput.prototype,"iconNameRight",2);r([t.n({type:String})],exports.PktTextinput.prototype,"prefix",2);r([t.n({type:String})],exports.PktTextinput.prototype,"suffix",2);r([t.n({type:Boolean})],exports.PktTextinput.prototype,"omitSearchIcon",2);r([u.r()],exports.PktTextinput.prototype,"counterCurrent",2);exports.PktTextinput=r([t.t("pkt-textinput")],exports.PktTextinput);
@@ -1,28 +1,29 @@
1
- import { x as h, E as n, n as o, t as c } from "./element-BKrU5soj.js";
2
- import { r as d } from "./state-C36ZmZgt.js";
3
- import { e as $, n as m } from "./ref-D5qG7OFB.js";
4
- import { e as g } from "./class-map-CQzsZCwS.js";
5
- import { P as f } from "./input-element-URKBm_vS.js";
6
- import "./input-wrapper-CWvzXs6X.js";
1
+ import { x as h, E as n, n as p, t as $ } from "./element-BKrU5soj.js";
2
+ import { r as m } from "./state-C36ZmZgt.js";
3
+ import { e as c, n as d } from "./ref-D5qG7OFB.js";
4
+ import { e as f } from "./class-map-CQzsZCwS.js";
5
+ import { P as g } from "./input-element-URKBm_vS.js";
6
+ import { P as x } from "./pkt-slot-controller-Clbye6cM.js";
7
+ import "./input-wrapper-Df18_PvD.js";
7
8
  import "./icon-Bsb0MB2h.js";
8
- var x = Object.defineProperty, y = Object.getOwnPropertyDescriptor, a = (i, e, r, t) => {
9
- for (var p = t > 1 ? void 0 : t ? y(e, r) : e, u = i.length - 1, l; u >= 0; u--)
10
- (l = i[u]) && (p = (t ? l(e, r, p) : l(p)) || p);
11
- return t && p && x(e, r, p), p;
9
+ var y = Object.defineProperty, v = Object.getOwnPropertyDescriptor, o = (e, i, r, t) => {
10
+ for (var a = t > 1 ? void 0 : t ? v(i, r) : i, l = e.length - 1, u; l >= 0; l--)
11
+ (u = e[l]) && (a = (t ? u(i, r, a) : u(a)) || a);
12
+ return t && a && y(i, r, a), a;
12
13
  };
13
- let s = class extends f {
14
+ let s = class extends g {
14
15
  constructor() {
15
- super(...arguments), this.value = "", this.type = "text", this.size = null, this.autocomplete = "off", this.iconNameRight = null, this.prefix = null, this.suffix = null, this.omitSearchIcon = !1, this.counterCurrent = 0, this.inputRef = $();
16
+ super(), this.inputRef = c(), this.helptextSlot = c(), this.value = "", this.type = "text", this.size = null, this.autocomplete = "off", this.iconNameRight = null, this.prefix = null, this.suffix = null, this.omitSearchIcon = !1, this.counterCurrent = 0, this.slotController = new x(this, this.helptextSlot);
16
17
  }
17
- attributeChangedCallback(i, e, r) {
18
- i === "value" && this.value !== e && (this.counterCurrent = r ? r.length : 0, this.valueChanged(r, e)), super.attributeChangedCallback(i, e, r);
18
+ attributeChangedCallback(e, i, r) {
19
+ e === "value" && this.value !== i && (this.counterCurrent = r ? r.length : 0, this.valueChanged(r, i)), super.attributeChangedCallback(e, i, r);
19
20
  }
20
- updated(i) {
21
- var e;
22
- 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);
21
+ updated(e) {
22
+ var i;
23
+ super.updated(e), e.has("value") && (this.counterCurrent = ((i = this.value) == null ? void 0 : i.length) || 0, this.valueChanged(this.value, e.get("value"))), e.has("id") && !this.name && this.id && (this.name = this.id);
23
24
  }
24
25
  render() {
25
- const i = this.type === "search" && !this.iconNameRight && !this.omitSearchIcon, e = g({
26
+ const e = this.type === "search" && !this.iconNameRight && !this.omitSearchIcon, i = f({
26
27
  "pkt-input": !0,
27
28
  "pkt-input--fullwidth": this.fullwidth,
28
29
  "pkt-input--counter-error": this.counter && this.counterMaxLength && this.value.length && this.value.length > this.counterMaxLength
@@ -50,11 +51,12 @@ let s = class extends f {
50
51
  .requiredText=${this.requiredText}
51
52
  class="pkt-textinput"
52
53
  >
54
+ <div class="pkt-contents" ${d(this.helptextSlot)} name="helptext" slot="helptext"></div>
53
55
  <div class="pkt-input__container">
54
56
  ${this.prefix ? h`<div class="pkt-input-prefix">${this.prefix}</div>` : n}
55
57
  <input
56
- ${m(this.inputRef)}
57
- class=${e}
58
+ ${d(this.inputRef)}
59
+ class=${i}
58
60
  type=${this.type}
59
61
  name=${(this.name || this.id) + "-input"}
60
62
  id=${this.id + "-input"}
@@ -88,47 +90,47 @@ let s = class extends f {
88
90
  class="pkt-input-suffix-icon"
89
91
  name=${this.iconNameRight}
90
92
  ></pkt-icon>` : n}
91
- ${i ? h`<pkt-icon
93
+ ${e ? h`<pkt-icon
92
94
  class="pkt-input-suffix-icon"
93
95
  name="magnifying-glass-big"
94
96
  ></pkt-icon>` : n}
95
97
  </div>` : n}
96
98
  ${!this.suffix && this.iconNameRight ? h`<pkt-icon class="pkt-input-icon" name=${this.iconNameRight}></pkt-icon>` : n}
97
- ${!this.suffix && i ? h`<pkt-icon class="pkt-input-icon" name="magnifying-glass-big"></pkt-icon>` : n}
99
+ ${!this.suffix && e ? h`<pkt-icon class="pkt-input-icon" name="magnifying-glass-big"></pkt-icon>` : n}
98
100
  </div>
99
101
  </pkt-input-wrapper>
100
102
  `;
101
103
  }
102
104
  };
103
- a([
104
- o({ type: String, reflect: !0 })
105
+ o([
106
+ p({ type: String, reflect: !0 })
105
107
  ], s.prototype, "value", 2);
106
- a([
107
- o({ type: String })
108
+ o([
109
+ p({ type: String })
108
110
  ], s.prototype, "type", 2);
109
- a([
110
- o({ type: Number })
111
+ o([
112
+ p({ type: Number })
111
113
  ], s.prototype, "size", 2);
112
- a([
113
- o({ type: String })
114
+ o([
115
+ p({ type: String })
114
116
  ], s.prototype, "autocomplete", 2);
115
- a([
116
- o({ type: String })
117
+ o([
118
+ p({ type: String })
117
119
  ], s.prototype, "iconNameRight", 2);
118
- a([
119
- o({ type: String })
120
+ o([
121
+ p({ type: String })
120
122
  ], s.prototype, "prefix", 2);
121
- a([
122
- o({ type: String })
123
+ o([
124
+ p({ type: String })
123
125
  ], s.prototype, "suffix", 2);
124
- a([
125
- o({ type: Boolean })
126
+ o([
127
+ p({ type: Boolean })
126
128
  ], s.prototype, "omitSearchIcon", 2);
127
- a([
128
- d()
129
+ o([
130
+ m()
129
131
  ], s.prototype, "counterCurrent", 2);
130
- s = a([
131
- c("pkt-textinput")
132
+ s = o([
133
+ $("pkt-textinput")
132
134
  ], s);
133
135
  export {
134
136
  s as P
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-elements",
3
- "version": "12.26.2",
3
+ "version": "12.27.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,7 +30,7 @@
30
30
  },
31
31
  "devDependencies": {
32
32
  "@oslokommune/punkt-assets": "^12.23.0",
33
- "@oslokommune/punkt-css": "^12.26.0",
33
+ "@oslokommune/punkt-css": "^12.27.0",
34
34
  "sass": "^1.78.0",
35
35
  "typescript": "^5.6.2",
36
36
  "vite": "^5.4.4",
@@ -57,5 +57,5 @@
57
57
  "url": "https://github.com/oslokommune/punkt/issues"
58
58
  },
59
59
  "license": "MIT",
60
- "gitHead": "40edb9d3d4eab9308ced03492923de706deff59d"
60
+ "gitHead": "3f9b61a0e5d35866d6bc44088e4793798632d0e0"
61
61
  }
@@ -13,6 +13,7 @@ import '@/components/calendar'
13
13
  import '@/components/icon'
14
14
  import '@/components/input-wrapper'
15
15
  import '@/components/tag'
16
+ import { PktSlotController } from '@/controllers/pkt-slot-controller'
16
17
 
17
18
  const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
18
19
  @customElement('pkt-datepicker')
@@ -82,6 +83,11 @@ export class PktDatepicker extends PktInputElement {
82
83
  * Housekeeping / lifecycle methods
83
84
  */
84
85
 
86
+ constructor() {
87
+ super()
88
+ this.slotController = new PktSlotController(this, this.helptextSlot)
89
+ }
90
+
85
91
  async connectedCallback() {
86
92
  super.connectedCallback()
87
93
 
@@ -179,6 +185,7 @@ export class PktDatepicker extends PktInputElement {
179
185
  btnRef: Ref<HTMLButtonElement> = createRef()
180
186
  calRef: Ref<PktCalendar> = createRef()
181
187
  popupRef: Ref<HTMLDivElement> = createRef()
188
+ helptextSlot: Ref<HTMLElement> = createRef()
182
189
 
183
190
  /**
184
191
  * Rendering
@@ -518,6 +525,7 @@ export class PktDatepicker extends PktInputElement {
518
525
  .ariaDescribedBy=${this.ariaDescribedBy}
519
526
  class="pkt-datepicker"
520
527
  >
528
+ <div class="pkt-contents" ${ref(this.helptextSlot)} name="helptext" slot="helptext"></div>
521
529
  ${this.multiple ? this.renderTags() : nothing}
522
530
  <div
523
531
  class="pkt-datepicker__inputs ${this.range && this.showRangeLabels
@@ -1,28 +1,33 @@
1
1
  import { PktElement } from '@/base-elements/element'
2
2
  import { html, nothing } from 'lit'
3
+ import { createRef, ref, Ref } from 'lit/directives/ref.js'
3
4
  import { unsafeHTML } from 'lit/directives/unsafe-html.js'
4
5
  import { classMap } from 'lit/directives/class-map.js'
5
6
  import { customElement, property, state } from 'lit/decorators.js'
6
7
  import { uuidish } from '@/utils/stringutils'
7
8
  import specs from 'componentSpecs/input-wrapper.json'
8
9
  import '@/components/icon'
10
+ import { PktSlotController } from '@/controllers/pkt-slot-controller'
9
11
 
10
12
  @customElement('pkt-helptext')
11
13
  export class PktHelptext extends PktElement {
14
+ defaultSlot: Ref<HTMLElement> = createRef()
15
+
12
16
  constructor() {
13
17
  super()
18
+ this.slotController = new PktSlotController(this, this.defaultSlot)
14
19
  }
15
20
 
16
21
  @property({ type: String, reflect: true })
17
22
  forId: string = uuidish()
18
23
 
19
- @property({ type: String, reflect: true })
24
+ @property({ type: String })
20
25
  helptext: string = ''
21
26
 
22
- @property({ type: String, reflect: true })
27
+ @property({ type: String })
23
28
  helptextDropdown: string = ''
24
29
 
25
- @property({ type: String, reflect: true })
30
+ @property({ type: String })
26
31
  helptextDropdownButton: string = specs.props.helptextDropdownButton.default
27
32
 
28
33
  @state() isHelpTextOpen: boolean = false
@@ -39,44 +44,45 @@ export class PktHelptext extends PktElement {
39
44
  )
40
45
  }
41
46
 
42
- const helptextElement = () => {
43
- if (this.helptext || this.helptextDropdown) {
44
- return html`<div>
45
- ${this.helptext
46
- ? html`<div class="pkt-inputwrapper__helptext" id="${this.forId}-helptext">
47
- ${unsafeHTML(this.helptext)}
48
- </div>`
49
- : nothing}
50
- ${this.helptextDropdown
51
- ? html`<div class="pkt-inputwrapper__helptext-expandable">
52
- <button
53
- class="pkt-link pkt-link--icon-right pkt-btn pkt-btn--small pkt-btn--tertiary pkt-btn--icon-right"
54
- type="button"
55
- @click=${toggleDropdown}
56
- >
57
- <pkt-icon
58
- class="pkt-btn__icon"
59
- name="${this.isHelpTextOpen ? 'chevron-thin-up' : 'chevron-thin-down'}"
60
- ></pkt-icon>
61
- <span class="pkt-btn__text">${unsafeHTML(this.helptextDropdownButton)}</span>
62
- </button>
63
- <div
64
- class="${classMap({
65
- 'pkt-inputwrapper__helptext': true,
66
- 'pkt-inputwrapper__helptext-expandable-open': this.isHelpTextOpen,
67
- 'pkt-inputwrapper__helptext-expandable-closed': !this.isHelpTextOpen,
68
- })}"
69
- >
70
- ${unsafeHTML(this.helptextDropdown)}
71
- </div>
72
- </div>`
73
- : nothing}
47
+ const helptextDropdown = () => {
48
+ if (this.helptextDropdown) {
49
+ return html`<div class="pkt-inputwrapper__helptext-expandable">
50
+ <button
51
+ class="pkt-link pkt-link--icon-right pkt-btn pkt-btn--small pkt-btn--tertiary pkt-btn--icon-right"
52
+ type="button"
53
+ @click=${toggleDropdown}
54
+ >
55
+ <pkt-icon
56
+ class="pkt-btn__icon"
57
+ name="${this.isHelpTextOpen ? 'chevron-thin-up' : 'chevron-thin-down'}"
58
+ ></pkt-icon>
59
+ <span class="pkt-btn__text">${unsafeHTML(this.helptextDropdownButton)}</span>
60
+ </button>
61
+ <div
62
+ class="${classMap({
63
+ 'pkt-inputwrapper__helptext': true,
64
+ 'pkt-inputwrapper__helptext-expandable-open': this.isHelpTextOpen,
65
+ 'pkt-inputwrapper__helptext-expandable-closed': !this.isHelpTextOpen,
66
+ })}"
67
+ >
68
+ ${unsafeHTML(this.helptextDropdown)}
69
+ </div>
74
70
  </div>`
75
71
  } else {
76
72
  return nothing
77
73
  }
78
74
  }
79
75
 
76
+ const helptextElement = () => {
77
+ return html`<div>
78
+ <div class="pkt-inputwrapper__helptext" id="${this.forId}-helptext">
79
+ <div class="pkt-contents" ${ref(this.defaultSlot)} name="helptext"></div>
80
+ ${this.helptext && unsafeHTML(this.helptext)}
81
+ </div>
82
+ ${helptextDropdown()}
83
+ </div>`
84
+ }
85
+
80
86
  return html`${helptextElement()}`
81
87
  }
82
88
  }
@@ -1,10 +1,10 @@
1
1
  import { PktElement } from '@/base-elements/element'
2
2
  import { PktSlotController } from '@/controllers/pkt-slot-controller'
3
3
  import { ref, Ref, createRef } from 'lit/directives/ref.js'
4
- import { html, nothing } from 'lit'
4
+ import { html, nothing, PropertyValues } from 'lit'
5
5
  import { unsafeHTML } from 'lit/directives/unsafe-html.js'
6
6
  import { classMap } from 'lit/directives/class-map.js'
7
- import { customElement, property } from 'lit/decorators.js'
7
+ import { customElement, property, state } from 'lit/decorators.js'
8
8
  import { uuidish } from '@/utils/stringutils'
9
9
  import specs from 'componentSpecs/input-wrapper.json'
10
10
  import '@/components/helptext'
@@ -13,10 +13,12 @@ import '@/components/icon'
13
13
  @customElement('pkt-input-wrapper')
14
14
  export class PktInputWrapper extends PktElement {
15
15
  defaultSlot: Ref<HTMLElement> = createRef()
16
+ helptextSlot: Ref<HTMLElement> = createRef()
17
+ @state() hasHelptextSlot: boolean = false
16
18
 
17
19
  constructor() {
18
20
  super()
19
- this.slotController = new PktSlotController(this, this.defaultSlot)
21
+ this.slotController = new PktSlotController(this, this.defaultSlot, this.helptextSlot)
20
22
  }
21
23
 
22
24
  /**
@@ -43,6 +45,15 @@ export class PktInputWrapper extends PktElement {
43
45
  @property({ type: Boolean }) useWrapper: boolean = specs.props.useWrapper.default
44
46
  @property({ type: String, reflect: true }) role: string | null = 'group'
45
47
 
48
+ public updateSlots(): void {
49
+ this.hasHelptextSlot = this.slotController.filledSlots.has('helptext')
50
+ }
51
+
52
+ protected updated(changedProperties: PropertyValues): void {
53
+ this.updateSlots()
54
+ super.updated(changedProperties)
55
+ }
56
+
46
57
  render() {
47
58
  const classes = {
48
59
  'pkt-inputwrapper': true,
@@ -111,22 +122,20 @@ export class PktInputWrapper extends PktElement {
111
122
  }
112
123
 
113
124
  const helptextElement = () => {
114
- if (this.useWrapper && (this.helptext || this.helptextDropdown)) {
115
- return html`
116
- <pkt-helptext
117
- .forId=${this.forId}
118
- .helptext=${this.helptext}
119
- .helptextDropdown=${this.helptextDropdown}
120
- .helptextDropdownButton=${this.helptextDropdownButton ||
121
- specs.props.helptextDropdownButton.default}
122
- @toggleHelpText=${(e: CustomEvent) => {
123
- this.toggleDropdown(e)
124
- }}
125
- ></pkt-helptext>
126
- `
127
- } else {
128
- return nothing
129
- }
125
+ return html`
126
+ <pkt-helptext
127
+ .forId=${this.forId}
128
+ .helptext=${this.helptext}
129
+ .helptextDropdown=${this.helptextDropdown}
130
+ .helptextDropdownButton=${this.helptextDropdownButton ||
131
+ specs.props.helptextDropdownButton.default}
132
+ @toggleHelpText=${(e: CustomEvent) => {
133
+ this.toggleDropdown(e)
134
+ }}
135
+ ${ref(this.helptextSlot)}
136
+ name="helptext"
137
+ ></pkt-helptext>
138
+ `
130
139
  }
131
140
 
132
141
  const counterElement = () => {
@@ -4,6 +4,7 @@ import { Ref, createRef, ref } from 'lit/directives/ref.js'
4
4
  import { ifDefined } from 'lit/directives/if-defined.js'
5
5
  import { PktInputElement } from '@/base-elements/input-element'
6
6
  import { PktOptionsSlotController } from '@/controllers/pkt-options-controller'
7
+ import { PktSlotController } from '@/controllers/pkt-slot-controller'
7
8
  import '@/components/input-wrapper'
8
9
 
9
10
  export type TSelectOption = {
@@ -31,17 +32,19 @@ export interface IPktSelect {
31
32
 
32
33
  @customElement('pkt-select')
33
34
  export class PktSelect extends PktInputElement implements IPktSelect {
34
- private selectRef: Ref<HTMLSelectElement> = createRef()
35
- defaultSlot: Ref<HTMLElement> = createRef()
35
+ private inputRef: Ref<HTMLSelectElement> = createRef()
36
+ private helptextSlot: Ref<HTMLElement> = createRef()
36
37
 
37
38
  @property({ type: Array }) options: TSelectOption[] = []
38
- @property({ type: String }) value: string = ''
39
+ @property({ type: String, reflect: true }) value: string = ''
39
40
 
40
41
  @state() private _options: TSelectOption[] = []
41
42
 
42
43
  constructor() {
43
44
  super()
44
45
  this.optionsController = new PktOptionsSlotController(this)
46
+ this.slotController = new PktSlotController(this, this.helptextSlot)
47
+ this.slotController.skipOptions = true
45
48
  }
46
49
 
47
50
  // Used for initilization
@@ -73,9 +76,23 @@ export class PktSelect extends PktInputElement implements IPktSelect {
73
76
  if (name === 'options') {
74
77
  this._options = value ? JSON.parse(value) : []
75
78
  }
79
+ if (name === 'value' && this.value !== _old) {
80
+ this.valueChanged(value, _old)
81
+ }
76
82
  super.attributeChangedCallback(name, _old, value)
77
83
  }
78
84
 
85
+ updated(changedProperties: PropertyValues) {
86
+ super.updated(changedProperties)
87
+ if (changedProperties.has('value')) {
88
+ this.counterCurrent = this.value?.length || 0
89
+ this.valueChanged(this.value, changedProperties.get('value'))
90
+ }
91
+ if (changedProperties.has('id')) {
92
+ !this.name && this.id && (this.name = this.id)
93
+ }
94
+ }
95
+
79
96
  protected firstUpdated(_changedProperties: PropertyValues): void {
80
97
  super.firstUpdated(_changedProperties)
81
98
  if (this.options.length) {
@@ -100,7 +117,7 @@ export class PktSelect extends PktInputElement implements IPktSelect {
100
117
  .counterMaxLength=${this.counterMaxLength}
101
118
  class="pkt-select"
102
119
  errorMessage=${ifDefined(this.errorMessage)}
103
- forId=${this.id}
120
+ forId=${this.id + '-input'}
104
121
  helptext=${ifDefined(this.helptext)}
105
122
  helptextDropdown=${ifDefined(this.helptextDropdown)}
106
123
  helptextDropdownButton=${ifDefined(this.helptextDropdownButton)}
@@ -114,11 +131,26 @@ export class PktSelect extends PktInputElement implements IPktSelect {
114
131
  aria-errormessage=${`${this.id}-error`}
115
132
  aria-labelledby=${ifDefined(this.ariaLabelledby)}
116
133
  ?disabled=${this.disabled}
117
- id=${this.id}
118
- name=${this.name || this.id}
134
+ id=${this.id + '-input'}
135
+ name=${(this.name || this.id) + '-input'}
119
136
  value=${this.value}
120
- ${ref(this.selectRef)}
121
- ${ref(this.defaultSlot)}
137
+ @change=${(e: Event) => {
138
+ this.value = (e.target as HTMLSelectElement).value
139
+ e.stopImmediatePropagation()
140
+ }}
141
+ @input=${(e: Event) => {
142
+ this.onInput()
143
+ e.stopImmediatePropagation()
144
+ }}
145
+ @focus=${(e: FocusEvent) => {
146
+ this.onFocus()
147
+ e.stopImmediatePropagation()
148
+ }}
149
+ @blur=${(e: FocusEvent) => {
150
+ this.onBlur()
151
+ e.stopImmediatePropagation()
152
+ }}
153
+ ${ref(this.inputRef)}
122
154
  >
123
155
  ${this._options.length > 0 &&
124
156
  this._options.map(
@@ -132,6 +164,7 @@ export class PktSelect extends PktInputElement implements IPktSelect {
132
164
  </option>`,
133
165
  )}
134
166
  </select>
167
+ <div class="pkt-contents" ${ref(this.helptextSlot)} name="helptext" slot="helptext"></div>
135
168
  </pkt-input-wrapper>
136
169
  `
137
170
  }
@@ -4,12 +4,16 @@ import { Ref, createRef, ref } from 'lit/directives/ref.js'
4
4
  import { classMap } from 'lit/directives/class-map.js'
5
5
  import { live } from 'lit/directives/live.js'
6
6
  import { PktInputElement } from '@/base-elements/input-element'
7
+ import { PktSlotController } from '@/controllers/pkt-slot-controller'
7
8
 
8
9
  import '@/components/input-wrapper'
9
10
  import '@/components/icon'
10
11
 
11
12
  @customElement('pkt-textarea')
12
13
  export class PktTextarea extends PktInputElement {
14
+ private inputRef: Ref<HTMLTextAreaElement> = createRef()
15
+ private helptextSlot: Ref<HTMLElement> = createRef()
16
+
13
17
  @property({ type: String, reflect: true })
14
18
  value: string = ''
15
19
 
@@ -24,7 +28,10 @@ export class PktTextarea extends PktInputElement {
24
28
 
25
29
  @state() counterCurrent = 0
26
30
 
27
- private inputRef: Ref<HTMLTextAreaElement> = createRef()
31
+ constructor() {
32
+ super()
33
+ this.slotController = new PktSlotController(this, this.helptextSlot)
34
+ }
28
35
 
29
36
  attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
30
37
  if (name === 'value' && this.value !== _old) {
@@ -79,6 +86,7 @@ export class PktTextarea extends PktInputElement {
79
86
  .requiredText=${this.requiredText}
80
87
  class="pkt-textarea"
81
88
  >
89
+ <div class="pkt-contents" ${ref(this.helptextSlot)} name="helptext" slot="helptext"></div>
82
90
  <textarea
83
91
  ${ref(this.inputRef)}
84
92
  class=${inputClasses}
@@ -3,11 +3,16 @@ import { customElement, property, state } from 'lit/decorators.js'
3
3
  import { Ref, createRef, ref } from 'lit/directives/ref.js'
4
4
  import { classMap } from 'lit/directives/class-map.js'
5
5
  import { PktInputElement } from '@/base-elements/input-element'
6
+ import { PktSlotController } from '@/controllers/pkt-slot-controller'
7
+
6
8
  import '@/components/input-wrapper'
7
9
  import '@/components/icon'
8
10
 
9
11
  @customElement('pkt-textinput')
10
12
  export class PktTextinput extends PktInputElement {
13
+ private inputRef: Ref<HTMLTextAreaElement> = createRef()
14
+ private helptextSlot: Ref<HTMLElement> = createRef()
15
+
11
16
  @property({ type: String, reflect: true })
12
17
  value: string = ''
13
18
 
@@ -34,7 +39,10 @@ export class PktTextinput extends PktInputElement {
34
39
 
35
40
  @state() counterCurrent = 0
36
41
 
37
- private inputRef: Ref<HTMLInputElement> = createRef()
42
+ constructor() {
43
+ super()
44
+ this.slotController = new PktSlotController(this, this.helptextSlot)
45
+ }
38
46
 
39
47
  attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
40
48
  if (name === 'value' && this.value !== _old) {
@@ -92,6 +100,7 @@ export class PktTextinput extends PktInputElement {
92
100
  .requiredText=${this.requiredText}
93
101
  class="pkt-textinput"
94
102
  >
103
+ <div class="pkt-contents" ${ref(this.helptextSlot)} name="helptext" slot="helptext"></div>
95
104
  <div class="pkt-input__container">
96
105
  ${this.prefix ? html`<div class="pkt-input-prefix">${this.prefix}</div>` : nothing}
97
106
  <input