nve-designsystem 0.4.10 → 0.4.12

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.
@@ -37,6 +37,10 @@ export default class NveLabel extends LitElement {
37
37
  * Ikon farge
38
38
  */
39
39
  iconColor: 'default' | 'black';
40
+ /**
41
+ * For-attributten legges på label, og brukes som html-standard. Sett til samme som id på elementet label tilhører
42
+ */
43
+ for?: string;
40
44
  static styles: import('lit').CSSResult[];
41
45
  private renderInfoIconWithTooltip;
42
46
  private renderValueProperty;
@@ -1,24 +1,25 @@
1
- import { r as u, x as a } from "../../chunks/lit-element.js";
2
- import { n as i, t as c } from "../../chunks/property.js";
3
- import { styles as p } from "./nve-label.styles.js";
1
+ import { r as c, x as a } from "../../chunks/lit-element.js";
2
+ import { n, t as p } from "../../chunks/property.js";
3
+ import { styles as d } from "./nve-label.styles.js";
4
4
  import "../nve-icon/nve-icon.component.js";
5
5
  import "../nve-tooltip/nve-tooltip.component.js";
6
- class d {
7
- constructor(t, ...s) {
8
- this.slotNames = [], this.handleSlotChange = (r) => {
9
- const e = r.target;
6
+ import { o as u } from "../../chunks/if-defined.js";
7
+ class m {
8
+ constructor(t, ...r) {
9
+ this.slotNames = [], this.handleSlotChange = (i) => {
10
+ const e = i.target;
10
11
  (this.slotNames.includes("[default]") && !e.name || e.name && this.slotNames.includes(e.name)) && this.host.requestUpdate();
11
- }, (this.host = t).addController(this), this.slotNames = s;
12
+ }, (this.host = t).addController(this), this.slotNames = r;
12
13
  }
13
14
  hasDefaultSlot() {
14
15
  return [...this.host.childNodes].some((t) => {
15
16
  if (t.nodeType === t.TEXT_NODE && t.textContent.trim() !== "")
16
17
  return !0;
17
18
  if (t.nodeType === t.ELEMENT_NODE) {
18
- const s = t;
19
- if (s.tagName.toLowerCase() === "sl-visually-hidden")
19
+ const r = t;
20
+ if (r.tagName.toLowerCase() === "sl-visually-hidden")
20
21
  return !1;
21
- if (!s.hasAttribute("slot"))
22
+ if (!r.hasAttribute("slot"))
22
23
  return !0;
23
24
  }
24
25
  return !1;
@@ -43,14 +44,14 @@ class d {
43
44
  this.host.shadowRoot.removeEventListener("slotchange", this.handleSlotChange);
44
45
  }
45
46
  }
46
- var m = Object.defineProperty, v = Object.getOwnPropertyDescriptor, n = (o, t, s, r) => {
47
- for (var e = r > 1 ? void 0 : r ? v(t, s) : t, h = o.length - 1, f; h >= 0; h--)
48
- (f = o[h]) && (e = (r ? f(t, s, e) : f(e)) || e);
49
- return r && e && m(t, s, e), e;
47
+ var v = Object.defineProperty, g = Object.getOwnPropertyDescriptor, s = (o, t, r, i) => {
48
+ for (var e = i > 1 ? void 0 : i ? g(t, r) : t, h = o.length - 1, f; h >= 0; h--)
49
+ (f = o[h]) && (e = (i ? f(t, r, e) : f(e)) || e);
50
+ return i && e && v(t, r, e), e;
50
51
  };
51
- let l = class extends u {
52
+ let l = class extends c {
52
53
  constructor() {
53
- super(...arguments), this.hasSlotController = new d(this, "tooltip"), this.value = "", this.size = "small", this.light = !1, this.tooltip = void 0, this.iconLeft = !1, this.iconColor = "default";
54
+ super(...arguments), this.hasSlotController = new m(this, "tooltip"), this.value = "", this.size = "small", this.light = !1, this.tooltip = void 0, this.iconLeft = !1, this.iconColor = "default", this.for = void 0;
54
55
  }
55
56
  renderInfoIconWithTooltip() {
56
57
  let o = this.tooltip;
@@ -60,9 +61,19 @@ let l = class extends u {
60
61
  </nve-tooltip>` : a``;
61
62
  }
62
63
  renderValueProperty() {
63
- return this.value.length ? a` <label part="form-control-label" class="form-control__label" aria-hidden="false">
64
+ return this.value.length ? a` <label
65
+ part="form-control-label"
66
+ class="form-control__label"
67
+ aria-hidden="false"
68
+ for=${u(this.for)}
69
+ >
64
70
  <slot name="label">${this.value}</slot>
65
- </label>` : a` <label part="form-control-label" class="form-control__label" aria-hidden="false">
71
+ </label>` : a` <label
72
+ part="form-control-label"
73
+ class="form-control__label"
74
+ aria-hidden="false"
75
+ for=${u(this.for)}
76
+ >
66
77
  <slot></slot>
67
78
  </label>`;
68
79
  }
@@ -74,27 +85,30 @@ let l = class extends u {
74
85
  `;
75
86
  }
76
87
  };
77
- l.styles = [p];
78
- n([
79
- i({ reflect: !0 })
88
+ l.styles = [d];
89
+ s([
90
+ n({ reflect: !0 })
80
91
  ], l.prototype, "value", 2);
81
- n([
82
- i({ reflect: !0 })
92
+ s([
93
+ n({ reflect: !0 })
83
94
  ], l.prototype, "size", 2);
84
- n([
85
- i({ type: Boolean, reflect: !0 })
95
+ s([
96
+ n({ type: Boolean, reflect: !0 })
86
97
  ], l.prototype, "light", 2);
87
- n([
88
- i({ reflect: !0 })
98
+ s([
99
+ n({ reflect: !0 })
89
100
  ], l.prototype, "tooltip", 2);
90
- n([
91
- i({ type: Boolean, reflect: !0 })
101
+ s([
102
+ n({ type: Boolean, reflect: !0 })
92
103
  ], l.prototype, "iconLeft", 2);
93
- n([
94
- i({ reflect: !0 })
104
+ s([
105
+ n({ reflect: !0 })
95
106
  ], l.prototype, "iconColor", 2);
96
- l = n([
97
- c("nve-label")
107
+ s([
108
+ n({ reflect: !0 })
109
+ ], l.prototype, "for", 2);
110
+ l = s([
111
+ p("nve-label")
98
112
  ], l);
99
113
  export {
100
114
  l as default
@@ -1,11 +1,20 @@
1
1
  import { default as SlOption } from '@shoelace-style/shoelace/dist/components/option/option.js';
2
+ import { PropertyValues } from 'lit';
2
3
  /**
3
4
  * Representerer et valg i nve-select.
4
5
  */
5
6
  export default class NveOption extends SlOption {
6
7
  constructor();
7
8
  static styles: import('lit').CSSResultGroup[];
8
- firstUpdated(changedProperties: any): void;
9
+ /**
10
+ * Tekst som vises i select når denne er valgt. Default er at all råtekst vises.
11
+ */
12
+ textLabel: string | undefined;
13
+ firstUpdated(changedProperties: PropertyValues): void;
14
+ /**
15
+ * Gir tilbake plain-tekst-label som vises i select
16
+ */
17
+ getTextLabel(): string;
9
18
  }
10
19
  declare global {
11
20
  interface HTMLElementTagNameMap {
@@ -2,17 +2,16 @@ import { o as f } from "../../chunks/chunk.MXB57G5B.js";
2
2
  import "../../chunks/chunk.6CTB5ZDJ.js";
3
3
  import "../../chunks/chunk.QCFOL4VF.js";
4
4
  import "../../chunks/chunk.EVP45OG4.js";
5
- import { t as u } from "../../chunks/property.js";
6
- import "../../chunks/lit-element.js";
7
- import a from "./nve-option.styles.js";
8
- var m = Object.defineProperty, n = Object.getOwnPropertyDescriptor, v = (r, t, o, s) => {
9
- for (var e = s > 1 ? void 0 : s ? n(t, o) : t, i = r.length - 1, l; i >= 0; i--)
10
- (l = r[i]) && (e = (s ? l(t, o, e) : l(e)) || e);
11
- return s && e && m(t, o, e), e;
5
+ import { n as u, t as n } from "../../chunks/property.js";
6
+ import b from "./nve-option.styles.js";
7
+ var v = Object.defineProperty, d = Object.getOwnPropertyDescriptor, a = (r, t, o, s) => {
8
+ for (var e = s > 1 ? void 0 : s ? d(t, o) : t, i = r.length - 1, p; i >= 0; i--)
9
+ (p = r[i]) && (e = (s ? p(t, o, e) : p(e)) || e);
10
+ return s && e && v(t, o, e), e;
12
11
  };
13
- let p = class extends f {
12
+ let l = class extends f {
14
13
  constructor() {
15
- super();
14
+ super(), this.textLabel = void 0;
16
15
  }
17
16
  /* Setter filled attributt på option når parent-select er filled, for å få annen hover-farge*/
18
17
  firstUpdated(r) {
@@ -20,11 +19,20 @@ let p = class extends f {
20
19
  const t = this.closest("nve-select");
21
20
  t != null && t.hasAttribute("filled") ? this.toggleAttribute("filled", !0) : this.toggleAttribute("filled", !1);
22
21
  }
22
+ /**
23
+ * Gir tilbake plain-tekst-label som vises i select
24
+ */
25
+ getTextLabel() {
26
+ return this.textLabel ? this.textLabel : super.getTextLabel();
27
+ }
23
28
  };
24
- p.styles = [f.styles, a];
25
- p = v([
26
- u("nve-option")
27
- ], p);
29
+ l.styles = [f.styles, b];
30
+ a([
31
+ u()
32
+ ], l.prototype, "textLabel", 2);
33
+ l = a([
34
+ n("nve-option")
35
+ ], l);
28
36
  export {
29
- p as default
37
+ l as default
30
38
  };
@@ -1,4 +1,5 @@
1
1
  import { default as SlSelect } from '@shoelace-style/shoelace/dist/components/select/select.js';
2
+ import { PropertyValues } from 'lit';
2
3
  /**
3
4
  * En nedtrekksliste, også kjent som rullgardin eller drop-down list. Kjært barn har mange navn.
4
5
  * TODO: Klarte ikke å sette feil-ikonet når validering feiler. Eneste måte å gjøre det på kunne ha vært å bruke ::after pseudo-element på noen av sl-select partene, men
@@ -19,8 +20,8 @@ export default class NveSelect extends SlSelect {
19
20
  disconnectedCallback(): void;
20
21
  constructor();
21
22
  static styles: import('lit').CSSResultGroup[];
22
- protected firstUpdated(changedProperties: any): void;
23
- updated(changedProperties: any): void;
23
+ protected firstUpdated(changedProperties: PropertyValues): void;
24
+ updated(changedProperties: PropertyValues): void;
24
25
  focus(): void;
25
26
  private handleOptionClick;
26
27
  private handleDefaultSlotChange;
@@ -61,8 +61,8 @@ export default class NveTextarea extends LitElement implements INveComponent {
61
61
  /** Indikerer om nettleserens autokorrekturfunksjon er på eller av. */
62
62
  tooltip?: string;
63
63
  /**
64
- * Brukes for å kunne identifisere komponenten i tester
65
- */
64
+ * Brukes for å kunne identifisere komponenten i tester
65
+ */
66
66
  testId: string;
67
67
  /**
68
68
  * Forteller nettleseren hvilken type data som vil bli skrevet inn av brukeren, slik at den kan vise det passende virtuelle
@@ -1,11 +1,11 @@
1
- import { r as c, x as l } from "../../chunks/lit-element.js";
1
+ import { r as c, x as o } from "../../chunks/lit-element.js";
2
2
  import { n as s, 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 } from "../../chunks/if-defined.js";
7
- import { l as f } from "../../chunks/live.js";
8
- import { e as g } from "../../chunks/class-map.js";
6
+ import { o as l } from "../../chunks/if-defined.js";
7
+ import { l as g } from "../../chunks/live.js";
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
11
  var y = Object.defineProperty, x = Object.getOwnPropertyDescriptor, i = (t, a, h, n) => {
@@ -75,38 +75,37 @@ let e = class extends c {
75
75
  this.toggleAttribute("data-valid", t), this.toggleAttribute("data-user-valid", t), this.toggleAttribute("data-invalid", !t), this.toggleAttribute("data-user-invalid", !t);
76
76
  }
77
77
  render() {
78
- return l`
79
- <div part="form-control" class=${g({ "form-control": !0, "form-control--has-label": this.label })}>
78
+ return o`
79
+ <div part="form-control" class=${f({ "form-control": !0, "form-control--has-label": this.label })}>
80
80
  <div part="textarea-label" class="textarea__label">
81
- ${this.label ? l`
81
+ ${this.label ? o`
82
82
  <nve-label
83
- for="input"
84
83
  aria-hidden=${this.label ? "false" : "true"}
85
84
  value=${this.label}
86
- tooltip=${o(this.tooltip)}
85
+ tooltip=${l(this.tooltip)}
87
86
  ></nve-label>
88
87
  ` : null}
89
- ${this.required && this.label ? l`<span class="textarea__required-label">${this.requiredLabel}</span>` : null}
88
+ ${this.required && this.label ? o`<span class="textarea__required-label">${this.requiredLabel}</span>` : null}
90
89
  </div>
91
90
  <div part="base" class="textarea__base">
92
91
  <textarea
93
92
  part="textarea"
94
93
  class="textarea__control"
95
94
  title=${this.title}
96
- name=${o(this.name)}
97
- .value=${f(this.value)}
95
+ name=${l(this.name)}
96
+ .value=${g(this.value)}
98
97
  ?disabled=${this.disabled}
99
98
  ?readonly=${this.readonly}
100
99
  ?required=${this.required}
101
- placeholder=${o(this.placeholder)}
102
- minlength=${o(this.minlength)}
103
- maxlength=${o(this.maxlength)}
104
- autocapitalize=${o(this.autocapitalize)}
105
- autocorrect=${o(this.autocorrect)}
100
+ placeholder=${l(this.placeholder)}
101
+ minlength=${l(this.minlength)}
102
+ maxlength=${l(this.maxlength)}
103
+ autocapitalize=${l(this.autocapitalize)}
104
+ autocorrect=${l(this.autocorrect)}
106
105
  ?autofocus=${this.autofocus}
107
- inputmode=${o(this.inputmode)}
106
+ inputmode=${l(this.inputmode)}
108
107
  aria-describedby="help-text"
109
- rows=${o(this.rows)}
108
+ rows=${l(this.rows)}
110
109
  @change=${this.handleChange}
111
110
  @input=${this.handleInput}
112
111
  @blur=${this.handleBlur}
@@ -116,17 +115,17 @@ let e = class extends c {
116
115
  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
116
  tilgjengelig i nettleseren og man må alltid sette brede på den manuelt. Nei takk.) -->
118
117
  <!-- 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}
118
+ ${this.disabled || this.showErrorMessage ? o`<div class="textarea__icon__container">
119
+ ${this.disabled ? o`<nve-icon name="lock"></nve-icon>` : null}
120
+ ${this.showErrorMessage ? o`<nve-icon class="textarea__icon--error" name="error"></nve-icon>` : null}
122
121
  </div>` : null}
123
122
  </div>
124
123
  <div part="help-text-container" class="textarea__help-text__container">
125
124
  <!-- Ikke vis hjelpe tekst mens feil -->
126
- ${!this.showErrorMessage && this.helpText ? l`<span class="textarea__help-text" aria-hidden=${this.helpText ? "false" : "true"}
125
+ ${!this.showErrorMessage && this.helpText ? o`<span class="textarea__help-text" aria-hidden=${this.helpText ? "false" : "true"}
127
126
  >${this.helpText}</span
128
127
  >` : null}
129
- ${this.showErrorMessage ? l`<span class="textarea__help-text textarea__help-text--error">${this.errorMessage}</span>` : null}
128
+ ${this.showErrorMessage ? o`<span class="textarea__help-text textarea__help-text--error">${this.errorMessage}</span>` : null}
130
129
  </div>
131
130
  </div>
132
131
  `;
@@ -53,6 +53,10 @@ const a = r`
53
53
  }
54
54
  }
55
55
 
56
+ :host([filled][data-user-invalid]) .textarea__control {
57
+ border-color: var(--feedback-background-emphasized-error);
58
+ }
59
+
56
60
  :host([readonly]) .textarea__control {
57
61
  background: var(--neutrals-background-secondary);
58
62
  color: var(--neutrals-foreground-subtle,);