@oslokommune/punkt-elements 12.26.2 → 12.27.1

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 (90) 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/alert.d.ts +7 -0
  4. package/dist/calendar.d.ts +7 -0
  5. package/dist/{card-CtipjQuP.cjs → card-BaxqXP-k.cjs} +1 -1
  6. package/dist/{card-ClWsCQfD.js → card-Br6A74Q1.js} +2 -2
  7. package/dist/card.d.ts +7 -0
  8. package/dist/{datepicker-B2W8ra1B.cjs → datepicker-BC0e34ws.cjs} +16 -15
  9. package/dist/{datepicker-BVI4szRk.js → datepicker-ONV4HuJt.js} +84 -82
  10. package/dist/datepicker.d.ts +7 -0
  11. package/dist/helptext-DHfBEO42.js +78 -0
  12. package/dist/helptext-xUdEGuNQ.cjs +24 -0
  13. package/dist/helptext.d.ts +7 -0
  14. package/dist/icon.d.ts +7 -0
  15. package/dist/index.d.ts +29 -8
  16. package/dist/input-wrapper-DeCY6nta.cjs +50 -0
  17. package/dist/input-wrapper-Df18_PvD.js +172 -0
  18. package/dist/input-wrapper.d.ts +7 -0
  19. package/dist/{link-B3PDtnXT.js → link-0N9wG5l8.js} +1 -1
  20. package/dist/{link-BnL83t0x.cjs → link-I_LKEBVK.cjs} +1 -1
  21. package/dist/link.d.ts +7 -0
  22. package/dist/{linkcard-C4q7HCwY.js → linkcard-BJeRbpq_.js} +1 -1
  23. package/dist/{linkcard-RyOjvpmF.cjs → linkcard-ClXGVwdJ.cjs} +1 -1
  24. package/dist/linkcard.d.ts +7 -0
  25. package/dist/{messagebox-BDfhozc3.js → messagebox-C5M56R8f.js} +1 -1
  26. package/dist/{messagebox-CuM1y2P_.cjs → messagebox-CC3j63Wp.cjs} +1 -1
  27. package/dist/messagebox.d.ts +7 -0
  28. package/dist/{modal-gLMGJSSY.cjs → modal-BkchlKkL.cjs} +1 -1
  29. package/dist/{modal-CYv8Qk0Y.js → modal-PKDnp91S.js} +1 -1
  30. package/dist/modal.d.ts +7 -0
  31. package/dist/pkt-alert.cjs +1 -1
  32. package/dist/pkt-alert.js +1 -1
  33. package/dist/pkt-card.cjs +1 -1
  34. package/dist/pkt-card.js +1 -1
  35. package/dist/pkt-datepicker.cjs +1 -1
  36. package/dist/pkt-datepicker.js +1 -1
  37. package/dist/pkt-helptext.cjs +1 -1
  38. package/dist/pkt-helptext.js +1 -1
  39. package/dist/pkt-index.cjs +1 -1
  40. package/dist/pkt-index.js +14 -14
  41. package/dist/pkt-input-wrapper.cjs +1 -1
  42. package/dist/pkt-input-wrapper.js +1 -1
  43. package/dist/pkt-link.cjs +1 -1
  44. package/dist/pkt-link.js +1 -1
  45. package/dist/pkt-linkcard.cjs +1 -1
  46. package/dist/pkt-linkcard.js +1 -1
  47. package/dist/pkt-messagebox.cjs +1 -1
  48. package/dist/pkt-messagebox.js +1 -1
  49. package/dist/pkt-modal.cjs +1 -1
  50. package/dist/pkt-modal.js +1 -1
  51. package/dist/pkt-select.cjs +1 -1
  52. package/dist/pkt-select.js +1 -1
  53. package/dist/pkt-slot-controller-Clbye6cM.js +85 -0
  54. package/dist/pkt-slot-controller-Oc32unDk.cjs +1 -0
  55. package/dist/pkt-tag.cjs +1 -1
  56. package/dist/pkt-tag.js +1 -1
  57. package/dist/pkt-textarea.cjs +1 -1
  58. package/dist/pkt-textarea.js +1 -1
  59. package/dist/pkt-textinput.cjs +1 -1
  60. package/dist/pkt-textinput.js +1 -1
  61. package/dist/progressbar.d.ts +7 -0
  62. package/dist/radiobutton.d.ts +7 -0
  63. package/dist/select-DFlu7Eq6.cjs +48 -0
  64. package/dist/{select-BJr30hL7.js → select-DVyh7z8C.js} +60 -43
  65. package/dist/select.d.ts +7 -0
  66. package/dist/{tag-nAMwKi6B.cjs → tag-DGywzHJ5.cjs} +1 -1
  67. package/dist/{tag-CPLBzyiV.js → tag-W9Lf1doW.js} +1 -1
  68. package/dist/tag.d.ts +7 -0
  69. package/dist/{textarea-Da-bIu5d.js → textarea-80zuPTTD.js} +35 -33
  70. package/dist/textarea-WWRAA1LV.cjs +49 -0
  71. package/dist/textarea.d.ts +7 -0
  72. package/dist/{textinput-C9pkRR6S.cjs → textinput-CE5AzOur.cjs} +4 -3
  73. package/dist/{textinput-Buj2CAKl.js → textinput-CZIE3v3S.js} +44 -42
  74. package/dist/textinput.d.ts +7 -0
  75. package/package.json +4 -4
  76. package/src/components/datepicker/datepicker.ts +8 -0
  77. package/src/components/helptext/helptext.ts +41 -35
  78. package/src/components/icon/icon.ts +10 -3
  79. package/src/components/input-wrapper/input-wrapper.ts +28 -19
  80. package/src/components/select/select.ts +41 -8
  81. package/src/components/textarea/textarea.ts +9 -1
  82. package/src/components/textinput/textinput.ts +10 -1
  83. package/dist/helptext-CNgXo34f.js +0 -75
  84. package/dist/helptext-XPScYIkx.cjs +0 -23
  85. package/dist/input-wrapper-CWvzXs6X.js +0 -160
  86. package/dist/input-wrapper-nvacN4EY.cjs +0 -48
  87. package/dist/pkt-slot-controller-BEDVscvU.cjs +0 -1
  88. package/dist/pkt-slot-controller-DhwCJd_0.js +0 -67
  89. package/dist/select-B19JEWYw.cjs +0 -44
  90. package/dist/textarea-D7uvC79V.cjs +0 -48
