nve-designsystem 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,33 +1,33 @@
1
- import { i as b, x as c } from "../../chunks/lit-element.js";
2
- import { n as a, t as p } from "../../chunks/property.js";
3
- import { r as d } from "../../chunks/state.js";
4
- import { e as f } from "../../chunks/query.js";
1
+ import { i as p, E as c, x as d } from "../../chunks/lit-element.js";
2
+ import { n as a, t as f } from "../../chunks/property.js";
3
+ import { r as u } from "../../chunks/state.js";
4
+ import { e as v } from "../../chunks/query.js";
5
5
  import "../nve-label/nve-label.component.js";
6
- import v from "./nve-checkbox-group.styles.js";
7
- import { t as g } from "../../chunks/updateInvalidProperty.js";
8
- function u(e, t) {
6
+ import g from "./nve-checkbox-group.styles.js";
7
+ import { t as y } from "../../chunks/updateInvalidProperty.js";
8
+ function b(e, t) {
9
9
  if (e === t) return !0;
10
10
  if (typeof e != "object" || e === null || typeof t != "object" || t === null)
11
11
  return !1;
12
12
  let s = Object.keys(e), i = Object.keys(t);
13
13
  if (s.length !== i.length) return !1;
14
14
  for (let o of s)
15
- if (!i.includes(o) || !u(e[o], t[o])) return !1;
15
+ if (!i.includes(o) || !b(e[o], t[o])) return !1;
16
16
  return !0;
17
17
  }
18
- var y = Object.defineProperty, m = Object.getOwnPropertyDescriptor, l = (e, t, s, i) => {
19
- for (var o = i > 1 ? void 0 : i ? m(t, s) : t, n = e.length - 1, h; n >= 0; n--)
18
+ var m = Object.defineProperty, k = Object.getOwnPropertyDescriptor, l = (e, t, s, i) => {
19
+ for (var o = i > 1 ? void 0 : i ? k(t, s) : t, n = e.length - 1, h; n >= 0; n--)
20
20
  (h = e[n]) && (o = (i ? h(t, s, o) : h(o)) || o);
21
- return i && o && y(t, s, o), o;
21
+ return i && o && m(t, s, o), o;
22
22
  };
23
- let r = class extends b {
23
+ let r = class extends p {
24
24
  constructor() {
25
25
  super(), this.disabled = !1, this.required = !1, this.orientation = "vertical", this.requiredLabel = "*Obligatorisk", this.showErrorMessage = !1, this.isCustomValidationError = !1, this.updateSelectedValues = (e) => {
26
26
  const t = e.target;
27
27
  if (t.checked)
28
28
  this.selectedValues || (this.selectedValues = []), this.selectedValues.push(t.value);
29
29
  else if (this.selectedValues) {
30
- const s = this.selectedValues.findIndex((i) => u(i, t.value));
30
+ const s = this.selectedValues.findIndex((i) => b(i, t.value));
31
31
  s !== -1 && this.selectedValues.splice(s, 1);
32
32
  }
33
33
  this.requestUpdate();
@@ -52,7 +52,7 @@ let r = class extends b {
52
52
  updated(e) {
53
53
  if (super.updated(e), e.has("disabled")) {
54
54
  const t = Array.from(this.querySelectorAll("nve-checkbox"));
55
- g(t, this.disabled, "disabled");
55
+ y(t, this.disabled, "disabled");
56
56
  }
57
57
  }
58
58
  /** En 'fake' metode som gjør custom validering enklere på checkbox-group komponent */
@@ -95,7 +95,7 @@ let r = class extends b {
95
95
  return Array.from(this.querySelectorAll("nve-checkbox")).some((s) => s.checked);
96
96
  }
97
97
  render() {
98
- return c`
98
+ return d`
99
99
  <fieldset
100
100
  class="checkbox-group"
101
101
  aria-required=${this.required}
@@ -103,18 +103,18 @@ let r = class extends b {
103
103
  aria-describedby="error-message"
104
104
  aria-errormessage="error-message"
105
105
  >
106
- ${this.label ? c`<div class="checkbox-group__label">
106
+ ${this.label ? d`<div class="checkbox-group__label">
107
107
  <nve-label id="label" value=${this.label} size="small" tooltip=${this.tooltip}></nve-label>
108
- </div>` : null}
108
+ </div>` : c}
109
109
  <slot class="checkbox-group__checkboxes"></slot>
110
- ${this.showErrorMessage ? c`<span role="alert" id="error-message" class="checkbox-group__error-message"
111
- >${this.errorMessage || null}</span
112
- >` : null}
110
+ ${this.showErrorMessage ? d`<span role="alert" id="error-message" class="checkbox-group__error-message"
111
+ >${this.errorMessage || c}</span
112
+ >` : c}
113
113
  </fieldset>
114
114
  `;
115
115
  }
116
116
  };
117
- r.styles = [v];
117
+ r.styles = [g];
118
118
  l([
119
119
  a({ type: Boolean, reflect: !0 })
120
120
  ], r.prototype, "disabled", 2);
@@ -140,16 +140,16 @@ l([
140
140
  a({ type: Array })
141
141
  ], r.prototype, "selectedValues", 2);
142
142
  l([
143
- f("slot")
143
+ v("slot")
144
144
  ], r.prototype, "slot", 2);
145
145
  l([
146
- d()
146
+ u()
147
147
  ], r.prototype, "showErrorMessage", 2);
148
148
  l([
149
- d()
149
+ u()
150
150
  ], r.prototype, "isCustomValidationError", 2);
151
151
  r = l([
152
- p("nve-checkbox-group")
152
+ f("nve-checkbox-group")
153
153
  ], r);
154
154
  export {
155
155
  r as default
@@ -48,6 +48,10 @@ const a = e`
48
48
  font: var(--body-xsmall);
49
49
  color: var(--feedback-background-emphasized-error);
50
50
  }
51
+
52
+ nve-label {
53
+ width: unset;
54
+ }
51
55
  `;
52
56
  export {
53
57
  a as default
@@ -87,11 +87,11 @@ const a = r`
87
87
  border-color: var(--feedback-background-emphasized-error);
88
88
  }
89
89
 
90
- /* Formaterer "*Obligatorisk" over input-felt og til høyre riktig når required er satt */
90
+ /* Formaterer "*Obligatorisk" over input-felt når required er satt */
91
91
  .form-control--has-label .form-control__label {
92
92
  display: flex;
93
- width: 100%;
94
- justify-content: space-between;
93
+ align-items: center;
94
+ gap: var(--spacing-xx-small);
95
95
  margin-inline-start: unset;
96
96
  }
97
97
  `;
@@ -1,29 +1,29 @@
1
- import { i as c, x as l } from "../../chunks/lit-element.js";
2
- import { n as s, t as m } from "../../chunks/property.js";
1
+ import { i as m, E as d, x as n } from "../../chunks/lit-element.js";
2
+ import { n as s, t as b } from "../../chunks/property.js";
3
3
  import { r as u } from "../../chunks/state.js";
4
- import { e as b } from "../../chunks/query.js";
5
- import v from "./nve-textarea.styles.js";
4
+ import { e as v } from "../../chunks/query.js";
5
+ import y from "./nve-textarea.styles.js";
6
6
  import { o } from "../../chunks/if-defined.js";
7
7
  import { l as g } from "../../chunks/live.js";
8
8
  import { e as f } from "../../chunks/class-map.js";
9
9
  import "../nve-icon/nve-icon.component.js";
10
10
  import "../nve-label/nve-label.component.js";
11
- var y = Object.defineProperty, x = Object.getOwnPropertyDescriptor, i = (t, a, h, n) => {
12
- for (var r = n > 1 ? void 0 : n ? x(a, h) : a, p = t.length - 1, d; p >= 0; p--)
13
- (d = t[p]) && (r = (n ? d(a, h, r) : d(r)) || r);
14
- return n && r && y(a, h, r), r;
11
+ var x = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, i = (t, a, h, l) => {
12
+ for (var r = l > 1 ? void 0 : l ? _(a, h) : a, p = t.length - 1, c; p >= 0; p--)
13
+ (c = t[p]) && (r = (l ? c(a, h, r) : c(r)) || r);
14
+ return l && r && x(a, h, r), r;
15
15
  };
16
- let e = class extends c {
16
+ let e = class extends m {
17
17
  constructor() {
18
18
  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.testId = "", this.showErrorMessage = !1, this.touched = !1, this.resizeObserver = null;
19
19
  }
20
20
  firstUpdated() {
21
- var h, n;
22
- if (this.required) {
21
+ var h, l;
22
+ if (this.requiredLabel && this.style.setProperty("--textarea-required-content", `"${this.requiredLabel}"`), this.required) {
23
23
  const r = this.input.checkValidity();
24
24
  this.toggleAttribute("data-valid", r), this.toggleAttribute("data-invalid", !r);
25
25
  }
26
- const t = (h = this.shadowRoot) == null ? void 0 : h.querySelector(".textarea__control"), a = (n = this.shadowRoot) == null ? void 0 : n.querySelector(".textarea__label");
26
+ const t = (h = this.shadowRoot) == null ? void 0 : h.querySelector(".textarea__control"), a = (l = this.shadowRoot) == null ? void 0 : l.querySelector(".textarea__label");
27
27
  t && (this.resizeObserver = new ResizeObserver((r) => {
28
28
  for (const p of r)
29
29
  a.style.width = `${p.contentRect.width + 32}px`;
@@ -76,18 +76,11 @@ let e = class extends c {
76
76
  }
77
77
  // eslint-disable-next-line max-lines-per-function
78
78
  render() {
79
- return l`
79
+ return n`
80
80
  <div part="form-control" class=${f({ "form-control": !0, "form-control--has-label": this.label })}>
81
- <div part="textarea-label" class="textarea__label">
82
- ${this.label ? l`
83
- <nve-label
84
- aria-hidden=${this.label ? "false" : "true"}
85
- value=${this.label}
86
- tooltip=${o(this.tooltip)}
87
- ></nve-label>
88
- ` : null}
89
- ${this.required && this.label ? l`<span class="textarea__required-label">${this.requiredLabel}</span>` : null}
90
- </div>
81
+ ${this.label ? n`<div class="textarea__label">
82
+ <nve-label id="label" value=${this.label} size="small" tooltip=${o(this.tooltip)}></nve-label>
83
+ </div>` : d}
91
84
  <div part="base" class="textarea__base">
92
85
  <textarea
93
86
  part="textarea"
@@ -116,23 +109,23 @@ let e = class extends c {
116
109
  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
117
110
  tilgjengelig i nettleseren og man må alltid sette brede på den manuelt. Nei takk.) -->
118
111
  <!-- Foreløpig kan man ha enten 'lock' eller 'error' ikone -->
119
- ${this.disabled || this.showErrorMessage ? l`<div class="textarea__icon__container">
120
- ${this.disabled ? l`<nve-icon name="lock"></nve-icon>` : null}
121
- ${this.showErrorMessage ? l`<nve-icon class="textarea__icon--error" name="error"></nve-icon>` : null}
122
- </div>` : null}
112
+ ${this.disabled || this.showErrorMessage ? n`<div class="textarea__icon__container">
113
+ ${this.disabled ? n`<nve-icon name="lock"></nve-icon>` : null}
114
+ ${this.showErrorMessage ? n`<nve-icon class="textarea__icon--error" name="error"></nve-icon>` : null}
115
+ </div>` : d}
123
116
  </div>
124
117
  <div part="help-text-container" class="textarea__help-text__container">
125
118
  <!-- Ikke vis hjelpe tekst mens feil -->
126
- ${!this.showErrorMessage && this.helpText ? l`<span class="textarea__help-text" aria-hidden=${this.helpText ? "false" : "true"}
119
+ ${!this.showErrorMessage && this.helpText ? n`<span class="textarea__help-text" aria-hidden=${this.helpText ? "false" : "true"}
127
120
  >${this.helpText}</span
128
- >` : null}
129
- ${this.showErrorMessage ? l`<span class="textarea__help-text textarea__help-text--error">${this.errorMessage}</span>` : null}
121
+ >` : d}
122
+ ${this.showErrorMessage ? n`<span class="textarea__help-text textarea__help-text--error">${this.errorMessage}</span>` : d}
130
123
  </div>
131
124
  </div>
132
125
  `;
133
126
  }
134
127
  };
135
- e.styles = [v];
128
+ e.styles = [y];
136
129
  i([
137
130
  s()
138
131
  ], e.prototype, "name", 2);
@@ -200,10 +193,10 @@ i([
200
193
  u()
201
194
  ], e.prototype, "touched", 2);
202
195
  i([
203
- b(".textarea__control")
196
+ v(".textarea__control")
204
197
  ], e.prototype, "input", 2);
205
198
  e = i([
206
- m("nve-textarea")
199
+ b("nve-textarea")
207
200
  ], e);
208
201
  export {
209
202
  e as default
@@ -2,6 +2,7 @@ import { a as r } from "../../chunks/lit-element.js";
2
2
  const a = r`
3
3
  :host {
4
4
  display: flex;
5
+ --textarea-required-content: '*Obligatorisk';
5
6
  }
6
7
 
7
8
  .form-control {
@@ -70,8 +71,10 @@ const a = r`
70
71
  align-items: center;
71
72
  }
72
73
 
73
- .textarea__required-label {
74
+ :host([required]) nve-label::after {
75
+ content: var(--textarea-required-content);
74
76
  font: var(--label-x-small-light);
77
+ margin-left: auto;
75
78
  color: var(--feedback-background-emphasized-error);
76
79
  }
77
80
 
@@ -100,6 +103,10 @@ const a = r`
100
103
  top: 10px;
101
104
  color: var(--feedback-background-emphasized-error);
102
105
  }
106
+
107
+ nve-label {
108
+ width: unset;
109
+ }
103
110
  `;
104
111
  export {
105
112
  a as default