nve-designsystem 0.1.61 → 0.1.63

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.
@@ -64,6 +64,13 @@ export default class NveTextarea extends LitElement {
64
64
  * tastaturet på støttede enheter.
65
65
  */
66
66
  inputmode?: 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';
67
+ /** Antall rader med tekst i textarea-taggen.
68
+ * Browser-default dersom denne ikke er satt er 2 i alle browsere
69
+ *
70
+ * Bestemmer initiell høyde på textarea-boksen
71
+ * (settes slik at antall rader * font-høyde får plass)
72
+ */
73
+ rows?: number;
67
74
  /** Bestemmer om feilmelding skal vises når validering feiler */
68
75
  private showErrorMessage;
69
76
  /** Om bruker starter å skrive noe i textarea */
@@ -1,11 +1,11 @@
1
- import { s as c, x as o } from "../../chunks/lit-element.js";
1
+ import { s as c, x as l } from "../../chunks/lit-element.js";
2
2
  import { n as r, t as m } from "../../chunks/property.js";
3
3
  import { r as u } from "../../chunks/state.js";
4
4
  import { e as b } from "../../chunks/query.js";
5
5
  import v from "./nve-textarea.styles.js";
6
- import { o as l } from "../../chunks/if-defined.js";
6
+ import { o } from "../../chunks/if-defined.js";
7
7
  import { l as f } from "../../chunks/live.js";
8
- import { e as y } from "../../chunks/class-map.js";
8
+ import { e as g } from "../../chunks/class-map.js";
9
9
  import "../nve-icon/nve-icon.component.js";
10
10
  import "../nve-label/nve-label.component.js";
11
11
  import "../../chunks/directive-helpers.js";
@@ -17,44 +17,44 @@ import "../../chunks/chunk.GMVRWIWU.js";
17
17
  import "../../chunks/chunk.KRRLOROJ.js";
18
18
  import "../../chunks/chunk.MAS2SHYD.js";
19
19
  import "../../chunks/chunk.Q6ASPMKT.js";
20
- var g = Object.defineProperty, x = Object.getOwnPropertyDescriptor, i = (t, a, n, h) => {
21
- for (var s = h > 1 ? void 0 : h ? x(a, n) : a, p = t.length - 1, d; p >= 0; p--)
22
- (d = t[p]) && (s = (h ? d(a, n, s) : d(s)) || s);
23
- return h && s && g(a, n, s), s;
20
+ var y = Object.defineProperty, x = Object.getOwnPropertyDescriptor, i = (e, a, h, n) => {
21
+ for (var s = n > 1 ? void 0 : n ? x(a, h) : a, p = e.length - 1, d; p >= 0; p--)
22
+ (d = e[p]) && (s = (n ? d(a, h, s) : d(s)) || s);
23
+ return n && s && y(a, h, s), s;
24
24
  };
25
- let e = class extends c {
25
+ let t = class extends c {
26
26
  constructor() {
27
27
  super(), this.name = "", this.value = "", this.title = "", this.filled = !1, this.label = "", this.helpText = "", this.disabled = !1, this.readonly = !1, this.placeholder = "", this.required = !1, this.requiredLabel = "*Obligatorisk", this.autocapitalize = "off", this.showErrorMessage = !1, this.touched = !1, this.resizeObserver = null;
28
28
  }
29
29
  firstUpdated() {
30
- var n, h;
30
+ var h, n;
31
31
  if (this.required) {
32
32
  const s = this.input.checkValidity();
33
33
  this.toggleAttribute("data-valid", s), this.toggleAttribute("data-invalid", !s);
34
34
  }
35
- const t = (n = this.shadowRoot) == null ? void 0 : n.querySelector(".textarea__control"), a = (h = this.shadowRoot) == null ? void 0 : h.querySelector(".textarea__label");
36
- t && (this.resizeObserver = new ResizeObserver((s) => {
35
+ const e = (h = this.shadowRoot) == null ? void 0 : h.querySelector(".textarea__control"), a = (n = this.shadowRoot) == null ? void 0 : n.querySelector(".textarea__label");
36
+ e && (this.resizeObserver = new ResizeObserver((s) => {
37
37
  for (let p of s)
38
38
  a.style.width = `${p.contentRect.width + 32}px`;
39
- }), this.resizeObserver.observe(t));
39
+ }), this.resizeObserver.observe(e));
40
40
  }
41
41
  connectedCallback() {
42
42
  super.connectedCallback();
43
- const t = this.closest("form");
44
- t == null || t.addEventListener("submit", this.handleSubmit.bind(this));
43
+ const e = this.closest("form");
44
+ e == null || e.addEventListener("submit", this.handleSubmit.bind(this));
45
45
  }
46
46
  disconnectedCallback() {
47
47
  var a;
48
48
  super.disconnectedCallback();
49
- const t = this.closest("form");
50
- t == null || t.removeEventListener("submit", this.handleSubmit.bind(this)), (a = this.resizeObserver) == null || a.disconnect();
49
+ const e = this.closest("form");
50
+ e == null || e.removeEventListener("submit", this.handleSubmit.bind(this)), (a = this.resizeObserver) == null || a.disconnect();
51
51
  }
52
52
  // kan senere flyttes til utils hvis blir brukt flere steder
53
- emit(t) {
54
- this.dispatchEvent(new CustomEvent(t));
53
+ emit(e) {
54
+ this.dispatchEvent(new CustomEvent(e));
55
55
  }
56
- handleSubmit(t) {
57
- t.preventDefault(), this.checkValidity();
56
+ handleSubmit(e) {
57
+ e.preventDefault(), this.checkValidity();
58
58
  }
59
59
  // validerer ikke hvis bruker ikke har tatt på input feltet
60
60
  handleBlur() {
@@ -70,8 +70,8 @@ let e = class extends c {
70
70
  checkValidity() {
71
71
  this.input.checkValidity() ? this.resetValidation() : this.makeInvalid();
72
72
  }
73
- setCustomValidity(t = "") {
74
- this.input.setCustomValidity(t), this.checkValidity();
73
+ setCustomValidity(e = "") {
74
+ this.input.setCustomValidity(e), this.checkValidity();
75
75
  }
76
76
  makeInvalid() {
77
77
  this.errorMessage = this.errorMessage || this.input.validationMessage, this.showErrorMessage = !0, this.emit("sl-invalid"), this.toggleValidationAttributes(!1);
@@ -80,129 +80,137 @@ let e = class extends c {
80
80
  this.showErrorMessage = !1, this.toggleValidationAttributes(!0);
81
81
  }
82
82
  /** Toggler riktig validering attribute for å vise riktig style */
83
- toggleValidationAttributes(t) {
84
- this.toggleAttribute("data-valid", t), this.toggleAttribute("data-user-valid", t), this.toggleAttribute("data-invalid", !t), this.toggleAttribute("data-user-invalid", !t);
83
+ toggleValidationAttributes(e) {
84
+ this.toggleAttribute("data-valid", e), this.toggleAttribute("data-user-valid", e), this.toggleAttribute("data-invalid", !e), this.toggleAttribute("data-user-invalid", !e);
85
85
  }
86
86
  render() {
87
- return o`
88
- <div part="form-control" class=${y({ "form-control": !0, "form-control--has-label": this.label })}>
87
+ return l`
88
+ <div part="form-control" class=${g({ "form-control": !0, "form-control--has-label": this.label })}>
89
89
  <div part="textarea-label" class="textarea__label">
90
- ${this.label ? o`
90
+ ${this.label ? l`
91
91
  <nve-label
92
92
  for="input"
93
93
  aria-hidden=${this.label ? "false" : "true"}
94
94
  value=${this.label}
95
- tooltip=${l(this.tooltip)}
95
+ tooltip=${o(this.tooltip)}
96
96
  ></nve-label>
97
97
  ` : null}
98
- ${this.required ? o`<span class="textarea__required-label">${this.requiredLabel}</span>` : null}
98
+ ${this.required && this.label ? l`<span class="textarea__required-label">${this.requiredLabel}</span>` : null}
99
99
  </div>
100
100
  <div part="base" class="textarea__base">
101
101
  <textarea
102
102
  part="textarea"
103
103
  class="textarea__control"
104
104
  title=${this.title}
105
- name=${l(this.name)}
105
+ name=${o(this.name)}
106
106
  .value=${f(this.value)}
107
107
  ?disabled=${this.disabled}
108
108
  ?readonly=${this.readonly}
109
109
  ?required=${this.required}
110
- placeholder=${l(this.placeholder)}
111
- minlength=${l(this.minlength)}
112
- maxlength=${l(this.maxlength)}
113
- autocapitalize=${l(this.autocapitalize)}
114
- autocorrect=${l(this.autocorrect)}
110
+ placeholder=${o(this.placeholder)}
111
+ minlength=${o(this.minlength)}
112
+ maxlength=${o(this.maxlength)}
113
+ autocapitalize=${o(this.autocapitalize)}
114
+ autocorrect=${o(this.autocorrect)}
115
115
  ?autofocus=${this.autofocus}
116
- inputmode=${l(this.inputmode)}
116
+ inputmode=${o(this.inputmode)}
117
117
  aria-describedby="help-text"
118
+ rows=${o(this.rows)}
118
119
  @change=${this.handleChange}
119
120
  @input=${this.handleInput}
120
121
  @blur=${this.handleBlur}
121
122
  ></textarea>
123
+ <!-- Her kommer litt hokus pokus med å poisjonere ikonen. Det er en ekstra div med posisjon relativt
124
+ som skal vises rett etter textarea, og den skal inneholde ikone med position absolute som skal deretter vises inn i textarea.
125
+ Må gjøres sånn fordi vi vil ikke begrense textarea__base brede til fit-content (da textarea kan aldri ta så mye plass som er
126
+ tilgjengelig i nettleseren og man må alltid sette brede på den manuelt. Nei takk.) -->
122
127
  <!-- Foreløpig kan man ha enten 'lock' eller 'error' ikone -->
123
- ${this.disabled || this.showErrorMessage ? o`<div class="textarea__icon__container">
124
- ${this.disabled ? o`<nve-icon name="lock"></nve-icon>` : null}
125
- ${this.showErrorMessage ? o`<nve-icon class="textarea__icon--error" name="error"></nve-icon>` : null}
128
+ ${this.disabled || this.showErrorMessage ? l`<div class="textarea__icon__container">
129
+ ${this.disabled ? l`<nve-icon name="lock"></nve-icon>` : null}
130
+ ${this.showErrorMessage ? l`<nve-icon class="textarea__icon--error" name="error"></nve-icon>` : null}
126
131
  </div>` : null}
127
132
  </div>
128
133
  <div part="help-text-container" class="textarea__help-text__container">
129
134
  <!-- Ikke vis hjelpe tekst mens feil -->
130
- ${!this.showErrorMessage && this.helpText ? o`<span class="textarea__help-text" aria-hidden=${this.helpText ? "false" : "true"}
135
+ ${!this.showErrorMessage && this.helpText ? l`<span class="textarea__help-text" aria-hidden=${this.helpText ? "false" : "true"}
131
136
  >${this.helpText}</span
132
137
  >` : null}
133
- ${this.showErrorMessage ? o`<span class="textarea__help-text textarea__help-text--error">${this.errorMessage}</span>` : null}
138
+ ${this.showErrorMessage ? l`<span class="textarea__help-text textarea__help-text--error">${this.errorMessage}</span>` : null}
134
139
  </div>
135
140
  </div>
136
141
  `;
137
142
  }
138
143
  };
139
- e.styles = [v];
144
+ t.styles = [v];
140
145
  i([
141
146
  r()
142
- ], e.prototype, "name", 2);
147
+ ], t.prototype, "name", 2);
143
148
  i([
144
149
  r()
145
- ], e.prototype, "value", 2);
150
+ ], t.prototype, "value", 2);
146
151
  i([
147
152
  r()
148
- ], e.prototype, "errorMessage", 2);
153
+ ], t.prototype, "errorMessage", 2);
149
154
  i([
150
155
  r()
151
- ], e.prototype, "title", 2);
156
+ ], t.prototype, "title", 2);
152
157
  i([
153
158
  r({ type: Boolean, reflect: !0 })
154
- ], e.prototype, "filled", 2);
159
+ ], t.prototype, "filled", 2);
155
160
  i([
156
161
  r()
157
- ], e.prototype, "label", 2);
162
+ ], t.prototype, "label", 2);
158
163
  i([
159
164
  r()
160
- ], e.prototype, "helpText", 2);
165
+ ], t.prototype, "helpText", 2);
161
166
  i([
162
167
  r({ type: Boolean, reflect: !0 })
163
- ], e.prototype, "disabled", 2);
168
+ ], t.prototype, "disabled", 2);
164
169
  i([
165
170
  r({ type: Boolean, reflect: !0 })
166
- ], e.prototype, "readonly", 2);
171
+ ], t.prototype, "readonly", 2);
167
172
  i([
168
173
  r()
169
- ], e.prototype, "placeholder", 2);
174
+ ], t.prototype, "placeholder", 2);
170
175
  i([
171
176
  r({ type: Boolean, reflect: !0 })
172
- ], e.prototype, "required", 2);
177
+ ], t.prototype, "required", 2);
173
178
  i([
174
179
  r()
175
- ], e.prototype, "requiredLabel", 2);
180
+ ], t.prototype, "requiredLabel", 2);
176
181
  i([
177
182
  r({ type: Number })
178
- ], e.prototype, "minlength", 2);
183
+ ], t.prototype, "minlength", 2);
179
184
  i([
180
185
  r({ type: Number })
181
- ], e.prototype, "maxlength", 2);
186
+ ], t.prototype, "maxlength", 2);
182
187
  i([
183
188
  r()
184
- ], e.prototype, "autocapitalize", 2);
189
+ ], t.prototype, "autocapitalize", 2);
185
190
  i([
186
191
  r()
187
- ], e.prototype, "autocorrect", 2);
192
+ ], t.prototype, "autocorrect", 2);
188
193
  i([
189
194
  r()
190
- ], e.prototype, "tooltip", 2);
195
+ ], t.prototype, "tooltip", 2);
191
196
  i([
192
197
  r()
193
- ], e.prototype, "inputmode", 2);
198
+ ], t.prototype, "inputmode", 2);
199
+ i([
200
+ r()
201
+ ], t.prototype, "rows", 2);
194
202
  i([
195
203
  u()
196
- ], e.prototype, "showErrorMessage", 2);
204
+ ], t.prototype, "showErrorMessage", 2);
197
205
  i([
198
206
  u()
199
- ], e.prototype, "touched", 2);
207
+ ], t.prototype, "touched", 2);
200
208
  i([
201
209
  b(".textarea__control")
202
- ], e.prototype, "input", 2);
203
- e = i([
210
+ ], t.prototype, "input", 2);
211
+ t = i([
204
212
  m("nve-textarea")
205
- ], e);
213
+ ], t);
206
214
  export {
207
- e as default
215
+ t as default
208
216
  };
@@ -13,7 +13,6 @@ const a = r`
13
13
 
14
14
  .textarea__base {
15
15
  display: flex;
16
- position: relative; /** trengs for å posisjonere ikonen */
17
16
  }
18
17
 
19
18
  .textarea__control {
@@ -88,12 +87,13 @@ const a = r`
88
87
  }
89
88
 
90
89
  .textarea__icon__container {
91
- position: absolute;
92
- right: var(--sizing-4x-small);
93
- top: var(--sizing-4x-small);
90
+ position: relative; /** trengs for å posisjonere ikonen */
94
91
  }
95
92
 
96
93
  .textarea__icon--error {
94
+ position: absolute;
95
+ left: -24px;
96
+ top: 10px;
97
97
  color: var(--feedback-background-emphasized-error);
98
98
  }
99
99
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nve-designsystem",
3
- "version": "0.1.61",
3
+ "version": "0.1.63",
4
4
  "exports": {
5
5
  ".": {
6
6
  "import": "./nve-designsystem.js",