@@ -1,18 +1,19 @@
1
- import { e as c, i as $, a as n, T as l, E as h, x as m, n as p, t as g } from "./element-BKrU5soj.js";
2
- import { r as f } from "./state-C36ZmZgt.js";
3
- import { f as b, m as v, e as x, n as T } from "./ref-D5qG7OFB.js";
1
+ import { e as $, i as g, a as o, T as l, E as h, x as f, n as p, t as x } from "./element-BKrU5soj.js";
2
+ import { r as v } from "./state-C36ZmZgt.js";
3
+ import { f as b, m as T, e as c, n as m } from "./ref-D5qG7OFB.js";
4
4
  import { e as y } from "./class-map-CQzsZCwS.js";
5
5
  import { P as w } from "./input-element-URKBm_vS.js";
6
- import "./input-wrapper-CWvzXs6X.js";
6
+ import { P as C } from "./pkt-slot-controller-Clbye6cM.js";
7
+ import "./input-wrapper-Df18_PvD.js";
7
8
  import "./icon-Bsb0MB2h.js";
8
9
  /**
9
10
  * @license
10
11
  * Copyright 2020 Google LLC
11
12
  * SPDX-License-Identifier: BSD-3-Clause
12
13
  */
13
- const E = c(class extends $ {
14
+ const E = $(class extends g {
14
15
  constructor(t) {
15
- if (super(t), t.type !== n.PROPERTY && t.type !== n.ATTRIBUTE && t.type !== n.BOOLEAN_ATTRIBUTE) throw Error("The `live` directive is not allowed on child or event bindings");
16
+ if (super(t), t.type !== o.PROPERTY && t.type !== o.ATTRIBUTE && t.type !== o.BOOLEAN_ATTRIBUTE) throw Error("The `live` directive is not allowed on child or event bindings");
16
17
  if (!b(t)) throw Error("`live` bindings can only contain a single expression");
17
18
  }
18
19
  render(t) {
@@ -21,22 +22,22 @@ const E = c(class extends $ {
21
22
  update(t, [r]) {
22
23
  if (r === l || r === h) return r;
23
24
  const e = t.element, i = t.name;
24
- if (t.type === n.PROPERTY) {
25
+ if (t.type === o.PROPERTY) {
25
26
  if (r === e[i]) return l;
26
- } else if (t.type === n.BOOLEAN_ATTRIBUTE) {
27
+ } else if (t.type === o.BOOLEAN_ATTRIBUTE) {
27
28
  if (!!r === e.hasAttribute(i)) return l;
28
- } else if (t.type === n.ATTRIBUTE && e.getAttribute(i) === r + "") return l;
29
- return v(t), r;
29
+ } else if (t.type === o.ATTRIBUTE && e.getAttribute(i) === r + "") return l;
30
+ return T(t), r;
30
31
  }
31
32
  });
32
- var C = Object.defineProperty, P = Object.getOwnPropertyDescriptor, o = (t, r, e, i) => {
33
- for (var a = i > 1 ? void 0 : i ? P(r, e) : r, u = t.length - 1, d; u >= 0; u--)
34
- (d = t[u]) && (a = (i ? d(r, e, a) : d(a)) || a);
35
- return i && a && C(r, e, a), a;
33
+ var P = Object.defineProperty, B = Object.getOwnPropertyDescriptor, n = (t, r, e, i) => {
34
+ for (var s = i > 1 ? void 0 : i ? B(r, e) : r, u = t.length - 1, d; u >= 0; u--)
35
+ (d = t[u]) && (s = (i ? d(r, e, s) : d(s)) || s);
36
+ return i && s && P(r, e, s), s;
36
37
  };
37
- let s = class extends w {
38
+ let a = class extends w {
38
39
  constructor() {
39
- super(...arguments), this.value = "", this.autocomplete = "off", this.placeholder = "", this.rows = null, this.counterCurrent = 0, this.inputRef = x();
40
+ super(), this.inputRef = c(), this.helptextSlot = c(), this.value = "", this.autocomplete = "off", this.placeholder = "", this.rows = null, this.counterCurrent = 0, this.slotController = new C(this, this.helptextSlot);
40
41
  }
41
42
  attributeChangedCallback(t, r, e) {
42
43
  t === "value" && this.value !== r && (this.counterCurrent = e ? e.length : 0, this.valueChanged(e, r)), super.attributeChangedCallback(t, r, e);
@@ -51,7 +52,7 @@ let s = class extends w {
51
52
  "pkt-input--fullwidth": this.fullwidth,
52
53
  "pkt-input--counter-error": this.counter && this.counterMaxLength && this.value.length && this.value.length > this.counterMaxLength
53
54
  }), r = this.ariaLabelledby || `${this.id}-input-label`;
54
- return m`<pkt-input-wrapper
55
+ return f`<pkt-input-wrapper
55
56
  label=${this.label}
56
57
  ?counter=${this.counter}
57
58
  ?disabled=${this.disabled}
@@ -73,8 +74,9 @@ let s = class extends w {
73
74
  .requiredText=${this.requiredText}
74
75
  class="pkt-textarea"
75
76
  >
77
+ <div class="pkt-contents" ${m(this.helptextSlot)} name="helptext" slot="helptext"></div>
76
78
  <textarea
77
- ${T(this.inputRef)}
79
+ ${m(this.inputRef)}
78
80
  class=${t}
79
81
  id=${this.id + "-input"}
80
82
  name=${(this.name || this.id) + "-input"}
@@ -105,24 +107,24 @@ let s = class extends w {
105
107
  </pkt-input-wrapper>`;
106
108
  }
107
109
  };
108
- o([
110
+ n([
109
111
  p({ type: String, reflect: !0 })
110
- ], s.prototype, "value", 2);
111
- o([
112
+ ], a.prototype, "value", 2);
113
+ n([
112
114
  p({ type: String })
113
- ], s.prototype, "autocomplete", 2);
114
- o([
115
+ ], a.prototype, "autocomplete", 2);
116
+ n([
115
117
  p({ type: String })
116
- ], s.prototype, "placeholder", 2);
117
- o([
118
+ ], a.prototype, "placeholder", 2);
119
+ n([
118
120
  p({ type: Number })
119
- ], s.prototype, "rows", 2);
120
- o([
121
- f()
122
- ], s.prototype, "counterCurrent", 2);
123
- s = o([
124
- g("pkt-textarea")
125
- ], s);
121
+ ], a.prototype, "rows", 2);
122
+ n([
123
+ v()
124
+ ], a.prototype, "counterCurrent", 2);
125
+ a = n([
126
+ x("pkt-textarea")
127
+ ], a);
126
128
  export {
127
- s as P
129
+ a as P
128
130
  };
@@ -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,6 +1,13 @@
1
1
  export { }
2
2
 
3
3
 
4
+ declare global {
5
+ interface HTMLElementTagNameMap {
6
+ 'pkt-icon': PktIcon;
7
+ }
8
+ }
9
+
10
+
4
11
  declare global {
5
12
  interface Window {
6
13
  pktTz: string;
@@ -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
@@ -1,6 +1,13 @@
1
1
  export { }
2
2
 
3
3
 
4
+ declare global {
5
+ interface HTMLElementTagNameMap {
6
+ 'pkt-icon': PktIcon;
7
+ }
8
+ }
9
+
10
+
4
11
  declare global {
5
12
  interface Window {
6
13
  pktTz: string;
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.1",
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",
@@ -29,8 +29,8 @@
29
29
  "urlpattern-polyfill": "^10.0.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@oslokommune/punkt-assets": "^12.23.0",
33
- "@oslokommune/punkt-css": "^12.26.0",
32
+ "@oslokommune/punkt-assets": "^12.27.1",
33
+ "@oslokommune/punkt-css": "^12.27.1",
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": "0b2f47770a00b04fc9f29d1e4fcb5e87800c8e54"
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,4 +1,5 @@
1
1
  import { PktElement } from '@/base-elements/element'
2
+ import { PktIconName } from '@oslokommune/punkt-assets/dist/icons/icon'
2
3
  import { html, PropertyValues } from 'lit'
3
4
  import { customElement, property } from 'lit/decorators.js'
4
5
  import { unsafeSVG } from 'lit/directives/unsafe-svg.js'
@@ -12,7 +13,7 @@ const errorSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"></
12
13
  const dlStatus: { [key: string]: string } = {}
13
14
 
14
15
  const downloadIconOrGetFromCache = async (
15
- name: string,
16
+ name: PktIconName,
16
17
  path: string | undefined,
17
18
  ): Promise<string | null> => {
18
19
  let i = 0
@@ -55,7 +56,7 @@ export class PktIcon extends PktElement {
55
56
  path: string | undefined = window.pktIconPath
56
57
 
57
58
  @property({ type: String, reflect: true })
58
- name: string = ''
59
+ name: PktIconName = ''
59
60
 
60
61
  @property({ type: SVGElement })
61
62
  private icon: any = unsafeSVG(errorSvg)
@@ -79,7 +80,7 @@ export class PktIcon extends PktElement {
79
80
  }
80
81
  }
81
82
 
82
- protected async getIcon(name = '') {
83
+ protected async getIcon(name: PktIconName = '') {
83
84
  if (this._updatedProps.length > 0) {
84
85
  if (!this.path) this.path === window.pktIconPath
85
86
  this.icon = unsafeSVG(
@@ -97,3 +98,9 @@ export class PktIcon extends PktElement {
97
98
  return html`${this.name && this.icon}`
98
99
  }
99
100
  }
101
+
102
+ declare global {
103
+ interface HTMLElementTagNameMap {
104
+ 'pkt-icon': PktIcon
105
+ }
106
+ }