@github/tab-container-element
Advanced tools
Comparing version 4.0.0 to 4.0.1
@@ -151,3 +151,3 @@ var __defProp = Object.defineProperty; | ||
this.addEventListener("click", this); | ||
this.selectTab(Math.max(__classPrivateFieldGet(this, _TabContainerElement_instances, "a", _TabContainerElement_tabs_get).findIndex((el) => el.matches("[aria-selected=true]")), 0)); | ||
this.selectTab(-1); | ||
__classPrivateFieldSet(this, _TabContainerElement_setupComplete, true, "f"); | ||
@@ -209,2 +209,5 @@ } | ||
__classPrivateFieldGet(this, _TabContainerElement_instances, "a", _TabContainerElement_afterPanelsSlot_get).assign(...afterSlotted); | ||
const defaultTab = Number(this.getAttribute("default-tab") || -1); | ||
const defaultIndex = defaultTab >= 0 ? defaultTab : __classPrivateFieldGet(this, _TabContainerElement_instances, "a", _TabContainerElement_tabs_get).findIndex((el) => el.matches("[aria-selected=true]")); | ||
index = index >= 0 ? index : Math.max(0, defaultIndex); | ||
} | ||
@@ -211,0 +214,0 @@ const tabs = __classPrivateFieldGet(this, _TabContainerElement_instances, "a", _TabContainerElement_tabs_get); |
@@ -125,3 +125,3 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
this.addEventListener('click', this); | ||
this.selectTab(Math.max(__classPrivateFieldGet(this, _TabContainerElement_instances, "a", _TabContainerElement_tabs_get).findIndex(el => el.matches('[aria-selected=true]')), 0)); | ||
this.selectTab(-1); | ||
__classPrivateFieldSet(this, _TabContainerElement_setupComplete, true, "f"); | ||
@@ -186,2 +186,5 @@ } | ||
__classPrivateFieldGet(this, _TabContainerElement_instances, "a", _TabContainerElement_afterPanelsSlot_get).assign(...afterSlotted); | ||
const defaultTab = Number(this.getAttribute('default-tab') || -1); | ||
const defaultIndex = defaultTab >= 0 ? defaultTab : __classPrivateFieldGet(this, _TabContainerElement_instances, "a", _TabContainerElement_tabs_get).findIndex(el => el.matches('[aria-selected=true]')); | ||
index = index >= 0 ? index : Math.max(0, defaultIndex); | ||
} | ||
@@ -188,0 +191,0 @@ const tabs = __classPrivateFieldGet(this, _TabContainerElement_instances, "a", _TabContainerElement_tabs_get); |
{ | ||
"name": "@github/tab-container-element", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "Tab container element", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -34,2 +34,13 @@ # <tab-container> element | ||
If none of the tabs have `aria-selected=true`, then the first tab will be selected automatically. You can also add the `default-tab=N` attribute to avoid having to set `aria-selected=true` on the desired tab, where `N` is the 0-based tab index: | ||
```html | ||
<!-- The _second_ tab will be selected --> | ||
<tab-container default-tab="1"> | ||
<button type="button" id="tab-one" role="tab">Tab one</button> | ||
<button type="button" id="tab-two" role="tab">Tab two</button> | ||
<button type="button" id="tab-three" role="tab">Tab three</button> | ||
<!-- ... --> | ||
</tab-container> | ||
### Events | ||
@@ -36,0 +47,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46698
715
131