From c7ea438ea042bbe4e9000fd68b95cf1a340fe150 Mon Sep 17 00:00:00 2001 From: Nick Milton Date: Mon, 27 Sep 2021 10:37:05 -0400 Subject: [PATCH] chore(release): 1.0.0 --- CHANGELOG.md | 13 +++++++++++++ dist/accessible-menu-bs4.js | 2 +- dist/accessible-menu-bs4.min.js | 2 +- dist/accessible-menu-bs4.min.js.map | 2 +- dist/disclosure-menu-bs4.esm.min.js | 2 +- dist/disclosure-menu-bs4.esm.min.js.map | 2 +- dist/disclosure-menu-bs4.js | 2 +- dist/disclosure-menu-bs4.min.js | 2 +- dist/disclosure-menu-bs4.min.js.map | 2 +- dist/menubar-bs4.esm.min.js | 2 +- dist/menubar-bs4.esm.min.js.map | 2 +- dist/menubar-bs4.js | 2 +- dist/menubar-bs4.min.js | 2 +- dist/menubar-bs4.min.js.map | 2 +- dist/treeview-bs4.esm.min.js | 2 +- dist/treeview-bs4.esm.min.js.map | 2 +- dist/treeview-bs4.js | 2 +- dist/treeview-bs4.min.js | 2 +- dist/treeview-bs4.min.js.map | 2 +- package.json | 2 +- 20 files changed, 32 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bac2da1..1e09044 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,19 @@ 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.0](https://github.com/NickDJM/accessible-menu-bootstrap-4/compare/v1.0.0-alpha.7...v1.0.0) (2021-09-27) + + +### Documentation + +* add usage docs ([379ab09](https://github.com/NickDJM/accessible-menu-bootstrap-4/commit/379ab096a474079542ccd2f8f91613106b1d0ab8)) +* update contrib/release documentation ([c571e1d](https://github.com/NickDJM/accessible-menu-bootstrap-4/commit/c571e1df55a61e55aa0510b0d3b37c7e0182c3bb)) + + +### Build System + +* **npm:** update dev dependencies to latest ([f297fc2](https://github.com/NickDJM/accessible-menu-bootstrap-4/commit/f297fc2307bc5af53c3ac594499d2733f20e826e)) + ## [1.0.0-alpha.7](https://github.com/NickDJM/accessible-menu-bootstrap-4/compare/v1.0.0-alpha.6...v1.0.0-alpha.7) (2021-09-16) diff --git a/dist/accessible-menu-bs4.js b/dist/accessible-menu-bs4.js index 7dd777e..93cd6ec 100644 --- a/dist/accessible-menu-bs4.js +++ b/dist/accessible-menu-bs4.js @@ -3099,5 +3099,5 @@ var AccessibleMenuBootstrap4 = (function () { return rollup; -}()); +})(); //# sourceMappingURL=accessible-menu-bs4.js.map diff --git a/dist/accessible-menu-bs4.min.js b/dist/accessible-menu-bs4.min.js index 1bc427c..1dfa1b1 100644 --- a/dist/accessible-menu-bs4.min.js +++ b/dist/accessible-menu-bs4.min.js @@ -1,2 +1,2 @@ -var AccessibleMenuBootstrap4=function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ".concat(o," given."))}for(var r in n)if(!(n[r]instanceof t)){var i=e(n[r]);throw new TypeError("AccessibleMenu: ".concat(r," must be an instance of ").concat(t.name,". ").concat(i," given."))}return!0}catch(e){return console.error(e),!1}}function n(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Values given to isValidType() must be inside of an object. ".concat(o," given."))}for(var r in n){var i=e(n[r]);if(i!==t)throw new TypeError("AccessibleMenu: ".concat(r," must be a ").concat(t,". ").concat(i," given."))}return!0}catch(e){return console.error(e),!1}}function o(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ".concat(n," given."))}for(var o in t)try{if(null===t[o])throw new Error;document.querySelector(t[o])}catch(e){throw new TypeError("AccessibleMenu: ".concat(o,' must be a valid CSS selector. "').concat(t[o],'" given.'))}return!0}catch(e){return console.error(e),!1}}function r(t){try{if("object"!==e(t)||Array.isArray(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidClassList() must be inside of an object. ".concat(n," given."))}var r=function(n){var r=e(t[n]);if("string"!==r){if(!Array.isArray(t[n]))throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. ").concat(r," given."));t[n].forEach((function(e){if("string"!=typeof e)throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. An array containing non-strings given."))}))}else{var i={};i[n]=t[n],o(i)}};for(var i in t)r(i);return!0}catch(e){return console.error(e),!1}}function i(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ".concat(n," given."))}var o=["off","on","dynamic"];for(var r in t)if(!o.includes(t[r]))throw new TypeError("AccessibleMenu: ".concat(r," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[r],'" given.'));return!0}catch(e){return console.error(e),!1}}function u(e,o){return!(!n("string",{event:e})||!t(HTMLElement,{element:o}))&&void 0!==o["on".concat(e)]}function l(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n0&&((o=o.toLowerCase().replace(/\s+/g,"-")).startsWith("-")&&(o=o.substring(1)),o.endsWith("-")&&(o=o.slice(0,-1)),r="".concat(o,"-").concat(r)),this.dom.toggle.id=this.dom.toggle.id||"".concat(r,"-menu-button"),this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||"".concat(r,"-menu")}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isOpen",get:function(){return this._open},set:function(e){n("boolean",{value:e}),this._open=e}},{key:"_expand",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,r=o.closeClass,i=o.openClass;this.dom.toggle.setAttribute("aria-expanded","true"),""!==i&&("string"==typeof i?this.elements.controlledMenu.dom.menu.classList.add(i):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,l(i))),""!==r&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.remove(r):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,l(r))),n&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,r=o.closeClass,i=o.openClass;this.dom.toggle.setAttribute("aria-expanded","false"),""!==r&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.add(r):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,l(r))),""!==i&&("string"==typeof i?this.elements.controlledMenu.dom.menu.classList.remove(i):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,l(i))),n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}},{key:"open",value:function(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}},{key:"preview",value:function(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}},{key:"close",value:function(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}},{key:"toggle",value:function(){this.isOpen?this.close():this.open()}},{key:"closeSiblings",value:function(){var e=this;this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach((function(t){t!==e&&t.close()}))}},{key:"closeChildren",value:function(){this.elements.controlledMenu.elements.submenuToggles.forEach((function(e){return e.close()}))}}])&&s(o.prototype,r),i&&s(o,i),e}();function m(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,o=new Array(t);n=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}},{key:"focusState",get:function(){return this._focusState},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidState() must be inside of an object. ".concat(n," given."))}var o=["none","self","child"];for(var r in t)if(!o.includes(t[r]))throw new TypeError("AccessibleMenu: ".concat(r," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[r],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._focusState!==t&&(this._focusState=t),this.elements.submenuToggles.length>0&&("self"===t||"none"===t)&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==t&&"child"!==t||(this.elements.parentMenu.focusState="child")}},{key:"currentEvent",get:function(){return this._currentEvent},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidEvent() must be inside of an object. ".concat(n," given."))}var o=["none","mouse","keyboard","character"];for(var r in t)if(!o.includes(t[r]))throw new TypeError("AccessibleMenu: ".concat(r," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[r],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._currentEvent!==t&&(this._currentEvent=t,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.currentEvent=t})))}},{key:"currentMenuItem",get:function(){return this.elements.menuItems[this.currentChild]}},{key:"hoverType",get:function(){return this._root?this._hoverType:this.elements.rootMenu.hoverType},set:function(e){i({value:e}),this._hoverType!==e&&(this._hoverType=e)}},{key:"hoverDelay",get:function(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay},set:function(e){n("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}},{key:"shouldFocus",get:function(){var e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}},{key:"_validate",value:function(){var e=!0;return null!==this._dom.container||null!==this._dom.controller?t(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(e=!1):t(HTMLElement,{menuElement:this._dom.menu})||(e=!1),""!==this._selectors.submenuItems?o({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(e=!1):o({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(e=!1),""===this._openClass||r({openClass:this._openClass})||(e=!1),""===this._closeClass||r({closeClass:this._closeClass})||(e=!1),n("boolean",{isTopLevel:this._root})||(e=!1),null===this._elements.parentMenu||t(l,{parentMenu:this._elements.parentMenu})||(e=!1),i({hoverType:this._hoverType})||(e=!1),n("number",{hoverDelay:this._hoverDelay})||(e=!1),e}},{key:"_setDOMElementType",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be set through _setDOMElementType.'));n!==this.dom.menu&&t(HTMLElement,{base:n});var r=Array.from(n.querySelectorAll(this.selectors[e])),i=r.filter((function(e){return e.parentElement===n}));this._dom[e]=o?i:[].concat(v(this._dom[e]),v(i))}},{key:"_resetDOMElementType",value:function(e){if(void 0===this.dom[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be reset through _resetDOMElementType.'));this._dom[e]=[]}},{key:"_setDOMElements",value:function(){var e=this;this._setDOMElementType("menuItems"),""!==this.selectors.submenuItems&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach((function(t){e._setDOMElementType("submenuToggles",t,!1),e._setDOMElementType("submenus",t,!1)})))}},{key:"_findRootMenu",value:function(e){if(e.isTopLevel)this._elements.rootMenu=e;else{if(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}},{key:"_createChildElements",value:function(){var e=this;this.dom.menuItems.forEach((function(t){var n;if(e.dom.submenuItems.includes(t)){var o=t.querySelector(e.selectors.submenuToggles),r=t.querySelector(e.selectors.submenus),i=new e._MenuType({menuElement:r,menuItemSelector:e.selectors.menuItems,menuLinkSelector:e.selectors.menuLinks,submenuItemSelector:e.selectors.submenuItems,submenuToggleSelector:e.selectors.submenuToggles,submenuSelector:e.selectors.submenus,openClass:e.openClass,closeClass:e.closeClass,isTopLevel:!1,parentMenu:e,hoverType:e.hoverType,hoverDelay:e.hoverDelay}),u=new e._MenuToggleType({menuToggleElement:o,parentElement:t,controlledMenu:i,parentMenu:e});e._elements.submenuToggles.push(u),n=new e._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:e,isSubmenuItem:!0,childMenu:i,toggle:u})}else{var l=t.querySelector(e.selectors.menuLinks);n=new e._MenuItemType({menuItemElement:t,menuLinkElement:l,parentMenu:e})}e._elements.menuItems.push(n)}))}},{key:"_handleFocus",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("focus",(function(){e.focusState="self",e.currentChild=n}))}))}},{key:"_handleClick",value:function(){var e=this,t=u("touchstart",this.dom.menu)?"touchstart":"mousedown",n=u("touchend",this.dom.menu)?"touchend":"mouseup";function o(e,t,n){d(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((function(r,i){r.dom.link.addEventListener(t,(function(){e.currentEvent="mouse",e.elements.rootMenu.blurChildren(),e.focusChild(i)})),r.isSubmenuItem&&(r.elements.toggle.dom.toggle["on".concat(n)]=function(t){e.currentEvent="mouse",o(e,r.elements.toggle,t)})})),this.isTopLevel&&this.elements.controller&&(this.elements.controller.dom.toggle["on".concat(n)]=function(t){e.currentEvent="mouse",o(e,e.elements.controller,t)})}},{key:"_handleHover",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("mouseenter",(function(){if("on"===e.hoverType)e.currentEvent="mouse",e.currentChild=n,t.isSubmenuItem&&t.elements.toggle.preview();else if("dynamic"===e.hoverType){var o=e.elements.submenuToggles.some((function(e){return e.isOpen}));e.currentChild=n,e.isTopLevel&&"none"===e.focusState||(e.currentEvent="mouse",e.focusCurrentChild()),!t.isSubmenuItem||e.isTopLevel&&!o||(e.currentEvent="mouse",t.elements.toggle.preview())}})),t.isSubmenuItem&&t.dom.item.addEventListener("mouseleave",(function(){"on"===e.hoverType?e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close()):"dynamic"===e.hoverType&&(e.isTopLevel||(e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild())))}))}))}},{key:"_handleKeydown",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=y(t);"Space"!==n&&"Enter"!==n||d(t)}))}},{key:"_handleKeyup",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=y(t);"Space"!==n&&"Enter"!==n||(d(t),e.elements.controller.open(),e.focusFirstChild())}))}},{key:"focus",value:function(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}},{key:"blur",value:function(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}},{key:"focusCurrentChild",value:function(){this.focusState="self",-1!==this.currentChild&&this.currentMenuItem.focus()}},{key:"focusChild",value:function(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}},{key:"focusFirstChild",value:function(){this.focusChild(0)}},{key:"focusLastChild",value:function(){this.focusChild(this.elements.menuItems.length-1)}},{key:"focusNextChild",value:function(){this.currentChild0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}},{key:"blurCurrentChild",value:function(){this.focusState="none",-1!==this.currentChild&&this.currentMenuItem.blur()}},{key:"focusController",value:function(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}},{key:"focusContainer",value:function(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}},{key:"closeChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.close()}))}},{key:"blurChildren",value:function(){this.elements.menuItems.forEach((function(e){e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()}))}}])&&g(c.prototype,s),a&&g(c,a),l}();function _(e){return(_="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function E(e,t){return(E=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function S(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=C(e);if(t){var r=C(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return O(this,n)}}function O(e,t){if(t&&("object"===_(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function C(e){return(C=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var T=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&E(e,t)}(n,e);var t=S(n);function n(e){var o,r=e.menuItemElement,i=e.menuLinkElement,u=e.parentMenu,l=e.isSubmenuItem,c=void 0!==l&&l,s=e.childMenu,a=void 0===s?null:s,f=e.toggle,m=void 0===f?null:f,p=e.initialize,h=void 0===p||p;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),o=t.call(this,{menuItemElement:r,menuLinkElement:i,parentMenu:u,isSubmenuItem:c,childMenu:a,toggle:m}),h&&o.initialize(),o}return n}(h);function I(e){return(I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function k(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,o=new Array(t);n0&&void 0!==arguments[0])||arguments[0],n=this.elements.controlledMenu.openClass;this.dom.toggle.setAttribute("aria-expanded","true"),""!==n&&("string"==typeof n?this.dom.container.classList.add(n):(e=this.dom.container.classList).add.apply(e,Y(n))),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,r=o.closeClass,i=o.openClass;this.dom.toggle.setAttribute("aria-expanded","false"),""!==r&&("string"==typeof r?this.dom.container.classList.add(r):(e=this.dom.container.classList).add.apply(e,Y(r))),""!==i&&("string"==typeof i?this.dom.container.classList.remove(i):(t=this.dom.container.classList).remove.apply(t,Y(i))),n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}])&&te(t.prototype,n),o&&te(t,o),i}(x);function se(e){return(se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ae(e,t){return(ae=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function fe(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=he(e);if(t){var r=he(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return me(this,n)}}function me(e,t){if(t&&("object"===se(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return pe(e)}function pe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function he(e){return(he=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ye(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var de=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ae(e,t)}(n,e);var t=fe(n);function n(e){var o,r=e.menuElement,i=e.menuItemSelector,u=void 0===i?".nav-item":i,l=e.menuLinkSelector,c=void 0===l?".nav-link,.dropdown-item":l,s=e.submenuItemSelector,a=void 0===s?".dropdown":s,f=e.submenuToggleSelector,m=void 0===f?".dropdown-toggle":f,p=e.submenuSelector,h=void 0===p?".dropdown-menu":p,y=e.controllerElement,d=void 0===y?null:y,v=e.containerElement,b=void 0===v?null:v,g=e.openClass,w=void 0===g?"show":g,M=e.closeClass,_=void 0===M?"collapse":M,E=e.isTopLevel,S=void 0===E||E,O=e.parentMenu,C=void 0===O?null:O,T=e.hoverType,I=void 0===T?"off":T,k=e.hoverDelay,j=void 0===k?250:k,A=e.optionalKeySupport,L=void 0!==A&&A,R=e.initialize,P=void 0===R||R;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),ye(pe(o=t.call(this,{menuElement:r,menuItemSelector:u,menuLinkSelector:c,submenuItemSelector:a,submenuToggleSelector:m,submenuSelector:h,controllerElement:d,containerElement:b,openClass:w,closeClass:_,isTopLevel:S,parentMenu:C,hoverType:I,hoverDelay:j,optionalKeySupport:L,initialize:!1})),"_MenuType",n),ye(pe(o),"_MenuItemType",Q),ye(pe(o),"_MenuToggleType",ce),P&&o.initialize(),o}return n}(q);function ve(e){return(ve="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function be(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,o=new Array(t);n0&&void 0!==arguments[0])||arguments[0],n=this.elements.controlledMenu.openClass;this.dom.toggle.setAttribute("aria-expanded","true"),""!==n&&("string"==typeof n?this.dom.container.classList.add(n):(e=this.dom.container.classList).add.apply(e,Je(n))),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,r=o.closeClass,i=o.openClass;this.dom.toggle.setAttribute("aria-expanded","false"),""!==r&&("string"==typeof r?this.dom.container.classList.add(r):(e=this.dom.container.classList).add.apply(e,Je(r))),""!==i&&("string"==typeof i?this.dom.container.classList.remove(i):(t=this.dom.container.classList).remove.apply(t,Je(i))),n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}])&&Xe(t.prototype,n),o&&Xe(t,o),i}(Le);function ut(e){return(ut="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function lt(e,t){return(lt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ct(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=ft(e);if(t){var r=ft(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return st(this,n)}}function st(e,t){if(t&&("object"===ut(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return at(e)}function at(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ft(e){return(ft=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function mt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var pt=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&<(e,t)}(n,e);var t=ct(n);function n(e){var o,r=e.menuElement,i=e.menuItemSelector,u=void 0===i?".nav-item":i,l=e.menuLinkSelector,c=void 0===l?".nav-link,.dropdown-item":l,s=e.submenuItemSelector,a=void 0===s?".dropdown":s,f=e.submenuToggleSelector,m=void 0===f?".dropdown-toggle":f,p=e.submenuSelector,h=void 0===p?".dropdown-menu":p,y=e.controllerElement,d=void 0===y?null:y,v=e.containerElement,b=void 0===v?null:v,g=e.openClass,w=void 0===g?"show":g,M=e.closeClass,_=void 0===M?"collapse":M,E=e.isTopLevel,S=void 0===E||E,O=e.parentMenu,C=void 0===O?null:O,T=e.hoverType,I=void 0===T?"off":T,k=e.hoverDelay,j=void 0===k?250:k,A=e.initialize,L=void 0===A||A;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),mt(at(o=t.call(this,{menuElement:r,menuItemSelector:u,menuLinkSelector:c,submenuItemSelector:a,submenuToggleSelector:m,submenuSelector:h,controllerElement:d,containerElement:b,openClass:w,closeClass:_,isTopLevel:S,parentMenu:C,hoverType:I,hoverDelay:j,initialize:!1})),"_MenuType",n),mt(at(o),"_MenuItemType",Ze),mt(at(o),"_MenuToggleType",it),L&&o.initialize(),o}return n}(He);function ht(e){return(ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function yt(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,o=new Array(t);ne.length)&&(t=e.length);for(var n=0,o=new Array(t);n0&&void 0!==arguments[0])||arguments[0],n=this.elements.controlledMenu.openClass;this.dom.toggle.setAttribute("aria-expanded","true"),""!==n&&("string"==typeof n?this.dom.container.classList.add(n):(e=this.dom.container.classList).add.apply(e,Wt(n))),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,r=o.closeClass,i=o.openClass;this.dom.toggle.setAttribute("aria-expanded","false"),""!==r&&("string"==typeof r?this.dom.container.classList.add(r):(e=this.dom.container.classList).add.apply(e,Wt(r))),""!==i&&("string"==typeof i?this.dom.container.classList.remove(i):(t=this.dom.container.classList).remove.apply(t,Wt(i))),n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}])&&Gt(t.prototype,n),o&&Gt(t,o),i}(Tt);function on(e){return(on="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function rn(e,t){return(rn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function un(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=sn(e);if(t){var r=sn(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return ln(this,n)}}function ln(e,t){if(t&&("object"===on(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return cn(e)}function cn(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function sn(e){return(sn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function an(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}return{Bootstrap4DisclosureMenu:de,Bootstrap4Menubar:pt,Bootstrap4Treeview:function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&rn(e,t)}(n,e);var t=un(n);function n(e){var o,r=e.menuElement,i=e.menuItemSelector,u=void 0===i?".nav-item":i,l=e.menuLinkSelector,c=void 0===l?".nav-link,.dropdown-item":l,s=e.submenuItemSelector,a=void 0===s?".dropdown":s,f=e.submenuToggleSelector,m=void 0===f?".dropdown-toggle":f,p=e.submenuSelector,h=void 0===p?".dropdown-menu":p,y=e.controllerElement,d=void 0===y?null:y,v=e.containerElement,b=void 0===v?null:v,g=e.openClass,w=void 0===g?"show":g,M=e.closeClass,_=void 0===M?"collapse":M,E=e.isTopLevel,S=void 0===E||E,O=e.parentMenu,C=void 0===O?null:O,T=e.hoverType,I=void 0===T?"off":T,k=e.hoverDelay,j=void 0===k?250:k,A=e.initialize,L=void 0===A||A;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),an(cn(o=t.call(this,{menuElement:r,menuItemSelector:u,menuLinkSelector:c,submenuItemSelector:a,submenuToggleSelector:m,submenuSelector:h,controllerElement:d,containerElement:b,openClass:w,closeClass:_,isTopLevel:S,parentMenu:C,hoverType:I,hoverDelay:j,initialize:!1})),"_MenuType",n),an(cn(o),"_MenuItemType",qt),an(cn(o),"_MenuToggleType",nn),L&&o.initialize(),o}return n}(Kt)}}(); +var AccessibleMenuBootstrap4=function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Elements given to isValidInstance() must be inside of an object. ".concat(o," given."))}for(var r in n)if(!(n[r]instanceof t)){var i=e(n[r]);throw new TypeError("AccessibleMenu: ".concat(r," must be an instance of ").concat(t.name,". ").concat(i," given."))}return!0}catch(e){return console.error(e),!1}}function n(t,n){try{if("object"!==e(n)){var o=e(n);throw new TypeError("AccessibleMenu: Values given to isValidType() must be inside of an object. ".concat(o," given."))}for(var r in n){var i=e(n[r]);if(i!==t)throw new TypeError("AccessibleMenu: ".concat(r," must be a ").concat(t,". ").concat(i," given."))}return!0}catch(e){return console.error(e),!1}}function o(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isCSSSelector() must be inside of an object. ".concat(n," given."))}for(var o in t)try{if(null===t[o])throw new Error;document.querySelector(t[o])}catch(e){throw new TypeError("AccessibleMenu: ".concat(o,' must be a valid CSS selector. "').concat(t[o],'" given.'))}return!0}catch(e){return console.error(e),!1}}function r(t){try{if("object"!==e(t)||Array.isArray(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidClassList() must be inside of an object. ".concat(n," given."))}var r=function(n){var r=e(t[n]);if("string"!==r){if(!Array.isArray(t[n]))throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. ").concat(r," given."));t[n].forEach((function(e){if("string"!=typeof e)throw new TypeError("AccessibleMenu: ".concat(n," must be a string or an array of strings. An array containing non-strings given."))}))}else{var i={};i[n]=t[n],o(i)}};for(var i in t)r(i);return!0}catch(e){return console.error(e),!1}}function i(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidHoverType() must be inside of an object. ".concat(n," given."))}var o=["off","on","dynamic"];for(var r in t)if(!o.includes(t[r]))throw new TypeError("AccessibleMenu: ".concat(r," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[r],'" given.'));return!0}catch(e){return console.error(e),!1}}function u(e,o){return!(!n("string",{event:e})||!t(HTMLElement,{element:o}))&&void 0!==o["on".concat(e)]}function l(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n0&&((o=o.toLowerCase().replace(/\s+/g,"-")).startsWith("-")&&(o=o.substring(1)),o.endsWith("-")&&(o=o.slice(0,-1)),r="".concat(o,"-").concat(r)),this.dom.toggle.id=this.dom.toggle.id||"".concat(r,"-menu-button"),this.elements.controlledMenu.dom.menu.id=this.elements.controlledMenu.dom.menu.id||"".concat(r,"-menu")}this.elements.controlledMenu.dom.menu.setAttribute("aria-labelledby",this.dom.toggle.id),this.dom.toggle.setAttribute("aria-controls",this.elements.controlledMenu.dom.menu.id),this._collapse(!1)}},{key:"dom",get:function(){return this._dom}},{key:"elements",get:function(){return this._elements}},{key:"isOpen",get:function(){return this._open},set:function(e){n("boolean",{value:e}),this._open=e}},{key:"_expand",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,r=o.closeClass,i=o.openClass;this.dom.toggle.setAttribute("aria-expanded","true"),""!==i&&("string"==typeof i?this.elements.controlledMenu.dom.menu.classList.add(i):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,l(i))),""!==r&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.remove(r):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,l(r))),n&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,r=o.closeClass,i=o.openClass;this.dom.toggle.setAttribute("aria-expanded","false"),""!==r&&("string"==typeof r?this.elements.controlledMenu.dom.menu.classList.add(r):(e=this.elements.controlledMenu.dom.menu.classList).add.apply(e,l(r))),""!==i&&("string"==typeof i?this.elements.controlledMenu.dom.menu.classList.remove(i):(t=this.elements.controlledMenu.dom.menu.classList).remove.apply(t,l(i))),n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}},{key:"open",value:function(){this.elements.controlledMenu.focusState="self",this._expand(),this.isOpen=!0}},{key:"preview",value:function(){this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._expand(),this.isOpen=!0}},{key:"close",value:function(){this.isOpen&&(this.elements.controlledMenu.currentChild=0,this.elements.controlledMenu.blur(),this.elements.parentMenu&&(this.elements.parentMenu.focusState="self"),this._collapse(),this.isOpen=!1)}},{key:"toggle",value:function(){this.isOpen?this.close():this.open()}},{key:"closeSiblings",value:function(){var e=this;this.elements.parentMenu&&this.elements.parentMenu.elements.submenuToggles.forEach((function(t){t!==e&&t.close()}))}},{key:"closeChildren",value:function(){this.elements.controlledMenu.elements.submenuToggles.forEach((function(e){return e.close()}))}}],r&&s(o.prototype,r),i&&s(o,i),e}();function m(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,o=new Array(t);n=this.elements.menuItems.length?(this._currentChild=this.elements.menuItems.length-1,t(this)):this.focusChild!==e&&(this._currentChild=e,t(this))}},{key:"focusState",get:function(){return this._focusState},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidState() must be inside of an object. ".concat(n," given."))}var o=["none","self","child"];for(var r in t)if(!o.includes(t[r]))throw new TypeError("AccessibleMenu: ".concat(r," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[r],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._focusState!==t&&(this._focusState=t),this.elements.submenuToggles.length>0&&("self"===t||"none"===t)&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.focusState="none"})),!this.elements.parentMenu||"self"!==t&&"child"!==t||(this.elements.parentMenu.focusState="child")}},{key:"currentEvent",get:function(){return this._currentEvent},set:function(t){!function(t){try{if("object"!==e(t)){var n=e(t);throw new TypeError("AccessibleMenu: Values given to isValidEvent() must be inside of an object. ".concat(n," given."))}var o=["none","mouse","keyboard","character"];for(var r in t)if(!o.includes(t[r]))throw new TypeError("AccessibleMenu: ".concat(r," must be one of the following values: ").concat(o.join(", "),'. "').concat(t[r],'" given.'))}catch(e){return console.error(e),!1}}({value:t}),this._currentEvent!==t&&(this._currentEvent=t,this.elements.submenuToggles.length>0&&this.elements.submenuToggles.forEach((function(e){e.elements.controlledMenu.currentEvent=t})))}},{key:"currentMenuItem",get:function(){return this.elements.menuItems[this.currentChild]}},{key:"hoverType",get:function(){return this._root?this._hoverType:this.elements.rootMenu.hoverType},set:function(e){i({value:e}),this._hoverType!==e&&(this._hoverType=e)}},{key:"hoverDelay",get:function(){return this._root?this._hoverDelay:this.elements.rootMenu.hoverDelay},set:function(e){n("number",{value:e}),this._hoverDelay!==e&&(this._hoverDelay=e)}},{key:"shouldFocus",get:function(){var e=!1;return"keyboard"!==this.currentEvent&&"character"!==this.currentEvent||(e=!0),"mouse"===this.currentEvent&&"dynamic"===this.hoverType&&(e=!0),e}},{key:"_validate",value:function(){var e=!0;return null!==this._dom.container||null!==this._dom.controller?t(HTMLElement,{menuElement:this._dom.menu,controllerElement:this._dom.controller,containerElement:this._dom.container})||(e=!1):t(HTMLElement,{menuElement:this._dom.menu})||(e=!1),""!==this._selectors.submenuItems?o({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks,submenuItemSelector:this._selectors.submenuItems,submenuToggleSelector:this._selectors.submenuToggles,submenuSelector:this._selectors.submenus})||(e=!1):o({menuItemSelector:this._selectors.menuItems,menuLinkSelector:this._selectors.menuLinks})||(e=!1),""===this._openClass||r({openClass:this._openClass})||(e=!1),""===this._closeClass||r({closeClass:this._closeClass})||(e=!1),n("boolean",{isTopLevel:this._root})||(e=!1),null===this._elements.parentMenu||t(l,{parentMenu:this._elements.parentMenu})||(e=!1),i({hoverType:this._hoverType})||(e=!1),n("number",{hoverDelay:this._hoverDelay})||(e=!1),e}},{key:"_setDOMElementType",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.dom.menu,o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if("string"!=typeof this.selectors[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be set through _setDOMElementType.'));n!==this.dom.menu&&t(HTMLElement,{base:n});var r=Array.from(n.querySelectorAll(this.selectors[e])),i=r.filter((function(e){return e.parentElement===n}));this._dom[e]=o?i:[].concat(v(this._dom[e]),v(i))}},{key:"_resetDOMElementType",value:function(e){if(void 0===this.dom[e])throw new Error('AccessibleMenu: "'.concat(e,'" is not a valid element type within the menu.'));if(!Array.isArray(this.dom[e]))throw new Error('AccessibleMenu: The "'.concat(e,'" element cannot be reset through _resetDOMElementType.'));this._dom[e]=[]}},{key:"_setDOMElements",value:function(){var e=this;this._setDOMElementType("menuItems"),""!==this.selectors.submenuItems&&(this._setDOMElementType("submenuItems"),this._resetDOMElementType("submenuToggles"),this._resetDOMElementType("submenus"),this.dom.submenuItems.forEach((function(t){e._setDOMElementType("submenuToggles",t,!1),e._setDOMElementType("submenus",t,!1)})))}},{key:"_findRootMenu",value:function(e){if(e.isTopLevel)this._elements.rootMenu=e;else{if(null===e.elements.parentMenu)throw new Error("Cannot find root menu.");this._findRootMenu(e.elements.parentMenu)}}},{key:"_createChildElements",value:function(){var e=this;this.dom.menuItems.forEach((function(t){var n;if(e.dom.submenuItems.includes(t)){var o=t.querySelector(e.selectors.submenuToggles),r=t.querySelector(e.selectors.submenus),i=new e._MenuType({menuElement:r,menuItemSelector:e.selectors.menuItems,menuLinkSelector:e.selectors.menuLinks,submenuItemSelector:e.selectors.submenuItems,submenuToggleSelector:e.selectors.submenuToggles,submenuSelector:e.selectors.submenus,openClass:e.openClass,closeClass:e.closeClass,isTopLevel:!1,parentMenu:e,hoverType:e.hoverType,hoverDelay:e.hoverDelay}),u=new e._MenuToggleType({menuToggleElement:o,parentElement:t,controlledMenu:i,parentMenu:e});e._elements.submenuToggles.push(u),n=new e._MenuItemType({menuItemElement:t,menuLinkElement:o,parentMenu:e,isSubmenuItem:!0,childMenu:i,toggle:u})}else{var l=t.querySelector(e.selectors.menuLinks);n=new e._MenuItemType({menuItemElement:t,menuLinkElement:l,parentMenu:e})}e._elements.menuItems.push(n)}))}},{key:"_handleFocus",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("focus",(function(){e.focusState="self",e.currentChild=n}))}))}},{key:"_handleClick",value:function(){var e=this,t=u("touchstart",this.dom.menu)?"touchstart":"mousedown",n=u("touchend",this.dom.menu)?"touchend":"mouseup";function o(e,t,n){d(n),t.toggle(),t.isOpen&&(e.focusState="self",t.elements.controlledMenu.focusState="none")}this.elements.menuItems.forEach((function(r,i){r.dom.link.addEventListener(t,(function(){e.currentEvent="mouse",e.elements.rootMenu.blurChildren(),e.focusChild(i)})),r.isSubmenuItem&&(r.elements.toggle.dom.toggle["on".concat(n)]=function(t){e.currentEvent="mouse",o(e,r.elements.toggle,t)})})),this.isTopLevel&&this.elements.controller&&(this.elements.controller.dom.toggle["on".concat(n)]=function(t){e.currentEvent="mouse",o(e,e.elements.controller,t)})}},{key:"_handleHover",value:function(){var e=this;this.elements.menuItems.forEach((function(t,n){t.dom.link.addEventListener("mouseenter",(function(){if("on"===e.hoverType)e.currentEvent="mouse",e.currentChild=n,t.isSubmenuItem&&t.elements.toggle.preview();else if("dynamic"===e.hoverType){var o=e.elements.submenuToggles.some((function(e){return e.isOpen}));e.currentChild=n,e.isTopLevel&&"none"===e.focusState||(e.currentEvent="mouse",e.focusCurrentChild()),!t.isSubmenuItem||e.isTopLevel&&!o||(e.currentEvent="mouse",t.elements.toggle.preview())}})),t.isSubmenuItem&&t.dom.item.addEventListener("mouseleave",(function(){"on"===e.hoverType?e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close()):"dynamic"===e.hoverType&&(e.isTopLevel||(e.hoverDelay>0?setTimeout((function(){e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild()}),e.hoverDelay):(e.currentEvent="mouse",t.elements.toggle.close(),e.focusCurrentChild())))}))}))}},{key:"_handleKeydown",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keydown",(function(t){e.currentEvent="keyboard";var n=y(t);"Space"!==n&&"Enter"!==n||d(t)}))}},{key:"_handleKeyup",value:function(){var e=this;this.isTopLevel&&this.elements.controller&&this.elements.controller.dom.toggle.addEventListener("keyup",(function(t){e.currentEvent="keyboard";var n=y(t);"Space"!==n&&"Enter"!==n||(d(t),e.elements.controller.open(),e.focusFirstChild())}))}},{key:"focus",value:function(){this.focusState="self",this.shouldFocus&&this.dom.menu.focus()}},{key:"blur",value:function(){this.focusState="none",this.shouldFocus&&this.dom.menu.blur()}},{key:"focusCurrentChild",value:function(){this.focusState="self",-1!==this.currentChild&&this.currentMenuItem.focus()}},{key:"focusChild",value:function(e){this.blurCurrentChild(),this.currentChild=e,this.focusCurrentChild()}},{key:"focusFirstChild",value:function(){this.focusChild(0)}},{key:"focusLastChild",value:function(){this.focusChild(this.elements.menuItems.length-1)}},{key:"focusNextChild",value:function(){this.currentChild0?this.focusChild(this.currentChild-1):this.focusCurrentChild()}},{key:"blurCurrentChild",value:function(){this.focusState="none",-1!==this.currentChild&&this.currentMenuItem.blur()}},{key:"focusController",value:function(){this.dom.controller&&(this.shouldFocus&&this.dom.controller.focus(),this.focusState="none")}},{key:"focusContainer",value:function(){this.dom.container&&(this.shouldFocus&&this.dom.container.focus(),this.focusState="none")}},{key:"closeChildren",value:function(){this.elements.submenuToggles.forEach((function(e){return e.close()}))}},{key:"blurChildren",value:function(){this.elements.menuItems.forEach((function(e){e.blur(),e.isSubmenuItem&&e.elements.childMenu.blurChildren()}))}}],s&&g(c.prototype,s),a&&g(c,a),l}();function _(e){return _="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_(e)}function E(e,t){return E=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},E(e,t)}function S(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=C(e);if(t){var r=C(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return O(this,n)}}function O(e,t){if(t&&("object"===_(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function C(e){return C=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},C(e)}var T=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&E(e,t)}(n,e);var t=S(n);function n(e){var o,r=e.menuItemElement,i=e.menuLinkElement,u=e.parentMenu,l=e.isSubmenuItem,c=void 0!==l&&l,s=e.childMenu,a=void 0===s?null:s,f=e.toggle,m=void 0===f?null:f,p=e.initialize,h=void 0===p||p;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),o=t.call(this,{menuItemElement:r,menuLinkElement:i,parentMenu:u,isSubmenuItem:c,childMenu:a,toggle:m}),h&&o.initialize(),o}return n}(h);function I(e){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},I(e)}function k(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,o=new Array(t);n0&&void 0!==arguments[0])||arguments[0],n=this.elements.controlledMenu.openClass;this.dom.toggle.setAttribute("aria-expanded","true"),""!==n&&("string"==typeof n?this.dom.container.classList.add(n):(e=this.dom.container.classList).add.apply(e,Y(n))),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,r=o.closeClass,i=o.openClass;this.dom.toggle.setAttribute("aria-expanded","false"),""!==r&&("string"==typeof r?this.dom.container.classList.add(r):(e=this.dom.container.classList).add.apply(e,Y(r))),""!==i&&("string"==typeof i?this.dom.container.classList.remove(i):(t=this.dom.container.classList).remove.apply(t,Y(i))),n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}],n&&te(t.prototype,n),o&&te(t,o),i}(x);function se(e){return se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},se(e)}function ae(e,t){return ae=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},ae(e,t)}function fe(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=he(e);if(t){var r=he(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return me(this,n)}}function me(e,t){if(t&&("object"===se(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return pe(e)}function pe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function he(e){return he=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},he(e)}function ye(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var de=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ae(e,t)}(n,e);var t=fe(n);function n(e){var o,r=e.menuElement,i=e.menuItemSelector,u=void 0===i?".nav-item":i,l=e.menuLinkSelector,c=void 0===l?".nav-link,.dropdown-item":l,s=e.submenuItemSelector,a=void 0===s?".dropdown":s,f=e.submenuToggleSelector,m=void 0===f?".dropdown-toggle":f,p=e.submenuSelector,h=void 0===p?".dropdown-menu":p,y=e.controllerElement,d=void 0===y?null:y,v=e.containerElement,b=void 0===v?null:v,g=e.openClass,w=void 0===g?"show":g,M=e.closeClass,_=void 0===M?"collapse":M,E=e.isTopLevel,S=void 0===E||E,O=e.parentMenu,C=void 0===O?null:O,T=e.hoverType,I=void 0===T?"off":T,k=e.hoverDelay,j=void 0===k?250:k,A=e.optionalKeySupport,L=void 0!==A&&A,R=e.initialize,P=void 0===R||R;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),ye(pe(o=t.call(this,{menuElement:r,menuItemSelector:u,menuLinkSelector:c,submenuItemSelector:a,submenuToggleSelector:m,submenuSelector:h,controllerElement:d,containerElement:b,openClass:w,closeClass:_,isTopLevel:S,parentMenu:C,hoverType:I,hoverDelay:j,optionalKeySupport:L,initialize:!1})),"_MenuType",n),ye(pe(o),"_MenuItemType",Q),ye(pe(o),"_MenuToggleType",ce),P&&o.initialize(),o}return n}(q);function ve(e){return ve="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ve(e)}function be(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,o=new Array(t);n0&&void 0!==arguments[0])||arguments[0],n=this.elements.controlledMenu.openClass;this.dom.toggle.setAttribute("aria-expanded","true"),""!==n&&("string"==typeof n?this.dom.container.classList.add(n):(e=this.dom.container.classList).add.apply(e,Je(n))),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,r=o.closeClass,i=o.openClass;this.dom.toggle.setAttribute("aria-expanded","false"),""!==r&&("string"==typeof r?this.dom.container.classList.add(r):(e=this.dom.container.classList).add.apply(e,Je(r))),""!==i&&("string"==typeof i?this.dom.container.classList.remove(i):(t=this.dom.container.classList).remove.apply(t,Je(i))),n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}],n&&Xe(t.prototype,n),o&&Xe(t,o),i}(Le);function ut(e){return ut="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ut(e)}function lt(e,t){return lt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},lt(e,t)}function ct(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=ft(e);if(t){var r=ft(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return st(this,n)}}function st(e,t){if(t&&("object"===ut(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return at(e)}function at(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ft(e){return ft=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},ft(e)}function mt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var pt=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&<(e,t)}(n,e);var t=ct(n);function n(e){var o,r=e.menuElement,i=e.menuItemSelector,u=void 0===i?".nav-item":i,l=e.menuLinkSelector,c=void 0===l?".nav-link,.dropdown-item":l,s=e.submenuItemSelector,a=void 0===s?".dropdown":s,f=e.submenuToggleSelector,m=void 0===f?".dropdown-toggle":f,p=e.submenuSelector,h=void 0===p?".dropdown-menu":p,y=e.controllerElement,d=void 0===y?null:y,v=e.containerElement,b=void 0===v?null:v,g=e.openClass,w=void 0===g?"show":g,M=e.closeClass,_=void 0===M?"collapse":M,E=e.isTopLevel,S=void 0===E||E,O=e.parentMenu,C=void 0===O?null:O,T=e.hoverType,I=void 0===T?"off":T,k=e.hoverDelay,j=void 0===k?250:k,A=e.initialize,L=void 0===A||A;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),mt(at(o=t.call(this,{menuElement:r,menuItemSelector:u,menuLinkSelector:c,submenuItemSelector:a,submenuToggleSelector:m,submenuSelector:h,controllerElement:d,containerElement:b,openClass:w,closeClass:_,isTopLevel:S,parentMenu:C,hoverType:I,hoverDelay:j,initialize:!1})),"_MenuType",n),mt(at(o),"_MenuItemType",Ze),mt(at(o),"_MenuToggleType",it),L&&o.initialize(),o}return n}(He);function ht(e){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ht(e)}function yt(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,o=new Array(t);ne.length)&&(t=e.length);for(var n=0,o=new Array(t);n0&&void 0!==arguments[0])||arguments[0],n=this.elements.controlledMenu.openClass;this.dom.toggle.setAttribute("aria-expanded","true"),""!==n&&("string"==typeof n?this.dom.container.classList.add(n):(e=this.dom.container.classList).add.apply(e,Wt(n))),t&&this.dom.toggle.dispatchEvent(this._expandEvent)}},{key:"_collapse",value:function(){var e,t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=this.elements.controlledMenu,r=o.closeClass,i=o.openClass;this.dom.toggle.setAttribute("aria-expanded","false"),""!==r&&("string"==typeof r?this.dom.container.classList.add(r):(e=this.dom.container.classList).add.apply(e,Wt(r))),""!==i&&("string"==typeof i?this.dom.container.classList.remove(i):(t=this.dom.container.classList).remove.apply(t,Wt(i))),n&&this.dom.toggle.dispatchEvent(this._collapseEvent)}}],n&&Gt(t.prototype,n),o&&Gt(t,o),i}(Tt);function on(e){return on="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},on(e)}function rn(e,t){return rn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},rn(e,t)}function un(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=sn(e);if(t){var r=sn(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return ln(this,n)}}function ln(e,t){if(t&&("object"===on(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return cn(e)}function cn(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function sn(e){return sn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},sn(e)}function an(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}return{Bootstrap4DisclosureMenu:de,Bootstrap4Menubar:pt,Bootstrap4Treeview:function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&rn(e,t)}(n,e);var t=un(n);function n(e){var o,r=e.menuElement,i=e.menuItemSelector,u=void 0===i?".nav-item":i,l=e.menuLinkSelector,c=void 0===l?".nav-link,.dropdown-item":l,s=e.submenuItemSelector,a=void 0===s?".dropdown":s,f=e.submenuToggleSelector,m=void 0===f?".dropdown-toggle":f,p=e.submenuSelector,h=void 0===p?".dropdown-menu":p,y=e.controllerElement,d=void 0===y?null:y,v=e.containerElement,b=void 0===v?null:v,g=e.openClass,w=void 0===g?"show":g,M=e.closeClass,_=void 0===M?"collapse":M,E=e.isTopLevel,S=void 0===E||E,O=e.parentMenu,C=void 0===O?null:O,T=e.hoverType,I=void 0===T?"off":T,k=e.hoverDelay,j=void 0===k?250:k,A=e.initialize,L=void 0===A||A;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),an(cn(o=t.call(this,{menuElement:r,menuItemSelector:u,menuLinkSelector:c,submenuItemSelector:a,submenuToggleSelector:m,submenuSelector:h,controllerElement:d,containerElement:b,openClass:w,closeClass:_,isTopLevel:S,parentMenu:C,hoverType:I,hoverDelay:j,initialize:!1})),"_MenuType",n),an(cn(o),"_MenuItemType",qt),an(cn(o),"_MenuToggleType",nn),L&&o.initialize(),o}return n}(Kt)}}(); //# sourceMappingURL=accessible-menu-bs4.min.js.map diff --git a/dist/accessible-menu-bs4.min.js.map b/dist/accessible-menu-bs4.min.js.map index bad7e23..93753f2 100644 --- a/dist/accessible-menu-bs4.min.js.map +++ b/dist/accessible-menu-bs4.min.js.map @@ -1 +1 @@ -{"version":3,"file":"accessible-menu-bs4.min.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","../rollup.js","../src/bootstrap4Treeview.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 */\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 `