import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["form","status","size","disabled","value","renderValue","isLoading","dropdownRef","dropdownForm","renderItem","getGroupLabel","labelForCreate","labelForEmptyItems","virtualScroll","onScrollToBottom","style","className","placeholder","view","iconClear","input","inputValue","inputDefaultValue","inputRef","aria-label","getGroupKey","getItemDisabled","getItemGroupKey","getItemKey","getItemLabel","items","onChange","dropdownClassName","onFocus","onBlur","onCreate","onInput","multiple","groups","onDropdownOpen","ignoreOutsideClicksRefs","clearButton","selectAll","selectAllLabel"];import{useAction}from"@reatom/npm-react";import React,{forwardRef}from"react";import{SelectDropdown}from"../SelectDropdown";import{SelectItem}from"../SelectItem";import{useForkRef}from"../../../hooks/useForkRef";import{cnCanary as cn}from"../../../utils/bem";import{useSendToAtom}from"../../../utils/state";import{withCtx}from"../../../utils/state/withCtx";import{withDefault}from"../defaultProps";import{SelectControlLayout}from"../SelectControlLayout";import{SelectInput}from"../SelectInput";import{useSelect}from"../useSelect";var cnSelectSingle=cn("SelectSelectSingleMultiple"),SelectSingleRender=function(a,b){var c=withDefault(a),d=useSendToAtom(c),e=c.form,f=c.status,g=c.size,h=c.disabled,i=c.value,j=c.renderValue,k=c.isLoading,l=c.dropdownRef,m=c.dropdownForm,n=c.renderItem,o=c.getGroupLabel,p=c.labelForCreate,q=c.labelForEmptyItems,r=c.virtualScroll,s=c.onScrollToBottom,t=c.style,u=c.className,v=c.placeholder,w=c.view,x=c.iconClear,y=c.input,z=c.inputValue,A=c.inputDefaultValue,B=c.inputRef,C=c["aria-label"],D=c.getGroupKey,E=c.getItemDisabled,F=c.getItemGroupKey,G=c.getItemKey,H=c.getItemLabel,I=c.items,J=c.onChange,K=c.dropdownClassName,L=c.onFocus,M=c.onBlur,N=c.onCreate,O=c.onInput,P=c.multiple,Q=c.groups,R=c.onDropdownOpen,S=c.ignoreOutsideClicksRefs,T=c.clearButton,U=c.selectAll,V=c.selectAllLabel,W=_objectWithoutProperties(c,_excluded),X=useAction(function(a,b){var c=b.value;return a.get(d).getItemLabel(c)},[]),Y=useAction(function(a,b){var c=b.item,e=b.active,f=b.hovered,g=b.onClick,h=b.onMouseEnter,i=b.ref,j=a.get(d),k=j.getItemLabel,l=j.size,m=j.dropdownForm,n=j.getItemDisabled;return console.log(n,l,k),React.createElement(SelectItem,{label:k(c),active:e,hovered:f,size:l,indent:"round"===m?"increased":"normal",onClick:g,onMouseEnter:h,disabled:n(c),ref:i})},[]),Z=useSelect({propsAtom:d}),$=Z.getOptionActions,_=Z.openAtom,aa=Z.visibleItemsAtom,ba=Z.focusAtom,ca=Z.handleInputFocus,da=Z.handleInputBlur,ea=Z.handleToggleDropdown,fa=Z.inputRef,ga=Z.handleInputClick,ha=Z.handleInputChange,ia=Z.clearValue,ja=Z.optionsRefs,ka=Z.controlRef,la=Z.dropdownRef,ma=Z.clearButtonAtom,na=Z.highlightedIndexAtom,oa=Z.getItemKeyAtom,pa=Z.valueAtom,qa=Z.onChangeAll,ra=Z.highlightIndex,sa=Z.onCreate,ta=Z.onChange,ua=Z.inputValueAtom,va=Z.hasItemsAtom,wa=Z.groupsCounterAtom,xa=Z.dropdownZIndexAtom;return React.createElement(React.Fragment,null,React.createElement(SelectControlLayout,Object.assign({},W,{style:t,className:cnSelectSingle(null,[u]),form:e,status:f,size:g,disabled:h,separator:!0,onClear:ia,onDropdownButton:ea,openAtom:_,focusAtom:ba,view:w,iconClear:x,clearButtonAtom:ma,ref:useForkRef([b,ka])}),React.createElement(SelectInput,{onFocus:ca,onBlur:da,ref:useForkRef([fa,B]),onClick:ga,onChange:y?ha:void 0,value:y?z:void 0,defaultValue:y?A:void 0,readOnly:!y||void 0,disabled:h,placeholder:v,"aria-label":C},i&&(j||X)({value:i}))),React.createElement(SelectDropdown,{valueAtom:pa,getItemKeyAtom:oa,openAtom:_,size:g,controlRef:ka,getOptionActions:$,dropdownRef:useForkRef([la,l]),form:m,className:K,renderItem:n||Y,getGroupLabel:o,visibleItemsAtom:aa,labelForCreate:p,isLoading:k,labelForEmptyItems:q,itemsRefs:ja,virtualScroll:r,onScrollToBottom:s,highlightedIndexAtom:na,highlightIndex:ra,onChangeAll:qa,onCreate:sa,onChange:ta,inputValueAtom:ua,hasItemsAtom:va,groupsCounterAtom:wa,dropdownZIndexAtom:xa,selectAllLabel:V}))};export var SelectSingle=withCtx(forwardRef(SelectSingleRender));
//# sourceMappingURL=SelectSingle.js.map