nve-designsystem 3.1.0 → 3.3.0

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 (197) hide show
  1. package/chunks/chunk.2PCBEMQZ.js +163 -226
  2. package/chunks/chunk.36O46B5H.js +15 -15
  3. package/chunks/chunk.4TUIT776.js +78 -96
  4. package/chunks/chunk.5JY5FUCG.js +965 -1245
  5. package/chunks/chunk.5P45LHIX.js +668 -96
  6. package/chunks/chunk.6CTB5ZDJ.js +107 -100
  7. package/chunks/chunk.B4BZKR24.js +29 -39
  8. package/chunks/chunk.D5YQDJ7X.js +122 -166
  9. package/chunks/chunk.EA437WHD.js +5 -5
  10. package/chunks/chunk.GI7VDIWX.js +14 -15
  11. package/chunks/chunk.GMYPQTFK.js +18 -20
  12. package/chunks/chunk.HVTXQL7M.js +191 -215
  13. package/chunks/chunk.IKV4VH3T.js +18 -16
  14. package/chunks/chunk.IVVHNXMC.js +26 -27
  15. package/chunks/chunk.JHOXTQXA.js +65 -74
  16. package/chunks/chunk.JXOKFADN.js +63 -90
  17. package/chunks/chunk.K7JGTRV7.js +24 -23
  18. package/chunks/chunk.KPLQLAWP.js +132 -147
  19. package/chunks/chunk.LD4M4QGE.js +61 -74
  20. package/chunks/chunk.MSKEYBDI.js +53 -71
  21. package/chunks/chunk.NYIIDP5N.js +39 -45
  22. package/chunks/chunk.RWUUFNUL.js +91 -114
  23. package/chunks/chunk.SAPQLUO4.js +249 -228
  24. package/chunks/chunk.SI4ACBFK.js +139 -5
  25. package/chunks/chunk.TP2GB2HO.js +361 -460
  26. package/chunks/chunk.UDWRA64J.js +185 -223
  27. package/chunks/chunk.URTPIBTY.js +119 -151
  28. package/chunks/chunk.VESXC477.js +63 -66
  29. package/chunks/chunk.XA43ZQPC.js +198 -313
  30. package/chunks/chunk.XQ2OKYYA.js +25 -26
  31. package/chunks/chunk.XZNBUGX7.js +6 -6
  32. package/chunks/chunk.YHLNUJ7P.js +93 -116
  33. package/chunks/chunk.ZH2AND3P.js +340 -399
  34. package/chunks/chunk.ZL53POKZ.js +61 -156
  35. package/chunks/chunk.js +20 -0
  36. package/chunks/class-map.js +49 -45
  37. package/chunks/decorate.js +105 -0
  38. package/chunks/directive-helpers.js +5 -7
  39. package/chunks/if-defined.js +5 -5
  40. package/chunks/lit.js +525 -0
  41. package/chunks/live.js +24 -24
  42. package/chunks/nve-alert.component.js +163 -0
  43. package/chunks/nve-carousel-item.component.js +36 -0
  44. package/chunks/nve-carousel.component.js +41 -0
  45. package/chunks/nve-checkbox-group.component.js +114 -0
  46. package/chunks/nve-checkbox.component.js +28 -0
  47. package/chunks/nve-dialog.component.js +39 -0
  48. package/chunks/nve-divider.component.js +23 -0
  49. package/chunks/nve-drawer.component.js +40 -0
  50. package/chunks/nve-dropdown.component.js +83 -0
  51. package/chunks/nve-input.component.js +80 -0
  52. package/chunks/nve-label.component.js +89 -0
  53. package/chunks/nve-menu-item.component.js +35 -0
  54. package/chunks/nve-menu.component.js +17 -0
  55. package/chunks/nve-option.component.js +27 -0
  56. package/chunks/nve-popup.component.js +15 -0
  57. package/chunks/nve-radio-button.component.js +20 -0
  58. package/chunks/nve-radio-group.component.js +78 -0
  59. package/chunks/nve-radio.component.js +18 -0
  60. package/chunks/nve-select.component.js +58 -0
  61. package/chunks/nve-skeleton.component.js +20 -0
  62. package/chunks/nve-spinner.component.js +23 -0
  63. package/chunks/nve-tooltip.component.js +20 -0
  64. package/chunks/nve-warning-level.component.js +57 -0
  65. package/chunks/ref.js +75 -84
  66. package/chunks/shoelace.js +10006 -0
  67. package/chunks/static-html.js +27 -0
  68. package/chunks/unsafe-html.js +24 -20
  69. package/chunks/updateInvalidProperty.js +7 -7
  70. package/chunks/watch.js +20 -20
  71. package/components/nve-accordion/nve-accordion.component.js +24 -30
  72. package/components/nve-accordion-item/nve-accordion-item.component.js +30 -64
  73. package/components/nve-accordion-item/nve-accordion-item.styles.js +5 -5
  74. package/components/nve-alert/nve-alert.component.js +2 -227
  75. package/components/nve-alert/nve-alert.styles.js +45 -27
  76. package/components/nve-badge/nve-badge.component.js +41 -45
  77. package/components/nve-badge/nve-badge.styles.js +33 -31
  78. package/components/nve-button/nve-button.component.d.ts +110 -10
  79. package/components/nve-button/nve-button.component.js +146 -39
  80. package/components/nve-button/nve-button.styles.js +214 -157
  81. package/components/nve-carousel/nve-carousel.component.js +2 -47
  82. package/components/nve-carousel/nve-carousel.styles.js +6 -6
  83. package/components/nve-carousel-item/nve-carousel-item.component.js +2 -40
  84. package/components/nve-carousel-item/nve-carousel-item.styles.js +5 -5
  85. package/components/nve-carousel-thumbnail/nve-carousel-thumbnail.component.js +44 -54
  86. package/components/nve-carousel-thumbnail/nve-carousel-thumbnail.styles.js +5 -5
  87. package/components/nve-checkbox/nve-checkbox.component.js +2 -34
  88. package/components/nve-checkbox/nve-checkbox.styles.js +7 -7
  89. package/components/nve-checkbox-group/nve-checkbox-group.component.js +2 -152
  90. package/components/nve-checkbox-group/nve-checkbox-group.styles.js +5 -5
  91. package/components/nve-combobox/nve-combobox.component.js +222 -440
  92. package/components/nve-combobox/nve-combobox.styles.js +6 -6
  93. package/components/nve-darkmode-switch/nve-darkmode-switch.component.js +32 -38
  94. package/components/nve-dialog/nve-dialog-styles.js +6 -6
  95. package/components/nve-dialog/nve-dialog.component.js +2 -54
  96. package/components/nve-divider/nve-divider.component.js +2 -30
  97. package/components/nve-drawer/nve-drawer.component.js +2 -44
  98. package/components/nve-drawer/nve-drawer.styles.js +6 -6
  99. package/components/nve-dropdown/nve-dropdown.component.js +2 -79
  100. package/components/nve-dropdown/nve-dropdown.styles.js +5 -5
  101. package/components/nve-heading/nve-heading.component.d.ts +29 -0
  102. package/components/nve-heading/nve-heading.component.js +45 -0
  103. package/components/nve-heading/nve-heading.styles.d.ts +2 -0
  104. package/components/nve-heading/nve-heading.styles.js +41 -0
  105. package/components/nve-icon/nve-icon.component.js +145 -164
  106. package/components/nve-icon/nve-icon.styles.js +11 -6
  107. package/components/nve-icon/offline-icons.js +16 -13
  108. package/components/nve-input/nve-input.component.js +2 -100
  109. package/components/nve-input/nve-input.styles.js +5 -5
  110. package/components/nve-label/nve-label.component.js +2 -115
  111. package/components/nve-label/nve-label.styles.js +5 -5
  112. package/components/nve-link-card/nve-link-card.component.d.ts +5 -2
  113. package/components/nve-link-card/nve-link-card.component.js +44 -80
  114. package/components/nve-link-card/nve-link-card.styles.js +71 -66
  115. package/components/nve-menu/nve-menu.component.js +2 -22
  116. package/components/nve-menu/nve-menu.styles.js +5 -5
  117. package/components/nve-menu-item/nve-menu-item.component.js +2 -43
  118. package/components/nve-menu-item/nve-menu-item.styles.js +7 -7
  119. package/components/nve-message-card/nve-message-card.component.js +61 -91
  120. package/components/nve-message-card/nve-message-card.styles.js +24 -27
  121. package/components/nve-navigation-card/nve-navigation-card.component.d.ts +52 -0
  122. package/components/nve-navigation-card/nve-navigation-card.component.js +60 -0
  123. package/components/nve-navigation-card/nve-navigation-card.styles.d.ts +2 -0
  124. package/components/nve-navigation-card/nve-navigation-card.styles.js +112 -0
  125. package/components/nve-option/nve-option.component.js +2 -41
  126. package/components/nve-option/nve-option.styles.js +5 -5
  127. package/components/nve-paragraph/nve-paragraph.component.d.ts +26 -0
  128. package/components/nve-paragraph/nve-paragraph.component.js +26 -0
  129. package/components/nve-paragraph/nve-paragraph.styles.d.ts +2 -0
  130. package/components/nve-paragraph/nve-paragraph.styles.js +105 -0
  131. package/components/nve-popup/nve-popup.component.js +2 -22
  132. package/components/nve-radio/nve-radio.component.js +2 -23
  133. package/components/nve-radio/nve-radio.styles.js +5 -5
  134. package/components/nve-radio-button/nve-radio-button.component.js +2 -25
  135. package/components/nve-radio-button/nve-radio-button.styles.js +5 -5
  136. package/components/nve-radio-group/nve-radio-group.component.js +2 -119
  137. package/components/nve-radio-group/nve-radio-group.styles.js +5 -5
  138. package/components/nve-relative-time/nve-relative-time.component.js +21 -56
  139. package/components/nve-relative-time/nve-relative-time.styles.js +5 -5
  140. package/components/nve-select/nve-select.component.js +2 -80
  141. package/components/nve-select/nve-select.styles.js +6 -6
  142. package/components/nve-skeleton/nve-skeleton.component.js +2 -27
  143. package/components/nve-skeleton/nve-skeleton.styles.js +5 -5
  144. package/components/nve-spinner/nve-spinner.component.js +2 -31
  145. package/components/nve-stepper/nve-step/nve-step.component.js +113 -173
  146. package/components/nve-stepper/nve-step/nve-step.styles.js +12 -12
  147. package/components/nve-stepper/nve-stepper-mobile.component.js +37 -49
  148. package/components/nve-stepper/nve-stepper-mobile.styles.js +7 -7
  149. package/components/nve-stepper/nve-stepper.component.js +94 -139
  150. package/components/nve-stepper/nve-stepper.styles.js +5 -5
  151. package/components/nve-switch/nve-switch.component.js +75 -107
  152. package/components/nve-switch/nve-switch.styles.js +7 -7
  153. package/components/nve-tab/nve-tab.component.js +30 -42
  154. package/components/nve-tab/nve-tab.styles.js +7 -7
  155. package/components/nve-tab-group/nve-tab-group.component.js +180 -260
  156. package/components/nve-tab-group/nve-tab-group.styles.js +5 -5
  157. package/components/nve-tab-panel/nve-tab-panel.component.js +21 -31
  158. package/components/nve-tab-panel/nve-tab-panel.styles.js +5 -5
  159. package/components/nve-tag/nve-tag.component.d.ts +3 -3
  160. package/components/nve-tag/nve-tag.component.js +71 -72
  161. package/components/nve-tag/nve-tag.styles.js +23 -22
  162. package/components/nve-textarea/nve-textarea.component.d.ts +3 -1
  163. package/components/nve-textarea/nve-textarea.component.js +112 -173
  164. package/components/nve-textarea/nve-textarea.styles.js +10 -5
  165. package/components/nve-tooltip/nve-tooltip.component.js +2 -30
  166. package/components/nve-tooltip/nve-tooltip.styles.js +5 -5
  167. package/components/nve-warning-level/nve-warning-level.component.js +2 -78
  168. package/components/nve-warning-level/nve-warning-level.styles.js +7 -7
  169. package/css/global.css +13 -55
  170. package/css/nve.css +1048 -393
  171. package/css/nve_dark.css +406 -305
  172. package/css/rme.css +1050 -395
  173. package/css/rme_dark.css +408 -307
  174. package/css/shoelace-styles.css +539 -0
  175. package/css/varsom.css +1046 -391
  176. package/css/varsom_dark.css +404 -303
  177. package/custom-elements.json +2905 -12389
  178. package/fonts/LICENSE.txt +37 -0
  179. package/fonts/SourceSans3-VariableFont_wght.woff2 +0 -0
  180. package/interfaces/NveComponent.interface.js +0 -1
  181. package/nve-designsystem.d.ts +5 -0
  182. package/nve-designsystem.js +46 -86
  183. package/package.json +26 -8
  184. package/registerIcons/systemLibraryCustomization.js +23 -91
  185. package/vite-env.d.js +0 -1
  186. package/chunks/chunk.3RPBFEDE.js +0 -162
  187. package/chunks/chunk.JCXLDPQF.js +0 -225
  188. package/chunks/chunk.JQBT7BOV.js +0 -8446
  189. package/chunks/chunk.MAQXLKQ7.js +0 -598
  190. package/chunks/lit-element.js +0 -508
  191. package/chunks/property.js +0 -37
  192. package/chunks/query.js +0 -13
  193. package/chunks/state.js +0 -7
  194. package/chunks/static.js +0 -26
  195. package/nve-designsystem.css +0 -1
  196. package/vscode.css-custom-data.json +0 -621
  197. package/vscode.html-custom-data.json +0 -2354
@@ -1,292 +1,212 @@
1
- import { a as w, E as f, x as u } from "../../chunks/lit-element.js";
2
- import { n as d, t as g } from "../../chunks/property.js";
3
- import { r as b } from "../../chunks/state.js";
4
- import m from "./nve-tab-group.styles.js";
5
- import y from "../nve-tab/nve-tab.component.js";
1
+ import { a as e, n as t, t as n } from "../../chunks/lit.js";
2
+ import { a as r, o as i, s as a, t as o } from "../../chunks/decorate.js";
3
+ import { t as s } from "../../chunks/class-map.js";
4
+ import { t as c } from "../../chunks/if-defined.js";
6
5
  import "../nve-icon/nve-icon.component.js";
7
6
  import "../nve-button/nve-button.component.js";
8
- import { e as v } from "../../chunks/class-map.js";
9
- import { o as k } from "../../chunks/if-defined.js";
10
- var S = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, c = (t, e, o, a) => {
11
- for (var s = a > 1 ? void 0 : a ? _(e, o) : e, i = t.length - 1, r; i >= 0; i--)
12
- (r = t[i]) && (s = (a ? r(e, o, s) : r(s)) || s);
13
- return a && s && S(e, o, s), s;
14
- };
15
- let n = class extends w {
16
- constructor() {
17
- super(), this.testId = void 0, this.background = !1, this.size = "large", this.activeTab = null, this.isOverflow = !1, this.canScrollBack = !1, this.canScrollForward = !1, this.isBackground = !1, this.tabs = [], this.panels = [], this.buttonContainerWidth = 40;
18
- }
19
- firstUpdated() {
20
- this.syncTabsAndPanels();
21
- const t = this.shadowRoot?.querySelector(".tab-group__nav");
22
- t && this.resizeObserver && (this.resizeObserver.observe(t), t.addEventListener("scroll", () => this.updateScrollState()));
23
- }
24
- async updated(t) {
25
- super.updated?.(t), (t.has("canScrollBack") || t.has("isOverflow")) && await this.removeTabIndexFromBackwardScrollButton(), (t.has("canScrollForward") || t.has("isOverflow")) && await this.removeTabIndexFromForwardScrollButton();
26
- }
27
- connectedCallback() {
28
- super.connectedCallback(), this.style.setProperty("--button-container-width", `${this.buttonContainerWidth}px`), this.setAttribute("role", "tablist"), this.resizeObserver = new ResizeObserver(() => this.checkOverflow()), this.addEventListener("click", this.handleClick), this.addEventListener("keydown", this.handleKeyDown);
29
- }
30
- disconnectedCallback() {
31
- super.disconnectedCallback(), this.resizeObserver?.disconnect();
32
- const t = this.shadowRoot?.querySelector(".tab-group__nav");
33
- t && t.removeEventListener("scroll", () => this.updateScrollState()), this.removeEventListener("click", this.handleClick), this.removeEventListener("keydown", this.handleKeyDown);
34
- }
35
- /**
36
- * @internal
37
- * Håndterer klikk på faner i tab gruppen.
38
- * Setter aktiv fane basert på klikket element.
39
- * @param event Klikkeventet.
40
- */
41
- handleClick(t) {
42
- const e = t.composedPath(), o = e.find(
43
- (s) => s instanceof HTMLElement && s.tagName.toLowerCase() === "nve-tab"
44
- );
45
- e.find(
46
- (s) => s instanceof HTMLElement && s.tagName.toLowerCase() === "nve-tab-group"
47
- ) === this && (o instanceof y && o.disabled || o && o.panel && this.setActiveTab(o.panel));
48
- }
49
- /**
50
- * @internal
51
- * Håndterer tastetrykk på faner i tab gruppen.
52
- * Setter aktiv fane basert på tastetrykket.
53
- * @param event Tastetrykk eventet.
54
- */
55
- handleKeyDown(t) {
56
- const e = t.composedPath(), o = e.find((s) => s instanceof HTMLElement && s.closest && s.closest("nve-tab") === s) || null;
57
- if (e.find(
58
- (s) => s instanceof HTMLElement && s.tagName.toLowerCase() === "nve-tab-group"
59
- ) === this && (["Enter", " "].includes(t.key) && o && o.panel && (this.setActiveTab(o.panel), t.preventDefault()), ["ArrowLeft", "ArrowRight", "Home", "End"].includes(t.key))) {
60
- const s = this.tabs.find((l) => l === o);
61
- if (!s) return;
62
- let i;
63
- const r = this.tabs.filter((l) => !l.disabled), h = r.indexOf(s);
64
- t.key === "ArrowLeft" && (i = h > 0 ? r[h - 1] : r[r.length - 1]), t.key === "ArrowRight" && (i = h < r.length - 1 ? r[h + 1] : r[0]), t.key === "Home" && (i = r[0]), t.key === "End" && (i = r[r.length - 1]), i && (i.focus(), t.preventDefault());
65
- }
66
- }
67
- /**
68
- * Henter alle paneler i tab gruppen.
69
- * @returns En liste over alle paneler i tab gruppen.
70
- */
71
- getPanels() {
72
- const t = this.shadowRoot?.querySelector("slot:not([name])");
73
- return t ? t.assignedElements({ flatten: !0 }).filter((o) => o.tagName.toLowerCase() === "nve-tab-panel") : [];
74
- }
75
- /**
76
- * Henter alle faner i tab gruppen.
77
- * @returns En liste over alle faner i tab gruppen.
78
- */
79
- getTabs() {
80
- const t = this.shadowRoot?.querySelector('slot[name="nav"]');
81
- return t ? t.assignedElements({ flatten: !0 }).filter((o) => o.tagName.toLowerCase() === "nve-tab") : [];
82
- }
83
- /** Setter aria-selected og tabindex på fanene. Kun aktiv fane skal bli fokusert. Gjemmer inaktive paneller.
84
- * Sender en nve-tab-change event med navnet på den aktive fanen.
85
- * @param panelName Navnet panelet som skal aktiveres.
86
- */
87
- setActiveTab(t) {
88
- this.tabs.forEach((e) => e.setAttribute("aria-selected", `${e.panel === t}`)), this.tabs.forEach((e) => e.setAttribute("tabindex", e.panel === t ? "0" : "-1")), this.panels.forEach((e) => e.classList.toggle("tab-panel--hidden", e.name !== t)), this.activeTab = t, requestAnimationFrame(() => {
89
- this.updateIndicator();
90
- }), requestAnimationFrame(() => {
91
- const e = this.tabs.find((o) => o.getAttribute("aria-selected") === "true");
92
- if (e) {
93
- const o = this.shadowRoot?.querySelector(".tab-group__nav");
94
- if (o) {
95
- const a = e.offsetLeft, s = e.offsetLeft + e.offsetWidth;
96
- a < o.scrollLeft ? o.scrollTo({ left: a, behavior: "smooth" }) : s > o.scrollLeft + o.clientWidth && o.scrollTo({ left: a, behavior: "smooth" });
97
- }
98
- }
99
- }), this.dispatchEvent(
100
- new CustomEvent("nve-tab-change", {
101
- detail: t,
102
- bubbles: !0,
103
- composed: !0
104
- })
105
- );
106
- }
107
- updateIndicator() {
108
- if (this.isBackground) return;
109
- const t = this.shadowRoot?.querySelector(".tab-group__nav"), e = this.tabs.find((o) => o.getAttribute("aria-selected") === "true");
110
- if (t && e) {
111
- const o = t.getBoundingClientRect(), s = e.getBoundingClientRect().left - o.left + t.scrollLeft, i = e.offsetWidth;
112
- t.style.setProperty("--indicator-x", `${s}px`), t.style.setProperty("--indicator-width", `${i}px`);
113
- }
114
- }
115
- /**
116
- * Setter aria-controls og aria-labelledby attributter på faner og paneler.
117
- * Dette er viktig for tilgjengelighet slik at skjermlesere kan forstå sammenhengen mellom faner og deres tilhørende paneler.
118
- */
119
- setAriaLabels() {
120
- this.tabs.forEach((t) => {
121
- const e = this.panels.find((o) => o.name === t.panel);
122
- e && (t.setAttribute("aria-controls", e.id), e.setAttribute("aria-labelledby", t.id));
123
- });
124
- }
125
- /**
126
- * Oppdaterer faner og paneler i tab gruppen.
127
- * Kalles når komponenten oppdateres eller når faner/paneler endres.
128
- */
129
- async syncTabsAndPanels() {
130
- if (await customElements.whenDefined("nve-tab"), await customElements.whenDefined("nve-tab-panel"), this.tabs = this.getTabs(), this.panels = this.getPanels(), this.setAriaLabels(), this.tabs.forEach((t) => {
131
- t.background = t.background ? t.background : this.background;
132
- }), this.isBackground = this.tabs.some((t) => t.background) || this.background, this.tabs.forEach((t) => {
133
- t.size = this.size;
134
- }), this.activeTab)
135
- this.setActiveTab(this.activeTab);
136
- else {
137
- const t = this.tabs.length > 0 ? this.tabs[0].panel : null;
138
- t && this.setActiveTab(t);
139
- }
140
- }
141
- /**
142
- * Fjerner tabindex fra fremover scroll-knappen.
143
- */
144
- async removeTabIndexFromForwardScrollButton() {
145
- const e = this.shadowRoot?.querySelector(".tab-group__nav-button--forward")?.querySelector("nve-button");
146
- if (e) {
147
- await e.updateComplete;
148
- const o = e.shadowRoot?.querySelector('[part="base"]');
149
- o && o.setAttribute("tabindex", "-1");
150
- }
151
- }
152
- /**
153
- * Fjerner tabindex fra bakover scroll-knappen.
154
- */
155
- async removeTabIndexFromBackwardScrollButton() {
156
- const e = this.shadowRoot?.querySelector(".tab-group__nav-button--backward")?.querySelector("nve-button");
157
- if (e) {
158
- await e.updateComplete;
159
- const o = e.shadowRoot?.querySelector('[part="base"]');
160
- o && o.setAttribute("tabindex", "-1");
161
- }
162
- }
163
- /**
164
- * Sjekker om tab gruppen har overflow og oppdaterer tilstanden for scroll knappene.
165
- * Kalles ved endring av størrelse på tab gruppen.
166
- */
167
- checkOverflow() {
168
- const t = this.shadowRoot?.querySelector(".tab-group__nav");
169
- if (!t) return;
170
- const e = t.scrollWidth > t.clientWidth;
171
- this.isOverflow = e, this.updateScrollState();
172
- }
173
- /**
174
- * Oppdaterer tilstanden for scroll knappene basert på gjeldende scroll posisjon.
175
- * Kalles når brukeren scroller i tab gruppen.
176
- */
177
- updateScrollState() {
178
- const t = this.shadowRoot?.querySelector(".tab-group__nav");
179
- t && (this.canScrollBack = t.scrollLeft > 0, this.canScrollForward = t.scrollLeft + t.clientWidth + 5 < t.scrollWidth);
180
- }
181
- /**
182
- * Ruller navigasjonslisten fremover. Flytter den siste fanen som er full synlig (den blir den første nå).
183
- */
184
- scrollNavForward() {
185
- const t = this.shadowRoot?.querySelector(".tab-group__nav");
186
- if (!t || !this.tabs.length) return;
187
- const e = t.scrollLeft, o = t.clientWidth, a = e + o;
188
- for (let s of this.tabs)
189
- if (s.offsetLeft + s.offsetWidth > a) {
190
- const l = this.tabs[this.tabs.indexOf(s) - 1], p = l ? l.offsetLeft : 0;
191
- t.scrollTo({
192
- left: p - this.buttonContainerWidth,
193
- behavior: "smooth"
194
- });
195
- return;
196
- }
197
- }
198
- /**
199
- * Ruller navigasjonslisten bakover. Flytter den første fanen som er full synlig (den blir den første nå).
200
- */
201
- scrollNavBackward() {
202
- const t = this.shadowRoot?.querySelector(".tab-group__nav");
203
- if (!t || !this.tabs.length) return;
204
- const e = t.clientWidth, o = t.scrollLeft;
205
- for (let a of this.tabs) {
206
- const s = a.offsetLeft, i = s + a.offsetWidth;
207
- if (s > o) {
208
- t.scrollTo({
209
- left: i - e + this.buttonContainerWidth,
210
- behavior: "smooth"
211
- });
212
- return;
213
- }
214
- }
215
- }
216
- render() {
217
- return u`
7
+ import l from "../nve-tab/nve-tab.component.js";
8
+ import u from "./nve-tab-group.styles.js";
9
+ //#region src/components/nve-tab-group/nve-tab-group.component.ts
10
+ var d = class extends n {
11
+ static {
12
+ this.styles = [u];
13
+ }
14
+ firstUpdated() {
15
+ this.syncTabsAndPanels();
16
+ let e = this.shadowRoot?.querySelector(".tab-group__nav");
17
+ e && this.resizeObserver && (this.resizeObserver.observe(e), e.addEventListener("scroll", () => this.updateScrollState()));
18
+ }
19
+ async updated(e) {
20
+ super.updated?.(e), (e.has("canScrollBack") || e.has("isOverflow")) && await this.removeTabIndexFromBackwardScrollButton(), (e.has("canScrollForward") || e.has("isOverflow")) && await this.removeTabIndexFromForwardScrollButton();
21
+ }
22
+ connectedCallback() {
23
+ super.connectedCallback(), this.style.setProperty("--button-container-width", `${this.buttonContainerWidth}px`), this.setAttribute("role", "tablist"), this.resizeObserver = new ResizeObserver(() => this.checkOverflow()), this.addEventListener("click", this.handleClick), this.addEventListener("keydown", this.handleKeyDown);
24
+ }
25
+ disconnectedCallback() {
26
+ super.disconnectedCallback(), this.resizeObserver?.disconnect();
27
+ let e = this.shadowRoot?.querySelector(".tab-group__nav");
28
+ e && e.removeEventListener("scroll", () => this.updateScrollState()), this.removeEventListener("click", this.handleClick), this.removeEventListener("keydown", this.handleKeyDown);
29
+ }
30
+ constructor() {
31
+ super(), this.testId = void 0, this.background = !1, this.size = "large", this.activeTab = null, this.isOverflow = !1, this.canScrollBack = !1, this.canScrollForward = !1, this.isBackground = !1, this.tabs = [], this.panels = [], this.buttonContainerWidth = 40;
32
+ }
33
+ handleClick(e) {
34
+ let t = e.composedPath(), n = t.find((e) => e instanceof HTMLElement && e.tagName.toLowerCase() === "nve-tab");
35
+ t.find((e) => e instanceof HTMLElement && e.tagName.toLowerCase() === "nve-tab-group") === this && (n instanceof l && n.disabled || n && n.panel && this.setActiveTab(n.panel));
36
+ }
37
+ handleKeyDown(e) {
38
+ let t = e.composedPath(), n = t.find((e) => e instanceof HTMLElement && e.closest && e.closest("nve-tab") === e) || null;
39
+ if (t.find((e) => e instanceof HTMLElement && e.tagName.toLowerCase() === "nve-tab-group") === this && (["Enter", " "].includes(e.key) && n && n.panel && (this.setActiveTab(n.panel), e.preventDefault()), [
40
+ "ArrowLeft",
41
+ "ArrowRight",
42
+ "Home",
43
+ "End"
44
+ ].includes(e.key))) {
45
+ let t = this.tabs.find((e) => e === n);
46
+ if (!t) return;
47
+ let r, i = this.tabs.filter((e) => !e.disabled), a = i.indexOf(t);
48
+ e.key === "ArrowLeft" && (r = a > 0 ? i[a - 1] : i[i.length - 1]), e.key === "ArrowRight" && (r = a < i.length - 1 ? i[a + 1] : i[0]), e.key === "Home" && (r = i[0]), e.key === "End" && (r = i[i.length - 1]), r && (r.focus(), e.preventDefault());
49
+ }
50
+ }
51
+ getPanels() {
52
+ let e = this.shadowRoot?.querySelector("slot:not([name])");
53
+ return e ? e.assignedElements({ flatten: !0 }).filter((e) => e.tagName.toLowerCase() === "nve-tab-panel") : [];
54
+ }
55
+ getTabs() {
56
+ let e = this.shadowRoot?.querySelector("slot[name=\"nav\"]");
57
+ return e ? e.assignedElements({ flatten: !0 }).filter((e) => e.tagName.toLowerCase() === "nve-tab") : [];
58
+ }
59
+ setActiveTab(e) {
60
+ this.tabs.forEach((t) => t.setAttribute("aria-selected", `${t.panel === e}`)), this.tabs.forEach((t) => t.setAttribute("tabindex", t.panel === e ? "0" : "-1")), this.panels.forEach((t) => t.classList.toggle("tab-panel--hidden", t.name !== e)), this.activeTab = e, requestAnimationFrame(() => {
61
+ this.updateIndicator();
62
+ }), requestAnimationFrame(() => {
63
+ let e = this.tabs.find((e) => e.getAttribute("aria-selected") === "true");
64
+ if (e) {
65
+ let t = this.shadowRoot?.querySelector(".tab-group__nav");
66
+ if (t) {
67
+ let n = e.offsetLeft, r = e.offsetLeft + e.offsetWidth;
68
+ (n < t.scrollLeft || r > t.scrollLeft + t.clientWidth) && t.scrollTo({
69
+ left: n,
70
+ behavior: "smooth"
71
+ });
72
+ }
73
+ }
74
+ }), this.dispatchEvent(new CustomEvent("nve-tab-change", {
75
+ detail: e,
76
+ bubbles: !0,
77
+ composed: !0
78
+ }));
79
+ }
80
+ updateIndicator() {
81
+ if (this.isBackground) return;
82
+ let e = this.shadowRoot?.querySelector(".tab-group__nav"), t = this.tabs.find((e) => e.getAttribute("aria-selected") === "true");
83
+ if (e && t) {
84
+ let n = e.getBoundingClientRect(), r = t.getBoundingClientRect().left - n.left + e.scrollLeft, i = t.offsetWidth;
85
+ e.style.setProperty("--indicator-x", `${r}px`), e.style.setProperty("--indicator-width", `${i}px`);
86
+ }
87
+ }
88
+ setAriaLabels() {
89
+ this.tabs.forEach((e) => {
90
+ let t = this.panels.find((t) => t.name === e.panel);
91
+ t && (e.setAttribute("aria-controls", t.id), t.setAttribute("aria-labelledby", e.id));
92
+ });
93
+ }
94
+ async syncTabsAndPanels() {
95
+ if (await customElements.whenDefined("nve-tab"), await customElements.whenDefined("nve-tab-panel"), this.tabs = this.getTabs(), this.panels = this.getPanels(), this.setAriaLabels(), this.tabs.forEach((e) => {
96
+ e.background = e.background ? e.background : this.background;
97
+ }), this.isBackground = this.tabs.some((e) => e.background) || this.background, this.tabs.forEach((e) => {
98
+ e.size = this.size;
99
+ }), this.activeTab) this.setActiveTab(this.activeTab);
100
+ else {
101
+ let e = this.tabs.length > 0 ? this.tabs[0].panel : null;
102
+ e && this.setActiveTab(e);
103
+ }
104
+ }
105
+ async removeTabIndexFromForwardScrollButton() {
106
+ let e = (this.shadowRoot?.querySelector(".tab-group__nav-button--forward"))?.querySelector("nve-button");
107
+ if (e) {
108
+ await e.updateComplete;
109
+ let t = e.shadowRoot?.querySelector("[part=\"base\"]");
110
+ t && t.setAttribute("tabindex", "-1");
111
+ }
112
+ }
113
+ async removeTabIndexFromBackwardScrollButton() {
114
+ let e = (this.shadowRoot?.querySelector(".tab-group__nav-button--backward"))?.querySelector("nve-button");
115
+ if (e) {
116
+ await e.updateComplete;
117
+ let t = e.shadowRoot?.querySelector("[part=\"base\"]");
118
+ t && t.setAttribute("tabindex", "-1");
119
+ }
120
+ }
121
+ checkOverflow() {
122
+ let e = this.shadowRoot?.querySelector(".tab-group__nav");
123
+ if (!e) return;
124
+ let t = e.scrollWidth > e.clientWidth;
125
+ this.isOverflow = t, this.updateScrollState();
126
+ }
127
+ updateScrollState() {
128
+ let e = this.shadowRoot?.querySelector(".tab-group__nav");
129
+ e && (this.canScrollBack = e.scrollLeft > 0, this.canScrollForward = e.scrollLeft + e.clientWidth + 5 < e.scrollWidth);
130
+ }
131
+ scrollNavForward() {
132
+ let e = this.shadowRoot?.querySelector(".tab-group__nav");
133
+ if (!e || !this.tabs.length) return;
134
+ let t = e.scrollLeft + e.clientWidth;
135
+ for (let n of this.tabs) if (n.offsetLeft + n.offsetWidth > t) {
136
+ let t = this.tabs[this.tabs.indexOf(n) - 1], r = t ? t.offsetLeft : 0;
137
+ e.scrollTo({
138
+ left: r - this.buttonContainerWidth,
139
+ behavior: "smooth"
140
+ });
141
+ return;
142
+ }
143
+ }
144
+ scrollNavBackward() {
145
+ let e = this.shadowRoot?.querySelector(".tab-group__nav");
146
+ if (!e || !this.tabs.length) return;
147
+ let t = e.clientWidth, n = e.scrollLeft;
148
+ for (let r of this.tabs) {
149
+ let i = r.offsetLeft, a = i + r.offsetWidth;
150
+ if (i > n) {
151
+ e.scrollTo({
152
+ left: a - t + this.buttonContainerWidth,
153
+ behavior: "smooth"
154
+ });
155
+ return;
156
+ }
157
+ }
158
+ }
159
+ render() {
160
+ return e`
218
161
  <div
219
162
  part="base"
220
163
  class="tab-group"
221
164
  @click=${this.handleClick}
222
165
  @keydown=${this.handleKeyDown}
223
- testId=${k(this.testId)}
166
+ testId=${c(this.testId)}
224
167
  >
225
168
  <div class="tab-group__nav-container">
226
169
  <div
227
170
  part="nav"
228
- class=${v({ "tab-group__nav": !0, "tab-group__nav--background": this.isBackground })}
171
+ class=${s({
172
+ "tab-group__nav": !0,
173
+ "tab-group__nav--background": this.isBackground
174
+ })}
229
175
  >
230
176
  <slot name="nav"></slot>
231
177
  </div>
232
- ${this.canScrollBack && this.isOverflow ? u`
178
+ ${this.canScrollBack && this.isOverflow ? e`
233
179
  <div
234
180
  aria-hidden="true"
235
181
  part="button-backward-base"
236
182
  class="tab-group__nav-button tab-group__nav-button--backward"
237
183
  >
238
- <nve-button @click=${this.scrollNavBackward} variant="text">
184
+ <nve-button @click=${this.scrollNavBackward} variant="ghost">
239
185
  <nve-icon name="chevron_backward"></nve-icon>
240
186
  </nve-button>
241
187
  </div>
242
- ` : f}
243
- ${this.canScrollForward && this.isOverflow ? u`
188
+ ` : t}
189
+ ${this.canScrollForward && this.isOverflow ? e`
244
190
  <div
245
191
  part="button-forward-base"
246
192
  aria-hidden="true"
247
- class=${v({
248
- "tab-group__nav-button tab-group__nav-button--forward": !0
249
- })}
193
+ class=${s({ "tab-group__nav-button tab-group__nav-button--forward": !0 })}
250
194
  >
251
- <nve-button variant="text" @click=${this.scrollNavForward}
252
- ><nve-icon name="chevron_forward"></nve-icon
253
- ></nve-button>
195
+ <nve-button variant="ghost" @click=${this.scrollNavForward}>
196
+ <nve-icon name="chevron_forward"></nve-icon>
197
+ </nve-button>
254
198
  </div>
255
- ` : f}
199
+ ` : t}
256
200
  </div>
257
201
  <slot part="body"></slot>
258
202
  </div>
259
203
  `;
260
- }
261
- };
262
- n.styles = [m];
263
- c([
264
- d({ type: String })
265
- ], n.prototype, "testId", 2);
266
- c([
267
- d({ type: Boolean })
268
- ], n.prototype, "background", 2);
269
- c([
270
- d({ type: String })
271
- ], n.prototype, "size", 2);
272
- c([
273
- d({ type: String, reflect: !0 })
274
- ], n.prototype, "activeTab", 2);
275
- c([
276
- b()
277
- ], n.prototype, "isOverflow", 2);
278
- c([
279
- b()
280
- ], n.prototype, "canScrollBack", 2);
281
- c([
282
- b()
283
- ], n.prototype, "canScrollForward", 2);
284
- c([
285
- b()
286
- ], n.prototype, "isBackground", 2);
287
- n = c([
288
- g("nve-tab-group")
289
- ], n);
290
- export {
291
- n as default
204
+ }
292
205
  };
206
+ o([i({ type: String })], d.prototype, "testId", void 0), o([i({ type: Boolean })], d.prototype, "background", void 0), o([i({ type: String })], d.prototype, "size", void 0), o([i({
207
+ type: String,
208
+ reflect: !0
209
+ })], d.prototype, "activeTab", void 0), o([r()], d.prototype, "isOverflow", void 0), o([r()], d.prototype, "canScrollBack", void 0), o([r()], d.prototype, "canScrollForward", void 0), o([r()], d.prototype, "isBackground", void 0), d = o([a("nve-tab-group")], d);
210
+ var f = d;
211
+ //#endregion
212
+ export { f as default };
@@ -1,5 +1,6 @@
1
- import { i as t } from "../../chunks/lit-element.js";
2
- const o = t`
1
+ import { u as e } from "../../chunks/lit.js";
2
+ //#region src/components/nve-tab-group/nve-tab-group.styles.ts
3
+ var t = e`
3
4
  .tab-group__nav-container {
4
5
  display: flex;
5
6
  position: relative;
@@ -70,6 +71,5 @@ const o = t`
70
71
  left: 0;
71
72
  }
72
73
  `;
73
- export {
74
- o as default
75
- };
74
+ //#endregion
75
+ export { t as default };
@@ -1,34 +1,24 @@
1
- import { a as d, x as h } from "../../chunks/lit-element.js";
2
- import { n as p, t as c } from "../../chunks/property.js";
3
- import m from "./nve-tab-panel.styles.js";
4
- var v = Object.defineProperty, b = Object.getOwnPropertyDescriptor, l = (o, s, n, r) => {
5
- for (var t = r > 1 ? void 0 : r ? b(s, n) : s, a = o.length - 1, i; a >= 0; a--)
6
- (i = o[a]) && (t = (r ? i(s, n, t) : i(t)) || t);
7
- return r && t && v(s, n, t), t;
8
- };
9
- let f = 0, e = class extends d {
10
- constructor() {
11
- super(), this.testId = void 0, this.name = null, this.attrId = ++f, this.componentId = `nve-panel-${this.attrId}`;
12
- }
13
- connectedCallback() {
14
- super.connectedCallback(), this.setAttribute("role", "tabpanel"), this.name && this.setAttribute("name", this.name);
15
- }
16
- render() {
17
- return this.id = this.id.length > 0 ? this.id : this.componentId, h`<div class="tab-panel" part="base">
1
+ import { a as e, t } from "../../chunks/lit.js";
2
+ import { o as n, s as r, t as i } from "../../chunks/decorate.js";
3
+ import a from "./nve-tab-panel.styles.js";
4
+ //#region src/components/nve-tab-panel/nve-tab-panel.component.ts
5
+ var o = 0, s = class extends t {
6
+ static {
7
+ this.styles = [a];
8
+ }
9
+ connectedCallback() {
10
+ super.connectedCallback(), this.setAttribute("role", "tabpanel"), this.name && this.setAttribute("name", this.name);
11
+ }
12
+ constructor() {
13
+ super(), this.testId = void 0, this.name = null, this.attrId = ++o, this.componentId = `nve-panel-${this.attrId}`;
14
+ }
15
+ render() {
16
+ return this.id = this.id.length > 0 ? this.id : this.componentId, e`<div class="tab-panel" part="base">
18
17
  <slot></slot>
19
18
  </div> `;
20
- }
21
- };
22
- e.styles = [m];
23
- l([
24
- p({ type: String })
25
- ], e.prototype, "testId", 2);
26
- l([
27
- p({ type: String })
28
- ], e.prototype, "name", 2);
29
- e = l([
30
- c("nve-tab-panel")
31
- ], e);
32
- export {
33
- e as default
19
+ }
34
20
  };
21
+ i([n({ type: String })], s.prototype, "testId", void 0), i([n({ type: String })], s.prototype, "name", void 0), s = i([r("nve-tab-panel")], s);
22
+ var c = s;
23
+ //#endregion
24
+ export { c as default };
@@ -1,5 +1,6 @@
1
- import { i as a } from "../../chunks/lit-element.js";
2
- const r = a`
1
+ import { u as e } from "../../chunks/lit.js";
2
+ //#region src/components/nve-tab-panel/nve-tab-panel.styles.ts
3
+ var t = e`
3
4
  :host(.tab-panel--hidden) {
4
5
  display: none;
5
6
  }
@@ -13,6 +14,5 @@ const r = a`
13
14
  padding: var(--spacing-small);
14
15
  }
15
16
  `;
16
- export {
17
- r as default
18
- };
17
+ //#endregion
18
+ export { t as default };
@@ -27,13 +27,13 @@ export default class NveTag extends LitElement {
27
27
  /** Størrelse på komponenten */
28
28
  size: 'small' | 'medium';
29
29
  /** Ekstra tekst */
30
- 'extra-text': string;
30
+ extraText: string;
31
31
  /** Viser dot-ikon i prefix */
32
32
  dot: boolean;
33
33
  /** Viser lukke-knapp */
34
- 'closeable': boolean;
34
+ closeable: boolean;
35
35
  /** aria-label på lukke-knapp */
36
- 'close-aria-label': string;
36
+ closeAriaLabel: string;
37
37
  private closeButtonClick;
38
38
  render(): import('lit-html').TemplateResult<1>;
39
39
  }