@oslokommune/punkt-elements 12.17.2 → 12.18.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 (128) hide show
  1. package/dist/alert-BbVWu2lm.cjs +27 -0
  2. package/dist/alert-Dh6A96vo.js +159 -0
  3. package/dist/{index-D2jSRMrn.js → calendar-BUqcNvfI.js} +41 -29
  4. package/dist/calendar-QSulz7im.cjs +108 -0
  5. package/dist/card-B0GPdG5M.cjs +23 -0
  6. package/dist/card-kWt0BA2a.js +170 -0
  7. package/dist/{class-map-a5HUzP83.cjs → class-map-Boa7BqCc.cjs} +2 -2
  8. package/dist/{class-map-CBvUV2N3.js → class-map-hz16xq5a.js} +9 -10
  9. package/dist/datepicker-BHepKxof.cjs +154 -0
  10. package/dist/datepicker-iNCYioZ9.js +659 -0
  11. package/dist/helptext--4FLdAWi.js +194 -0
  12. package/dist/helptext-iZEgxz2U.cjs +23 -0
  13. package/dist/icon-CdMQ6zBT.cjs +250 -0
  14. package/dist/{index-CFDwiDTU.js → icon-wUXeHiBk.js} +7371 -7559
  15. package/dist/if-defined-DEDlGbAc.cjs +5 -0
  16. package/dist/if-defined-ZFE4ti2t.js +10 -0
  17. package/dist/index.d.ts +96 -51
  18. package/dist/input-element-D1Vls6A5.js +184 -0
  19. package/dist/input-element-DPKoFVwJ.cjs +1 -0
  20. package/dist/{input-wrapper-6vTrKtsW.js → input-wrapper-BTQk3W8T.js} +10 -10
  21. package/dist/input-wrapper-D-PNRJB_.cjs +46 -0
  22. package/dist/link-BpqavGSD.cjs +8 -0
  23. package/dist/link-Bx9nVgZi.js +108 -0
  24. package/dist/{linkcard-BlWQ8jOv.js → linkcard-CUrbzjLK.js} +16 -17
  25. package/dist/linkcard-DSu3A4Yx.cjs +13 -0
  26. package/dist/messagebox-C1aWoQbu.cjs +12 -0
  27. package/dist/messagebox-LpiVQIoM.js +107 -0
  28. package/dist/{modal-DYTVJjYh.cjs → modal-Avai5eVz.cjs} +2 -2
  29. package/dist/{modal-3OZTPqee.js → modal-Co1YFmHi.js} +8 -8
  30. package/dist/pkt-alert.cjs +1 -27
  31. package/dist/pkt-alert.js +4 -157
  32. package/dist/pkt-calendar.cjs +1 -1
  33. package/dist/pkt-calendar.js +4 -7
  34. package/dist/pkt-card.cjs +1 -23
  35. package/dist/pkt-card.js +4 -168
  36. package/dist/pkt-datepicker.cjs +1 -154
  37. package/dist/pkt-datepicker.js +4 -657
  38. package/dist/pkt-helptext.cjs +1 -1
  39. package/dist/pkt-helptext.js +1 -1
  40. package/dist/pkt-icon.cjs +1 -1
  41. package/dist/pkt-icon.js +4 -4
  42. package/dist/pkt-index.cjs +29 -1
  43. package/dist/pkt-index.js +127 -30
  44. package/dist/pkt-input-wrapper.cjs +1 -1
  45. package/dist/pkt-input-wrapper.js +1 -1
  46. package/dist/pkt-link.cjs +1 -8
  47. package/dist/pkt-link.js +4 -107
  48. package/dist/pkt-linkcard.cjs +1 -1
  49. package/dist/pkt-linkcard.js +1 -1
  50. package/dist/pkt-messagebox.cjs +1 -12
  51. package/dist/pkt-messagebox.js +4 -105
  52. package/dist/pkt-modal.cjs +1 -1
  53. package/dist/pkt-modal.js +1 -1
  54. package/dist/pkt-progressbar.cjs +1 -0
  55. package/dist/pkt-progressbar.js +6 -0
  56. package/dist/pkt-slot-controller-Ckk_yV0j.cjs +1 -0
  57. package/dist/pkt-slot-controller-RJvOnbF4.js +61 -0
  58. package/dist/pkt-tag.cjs +1 -17
  59. package/dist/pkt-tag.js +4 -148
  60. package/dist/pkt-textarea.cjs +1 -1
  61. package/dist/pkt-textarea.js +1 -1
  62. package/dist/pkt-textinput.cjs +1 -1
  63. package/dist/pkt-textinput.js +1 -1
  64. package/dist/progressbar-BS_oawSB.js +150 -0
  65. package/dist/progressbar-CuXkbAhJ.cjs +32 -0
  66. package/dist/ref-DCOsLZQg.cjs +13 -0
  67. package/dist/ref-DuFGTLVX.js +142 -0
  68. package/dist/state-BfyXV7EL.js +12 -0
  69. package/dist/state-SKYD8kRO.cjs +5 -0
  70. package/dist/stringutils-CkVRq4jP.cjs +1 -0
  71. package/dist/stringutils-DJjRa8dG.js +7 -0
  72. package/dist/tag-CGy2mSLE.cjs +17 -0
  73. package/dist/tag-DGFgUF3l.js +150 -0
  74. package/dist/{textarea-BTpJjEhO.js → textarea-BAGWR1Hi.js} +29 -29
  75. package/dist/textarea-BiUrhAlk.cjs +48 -0
  76. package/dist/{textinput-BIhQEr8z.cjs → textinput-CHOR5PPp.cjs} +2 -2
  77. package/dist/{textinput-CVo5wG14.js → textinput-pJ3N8m6g.js} +23 -23
  78. package/package.json +2 -2
  79. package/src/components/alert/alert.ts +115 -0
  80. package/src/components/alert/index.ts +4 -113
  81. package/src/components/calendar/calendar.ts +711 -0
  82. package/src/components/calendar/index.ts +3 -711
  83. package/src/components/card/card.ts +78 -0
  84. package/src/components/card/index.ts +4 -77
  85. package/src/components/datepicker/datepicker.ts +619 -0
  86. package/src/components/datepicker/index.ts +3 -618
  87. package/src/components/helptext/helptext.ts +2 -2
  88. package/src/components/icon/icon.ts +99 -0
  89. package/src/components/icon/index.ts +3 -98
  90. package/src/components/index.ts +29 -15
  91. package/src/components/input-wrapper/input-wrapper.ts +2 -2
  92. package/src/components/link/index.ts +3 -56
  93. package/src/components/link/link.ts +57 -0
  94. package/src/components/linkcard/index.ts +1 -1
  95. package/src/components/linkcard/linkcard.ts +5 -6
  96. package/src/components/messagebox/index.ts +4 -69
  97. package/src/components/messagebox/messagebox.ts +69 -0
  98. package/src/components/modal/index.ts +0 -1
  99. package/src/components/modal/modal.ts +5 -7
  100. package/src/components/progressbar/index.ts +12 -0
  101. package/src/components/progressbar/progressbar.ts +144 -0
  102. package/src/components/tag/index.ts +4 -109
  103. package/src/components/tag/tag.ts +118 -0
  104. package/src/components/textarea/textarea.ts +5 -4
  105. package/src/components/textinput/textinput.ts +3 -3
  106. package/dist/converters-DNCwIFwr.js +0 -17
  107. package/dist/converters-DhM11VlY.cjs +0 -1
  108. package/dist/custom-element-B-TlBwRu.cjs +0 -9
  109. package/dist/custom-element-CWfU4dcr.js +0 -38
  110. package/dist/element.d.ts +0 -8
  111. package/dist/helptext-DBolvFI4.js +0 -72
  112. package/dist/helptext-_fMLOOCL.cjs +0 -23
  113. package/dist/index-CR7t1zY9.cjs +0 -238
  114. package/dist/index-CmTjXoAb.cjs +0 -9
  115. package/dist/index-RwtTBIhT.js +0 -88
  116. package/dist/index-tvpcg-ad.cjs +0 -108
  117. package/dist/input-wrapper-DX41tnbj.cjs +0 -46
  118. package/dist/linkcard-Det6CJ5D.cjs +0 -13
  119. package/dist/pkt-component-template.cjs +0 -29
  120. package/dist/pkt-component-template.js +0 -99
  121. package/dist/pkt-element.cjs +0 -1
  122. package/dist/pkt-element.js +0 -5
  123. package/dist/ref-C2yPtMJA.cjs +0 -13
  124. package/dist/ref-CaiKp3S2.js +0 -202
  125. package/dist/textarea-B45ZZYpx.cjs +0 -48
  126. package/src/components/component-template/index.ts +0 -129
  127. package/src/components/element/index.ts +0 -353
  128. /package/dist/{component-template.d.ts → progressbar.d.ts} +0 -0
