diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9d01ea1..7139ca4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,23 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
+### [1.0.4](https://github.com/NickDJM/accessible-menu-bootstrap-4/compare/v1.0.3...v1.0.4) (2023-06-30)
+
+
+### Continuous Integration
+
+* **codeql:** upgrade to v2 ([463bfa3](https://github.com/NickDJM/accessible-menu-bootstrap-4/commit/463bfa398ba1ed125312f4bc699e4a021f5ce0b7)), closes [#56](https://github.com/NickDJM/accessible-menu-bootstrap-4/issues/56)
+
+
+### Build System
+
+* bump eslint-plugin-jsdoc from 40.3.0 to 43.0.0 ([9d77f09](https://github.com/NickDJM/accessible-menu-bootstrap-4/commit/9d77f098502fe814c5635b1add8b6e50c3254e1b))
+* bump eslint-plugin-jsdoc from 43.2.0 to 44.2.4 ([fa5e7b2](https://github.com/NickDJM/accessible-menu-bootstrap-4/commit/fa5e7b2f453bc27b82a82d0a1e3fb88d136d91db))
+* bump eslint-plugin-jsdoc from 44.2.7 to 46.2.6 ([e1f6b50](https://github.com/NickDJM/accessible-menu-bootstrap-4/commit/e1f6b504f0223e6d11298bc34765fa55e64699e0))
+* bump jest-extended from 3.2.4 to 4.0.0 ([51a1375](https://github.com/NickDJM/accessible-menu-bootstrap-4/commit/51a13754bd17dbfd3824f706083d6bfc1d68e062))
+* **npm:** require at least accessible-menu v3.0.7 ([5e13166](https://github.com/NickDJM/accessible-menu-bootstrap-4/commit/5e13166182f1e70518a2f8418682828dce17d127))
+* **npm:** update all dependencies to latest ([4394ff8](https://github.com/NickDJM/accessible-menu-bootstrap-4/commit/4394ff8bdb55264acb9a9e035f78d4cd43c6dfa0))
+
### [1.0.3](https://github.com/NickDJM/accessible-menu-bootstrap-4/compare/v1.0.2...v1.0.3) (2023-02-17)
diff --git a/README.md b/README.md
index 29dd713..f745587 100644
--- a/README.md
+++ b/README.md
@@ -45,7 +45,7 @@ For learning/prototyping purposes you can use the latest version with:
For production environments, it is recommend to use a specific version to avoid unforseen breaking changes:
```html
-
+
```
## Usage
@@ -75,7 +75,7 @@ import AccessibleMenu from "accessible-menu-bootstrap-4";
or
```html
-
+
```
Once you have **accessible-menu-bootstrap-4** loaded, declare a new menu object.
@@ -103,7 +103,7 @@ import { Bootstrap4DisclosureMenu } from "accessible-menu-bootstrap-4";
or
```html
-
+
```
then
@@ -123,7 +123,7 @@ import { Bootstrap4Menubar } from "accessible-menu-bootstrap-4";
or
```html
-
+
```
then
@@ -143,7 +143,7 @@ import { Bootstrap4Treeview } from "accessible-menu-bootstrap-4";
or
```html
-
+
```
then
diff --git a/dist/accessible-menu-bs4.js b/dist/accessible-menu-bs4.js
index b341cb8..bd4e803 100644
--- a/dist/accessible-menu-bs4.js
+++ b/dist/accessible-menu-bs4.js
@@ -158,10 +158,28 @@ var AccessibleMenuBootstrap4 = (function () {
}
}
- function _defineProperty$b(obj, key, value) { key = _toPropertyKey$b(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
- function _toPropertyKey$b(arg) { var key = _toPrimitive$b(arg, "string"); return typeof key === "symbol" ? key : String(key); }
- function _toPrimitive$b(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenuToggle {
+ _dom = {
+ toggle: null,
+ parent: null
+ };
+ _elements = {
+ controlledMenu: null,
+ parentMenu: null
+ };
+ _open = false;
+ _expandEvent = new CustomEvent("accessibleMenuExpand", {
+ bubbles: true,
+ detail: {
+ toggle: this
+ }
+ });
+ _collapseEvent = new CustomEvent("accessibleMenuCollapse", {
+ bubbles: true,
+ detail: {
+ toggle: this
+ }
+ });
constructor(_ref) {
let {
menuToggleElement,
@@ -169,27 +187,6 @@ var AccessibleMenuBootstrap4 = (function () {
controlledMenu,
parentMenu = null
} = _ref;
- _defineProperty$b(this, "_dom", {
- toggle: null,
- parent: null
- });
- _defineProperty$b(this, "_elements", {
- controlledMenu: null,
- parentMenu: null
- });
- _defineProperty$b(this, "_open", false);
- _defineProperty$b(this, "_expandEvent", new CustomEvent("accessibleMenuExpand", {
- bubbles: true,
- detail: {
- toggle: this
- }
- }));
- _defineProperty$b(this, "_collapseEvent", new CustomEvent("accessibleMenuCollapse", {
- bubbles: true,
- detail: {
- toggle: this
- }
- }));
this._dom.toggle = menuToggleElement;
this._dom.parent = parentElement;
this._elements.controlledMenu = controlledMenu;
@@ -334,10 +331,17 @@ var AccessibleMenuBootstrap4 = (function () {
}
}
- function _defineProperty$a(obj, key, value) { key = _toPropertyKey$a(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
- function _toPropertyKey$a(arg) { var key = _toPrimitive$a(arg, "string"); return typeof key === "symbol" ? key : String(key); }
- function _toPrimitive$a(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenuItem {
+ _dom = {
+ item: null,
+ link: null
+ };
+ _elements = {
+ parentMenu: null,
+ childMenu: null,
+ toggle: null
+ };
+ _submenu = false;
constructor(_ref) {
let {
menuItemElement,
@@ -347,16 +351,6 @@ var AccessibleMenuBootstrap4 = (function () {
childMenu = null,
toggle = null
} = _ref;
- _defineProperty$a(this, "_dom", {
- item: null,
- link: null
- });
- _defineProperty$a(this, "_elements", {
- parentMenu: null,
- childMenu: null,
- toggle: null
- });
- _defineProperty$a(this, "_submenu", false);
this._dom.item = menuItemElement;
this._dom.link = menuLinkElement;
this._elements.parentMenu = parentMenu;
@@ -413,10 +407,41 @@ var AccessibleMenuBootstrap4 = (function () {
event.stopPropagation();
}
- function _defineProperty$9(obj, key, value) { key = _toPropertyKey$9(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
- function _toPropertyKey$9(arg) { var key = _toPrimitive$9(arg, "string"); return typeof key === "symbol" ? key : String(key); }
- function _toPrimitive$9(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class BaseMenu {
+ _MenuType = BaseMenu;
+ _MenuItemType = BaseMenuItem;
+ _MenuToggleType = BaseMenuToggle;
+ _dom = {
+ menu: null,
+ menuItems: [],
+ submenuItems: [],
+ submenuToggles: [],
+ submenus: [],
+ controller: null,
+ container: null
+ };
+ _selectors = {
+ menuItems: "",
+ menuLinks: "",
+ submenuItems: "",
+ submenuToggles: "",
+ submenus: ""
+ };
+ _elements = {
+ menuItems: [],
+ submenuToggles: [],
+ controller: null,
+ parentMenu: null,
+ rootMenu: null
+ };
+ _openClass = "show";
+ _closeClass = "hide";
+ _root = true;
+ _currentChild = 0;
+ _focusState = "none";
+ _currentEvent = "none";
+ _hoverType = "off";
+ _hoverDelay = 250;
constructor(_ref) {
let {
menuElement,
@@ -434,40 +459,6 @@ var AccessibleMenuBootstrap4 = (function () {
hoverType = "off",
hoverDelay = 250
} = _ref;
- _defineProperty$9(this, "_MenuType", BaseMenu);
- _defineProperty$9(this, "_MenuItemType", BaseMenuItem);
- _defineProperty$9(this, "_MenuToggleType", BaseMenuToggle);
- _defineProperty$9(this, "_dom", {
- menu: null,
- menuItems: [],
- submenuItems: [],
- submenuToggles: [],
- submenus: [],
- controller: null,
- container: null
- });
- _defineProperty$9(this, "_selectors", {
- menuItems: "",
- menuLinks: "",
- submenuItems: "",
- submenuToggles: "",
- submenus: ""
- });
- _defineProperty$9(this, "_elements", {
- menuItems: [],
- submenuToggles: [],
- controller: null,
- parentMenu: null,
- rootMenu: null
- });
- _defineProperty$9(this, "_openClass", "show");
- _defineProperty$9(this, "_closeClass", "hide");
- _defineProperty$9(this, "_root", true);
- _defineProperty$9(this, "_currentChild", 0);
- _defineProperty$9(this, "_focusState", "none");
- _defineProperty$9(this, "_currentEvent", "none");
- _defineProperty$9(this, "_hoverType", "off");
- _defineProperty$9(this, "_hoverDelay", 250);
this._dom.menu = menuElement;
this._dom.controller = controllerElement;
this._dom.container = containerElement;
@@ -920,8 +911,10 @@ var AccessibleMenuBootstrap4 = (function () {
const key = keyPress(event);
if (key === "Space" || key === "Enter") {
preventEvent(event);
- this.elements.controller.open();
- this.focusFirstChild();
+ this.elements.controller.toggle();
+ if (this.elements.controller.isOpen) {
+ this.focusFirstChild();
+ }
}
});
}
@@ -1064,10 +1057,12 @@ var AccessibleMenuBootstrap4 = (function () {
}
}
- function _defineProperty$8(obj, key, value) { key = _toPropertyKey$8(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
- function _toPropertyKey$8(arg) { var key = _toPrimitive$8(arg, "string"); return typeof key === "symbol" ? key : String(key); }
- function _toPrimitive$8(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class DisclosureMenu extends BaseMenu {
+ _MenuType = DisclosureMenu;
+ _MenuItemType = DisclosureMenuItem;
+ _MenuToggleType = DisclosureMenuToggle;
+ _currentChild = -1;
+ _optionalSupport = false;
constructor(_ref) {
let {
menuElement,
@@ -1103,11 +1098,6 @@ var AccessibleMenuBootstrap4 = (function () {
hoverType,
hoverDelay
});
- _defineProperty$8(this, "_MenuType", DisclosureMenu);
- _defineProperty$8(this, "_MenuItemType", DisclosureMenuItem);
- _defineProperty$8(this, "_MenuToggleType", DisclosureMenuToggle);
- _defineProperty$8(this, "_currentChild", -1);
- _defineProperty$8(this, "_optionalSupport", false);
this._optionalSupport = optionalKeySupport;
if (initialize) {
this.initialize();
@@ -1264,10 +1254,12 @@ var AccessibleMenuBootstrap4 = (function () {
}
}
- function _defineProperty$7(obj, key, value) { key = _toPropertyKey$7(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
- function _toPropertyKey$7(arg) { var key = _toPrimitive$7(arg, "string"); return typeof key === "symbol" ? key : String(key); }
- function _toPrimitive$7(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Bootstrap4DisclosureMenuToggle extends DisclosureMenuToggle {
+ _dom = {
+ toggle: null,
+ parent: null,
+ container: null
+ };
constructor(_ref) {
let {
menuToggleElement,
@@ -1283,11 +1275,6 @@ var AccessibleMenuBootstrap4 = (function () {
parentMenu,
initialize: false
});
- _defineProperty$7(this, "_dom", {
- toggle: null,
- parent: null,
- container: null
- });
this._dom.toggle = menuToggleElement;
this._dom.parent = parentElement;
this._dom.container = controlledMenu.isTopLevel ? controlledMenu.dom.container : controlledMenu.dom.menu;
@@ -1348,10 +1335,10 @@ var AccessibleMenuBootstrap4 = (function () {
}
}
- function _defineProperty$6(obj, key, value) { key = _toPropertyKey$6(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
- function _toPropertyKey$6(arg) { var key = _toPrimitive$6(arg, "string"); return typeof key === "symbol" ? key : String(key); }
- function _toPrimitive$6(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Bootstrap4DisclosureMenu extends DisclosureMenu {
+ _MenuType = Bootstrap4DisclosureMenu;
+ _MenuItemType = Bootstrap4DisclosureMenuItem;
+ _MenuToggleType = Bootstrap4DisclosureMenuToggle;
constructor(_ref) {
let {
menuElement,
@@ -1389,9 +1376,6 @@ var AccessibleMenuBootstrap4 = (function () {
optionalKeySupport,
initialize: false
});
- _defineProperty$6(this, "_MenuType", Bootstrap4DisclosureMenu);
- _defineProperty$6(this, "_MenuItemType", Bootstrap4DisclosureMenuItem);
- _defineProperty$6(this, "_MenuToggleType", Bootstrap4DisclosureMenuToggle);
if (initialize) {
this.initialize();
}
@@ -1476,10 +1460,10 @@ var AccessibleMenuBootstrap4 = (function () {
}
}
- function _defineProperty$5(obj, key, value) { key = _toPropertyKey$5(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
- function _toPropertyKey$5(arg) { var key = _toPrimitive$5(arg, "string"); return typeof key === "symbol" ? key : String(key); }
- function _toPrimitive$5(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Menubar extends BaseMenu {
+ _MenuType = Menubar;
+ _MenuItemType = MenubarItem;
+ _MenuToggleType = MenubarToggle;
constructor(_ref) {
let {
menuElement,
@@ -1514,9 +1498,6 @@ var AccessibleMenuBootstrap4 = (function () {
hoverType,
hoverDelay
});
- _defineProperty$5(this, "_MenuType", Menubar);
- _defineProperty$5(this, "_MenuItemType", MenubarItem);
- _defineProperty$5(this, "_MenuToggleType", MenubarToggle);
if (initialize) {
this.initialize();
}
@@ -1524,7 +1505,11 @@ var AccessibleMenuBootstrap4 = (function () {
initialize() {
try {
super.initialize();
- this.dom.menu.setAttribute("role", "menubar");
+ if (this.isTopLevel) {
+ this.dom.menu.setAttribute("role", "menubar");
+ } else {
+ this.dom.menu.setAttribute("role", "menu");
+ }
this._handleFocus();
this._handleClick();
this._handleHover();
@@ -1802,10 +1787,12 @@ var AccessibleMenuBootstrap4 = (function () {
}
}
- function _defineProperty$4(obj, key, value) { key = _toPropertyKey$4(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
- function _toPropertyKey$4(arg) { var key = _toPrimitive$4(arg, "string"); return typeof key === "symbol" ? key : String(key); }
- function _toPrimitive$4(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Bootstrap4MenubarToggle extends MenubarToggle {
+ _dom = {
+ toggle: null,
+ parent: null,
+ container: null
+ };
constructor(_ref) {
let {
menuToggleElement,
@@ -1821,11 +1808,6 @@ var AccessibleMenuBootstrap4 = (function () {
parentMenu,
initialize: false
});
- _defineProperty$4(this, "_dom", {
- toggle: null,
- parent: null,
- container: null
- });
this._dom.toggle = menuToggleElement;
this._dom.parent = parentElement;
this._dom.container = controlledMenu.isTopLevel ? controlledMenu.dom.container : controlledMenu.dom.menu;
@@ -1886,10 +1868,10 @@ var AccessibleMenuBootstrap4 = (function () {
}
}
- function _defineProperty$3(obj, key, value) { key = _toPropertyKey$3(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
- function _toPropertyKey$3(arg) { var key = _toPrimitive$3(arg, "string"); return typeof key === "symbol" ? key : String(key); }
- function _toPrimitive$3(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Bootstrap4Menubar extends Menubar {
+ _MenuType = Bootstrap4Menubar;
+ _MenuItemType = Bootstrap4MenubarItem;
+ _MenuToggleType = Bootstrap4MenubarToggle;
constructor(_ref) {
let {
menuElement,
@@ -1925,9 +1907,6 @@ var AccessibleMenuBootstrap4 = (function () {
hoverDelay,
initialize: false
});
- _defineProperty$3(this, "_MenuType", Bootstrap4Menubar);
- _defineProperty$3(this, "_MenuItemType", Bootstrap4MenubarItem);
- _defineProperty$3(this, "_MenuToggleType", Bootstrap4MenubarToggle);
if (initialize) {
this.initialize();
}
@@ -1994,10 +1973,10 @@ var AccessibleMenuBootstrap4 = (function () {
}
}
- function _defineProperty$2(obj, key, value) { key = _toPropertyKey$2(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
- function _toPropertyKey$2(arg) { var key = _toPrimitive$2(arg, "string"); return typeof key === "symbol" ? key : String(key); }
- function _toPrimitive$2(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Treeview extends BaseMenu {
+ _MenuType = Treeview;
+ _MenuItemType = TreeviewItem;
+ _MenuToggleType = TreeviewToggle;
constructor(_ref) {
let {
menuElement,
@@ -2032,9 +2011,6 @@ var AccessibleMenuBootstrap4 = (function () {
hoverType,
hoverDelay
});
- _defineProperty$2(this, "_MenuType", Treeview);
- _defineProperty$2(this, "_MenuItemType", TreeviewItem);
- _defineProperty$2(this, "_MenuToggleType", TreeviewToggle);
if (initialize) {
this.initialize();
}
@@ -2273,10 +2249,12 @@ var AccessibleMenuBootstrap4 = (function () {
}
}
- function _defineProperty$1(obj, key, value) { key = _toPropertyKey$1(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
- function _toPropertyKey$1(arg) { var key = _toPrimitive$1(arg, "string"); return typeof key === "symbol" ? key : String(key); }
- function _toPrimitive$1(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Bootstrap4TreeviewToggle extends TreeviewToggle {
+ _dom = {
+ toggle: null,
+ parent: null,
+ container: null
+ };
constructor(_ref) {
let {
menuToggleElement,
@@ -2292,11 +2270,6 @@ var AccessibleMenuBootstrap4 = (function () {
parentMenu,
initialize: false
});
- _defineProperty$1(this, "_dom", {
- toggle: null,
- parent: null,
- container: null
- });
this._dom.toggle = menuToggleElement;
this._dom.parent = parentElement;
this._dom.container = controlledMenu.isTopLevel ? controlledMenu.dom.container : controlledMenu.dom.menu;
@@ -2357,10 +2330,10 @@ var AccessibleMenuBootstrap4 = (function () {
}
}
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class Bootstrap4Treeview extends Treeview {
+ _MenuType = Bootstrap4Treeview;
+ _MenuItemType = Bootstrap4TreeviewItem;
+ _MenuToggleType = Bootstrap4TreeviewToggle;
constructor(_ref) {
let {
menuElement,
@@ -2396,9 +2369,6 @@ var AccessibleMenuBootstrap4 = (function () {
hoverDelay,
initialize: false
});
- _defineProperty(this, "_MenuType", Bootstrap4Treeview);
- _defineProperty(this, "_MenuItemType", Bootstrap4TreeviewItem);
- _defineProperty(this, "_MenuToggleType", Bootstrap4TreeviewToggle);
if (initialize) {
this.initialize();
}
diff --git a/dist/accessible-menu-bs4.js.map b/dist/accessible-menu-bs4.js.map
index e7b54d8..a1cea46 100644
--- a/dist/accessible-menu-bs4.js.map
+++ b/dist/accessible-menu-bs4.js.map
@@ -1 +1 @@
-{"version":3,"file":"accessible-menu-bs4.js","sources":["../node_modules/accessible-menu/src/validate.js","../node_modules/accessible-menu/src/_baseMenuToggle.js","../node_modules/accessible-menu/src/_baseMenuItem.js","../node_modules/accessible-menu/src/eventHandlers.js","../node_modules/accessible-menu/src/_baseMenu.js","../node_modules/accessible-menu/src/disclosureMenuItem.js","../node_modules/accessible-menu/src/disclosureMenuToggle.js","../node_modules/accessible-menu/src/disclosureMenu.js","../src/bootstrap4DisclosureMenuItem.js","../src/bootstrap4DisclosureMenuToggle.js","../src/bootstrap4DisclosureMenu.js","../node_modules/accessible-menu/src/menubarItem.js","../node_modules/accessible-menu/src/menubarToggle.js","../node_modules/accessible-menu/src/menubar.js","../src/bootstrap4MenubarItem.js","../src/bootstrap4MenubarToggle.js","../src/bootstrap4Menubar.js","../node_modules/accessible-menu/src/treeviewItem.js","../node_modules/accessible-menu/src/treeviewToggle.js","../node_modules/accessible-menu/src/treeview.js","../src/bootstrap4TreeviewItem.js","../src/bootstrap4TreeviewToggle.js","../src/bootstrap4Treeview.js","../rollup.js"],"sourcesContent":["/**\n * Check to see if the provided elements have a specific contructor.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * This is essentially just a wrapper function around checking instanceof with\n * more descriptive error message to help debugging.\n *\n * Will return true is the check is successful.\n *\n * @param {object} contructor - The constructor to check for.\n * @param {object} elements - The element(s) to check.\n * @return {boolean} - The result of the check.\n */\nexport function isValidInstance(contructor, elements) {\n try {\n if (typeof elements !== \"object\") {\n const elementsType = typeof elements;\n\n throw new TypeError(\n `AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ${elementsType} given.`\n );\n }\n\n for (const key in elements) {\n if (!(elements[key] instanceof contructor)) {\n const elementType = typeof elements[key];\n throw new TypeError(\n `AccessibleMenu: ${key} must be an instance of ${contructor.name}. ${elementType} given.`\n );\n }\n }\n\n return true;\n } catch (error) {\n console.error(error);\n return false;\n }\n}\n\n/**\n * Check to see if the provided values are of a specific type.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * This is essentially just a wrapper function around checking typeof with\n * more descriptive error message to help debugging.\n *\n * Will return true is the check is successful.\n *\n * @param {string} type - The type to check for.\n * @param {object} values - The value(s) to check.\n * @return {boolean} - The result of the check.\n */\nexport function isValidType(type, values) {\n try {\n if (typeof values !== \"object\") {\n const valuesType = typeof values;\n\n throw new TypeError(\n `AccessibleMenu: Values given to isValidType() must be inside of an object. ${valuesType} given.`\n );\n }\n\n for (const key in values) {\n const valueType = typeof values[key];\n\n if (valueType !== type) {\n throw new TypeError(\n `AccessibleMenu: ${key} must be a ${type}. ${valueType} given.`\n );\n }\n }\n\n return true;\n } catch (error) {\n console.error(error);\n return false;\n }\n}\n\n/**\n * Checks to see if the provided values are valid CSS selectors.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return true is the check is successful.\n *\n * @param {Object} values - The value(s) to check.\n * @return {boolean} - The result of the check.\n */\nexport function isCSSSelector(values) {\n try {\n if (typeof values !== \"object\") {\n const type = typeof values;\n\n throw new TypeError(\n `AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ${type} given.`\n );\n }\n\n for (const key in values) {\n try {\n if (values[key] === null) {\n throw new Error();\n }\n\n document.querySelector(values[key]);\n } catch (error) {\n throw new TypeError(\n `AccessibleMenu: ${key} must be a valid CSS selector. \"${values[key]}\" given.`\n );\n }\n }\n\n return true;\n } catch (error) {\n console.error(error);\n return false;\n }\n}\n\n/**\n * Checks to see if the provided value is either a string or an array of strings.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return true is the check is successful.\n *\n * @param {Object} values - The value(s) to check.\n * @return {boolean} - The result of the check.\n */\nexport function isValidClassList(values) {\n try {\n if (typeof values !== \"object\" || Array.isArray(values)) {\n const type = typeof values;\n\n throw new TypeError(\n `AccessibleMenu: Values given to isValidClassList() must be inside of an object. ${type} given.`\n );\n }\n\n for (const key in values) {\n const type = typeof values[key];\n\n if (type !== \"string\") {\n if (Array.isArray(values[key])) {\n values[key].forEach((value) => {\n if (typeof value !== \"string\") {\n throw new TypeError(\n `AccessibleMenu: ${key} must be a string or an array of strings. An array containing non-strings given.`\n );\n }\n });\n } else {\n throw new TypeError(\n `AccessibleMenu: ${key} must be a string or an array of strings. ${type} given.`\n );\n }\n } else {\n const obj = {};\n obj[key] = values[key];\n\n isCSSSelector(obj);\n }\n }\n\n return true;\n } catch (error) {\n console.error(error);\n return false;\n }\n}\n\n/**\n * Check to see if the provided values are valid focus states for a menu.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return true is the check is successful.\n *\n * @param {Object} values - The value(s) to check.\n * @return {boolean} - The result of the check.\n */\nexport function isValidState(values) {\n try {\n if (typeof values !== \"object\") {\n const type = typeof values;\n\n throw new TypeError(\n `AccessibleMenu: Values given to isValidState() must be inside of an object. ${type} given.`\n );\n }\n\n const validStates = [\"none\", \"self\", \"child\"];\n\n for (const key in values) {\n if (!validStates.includes(values[key])) {\n throw new TypeError(\n `AccessibleMenu: ${key} must be one of the following values: ${validStates.join(\n \", \"\n )}. \"${values[key]}\" given.`\n );\n }\n }\n\n return true;\n } catch (error) {\n console.error(error);\n return false;\n }\n}\n\n/**\n * Check to see if the provided values are valid event types for a menu.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return true is the check is successful.\n *\n * @param {Object} values - The value(s) to check.\n * @return {boolean} - The result of the check.\n */\nexport function isValidEvent(values) {\n try {\n if (typeof values !== \"object\") {\n const type = typeof values;\n\n throw new TypeError(\n `AccessibleMenu: Values given to isValidEvent() must be inside of an object. ${type} given.`\n );\n }\n\n const validEvents = [\"none\", \"mouse\", \"keyboard\", \"character\"];\n\n for (const key in values) {\n if (!validEvents.includes(values[key])) {\n throw new TypeError(\n `AccessibleMenu: ${key} must be one of the following values: ${validEvents.join(\n \", \"\n )}. \"${values[key]}\" given.`\n );\n }\n }\n\n return true;\n } catch (error) {\n console.error(error);\n return false;\n }\n}\n\n/**\n * Check to see if the provided values are valid hover types for a menu.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return true is the check is successful.\n *\n * @param {Object} values - The value(s) to check.\n * @return {boolean} - The result of the check.\n */\nexport function isValidHoverType(values) {\n try {\n if (typeof values !== \"object\") {\n const type = typeof values;\n\n throw new TypeError(\n `AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ${type} given.`\n );\n }\n\n const validTypes = [\"off\", \"on\", \"dynamic\"];\n\n for (const key in values) {\n if (!validTypes.includes(values[key])) {\n throw new TypeError(\n `AccessibleMenu: ${key} must be one of the following values: ${validTypes.join(\n \", \"\n )}. \"${values[key]}\" given.`\n );\n }\n }\n\n return true;\n } catch (error) {\n console.error(error);\n return false;\n }\n}\n\n/**\n * Checks to see if the provided elements are using a specific tag.\n *\n * The elements must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * @param {string} tagName - The name of the tag.\n * @param {Object} elements - The element(s) to check.\n * @return {boolean} - The result of the check.\n */\nexport function isTag(tagName, elements) {\n if (\n isValidType(\"string\", { tagName }) &&\n isValidInstance(HTMLElement, elements)\n ) {\n const tag = tagName.toLowerCase();\n let check = true;\n\n for (const key in elements) {\n if (elements[key].tagName.toLowerCase() !== tag) check = false;\n }\n\n return check;\n } else {\n return false;\n }\n}\n\n/**\n * Checks to see if an event is supported by a node.\n *\n * @param {string} event - The event type.\n * @param {HTMLElement} element - The element to check.\n * @return {boolean} - The result.\n *\n * @deprecated Will be removed in v4 unless there is a new found need for it.\n */\nexport function isEventSupported(event, element) {\n if (\n isValidType(\"string\", { event }) &&\n isValidInstance(HTMLElement, { element })\n ) {\n const eventProp = `on${event}`;\n\n return typeof element[eventProp] !== \"undefined\";\n } else {\n return false;\n }\n}\n","/* eslint-disable jsdoc/no-undefined-types */\n\nimport { isTag, isValidType } from \"./validate.js\";\n\n/**\n * A link or button that controls the visibility of a {@link BaseMenu}.\n */\nclass BaseMenuToggle {\n /**\n * The DOM elements within the menu toggle.\n *\n * @protected\n *\n * @type {Object}\n *\n * @property {HTMLElement} toggle - The menu toggle.\n * @property {HTMLElement} parent - The menu containing this toggle.\n */\n _dom = {\n toggle: null,\n parent: null,\n };\n\n /**\n * The declared accessible-menu elements within the menu toggle.\n *\n * @protected\n *\n * @type {Object}\n *\n * @property {BaseMenu} controlledMenu - The menu controlled by this toggle.\n * @property {BaseMenu} parentMenu - The menu containing this toggle.\n */\n _elements = {\n controlledMenu: null,\n parentMenu: null,\n };\n\n /**\n * The open state of the menu toggle.\n *\n * @protected\n *\n * @type {boolean}\n */\n _open = false;\n\n /**\n * Expand event.\n *\n * @protected\n *\n * @event accessibleMenuExpand\n *\n * @type {CustomEvent}\n *\n * @property {Object} details - The details object containing the BaseMenuToggle itself.\n */\n _expandEvent = new CustomEvent(\"accessibleMenuExpand\", {\n bubbles: true,\n detail: { toggle: this },\n });\n\n /**\n * Collapse event.\n *\n * @protected\n *\n * @event accessibleMenuCollapse\n *\n * @type {CustomEvent}\n *\n * @property {Object} details - The details object containing the BaseMenuToggle itself.\n */\n _collapseEvent = new CustomEvent(\"accessibleMenuCollapse\", {\n bubbles: true,\n detail: { toggle: this },\n });\n\n /**\n * Constructs the menu toggle.\n *\n * @param {object} options - The options for generating the menu toggle.\n * @param {HTMLElement} options.menuToggleElement - The toggle element in the DOM.\n * @param {HTMLElement} options.parentElement - The element containing the controlled menu.\n * @param {BaseMenu} options.controlledMenu - The menu controlled by this toggle.\n * @param {BaseMenu|null} [options.parentMenu = null] - The menu containing this toggle.\n */\n constructor({\n menuToggleElement,\n parentElement,\n controlledMenu,\n parentMenu = null,\n }) {\n // Set DOM elements.\n this._dom.toggle = menuToggleElement;\n this._dom.parent = parentElement;\n\n // Set menu elements.\n this._elements.controlledMenu = controlledMenu;\n this._elements.parentMenu = parentMenu;\n }\n\n /**\n * Initializes the menu toggle.\n *\n * Initialize does a lot of setup on the menu toggle.\n *\n * The most basic setup steps are to ensure that the toggle has `aria-haspopup`\n * set to \"true\", `aria-expanded` initially set to \"false\" and, if the toggle\n * element is not a `