@vonage/vivid 4.12.0 → 4.13.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.
- package/custom-elements.json +2339 -288
- package/lib/accordion/accordion.d.ts +21 -2
- package/lib/accordion-item/accordion-item.d.ts +6 -2
- package/lib/calendar/calendar.d.ts +1 -1
- package/lib/date-picker/date-picker.d.ts +1 -0
- package/lib/file-picker/file-picker.d.ts +6 -0
- package/lib/menu/menu.d.ts +16 -3
- package/lib/menu-item/menu-item.d.ts +10 -2
- package/lib/option/option.d.ts +27 -7
- package/lib/radio/radio.d.ts +12 -2
- package/lib/radio/radio.form-associated.d.ts +10 -0
- package/lib/radio-group/radio-group.d.ts +20 -2
- package/lib/switch/switch.d.ts +5 -2
- package/lib/switch/switch.form-associated.d.ts +10 -0
- package/lib/tab/tab.d.ts +3 -2
- package/lib/tab-panel/tab-panel.d.ts +2 -2
- package/lib/tabs/tabs.d.ts +33 -11
- package/lib/text-area/text-area.d.ts +25 -3
- package/lib/text-area/text-field.form-associated.d.ts +10 -0
- package/lib/text-field/text-field.d.ts +28 -3
- package/lib/text-field/text-field.form-associated.d.ts +10 -0
- package/package.json +1 -1
- package/shared/date-picker/date-picker-base.d.ts +1 -0
- package/shared/definition.cjs +29 -72
- package/shared/definition.js +30 -73
- package/shared/definition11.cjs +1 -1
- package/shared/definition11.js +1 -1
- package/shared/definition16.cjs +1 -2
- package/shared/definition16.js +1 -2
- package/shared/definition17.cjs +3 -3
- package/shared/definition17.js +3 -3
- package/shared/definition18.cjs +6 -1
- package/shared/definition18.js +6 -1
- package/shared/definition19.cjs +17 -8
- package/shared/definition19.js +17 -8
- package/shared/definition2.cjs +154 -187
- package/shared/definition2.js +157 -190
- package/shared/definition20.cjs +3 -2
- package/shared/definition20.js +3 -2
- package/shared/definition21.cjs +1 -1
- package/shared/definition21.js +1 -1
- package/shared/definition24.cjs +1 -1
- package/shared/definition24.js +1 -1
- package/shared/definition25.cjs +24 -3
- package/shared/definition25.js +24 -3
- package/shared/definition29.cjs +358 -559
- package/shared/definition29.js +359 -560
- package/shared/definition30.cjs +2 -0
- package/shared/definition30.js +2 -0
- package/shared/definition35.cjs +223 -3
- package/shared/definition35.js +223 -3
- package/shared/definition36.cjs +149 -14
- package/shared/definition36.js +150 -15
- package/shared/definition40.cjs +226 -399
- package/shared/definition40.js +229 -402
- package/shared/definition42.cjs +3 -2
- package/shared/definition42.js +3 -2
- package/shared/definition43.cjs +1 -0
- package/shared/definition43.js +1 -0
- package/shared/definition44.cjs +1 -1
- package/shared/definition44.js +1 -1
- package/shared/definition46.cjs +1 -1
- package/shared/definition46.js +1 -1
- package/shared/definition47.cjs +8 -16
- package/shared/definition47.js +4 -12
- package/shared/definition49.cjs +64 -89
- package/shared/definition49.js +66 -91
- package/shared/definition5.cjs +1 -1
- package/shared/definition5.js +1 -1
- package/shared/definition50.cjs +1 -11
- package/shared/definition50.js +1 -11
- package/shared/definition51.cjs +5 -15
- package/shared/definition51.js +6 -16
- package/shared/definition52.cjs +284 -20
- package/shared/definition52.js +288 -24
- package/shared/definition55.cjs +160 -180
- package/shared/definition55.js +160 -180
- package/shared/definition56.cjs +3 -307
- package/shared/definition56.js +5 -309
- package/shared/definition57.cjs +34 -11
- package/shared/definition57.js +30 -7
- package/shared/definition61.cjs +1 -1
- package/shared/definition61.js +1 -1
- package/shared/definition62.cjs +17 -8
- package/shared/definition62.js +17 -8
- package/shared/definition64.cjs +18 -7
- package/shared/definition64.js +19 -8
- package/shared/form-associated.cjs +1 -1
- package/shared/form-associated.js +1 -1
- package/shared/icon.cjs +1 -1
- package/shared/icon.js +1 -1
- package/shared/index.cjs +1 -0
- package/shared/index.js +1 -1
- package/shared/key-codes.cjs +1 -94
- package/shared/key-codes.js +2 -89
- package/shared/key-codes2.cjs +87 -1
- package/shared/key-codes2.js +83 -2
- package/shared/listbox.cjs +204 -10
- package/shared/listbox.js +200 -6
- package/shared/{direction.cjs → localization.cjs} +12 -3
- package/shared/{direction.js → localization.js} +12 -3
- package/shared/numbers.cjs +0 -12
- package/shared/numbers.js +1 -12
- package/shared/presentationDate.cjs +22 -8
- package/shared/presentationDate.js +16 -2
- package/shared/radio.cjs +92 -117
- package/shared/radio.js +93 -118
- package/shared/slider.template.cjs +2 -15
- package/shared/slider.template.js +2 -14
- package/shared/strings.cjs +26 -0
- package/shared/strings.js +25 -1
- package/shared/text-field2.cjs +538 -194
- package/shared/text-field2.js +539 -195
- package/styles/core/all.css +21 -1
- package/styles/core/theme.css +21 -1
- package/styles/core/typography.css +1 -1
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/styles/tokens/vivid-2-compat.css +1 -1
- package/vivid.api.json +44 -0
- package/shared/Reflector.cjs +0 -71
- package/shared/Reflector.js +0 -69
- package/shared/listbox-option.cjs +0 -204
- package/shared/listbox-option.js +0 -201
package/shared/definition52.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as __decorate, a as attr, o as observable, F as FoundationElement, h as html, r as registerFactory } from './index.js';
|
|
2
2
|
import { a as tabRegistries } from './definition51.js';
|
|
3
3
|
import { a as tabPanelRegistries } from './definition50.js';
|
|
4
|
+
import { f as keyArrowRight$1, e as keyArrowLeft$1, c as keyArrowDown$1, d as keyArrowUp$1, a as keyEnd$1, b as keyHome$1 } from './key-codes.js';
|
|
4
5
|
import { S as StartEnd } from './start-end.js';
|
|
5
6
|
import { a as applyMixins } from './apply-mixins.js';
|
|
6
|
-
import { h as keyArrowRight, i as keyArrowLeft, f as keyArrowDown, e as keyArrowUp, d as keyEnd, g as keyHome } from './key-
|
|
7
|
-
import { u as uniqueId } from './strings.js';
|
|
8
|
-
import { l as limit } from './numbers.js';
|
|
7
|
+
import { h as keyArrowRight, i as keyArrowLeft, f as keyArrowDown, e as keyArrowUp, d as keyEnd, g as keyHome } from './key-codes2.js';
|
|
8
|
+
import { u as uniqueId$1, l as limit } from './strings.js';
|
|
9
|
+
import { l as limit$1 } from './numbers.js';
|
|
9
10
|
import { r as ref } from './ref.js';
|
|
10
11
|
import { s as slotted } from './slotted.js';
|
|
11
12
|
import { w as when } from './when.js';
|
|
@@ -275,13 +276,13 @@ let Tabs$1 = class Tabs extends FoundationElement {
|
|
|
275
276
|
getTabIds() {
|
|
276
277
|
return this.tabs.map((tab) => {
|
|
277
278
|
var _a;
|
|
278
|
-
return (_a = tab.getAttribute("id")) !== null && _a !== void 0 ? _a : `tab-${uniqueId()}`;
|
|
279
|
+
return (_a = tab.getAttribute("id")) !== null && _a !== void 0 ? _a : `tab-${uniqueId$1()}`;
|
|
279
280
|
});
|
|
280
281
|
}
|
|
281
282
|
getTabPanelIds() {
|
|
282
283
|
return this.tabpanels.map((tabPanel) => {
|
|
283
284
|
var _a;
|
|
284
|
-
return (_a = tabPanel.getAttribute("id")) !== null && _a !== void 0 ? _a : `panel-${uniqueId()}`;
|
|
285
|
+
return (_a = tabPanel.getAttribute("id")) !== null && _a !== void 0 ? _a : `panel-${uniqueId$1()}`;
|
|
285
286
|
});
|
|
286
287
|
}
|
|
287
288
|
setComponent() {
|
|
@@ -381,7 +382,15 @@ __decorate([
|
|
|
381
382
|
], Tabs$1.prototype, "showActiveIndicator", void 0);
|
|
382
383
|
applyMixins(Tabs$1, StartEnd);
|
|
383
384
|
|
|
384
|
-
|
|
385
|
+
let uniqueIdCounter = 0;
|
|
386
|
+
/**
|
|
387
|
+
* Generates a unique ID based on incrementing a counter.
|
|
388
|
+
*/
|
|
389
|
+
function uniqueId(prefix = "") {
|
|
390
|
+
return `${prefix}${uniqueIdCounter++}`;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
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{--_tabs-tablist-gutter: 8px;--_tabs-active-indicator-stroke-width: 2px;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.layout-stretch .scroll-shadow{flex:1}.base:not(.orientation-vertical) .scroll-shadow{position:relative;overflow:hidden;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}.tabs{display:flex;overflow:hidden}.base.orientation-vertical .tabs{flex-direction:column;box-shadow:1px 0 0 0 var(--vvd-color-neutral-300)}.base.orientation-horizontal .tabs{flex-direction:row;border-bottom:1px solid var(--vvd-color-neutral-300)}.tablist{position:relative;display:grid;box-sizing:border-box;color:var(--_appearance-color-text)}.base.layout-stretch .tablist{--_tab-justify-content: center;--_tabs-tablist-column: 1fr}.tablist .base:not(.layout-stretch){--_tabs-tablist-column: auto}.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-rows:auto auto;inline-size:100%;padding-inline:var(--_tabs-tablist-gutter)}.base.has-action-items.orientation-vertical .tablist{padding-block-end:0}.base.has-action-items:not(.orientation-vertical) .tablist{padding-inline-end:0}.tablist-wrapper{--scrollbar-track-color: transparent;--scrollbar-thumb-color: color-mix(in srgb, var(--vvd-color-neutral-950), transparent 70%)}.tablist-wrapper{scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin}.tablist-wrapper ::-webkit-scrollbar{width:4px}.tablist-wrapper ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}.tablist-wrapper ::-webkit-scrollbar-thumb{border:0;border-radius:4px;background-color:var(--scrollbar-thumb-color)}.base:not(.orientation-vertical) .tablist-wrapper{overflow:auto hidden;align-self:end;inline-size:100%}.base.orientation-vertical .tablist-wrapper{overflow:hidden auto;block-size:100%}.tablist-wrapper::-webkit-scrollbar{display:none}slot[name=action-items]{display:flex}.base.has-action-items.orientation-horizontal slot[name=action-items]{align-items:center;margin-inline:var(--_tabs-tablist-gutter)}.base.has-action-items.orientation-vertical slot[name=action-items]{margin-block:var(--_tabs-tablist-gutter)}.tabpanel{box-sizing:border-box;block-size:100%;min-block-size:0;min-inline-size:0}.base.scroll .tabpanel{overflow-y:auto;--scrollbar-track-color: transparent;--scrollbar-thumb-color: color-mix(in srgb, var(--vvd-color-neutral-950), transparent 70%)}.base.scroll .tabpanel{scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin}.base.scroll .tabpanel ::-webkit-scrollbar{width:4px}.base.scroll .tabpanel ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}.base.scroll .tabpanel ::-webkit-scrollbar-thumb{border:0;border-radius:4px;background-color:var(--scrollbar-thumb-color)}.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;border-radius:2px;block-size:var(--_tabs-active-indicator-stroke-width);grid-column:1/auto;inline-size:calc(var(--_tabs-active-tab-inline-size));inset-block-end:0;inset-inline-start:8px}.activeIndicatorTransition{transition:transform .2s ease-out 0s,inline-size .2s ease-out 0s}";
|
|
385
394
|
|
|
386
395
|
var __defProp = Object.defineProperty;
|
|
387
396
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -393,43 +402,269 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
393
402
|
return result;
|
|
394
403
|
};
|
|
395
404
|
const ACTIVE_TAB_WIDTH = "--_tabs-active-tab-inline-size";
|
|
396
|
-
|
|
405
|
+
const TABLIST_COLUMN = "--_tabs-tablist-column";
|
|
406
|
+
class Tabs extends FoundationElement {
|
|
397
407
|
constructor() {
|
|
398
|
-
super();
|
|
408
|
+
super(...arguments);
|
|
409
|
+
// eslint-disable-next-line @nrwl/nx/workspace/no-attribute-default-value
|
|
410
|
+
this.orientation = TabsOrientation.horizontal;
|
|
411
|
+
// eslint-disable-next-line @nrwl/nx/workspace/no-attribute-default-value
|
|
412
|
+
this.activeindicator = true;
|
|
413
|
+
this.showActiveIndicator = true;
|
|
414
|
+
this.prevActiveTabIndex = 0;
|
|
415
|
+
this.activeTabIndex = 0;
|
|
416
|
+
this.tabIds = [];
|
|
417
|
+
this.tabpanelIds = [];
|
|
418
|
+
this.change = () => {
|
|
419
|
+
this.$emit("change", this.activetab);
|
|
420
|
+
};
|
|
421
|
+
this.isDisabledElement = (el) => {
|
|
422
|
+
return el.getAttribute("aria-disabled") === "true";
|
|
423
|
+
};
|
|
424
|
+
this.isHiddenElement = (el) => {
|
|
425
|
+
return el.hasAttribute("hidden");
|
|
426
|
+
};
|
|
427
|
+
this.isFocusableElement = (el) => {
|
|
428
|
+
return !this.isDisabledElement(el) && !this.isHiddenElement(el);
|
|
429
|
+
};
|
|
430
|
+
this.setTabs = () => {
|
|
431
|
+
const gridHorizontalProperty = "gridColumn";
|
|
432
|
+
const gridVerticalProperty = "gridRow";
|
|
433
|
+
const gridProperty = this.isHorizontal() ? gridHorizontalProperty : gridVerticalProperty;
|
|
434
|
+
this.activeTabIndex = this.getActiveIndex();
|
|
435
|
+
this.showActiveIndicator = false;
|
|
436
|
+
if (this.isHorizontal()) {
|
|
437
|
+
this.tablist.style.setProperty(
|
|
438
|
+
"grid-template-columns",
|
|
439
|
+
`repeat(${this.tabs.length}, var(${TABLIST_COLUMN}))`
|
|
440
|
+
);
|
|
441
|
+
} else {
|
|
442
|
+
this.tablist.style.removeProperty("grid-template-columns");
|
|
443
|
+
}
|
|
444
|
+
this.tabs.forEach((tab, index) => {
|
|
445
|
+
if (tab.slot === "tab") {
|
|
446
|
+
const isActiveTab = this.activeTabIndex === index && this.isFocusableElement(tab);
|
|
447
|
+
if (this.activeindicator && this.isFocusableElement(tab)) {
|
|
448
|
+
this.showActiveIndicator = true;
|
|
449
|
+
}
|
|
450
|
+
const tabId = this.tabIds[index];
|
|
451
|
+
const tabpanelId = this.tabpanelIds[index];
|
|
452
|
+
tab.setAttribute("id", tabId);
|
|
453
|
+
tab.setAttribute("aria-selected", isActiveTab ? "true" : "false");
|
|
454
|
+
tab.setAttribute("aria-controls", tabpanelId);
|
|
455
|
+
tab.addEventListener("click", this.handleTabClick);
|
|
456
|
+
tab.addEventListener("keydown", this.handleTabKeyDown);
|
|
457
|
+
tab.setAttribute("tabindex", isActiveTab ? "0" : "-1");
|
|
458
|
+
if (isActiveTab) {
|
|
459
|
+
this.activetab = tab;
|
|
460
|
+
this.activeid = tabId;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
tab.style[gridHorizontalProperty] = "";
|
|
464
|
+
tab.style[gridVerticalProperty] = "";
|
|
465
|
+
tab.style[gridProperty] = `${index + 1}`;
|
|
466
|
+
!this.isHorizontal() ? tab.classList.add("vertical") : tab.classList.remove("vertical");
|
|
467
|
+
});
|
|
468
|
+
};
|
|
469
|
+
this.setTabPanels = () => {
|
|
470
|
+
this.tabpanels.forEach((tabpanel, index) => {
|
|
471
|
+
const tabId = this.tabIds[index];
|
|
472
|
+
const tabpanelId = this.tabpanelIds[index];
|
|
473
|
+
tabpanel.setAttribute("id", tabpanelId);
|
|
474
|
+
tabpanel.setAttribute("aria-labelledby", tabId);
|
|
475
|
+
this.activeTabIndex !== index ? tabpanel.setAttribute("hidden", "") : tabpanel.removeAttribute("hidden");
|
|
476
|
+
});
|
|
477
|
+
};
|
|
478
|
+
this.handleTabClick = (event) => {
|
|
479
|
+
const selectedTab = event.currentTarget;
|
|
480
|
+
if (selectedTab.nodeType === 1 && this.isFocusableElement(selectedTab)) {
|
|
481
|
+
this.prevActiveTabIndex = this.activeTabIndex;
|
|
482
|
+
this.activeTabIndex = this.tabs.indexOf(selectedTab);
|
|
483
|
+
this.setComponent();
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
this.handleTabKeyDown = (event) => {
|
|
487
|
+
if (this.isHorizontal()) {
|
|
488
|
+
switch (event.key) {
|
|
489
|
+
case keyArrowLeft$1:
|
|
490
|
+
event.preventDefault();
|
|
491
|
+
this.adjustBackward(event);
|
|
492
|
+
break;
|
|
493
|
+
case keyArrowRight$1:
|
|
494
|
+
event.preventDefault();
|
|
495
|
+
this.adjustForward(event);
|
|
496
|
+
break;
|
|
497
|
+
}
|
|
498
|
+
} else {
|
|
499
|
+
switch (event.key) {
|
|
500
|
+
case keyArrowUp$1:
|
|
501
|
+
event.preventDefault();
|
|
502
|
+
this.adjustBackward(event);
|
|
503
|
+
break;
|
|
504
|
+
case keyArrowDown$1:
|
|
505
|
+
event.preventDefault();
|
|
506
|
+
this.adjustForward(event);
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
switch (event.key) {
|
|
511
|
+
case keyHome$1:
|
|
512
|
+
event.preventDefault();
|
|
513
|
+
this.adjust(-this.activeTabIndex);
|
|
514
|
+
break;
|
|
515
|
+
case keyEnd$1:
|
|
516
|
+
event.preventDefault();
|
|
517
|
+
this.adjust(this.tabs.length - this.activeTabIndex - 1);
|
|
518
|
+
break;
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
this.adjustForward = (_) => {
|
|
522
|
+
this.#moveToNextTab(1);
|
|
523
|
+
};
|
|
524
|
+
this.adjustBackward = (_) => {
|
|
525
|
+
this.#moveToNextTab(-1);
|
|
526
|
+
};
|
|
527
|
+
this.moveToTabByIndex = (group, index) => {
|
|
528
|
+
const tab = group[index];
|
|
529
|
+
this.activetab = tab;
|
|
530
|
+
this.prevActiveTabIndex = this.activeTabIndex;
|
|
531
|
+
this.activeTabIndex = index;
|
|
532
|
+
tab.focus();
|
|
533
|
+
this.setComponent();
|
|
534
|
+
};
|
|
399
535
|
this.scrollablePanel = false;
|
|
400
536
|
this._actionItemsSlottedContent = [];
|
|
401
|
-
this.handleActiveIndicatorPosition = () => this.#handleActiveIndicatorPosition();
|
|
402
|
-
this.animateActiveIndicator = () => this.#animateActiveIndicator();
|
|
403
|
-
}
|
|
404
|
-
connotationChanged() {
|
|
405
|
-
this.#updateTabsConnotation();
|
|
406
537
|
}
|
|
538
|
+
/**
|
|
539
|
+
* @internal
|
|
540
|
+
*/
|
|
407
541
|
orientationChanged() {
|
|
408
|
-
|
|
542
|
+
if (this.$fastController.isConnected) {
|
|
543
|
+
this.setTabs();
|
|
544
|
+
this.setTabPanels();
|
|
545
|
+
this.handleActiveIndicatorPosition();
|
|
546
|
+
}
|
|
409
547
|
this.patchIndicatorStyleTransition();
|
|
410
548
|
if (!this.activeIndicatorRef) return;
|
|
411
549
|
if (this.orientation === TabsOrientation.vertical) {
|
|
412
550
|
this.activeIndicatorRef.style.removeProperty(ACTIVE_TAB_WIDTH);
|
|
413
551
|
}
|
|
414
552
|
}
|
|
415
|
-
|
|
416
|
-
|
|
553
|
+
/**
|
|
554
|
+
* @internal
|
|
555
|
+
*/
|
|
556
|
+
activeidChanged(oldValue, _) {
|
|
557
|
+
if (this.$fastController.isConnected && this.tabs.length <= this.tabpanels.length) {
|
|
558
|
+
this.prevActiveTabIndex = this.tabs.findIndex(
|
|
559
|
+
(item) => item.id === oldValue
|
|
560
|
+
);
|
|
561
|
+
this.setTabs();
|
|
562
|
+
this.setTabPanels();
|
|
563
|
+
this.handleActiveIndicatorPosition();
|
|
564
|
+
}
|
|
417
565
|
this.patchIndicatorStyleTransition();
|
|
418
566
|
this.#updateTabsConnotation();
|
|
419
567
|
this.#scrollToIndex(this.activeTabIndex);
|
|
420
568
|
}
|
|
569
|
+
/**
|
|
570
|
+
* @internal
|
|
571
|
+
*/
|
|
421
572
|
tabsChanged() {
|
|
422
|
-
|
|
573
|
+
if (this.$fastController.isConnected && this.tabs.length <= this.tabpanels.length) {
|
|
574
|
+
this.tabIds = this.getTabIds();
|
|
575
|
+
this.tabpanelIds = this.getTabPanelIds();
|
|
576
|
+
this.setTabs();
|
|
577
|
+
this.setTabPanels();
|
|
578
|
+
this.handleActiveIndicatorPosition();
|
|
579
|
+
}
|
|
423
580
|
this.patchIndicatorStyleTransition();
|
|
424
581
|
this.#updateScrollStatus();
|
|
425
582
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
583
|
+
/**
|
|
584
|
+
* @internal
|
|
585
|
+
*/
|
|
429
586
|
tabpanelsChanged() {
|
|
430
|
-
|
|
587
|
+
if (this.$fastController.isConnected && this.tabpanels.length <= this.tabs.length) {
|
|
588
|
+
this.tabIds = this.getTabIds();
|
|
589
|
+
this.tabpanelIds = this.getTabPanelIds();
|
|
590
|
+
this.setTabs();
|
|
591
|
+
this.setTabPanels();
|
|
592
|
+
this.handleActiveIndicatorPosition();
|
|
593
|
+
}
|
|
431
594
|
this.patchIndicatorStyleTransition();
|
|
432
595
|
}
|
|
596
|
+
getActiveIndex() {
|
|
597
|
+
const id = this.activeid;
|
|
598
|
+
if (id !== void 0) {
|
|
599
|
+
return this.tabIds.indexOf(this.activeid) === -1 ? 0 : this.tabIds.indexOf(this.activeid);
|
|
600
|
+
} else {
|
|
601
|
+
return 0;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
getTabIds() {
|
|
605
|
+
return this.tabs.map((tab) => {
|
|
606
|
+
return tab.getAttribute("id") ?? `tab-${uniqueId()}`;
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
getTabPanelIds() {
|
|
610
|
+
return this.tabpanels.map((tabPanel) => {
|
|
611
|
+
return tabPanel.getAttribute("id") ?? `panel-${uniqueId()}`;
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
setComponent() {
|
|
615
|
+
if (this.activeTabIndex !== this.prevActiveTabIndex) {
|
|
616
|
+
this.activeid = this.tabIds[this.activeTabIndex];
|
|
617
|
+
this.focusTab();
|
|
618
|
+
this.change();
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
isHorizontal() {
|
|
622
|
+
return this.orientation === TabsOrientation.horizontal;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* The adjust method for FASTTabs
|
|
626
|
+
* @public
|
|
627
|
+
* @remarks
|
|
628
|
+
* This method allows the active index to be adjusted by numerical increments
|
|
629
|
+
*/
|
|
630
|
+
adjust(adjustment) {
|
|
631
|
+
const focusableTabs = this.tabs.filter((t) => this.isFocusableElement(t));
|
|
632
|
+
const currentActiveTabIndex = focusableTabs.indexOf(this.activetab);
|
|
633
|
+
const nextTabIndex = limit$1(
|
|
634
|
+
0,
|
|
635
|
+
focusableTabs.length - 1,
|
|
636
|
+
currentActiveTabIndex + adjustment
|
|
637
|
+
);
|
|
638
|
+
const nextIndex = this.tabs.indexOf(focusableTabs[nextTabIndex]);
|
|
639
|
+
if (nextIndex > -1) {
|
|
640
|
+
this.moveToTabByIndex(this.tabs, nextIndex);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
#moveToNextTab(direction) {
|
|
644
|
+
const activeIndex = this.tabs.indexOf(this.activetab);
|
|
645
|
+
for (let offset = 1; offset < this.tabs.length; offset++) {
|
|
646
|
+
const index = (activeIndex + direction * offset + this.tabs.length) % this.tabs.length;
|
|
647
|
+
if (this.isFocusableElement(this.tabs[index])) {
|
|
648
|
+
this.moveToTabByIndex(this.tabs, index);
|
|
649
|
+
break;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
focusTab() {
|
|
654
|
+
this.tabs[this.activeTabIndex].focus();
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* @internal
|
|
658
|
+
*/
|
|
659
|
+
connotationChanged() {
|
|
660
|
+
this.#updateTabsConnotation();
|
|
661
|
+
}
|
|
662
|
+
#updateScrollStatus() {
|
|
663
|
+
this.tablist.parentElement.dispatchEvent(new Event("scroll"));
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* @internal
|
|
667
|
+
*/
|
|
433
668
|
patchIndicatorStyleTransition() {
|
|
434
669
|
if (!this.activetab || !this.activeIndicatorRef) return;
|
|
435
670
|
if (this.orientation === TabsOrientation.vertical || !this.showActiveIndicator)
|
|
@@ -439,6 +674,9 @@ class Tabs extends Tabs$1 {
|
|
|
439
674
|
}
|
|
440
675
|
connectedCallback() {
|
|
441
676
|
super.connectedCallback();
|
|
677
|
+
this.tabIds = this.getTabIds();
|
|
678
|
+
this.tabpanelIds = this.getTabPanelIds();
|
|
679
|
+
this.activeTabIndex = this.getActiveIndex();
|
|
442
680
|
requestAnimationFrame(() => this.#updateScrollStatus());
|
|
443
681
|
const scrollWrapper = this.tablist.parentElement;
|
|
444
682
|
this.#resizeObserver = new ResizeObserver(() => {
|
|
@@ -494,12 +732,12 @@ class Tabs extends Tabs$1 {
|
|
|
494
732
|
#getTranslateProperty() {
|
|
495
733
|
return this.isHorizontal() ? "translateX" : "translateY";
|
|
496
734
|
}
|
|
497
|
-
|
|
735
|
+
handleActiveIndicatorPosition() {
|
|
498
736
|
if (this.showActiveIndicator && this.activeindicator) {
|
|
499
737
|
this.animateActiveIndicator();
|
|
500
738
|
}
|
|
501
739
|
}
|
|
502
|
-
|
|
740
|
+
animateActiveIndicator() {
|
|
503
741
|
const offsetProperty = this.isHorizontal() ? "offsetLeft" : "offsetTop";
|
|
504
742
|
const currentOffset = this.activeIndicatorRef[offsetProperty];
|
|
505
743
|
const currentGridValue = this.activeIndicatorRef.style[this.#getGridProperty()];
|
|
@@ -521,6 +759,27 @@ class Tabs extends Tabs$1 {
|
|
|
521
759
|
});
|
|
522
760
|
}
|
|
523
761
|
}
|
|
762
|
+
__decorateClass([
|
|
763
|
+
attr
|
|
764
|
+
], Tabs.prototype, "orientation");
|
|
765
|
+
__decorateClass([
|
|
766
|
+
attr
|
|
767
|
+
], Tabs.prototype, "activeid");
|
|
768
|
+
__decorateClass([
|
|
769
|
+
observable
|
|
770
|
+
], Tabs.prototype, "tabs");
|
|
771
|
+
__decorateClass([
|
|
772
|
+
observable
|
|
773
|
+
], Tabs.prototype, "tabpanels");
|
|
774
|
+
__decorateClass([
|
|
775
|
+
attr({ mode: "boolean" })
|
|
776
|
+
], Tabs.prototype, "activeindicator");
|
|
777
|
+
__decorateClass([
|
|
778
|
+
observable
|
|
779
|
+
], Tabs.prototype, "activeIndicatorRef");
|
|
780
|
+
__decorateClass([
|
|
781
|
+
observable
|
|
782
|
+
], Tabs.prototype, "showActiveIndicator");
|
|
524
783
|
__decorateClass([
|
|
525
784
|
observable
|
|
526
785
|
], Tabs.prototype, "tablist");
|
|
@@ -533,6 +792,9 @@ __decorateClass([
|
|
|
533
792
|
__decorateClass([
|
|
534
793
|
attr({ mode: "boolean", attribute: "scrollable-panel" })
|
|
535
794
|
], Tabs.prototype, "scrollablePanel");
|
|
795
|
+
__decorateClass([
|
|
796
|
+
attr({ attribute: "tabs-layout" })
|
|
797
|
+
], Tabs.prototype, "tabsLayout");
|
|
536
798
|
__decorateClass([
|
|
537
799
|
observable
|
|
538
800
|
], Tabs.prototype, "_actionItemsSlottedContent");
|
|
@@ -542,9 +804,11 @@ const getClasses = ({
|
|
|
542
804
|
orientation,
|
|
543
805
|
gutters,
|
|
544
806
|
scrollablePanel,
|
|
807
|
+
tabsLayout,
|
|
545
808
|
_actionItemsSlottedContent
|
|
546
809
|
}) => classNames(
|
|
547
810
|
"base",
|
|
811
|
+
`layout-${tabsLayout ?? "align-start"}`,
|
|
548
812
|
[`connotation-${connotation}`, Boolean(connotation)],
|
|
549
813
|
[`orientation-${orientation}`, Boolean(orientation)],
|
|
550
814
|
`gutters-${gutters ?? "small"}`,
|