@@ -0,0 +1,150 @@
1
+ import { e as h } from "./class-map-hz16xq5a.js";
2
+ import { P as d, x as p, n as l, t as y } from "./icon-wUXeHiBk.js";
3
+ import { r as m } from "./state-BfyXV7EL.js";
4
+ import { P as g } from "./pkt-slot-controller-RJvOnbF4.js";
5
+ import { e as k, n as f } from "./ref-DuFGTLVX.js";
6
+ const b = "pkt-tag", S = !0, $ = {
7
+ closeTag: {
8
+ type: "boolean",
9
+ required: !1,
10
+ default: !1
11
+ },
12
+ size: {
13
+ required: !1,
14
+ default: "medium",
15
+ type: [
16
+ "small",
17
+ "medium",
18
+ "large"
19
+ ]
20
+ },
21
+ iconName: {
22
+ type: "icon",
23
+ required: !1
24
+ },
25
+ skin: {
26
+ required: !1,
27
+ default: "blue",
28
+ type: [
29
+ "blue",
30
+ "green",
31
+ "red",
32
+ "beige",
33
+ "yellow",
34
+ "gray",
35
+ "blue-light"
36
+ ]
37
+ },
38
+ textStyle: {
39
+ required: !1,
40
+ default: "normal-text",
41
+ type: [
42
+ "thin-text",
43
+ "normal-text"
44
+ ]
45
+ },
46
+ type: {
47
+ required: !1,
48
+ default: "button",
49
+ type: [
50
+ "button",
51
+ "submit",
52
+ "reset"
53
+ ]
54
+ },
55
+ ariaLabel: {
56
+ type: "string",
57
+ required: !1,
58
+ default: "Lukk"
59
+ }
60
+ }, _ = {
61
+ default: {
62
+ description: "Teksten til tag"
63
+ }
64
+ }, a = {
65
+ name: b,
66
+ "css-class": "pkt-tag",
67
+ isElement: S,
68
+ props: $,
69
+ slots: _
70
+ };
71
+ var x = Object.defineProperty, C = Object.getOwnPropertyDescriptor, e = (s, o, n, r) => {
72
+ for (var i = r > 1 ? void 0 : r ? C(o, n) : o, c = s.length - 1, u; c >= 0; c--)
73
+ (u = s[c]) && (i = (r ? u(o, n, i) : u(i)) || i);
74
+ return r && i && x(o, n, i), i;
75
+ };
76
+ let t = class extends d {
77
+ constructor() {
78
+ super(), this.defaultSlot = k(), this.closeTag = a.props.closeTag.default, this.size = a.props.size.default, this.skin = a.props.skin.default, this.textStyle = a.props.textStyle.default, this.iconName = void 0, this.type = a.props.type.default, this.ariaLabel = a.props.ariaLabel.default, this._isClosed = !1, this.close = (s) => {
79
+ this._isClosed = !0, this.dispatchEvent(
80
+ new CustomEvent("close", { detail: { origin: s }, bubbles: !0, composed: !0 })
81
+ ), this.dispatchEvent(
82
+ new CustomEvent("on-close", { detail: { origin: s }, bubbles: !0, composed: !0 })
83
+ );
84
+ }, this.slotController = new g(this, this.defaultSlot), this._isClosed = !1;
85
+ }
86
+ render() {
87
+ const s = {
88
+ "pkt-tag": !0,
89
+ [`pkt-tag--${this.size}`]: !!this.size,
90
+ [`pkt-tag--${this.skin}`]: !!this.skin,
91
+ [`pkt-tag--${this.textStyle}`]: !!this.textStyle
92
+ }, o = {
93
+ "pkt-tag": !0,
94
+ "pkt-btn": !0,
95
+ "pkt-btn--tertiary": !0,
96
+ [`pkt-tag--${this.size}`]: !!this.size,
97
+ [`pkt-tag--${this.skin}`]: !!this.skin,
98
+ [`pkt-tag--${this.textStyle}`]: !!this.textStyle,
99
+ "pkt-btn--icons-right-and-left": this.closeTag && !!this.iconName,
100
+ "pkt-hide": this._isClosed
101
+ };
102
+ return this.closeTag ? p`
103
+ <button
104
+ class=${h(o)}
105
+ type=${this.type}
106
+ aria-label=${this.ariaLabel}
107
+ @click=${this.close}
108
+ >
109
+ ${this.iconName && p`<pkt-icon class="pkt-tag__icon" name=${this.iconName}></pkt-icon>`}
110
+ <span ${f(this.defaultSlot)}></span>
111
+ <pkt-icon class="pkt-tag__close-btn" name="close"></pkt-icon>
112
+ </button>
113
+ ` : p`
114
+ <span class=${h(s)}>
115
+ ${this.iconName && p` <pkt-icon class="pkt-tag__icon" name=${this.iconName}></pkt-icon> `}
116
+ <span ${f(this.defaultSlot)}></span>
117
+ </span>
118
+ `;
119
+ }
120
+ };
121
+ e([
122
+ l({ type: Boolean, reflect: !0 })
123
+ ], t.prototype, "closeTag", 2);
124
+ e([
125
+ l({ type: String, reflect: !0 })
126
+ ], t.prototype, "size", 2);
127
+ e([
128
+ l({ type: String, reflect: !0 })
129
+ ], t.prototype, "skin", 2);
130
+ e([
131
+ l({ type: String, reflect: !0 })
132
+ ], t.prototype, "textStyle", 2);
133
+ e([
134
+ l({ type: String, reflect: !0 })
135
+ ], t.prototype, "iconName", 2);
136
+ e([
137
+ l({ type: String, reflect: !0 })
138
+ ], t.prototype, "type", 2);
139
+ e([
140
+ l({ type: String, reflect: !0 })
141
+ ], t.prototype, "ariaLabel", 2);
142
+ e([
143
+ m()
144
+ ], t.prototype, "_isClosed", 2);
145
+ t = e([
146
+ y("pkt-tag")
147
+ ], t);
148
+ export {
149
+ t as P
150
+ };
@@ -1,18 +1,18 @@
1
- import { T as l, E as h, r as c, a as $, x as g, n as p } from "./index-CFDwiDTU.js";
2
- import { e as m, i as f, a as n, t as b } from "./custom-element-CWfU4dcr.js";
3
- import { f as v, m as x, e as T, n as y } from "./ref-CaiKp3S2.js";
4
- import { e as w } from "./class-map-CBvUV2N3.js";
5
- import "./input-wrapper-6vTrKtsW.js";
6
- import "./index-RwtTBIhT.js";
1
+ import { e as c, i as $, b as n, T as l, E as h, x as m, n as p, t as g } from "./icon-wUXeHiBk.js";
2
+ import { r as f } from "./state-BfyXV7EL.js";
3
+ import { f as b, m as v, e as x, n as T } from "./ref-DuFGTLVX.js";
4
+ import { e as y } from "./class-map-hz16xq5a.js";
5
+ import { P as w } from "./input-element-D1Vls6A5.js";
6
+ import "./input-wrapper-BTQk3W8T.js";
7
7
  /**
8
8
  * @license
9
9
  * Copyright 2020 Google LLC
10
10
  * SPDX-License-Identifier: BSD-3-Clause
11
11
  */
