@vonage/vivid 4.5.0 → 4.6.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 (170) hide show
  1. package/custom-elements.json +1091 -187
  2. package/elevation/index.cjs +1 -1
  3. package/elevation/index.js +1 -1
  4. package/index.cjs +62 -56
  5. package/index.js +20 -19
  6. package/lib/components.d.ts +1 -0
  7. package/lib/menu/menu.d.ts +2 -1
  8. package/lib/number-field/number-field.d.ts +3 -1
  9. package/lib/searchable-select/definition.d.ts +4 -0
  10. package/lib/searchable-select/locale.d.ts +6 -0
  11. package/lib/searchable-select/option-tag.d.ts +14 -0
  12. package/lib/searchable-select/option-tag.template.d.ts +4 -0
  13. package/lib/searchable-select/searchable-select.d.ts +29 -0
  14. package/lib/searchable-select/searchable-select.form-associated.d.ts +10 -0
  15. package/lib/searchable-select/searchable-select.template.d.ts +4 -0
  16. package/lib/select/select.d.ts +3 -1
  17. package/lib/tab/locale.d.ts +3 -0
  18. package/lib/tab/tab.d.ts +5 -1
  19. package/lib/tag/definition.d.ts +1 -0
  20. package/lib/text-field/text-field.d.ts +3 -1
  21. package/locales/de-DE.cjs +12 -0
  22. package/locales/de-DE.js +12 -0
  23. package/locales/en-GB.cjs +12 -0
  24. package/locales/en-GB.js +12 -0
  25. package/locales/en-US.cjs +12 -0
  26. package/locales/en-US.js +12 -0
  27. package/locales/ja-JP.cjs +12 -0
  28. package/locales/ja-JP.js +12 -0
  29. package/locales/zh-CN.cjs +12 -0
  30. package/locales/zh-CN.js +12 -0
  31. package/package.json +1 -1
  32. package/popup/index.cjs +1 -1
  33. package/popup/index.js +1 -1
  34. package/searchable-select/index.cjs +5 -0
  35. package/searchable-select/index.js +3 -0
  36. package/select/index.cjs +1 -1
  37. package/select/index.js +1 -1
  38. package/selectable-box/index.cjs +1 -1
  39. package/selectable-box/index.js +1 -1
  40. package/shared/definition11.cjs +1 -1
  41. package/shared/definition11.js +1 -1
  42. package/shared/definition14.cjs +1 -1
  43. package/shared/definition14.js +1 -1
  44. package/shared/definition16.cjs +1 -1
  45. package/shared/definition16.js +1 -1
  46. package/shared/definition18.cjs +2 -2
  47. package/shared/definition18.js +2 -2
  48. package/shared/definition19.cjs +2 -2
  49. package/shared/definition19.js +2 -2
  50. package/shared/definition20.cjs +14 -34
  51. package/shared/definition20.js +14 -34
  52. package/shared/definition21.cjs +1 -1
  53. package/shared/definition21.js +1 -1
  54. package/shared/definition26.cjs +1 -1
  55. package/shared/definition26.js +1 -1
  56. package/shared/definition29.cjs +4 -0
  57. package/shared/definition29.js +4 -0
  58. package/shared/definition30.cjs +2 -1
  59. package/shared/definition30.js +2 -1
  60. package/shared/definition35.cjs +12 -7
  61. package/shared/definition35.js +12 -7
  62. package/shared/definition36.cjs +50 -207
  63. package/shared/definition36.js +51 -207
  64. package/shared/definition4.cjs +1 -1
  65. package/shared/definition4.js +1 -1
  66. package/shared/definition42.cjs +1 -1
  67. package/shared/definition42.js +1 -1
  68. package/shared/definition43.cjs +993 -645
  69. package/shared/definition43.js +989 -642
  70. package/shared/definition44.cjs +723 -112
  71. package/shared/definition44.js +722 -111
  72. package/shared/definition45.cjs +121 -80
  73. package/shared/definition45.js +119 -78
  74. package/shared/definition46.cjs +81 -614
  75. package/shared/definition46.js +80 -612
  76. package/shared/definition47.cjs +608 -114
  77. package/shared/definition47.js +606 -113
  78. package/shared/definition48.cjs +116 -134
  79. package/shared/definition48.js +115 -133
  80. package/shared/definition49.cjs +149 -19
  81. package/shared/definition49.js +148 -18
  82. package/shared/definition5.cjs +1 -1
  83. package/shared/definition5.js +1 -1
  84. package/shared/definition50.cjs +21 -82
  85. package/shared/definition50.js +20 -81
  86. package/shared/definition51.cjs +77 -539
  87. package/shared/definition51.js +76 -538
  88. package/shared/definition52.cjs +568 -28
  89. package/shared/definition52.js +567 -27
  90. package/shared/definition53.cjs +28 -123
  91. package/shared/definition53.js +26 -122
  92. package/shared/definition54.cjs +115 -295
  93. package/shared/definition54.js +114 -294
  94. package/shared/definition55.cjs +251 -311
  95. package/shared/definition55.js +251 -311
  96. package/shared/definition56.cjs +299 -780
  97. package/shared/definition56.js +298 -779
  98. package/shared/definition57.cjs +800 -102
  99. package/shared/definition57.js +799 -101
  100. package/shared/definition58.cjs +92 -63
  101. package/shared/definition58.js +91 -62
  102. package/shared/definition59.cjs +117 -75
  103. package/shared/definition59.js +116 -74
  104. package/shared/definition60.cjs +70 -285
  105. package/shared/definition60.js +71 -286
  106. package/shared/definition61.cjs +274 -66146
  107. package/shared/definition61.js +273 -66145
  108. package/shared/definition62.cjs +66160 -27
  109. package/shared/definition62.js +66158 -25
  110. package/shared/definition63.cjs +24 -1952
  111. package/shared/definition63.js +23 -1950
  112. package/shared/definition64.cjs +1976 -0
  113. package/shared/definition64.js +1971 -0
  114. package/shared/listbox-option.cjs +204 -0
  115. package/shared/listbox-option.js +201 -0
  116. package/shared/listbox.cjs +3 -3
  117. package/shared/listbox.js +1 -1
  118. package/shared/localization/Locale.d.ts +4 -0
  119. package/shared/presentationDate.cjs +2 -2
  120. package/shared/presentationDate.js +2 -2
  121. package/shared/scrollIntoView.cjs +51 -0
  122. package/shared/scrollIntoView.js +49 -0
  123. package/shared/slider.template.cjs +1 -1
  124. package/shared/slider.template.js +1 -1
  125. package/shared/text-field.cjs +1 -1
  126. package/shared/text-field.js +1 -1
  127. package/shared/utils/scrollIntoView.d.ts +1 -0
  128. package/side-drawer/index.cjs +1 -1
  129. package/side-drawer/index.js +1 -1
  130. package/slider/index.cjs +1 -1
  131. package/slider/index.js +1 -1
  132. package/split-button/index.cjs +1 -1
  133. package/split-button/index.js +1 -1
  134. package/styles/core/all.css +1 -1
  135. package/styles/core/theme.css +1 -1
  136. package/styles/core/typography.css +1 -1
  137. package/styles/tokens/theme-dark.css +4 -4
  138. package/styles/tokens/theme-light.css +4 -4
  139. package/styles/tokens/vivid-2-compat.css +1 -1
  140. package/switch/index.cjs +1 -1
  141. package/switch/index.js +1 -1
  142. package/tab/index.cjs +1 -1
  143. package/tab/index.js +1 -1
  144. package/tab-panel/index.cjs +1 -1
  145. package/tab-panel/index.js +1 -1
  146. package/tabs/index.cjs +1 -1
  147. package/tabs/index.js +1 -1
  148. package/tag/index.cjs +1 -1
  149. package/tag/index.js +1 -1
  150. package/tag-group/index.cjs +1 -1
  151. package/tag-group/index.js +1 -1
  152. package/text-area/index.cjs +1 -1
  153. package/text-area/index.js +1 -1
  154. package/text-field/index.cjs +1 -1
  155. package/text-field/index.js +1 -1
  156. package/time-picker/index.cjs +1 -1
  157. package/time-picker/index.js +1 -1
  158. package/toggletip/index.cjs +1 -1
  159. package/toggletip/index.js +1 -1
  160. package/tooltip/index.cjs +1 -1
  161. package/tooltip/index.js +1 -1
  162. package/tree-item/index.cjs +1 -1
  163. package/tree-item/index.js +1 -1
  164. package/tree-view/index.cjs +1 -1
  165. package/tree-view/index.js +1 -1
  166. package/video-player/index.cjs +1 -1
  167. package/video-player/index.js +1 -1
  168. package/vivid.api.json +295 -0
  169. package/api-extractor.json +0 -25
  170. package/tsdoc-metadata.json +0 -11
