From 442d7abb6ebfb088871cbb403384a9fcc84013a4 Mon Sep 17 00:00:00 2001 From: Sasha Khamkov Date: Thu, 5 Sep 2019 23:09:15 +0300 Subject: [PATCH] FEATURE (keyDown): expose keydown function override closes #28 --- README.md | 1 + dist/react-dropdown-select.js | 2 +- docs/src/pages/api.md | 9 +++++---- lib/index.js | 2 +- src/index.js | 35 ++++++++++++++++++++++------------- types.d.ts | 9 +++++++++ 6 files changed, 39 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index f0090228..6ecec9d1 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ and use as: | [dropdownRenderer](https://sanusart.github.io/react-dropdown-select/prop/dropdown-renderer) | func | | Overrides internal dropdown component | | [dropdownHandleRenderer](https://sanusart.github.io/react-dropdown-select/prop/dropdown-handle-renderer) | func | | Overrides internal dropdown handle | | searchFn | func | undefined | Overrides internal search function | +| handleKeyDownFn | func | undefined | Overrides internal keyDown function | ### License diff --git a/dist/react-dropdown-select.js b/dist/react-dropdown-select.js index 3df2af51..515f8da6 100644 --- a/dist/react-dropdown-select.js +++ b/dist/react-dropdown-select.js @@ -1 +1 @@ -module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return{}.hasOwnProperty.call(e,t)},r.p="",r(r.s=5)}([function(e,t){e.exports=require("react")},function(e,t){e.exports=require("prop-types")},function(e,t){function r(){return e.exports=r=Object.assign||function(e){for(var t=1;te.charCodeAt(2)}),d=r(3),u=r.n(d);var p=function(){function e(e){this.isSpeedy=void 0===e.speedy||e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.before=null}var t=e.prototype;return t.insert=function(e){if(this.ctr%(this.isSpeedy?65e3:1)==0){var t,r=function(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("")),t}(this);t=0===this.tags.length?this.before:this.tags[this.tags.length-1].nextSibling,this.container.insertBefore(r,t),this.tags.push(r)}var n=this.tags[this.tags.length-1];if(this.isSpeedy){var o=function(e){if(e.sheet)return e.sheet;for(var t=0;ti;++i)t[i]=r(e,t[i],n).trim();break;default:var c=i=0;for(t=[];a>i;++i)for(var l=0;s>l;++l)t[c++]=r(e[l]+" ",o[i],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(m,"$1"+e.trim());case 58:return e.trim()+t.replace(m,"$1"+e.trim());default:if(1*r>0&&t.indexOf("\f")>0)return t.replace(m,(58===e.charCodeAt(0)?"":"$1")+e.trim())}return e+t}function n(e,t,r,a){var s=e+";",i=2*t+3*r+4*a;if(944===i){e=s.indexOf(":",9)+1;var c=s.substring(e,s.length-1).trim();return c=s.substring(0,e).trim()+c+";",1===_||2===_&&o(c,1)?"-webkit-"+c+c:c}if(0===_||2===_&&!o(s,1))return s;switch(i){case 1015:return 97===s.charCodeAt(10)?"-webkit-"+s+s:s;case 951:return 116===s.charCodeAt(3)?"-webkit-"+s+s:s;case 963:return 110===s.charCodeAt(5)?"-webkit-"+s+s:s;case 1009:if(100!==s.charCodeAt(4))break;case 969:case 942:return"-webkit-"+s+s;case 978:return"-webkit-"+s+"-moz-"+s+s;case 1019:case 983:return"-webkit-"+s+"-moz-"+s+"-ms-"+s+s;case 883:if(45===s.charCodeAt(8))return"-webkit-"+s+s;if(s.indexOf("image-set(",11)>0)return s.replace(A,"$1-webkit-$2")+s;break;case 932:if(45===s.charCodeAt(4))switch(s.charCodeAt(5)){case 103:return"-webkit-box-"+s.replace("-grow","")+"-webkit-"+s+"-ms-"+s.replace("grow","positive")+s;case 115:return"-webkit-"+s+"-ms-"+s.replace("shrink","negative")+s;case 98:return"-webkit-"+s+"-ms-"+s.replace("basis","preferred-size")+s}return"-webkit-"+s+"-ms-"+s+s;case 964:return"-webkit-"+s+"-ms-flex-"+s+s;case 1023:if(99!==s.charCodeAt(8))break;return"-webkit-box-pack"+(c=s.substring(s.indexOf(":",15)).replace("flex-","").replace("space-between","justify"))+"-webkit-"+s+"-ms-flex-pack"+c+s;case 1005:return p.test(s)?s.replace(u,":-webkit-")+s.replace(u,":-moz-")+s:s;case 1e3:switch(t=(c=s.substring(13).trim()).indexOf("-")+1,c.charCodeAt(0)+c.charCodeAt(t)){case 226:c=s.replace(w,"tb");break;case 232:c=s.replace(w,"tb-rl");break;case 220:c=s.replace(w,"lr");break;default:return s}return"-webkit-"+s+"-ms-"+c+s;case 1017:if(-1===s.indexOf("sticky",9))break;case 975:switch(t=(s=e).length-10,i=(c=(33===s.charCodeAt(t)?s.substring(0,t):s).substring(e.indexOf(":",7)+1).trim()).charCodeAt(0)+(0|c.charCodeAt(7))){case 203:if(111>c.charCodeAt(8))break;case 115:s=s.replace(c,"-webkit-"+c)+";"+s;break;case 207:case 102:s=s.replace(c,"-webkit-"+(i>102?"inline-":"")+"box")+";"+s.replace(c,"-webkit-"+c)+";"+s.replace(c,"-ms-"+c+"box")+";"+s}return s+";";case 938:if(45===s.charCodeAt(5))switch(s.charCodeAt(6)){case 105:return c=s.replace("-items",""),"-webkit-"+s+"-webkit-box-"+c+"-ms-flex-"+c+s;case 115:return"-webkit-"+s+"-ms-flex-item-"+s.replace(x,"")+s;default:return"-webkit-"+s+"-ms-flex-line-pack"+s.replace("align-content","").replace(x,"")+s}break;case 973:case 989:if(45!==s.charCodeAt(3)||122===s.charCodeAt(4))break;case 931:case 953:if(!0===S.test(e))return 115===(c=e.substring(e.indexOf(":")+1)).charCodeAt(0)?n(e.replace("stretch","fill-available"),t,r,a).replace(":fill-available",":stretch"):s.replace(c,"-webkit-"+c)+s.replace(c,"-moz-"+c.replace("fill-",""))+s;break;case 962:if(s="-webkit-"+s+(102===s.charCodeAt(5)?"-ms-"+s:"")+s,211===r+a&&105===s.charCodeAt(13)&&s.indexOf("transform",10)>0)return s.substring(0,s.indexOf(";",27)+1).replace(f,"$1-webkit-$2")+s}return s}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),N(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(k," or ($1)").substring(4):"("+t+")"}function s(e,t,r,n,o,a,s,i,l,d){for(var u,p=0,f=t;I>p;++p)switch(u=P[p].call(c,e,f,r,n,o,a,s,i,l,d)){case void 0:case!1:case!0:case null:break;default:f=u}if(f!==t)return f}function i(e){return void 0!==(e=e.prefix)&&(N=null,e?"function"!=typeof e?_=1:(_=2,N=e):_=0),i}function c(e,r){var i=e;if(33>i.charCodeAt(0)&&(i=i.trim()),i=[i],I>0){var c=s(-1,r,i,i,E,O,0,0,0,0);void 0!==c&&"string"==typeof c&&(r=c)}var u=function e(r,i,c,u,p){for(var f,h,m,w,k,x=0,C=0,S=0,A=0,P=0,N=0,j=m=f=0,F=0,z=0,L=0,T=0,M=c.length,H=M-1,q="",U="",$="",G="";M>F;){if(h=c.charCodeAt(F),F===H&&0!==C+A+S+x&&(0!==C&&(h=47===C?10:47),A=S=x=0,M++,H++),0===C+A+S+x){if(F===H&&(z>0&&(q=q.replace(d,"")),q.trim().length>0)){switch(h){case 32:case 9:case 59:case 13:case 10:break;default:q+=c.charAt(F)}h=59}switch(h){case 123:for(f=(q=q.trim()).charCodeAt(0),m=1,T=++F;M>F;){switch(h=c.charCodeAt(F)){case 123:m++;break;case 125:m--;break;case 47:switch(h=c.charCodeAt(F+1)){case 42:case 47:e:{for(j=F+1;H>j;++j)switch(c.charCodeAt(j)){case 47:if(42===h&&42===c.charCodeAt(j-1)&&F+2!==j){F=j+1;break e}break;case 10:if(47===h){F=j+1;break e}}F=j}}break;case 91:h++;case 40:h++;case 34:case 39:for(;F++0&&(q=q.replace(d,"")),h=q.charCodeAt(1)){case 100:case 109:case 115:case 45:z=i;break;default:z=D}if(T=(m=e(i,z,m,h,p+1)).length,I>0&&(k=s(3,m,z=t(D,q,L),i,E,O,T,h,p,u),q=z.join(""),void 0!==k&&0===(T=(m=k.trim()).length)&&(h=0,m="")),T>0)switch(h){case 115:q=q.replace(y,a);case 100:case 109:case 45:m=q+"{"+m+"}";break;case 107:m=(q=q.replace(v,"$1 $2"))+"{"+m+"}",m=1===_||2===_&&o("@"+m,3)?"@-webkit-"+m+"@"+m:"@"+m;break;default:m=q+m,112===u&&(U+=m,m="")}else m="";break;default:m=e(i,t(i,q,L),m,u,p+1)}$+=m,m=L=z=j=f=0,q="",h=c.charCodeAt(++F);break;case 125:case 59:if((T=(q=(z>0?q.replace(d,""):q).trim()).length)>1)switch(0===j&&(f=q.charCodeAt(0),45===f||f>96&&123>f)&&(T=(q=q.replace(" ",":")).length),I>0&&void 0!==(k=s(1,q,i,r,E,O,U.length,u,p,u))&&0===(T=(q=k.trim()).length)&&(q="\0\0"),f=q.charCodeAt(0),h=q.charCodeAt(1),f){case 0:break;case 64:if(105===h||99===h){G+=q+c.charAt(F);break}default:58!==q.charCodeAt(T-1)&&(U+=n(q,f,h,q.charCodeAt(2)))}L=z=j=f=0,q="",h=c.charCodeAt(++F)}}switch(h){case 13:case 10:47===C?C=0:0===1+f&&107!==u&&q.length>0&&(z=1,q+="\0"),I*B>0&&s(0,q,i,r,E,O,U.length,u,p,u),O=1,E++;break;case 59:case 125:if(0===C+A+S+x){O++;break}default:switch(O++,w=c.charAt(F),h){case 9:case 32:if(0===A+x+C)switch(P){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&&(z=L=1,w="\f"+w);break;case 108:if(0===A+C+x+R&&j>0)switch(F-j){case 2:112===P&&58===c.charCodeAt(F-3)&&(R=P);case 8:111===N&&(R=N)}break;case 58:0===A+C+x&&(j=F);break;case 44:0===C+S+A+x&&(z=1,w+="\r");break;case 34:case 39:0===C&&(A=A===h?0:0===A?h:A);break;case 91:0===A+C+S&&x++;break;case 93:0===A+C+S&&x--;break;case 41:0===A+C+x&&S--;break;case 40:if(0===A+C+x){if(0===f)switch(2*P+3*N){case 533:break;default:f=1}S++}break;case 64:0===C+S+A+x+j+m&&(m=1);break;case 42:case 47:if(0>=A+x+S)switch(C){case 0:switch(2*h+3*c.charCodeAt(F+1)){case 235:C=47;break;case 220:T=F,C=42}break;case 42:47===h&&42===P&&T+2!==F&&(33===c.charCodeAt(T+2)&&(U+=c.substring(T,F+1)),w="",C=0)}}0===C&&(q+=w)}N=P,P=h,F++}if((T=U.length)>0){if(z=i,I>0&&void 0!==(k=s(2,U,z,r,E,O,T,u,p,u))&&0===(U=k).length)return G+U+$;if(U=z.join(",")+"{"+U+"}",0!=_*R){switch(2!==_||o(U,2)||(R=0),R){case 111:U=U.replace(b,":-moz-$1")+U;break;case 112:U=U.replace(g,"::-webkit-input-$1")+U.replace(g,"::-moz-$1")+U.replace(g,":-ms-input-$1")+U}R=0}}return G+U+$}(D,i,r,0,0);return I>0&&void 0!==(c=s(-2,u,i,i,E,O,u.length,0,0,0))&&(u=c),R=0,O=E=1,u}var l=/^\0+/g,d=/[\0\r\f]/g,u=/: */g,p=/zoo|gra/,f=/([,: ])(transform)/g,h=/,\r+?/g,m=/([\t\r\n ])*\f?&/g,v=/@(k\w+)\s*(\S*)\s*/,g=/::(place)/g,b=/:(read-only)/g,w=/[svh]\w+-[tblr]{2}/,y=/\(\s*(.*)\s*\)/g,k=/([\s\S]*?);/g,x=/-self|flex-/g,C=/[^]*?(:[rp][el]a[\w-]+)[^]*/,S=/stretch|:\s*\w+\-(?:conte|avail)/,A=/([^-])(image-set\()/,O=1,E=1,R=0,_=1,D=[],P=[],I=0,N=null,B=0;return c.use=function e(t){switch(t){case void 0:case null:I=P.length=0;break;default:if("function"==typeof t)P[I++]=t;else if("object"==typeof t)for(var r=0,n=t.length;n>r;++r)e(t[r]);else B=0|!!t}return e},c.set=i,void 0!==e&&i(e),c};function h(e){e&&m.current.insert(e+"}")}var m={current:null},v=function(e,t,r,n,o,a,s,i,c,l){switch(e){case 1:switch(t.charCodeAt(0)){case 64:return m.current.insert(t+";"),"";case 108:if(98===t.charCodeAt(2))return""}break;case 2:if(0===i)return t+"/*|*/";break;case 3:switch(i){case 102:case 112:return m.current.insert(r[0]+t),"";default:return t+(0===l?"/*|*/":"")}case-2:t.split("/*|*/}").forEach(h)}},g=function(e){void 0===e&&(e={});var t,r=e.key||"css";void 0!==e.prefix&&(t={prefix:e.prefix});var n=new f(t);var o,a={};o=e.container||document.head;var s,i=document.querySelectorAll("style[data-emotion-"+r+"]");[].forEach.call(i,function(e){e.getAttribute("data-emotion-"+r).split(" ").forEach(function(e){a[e]=!0}),e.parentNode!==o&&o.appendChild(e)}),n.use(e.stylisPlugins)(v),s=function(e,t,r,o){var a=t.name;m.current=r,n(e,t.styles),o&&(c.inserted[a]=!0)};var c={key:r,sheet:new p({key:r,container:o,nonce:e.nonce,speedy:e.speedy}),nonce:e.nonce,inserted:a,registered:{},insert:s};return c};function b(e,t,r){var n="";return r.split(" ").forEach(function(r){void 0!==e[r]?t.push(e[r]):n+=r+" "}),n}var w=function(e,t,r){var n=e.key+"-"+t.name;if(!1===r&&void 0===e.registered[n]&&(e.registered[n]=t.styles),void 0===e.inserted[t.name]){var o=t;do{e.insert("."+n,o,e.sheet,!0);o=o.next}while(void 0!==o)}};var y=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)},k={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,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan: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},x=/[A-Z]|^ms/g,C=/_EMO_([^_]+?)_([^]*?)_EMO_/g,S=function(e){return 45===e.charCodeAt(1)},A=i(function(e){return S(e)?e:e.replace(x,"-$&").toLowerCase()}),O=function(e,t){if(null==t||"boolean"==typeof t)return"";switch(e){case"animation":case"animationName":"string"==typeof t&&(t=t.replace(C,function(e,t,r){return R={name:t,styles:r,next:R},t}))}return 1===k[e]||S(e)||"number"!=typeof t||0===t?t:t+"px"};function E(e,t,r,n){if(null==r)return"";if(void 0!==r.__emotion_styles)return r;switch(typeof r){case"boolean":return"";case"object":if(1===r.anim)return R={name:r.name,styles:r.styles,next:R},r.name;if(void 0!==r.styles){var o=r.next;if(void 0!==o)for(;void 0!==o;)R={name:o.name,styles:o.styles,next:R},o=o.next;return r.styles}return function(e,t,r){var n="";if(Array.isArray(r))for(var o=0;on;n++){var a=t[n];if(null!=a){var s=void 0;switch(typeof a){case"boolean":break;case"object":if(Array.isArray(a))s=e(a);else for(var i in s="",a)a[i]&&i&&(s&&(s+=" "),s+=i);break;default:s=a}s&&(o&&(o+=" "),o+=s)}}return o};function L(e,t,r){var n=[],o=b(e,n,r);return 2>n.length?r:o+t(n)}N(function(e,t){return Object(a.createElement)(I.Consumer,null,function(r){var n=function(){for(var e=arguments.length,r=new Array(e),n=0;e>n;n++)r[n]=arguments[n];var o=D(r,t.registered);return w(t,o,!1),t.key+"-"+o.name},o={css:n,cx:function(){for(var e=arguments.length,r=new Array(e),o=0;e>o;o++)r[o]=arguments[o];return L(t.registered,n,z(r))},theme:r},a=e.children(o);return!0,a})});var T=l,M=function(e){return"theme"!==e&&"innerRef"!==e},H=function(e){return"string"==typeof e&&e.charCodeAt(0)>96?T:M},q=function e(t,r){var n,s,i;void 0!==r&&(n=r.label,i=r.target,s=t.__emotion_forwardProp&&r.shouldForwardProp?function(e){return t.__emotion_forwardProp(e)&&r.shouldForwardProp(e)}:r.shouldForwardProp);var c=t.__emotion_real===t,l=c&&t.__emotion_base||t;"function"!=typeof s&&c&&(s=t.__emotion_forwardProp);var d=s||H(l),u=!d("as");return function(){var p=arguments,f=c&&void 0!==t.__emotion_styles?t.__emotion_styles.slice(0):[];if(void 0!==n&&f.push("label:"+n+";"),null==p[0]||void 0===p[0].raw)f.push.apply(f,p);else{f.push(p[0][0]);for(var h=p.length,m=1;h>m;m++)f.push(p[m],p[0][m])}var v=N(function(e,t,r){return Object(a.createElement)(I.Consumer,null,function(n){var o=u&&e.as||l,c="",p=[],h=e;if(null==e.theme){for(var m in h={},e)h[m]=e[m];h.theme=n}"string"==typeof e.className&&(c+=b(t.registered,p,e.className));var v=D(f.concat(p),t.registered,h);w(t,v,"string"==typeof o),c+=t.key+"-"+v.name,void 0!==i&&(c+=" "+i);var g=u&&void 0===s?H(o):d,y={};for(var k in e)u&&"as"===k||g(k)&&(y[k]=e[k]);return y.className=c,y.ref=r||e.innerRef,Object(a.createElement)(o,y)})});return v.displayName=void 0!==n?n:"Styled("+("string"==typeof l?l:l.displayName||l.name||"Component")+")",v.defaultProps=t.defaultProps,v.__emotion_real=v,v.__emotion_base=l,v.__emotion_styles=f,v.__emotion_forwardProp=s,Object.defineProperty(v,"toString",{value:function(){return"."+i}}),v.withComponent=function(t,n){return e(t,void 0!==n?o()({},r||{},n):r).apply(void 0,f)},v}},U=r(4),$=r.n(U);r(1);function G(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function K(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var W=function(e){function t(){for(var t,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return K(G(t=e.call.apply(e,[this].concat(n))||this),"container",s.a.createRef()),K(G(t),"handleClick",function(e){var r=t.container.current,n=e.target,o=t.props.onClickOutside;(r&&r===n||r&&!r.contains(n))&&o(e)}),t}!function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}(t,e);var r=t.prototype;return r.componentDidMount=function(){document.addEventListener("click",this.handleClick,!0)},r.componentWillUnmount=function(){document.removeEventListener("click",this.handleClick,!0)},r.render=function(){var e=this.props,t=e.className,r=e.children;return s.a.createElement("div",{className:t,ref:this.container},r)},t}(s.a.Component),V=function(e,t,r){return!!t.find(function(t){return Z(t,r.valueField)===e})},X=function(e,t){return"rgba("+parseInt(e.slice(1,3),16)+", "+parseInt(e.slice(3,5),16)+", "+parseInt(e.slice(5,7),16)+(t&&", "+t)+")"},Y=function(e,t){var r;return void 0===t&&(t=0),function(){for(var n=arguments.length,o=Array(n),a=0;n>a;a++)o[a]=arguments[a];r&&clearTimeout(r),r=setTimeout(function(){e.apply(void 0,o),r=null},t)}},J=function(e,t){return JSON.stringify(e)===JSON.stringify(t)},Z=function(e,t){return t?t.split(".").reduce(function(e,t){return e[t]},e):void 0},Q=function(e,t,r){if(!t)return e;var n=Array.isArray(t)?t:t.split(".").filter(function(e){return e.length});return n.length?Q(e[n.shift()],n,r):void 0===e?r:e},ee="react-dropdown-select",te=q("span",{target:"e1l4eby50",label:"OptionComponent"})("padding:0 5px;border-radius:2px;line-height:21px;margin:3px 0 3px 5px;background:",function(e){return e.color},";color:#fff;display:flex;flex-direction:",function(e){return"rtl"===e.direction?"row-reverse":"row"},";.",ee,"-option-remove{cursor:pointer;width:22px;height:22px;display:inline-block;text-align:center;margin:0 -5px 0 0px;border-radius:0 3px 3px 0;:hover{color:tomato;}}:hover,:hover > span{opacity:0.9;}"),re=function(e){var t=e.item,r=e.props,n=e.state,o=e.methods;return t&&r.optionRenderer?r.optionRenderer({item:t,props:r,state:n,methods:o}):s.a.createElement(te,{role:"listitem",disabled:r.disabled,direction:r.direction,className:ee+"-option",color:r.color},s.a.createElement("span",{className:ee+"-option-label"},Z(t,r.labelField)),s.a.createElement("span",{className:ee+"-option-remove",onClick:function(e){return o.removeItem(e,t,r.closeOnSelect)}},"×"))};function ne(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function oe(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var ae=function(e,t){var r=e.addPlaceholder,n=e.searchable,o=e.placeholder,a=t.values&&0===t.values.length,s=t.values&&t.values.length>0;return s&&r&&n?r:a?o:""},se=function(e){function t(){for(var t,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return oe(ne(t=e.call.apply(e,[this].concat(n))||this),"input",s.a.createRef()),oe(ne(t),"onBlur",function(){return t.props.state.dropdown?t.input.current.focus():t.input.current.blur()}),oe(ne(t),"handleKeyPress",function(e){var r=t.props,n=r.props,o=r.state,a=r.methods;return n.create&&"Enter"===e.key&&!V(o.search,o.values,t.props)&&o.search&&null===o.cursor&&a.createNew(o.search)}),t}!function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}(t,e);var r=t.prototype;return r.componentDidUpdate=function(e){(this.props.state.dropdown||e.state.dropdown!==this.props.state.dropdown&&this.props.state.dropdown||this.props.props.autoFocus)&&this.input.current.focus(),e.state.dropdown===this.props.state.dropdown||this.props.state.dropdown||this.input.current.blur()},r.render=function(){var e=this.props,t=e.props,r=e.state,n=e.methods;return t.inputRenderer?t.inputRenderer({props:t,state:r,methods:n,inputRef:this.input}):s.a.createElement(ie,{ref:this.input,tabIndex:"-1",className:ee+"-input",size:n.getInputSize(),value:r.search,readOnly:!t.searchable,onClick:function(){return n.dropDown("open")},onKeyPress:this.handleKeyPress,onChange:n.setSearch,onBlur:this.onBlur,placeholder:ae(t,r)})},t}(a.Component),ie=q("input",{target:"e11wid6y0",label:"InputComponent"})("line-height:inherit;width:calc(",function(e){return e.size+"ch"}," + 5px);border:none;margin-left:5px;background:transparent;font-size:smaller;",function(e){return e.readOnly&&"cursor: pointer;"},":focus{outline:none;}"),ce=se,le=q("div",{target:"e1gn6jc30",label:"ContentComponent"})({name:"1vw3e5y",styles:"display:flex;flex:1;flex-wrap:wrap;"}),de=function(e){var t=e.props,r=e.state,n=e.methods;return s.a.createElement(le,{className:ee+"-content "+(t.multi?ee+"-type-multi":ee+"-type-single"),onClick:function(){return n.dropDown("open")}},t.contentRenderer?t.contentRenderer({props:t,state:r,methods:n}):s.a.createElement(s.a.Fragment,null,t.multi?r.values&&r.values.map(function(e){return s.a.createElement(re,{key:""+Z(e,t.valueField)+Z(e,t.labelField),item:e,state:r,props:t,methods:n})}):r.values&&r.values.length>0&&s.a.createElement("span",null,Z(r.values[0],t.labelField)),s.a.createElement(ce,{props:t,methods:n,state:r})))},ue=q("div",{target:"e1l5ho1t0",label:"NoDataComponent"})("padding:10px;text-align:center;color:",function(e){return e.color},";"),pe=function(e){var t=e.props,r=e.state,n=e.methods;return t.noDataRenderer?t.noDataRenderer({props:t,state:r,methods:n}):s.a.createElement(ue,{className:ee+"-no-data",color:t.color},t.noDataLabel)};var fe=function(e){function t(){for(var t,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return function(e,t,r){t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t=e.call.apply(e,[this].concat(n))||this),"item",s.a.createRef()),t}!function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}(t,e);var r=t.prototype;return r.componentDidUpdate=function(){this.props.state.cursor===this.props.itemIndex&&this.item.current&&this.item.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})},r.render=function(){var e=this.props,t=e.props,r=e.state,n=e.methods,o=e.item,a=e.itemIndex;return t.itemRenderer?t.itemRenderer({item:o,itemIndex:a,props:t,state:r,methods:n}):!t.keepSelectedInList&&n.isSelected(o)?null:s.a.createElement(he,{role:"option",ref:this.item,"aria-selected":n.isSelected(o),"aria-disabled":o.disabled,disabled:o.disabled,"aria-label":Z(o,t.labelField),key:""+Z(o,t.valueField)+Z(o,t.labelField),tabIndex:"-1",className:ee+"-item "+(n.isSelected(o)?ee+"-item-selected":"")+" "+(r.cursor===a?ee+"-item-active":"")+" "+(o.disabled?ee+"-item-disabled":""),onClick:o.disabled?void 0:function(){return n.addItem(o)},onKeyPress:o.disabled?void 0:function(){return n.addItem(o)},color:t.color},Z(o,t.labelField)," ",o.disabled&&s.a.createElement("ins",null,t.disabledLabel))},t}(a.Component),he=q("span",{target:"evc32pp0",label:"ItemComponent"})("padding:5px 10px;cursor:pointer;border-bottom:1px solid #fff;&.",ee,"-item-active{border-bottom:1px solid #fff;",function(e){var t=e.disabled,r=e.color;return!t&&r&&"background: "+X(r,.1)+";"},"}:hover,:focus{background:",function(e){var t=e.color;return t&&X(t,.1)},";outline:none;}&.",ee,"-item-selected{",function(e){var t=e.disabled,r=e.color;return t?"\n background: #f2f2f2;\n color: #ccc;\n ":"\n background: "+r+";\n color: #fff;\n border-bottom: 1px solid #fff;\n "},"}",function(e){return e.disabled?"\n background: #f2f2f2;\n color: #ccc;\n \n ins {\n text-decoration: none;\n border:1px solid #ccc;\n border-radius: 2px;\n padding: 0px 3px;\n font-size: x-small;\n text-transform: uppercase;\n }\n ":""},""),me=fe,ve=function(e,t){var r=t.getSelectRef().getBoundingClientRect(),n=r.bottom+parseInt(e.dropdownHeight,10)+parseInt(e.dropdownGap,10);return"auto"===e.dropdownPosition?n>window.innerHeight&&n>r.top?"top":"bottom":e.dropdownPosition},ge=q("div",{target:"e1qjn9k90",label:"DropDown"})("position:absolute;",function(e){var t=e.selectBounds,r=e.dropdownGap;return"top"===e.dropdownPosition?"bottom: "+(t.height+2+r)+"px":"top: "+(t.height+2+r)+"px"},";",function(e){var t=e.selectBounds,r=e.dropdownGap;return e.portal?"\n position: fixed;\n top: "+(t.bottom+r)+"px;\n left: "+(t.left-1)+"px;":"left: -1px;"},";border:1px solid #ccc;width:",function(e){return e.selectBounds.width},"px;padding:0;display:flex;flex-direction:column;background:#fff;border-radius:2px;box-shadow:0 0 10px 0 ",function(){return X("#000000",.2)},";max-height:",function(e){return e.dropdownHeight},";overflow:auto;z-index:9;:focus{outline:none;}}"),be=q("div",{target:"e1qjn9k91",label:"AddNew"})("color:",function(e){return e.color},";padding:5px 10px;:hover{background:",function(e){var t=e.color;return t&&X(t,.1)},";outline:none;cursor:pointer;}"),we=function(e){var t=e.props,r=e.state,n=e.methods;return s.a.createElement(ge,{tabIndex:"-1","aria-expanded":"true",role:"list",dropdownPosition:ve(t,n),selectBounds:r.selectBounds,portal:t.portal,dropdownGap:t.dropdownGap,dropdownHeight:t.dropdownHeight,className:ee+"-dropdown "+ee+"-dropdown-position-"+ve(t,n)},t.dropdownRenderer?t.dropdownRenderer({props:t,state:r,methods:n}):s.a.createElement(s.a.Fragment,null,t.create&&r.search&&!V(r.search,r.values,t)&&s.a.createElement(be,{className:ee+"-dropdown-add-new",color:t.color,onClick:function(){return n.createNew(r.search)}},t.createNewLabel.replace("{search}",'"'+r.search+'"')),0===n.searchResults().length?s.a.createElement(pe,{className:ee+"-no-data",state:r,props:t,methods:n}):n.searchResults().map(function(e,o){return s.a.createElement(me,{key:e[t.valueField],item:e,itemIndex:o,state:r,props:t,methods:n})})))},ye=q("div",{target:"e1l5cpc30",label:"LoadingComponent"})("@keyframes dual-ring-spin{0%{transform:rotate(0deg);}100%{transform:rotate(180deg);}}padding:0 5px;display:block;width:auto;height:auto;:after{content:' ';display:block;width:16px;height:16px;border-radius:50%;border-width:1px;border-style:solid;border-color:",function(e){return e.color}," transparent;animation:dual-ring-spin 0.7s ease-in-out infinite;margin:0 0 0 -10px;}"),ke=function(e){var t=e.props;return t.loadingRenderer?t.loadingRenderer({props:t}):s.a.createElement(ye,{className:ee+"-loading",color:t.color})},xe=q("div",{target:"e11qlq5e0",label:"ClearComponent"})({name:"992gsg",styles:"line-height:25px;margin:0 10px;cursor:pointer;:focus{outline:none;}:hover{color:tomato;}"}),Ce=function(e){var t=e.props,r=e.state,n=e.methods;return t.clearRenderer?t.clearRenderer({props:t,state:r,methods:n}):s.a.createElement(xe,{className:ee+"-clear",tabIndex:"-1",onClick:function(){return n.clearAll()},onKeyPress:function(){return n.clearAll()}},"×")},Se=q("div",{target:"e19h5j1v0",label:"SeparatorComponent"})({name:"gjy0ue",styles:"border-left:1px solid #ccc;width:1px;height:25px;display:block;"}),Ae=function(e){var t=e.props,r=e.state,n=e.methods;return t.separatorRenderer?t.separatorRenderer({props:t,state:r,methods:n}):s.a.createElement(Se,{className:ee+"-separator"})},Oe=q("div",{target:"e1vudypg0",label:"DropdownHandleComponent"})("text-align:center;",function(e){return e.dropdownOpen?"\n transform: rotate(0deg);\n margin: 0px 0 -3px 5px;\n ":"\n margin: 0 0 0 5px;\n transform: rotate(180deg);\n "},";cursor:pointer;svg{width:16px;height:16px;}:hover{path{stroke:",function(e){return e.color},";}}:focus{outline:none;path{stroke:",function(e){return e.color},";}}"),Ee=function(e){var t=e.props,r=e.state,n=e.methods;return t.dropdownHandleRenderer?t.dropdownHandleRenderer({props:t,state:r,methods:n}):s.a.createElement(Oe,{tabIndex:"-1",onClick:function(e){return n.dropDown(r.dropdown?"close":"open",e)},dropdownOpen:r.dropdown,onKeyPress:function(e){return n.dropDown("toggle",e)},onKeyDown:function(e){return n.dropDown("toggle",e)},className:ee+"-dropdown-handle",color:t.color},s.a.createElement("svg",{fill:"currentColor",viewBox:"0 0 40 40"},s.a.createElement("path",{d:"M31 26.4q0 .3-.2.5l-1.1 1.2q-.3.2-.6.2t-.5-.2l-8.7-8.8-8.8 8.8q-.2.2-.5.2t-.5-.2l-1.2-1.2q-.2-.2-.2-.5t.2-.5l10.4-10.4q.3-.2.6-.2t.5.2l10.4 10.4q.2.2.2.5z"})))};function Re(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.d(t,"Select",function(){return De});var De=function(e){function t(t){var r;return _e(Re(r=e.call(this,t)||this),"onDropdownClose",function(){r.setState({cursor:null}),r.props.onDropdownClose()}),_e(Re(r),"onScroll",function(){r.props.closeOnScroll&&r.dropDown("close"),r.updateSelectBounds()}),_e(Re(r),"updateSelectBounds",function(){return r.select.current&&r.setState({selectBounds:r.select.current.getBoundingClientRect()})}),_e(Re(r),"getSelectBounds",function(){return r.state.selectBounds}),_e(Re(r),"dropDown",function(e,t){void 0===e&&(e="toggle");var n=t&&t.target||t&&t.srcElement;return r.props.portal&&!r.props.closeOnScroll&&!r.props.closeOnSelect&&t&&n&&n.offsetParent&&n.offsetParent.classList.contains("react-dropdown-select-dropdown")?void 0:r.props.keepOpen?r.setState({dropdown:!0}):"close"===e&&r.state.dropdown?(r.select.current.blur(),r.setState({dropdown:!1,search:r.props.clearOnBlur?"":r.state.search})):"open"!==e||r.state.dropdown?"toggle"===e&&(r.select.current.focus(),r.setState({dropdown:!r.state.dropdown})):r.setState({dropdown:!0})}),_e(Re(r),"getSelectRef",function(){return r.select.current}),_e(Re(r),"addItem",function(e){if(r.props.multi){if(V(Z(e,r.props.valueField),r.state.values,r.props))return r.removeItem(null,e,!1);r.setState({values:[].concat(r.state.values,[e])})}else r.setState({values:[e],dropdown:!1});return r.props.clearOnSelect&&r.setState({search:""}),!0}),_e(Re(r),"removeItem",function(e,t,n){void 0===n&&(n=!1),e&&n&&(e.preventDefault(),e.stopPropagation(),r.dropDown("close")),r.setState({values:r.state.values.filter(function(e){return Z(e,r.props.valueField)!==Z(t,r.props.valueField)})})}),_e(Re(r),"setSearch",function(e){r.setState({cursor:null}),r.setState({search:e.target.value})}),_e(Re(r),"getInputSize",function(){return r.state.search?r.state.search.length:r.state.values.length>0?r.props.addPlaceholder.length:r.props.placeholder.length}),_e(Re(r),"toggleSelectAll",function(){return r.setState({values:0===r.state.values.length?r.selectAll():r.clearAll()})}),_e(Re(r),"clearAll",function(){r.props.onClearAll(),r.setState({values:[]})}),_e(Re(r),"selectAll",function(){return r.props.onSelectAll(),r.setState({values:r.props.options.filter(function(e){return!e.disabled})})}),_e(Re(r),"isSelected",function(e){return!!r.state.values.find(function(t){return Z(t,r.props.valueField)===Z(e,r.props.valueField)})}),_e(Re(r),"areAllSelected",function(){return r.state.values.length===r.props.options.filter(function(e){return!e.disabled}).length}),_e(Re(r),"safeString",function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}),_e(Re(r),"sortBy",function(){var e=r.props,t=e.sortBy,n=e.options;return t?(n.sort(function(e,r){return Q(e,t)Q(r,t)?1:0}),n):n}),_e(Re(r),"searchFn",function(e){var t=e.state,n=e.methods,o=new RegExp(n.safeString(t.search),"i");return n.sortBy().filter(function(e){return o.test(Z(e,r.props.searchBy)||Z(e,r.props.valueField))})}),_e(Re(r),"searchResults",function(){var e={state:r.state,props:r.props,methods:r.methods};return r.props.searchFn(e)||r.searchFn(e)}),_e(Re(r),"activeCursorItem",function(e){return r.setState({activeCursorItem:e})}),_e(Re(r),"handleKeyDown",function(e){var t=r.state.cursor;if("ArrowDown"===e.key&&null===t)return r.setState({cursor:0});if(("ArrowUp"===e.key||"ArrowDown"===e.key)&&e.preventDefault(),"Escape"===e.key&&r.dropDown("close"),"Enter"===e.key){var n=r.searchResults()[t];if(n&&!n.disabled){if(r.props.create&&V(r.state.search,r.state.values,r.props))return null;r.addItem(n)}}return"ArrowUp"===e.key&&t>0&&r.setState(function(e){return{cursor:e.cursor-1}}),"ArrowUp"===e.key&&0===t&&r.setState({cursor:r.searchResults().length}),"ArrowDown"===e.key&&r.setState(function(e){return{cursor:e.cursor+1}}),"ArrowDown"===e.key&&r.searchResults().length===t?r.setState({cursor:0}):void 0}),_e(Re(r),"renderDropdown",function(){return r.props.portal?$.a.createPortal(s.a.createElement(we,{props:r.props,state:r.state,methods:r.methods}),r.dropdownRoot):s.a.createElement(we,{props:r.props,state:r.state,methods:r.methods})}),_e(Re(r),"createNew",function(e){var t,n=((t={})[r.props.labelField]=e,t[r.props.valueField]=e,t);r.addItem(n),r.props.onCreateNew(n),r.setState({search:""})}),r.state={dropdown:!1,values:t.values,search:"",selectBounds:{},cursor:null},r.methods={removeItem:r.removeItem,dropDown:r.dropDown,addItem:r.addItem,setSearch:r.setSearch,getInputSize:r.getInputSize,toggleSelectAll:r.toggleSelectAll,clearAll:r.clearAll,selectAll:r.selectAll,searchResults:r.searchResults,getSelectRef:r.getSelectRef,isSelected:r.isSelected,getSelectBounds:r.getSelectBounds,areAllSelected:r.areAllSelected,handleKeyDown:r.handleKeyDown,activeCursorItem:r.activeCursorItem,createNew:r.createNew,sortBy:r.sortBy,safeString:r.safeString},r.select=s.a.createRef(),r.dropdownRoot="undefined"!=typeof document&&document.createElement("div"),r}!function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}(t,e);var r=t.prototype;return r.componentDidMount=function(){this.props.portal&&this.props.portal.appendChild(this.dropdownRoot),window.addEventListener("resize",Y(this.updateSelectBounds)),window.addEventListener("scroll",Y(this.onScroll)),this.props.onChange(this.state.values),this.dropDown("close"),this.select&&this.updateSelectBounds()},r.componentDidUpdate=function(e,t){!J(e.values,this.props.values)&&J(e.values,t.values)&&(this.props.onChange(this.state.values),this.setState({values:this.props.values}),this.updateSelectBounds()),t.values!==this.state.values&&(this.props.onChange(this.state.values),this.updateSelectBounds()),t.search!==this.state.search&&this.updateSelectBounds(),t.values!==this.state.values&&this.props.closeOnSelect&&this.dropDown("close"),e.multi!==this.props.multi&&this.updateSelectBounds(),t.dropdown&&t.dropdown!==this.state.dropdown&&this.onDropdownClose(),t.dropdown||t.dropdown===this.state.dropdown||this.props.onDropdownOpen()},r.componentWillUnmount=function(){this.props.portal&&this.props.portal.removeChild(this.dropdownRoot),window.removeEventListener("resize",Y(this.updateSelectBounds,this.props.debounceDelay)),window.removeEventListener("scroll",Y(this.onScroll,this.props.debounceDelay))},r.render=function(){var e=this;return s.a.createElement(W,{onClickOutside:function(t){return e.dropDown("close",t)}},s.a.createElement(Pe,{onKeyDown:this.handleKeyDown,onClick:function(t){return e.dropDown("open",t)},tabIndex:"0",direction:this.props.direction,style:this.props.style,ref:this.select,disabled:this.props.disabled,className:ee+" "+this.props.className,color:this.props.color},s.a.createElement(de,{props:this.props,state:this.state,methods:this.methods}),this.props.name&&s.a.createElement("input",{name:this.props.name,type:"hidden",value:this.props.values}),this.props.loading&&s.a.createElement(ke,{props:this.props}),this.props.clearable&&s.a.createElement(Ce,{props:this.props,state:this.state,methods:this.methods}),this.props.separator&&s.a.createElement(Ae,{props:this.props,state:this.state,methods:this.methods}),this.props.dropdownHandle&&s.a.createElement(Ee,{onClick:function(){return e.select.current.focus()},props:this.props,state:this.state,methods:this.methods}),this.state.dropdown&&this.renderDropdown()))},t}(a.Component);De.defaultProps={addPlaceholder:"",placeholder:"Select...",values:[],options:[],multi:!1,disabled:!1,searchBy:"label",sortBy:null,clearable:!1,searchable:!0,dropdownHandle:!0,separator:!1,keepOpen:void 0,noDataLabel:"No data",createNewLabel:"add {search}",disabledLabel:"disabled",dropdownGap:5,closeOnScroll:!1,debounceDelay:0,labelField:"label",valueField:"value",color:"#0074D9",keepSelectedInList:!0,closeOnSelect:!1,clearOnBlur:!0,clearOnSelect:!0,dropdownPosition:"bottom",dropdownHeight:"300px",autoFocus:!1,portal:null,create:!1,direction:"ltr",name:null,onChange:function(){},onDropdownOpen:function(){},onDropdownClose:function(){},onClearAll:function(){},onSelectAll:function(){},onCreateNew:function(){},searchFn:function(){}};var Pe=q("div",{target:"e1gzf2xs0",label:"ReactDropdownSelect"})("position:relative;display:flex;border:1px solid #ccc;width:100%;border-radius:2px;padding:2px 5px;flex-direction:row;direction:",function(e){return e.direction},";align-items:center;min-height:36px;",function(e){return e.disabled?"cursor: not-allowed;pointer-events: none;opacity: 0.3;":"pointer-events: all;"},":hover,:focus-within{border-color:",function(e){return e.color},";}:focus,:focus-within{outline:0;box-shadow:0 0 0 3px ",function(e){var t=e.color;return X(t,.2)},";}");t.default=De}]); \ No newline at end of file +module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return{}.hasOwnProperty.call(e,t)},r.p="",r(r.s=5)}([function(e,t){e.exports=require("react")},function(e,t){e.exports=require("prop-types")},function(e,t){function r(){return e.exports=r=Object.assign||function(e){for(var t=1;te.charCodeAt(2)}),d=r(3),u=r.n(d);var p=function(){function e(e){this.isSpeedy=void 0===e.speedy||e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.before=null}var t=e.prototype;return t.insert=function(e){if(this.ctr%(this.isSpeedy?65e3:1)==0){var t,r=function(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("")),t}(this);t=0===this.tags.length?this.before:this.tags[this.tags.length-1].nextSibling,this.container.insertBefore(r,t),this.tags.push(r)}var n=this.tags[this.tags.length-1];if(this.isSpeedy){var o=function(e){if(e.sheet)return e.sheet;for(var t=0;ti;++i)t[i]=r(e,t[i],n).trim();break;default:var c=i=0;for(t=[];a>i;++i)for(var l=0;s>l;++l)t[c++]=r(e[l]+" ",o[i],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(m,"$1"+e.trim());case 58:return e.trim()+t.replace(m,"$1"+e.trim());default:if(1*r>0&&t.indexOf("\f")>0)return t.replace(m,(58===e.charCodeAt(0)?"":"$1")+e.trim())}return e+t}function n(e,t,r,a){var s=e+";",i=2*t+3*r+4*a;if(944===i){e=s.indexOf(":",9)+1;var c=s.substring(e,s.length-1).trim();return c=s.substring(0,e).trim()+c+";",1===_||2===_&&o(c,1)?"-webkit-"+c+c:c}if(0===_||2===_&&!o(s,1))return s;switch(i){case 1015:return 97===s.charCodeAt(10)?"-webkit-"+s+s:s;case 951:return 116===s.charCodeAt(3)?"-webkit-"+s+s:s;case 963:return 110===s.charCodeAt(5)?"-webkit-"+s+s:s;case 1009:if(100!==s.charCodeAt(4))break;case 969:case 942:return"-webkit-"+s+s;case 978:return"-webkit-"+s+"-moz-"+s+s;case 1019:case 983:return"-webkit-"+s+"-moz-"+s+"-ms-"+s+s;case 883:if(45===s.charCodeAt(8))return"-webkit-"+s+s;if(s.indexOf("image-set(",11)>0)return s.replace(A,"$1-webkit-$2")+s;break;case 932:if(45===s.charCodeAt(4))switch(s.charCodeAt(5)){case 103:return"-webkit-box-"+s.replace("-grow","")+"-webkit-"+s+"-ms-"+s.replace("grow","positive")+s;case 115:return"-webkit-"+s+"-ms-"+s.replace("shrink","negative")+s;case 98:return"-webkit-"+s+"-ms-"+s.replace("basis","preferred-size")+s}return"-webkit-"+s+"-ms-"+s+s;case 964:return"-webkit-"+s+"-ms-flex-"+s+s;case 1023:if(99!==s.charCodeAt(8))break;return"-webkit-box-pack"+(c=s.substring(s.indexOf(":",15)).replace("flex-","").replace("space-between","justify"))+"-webkit-"+s+"-ms-flex-pack"+c+s;case 1005:return p.test(s)?s.replace(u,":-webkit-")+s.replace(u,":-moz-")+s:s;case 1e3:switch(t=(c=s.substring(13).trim()).indexOf("-")+1,c.charCodeAt(0)+c.charCodeAt(t)){case 226:c=s.replace(w,"tb");break;case 232:c=s.replace(w,"tb-rl");break;case 220:c=s.replace(w,"lr");break;default:return s}return"-webkit-"+s+"-ms-"+c+s;case 1017:if(-1===s.indexOf("sticky",9))break;case 975:switch(t=(s=e).length-10,i=(c=(33===s.charCodeAt(t)?s.substring(0,t):s).substring(e.indexOf(":",7)+1).trim()).charCodeAt(0)+(0|c.charCodeAt(7))){case 203:if(111>c.charCodeAt(8))break;case 115:s=s.replace(c,"-webkit-"+c)+";"+s;break;case 207:case 102:s=s.replace(c,"-webkit-"+(i>102?"inline-":"")+"box")+";"+s.replace(c,"-webkit-"+c)+";"+s.replace(c,"-ms-"+c+"box")+";"+s}return s+";";case 938:if(45===s.charCodeAt(5))switch(s.charCodeAt(6)){case 105:return c=s.replace("-items",""),"-webkit-"+s+"-webkit-box-"+c+"-ms-flex-"+c+s;case 115:return"-webkit-"+s+"-ms-flex-item-"+s.replace(x,"")+s;default:return"-webkit-"+s+"-ms-flex-line-pack"+s.replace("align-content","").replace(x,"")+s}break;case 973:case 989:if(45!==s.charCodeAt(3)||122===s.charCodeAt(4))break;case 931:case 953:if(!0===S.test(e))return 115===(c=e.substring(e.indexOf(":")+1)).charCodeAt(0)?n(e.replace("stretch","fill-available"),t,r,a).replace(":fill-available",":stretch"):s.replace(c,"-webkit-"+c)+s.replace(c,"-moz-"+c.replace("fill-",""))+s;break;case 962:if(s="-webkit-"+s+(102===s.charCodeAt(5)?"-ms-"+s:"")+s,211===r+a&&105===s.charCodeAt(13)&&s.indexOf("transform",10)>0)return s.substring(0,s.indexOf(";",27)+1).replace(f,"$1-webkit-$2")+s}return s}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),N(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(k," or ($1)").substring(4):"("+t+")"}function s(e,t,r,n,o,a,s,i,l,d){for(var u,p=0,f=t;I>p;++p)switch(u=P[p].call(c,e,f,r,n,o,a,s,i,l,d)){case void 0:case!1:case!0:case null:break;default:f=u}if(f!==t)return f}function i(e){return void 0!==(e=e.prefix)&&(N=null,e?"function"!=typeof e?_=1:(_=2,N=e):_=0),i}function c(e,r){var i=e;if(33>i.charCodeAt(0)&&(i=i.trim()),i=[i],I>0){var c=s(-1,r,i,i,E,O,0,0,0,0);void 0!==c&&"string"==typeof c&&(r=c)}var u=function e(r,i,c,u,p){for(var f,h,m,w,k,x=0,C=0,S=0,A=0,P=0,N=0,B=m=f=0,j=0,z=0,L=0,T=0,M=c.length,H=M-1,q="",U="",$="",K="";M>j;){if(h=c.charCodeAt(j),j===H&&0!==C+A+S+x&&(0!==C&&(h=47===C?10:47),A=S=x=0,M++,H++),0===C+A+S+x){if(j===H&&(z>0&&(q=q.replace(d,"")),q.trim().length>0)){switch(h){case 32:case 9:case 59:case 13:case 10:break;default:q+=c.charAt(j)}h=59}switch(h){case 123:for(f=(q=q.trim()).charCodeAt(0),m=1,T=++j;M>j;){switch(h=c.charCodeAt(j)){case 123:m++;break;case 125:m--;break;case 47:switch(h=c.charCodeAt(j+1)){case 42:case 47:e:{for(B=j+1;H>B;++B)switch(c.charCodeAt(B)){case 47:if(42===h&&42===c.charCodeAt(B-1)&&j+2!==B){j=B+1;break e}break;case 10:if(47===h){j=B+1;break e}}j=B}}break;case 91:h++;case 40:h++;case 34:case 39:for(;j++0&&(q=q.replace(d,"")),h=q.charCodeAt(1)){case 100:case 109:case 115:case 45:z=i;break;default:z=D}if(T=(m=e(i,z,m,h,p+1)).length,I>0&&(k=s(3,m,z=t(D,q,L),i,E,O,T,h,p,u),q=z.join(""),void 0!==k&&0===(T=(m=k.trim()).length)&&(h=0,m="")),T>0)switch(h){case 115:q=q.replace(y,a);case 100:case 109:case 45:m=q+"{"+m+"}";break;case 107:m=(q=q.replace(v,"$1 $2"))+"{"+m+"}",m=1===_||2===_&&o("@"+m,3)?"@-webkit-"+m+"@"+m:"@"+m;break;default:m=q+m,112===u&&(U+=m,m="")}else m="";break;default:m=e(i,t(i,q,L),m,u,p+1)}$+=m,m=L=z=B=f=0,q="",h=c.charCodeAt(++j);break;case 125:case 59:if((T=(q=(z>0?q.replace(d,""):q).trim()).length)>1)switch(0===B&&(f=q.charCodeAt(0),45===f||f>96&&123>f)&&(T=(q=q.replace(" ",":")).length),I>0&&void 0!==(k=s(1,q,i,r,E,O,U.length,u,p,u))&&0===(T=(q=k.trim()).length)&&(q="\0\0"),f=q.charCodeAt(0),h=q.charCodeAt(1),f){case 0:break;case 64:if(105===h||99===h){K+=q+c.charAt(j);break}default:58!==q.charCodeAt(T-1)&&(U+=n(q,f,h,q.charCodeAt(2)))}L=z=B=f=0,q="",h=c.charCodeAt(++j)}}switch(h){case 13:case 10:47===C?C=0:0===1+f&&107!==u&&q.length>0&&(z=1,q+="\0"),I*F>0&&s(0,q,i,r,E,O,U.length,u,p,u),O=1,E++;break;case 59:case 125:if(0===C+A+S+x){O++;break}default:switch(O++,w=c.charAt(j),h){case 9:case 32:if(0===A+x+C)switch(P){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&&(z=L=1,w="\f"+w);break;case 108:if(0===A+C+x+R&&B>0)switch(j-B){case 2:112===P&&58===c.charCodeAt(j-3)&&(R=P);case 8:111===N&&(R=N)}break;case 58:0===A+C+x&&(B=j);break;case 44:0===C+S+A+x&&(z=1,w+="\r");break;case 34:case 39:0===C&&(A=A===h?0:0===A?h:A);break;case 91:0===A+C+S&&x++;break;case 93:0===A+C+S&&x--;break;case 41:0===A+C+x&&S--;break;case 40:if(0===A+C+x){if(0===f)switch(2*P+3*N){case 533:break;default:f=1}S++}break;case 64:0===C+S+A+x+B+m&&(m=1);break;case 42:case 47:if(0>=A+x+S)switch(C){case 0:switch(2*h+3*c.charCodeAt(j+1)){case 235:C=47;break;case 220:T=j,C=42}break;case 42:47===h&&42===P&&T+2!==j&&(33===c.charCodeAt(T+2)&&(U+=c.substring(T,j+1)),w="",C=0)}}0===C&&(q+=w)}N=P,P=h,j++}if((T=U.length)>0){if(z=i,I>0&&void 0!==(k=s(2,U,z,r,E,O,T,u,p,u))&&0===(U=k).length)return K+U+$;if(U=z.join(",")+"{"+U+"}",0!=_*R){switch(2!==_||o(U,2)||(R=0),R){case 111:U=U.replace(b,":-moz-$1")+U;break;case 112:U=U.replace(g,"::-webkit-input-$1")+U.replace(g,"::-moz-$1")+U.replace(g,":-ms-input-$1")+U}R=0}}return K+U+$}(D,i,r,0,0);return I>0&&void 0!==(c=s(-2,u,i,i,E,O,u.length,0,0,0))&&(u=c),R=0,O=E=1,u}var l=/^\0+/g,d=/[\0\r\f]/g,u=/: */g,p=/zoo|gra/,f=/([,: ])(transform)/g,h=/,\r+?/g,m=/([\t\r\n ])*\f?&/g,v=/@(k\w+)\s*(\S*)\s*/,g=/::(place)/g,b=/:(read-only)/g,w=/[svh]\w+-[tblr]{2}/,y=/\(\s*(.*)\s*\)/g,k=/([\s\S]*?);/g,x=/-self|flex-/g,C=/[^]*?(:[rp][el]a[\w-]+)[^]*/,S=/stretch|:\s*\w+\-(?:conte|avail)/,A=/([^-])(image-set\()/,O=1,E=1,R=0,_=1,D=[],P=[],I=0,N=null,F=0;return c.use=function e(t){switch(t){case void 0:case null:I=P.length=0;break;default:if("function"==typeof t)P[I++]=t;else if("object"==typeof t)for(var r=0,n=t.length;n>r;++r)e(t[r]);else F=0|!!t}return e},c.set=i,void 0!==e&&i(e),c};function h(e){e&&m.current.insert(e+"}")}var m={current:null},v=function(e,t,r,n,o,a,s,i,c,l){switch(e){case 1:switch(t.charCodeAt(0)){case 64:return m.current.insert(t+";"),"";case 108:if(98===t.charCodeAt(2))return""}break;case 2:if(0===i)return t+"/*|*/";break;case 3:switch(i){case 102:case 112:return m.current.insert(r[0]+t),"";default:return t+(0===l?"/*|*/":"")}case-2:t.split("/*|*/}").forEach(h)}},g=function(e){void 0===e&&(e={});var t,r=e.key||"css";void 0!==e.prefix&&(t={prefix:e.prefix});var n=new f(t);var o,a={};o=e.container||document.head;var s,i=document.querySelectorAll("style[data-emotion-"+r+"]");[].forEach.call(i,function(e){e.getAttribute("data-emotion-"+r).split(" ").forEach(function(e){a[e]=!0}),e.parentNode!==o&&o.appendChild(e)}),n.use(e.stylisPlugins)(v),s=function(e,t,r,o){var a=t.name;m.current=r,n(e,t.styles),o&&(c.inserted[a]=!0)};var c={key:r,sheet:new p({key:r,container:o,nonce:e.nonce,speedy:e.speedy}),nonce:e.nonce,inserted:a,registered:{},insert:s};return c};function b(e,t,r){var n="";return r.split(" ").forEach(function(r){void 0!==e[r]?t.push(e[r]):n+=r+" "}),n}var w=function(e,t,r){var n=e.key+"-"+t.name;if(!1===r&&void 0===e.registered[n]&&(e.registered[n]=t.styles),void 0===e.inserted[t.name]){var o=t;do{e.insert("."+n,o,e.sheet,!0);o=o.next}while(void 0!==o)}};var y=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)},k={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,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan: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},x=/[A-Z]|^ms/g,C=/_EMO_([^_]+?)_([^]*?)_EMO_/g,S=function(e){return 45===e.charCodeAt(1)},A=i(function(e){return S(e)?e:e.replace(x,"-$&").toLowerCase()}),O=function(e,t){if(null==t||"boolean"==typeof t)return"";switch(e){case"animation":case"animationName":"string"==typeof t&&(t=t.replace(C,function(e,t,r){return R={name:t,styles:r,next:R},t}))}return 1===k[e]||S(e)||"number"!=typeof t||0===t?t:t+"px"};function E(e,t,r,n){if(null==r)return"";if(void 0!==r.__emotion_styles)return r;switch(typeof r){case"boolean":return"";case"object":if(1===r.anim)return R={name:r.name,styles:r.styles,next:R},r.name;if(void 0!==r.styles){var o=r.next;if(void 0!==o)for(;void 0!==o;)R={name:o.name,styles:o.styles,next:R},o=o.next;return r.styles}return function(e,t,r){var n="";if(Array.isArray(r))for(var o=0;on;n++){var a=t[n];if(null!=a){var s=void 0;switch(typeof a){case"boolean":break;case"object":if(Array.isArray(a))s=e(a);else for(var i in s="",a)a[i]&&i&&(s&&(s+=" "),s+=i);break;default:s=a}s&&(o&&(o+=" "),o+=s)}}return o};function L(e,t,r){var n=[],o=b(e,n,r);return 2>n.length?r:o+t(n)}N(function(e,t){return Object(a.createElement)(I.Consumer,null,function(r){var n=function(){for(var e=arguments.length,r=new Array(e),n=0;e>n;n++)r[n]=arguments[n];var o=D(r,t.registered);return w(t,o,!1),t.key+"-"+o.name},o={css:n,cx:function(){for(var e=arguments.length,r=new Array(e),o=0;e>o;o++)r[o]=arguments[o];return L(t.registered,n,z(r))},theme:r},a=e.children(o);return!0,a})});var T=l,M=function(e){return"theme"!==e&&"innerRef"!==e},H=function(e){return"string"==typeof e&&e.charCodeAt(0)>96?T:M},q=function e(t,r){var n,s,i;void 0!==r&&(n=r.label,i=r.target,s=t.__emotion_forwardProp&&r.shouldForwardProp?function(e){return t.__emotion_forwardProp(e)&&r.shouldForwardProp(e)}:r.shouldForwardProp);var c=t.__emotion_real===t,l=c&&t.__emotion_base||t;"function"!=typeof s&&c&&(s=t.__emotion_forwardProp);var d=s||H(l),u=!d("as");return function(){var p=arguments,f=c&&void 0!==t.__emotion_styles?t.__emotion_styles.slice(0):[];if(void 0!==n&&f.push("label:"+n+";"),null==p[0]||void 0===p[0].raw)f.push.apply(f,p);else{f.push(p[0][0]);for(var h=p.length,m=1;h>m;m++)f.push(p[m],p[0][m])}var v=N(function(e,t,r){return Object(a.createElement)(I.Consumer,null,function(n){var o=u&&e.as||l,c="",p=[],h=e;if(null==e.theme){for(var m in h={},e)h[m]=e[m];h.theme=n}"string"==typeof e.className&&(c+=b(t.registered,p,e.className));var v=D(f.concat(p),t.registered,h);w(t,v,"string"==typeof o),c+=t.key+"-"+v.name,void 0!==i&&(c+=" "+i);var g=u&&void 0===s?H(o):d,y={};for(var k in e)u&&"as"===k||g(k)&&(y[k]=e[k]);return y.className=c,y.ref=r||e.innerRef,Object(a.createElement)(o,y)})});return v.displayName=void 0!==n?n:"Styled("+("string"==typeof l?l:l.displayName||l.name||"Component")+")",v.defaultProps=t.defaultProps,v.__emotion_real=v,v.__emotion_base=l,v.__emotion_styles=f,v.__emotion_forwardProp=s,Object.defineProperty(v,"toString",{value:function(){return"."+i}}),v.withComponent=function(t,n){return e(t,void 0!==n?o()({},r||{},n):r).apply(void 0,f)},v}},U=r(4),$=r.n(U);r(1);function K(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function G(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var W=function(e){function t(){for(var t,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return G(K(t=e.call.apply(e,[this].concat(n))||this),"container",s.a.createRef()),G(K(t),"handleClick",function(e){var r=t.container.current,n=e.target,o=t.props.onClickOutside;(r&&r===n||r&&!r.contains(n))&&o(e)}),t}!function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}(t,e);var r=t.prototype;return r.componentDidMount=function(){document.addEventListener("click",this.handleClick,!0)},r.componentWillUnmount=function(){document.removeEventListener("click",this.handleClick,!0)},r.render=function(){var e=this.props,t=e.className,r=e.children;return s.a.createElement("div",{className:t,ref:this.container},r)},t}(s.a.Component),V=function(e,t,r){return!!t.find(function(t){return Z(t,r.valueField)===e})},X=function(e,t){return"rgba("+parseInt(e.slice(1,3),16)+", "+parseInt(e.slice(3,5),16)+", "+parseInt(e.slice(5,7),16)+(t&&", "+t)+")"},Y=function(e,t){var r;return void 0===t&&(t=0),function(){for(var n=arguments.length,o=Array(n),a=0;n>a;a++)o[a]=arguments[a];r&&clearTimeout(r),r=setTimeout(function(){e.apply(void 0,o),r=null},t)}},J=function(e,t){return JSON.stringify(e)===JSON.stringify(t)},Z=function(e,t){return t?t.split(".").reduce(function(e,t){return e[t]},e):void 0},Q=function(e,t,r){if(!t)return e;var n=Array.isArray(t)?t:t.split(".").filter(function(e){return e.length});return n.length?Q(e[n.shift()],n,r):void 0===e?r:e},ee="react-dropdown-select",te=q("span",{target:"e1l4eby50",label:"OptionComponent"})("padding:0 5px;border-radius:2px;line-height:21px;margin:3px 0 3px 5px;background:",function(e){return e.color},";color:#fff;display:flex;flex-direction:",function(e){return"rtl"===e.direction?"row-reverse":"row"},";.",ee,"-option-remove{cursor:pointer;width:22px;height:22px;display:inline-block;text-align:center;margin:0 -5px 0 0px;border-radius:0 3px 3px 0;:hover{color:tomato;}}:hover,:hover > span{opacity:0.9;}"),re=function(e){var t=e.item,r=e.props,n=e.state,o=e.methods;return t&&r.optionRenderer?r.optionRenderer({item:t,props:r,state:n,methods:o}):s.a.createElement(te,{role:"listitem",disabled:r.disabled,direction:r.direction,className:ee+"-option",color:r.color},s.a.createElement("span",{className:ee+"-option-label"},Z(t,r.labelField)),s.a.createElement("span",{className:ee+"-option-remove",onClick:function(e){return o.removeItem(e,t,r.closeOnSelect)}},"×"))};function ne(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function oe(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var ae=function(e,t){var r=e.addPlaceholder,n=e.searchable,o=e.placeholder,a=t.values&&0===t.values.length,s=t.values&&t.values.length>0;return s&&r&&n?r:a?o:""},se=function(e){function t(){for(var t,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return oe(ne(t=e.call.apply(e,[this].concat(n))||this),"input",s.a.createRef()),oe(ne(t),"onBlur",function(){return t.props.state.dropdown?t.input.current.focus():t.input.current.blur()}),oe(ne(t),"handleKeyPress",function(e){var r=t.props,n=r.props,o=r.state,a=r.methods;return n.create&&"Enter"===e.key&&!V(o.search,o.values,t.props)&&o.search&&null===o.cursor&&a.createNew(o.search)}),t}!function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}(t,e);var r=t.prototype;return r.componentDidUpdate=function(e){(this.props.state.dropdown||e.state.dropdown!==this.props.state.dropdown&&this.props.state.dropdown||this.props.props.autoFocus)&&this.input.current.focus(),e.state.dropdown===this.props.state.dropdown||this.props.state.dropdown||this.input.current.blur()},r.render=function(){var e=this.props,t=e.props,r=e.state,n=e.methods;return t.inputRenderer?t.inputRenderer({props:t,state:r,methods:n,inputRef:this.input}):s.a.createElement(ie,{ref:this.input,tabIndex:"-1",className:ee+"-input",size:n.getInputSize(),value:r.search,readOnly:!t.searchable,onClick:function(){return n.dropDown("open")},onKeyPress:this.handleKeyPress,onChange:n.setSearch,onBlur:this.onBlur,placeholder:ae(t,r)})},t}(a.Component),ie=q("input",{target:"e11wid6y0",label:"InputComponent"})("line-height:inherit;width:calc(",function(e){return e.size+"ch"}," + 5px);border:none;margin-left:5px;background:transparent;font-size:smaller;",function(e){return e.readOnly&&"cursor: pointer;"},":focus{outline:none;}"),ce=se,le=q("div",{target:"e1gn6jc30",label:"ContentComponent"})({name:"1vw3e5y",styles:"display:flex;flex:1;flex-wrap:wrap;"}),de=function(e){var t=e.props,r=e.state,n=e.methods;return s.a.createElement(le,{className:ee+"-content "+(t.multi?ee+"-type-multi":ee+"-type-single"),onClick:function(){return n.dropDown("open")}},t.contentRenderer?t.contentRenderer({props:t,state:r,methods:n}):s.a.createElement(s.a.Fragment,null,t.multi?r.values&&r.values.map(function(e){return s.a.createElement(re,{key:""+Z(e,t.valueField)+Z(e,t.labelField),item:e,state:r,props:t,methods:n})}):r.values&&r.values.length>0&&s.a.createElement("span",null,Z(r.values[0],t.labelField)),s.a.createElement(ce,{props:t,methods:n,state:r})))},ue=q("div",{target:"e1l5ho1t0",label:"NoDataComponent"})("padding:10px;text-align:center;color:",function(e){return e.color},";"),pe=function(e){var t=e.props,r=e.state,n=e.methods;return t.noDataRenderer?t.noDataRenderer({props:t,state:r,methods:n}):s.a.createElement(ue,{className:ee+"-no-data",color:t.color},t.noDataLabel)};var fe=function(e){function t(){for(var t,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return function(e,t,r){t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t=e.call.apply(e,[this].concat(n))||this),"item",s.a.createRef()),t}!function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}(t,e);var r=t.prototype;return r.componentDidUpdate=function(){this.props.state.cursor===this.props.itemIndex&&this.item.current&&this.item.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})},r.render=function(){var e=this.props,t=e.props,r=e.state,n=e.methods,o=e.item,a=e.itemIndex;return t.itemRenderer?t.itemRenderer({item:o,itemIndex:a,props:t,state:r,methods:n}):!t.keepSelectedInList&&n.isSelected(o)?null:s.a.createElement(he,{role:"option",ref:this.item,"aria-selected":n.isSelected(o),"aria-disabled":o.disabled,disabled:o.disabled,"aria-label":Z(o,t.labelField),key:""+Z(o,t.valueField)+Z(o,t.labelField),tabIndex:"-1",className:ee+"-item "+(n.isSelected(o)?ee+"-item-selected":"")+" "+(r.cursor===a?ee+"-item-active":"")+" "+(o.disabled?ee+"-item-disabled":""),onClick:o.disabled?void 0:function(){return n.addItem(o)},onKeyPress:o.disabled?void 0:function(){return n.addItem(o)},color:t.color},Z(o,t.labelField)," ",o.disabled&&s.a.createElement("ins",null,t.disabledLabel))},t}(a.Component),he=q("span",{target:"evc32pp0",label:"ItemComponent"})("padding:5px 10px;cursor:pointer;border-bottom:1px solid #fff;&.",ee,"-item-active{border-bottom:1px solid #fff;",function(e){var t=e.disabled,r=e.color;return!t&&r&&"background: "+X(r,.1)+";"},"}:hover,:focus{background:",function(e){var t=e.color;return t&&X(t,.1)},";outline:none;}&.",ee,"-item-selected{",function(e){var t=e.disabled,r=e.color;return t?"\n background: #f2f2f2;\n color: #ccc;\n ":"\n background: "+r+";\n color: #fff;\n border-bottom: 1px solid #fff;\n "},"}",function(e){return e.disabled?"\n background: #f2f2f2;\n color: #ccc;\n \n ins {\n text-decoration: none;\n border:1px solid #ccc;\n border-radius: 2px;\n padding: 0px 3px;\n font-size: x-small;\n text-transform: uppercase;\n }\n ":""},""),me=fe,ve=function(e,t){var r=t.getSelectRef().getBoundingClientRect(),n=r.bottom+parseInt(e.dropdownHeight,10)+parseInt(e.dropdownGap,10);return"auto"===e.dropdownPosition?n>window.innerHeight&&n>r.top?"top":"bottom":e.dropdownPosition},ge=q("div",{target:"e1qjn9k90",label:"DropDown"})("position:absolute;",function(e){var t=e.selectBounds,r=e.dropdownGap;return"top"===e.dropdownPosition?"bottom: "+(t.height+2+r)+"px":"top: "+(t.height+2+r)+"px"},";",function(e){var t=e.selectBounds,r=e.dropdownGap;return e.portal?"\n position: fixed;\n top: "+(t.bottom+r)+"px;\n left: "+(t.left-1)+"px;":"left: -1px;"},";border:1px solid #ccc;width:",function(e){return e.selectBounds.width},"px;padding:0;display:flex;flex-direction:column;background:#fff;border-radius:2px;box-shadow:0 0 10px 0 ",function(){return X("#000000",.2)},";max-height:",function(e){return e.dropdownHeight},";overflow:auto;z-index:9;:focus{outline:none;}}"),be=q("div",{target:"e1qjn9k91",label:"AddNew"})("color:",function(e){return e.color},";padding:5px 10px;:hover{background:",function(e){var t=e.color;return t&&X(t,.1)},";outline:none;cursor:pointer;}"),we=function(e){var t=e.props,r=e.state,n=e.methods;return s.a.createElement(ge,{tabIndex:"-1","aria-expanded":"true",role:"list",dropdownPosition:ve(t,n),selectBounds:r.selectBounds,portal:t.portal,dropdownGap:t.dropdownGap,dropdownHeight:t.dropdownHeight,className:ee+"-dropdown "+ee+"-dropdown-position-"+ve(t,n)},t.dropdownRenderer?t.dropdownRenderer({props:t,state:r,methods:n}):s.a.createElement(s.a.Fragment,null,t.create&&r.search&&!V(r.search,r.values,t)&&s.a.createElement(be,{className:ee+"-dropdown-add-new",color:t.color,onClick:function(){return n.createNew(r.search)}},t.createNewLabel.replace("{search}",'"'+r.search+'"')),0===n.searchResults().length?s.a.createElement(pe,{className:ee+"-no-data",state:r,props:t,methods:n}):n.searchResults().map(function(e,o){return s.a.createElement(me,{key:e[t.valueField],item:e,itemIndex:o,state:r,props:t,methods:n})})))},ye=q("div",{target:"e1l5cpc30",label:"LoadingComponent"})("@keyframes dual-ring-spin{0%{transform:rotate(0deg);}100%{transform:rotate(180deg);}}padding:0 5px;display:block;width:auto;height:auto;:after{content:' ';display:block;width:16px;height:16px;border-radius:50%;border-width:1px;border-style:solid;border-color:",function(e){return e.color}," transparent;animation:dual-ring-spin 0.7s ease-in-out infinite;margin:0 0 0 -10px;}"),ke=function(e){var t=e.props;return t.loadingRenderer?t.loadingRenderer({props:t}):s.a.createElement(ye,{className:ee+"-loading",color:t.color})},xe=q("div",{target:"e11qlq5e0",label:"ClearComponent"})({name:"992gsg",styles:"line-height:25px;margin:0 10px;cursor:pointer;:focus{outline:none;}:hover{color:tomato;}"}),Ce=function(e){var t=e.props,r=e.state,n=e.methods;return t.clearRenderer?t.clearRenderer({props:t,state:r,methods:n}):s.a.createElement(xe,{className:ee+"-clear",tabIndex:"-1",onClick:function(){return n.clearAll()},onKeyPress:function(){return n.clearAll()}},"×")},Se=q("div",{target:"e19h5j1v0",label:"SeparatorComponent"})({name:"gjy0ue",styles:"border-left:1px solid #ccc;width:1px;height:25px;display:block;"}),Ae=function(e){var t=e.props,r=e.state,n=e.methods;return t.separatorRenderer?t.separatorRenderer({props:t,state:r,methods:n}):s.a.createElement(Se,{className:ee+"-separator"})},Oe=q("div",{target:"e1vudypg0",label:"DropdownHandleComponent"})("text-align:center;",function(e){return e.dropdownOpen?"\n transform: rotate(0deg);\n margin: 0px 0 -3px 5px;\n ":"\n margin: 0 0 0 5px;\n transform: rotate(180deg);\n "},";cursor:pointer;svg{width:16px;height:16px;}:hover{path{stroke:",function(e){return e.color},";}}:focus{outline:none;path{stroke:",function(e){return e.color},";}}"),Ee=function(e){var t=e.props,r=e.state,n=e.methods;return t.dropdownHandleRenderer?t.dropdownHandleRenderer({props:t,state:r,methods:n}):s.a.createElement(Oe,{tabIndex:"-1",onClick:function(e){return n.dropDown(r.dropdown?"close":"open",e)},dropdownOpen:r.dropdown,onKeyPress:function(e){return n.dropDown("toggle",e)},onKeyDown:function(e){return n.dropDown("toggle",e)},className:ee+"-dropdown-handle",color:t.color},s.a.createElement("svg",{fill:"currentColor",viewBox:"0 0 40 40"},s.a.createElement("path",{d:"M31 26.4q0 .3-.2.5l-1.1 1.2q-.3.2-.6.2t-.5-.2l-8.7-8.8-8.8 8.8q-.2.2-.5.2t-.5-.2l-1.2-1.2q-.2-.2-.2-.5t.2-.5l10.4-10.4q.3-.2.6-.2t.5.2l10.4 10.4q.2.2.2.5z"})))};function Re(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.d(t,"Select",function(){return De});var De=function(e){function t(t){var r;return _e(Re(r=e.call(this,t)||this),"onDropdownClose",function(){r.setState({cursor:null}),r.props.onDropdownClose()}),_e(Re(r),"onScroll",function(){r.props.closeOnScroll&&r.dropDown("close"),r.updateSelectBounds()}),_e(Re(r),"updateSelectBounds",function(){return r.select.current&&r.setState({selectBounds:r.select.current.getBoundingClientRect()})}),_e(Re(r),"getSelectBounds",function(){return r.state.selectBounds}),_e(Re(r),"dropDown",function(e,t){void 0===e&&(e="toggle");var n=t&&t.target||t&&t.srcElement;return r.props.portal&&!r.props.closeOnScroll&&!r.props.closeOnSelect&&t&&n&&n.offsetParent&&n.offsetParent.classList.contains("react-dropdown-select-dropdown")?void 0:r.props.keepOpen?r.setState({dropdown:!0}):"close"===e&&r.state.dropdown?(r.select.current.blur(),r.setState({dropdown:!1,search:r.props.clearOnBlur?"":r.state.search})):"open"!==e||r.state.dropdown?"toggle"===e&&(r.select.current.focus(),r.setState({dropdown:!r.state.dropdown})):r.setState({dropdown:!0})}),_e(Re(r),"getSelectRef",function(){return r.select.current}),_e(Re(r),"addItem",function(e){if(r.props.multi){if(V(Z(e,r.props.valueField),r.state.values,r.props))return r.removeItem(null,e,!1);r.setState({values:[].concat(r.state.values,[e])})}else r.setState({values:[e],dropdown:!1});return r.props.clearOnSelect&&r.setState({search:""}),!0}),_e(Re(r),"removeItem",function(e,t,n){void 0===n&&(n=!1),e&&n&&(e.preventDefault(),e.stopPropagation(),r.dropDown("close")),r.setState({values:r.state.values.filter(function(e){return Z(e,r.props.valueField)!==Z(t,r.props.valueField)})})}),_e(Re(r),"setSearch",function(e){r.setState({cursor:null}),r.setState({search:e.target.value})}),_e(Re(r),"getInputSize",function(){return r.state.search?r.state.search.length:r.state.values.length>0?r.props.addPlaceholder.length:r.props.placeholder.length}),_e(Re(r),"toggleSelectAll",function(){return r.setState({values:0===r.state.values.length?r.selectAll():r.clearAll()})}),_e(Re(r),"clearAll",function(){r.props.onClearAll(),r.setState({values:[]})}),_e(Re(r),"selectAll",function(){return r.props.onSelectAll(),r.setState({values:r.props.options.filter(function(e){return!e.disabled})})}),_e(Re(r),"isSelected",function(e){return!!r.state.values.find(function(t){return Z(t,r.props.valueField)===Z(e,r.props.valueField)})}),_e(Re(r),"areAllSelected",function(){return r.state.values.length===r.props.options.filter(function(e){return!e.disabled}).length}),_e(Re(r),"safeString",function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}),_e(Re(r),"sortBy",function(){var e=r.props,t=e.sortBy,n=e.options;return t?(n.sort(function(e,r){return Q(e,t)Q(r,t)?1:0}),n):n}),_e(Re(r),"searchFn",function(e){var t=e.state,n=e.methods,o=new RegExp(n.safeString(t.search),"i");return n.sortBy().filter(function(e){return o.test(Z(e,r.props.searchBy)||Z(e,r.props.valueField))})}),_e(Re(r),"searchResults",function(){var e={state:r.state,props:r.props,methods:r.methods};return r.props.searchFn(e)||r.searchFn(e)}),_e(Re(r),"activeCursorItem",function(e){return r.setState({activeCursorItem:e})}),_e(Re(r),"handleKeyDown",function(e){var t={event:e,state:r.state,props:r.props,methods:r.methods,setState:r.setState.bind(Re(r))};return r.props.handleKeyDownFn(t)||r.handleKeyDownFn(t)}),_e(Re(r),"handleKeyDownFn",function(e){var t=e.event,n=e.state,o=e.props,a=e.methods,s=e.setState,i=n.cursor;if("ArrowDown"===t.key&&null===i)return s({cursor:0});if(("ArrowUp"===t.key||"ArrowDown"===t.key)&&t.preventDefault(),"Escape"===t.key&&r.dropDown("close"),"Enter"===t.key){var c=a.searchResults()[i];if(c&&!c.disabled){if(o.create&&V(n.search,n.values,o))return null;a.addItem(c)}}return"ArrowUp"===t.key&&i>0&&s(function(e){return{cursor:e.cursor-1}}),"ArrowUp"===t.key&&0===i&&s({cursor:a.searchResults().length}),"ArrowDown"===t.key&&s(function(e){return{cursor:e.cursor+1}}),"ArrowDown"===t.key&&a.searchResults().length===i?s({cursor:0}):void 0}),_e(Re(r),"renderDropdown",function(){return r.props.portal?$.a.createPortal(s.a.createElement(we,{props:r.props,state:r.state,methods:r.methods}),r.dropdownRoot):s.a.createElement(we,{props:r.props,state:r.state,methods:r.methods})}),_e(Re(r),"createNew",function(e){var t,n=((t={})[r.props.labelField]=e,t[r.props.valueField]=e,t);r.addItem(n),r.props.onCreateNew(n),r.setState({search:""})}),r.state={dropdown:!1,values:t.values,search:"",selectBounds:{},cursor:null},r.methods={removeItem:r.removeItem,dropDown:r.dropDown,addItem:r.addItem,setSearch:r.setSearch,getInputSize:r.getInputSize,toggleSelectAll:r.toggleSelectAll,clearAll:r.clearAll,selectAll:r.selectAll,searchResults:r.searchResults,getSelectRef:r.getSelectRef,isSelected:r.isSelected,getSelectBounds:r.getSelectBounds,areAllSelected:r.areAllSelected,handleKeyDown:r.handleKeyDown,activeCursorItem:r.activeCursorItem,createNew:r.createNew,sortBy:r.sortBy,safeString:r.safeString},r.select=s.a.createRef(),r.dropdownRoot="undefined"!=typeof document&&document.createElement("div"),r}!function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}(t,e);var r=t.prototype;return r.componentDidMount=function(){this.props.portal&&this.props.portal.appendChild(this.dropdownRoot),window.addEventListener("resize",Y(this.updateSelectBounds)),window.addEventListener("scroll",Y(this.onScroll)),this.props.onChange(this.state.values),this.dropDown("close"),this.select&&this.updateSelectBounds()},r.componentDidUpdate=function(e,t){!J(e.values,this.props.values)&&J(e.values,t.values)&&(this.props.onChange(this.state.values),this.setState({values:this.props.values}),this.updateSelectBounds()),t.values!==this.state.values&&(this.props.onChange(this.state.values),this.updateSelectBounds()),t.search!==this.state.search&&this.updateSelectBounds(),t.values!==this.state.values&&this.props.closeOnSelect&&this.dropDown("close"),e.multi!==this.props.multi&&this.updateSelectBounds(),t.dropdown&&t.dropdown!==this.state.dropdown&&this.onDropdownClose(),t.dropdown||t.dropdown===this.state.dropdown||this.props.onDropdownOpen()},r.componentWillUnmount=function(){this.props.portal&&this.props.portal.removeChild(this.dropdownRoot),window.removeEventListener("resize",Y(this.updateSelectBounds,this.props.debounceDelay)),window.removeEventListener("scroll",Y(this.onScroll,this.props.debounceDelay))},r.render=function(){var e=this;return s.a.createElement(W,{onClickOutside:function(t){return e.dropDown("close",t)}},s.a.createElement(Pe,{onKeyDown:this.handleKeyDown,onClick:function(t){return e.dropDown("open",t)},tabIndex:"0",direction:this.props.direction,style:this.props.style,ref:this.select,disabled:this.props.disabled,className:ee+" "+this.props.className,color:this.props.color},s.a.createElement(de,{props:this.props,state:this.state,methods:this.methods}),this.props.name&&s.a.createElement("input",{name:this.props.name,type:"hidden",value:this.props.values}),this.props.loading&&s.a.createElement(ke,{props:this.props}),this.props.clearable&&s.a.createElement(Ce,{props:this.props,state:this.state,methods:this.methods}),this.props.separator&&s.a.createElement(Ae,{props:this.props,state:this.state,methods:this.methods}),this.props.dropdownHandle&&s.a.createElement(Ee,{onClick:function(){return e.select.current.focus()},props:this.props,state:this.state,methods:this.methods}),this.state.dropdown&&this.renderDropdown()))},t}(a.Component);De.defaultProps={addPlaceholder:"",placeholder:"Select...",values:[],options:[],multi:!1,disabled:!1,searchBy:"label",sortBy:null,clearable:!1,searchable:!0,dropdownHandle:!0,separator:!1,keepOpen:void 0,noDataLabel:"No data",createNewLabel:"add {search}",disabledLabel:"disabled",dropdownGap:5,closeOnScroll:!1,debounceDelay:0,labelField:"label",valueField:"value",color:"#0074D9",keepSelectedInList:!0,closeOnSelect:!1,clearOnBlur:!0,clearOnSelect:!0,dropdownPosition:"bottom",dropdownHeight:"300px",autoFocus:!1,portal:null,create:!1,direction:"ltr",name:null,onChange:function(){},onDropdownOpen:function(){},onDropdownClose:function(){},onClearAll:function(){},onSelectAll:function(){},onCreateNew:function(){},searchFn:function(){},handleKeyDownFn:function(){}};var Pe=q("div",{target:"e1gzf2xs0",label:"ReactDropdownSelect"})("position:relative;display:flex;border:1px solid #ccc;width:100%;border-radius:2px;padding:2px 5px;flex-direction:row;direction:",function(e){return e.direction},";align-items:center;min-height:36px;",function(e){return e.disabled?"cursor: not-allowed;pointer-events: none;opacity: 0.3;":"pointer-events: all;"},":hover,:focus-within{border-color:",function(e){return e.color},";}:focus,:focus-within{outline:0;box-shadow:0 0 0 3px ",function(e){var t=e.color;return X(t,.2)},";}");t.default=De}]); \ No newline at end of file diff --git a/docs/src/pages/api.md b/docs/src/pages/api.md index c8b0a6aa..a3e4e392 100644 --- a/docs/src/pages/api.md +++ b/docs/src/pages/api.md @@ -29,10 +29,10 @@ title: 'API' | dropdownHandle | bool | true | Dropdown handle to open/close dropdown | | dropdownHeight | string | "300px" | Minimum height of a dropdown | | [direction](https://sanusart.github.io/react-dropdown-select/examples/#Right-to-left) | string | "ltr" | direction of a dropdown "ltr", "rtl" or "auto" | -| searchBy | string | label | Search by object property (or nested property with dot notation) in values | -| sortBy | string | null | Sort by object property (or nested property with dot notation) in values | -| labelField | string | "label" | Field (or nested property with dot notation) in data to use for label | -| valueField | string | "value" | Field (or nested property with dot notation) in data to use for value | +| searchBy | string | label | Search by object property (or nested property with dot notation) in values | +| sortBy | string | null | Sort by object property (or nested property with dot notation) in values | +| labelField | string | "label" | Field (or nested property with dot notation) in data to use for label | +| valueField | string | "value" | Field (or nested property with dot notation) in data to use for value | | color | string | "#0074D9" | Base color to use in component, also can be overwritten via CSS | | closeOnScroll | bool | false | If true, scrolling the page will close the dropdown | | closeOnSelect | bool | false | If true, selecting option will close the dropdown | @@ -66,3 +66,4 @@ title: 'API' | [dropdownRenderer](https://sanusart.github.io/react-dropdown-select/prop/dropdown-renderer) | func | | Overrides internal dropdown component | | [dropdownHandleRenderer](https://sanusart.github.io/react-dropdown-select/prop/dropdown-handle-renderer) | func | | Overrides internal dropdown handle | | searchFn | func | undefined | Overrides internal search function | +| handleKeyDownFn | func | undefined | Overrides internal keyDown function | diff --git a/lib/index.js b/lib/index.js index 66514923..b19231bb 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1 +1 @@ -"use strict";exports.__esModule=!0,exports.default=exports.Select=void 0;var _styledBase=_interopRequireDefault(require("@emotion/styled-base")),_react=_interopRequireWildcard(require("react")),_reactDom=_interopRequireDefault(require("react-dom")),_propTypes=_interopRequireDefault(require("prop-types")),_ClickOutside=_interopRequireDefault(require("./components/ClickOutside")),_Content=_interopRequireDefault(require("./components/Content")),_Dropdown=_interopRequireDefault(require("./components/Dropdown")),_Loading=_interopRequireDefault(require("./components/Loading")),_Clear=_interopRequireDefault(require("./components/Clear")),_Separator=_interopRequireDefault(require("./components/Separator")),_DropdownHandle=_interopRequireDefault(require("./components/DropdownHandle")),_util=require("./util"),_constants=require("./constants");function _interopRequireWildcard(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)if(Object.prototype.hasOwnProperty.call(a,c)){var d=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(a,c):{};d.get||d.set?Object.defineProperty(b,c,d):b[c]=a[c]}return b.default=a,b}function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _inheritsLoose(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a,a.__proto__=b}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}var Select=/*#__PURE__*/function(a){function b(b){var c;return c=a.call(this,b)||this,_defineProperty(_assertThisInitialized(c),"onDropdownClose",function(){c.setState({cursor:null}),c.props.onDropdownClose()}),_defineProperty(_assertThisInitialized(c),"onScroll",function(){c.props.closeOnScroll&&c.dropDown("close"),c.updateSelectBounds()}),_defineProperty(_assertThisInitialized(c),"updateSelectBounds",function(){return c.select.current&&c.setState({selectBounds:c.select.current.getBoundingClientRect()})}),_defineProperty(_assertThisInitialized(c),"getSelectBounds",function(){return c.state.selectBounds}),_defineProperty(_assertThisInitialized(c),"dropDown",function(a,b){void 0===a&&(a="toggle");var d=b&&b.target||b&&b.srcElement;return c.props.portal&&!c.props.closeOnScroll&&!c.props.closeOnSelect&&b&&d&&d.offsetParent&&d.offsetParent.classList.contains("react-dropdown-select-dropdown")?void 0:c.props.keepOpen?c.setState({dropdown:!0}):"close"===a&&c.state.dropdown?(c.select.current.blur(),c.setState({dropdown:!1,search:c.props.clearOnBlur?"":c.state.search})):"open"!==a||c.state.dropdown?"toggle"===a&&(c.select.current.focus(),c.setState({dropdown:!c.state.dropdown})):c.setState({dropdown:!0})}),_defineProperty(_assertThisInitialized(c),"getSelectRef",function(){return c.select.current}),_defineProperty(_assertThisInitialized(c),"addItem",function(a){if(c.props.multi){if((0,_util.valueExistInSelected)((0,_util.getByPath)(a,c.props.valueField),c.state.values,c.props))return c.removeItem(null,a,!1);c.setState({values:[].concat(c.state.values,[a])})}else c.setState({values:[a],dropdown:!1});return c.props.clearOnSelect&&c.setState({search:""}),!0}),_defineProperty(_assertThisInitialized(c),"removeItem",function(a,b,d){void 0===d&&(d=!1),a&&d&&(a.preventDefault(),a.stopPropagation(),c.dropDown("close")),c.setState({values:c.state.values.filter(function(a){return(0,_util.getByPath)(a,c.props.valueField)!==(0,_util.getByPath)(b,c.props.valueField)})})}),_defineProperty(_assertThisInitialized(c),"setSearch",function(a){c.setState({cursor:null}),c.setState({search:a.target.value})}),_defineProperty(_assertThisInitialized(c),"getInputSize",function(){return c.state.search?c.state.search.length:0(0,_util.getProp)(a,d)?1:0}),e):e}),_defineProperty(_assertThisInitialized(c),"searchFn",function(a){var b=a.state,d=a.methods,e=new RegExp(d.safeString(b.search),"i");return d.sortBy().filter(function(a){return e.test((0,_util.getByPath)(a,c.props.searchBy)||(0,_util.getByPath)(a,c.props.valueField))})}),_defineProperty(_assertThisInitialized(c),"searchResults",function(){var a={state:c.state,props:c.props,methods:c.methods};return c.props.searchFn(a)||c.searchFn(a)}),_defineProperty(_assertThisInitialized(c),"activeCursorItem",function(a){return c.setState({activeCursorItem:a})}),_defineProperty(_assertThisInitialized(c),"handleKeyDown",function(a){var b=c.state.cursor;if("ArrowDown"===a.key&&null===b)return c.setState({cursor:0});if(("ArrowUp"===a.key||"ArrowDown"===a.key)&&a.preventDefault(),"Escape"===a.key&&c.dropDown("close"),"Enter"===a.key){var d=c.searchResults()[b];if(d&&!d.disabled){if(c.props.create&&(0,_util.valueExistInSelected)(c.state.search,c.state.values,c.props))return null;c.addItem(d)}}return("ArrowUp"===a.key&&0(0,_util.getProp)(a,d)?1:0}),e):e}),_defineProperty(_assertThisInitialized(c),"searchFn",function(a){var b=a.state,d=a.methods,e=new RegExp(d.safeString(b.search),"i");return d.sortBy().filter(function(a){return e.test((0,_util.getByPath)(a,c.props.searchBy)||(0,_util.getByPath)(a,c.props.valueField))})}),_defineProperty(_assertThisInitialized(c),"searchResults",function(){var a={state:c.state,props:c.props,methods:c.methods};return c.props.searchFn(a)||c.searchFn(a)}),_defineProperty(_assertThisInitialized(c),"activeCursorItem",function(a){return c.setState({activeCursorItem:a})}),_defineProperty(_assertThisInitialized(c),"handleKeyDown",function(a){var b={event:a,state:c.state,props:c.props,methods:c.methods,setState:c.setState.bind(_assertThisInitialized(c))};return c.props.handleKeyDownFn(b)||c.handleKeyDownFn(b)}),_defineProperty(_assertThisInitialized(c),"handleKeyDownFn",function(a){var b=a.event,d=a.state,e=a.props,f=a.methods,g=a.setState,h=d.cursor;if("ArrowDown"===b.key&&null===h)return g({cursor:0});if(("ArrowUp"===b.key||"ArrowDown"===b.key)&&b.preventDefault(),"Escape"===b.key&&c.dropDown("close"),"Enter"===b.key){var i=f.searchResults()[h];if(i&&!i.disabled){if(e.create&&(0,_util.valueExistInSelected)(d.search,d.values,e))return null;f.addItem(i)}}return("ArrowUp"===b.key&&0 { if (this.props.multi) { - if (valueExistInSelected(getByPath(item, this.props.valueField), this.state.values, this.props)) { + if ( + valueExistInSelected(getByPath(item, this.props.valueField), this.state.values, this.props) + ) { return this.removeItem(null, item, false); } @@ -344,10 +346,16 @@ export class Select extends Component { }); handleKeyDown = (event) => { - const { cursor } = this.state; + const args = { event, state: this.state, props: this.props, methods: this.methods, setState: this.setState.bind(this) }; + + return this.props.handleKeyDownFn(args) || this.handleKeyDownFn(args); + }; + + handleKeyDownFn = ({ event, state, props, methods, setState }) => { + const { cursor } = state; if (event.key === 'ArrowDown' && cursor === null) { - return this.setState({ + return setState({ cursor: 0 }); } @@ -361,36 +369,36 @@ export class Select extends Component { } if (event.key === 'Enter') { - const currentItem = this.searchResults()[cursor]; + const currentItem = methods.searchResults()[cursor]; if (currentItem && !currentItem.disabled) { - if (this.props.create && valueExistInSelected(this.state.search, this.state.values, this.props)) { + if (props.create && valueExistInSelected(state.search, state.values, props)) { return null; } - this.addItem(currentItem); + methods.addItem(currentItem); } } if (event.key === 'ArrowUp' && cursor > 0) { - this.setState((prevState) => ({ + setState((prevState) => ({ cursor: prevState.cursor - 1 })); } if (event.key === 'ArrowUp' && cursor === 0) { - this.setState({ - cursor: this.searchResults().length + setState({ + cursor: methods.searchResults().length }); } if (event.key === 'ArrowDown') { - this.setState((prevState) => ({ + setState((prevState) => ({ cursor: prevState.cursor + 1 })); } - if (event.key === 'ArrowDown' && this.searchResults().length === cursor) { - return this.setState({ + if (event.key === 'ArrowDown' && methods.searchResults().length === cursor) { + return setState({ cursor: 0 }); } @@ -502,7 +510,8 @@ Select.defaultProps = { onClearAll: () => undefined, onSelectAll: () => undefined, onCreateNew: () => undefined, - searchFn: () => undefined + searchFn: () => undefined, + handleKeyDownFn: () => undefined, }; const ReactDropdownSelect = styled.div` diff --git a/types.d.ts b/types.d.ts index eccf24f1..086b995a 100644 --- a/types.d.ts +++ b/types.d.ts @@ -35,6 +35,14 @@ export interface IRenderer { methods?: IMethods; } +export interface IKeyDown { + event: Event; + props?: ISelectProps; + state?: IState; + methods?: IMethods; + setState?: () => void; +} + export interface IItemRenderer { item?: number; itemIndex?: number; @@ -84,6 +92,7 @@ export interface ISelectProps { onSelectAll?: () => void; onCreateNew?: () => void; searchFn?: () => void; + handleKeyDownFn?: ({ event, props, state, methods, setState }: IKeyDown) => void; clearRenderer?: ({ props, state, methods }: IRenderer) => void; contentRenderer?: ({ props, state, methods }: IRenderer) => void; dropdownRenderer?: ({ props, state, methods }: IRenderer) => void;