12
- const E = m(class extends f {
12
+ const E = c(class extends $ {
13
13
  constructor(t) {
14
14
  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");
15
- if (!v(t)) throw Error("`live` bindings can only contain a single expression");
15
+ if (!b(t)) throw Error("`live` bindings can only contain a single expression");
16
16
  }
17
17
  render(t) {
18
18
  return t;
@@ -25,17 +25,17 @@ const E = m(class extends f {
25
25
  } else if (t.type === n.BOOLEAN_ATTRIBUTE) {
26
26
  if (!!r === e.hasAttribute(i)) return l;
27
27
  } else if (t.type === n.ATTRIBUTE && e.getAttribute(i) === r + "") return l;
28
- return x(t), r;
28
+ return v(t), r;
29
29
  }
30
30
  });
31
- var C = Object.defineProperty, B = Object.getOwnPropertyDescriptor, o = (t, r, e, i) => {
32
- for (var a = i > 1 ? void 0 : i ? B(r, e) : r, u = t.length - 1, d; u >= 0; u--)
33
- (d = t[u]) && (a = (i ? d(r, e, a) : d(a)) || a);
34
- return i && a && C(r, e, a), a;
31
+ var C = Object.defineProperty, P = Object.getOwnPropertyDescriptor, o = (t, r, e, i) => {
32
+ for (var s = i > 1 ? void 0 : i ? P(r, e) : r, u = t.length - 1, d; u >= 0; u--)
33
+ (d = t[u]) && (s = (i ? d(r, e, s) : d(s)) || s);
34
+ return i && s && C(r, e, s), s;
35
35
  };
36
- let s = class extends $ {
36
+ let a = class extends w {
37
37
  constructor() {
38
- super(...arguments), this.value = "", this.autocomplete = "off", this.placeholder = "", this.rows = null, this.counterCurrent = 0, this.inputRef = T();
38
+ super(...arguments), this.value = "", this.autocomplete = "off", this.placeholder = "", this.rows = null, this.counterCurrent = 0, this.inputRef = x();
39
39
  }
40
40
  attributeChangedCallback(t, r, e) {
41
41
  t === "value" && this.value !== r && (this.counterCurrent = e ? e.length : 0, this.valueChanged(e, r)), super.attributeChangedCallback(t, r, e);
@@ -45,13 +45,13 @@ let s = class extends $ {
45
45
  super.updated(t), t.has("value") && (this.counterCurrent = ((r = this.value) == null ? void 0 : r.length) || 0, this.valueChanged(this.value, t.get("value"))), t.has("id") && !this.name && this.id && (this.name = this.id);
46
46
  }
47
47
  render() {
48
- const t = w({
48
+ const t = y({
49
49
  "pkt-input": !0,
50
50
  "pkt-input--fullwidth": this.fullwidth,
51
51
  "pkt-input--counter-error": this.counter && this.counterMaxLength && this.value.length && this.value.length > this.counterMaxLength
52
52
  }), r = this.ariaLabelledby || `${this.id}-input-label`;
53
- return g`<pkt-input-wrapper
54
- label="${this.label}"
53
+ return m`<pkt-input-wrapper
54
+ label=${this.label}
55
55
  ?counter=${this.counter}
56
56
  ?disabled=${this.disabled}
57
57
  ?hasError=${this.hasError}
@@ -73,7 +73,7 @@ let s = class extends $ {
73
73
  class="pkt-textarea"
74
74
  >
75
75
  <textarea
76
- ${y(this.inputRef)}
76
+ ${T(this.inputRef)}
77
77
  class=${t}
78
78
  id=${this.id + "-input"}
79
79
  name=${(this.name || this.id) + "-input"}
@@ -106,22 +106,22 @@ let s = class extends $ {
106
106
  };
107
107
  o([
108
108
  p({ type: String, reflect: !0 })
109
- ], s.prototype, "value", 2);
109
+ ], a.prototype, "value", 2);
110
110
  o([
111
111
  p({ type: String })
112
- ], s.prototype, "autocomplete", 2);
112
+ ], a.prototype, "autocomplete", 2);
113
113
  o([
114
114
  p({ type: String })
115
- ], s.prototype, "placeholder", 2);
115
+ ], a.prototype, "placeholder", 2);
116
116
  o([
117
117
  p({ type: Number })
118
- ], s.prototype, "rows", 2);
118
+ ], a.prototype, "rows", 2);
119
119
  o([
120
- c()
121
- ], s.prototype, "counterCurrent", 2);
122
- s = o([
123
- b("pkt-textarea")
124
- ], s);
120
+ f()
121
+ ], a.prototype, "counterCurrent", 2);
122
+ a = o([
123
+ g("pkt-textarea")
124
+ ], a);
125
125
  export {
126
- s as P
126
+ a as P
127
127
  };
@@ -0,0 +1,48 @@
1
+ "use strict";const r=require("./icon-CdMQ6zBT.cjs"),h=require("./state-SKYD8kRO.cjs"),o=require("./ref-DCOsLZQg.cjs"),p=require("./class-map-Boa7BqCc.cjs"),d=require("./input-element-DPKoFVwJ.cjs");require("./input-wrapper-D-PNRJB_.cjs");/**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */const c=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(!o.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 a=i.element,t=i.name;if(i.type===r.t$1.PROPERTY){if(e===a[t])return r.T}else if(i.type===r.t$1.BOOLEAN_ATTRIBUTE){if(!!e===a.hasAttribute(t))return r.T}else if(i.type===r.t$1.ATTRIBUTE&&a.getAttribute(t)===e+"")return r.T;return o.m(i),e}});var $=Object.defineProperty,g=Object.getOwnPropertyDescriptor,n=(i,e,a,t)=>{for(var s=t>1?void 0:t?g(e,a):e,u=i.length-1,l;u>=0;u--)(l=i[u])&&(s=(t?l(e,a,s):l(s))||s);return t&&s&&$(e,a,s),s};exports.PktTextarea=class extends d.PktInputElement{constructor(){super(...arguments),this.value="",this.autocomplete="off",this.placeholder="",this.rows=null,this.counterCurrent=0,this.inputRef=o.e()}attributeChangedCallback(e,a,t){e==="value"&&this.value!==a&&(this.counterCurrent=t?t.length:0,this.valueChanged(t,a)),super.attributeChangedCallback(e,a,t)}updated(e){var a;super.updated(e),e.has("value")&&(this.counterCurrent=((a=this.value)==null?void 0:a.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}),a=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
+ <textarea
28
+ ${o.n(this.inputRef)}
29
+ class=${e}
30
+ id=${this.id+"-input"}
31
+ name=${(this.name||this.id)+"-input"}
32
+ placeholder=${this.placeholder??r.E}
33
+ .value=${c(this.value)}
34
+ minlength=${this.minlength||r.E}
35
+ maxlength=${this.maxlength||r.E}
36
+ ?readonly=${this.readonly}
37
+ autocomplete=${this.autocomplete}
38
+ aria-labelledby=${a}
39
+ aria-invalid=${this.hasError}
40
+ aria-errormessage=${`${this.id}-error`}
41
+ rows=${this.rows}
42
+ ?disabled=${this.disabled}
43
+ @input=${t=>{this.value=t.target.value,this.onInput(),t.stopImmediatePropagation()}}
44
+ @change=${t=>{t.stopImmediatePropagation()}}
45
+ @focus=${t=>{this.onFocus(),t.stopImmediatePropagation()}}
46
+ @blur=${t=>{this.value=t.target.value,this.onBlur(),t.stopImmediatePropagation()}}
47
+ ></textarea>
48
+ </pkt-input-wrapper>`}};n([r.n({type:String,reflect:!0})],exports.PktTextarea.prototype,"value",2);n([r.n({type:String})],exports.PktTextarea.prototype,"autocomplete",2);n([r.n({type:String})],exports.PktTextarea.prototype,"placeholder",2);n([r.n({type:Number})],exports.PktTextarea.prototype,"rows",2);n([h.r()],exports.PktTextarea.prototype,"counterCurrent",2);exports.PktTextarea=n([r.t("pkt-textarea")],exports.PktTextarea);
@@ -1,4 +1,4 @@
1
- "use strict";const t=require("./index-CR7t1zY9.cjs"),h=require("./custom-element-B-TlBwRu.cjs"),o=require("./ref-C2yPtMJA.cjs"),l=require("./class-map-a5HUzP83.cjs");require("./input-wrapper-DX41tnbj.cjs");require("./index-CmTjXoAb.cjs");var c=Object.defineProperty,d=Object.getOwnPropertyDescriptor,r=(p,i,n,s)=>{for(var e=s>1?void 0:s?d(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&&c(i,n,e),e};exports.PktTextinput=class extends t.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("./icon-CdMQ6zBT.cjs"),h=require("./state-SKYD8kRO.cjs"),o=require("./ref-DCOsLZQg.cjs"),l=require("./class-map-Boa7BqCc.cjs"),c=require("./input-element-DPKoFVwJ.cjs");require("./input-wrapper-D-PNRJB_.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`
2
2
  <pkt-input-wrapper
3
3
  label="${this.label}"
4
4
  ?counter=${this.counter}
@@ -60,4 +60,4 @@
60
60
  ${!this.suffix&&i?t.x`<pkt-icon class="pkt-input-icon" name="magnifying-glass-big"></pkt-icon>`:t.E}
61
61
  </div>
62
62
  </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([t.r()],exports.PktTextinput.prototype,"counterCurrent",2);exports.PktTextinput=r([h.t("pkt-textinput")],exports.PktTextinput);
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);
@@ -1,17 +1,17 @@
1
- import { r as c, a as d, x as h, E as n, n as p } from "./index-CFDwiDTU.js";
2
- import { t as $ } from "./custom-element-CWfU4dcr.js";
3
- import { e as g, n as m } from "./ref-CaiKp3S2.js";
4
- import { e as f } from "./class-map-CBvUV2N3.js";
5
- import "./input-wrapper-6vTrKtsW.js";
6
- import "./index-RwtTBIhT.js";
1
+ import { x as h, E as n, n as o, t as c } from "./icon-wUXeHiBk.js";
2
+ import { r as d } from "./state-BfyXV7EL.js";
3
+ import { e as $, n as g } from "./ref-DuFGTLVX.js";
4
+ import { e as m } from "./class-map-hz16xq5a.js";
5
+ import { P as f } from "./input-element-D1Vls6A5.js";
6
+ import "./input-wrapper-BTQk3W8T.js";
7
7
  var x = Object.defineProperty, y = Object.getOwnPropertyDescriptor, a = (i, e, r, t) => {
8
- for (var o = t > 1 ? void 0 : t ? y(e, r) : e, u = i.length - 1, l; u >= 0; u--)
9
- (l = i[u]) && (o = (t ? l(e, r, o) : l(o)) || o);
10
- return t && o && x(e, r, o), o;
8
+ for (var p = t > 1 ? void 0 : t ? y(e, r) : e, u = i.length - 1, l; u >= 0; u--)
9
+ (l = i[u]) && (p = (t ? l(e, r, p) : l(p)) || p);
10
+ return t && p && x(e, r, p), p;
11
11
  };
12
- let s = class extends d {
12
+ let s = class extends f {
13
13
  constructor() {
14
- 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 = g();
14
+ 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 = $();
15
15
  }
16
16
  attributeChangedCallback(i, e, r) {
17
17
  i === "value" && this.value !== e && (this.counterCurrent = r ? r.length : 0, this.valueChanged(r, e)), super.attributeChangedCallback(i, e, r);
@@ -21,7 +21,7 @@ let s = class extends d {
21
21
  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);
22
22
  }
23
23
  render() {
24
- const i = this.type === "search" && !this.iconNameRight && !this.omitSearchIcon, e = f({
24
+ const i = this.type === "search" && !this.iconNameRight && !this.omitSearchIcon, e = m({
25
25
  "pkt-input": !0,
26
26
  "pkt-input--fullwidth": this.fullwidth,
27
27
  "pkt-input--counter-error": this.counter && this.counterMaxLength && this.value.length && this.value.length > this.counterMaxLength
@@ -52,7 +52,7 @@ let s = class extends d {
52
52
  <div class="pkt-input__container">
53
53
  ${this.prefix ? h`<div class="pkt-input-prefix">${this.prefix}</div>` : n}
54
54
  <input
55
- ${m(this.inputRef)}
55
+ ${g(this.inputRef)}
56
56
  class=${e}
57
57
  type=${this.type}
58
58
  name=${(this.name || this.id) + "-input"}
@@ -100,34 +100,34 @@ let s = class extends d {
100
100
  }
101
101
  };
102
102
  a([
103
- p({ type: String, reflect: !0 })
103
+ o({ type: String, reflect: !0 })
104
104
  ], s.prototype, "value", 2);
105
105
  a([
106
- p({ type: String })
106
+ o({ type: String })
107
107
  ], s.prototype, "type", 2);
108
108
  a([
109
- p({ type: Number })
109
+ o({ type: Number })
110
110
  ], s.prototype, "size", 2);
111
111
  a([
112
- p({ type: String })
112
+ o({ type: String })
113
113
  ], s.prototype, "autocomplete", 2);
114
114
  a([
115
- p({ type: String })
115
+ o({ type: String })
116
116
  ], s.prototype, "iconNameRight", 2);
117
117
  a([
118
- p({ type: String })
118
+ o({ type: String })
119
119
  ], s.prototype, "prefix", 2);
120
120
  a([
121
- p({ type: String })
121
+ o({ type: String })
122
122
  ], s.prototype, "suffix", 2);
123
123
  a([
124
- p({ type: Boolean })
124
+ o({ type: Boolean })
125
125
  ], s.prototype, "omitSearchIcon", 2);
126
126
  a([
127
- c()
127
+ d()
128
128
  ], s.prototype, "counterCurrent", 2);
129
129
  s = a([
130
- $("pkt-textinput")
130
+ c("pkt-textinput")
131
131
  ], s);
132
132
  export {
133
133
  s as P
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-elements",
3
- "version": "12.17.2",
3
+ "version": "12.18.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",
@@ -57,5 +57,5 @@
57
57
  "url": "https://github.com/oslokommune/punkt/issues"
58
58
  },
59
59
  "license": "MIT",
60
- "gitHead": "998cf96281840a47cba5ba3e0c76e6fa1d2ed10e"
60
+ "gitHead": "6ae85b68cc5757ecef1c2a851cc4450e5e27f3db"
61
61
  }
@@ -0,0 +1,115 @@
1
+ import { classMap } from 'lit/directives/class-map.js'
2
+ import { customElement, property, state } from 'lit/decorators.js'
3
+ import { html, nothing, PropertyValues } from 'lit'
4
+ import { PktElement } from '@/base-elements/element'
5
+ import { PktSlotController } from '@/controllers/pkt-slot-controller'
6
+ import { ref, createRef, Ref } from 'lit/directives/ref.js'
7
+ import { TAriaLive } from '@/types/aria'
8
+
9
+ import specs from 'componentSpecs/alert.json'
10
+
11
+ import '@/components/icon'
12
+
13
+ export type TAlertSkin = 'error' | 'success' | 'warning' | 'info'
14
+
15
+ export interface IPktAlert {
16
+ skin?: TAlertSkin
17
+ closeAlert?: boolean
18
+ title?: string
19
+ date?: string
20
+ ariaLive?: TAriaLive
21
+ 'aria-live'?: TAriaLive
22
+ compact?: boolean
23
+ }
24
+ @customElement('pkt-alert')
25
+ export class PktAlert extends PktElement {
26
+ defaultSlot: Ref<HTMLElement> = createRef()
27
+
28
+ constructor() {
29
+ super()
30
+ this.slotController = new PktSlotController(this, this.defaultSlot)
31
+ this._isClosed = false
32
+ }
33
+
34
+ @property({ type: Boolean, reflect: false }) compact = specs.props.compact.default
35
+ @property({ type: String, reflect: true }) title: string = ''
36
+ @property({ type: String, reflect: true }) skin: TAlertSkin = specs.props.skin
37
+ .default as TAlertSkin
38
+ @property({ type: String }) ariaLive: TAriaLive = specs.props.ariaLive.default as TAriaLive
39
+ @property({ type: String, reflect: true }) 'aria-live': TAriaLive = null
40
+ @property({ type: Boolean, reflect: true }) closeAlert = specs.props.closeAlert.default
41
+ @property({ type: String, reflect: true }) date: string | null = null
42
+
43
+ @state() _isClosed: boolean = false
44
+
45
+ private close = (event: MouseEvent) => {
46
+ this._isClosed = true
47
+ this.dispatchEvent(
48
+ new CustomEvent('close', { detail: { origin: event }, bubbles: true, composed: true }),
49
+ )
50
+ // Historical support of old Vue implementations…
51
+ this.dispatchEvent(
52
+ new CustomEvent('on-close', { detail: { origin: event }, bubbles: true, composed: true }),
53
+ )
54
+ }
55
+
56
+ connectedCallback(): void {
57
+ super.connectedCallback()
58
+ this['aria-live'] = (this.getAttribute('aria-live') as TAriaLive) || this.ariaLive
59
+ }
60
+
61
+ attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
62
+ if (name === 'ariaLive') {
63
+ this['aria-live'] = value as TAriaLive
64
+ }
65
+ super.attributeChangedCallback(name, _old, value)
66
+ }
67
+
68
+ protected updated(_changedProperties: PropertyValues): void {
69
+ super.updated(_changedProperties)
70
+ if (_changedProperties.has('ariaLive')) {
71
+ this['aria-live'] = this.ariaLive
72
+ }
73
+ }
74
+
75
+ render() {
76
+ const classes = {
77
+ 'pkt-alert': true,
78
+ 'pkt-alert--compact': this.compact,
79
+ [`pkt-alert--${this.skin}`]: this.skin,
80
+ 'pkt-hide': this._isClosed,
81
+ }
82
+
83
+ return html`
84
+ <div class=${classMap(classes)}>
85
+ <pkt-icon
86
+ class="pkt-alert__icon"
87
+ name=${this.skin === 'info' ? 'alert-information' : `alert-${this.skin}`}
88
+ ></pkt-icon>
89
+
90
+ ${this.closeAlert
91
+ ? html`
92
+ <div class="pkt-alert__close">
93
+ <button
94
+ type="button"
95
+ class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
96
+ tabindex="0"
97
+ aria-label="close"
98
+ @click=${this.close}
99
+ >
100
+ <pkt-icon name="close" class="pkt-btn__icon" aria-hidden="true"></pkt-icon>
101
+ </button>
102
+ </div>
103
+ `
104
+ : nothing}
105
+ ${this.title ? html`<div class="pkt-alert__title">${this.title}</div>` : nothing}
106
+
107
+ <div class="pkt-alert__text" ${ref(this.defaultSlot)}></div>
108
+
109
+ ${this.date
110
+ ? html`<div class="pkt-alert__date">Sist oppdatert: ${this.date}</div>`
111
+ : nothing}
112
+ </div>
113
+ `
114
+ }
115
+ }