@servicensw/drop-menu
Advanced tools
Comparing version 2.0.3 to 2.1.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [2.1.0](http://github.com/previousnext/snsw-styleguide/tree/master/packages/drop-menu/compare/@servicensw/drop-menu@2.0.3...@servicensw/drop-menu@2.1.0) (2019-09-22) | ||
### Features | ||
* allow queing of dialogs and overlays within SNSW.Keyboard ([d9c4ff3](http://github.com/previousnext/snsw-styleguide/tree/master/packages/drop-menu/commit/d9c4ff3)) | ||
## [2.0.3](http://github.com/previousnext/snsw-styleguide/tree/master/packages/drop-menu/compare/@servicensw/drop-menu@2.0.2...@servicensw/drop-menu@2.0.3) (2019-09-17) | ||
@@ -8,0 +19,0 @@ |
@@ -1,1 +0,1 @@ | ||
"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),e}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var _temp,keyboard=function(e){return"SNSW.Keyboard has not been loaded. Keyboard navigation for the ".concat(e," component will not function.")},polyfill=function(e){return"Required polyfills are not loaded, the ".concat(e," component will not function properly in this browser.")};if(window.SNSW=window.SNSW||{},void 0===SNSW.Keyboard&&console.warn(keyboard("Drop menu")),!NodeList.prototype.forEach)throw new Error(polyfill("Drop menu"));SNSW.DropMenu=_temp=function(){function i(e,t){var n=this;_classCallCheck(this,i),_defineProperty(this,"closeMenu",function(){n.button.setAttribute("aria-expanded","false"),n.menu.setAttribute("aria-hidden","true"),n.menuItems[0].setAttribute("tabIndex","-1"),n.button.focus(),SNSW.Keyboard&&(SNSW.Keyboard.detachOverlay(),SNSW.Keyboard.detachMenu())}),_defineProperty(this,"buttonClickHandler",function(e){e.stopPropagation(),"false"!==n.button.getAttribute("aria-expanded")?n.closeMenu():n.openMenu()}),_defineProperty(this,"buttonKeyDownHandler",function(e){switch(e.key){case"Enter":case" ":case"ArrowDown":e.preventDefault(),e.stopPropagation(),n.openMenu();break;case"ArrowUp":e.preventDefault(),e.stopPropagation(),n.openMenu(n.menuItems.length-1)}}),_defineProperty(this,"menuItemClickHandler",function(e){e.stopPropagation(),n.setActiveMenuItem(e.currentTarget),n.closeMenu()}),_defineProperty(this,"menuItemKeyDownHandler",function(e){switch(e.key){case"Enter":case" ":e.preventDefault(),e.currentTarget.click(),n.button.focus()}}),this.element=e,this.element&&this.element.nodeType&&(this.index=t,void 0===this.index&&(this.index=0),this.menu=this.element.querySelector("ul"),this.menu.setAttribute("id","menuButton".concat(this.index)),this.menu.setAttribute("role","menu"),this.menu.setAttribute("aria-hidden","true"),this.listItems=this.element.querySelectorAll("li"),this.listItems.forEach(function(e){e.setAttribute("role","none")}),this.menuItems=this.element.querySelectorAll("a"),this.menuItems.forEach(function(e,t){e.setAttribute("role","menuitem"),e.setAttribute("tabIndex","-1"),0===t&&(e.setAttribute("aria-current","true"),n.listItems[t].classList.add("is-active")),e.addEventListener("click",n.menuItemClickHandler),e.addEventListener("keydown",n.menuItemKeyDownHandler)}),this.button=document.createElement("button"),this.button.setAttribute("aria-haspopup","true"),this.button.setAttribute("aria-controls",this.menu.getAttribute("id")),this.button.setAttribute("aria-expanded","false"),this.button.setAttribute("aria-label","Open ".concat(this.menu.getAttribute("aria-label"))),this.button.classList.add("reset--button"),this.element.insertBefore(this.button,this.menu),this.button.addEventListener("click",this.buttonClickHandler),this.button.addEventListener("keydown",this.buttonKeyDownHandler))}return _createClass(i,[{key:"setActiveMenuItem",value:function(n){var i=this;this.menuItems.forEach(function(e,t){e!==n?(e.setAttribute("aria-current",""),i.listItems[t].classList.remove("is-active")):(e.setAttribute("aria-current","true"),i.listItems[t].classList.add("is-active"))})}},{key:"openMenu",value:function(e){e=void 0!==e?e:0,this.button.setAttribute("aria-expanded","true"),this.menu.setAttribute("aria-hidden","false"),this.menuItems[0].setAttribute("tabIndex","0"),this.menuItems[e].focus(),SNSW.Keyboard&&(SNSW.Keyboard.attachOverlay(this,this.closeMenu),SNSW.Keyboard.attachMenu(this,this.menuItems))}}]),i}(),window.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll(".drop-button:not(.is-excluded)");e&&e.forEach(function(e,t){new SNSW.DropMenu(e,t)})}); | ||
"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),e}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var _temp,keyboard=function(e){return"SNSW.Keyboard has not been loaded. Keyboard navigation for the ".concat(e," component will not function.")},polyfill=function(e){return"Required polyfills are not loaded, the ".concat(e," component will not function properly in this browser.")};if(window.SNSW=window.SNSW||{},void 0===SNSW.Keyboard&&console.warn(keyboard("Drop menu")),!NodeList.prototype.forEach)throw new Error(polyfill("Drop menu"));SNSW.DropMenu=_temp=function(){function i(e,t){var n=this;_classCallCheck(this,i),_defineProperty(this,"closeMenu",function(){n.button.setAttribute("aria-expanded","false"),n.menu.setAttribute("aria-hidden","true"),n.menuItems[0].setAttribute("tabIndex","-1"),n.button.focus(),SNSW.Keyboard&&(SNSW.Keyboard.detachOverlay("DropMenu".concat(n.index)),SNSW.Keyboard.detachMenu())}),_defineProperty(this,"buttonClickHandler",function(e){e.stopPropagation(),"false"!==n.button.getAttribute("aria-expanded")?n.closeMenu():n.openMenu()}),_defineProperty(this,"buttonKeyDownHandler",function(e){switch(e.key){case"Enter":case" ":case"ArrowDown":e.preventDefault(),e.stopPropagation(),n.openMenu();break;case"ArrowUp":e.preventDefault(),e.stopPropagation(),n.openMenu(n.menuItems.length-1)}}),_defineProperty(this,"menuItemClickHandler",function(e){e.stopPropagation(),n.setActiveMenuItem(e.currentTarget),n.closeMenu()}),_defineProperty(this,"menuItemKeyDownHandler",function(e){switch(e.key){case"Enter":case" ":e.preventDefault(),e.currentTarget.click(),n.button.focus()}}),this.element=e,this.element&&this.element.nodeType&&(this.index=t,void 0===this.index&&(this.index=0),this.menu=this.element.querySelector("ul"),this.menu.setAttribute("id","menuButton".concat(this.index)),this.menu.setAttribute("role","menu"),this.menu.setAttribute("aria-hidden","true"),this.listItems=this.element.querySelectorAll("li"),this.listItems.forEach(function(e){e.setAttribute("role","none")}),this.menuItems=this.element.querySelectorAll("a"),this.menuItems.forEach(function(e,t){e.setAttribute("role","menuitem"),e.setAttribute("tabIndex","-1"),0===t&&(e.setAttribute("aria-current","true"),n.listItems[t].classList.add("is-active")),e.addEventListener("click",n.menuItemClickHandler),e.addEventListener("keydown",n.menuItemKeyDownHandler)}),this.button=document.createElement("button"),this.button.setAttribute("aria-haspopup","true"),this.button.setAttribute("aria-controls",this.menu.getAttribute("id")),this.button.setAttribute("aria-expanded","false"),this.button.setAttribute("aria-label","Open ".concat(this.menu.getAttribute("aria-label"))),this.button.classList.add("reset--button"),this.element.insertBefore(this.button,this.menu),this.button.addEventListener("click",this.buttonClickHandler),this.button.addEventListener("keydown",this.buttonKeyDownHandler))}return _createClass(i,[{key:"setActiveMenuItem",value:function(n){var i=this;this.menuItems.forEach(function(e,t){e!==n?(e.setAttribute("aria-current",""),i.listItems[t].classList.remove("is-active")):(e.setAttribute("aria-current","true"),i.listItems[t].classList.add("is-active"))})}},{key:"openMenu",value:function(e){e=void 0!==e?e:0,this.button.setAttribute("aria-expanded","true"),this.menu.setAttribute("aria-hidden","false"),this.menuItems[0].setAttribute("tabIndex","0"),this.menuItems[e].focus(),SNSW.Keyboard&&(SNSW.Keyboard.attachOverlay("DropMenu".concat(this.index),this.closeMenu),SNSW.Keyboard.attachMenu(this,this.menuItems))}}]),i}(),window.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll(".drop-button:not(.is-excluded)");e&&e.forEach(function(e,t){new SNSW.DropMenu(e,t)})}); |
{ | ||
"name": "@servicensw/drop-menu", | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"description": "Drop menu component", | ||
@@ -37,3 +37,3 @@ "repository": { | ||
"dependencies": { | ||
"@servicensw/base": "^2.0.3", | ||
"@servicensw/base": "^2.1.0", | ||
"@servicensw/constants": "^2.0.0" | ||
@@ -51,3 +51,3 @@ }, | ||
], | ||
"gitHead": "6203fd423c7a7fd12e793cccb6d46e783731ffb9" | ||
"gitHead": "33fa8b391a0b04d6a7ed2fed6c2119580cdbf5fd" | ||
} |
@@ -103,3 +103,3 @@ /** | ||
if (SNSW.Keyboard) { | ||
SNSW.Keyboard.attachOverlay(this, this.closeMenu); | ||
SNSW.Keyboard.attachOverlay(`DropMenu${this.index}`, this.closeMenu); | ||
SNSW.Keyboard.attachMenu(this, this.menuItems); | ||
@@ -116,3 +116,3 @@ } | ||
if (SNSW.Keyboard) { | ||
SNSW.Keyboard.detachOverlay(); | ||
SNSW.Keyboard.detachOverlay(`DropMenu${this.index}`); | ||
SNSW.Keyboard.detachMenu(); | ||
@@ -119,0 +119,0 @@ } |
20390
Updated@servicensw/base@^2.1.0