@leafygreen-ui/select
Advanced tools
Comparing version 10.3.9 to 10.3.10
# @leafygreen-ui/select | ||
## 10.3.10 | ||
### Patch Changes | ||
- e8ef95e6: Updates disabled styles | ||
- Updated dependencies [e8ef95e6] | ||
- @leafygreen-ui/button@21.0.1 | ||
## 10.3.9 | ||
@@ -4,0 +12,0 @@ |
@@ -1,2 +0,2 @@ | ||
import e,{createContext as n,useContext as r,useRef as t,useCallback as o,useEffect as a,useState as i,useMemo as l}from"react";import s from"lodash/isUndefined";import{css as c,cx as d}from"@leafygreen-ui/emotion";import{usePrevious as u,useIdAllocator as p,useAvailableSpace as f,useEventListener as g,useViewportSize as h}from"@leafygreen-ui/hooks";import{Theme as b,createUniqueClassName as m,isComponentType as v,consoleOnce as y,keyMap as x}from"@leafygreen-ui/lib";import w,{Align as O,Justify as k}from"@leafygreen-ui/popover";import{transitionDuration as N,fontFamilies as E,fontWeights as S,breakpoints as j,spacing as C,typeScales as z,focusRing as D,hoverRing as I,BaseFontSize as _}from"@leafygreen-ui/tokens";import{transparentize as P}from"polished";import{palette as L}from"@leafygreen-ui/palette";import{isFragment as A}from"react-is";import T from"prop-types";import{isComponentGlyph as M}from"@leafygreen-ui/icon";import F from"@leafygreen-ui/icon/dist/Checkmark";import B,{Size as G,Variant as V}from"@leafygreen-ui/button";import H from"@leafygreen-ui/icon/dist/CaretDown";import R from"@leafygreen-ui/icon/dist/Warning";import{useDarkMode as W}from"@leafygreen-ui/leafygreen-provider";import{Label as Z,Description as K}from"@leafygreen-ui/typography";function X(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),r.push.apply(r,t)}return r}function q(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?X(Object(r),!0).forEach((function(n){U(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):X(Object(r)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))}))}return e}function U(e,n,r){return(n=function(e){var n=function(e,n){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var t=r.call(e,n||"default");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}(e,"string");return"symbol"==typeof n?n:String(n)}(n))in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},Y.apply(this,arguments)}function $(e,n){if(null==e)return{};var r,t,o=function(e,n){if(null==e)return{};var r,t,o={},a=Object.keys(e);for(t=0;t<a.length;t++)r=a[t],n.indexOf(r)>=0||(o[r]=e[r]);return o}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(t=0;t<a.length;t++)r=a[t],n.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function J(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}function Q(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var t,o,a,i,l=[],s=!0,c=!1;try{if(a=(r=r.call(e)).next,0===n){if(Object(r)!==r)return;s=!1}else for(;!(s=(t=a.call(r)).done)&&(l.push(t.value),l.length!==n);s=!0);}catch(e){c=!0,o=e}finally{try{if(!s&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(c)throw o}}return l}}(e,n)||ne(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 ee(e){return function(e){if(Array.isArray(e))return re(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||ne(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 ne(e,n){if(e){if("string"==typeof e)return re(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?re(e,n):void 0}}function re(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}var te,oe,ae,ie,le,se,ce,de,ue,pe,fe,ge,he,be,me,ve,ye,xe,we={XSmall:"xsmall",Small:"small",Default:"default",Large:"large"},Oe={None:"none",Error:"error"},ke={Trigger:"trigger",Option:"option"},Ne=n({theme:b.Light,size:we.Default,open:!1,disabled:!1}),Ee=(U(te={},b.Light,{menu:{border:L.gray.light2,shadow:P(.75,L.black)},option:{group:{label:L.gray.dark1},background:{base:L.white,hovered:L.gray.light2,focused:L.blue.light3},text:{base:L.gray.dark3,selected:L.blue.base,disabled:L.gray.base,focused:L.blue.dark2},icon:{base:L.gray.dark1,selected:L.blue.base,disabled:L.gray.base},indicator:{focused:L.blue.base}}}),U(te,b.Dark,{menu:{border:L.gray.base,shadow:P(.85,"#000000")},option:{group:{label:L.gray.base},background:{base:L.gray.dark3,hovered:L.gray.dark4,focused:L.blue.dark3},text:{base:L.gray.light2,selected:L.gray.light2,disabled:L.gray.dark2,focused:L.blue.light3},icon:{base:L.gray.base,selected:L.blue.light1,disabled:L.gray.dark1},indicator:{focused:L.blue.light1}}}),te),Se=(U(oe={},we.XSmall,{height:22,text:13,option:{text:13},warningIcon:16}),U(oe,we.Small,{height:28,text:13,option:{text:13},warningIcon:16}),U(oe,we.Default,{height:36,text:13,option:{text:13},warningIcon:16}),U(oe,we.Large,{height:48,text:18,option:{text:16},warningIcon:16}),oe),je=36,Ce=16,ze={text:16,lineHeight:19},De={text:16,lineHeight:22},Ie={text:16},_e=["children","className","glyph","selected","focused","disabled","onClick","onFocus","triggerScrollIntoView","hasGlyphs"],Pe=m("option"),Le=c(ae||(ae=J(["\n display: flex;\n width: 100%;\n outline: none;\n overflow-wrap: anywhere;\n transition: background-color ","ms ease-in-out;\n position: relative;\n padding: 8px 12px;\n\n &:before {\n content: '';\n position: absolute;\n transform: scaleY(0.3);\n top: 7px;\n bottom: 7px;\n left: 0;\n right: 0;\n width: 4px;\n border-radius: 0px 4px 4px 0px;\n opacity: 0;\n transition: all ","ms ease-in-out;\n }\n"])),N.default,N.default),Ae=c(ie||(ie=J(["\n display: flex;\n align-items: center;\n font-family: ",";\n"])),E.default),Te=c(le||(le=J(["\n min-width: 16px;\n margin-right: 6px;\n"]))),Me=c(se||(se=J(["\n ."," {\n &:focus-visible & {\n color: currentColor;\n }\n }\n"])),Pe);function Fe(n){var i,l=n.children,s=n.className,p=n.glyph,f=n.selected,g=n.focused,h=n.disabled,b=n.onClick,m=n.onFocus,v=n.triggerScrollIntoView,y=n.hasGlyphs,x=$(n,_e),w=r(Ne).theme,O=Ee[w].option,k=t(null),N=o((function(){if(null==k.current)return null;var e=k.current,n=null==e?void 0:e.offsetParent;if(!n)return null;n.scrollTop=e.offsetTop+(e.clientHeight-n.clientHeight)/2}),[k]),E=u(v),j=v&&!E;a((function(){j&&N()}),[N,j]);var C=u(g),z=g&&!C;a((function(){z&&k.current.focus()}),[z]);var D=e.createElement("span",{className:d(Ae,U({},c(ce||(ce=J(["\n font-weight: ",";\n "])),S.bold),f))},l),I=e.createElement("span",{className:d(Te,c(de||(de=J(["\n height: 100%;\n "]))))}),_=I;p&&(M(p)?_=e.cloneElement(p,{key:"glyph",className:d(Te,c(ue||(ue=J(["\n color: ",";\n "])),O.icon.base),Me,U({},c(pe||(pe=J(["\n color: ",";\n "])),O.icon.disabled),h),p.props.className)}):console.error("`Option` instance did not render icon because it is not a known glyph element."));var P,L=f?e.createElement(F,{key:"checkmark",className:d(Te,c(fe||(fe=J(["\n color: ",";\n "])),O.icon.selected),Me,U({},c(ge||(ge=J(["\n color: ",";\n "])),O.icon.disabled),h))}):I;return P=y?e.createElement("span",{className:c(he||(he=J(["\n display: flex;\n justify-content: space-between;\n width: 100%;\n "])))},e.createElement("span",{className:c(be||(be=J(["\n display: flex;\n "])))},_,D),L):e.createElement(e.Fragment,null,L,D),e.createElement("li",Y({},x,{role:"option","aria-selected":f,tabIndex:-1,ref:k,className:d(Pe,Le,c(me||(me=J(["\n cursor: pointer;\n color: ",";\n "])),O.text.base),(i={},U(i,c(ve||(ve=J(["\n &:hover {\n background-color: ",";\n }\n "])),O.background.hovered),!h),U(i,c(ye||(ye=J(["\n &:focus-visible {\n color: ",";\n background-color: ",";\n\n &:before {\n opacity: 1;\n transform: scaleY(1);\n background-color: ",";\n }\n }\n "])),O.text.focused,O.background.focused,O.indicator.focused),!h),U(i,c(xe||(xe=J(["\n cursor: not-allowed;\n color: ",";\n "])),O.text.disabled),h),i),s),onClick:b,onFocus:m,onKeyDown:void 0}),P)}function Be(e){throw Error("`Option` must be a child of a `Select` instance")}Fe.displayName="Option",Be.displayName="Option",Be.propTypes={children:T.node.isRequired,className:T.string,glyph:T.element,value:T.string,disabled:T.bool};var Ge,Ve,He,Re=["className","label","children"],We=c(Ge||(Ge=J(["\n padding: 8px 0;\n"]))),Ze=c(Ve||(Ve=J(["\n cursor: default;\n width: 100%;\n padding: 0 12px 2px;\n outline: none;\n overflow-wrap: anywhere;\n font-size: 12px;\n line-height: 16px;\n font-weight: ",";\n text-transform: uppercase;\n letter-spacing: 0.4px;\n"])),S.bold);function Ke(n){var t=n.className,o=n.label,a=n.children,i=$(n,Re),l=r(Ne).theme,s=Ee[l].option,u=p({prefix:"select-option-group"});return e.createElement("div",Y({className:d(We,t)},i),e.createElement("div",{id:u,className:d(Ze,c(He||(He=J(["\n color: ",";\n "])),s.group.label))},o),e.createElement("div",{role:"group","aria-labelledby":u},a))}function Xe(e){throw Error("`OptionGroup` must be a child of a `Select` instance")}Ke.displayName="OptionGroup",Xe.displayName="OptionGroup",Xe.propTypes={children:T.oneOfType([T.element,T.arrayOf(T.oneOfType([T.oneOf([!1,null,void 0,""]),T.element]))]).isRequired,className:T.string,label:T.string.isRequired,disabled:T.bool};var qe=["children"],Ue="@media only screen and (max-width: ".concat(j.Tablet,"px) and (hover: none)"),Ye="".concat(Ue," and (pointer: coarse), ").concat(Ue," and (pointer: none)");function $e(e){return null==e||!1===e||""===e}function Je(n,r){e.Children.forEach(n,(function(e){v(e,"Option")?r(e):v(e,"OptionGroup")?Je(e.props.children,(function(n){return r(n,e)})):A(e)&&Je(e.props.children,r)}))}function Qe(n,r,t){return e.Children.toArray(n).every((function(e){return v(e,"Option")}))||e.Children.toArray(n).every((function(e){return v(e,"OptionGroup")}))||y.warn("LeafyGreen Select: Combining grouped and ungrouped Select Options can cause styling issues"),e.Children.map(n,(function(n){if(v(n,"Option"))return e.createElement(Fe,r(n));if(v(n,"OptionGroup")){var o=n.props,a=o.children,i=$(o,qe);return e.createElement(Ke,Y({className:void 0},i),Qe(a,(function(e){return r(e,n)}),t))}return A(n)?Qe(n.props.children,r,t):($e(n)||null==t||t(n),null)}))}function en(e){return null===e?"":void 0!==e.props.value?e.props.value:Array.isArray(e.props.children)?e.props.children.filter((function(e){return!$e(e)})).join(""):e.props.children?e.props.children.toString():""}function nn(e,n){var r,t,o;return null!==(r=e.props.disabled)&&void 0!==r&&r||null!==(t=null==n||null===(o=n.props)||void 0===o?void 0:o.disabled)&&void 0!==t&&t}function rn(e,n,r){return en(e)===r&&!nn(e,n)}function tn(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.initialValue,o=n.deps,a=void 0===o?[]:o,i=t(r);return l((function(){return{get current(){return i.current},set current(n){i.current=n,e(n)}}}),[e,i].concat(ee(a)))}function on(e,n){var r=o((function(e,n){Array.isArray(e)?e.forEach(r):"function"==typeof e?e(n):e&&(e.current=n)}),[]);return tn(o((function(n){return r(e,n)}),[e,r]),{initialValue:n})}var an,ln,sn,cn,dn=function(e){var n=Q(i(e),2),r=n[0];return tn(n[1],{initialValue:e,deps:[r]})},un=m("select-popover"),pn=c(an||(an=J(["\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"]))),fn=c(ln||(ln=J(["\n width: max-content;\n"]))),gn=function(e,n){var r=Se[n],t=Ee[e];return d(c(sn||(sn=J(["\n font-family: ",";\n font-size: ","px;\n min-height: ","px;\n background-color: ",";\n border-radius: 12px;\n box-shadow: 0 4px 7px 0 ",";\n padding: 8px 0;\n "])),E.default,r.option.text,r.height,t.option.background.base,t.menu.shadow))},hn=e.forwardRef((function(n,t){var a=n.children,i=n.id,l=n.referenceElement,u=n.className,p=n.labelId,g=n.dropdownWidthBasis,h=n.usePortal,b=void 0===h||h,m=n.portalContainer,v=n.scrollContainer,y=n.portalClassName,x=n.popoverZIndex,N=r(Ne),E=N.theme,S=N.size,j=N.disabled,C=N.open,z=on(t,null),D=f(l,8),I=s(D)?"unset":"".concat(Math.min(D,274),"px"),_=o((function(e){z.current&&z.current.focus(),e.stopPropagation()}),[z]),P=q({popoverZIndex:x},b?{usePortal:b,portalClassName:y,portalContainer:m,scrollContainer:v}:{usePortal:b});return e.createElement(w,Y({active:C&&!j,spacing:6,align:O.Bottom,justify:k.Start,adjustOnMutation:!0,className:d(un,u,U({},fn,g===ke.Option)),refEl:l},P),e.createElement("ul",{"aria-labelledby":p,role:"listbox",ref:z,tabIndex:-1,onClick:_,className:d(pn,gn(E,S),c(cn||(cn=J(["\n max-height: ",";\n "," {\n font-size: ","px;\n }\n "])),I,Ye,Ie.text)),id:i},a))}));hn.displayName="ListMenu";var bn,mn,vn,yn,xn,wn,On,kn,Nn,En,Sn,jn,Cn,zn,Dn,In,_n,Pn,Ln,An,Tn,Mn,Fn,Bn,Gn,Vn,Hn,Rn,Wn,Zn=["children","value","text","name","deselected","readOnly","onClose","onOpen","errorMessage","state","baseFontSize","__INTERNAL__menuButtonSlot__"],Kn=m("select-menu"),Xn=c(bn||(bn=J(["\n // Override button defaults\n font-weight: ",";\n > *:last-child {\n grid-template-columns: 1fr 16px;\n justify-content: flex-start;\n\n > svg {\n justify-self: right;\n width: 16px;\n height: 16px;\n }\n }\n"])),S.regular),qn=(U(wn={},we.Default,c(mn||(mn=J(["\n > *:last-child {\n padding: 0 12px;\n }\n "])))),U(wn,we.Large,c(vn||(vn=J(["\n > *:last-child {\n padding: 0 12px 0 ","px;\n }\n "])),C[3])),U(wn,we.Small,c(yn||(yn=J(["\n > *:last-child {\n padding: 0 ","px 0 10px;\n }\n "])),C[2])),U(wn,we.XSmall,c(xn||(xn=J(["\n text-transform: none;\n font-size: ","px;\n line-height: ","px;\n > *:last-child {\n padding: 0 ","px 0 10px;\n }\n "])),z.body1.fontSize,z.body1.lineHeight,C[1])),wn),Un=(U(Nn={},b.Light,c(On||(On=J(["\n background-color: ",";\n // Override button default color\n > *:last-child {\n > svg {\n color: ",";\n }\n }\n "])),L.white,L.gray.dark2)),U(Nn,b.Dark,c(kn||(kn=J(["\n border-color: ",";\n background-color: ",";\n color: ",";\n\n // Override button default color\n > *:last-child {\n > svg {\n color: ",";\n }\n }\n\n &:hover,\n &:active,\n &:focus {\n background-color: ",";\n color: ",";\n }\n "])),L.gray.base,L.gray.dark4,L.gray.light3,L.gray.light1,L.gray.dark4,L.gray.light3)),Nn),Yn=(U(jn={},b.Light,c(En||(En=J(["\n &:focus-visible {\n box-shadow: ",";\n border-color: rgba(255, 255, 255, 0);\n }\n "])),D.light.input)),U(jn,b.Dark,c(Sn||(Sn=J(["\n &:focus-visible {\n background-color: ",";\n box-shadow: ",";\n border-color: rgba(255, 255, 255, 0);\n }\n "])),L.gray.dark4,D.dark.input)),jn),$n=(U(Dn={},b.Light,c(Cn||(Cn=J(["\n color: ",";\n "])),L.gray.dark1)),U(Dn,b.Dark,c(zn||(zn=J(["\n color: ",";\n\n &:hover,\n &:active,\n &:focus {\n color: ",";\n }\n "])),L.gray.light1,L.gray.light1)),Dn),Jn=c(In||(In=J(["\n &:disabled {\n cursor: not-allowed;\n pointer-events: unset;\n box-shadow: unset;\n\n &:active {\n pointer-events: none;\n }\n }\n"]))),Qn=(U(Ln={},b.Light,d(Jn,c(_n||(_n=J(["\n &:disabled {\n background-color: ",";\n color: ",";\n\n > *:last-child {\n > svg {\n color: ",";\n }\n }\n }\n "])),L.gray.light2,L.gray.base,L.gray.base))),U(Ln,b.Dark,d(Jn,c(Pn||(Pn=J(["\n &:disabled {\n background-color: ",";\n color: ",";\n border-color: ",";\n\n > *:last-child {\n > svg {\n color: ",";\n }\n }\n }\n "])),L.gray.dark3,L.gray.dark2,L.gray.dark2,L.gray.dark2))),Ln),er=c(An||(An=J(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n flex-grow: 1;\n gap: ","px;\n overflow: hidden;\n"])),C[1]),nr=c(Tn||(Tn=J(["\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n max-width: 100%;\n"]))),rr=(U(Mn={},b.Light,L.red.base),U(Mn,b.Dark,L.red.light1),Mn),tr=(U(Gn={},b.Light,c(Fn||(Fn=J(["\n border-color: ",";\n background-color: ",";\n\n &:hover,\n &:active {\n box-shadow: ",";\n }\n "])),rr[b.Light],L.white,I.light.red)),U(Gn,b.Dark,c(Bn||(Bn=J(["\n border-color: ",";\n\n &:hover,\n &:active {\n border-color: ",";\n box-shadow: ",";\n }\n "])),rr[b.Dark],rr[b.Dark],I.dark.red)),Gn),or=e.forwardRef((function(n,t){var a,i,l=n.children,s=n.value,u=n.text,p=n.name,f=n.deselected;n.readOnly;var g=n.onClose,h=n.onOpen,m=n.errorMessage,v=n.state,y=n.baseFontSize,x=n.__INTERNAL__menuButtonSlot__,w=$(n,Zn),O=r(Ne),k=O.theme,N=O.open,E=O.size,S=O.disabled,j=on(t,null),C=Se[E],z=o((function(){N?g():h(),j.current.focus()}),[g,h,N,j]),D=x||B,I=x?"":d(Xn,Un[k],qn[E],Yn[k],(U(a={},$n[k],f),U(a,Qn[k],S),U(a,tr[k],v===Oe.Error&&!!m),U(a,c(Vn||(Vn=J(["\n letter-spacing: initial;\n "]))),E===G.XSmall),a),c(Hn||(Hn=J(["\n width: 100%;\n "," {\n height: ","px;\n font-size: ","px;\n }\n "])),Ye,je,Ce)),_=null!==(i=w["data-testid"])&&void 0!==i?i:"leafygreen-ui-select-menubutton";return e.createElement(D,Y({},w,{ref:j,name:p,value:s,disabled:S,onClick:z,variant:V.Default,darkMode:k===b.Dark,rightGlyph:e.createElement(H,null),size:E,"data-testid":_,className:d(I,U({},c(Rn||(Rn=J(["\n font-size: ","px;\n "])),y),E===G.Default))}),e.createElement("div",{className:er},e.createElement("div",{className:d(Kn,nr)},u),v===Oe.Error&&m&&e.createElement(R,{role:"presentation",className:c(Wn||(Wn=J(["\n color: ",";\n "])),rr[k]),size:C.warningIcon})),l)}));or.displayName="MenuButton";var ar,ir,lr,sr,cr,dr,ur,pr,fr,gr,hr,br,mr=["children","darkMode","size","disabled","allowDeselect","usePortal","placeholder","errorMessage","state","dropdownWidthBasis","baseFontSize","id","aria-labelledby","aria-label","className","label","description","name","defaultValue","value","onChange","readOnly","portalContainer","scrollContainer","portalClassName","popoverZIndex","__INTERNAL__menuButtonSlot__"],vr=c(ar||(ar=J(["\n display: flex;\n flex-direction: column;\n margin-bottom: ","px;\n"])),C[1]),yr=c(ir||(ir=J(["\n display: flex;\n flex-direction: column;\n"]))),xr=c(lr||(lr=J(["\n font-size: ","px;\n line-height: ","px;\n"])),z.large.fontSize,z.large.lineHeight),wr=function(e){var n=e.darkMode,r=e.sizeSet;return c(sr||(sr=J(["\n font-family: ",";\n color: ",";\n font-size: ","px;\n margin-top: ","px;\n padding-left: 2px;\n transition: color ","ms ease-in-out;\n transition-delay: ","ms;\n"])),E.default,n?L.red.light1:L.red.base,r.text,C[1],N.faster,N.faster)};function Or(n){var r,t,s,u=n.children,f=n.darkMode,b=n.size,m=void 0===b?we.Default:b,v=n.disabled,y=void 0!==v&&v,w=n.allowDeselect,O=void 0===w||w,k=n.usePortal,N=void 0===k||k,E=n.placeholder,S=void 0===E?"Select":E,j=n.errorMessage,C=void 0===j?"":j,z=n.state,D=void 0===z?Oe.None:z,I=n.dropdownWidthBasis,P=void 0===I?ke.Trigger:I,L=n.baseFontSize,A=void 0===L?_.Body1:L,T=n.id,M=n["aria-labelledby"],F=n["aria-label"],B=n.className,G=n.label,V=n.description,H=n.name,R=n.defaultValue,X=n.value,ee=n.onChange,ne=n.readOnly,re=n.portalContainer,te=n.scrollContainer,oe=n.portalClassName,ae=n.popoverZIndex,ie=n.__INTERNAL__menuButtonSlot__,le=$(n,mr),se=p({prefix:"select",id:T}),ce=l((function(){return F&&!G?void 0:null!=M?M:"".concat(se,"-label")}),[M,F,G,se]);G||M||F||console.error("For screen-reader accessibility, label, aria-label, or aria-labelledby must be provided to Select.");var de=W(f),ue=de.darkMode,pe=de.theme,fe="".concat(se,"-description"),ge="".concat(se,"-menu"),he=Q(i(!1),2),be=he[0],me=he[1],ve=dn(null),ye=p({prefix:"select"}),xe=dn(null),Ee=Se[m],je=l((function(){return{theme:pe,size:m,open:be,disabled:y}}),[pe,m,be,y]);a((function(){void 0!==X&&void 0===ee&&!0!==ne&&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`.")}),[ee,ne,X]);var Ce=o((function(){me(!0)}),[]),Ie=o((function(){me(!1),ve.current.focus()}),[ve]);a((function(){if(be){var e=function(e){var n=ve.current.contains(e.target)||xe.current.contains(e.target);me(n)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}}),[xe,ve,be]);var _e=l((function(){var e=null;return void 0===X&&void 0!==R&&Je(u,(function(n,r){rn(n,r,R)&&(e=n)})),e}),[u,R,X]),Pe=Q(i(_e),2),Le=Pe[0],Ae=Pe[1];a((function(){var e;null!==Le&&Ae(null!==(e=function(e,n){var r,t,o,a,i,l,s,c;return Je(e,(function(e){if(e===n)i=n;else if(e.props.children===n.props.children&&e.props.value===n.props.value){var r;null!==(r=l)&&void 0!==r||(l=e)}else if(void 0!==e.props.value&&e.props.value===n.props.value){var t;null!==(t=s)&&void 0!==t||(s=e)}else if(en(e)===en(n)){var o;null!==(o=c)&&void 0!==o||(c=e)}})),null!==(r=null!==(t=null!==(o=null!==(a=i)&&void 0!==a?a:l)&&void 0!==o?o:s)&&void 0!==t?t:c)&&void 0!==r?r:null}(u,Le))&&void 0!==e?e:_e)}),[u,_e,Le]);var Te=l((function(){if(void 0!==X){var e=null;return Je(u,(function(n,r){rn(n,r,X)&&(e=n)})),e}return Le}),[u,Le,X]),Me=o((function(e,n){void 0===X&&Ae(e),null==ee||ee(en(e),n),He(void 0),Ie()}),[ee,Ie,X]),Be=o((function(e,n){return function(r){r.preventDefault(),r.stopPropagation(),y||n||(Me(e,r),Ie())}}),[y,Ie,Me]),Ge=Q(i(),2),Ve=Ge[0],He=Ge[1],Re=l((function(){var e=[];return O&&e.push(null),Je(u,(function(n,r){nn(n,r)||e.push(n)})),e}),[u,O]),We=o((function(e){void 0!==Ve&&Me(Ve,e)}),[Ve,Me]),Ze=o((function(){He(Re[0])}),[Re]),Ke=o((function(){He(Re[Re.length-1])}),[Re]),Xe=o((function(){if(void 0===Ve||0===Re.indexOf(Ve))Ke();else{var e=Re.indexOf(Ve)-1;He(Re[e])}}),[Re,Ve,Ke]),qe=o((function(){if(void 0===Ve||Re.indexOf(Ve)===Re.length-1)Ze();else{var e=Re.indexOf(Ve)+1;He(Re[e])}}),[Re,Ve,Ze]),Ue=o((function(e,n){return function(r){r.preventDefault(),r.stopPropagation(),y||n||He(e)}}),[y]),$e=o((function(e){var n,r;if(!(e.ctrlKey||e.shiftKey||e.altKey)){var t=null===(n=xe.current)||void 0===n?void 0:n.contains(document.activeElement),o=null===(r=ve.current)||void 0===r?void 0:r.contains(document.activeElement);if(o||t)switch(e.keyCode){case x.Tab:case x.Escape:Ie(),He(void 0);break;case x.Enter:case x.Space:be&&!o&&e.preventDefault(),We(e);break;case x.ArrowUp:!be&&o&&Ce(),e.preventDefault(),Xe();break;case x.ArrowDown:!be&&o&&Ce(),e.preventDefault(),qe()}}}),[xe,ve,Ie,be,We,Xe,qe,Ce]);g("keydown",$e);var tn=h(),on=l((function(){var e=!1;return Je(u,(function(n){e||(e=void 0!==n.props.glyph)})),e}),[u]),an=l((function(){return null!==tn&&null!==xe.current&&void 0===Ve&&be}),[Ve,xe,be,tn]),ln=l((function(){var n=null===Te;return e.createElement(Fe,{className:void 0,glyph:void 0,selected:n,focused:null===Ve,disabled:!1,onClick:Be(null,!1),onFocus:Ue(null,!1),hasGlyphs:!1,triggerScrollIntoView:n&&an},S)}),[an,Ve,Be,Ue,S,Te]),sn=l((function(){return Qe(u,(function(e,n){var r=e===Te,t=nn(e,n);return q(q({},e.props),{},{className:e.props.className,glyph:e.props.glyph,selected:r,focused:e===Ve,disabled:t,children:e.props.children,hasGlyphs:on,onClick:Be(e,t),onFocus:Ue(e,t),triggerScrollIntoView:r&&an})}),(function(){console.error("`Select` instance received child that is not `Option` or `OptionGroup`.")}))}),[an,u,Ve,Be,Ue,on,Te]),cn=q({popoverZIndex:ae},N?{usePortal:N,portalClassName:oe,portalContainer:re,scrollContainer:te}:{usePortal:N});return e.createElement("div",{className:d(yr,B)},(G||V)&&e.createElement("div",{className:vr},G&&e.createElement(Z,{htmlFor:ye,id:ce,darkMode:ue,disabled:y,className:d((r={},U(r,xr,m===we.Large),U(r,c(cr||(cr=J(["\n font-size: ","px;\n line-height: 20px;\n "])),A),m===we.Default),r),c(dr||(dr=J(["\n // Prevent hover state from showing when hovering label\n pointer-events: none;\n "]))),c(ur||(ur=J(["\n "," {\n font-size: ","px;\n line-height: ","px;\n }\n "])),Ye,ze.text,ze.lineHeight))},G),V&&e.createElement(K,{id:fe,darkMode:ue,disabled:y,className:d((t={},U(t,xr,m===we.Large),U(t,c(pr||(pr=J(["\n font-size: ","px;\n line-height: 20px;\n "])),A),m===we.Default),t),c(fr||(fr=J(["\n "," {\n font-size: ","px;\n line-height: ","px;\n }\n "])),Ye,De.text,De.lineHeight))},V)),e.createElement(Ne.Provider,{value:je},e.createElement(or,Y({},le,{id:ye,ref:ve,name:H,readOnly:ne,value:en(Te),text:null!==Te?Te.props.children:S,deselected:null===Te,onOpen:Ce,onClose:Ie,"aria-labelledby":ce,"aria-label":G||M?void 0:F,"aria-controls":ge,"aria-expanded":be,"aria-describedby":fe,"aria-invalid":D===Oe.Error,"aria-disabled":y,errorMessage:C,state:D,baseFontSize:A,__INTERNAL__menuButtonSlot__:ie}),e.createElement(hn,Y({labelId:ce,id:ge,referenceElement:ve,ref:xe,className:d(U({},c(gr||(gr=J(["\n width: ","px;\n "])),null===(s=ve.current)||void 0===s?void 0:s.clientWidth),P===ke.Trigger)),dropdownWidthBasis:P},cn),O&&ln,sn))),D===Oe.Error&&C&&e.createElement("span",{className:d(wr({darkMode:ue,sizeSet:Ee}),c(hr||(hr=J(["\n "," {\n font-size: ","px;\n line-height: ","px;\n }\n "])),Ye,De.text,De.lineHeight),U({},c(br||(br=J(["\n // Hide error text when menu is open,\n // so it doesn't peek around the menu corner\n color: transparent;\n "]))),be))},C))}Or.displayName="Select",Or.propTypes={label:T.string,"aria-labelledby":T.string,"aria-label":T.string,description:T.string,placeholder:T.string,className:T.string,darkMode:T.bool,size:T.oneOf(Object.values(we)),disabled:T.bool,id:T.string,value:T.string,defaultValue:T.string,onChange:T.func,readOnly:T.bool,errorMessage:T.string,state:T.oneOf(Object.values(Oe)),allowDeselect:T.bool,baseFontSize:T.oneOf(Object.values(_)),dropdownWidthBasis:T.oneOf(Object.values(ke))};export{ke as DropdownWidthBasis,Be as Option,Xe as OptionGroup,Or as Select,we as Size,Oe as State,Kn as menuButtonTextClassName,un as popoverClassName}; | ||
import e,{createContext as n,useContext as r,useRef as t,useCallback as o,useEffect as a,useState as i,useMemo as l}from"react";import s from"lodash/isUndefined";import{css as c,cx as d}from"@leafygreen-ui/emotion";import{usePrevious as u,useIdAllocator as p,useAvailableSpace as f,useEventListener as g,useViewportSize as h}from"@leafygreen-ui/hooks";import{Theme as b,createUniqueClassName as m,isComponentType as v,consoleOnce as y,keyMap as x}from"@leafygreen-ui/lib";import w,{Align as O,Justify as k}from"@leafygreen-ui/popover";import{transitionDuration as N,fontFamilies as E,fontWeights as S,breakpoints as j,spacing as C,typeScales as z,focusRing as D,hoverRing as I,BaseFontSize as _}from"@leafygreen-ui/tokens";import{transparentize as P}from"polished";import{palette as L}from"@leafygreen-ui/palette";import{isFragment as A}from"react-is";import T from"prop-types";import{isComponentGlyph as M}from"@leafygreen-ui/icon";import F from"@leafygreen-ui/icon/dist/Checkmark";import B,{Size as G,Variant as V}from"@leafygreen-ui/button";import H from"@leafygreen-ui/icon/dist/CaretDown";import R from"@leafygreen-ui/icon/dist/Warning";import{useDarkMode as W}from"@leafygreen-ui/leafygreen-provider";import{Label as Z,Description as K}from"@leafygreen-ui/typography";function X(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),r.push.apply(r,t)}return r}function q(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?X(Object(r),!0).forEach((function(n){U(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):X(Object(r)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))}))}return e}function U(e,n,r){return(n=function(e){var n=function(e,n){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var t=r.call(e,n||"default");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}(e,"string");return"symbol"==typeof n?n:String(n)}(n))in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},Y.apply(this,arguments)}function $(e,n){if(null==e)return{};var r,t,o=function(e,n){if(null==e)return{};var r,t,o={},a=Object.keys(e);for(t=0;t<a.length;t++)r=a[t],n.indexOf(r)>=0||(o[r]=e[r]);return o}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(t=0;t<a.length;t++)r=a[t],n.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function J(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}function Q(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var t,o,a,i,l=[],s=!0,c=!1;try{if(a=(r=r.call(e)).next,0===n){if(Object(r)!==r)return;s=!1}else for(;!(s=(t=a.call(r)).done)&&(l.push(t.value),l.length!==n);s=!0);}catch(e){c=!0,o=e}finally{try{if(!s&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(c)throw o}}return l}}(e,n)||ne(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 ee(e){return function(e){if(Array.isArray(e))return re(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||ne(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 ne(e,n){if(e){if("string"==typeof e)return re(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?re(e,n):void 0}}function re(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}var te,oe,ae,ie,le,se,ce,de,ue,pe,fe,ge,he,be,me,ve,ye,xe,we={XSmall:"xsmall",Small:"small",Default:"default",Large:"large"},Oe={None:"none",Error:"error"},ke={Trigger:"trigger",Option:"option"},Ne=n({theme:b.Light,size:we.Default,open:!1,disabled:!1}),Ee=(U(te={},b.Light,{menu:{border:L.gray.light2,shadow:P(.75,L.black)},option:{group:{label:L.gray.dark1},background:{base:L.white,hovered:L.gray.light2,focused:L.blue.light3},text:{base:L.gray.dark3,selected:L.blue.base,disabled:L.gray.base,focused:L.blue.dark2},icon:{base:L.gray.dark1,selected:L.blue.base,disabled:L.gray.base},indicator:{focused:L.blue.base}}}),U(te,b.Dark,{menu:{border:L.gray.base,shadow:P(.85,"#000000")},option:{group:{label:L.gray.base},background:{base:L.gray.dark3,hovered:L.gray.dark4,focused:L.blue.dark3},text:{base:L.gray.light2,selected:L.gray.light2,disabled:L.gray.dark2,focused:L.blue.light3},icon:{base:L.gray.base,selected:L.blue.light1,disabled:L.gray.dark1},indicator:{focused:L.blue.light1}}}),te),Se=(U(oe={},we.XSmall,{height:22,text:13,option:{text:13},warningIcon:16}),U(oe,we.Small,{height:28,text:13,option:{text:13},warningIcon:16}),U(oe,we.Default,{height:36,text:13,option:{text:13},warningIcon:16}),U(oe,we.Large,{height:48,text:18,option:{text:16},warningIcon:16}),oe),je=36,Ce=16,ze={text:16,lineHeight:19},De={text:16,lineHeight:22},Ie={text:16},_e=["children","className","glyph","selected","focused","disabled","onClick","onFocus","triggerScrollIntoView","hasGlyphs"],Pe=m("option"),Le=c(ae||(ae=J(["\n display: flex;\n width: 100%;\n outline: none;\n overflow-wrap: anywhere;\n transition: background-color ","ms ease-in-out;\n position: relative;\n padding: 8px 12px;\n\n &:before {\n content: '';\n position: absolute;\n transform: scaleY(0.3);\n top: 7px;\n bottom: 7px;\n left: 0;\n right: 0;\n width: 4px;\n border-radius: 0px 4px 4px 0px;\n opacity: 0;\n transition: all ","ms ease-in-out;\n }\n"])),N.default,N.default),Ae=c(ie||(ie=J(["\n display: flex;\n align-items: center;\n font-family: ",";\n"])),E.default),Te=c(le||(le=J(["\n min-width: 16px;\n margin-right: 6px;\n"]))),Me=c(se||(se=J(["\n ."," {\n &:focus-visible & {\n color: currentColor;\n }\n }\n"])),Pe);function Fe(n){var i,l=n.children,s=n.className,p=n.glyph,f=n.selected,g=n.focused,h=n.disabled,b=n.onClick,m=n.onFocus,v=n.triggerScrollIntoView,y=n.hasGlyphs,x=$(n,_e),w=r(Ne).theme,O=Ee[w].option,k=t(null),N=o((function(){if(null==k.current)return null;var e=k.current,n=null==e?void 0:e.offsetParent;if(!n)return null;n.scrollTop=e.offsetTop+(e.clientHeight-n.clientHeight)/2}),[k]),E=u(v),j=v&&!E;a((function(){j&&N()}),[N,j]);var C=u(g),z=g&&!C;a((function(){z&&k.current.focus()}),[z]);var D=e.createElement("span",{className:d(Ae,U({},c(ce||(ce=J(["\n font-weight: ",";\n "])),S.bold),f))},l),I=e.createElement("span",{className:d(Te,c(de||(de=J(["\n height: 100%;\n "]))))}),_=I;p&&(M(p)?_=e.cloneElement(p,{key:"glyph",className:d(Te,c(ue||(ue=J(["\n color: ",";\n "])),O.icon.base),Me,U({},c(pe||(pe=J(["\n color: ",";\n "])),O.icon.disabled),h),p.props.className)}):console.error("`Option` instance did not render icon because it is not a known glyph element."));var P,L=f?e.createElement(F,{key:"checkmark",className:d(Te,c(fe||(fe=J(["\n color: ",";\n "])),O.icon.selected),Me,U({},c(ge||(ge=J(["\n color: ",";\n "])),O.icon.disabled),h))}):I;return P=y?e.createElement("span",{className:c(he||(he=J(["\n display: flex;\n justify-content: space-between;\n width: 100%;\n "])))},e.createElement("span",{className:c(be||(be=J(["\n display: flex;\n "])))},_,D),L):e.createElement(e.Fragment,null,L,D),e.createElement("li",Y({},x,{role:"option","aria-selected":f,tabIndex:-1,ref:k,className:d(Pe,Le,c(me||(me=J(["\n cursor: pointer;\n color: ",";\n "])),O.text.base),(i={},U(i,c(ve||(ve=J(["\n &:hover {\n background-color: ",";\n }\n "])),O.background.hovered),!h),U(i,c(ye||(ye=J(["\n &:focus-visible {\n color: ",";\n background-color: ",";\n\n &:before {\n opacity: 1;\n transform: scaleY(1);\n background-color: ",";\n }\n }\n "])),O.text.focused,O.background.focused,O.indicator.focused),!h),U(i,c(xe||(xe=J(["\n cursor: not-allowed;\n color: ",";\n "])),O.text.disabled),h),i),s),onClick:b,onFocus:m,onKeyDown:void 0}),P)}function Be(e){throw Error("`Option` must be a child of a `Select` instance")}Fe.displayName="Option",Be.displayName="Option",Be.propTypes={children:T.node.isRequired,className:T.string,glyph:T.element,value:T.string,disabled:T.bool};var Ge,Ve,He,Re=["className","label","children"],We=c(Ge||(Ge=J(["\n padding: 8px 0;\n"]))),Ze=c(Ve||(Ve=J(["\n cursor: default;\n width: 100%;\n padding: 0 12px 2px;\n outline: none;\n overflow-wrap: anywhere;\n font-size: 12px;\n line-height: 16px;\n font-weight: ",";\n text-transform: uppercase;\n letter-spacing: 0.4px;\n"])),S.bold);function Ke(n){var t=n.className,o=n.label,a=n.children,i=$(n,Re),l=r(Ne).theme,s=Ee[l].option,u=p({prefix:"select-option-group"});return e.createElement("div",Y({className:d(We,t)},i),e.createElement("div",{id:u,className:d(Ze,c(He||(He=J(["\n color: ",";\n "])),s.group.label))},o),e.createElement("div",{role:"group","aria-labelledby":u},a))}function Xe(e){throw Error("`OptionGroup` must be a child of a `Select` instance")}Ke.displayName="OptionGroup",Xe.displayName="OptionGroup",Xe.propTypes={children:T.oneOfType([T.element,T.arrayOf(T.oneOfType([T.oneOf([!1,null,void 0,""]),T.element]))]).isRequired,className:T.string,label:T.string.isRequired,disabled:T.bool};var qe=["children"],Ue="@media only screen and (max-width: ".concat(j.Tablet,"px) and (hover: none)"),Ye="".concat(Ue," and (pointer: coarse), ").concat(Ue," and (pointer: none)");function $e(e){return null==e||!1===e||""===e}function Je(n,r){e.Children.forEach(n,(function(e){v(e,"Option")?r(e):v(e,"OptionGroup")?Je(e.props.children,(function(n){return r(n,e)})):A(e)&&Je(e.props.children,r)}))}function Qe(n,r,t){return e.Children.toArray(n).every((function(e){return v(e,"Option")}))||e.Children.toArray(n).every((function(e){return v(e,"OptionGroup")}))||y.warn("LeafyGreen Select: Combining grouped and ungrouped Select Options can cause styling issues"),e.Children.map(n,(function(n){if(v(n,"Option"))return e.createElement(Fe,r(n));if(v(n,"OptionGroup")){var o=n.props,a=o.children,i=$(o,qe);return e.createElement(Ke,Y({className:void 0},i),Qe(a,(function(e){return r(e,n)}),t))}return A(n)?Qe(n.props.children,r,t):($e(n)||null==t||t(n),null)}))}function en(e){return null===e?"":void 0!==e.props.value?e.props.value:Array.isArray(e.props.children)?e.props.children.filter((function(e){return!$e(e)})).join(""):e.props.children?e.props.children.toString():""}function nn(e,n){var r,t,o;return null!==(r=e.props.disabled)&&void 0!==r&&r||null!==(t=null==n||null===(o=n.props)||void 0===o?void 0:o.disabled)&&void 0!==t&&t}function rn(e,n,r){return en(e)===r&&!nn(e,n)}function tn(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.initialValue,o=n.deps,a=void 0===o?[]:o,i=t(r);return l((function(){return{get current(){return i.current},set current(n){i.current=n,e(n)}}}),[e,i].concat(ee(a)))}function on(e,n){var r=o((function(e,n){Array.isArray(e)?e.forEach(r):"function"==typeof e?e(n):e&&(e.current=n)}),[]);return tn(o((function(n){return r(e,n)}),[e,r]),{initialValue:n})}var an,ln,sn,cn,dn=function(e){var n=Q(i(e),2),r=n[0];return tn(n[1],{initialValue:e,deps:[r]})},un=m("select-popover"),pn=c(an||(an=J(["\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"]))),fn=c(ln||(ln=J(["\n width: max-content;\n"]))),gn=function(e,n){var r=Se[n],t=Ee[e];return d(c(sn||(sn=J(["\n font-family: ",";\n font-size: ","px;\n min-height: ","px;\n background-color: ",";\n border-radius: 12px;\n box-shadow: 0 4px 7px 0 ",";\n padding: 8px 0;\n "])),E.default,r.option.text,r.height,t.option.background.base,t.menu.shadow))},hn=e.forwardRef((function(n,t){var a=n.children,i=n.id,l=n.referenceElement,u=n.className,p=n.labelId,g=n.dropdownWidthBasis,h=n.usePortal,b=void 0===h||h,m=n.portalContainer,v=n.scrollContainer,y=n.portalClassName,x=n.popoverZIndex,N=r(Ne),E=N.theme,S=N.size,j=N.disabled,C=N.open,z=on(t,null),D=f(l,8),I=s(D)?"unset":"".concat(Math.min(D,274),"px"),_=o((function(e){z.current&&z.current.focus(),e.stopPropagation()}),[z]),P=q({popoverZIndex:x},b?{usePortal:b,portalClassName:y,portalContainer:m,scrollContainer:v}:{usePortal:b});return e.createElement(w,Y({active:C&&!j,spacing:6,align:O.Bottom,justify:k.Start,adjustOnMutation:!0,className:d(un,u,U({},fn,g===ke.Option)),refEl:l},P),e.createElement("ul",{"aria-labelledby":p,role:"listbox",ref:z,tabIndex:-1,onClick:_,className:d(pn,gn(E,S),c(cn||(cn=J(["\n max-height: ",";\n "," {\n font-size: ","px;\n }\n "])),I,Ye,Ie.text)),id:i},a))}));hn.displayName="ListMenu";var bn,mn,vn,yn,xn,wn,On,kn,Nn,En,Sn,jn,Cn,zn,Dn,In,_n,Pn,Ln,An,Tn,Mn,Fn,Bn,Gn,Vn,Hn,Rn,Wn,Zn=["children","value","text","name","deselected","readOnly","onClose","onOpen","errorMessage","state","baseFontSize","__INTERNAL__menuButtonSlot__"],Kn=m("select-menu"),Xn=c(bn||(bn=J(["\n // Override button defaults\n font-weight: ",";\n > *:last-child {\n grid-template-columns: 1fr 16px;\n justify-content: flex-start;\n\n > svg {\n justify-self: right;\n width: 16px;\n height: 16px;\n }\n }\n"])),S.regular),qn=(U(wn={},we.Default,c(mn||(mn=J(["\n > *:last-child {\n padding: 0 12px;\n }\n "])))),U(wn,we.Large,c(vn||(vn=J(["\n > *:last-child {\n padding: 0 12px 0 ","px;\n }\n "])),C[3])),U(wn,we.Small,c(yn||(yn=J(["\n > *:last-child {\n padding: 0 ","px 0 10px;\n }\n "])),C[2])),U(wn,we.XSmall,c(xn||(xn=J(["\n text-transform: none;\n font-size: ","px;\n line-height: ","px;\n > *:last-child {\n padding: 0 ","px 0 10px;\n }\n "])),z.body1.fontSize,z.body1.lineHeight,C[1])),wn),Un=(U(Nn={},b.Light,c(On||(On=J(["\n background-color: ",";\n // Override button default color\n > *:last-child {\n > svg {\n color: ",";\n }\n }\n "])),L.white,L.gray.dark2)),U(Nn,b.Dark,c(kn||(kn=J(["\n border-color: ",";\n background-color: ",";\n color: ",";\n\n // Override button default color\n > *:last-child {\n > svg {\n color: ",";\n }\n }\n\n &:hover,\n &:active,\n &:focus {\n background-color: ",";\n color: ",";\n }\n "])),L.gray.base,L.gray.dark4,L.gray.light3,L.gray.light1,L.gray.dark4,L.gray.light3)),Nn),Yn=(U(jn={},b.Light,c(En||(En=J(["\n &:focus-visible {\n box-shadow: ",";\n border-color: rgba(255, 255, 255, 0);\n }\n "])),D.light.input)),U(jn,b.Dark,c(Sn||(Sn=J(["\n &:focus-visible {\n background-color: ",";\n box-shadow: ",";\n border-color: rgba(255, 255, 255, 0);\n }\n "])),L.gray.dark4,D.dark.input)),jn),$n=(U(Dn={},b.Light,c(Cn||(Cn=J(["\n color: ",";\n "])),L.gray.dark1)),U(Dn,b.Dark,c(zn||(zn=J(["\n color: ",";\n\n &:hover,\n &:active,\n &:focus {\n color: ",";\n }\n "])),L.gray.light1,L.gray.light1)),Dn),Jn=c(In||(In=J(["\n cursor: not-allowed;\n pointer-events: unset;\n box-shadow: unset;\n\n &:active {\n pointer-events: none;\n }\n"]))),Qn=(U(Ln={},b.Light,d(Jn,c(_n||(_n=J(["\n &[aria-disabled='true'] {\n background-color: ",";\n color: ",";\n\n > *:last-child {\n > svg {\n color: ",";\n }\n }\n }\n "])),L.gray.light2,L.gray.base,L.gray.base))),U(Ln,b.Dark,d(Jn,c(Pn||(Pn=J(["\n &[aria-disabled='true'] {\n background-color: ",";\n color: ",";\n border-color: ",";\n\n > *:last-child {\n > svg {\n color: ",";\n }\n }\n }\n "])),L.gray.dark3,L.gray.dark2,L.gray.dark2,L.gray.dark2))),Ln),er=c(An||(An=J(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n flex-grow: 1;\n gap: ","px;\n overflow: hidden;\n"])),C[1]),nr=c(Tn||(Tn=J(["\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n max-width: 100%;\n"]))),rr=(U(Mn={},b.Light,L.red.base),U(Mn,b.Dark,L.red.light1),Mn),tr=(U(Gn={},b.Light,c(Fn||(Fn=J(["\n border-color: ",";\n background-color: ",";\n\n &:hover,\n &:active {\n box-shadow: ",";\n }\n "])),rr[b.Light],L.white,I.light.red)),U(Gn,b.Dark,c(Bn||(Bn=J(["\n border-color: ",";\n\n &:hover,\n &:active {\n border-color: ",";\n box-shadow: ",";\n }\n "])),rr[b.Dark],rr[b.Dark],I.dark.red)),Gn),or=e.forwardRef((function(n,t){var a,i,l=n.children,s=n.value,u=n.text,p=n.name,f=n.deselected;n.readOnly;var g=n.onClose,h=n.onOpen,m=n.errorMessage,v=n.state,y=n.baseFontSize,x=n.__INTERNAL__menuButtonSlot__,w=$(n,Zn),O=r(Ne),k=O.theme,N=O.open,E=O.size,S=O.disabled,j=on(t,null),C=Se[E],z=o((function(){N?g():h(),j.current.focus()}),[g,h,N,j]),D=x||B,I=x?"":d(Xn,Un[k],qn[E],Yn[k],(U(a={},$n[k],f),U(a,Qn[k],S),U(a,tr[k],v===Oe.Error&&!!m),U(a,c(Vn||(Vn=J(["\n letter-spacing: initial;\n "]))),E===G.XSmall),a),c(Hn||(Hn=J(["\n width: 100%;\n "," {\n height: ","px;\n font-size: ","px;\n }\n "])),Ye,je,Ce)),_=null!==(i=w["data-testid"])&&void 0!==i?i:"leafygreen-ui-select-menubutton";return e.createElement(D,Y({},w,{ref:j,name:p,value:s,disabled:S,onClick:z,variant:V.Default,darkMode:k===b.Dark,rightGlyph:e.createElement(H,null),size:E,"data-testid":_,className:d(I,U({},c(Rn||(Rn=J(["\n font-size: ","px;\n "])),y),E===G.Default))}),e.createElement("div",{className:er},e.createElement("div",{className:d(Kn,nr)},u),v===Oe.Error&&m&&e.createElement(R,{role:"presentation",className:c(Wn||(Wn=J(["\n color: ",";\n "])),rr[k]),size:C.warningIcon})),l)}));or.displayName="MenuButton";var ar,ir,lr,sr,cr,dr,ur,pr,fr,gr,hr,br,mr=["children","darkMode","size","disabled","allowDeselect","usePortal","placeholder","errorMessage","state","dropdownWidthBasis","baseFontSize","id","aria-labelledby","aria-label","className","label","description","name","defaultValue","value","onChange","readOnly","portalContainer","scrollContainer","portalClassName","popoverZIndex","__INTERNAL__menuButtonSlot__"],vr=c(ar||(ar=J(["\n display: flex;\n flex-direction: column;\n margin-bottom: ","px;\n"])),C[1]),yr=c(ir||(ir=J(["\n display: flex;\n flex-direction: column;\n"]))),xr=c(lr||(lr=J(["\n font-size: ","px;\n line-height: ","px;\n"])),z.large.fontSize,z.large.lineHeight),wr=function(e){var n=e.darkMode,r=e.sizeSet;return c(sr||(sr=J(["\n font-family: ",";\n color: ",";\n font-size: ","px;\n margin-top: ","px;\n padding-left: 2px;\n transition: color ","ms ease-in-out;\n transition-delay: ","ms;\n"])),E.default,n?L.red.light1:L.red.base,r.text,C[1],N.faster,N.faster)};function Or(n){var r,t,s,u=n.children,f=n.darkMode,b=n.size,m=void 0===b?we.Default:b,v=n.disabled,y=void 0!==v&&v,w=n.allowDeselect,O=void 0===w||w,k=n.usePortal,N=void 0===k||k,E=n.placeholder,S=void 0===E?"Select":E,j=n.errorMessage,C=void 0===j?"":j,z=n.state,D=void 0===z?Oe.None:z,I=n.dropdownWidthBasis,P=void 0===I?ke.Trigger:I,L=n.baseFontSize,A=void 0===L?_.Body1:L,T=n.id,M=n["aria-labelledby"],F=n["aria-label"],B=n.className,G=n.label,V=n.description,H=n.name,R=n.defaultValue,X=n.value,ee=n.onChange,ne=n.readOnly,re=n.portalContainer,te=n.scrollContainer,oe=n.portalClassName,ae=n.popoverZIndex,ie=n.__INTERNAL__menuButtonSlot__,le=$(n,mr),se=p({prefix:"select",id:T}),ce=l((function(){return F&&!G?void 0:null!=M?M:"".concat(se,"-label")}),[M,F,G,se]);G||M||F||console.error("For screen-reader accessibility, label, aria-label, or aria-labelledby must be provided to Select.");var de=W(f),ue=de.darkMode,pe=de.theme,fe="".concat(se,"-description"),ge="".concat(se,"-menu"),he=Q(i(!1),2),be=he[0],me=he[1],ve=dn(null),ye=p({prefix:"select"}),xe=dn(null),Ee=Se[m],je=l((function(){return{theme:pe,size:m,open:be,disabled:y}}),[pe,m,be,y]);a((function(){void 0!==X&&void 0===ee&&!0!==ne&&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`.")}),[ee,ne,X]);var Ce=o((function(){me(!0)}),[]),Ie=o((function(){me(!1),ve.current.focus()}),[ve]);a((function(){if(be){var e=function(e){var n=ve.current.contains(e.target)||xe.current.contains(e.target);me(n)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}}),[xe,ve,be]);var _e=l((function(){var e=null;return void 0===X&&void 0!==R&&Je(u,(function(n,r){rn(n,r,R)&&(e=n)})),e}),[u,R,X]),Pe=Q(i(_e),2),Le=Pe[0],Ae=Pe[1];a((function(){var e;null!==Le&&Ae(null!==(e=function(e,n){var r,t,o,a,i,l,s,c;return Je(e,(function(e){if(e===n)i=n;else if(e.props.children===n.props.children&&e.props.value===n.props.value){var r;null!==(r=l)&&void 0!==r||(l=e)}else if(void 0!==e.props.value&&e.props.value===n.props.value){var t;null!==(t=s)&&void 0!==t||(s=e)}else if(en(e)===en(n)){var o;null!==(o=c)&&void 0!==o||(c=e)}})),null!==(r=null!==(t=null!==(o=null!==(a=i)&&void 0!==a?a:l)&&void 0!==o?o:s)&&void 0!==t?t:c)&&void 0!==r?r:null}(u,Le))&&void 0!==e?e:_e)}),[u,_e,Le]);var Te=l((function(){if(void 0!==X){var e=null;return Je(u,(function(n,r){rn(n,r,X)&&(e=n)})),e}return Le}),[u,Le,X]),Me=o((function(e,n){void 0===X&&Ae(e),null==ee||ee(en(e),n),He(void 0),Ie()}),[ee,Ie,X]),Be=o((function(e,n){return function(r){r.preventDefault(),r.stopPropagation(),y||n||(Me(e,r),Ie())}}),[y,Ie,Me]),Ge=Q(i(),2),Ve=Ge[0],He=Ge[1],Re=l((function(){var e=[];return O&&e.push(null),Je(u,(function(n,r){nn(n,r)||e.push(n)})),e}),[u,O]),We=o((function(e){void 0!==Ve&&Me(Ve,e)}),[Ve,Me]),Ze=o((function(){He(Re[0])}),[Re]),Ke=o((function(){He(Re[Re.length-1])}),[Re]),Xe=o((function(){if(void 0===Ve||0===Re.indexOf(Ve))Ke();else{var e=Re.indexOf(Ve)-1;He(Re[e])}}),[Re,Ve,Ke]),qe=o((function(){if(void 0===Ve||Re.indexOf(Ve)===Re.length-1)Ze();else{var e=Re.indexOf(Ve)+1;He(Re[e])}}),[Re,Ve,Ze]),Ue=o((function(e,n){return function(r){r.preventDefault(),r.stopPropagation(),y||n||He(e)}}),[y]),$e=o((function(e){var n,r;if(!(e.ctrlKey||e.shiftKey||e.altKey)){var t=null===(n=xe.current)||void 0===n?void 0:n.contains(document.activeElement),o=null===(r=ve.current)||void 0===r?void 0:r.contains(document.activeElement);if(o||t)switch(e.keyCode){case x.Tab:case x.Escape:Ie(),He(void 0);break;case x.Enter:case x.Space:be&&!o&&e.preventDefault(),We(e);break;case x.ArrowUp:!be&&o&&Ce(),e.preventDefault(),Xe();break;case x.ArrowDown:!be&&o&&Ce(),e.preventDefault(),qe()}}}),[xe,ve,Ie,be,We,Xe,qe,Ce]);g("keydown",$e);var tn=h(),on=l((function(){var e=!1;return Je(u,(function(n){e||(e=void 0!==n.props.glyph)})),e}),[u]),an=l((function(){return null!==tn&&null!==xe.current&&void 0===Ve&&be}),[Ve,xe,be,tn]),ln=l((function(){var n=null===Te;return e.createElement(Fe,{className:void 0,glyph:void 0,selected:n,focused:null===Ve,disabled:!1,onClick:Be(null,!1),onFocus:Ue(null,!1),hasGlyphs:!1,triggerScrollIntoView:n&&an},S)}),[an,Ve,Be,Ue,S,Te]),sn=l((function(){return Qe(u,(function(e,n){var r=e===Te,t=nn(e,n);return q(q({},e.props),{},{className:e.props.className,glyph:e.props.glyph,selected:r,focused:e===Ve,disabled:t,children:e.props.children,hasGlyphs:on,onClick:Be(e,t),onFocus:Ue(e,t),triggerScrollIntoView:r&&an})}),(function(){console.error("`Select` instance received child that is not `Option` or `OptionGroup`.")}))}),[an,u,Ve,Be,Ue,on,Te]),cn=q({popoverZIndex:ae},N?{usePortal:N,portalClassName:oe,portalContainer:re,scrollContainer:te}:{usePortal:N});return e.createElement("div",{className:d(yr,B)},(G||V)&&e.createElement("div",{className:vr},G&&e.createElement(Z,{htmlFor:ye,id:ce,darkMode:ue,disabled:y,className:d((r={},U(r,xr,m===we.Large),U(r,c(cr||(cr=J(["\n font-size: ","px;\n line-height: 20px;\n "])),A),m===we.Default),r),c(dr||(dr=J(["\n // Prevent hover state from showing when hovering label\n pointer-events: none;\n "]))),c(ur||(ur=J(["\n "," {\n font-size: ","px;\n line-height: ","px;\n }\n "])),Ye,ze.text,ze.lineHeight))},G),V&&e.createElement(K,{id:fe,darkMode:ue,disabled:y,className:d((t={},U(t,xr,m===we.Large),U(t,c(pr||(pr=J(["\n font-size: ","px;\n line-height: 20px;\n "])),A),m===we.Default),t),c(fr||(fr=J(["\n "," {\n font-size: ","px;\n line-height: ","px;\n }\n "])),Ye,De.text,De.lineHeight))},V)),e.createElement(Ne.Provider,{value:je},e.createElement(or,Y({},le,{id:ye,ref:ve,name:H,readOnly:ne,value:en(Te),text:null!==Te?Te.props.children:S,deselected:null===Te,onOpen:Ce,onClose:Ie,"aria-labelledby":ce,"aria-label":G||M?void 0:F,"aria-controls":ge,"aria-expanded":be,"aria-describedby":fe,"aria-invalid":D===Oe.Error,"aria-disabled":y,errorMessage:C,state:D,baseFontSize:A,__INTERNAL__menuButtonSlot__:ie}),e.createElement(hn,Y({labelId:ce,id:ge,referenceElement:ve,ref:xe,className:d(U({},c(gr||(gr=J(["\n width: ","px;\n "])),null===(s=ve.current)||void 0===s?void 0:s.clientWidth),P===ke.Trigger)),dropdownWidthBasis:P},cn),O&&ln,sn))),D===Oe.Error&&C&&e.createElement("span",{className:d(wr({darkMode:ue,sizeSet:Ee}),c(hr||(hr=J(["\n "," {\n font-size: ","px;\n line-height: ","px;\n }\n "])),Ye,De.text,De.lineHeight),U({},c(br||(br=J(["\n // Hide error text when menu is open,\n // so it doesn't peek around the menu corner\n color: transparent;\n "]))),be))},C))}Or.displayName="Select",Or.propTypes={label:T.string,"aria-labelledby":T.string,"aria-label":T.string,description:T.string,placeholder:T.string,className:T.string,darkMode:T.bool,size:T.oneOf(Object.values(we)),disabled:T.bool,id:T.string,value:T.string,defaultValue:T.string,onChange:T.func,readOnly:T.bool,errorMessage:T.string,state:T.oneOf(Object.values(Oe)),allowDeselect:T.bool,baseFontSize:T.oneOf(Object.values(_)),dropdownWidthBasis:T.oneOf(Object.values(ke))};export{ke as DropdownWidthBasis,Be as Option,Xe as OptionGroup,Or as Select,we as Size,Oe as State,Kn as menuButtonTextClassName,un as popoverClassName}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("lodash/isUndefined"),require("@leafygreen-ui/emotion"),require("@leafygreen-ui/hooks"),require("@leafygreen-ui/lib"),require("@leafygreen-ui/popover"),require("@leafygreen-ui/tokens"),require("polished"),require("@leafygreen-ui/palette"),require("react-is"),require("prop-types"),require("@leafygreen-ui/icon"),require("@leafygreen-ui/icon/dist/Checkmark"),require("@leafygreen-ui/button"),require("@leafygreen-ui/icon/dist/CaretDown"),require("@leafygreen-ui/icon/dist/Warning"),require("@leafygreen-ui/leafygreen-provider"),require("@leafygreen-ui/typography")):"function"==typeof define&&define.amd?define(["exports","react","lodash/isUndefined","@leafygreen-ui/emotion","@leafygreen-ui/hooks","@leafygreen-ui/lib","@leafygreen-ui/popover","@leafygreen-ui/tokens","polished","@leafygreen-ui/palette","react-is","prop-types","@leafygreen-ui/icon","@leafygreen-ui/icon/dist/Checkmark","@leafygreen-ui/button","@leafygreen-ui/icon/dist/CaretDown","@leafygreen-ui/icon/dist/Warning","@leafygreen-ui/leafygreen-provider","@leafygreen-ui/typography"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self)["@leafygreen-ui/select"]={},e.React,e.isUndefined,e["@leafygreen-ui/emotion"],e["@leafygreen-ui/hooks"],e["@leafygreen-ui/lib"],e["@leafygreen-ui/popover"],e["@leafygreen-ui/tokens"],e.polished,e["@leafygreen-ui/palette"],e["react-is"],e.PropTypes,e["@leafygreen-ui/icon"],e.Checkmark,e["@leafygreen-ui/button"],e.CaretDown,e.Warning,e["@leafygreen-ui/leafygreen-provider"],e["@leafygreen-ui/typography"])}(this,(function(e,n,t,r,a,l,o,i,s,u,c,d,p,f,g,h,b,m,y){"use strict";function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var x=v(n),k=v(t),w=v(o),O=v(d),C=v(f),S=v(g),N=v(h),E=v(b);function T(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function j(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?T(Object(t),!0).forEach((function(n){D(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):T(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function D(e,n,t){return(n=function(e){var n=function(e,n){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,n||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}(e,"string");return"symbol"==typeof n?n:String(n)}(n))in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function z(){return z=Object.assign?Object.assign.bind():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},z.apply(this,arguments)}function M(e,n){if(null==e)return{};var t,r,a=function(e,n){if(null==e)return{};var t,r,a={},l=Object.keys(e);for(r=0;r<l.length;r++)t=l[r],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)t=l[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function I(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}function P(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,a,l,o,i=[],s=!0,u=!1;try{if(l=(t=t.call(e)).next,0===n){if(Object(t)!==t)return;s=!1}else for(;!(s=(r=l.call(t)).done)&&(i.push(r.value),i.length!==n);s=!0);}catch(e){u=!0,a=e}finally{try{if(!s&&null!=t.return&&(o=t.return(),Object(o)!==o))return}finally{if(u)throw a}}return i}}(e,n)||A(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 _(e){return function(e){if(Array.isArray(e))return L(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||A(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 A(e,n){if(e){if("string"==typeof e)return L(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)?L(e,n):void 0}}function L(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 q,F,B,R,G,V,W,H,U,Z,K,X,Y,J,$,Q,ee,ne,te={XSmall:"xsmall",Small:"small",Default:"default",Large:"large"},re={None:"none",Error:"error"},ae={Trigger:"trigger",Option:"option"},le=n.createContext({theme:l.Theme.Light,size:te.Default,open:!1,disabled:!1}),oe=(D(q={},l.Theme.Light,{menu:{border:u.palette.gray.light2,shadow:s.transparentize(.75,u.palette.black)},option:{group:{label:u.palette.gray.dark1},background:{base:u.palette.white,hovered:u.palette.gray.light2,focused:u.palette.blue.light3},text:{base:u.palette.gray.dark3,selected:u.palette.blue.base,disabled:u.palette.gray.base,focused:u.palette.blue.dark2},icon:{base:u.palette.gray.dark1,selected:u.palette.blue.base,disabled:u.palette.gray.base},indicator:{focused:u.palette.blue.base}}}),D(q,l.Theme.Dark,{menu:{border:u.palette.gray.base,shadow:s.transparentize(.85,"#000000")},option:{group:{label:u.palette.gray.base},background:{base:u.palette.gray.dark3,hovered:u.palette.gray.dark4,focused:u.palette.blue.dark3},text:{base:u.palette.gray.light2,selected:u.palette.gray.light2,disabled:u.palette.gray.dark2,focused:u.palette.blue.light3},icon:{base:u.palette.gray.base,selected:u.palette.blue.light1,disabled:u.palette.gray.dark1},indicator:{focused:u.palette.blue.light1}}}),q),ie=(D(F={},te.XSmall,{height:22,text:13,option:{text:13},warningIcon:16}),D(F,te.Small,{height:28,text:13,option:{text:13},warningIcon:16}),D(F,te.Default,{height:36,text:13,option:{text:13},warningIcon:16}),D(F,te.Large,{height:48,text:18,option:{text:16},warningIcon:16}),F),se=36,ue=16,ce={text:16,lineHeight:19},de={text:16,lineHeight:22},pe={text:16},fe=["children","className","glyph","selected","focused","disabled","onClick","onFocus","triggerScrollIntoView","hasGlyphs"],ge=l.createUniqueClassName("option"),he=r.css(B||(B=I(["\n display: flex;\n width: 100%;\n outline: none;\n overflow-wrap: anywhere;\n transition: background-color ","ms ease-in-out;\n position: relative;\n padding: 8px 12px;\n\n &:before {\n content: '';\n position: absolute;\n transform: scaleY(0.3);\n top: 7px;\n bottom: 7px;\n left: 0;\n right: 0;\n width: 4px;\n border-radius: 0px 4px 4px 0px;\n opacity: 0;\n transition: all ","ms ease-in-out;\n }\n"])),i.transitionDuration.default,i.transitionDuration.default),be=r.css(R||(R=I(["\n display: flex;\n align-items: center;\n font-family: ",";\n"])),i.fontFamilies.default),me=r.css(G||(G=I(["\n min-width: 16px;\n margin-right: 6px;\n"]))),ye=r.css(V||(V=I(["\n ."," {\n &:focus-visible & {\n color: currentColor;\n }\n }\n"])),ge);function ve(e){var t,l=e.children,o=e.className,s=e.glyph,u=e.selected,c=e.focused,d=e.disabled,f=e.onClick,g=e.onFocus,h=e.triggerScrollIntoView,b=e.hasGlyphs,m=M(e,fe),y=n.useContext(le).theme,v=oe[y].option,k=n.useRef(null),w=n.useCallback((function(){if(null==k.current)return null;var e=k.current,n=null==e?void 0:e.offsetParent;if(!n)return null;n.scrollTop=e.offsetTop+(e.clientHeight-n.clientHeight)/2}),[k]),O=a.usePrevious(h),S=h&&!O;n.useEffect((function(){S&&w()}),[w,S]);var N=a.usePrevious(c),E=c&&!N;n.useEffect((function(){E&&k.current.focus()}),[E]);var T=x.default.createElement("span",{className:r.cx(be,D({},r.css(W||(W=I(["\n font-weight: ",";\n "])),i.fontWeights.bold),u))},l),j=x.default.createElement("span",{className:r.cx(me,r.css(H||(H=I(["\n height: 100%;\n "]))))}),P=j;s&&(p.isComponentGlyph(s)?P=x.default.cloneElement(s,{key:"glyph",className:r.cx(me,r.css(U||(U=I(["\n color: ",";\n "])),v.icon.base),ye,D({},r.css(Z||(Z=I(["\n color: ",";\n "])),v.icon.disabled),d),s.props.className)}):console.error("`Option` instance did not render icon because it is not a known glyph element."));var _,A=u?x.default.createElement(C.default,{key:"checkmark",className:r.cx(me,r.css(K||(K=I(["\n color: ",";\n "])),v.icon.selected),ye,D({},r.css(X||(X=I(["\n color: ",";\n "])),v.icon.disabled),d))}):j;return _=b?x.default.createElement("span",{className:r.css(Y||(Y=I(["\n display: flex;\n justify-content: space-between;\n width: 100%;\n "])))},x.default.createElement("span",{className:r.css(J||(J=I(["\n display: flex;\n "])))},P,T),A):x.default.createElement(x.default.Fragment,null,A,T),x.default.createElement("li",z({},m,{role:"option","aria-selected":u,tabIndex:-1,ref:k,className:r.cx(ge,he,r.css($||($=I(["\n cursor: pointer;\n color: ",";\n "])),v.text.base),(t={},D(t,r.css(Q||(Q=I(["\n &:hover {\n background-color: ",";\n }\n "])),v.background.hovered),!d),D(t,r.css(ee||(ee=I(["\n &:focus-visible {\n color: ",";\n background-color: ",";\n\n &:before {\n opacity: 1;\n transform: scaleY(1);\n background-color: ",";\n }\n }\n "])),v.text.focused,v.background.focused,v.indicator.focused),!d),D(t,r.css(ne||(ne=I(["\n cursor: not-allowed;\n color: ",";\n "])),v.text.disabled),d),t),o),onClick:f,onFocus:g,onKeyDown:void 0}),_)}function xe(e){throw Error("`Option` must be a child of a `Select` instance")}ve.displayName="Option",xe.displayName="Option",xe.propTypes={children:O.default.node.isRequired,className:O.default.string,glyph:O.default.element,value:O.default.string,disabled:O.default.bool};var ke,we,Oe,Ce=["className","label","children"],Se=r.css(ke||(ke=I(["\n padding: 8px 0;\n"]))),Ne=r.css(we||(we=I(["\n cursor: default;\n width: 100%;\n padding: 0 12px 2px;\n outline: none;\n overflow-wrap: anywhere;\n font-size: 12px;\n line-height: 16px;\n font-weight: ",";\n text-transform: uppercase;\n letter-spacing: 0.4px;\n"])),i.fontWeights.bold);function Ee(e){var t=e.className,l=e.label,o=e.children,i=M(e,Ce),s=n.useContext(le).theme,u=oe[s].option,c=a.useIdAllocator({prefix:"select-option-group"});return x.default.createElement("div",z({className:r.cx(Se,t)},i),x.default.createElement("div",{id:c,className:r.cx(Ne,r.css(Oe||(Oe=I(["\n color: ",";\n "])),u.group.label))},l),x.default.createElement("div",{role:"group","aria-labelledby":c},o))}function Te(e){throw Error("`OptionGroup` must be a child of a `Select` instance")}Ee.displayName="OptionGroup",Te.displayName="OptionGroup",Te.propTypes={children:O.default.oneOfType([O.default.element,O.default.arrayOf(O.default.oneOfType([O.default.oneOf([!1,null,void 0,""]),O.default.element]))]).isRequired,className:O.default.string,label:O.default.string.isRequired,disabled:O.default.bool};var je=["children"],De="@media only screen and (max-width: ".concat(i.breakpoints.Tablet,"px) and (hover: none)"),ze="".concat(De," and (pointer: coarse), ").concat(De," and (pointer: none)");function Me(e){return null==e||!1===e||""===e}function Ie(e,n){x.default.Children.forEach(e,(function(e){l.isComponentType(e,"Option")?n(e):l.isComponentType(e,"OptionGroup")?Ie(e.props.children,(function(t){return n(t,e)})):c.isFragment(e)&&Ie(e.props.children,n)}))}function Pe(e,n,t){return x.default.Children.toArray(e).every((function(e){return l.isComponentType(e,"Option")}))||x.default.Children.toArray(e).every((function(e){return l.isComponentType(e,"OptionGroup")}))||l.consoleOnce.warn("LeafyGreen Select: Combining grouped and ungrouped Select Options can cause styling issues"),x.default.Children.map(e,(function(e){if(l.isComponentType(e,"Option"))return x.default.createElement(ve,n(e));if(l.isComponentType(e,"OptionGroup")){var r=e.props,a=r.children,o=M(r,je);return x.default.createElement(Ee,z({className:void 0},o),Pe(a,(function(t){return n(t,e)}),t))}return c.isFragment(e)?Pe(e.props.children,n,t):(Me(e)||null==t||t(e),null)}))}function _e(e){return null===e?"":void 0!==e.props.value?e.props.value:Array.isArray(e.props.children)?e.props.children.filter((function(e){return!Me(e)})).join(""):e.props.children?e.props.children.toString():""}function Ae(e,n){var t,r,a;return null!==(t=e.props.disabled)&&void 0!==t&&t||null!==(r=null==n||null===(a=n.props)||void 0===a?void 0:a.disabled)&&void 0!==r&&r}function Le(e,n,t){return _e(e)===t&&!Ae(e,n)}function qe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.initialValue,a=t.deps,l=void 0===a?[]:a,o=n.useRef(r);return n.useMemo((function(){return{get current(){return o.current},set current(n){o.current=n,e(n)}}}),[e,o].concat(_(l)))}function Fe(e,t){var r=n.useCallback((function(e,n){Array.isArray(e)?e.forEach(r):"function"==typeof e?e(n):e&&(e.current=n)}),[]);return qe(n.useCallback((function(n){return r(e,n)}),[e,r]),{initialValue:t})}var Be,Re,Ge,Ve,We=function(e){var t=P(n.useState(e),2),r=t[0];return qe(t[1],{initialValue:e,deps:[r]})},He=l.createUniqueClassName("select-popover"),Ue=r.css(Be||(Be=I(["\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"]))),Ze=r.css(Re||(Re=I(["\n width: max-content;\n"]))),Ke=function(e,n){var t=ie[n],a=oe[e];return r.cx(r.css(Ge||(Ge=I(["\n font-family: ",";\n font-size: ","px;\n min-height: ","px;\n background-color: ",";\n border-radius: 12px;\n box-shadow: 0 4px 7px 0 ",";\n padding: 8px 0;\n "])),i.fontFamilies.default,t.option.text,t.height,a.option.background.base,a.menu.shadow))},Xe=x.default.forwardRef((function(e,t){var l=e.children,i=e.id,s=e.referenceElement,u=e.className,c=e.labelId,d=e.dropdownWidthBasis,p=e.usePortal,f=void 0===p||p,g=e.portalContainer,h=e.scrollContainer,b=e.portalClassName,m=e.popoverZIndex,y=n.useContext(le),v=y.theme,O=y.size,C=y.disabled,S=y.open,N=Fe(t,null),E=a.useAvailableSpace(s,8),T=k.default(E)?"unset":"".concat(Math.min(E,274),"px"),M=n.useCallback((function(e){N.current&&N.current.focus(),e.stopPropagation()}),[N]),P=j({popoverZIndex:m},f?{usePortal:f,portalClassName:b,portalContainer:g,scrollContainer:h}:{usePortal:f});return x.default.createElement(w.default,z({active:S&&!C,spacing:6,align:o.Align.Bottom,justify:o.Justify.Start,adjustOnMutation:!0,className:r.cx(He,u,D({},Ze,d===ae.Option)),refEl:s},P),x.default.createElement("ul",{"aria-labelledby":c,role:"listbox",ref:N,tabIndex:-1,onClick:M,className:r.cx(Ue,Ke(v,O),r.css(Ve||(Ve=I(["\n max-height: ",";\n "," {\n font-size: ","px;\n }\n "])),T,ze,pe.text)),id:i},l))}));Xe.displayName="ListMenu";var Ye,Je,$e,Qe,en,nn,tn,rn,an,ln,on,sn,un,cn,dn,pn,fn,gn,hn,bn,mn,yn,vn,xn,kn,wn,On,Cn,Sn,Nn=["children","value","text","name","deselected","readOnly","onClose","onOpen","errorMessage","state","baseFontSize","__INTERNAL__menuButtonSlot__"],En=l.createUniqueClassName("select-menu"),Tn=r.css(Ye||(Ye=I(["\n // Override button defaults\n font-weight: ",";\n > *:last-child {\n grid-template-columns: 1fr 16px;\n justify-content: flex-start;\n\n > svg {\n justify-self: right;\n width: 16px;\n height: 16px;\n }\n }\n"])),i.fontWeights.regular),jn=(D(nn={},te.Default,r.css(Je||(Je=I(["\n > *:last-child {\n padding: 0 12px;\n }\n "])))),D(nn,te.Large,r.css($e||($e=I(["\n > *:last-child {\n padding: 0 12px 0 ","px;\n }\n "])),i.spacing[3])),D(nn,te.Small,r.css(Qe||(Qe=I(["\n > *:last-child {\n padding: 0 ","px 0 10px;\n }\n "])),i.spacing[2])),D(nn,te.XSmall,r.css(en||(en=I(["\n text-transform: none;\n font-size: ","px;\n line-height: ","px;\n > *:last-child {\n padding: 0 ","px 0 10px;\n }\n "])),i.typeScales.body1.fontSize,i.typeScales.body1.lineHeight,i.spacing[1])),nn),Dn=(D(an={},l.Theme.Light,r.css(tn||(tn=I(["\n background-color: ",";\n // Override button default color\n > *:last-child {\n > svg {\n color: ",";\n }\n }\n "])),u.palette.white,u.palette.gray.dark2)),D(an,l.Theme.Dark,r.css(rn||(rn=I(["\n border-color: ",";\n background-color: ",";\n color: ",";\n\n // Override button default color\n > *:last-child {\n > svg {\n color: ",";\n }\n }\n\n &:hover,\n &:active,\n &:focus {\n background-color: ",";\n color: ",";\n }\n "])),u.palette.gray.base,u.palette.gray.dark4,u.palette.gray.light3,u.palette.gray.light1,u.palette.gray.dark4,u.palette.gray.light3)),an),zn=(D(sn={},l.Theme.Light,r.css(ln||(ln=I(["\n &:focus-visible {\n box-shadow: ",";\n border-color: rgba(255, 255, 255, 0);\n }\n "])),i.focusRing.light.input)),D(sn,l.Theme.Dark,r.css(on||(on=I(["\n &:focus-visible {\n background-color: ",";\n box-shadow: ",";\n border-color: rgba(255, 255, 255, 0);\n }\n "])),u.palette.gray.dark4,i.focusRing.dark.input)),sn),Mn=(D(dn={},l.Theme.Light,r.css(un||(un=I(["\n color: ",";\n "])),u.palette.gray.dark1)),D(dn,l.Theme.Dark,r.css(cn||(cn=I(["\n color: ",";\n\n &:hover,\n &:active,\n &:focus {\n color: ",";\n }\n "])),u.palette.gray.light1,u.palette.gray.light1)),dn),In=r.css(pn||(pn=I(["\n &:disabled {\n cursor: not-allowed;\n pointer-events: unset;\n box-shadow: unset;\n\n &:active {\n pointer-events: none;\n }\n }\n"]))),Pn=(D(hn={},l.Theme.Light,r.cx(In,r.css(fn||(fn=I(["\n &:disabled {\n background-color: ",";\n color: ",";\n\n > *:last-child {\n > svg {\n color: ",";\n }\n }\n }\n "])),u.palette.gray.light2,u.palette.gray.base,u.palette.gray.base))),D(hn,l.Theme.Dark,r.cx(In,r.css(gn||(gn=I(["\n &:disabled {\n background-color: ",";\n color: ",";\n border-color: ",";\n\n > *:last-child {\n > svg {\n color: ",";\n }\n }\n }\n "])),u.palette.gray.dark3,u.palette.gray.dark2,u.palette.gray.dark2,u.palette.gray.dark2))),hn),_n=r.css(bn||(bn=I(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n flex-grow: 1;\n gap: ","px;\n overflow: hidden;\n"])),i.spacing[1]),An=r.css(mn||(mn=I(["\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n max-width: 100%;\n"]))),Ln=(D(yn={},l.Theme.Light,u.palette.red.base),D(yn,l.Theme.Dark,u.palette.red.light1),yn),qn=(D(kn={},l.Theme.Light,r.css(vn||(vn=I(["\n border-color: ",";\n background-color: ",";\n\n &:hover,\n &:active {\n box-shadow: ",";\n }\n "])),Ln[l.Theme.Light],u.palette.white,i.hoverRing.light.red)),D(kn,l.Theme.Dark,r.css(xn||(xn=I(["\n border-color: ",";\n\n &:hover,\n &:active {\n border-color: ",";\n box-shadow: ",";\n }\n "])),Ln[l.Theme.Dark],Ln[l.Theme.Dark],i.hoverRing.dark.red)),kn),Fn=x.default.forwardRef((function(e,t){var a,o,i=e.children,s=e.value,u=e.text,c=e.name,d=e.deselected;e.readOnly;var p=e.onClose,f=e.onOpen,h=e.errorMessage,b=e.state,m=e.baseFontSize,y=e.__INTERNAL__menuButtonSlot__,v=M(e,Nn),k=n.useContext(le),w=k.theme,O=k.open,C=k.size,T=k.disabled,j=Fe(t,null),P=ie[C],_=n.useCallback((function(){O?p():f(),j.current.focus()}),[p,f,O,j]),A=y||S.default,L=y?"":r.cx(Tn,Dn[w],jn[C],zn[w],(D(a={},Mn[w],d),D(a,Pn[w],T),D(a,qn[w],b===re.Error&&!!h),D(a,r.css(wn||(wn=I(["\n letter-spacing: initial;\n "]))),C===g.Size.XSmall),a),r.css(On||(On=I(["\n width: 100%;\n "," {\n height: ","px;\n font-size: ","px;\n }\n "])),ze,se,ue)),q=null!==(o=v["data-testid"])&&void 0!==o?o:"leafygreen-ui-select-menubutton";return x.default.createElement(A,z({},v,{ref:j,name:c,value:s,disabled:T,onClick:_,variant:g.Variant.Default,darkMode:w===l.Theme.Dark,rightGlyph:x.default.createElement(N.default,null),size:C,"data-testid":q,className:r.cx(L,D({},r.css(Cn||(Cn=I(["\n font-size: ","px;\n "])),m),C===g.Size.Default))}),x.default.createElement("div",{className:_n},x.default.createElement("div",{className:r.cx(En,An)},u),b===re.Error&&h&&x.default.createElement(E.default,{role:"presentation",className:r.css(Sn||(Sn=I(["\n color: ",";\n "])),Ln[w]),size:P.warningIcon})),i)}));Fn.displayName="MenuButton";var Bn,Rn,Gn,Vn,Wn,Hn,Un,Zn,Kn,Xn,Yn,Jn,$n=["children","darkMode","size","disabled","allowDeselect","usePortal","placeholder","errorMessage","state","dropdownWidthBasis","baseFontSize","id","aria-labelledby","aria-label","className","label","description","name","defaultValue","value","onChange","readOnly","portalContainer","scrollContainer","portalClassName","popoverZIndex","__INTERNAL__menuButtonSlot__"],Qn=r.css(Bn||(Bn=I(["\n display: flex;\n flex-direction: column;\n margin-bottom: ","px;\n"])),i.spacing[1]),et=r.css(Rn||(Rn=I(["\n display: flex;\n flex-direction: column;\n"]))),nt=r.css(Gn||(Gn=I(["\n font-size: ","px;\n line-height: ","px;\n"])),i.typeScales.large.fontSize,i.typeScales.large.lineHeight),tt=function(e){var n=e.darkMode,t=e.sizeSet;return r.css(Vn||(Vn=I(["\n font-family: ",";\n color: ",";\n font-size: ","px;\n margin-top: ","px;\n padding-left: 2px;\n transition: color ","ms ease-in-out;\n transition-delay: ","ms;\n"])),i.fontFamilies.default,n?u.palette.red.light1:u.palette.red.base,t.text,i.spacing[1],i.transitionDuration.faster,i.transitionDuration.faster)};function rt(e){var t,o,s,u=e.children,c=e.darkMode,d=e.size,p=void 0===d?te.Default:d,f=e.disabled,g=void 0!==f&&f,h=e.allowDeselect,b=void 0===h||h,v=e.usePortal,k=void 0===v||v,w=e.placeholder,O=void 0===w?"Select":w,C=e.errorMessage,S=void 0===C?"":C,N=e.state,E=void 0===N?re.None:N,T=e.dropdownWidthBasis,_=void 0===T?ae.Trigger:T,A=e.baseFontSize,L=void 0===A?i.BaseFontSize.Body1:A,q=e.id,F=e["aria-labelledby"],B=e["aria-label"],R=e.className,G=e.label,V=e.description,W=e.name,H=e.defaultValue,U=e.value,Z=e.onChange,K=e.readOnly,X=e.portalContainer,Y=e.scrollContainer,J=e.portalClassName,$=e.popoverZIndex,Q=e.__INTERNAL__menuButtonSlot__,ee=M(e,$n),ne=a.useIdAllocator({prefix:"select",id:q}),oe=n.useMemo((function(){return B&&!G?void 0:null!=F?F:"".concat(ne,"-label")}),[F,B,G,ne]);G||F||B||console.error("For screen-reader accessibility, label, aria-label, or aria-labelledby must be provided to Select.");var se=m.useDarkMode(c),ue=se.darkMode,pe=se.theme,fe="".concat(ne,"-description"),ge="".concat(ne,"-menu"),he=P(n.useState(!1),2),be=he[0],me=he[1],ye=We(null),xe=a.useIdAllocator({prefix:"select"}),ke=We(null),we=ie[p],Oe=n.useMemo((function(){return{theme:pe,size:p,open:be,disabled:g}}),[pe,p,be,g]);n.useEffect((function(){void 0!==U&&void 0===Z&&!0!==K&&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`.")}),[Z,K,U]);var Ce=n.useCallback((function(){me(!0)}),[]),Se=n.useCallback((function(){me(!1),ye.current.focus()}),[ye]);n.useEffect((function(){if(be){var e=function(e){var n=ye.current.contains(e.target)||ke.current.contains(e.target);me(n)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}}),[ke,ye,be]);var Ne=n.useMemo((function(){var e=null;return void 0===U&&void 0!==H&&Ie(u,(function(n,t){Le(n,t,H)&&(e=n)})),e}),[u,H,U]),Ee=P(n.useState(Ne),2),Te=Ee[0],je=Ee[1];n.useEffect((function(){var e;null!==Te&&je(null!==(e=function(e,n){var t,r,a,l,o,i,s,u;return Ie(e,(function(e){if(e===n)o=n;else if(e.props.children===n.props.children&&e.props.value===n.props.value){var t;null!==(t=i)&&void 0!==t||(i=e)}else if(void 0!==e.props.value&&e.props.value===n.props.value){var r;null!==(r=s)&&void 0!==r||(s=e)}else if(_e(e)===_e(n)){var a;null!==(a=u)&&void 0!==a||(u=e)}})),null!==(t=null!==(r=null!==(a=null!==(l=o)&&void 0!==l?l:i)&&void 0!==a?a:s)&&void 0!==r?r:u)&&void 0!==t?t:null}(u,Te))&&void 0!==e?e:Ne)}),[u,Ne,Te]);var De=n.useMemo((function(){if(void 0!==U){var e=null;return Ie(u,(function(n,t){Le(n,t,U)&&(e=n)})),e}return Te}),[u,Te,U]),Me=n.useCallback((function(e,n){void 0===U&&je(e),null==Z||Z(_e(e),n),Re(void 0),Se()}),[Z,Se,U]),qe=n.useCallback((function(e,n){return function(t){t.preventDefault(),t.stopPropagation(),g||n||(Me(e,t),Se())}}),[g,Se,Me]),Fe=P(n.useState(),2),Be=Fe[0],Re=Fe[1],Ge=n.useMemo((function(){var e=[];return b&&e.push(null),Ie(u,(function(n,t){Ae(n,t)||e.push(n)})),e}),[u,b]),Ve=n.useCallback((function(e){void 0!==Be&&Me(Be,e)}),[Be,Me]),He=n.useCallback((function(){Re(Ge[0])}),[Ge]),Ue=n.useCallback((function(){Re(Ge[Ge.length-1])}),[Ge]),Ze=n.useCallback((function(){if(void 0===Be||0===Ge.indexOf(Be))Ue();else{var e=Ge.indexOf(Be)-1;Re(Ge[e])}}),[Ge,Be,Ue]),Ke=n.useCallback((function(){if(void 0===Be||Ge.indexOf(Be)===Ge.length-1)He();else{var e=Ge.indexOf(Be)+1;Re(Ge[e])}}),[Ge,Be,He]),Ye=n.useCallback((function(e,n){return function(t){t.preventDefault(),t.stopPropagation(),g||n||Re(e)}}),[g]),Je=n.useCallback((function(e){var n,t;if(!(e.ctrlKey||e.shiftKey||e.altKey)){var r=null===(n=ke.current)||void 0===n?void 0:n.contains(document.activeElement),a=null===(t=ye.current)||void 0===t?void 0:t.contains(document.activeElement);if(a||r)switch(e.keyCode){case l.keyMap.Tab:case l.keyMap.Escape:Se(),Re(void 0);break;case l.keyMap.Enter:case l.keyMap.Space:be&&!a&&e.preventDefault(),Ve(e);break;case l.keyMap.ArrowUp:!be&&a&&Ce(),e.preventDefault(),Ze();break;case l.keyMap.ArrowDown:!be&&a&&Ce(),e.preventDefault(),Ke()}}}),[ke,ye,Se,be,Ve,Ze,Ke,Ce]);a.useEventListener("keydown",Je);var $e=a.useViewportSize(),Qe=n.useMemo((function(){var e=!1;return Ie(u,(function(n){e||(e=void 0!==n.props.glyph)})),e}),[u]),en=n.useMemo((function(){return null!==$e&&null!==ke.current&&void 0===Be&&be}),[Be,ke,be,$e]),nn=n.useMemo((function(){var e=null===De;return x.default.createElement(ve,{className:void 0,glyph:void 0,selected:e,focused:null===Be,disabled:!1,onClick:qe(null,!1),onFocus:Ye(null,!1),hasGlyphs:!1,triggerScrollIntoView:e&&en},O)}),[en,Be,qe,Ye,O,De]),tn=n.useMemo((function(){return Pe(u,(function(e,n){var t=e===De,r=Ae(e,n);return j(j({},e.props),{},{className:e.props.className,glyph:e.props.glyph,selected:t,focused:e===Be,disabled:r,children:e.props.children,hasGlyphs:Qe,onClick:qe(e,r),onFocus:Ye(e,r),triggerScrollIntoView:t&&en})}),(function(){console.error("`Select` instance received child that is not `Option` or `OptionGroup`.")}))}),[en,u,Be,qe,Ye,Qe,De]),rn=j({popoverZIndex:$},k?{usePortal:k,portalClassName:J,portalContainer:X,scrollContainer:Y}:{usePortal:k});return x.default.createElement("div",{className:r.cx(et,R)},(G||V)&&x.default.createElement("div",{className:Qn},G&&x.default.createElement(y.Label,{htmlFor:xe,id:oe,darkMode:ue,disabled:g,className:r.cx((t={},D(t,nt,p===te.Large),D(t,r.css(Wn||(Wn=I(["\n font-size: ","px;\n line-height: 20px;\n "])),L),p===te.Default),t),r.css(Hn||(Hn=I(["\n // Prevent hover state from showing when hovering label\n pointer-events: none;\n "]))),r.css(Un||(Un=I(["\n "," {\n font-size: ","px;\n line-height: ","px;\n }\n "])),ze,ce.text,ce.lineHeight))},G),V&&x.default.createElement(y.Description,{id:fe,darkMode:ue,disabled:g,className:r.cx((o={},D(o,nt,p===te.Large),D(o,r.css(Zn||(Zn=I(["\n font-size: ","px;\n line-height: 20px;\n "])),L),p===te.Default),o),r.css(Kn||(Kn=I(["\n "," {\n font-size: ","px;\n line-height: ","px;\n }\n "])),ze,de.text,de.lineHeight))},V)),x.default.createElement(le.Provider,{value:Oe},x.default.createElement(Fn,z({},ee,{id:xe,ref:ye,name:W,readOnly:K,value:_e(De),text:null!==De?De.props.children:O,deselected:null===De,onOpen:Ce,onClose:Se,"aria-labelledby":oe,"aria-label":G||F?void 0:B,"aria-controls":ge,"aria-expanded":be,"aria-describedby":fe,"aria-invalid":E===re.Error,"aria-disabled":g,errorMessage:S,state:E,baseFontSize:L,__INTERNAL__menuButtonSlot__:Q}),x.default.createElement(Xe,z({labelId:oe,id:ge,referenceElement:ye,ref:ke,className:r.cx(D({},r.css(Xn||(Xn=I(["\n width: ","px;\n "])),null===(s=ye.current)||void 0===s?void 0:s.clientWidth),_===ae.Trigger)),dropdownWidthBasis:_},rn),b&&nn,tn))),E===re.Error&&S&&x.default.createElement("span",{className:r.cx(tt({darkMode:ue,sizeSet:we}),r.css(Yn||(Yn=I(["\n "," {\n font-size: ","px;\n line-height: ","px;\n }\n "])),ze,de.text,de.lineHeight),D({},r.css(Jn||(Jn=I(["\n // Hide error text when menu is open,\n // so it doesn't peek around the menu corner\n color: transparent;\n "]))),be))},S))}rt.displayName="Select",rt.propTypes={label:O.default.string,"aria-labelledby":O.default.string,"aria-label":O.default.string,description:O.default.string,placeholder:O.default.string,className:O.default.string,darkMode:O.default.bool,size:O.default.oneOf(Object.values(te)),disabled:O.default.bool,id:O.default.string,value:O.default.string,defaultValue:O.default.string,onChange:O.default.func,readOnly:O.default.bool,errorMessage:O.default.string,state:O.default.oneOf(Object.values(re)),allowDeselect:O.default.bool,baseFontSize:O.default.oneOf(Object.values(i.BaseFontSize)),dropdownWidthBasis:O.default.oneOf(Object.values(ae))},e.DropdownWidthBasis=ae,e.Option=xe,e.OptionGroup=Te,e.Select=rt,e.Size=te,e.State=re,e.menuButtonTextClassName=En,e.popoverClassName=He})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("lodash/isUndefined"),require("@leafygreen-ui/emotion"),require("@leafygreen-ui/hooks"),require("@leafygreen-ui/lib"),require("@leafygreen-ui/popover"),require("@leafygreen-ui/tokens"),require("polished"),require("@leafygreen-ui/palette"),require("react-is"),require("prop-types"),require("@leafygreen-ui/icon"),require("@leafygreen-ui/icon/dist/Checkmark"),require("@leafygreen-ui/button"),require("@leafygreen-ui/icon/dist/CaretDown"),require("@leafygreen-ui/icon/dist/Warning"),require("@leafygreen-ui/leafygreen-provider"),require("@leafygreen-ui/typography")):"function"==typeof define&&define.amd?define(["exports","react","lodash/isUndefined","@leafygreen-ui/emotion","@leafygreen-ui/hooks","@leafygreen-ui/lib","@leafygreen-ui/popover","@leafygreen-ui/tokens","polished","@leafygreen-ui/palette","react-is","prop-types","@leafygreen-ui/icon","@leafygreen-ui/icon/dist/Checkmark","@leafygreen-ui/button","@leafygreen-ui/icon/dist/CaretDown","@leafygreen-ui/icon/dist/Warning","@leafygreen-ui/leafygreen-provider","@leafygreen-ui/typography"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self)["@leafygreen-ui/select"]={},e.React,e["/isUndefined"],e["@leafygreen-ui/emotion"],e["@leafygreen-ui/hooks"],e["@leafygreen-ui/lib"],e["@leafygreen-ui/popover"],e["@leafygreen-ui/tokens"],e.polished,e["@leafygreen-ui/palette"],e["react-is"],e.PropTypes,e["@leafygreen-ui/icon"],e.Checkmark,e["@leafygreen-ui/button"],e.CaretDown,e.Warning,e["@leafygreen-ui/leafygreen-provider"],e["@leafygreen-ui/typography"])}(this,(function(e,n,t,r,a,l,o,i,s,u,c,d,p,f,g,h,b,m,y){"use strict";function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var x=v(n),k=v(t),w=v(o),O=v(d),C=v(f),S=v(g),N=v(h),E=v(b);function T(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function j(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?T(Object(t),!0).forEach((function(n){D(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):T(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function D(e,n,t){return(n=function(e){var n=function(e,n){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,n||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}(e,"string");return"symbol"==typeof n?n:String(n)}(n))in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function z(){return z=Object.assign?Object.assign.bind():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},z.apply(this,arguments)}function M(e,n){if(null==e)return{};var t,r,a=function(e,n){if(null==e)return{};var t,r,a={},l=Object.keys(e);for(r=0;r<l.length;r++)t=l[r],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)t=l[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function I(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}function P(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,a,l,o,i=[],s=!0,u=!1;try{if(l=(t=t.call(e)).next,0===n){if(Object(t)!==t)return;s=!1}else for(;!(s=(r=l.call(t)).done)&&(i.push(r.value),i.length!==n);s=!0);}catch(e){u=!0,a=e}finally{try{if(!s&&null!=t.return&&(o=t.return(),Object(o)!==o))return}finally{if(u)throw a}}return i}}(e,n)||A(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 _(e){return function(e){if(Array.isArray(e))return L(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||A(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 A(e,n){if(e){if("string"==typeof e)return L(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)?L(e,n):void 0}}function L(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 q,F,B,R,G,V,W,H,U,Z,K,X,Y,J,$,Q,ee,ne,te={XSmall:"xsmall",Small:"small",Default:"default",Large:"large"},re={None:"none",Error:"error"},ae={Trigger:"trigger",Option:"option"},le=n.createContext({theme:l.Theme.Light,size:te.Default,open:!1,disabled:!1}),oe=(D(q={},l.Theme.Light,{menu:{border:u.palette.gray.light2,shadow:s.transparentize(.75,u.palette.black)},option:{group:{label:u.palette.gray.dark1},background:{base:u.palette.white,hovered:u.palette.gray.light2,focused:u.palette.blue.light3},text:{base:u.palette.gray.dark3,selected:u.palette.blue.base,disabled:u.palette.gray.base,focused:u.palette.blue.dark2},icon:{base:u.palette.gray.dark1,selected:u.palette.blue.base,disabled:u.palette.gray.base},indicator:{focused:u.palette.blue.base}}}),D(q,l.Theme.Dark,{menu:{border:u.palette.gray.base,shadow:s.transparentize(.85,"#000000")},option:{group:{label:u.palette.gray.base},background:{base:u.palette.gray.dark3,hovered:u.palette.gray.dark4,focused:u.palette.blue.dark3},text:{base:u.palette.gray.light2,selected:u.palette.gray.light2,disabled:u.palette.gray.dark2,focused:u.palette.blue.light3},icon:{base:u.palette.gray.base,selected:u.palette.blue.light1,disabled:u.palette.gray.dark1},indicator:{focused:u.palette.blue.light1}}}),q),ie=(D(F={},te.XSmall,{height:22,text:13,option:{text:13},warningIcon:16}),D(F,te.Small,{height:28,text:13,option:{text:13},warningIcon:16}),D(F,te.Default,{height:36,text:13,option:{text:13},warningIcon:16}),D(F,te.Large,{height:48,text:18,option:{text:16},warningIcon:16}),F),se=36,ue=16,ce={text:16,lineHeight:19},de={text:16,lineHeight:22},pe={text:16},fe=["children","className","glyph","selected","focused","disabled","onClick","onFocus","triggerScrollIntoView","hasGlyphs"],ge=l.createUniqueClassName("option"),he=r.css(B||(B=I(["\n display: flex;\n width: 100%;\n outline: none;\n overflow-wrap: anywhere;\n transition: background-color ","ms ease-in-out;\n position: relative;\n padding: 8px 12px;\n\n &:before {\n content: '';\n position: absolute;\n transform: scaleY(0.3);\n top: 7px;\n bottom: 7px;\n left: 0;\n right: 0;\n width: 4px;\n border-radius: 0px 4px 4px 0px;\n opacity: 0;\n transition: all ","ms ease-in-out;\n }\n"])),i.transitionDuration.default,i.transitionDuration.default),be=r.css(R||(R=I(["\n display: flex;\n align-items: center;\n font-family: ",";\n"])),i.fontFamilies.default),me=r.css(G||(G=I(["\n min-width: 16px;\n margin-right: 6px;\n"]))),ye=r.css(V||(V=I(["\n ."," {\n &:focus-visible & {\n color: currentColor;\n }\n }\n"])),ge);function ve(e){var t,l=e.children,o=e.className,s=e.glyph,u=e.selected,c=e.focused,d=e.disabled,f=e.onClick,g=e.onFocus,h=e.triggerScrollIntoView,b=e.hasGlyphs,m=M(e,fe),y=n.useContext(le).theme,v=oe[y].option,k=n.useRef(null),w=n.useCallback((function(){if(null==k.current)return null;var e=k.current,n=null==e?void 0:e.offsetParent;if(!n)return null;n.scrollTop=e.offsetTop+(e.clientHeight-n.clientHeight)/2}),[k]),O=a.usePrevious(h),S=h&&!O;n.useEffect((function(){S&&w()}),[w,S]);var N=a.usePrevious(c),E=c&&!N;n.useEffect((function(){E&&k.current.focus()}),[E]);var T=x.default.createElement("span",{className:r.cx(be,D({},r.css(W||(W=I(["\n font-weight: ",";\n "])),i.fontWeights.bold),u))},l),j=x.default.createElement("span",{className:r.cx(me,r.css(H||(H=I(["\n height: 100%;\n "]))))}),P=j;s&&(p.isComponentGlyph(s)?P=x.default.cloneElement(s,{key:"glyph",className:r.cx(me,r.css(U||(U=I(["\n color: ",";\n "])),v.icon.base),ye,D({},r.css(Z||(Z=I(["\n color: ",";\n "])),v.icon.disabled),d),s.props.className)}):console.error("`Option` instance did not render icon because it is not a known glyph element."));var _,A=u?x.default.createElement(C.default,{key:"checkmark",className:r.cx(me,r.css(K||(K=I(["\n color: ",";\n "])),v.icon.selected),ye,D({},r.css(X||(X=I(["\n color: ",";\n "])),v.icon.disabled),d))}):j;return _=b?x.default.createElement("span",{className:r.css(Y||(Y=I(["\n display: flex;\n justify-content: space-between;\n width: 100%;\n "])))},x.default.createElement("span",{className:r.css(J||(J=I(["\n display: flex;\n "])))},P,T),A):x.default.createElement(x.default.Fragment,null,A,T),x.default.createElement("li",z({},m,{role:"option","aria-selected":u,tabIndex:-1,ref:k,className:r.cx(ge,he,r.css($||($=I(["\n cursor: pointer;\n color: ",";\n "])),v.text.base),(t={},D(t,r.css(Q||(Q=I(["\n &:hover {\n background-color: ",";\n }\n "])),v.background.hovered),!d),D(t,r.css(ee||(ee=I(["\n &:focus-visible {\n color: ",";\n background-color: ",";\n\n &:before {\n opacity: 1;\n transform: scaleY(1);\n background-color: ",";\n }\n }\n "])),v.text.focused,v.background.focused,v.indicator.focused),!d),D(t,r.css(ne||(ne=I(["\n cursor: not-allowed;\n color: ",";\n "])),v.text.disabled),d),t),o),onClick:f,onFocus:g,onKeyDown:void 0}),_)}function xe(e){throw Error("`Option` must be a child of a `Select` instance")}ve.displayName="Option",xe.displayName="Option",xe.propTypes={children:O.default.node.isRequired,className:O.default.string,glyph:O.default.element,value:O.default.string,disabled:O.default.bool};var ke,we,Oe,Ce=["className","label","children"],Se=r.css(ke||(ke=I(["\n padding: 8px 0;\n"]))),Ne=r.css(we||(we=I(["\n cursor: default;\n width: 100%;\n padding: 0 12px 2px;\n outline: none;\n overflow-wrap: anywhere;\n font-size: 12px;\n line-height: 16px;\n font-weight: ",";\n text-transform: uppercase;\n letter-spacing: 0.4px;\n"])),i.fontWeights.bold);function Ee(e){var t=e.className,l=e.label,o=e.children,i=M(e,Ce),s=n.useContext(le).theme,u=oe[s].option,c=a.useIdAllocator({prefix:"select-option-group"});return x.default.createElement("div",z({className:r.cx(Se,t)},i),x.default.createElement("div",{id:c,className:r.cx(Ne,r.css(Oe||(Oe=I(["\n color: ",";\n "])),u.group.label))},l),x.default.createElement("div",{role:"group","aria-labelledby":c},o))}function Te(e){throw Error("`OptionGroup` must be a child of a `Select` instance")}Ee.displayName="OptionGroup",Te.displayName="OptionGroup",Te.propTypes={children:O.default.oneOfType([O.default.element,O.default.arrayOf(O.default.oneOfType([O.default.oneOf([!1,null,void 0,""]),O.default.element]))]).isRequired,className:O.default.string,label:O.default.string.isRequired,disabled:O.default.bool};var je=["children"],De="@media only screen and (max-width: ".concat(i.breakpoints.Tablet,"px) and (hover: none)"),ze="".concat(De," and (pointer: coarse), ").concat(De," and (pointer: none)");function Me(e){return null==e||!1===e||""===e}function Ie(e,n){x.default.Children.forEach(e,(function(e){l.isComponentType(e,"Option")?n(e):l.isComponentType(e,"OptionGroup")?Ie(e.props.children,(function(t){return n(t,e)})):c.isFragment(e)&&Ie(e.props.children,n)}))}function Pe(e,n,t){return x.default.Children.toArray(e).every((function(e){return l.isComponentType(e,"Option")}))||x.default.Children.toArray(e).every((function(e){return l.isComponentType(e,"OptionGroup")}))||l.consoleOnce.warn("LeafyGreen Select: Combining grouped and ungrouped Select Options can cause styling issues"),x.default.Children.map(e,(function(e){if(l.isComponentType(e,"Option"))return x.default.createElement(ve,n(e));if(l.isComponentType(e,"OptionGroup")){var r=e.props,a=r.children,o=M(r,je);return x.default.createElement(Ee,z({className:void 0},o),Pe(a,(function(t){return n(t,e)}),t))}return c.isFragment(e)?Pe(e.props.children,n,t):(Me(e)||null==t||t(e),null)}))}function _e(e){return null===e?"":void 0!==e.props.value?e.props.value:Array.isArray(e.props.children)?e.props.children.filter((function(e){return!Me(e)})).join(""):e.props.children?e.props.children.toString():""}function Ae(e,n){var t,r,a;return null!==(t=e.props.disabled)&&void 0!==t&&t||null!==(r=null==n||null===(a=n.props)||void 0===a?void 0:a.disabled)&&void 0!==r&&r}function Le(e,n,t){return _e(e)===t&&!Ae(e,n)}function qe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.initialValue,a=t.deps,l=void 0===a?[]:a,o=n.useRef(r);return n.useMemo((function(){return{get current(){return o.current},set current(n){o.current=n,e(n)}}}),[e,o].concat(_(l)))}function Fe(e,t){var r=n.useCallback((function(e,n){Array.isArray(e)?e.forEach(r):"function"==typeof e?e(n):e&&(e.current=n)}),[]);return qe(n.useCallback((function(n){return r(e,n)}),[e,r]),{initialValue:t})}var Be,Re,Ge,Ve,We=function(e){var t=P(n.useState(e),2),r=t[0];return qe(t[1],{initialValue:e,deps:[r]})},He=l.createUniqueClassName("select-popover"),Ue=r.css(Be||(Be=I(["\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"]))),Ze=r.css(Re||(Re=I(["\n width: max-content;\n"]))),Ke=function(e,n){var t=ie[n],a=oe[e];return r.cx(r.css(Ge||(Ge=I(["\n font-family: ",";\n font-size: ","px;\n min-height: ","px;\n background-color: ",";\n border-radius: 12px;\n box-shadow: 0 4px 7px 0 ",";\n padding: 8px 0;\n "])),i.fontFamilies.default,t.option.text,t.height,a.option.background.base,a.menu.shadow))},Xe=x.default.forwardRef((function(e,t){var l=e.children,i=e.id,s=e.referenceElement,u=e.className,c=e.labelId,d=e.dropdownWidthBasis,p=e.usePortal,f=void 0===p||p,g=e.portalContainer,h=e.scrollContainer,b=e.portalClassName,m=e.popoverZIndex,y=n.useContext(le),v=y.theme,O=y.size,C=y.disabled,S=y.open,N=Fe(t,null),E=a.useAvailableSpace(s,8),T=k.default(E)?"unset":"".concat(Math.min(E,274),"px"),M=n.useCallback((function(e){N.current&&N.current.focus(),e.stopPropagation()}),[N]),P=j({popoverZIndex:m},f?{usePortal:f,portalClassName:b,portalContainer:g,scrollContainer:h}:{usePortal:f});return x.default.createElement(w.default,z({active:S&&!C,spacing:6,align:o.Align.Bottom,justify:o.Justify.Start,adjustOnMutation:!0,className:r.cx(He,u,D({},Ze,d===ae.Option)),refEl:s},P),x.default.createElement("ul",{"aria-labelledby":c,role:"listbox",ref:N,tabIndex:-1,onClick:M,className:r.cx(Ue,Ke(v,O),r.css(Ve||(Ve=I(["\n max-height: ",";\n "," {\n font-size: ","px;\n }\n "])),T,ze,pe.text)),id:i},l))}));Xe.displayName="ListMenu";var Ye,Je,$e,Qe,en,nn,tn,rn,an,ln,on,sn,un,cn,dn,pn,fn,gn,hn,bn,mn,yn,vn,xn,kn,wn,On,Cn,Sn,Nn=["children","value","text","name","deselected","readOnly","onClose","onOpen","errorMessage","state","baseFontSize","__INTERNAL__menuButtonSlot__"],En=l.createUniqueClassName("select-menu"),Tn=r.css(Ye||(Ye=I(["\n // Override button defaults\n font-weight: ",";\n > *:last-child {\n grid-template-columns: 1fr 16px;\n justify-content: flex-start;\n\n > svg {\n justify-self: right;\n width: 16px;\n height: 16px;\n }\n }\n"])),i.fontWeights.regular),jn=(D(nn={},te.Default,r.css(Je||(Je=I(["\n > *:last-child {\n padding: 0 12px;\n }\n "])))),D(nn,te.Large,r.css($e||($e=I(["\n > *:last-child {\n padding: 0 12px 0 ","px;\n }\n "])),i.spacing[3])),D(nn,te.Small,r.css(Qe||(Qe=I(["\n > *:last-child {\n padding: 0 ","px 0 10px;\n }\n "])),i.spacing[2])),D(nn,te.XSmall,r.css(en||(en=I(["\n text-transform: none;\n font-size: ","px;\n line-height: ","px;\n > *:last-child {\n padding: 0 ","px 0 10px;\n }\n "])),i.typeScales.body1.fontSize,i.typeScales.body1.lineHeight,i.spacing[1])),nn),Dn=(D(an={},l.Theme.Light,r.css(tn||(tn=I(["\n background-color: ",";\n // Override button default color\n > *:last-child {\n > svg {\n color: ",";\n }\n }\n "])),u.palette.white,u.palette.gray.dark2)),D(an,l.Theme.Dark,r.css(rn||(rn=I(["\n border-color: ",";\n background-color: ",";\n color: ",";\n\n // Override button default color\n > *:last-child {\n > svg {\n color: ",";\n }\n }\n\n &:hover,\n &:active,\n &:focus {\n background-color: ",";\n color: ",";\n }\n "])),u.palette.gray.base,u.palette.gray.dark4,u.palette.gray.light3,u.palette.gray.light1,u.palette.gray.dark4,u.palette.gray.light3)),an),zn=(D(sn={},l.Theme.Light,r.css(ln||(ln=I(["\n &:focus-visible {\n box-shadow: ",";\n border-color: rgba(255, 255, 255, 0);\n }\n "])),i.focusRing.light.input)),D(sn,l.Theme.Dark,r.css(on||(on=I(["\n &:focus-visible {\n background-color: ",";\n box-shadow: ",";\n border-color: rgba(255, 255, 255, 0);\n }\n "])),u.palette.gray.dark4,i.focusRing.dark.input)),sn),Mn=(D(dn={},l.Theme.Light,r.css(un||(un=I(["\n color: ",";\n "])),u.palette.gray.dark1)),D(dn,l.Theme.Dark,r.css(cn||(cn=I(["\n color: ",";\n\n &:hover,\n &:active,\n &:focus {\n color: ",";\n }\n "])),u.palette.gray.light1,u.palette.gray.light1)),dn),In=r.css(pn||(pn=I(["\n cursor: not-allowed;\n pointer-events: unset;\n box-shadow: unset;\n\n &:active {\n pointer-events: none;\n }\n"]))),Pn=(D(hn={},l.Theme.Light,r.cx(In,r.css(fn||(fn=I(["\n &[aria-disabled='true'] {\n background-color: ",";\n color: ",";\n\n > *:last-child {\n > svg {\n color: ",";\n }\n }\n }\n "])),u.palette.gray.light2,u.palette.gray.base,u.palette.gray.base))),D(hn,l.Theme.Dark,r.cx(In,r.css(gn||(gn=I(["\n &[aria-disabled='true'] {\n background-color: ",";\n color: ",";\n border-color: ",";\n\n > *:last-child {\n > svg {\n color: ",";\n }\n }\n }\n "])),u.palette.gray.dark3,u.palette.gray.dark2,u.palette.gray.dark2,u.palette.gray.dark2))),hn),_n=r.css(bn||(bn=I(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n flex-grow: 1;\n gap: ","px;\n overflow: hidden;\n"])),i.spacing[1]),An=r.css(mn||(mn=I(["\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n max-width: 100%;\n"]))),Ln=(D(yn={},l.Theme.Light,u.palette.red.base),D(yn,l.Theme.Dark,u.palette.red.light1),yn),qn=(D(kn={},l.Theme.Light,r.css(vn||(vn=I(["\n border-color: ",";\n background-color: ",";\n\n &:hover,\n &:active {\n box-shadow: ",";\n }\n "])),Ln[l.Theme.Light],u.palette.white,i.hoverRing.light.red)),D(kn,l.Theme.Dark,r.css(xn||(xn=I(["\n border-color: ",";\n\n &:hover,\n &:active {\n border-color: ",";\n box-shadow: ",";\n }\n "])),Ln[l.Theme.Dark],Ln[l.Theme.Dark],i.hoverRing.dark.red)),kn),Fn=x.default.forwardRef((function(e,t){var a,o,i=e.children,s=e.value,u=e.text,c=e.name,d=e.deselected;e.readOnly;var p=e.onClose,f=e.onOpen,h=e.errorMessage,b=e.state,m=e.baseFontSize,y=e.__INTERNAL__menuButtonSlot__,v=M(e,Nn),k=n.useContext(le),w=k.theme,O=k.open,C=k.size,T=k.disabled,j=Fe(t,null),P=ie[C],_=n.useCallback((function(){O?p():f(),j.current.focus()}),[p,f,O,j]),A=y||S.default,L=y?"":r.cx(Tn,Dn[w],jn[C],zn[w],(D(a={},Mn[w],d),D(a,Pn[w],T),D(a,qn[w],b===re.Error&&!!h),D(a,r.css(wn||(wn=I(["\n letter-spacing: initial;\n "]))),C===g.Size.XSmall),a),r.css(On||(On=I(["\n width: 100%;\n "," {\n height: ","px;\n font-size: ","px;\n }\n "])),ze,se,ue)),q=null!==(o=v["data-testid"])&&void 0!==o?o:"leafygreen-ui-select-menubutton";return x.default.createElement(A,z({},v,{ref:j,name:c,value:s,disabled:T,onClick:_,variant:g.Variant.Default,darkMode:w===l.Theme.Dark,rightGlyph:x.default.createElement(N.default,null),size:C,"data-testid":q,className:r.cx(L,D({},r.css(Cn||(Cn=I(["\n font-size: ","px;\n "])),m),C===g.Size.Default))}),x.default.createElement("div",{className:_n},x.default.createElement("div",{className:r.cx(En,An)},u),b===re.Error&&h&&x.default.createElement(E.default,{role:"presentation",className:r.css(Sn||(Sn=I(["\n color: ",";\n "])),Ln[w]),size:P.warningIcon})),i)}));Fn.displayName="MenuButton";var Bn,Rn,Gn,Vn,Wn,Hn,Un,Zn,Kn,Xn,Yn,Jn,$n=["children","darkMode","size","disabled","allowDeselect","usePortal","placeholder","errorMessage","state","dropdownWidthBasis","baseFontSize","id","aria-labelledby","aria-label","className","label","description","name","defaultValue","value","onChange","readOnly","portalContainer","scrollContainer","portalClassName","popoverZIndex","__INTERNAL__menuButtonSlot__"],Qn=r.css(Bn||(Bn=I(["\n display: flex;\n flex-direction: column;\n margin-bottom: ","px;\n"])),i.spacing[1]),et=r.css(Rn||(Rn=I(["\n display: flex;\n flex-direction: column;\n"]))),nt=r.css(Gn||(Gn=I(["\n font-size: ","px;\n line-height: ","px;\n"])),i.typeScales.large.fontSize,i.typeScales.large.lineHeight),tt=function(e){var n=e.darkMode,t=e.sizeSet;return r.css(Vn||(Vn=I(["\n font-family: ",";\n color: ",";\n font-size: ","px;\n margin-top: ","px;\n padding-left: 2px;\n transition: color ","ms ease-in-out;\n transition-delay: ","ms;\n"])),i.fontFamilies.default,n?u.palette.red.light1:u.palette.red.base,t.text,i.spacing[1],i.transitionDuration.faster,i.transitionDuration.faster)};function rt(e){var t,o,s,u=e.children,c=e.darkMode,d=e.size,p=void 0===d?te.Default:d,f=e.disabled,g=void 0!==f&&f,h=e.allowDeselect,b=void 0===h||h,v=e.usePortal,k=void 0===v||v,w=e.placeholder,O=void 0===w?"Select":w,C=e.errorMessage,S=void 0===C?"":C,N=e.state,E=void 0===N?re.None:N,T=e.dropdownWidthBasis,_=void 0===T?ae.Trigger:T,A=e.baseFontSize,L=void 0===A?i.BaseFontSize.Body1:A,q=e.id,F=e["aria-labelledby"],B=e["aria-label"],R=e.className,G=e.label,V=e.description,W=e.name,H=e.defaultValue,U=e.value,Z=e.onChange,K=e.readOnly,X=e.portalContainer,Y=e.scrollContainer,J=e.portalClassName,$=e.popoverZIndex,Q=e.__INTERNAL__menuButtonSlot__,ee=M(e,$n),ne=a.useIdAllocator({prefix:"select",id:q}),oe=n.useMemo((function(){return B&&!G?void 0:null!=F?F:"".concat(ne,"-label")}),[F,B,G,ne]);G||F||B||console.error("For screen-reader accessibility, label, aria-label, or aria-labelledby must be provided to Select.");var se=m.useDarkMode(c),ue=se.darkMode,pe=se.theme,fe="".concat(ne,"-description"),ge="".concat(ne,"-menu"),he=P(n.useState(!1),2),be=he[0],me=he[1],ye=We(null),xe=a.useIdAllocator({prefix:"select"}),ke=We(null),we=ie[p],Oe=n.useMemo((function(){return{theme:pe,size:p,open:be,disabled:g}}),[pe,p,be,g]);n.useEffect((function(){void 0!==U&&void 0===Z&&!0!==K&&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`.")}),[Z,K,U]);var Ce=n.useCallback((function(){me(!0)}),[]),Se=n.useCallback((function(){me(!1),ye.current.focus()}),[ye]);n.useEffect((function(){if(be){var e=function(e){var n=ye.current.contains(e.target)||ke.current.contains(e.target);me(n)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}}),[ke,ye,be]);var Ne=n.useMemo((function(){var e=null;return void 0===U&&void 0!==H&&Ie(u,(function(n,t){Le(n,t,H)&&(e=n)})),e}),[u,H,U]),Ee=P(n.useState(Ne),2),Te=Ee[0],je=Ee[1];n.useEffect((function(){var e;null!==Te&&je(null!==(e=function(e,n){var t,r,a,l,o,i,s,u;return Ie(e,(function(e){if(e===n)o=n;else if(e.props.children===n.props.children&&e.props.value===n.props.value){var t;null!==(t=i)&&void 0!==t||(i=e)}else if(void 0!==e.props.value&&e.props.value===n.props.value){var r;null!==(r=s)&&void 0!==r||(s=e)}else if(_e(e)===_e(n)){var a;null!==(a=u)&&void 0!==a||(u=e)}})),null!==(t=null!==(r=null!==(a=null!==(l=o)&&void 0!==l?l:i)&&void 0!==a?a:s)&&void 0!==r?r:u)&&void 0!==t?t:null}(u,Te))&&void 0!==e?e:Ne)}),[u,Ne,Te]);var De=n.useMemo((function(){if(void 0!==U){var e=null;return Ie(u,(function(n,t){Le(n,t,U)&&(e=n)})),e}return Te}),[u,Te,U]),Me=n.useCallback((function(e,n){void 0===U&&je(e),null==Z||Z(_e(e),n),Re(void 0),Se()}),[Z,Se,U]),qe=n.useCallback((function(e,n){return function(t){t.preventDefault(),t.stopPropagation(),g||n||(Me(e,t),Se())}}),[g,Se,Me]),Fe=P(n.useState(),2),Be=Fe[0],Re=Fe[1],Ge=n.useMemo((function(){var e=[];return b&&e.push(null),Ie(u,(function(n,t){Ae(n,t)||e.push(n)})),e}),[u,b]),Ve=n.useCallback((function(e){void 0!==Be&&Me(Be,e)}),[Be,Me]),He=n.useCallback((function(){Re(Ge[0])}),[Ge]),Ue=n.useCallback((function(){Re(Ge[Ge.length-1])}),[Ge]),Ze=n.useCallback((function(){if(void 0===Be||0===Ge.indexOf(Be))Ue();else{var e=Ge.indexOf(Be)-1;Re(Ge[e])}}),[Ge,Be,Ue]),Ke=n.useCallback((function(){if(void 0===Be||Ge.indexOf(Be)===Ge.length-1)He();else{var e=Ge.indexOf(Be)+1;Re(Ge[e])}}),[Ge,Be,He]),Ye=n.useCallback((function(e,n){return function(t){t.preventDefault(),t.stopPropagation(),g||n||Re(e)}}),[g]),Je=n.useCallback((function(e){var n,t;if(!(e.ctrlKey||e.shiftKey||e.altKey)){var r=null===(n=ke.current)||void 0===n?void 0:n.contains(document.activeElement),a=null===(t=ye.current)||void 0===t?void 0:t.contains(document.activeElement);if(a||r)switch(e.keyCode){case l.keyMap.Tab:case l.keyMap.Escape:Se(),Re(void 0);break;case l.keyMap.Enter:case l.keyMap.Space:be&&!a&&e.preventDefault(),Ve(e);break;case l.keyMap.ArrowUp:!be&&a&&Ce(),e.preventDefault(),Ze();break;case l.keyMap.ArrowDown:!be&&a&&Ce(),e.preventDefault(),Ke()}}}),[ke,ye,Se,be,Ve,Ze,Ke,Ce]);a.useEventListener("keydown",Je);var $e=a.useViewportSize(),Qe=n.useMemo((function(){var e=!1;return Ie(u,(function(n){e||(e=void 0!==n.props.glyph)})),e}),[u]),en=n.useMemo((function(){return null!==$e&&null!==ke.current&&void 0===Be&&be}),[Be,ke,be,$e]),nn=n.useMemo((function(){var e=null===De;return x.default.createElement(ve,{className:void 0,glyph:void 0,selected:e,focused:null===Be,disabled:!1,onClick:qe(null,!1),onFocus:Ye(null,!1),hasGlyphs:!1,triggerScrollIntoView:e&&en},O)}),[en,Be,qe,Ye,O,De]),tn=n.useMemo((function(){return Pe(u,(function(e,n){var t=e===De,r=Ae(e,n);return j(j({},e.props),{},{className:e.props.className,glyph:e.props.glyph,selected:t,focused:e===Be,disabled:r,children:e.props.children,hasGlyphs:Qe,onClick:qe(e,r),onFocus:Ye(e,r),triggerScrollIntoView:t&&en})}),(function(){console.error("`Select` instance received child that is not `Option` or `OptionGroup`.")}))}),[en,u,Be,qe,Ye,Qe,De]),rn=j({popoverZIndex:$},k?{usePortal:k,portalClassName:J,portalContainer:X,scrollContainer:Y}:{usePortal:k});return x.default.createElement("div",{className:r.cx(et,R)},(G||V)&&x.default.createElement("div",{className:Qn},G&&x.default.createElement(y.Label,{htmlFor:xe,id:oe,darkMode:ue,disabled:g,className:r.cx((t={},D(t,nt,p===te.Large),D(t,r.css(Wn||(Wn=I(["\n font-size: ","px;\n line-height: 20px;\n "])),L),p===te.Default),t),r.css(Hn||(Hn=I(["\n // Prevent hover state from showing when hovering label\n pointer-events: none;\n "]))),r.css(Un||(Un=I(["\n "," {\n font-size: ","px;\n line-height: ","px;\n }\n "])),ze,ce.text,ce.lineHeight))},G),V&&x.default.createElement(y.Description,{id:fe,darkMode:ue,disabled:g,className:r.cx((o={},D(o,nt,p===te.Large),D(o,r.css(Zn||(Zn=I(["\n font-size: ","px;\n line-height: 20px;\n "])),L),p===te.Default),o),r.css(Kn||(Kn=I(["\n "," {\n font-size: ","px;\n line-height: ","px;\n }\n "])),ze,de.text,de.lineHeight))},V)),x.default.createElement(le.Provider,{value:Oe},x.default.createElement(Fn,z({},ee,{id:xe,ref:ye,name:W,readOnly:K,value:_e(De),text:null!==De?De.props.children:O,deselected:null===De,onOpen:Ce,onClose:Se,"aria-labelledby":oe,"aria-label":G||F?void 0:B,"aria-controls":ge,"aria-expanded":be,"aria-describedby":fe,"aria-invalid":E===re.Error,"aria-disabled":g,errorMessage:S,state:E,baseFontSize:L,__INTERNAL__menuButtonSlot__:Q}),x.default.createElement(Xe,z({labelId:oe,id:ge,referenceElement:ye,ref:ke,className:r.cx(D({},r.css(Xn||(Xn=I(["\n width: ","px;\n "])),null===(s=ye.current)||void 0===s?void 0:s.clientWidth),_===ae.Trigger)),dropdownWidthBasis:_},rn),b&&nn,tn))),E===re.Error&&S&&x.default.createElement("span",{className:r.cx(tt({darkMode:ue,sizeSet:we}),r.css(Yn||(Yn=I(["\n "," {\n font-size: ","px;\n line-height: ","px;\n }\n "])),ze,de.text,de.lineHeight),D({},r.css(Jn||(Jn=I(["\n // Hide error text when menu is open,\n // so it doesn't peek around the menu corner\n color: transparent;\n "]))),be))},S))}rt.displayName="Select",rt.propTypes={label:O.default.string,"aria-labelledby":O.default.string,"aria-label":O.default.string,description:O.default.string,placeholder:O.default.string,className:O.default.string,darkMode:O.default.bool,size:O.default.oneOf(Object.values(te)),disabled:O.default.bool,id:O.default.string,value:O.default.string,defaultValue:O.default.string,onChange:O.default.func,readOnly:O.default.bool,errorMessage:O.default.string,state:O.default.oneOf(Object.values(re)),allowDeselect:O.default.bool,baseFontSize:O.default.oneOf(Object.values(i.BaseFontSize)),dropdownWidthBasis:O.default.oneOf(Object.values(ae))},e.DropdownWidthBasis=ae,e.Option=xe,e.OptionGroup=Te,e.Select=rt,e.Size=te,e.State=re,e.menuButtonTextClassName=En,e.popoverClassName=He})); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@leafygreen-ui/select", | ||
"version": "10.3.9", | ||
"version": "10.3.10", | ||
"description": "leafyGreen UI Kit Select", | ||
@@ -25,3 +25,3 @@ "main": "./dist/index.js", | ||
"dependencies": { | ||
"@leafygreen-ui/button": "^21.0.0", | ||
"@leafygreen-ui/button": "^21.0.1", | ||
"@leafygreen-ui/emotion": "^4.0.5", | ||
@@ -28,0 +28,0 @@ "@leafygreen-ui/hooks": "^7.7.6", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
396996