UNPKG

react-dropdown-aria-jesus

Version:

Simple and accessible React dropdown component

3 lines (2 loc) 30.8 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),r=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,n=function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};var o={animationIterationCount:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};function a(e){function t(e,t,n){var o=t.trim().split(h);t=o;var a=o.length,i=e.length;switch(i){case 0:case 1:var c=0;for(e=0===i?"":e[0]+" ";c<a;++c)t[c]=r(e,t[c],n).trim();break;default:var s=c=0;for(t=[];c<a;++c)for(var l=0;l<i;++l)t[s++]=r(e[l]+" ",o[c],n).trim()}return t}function r(e,t,r){var n=t.charCodeAt(0);switch(33>n&&(n=(t=t.trim()).charCodeAt(0)),n){case 38:return t.replace(b,"$1"+e.trim());case 58:return e.trim()+t.replace(b,"$1"+e.trim());default:if(0<1*r&&0<t.indexOf("\f"))return t.replace(b,(58===e.charCodeAt(0)?"":"$1")+e.trim())}return e+t}function n(e,t,r,a){var i=e+";",c=2*t+3*r+4*a;if(944===c){e=i.indexOf(":",9)+1;var s=i.substring(e,i.length-1).trim();return s=i.substring(0,e).trim()+s+";",1===_||2===_&&o(s,1)?"-webkit-"+s+s:s}if(0===_||2===_&&!o(i,1))return i;switch(c){case 1015:return 97===i.charCodeAt(10)?"-webkit-"+i+i:i;case 951:return 116===i.charCodeAt(3)?"-webkit-"+i+i:i;case 963:return 110===i.charCodeAt(5)?"-webkit-"+i+i:i;case 1009:if(100!==i.charCodeAt(4))break;case 969:case 942:return"-webkit-"+i+i;case 978:return"-webkit-"+i+"-moz-"+i+i;case 1019:case 983:return"-webkit-"+i+"-moz-"+i+"-ms-"+i+i;case 883:if(45===i.charCodeAt(8))return"-webkit-"+i+i;if(0<i.indexOf("image-set(",11))return i.replace(A,"$1-webkit-$2")+i;break;case 932:if(45===i.charCodeAt(4))switch(i.charCodeAt(5)){case 103:return"-webkit-box-"+i.replace("-grow","")+"-webkit-"+i+"-ms-"+i.replace("grow","positive")+i;case 115:return"-webkit-"+i+"-ms-"+i.replace("shrink","negative")+i;case 98:return"-webkit-"+i+"-ms-"+i.replace("basis","preferred-size")+i}return"-webkit-"+i+"-ms-"+i+i;case 964:return"-webkit-"+i+"-ms-flex-"+i+i;case 1023:if(99!==i.charCodeAt(8))break;return"-webkit-box-pack"+(s=i.substring(i.indexOf(":",15)).replace("flex-","").replace("space-between","justify"))+"-webkit-"+i+"-ms-flex-pack"+s+i;case 1005:return p.test(i)?i.replace(d,":-webkit-")+i.replace(d,":-moz-")+i:i;case 1e3:switch(t=(s=i.substring(13).trim()).indexOf("-")+1,s.charCodeAt(0)+s.charCodeAt(t)){case 226:s=i.replace(w,"tb");break;case 232:s=i.replace(w,"tb-rl");break;case 220:s=i.replace(w,"lr");break;default:return i}return"-webkit-"+i+"-ms-"+s+i;case 1017:if(-1===i.indexOf("sticky",9))break;case 975:switch(t=(i=e).length-10,c=(s=(33===i.charCodeAt(t)?i.substring(0,t):i).substring(e.indexOf(":",7)+1).trim()).charCodeAt(0)+(0|s.charCodeAt(7))){case 203:if(111>s.charCodeAt(8))break;case 115:i=i.replace(s,"-webkit-"+s)+";"+i;break;case 207:case 102:i=i.replace(s,"-webkit-"+(102<c?"inline-":"")+"box")+";"+i.replace(s,"-webkit-"+s)+";"+i.replace(s,"-ms-"+s+"box")+";"+i}return i+";";case 938:if(45===i.charCodeAt(5))switch(i.charCodeAt(6)){case 105:return s=i.replace("-items",""),"-webkit-"+i+"-webkit-box-"+s+"-ms-flex-"+s+i;case 115:return"-webkit-"+i+"-ms-flex-item-"+i.replace(x,"")+i;default:return"-webkit-"+i+"-ms-flex-line-pack"+i.replace("align-content","").replace(x,"")+i}break;case 973:case 989:if(45!==i.charCodeAt(3)||122===i.charCodeAt(4))break;case 931:case 953:if(!0===E.test(e))return 115===(s=e.substring(e.indexOf(":")+1)).charCodeAt(0)?n(e.replace("stretch","fill-available"),t,r,a).replace(":fill-available",":stretch"):i.replace(s,"-webkit-"+s)+i.replace(s,"-moz-"+s.replace("fill-",""))+i;break;case 962:if(i="-webkit-"+i+(102===i.charCodeAt(5)?"-ms-"+i:"")+i,211===r+a&&105===i.charCodeAt(13)&&0<i.indexOf("transform",10))return i.substring(0,i.indexOf(";",27)+1).replace(f,"$1-webkit-$2")+i}return i}function o(e,t){var r=e.indexOf(1===t?":":"{"),n=e.substring(0,3!==t?r:10);return r=e.substring(r+1,e.length-1),P(2!==t?n:n.replace(C,"$1"),r,t)}function a(e,t){var r=n(t,t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2));return r!==t+";"?r.replace(y," or ($1)").substring(4):"("+t+")"}function i(e,t,r,n,o,a,i,c,l,u){for(var d,p=0,f=t;p<T;++p)switch(d=D[p].call(s,e,f,r,n,o,a,i,c,l,u)){case void 0:case!1:case!0:case null:break;default:f=d}if(f!==t)return f}function c(e){return void 0!==(e=e.prefix)&&(P=null,e?"function"!=typeof e?_=1:(_=2,P=e):_=0),c}function s(e,r){var c=e;if(33>c.charCodeAt(0)&&(c=c.trim()),c=[c],0<T){var s=i(-1,r,c,c,S,O,0,0,0,0);void 0!==s&&"string"==typeof s&&(r=s)}var d=function e(r,c,s,d,p){for(var f,h,b,w,y,x=0,C=0,E=0,A=0,D=0,P=0,W=b=f=0,j=0,L=0,G=0,z=0,K=s.length,M=K-1,$="",B="",V="",F="";j<K;){if(h=s.charCodeAt(j),j===M&&0!==C+A+E+x&&(0!==C&&(h=47===C?10:47),A=E=x=0,K++,M++),0===C+A+E+x){if(j===M&&(0<L&&($=$.replace(u,"")),0<$.trim().length)){switch(h){case 32:case 9:case 59:case 13:case 10:break;default:$+=s.charAt(j)}h=59}switch(h){case 123:for(f=($=$.trim()).charCodeAt(0),b=1,z=++j;j<K;){switch(h=s.charCodeAt(j)){case 123:b++;break;case 125:b--;break;case 47:switch(h=s.charCodeAt(j+1)){case 42:case 47:e:{for(W=j+1;W<M;++W)switch(s.charCodeAt(W)){case 47:if(42===h&&42===s.charCodeAt(W-1)&&j+2!==W){j=W+1;break e}break;case 10:if(47===h){j=W+1;break e}}j=W}}break;case 91:h++;case 40:h++;case 34:case 39:for(;j++<M&&s.charCodeAt(j)!==h;);}if(0===b)break;j++}switch(b=s.substring(z,j),0===f&&(f=($=$.replace(l,"").trim()).charCodeAt(0)),f){case 64:switch(0<L&&($=$.replace(u,"")),h=$.charCodeAt(1)){case 100:case 109:case 115:case 45:L=c;break;default:L=R}if(z=(b=e(c,L,b,h,p+1)).length,0<T&&(y=i(3,b,L=t(R,$,G),c,S,O,z,h,p,d),$=L.join(""),void 0!==y&&0===(z=(b=y.trim()).length)&&(h=0,b="")),0<z)switch(h){case 115:$=$.replace(k,a);case 100:case 109:case 45:b=$+"{"+b+"}";break;case 107:b=($=$.replace(m,"$1 $2"))+"{"+b+"}",b=1===_||2===_&&o("@"+b,3)?"@-webkit-"+b+"@"+b:"@"+b;break;default:b=$+b,112===d&&(B+=b,b="")}else b="";break;default:b=e(c,t(c,$,G),b,d,p+1)}V+=b,b=G=L=W=f=0,$="",h=s.charCodeAt(++j);break;case 125:case 59:if(1<(z=($=(0<L?$.replace(u,""):$).trim()).length))switch(0===W&&(f=$.charCodeAt(0),45===f||96<f&&123>f)&&(z=($=$.replace(" ",":")).length),0<T&&void 0!==(y=i(1,$,c,r,S,O,B.length,d,p,d))&&0===(z=($=y.trim()).length)&&($="\0\0"),f=$.charCodeAt(0),h=$.charCodeAt(1),f){case 0:break;case 64:if(105===h||99===h){F+=$+s.charAt(j);break}default:58!==$.charCodeAt(z-1)&&(B+=n($,f,h,$.charCodeAt(2)))}G=L=W=f=0,$="",h=s.charCodeAt(++j)}}switch(h){case 13:case 10:47===C?C=0:0===1+f&&107!==d&&0<$.length&&(L=1,$+="\0"),0<T*I&&i(0,$,c,r,S,O,B.length,d,p,d),O=1,S++;break;case 59:case 125:if(0===C+A+E+x){O++;break}default:switch(O++,w=s.charAt(j),h){case 9:case 32:if(0===A+x+C)switch(D){case 44:case 58:case 9:case 32:w="";break;default:32!==h&&(w=" ")}break;case 0:w="\\0";break;case 12:w="\\f";break;case 11:w="\\v";break;case 38:0===A+C+x&&(L=G=1,w="\f"+w);break;case 108:if(0===A+C+x+N&&0<W)switch(j-W){case 2:112===D&&58===s.charCodeAt(j-3)&&(N=D);case 8:111===P&&(N=P)}break;case 58:0===A+C+x&&(W=j);break;case 44:0===C+E+A+x&&(L=1,w+="\r");break;case 34:case 39:0===C&&(A=A===h?0:0===A?h:A);break;case 91:0===A+C+E&&x++;break;case 93:0===A+C+E&&x--;break;case 41:0===A+C+x&&E--;break;case 40:if(0===A+C+x){if(0===f)switch(2*D+3*P){case 533:break;default:f=1}E++}break;case 64:0===C+E+A+x+W+b&&(b=1);break;case 42:case 47:if(!(0<A+x+E))switch(C){case 0:switch(2*h+3*s.charCodeAt(j+1)){case 235:C=47;break;case 220:z=j,C=42}break;case 42:47===h&&42===D&&z+2!==j&&(33===s.charCodeAt(z+2)&&(B+=s.substring(z,j+1)),w="",C=0)}}0===C&&($+=w)}P=D,D=h,j++}if(0<(z=B.length)){if(L=c,0<T&&(void 0!==(y=i(2,B,L,r,S,O,z,d,p,d))&&0===(B=y).length))return F+B+V;if(B=L.join(",")+"{"+B+"}",0!=_*N){switch(2!==_||o(B,2)||(N=0),N){case 111:B=B.replace(v,":-moz-$1")+B;break;case 112:B=B.replace(g,"::-webkit-input-$1")+B.replace(g,"::-moz-$1")+B.replace(g,":-ms-input-$1")+B}N=0}}return F+B+V}(R,c,r,0,0);return 0<T&&(void 0!==(s=i(-2,d,c,c,S,O,d.length,0,0,0))&&(d=s)),"",N=0,O=S=1,d}var l=/^\0+/g,u=/[\0\r\f]/g,d=/: */g,p=/zoo|gra/,f=/([,: ])(transform)/g,h=/,\r+?/g,b=/([\t\r\n ])*\f?&/g,m=/@(k\w+)\s*(\S*)\s*/,g=/::(place)/g,v=/:(read-only)/g,w=/[svh]\w+-[tblr]{2}/,k=/\(\s*(.*)\s*\)/g,y=/([\s\S]*?);/g,x=/-self|flex-/g,C=/[^]*?(:[rp][el]a[\w-]+)[^]*/,E=/stretch|:\s*\w+\-(?:conte|avail)/,A=/([^-])(image-set\()/,O=1,S=1,N=0,_=1,R=[],D=[],T=0,P=null,I=0;return s.use=function e(t){switch(t){case void 0:case null:T=D.length=0;break;default:switch(t.constructor){case Array:for(var r=0,n=t.length;r<n;++r)e(t[r]);break;case Function:D[T++]=t;break;case Boolean:I=0|!!t}}return e},s.set=c,void 0!==e&&c(e),s}var i,c,s=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,t){e.exports=function(e){function t(t){if(t)try{e(t+"}")}catch(e){}}return function(r,n,o,a,i,c,s,l,u,d){switch(r){case 1:if(0===u&&64===n.charCodeAt(0))return e(n+";"),"";break;case 2:if(0===l)return n+"/*|*/";break;case 3:switch(l){case 102:case 112:return e(o[0]+n),"";default:return n+(0===d?"/*|*/":"")}case-2:n.split("/*|*/}").forEach(t)}}}})),l=/[A-Z]|^ms/g,u=(i=function(e){return e.replace(l,"-$&").toLowerCase()},c={},function(e){return void 0===c[e]&&(c[e]=i(e)),c[e]}),d=function(e,t){return null==t||"boolean"==typeof t?"":1===o[e]||45===e.charCodeAt(1)||isNaN(t)||0===t?t:t+"px"};if("production"!==process.env.NODE_ENV){var p=/(attr|calc|counters?|url)\(/,f=["normal","none","counter","open-quote","close-quote","no-open-quote","no-close-quote","initial","inherit","unset"],h=d;d=function(e,t){return"content"===e&&("string"!=typeof t||-1===f.indexOf(t)&&!p.test(t)&&(t.charAt(0)!==t.charAt(t.length-1)||'"'!==t.charAt(0)&&"'"!==t.charAt(0)))&&console.error("You seem to be using a value for 'content' without quotes, try replacing it with `content: '\""+t+"\"'`"),h(e,t)}}var b=function e(t){for(var r=t.length,n=0,o="";n<r;n++){var a=t[n];if(null!=a){var i=void 0;switch(typeof a){case"boolean":break;case"function":"production"!==process.env.NODE_ENV&&console.error("Passing functions to cx is deprecated and will be removed in the next major version of Emotion.\nPlease call the function before passing it to cx."),i=e([a()]);break;case"object":if(Array.isArray(a))i=e(a);else for(var c in i="",a)a[c]&&c&&(i&&(i+=" "),i+=c);break;default:i=a}i&&(o&&(o+=" "),o+=i)}}return o},m="undefined"!=typeof document;function g(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key||""),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),(void 0!==e.container?e.container:document.head).appendChild(t),t}var v=function(){function e(e){this.isSpeedy="production"===process.env.NODE_ENV,this.tags=[],this.ctr=0,this.opts=e}var t=e.prototype;return t.inject=function(){if(this.injected)throw new Error("already injected!");this.tags[0]=g(this.opts),this.injected=!0},t.speedy=function(e){if(0!==this.ctr)throw new Error("cannot change speedy now");this.isSpeedy=!!e},t.insert=function(e,t){if(this.isSpeedy){var r=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(this.tags[this.tags.length-1]);try{r.insertRule(e,r.cssRules.length)}catch(t){"production"!==process.env.NODE_ENV&&console.warn("illegal rule",e)}}else{var n=g(this.opts);this.tags.push(n),n.appendChild(document.createTextNode(e+(t||"")))}this.ctr++,this.ctr%65e3==0&&this.tags.push(g(this.opts))},t.flush=function(){this.tags.forEach((function(e){return e.parentNode.removeChild(e)})),this.tags=[],this.ctr=0,this.injected=!1},e}();var w,k,y=function(e,t){if(void 0!==e.__SECRET_EMOTION__)return e.__SECRET_EMOTION__;void 0===t&&(t={});var r,n=t.key||"css";if("production"!==process.env.NODE_ENV&&/[^a-z-]/.test(n))throw new Error('Emotion key must only contain lower case alphabetical characters and - but "'+n+'" was passed');var o,i=s((function(e){r+=e,m&&l.insert(e,f)}));void 0!==t.prefix&&(o={prefix:t.prefix});var c={registered:{},inserted:{},nonce:t.nonce,key:n},l=new v(t);m&&l.inject();var p=new a(o);p.use(t.stylisPlugins)(i);var f="";function h(e,t){if(null==e)return"";switch(typeof e){case"boolean":return"";case"function":if(void 0!==e.__emotion_styles){var r=e.toString();if("NO_COMPONENT_SELECTOR"===r&&"production"!==process.env.NODE_ENV)throw new Error("Component selectors can only be used in conjunction with babel-plugin-emotion.");return r}return void 0===this&&"production"!==process.env.NODE_ENV&&console.error("Interpolating functions in css calls is deprecated and will be removed in the next major version of Emotion.\nIf you want to have a css call based on props, create a function that returns a css call like this\nlet dynamicStyle = (props) => css`color: ${props.color}`\nIt can be called directly with props or interpolated in a styled call like this\nlet SomeComponent = styled('div')`${dynamicStyle}`"),h.call(this,void 0===this?e():e(this.mergedProps,this.context),t);case"object":return y.call(this,e);default:var n=c.registered[e];return!1===t&&void 0!==n?n:e}}var g,w,k=new WeakMap;function y(e){if(k.has(e))return k.get(e);var t="";return Array.isArray(e)?e.forEach((function(e){t+=h.call(this,e,!1)}),this):Object.keys(e).forEach((function(r){if("object"!=typeof e[r])void 0!==c.registered[e[r]]?t+=r+"{"+c.registered[e[r]]+"}":t+=u(r)+":"+d(r,e[r])+";";else{if("NO_COMPONENT_SELECTOR"===r&&"production"!==process.env.NODE_ENV)throw new Error("Component selectors can only be used in conjunction with babel-plugin-emotion.");Array.isArray(e[r])&&"string"==typeof e[r][0]&&void 0===c.registered[e[r][0]]?e[r].forEach((function(e){t+=u(r)+":"+d(r,e)+";"})):t+=r+"{"+h.call(this,e[r],!1)+"}"}}),this),k.set(e,t),t}var x=/label:\s*([^\s;\n{]+)\s*;/g,C=function(e,t){return function(e){for(var t,r=e.length,n=r^r,o=0;r>=4;)t=1540483477*(65535&(t=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(t>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(t=1540483477*(65535&(t^=t>>>24))+((1540483477*(t>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:n^=(255&e.charCodeAt(o+2))<<16;case 2:n^=(255&e.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),((n^=n>>>15)>>>0).toString(36)}(e+t)+t};if("production"!==process.env.NODE_ENV){var E=C,A=/\/\*#\ssourceMappingURL=data:application\/json;\S+\s+\*\//g;C=function(e,t){return E(e.replace(A,(function(e){return f=e,""})),t)}}var O=function(e){var t=!0,r="",n="";null==e||void 0===e.raw?(t=!1,r+=h.call(this,e,!1)):r+=e[0];for(var o=arguments.length,a=new Array(o>1?o-1:0),i=1;i<o;i++)a[i-1]=arguments[i];return a.forEach((function(n,o){r+=h.call(this,n,46===r.charCodeAt(r.length-1)),!0===t&&void 0!==e[o+1]&&(r+=e[o+1])}),this),w=r,r=r.replace(x,(function(e,t){return n+="-"+t,""})),g=C(r,n),r};if("production"!==process.env.NODE_ENV){var S=p;p=function(e,t){S(e,t),f=""}}function N(e,t){void 0===c.inserted[g]&&(r="",p(e,t),c.inserted[g]=r)}var _=function(){var e=O.apply(this,arguments),t=n+"-"+g;return void 0===c.registered[t]&&(c.registered[t]=w),N("."+t,e),t};function R(e,t){var r="";return t.split(" ").forEach((function(t){void 0!==c.registered[t]?e.push(t):r+=t+" "})),r}function D(e,t){var r=[],n=R(r,e);return r.length<2?e:n+_(r,t)}function T(e){c.inserted[e]=!0}if(m){var P=document.querySelectorAll("[data-emotion-"+n+"]");Array.prototype.forEach.call(P,(function(e){l.tags[0].parentNode.insertBefore(e,l.tags[0]),e.getAttribute("data-emotion-"+n).split(" ").forEach(T)}))}var I={flush:function(){m&&(l.flush(),l.inject()),c.inserted={},c.registered={}},hydrate:function(e){e.forEach(T)},cx:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return D(b(t))},merge:D,getRegisteredStyles:R,injectGlobal:function(){var e=O.apply(this,arguments);N("",e)},keyframes:function(){var e=O.apply(this,arguments),t="animation-"+g;return N("","@keyframes "+t+"{"+e+"}"),t},css:_,sheet:l,caches:c};return e.__SECRET_EMOTION__=I,I}("undefined"!=typeof global?global:{}),x=(y.flush,y.hydrate,y.cx),C=(y.merge,y.getRegisteredStyles,y.injectGlobal,y.keyframes,y.css);y.sheet,y.caches;(w=exports.StyleKeys||(exports.StyleKeys={})).Arrow="Arrow",w.DropdownSelector="DropdownSelector",w.DropdownWrapper="DropdownWrapper",w.SelectorSearch="SelectorSearch",w.SelectedValue="SelectedValue",w.Placeholder="Placeholder",w.GroupContainer="GroupContainer",w.GroupDivider="GroupDivider",w.GroupHeading="GroupHeading",w.OptionContainer="OptionContainer",w.OptionItem="OptionItem",w.IconContainer="IconContainer",w.Loader="Loader",function(e){e[e.DOWN_ARROW=40]="DOWN_ARROW",e[e.ENTER=13]="ENTER",e[e.ESCAPE=27]="ESCAPE",e[e.PAGE_DOWN=34]="PAGE_DOWN",e[e.PAGE_UP=33]="PAGE_UP",e[e.TAB=9]="TAB",e[e.UP_ARROW=38]="UP_ARROW"}(k||(k={}));var E=[k.ESCAPE,k.UP_ARROW,k.DOWN_ARROW,k.PAGE_UP,k.PAGE_DOWN],A={base:"#808080",dark:"#7C7C7C",darker:"#6e6d6d",light:"#CECECE",lighter:"#e0e0e0",lightest:"#f5f5f5"},O={disabled:"#ededed",focused:"#0080bc"},S=r.memo((function(e){var n=e.onOptionClicked,o=e.option,a=e.optionClass,i=e.itemRenderer,c=e.index,s=e.selected,l=t.useCallback((function(e){e.stopPropagation(),n(o,!0)}),[n,o]),u=r.createElement(r.Fragment,null,o.iconClass&&r.createElement("i",{className:o.iconClass+" dropdown-option-icon"}),o.value);return i&&(u=i(e,c)),r.createElement("div",{"aria-label":o.ariaLabel,"aria-selected":s,className:"dropdown-option "+a,onClick:l,title:o.title},u)}));function N(e){return void 0!==e.groupOptions}var _=function(e,t){return N(t)?e.concat(t.groupOptions):e.concat(t)},R=function(e,t){return n(n({},e),{groupOptions:e.groupOptions.filter((function(e){return e.value.toLowerCase().includes(t)}))})},D=function(e){var t=e.children,n=e.className,o=e.dim,a=void 0===o?24:o;return r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:a,height:a,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather "+n},t)},T=function(){return r.createElement(D,{className:"feather-inbox"},r.createElement("polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12"}),r.createElement("path",{d:"M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"}))},P=function(){return r.createElement(D,{className:"feather-chevron-down",dim:16},r.createElement("polyline",{points:"6 9 12 15 18 9"}))},I=function(){return r.createElement(D,{className:"feather-search",dim:16},r.createElement("circle",{cx:"11",cy:"11",r:"8"}),r.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}))};function W(e){var t=e.selectedOption,n=e.options,o=e.focusedIndex,a=e.onOptionClicked,i=e.getStyle,c=e.optionItemRenderer;if(e.empty)return r.createElement("div",{"aria-label":"no data",className:"dropdown-selector-content--empty"},r.createElement(T,null),"No data");var s=c?function(e,t){return c(e,i,t)}:void 0,l=0,u=n.map((function(e){if(N(e)){var n=e.groupOptions,c=e.label,u=n.map((function(e){var n=e.value===t,c=l===o,u=x(e.className,i(exports.StyleKeys.OptionItem,{selected:n,focused:c}));return l+=1,r.createElement(S,{key:e.value,optionClass:u,onOptionClicked:a,option:e,itemRenderer:s,index:l-1,selected:n})}));return u.length?r.createElement("div",{className:i(exports.StyleKeys.GroupContainer),key:e.label},r.createElement("div",{className:i(exports.StyleKeys.GroupHeading)},r.createElement("span",null,c.toUpperCase()," |  "),r.createElement("span",null,n.length)),u,r.createElement("div",{className:i(exports.StyleKeys.GroupDivider)})):null}var d=e.value,p=e.className,f=l===o,h=d===t,b=x(p,i(exports.StyleKeys.OptionItem,{selected:h,focused:f}));return l+=1,r.createElement(S,{key:d,optionClass:b,onOptionClicked:a,option:e,itemRenderer:s,index:l-1,selected:h})}));return r.createElement(r.Fragment,null,u)}var j=function(e){return{bottom:0,left:"11px",lineHeight:"30px",overflow:"hidden",position:"absolute",right:"25px",textAlign:e.centerText?"center":"left",textOverflow:"ellipsis",top:0,whiteSpace:"nowrap"}},L={Arrow:function(){return{alignItems:"center",bottom:0,color:A.base,display:"flex",position:"absolute",right:"10px",top:0}},DropdownSelector:function(e,t){return{alignItems:"center",boxSizing:"border-box",cursor:t.open&&e.searchable?"text":"inherit",display:"flex",height:"32px",padding:"0 11px",position:"relative",width:"100%",input:{backgroundColor:"inherit",border:"none",fontSize:"inherit",height:"30px",outline:"none",width:"100%"}}},DropdownWrapper:function(e,t){var r=e.width,n=e.height,o=e.disabled,a=t.open,i=t.dropdownFocused;return{backgroundColor:o?A.light:A.lightest,border:"2px solid "+(a||i?O.focused:A.dark),borderRadius:"7",cursor:o?"not-allowed":"pointer",display:"flex",flexDirection:"column",fontSize:"1em",height:n,position:"relative",width:r,"&:hover":{border:"2px solid "+(a||i?O.focused:A.darker)},"&:disabled":{backgroundColor:O.disabled,cursor:"unset"}}},GroupContainer:function(){return{padding:"1em 0 0 0"}},GroupDivider:function(){return{borderBottom:"1px solid "+A.dark,margin:"auto",paddingTop:10,width:"85%"}},GroupHeading:function(){return{color:"grey",display:"flex",flexDirection:"row",fontSize:"0.9em",padding:"0 10px 3px 5px"}},OptionContainer:function(e,t){var r=e.openUp,n=e.maxContentHeight,o=t.open;return{backgroundColor:A.lightest,border:"2px solid "+A.darker,borderRadius:"4px",bottom:r?"105%":void 0,boxShadow:"0px "+(r?"-4px":"4px")+" 4px rgba(0, 0, 0, 0.25)",boxSizing:"border-box",color:"black",display:o?"block":"none",left:"0",listStyleType:"none",margin:"0",maxHeight:n||"175px",overflowX:"hidden",overflowY:"auto",padding:"2px 0",position:"absolute",top:r?void 0:"100%",width:"100%",zIndex:9999,".dropdown-selector-content--empty":{alignItems:"center",color:A.base,display:"flex",flexDirection:"column",justifyContent:"center",padding:"4px 0"},"&::-webkit-scrollbar":{width:"5px"},"&::-webkit-scrollbar-track":{background:"#ddd"},"&::-webkit-scrollbar-thumb":{background:"#666"}}},OptionItem:function(e,t,r){var n=r.selected,o=r.focused,a=A.lightest,i="inherit";return o&&n?(a=A.dark,i=A.lightest):o?a=A.lighter:n&&(a=A.light),{backgroundColor:a,border:"none",color:i,cursor:"pointer",fontSize:"0.95em",overflow:"hidden",padding:"5px 10px",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",display:"flex",alignItems:"center","&:hover":{backgroundColor:n?A.dark:A.light,color:n?A.lightest:void 0},".option-icon":{paddingRight:"5px"}}},Placeholder:function(e){return n({color:A.base},j(e))},SelectedValue:function(e,t){var r=t.open;return n({color:e.value&&!r?"black":A.base},j(e))},SelectorSearch:function(){return{bottom:0,left:"11px",position:"absolute",right:"25px",top:0}},IconContainer:function(){return{position:"absolute",right:"10px",top:"calc(50% - 10px)"}},Loader:function(){return{position:"relative",height:"20px",width:"20px",display:"inline-block",animation:"around 5.4s infinite","@keyframes around":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}},"&::after, &::before":{content:'""',background:"white",position:"absolute",display:"inline-block",width:"100%",height:"100%",borderWidth:"2px",borderColor:"#333 #333 transparent transparent",borderStyle:"solid",borderRadius:"20px",boxSizing:"border-box",top:"0",left:"0",animation:"around 0.7s ease-in-out infinite"},"&:: after":{animation:"around 0.7s ease-in-out 0.1s infinite",background:"transparent"}}}},G={height:0,width:0,overflow:"hidden"},z=function(e,t,o,a){var i=e.length>0?e.map((function(e,n){return r.createElement("div",{role:"option",id:o+"_list_"+n,key:o+"_list_"+n,"aria-selected":n===t,"aria-label":e.ariaLabel})})):r.createElement("div",{role:"option",id:o+"_list_0",key:o+"_list_0","aria-selected":!1,"aria-label":"No Data","aria-hidden":!0});return r.createElement("div",n({role:"listbox"},a,{id:o+"_list",style:G}),i)},K=function(e,r,n){var o=t.useState(""),a=o[0],i=o[1],c=t.useMemo((function(){return n&&a.trim()?function(e,t){for(var r=[],n=t.toLowerCase(),o=0,a=e;o<a.length;o++){var i=a[o];if(N(i)){var c=R(i,n);c.groupOptions.length>=0&&r.push(c)}else i.value.toLowerCase().includes(n)&&r.push(i)}return r}(r,a):r}),[r,a]),s=t.useCallback((function(t,r){void 0===r&&(r=!0),i(t),r&&e(0)}),[e,i]);return{searchTerm:a,setSearchTerm:s,filteredOptions:c}},M=function(e,r){var n=e.style,o=e.options,a=e.searchable,i=e.onChange,c=e.disabled,s=e.ariaDescribedBy,l=e.ariaLabel,u=e.ariaLabelledBy,d=e.ariaRequired,p=e.value,f=e.defaultOpen,h=t.useState(-1),b=h[0],m=h[1],g=t.useState(f),v=g[0],w=g[1],k=t.useRef(null),y=t.useRef(null),x=t.useRef(null),E=t.useState(!1),A=E[0],O=E[1],S=K(m,o,a),N=S.searchTerm,R=S.setSearchTerm,D=S.filteredOptions,T=t.useMemo((function(){return D.reduce(_,[])}),[D]),P=t.useMemo((function(){return T.map((function(e){return e.value})).indexOf(p)}),[T,p]),I=t.useCallback((function(t,r){var o={focusedIndex:b,open:v,dropdownFocused:A},a=L[t](e,o,r||{}),i=n[t];return C(i?i(a,o,r):a)}),[n,b,v,e,A]),W=t.useCallback((function(e){void 0===e&&(e=!1),R("",!1),w(!1),m(-1),e&&y.current&&y.current.focus()}),[y.current,R,w,m]),j=t.useCallback((function(){m(P>0?P:0),w(!0)}),[w,m,P]),G=t.useCallback((function(e,t){void 0===t&&(t=!1),e&&(i(e),R("",!1)),t&&W(!0)}),[i,W,R]);!function(e,r){var n=function(t){r.current&&!r.current.contains(t.target)&&e()};t.useEffect((function(){return document.addEventListener("mouseup",n,!1),document.addEventListener("touchend",n,!1),function(){document.removeEventListener("mouseup",n),document.removeEventListener("touchend",n)}}),[])}(W,k),function(e,r){t.useEffect((function(){if(r.current&&e>=0){var t=r.current.getElementsByClassName("dropdown-option"),n=t&&t.length?t[e]:null;if(n&&n.getBoundingClientRect){var o=n.getBoundingClientRect().height,a=r.current.getBoundingClientRect().height,i=r.current.scrollTop,c=n.offsetTop<=i;n.offsetTop>=i&&n.offsetTop+o<=i+a||(c?r.current.scrollTo({top:n.offsetTop}):r.current.scrollTo({top:n.offsetTop-a+o+8}))}}}),[e])}(b,x);var M=t.useMemo((function(){return{"aria-hidden":c,"aria-expanded":v,"aria-haspopup":"listbox","aria-activedescendant":-1===b?"":r+"_list_"+b,"aria-controls":r+"_list","aria-owns":r+"_list","aria-label":l,"aria-labelledby":u,"aria-describedby":s,"aria-required":d}}),[c,v,r,b,l,u,s,d]),$=t.useMemo((function(){return{"aria-hidden":c,"aria-expanded":v,"aria-haspopup":"listbox","aria-label":l,"aria-labelledby":u,"aria-describedby":s,"aria-required":d}}),[c,v,l,u,s,d]);return{focusedIndex:b,setFocusedIndex:m,open:v,setOpen:w,searchTerm:N,setSearchTerm:R,dropdownFocused:A,setDropdownFocused:O,setValue:G,filteredOptions:D,getStyle:I,openDropdown:j,closeDropdown:W,flattenedOptions:T,container:k,inputRef:y,listWrapper:x,ariaProps:M,ariaList:z(T,P,r,$)}},$="undefined"!=typeof window&&window.document&&window.document.documentElement,B="test"!==process.env.NODE_ENV&&$,V=0,F=function(e){var o,a=e.arrowRenderer,i=e.contentClassName,c=e.className,s=e.disabled,l=e.hideArrow,u=e.id,d=e.optionItemRenderer,p=e.pageKeyTraverseSize,f=e.placeholder,h=e.searchable,b=e.value,m=e.loading,g=(o=u,t.useMemo((function(){return o||(B?(e=V,V+=1):e="test_or_ssr","react_dropdown_aria_"+e);var e}),[o])),v=M(e,g),w=v.getStyle,y=v.open,C=v.focusedIndex,A=v.setFocusedIndex,O=v.setDropdownFocused,S=v.setValue,N=v.openDropdown,_=v.closeDropdown,R=v.searchTerm,D=v.setSearchTerm,T=v.filteredOptions,j=v.flattenedOptions,L=v.container,G=v.inputRef,z=v.listWrapper,K=v.ariaProps,$=v.ariaList,F=t.useCallback((function(){G.current&&G.current.focus()}),[G.current]),U=t.useCallback((function(){F(),s||y&&h||(y?_(!0):N())}),[y,s,h,_,N]),q=t.useCallback((function(e){switch(e){case k.UP_ARROW:A((function(e){return 0===e?j.length-1:e-1}));break;case k.DOWN_ARROW:A((function(e){return(e+1)%j.length}));break;case k.PAGE_UP:A((function(e){return e-p<0&&0!==e?0:e-p<0?j.length-1:e-p}));break;case k.PAGE_DOWN:A((function(e){return e===j.length-1?0:e+p>j.length-1?j.length-1:(e+p)%j.length}));break;case k.ESCAPE:_(!0)}}),[A,j,p,_]),H=t.useCallback((function(e){var t=e.keyCode;-1!==E.indexOf(t)?(e.preventDefault(),e.stopPropagation(),q(t)):t!==k.ENTER||y?t!==k.TAB||h?(t===k.TAB||t===k.ENTER)&&j.length>0&&C>=0&&y&&(e.stopPropagation(),e.preventDefault(),S(j[C],!0)):_():N()}),[j,S,C,y,q,N,h,_]),Y=t.useCallback((function(e){D(e.target.value)}),[D]),X=t.useCallback((function(){return O(!0)}),[O]),Z=t.useCallback((function(){return O(!1)}),[O]),J=x("dropdown",c,w(exports.StyleKeys.DropdownWrapper)),Q=x("dropdown-selector",w(exports.StyleKeys.DropdownSelector)),ee=x("dropdown-selector-search",w(exports.StyleKeys.SelectorSearch)),te=x("dropdown-selector-placeholder",w(exports.StyleKeys.Placeholder)),re=x("dropdown-selector-content",i,w(exports.StyleKeys.OptionContainer)),ne=x("dropdown-arrow",w(exports.StyleKeys.Arrow)),oe=x("icon-container",w(exports.StyleKeys.IconContainer)),ae=x("loader",w(exports.StyleKeys.Loader)),ie=t.useMemo((function(){if(l||m)return null;if(a)return r.createElement("div",{className:ne},a(y));var e=y&&h;return r.createElement("div",{className:ne},e&&r.createElement(I,null),!e&&r.createElement(P,null))}),[y,a,ne,h,l,m]),ce=t.useMemo((function(){return m?r.createElement("div",{className:oe},r.createElement("i",{className:ae})):null}),[m,oe,ae]);return r.createElement("div",{ref:L,className:J,onFocus:F,onClick:U},r.createElement("div",{className:Q},r.createElement("span",{className:ee},r.createElement("input",n({id:g,ref:G,value:b||R,onChange:Y,onKeyDown:H,onFocus:X,onBlur:Z,readOnly:!y||!h,disabled:s,autoComplete:"off",role:"combobox"},K))),ce,!b&&!R&&r.createElement("span",{className:te},f),ie),$,r.createElement("div",{className:re,ref:z},r.createElement(W,{selectedOption:b,options:T,focusedIndex:C,onOptionClicked:S,optionItemRenderer:d,getStyle:w,empty:0===j.length})))};F.defaultProps={ariaDescribedBy:null,ariaLabel:null,ariaLabelledBy:null,ariaRequired:!1,arrowRenderer:void 0,centerText:!1,className:void 0,contentClassName:null,defaultOpen:!1,disabled:!1,height:null,hideArrow:!1,id:null,maxContentHeight:150,openUp:!1,optionItemRenderer:void 0,pageKeyTraverseSize:10,placeholder:"Select ...",searchable:!1,style:{},value:void 0,width:null},exports.default=F; //# sourceMappingURL=index.js.map