@wezz/ariatabmanager
Advanced tools
Comparing version 0.1.4 to 1.0.3
@@ -9,5 +9,7 @@ export default class ARIATabManager { | ||
private tabMediaQueryAttributeName; | ||
private ariaManager; | ||
private defaultDelay; | ||
constructor(); | ||
InitiateElements(): void; | ||
constructor(options?: ARIATabManagerInitiationOptions); | ||
private parseOptions; | ||
InitiateElements(parent?: HTMLElement): void; | ||
private initiateElement; | ||
@@ -25,1 +27,6 @@ private setDefaultDelay; | ||
} | ||
interface ARIATabManagerInitiationOptions { | ||
parent?: HTMLElement; | ||
initiateElements?: Boolean; | ||
} | ||
export {}; |
@@ -1,12 +0,18 @@ | ||
var u = Object.defineProperty; | ||
var b = (r, t, e) => t in r ? u(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e; | ||
var o = (r, t, e) => (b(r, typeof t != "symbol" ? t + "" : t, e), e); | ||
var g = Object.defineProperty, A = (r, t, e) => t in r ? g(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, h = (r, t, e) => (A(r, typeof t != "symbol" ? t + "" : t, e), e); | ||
var h = Object.defineProperty; | ||
var u = (r, t, e) => t in r ? h(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e; | ||
var o = (r, t, e) => (u(r, typeof t != "symbol" ? t + "" : t, e), e); | ||
var b = Object.defineProperty, g = (r, t, e) => t in r ? b(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, c = (r, t, e) => (g(r, typeof t != "symbol" ? t + "" : t, e), e); | ||
class f { | ||
constructor(t = document.body) { | ||
h(this, "controlelements", []), h(this, "controlselector", "[aria-controls]:not([data-ariamanager-ignore])"), h(this, "delayAttribute", "data-ariamanager-delay"), this.InitiateElements(t), window.addEventListener("global-markupchange", (e) => { | ||
var a; | ||
this.InitiateElements(((a = e == null ? void 0 : e.detail) == null ? void 0 : a.target) ?? document); | ||
}); | ||
constructor(t) { | ||
c(this, "controlelements", []), c(this, "controlselector", "[aria-controls]:not([data-ariamanager-ignore])"), c(this, "delayAttribute", "data-ariamanager-delay"); | ||
const e = this.parseOptions(t); | ||
e.initiateElements && (this.InitiateElements(e.parent), window.addEventListener("global-markupchange", (a) => { | ||
var i; | ||
this.InitiateElements(((i = a == null ? void 0 : a.detail) == null ? void 0 : i.target) ?? document); | ||
})); | ||
} | ||
parseOptions(t) { | ||
const e = { parent: document.body, initiateElements: !0 }; | ||
return !t || typeof t != "object" || typeof t.parent > "u" && typeof t.initiateElements > "u" ? e : { ...e, ...t }; | ||
} | ||
InitiateElements(t = document.body) { | ||
@@ -154,8 +160,7 @@ const e = [].slice.call( | ||
} | ||
const l = new f(document.body); | ||
class c { | ||
class l { | ||
} | ||
o(c, "AllowNone", "allownone"), o(c, "TabletAccordion", "tabletaccordion"), o(c, "Default", ""); | ||
class m { | ||
constructor() { | ||
o(l, "AllowNone", "allownone"), o(l, "TabletAccordion", "tabletaccordion"), o(l, "Default", ""); | ||
class A { | ||
constructor(t) { | ||
o(this, "controlelements", []); | ||
@@ -168,14 +173,20 @@ o(this, "controlSelector", "[data-tab-container]"); | ||
o(this, "tabMediaQueryAttributeName", "data-tab-mediaquery"); | ||
o(this, "ariaManager"); | ||
o(this, "defaultDelay", 0); | ||
this.InitiateElements(), this.checkPageHash(); | ||
const e = this.parseOptions(t); | ||
this.ariaManager = new f(t), e.initiateElements && this.InitiateElements(e.parent), this.checkPageHash(); | ||
} | ||
InitiateElements() { | ||
const e = [].slice.call( | ||
document.querySelectorAll(this.controlSelector) | ||
parseOptions(t) { | ||
const e = { parent: document.body, initiateElements: !0 }; | ||
return !t || typeof t != "object" || typeof t.parent > "u" && typeof t.initiateElements > "u" ? e : { ...e, ...t }; | ||
} | ||
InitiateElements(t = document.body) { | ||
const a = [].slice.call( | ||
t.querySelectorAll(this.controlSelector) | ||
).filter( | ||
(a) => a.dataset.tabmanager !== "activated" | ||
(i) => i.dataset.tabmanager !== "activated" | ||
); | ||
e.forEach(this.initiateElement.bind(this)), e.forEach((a) => a.dataset.tabmanager = "activated"), this.controlelements = [].concat( | ||
a.forEach(this.initiateElement.bind(this)), a.forEach((i) => i.dataset.tabmanager = "activated"), this.controlelements = [].concat( | ||
this.controlelements, | ||
e | ||
a | ||
); | ||
@@ -207,4 +218,4 @@ } | ||
async onBeforeClick(t, e) { | ||
const a = await l.GetARIAControlTargets(e), i = t.getAttribute(this.tabModeAttributeName), n = a[0].id; | ||
if (i === c.TabletAccordion) { | ||
const a = await this.ariaManager.GetARIAControlTargets(e), i = t.getAttribute(this.tabModeAttributeName), n = a[0].id; | ||
if (i === l.TabletAccordion) { | ||
const d = t.hasAttribute(this.tabMediaQueryAttributeName) ? t.getAttribute(this.tabMediaQueryAttributeName) + "" : "only screen and (min-width: 768px)"; | ||
@@ -217,4 +228,4 @@ if (typeof (window == null ? void 0 : window.matchMedia) < "u" && !window.matchMedia(d).matches) | ||
).forEach((d) => { | ||
l.AriaHidden(d, !0), l.AriaExpand(d, !1); | ||
}), this.setPageHash(e), this.setContentHeight(t), i !== c.AllowNone && this.displayTarget(a[0], t); | ||
this.ariaManager.AriaHidden(d, !0), this.ariaManager.AriaExpand(d, !1); | ||
}), this.setPageHash(e), this.setContentHeight(t), i !== l.AllowNone && this.displayTarget(a[0], t); | ||
} | ||
@@ -252,3 +263,3 @@ setPageHash(t) { | ||
(s) => s.getAttribute("aria-hidden") === "true" | ||
).length === i.length && (l.AriaHidden(t, !1), l.AriaExpand(t, !0)); | ||
).length === i.length && (this.ariaManager.AriaHidden(t, !1), this.ariaManager.AriaExpand(t, !0)); | ||
}, a); | ||
@@ -278,3 +289,3 @@ } | ||
export { | ||
m as ARIATabManager | ||
A as default | ||
}; |
@@ -1,1 +0,2 @@ | ||
export { default as ARIATabManager } from './ARIATabManager'; | ||
import ARIATabManager from './ARIATabManager'; | ||
export default ARIATabManager; |
{ | ||
"name": "@wezz/ariatabmanager", | ||
"version": "0.1.4", | ||
"version": "1.0.3", | ||
"type": "module", | ||
@@ -46,4 +46,4 @@ "main": "./dist/ariatabmanager.umd.cjs", | ||
"dependencies": { | ||
"@wezz/ariamanager": "^0.1.5" | ||
"@wezz/ariamanager": "^1.0.4" | ||
} | ||
} |
@@ -15,4 +15,4 @@ # ARIA Tab Manager | ||
``` | ||
import { ARIAManager } from "@wezz/ariamanager"; | ||
import { ARIATabManager } from "@wezz/ariatabmanager"; | ||
import ARIAManager from "@wezz/ariamanager"; | ||
import ARIATabManager from "@wezz/ariatabmanager"; | ||
// On document ready | ||
@@ -23,2 +23,13 @@ new ARIAManager(); | ||
#### Initiation options | ||
The constructor can take the following options object: | ||
``` | ||
const ariaOptions = { | ||
parent: document.body, // This defined the entrypoint where ARIA Manager will query for relevant elements | ||
initiateElements: true // This disables the automatic initiation | ||
}; | ||
new ARIAManager(ariaOptions); | ||
new ARIATabManager(ariaOptions); | ||
``` | ||
### Tab markup example | ||
@@ -25,0 +36,0 @@ ``` |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
22749
348
0
58
+ Added@wezz/ariamanager@1.0.7(transitive)
- Removed@wezz/ariamanager@0.1.6(transitive)
Updated@wezz/ariamanager@^1.0.4