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","getGroupKey","getItemDisabled","getItemGroupKey","getItemKey","getItemLabel","items","onChange","dropdownClassName","onFocus","onBlur","onCreate","onInput","multiple","groups","onDropdownOpen","ignoreOutsideClicksRefs","clearButton","selectAll","selectAllLabel"];import"./SelectMultiple.css";import{useAction}from"@reatom/npm-react";import React,{forwardRef,useRef}from"react";import{FieldArrayValueInlineControl,FieldArrayValueItem}from"../../FieldComponents";import{SelectDropdown}from"../SelectDropdown";import{SelectItem}from"../SelectItem";import{useForkRef}from"../../../hooks/useForkRef";import{cnMixScrollBar}from"../../../mixs/MixScrollBar";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{useSelect}from"../useSelect";var cnSelectMultiple=cn("SelectMultiple"),SelectMultipleRender=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.getGroupKey,D=c.getItemDisabled,E=c.getItemGroupKey,F=c.getItemKey,G=c.getItemLabel,H=c.items,I=c.onChange,J=c.dropdownClassName,K=c.onFocus,L=c.onBlur,M=c.onCreate,N=c.onInput,O=c.multiple,P=c.groups,Q=c.onDropdownOpen,R=c.ignoreOutsideClicksRefs,S=c.clearButton,T=c.selectAll,U=c.selectAllLabel,V=_objectWithoutProperties(c,_excluded),W=useSelect({propsAtom:d}),X=W.getOptionActions,Y=W.openAtom,Z=W.visibleItemsAtom,$=W.focusAtom,_=W.handleInputFocus,aa=W.handleInputBlur,ba=W.handleToggleDropdown,ca=W.inputRef,da=W.handleInputClick,ea=W.handleInputChange,fa=W.clearValue,ga=W.optionsRefs,ha=W.controlRef,ia=W.dropdownRef,ja=W.clearButtonAtom,ka=W.highlightedIndexAtom,la=W.getItemKeyAtom,ma=W.valueAtom,na=W.onChangeAll,oa=W.highlightIndex,pa=W.onCreate,qa=W.onChange,ra=W.inputValueAtom,sa=W.getHandleRemoveValue,ta=W.hasItemsAtom,ua=W.groupsCounterAtom,va=W.dropdownZIndexAtom,wa=useRef(null),xa=useAction(function(a,b){var c=b.value,e=b.getRemove,f=a.get(d),g=f.disabled,h=f.getItemDisabled,i=f.getItemKey,j=f.size,k=f.getItemLabel;return c.map(function(a){var b=g||h(a);return React.createElement(FieldArrayValueItem,{key:i(a),size:j,label:k(a),disabled:b,onRemove:b?void 0:e(a)})})}),ya=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.getItemDisabled,l=j.size,m=j.getItemLabel,n=j.dropdownForm;return React.createElement(SelectItem,{label:m(c),active:e,hovered:f,size:l,indent:"round"===n?"increased":"normal",onClick:g,onMouseEnter:h,disabled:k(c),ref:i,multiple:!0})}),za=useAction(function(a,b){var c=a.get(d),e=c.renderValue;return(e||xa)({value:b,getRemove:sa})});return React.createElement(React.Fragment,null,React.createElement(SelectControlLayout,Object.assign({},V,{style:t,className:cnSelectMultiple(null,[u]),form:e,status:f,size:g,disabled:h,separator:!0,onClear:fa,onDropdownButton:ba,openAtom:Y,focusAtom:$,view:w,iconClear:x,clearButtonAtom:ja,ref:useForkRef([b,ha])}),React.createElement(FieldArrayValueInlineControl,{className:cnSelectMultiple("Value",[cnMixScrollBar({size:"xs",trackSize:"auto"})]),onFocus:_,onBlur:aa,onClick:da,value:i||void 0,disabled:h,placeholder:v,renderValue:za,size:g,disableInput:!y||void 0,inputRef:useForkRef([ca,B]),ref:wa,inputDefaultValue:y?A:void 0,onChange:ea})),React.createElement(SelectDropdown,{valueAtom:ma,getItemKeyAtom:la,openAtom:Y,size:g,controlRef:ha,getOptionActions:X,dropdownRef:useForkRef([ia,l]),form:m,className:J,renderItem:n||ya,getGroupLabel:o,visibleItemsAtom:Z,labelForCreate:p,isLoading:k,labelForEmptyItems:q,itemsRefs:ga,virtualScroll:r,onScrollToBottom:s,highlightedIndexAtom:ka,highlightIndex:oa,onChangeAll:na,onCreate:pa,onChange:qa,inputValueAtom:ra,hasItemsAtom:ta,groupsCounterAtom:ua,dropdownZIndexAtom:va,selectAllLabel:U}))};export var SelectMultiple=withCtx(forwardRef(SelectMultipleRender));
//# sourceMappingURL=SelectMultiple.js.map