@@ -1,9 +1,389 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
+ const definition = require('./definition51.cjs');
5
+ const definition$1 = require('./definition50.cjs');
6
+ const startEnd = require('./start-end.cjs');
7
+ const applyMixins = require('./apply-mixins.cjs');
8
+ const keyCodes = require('./key-codes.cjs');
9
+ const strings = require('./strings.cjs');
10
+ const numbers = require('./numbers.cjs');
11
+ const ref = require('./ref.cjs');
12
+ const slotted = require('./slotted.cjs');
13
+ const when = require('./when.cjs');
4
14
  const classNames = require('./class-names.cjs');
5
15
 
6
- const styles = ".base{display:flex;flex-wrap:wrap;gap:8px}";
16
+ /**
17
+ * The orientation of the {@link @microsoft/fast-foundation#(Tabs:class)} component
18
+ * @public
19
+ */
20
+ const TabsOrientation = {
21
+ vertical: "vertical",
22
+ horizontal: "horizontal",
23
+ };
24
+ /**
25
+ * A Tabs Custom HTML Element.
26
+ * Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#tablist | ARIA tablist }.
27
+ *
28
+ * @slot start - Content which can be provided before the tablist element
29
+ * @slot end - Content which can be provided after the tablist element
30
+ * @slot tab - The slot for tabs
31
+ * @slot tabpanel - The slot for tabpanels
32
+ * @csspart tablist - The element wrapping for the tabs
33
+ * @csspart tab - The tab slot
34
+ * @csspart activeIndicator - The visual indicator
35
+ * @csspart tabpanel - The tabpanel slot
36
+ * @fires change - Fires a custom 'change' event when a tab is clicked or during keyboard navigation
37
+ *
38
+ * @public
39
+ */
40
+ let Tabs$1 = class Tabs extends index.FoundationElement {
41
+ constructor() {
42
+ super(...arguments);
43
+ /**
44
+ * The orientation
45
+ * @public
46
+ * @remarks
47
+ * HTML Attribute: orientation
48
+ */
49
+ this.orientation = TabsOrientation.horizontal;
50
+ /**
51
+ * Whether or not to show the active indicator
52
+ * @public
53
+ * @remarks
54
+ * HTML Attribute: activeindicator
55
+ */
56
+ this.activeindicator = true;
57
+ /**
58
+ * @internal
59
+ */
60
+ this.showActiveIndicator = true;
61
+ this.prevActiveTabIndex = 0;
62
+ this.activeTabIndex = 0;
63
+ this.ticking = false;
64
+ this.change = () => {
65
+ this.$emit("change", this.activetab);
66
+ };
67
+ this.isDisabledElement = (el) => {
68
+ return el.getAttribute("aria-disabled") === "true";
69
+ };
70
+ this.isHiddenElement = (el) => {
71
+ return el.hasAttribute("hidden");
72
+ };
73
+ this.isFocusableElement = (el) => {
74
+ return !this.isDisabledElement(el) && !this.isHiddenElement(el);
75
+ };
76
+ this.setTabs = () => {
77
+ const gridHorizontalProperty = "gridColumn";
78
+ const gridVerticalProperty = "gridRow";
79
+ const gridProperty = this.isHorizontal()
80
+ ? gridHorizontalProperty
81
+ : gridVerticalProperty;
82
+ this.activeTabIndex = this.getActiveIndex();
83
+ this.showActiveIndicator = false;
84
+ this.tabs.forEach((tab, index) => {
85
+ if (tab.slot === "tab") {
86
+ const isActiveTab = this.activeTabIndex === index && this.isFocusableElement(tab);
87
+ if (this.activeindicator && this.isFocusableElement(tab)) {
88
+ this.showActiveIndicator = true;
89
+ }
90
+ const tabId = this.tabIds[index];
91
+ const tabpanelId = this.tabpanelIds[index];
92
+ tab.setAttribute("id", tabId);
93
+ tab.setAttribute("aria-selected", isActiveTab ? "true" : "false");
94
+ tab.setAttribute("aria-controls", tabpanelId);
95
+ tab.addEventListener("click", this.handleTabClick);
96
+ tab.addEventListener("keydown", this.handleTabKeyDown);
97
+ tab.setAttribute("tabindex", isActiveTab ? "0" : "-1");
98
+ if (isActiveTab) {
99
+ this.activetab = tab;
100
+ this.activeid = tabId;
101
+ }
102
+ }
103
+ // If the original property isn't emptied out,
104
+ // the next set will morph into a grid-area style setting that is not what we want
105
+ tab.style[gridHorizontalProperty] = "";
106
+ tab.style[gridVerticalProperty] = "";
107
+ tab.style[gridProperty] = `${index + 1}`;
108
+ !this.isHorizontal()
109
+ ? tab.classList.add("vertical")
110
+ : tab.classList.remove("vertical");
111
+ });
112
+ };
113
+ this.setTabPanels = () => {
114
+ this.tabpanels.forEach((tabpanel, index) => {
115
+ const tabId = this.tabIds[index];
116
+ const tabpanelId = this.tabpanelIds[index];
117
+ tabpanel.setAttribute("id", tabpanelId);
118
+ tabpanel.setAttribute("aria-labelledby", tabId);
119
+ this.activeTabIndex !== index
120
+ ? tabpanel.setAttribute("hidden", "")
121
+ : tabpanel.removeAttribute("hidden");
122
+ });
123
+ };
124
+ this.handleTabClick = (event) => {
125
+ const selectedTab = event.currentTarget;
126
+ if (selectedTab.nodeType === 1 && this.isFocusableElement(selectedTab)) {
127
+ this.prevActiveTabIndex = this.activeTabIndex;
128
+ this.activeTabIndex = this.tabs.indexOf(selectedTab);
129
+ this.setComponent();
130
+ }
131
+ };
132
+ this.handleTabKeyDown = (event) => {
133
+ if (this.isHorizontal()) {
134
+ switch (event.key) {
135
+ case keyCodes.keyArrowLeft:
136
+ event.preventDefault();
137
+ this.adjustBackward(event);
138
+ break;
139
+ case keyCodes.keyArrowRight:
140
+ event.preventDefault();
141
+ this.adjustForward(event);
142
+ break;
143
+ }
144
+ }
145
+ else {
146
+ switch (event.key) {
147
+ case keyCodes.keyArrowUp:
148
+ event.preventDefault();
149
+ this.adjustBackward(event);
150
+ break;
151
+ case keyCodes.keyArrowDown:
152
+ event.preventDefault();
153
+ this.adjustForward(event);
154
+ break;
155
+ }
156
+ }
157
+ switch (event.key) {
158
+ case keyCodes.keyHome:
159
+ event.preventDefault();
160
+ this.adjust(-this.activeTabIndex);
161
+ break;
162
+ case keyCodes.keyEnd:
163
+ event.preventDefault();
164
+ this.adjust(this.tabs.length - this.activeTabIndex - 1);
165
+ break;
166
+ }
167
+ };
168
+ this.adjustForward = (e) => {
169
+ const group = this.tabs;
170
+ let index = 0;
171
+ index = this.activetab ? group.indexOf(this.activetab) + 1 : 1;
172
+ if (index === group.length) {
173
+ index = 0;
174
+ }
175
+ while (index < group.length && group.length > 1) {
176
+ if (this.isFocusableElement(group[index])) {
177
+ this.moveToTabByIndex(group, index);
178
+ break;
179
+ }
180
+ else if (this.activetab && index === group.indexOf(this.activetab)) {
181
+ break;
182
+ }
183
+ else if (index + 1 >= group.length) {
184
+ index = 0;
185
+ }
186
+ else {
187
+ index += 1;
188
+ }
189
+ }
190
+ };
191
+ this.adjustBackward = (e) => {
192
+ const group = this.tabs;
193
+ let index = 0;
194
+ index = this.activetab ? group.indexOf(this.activetab) - 1 : 0;
195
+ index = index < 0 ? group.length - 1 : index;
196
+ while (index >= 0 && group.length > 1) {
197
+ if (this.isFocusableElement(group[index])) {
198
+ this.moveToTabByIndex(group, index);
199
+ break;
200
+ }
201
+ else if (index - 1 < 0) {
202
+ index = group.length - 1;
203
+ }
204
+ else {
205
+ index -= 1;
206
+ }
207
+ }
208
+ };
209
+ this.moveToTabByIndex = (group, index) => {
210
+ const tab = group[index];
211
+ this.activetab = tab;
212
+ this.prevActiveTabIndex = this.activeTabIndex;
213
+ this.activeTabIndex = index;
214
+ tab.focus();
215
+ this.setComponent();
216
+ };
217
+ }
218
+ /**
219
+ * @internal
220
+ */
221
+ orientationChanged() {
222
+ if (this.$fastController.isConnected) {
223
+ this.setTabs();
224
+ this.setTabPanels();
225
+ this.handleActiveIndicatorPosition();
226
+ }
227
+ }
228
+ /**
229
+ * @internal
230
+ */
231
+ activeidChanged(oldValue, newValue) {
232
+ if (this.$fastController.isConnected &&
233
+ this.tabs.length <= this.tabpanels.length) {
234
+ this.prevActiveTabIndex = this.tabs.findIndex((item) => item.id === oldValue);
235
+ this.setTabs();
236
+ this.setTabPanels();
237
+ this.handleActiveIndicatorPosition();
238
+ }
239
+ }
240
+ /**
241
+ * @internal
242
+ */
243
+ tabsChanged() {
244
+ if (this.$fastController.isConnected &&
245
+ this.tabs.length <= this.tabpanels.length) {
246
+ this.tabIds = this.getTabIds();
247
+ this.tabpanelIds = this.getTabPanelIds();
248
+ this.setTabs();
249
+ this.setTabPanels();
250
+ this.handleActiveIndicatorPosition();
251
+ }
252
+ }
253
+ /**
254
+ * @internal
255
+ */
256
+ tabpanelsChanged() {
257
+ if (this.$fastController.isConnected &&
258
+ this.tabpanels.length <= this.tabs.length) {
259
+ this.tabIds = this.getTabIds();
260
+ this.tabpanelIds = this.getTabPanelIds();
261
+ this.setTabs();
262
+ this.setTabPanels();
263
+ this.handleActiveIndicatorPosition();
264
+ }
265
+ }
266
+ getActiveIndex() {
267
+ const id = this.activeid;
268
+ if (id !== undefined) {
269
+ return this.tabIds.indexOf(this.activeid) === -1
270
+ ? 0
271
+ : this.tabIds.indexOf(this.activeid);
272
+ }
273
+ else {
274
+ return 0;
275
+ }
276
+ }
277
+ getTabIds() {
278
+ return this.tabs.map((tab) => {
279
+ var _a;
280
+ return (_a = tab.getAttribute("id")) !== null && _a !== void 0 ? _a : `tab-${strings.uniqueId()}`;
281
+ });
282
+ }
283
+ getTabPanelIds() {
284
+ return this.tabpanels.map((tabPanel) => {
285
+ var _a;
286
+ return (_a = tabPanel.getAttribute("id")) !== null && _a !== void 0 ? _a : `panel-${strings.uniqueId()}`;
287
+ });
288
+ }
289
+ setComponent() {
290
+ if (this.activeTabIndex !== this.prevActiveTabIndex) {
291
+ this.activeid = this.tabIds[this.activeTabIndex];
292
+ this.focusTab();
293
+ this.change();
294
+ }
295
+ }
296
+ isHorizontal() {
297
+ return this.orientation === TabsOrientation.horizontal;
298
+ }
299
+ handleActiveIndicatorPosition() {
300
+ // Ignore if we click twice on the same tab
301
+ if (this.showActiveIndicator &&
302
+ this.activeindicator &&
303
+ this.activeTabIndex !== this.prevActiveTabIndex) {
304
+ if (this.ticking) {
305
+ this.ticking = false;
306
+ }
307
+ else {
308
+ this.ticking = true;
309
+ this.animateActiveIndicator();
310
+ }
311
+ }
312
+ }
313
+ animateActiveIndicator() {
314
+ this.ticking = true;
315
+ const gridProperty = this.isHorizontal() ? "gridColumn" : "gridRow";
316
+ const translateProperty = this.isHorizontal()
317
+ ? "translateX"
318
+ : "translateY";
319
+ const offsetProperty = this.isHorizontal() ? "offsetLeft" : "offsetTop";
320
+ const prev = this.activeIndicatorRef[offsetProperty];
321
+ this.activeIndicatorRef.style[gridProperty] = `${this.activeTabIndex + 1}`;
322
+ const next = this.activeIndicatorRef[offsetProperty];
323
+ this.activeIndicatorRef.style[gridProperty] = `${this.prevActiveTabIndex + 1}`;
324
+ const dif = next - prev;
325
+ this.activeIndicatorRef.style.transform = `${translateProperty}(${dif}px)`;
326
+ this.activeIndicatorRef.classList.add("activeIndicatorTransition");
327
+ this.activeIndicatorRef.addEventListener("transitionend", () => {
328
+ this.ticking = false;
329
+ this.activeIndicatorRef.style[gridProperty] = `${this.activeTabIndex + 1}`;
330
+ this.activeIndicatorRef.style.transform = `${translateProperty}(0px)`;
331
+ this.activeIndicatorRef.classList.remove("activeIndicatorTransition");
332
+ });
333
+ }
334
+ /**
335
+ * The adjust method for FASTTabs
336
+ * @public
337
+ * @remarks
338
+ * This method allows the active index to be adjusted by numerical increments
339
+ */
340
+ adjust(adjustment) {
341
+ const focusableTabs = this.tabs.filter(t => this.isFocusableElement(t));
342
+ const currentActiveTabIndex = focusableTabs.indexOf(this.activetab);
343
+ const nextTabIndex = numbers.limit(0, focusableTabs.length - 1, currentActiveTabIndex + adjustment);
344
+ // the index of the next focusable tab within the context of all available tabs
345
+ const nextIndex = this.tabs.indexOf(focusableTabs[nextTabIndex]);
346
+ if (nextIndex > -1) {
347
+ this.moveToTabByIndex(this.tabs, nextIndex);
348
+ }
349
+ }
350
+ focusTab() {
351
+ this.tabs[this.activeTabIndex].focus();
352
+ }
353
+ /**
354
+ * @internal
355
+ */
356
+ connectedCallback() {
357
+ super.connectedCallback();
358
+ this.tabIds = this.getTabIds();
359
+ this.tabpanelIds = this.getTabPanelIds();
360
+ this.activeTabIndex = this.getActiveIndex();
361
+ }
362
+ };
363
+ index.__decorate([
364
+ index.attr
365
+ ], Tabs$1.prototype, "orientation", void 0);
366
+ index.__decorate([
367
+ index.attr
368
+ ], Tabs$1.prototype, "activeid", void 0);
369
+ index.__decorate([
370
+ index.observable
371
+ ], Tabs$1.prototype, "tabs", void 0);
372
+ index.__decorate([
373
+ index.observable
374
+ ], Tabs$1.prototype, "tabpanels", void 0);
375
+ index.__decorate([
376
+ index.attr({ mode: "boolean" })
377
+ ], Tabs$1.prototype, "activeindicator", void 0);
378
+ index.__decorate([
379
+ index.observable
380
+ ], Tabs$1.prototype, "activeIndicatorRef", void 0);
381
+ index.__decorate([
382
+ index.observable
383
+ ], Tabs$1.prototype, "showActiveIndicator", void 0);
384
+ applyMixins.applyMixins(Tabs$1, startEnd.StartEnd);
385
+
386
+ const styles = ":host{display:block}.base{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.base.connotation-cta{--_connotation-color-firm: var(--vvd-tabs-cta-firm, var(--vvd-color-cta-600))}.base:not(.connotation-cta){--_connotation-color-firm: var(--vvd-tabs-accent-firm, var(--vvd-color-canvas-text))}.base{display:grid;box-sizing:border-box}.base.orientation-vertical{overflow:hidden;block-size:inherit;grid-template-columns:auto 1fr;grid-template-rows:1fr}.base:not(.orientation-vertical){grid-template-columns:1fr;grid-template-rows:auto 1fr;max-block-size:100%}.base:not(.orientation-vertical) .scroll-shadow{position:relative;overflow:hidden;inline-size:100%;isolation:isolate}.base:not(.orientation-vertical) .scroll-shadow.start-scroll:before,.base:not(.orientation-vertical) .scroll-shadow.start-scroll:after,.base:not(.orientation-vertical) .scroll-shadow.end-scroll:before,.base:not(.orientation-vertical) .scroll-shadow.end-scroll:after{position:absolute;content:\"\";inline-size:10px;inset-block:0;opacity:0;transition:opacity .1s}.base:not(.orientation-vertical) .scroll-shadow.start-scroll:before{z-index:1;box-shadow:inset 7px 1px 5px -3px var(--vvd-color-neutral-950);inset-inline-start:0;opacity:.2}.base:not(.orientation-vertical) .scroll-shadow.end-scroll:after{box-shadow:inset -7px 1px 5px -3px var(--vvd-color-neutral-950);inset-inline-end:0;opacity:.2}.tablist{--_tabs-tablist-gutter: 8px;--_tabs-active-indicator-stroke-width: 2px;position:relative;display:grid;box-sizing:border-box;color:var(--_appearance-color-text)}.base.orientation-vertical .tablist{padding:var(--_tabs-tablist-gutter);grid-row:1/2;grid-template-columns:auto 1fr;grid-template-rows:auto;inline-size:100%;place-self:flex-start end;row-gap:var(--_tabs-tablist-gutter)}.base:not(.orientation-vertical) .tablist{justify-content:flex-start;column-gap:var(--_tabs-tablist-gutter);grid-auto-flow:column;grid-template-columns:auto;grid-template-rows:auto auto;inline-size:100%;padding-inline:var(--_tabs-tablist-gutter)}.base:not(.orientation-vertical) .tablist-wrapper{overflow:auto hidden;align-self:end;border-bottom:1px solid var(--vvd-color-neutral-300);inline-size:100%}.base.orientation-vertical .tablist-wrapper{overflow:hidden auto;block-size:100%;box-shadow:1px 0 0 0 var(--vvd-color-neutral-300)}.tablist-wrapper::-webkit-scrollbar{display:none}.tabpanel{box-sizing:border-box;block-size:100%;min-block-size:0;min-inline-size:0}.base.scroll .tabpanel{overflow-y:auto}.base.gutters-small .tabpanel{padding:calc(1px*(40 + 4*clamp(-1,var(--vvd-size-density, 0),2)) - (1px*(24 + 4*clamp(-1,var(--vvd-size-density, 0),2))))}.active-indicator{background:currentColor;margin-inline-start:calc(var(--_tabs-tablist-gutter) * -1)}.base.orientation-vertical .active-indicator{align-self:center;border-radius:2px;block-size:80%;grid-area:1/1/auto/auto;inline-size:var(--_tabs-active-indicator-stroke-width)}.base:not(.orientation-vertical) .active-indicator{position:absolute;z-index:1;block-size:var(--_tabs-active-indicator-stroke-width);grid-column:1/auto;inline-size:calc(var(--_tabs-active-tab-inline-size) - 32px);inset-block-end:0;inset-inline-start:8px;justify-self:center;padding-inline:var(--_tabs-tablist-gutter)}.activeIndicatorTransition{transition:transform .2s ease-out 0s,inline-size .2s ease-out 0s}.base:not(.orientation-vertical) .active-indicator:not(.activeIndicatorTransition){opacity:0}";
7
387
 
8
388
  var __defProp = Object.defineProperty;
9
389
  var __decorateClass = (decorators, target, key, kind) => {
@@ -14,40 +394,200 @@ var __decorateClass = (decorators, target, key, kind) => {
14
394
  if (result) __defProp(target, key, result);
15
395
  return result;
16
396
  };
17
- class TagGroup extends index.FoundationElement {
397
+ const ACTIVE_TAB_WIDTH = "--_tabs-active-tab-inline-size";
398
+ class Tabs extends Tabs$1 {
18
399
  constructor() {
19
400
  super(...arguments);
20
- this.ariaLabel = null;
401
+ this.scrollablePanel = false;
402
+ }
403
+ connotationChanged() {
404
+ this.#updateTabsConnotation();
405
+ }
406
+ orientationChanged() {
407
+ super.orientationChanged();
408
+ this.patchIndicatorStyleTransition();
409
+ if (!this.activeIndicatorRef) return;
410
+ if (this.orientation === TabsOrientation.vertical) {
411
+ this.activeIndicatorRef.style.removeProperty(ACTIVE_TAB_WIDTH);
412
+ }
413
+ this.#patchActiveID();
414
+ }
415
+ activeidChanged(oldValue, newValue) {
416
+ super.activeidChanged(oldValue, newValue);
417
+ this.patchIndicatorStyleTransition();
418
+ this.#patchActiveID();
419
+ }
420
+ tabsChanged() {
421
+ super.tabsChanged();
422
+ this.patchIndicatorStyleTransition();
423
+ this.#patchActiveID();
424
+ this.#updateScrollStatus();
425
+ }
426
+ #updateScrollStatus() {
427
+ this.tablist.parentElement.dispatchEvent(new Event("scroll"));
428
+ }
429
+ tabpanelsChanged() {
430
+ super.tabpanelsChanged();
431
+ this.patchIndicatorStyleTransition();
432
+ this.#patchActiveID();
433
+ }
434
+ patchIndicatorStyleTransition() {
435
+ if (!this.activetab || !this.activeIndicatorRef) return;
436
+ if (this.orientation === TabsOrientation.vertical || !this.showActiveIndicator)
437
+ return;
438
+ const width = this.activetab.getBoundingClientRect().width;
439
+ this.activeIndicatorRef.style.setProperty(ACTIVE_TAB_WIDTH, `${width}px`);
440
+ }
441
+ connectedCallback() {
442
+ super.connectedCallback();
443
+ requestAnimationFrame(() => this.#updateScrollStatus());
444
+ const scrollWrapper = this.tablist.parentElement;
445
+ this.#resizeObserver = new ResizeObserver(() => {
446
+ this.#updateScrollStatus();
447
+ });
448
+ this.#resizeObserver.observe(scrollWrapper);
449
+ }
450
+ #resizeObserver;
451
+ disconnectedCallback() {
452
+ super.disconnectedCallback();
453
+ this.#resizeObserver.disconnect();
454
+ }
455
+ #updateTabsConnotation() {
456
+ if (this.tabs) {
457
+ this.tabs.forEach((tab) => {
458
+ if (tab.getAttribute("aria-selected") === "true") {
459
+ tab.setAttribute("connotation", this.connotation);
460
+ } else {
461
+ tab.removeAttribute("connotation");
462
+ }
463
+ });
464
+ }
465
+ }
466
+ get #tabListWrapper() {
467
+ return this.shadowRoot.querySelector(".tablist-wrapper");
468
+ }
469
+ #scrollToIndex(index) {
470
+ const tab = this.tabs[index];
471
+ if (!tab) return;
472
+ let left = 0;
473
+ let top = 0;
474
+ if (this.orientation === TabsOrientation.vertical) {
475
+ if (index === this.tabs.length - 1) {
476
+ top = this.#tabListWrapper.scrollHeight;
477
+ }
478
+ if (index > 0 && index < this.tabs.length - 1) {
479
+ top = tab.offsetTop - this.#tabListWrapper.offsetHeight / 2 + tab.offsetHeight / 2;
480
+ }
481
+ } else {
482
+ if (index === this.tabs.length - 1) {
483
+ left = this.#tabListWrapper.scrollWidth;
484
+ }
485
+ if (index > 0 && index < this.tabs.length - 1) {
486
+ left = tab.offsetLeft - this.#tabListWrapper.offsetWidth / 2 + tab.offsetWidth / 2;
487
+ }
488
+ }
489
+ this.#tabListWrapper.scrollTo({ top, left, behavior: "smooth" });
490
+ }
491
+ // adapted FAST fix https://github.com/microsoft/fast/pull/6606
492
+ #patchActiveID() {
493
+ if (!this.activetab) return;
494
+ const idx = this.tabs.indexOf(this.activetab);
495
+ this.activeid = this["tabIds"][idx];
496
+ this.#updateTabsConnotation();
497
+ this.#scrollToIndex(idx);
21
498
  }
22
499
  }
23
500
  __decorateClass([
24
- index.attr({ attribute: "aria-label" })
25
- ], TagGroup.prototype, "ariaLabel");
501
+ index.observable
502
+ ], Tabs.prototype, "tablist");
503
+ __decorateClass([
504
+ index.attr
505
+ ], Tabs.prototype, "connotation");
506
+ __decorateClass([
507
+ index.attr
508
+ ], Tabs.prototype, "gutters");
509
+ __decorateClass([
510
+ index.attr({ mode: "boolean", attribute: "scrollable-panel" })
511
+ ], Tabs.prototype, "scrollablePanel");
26
512
 
27
- const getClasses = (_) => classNames.classNames("base");
28
- const TagGroupTemplate = () => {
513
+ const getClasses = ({
514
+ connotation,
515
+ orientation,
516
+ gutters,
517
+ scrollablePanel
518
+ }) => classNames.classNames(
519
+ "base",
520
+ [`connotation-${connotation}`, Boolean(connotation)],
521
+ [`orientation-${orientation}`, Boolean(orientation)],
522
+ `gutters-${gutters ?? "small"}`,
523
+ ["scroll", Boolean(scrollablePanel)]
524
+ );
525
+ function setNoScrollState(scrollShadow, scrollWrapper) {
526
+ if (scrollWrapper.scrollWidth <= scrollWrapper.clientWidth) {
527
+ scrollShadow.classList.toggle("start-scroll", false);
528
+ scrollShadow.classList.toggle("end-scroll", false);
529
+ return true;
530
+ }
531
+ return false;
532
+ }
533
+ function addStartShadow(scrollShadow, scrollWrapper) {
534
+ scrollShadow.classList.toggle("start-scroll", scrollWrapper.scrollLeft > 0);
535
+ }
536
+ function addEndShadow(scrollShadow, scrollWrapper) {
537
+ scrollShadow.classList.toggle(
538
+ "end-scroll",
539
+ scrollWrapper.scrollLeft < scrollWrapper.scrollWidth - scrollWrapper.clientWidth
540
+ );
541
+ }
542
+ function setShadowWhenScrollTabs(_, { event }) {
543
+ const scrollWrapper = event.target;
544
+ const scrollShadow = scrollWrapper.parentElement;
545
+ if (setNoScrollState(scrollShadow, scrollWrapper)) {
546
+ return;
547
+ }
548
+ addStartShadow(scrollShadow, scrollWrapper);
549
+ addEndShadow(scrollShadow, scrollWrapper);
550
+ }
551
+ function TabsTemplate() {
29
552
  return index.html`
30
- <div
31
- class="${getClasses}"
32
- role="listbox"
33
- aria-orientation="horizontal"
34
- aria-label="${(x) => x.ariaLabel}"
35
- >
36
- <slot></slot>
37
- </div>
553
+ <template>
554
+ <div class="${getClasses}">
555
+ <div class="scroll-shadow">
556
+ <div class="tablist-wrapper" @scroll="${setShadowWhenScrollTabs}">
557
+ <div class="tablist" role="tablist" ${ref.ref("tablist")}>
558
+ <slot name="tab" ${slotted.slotted("tabs")}></slot>
559
+ ${when.when(
560
+ (x) => x.showActiveIndicator,
561
+ index.html`
562
+ <div
563
+ ${ref.ref("activeIndicatorRef")}
564
+ class="active-indicator"
565
+ ></div>
566
+ `
567
+ )}
568
+ </div>
569
+ </div>
570
+ </div>
571
+ <div class="tabpanel" part="tab-panel">
572
+ <slot name="tabpanel" ${slotted.slotted("tabpanels")}></slot>
573
+ </div>
574
+ </div>
575
+ </template>
38
576
  `;
39
- };
577
+ }
40
578
 
41
- const tagGroupDefinition = TagGroup.compose(
42
- {
43
- baseName: "tag-group",
44
- template: TagGroupTemplate,
45
- styles
46
- }
47
- );
48
- const tagGroupRegistries = [tagGroupDefinition()];
49
- const registerTagGroup = index.registerFactory(tagGroupRegistries);
579
+ const tabsDefinition = Tabs.compose({
580
+ baseName: "tabs",
581
+ template: TabsTemplate,
582
+ styles
583
+ });
584
+ const tabsRegistries = [
585
+ tabsDefinition(),
586
+ ...definition.tabRegistries,
587
+ ...definition$1.tabPanelRegistries
588
+ ];
589
+ const registerTabs = index.registerFactory(tabsRegistries);
50
590
 
51
- exports.registerTagGroup = registerTagGroup;
52
- exports.tagGroupDefinition = tagGroupDefinition;
53
- exports.tagGroupRegistries = tagGroupRegistries;
591
+ exports.registerTabs = registerTabs;
592
+ exports.tabsDefinition = tabsDefinition;
593
+ exports.tabsRegistries = tabsRegistries;