nve-designsystem 2.10.0 → 2.10.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.
@@ -9,13 +9,13 @@ var f = Object.defineProperty, m = Object.getOwnPropertyDescriptor, r = (p, s, i
9
9
  };
10
10
  let v = 0, e = class extends d {
11
11
  constructor() {
12
- super(), this.testId = void 0, this.panel = null, this.size = "large", this.background = !1, this.attrId = ++v, this.componentId = `nve-tab-${this.attrId}`, this.id = this.id.length > 0 ? this.id : this.componentId;
12
+ super(), this.testId = void 0, this.panel = null, this.size = "large", this.background = !1, this.attrId = ++v, this.componentId = `nve-tab-${this.attrId}`;
13
13
  }
14
14
  connectedCallback() {
15
15
  super.connectedCallback(), this.setAttribute("role", "tab");
16
16
  }
17
17
  render() {
18
- return c`
18
+ return this.id = this.id.length > 0 ? this.id : this.componentId, c`
19
19
  <div
20
20
  part="base"
21
21
  class=${u({ tab: !0, "tab--large": this.size === "large", "tab--background": this.background })}
@@ -5,10 +5,10 @@ import y from "./nve-tab-group.styles.js";
5
5
  import "../nve-button/nve-button.component.js";
6
6
  import { e as v } from "../../chunks/class-map.js";
7
7
  import { o as m } from "../../chunks/if-defined.js";
8
- var k = Object.defineProperty, S = Object.getOwnPropertyDescriptor, c = (t, e, s, o) => {
9
- for (var a = o > 1 ? void 0 : o ? S(e, s) : e, i = t.length - 1, r; i >= 0; i--)
10
- (r = t[i]) && (a = (o ? r(e, s, a) : r(a)) || a);
11
- return o && a && k(e, s, a), a;
8
+ var k = Object.defineProperty, S = Object.getOwnPropertyDescriptor, c = (t, e, a, r) => {
9
+ for (var s = r > 1 ? void 0 : r ? S(e, a) : e, o = t.length - 1, i; o >= 0; o--)
10
+ (i = t[o]) && (s = (r ? i(e, a, s) : i(s)) || s);
11
+ return r && s && k(e, a, s), s;
12
12
  };
13
13
  let n = class extends w {
14
14
  constructor() {
@@ -37,12 +37,12 @@ let n = class extends w {
37
37
  * @param event Klikkeventet.
38
38
  */
39
39
  handleClick(t) {
40
- const e = t.composedPath(), s = e.find(
41
- (a) => a instanceof HTMLElement && a.tagName.toLowerCase() === "nve-tab"
40
+ const e = t.composedPath(), a = e.find(
41
+ (s) => s instanceof HTMLElement && s.tagName.toLowerCase() === "nve-tab"
42
42
  );
43
43
  e.find(
44
- (a) => a instanceof HTMLElement && a.tagName.toLowerCase() === "nve-tab-group"
45
- ) === this && s && s.panel && this.setActiveTab(s.panel);
44
+ (s) => s instanceof HTMLElement && s.tagName.toLowerCase() === "nve-tab-group"
45
+ ) === this && a && a.panel && this.setActiveTab(a.panel);
46
46
  }
47
47
  /**
48
48
  * @internal
@@ -51,15 +51,15 @@ let n = class extends w {
51
51
  * @param event Tastetrykk eventet.
52
52
  */
53
53
  handleKeyDown(t) {
54
- const e = t.composedPath(), s = e.find((a) => a instanceof HTMLElement && a.closest && a.closest("nve-tab") === a) || null;
54
+ const e = t.composedPath(), a = e.find((s) => s instanceof HTMLElement && s.closest && s.closest("nve-tab") === s) || null;
55
55
  if (e.find(
56
- (a) => a instanceof HTMLElement && a.tagName.toLowerCase() === "nve-tab-group"
57
- ) === this && (["Enter", " "].includes(t.key) && s && s.panel && (this.setActiveTab(s.panel), t.preventDefault()), ["ArrowLeft", "ArrowRight", "Home", "End"].includes(t.key))) {
58
- const a = this.tabs.find((d) => d === s);
59
- if (!a) return;
60
- const i = this.tabs.indexOf(a);
61
- let r;
62
- t.key === "ArrowLeft" && (r = i > 0 ? this.tabs[i - 1] : this.tabs[this.tabs.length - 1]), t.key === "ArrowRight" && (r = i < this.tabs.length - 1 ? this.tabs[i + 1] : this.tabs[0]), t.key === "Home" && (r = this.tabs[0]), t.key === "End" && (r = this.tabs[this.tabs.length - 1]), r && (r.focus(), t.preventDefault());
56
+ (s) => s instanceof HTMLElement && s.tagName.toLowerCase() === "nve-tab-group"
57
+ ) === this && (["Enter", " "].includes(t.key) && a && a.panel && (this.setActiveTab(a.panel), t.preventDefault()), ["ArrowLeft", "ArrowRight", "Home", "End"].includes(t.key))) {
58
+ const s = this.tabs.find((d) => d === a);
59
+ if (!s) return;
60
+ const o = this.tabs.indexOf(s);
61
+ let i;
62
+ t.key === "ArrowLeft" && (i = o > 0 ? this.tabs[o - 1] : this.tabs[this.tabs.length - 1]), t.key === "ArrowRight" && (i = o < this.tabs.length - 1 ? this.tabs[o + 1] : this.tabs[0]), t.key === "Home" && (i = this.tabs[0]), t.key === "End" && (i = this.tabs[this.tabs.length - 1]), i && (i.focus(), t.preventDefault());
63
63
  }
64
64
  }
65
65
  /**
@@ -68,7 +68,7 @@ let n = class extends w {
68
68
  */
69
69
  getPanels() {
70
70
  const t = this.shadowRoot?.querySelector("slot:not([name])");
71
- return t ? t.assignedElements({ flatten: !0 }).filter((s) => s.tagName.toLowerCase() === "nve-tab-panel") : [];
71
+ return t ? t.assignedElements({ flatten: !0 }).filter((a) => a.tagName.toLowerCase() === "nve-tab-panel") : [];
72
72
  }
73
73
  /**
74
74
  * Henter alle faner i tab gruppen.
@@ -76,7 +76,7 @@ let n = class extends w {
76
76
  */
77
77
  getTabs() {
78
78
  const t = this.shadowRoot?.querySelector('slot[name="nav"]');
79
- return t ? t.assignedElements({ flatten: !0 }).filter((s) => s.tagName.toLowerCase() === "nve-tab") : [];
79
+ return t ? t.assignedElements({ flatten: !0 }).filter((a) => a.tagName.toLowerCase() === "nve-tab") : [];
80
80
  }
81
81
  /** Setter aria-selected og tabindex på fanene. Kun aktiv fane skal bli fokusert. Gjemmer inaktive paneller.
82
82
  * Sender en nve-tab-change event med navnet på den aktive fanen.
@@ -95,9 +95,9 @@ let n = class extends w {
95
95
  }
96
96
  updateIndicator() {
97
97
  if (this.isBackground) return;
98
- const t = this.shadowRoot?.querySelector(".tab-group__nav"), e = this.tabs.find((s) => s.getAttribute("aria-selected") === "true");
98
+ const t = this.shadowRoot?.querySelector(".tab-group__nav"), e = this.tabs.find((a) => a.getAttribute("aria-selected") === "true");
99
99
  if (t && e) {
100
- const s = e.offsetLeft - t.offsetLeft - 25, o = e.offsetWidth;
100
+ const a = t.getBoundingClientRect(), s = e.getBoundingClientRect().left - a.left + t.scrollLeft, o = e.offsetWidth;
101
101
  t.style.setProperty("--indicator-x", `${s}px`), t.style.setProperty("--indicator-width", `${o}px`);
102
102
  }
103
103
  }
@@ -107,7 +107,7 @@ let n = class extends w {
107
107
  */
108
108
  setAriaLabels() {
109
109
  this.tabs.forEach((t) => {
110
- const e = this.panels.find((s) => s.name === t.panel);
110
+ const e = this.panels.find((a) => a.name === t.panel);
111
111
  e && (t.setAttribute("aria-controls", e.id), e.setAttribute("aria-labelledby", t.id));
112
112
  });
113
113
  }
@@ -134,8 +134,8 @@ let n = class extends w {
134
134
  const e = this.shadowRoot?.querySelector(".tab-group__nav-button--forward")?.querySelector("nve-button");
135
135
  if (e) {
136
136
  await e.updateComplete;
137
- const s = e.shadowRoot?.querySelector('[part="base"]');
138
- s && s.setAttribute("tabindex", "-1");
137
+ const a = e.shadowRoot?.querySelector('[part="base"]');
138
+ a && a.setAttribute("tabindex", "-1");
139
139
  }
140
140
  }
141
141
  /**
@@ -145,8 +145,8 @@ let n = class extends w {
145
145
  const e = this.shadowRoot?.querySelector(".tab-group__nav-button--backward")?.querySelector("nve-button");
146
146
  if (e) {
147
147
  await e.updateComplete;
148
- const s = e.shadowRoot?.querySelector('[part="base"]');
149
- s && s.setAttribute("tabindex", "-1");
148
+ const a = e.shadowRoot?.querySelector('[part="base"]');
149
+ a && a.setAttribute("tabindex", "-1");
150
150
  }
151
151
  }
152
152
  /**
@@ -173,10 +173,10 @@ let n = class extends w {
173
173
  scrollNavForward() {
174
174
  const t = this.shadowRoot?.querySelector(".tab-group__nav");
175
175
  if (!t || !this.tabs.length) return;
176
- const e = t.scrollLeft, s = t.clientWidth, o = e + s;
177
- for (let a of this.tabs)
178
- if (a.offsetLeft + a.offsetWidth > o) {
179
- const u = this.tabs[this.tabs.indexOf(a) - 1], p = u ? u.offsetLeft : 0;
176
+ const e = t.scrollLeft, a = t.clientWidth, r = e + a;
177
+ for (let s of this.tabs)
178
+ if (s.offsetLeft + s.offsetWidth > r) {
179
+ const u = this.tabs[this.tabs.indexOf(s) - 1], p = u ? u.offsetLeft : 0;
180
180
  t.scrollTo({
181
181
  left: p - this.buttonContainerWidth,
182
182
  behavior: "smooth"
@@ -190,12 +190,12 @@ let n = class extends w {
190
190
  scrollNavBackward() {
191
191
  const t = this.shadowRoot?.querySelector(".tab-group__nav");
192
192
  if (!t || !this.tabs.length) return;
193
- const e = t.clientWidth, s = t.scrollLeft;
194
- for (let o of this.tabs) {
195
- const a = o.offsetLeft, i = a + o.offsetWidth;
196
- if (a > s) {
193
+ const e = t.clientWidth, a = t.scrollLeft;
194
+ for (let r of this.tabs) {
195
+ const s = r.offsetLeft, o = s + r.offsetWidth;
196
+ if (s > a) {
197
197
  t.scrollTo({
198
- left: i - e + this.buttonContainerWidth,
198
+ left: o - e + this.buttonContainerWidth,
199
199
  behavior: "smooth"
200
200
  });
201
201
  return;
@@ -8,13 +8,13 @@ var v = Object.defineProperty, b = Object.getOwnPropertyDescriptor, l = (o, s, n
8
8
  };
9
9
  let f = 0, e = class extends d {
10
10
  constructor() {
11
- super(), this.testId = void 0, this.name = null, this.attrId = ++f, this.componentId = `nve-panel-${this.attrId}`, this.id = this.id.length > 0 ? this.id : this.componentId;
11
+ super(), this.testId = void 0, this.name = null, this.attrId = ++f, this.componentId = `nve-panel-${this.attrId}`;
12
12
  }
13
13
  connectedCallback() {
14
14
  super.connectedCallback(), this.setAttribute("role", "tabpanel"), this.name && this.setAttribute("name", this.name);
15
15
  }
16
16
  render() {
17
- return h`<div class="tab-panel" part="base">
17
+ return this.id = this.id.length > 0 ? this.id : this.componentId, h`<div class="tab-panel" part="base">
18
18
  <slot></slot>
19
19
  </div> `;
20
20
  }
@@ -5388,10 +5388,6 @@
5388
5388
  {
5389
5389
  "kind": "method",
5390
5390
  "name": "render"
5391
- },
5392
- {
5393
- "kind": "field",
5394
- "name": "id"
5395
5391
  }
5396
5392
  ],
5397
5393
  "attributes": [
@@ -5755,10 +5751,6 @@
5755
5751
  {
5756
5752
  "kind": "method",
5757
5753
  "name": "render"
5758
- },
5759
- {
5760
- "kind": "field",
5761
- "name": "id"
5762
5754
  }
5763
5755
  ],
5764
5756
  "attributes": [
@@ -7173,7 +7165,7 @@
7173
7165
  "package": {
7174
7166
  "name": "nve-designsystem",
7175
7167
  "description": "Designsystem for NVE",
7176
- "version": "2.9.1",
7168
+ "version": "2.10.0",
7177
7169
  "author": {
7178
7170
  "name": "NVE",
7179
7171
  "email": "nve@nve.no"
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "license": "MIT",
9
9
  "homepage": "https://github.com/NVE/Designsystem/",
10
- "version": "2.10.0",
10
+ "version": "2.10.1",
11
11
  "customElements": "custom-elements.json",
12
12
  "exports": {
13
13
  ".": {