@aurodesignsystem/auro-menu
Advanced tools
Comparing version 3.9.0 to 3.9.1
# Semantic Release Automated Changelog | ||
## [3.9.1](https://github.com/AlaskaAirlines/auro-menu/compare/v3.9.0...v3.9.1) (2022-10-11) | ||
### Bug Fixes | ||
* **nav:** keyboard nav now skips hidden options [#156](https://github.com/AlaskaAirlines/auro-menu/issues/156) ([f401ea6](https://github.com/AlaskaAirlines/auro-menu/commit/f401ea66ec6530cd3e7deacd9cea070f36ad9a9d)) | ||
# [3.9.0](https://github.com/AlaskaAirlines/auro-menu/compare/v3.8.1...v3.9.0) (2022-08-19) | ||
@@ -4,0 +11,0 @@ |
@@ -166,2 +166,2 @@ /** | ||
*****************************************************/ | ||
!function(e){function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var n,i,s,o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},r=function(){function e(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)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),a="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};n=function(e,n){var i=function(){function i(n){t(this,i),this.ctx=n,this.ie=!1;var s=e.navigator.userAgent;(s.indexOf("MSIE")>-1||s.indexOf("Trident")>-1)&&(this.ie=!0)}return r(i,[{key:"log",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"debug",n=this.opt.log;this.opt.debug&&"object"===(void 0===n?"undefined":a(n))&&"function"==typeof n[t]&&n[t]("mark.js: "+e)}},{key:"escapeStr",value:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}},{key:"createRegExp",value:function(e){return"disabled"!==this.opt.wildcards&&(e=this.setupWildcardsRegExp(e)),e=this.escapeStr(e),Object.keys(this.opt.synonyms).length&&(e=this.createSynonymsRegExp(e)),(this.opt.ignoreJoiners||this.opt.ignorePunctuation.length)&&(e=this.setupIgnoreJoinersRegExp(e)),this.opt.diacritics&&(e=this.createDiacriticsRegExp(e)),e=this.createMergedBlanksRegExp(e),(this.opt.ignoreJoiners||this.opt.ignorePunctuation.length)&&(e=this.createJoinersRegExp(e)),"disabled"!==this.opt.wildcards&&(e=this.createWildcardsRegExp(e)),this.createAccuracyRegExp(e)}},{key:"createSynonymsRegExp",value:function(e){var t=this.opt.synonyms,n=this.opt.caseSensitive?"":"i",i=this.opt.ignoreJoiners||this.opt.ignorePunctuation.length?"\0":"";for(var s in t)if(t.hasOwnProperty(s)){var o=t[s],r="disabled"!==this.opt.wildcards?this.setupWildcardsRegExp(s):this.escapeStr(s),a="disabled"!==this.opt.wildcards?this.setupWildcardsRegExp(o):this.escapeStr(o);""!==r&&""!==a&&(e=e.replace(new RegExp("("+r+"|"+a+")","gm"+n),i+"("+this.processSynomyms(r)+"|"+this.processSynomyms(a)+")"+i))}return e}},{key:"processSynomyms",value:function(e){return(this.opt.ignoreJoiners||this.opt.ignorePunctuation.length)&&(e=this.setupIgnoreJoinersRegExp(e)),e}},{key:"setupWildcardsRegExp",value:function(e){return(e=e.replace(/(?:\\)*\?/g,(function(e){return"\\"===e.charAt(0)?"?":""}))).replace(/(?:\\)*\*/g,(function(e){return"\\"===e.charAt(0)?"*":""}))}},{key:"createWildcardsRegExp",value:function(e){var t="withSpaces"===this.opt.wildcards;return e.replace(/\u0001/g,t?"[\\S\\s]?":"\\S?").replace(/\u0002/g,t?"[\\S\\s]*?":"\\S*")}},{key:"setupIgnoreJoinersRegExp",value:function(e){return e.replace(/[^(|)\\]/g,(function(e,t,n){var i=n.charAt(t+1);return/[(|)\\]/.test(i)||""===i?e:e+"\0"}))}},{key:"createJoinersRegExp",value:function(e){var t=[],n=this.opt.ignorePunctuation;return Array.isArray(n)&&n.length&&t.push(this.escapeStr(n.join(""))),this.opt.ignoreJoiners&&t.push("\\u00ad\\u200b\\u200c\\u200d"),t.length?e.split(/\u0000+/).join("["+t.join("")+"]*"):e}},{key:"createDiacriticsRegExp",value:function(e){var t=this.opt.caseSensitive?"":"i",n=this.opt.caseSensitive?["aàáảãạăằắẳẵặâầấẩẫậäåāą","AÀÁẢÃẠĂẰẮẲẴẶÂẦẤẨẪẬÄÅĀĄ","cçćč","CÇĆČ","dđď","DĐĎ","eèéẻẽẹêềếểễệëěēę","EÈÉẺẼẸÊỀẾỂỄỆËĚĒĘ","iìíỉĩịîïī","IÌÍỈĨỊÎÏĪ","lł","LŁ","nñňń","NÑŇŃ","oòóỏõọôồốổỗộơởỡớờợöøō","OÒÓỎÕỌÔỒỐỔỖỘƠỞỠỚỜỢÖØŌ","rř","RŘ","sšśșş","SŠŚȘŞ","tťțţ","TŤȚŢ","uùúủũụưừứửữựûüůū","UÙÚỦŨỤƯỪỨỬỮỰÛÜŮŪ","yýỳỷỹỵÿ","YÝỲỶỸỴŸ","zžżź","ZŽŻŹ"]:["aàáảãạăằắẳẵặâầấẩẫậäåāąAÀÁẢÃẠĂẰẮẲẴẶÂẦẤẨẪẬÄÅĀĄ","cçćčCÇĆČ","dđďDĐĎ","eèéẻẽẹêềếểễệëěēęEÈÉẺẼẸÊỀẾỂỄỆËĚĒĘ","iìíỉĩịîïīIÌÍỈĨỊÎÏĪ","lłLŁ","nñňńNÑŇŃ","oòóỏõọôồốổỗộơởỡớờợöøōOÒÓỎÕỌÔỒỐỔỖỘƠỞỠỚỜỢÖØŌ","rřRŘ","sšśșşSŠŚȘŞ","tťțţTŤȚŢ","uùúủũụưừứửữựûüůūUÙÚỦŨỤƯỪỨỬỮỰÛÜŮŪ","yýỳỷỹỵÿYÝỲỶỸỴŸ","zžżźZŽŻŹ"],i=[];return e.split("").forEach((function(s){n.every((function(n){if(-1!==n.indexOf(s)){if(i.indexOf(n)>-1)return!1;e=e.replace(new RegExp("["+n+"]","gm"+t),"["+n+"]"),i.push(n)}return!0}))})),e}},{key:"createMergedBlanksRegExp",value:function(e){return e.replace(/[\s]+/gim,"[\\s]+")}},{key:"createAccuracyRegExp",value:function(e){var t=this,n=this.opt.accuracy,i="string"==typeof n?n:n.value,s="";switch(("string"==typeof n?[]:n.limiters).forEach((function(e){s+="|"+t.escapeStr(e)})),i){case"partially":default:return"()("+e+")";case"complementary":return"()([^"+(s="\\s"+(s||this.escapeStr("!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~¡¿")))+"]*"+e+"[^"+s+"]*)";case"exactly":return"(^|\\s"+s+")("+e+")(?=$|\\s"+s+")"}}},{key:"getSeparatedKeywords",value:function(e){var t=this,n=[];return e.forEach((function(e){t.opt.separateWordSearch?e.split(" ").forEach((function(e){e.trim()&&-1===n.indexOf(e)&&n.push(e)})):e.trim()&&-1===n.indexOf(e)&&n.push(e)})),{keywords:n.sort((function(e,t){return t.length-e.length})),length:n.length}}},{key:"isNumeric",value:function(e){return Number(parseFloat(e))==e}},{key:"checkRanges",value:function(e){var t=this;if(!Array.isArray(e)||"[object Object]"!==Object.prototype.toString.call(e[0]))return this.log("markRanges() will only accept an array of objects"),this.opt.noMatch(e),[];var n=[],i=0;return e.sort((function(e,t){return e.start-t.start})).forEach((function(e){var s=t.callNoMatchOnInvalidRanges(e,i),o=s.start,r=s.end;s.valid&&(e.start=o,e.length=r-o,n.push(e),i=r)})),n}},{key:"callNoMatchOnInvalidRanges",value:function(e,t){var n=void 0,i=void 0,s=!1;return e&&void 0!==e.start?(i=(n=parseInt(e.start,10))+parseInt(e.length,10),this.isNumeric(e.start)&&this.isNumeric(e.length)&&i-t>0&&i-n>0?s=!0:(this.log("Ignoring invalid or overlapping range: "+JSON.stringify(e)),this.opt.noMatch(e))):(this.log("Ignoring invalid range: "+JSON.stringify(e)),this.opt.noMatch(e)),{start:n,end:i,valid:s}}},{key:"checkWhitespaceRanges",value:function(e,t,n){var i=void 0,s=!0,o=n.length,r=t-o,a=parseInt(e.start,10)-r;return(i=(a=a>o?o:a)+parseInt(e.length,10))>o&&(i=o,this.log("End range automatically set to the max value of "+o)),a<0||i-a<0||a>o||i>o?(s=!1,this.log("Invalid range: "+JSON.stringify(e)),this.opt.noMatch(e)):""===n.substring(a,i).replace(/\s+/g,"")&&(s=!1,this.log("Skipping whitespace only range: "+JSON.stringify(e)),this.opt.noMatch(e)),{start:a,end:i,valid:s}}},{key:"getTextNodes",value:function(e){var t=this,n="",i=[];this.iterator.forEachNode(NodeFilter.SHOW_TEXT,(function(e){i.push({start:n.length,end:(n+=e.textContent).length,node:e})}),(function(e){return t.matchesExclude(e.parentNode)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),(function(){e({value:n,nodes:i})}))}},{key:"matchesExclude",value:function(e){return s.matches(e,this.opt.exclude.concat(["script","style","title","head","html"]))}},{key:"wrapRangeInTextNode",value:function(e,t,i){var s=this.opt.element?this.opt.element:"mark",o=e.splitText(t),r=o.splitText(i-t),a=n.createElement(s);return a.setAttribute("data-markjs","true"),this.opt.className&&a.setAttribute("class",this.opt.className),a.textContent=o.textContent,o.parentNode.replaceChild(a,o),r}},{key:"wrapRangeInMappedTextNode",value:function(e,t,n,i,s){var o=this;e.nodes.every((function(r,a){var c=e.nodes[a+1];if(void 0===c||c.start>t){if(!i(r.node))return!1;var l=t-r.start,h=(n>r.end?r.end:n)-r.start,u=e.value.substr(0,r.start),d=e.value.substr(h+r.start);if(r.node=o.wrapRangeInTextNode(r.node,l,h),e.value=u+d,e.nodes.forEach((function(t,n){n>=a&&(e.nodes[n].start>0&&n!==a&&(e.nodes[n].start-=h),e.nodes[n].end-=h)})),n-=h,s(r.node.previousSibling,r.start),!(n>r.end))return!1;t=r.end}return!0}))}},{key:"wrapMatches",value:function(e,t,n,i,s){var o=this,r=0===t?0:t+1;this.getTextNodes((function(t){t.nodes.forEach((function(t){t=t.node;for(var s=void 0;null!==(s=e.exec(t.textContent))&&""!==s[r];)if(n(s[r],t)){var a=s.index;if(0!==r)for(var c=1;c<r;c++)a+=s[c].length;t=o.wrapRangeInTextNode(t,a,a+s[r].length),i(t.previousSibling),e.lastIndex=0}})),s()}))}},{key:"wrapMatchesAcrossElements",value:function(e,t,n,i,s){var o=this,r=0===t?0:t+1;this.getTextNodes((function(t){for(var a=void 0;null!==(a=e.exec(t.value))&&""!==a[r];){var c=a.index;if(0!==r)for(var l=1;l<r;l++)c+=a[l].length;var h=c+a[r].length;o.wrapRangeInMappedTextNode(t,c,h,(function(e){return n(a[r],e)}),(function(t,n){e.lastIndex=n,i(t)}))}s()}))}},{key:"wrapRangeFromIndex",value:function(e,t,n,i){var s=this;this.getTextNodes((function(o){var r=o.value.length;e.forEach((function(e,i){var a=s.checkWhitespaceRanges(e,r,o.value),c=a.start,l=a.end;a.valid&&s.wrapRangeInMappedTextNode(o,c,l,(function(n){return t(n,e,o.value.substring(c,l),i)}),(function(t){n(t,e)}))})),i()}))}},{key:"unwrapMatches",value:function(e){for(var t=e.parentNode,i=n.createDocumentFragment();e.firstChild;)i.appendChild(e.removeChild(e.firstChild));t.replaceChild(i,e),this.ie?this.normalizeTextNode(t):t.normalize()}},{key:"normalizeTextNode",value:function(e){if(e){if(3===e.nodeType)for(;e.nextSibling&&3===e.nextSibling.nodeType;)e.nodeValue+=e.nextSibling.nodeValue,e.parentNode.removeChild(e.nextSibling);else this.normalizeTextNode(e.firstChild);this.normalizeTextNode(e.nextSibling)}}},{key:"markRegExp",value:function(e,t){var n=this;this.opt=t,this.log('Searching with expression "'+e+'"');var i=0,s="wrapMatches";this.opt.acrossElements&&(s="wrapMatchesAcrossElements"),this[s](e,this.opt.ignoreGroups,(function(e,t){return n.opt.filter(t,e,i)}),(function(e){i++,n.opt.each(e)}),(function(){0===i&&n.opt.noMatch(e),n.opt.done(i)}))}},{key:"mark",value:function(e,t){var n=this;this.opt=t;var i=0,s="wrapMatches",o=this.getSeparatedKeywords("string"==typeof e?[e]:e),r=o.keywords,a=o.length,c=this.opt.caseSensitive?"":"i";this.opt.acrossElements&&(s="wrapMatchesAcrossElements"),0===a?this.opt.done(i):function e(t){var o=new RegExp(n.createRegExp(t),"gm"+c),l=0;n.log('Searching with expression "'+o+'"'),n[s](o,1,(function(e,s){return n.opt.filter(s,t,i,l)}),(function(e){l++,i++,n.opt.each(e)}),(function(){0===l&&n.opt.noMatch(t),r[a-1]===t?n.opt.done(i):e(r[r.indexOf(t)+1])}))}(r[0])}},{key:"markRanges",value:function(e,t){var n=this;this.opt=t;var i=0,s=this.checkRanges(e);s&&s.length?(this.log("Starting to mark with the following ranges: "+JSON.stringify(s)),this.wrapRangeFromIndex(s,(function(e,t,i,s){return n.opt.filter(e,t,i,s)}),(function(e,t){i++,n.opt.each(e,t)}),(function(){n.opt.done(i)}))):this.opt.done(i)}},{key:"unmark",value:function(e){var t=this;this.opt=e;var n=this.opt.element?this.opt.element:"*";n+="[data-markjs]",this.opt.className&&(n+="."+this.opt.className),this.log('Removal selector "'+n+'"'),this.iterator.forEachNode(NodeFilter.SHOW_ELEMENT,(function(e){t.unwrapMatches(e)}),(function(e){var i=s.matches(e,n),o=t.matchesExclude(e);return!i||o?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),this.opt.done)}},{key:"opt",set:function(t){this._opt=o({},{element:"",className:"",exclude:[],iframes:!1,iframesTimeout:5e3,separateWordSearch:!0,diacritics:!0,synonyms:{},accuracy:"partially",acrossElements:!1,caseSensitive:!1,ignoreJoiners:!1,ignoreGroups:0,ignorePunctuation:[],wildcards:"disabled",each:function(){},noMatch:function(){},filter:function(){return!0},done:function(){},debug:!1,log:e.console},t)},get:function(){return this._opt}},{key:"iterator",get:function(){return new s(this.ctx,this.opt.iframes,this.opt.exclude,this.opt.iframesTimeout)}}]),i}(),s=function(){function e(n){var i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5e3;t(this,e),this.ctx=n,this.iframes=i,this.exclude=s,this.iframesTimeout=o}return r(e,[{key:"getContexts",value:function(){var e=[];return(void 0!==this.ctx&&this.ctx?NodeList.prototype.isPrototypeOf(this.ctx)?Array.prototype.slice.call(this.ctx):Array.isArray(this.ctx)?this.ctx:"string"==typeof this.ctx?Array.prototype.slice.call(n.querySelectorAll(this.ctx)):[this.ctx]:[]).forEach((function(t){var n=e.filter((function(e){return e.contains(t)})).length>0;-1!==e.indexOf(t)||n||e.push(t)})),e}},{key:"getIframeContents",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},i=void 0;try{var s=e.contentWindow;if(i=s.document,!s||!i)throw new Error("iframe inaccessible")}catch(e){n()}i&&t(i)}},{key:"isIframeBlank",value:function(e){var t="about:blank",n=e.getAttribute("src").trim();return e.contentWindow.location.href===t&&n!==t&&n}},{key:"observeIframeLoad",value:function(e,t,n){var i=this,s=!1,o=null,r=function r(){if(!s){s=!0,clearTimeout(o);try{i.isIframeBlank(e)||(e.removeEventListener("load",r),i.getIframeContents(e,t,n))}catch(e){n()}}};e.addEventListener("load",r),o=setTimeout(r,this.iframesTimeout)}},{key:"onIframeReady",value:function(e,t,n){try{"complete"===e.contentWindow.document.readyState?this.isIframeBlank(e)?this.observeIframeLoad(e,t,n):this.getIframeContents(e,t,n):this.observeIframeLoad(e,t,n)}catch(e){n()}}},{key:"waitForIframes",value:function(e,t){var n=this,i=0;this.forEachIframe(e,(function(){return!0}),(function(e){i++,n.waitForIframes(e.querySelector("html"),(function(){--i||t()}))}),(function(e){e||t()}))}},{key:"forEachIframe",value:function(t,n,i){var s=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},r=t.querySelectorAll("iframe"),a=r.length,c=0;r=Array.prototype.slice.call(r);var l=function(){--a<=0&&o(c)};a||l(),r.forEach((function(t){e.matches(t,s.exclude)?l():s.onIframeReady(t,(function(e){n(t)&&(c++,i(e)),l()}),l)}))}},{key:"createIterator",value:function(e,t,i){return n.createNodeIterator(e,t,i,!1)}},{key:"createInstanceOnIframe",value:function(t){return new e(t.querySelector("html"),this.iframes)}},{key:"compareNodeIframe",value:function(e,t,n){if(e.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_PRECEDING){if(null===t)return!0;if(t.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_FOLLOWING)return!0}return!1}},{key:"getIteratorNode",value:function(e){var t=e.previousNode();return{prevNode:t,node:(null===t||e.nextNode())&&e.nextNode()}}},{key:"checkIframeFilter",value:function(e,t,n,i){var s=!1,o=!1;return i.forEach((function(e,t){e.val===n&&(s=t,o=e.handled)})),this.compareNodeIframe(e,t,n)?(!1!==s||o?!1===s||o||(i[s].handled=!0):i.push({val:n,handled:!0}),!0):(!1===s&&i.push({val:n,handled:!1}),!1)}},{key:"handleOpenIframes",value:function(e,t,n,i){var s=this;e.forEach((function(e){e.handled||s.getIframeContents(e.val,(function(e){s.createInstanceOnIframe(e).forEachNode(t,n,i)}))}))}},{key:"iterateThroughNodes",value:function(e,t,n,i,s){for(var o=this,r=this.createIterator(t,e,i),a=[],c=[],l=void 0,h=void 0;function(){var e=o.getIteratorNode(r);return h=e.prevNode,l=e.node}();)this.iframes&&this.forEachIframe(t,(function(e){return o.checkIframeFilter(l,h,e,a)}),(function(t){o.createInstanceOnIframe(t).forEachNode(e,(function(e){return c.push(e)}),i)})),c.push(l);c.forEach((function(e){n(e)})),this.iframes&&this.handleOpenIframes(a,e,n,i),s()}},{key:"forEachNode",value:function(e,t,n){var i=this,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},o=this.getContexts(),r=o.length;r||s(),o.forEach((function(o){var a=function(){i.iterateThroughNodes(e,o,t,n,(function(){--r<=0&&s()}))};i.iframes?i.waitForIframes(o,a):a()}))}}],[{key:"matches",value:function(e,t){var n="string"==typeof t?[t]:t,i=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.oMatchesSelector||e.webkitMatchesSelector;if(i){var s=!1;return n.every((function(t){return!i.call(e,t)||(s=!0,!1)})),s}return!1}}]),e}();return e.Mark=function(e){var t=this,n=new i(e);return this.mark=function(e,i){return n.mark(e,i),t},this.markRegExp=function(e,i){return n.markRegExp(e,i),t},this.markRanges=function(e,i){return n.markRanges(e,i),t},this.unmark=function(e){return n.unmark(e),t},this},e.Mark},i=window,s=document,"object"===a(e)&&e.exports?e.exports=n(i,s):n(i,s)}({exports:{}});class oe extends X{constructor(){super(),this.value=void 0,this.optionSelected=void 0,this.matchWord=void 0,this.noCheckmark=!1,this.ready=!1,this.optionActive=void 0,this.rootMenu=!0}static get properties(){return{noCheckmark:{type:Boolean,reflect:!0},optionSelected:{type:Object},optionActive:{type:Object},matchWord:{type:String},ready:{type:Boolean},value:{type:String}}}static get styles(){return[Q,ee]}firstUpdated(){this.addEventListener("keydown",this.handleKeyDown)}updated(e){if(this.noCheckmark){this.querySelectorAll("auro-menu").forEach((e=>{e.setAttribute("noCheckmark","")}));this.querySelectorAll("auro-menuoption").forEach((e=>{e.setAttribute("noCheckmark","")}))}e.has("matchWord")&&this.markOptions(),e.has("value")&&this.selectByValue(this.value)}optionInteractive(e){return!e.hasAttribute("disabled")&&!e.hasAttribute("static")}markOptions(){let e=[];this.items.forEach((t=>{this.optionInteractive(t)&&!t.hasAttribute("persistent")&&e.push(t)}));const t=new Mark(e);t.unmark(),this.matchWord&&this.matchWord.length>0&&t.mark(this.matchWord,{element:"strong",separateWordSearch:!1,acrossElements:!0})}resetOptionsStates(){this.optionSelected=void 0,this.items.forEach((e=>{e.classList.remove("active"),e.removeAttribute("selected"),e.removeAttribute("aria-selected")}))}handleLocalSelectState(e){e.setAttribute("selected",""),e.classList.add("active"),e.ariaSelected=!0,this.value=e.value,this.optionSelected=e,this.index=this.items.indexOf(e)}notifySelectionChange(){this.dispatchEvent(new CustomEvent("selectedOption",{bubbles:!0,cancelable:!1,composed:!0})),this.dispatchEvent(new CustomEvent("auroMenu-selectedOption",{bubbles:!0,cancelable:!1,composed:!0}))}makeSelection(){if(this.items||this.initItems(),this.resetOptionsStates(),this.index>=0){const e=this.items[this.index];e&&this.optionInteractive(e)&&(e.hasAttribute("event")?(this.dispatchEvent(new CustomEvent(e.getAttribute("event"),{bubbles:!0,cancelable:!1,composed:!0})),this.dispatchEvent(new CustomEvent("auroMenuCustomEventFired",{bubbles:!0,cancelable:!1,composed:!0})),this.dispatchEvent(new CustomEvent("auroMenu-customEventFired",{bubbles:!0,cancelable:!1,composed:!0}))):this.handleLocalSelectState(e))}this.notifySelectionChange()}handleKeyDown(e){switch(e.preventDefault(),e.key){case"ArrowDown":this.selectNextItem("down");break;case"ArrowUp":this.selectNextItem("up");break;case"Enter":this.makeSelection()}}initItems(){this.items=Array.from(this.querySelectorAll("auro-menuoption"))}getSelectedIndex(){const e=this.items.findIndex((e=>e.hasAttribute("selected")&&this.optionInteractive(e)));e>=0&&(this.index=e,this.makeSelection())}selectNextItem(e){if(this.index>=0){this.items[this.index].classList.remove("active");let t=0;"down"===e?t=1:"up"===e&&(t=-1),this.index+=t,this.index>this.items.length-1?this.index=0:this.index<0&&(this.index=this.items.length-1),this.optionInteractive(this.items[this.index])?this.updateActiveOption(this.index):this.selectNextItem(e)}else this.index=0,this.items[this.index].hasAttribute("hidden")||this.items[this.index].hasAttribute("disabled")?this.selectNextItem(e):this.updateActiveOption(this.index)}handleNestedMenus(e){const t=e.querySelectorAll("auro-menu");0!==t.length&&t.forEach((e=>{e.querySelectorAll(":scope > auro-menuoption").forEach((e=>{e.innerHTML=`<span class="nestingSpacer"></span> ${e.innerHTML}`})),this.handleNestedMenus(e)}))}selectByValue(e){let t=!1;if(this.items||this.initItems(),this.index=void 0,this.value&&this.value.length>0){for(let n=0;n<this.items.length;n+=1)this.items[n].value===e&&(t=!0,this.index=n);t?this.makeSelection():(this.index=void 0,this.dispatchEvent(new CustomEvent("auroMenuSelectValueFailure",{bubbles:!0,cancelable:!1,composed:!0})),this.dispatchEvent(new CustomEvent("auroMenu-selectValueFailure",{bubbles:!0,cancelable:!1,composed:!0})))}else this.resetOptionsStates(),this.dispatchEvent(new CustomEvent("auroMenu-selectValueReset",{bubbles:!0,cancelable:!1,composed:!0}))}updateActiveOption(e){this.items.forEach((e=>{e.classList.remove("active")})),this.items[e].classList.add("active"),this.optionActive=this.items[e],this.dispatchEvent(new CustomEvent("auroMenuActivatedOption",{bubbles:!0,cancelable:!1,composed:!0,detail:this.items[e]})),this.dispatchEvent(new CustomEvent("auroMenu-activatedOption",{bubbles:!0,cancelable:!1,composed:!0,detail:this.items[e]}))}handleSlotItems(){this.parentElement&&this.parentElement.closest("auro-menu")&&(this.rootMenu=!1),this.rootMenu&&(this.initItems(),this.setAttribute("role","listbox"),this.handleNestedMenus(this),this.markOptions(),this.index=-1,this.getSelectedIndex(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("mousedown",this.makeSelection),this.addEventListener("auroMenuOption-mouseover",(e=>{this.index=this.items.indexOf(e.target),this.updateActiveOption(this.index)})),this.notifyReady())}notifyReady(){this.ready=!0,this.dispatchEvent(new CustomEvent("auroMenu-ready",{bubbles:!0,cancelable:!1,composed:!0}))}render(){return V`<slot @slotchange="${this.handleSlotItems}"></slot>`}}customElements.get("auro-menu")||customElements.define("auro-menu",oe); | ||
!function(e){function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var n,i,s,o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},r=function(){function e(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)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),a="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};n=function(e,n){var i=function(){function i(n){t(this,i),this.ctx=n,this.ie=!1;var s=e.navigator.userAgent;(s.indexOf("MSIE")>-1||s.indexOf("Trident")>-1)&&(this.ie=!0)}return r(i,[{key:"log",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"debug",n=this.opt.log;this.opt.debug&&"object"===(void 0===n?"undefined":a(n))&&"function"==typeof n[t]&&n[t]("mark.js: "+e)}},{key:"escapeStr",value:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}},{key:"createRegExp",value:function(e){return"disabled"!==this.opt.wildcards&&(e=this.setupWildcardsRegExp(e)),e=this.escapeStr(e),Object.keys(this.opt.synonyms).length&&(e=this.createSynonymsRegExp(e)),(this.opt.ignoreJoiners||this.opt.ignorePunctuation.length)&&(e=this.setupIgnoreJoinersRegExp(e)),this.opt.diacritics&&(e=this.createDiacriticsRegExp(e)),e=this.createMergedBlanksRegExp(e),(this.opt.ignoreJoiners||this.opt.ignorePunctuation.length)&&(e=this.createJoinersRegExp(e)),"disabled"!==this.opt.wildcards&&(e=this.createWildcardsRegExp(e)),this.createAccuracyRegExp(e)}},{key:"createSynonymsRegExp",value:function(e){var t=this.opt.synonyms,n=this.opt.caseSensitive?"":"i",i=this.opt.ignoreJoiners||this.opt.ignorePunctuation.length?"\0":"";for(var s in t)if(t.hasOwnProperty(s)){var o=t[s],r="disabled"!==this.opt.wildcards?this.setupWildcardsRegExp(s):this.escapeStr(s),a="disabled"!==this.opt.wildcards?this.setupWildcardsRegExp(o):this.escapeStr(o);""!==r&&""!==a&&(e=e.replace(new RegExp("("+r+"|"+a+")","gm"+n),i+"("+this.processSynomyms(r)+"|"+this.processSynomyms(a)+")"+i))}return e}},{key:"processSynomyms",value:function(e){return(this.opt.ignoreJoiners||this.opt.ignorePunctuation.length)&&(e=this.setupIgnoreJoinersRegExp(e)),e}},{key:"setupWildcardsRegExp",value:function(e){return(e=e.replace(/(?:\\)*\?/g,(function(e){return"\\"===e.charAt(0)?"?":""}))).replace(/(?:\\)*\*/g,(function(e){return"\\"===e.charAt(0)?"*":""}))}},{key:"createWildcardsRegExp",value:function(e){var t="withSpaces"===this.opt.wildcards;return e.replace(/\u0001/g,t?"[\\S\\s]?":"\\S?").replace(/\u0002/g,t?"[\\S\\s]*?":"\\S*")}},{key:"setupIgnoreJoinersRegExp",value:function(e){return e.replace(/[^(|)\\]/g,(function(e,t,n){var i=n.charAt(t+1);return/[(|)\\]/.test(i)||""===i?e:e+"\0"}))}},{key:"createJoinersRegExp",value:function(e){var t=[],n=this.opt.ignorePunctuation;return Array.isArray(n)&&n.length&&t.push(this.escapeStr(n.join(""))),this.opt.ignoreJoiners&&t.push("\\u00ad\\u200b\\u200c\\u200d"),t.length?e.split(/\u0000+/).join("["+t.join("")+"]*"):e}},{key:"createDiacriticsRegExp",value:function(e){var t=this.opt.caseSensitive?"":"i",n=this.opt.caseSensitive?["aàáảãạăằắẳẵặâầấẩẫậäåāą","AÀÁẢÃẠĂẰẮẲẴẶÂẦẤẨẪẬÄÅĀĄ","cçćč","CÇĆČ","dđď","DĐĎ","eèéẻẽẹêềếểễệëěēę","EÈÉẺẼẸÊỀẾỂỄỆËĚĒĘ","iìíỉĩịîïī","IÌÍỈĨỊÎÏĪ","lł","LŁ","nñňń","NÑŇŃ","oòóỏõọôồốổỗộơởỡớờợöøō","OÒÓỎÕỌÔỒỐỔỖỘƠỞỠỚỜỢÖØŌ","rř","RŘ","sšśșş","SŠŚȘŞ","tťțţ","TŤȚŢ","uùúủũụưừứửữựûüůū","UÙÚỦŨỤƯỪỨỬỮỰÛÜŮŪ","yýỳỷỹỵÿ","YÝỲỶỸỴŸ","zžżź","ZŽŻŹ"]:["aàáảãạăằắẳẵặâầấẩẫậäåāąAÀÁẢÃẠĂẰẮẲẴẶÂẦẤẨẪẬÄÅĀĄ","cçćčCÇĆČ","dđďDĐĎ","eèéẻẽẹêềếểễệëěēęEÈÉẺẼẸÊỀẾỂỄỆËĚĒĘ","iìíỉĩịîïīIÌÍỈĨỊÎÏĪ","lłLŁ","nñňńNÑŇŃ","oòóỏõọôồốổỗộơởỡớờợöøōOÒÓỎÕỌÔỒỐỔỖỘƠỞỠỚỜỢÖØŌ","rřRŘ","sšśșşSŠŚȘŞ","tťțţTŤȚŢ","uùúủũụưừứửữựûüůūUÙÚỦŨỤƯỪỨỬỮỰÛÜŮŪ","yýỳỷỹỵÿYÝỲỶỸỴŸ","zžżźZŽŻŹ"],i=[];return e.split("").forEach((function(s){n.every((function(n){if(-1!==n.indexOf(s)){if(i.indexOf(n)>-1)return!1;e=e.replace(new RegExp("["+n+"]","gm"+t),"["+n+"]"),i.push(n)}return!0}))})),e}},{key:"createMergedBlanksRegExp",value:function(e){return e.replace(/[\s]+/gim,"[\\s]+")}},{key:"createAccuracyRegExp",value:function(e){var t=this,n=this.opt.accuracy,i="string"==typeof n?n:n.value,s="";switch(("string"==typeof n?[]:n.limiters).forEach((function(e){s+="|"+t.escapeStr(e)})),i){case"partially":default:return"()("+e+")";case"complementary":return"()([^"+(s="\\s"+(s||this.escapeStr("!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~¡¿")))+"]*"+e+"[^"+s+"]*)";case"exactly":return"(^|\\s"+s+")("+e+")(?=$|\\s"+s+")"}}},{key:"getSeparatedKeywords",value:function(e){var t=this,n=[];return e.forEach((function(e){t.opt.separateWordSearch?e.split(" ").forEach((function(e){e.trim()&&-1===n.indexOf(e)&&n.push(e)})):e.trim()&&-1===n.indexOf(e)&&n.push(e)})),{keywords:n.sort((function(e,t){return t.length-e.length})),length:n.length}}},{key:"isNumeric",value:function(e){return Number(parseFloat(e))==e}},{key:"checkRanges",value:function(e){var t=this;if(!Array.isArray(e)||"[object Object]"!==Object.prototype.toString.call(e[0]))return this.log("markRanges() will only accept an array of objects"),this.opt.noMatch(e),[];var n=[],i=0;return e.sort((function(e,t){return e.start-t.start})).forEach((function(e){var s=t.callNoMatchOnInvalidRanges(e,i),o=s.start,r=s.end;s.valid&&(e.start=o,e.length=r-o,n.push(e),i=r)})),n}},{key:"callNoMatchOnInvalidRanges",value:function(e,t){var n=void 0,i=void 0,s=!1;return e&&void 0!==e.start?(i=(n=parseInt(e.start,10))+parseInt(e.length,10),this.isNumeric(e.start)&&this.isNumeric(e.length)&&i-t>0&&i-n>0?s=!0:(this.log("Ignoring invalid or overlapping range: "+JSON.stringify(e)),this.opt.noMatch(e))):(this.log("Ignoring invalid range: "+JSON.stringify(e)),this.opt.noMatch(e)),{start:n,end:i,valid:s}}},{key:"checkWhitespaceRanges",value:function(e,t,n){var i=void 0,s=!0,o=n.length,r=t-o,a=parseInt(e.start,10)-r;return(i=(a=a>o?o:a)+parseInt(e.length,10))>o&&(i=o,this.log("End range automatically set to the max value of "+o)),a<0||i-a<0||a>o||i>o?(s=!1,this.log("Invalid range: "+JSON.stringify(e)),this.opt.noMatch(e)):""===n.substring(a,i).replace(/\s+/g,"")&&(s=!1,this.log("Skipping whitespace only range: "+JSON.stringify(e)),this.opt.noMatch(e)),{start:a,end:i,valid:s}}},{key:"getTextNodes",value:function(e){var t=this,n="",i=[];this.iterator.forEachNode(NodeFilter.SHOW_TEXT,(function(e){i.push({start:n.length,end:(n+=e.textContent).length,node:e})}),(function(e){return t.matchesExclude(e.parentNode)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),(function(){e({value:n,nodes:i})}))}},{key:"matchesExclude",value:function(e){return s.matches(e,this.opt.exclude.concat(["script","style","title","head","html"]))}},{key:"wrapRangeInTextNode",value:function(e,t,i){var s=this.opt.element?this.opt.element:"mark",o=e.splitText(t),r=o.splitText(i-t),a=n.createElement(s);return a.setAttribute("data-markjs","true"),this.opt.className&&a.setAttribute("class",this.opt.className),a.textContent=o.textContent,o.parentNode.replaceChild(a,o),r}},{key:"wrapRangeInMappedTextNode",value:function(e,t,n,i,s){var o=this;e.nodes.every((function(r,a){var c=e.nodes[a+1];if(void 0===c||c.start>t){if(!i(r.node))return!1;var l=t-r.start,h=(n>r.end?r.end:n)-r.start,u=e.value.substr(0,r.start),d=e.value.substr(h+r.start);if(r.node=o.wrapRangeInTextNode(r.node,l,h),e.value=u+d,e.nodes.forEach((function(t,n){n>=a&&(e.nodes[n].start>0&&n!==a&&(e.nodes[n].start-=h),e.nodes[n].end-=h)})),n-=h,s(r.node.previousSibling,r.start),!(n>r.end))return!1;t=r.end}return!0}))}},{key:"wrapMatches",value:function(e,t,n,i,s){var o=this,r=0===t?0:t+1;this.getTextNodes((function(t){t.nodes.forEach((function(t){t=t.node;for(var s=void 0;null!==(s=e.exec(t.textContent))&&""!==s[r];)if(n(s[r],t)){var a=s.index;if(0!==r)for(var c=1;c<r;c++)a+=s[c].length;t=o.wrapRangeInTextNode(t,a,a+s[r].length),i(t.previousSibling),e.lastIndex=0}})),s()}))}},{key:"wrapMatchesAcrossElements",value:function(e,t,n,i,s){var o=this,r=0===t?0:t+1;this.getTextNodes((function(t){for(var a=void 0;null!==(a=e.exec(t.value))&&""!==a[r];){var c=a.index;if(0!==r)for(var l=1;l<r;l++)c+=a[l].length;var h=c+a[r].length;o.wrapRangeInMappedTextNode(t,c,h,(function(e){return n(a[r],e)}),(function(t,n){e.lastIndex=n,i(t)}))}s()}))}},{key:"wrapRangeFromIndex",value:function(e,t,n,i){var s=this;this.getTextNodes((function(o){var r=o.value.length;e.forEach((function(e,i){var a=s.checkWhitespaceRanges(e,r,o.value),c=a.start,l=a.end;a.valid&&s.wrapRangeInMappedTextNode(o,c,l,(function(n){return t(n,e,o.value.substring(c,l),i)}),(function(t){n(t,e)}))})),i()}))}},{key:"unwrapMatches",value:function(e){for(var t=e.parentNode,i=n.createDocumentFragment();e.firstChild;)i.appendChild(e.removeChild(e.firstChild));t.replaceChild(i,e),this.ie?this.normalizeTextNode(t):t.normalize()}},{key:"normalizeTextNode",value:function(e){if(e){if(3===e.nodeType)for(;e.nextSibling&&3===e.nextSibling.nodeType;)e.nodeValue+=e.nextSibling.nodeValue,e.parentNode.removeChild(e.nextSibling);else this.normalizeTextNode(e.firstChild);this.normalizeTextNode(e.nextSibling)}}},{key:"markRegExp",value:function(e,t){var n=this;this.opt=t,this.log('Searching with expression "'+e+'"');var i=0,s="wrapMatches";this.opt.acrossElements&&(s="wrapMatchesAcrossElements"),this[s](e,this.opt.ignoreGroups,(function(e,t){return n.opt.filter(t,e,i)}),(function(e){i++,n.opt.each(e)}),(function(){0===i&&n.opt.noMatch(e),n.opt.done(i)}))}},{key:"mark",value:function(e,t){var n=this;this.opt=t;var i=0,s="wrapMatches",o=this.getSeparatedKeywords("string"==typeof e?[e]:e),r=o.keywords,a=o.length,c=this.opt.caseSensitive?"":"i";this.opt.acrossElements&&(s="wrapMatchesAcrossElements"),0===a?this.opt.done(i):function e(t){var o=new RegExp(n.createRegExp(t),"gm"+c),l=0;n.log('Searching with expression "'+o+'"'),n[s](o,1,(function(e,s){return n.opt.filter(s,t,i,l)}),(function(e){l++,i++,n.opt.each(e)}),(function(){0===l&&n.opt.noMatch(t),r[a-1]===t?n.opt.done(i):e(r[r.indexOf(t)+1])}))}(r[0])}},{key:"markRanges",value:function(e,t){var n=this;this.opt=t;var i=0,s=this.checkRanges(e);s&&s.length?(this.log("Starting to mark with the following ranges: "+JSON.stringify(s)),this.wrapRangeFromIndex(s,(function(e,t,i,s){return n.opt.filter(e,t,i,s)}),(function(e,t){i++,n.opt.each(e,t)}),(function(){n.opt.done(i)}))):this.opt.done(i)}},{key:"unmark",value:function(e){var t=this;this.opt=e;var n=this.opt.element?this.opt.element:"*";n+="[data-markjs]",this.opt.className&&(n+="."+this.opt.className),this.log('Removal selector "'+n+'"'),this.iterator.forEachNode(NodeFilter.SHOW_ELEMENT,(function(e){t.unwrapMatches(e)}),(function(e){var i=s.matches(e,n),o=t.matchesExclude(e);return!i||o?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),this.opt.done)}},{key:"opt",set:function(t){this._opt=o({},{element:"",className:"",exclude:[],iframes:!1,iframesTimeout:5e3,separateWordSearch:!0,diacritics:!0,synonyms:{},accuracy:"partially",acrossElements:!1,caseSensitive:!1,ignoreJoiners:!1,ignoreGroups:0,ignorePunctuation:[],wildcards:"disabled",each:function(){},noMatch:function(){},filter:function(){return!0},done:function(){},debug:!1,log:e.console},t)},get:function(){return this._opt}},{key:"iterator",get:function(){return new s(this.ctx,this.opt.iframes,this.opt.exclude,this.opt.iframesTimeout)}}]),i}(),s=function(){function e(n){var i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5e3;t(this,e),this.ctx=n,this.iframes=i,this.exclude=s,this.iframesTimeout=o}return r(e,[{key:"getContexts",value:function(){var e=[];return(void 0!==this.ctx&&this.ctx?NodeList.prototype.isPrototypeOf(this.ctx)?Array.prototype.slice.call(this.ctx):Array.isArray(this.ctx)?this.ctx:"string"==typeof this.ctx?Array.prototype.slice.call(n.querySelectorAll(this.ctx)):[this.ctx]:[]).forEach((function(t){var n=e.filter((function(e){return e.contains(t)})).length>0;-1!==e.indexOf(t)||n||e.push(t)})),e}},{key:"getIframeContents",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},i=void 0;try{var s=e.contentWindow;if(i=s.document,!s||!i)throw new Error("iframe inaccessible")}catch(e){n()}i&&t(i)}},{key:"isIframeBlank",value:function(e){var t="about:blank",n=e.getAttribute("src").trim();return e.contentWindow.location.href===t&&n!==t&&n}},{key:"observeIframeLoad",value:function(e,t,n){var i=this,s=!1,o=null,r=function r(){if(!s){s=!0,clearTimeout(o);try{i.isIframeBlank(e)||(e.removeEventListener("load",r),i.getIframeContents(e,t,n))}catch(e){n()}}};e.addEventListener("load",r),o=setTimeout(r,this.iframesTimeout)}},{key:"onIframeReady",value:function(e,t,n){try{"complete"===e.contentWindow.document.readyState?this.isIframeBlank(e)?this.observeIframeLoad(e,t,n):this.getIframeContents(e,t,n):this.observeIframeLoad(e,t,n)}catch(e){n()}}},{key:"waitForIframes",value:function(e,t){var n=this,i=0;this.forEachIframe(e,(function(){return!0}),(function(e){i++,n.waitForIframes(e.querySelector("html"),(function(){--i||t()}))}),(function(e){e||t()}))}},{key:"forEachIframe",value:function(t,n,i){var s=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},r=t.querySelectorAll("iframe"),a=r.length,c=0;r=Array.prototype.slice.call(r);var l=function(){--a<=0&&o(c)};a||l(),r.forEach((function(t){e.matches(t,s.exclude)?l():s.onIframeReady(t,(function(e){n(t)&&(c++,i(e)),l()}),l)}))}},{key:"createIterator",value:function(e,t,i){return n.createNodeIterator(e,t,i,!1)}},{key:"createInstanceOnIframe",value:function(t){return new e(t.querySelector("html"),this.iframes)}},{key:"compareNodeIframe",value:function(e,t,n){if(e.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_PRECEDING){if(null===t)return!0;if(t.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_FOLLOWING)return!0}return!1}},{key:"getIteratorNode",value:function(e){var t=e.previousNode();return{prevNode:t,node:(null===t||e.nextNode())&&e.nextNode()}}},{key:"checkIframeFilter",value:function(e,t,n,i){var s=!1,o=!1;return i.forEach((function(e,t){e.val===n&&(s=t,o=e.handled)})),this.compareNodeIframe(e,t,n)?(!1!==s||o?!1===s||o||(i[s].handled=!0):i.push({val:n,handled:!0}),!0):(!1===s&&i.push({val:n,handled:!1}),!1)}},{key:"handleOpenIframes",value:function(e,t,n,i){var s=this;e.forEach((function(e){e.handled||s.getIframeContents(e.val,(function(e){s.createInstanceOnIframe(e).forEachNode(t,n,i)}))}))}},{key:"iterateThroughNodes",value:function(e,t,n,i,s){for(var o=this,r=this.createIterator(t,e,i),a=[],c=[],l=void 0,h=void 0;function(){var e=o.getIteratorNode(r);return h=e.prevNode,l=e.node}();)this.iframes&&this.forEachIframe(t,(function(e){return o.checkIframeFilter(l,h,e,a)}),(function(t){o.createInstanceOnIframe(t).forEachNode(e,(function(e){return c.push(e)}),i)})),c.push(l);c.forEach((function(e){n(e)})),this.iframes&&this.handleOpenIframes(a,e,n,i),s()}},{key:"forEachNode",value:function(e,t,n){var i=this,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},o=this.getContexts(),r=o.length;r||s(),o.forEach((function(o){var a=function(){i.iterateThroughNodes(e,o,t,n,(function(){--r<=0&&s()}))};i.iframes?i.waitForIframes(o,a):a()}))}}],[{key:"matches",value:function(e,t){var n="string"==typeof t?[t]:t,i=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.oMatchesSelector||e.webkitMatchesSelector;if(i){var s=!1;return n.every((function(t){return!i.call(e,t)||(s=!0,!1)})),s}return!1}}]),e}();return e.Mark=function(e){var t=this,n=new i(e);return this.mark=function(e,i){return n.mark(e,i),t},this.markRegExp=function(e,i){return n.markRegExp(e,i),t},this.markRanges=function(e,i){return n.markRanges(e,i),t},this.unmark=function(e){return n.unmark(e),t},this},e.Mark},i=window,s=document,"object"===a(e)&&e.exports?e.exports=n(i,s):n(i,s)}({exports:{}});class oe extends X{constructor(){super(),this.value=void 0,this.optionSelected=void 0,this.matchWord=void 0,this.noCheckmark=!1,this.ready=!1,this.optionActive=void 0,this.rootMenu=!0}static get properties(){return{noCheckmark:{type:Boolean,reflect:!0},optionSelected:{type:Object},optionActive:{type:Object},matchWord:{type:String},ready:{type:Boolean},value:{type:String}}}static get styles(){return[Q,ee]}firstUpdated(){this.addEventListener("keydown",this.handleKeyDown)}updated(e){if(this.noCheckmark){this.querySelectorAll("auro-menu").forEach((e=>{e.setAttribute("noCheckmark","")}));this.querySelectorAll("auro-menuoption").forEach((e=>{e.setAttribute("noCheckmark","")}))}e.has("matchWord")&&this.markOptions(),e.has("value")&&this.selectByValue(this.value)}optionInteractive(e){return!e.hasAttribute("hidden")&&!e.hasAttribute("disabled")&&!e.hasAttribute("static")}markOptions(){let e=[];this.items.forEach((t=>{this.optionInteractive(t)&&!t.hasAttribute("persistent")&&e.push(t)}));const t=new Mark(e);t.unmark(),this.matchWord&&this.matchWord.length>0&&t.mark(this.matchWord,{element:"strong",separateWordSearch:!1,acrossElements:!0})}resetOptionsStates(){this.optionSelected=void 0,this.items.forEach((e=>{e.classList.remove("active"),e.removeAttribute("selected"),e.removeAttribute("aria-selected")}))}handleLocalSelectState(e){e.setAttribute("selected",""),e.classList.add("active"),e.ariaSelected=!0,this.value=e.value,this.optionSelected=e,this.index=this.items.indexOf(e)}notifySelectionChange(){this.dispatchEvent(new CustomEvent("selectedOption",{bubbles:!0,cancelable:!1,composed:!0})),this.dispatchEvent(new CustomEvent("auroMenu-selectedOption",{bubbles:!0,cancelable:!1,composed:!0}))}makeSelection(){if(this.items||this.initItems(),this.resetOptionsStates(),this.index>=0){const e=this.items[this.index];e&&this.optionInteractive(e)&&(e.hasAttribute("event")?(this.dispatchEvent(new CustomEvent(e.getAttribute("event"),{bubbles:!0,cancelable:!1,composed:!0})),this.dispatchEvent(new CustomEvent("auroMenuCustomEventFired",{bubbles:!0,cancelable:!1,composed:!0})),this.dispatchEvent(new CustomEvent("auroMenu-customEventFired",{bubbles:!0,cancelable:!1,composed:!0}))):this.handleLocalSelectState(e))}this.notifySelectionChange()}handleKeyDown(e){switch(e.preventDefault(),e.key){case"ArrowDown":this.selectNextItem("down");break;case"ArrowUp":this.selectNextItem("up");break;case"Enter":this.makeSelection()}}initItems(){this.items=Array.from(this.querySelectorAll("auro-menuoption"))}getSelectedIndex(){const e=this.items.findIndex((e=>e.hasAttribute("selected")&&this.optionInteractive(e)));e>=0&&(this.index=e,this.makeSelection())}selectNextItem(e){if(this.index>=0){this.items[this.index].classList.remove("active");let t=0;"down"===e?t=1:"up"===e&&(t=-1),this.index+=t,this.index>this.items.length-1?this.index=0:this.index<0&&(this.index=this.items.length-1),this.optionInteractive(this.items[this.index])?this.updateActiveOption(this.index):this.selectNextItem(e)}else this.index=0,this.items[this.index].hasAttribute("hidden")||this.items[this.index].hasAttribute("disabled")?this.selectNextItem(e):this.updateActiveOption(this.index)}handleNestedMenus(e){const t=e.querySelectorAll("auro-menu");0!==t.length&&t.forEach((e=>{e.querySelectorAll(":scope > auro-menuoption").forEach((e=>{e.innerHTML=`<span class="nestingSpacer"></span> ${e.innerHTML}`})),this.handleNestedMenus(e)}))}selectByValue(e){let t=!1;if(this.items||this.initItems(),this.index=void 0,this.value&&this.value.length>0){for(let n=0;n<this.items.length;n+=1)this.items[n].value===e&&(t=!0,this.index=n);t?this.makeSelection():(this.index=void 0,this.dispatchEvent(new CustomEvent("auroMenuSelectValueFailure",{bubbles:!0,cancelable:!1,composed:!0})),this.dispatchEvent(new CustomEvent("auroMenu-selectValueFailure",{bubbles:!0,cancelable:!1,composed:!0})))}else this.resetOptionsStates(),this.dispatchEvent(new CustomEvent("auroMenu-selectValueReset",{bubbles:!0,cancelable:!1,composed:!0}))}updateActiveOption(e){this.items.forEach((e=>{e.classList.remove("active")})),this.items[e].classList.add("active"),this.optionActive=this.items[e],this.dispatchEvent(new CustomEvent("auroMenuActivatedOption",{bubbles:!0,cancelable:!1,composed:!0,detail:this.items[e]})),this.dispatchEvent(new CustomEvent("auroMenu-activatedOption",{bubbles:!0,cancelable:!1,composed:!0,detail:this.items[e]}))}handleSlotItems(){this.parentElement&&this.parentElement.closest("auro-menu")&&(this.rootMenu=!1),this.rootMenu&&(this.initItems(),this.setAttribute("role","listbox"),this.handleNestedMenus(this),this.markOptions(),this.index=-1,this.getSelectedIndex(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("mousedown",this.makeSelection),this.addEventListener("auroMenuOption-mouseover",(e=>{this.index=this.items.indexOf(e.target),this.updateActiveOption(this.index)})),this.notifyReady())}notifyReady(){this.ready=!0,this.dispatchEvent(new CustomEvent("auroMenu-ready",{bubbles:!0,cancelable:!1,composed:!0}))}render(){return V`<slot @slotchange="${this.handleSlotItems}"></slot>`}}customElements.get("auro-menu")||customElements.define("auro-menu",oe); |
@@ -106,3 +106,3 @@ // Copyright (c) 2021 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license | ||
optionInteractive(option) { | ||
return !option.hasAttribute('disabled') && !option.hasAttribute('static'); | ||
return !option.hasAttribute('hidden') && !option.hasAttribute('disabled') && !option.hasAttribute('static'); | ||
} | ||
@@ -109,0 +109,0 @@ |
@@ -10,3 +10,3 @@ { | ||
"name": "@aurodesignsystem/auro-menu", | ||
"version": "3.9.0", | ||
"version": "3.9.1", | ||
"description": "auro-menu HTML custom element", | ||
@@ -13,0 +13,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
138862