Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@leafygreen-ui/select

Package Overview
Dependencies
Maintainers
3
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@leafygreen-ui/select - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

10

CHANGELOG.md
# @leafygreen-ui/select
## 1.1.2
### Patch Changes
- bf8b83e1: Sets aria `role="presentation"` on Caret in the component's menu button
- Updated dependencies [bf8b83e1]
- Updated dependencies [dca5605b]
- @leafygreen-ui/icon@8.0.1
- @leafygreen-ui/popover@7.1.2
## 1.1.1

@@ -4,0 +14,0 @@

2

dist/esm/index.js

@@ -1,2 +0,2 @@

import{transparentize as e}from"polished";import{uiColors as n}from"@leafygreen-ui/palette";import t,{createContext as r,useContext as o,useRef as i,useCallback as a,useEffect as l,useMemo as u,useState as c}from"react";import s from"prop-types";import{css as d,cx as f}from"@leafygreen-ui/emotion";import{usePrevious as p,useViewportSize as h}from"@leafygreen-ui/hooks";import{IdAllocator as b,isComponentType as v,keyMap as m}from"@leafygreen-ui/lib";import{fontFamilies as g,breakpoints as y}from"@leafygreen-ui/tokens";import x,{Align as w,Justify as O}from"@leafygreen-ui/popover";import k from"@leafygreen-ui/icon/dist/Checkmark";import{isFragment as E}from"react-is";import N,{Variant as D}from"@leafygreen-ui/button";import S from"@leafygreen-ui/icon/dist/CaretDown";function C(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function j(){return(j=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function F(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function P(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}function z(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,o=!1,i=void 0;try{for(var a,l=e[Symbol.iterator]();!(r=(a=l.next()).done)&&(t.push(a.value),!n||t.length!==n);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==l.return||l.return()}finally{if(o)throw i}}return t}(e,n)||H(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e){return function(e){if(Array.isArray(e))return T(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||H(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function H(e,n){if(e){if("string"==typeof e)return T(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?T(e,n):void 0}}function T(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var I,G,K="dark",V="light",L=(C(I={},V,{label:{base:n.gray.dark3,disabled:n.gray.dark1},description:n.gray.dark1,border:{base:n.gray.light1,open:n.gray.dark1},text:{base:n.gray.dark3,deselected:n.gray.dark1,disabled:n.gray.base},menu:{shadow:e(.78,n.black)},option:{group:{label:n.gray.dark3,border:n.gray.light2},background:{base:n.white,hovered:n.gray.light2,focused:n.blue.light3},text:{base:n.gray.dark3,selected:n.blue.base,disabled:n.gray.base},icon:{base:n.gray.dark1,selected:n.blue.base,disabled:n.gray.base}}}),C(I,K,{label:{base:n.white,disabled:n.gray.light1},description:n.gray.light1,border:{base:n.gray.dark2,open:n.gray.dark2},text:{base:n.white,deselected:n.gray.light1,disabled:n.gray.dark1},menu:{shadow:e(.2,n.black)},option:{group:{label:n.white,border:n.gray.dark1},background:{base:n.gray.dark2,hovered:n.gray.dark1,focused:n.blue.base},text:{base:n.white,selected:"#9DD0E7",disabled:n.gray.base},icon:{base:n.gray.light1,selected:"#9DD0E7",disabled:n.gray.base}}}),I),M={XSmall:"xsmall",Small:"small",Default:"default",Large:"large"},B=(C(G={},M.XSmall,{height:22,width:194,text:12,label:{text:14,lineHeight:16},description:{text:14,lineHeight:16},option:{text:14}}),C(G,M.Small,{height:28,width:194,text:14,label:{text:14,lineHeight:16},description:{text:14,lineHeight:16},option:{text:14}}),C(G,M.Default,{height:36,width:194,text:14,label:{text:14,lineHeight:16},description:{text:14,lineHeight:20},option:{text:14}}),C(G,M.Large,{height:48,width:230,text:18,label:{text:18,lineHeight:21},description:{text:18,lineHeight:24},option:{text:16}}),G),R=36,q=194,U=16,X={text:16,lineHeight:19},W={text:16,lineHeight:22},Y={text:16},$=r({mode:V,size:M.Default,open:!1,disabled:!1});function J(){var e=P(["\n cursor: not-allowed;\n color: ",";\n "]);return J=function(){return e},e}function Q(){var e=P(["\n cursor: pointer;\n color: ",";\n "]);return Q=function(){return e},e}function Z(){var e=P(["\n display: flex;\n "]);return Z=function(){return e},e}function _(){var e=P(["\n display: flex;\n justify-content: space-between;\n width: 100%;\n "]);return _=function(){return e},e}function ee(){var e=P(["\n color: ",";\n "]);return ee=function(){return e},e}function ne(){var e=P(["\n color: ",";\n "]);return ne=function(){return e},e}function te(){var e=P(["\n color: ",";\n "]);return te=function(){return e},e}function re(){var e=P(["\n color: ",";\n "]);return re=function(){return e},e}function oe(){var e=P(["\n height: 100%;\n "]);return oe=function(){return e},e}function ie(){var e=P(["\n font-weight: bold;\n "]);return ie=function(){return e},e}function ae(){var e=P(["\n min-width: 16px;\n margin-right: 6px;\n"]);return ae=function(){return e},e}function le(){var e=P(["\n display: flex;\n align-items: center;\n"]);return le=function(){return e},e}function ue(){var e=P(["\n display: flex;\n width: 100%;\n padding: 10px 12px;\n outline: none;\n overflow-wrap: anywhere;\n transition: background-color 150ms ease-in-out;\n"]);return ue=function(){return e},e}var ce=d(ue()),se=d(le()),de=d(ae());function fe(e){var n,r=e.children,u=e.className,c=e.glyph,s=e.selected,h=e.focused,b=e.disabled,v=e.onClick,m=e.onFocus,g=e.isDeselection,y=e.triggerScrollIntoView,x=e.hasGlyphs,w=o($).mode,O=L[w].option,E=i(null),N=a((function(){var e=E.current,n=e.offsetParent;n.scrollTop=e.offsetTop+(e.clientHeight-n.clientHeight)/2}),[E]),D=p(y),S=y&&!D;l((function(){S&&N()}),[N,S]);var j=p(h),F=h&&!j;l((function(){F&&E.current.focus()}),[F]);var P=t.createElement("span",{className:f(se,C({},d(ie()),s&&!g))},r),z=t.createElement("span",{className:f(de,d(oe()))}),A=z;c&&(c.type.isGlyph?A=t.cloneElement(c,{key:"glyph",className:f(de,d(re(),O.icon.base),C({},d(te(),O.icon.disabled),b),c.props.className)}):console.error("`Option` instance did not render icon because it is not a known glyph element."));var H,T=s&&!g?t.createElement(k,{key:"checkmark",className:f(de,d(ne(),O.icon.selected),C({},d(ee(),O.icon.disabled),b))}):z;return H=x?t.createElement("span",{className:d(_())},t.createElement("span",{className:d(Z())},A,P),T):t.createElement(t.Fragment,null,T,P),t.createElement("li",{role:"option","aria-selected":s,tabIndex:-1,ref:E,className:f(ce,d(Q(),O.text.base),(n={},C(n,d("\n &:focus {\n background-color: ".concat(O.background.focused,";\n }\n\n &:hover {\n background-color: ").concat(O.background.hovered,";\n }\n ")),!b),C(n,d(J(),O.text.disabled),b),n),u),onClick:v,onFocus:m,onKeyDown:void 0},H)}function pe(e){throw Error("`Option` must be a child of a `Select` instance")}fe.displayName="Option",pe.displayName="Option";var he=s.oneOfType([s.string,s.number]);function be(){var e=P(["\n color: ",";\n "]);return be=function(){return e},e}function ve(){var e=P(["\n border-bottom: 1px solid ",";\n "]);return ve=function(){return e},e}function me(){var e=P(["\n cursor: default;\n width: 100%;\n padding: 0 12px 2px;\n outline: none;\n overflow-wrap: anywhere;\n font-size: 13px;\n line-height: 16px;\n font-weight: bold;\n"]);return me=function(){return e},e}function ge(){var e=P(["\n padding-top: 8px;\n"]);return ge=function(){return e},e}pe.propTypes={children:s.oneOfType([he,s.arrayOf(s.oneOfType([he,s.oneOf([!1,null,void 0,""])]))]).isRequired,className:s.string,glyph:s.element,value:s.string,disabled:s.bool};var ye=d(ge()),xe=d(me()),we=b.create("select-option-group");function Oe(e){var n=e.className,r=e.label,i=e.children,a=o($).mode,l=L[a].option,c=u((function(){return we.generate()}),[]);return t.createElement("div",{className:f(ye,d(ve(),l.group.border),n)},t.createElement("div",{id:c,className:f(xe,d(be(),l.group.label))},r),t.createElement("div",{role:"group","aria-labelledby":c},i))}function ke(e){throw Error("`OptionGroup` must be a child of a `Select` instance")}function Ee(e){return null==e||!1===e||""===e}function Ne(e,n){t.Children.forEach(e,(function(e){v(e,"Option")?n(e):v(e,"OptionGroup")?Ne(e.props.children,(function(t){return n(t,e)})):E(e)&&Ne(e.props.children,n)}))}function De(e,n,r){return t.Children.map(e,(function(e){if(v(e,"Option"))return t.createElement(fe,n(e));if(v(e,"OptionGroup")){var o=e.props,i=o.children,a=F(o,["children"]);return t.createElement(Oe,j({className:void 0},a),De(i,(function(t){return n(t,e)}),r))}return E(e)?De(e.props.children,n,r):(Ee(e)||null==r||r(e),null)}))}function Se(e){return null===e?"":void 0!==e.props.value?e.props.value:Array.isArray(e.props.children)?e.props.children.filter((function(e){return!Ee(e)})).join(""):e.props.children.toString()}function Ce(e,n){var t,r,o;return null!==(t=e.props.disabled)&&void 0!==t&&t||null!==(r=null==n||null===(o=n.props)||void 0===o?void 0:o.disabled)&&void 0!==r&&r}function je(e,n,t){return Se(e)===t&&!Ce(e,n)}function Fe(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=n.initialValue,r=n.deps,o=void 0===r?[]:r,a=i(t);return u((function(){return{get current(){return a.current},set current(n){a.current=n,e(n)}}}),[e,a].concat(A(o)))}function Pe(e,n){var t=a((function(e,n){Array.isArray(e)?e.forEach(t):"function"==typeof e?e(n):e&&(e.current=n)}),[]);return Fe(a((function(n){return t(e,n)}),[e,t]),{initialValue:n})}Oe.displayName="OptionGroup",ke.displayName="OptionGroup",ke.propTypes={children:s.oneOfType([s.element,s.arrayOf(s.oneOfType([s.oneOf([!1,null,void 0,""]),s.element]))]).isRequired,className:s.string,label:s.string.isRequired,disabled:s.bool};var ze=function(e){var n=z(c(e),2),t=n[0];return Fe(n[1],{initialValue:e,deps:[t]})};function Ae(){var e=P(["\n font-family: ",";\n font-size: ","px;\n max-height: ","px;\n background-color: ",";\n box-shadow: 0 3px 7px 0 ",";\n\n @media only screen and (max-width: ","px) {\n font-size: ","px;\n }\n "]);return Ae=function(){return e},e}function He(){var e=P(["\n position: relative;\n text-align: left;\n width: 100%;\n border-radius: 3px;\n line-height: 16px;\n list-style: none;\n margin: 0;\n padding: 0;\n overflow: auto;\n"]);return He=function(){return e},e}var Te=d(He()),Ie=t.forwardRef((function(e,n){var r=e.children,i=e.id,l=e.referenceElement,u=e.onClose,c=e.onFocusPreviousOption,s=e.onFocusNextOption,p=e.onSelectFocusedOption,b=e.className,v=e.usePortal,k=o($),E=k.mode,N=k.size,D=k.disabled,S=k.open,C=L[E],j=B[N],F=Pe(n,null),P=a((function(e){if(!(e.ctrlKey||e.shiftKey||e.altKey)){var n=!1;switch(e.keyCode){case m.Tab:case m.Enter:p(e);break;case m.Escape:u();break;case m.ArrowUp:c();break;case m.ArrowDown:s();break;default:n=!0}n||(e.preventDefault(),e.stopPropagation())}}),[u,s,c,p]),z=h(),A=null===z||null===F.current?0:z.height-F.current.getBoundingClientRect().top-10,H=a((function(e){F.current&&F.current.focus(),e.stopPropagation()}),[F]);return t.createElement(x,{active:S&&!D,spacing:4,align:w.Bottom,justify:O.Middle,adjustOnMutation:!0,className:b,refEl:l,usePortal:v},t.createElement("ul",{role:"listbox",ref:F,tabIndex:-1,onKeyDown:P,onClick:H,className:f(Te,d(Ae(),g.default,j.option.text,A,C.option.background.base,C.menu.shadow,y.Desktop,Y.text)),id:i},r))}));function Ge(){var e=P(["\n color: ",";\n "]);return Ge=function(){return e},e}function Ke(){var e=P(["\n // Displays the active state defined by <Button />\n &:after {\n opacity: 1;\n }\n "]);return Ke=function(){return e},e}function Ve(){var e=P(["\n height: ","px;\n width: ","px;\n font-size: ","px;\n color: ",";\n border-color: ",";\n\n @media only screen and (max-width: ","px) {\n height: ","px;\n width: ","px;\n font-size: ","px;\n }\n "]);return Ve=function(){return e},e}function Le(){var e=P(["\n min-width: 16px;\n"]);return Le=function(){return e},e}function Me(){var e=P(["\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n"]);return Me=function(){return e},e}function Be(){var e=P(["\n position: relative;\n display: flex;\n align-items: center;\n justify-content: space-between;\n height: 100%;\n width: 100%;\n"]);return Be=function(){return e},e}function Re(){var e=P(["\n margin-top: 2px;\n\n // reset default Button padding\n > span {\n padding: 0;\n }\n"]);return Re=function(){return e},e}Ie.displayName="ListMenu";var qe=d(Re()),Ue=d(Be()),Xe=d(Me()),We=d(Le()),Ye=t.forwardRef((function(e,n){var r,i=e.children,l=e.value,c=e.text,s=e.name,p=e.deselected,h=(e.readOnly,e.onDeselect),b=e.onFocusFirstOption,v=e.onFocusLastOption,g=e.onClose,x=e.onOpen,w=F(e,["children","value","text","name","deselected","readOnly","onDeselect","onFocusFirstOption","onFocusLastOption","onClose","onOpen"]),O=o($),k=O.mode,E=O.size,P=O.open,z=O.disabled,A=Pe(n,null),H=L[k],T=B[E],I=a((function(e){if(!z&&!(e.ctrlKey||e.shiftKey||e.altKey)){var n=!1;switch(e.keyCode){case m.Tab:g(),n=!0;break;case m.Escape:P?g():h(e);break;case m.ArrowUp:x(),v();break;case m.ArrowDown:x(),b();break;default:n=!0}n||(e.preventDefault(),e.stopPropagation())}}),[z,g,h,b,v,x,P]),G=a((function(){P?g():x(),A.current.focus()}),[g,x,P,A]),V=u((function(){if(P&&!z)return{focused:!0,active:!0}}),[P,z]);return t.createElement(N,j({role:"combobox"},w,{ref:A,name:s,value:l,disabled:z,onClick:G,onKeyDown:I,variant:k===K?D.Dark:D.Default,darkMode:k===K,forceState:V,className:f(qe,d(Ve(),T.height,T.width,T.text,p?H.text.deselected:H.text.base,P&&!z?H.border.open:H.border.base,y.Desktop,R,q,U),(r={},C(r,d(Ke()),P&&!z),C(r,d(Ge(),H.text.disabled),z),r))}),t.createElement("div",{className:Ue},t.createElement("span",{className:Xe},c),t.createElement(S,{"aria-hidden":!0,className:We})),i)}));function $e(){var e=P(["\n width: ","px;\n "]);return $e=function(){return e},e}function Je(){var e=P(["\n color: ",";\n font-size: ","px;\n line-height: ","px;\n\n @media only screen and (max-width: ","px) {\n font-size: ","px;\n line-height: ","px;\n }\n "]);return Je=function(){return e},e}function Qe(){var e=P(["\n cursor: not-allowed;\n "]);return Qe=function(){return e},e}function Ze(){var e=P(["\n color: ",";\n font-size: ","px;\n line-height: ","px;\n\n @media only screen and (max-width: ","px) {\n font-size: ","px;\n line-height: ","px;\n }\n "]);return Ze=function(){return e},e}function _e(){var e=P(["\n cursor: not-allowed;\n "]);return _e=function(){return e},e}function en(){var e=P(["\n margin-bottom: 2px;\n font-weight: bold;\n"]);return en=function(){return e},e}function nn(){var e=P(["\n font-family: ",";\n display: block;\n"]);return nn=function(){return e},e}Ye.displayName="MenuButton";var tn=d(nn(),g.default),rn=d(en()),on=b.create("select");function an(e){var n,r,o=e.children,i=e.darkMode,s=void 0!==i&&i,p=e.size,b=void 0===p?M.Default:p,v=e.disabled,m=void 0!==v&&v,g=e.usePortal,x=void 0===g||g,w=e.placeholder,O=void 0===w?"Select":w,k=e.className,E=e.id,N=e.label,D=e.description,S=e.name,j=e.defaultValue,F=e.value,P=e.onChange,A=e.readOnly,H=e["aria-labelledby"],T=u((function(){return null!=E?E:on.generate()}),[E]),I=null!==(n="aria-labelledby")?n:"".concat(T,"-label"),G="".concat(T,"-description"),R="".concat(T,"-menu"),q=z(c(!1),2),U=q[0],Y=q[1],J=ze(null),Q=ze(null),Z=s?K:V,_=L[Z],ee=B[b],ne=u((function(){return{mode:Z,size:b,open:U,disabled:m}}),[Z,b,U,m]);l((function(){void 0!==F&&void 0===P&&!0!==A&&console.warn("You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.")}),[P,A,F]),N||H||console.error("For screen-reader accessibility, label or aria-labelledby must be provided to IconButton.");var te=a((function(){Y(!0)}),[]),re=a((function(){Y(!1),J.current.focus()}),[J]);l((function(){if(U){var e=function(e){var n=J.current.contains(e.target)||Q.current.contains(e.target);Y(n)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}}),[Q,J,U]);var oe=u((function(){var e=null;return void 0===F&&void 0!==j&&Ne(o,(function(n,t){je(n,t,j)&&(e=n)})),e}),[o,j,F]),ie=z(c(oe),2),ae=ie[0],le=ie[1];l((function(){var e;null!==ae&&le(null!==(e=function(e,n){var t,r,o,i,a,l,u,c;return Ne(e,(function(e){if(e===n)a=n;else if(e.props.children===n.props.children&&e.props.value===n.props.value){var t;null!==(t=l)&&void 0!==t||(l=e)}else if(void 0!==e.props.value&&e.props.value===n.props.value){var r;null!==(r=u)&&void 0!==r||(u=e)}else if(Se(e)===Se(n)){var o;null!==(o=c)&&void 0!==o||(c=e)}})),null!==(t=null!==(r=null!==(o=null!==(i=a)&&void 0!==i?i:l)&&void 0!==o?o:u)&&void 0!==r?r:c)&&void 0!==t?t:null}(o,ae))&&void 0!==e?e:oe)}),[o,oe,ae]);var ue=u((function(){if(void 0!==F){var e=null;return Ne(o,(function(n,t){je(n,t,F)&&(e=n)})),e}return ae}),[o,ae,F]),ce=a((function(e,n){void 0===F&&le(e),null==P||P(Se(e),n),be(void 0),re()}),[P,re,F]),se=a((function(e,n){return function(t){t.preventDefault(),t.stopPropagation(),m||n||(ce(e,t),re())}}),[m,re,ce]),de=a((function(e){ce(null,e)}),[ce]),pe=z(c(),2),he=pe[0],be=pe[1],ve=u((function(){var e=[null];return Ne(o,(function(n,t){Ce(n,t)||e.push(n)})),e}),[o]),me=a((function(e){void 0!==he&&ce(he,e)}),[he,ce]),ge=a((function(){be(null)}),[]),ye=a((function(){be(ve[ve.length-1])}),[ve]),xe=a((function(){if(void 0===he||0===ve.indexOf(he))ye();else{var e=ve.indexOf(he)-1;be(ve[e])}}),[ve,he,ye]),we=a((function(){if(void 0===he||ve.indexOf(he)===ve.length-1)ge();else{var e=ve.indexOf(he)+1;be(ve[e])}}),[ve,he,ge]),Oe=a((function(e,n){return function(t){t.preventDefault(),t.stopPropagation(),m||n||be(e)}}),[m]),ke=h(),Ee=u((function(){var e=!1;return Ne(o,(function(n){e||(e=void 0!==n.props.glyph)})),e}),[o]),Fe=u((function(){return null!==ke&&null!==Q.current&&void 0===he&&U}),[he,Q,U,ke]),Pe=u((function(){var e=null===ue;return t.createElement(fe,{className:void 0,glyph:void 0,selected:e,focused:null===he,disabled:!1,onClick:se(null,!1),onFocus:Oe(null,!1),isDeselection:!0,hasGlyphs:!0,triggerScrollIntoView:e&&Fe},O)}),[Fe,he,se,Oe,O,ue]),Ae=u((function(){return De(o,(function(e,n){var t=e===ue,r=Ce(e,n);return{className:e.props.className,glyph:e.props.glyph,selected:t,focused:e===he,disabled:r,children:e.props.children,isDeselection:!1,hasGlyphs:Ee,onClick:se(e,r),onFocus:Oe(e,r),triggerScrollIntoView:t&&Fe}}),(function(){console.error("`Select` instance received child that is not `Option` or `OptionGroup`.")}))}),[Fe,o,he,se,Oe,Ee,ue]);return t.createElement("div",{className:f(C({},d(_e()),m),k)},N&&t.createElement("label",{id:I,className:f(tn,rn,d(Ze(),m?_.label.disabled:_.label.base,ee.label.text,ee.label.lineHeight,y.Desktop,X.text,X.lineHeight),C({},d(Qe()),m))},N),D&&t.createElement("div",{id:G,className:f(tn,d(Je(),_.description,ee.description.text,ee.description.lineHeight,y.Desktop,W.text,W.lineHeight))},D),t.createElement($.Provider,{value:ne},t.createElement(Ye,{ref:J,name:S,readOnly:A,value:Se(ue),text:null!==ue?ue.props.children:O,deselected:null===ue,onDeselect:de,onOpen:te,onClose:re,onFocusFirstOption:ge,onFocusLastOption:ye,"aria-labelledby":I,"aria-controls":R,"aria-expanded":U,"aria-describedby":G},t.createElement(Ie,{id:R,referenceElement:J,ref:Q,onClose:re,onSelectFocusedOption:me,onFocusPreviousOption:xe,onFocusNextOption:we,usePortal:x,className:d($e(),null===(r=J.current)||void 0===r?void 0:r.clientWidth)},Pe,Ae))))}an.displayName="Select",an.propTypes={label:s.string,"aria-labelledby":s.string,description:s.string,placeholder:s.string,className:s.string,darkMode:s.bool,size:s.oneOf(Object.values(M)),disabled:s.bool,id:s.string,value:s.string,defaultValue:s.string,onChange:s.func,readOnly:s.bool};export{pe as Option,ke as OptionGroup,an as Select,M as Size};
import{transparentize as e}from"polished";import{uiColors as n}from"@leafygreen-ui/palette";import t,{createContext as r,useContext as o,useRef as i,useCallback as a,useEffect as l,useMemo as u,useState as c}from"react";import s from"prop-types";import{css as d,cx as f}from"@leafygreen-ui/emotion";import{usePrevious as p,useViewportSize as h}from"@leafygreen-ui/hooks";import{IdAllocator as b,isComponentType as v,keyMap as m}from"@leafygreen-ui/lib";import{fontFamilies as g,breakpoints as y}from"@leafygreen-ui/tokens";import x,{Align as w,Justify as O}from"@leafygreen-ui/popover";import k from"@leafygreen-ui/icon/dist/Checkmark";import{isFragment as E}from"react-is";import N,{Variant as D}from"@leafygreen-ui/button";import S from"@leafygreen-ui/icon/dist/CaretDown";function C(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function j(){return(j=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function F(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function P(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}function z(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,o=!1,i=void 0;try{for(var a,l=e[Symbol.iterator]();!(r=(a=l.next()).done)&&(t.push(a.value),!n||t.length!==n);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==l.return||l.return()}finally{if(o)throw i}}return t}(e,n)||H(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e){return function(e){if(Array.isArray(e))return T(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||H(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function H(e,n){if(e){if("string"==typeof e)return T(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?T(e,n):void 0}}function T(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var I,G,K="dark",V="light",L=(C(I={},V,{label:{base:n.gray.dark3,disabled:n.gray.dark1},description:n.gray.dark1,border:{base:n.gray.light1,open:n.gray.dark1},text:{base:n.gray.dark3,deselected:n.gray.dark1,disabled:n.gray.base},menu:{shadow:e(.78,n.black)},option:{group:{label:n.gray.dark3,border:n.gray.light2},background:{base:n.white,hovered:n.gray.light2,focused:n.blue.light3},text:{base:n.gray.dark3,selected:n.blue.base,disabled:n.gray.base},icon:{base:n.gray.dark1,selected:n.blue.base,disabled:n.gray.base}}}),C(I,K,{label:{base:n.white,disabled:n.gray.light1},description:n.gray.light1,border:{base:n.gray.dark2,open:n.gray.dark2},text:{base:n.white,deselected:n.gray.light1,disabled:n.gray.dark1},menu:{shadow:e(.2,n.black)},option:{group:{label:n.white,border:n.gray.dark1},background:{base:n.gray.dark2,hovered:n.gray.dark1,focused:n.blue.base},text:{base:n.white,selected:"#9DD0E7",disabled:n.gray.base},icon:{base:n.gray.light1,selected:"#9DD0E7",disabled:n.gray.base}}}),I),M={XSmall:"xsmall",Small:"small",Default:"default",Large:"large"},B=(C(G={},M.XSmall,{height:22,width:194,text:12,label:{text:14,lineHeight:16},description:{text:14,lineHeight:16},option:{text:14}}),C(G,M.Small,{height:28,width:194,text:14,label:{text:14,lineHeight:16},description:{text:14,lineHeight:16},option:{text:14}}),C(G,M.Default,{height:36,width:194,text:14,label:{text:14,lineHeight:16},description:{text:14,lineHeight:20},option:{text:14}}),C(G,M.Large,{height:48,width:230,text:18,label:{text:18,lineHeight:21},description:{text:18,lineHeight:24},option:{text:16}}),G),R=36,q=194,U=16,X={text:16,lineHeight:19},W={text:16,lineHeight:22},Y={text:16},$=r({mode:V,size:M.Default,open:!1,disabled:!1});function J(){var e=P(["\n cursor: not-allowed;\n color: ",";\n "]);return J=function(){return e},e}function Q(){var e=P(["\n cursor: pointer;\n color: ",";\n "]);return Q=function(){return e},e}function Z(){var e=P(["\n display: flex;\n "]);return Z=function(){return e},e}function _(){var e=P(["\n display: flex;\n justify-content: space-between;\n width: 100%;\n "]);return _=function(){return e},e}function ee(){var e=P(["\n color: ",";\n "]);return ee=function(){return e},e}function ne(){var e=P(["\n color: ",";\n "]);return ne=function(){return e},e}function te(){var e=P(["\n color: ",";\n "]);return te=function(){return e},e}function re(){var e=P(["\n color: ",";\n "]);return re=function(){return e},e}function oe(){var e=P(["\n height: 100%;\n "]);return oe=function(){return e},e}function ie(){var e=P(["\n font-weight: bold;\n "]);return ie=function(){return e},e}function ae(){var e=P(["\n min-width: 16px;\n margin-right: 6px;\n"]);return ae=function(){return e},e}function le(){var e=P(["\n display: flex;\n align-items: center;\n"]);return le=function(){return e},e}function ue(){var e=P(["\n display: flex;\n width: 100%;\n padding: 10px 12px;\n outline: none;\n overflow-wrap: anywhere;\n transition: background-color 150ms ease-in-out;\n"]);return ue=function(){return e},e}var ce=d(ue()),se=d(le()),de=d(ae());function fe(e){var n,r=e.children,u=e.className,c=e.glyph,s=e.selected,h=e.focused,b=e.disabled,v=e.onClick,m=e.onFocus,g=e.isDeselection,y=e.triggerScrollIntoView,x=e.hasGlyphs,w=o($).mode,O=L[w].option,E=i(null),N=a((function(){var e=E.current,n=e.offsetParent;n.scrollTop=e.offsetTop+(e.clientHeight-n.clientHeight)/2}),[E]),D=p(y),S=y&&!D;l((function(){S&&N()}),[N,S]);var j=p(h),F=h&&!j;l((function(){F&&E.current.focus()}),[F]);var P=t.createElement("span",{className:f(se,C({},d(ie()),s&&!g))},r),z=t.createElement("span",{className:f(de,d(oe()))}),A=z;c&&(c.type.isGlyph?A=t.cloneElement(c,{key:"glyph",className:f(de,d(re(),O.icon.base),C({},d(te(),O.icon.disabled),b),c.props.className)}):console.error("`Option` instance did not render icon because it is not a known glyph element."));var H,T=s&&!g?t.createElement(k,{key:"checkmark",className:f(de,d(ne(),O.icon.selected),C({},d(ee(),O.icon.disabled),b))}):z;return H=x?t.createElement("span",{className:d(_())},t.createElement("span",{className:d(Z())},A,P),T):t.createElement(t.Fragment,null,T,P),t.createElement("li",{role:"option","aria-selected":s,tabIndex:-1,ref:E,className:f(ce,d(Q(),O.text.base),(n={},C(n,d("\n &:focus {\n background-color: ".concat(O.background.focused,";\n }\n\n &:hover {\n background-color: ").concat(O.background.hovered,";\n }\n ")),!b),C(n,d(J(),O.text.disabled),b),n),u),onClick:v,onFocus:m,onKeyDown:void 0},H)}function pe(e){throw Error("`Option` must be a child of a `Select` instance")}fe.displayName="Option",pe.displayName="Option";var he=s.oneOfType([s.string,s.number]);function be(){var e=P(["\n color: ",";\n "]);return be=function(){return e},e}function ve(){var e=P(["\n border-bottom: 1px solid ",";\n "]);return ve=function(){return e},e}function me(){var e=P(["\n cursor: default;\n width: 100%;\n padding: 0 12px 2px;\n outline: none;\n overflow-wrap: anywhere;\n font-size: 13px;\n line-height: 16px;\n font-weight: bold;\n"]);return me=function(){return e},e}function ge(){var e=P(["\n padding-top: 8px;\n"]);return ge=function(){return e},e}pe.propTypes={children:s.oneOfType([he,s.arrayOf(s.oneOfType([he,s.oneOf([!1,null,void 0,""])]))]).isRequired,className:s.string,glyph:s.element,value:s.string,disabled:s.bool};var ye=d(ge()),xe=d(me()),we=b.create("select-option-group");function Oe(e){var n=e.className,r=e.label,i=e.children,a=o($).mode,l=L[a].option,c=u((function(){return we.generate()}),[]);return t.createElement("div",{className:f(ye,d(ve(),l.group.border),n)},t.createElement("div",{id:c,className:f(xe,d(be(),l.group.label))},r),t.createElement("div",{role:"group","aria-labelledby":c},i))}function ke(e){throw Error("`OptionGroup` must be a child of a `Select` instance")}function Ee(e){return null==e||!1===e||""===e}function Ne(e,n){t.Children.forEach(e,(function(e){v(e,"Option")?n(e):v(e,"OptionGroup")?Ne(e.props.children,(function(t){return n(t,e)})):E(e)&&Ne(e.props.children,n)}))}function De(e,n,r){return t.Children.map(e,(function(e){if(v(e,"Option"))return t.createElement(fe,n(e));if(v(e,"OptionGroup")){var o=e.props,i=o.children,a=F(o,["children"]);return t.createElement(Oe,j({className:void 0},a),De(i,(function(t){return n(t,e)}),r))}return E(e)?De(e.props.children,n,r):(Ee(e)||null==r||r(e),null)}))}function Se(e){return null===e?"":void 0!==e.props.value?e.props.value:Array.isArray(e.props.children)?e.props.children.filter((function(e){return!Ee(e)})).join(""):e.props.children.toString()}function Ce(e,n){var t,r,o;return null!==(t=e.props.disabled)&&void 0!==t&&t||null!==(r=null==n||null===(o=n.props)||void 0===o?void 0:o.disabled)&&void 0!==r&&r}function je(e,n,t){return Se(e)===t&&!Ce(e,n)}function Fe(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=n.initialValue,r=n.deps,o=void 0===r?[]:r,a=i(t);return u((function(){return{get current(){return a.current},set current(n){a.current=n,e(n)}}}),[e,a].concat(A(o)))}function Pe(e,n){var t=a((function(e,n){Array.isArray(e)?e.forEach(t):"function"==typeof e?e(n):e&&(e.current=n)}),[]);return Fe(a((function(n){return t(e,n)}),[e,t]),{initialValue:n})}Oe.displayName="OptionGroup",ke.displayName="OptionGroup",ke.propTypes={children:s.oneOfType([s.element,s.arrayOf(s.oneOfType([s.oneOf([!1,null,void 0,""]),s.element]))]).isRequired,className:s.string,label:s.string.isRequired,disabled:s.bool};var ze=function(e){var n=z(c(e),2),t=n[0];return Fe(n[1],{initialValue:e,deps:[t]})};function Ae(){var e=P(["\n font-family: ",";\n font-size: ","px;\n max-height: ","px;\n background-color: ",";\n box-shadow: 0 3px 7px 0 ",";\n\n @media only screen and (max-width: ","px) {\n font-size: ","px;\n }\n "]);return Ae=function(){return e},e}function He(){var e=P(["\n position: relative;\n text-align: left;\n width: 100%;\n border-radius: 3px;\n line-height: 16px;\n list-style: none;\n margin: 0;\n padding: 0;\n overflow: auto;\n"]);return He=function(){return e},e}var Te=d(He()),Ie=t.forwardRef((function(e,n){var r=e.children,i=e.id,l=e.referenceElement,u=e.onClose,c=e.onFocusPreviousOption,s=e.onFocusNextOption,p=e.onSelectFocusedOption,b=e.className,v=e.usePortal,k=o($),E=k.mode,N=k.size,D=k.disabled,S=k.open,C=L[E],j=B[N],F=Pe(n,null),P=a((function(e){if(!(e.ctrlKey||e.shiftKey||e.altKey)){var n=!1;switch(e.keyCode){case m.Tab:case m.Enter:p(e);break;case m.Escape:u();break;case m.ArrowUp:c();break;case m.ArrowDown:s();break;default:n=!0}n||(e.preventDefault(),e.stopPropagation())}}),[u,s,c,p]),z=h(),A=null===z||null===F.current?0:z.height-F.current.getBoundingClientRect().top-10,H=a((function(e){F.current&&F.current.focus(),e.stopPropagation()}),[F]);return t.createElement(x,{active:S&&!D,spacing:4,align:w.Bottom,justify:O.Middle,adjustOnMutation:!0,className:b,refEl:l,usePortal:v},t.createElement("ul",{role:"listbox",ref:F,tabIndex:-1,onKeyDown:P,onClick:H,className:f(Te,d(Ae(),g.default,j.option.text,A,C.option.background.base,C.menu.shadow,y.Desktop,Y.text)),id:i},r))}));function Ge(){var e=P(["\n color: ",";\n "]);return Ge=function(){return e},e}function Ke(){var e=P(["\n // Displays the active state defined by <Button />\n &:after {\n opacity: 1;\n }\n "]);return Ke=function(){return e},e}function Ve(){var e=P(["\n height: ","px;\n width: ","px;\n font-size: ","px;\n color: ",";\n border-color: ",";\n\n @media only screen and (max-width: ","px) {\n height: ","px;\n width: ","px;\n font-size: ","px;\n }\n "]);return Ve=function(){return e},e}function Le(){var e=P(["\n min-width: 16px;\n"]);return Le=function(){return e},e}function Me(){var e=P(["\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n"]);return Me=function(){return e},e}function Be(){var e=P(["\n position: relative;\n display: flex;\n align-items: center;\n justify-content: space-between;\n height: 100%;\n width: 100%;\n"]);return Be=function(){return e},e}function Re(){var e=P(["\n margin-top: 2px;\n\n // reset default Button padding\n > span {\n padding: 0;\n }\n"]);return Re=function(){return e},e}Ie.displayName="ListMenu";var qe=d(Re()),Ue=d(Be()),Xe=d(Me()),We=d(Le()),Ye=t.forwardRef((function(e,n){var r,i=e.children,l=e.value,c=e.text,s=e.name,p=e.deselected,h=(e.readOnly,e.onDeselect),b=e.onFocusFirstOption,v=e.onFocusLastOption,g=e.onClose,x=e.onOpen,w=F(e,["children","value","text","name","deselected","readOnly","onDeselect","onFocusFirstOption","onFocusLastOption","onClose","onOpen"]),O=o($),k=O.mode,E=O.size,P=O.open,z=O.disabled,A=Pe(n,null),H=L[k],T=B[E],I=a((function(e){if(!z&&!(e.ctrlKey||e.shiftKey||e.altKey)){var n=!1;switch(e.keyCode){case m.Tab:g(),n=!0;break;case m.Escape:P?g():h(e);break;case m.ArrowUp:x(),v();break;case m.ArrowDown:x(),b();break;default:n=!0}n||(e.preventDefault(),e.stopPropagation())}}),[z,g,h,b,v,x,P]),G=a((function(){P?g():x(),A.current.focus()}),[g,x,P,A]),V=u((function(){if(P&&!z)return{focused:!0,active:!0}}),[P,z]);return t.createElement(N,j({role:"combobox"},w,{ref:A,name:s,value:l,disabled:z,onClick:G,onKeyDown:I,variant:k===K?D.Dark:D.Default,darkMode:k===K,forceState:V,className:f(qe,d(Ve(),T.height,T.width,T.text,p?H.text.deselected:H.text.base,P&&!z?H.border.open:H.border.base,y.Desktop,R,q,U),(r={},C(r,d(Ke()),P&&!z),C(r,d(Ge(),H.text.disabled),z),r))}),t.createElement("div",{className:Ue},t.createElement("span",{className:Xe},c),t.createElement(S,{"aria-hidden":!0,role:"presentation",className:We})),i)}));function $e(){var e=P(["\n width: ","px;\n "]);return $e=function(){return e},e}function Je(){var e=P(["\n color: ",";\n font-size: ","px;\n line-height: ","px;\n\n @media only screen and (max-width: ","px) {\n font-size: ","px;\n line-height: ","px;\n }\n "]);return Je=function(){return e},e}function Qe(){var e=P(["\n cursor: not-allowed;\n "]);return Qe=function(){return e},e}function Ze(){var e=P(["\n color: ",";\n font-size: ","px;\n line-height: ","px;\n\n @media only screen and (max-width: ","px) {\n font-size: ","px;\n line-height: ","px;\n }\n "]);return Ze=function(){return e},e}function _e(){var e=P(["\n cursor: not-allowed;\n "]);return _e=function(){return e},e}function en(){var e=P(["\n margin-bottom: 2px;\n font-weight: bold;\n"]);return en=function(){return e},e}function nn(){var e=P(["\n font-family: ",";\n display: block;\n"]);return nn=function(){return e},e}Ye.displayName="MenuButton";var tn=d(nn(),g.default),rn=d(en()),on=b.create("select");function an(e){var n,r,o=e.children,i=e.darkMode,s=void 0!==i&&i,p=e.size,b=void 0===p?M.Default:p,v=e.disabled,m=void 0!==v&&v,g=e.usePortal,x=void 0===g||g,w=e.placeholder,O=void 0===w?"Select":w,k=e.className,E=e.id,N=e.label,D=e.description,S=e.name,j=e.defaultValue,F=e.value,P=e.onChange,A=e.readOnly,H=e["aria-labelledby"],T=u((function(){return null!=E?E:on.generate()}),[E]),I=null!==(n="aria-labelledby")?n:"".concat(T,"-label"),G="".concat(T,"-description"),R="".concat(T,"-menu"),q=z(c(!1),2),U=q[0],Y=q[1],J=ze(null),Q=ze(null),Z=s?K:V,_=L[Z],ee=B[b],ne=u((function(){return{mode:Z,size:b,open:U,disabled:m}}),[Z,b,U,m]);l((function(){void 0!==F&&void 0===P&&!0!==A&&console.warn("You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.")}),[P,A,F]),N||H||console.error("For screen-reader accessibility, label or aria-labelledby must be provided to IconButton.");var te=a((function(){Y(!0)}),[]),re=a((function(){Y(!1),J.current.focus()}),[J]);l((function(){if(U){var e=function(e){var n=J.current.contains(e.target)||Q.current.contains(e.target);Y(n)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}}),[Q,J,U]);var oe=u((function(){var e=null;return void 0===F&&void 0!==j&&Ne(o,(function(n,t){je(n,t,j)&&(e=n)})),e}),[o,j,F]),ie=z(c(oe),2),ae=ie[0],le=ie[1];l((function(){var e;null!==ae&&le(null!==(e=function(e,n){var t,r,o,i,a,l,u,c;return Ne(e,(function(e){if(e===n)a=n;else if(e.props.children===n.props.children&&e.props.value===n.props.value){var t;null!==(t=l)&&void 0!==t||(l=e)}else if(void 0!==e.props.value&&e.props.value===n.props.value){var r;null!==(r=u)&&void 0!==r||(u=e)}else if(Se(e)===Se(n)){var o;null!==(o=c)&&void 0!==o||(c=e)}})),null!==(t=null!==(r=null!==(o=null!==(i=a)&&void 0!==i?i:l)&&void 0!==o?o:u)&&void 0!==r?r:c)&&void 0!==t?t:null}(o,ae))&&void 0!==e?e:oe)}),[o,oe,ae]);var ue=u((function(){if(void 0!==F){var e=null;return Ne(o,(function(n,t){je(n,t,F)&&(e=n)})),e}return ae}),[o,ae,F]),ce=a((function(e,n){void 0===F&&le(e),null==P||P(Se(e),n),be(void 0),re()}),[P,re,F]),se=a((function(e,n){return function(t){t.preventDefault(),t.stopPropagation(),m||n||(ce(e,t),re())}}),[m,re,ce]),de=a((function(e){ce(null,e)}),[ce]),pe=z(c(),2),he=pe[0],be=pe[1],ve=u((function(){var e=[null];return Ne(o,(function(n,t){Ce(n,t)||e.push(n)})),e}),[o]),me=a((function(e){void 0!==he&&ce(he,e)}),[he,ce]),ge=a((function(){be(null)}),[]),ye=a((function(){be(ve[ve.length-1])}),[ve]),xe=a((function(){if(void 0===he||0===ve.indexOf(he))ye();else{var e=ve.indexOf(he)-1;be(ve[e])}}),[ve,he,ye]),we=a((function(){if(void 0===he||ve.indexOf(he)===ve.length-1)ge();else{var e=ve.indexOf(he)+1;be(ve[e])}}),[ve,he,ge]),Oe=a((function(e,n){return function(t){t.preventDefault(),t.stopPropagation(),m||n||be(e)}}),[m]),ke=h(),Ee=u((function(){var e=!1;return Ne(o,(function(n){e||(e=void 0!==n.props.glyph)})),e}),[o]),Fe=u((function(){return null!==ke&&null!==Q.current&&void 0===he&&U}),[he,Q,U,ke]),Pe=u((function(){var e=null===ue;return t.createElement(fe,{className:void 0,glyph:void 0,selected:e,focused:null===he,disabled:!1,onClick:se(null,!1),onFocus:Oe(null,!1),isDeselection:!0,hasGlyphs:!0,triggerScrollIntoView:e&&Fe},O)}),[Fe,he,se,Oe,O,ue]),Ae=u((function(){return De(o,(function(e,n){var t=e===ue,r=Ce(e,n);return{className:e.props.className,glyph:e.props.glyph,selected:t,focused:e===he,disabled:r,children:e.props.children,isDeselection:!1,hasGlyphs:Ee,onClick:se(e,r),onFocus:Oe(e,r),triggerScrollIntoView:t&&Fe}}),(function(){console.error("`Select` instance received child that is not `Option` or `OptionGroup`.")}))}),[Fe,o,he,se,Oe,Ee,ue]);return t.createElement("div",{className:f(C({},d(_e()),m),k)},N&&t.createElement("label",{id:I,className:f(tn,rn,d(Ze(),m?_.label.disabled:_.label.base,ee.label.text,ee.label.lineHeight,y.Desktop,X.text,X.lineHeight),C({},d(Qe()),m))},N),D&&t.createElement("div",{id:G,className:f(tn,d(Je(),_.description,ee.description.text,ee.description.lineHeight,y.Desktop,W.text,W.lineHeight))},D),t.createElement($.Provider,{value:ne},t.createElement(Ye,{ref:J,name:S,readOnly:A,value:Se(ue),text:null!==ue?ue.props.children:O,deselected:null===ue,onDeselect:de,onOpen:te,onClose:re,onFocusFirstOption:ge,onFocusLastOption:ye,"aria-labelledby":I,"aria-controls":R,"aria-expanded":U,"aria-describedby":G},t.createElement(Ie,{id:R,referenceElement:J,ref:Q,onClose:re,onSelectFocusedOption:me,onFocusPreviousOption:xe,onFocusNextOption:we,usePortal:x,className:d($e(),null===(r=J.current)||void 0===r?void 0:r.clientWidth)},Pe,Ae))))}an.displayName="Select",an.propTypes={label:s.string,"aria-labelledby":s.string,description:s.string,placeholder:s.string,className:s.string,darkMode:s.bool,size:s.oneOf(Object.values(M)),disabled:s.bool,id:s.string,value:s.string,defaultValue:s.string,onChange:s.func,readOnly:s.bool};export{pe as Option,ke as OptionGroup,an as Select,M as Size};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("polished"),require("@leafygreen-ui/palette"),require("react"),require("prop-types"),require("@leafygreen-ui/emotion"),require("@leafygreen-ui/hooks"),require("@leafygreen-ui/lib"),require("@leafygreen-ui/tokens"),require("@leafygreen-ui/popover"),require("@leafygreen-ui/icon/dist/Checkmark"),require("react-is"),require("@leafygreen-ui/button"),require("@leafygreen-ui/icon/dist/CaretDown")):"function"==typeof define&&define.amd?define(["exports","polished","@leafygreen-ui/palette","react","prop-types","@leafygreen-ui/emotion","@leafygreen-ui/hooks","@leafygreen-ui/lib","@leafygreen-ui/tokens","@leafygreen-ui/popover","@leafygreen-ui/icon/dist/Checkmark","react-is","@leafygreen-ui/button","@leafygreen-ui/icon/dist/CaretDown"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self)["@leafygreen-ui/select"]={},e.polished,e["@leafygreen-ui/palette"],e.React,e.PropTypes,e["@leafygreen-ui/emotion"],e["@leafygreen-ui/hooks"],e["@leafygreen-ui/lib"],e["@leafygreen-ui/tokens"],e["@leafygreen-ui/popover"],e.Checkmark,e.reactIs,e["@leafygreen-ui/button"],e.CaretDown)}(this,(function(e,n,t,r,o,a,i,l,u,s,c,d,f,p){"use strict";function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h,g,y=b(r),v=b(o),m=b(s),x=b(c),k=b(f),C=b(p);function w(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function O(){return(O=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function E(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function N(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}function S(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,o=!1,a=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(t.push(i.value),!n||t.length!==n);r=!0);}catch(e){o=!0,a=e}finally{try{r||null==l.return||l.return()}finally{if(o)throw a}}return t}(e,n)||M(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function D(e){return function(e){if(Array.isArray(e))return j(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||M(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function M(e,n){if(e){if("string"==typeof e)return j(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?j(e,n):void 0}}function j(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var F="dark",z="light",P=(w(h={},z,{label:{base:t.uiColors.gray.dark3,disabled:t.uiColors.gray.dark1},description:t.uiColors.gray.dark1,border:{base:t.uiColors.gray.light1,open:t.uiColors.gray.dark1},text:{base:t.uiColors.gray.dark3,deselected:t.uiColors.gray.dark1,disabled:t.uiColors.gray.base},menu:{shadow:n.transparentize(.78,t.uiColors.black)},option:{group:{label:t.uiColors.gray.dark3,border:t.uiColors.gray.light2},background:{base:t.uiColors.white,hovered:t.uiColors.gray.light2,focused:t.uiColors.blue.light3},text:{base:t.uiColors.gray.dark3,selected:t.uiColors.blue.base,disabled:t.uiColors.gray.base},icon:{base:t.uiColors.gray.dark1,selected:t.uiColors.blue.base,disabled:t.uiColors.gray.base}}}),w(h,F,{label:{base:t.uiColors.white,disabled:t.uiColors.gray.light1},description:t.uiColors.gray.light1,border:{base:t.uiColors.gray.dark2,open:t.uiColors.gray.dark2},text:{base:t.uiColors.white,deselected:t.uiColors.gray.light1,disabled:t.uiColors.gray.dark1},menu:{shadow:n.transparentize(.2,t.uiColors.black)},option:{group:{label:t.uiColors.white,border:t.uiColors.gray.dark1},background:{base:t.uiColors.gray.dark2,hovered:t.uiColors.gray.dark1,focused:t.uiColors.blue.base},text:{base:t.uiColors.white,selected:"#9DD0E7",disabled:t.uiColors.gray.base},icon:{base:t.uiColors.gray.light1,selected:"#9DD0E7",disabled:t.uiColors.gray.base}}}),h),T={XSmall:"xsmall",Small:"small",Default:"default",Large:"large"},A=(w(g={},T.XSmall,{height:22,width:194,text:12,label:{text:14,lineHeight:16},description:{text:14,lineHeight:16},option:{text:14}}),w(g,T.Small,{height:28,width:194,text:14,label:{text:14,lineHeight:16},description:{text:14,lineHeight:16},option:{text:14}}),w(g,T.Default,{height:36,width:194,text:14,label:{text:14,lineHeight:16},description:{text:14,lineHeight:20},option:{text:14}}),w(g,T.Large,{height:48,width:230,text:18,label:{text:18,lineHeight:21},description:{text:18,lineHeight:24},option:{text:16}}),g),q=36,H=194,I=16,V={text:16,lineHeight:19},G={text:16,lineHeight:22},K={text:16},R=r.createContext({mode:z,size:T.Default,open:!1,disabled:!1});function L(){var e=N(["\n cursor: not-allowed;\n color: ",";\n "]);return L=function(){return e},e}function B(){var e=N(["\n cursor: pointer;\n color: ",";\n "]);return B=function(){return e},e}function U(){var e=N(["\n display: flex;\n "]);return U=function(){return e},e}function X(){var e=N(["\n display: flex;\n justify-content: space-between;\n width: 100%;\n "]);return X=function(){return e},e}function _(){var e=N(["\n color: ",";\n "]);return _=function(){return e},e}function J(){var e=N(["\n color: ",";\n "]);return J=function(){return e},e}function W(){var e=N(["\n color: ",";\n "]);return W=function(){return e},e}function Y(){var e=N(["\n color: ",";\n "]);return Y=function(){return e},e}function $(){var e=N(["\n height: 100%;\n "]);return $=function(){return e},e}function Q(){var e=N(["\n font-weight: bold;\n "]);return Q=function(){return e},e}function Z(){var e=N(["\n min-width: 16px;\n margin-right: 6px;\n"]);return Z=function(){return e},e}function ee(){var e=N(["\n display: flex;\n align-items: center;\n"]);return ee=function(){return e},e}function ne(){var e=N(["\n display: flex;\n width: 100%;\n padding: 10px 12px;\n outline: none;\n overflow-wrap: anywhere;\n transition: background-color 150ms ease-in-out;\n"]);return ne=function(){return e},e}var te=a.css(ne()),re=a.css(ee()),oe=a.css(Z());function ae(e){var n,t=e.children,o=e.className,l=e.glyph,u=e.selected,s=e.focused,c=e.disabled,d=e.onClick,f=e.onFocus,p=e.isDeselection,b=e.triggerScrollIntoView,h=e.hasGlyphs,g=r.useContext(R).mode,v=P[g].option,m=r.useRef(null),k=r.useCallback((function(){var e=m.current,n=e.offsetParent;n.scrollTop=e.offsetTop+(e.clientHeight-n.clientHeight)/2}),[m]),C=i.usePrevious(b),O=b&&!C;r.useEffect((function(){O&&k()}),[k,O]);var E=i.usePrevious(s),N=s&&!E;r.useEffect((function(){N&&m.current.focus()}),[N]);var S=y.default.createElement("span",{className:a.cx(re,w({},a.css(Q()),u&&!p))},t),D=y.default.createElement("span",{className:a.cx(oe,a.css($()))}),M=D;l&&(l.type.isGlyph?M=y.default.cloneElement(l,{key:"glyph",className:a.cx(oe,a.css(Y(),v.icon.base),w({},a.css(W(),v.icon.disabled),c),l.props.className)}):console.error("`Option` instance did not render icon because it is not a known glyph element."));var j,F=u&&!p?y.default.createElement(x.default,{key:"checkmark",className:a.cx(oe,a.css(J(),v.icon.selected),w({},a.css(_(),v.icon.disabled),c))}):D;return j=h?y.default.createElement("span",{className:a.css(X())},y.default.createElement("span",{className:a.css(U())},M,S),F):y.default.createElement(y.default.Fragment,null,F,S),y.default.createElement("li",{role:"option","aria-selected":u,tabIndex:-1,ref:m,className:a.cx(te,a.css(B(),v.text.base),(n={},w(n,a.css("\n &:focus {\n background-color: ".concat(v.background.focused,";\n }\n\n &:hover {\n background-color: ").concat(v.background.hovered,";\n }\n ")),!c),w(n,a.css(L(),v.text.disabled),c),n),o),onClick:d,onFocus:f,onKeyDown:void 0},j)}function ie(e){throw Error("`Option` must be a child of a `Select` instance")}ae.displayName="Option",ie.displayName="Option";var le=v.default.oneOfType([v.default.string,v.default.number]);function ue(){var e=N(["\n color: ",";\n "]);return ue=function(){return e},e}function se(){var e=N(["\n border-bottom: 1px solid ",";\n "]);return se=function(){return e},e}function ce(){var e=N(["\n cursor: default;\n width: 100%;\n padding: 0 12px 2px;\n outline: none;\n overflow-wrap: anywhere;\n font-size: 13px;\n line-height: 16px;\n font-weight: bold;\n"]);return ce=function(){return e},e}function de(){var e=N(["\n padding-top: 8px;\n"]);return de=function(){return e},e}ie.propTypes={children:v.default.oneOfType([le,v.default.arrayOf(v.default.oneOfType([le,v.default.oneOf([!1,null,void 0,""])]))]).isRequired,className:v.default.string,glyph:v.default.element,value:v.default.string,disabled:v.default.bool};var fe=a.css(de()),pe=a.css(ce()),be=l.IdAllocator.create("select-option-group");function he(e){var n=e.className,t=e.label,o=e.children,i=r.useContext(R).mode,l=P[i].option,u=r.useMemo((function(){return be.generate()}),[]);return y.default.createElement("div",{className:a.cx(fe,a.css(se(),l.group.border),n)},y.default.createElement("div",{id:u,className:a.cx(pe,a.css(ue(),l.group.label))},t),y.default.createElement("div",{role:"group","aria-labelledby":u},o))}function ge(e){throw Error("`OptionGroup` must be a child of a `Select` instance")}function ye(e){return null==e||!1===e||""===e}function ve(e,n){y.default.Children.forEach(e,(function(e){l.isComponentType(e,"Option")?n(e):l.isComponentType(e,"OptionGroup")?ve(e.props.children,(function(t){return n(t,e)})):d.isFragment(e)&&ve(e.props.children,n)}))}function me(e,n,t){return y.default.Children.map(e,(function(e){if(l.isComponentType(e,"Option"))return y.default.createElement(ae,n(e));if(l.isComponentType(e,"OptionGroup")){var r=e.props,o=r.children,a=E(r,["children"]);return y.default.createElement(he,O({className:void 0},a),me(o,(function(t){return n(t,e)}),t))}return d.isFragment(e)?me(e.props.children,n,t):(ye(e)||null==t||t(e),null)}))}function xe(e){return null===e?"":void 0!==e.props.value?e.props.value:Array.isArray(e.props.children)?e.props.children.filter((function(e){return!ye(e)})).join(""):e.props.children.toString()}function ke(e,n){var t,r,o;return null!==(t=e.props.disabled)&&void 0!==t&&t||null!==(r=null==n||null===(o=n.props)||void 0===o?void 0:o.disabled)&&void 0!==r&&r}function Ce(e,n,t){return xe(e)===t&&!ke(e,n)}function we(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=n.initialValue,o=n.deps,a=void 0===o?[]:o,i=r.useRef(t);return r.useMemo((function(){return{get current(){return i.current},set current(n){i.current=n,e(n)}}}),[e,i].concat(D(a)))}function Oe(e,n){var t=r.useCallback((function(e,n){Array.isArray(e)?e.forEach(t):"function"==typeof e?e(n):e&&(e.current=n)}),[]);return we(r.useCallback((function(n){return t(e,n)}),[e,t]),{initialValue:n})}he.displayName="OptionGroup",ge.displayName="OptionGroup",ge.propTypes={children:v.default.oneOfType([v.default.element,v.default.arrayOf(v.default.oneOfType([v.default.oneOf([!1,null,void 0,""]),v.default.element]))]).isRequired,className:v.default.string,label:v.default.string.isRequired,disabled:v.default.bool};var Ee=function(e){var n=S(r.useState(e),2),t=n[0];return we(n[1],{initialValue:e,deps:[t]})};function Ne(){var e=N(["\n font-family: ",";\n font-size: ","px;\n max-height: ","px;\n background-color: ",";\n box-shadow: 0 3px 7px 0 ",";\n\n @media only screen and (max-width: ","px) {\n font-size: ","px;\n }\n "]);return Ne=function(){return e},e}function Se(){var e=N(["\n position: relative;\n text-align: left;\n width: 100%;\n border-radius: 3px;\n line-height: 16px;\n list-style: none;\n margin: 0;\n padding: 0;\n overflow: auto;\n"]);return Se=function(){return e},e}var De=a.css(Se()),Me=y.default.forwardRef((function(e,n){var t=e.children,o=e.id,c=e.referenceElement,d=e.onClose,f=e.onFocusPreviousOption,p=e.onFocusNextOption,b=e.onSelectFocusedOption,h=e.className,g=e.usePortal,v=r.useContext(R),x=v.mode,k=v.size,C=v.disabled,w=v.open,O=P[x],E=A[k],N=Oe(n,null),S=r.useCallback((function(e){if(!(e.ctrlKey||e.shiftKey||e.altKey)){var n=!1;switch(e.keyCode){case l.keyMap.Tab:case l.keyMap.Enter:b(e);break;case l.keyMap.Escape:d();break;case l.keyMap.ArrowUp:f();break;case l.keyMap.ArrowDown:p();break;default:n=!0}n||(e.preventDefault(),e.stopPropagation())}}),[d,p,f,b]),D=i.useViewportSize(),M=null===D||null===N.current?0:D.height-N.current.getBoundingClientRect().top-10,j=r.useCallback((function(e){N.current&&N.current.focus(),e.stopPropagation()}),[N]);return y.default.createElement(m.default,{active:w&&!C,spacing:4,align:s.Align.Bottom,justify:s.Justify.Middle,adjustOnMutation:!0,className:h,refEl:c,usePortal:g},y.default.createElement("ul",{role:"listbox",ref:N,tabIndex:-1,onKeyDown:S,onClick:j,className:a.cx(De,a.css(Ne(),u.fontFamilies.default,E.option.text,M,O.option.background.base,O.menu.shadow,u.breakpoints.Desktop,K.text)),id:o},t))}));function je(){var e=N(["\n color: ",";\n "]);return je=function(){return e},e}function Fe(){var e=N(["\n // Displays the active state defined by <Button />\n &:after {\n opacity: 1;\n }\n "]);return Fe=function(){return e},e}function ze(){var e=N(["\n height: ","px;\n width: ","px;\n font-size: ","px;\n color: ",";\n border-color: ",";\n\n @media only screen and (max-width: ","px) {\n height: ","px;\n width: ","px;\n font-size: ","px;\n }\n "]);return ze=function(){return e},e}function Pe(){var e=N(["\n min-width: 16px;\n"]);return Pe=function(){return e},e}function Te(){var e=N(["\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n"]);return Te=function(){return e},e}function Ae(){var e=N(["\n position: relative;\n display: flex;\n align-items: center;\n justify-content: space-between;\n height: 100%;\n width: 100%;\n"]);return Ae=function(){return e},e}function qe(){var e=N(["\n margin-top: 2px;\n\n // reset default Button padding\n > span {\n padding: 0;\n }\n"]);return qe=function(){return e},e}Me.displayName="ListMenu";var He=a.css(qe()),Ie=a.css(Ae()),Ve=a.css(Te()),Ge=a.css(Pe()),Ke=y.default.forwardRef((function(e,n){var t,o=e.children,i=e.value,s=e.text,c=e.name,d=e.deselected,p=(e.readOnly,e.onDeselect),b=e.onFocusFirstOption,h=e.onFocusLastOption,g=e.onClose,v=e.onOpen,m=E(e,["children","value","text","name","deselected","readOnly","onDeselect","onFocusFirstOption","onFocusLastOption","onClose","onOpen"]),x=r.useContext(R),N=x.mode,S=x.size,D=x.open,M=x.disabled,j=Oe(n,null),z=P[N],T=A[S],V=r.useCallback((function(e){if(!M&&!(e.ctrlKey||e.shiftKey||e.altKey)){var n=!1;switch(e.keyCode){case l.keyMap.Tab:g(),n=!0;break;case l.keyMap.Escape:D?g():p(e);break;case l.keyMap.ArrowUp:v(),h();break;case l.keyMap.ArrowDown:v(),b();break;default:n=!0}n||(e.preventDefault(),e.stopPropagation())}}),[M,g,p,b,h,v,D]),G=r.useCallback((function(){D?g():v(),j.current.focus()}),[g,v,D,j]),K=r.useMemo((function(){if(D&&!M)return{focused:!0,active:!0}}),[D,M]);return y.default.createElement(k.default,O({role:"combobox"},m,{ref:j,name:c,value:i,disabled:M,onClick:G,onKeyDown:V,variant:N===F?f.Variant.Dark:f.Variant.Default,darkMode:N===F,forceState:K,className:a.cx(He,a.css(ze(),T.height,T.width,T.text,d?z.text.deselected:z.text.base,D&&!M?z.border.open:z.border.base,u.breakpoints.Desktop,q,H,I),(t={},w(t,a.css(Fe()),D&&!M),w(t,a.css(je(),z.text.disabled),M),t))}),y.default.createElement("div",{className:Ie},y.default.createElement("span",{className:Ve},s),y.default.createElement(C.default,{"aria-hidden":!0,className:Ge})),o)}));function Re(){var e=N(["\n width: ","px;\n "]);return Re=function(){return e},e}function Le(){var e=N(["\n color: ",";\n font-size: ","px;\n line-height: ","px;\n\n @media only screen and (max-width: ","px) {\n font-size: ","px;\n line-height: ","px;\n }\n "]);return Le=function(){return e},e}function Be(){var e=N(["\n cursor: not-allowed;\n "]);return Be=function(){return e},e}function Ue(){var e=N(["\n color: ",";\n font-size: ","px;\n line-height: ","px;\n\n @media only screen and (max-width: ","px) {\n font-size: ","px;\n line-height: ","px;\n }\n "]);return Ue=function(){return e},e}function Xe(){var e=N(["\n cursor: not-allowed;\n "]);return Xe=function(){return e},e}function _e(){var e=N(["\n margin-bottom: 2px;\n font-weight: bold;\n"]);return _e=function(){return e},e}function Je(){var e=N(["\n font-family: ",";\n display: block;\n"]);return Je=function(){return e},e}Ke.displayName="MenuButton";var We=a.css(Je(),u.fontFamilies.default),Ye=a.css(_e()),$e=l.IdAllocator.create("select");function Qe(e){var n,t,o=e.children,l=e.darkMode,s=void 0!==l&&l,c=e.size,d=void 0===c?T.Default:c,f=e.disabled,p=void 0!==f&&f,b=e.usePortal,h=void 0===b||b,g=e.placeholder,v=void 0===g?"Select":g,m=e.className,x=e.id,k=e.label,C=e.description,O=e.name,E=e.defaultValue,N=e.value,D=e.onChange,M=e.readOnly,j=e["aria-labelledby"],q=r.useMemo((function(){return null!=x?x:$e.generate()}),[x]),H=null!==(n="aria-labelledby")?n:"".concat(q,"-label"),I="".concat(q,"-description"),K="".concat(q,"-menu"),L=S(r.useState(!1),2),B=L[0],U=L[1],X=Ee(null),_=Ee(null),J=s?F:z,W=P[J],Y=A[d],$=r.useMemo((function(){return{mode:J,size:d,open:B,disabled:p}}),[J,d,B,p]);r.useEffect((function(){void 0!==N&&void 0===D&&!0!==M&&console.warn("You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.")}),[D,M,N]),k||j||console.error("For screen-reader accessibility, label or aria-labelledby must be provided to IconButton.");var Q=r.useCallback((function(){U(!0)}),[]),Z=r.useCallback((function(){U(!1),X.current.focus()}),[X]);r.useEffect((function(){if(B){var e=function(e){var n=X.current.contains(e.target)||_.current.contains(e.target);U(n)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}}),[_,X,B]);var ee=r.useMemo((function(){var e=null;return void 0===N&&void 0!==E&&ve(o,(function(n,t){Ce(n,t,E)&&(e=n)})),e}),[o,E,N]),ne=S(r.useState(ee),2),te=ne[0],re=ne[1];r.useEffect((function(){var e;null!==te&&re(null!==(e=function(e,n){var t,r,o,a,i,l,u,s;return ve(e,(function(e){if(e===n)i=n;else if(e.props.children===n.props.children&&e.props.value===n.props.value){var t;null!==(t=l)&&void 0!==t||(l=e)}else if(void 0!==e.props.value&&e.props.value===n.props.value){var r;null!==(r=u)&&void 0!==r||(u=e)}else if(xe(e)===xe(n)){var o;null!==(o=s)&&void 0!==o||(s=e)}})),null!==(t=null!==(r=null!==(o=null!==(a=i)&&void 0!==a?a:l)&&void 0!==o?o:u)&&void 0!==r?r:s)&&void 0!==t?t:null}(o,te))&&void 0!==e?e:ee)}),[o,ee,te]);var oe=r.useMemo((function(){if(void 0!==N){var e=null;return ve(o,(function(n,t){Ce(n,t,N)&&(e=n)})),e}return te}),[o,te,N]),ie=r.useCallback((function(e,n){void 0===N&&re(e),null==D||D(xe(e),n),de(void 0),Z()}),[D,Z,N]),le=r.useCallback((function(e,n){return function(t){t.preventDefault(),t.stopPropagation(),p||n||(ie(e,t),Z())}}),[p,Z,ie]),ue=r.useCallback((function(e){ie(null,e)}),[ie]),se=S(r.useState(),2),ce=se[0],de=se[1],fe=r.useMemo((function(){var e=[null];return ve(o,(function(n,t){ke(n,t)||e.push(n)})),e}),[o]),pe=r.useCallback((function(e){void 0!==ce&&ie(ce,e)}),[ce,ie]),be=r.useCallback((function(){de(null)}),[]),he=r.useCallback((function(){de(fe[fe.length-1])}),[fe]),ge=r.useCallback((function(){if(void 0===ce||0===fe.indexOf(ce))he();else{var e=fe.indexOf(ce)-1;de(fe[e])}}),[fe,ce,he]),ye=r.useCallback((function(){if(void 0===ce||fe.indexOf(ce)===fe.length-1)be();else{var e=fe.indexOf(ce)+1;de(fe[e])}}),[fe,ce,be]),we=r.useCallback((function(e,n){return function(t){t.preventDefault(),t.stopPropagation(),p||n||de(e)}}),[p]),Oe=i.useViewportSize(),Ne=r.useMemo((function(){var e=!1;return ve(o,(function(n){e||(e=void 0!==n.props.glyph)})),e}),[o]),Se=r.useMemo((function(){return null!==Oe&&null!==_.current&&void 0===ce&&B}),[ce,_,B,Oe]),De=r.useMemo((function(){var e=null===oe;return y.default.createElement(ae,{className:void 0,glyph:void 0,selected:e,focused:null===ce,disabled:!1,onClick:le(null,!1),onFocus:we(null,!1),isDeselection:!0,hasGlyphs:!0,triggerScrollIntoView:e&&Se},v)}),[Se,ce,le,we,v,oe]),je=r.useMemo((function(){return me(o,(function(e,n){var t=e===oe,r=ke(e,n);return{className:e.props.className,glyph:e.props.glyph,selected:t,focused:e===ce,disabled:r,children:e.props.children,isDeselection:!1,hasGlyphs:Ne,onClick:le(e,r),onFocus:we(e,r),triggerScrollIntoView:t&&Se}}),(function(){console.error("`Select` instance received child that is not `Option` or `OptionGroup`.")}))}),[Se,o,ce,le,we,Ne,oe]);return y.default.createElement("div",{className:a.cx(w({},a.css(Xe()),p),m)},k&&y.default.createElement("label",{id:H,className:a.cx(We,Ye,a.css(Ue(),p?W.label.disabled:W.label.base,Y.label.text,Y.label.lineHeight,u.breakpoints.Desktop,V.text,V.lineHeight),w({},a.css(Be()),p))},k),C&&y.default.createElement("div",{id:I,className:a.cx(We,a.css(Le(),W.description,Y.description.text,Y.description.lineHeight,u.breakpoints.Desktop,G.text,G.lineHeight))},C),y.default.createElement(R.Provider,{value:$},y.default.createElement(Ke,{ref:X,name:O,readOnly:M,value:xe(oe),text:null!==oe?oe.props.children:v,deselected:null===oe,onDeselect:ue,onOpen:Q,onClose:Z,onFocusFirstOption:be,onFocusLastOption:he,"aria-labelledby":H,"aria-controls":K,"aria-expanded":B,"aria-describedby":I},y.default.createElement(Me,{id:K,referenceElement:X,ref:_,onClose:Z,onSelectFocusedOption:pe,onFocusPreviousOption:ge,onFocusNextOption:ye,usePortal:h,className:a.css(Re(),null===(t=X.current)||void 0===t?void 0:t.clientWidth)},De,je))))}Qe.displayName="Select",Qe.propTypes={label:v.default.string,"aria-labelledby":v.default.string,description:v.default.string,placeholder:v.default.string,className:v.default.string,darkMode:v.default.bool,size:v.default.oneOf(Object.values(T)),disabled:v.default.bool,id:v.default.string,value:v.default.string,defaultValue:v.default.string,onChange:v.default.func,readOnly:v.default.bool},e.Option=ie,e.OptionGroup=ge,e.Select=Qe,e.Size=T,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("polished"),require("@leafygreen-ui/palette"),require("react"),require("prop-types"),require("@leafygreen-ui/emotion"),require("@leafygreen-ui/hooks"),require("@leafygreen-ui/lib"),require("@leafygreen-ui/tokens"),require("@leafygreen-ui/popover"),require("@leafygreen-ui/icon/dist/Checkmark"),require("react-is"),require("@leafygreen-ui/button"),require("@leafygreen-ui/icon/dist/CaretDown")):"function"==typeof define&&define.amd?define(["exports","polished","@leafygreen-ui/palette","react","prop-types","@leafygreen-ui/emotion","@leafygreen-ui/hooks","@leafygreen-ui/lib","@leafygreen-ui/tokens","@leafygreen-ui/popover","@leafygreen-ui/icon/dist/Checkmark","react-is","@leafygreen-ui/button","@leafygreen-ui/icon/dist/CaretDown"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self)["@leafygreen-ui/select"]={},e.polished,e["@leafygreen-ui/palette"],e.React,e.PropTypes,e["@leafygreen-ui/emotion"],e["@leafygreen-ui/hooks"],e["@leafygreen-ui/lib"],e["@leafygreen-ui/tokens"],e["@leafygreen-ui/popover"],e.Checkmark,e.reactIs,e["@leafygreen-ui/button"],e.CaretDown)}(this,(function(e,n,t,r,o,a,i,l,u,s,c,d,f,p){"use strict";function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h,g,y=b(r),v=b(o),m=b(s),x=b(c),k=b(f),C=b(p);function w(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function O(){return(O=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function E(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function N(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}function S(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,o=!1,a=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(t.push(i.value),!n||t.length!==n);r=!0);}catch(e){o=!0,a=e}finally{try{r||null==l.return||l.return()}finally{if(o)throw a}}return t}(e,n)||M(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function D(e){return function(e){if(Array.isArray(e))return j(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||M(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function M(e,n){if(e){if("string"==typeof e)return j(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?j(e,n):void 0}}function j(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var F="dark",z="light",P=(w(h={},z,{label:{base:t.uiColors.gray.dark3,disabled:t.uiColors.gray.dark1},description:t.uiColors.gray.dark1,border:{base:t.uiColors.gray.light1,open:t.uiColors.gray.dark1},text:{base:t.uiColors.gray.dark3,deselected:t.uiColors.gray.dark1,disabled:t.uiColors.gray.base},menu:{shadow:n.transparentize(.78,t.uiColors.black)},option:{group:{label:t.uiColors.gray.dark3,border:t.uiColors.gray.light2},background:{base:t.uiColors.white,hovered:t.uiColors.gray.light2,focused:t.uiColors.blue.light3},text:{base:t.uiColors.gray.dark3,selected:t.uiColors.blue.base,disabled:t.uiColors.gray.base},icon:{base:t.uiColors.gray.dark1,selected:t.uiColors.blue.base,disabled:t.uiColors.gray.base}}}),w(h,F,{label:{base:t.uiColors.white,disabled:t.uiColors.gray.light1},description:t.uiColors.gray.light1,border:{base:t.uiColors.gray.dark2,open:t.uiColors.gray.dark2},text:{base:t.uiColors.white,deselected:t.uiColors.gray.light1,disabled:t.uiColors.gray.dark1},menu:{shadow:n.transparentize(.2,t.uiColors.black)},option:{group:{label:t.uiColors.white,border:t.uiColors.gray.dark1},background:{base:t.uiColors.gray.dark2,hovered:t.uiColors.gray.dark1,focused:t.uiColors.blue.base},text:{base:t.uiColors.white,selected:"#9DD0E7",disabled:t.uiColors.gray.base},icon:{base:t.uiColors.gray.light1,selected:"#9DD0E7",disabled:t.uiColors.gray.base}}}),h),T={XSmall:"xsmall",Small:"small",Default:"default",Large:"large"},A=(w(g={},T.XSmall,{height:22,width:194,text:12,label:{text:14,lineHeight:16},description:{text:14,lineHeight:16},option:{text:14}}),w(g,T.Small,{height:28,width:194,text:14,label:{text:14,lineHeight:16},description:{text:14,lineHeight:16},option:{text:14}}),w(g,T.Default,{height:36,width:194,text:14,label:{text:14,lineHeight:16},description:{text:14,lineHeight:20},option:{text:14}}),w(g,T.Large,{height:48,width:230,text:18,label:{text:18,lineHeight:21},description:{text:18,lineHeight:24},option:{text:16}}),g),q=36,H=194,I=16,V={text:16,lineHeight:19},G={text:16,lineHeight:22},K={text:16},R=r.createContext({mode:z,size:T.Default,open:!1,disabled:!1});function L(){var e=N(["\n cursor: not-allowed;\n color: ",";\n "]);return L=function(){return e},e}function B(){var e=N(["\n cursor: pointer;\n color: ",";\n "]);return B=function(){return e},e}function U(){var e=N(["\n display: flex;\n "]);return U=function(){return e},e}function X(){var e=N(["\n display: flex;\n justify-content: space-between;\n width: 100%;\n "]);return X=function(){return e},e}function _(){var e=N(["\n color: ",";\n "]);return _=function(){return e},e}function J(){var e=N(["\n color: ",";\n "]);return J=function(){return e},e}function W(){var e=N(["\n color: ",";\n "]);return W=function(){return e},e}function Y(){var e=N(["\n color: ",";\n "]);return Y=function(){return e},e}function $(){var e=N(["\n height: 100%;\n "]);return $=function(){return e},e}function Q(){var e=N(["\n font-weight: bold;\n "]);return Q=function(){return e},e}function Z(){var e=N(["\n min-width: 16px;\n margin-right: 6px;\n"]);return Z=function(){return e},e}function ee(){var e=N(["\n display: flex;\n align-items: center;\n"]);return ee=function(){return e},e}function ne(){var e=N(["\n display: flex;\n width: 100%;\n padding: 10px 12px;\n outline: none;\n overflow-wrap: anywhere;\n transition: background-color 150ms ease-in-out;\n"]);return ne=function(){return e},e}var te=a.css(ne()),re=a.css(ee()),oe=a.css(Z());function ae(e){var n,t=e.children,o=e.className,l=e.glyph,u=e.selected,s=e.focused,c=e.disabled,d=e.onClick,f=e.onFocus,p=e.isDeselection,b=e.triggerScrollIntoView,h=e.hasGlyphs,g=r.useContext(R).mode,v=P[g].option,m=r.useRef(null),k=r.useCallback((function(){var e=m.current,n=e.offsetParent;n.scrollTop=e.offsetTop+(e.clientHeight-n.clientHeight)/2}),[m]),C=i.usePrevious(b),O=b&&!C;r.useEffect((function(){O&&k()}),[k,O]);var E=i.usePrevious(s),N=s&&!E;r.useEffect((function(){N&&m.current.focus()}),[N]);var S=y.default.createElement("span",{className:a.cx(re,w({},a.css(Q()),u&&!p))},t),D=y.default.createElement("span",{className:a.cx(oe,a.css($()))}),M=D;l&&(l.type.isGlyph?M=y.default.cloneElement(l,{key:"glyph",className:a.cx(oe,a.css(Y(),v.icon.base),w({},a.css(W(),v.icon.disabled),c),l.props.className)}):console.error("`Option` instance did not render icon because it is not a known glyph element."));var j,F=u&&!p?y.default.createElement(x.default,{key:"checkmark",className:a.cx(oe,a.css(J(),v.icon.selected),w({},a.css(_(),v.icon.disabled),c))}):D;return j=h?y.default.createElement("span",{className:a.css(X())},y.default.createElement("span",{className:a.css(U())},M,S),F):y.default.createElement(y.default.Fragment,null,F,S),y.default.createElement("li",{role:"option","aria-selected":u,tabIndex:-1,ref:m,className:a.cx(te,a.css(B(),v.text.base),(n={},w(n,a.css("\n &:focus {\n background-color: ".concat(v.background.focused,";\n }\n\n &:hover {\n background-color: ").concat(v.background.hovered,";\n }\n ")),!c),w(n,a.css(L(),v.text.disabled),c),n),o),onClick:d,onFocus:f,onKeyDown:void 0},j)}function ie(e){throw Error("`Option` must be a child of a `Select` instance")}ae.displayName="Option",ie.displayName="Option";var le=v.default.oneOfType([v.default.string,v.default.number]);function ue(){var e=N(["\n color: ",";\n "]);return ue=function(){return e},e}function se(){var e=N(["\n border-bottom: 1px solid ",";\n "]);return se=function(){return e},e}function ce(){var e=N(["\n cursor: default;\n width: 100%;\n padding: 0 12px 2px;\n outline: none;\n overflow-wrap: anywhere;\n font-size: 13px;\n line-height: 16px;\n font-weight: bold;\n"]);return ce=function(){return e},e}function de(){var e=N(["\n padding-top: 8px;\n"]);return de=function(){return e},e}ie.propTypes={children:v.default.oneOfType([le,v.default.arrayOf(v.default.oneOfType([le,v.default.oneOf([!1,null,void 0,""])]))]).isRequired,className:v.default.string,glyph:v.default.element,value:v.default.string,disabled:v.default.bool};var fe=a.css(de()),pe=a.css(ce()),be=l.IdAllocator.create("select-option-group");function he(e){var n=e.className,t=e.label,o=e.children,i=r.useContext(R).mode,l=P[i].option,u=r.useMemo((function(){return be.generate()}),[]);return y.default.createElement("div",{className:a.cx(fe,a.css(se(),l.group.border),n)},y.default.createElement("div",{id:u,className:a.cx(pe,a.css(ue(),l.group.label))},t),y.default.createElement("div",{role:"group","aria-labelledby":u},o))}function ge(e){throw Error("`OptionGroup` must be a child of a `Select` instance")}function ye(e){return null==e||!1===e||""===e}function ve(e,n){y.default.Children.forEach(e,(function(e){l.isComponentType(e,"Option")?n(e):l.isComponentType(e,"OptionGroup")?ve(e.props.children,(function(t){return n(t,e)})):d.isFragment(e)&&ve(e.props.children,n)}))}function me(e,n,t){return y.default.Children.map(e,(function(e){if(l.isComponentType(e,"Option"))return y.default.createElement(ae,n(e));if(l.isComponentType(e,"OptionGroup")){var r=e.props,o=r.children,a=E(r,["children"]);return y.default.createElement(he,O({className:void 0},a),me(o,(function(t){return n(t,e)}),t))}return d.isFragment(e)?me(e.props.children,n,t):(ye(e)||null==t||t(e),null)}))}function xe(e){return null===e?"":void 0!==e.props.value?e.props.value:Array.isArray(e.props.children)?e.props.children.filter((function(e){return!ye(e)})).join(""):e.props.children.toString()}function ke(e,n){var t,r,o;return null!==(t=e.props.disabled)&&void 0!==t&&t||null!==(r=null==n||null===(o=n.props)||void 0===o?void 0:o.disabled)&&void 0!==r&&r}function Ce(e,n,t){return xe(e)===t&&!ke(e,n)}function we(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=n.initialValue,o=n.deps,a=void 0===o?[]:o,i=r.useRef(t);return r.useMemo((function(){return{get current(){return i.current},set current(n){i.current=n,e(n)}}}),[e,i].concat(D(a)))}function Oe(e,n){var t=r.useCallback((function(e,n){Array.isArray(e)?e.forEach(t):"function"==typeof e?e(n):e&&(e.current=n)}),[]);return we(r.useCallback((function(n){return t(e,n)}),[e,t]),{initialValue:n})}he.displayName="OptionGroup",ge.displayName="OptionGroup",ge.propTypes={children:v.default.oneOfType([v.default.element,v.default.arrayOf(v.default.oneOfType([v.default.oneOf([!1,null,void 0,""]),v.default.element]))]).isRequired,className:v.default.string,label:v.default.string.isRequired,disabled:v.default.bool};var Ee=function(e){var n=S(r.useState(e),2),t=n[0];return we(n[1],{initialValue:e,deps:[t]})};function Ne(){var e=N(["\n font-family: ",";\n font-size: ","px;\n max-height: ","px;\n background-color: ",";\n box-shadow: 0 3px 7px 0 ",";\n\n @media only screen and (max-width: ","px) {\n font-size: ","px;\n }\n "]);return Ne=function(){return e},e}function Se(){var e=N(["\n position: relative;\n text-align: left;\n width: 100%;\n border-radius: 3px;\n line-height: 16px;\n list-style: none;\n margin: 0;\n padding: 0;\n overflow: auto;\n"]);return Se=function(){return e},e}var De=a.css(Se()),Me=y.default.forwardRef((function(e,n){var t=e.children,o=e.id,c=e.referenceElement,d=e.onClose,f=e.onFocusPreviousOption,p=e.onFocusNextOption,b=e.onSelectFocusedOption,h=e.className,g=e.usePortal,v=r.useContext(R),x=v.mode,k=v.size,C=v.disabled,w=v.open,O=P[x],E=A[k],N=Oe(n,null),S=r.useCallback((function(e){if(!(e.ctrlKey||e.shiftKey||e.altKey)){var n=!1;switch(e.keyCode){case l.keyMap.Tab:case l.keyMap.Enter:b(e);break;case l.keyMap.Escape:d();break;case l.keyMap.ArrowUp:f();break;case l.keyMap.ArrowDown:p();break;default:n=!0}n||(e.preventDefault(),e.stopPropagation())}}),[d,p,f,b]),D=i.useViewportSize(),M=null===D||null===N.current?0:D.height-N.current.getBoundingClientRect().top-10,j=r.useCallback((function(e){N.current&&N.current.focus(),e.stopPropagation()}),[N]);return y.default.createElement(m.default,{active:w&&!C,spacing:4,align:s.Align.Bottom,justify:s.Justify.Middle,adjustOnMutation:!0,className:h,refEl:c,usePortal:g},y.default.createElement("ul",{role:"listbox",ref:N,tabIndex:-1,onKeyDown:S,onClick:j,className:a.cx(De,a.css(Ne(),u.fontFamilies.default,E.option.text,M,O.option.background.base,O.menu.shadow,u.breakpoints.Desktop,K.text)),id:o},t))}));function je(){var e=N(["\n color: ",";\n "]);return je=function(){return e},e}function Fe(){var e=N(["\n // Displays the active state defined by <Button />\n &:after {\n opacity: 1;\n }\n "]);return Fe=function(){return e},e}function ze(){var e=N(["\n height: ","px;\n width: ","px;\n font-size: ","px;\n color: ",";\n border-color: ",";\n\n @media only screen and (max-width: ","px) {\n height: ","px;\n width: ","px;\n font-size: ","px;\n }\n "]);return ze=function(){return e},e}function Pe(){var e=N(["\n min-width: 16px;\n"]);return Pe=function(){return e},e}function Te(){var e=N(["\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n"]);return Te=function(){return e},e}function Ae(){var e=N(["\n position: relative;\n display: flex;\n align-items: center;\n justify-content: space-between;\n height: 100%;\n width: 100%;\n"]);return Ae=function(){return e},e}function qe(){var e=N(["\n margin-top: 2px;\n\n // reset default Button padding\n > span {\n padding: 0;\n }\n"]);return qe=function(){return e},e}Me.displayName="ListMenu";var He=a.css(qe()),Ie=a.css(Ae()),Ve=a.css(Te()),Ge=a.css(Pe()),Ke=y.default.forwardRef((function(e,n){var t,o=e.children,i=e.value,s=e.text,c=e.name,d=e.deselected,p=(e.readOnly,e.onDeselect),b=e.onFocusFirstOption,h=e.onFocusLastOption,g=e.onClose,v=e.onOpen,m=E(e,["children","value","text","name","deselected","readOnly","onDeselect","onFocusFirstOption","onFocusLastOption","onClose","onOpen"]),x=r.useContext(R),N=x.mode,S=x.size,D=x.open,M=x.disabled,j=Oe(n,null),z=P[N],T=A[S],V=r.useCallback((function(e){if(!M&&!(e.ctrlKey||e.shiftKey||e.altKey)){var n=!1;switch(e.keyCode){case l.keyMap.Tab:g(),n=!0;break;case l.keyMap.Escape:D?g():p(e);break;case l.keyMap.ArrowUp:v(),h();break;case l.keyMap.ArrowDown:v(),b();break;default:n=!0}n||(e.preventDefault(),e.stopPropagation())}}),[M,g,p,b,h,v,D]),G=r.useCallback((function(){D?g():v(),j.current.focus()}),[g,v,D,j]),K=r.useMemo((function(){if(D&&!M)return{focused:!0,active:!0}}),[D,M]);return y.default.createElement(k.default,O({role:"combobox"},m,{ref:j,name:c,value:i,disabled:M,onClick:G,onKeyDown:V,variant:N===F?f.Variant.Dark:f.Variant.Default,darkMode:N===F,forceState:K,className:a.cx(He,a.css(ze(),T.height,T.width,T.text,d?z.text.deselected:z.text.base,D&&!M?z.border.open:z.border.base,u.breakpoints.Desktop,q,H,I),(t={},w(t,a.css(Fe()),D&&!M),w(t,a.css(je(),z.text.disabled),M),t))}),y.default.createElement("div",{className:Ie},y.default.createElement("span",{className:Ve},s),y.default.createElement(C.default,{"aria-hidden":!0,role:"presentation",className:Ge})),o)}));function Re(){var e=N(["\n width: ","px;\n "]);return Re=function(){return e},e}function Le(){var e=N(["\n color: ",";\n font-size: ","px;\n line-height: ","px;\n\n @media only screen and (max-width: ","px) {\n font-size: ","px;\n line-height: ","px;\n }\n "]);return Le=function(){return e},e}function Be(){var e=N(["\n cursor: not-allowed;\n "]);return Be=function(){return e},e}function Ue(){var e=N(["\n color: ",";\n font-size: ","px;\n line-height: ","px;\n\n @media only screen and (max-width: ","px) {\n font-size: ","px;\n line-height: ","px;\n }\n "]);return Ue=function(){return e},e}function Xe(){var e=N(["\n cursor: not-allowed;\n "]);return Xe=function(){return e},e}function _e(){var e=N(["\n margin-bottom: 2px;\n font-weight: bold;\n"]);return _e=function(){return e},e}function Je(){var e=N(["\n font-family: ",";\n display: block;\n"]);return Je=function(){return e},e}Ke.displayName="MenuButton";var We=a.css(Je(),u.fontFamilies.default),Ye=a.css(_e()),$e=l.IdAllocator.create("select");function Qe(e){var n,t,o=e.children,l=e.darkMode,s=void 0!==l&&l,c=e.size,d=void 0===c?T.Default:c,f=e.disabled,p=void 0!==f&&f,b=e.usePortal,h=void 0===b||b,g=e.placeholder,v=void 0===g?"Select":g,m=e.className,x=e.id,k=e.label,C=e.description,O=e.name,E=e.defaultValue,N=e.value,D=e.onChange,M=e.readOnly,j=e["aria-labelledby"],q=r.useMemo((function(){return null!=x?x:$e.generate()}),[x]),H=null!==(n="aria-labelledby")?n:"".concat(q,"-label"),I="".concat(q,"-description"),K="".concat(q,"-menu"),L=S(r.useState(!1),2),B=L[0],U=L[1],X=Ee(null),_=Ee(null),J=s?F:z,W=P[J],Y=A[d],$=r.useMemo((function(){return{mode:J,size:d,open:B,disabled:p}}),[J,d,B,p]);r.useEffect((function(){void 0!==N&&void 0===D&&!0!==M&&console.warn("You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.")}),[D,M,N]),k||j||console.error("For screen-reader accessibility, label or aria-labelledby must be provided to IconButton.");var Q=r.useCallback((function(){U(!0)}),[]),Z=r.useCallback((function(){U(!1),X.current.focus()}),[X]);r.useEffect((function(){if(B){var e=function(e){var n=X.current.contains(e.target)||_.current.contains(e.target);U(n)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}}),[_,X,B]);var ee=r.useMemo((function(){var e=null;return void 0===N&&void 0!==E&&ve(o,(function(n,t){Ce(n,t,E)&&(e=n)})),e}),[o,E,N]),ne=S(r.useState(ee),2),te=ne[0],re=ne[1];r.useEffect((function(){var e;null!==te&&re(null!==(e=function(e,n){var t,r,o,a,i,l,u,s;return ve(e,(function(e){if(e===n)i=n;else if(e.props.children===n.props.children&&e.props.value===n.props.value){var t;null!==(t=l)&&void 0!==t||(l=e)}else if(void 0!==e.props.value&&e.props.value===n.props.value){var r;null!==(r=u)&&void 0!==r||(u=e)}else if(xe(e)===xe(n)){var o;null!==(o=s)&&void 0!==o||(s=e)}})),null!==(t=null!==(r=null!==(o=null!==(a=i)&&void 0!==a?a:l)&&void 0!==o?o:u)&&void 0!==r?r:s)&&void 0!==t?t:null}(o,te))&&void 0!==e?e:ee)}),[o,ee,te]);var oe=r.useMemo((function(){if(void 0!==N){var e=null;return ve(o,(function(n,t){Ce(n,t,N)&&(e=n)})),e}return te}),[o,te,N]),ie=r.useCallback((function(e,n){void 0===N&&re(e),null==D||D(xe(e),n),de(void 0),Z()}),[D,Z,N]),le=r.useCallback((function(e,n){return function(t){t.preventDefault(),t.stopPropagation(),p||n||(ie(e,t),Z())}}),[p,Z,ie]),ue=r.useCallback((function(e){ie(null,e)}),[ie]),se=S(r.useState(),2),ce=se[0],de=se[1],fe=r.useMemo((function(){var e=[null];return ve(o,(function(n,t){ke(n,t)||e.push(n)})),e}),[o]),pe=r.useCallback((function(e){void 0!==ce&&ie(ce,e)}),[ce,ie]),be=r.useCallback((function(){de(null)}),[]),he=r.useCallback((function(){de(fe[fe.length-1])}),[fe]),ge=r.useCallback((function(){if(void 0===ce||0===fe.indexOf(ce))he();else{var e=fe.indexOf(ce)-1;de(fe[e])}}),[fe,ce,he]),ye=r.useCallback((function(){if(void 0===ce||fe.indexOf(ce)===fe.length-1)be();else{var e=fe.indexOf(ce)+1;de(fe[e])}}),[fe,ce,be]),we=r.useCallback((function(e,n){return function(t){t.preventDefault(),t.stopPropagation(),p||n||de(e)}}),[p]),Oe=i.useViewportSize(),Ne=r.useMemo((function(){var e=!1;return ve(o,(function(n){e||(e=void 0!==n.props.glyph)})),e}),[o]),Se=r.useMemo((function(){return null!==Oe&&null!==_.current&&void 0===ce&&B}),[ce,_,B,Oe]),De=r.useMemo((function(){var e=null===oe;return y.default.createElement(ae,{className:void 0,glyph:void 0,selected:e,focused:null===ce,disabled:!1,onClick:le(null,!1),onFocus:we(null,!1),isDeselection:!0,hasGlyphs:!0,triggerScrollIntoView:e&&Se},v)}),[Se,ce,le,we,v,oe]),je=r.useMemo((function(){return me(o,(function(e,n){var t=e===oe,r=ke(e,n);return{className:e.props.className,glyph:e.props.glyph,selected:t,focused:e===ce,disabled:r,children:e.props.children,isDeselection:!1,hasGlyphs:Ne,onClick:le(e,r),onFocus:we(e,r),triggerScrollIntoView:t&&Se}}),(function(){console.error("`Select` instance received child that is not `Option` or `OptionGroup`.")}))}),[Se,o,ce,le,we,Ne,oe]);return y.default.createElement("div",{className:a.cx(w({},a.css(Xe()),p),m)},k&&y.default.createElement("label",{id:H,className:a.cx(We,Ye,a.css(Ue(),p?W.label.disabled:W.label.base,Y.label.text,Y.label.lineHeight,u.breakpoints.Desktop,V.text,V.lineHeight),w({},a.css(Be()),p))},k),C&&y.default.createElement("div",{id:I,className:a.cx(We,a.css(Le(),W.description,Y.description.text,Y.description.lineHeight,u.breakpoints.Desktop,G.text,G.lineHeight))},C),y.default.createElement(R.Provider,{value:$},y.default.createElement(Ke,{ref:X,name:O,readOnly:M,value:xe(oe),text:null!==oe?oe.props.children:v,deselected:null===oe,onDeselect:ue,onOpen:Q,onClose:Z,onFocusFirstOption:be,onFocusLastOption:he,"aria-labelledby":H,"aria-controls":K,"aria-expanded":B,"aria-describedby":I},y.default.createElement(Me,{id:K,referenceElement:X,ref:_,onClose:Z,onSelectFocusedOption:pe,onFocusPreviousOption:ge,onFocusNextOption:ye,usePortal:h,className:a.css(Re(),null===(t=X.current)||void 0===t?void 0:t.clientWidth)},De,je))))}Qe.displayName="Select",Qe.propTypes={label:v.default.string,"aria-labelledby":v.default.string,description:v.default.string,placeholder:v.default.string,className:v.default.string,darkMode:v.default.bool,size:v.default.oneOf(Object.values(T)),disabled:v.default.bool,id:v.default.string,value:v.default.string,defaultValue:v.default.string,onChange:v.default.func,readOnly:v.default.bool},e.Option=ie,e.OptionGroup=ge,e.Select=Qe,e.Size=T,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.js.map
{
"name": "@leafygreen-ui/select",
"version": "1.1.1",
"version": "1.1.2",
"description": "leafyGreen UI Kit Select",

@@ -26,6 +26,6 @@ "main": "./dist/index.js",

"@leafygreen-ui/hooks": "^6.0.0",
"@leafygreen-ui/icon": "^8.0.0",
"@leafygreen-ui/icon": "^8.0.1",
"@leafygreen-ui/lib": "^6.1.2",
"@leafygreen-ui/palette": "^3.1.0",
"@leafygreen-ui/popover": "^7.1.1",
"@leafygreen-ui/popover": "^7.1.2",
"@leafygreen-ui/tokens": "0.5.0",

@@ -32,0 +32,0 @@ "@types/react-is": "^17.0.0",

@@ -65,11 +65,10 @@ # Select

><svg
class="leafygreen-ui-msi0rg"
class="leafygreen-ui-1jr2j1f"
height="16"
width="16"
role="presentation"
aria-hidden="true"
alt=""
viewBox="0 0 16 16"
role="img"
aria-labelledby="CaretDown-7"
>
<title id="CaretDown-7">Caret Down Icon</title>
<desc>Created with Sketch.</desc>
<g

@@ -76,0 +75,0 @@ id="CaretDown-Copy"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc