import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["controlRef","size","getOptionProps","dropdownRef","labelForCreate","className","labelForNotFound","labelForEmptyItems","hasItems","form","isOpen","offset","renderItem","visibleItems","isLoading","getGroupLabel","notFound"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"./SelectDropdown.css";import React,{Fragment,useMemo,useRef}from"react";import{Transition}from"react-transition-group";import{cnListBox,ListItem,mapVerticalSpase}from"../../ListCanary";import{cnMixScrollBar}from"../../../mixs/MixScrollBar";import{cnMixSpace}from"../../../mixs/MixSpace";import{isOptionForCreate,isOptionForSelectAll}from"../../../hooks/useSelect/useSelect";import{animateTimeout,cnMixPopoverAnimate}from"../../../mixs/MixPopoverAnimate/MixPopoverAnimate";import{cn}from"../../../utils/bem";import{fabricIndex}from"../../../utils/fabricIndex";import{Popover}from"../../Popover/Popover";import{SelectCreateButton}from"../SelectCreateButton/SelectCreateButton";import{SelectGroupLabel}from"../SelectGroupLabel/SelectGroupLabel";import{SelectItemAll}from"../SelectItemAll/SelectSelectAll";import{SelectLoader}from"../SelectLoader/SelectLoader";export var selectDropdownform=["default","brick","round"];export var defaultSelectDropdownPropForm=selectDropdownform[0];var cnSelectDropdown=cn("SelectDropdown");export var SelectDropdown=function(a){var b=a.controlRef,c=a.size,d=a.getOptionProps,e=a.dropdownRef,f=a.labelForCreate,g=a.className,h=a.labelForNotFound,i=a.labelForEmptyItems,j=a.hasItems,k=!(void 0!==j)||j,l=a.form,m=a.isOpen,n=a.offset,o=void 0===n?"none":n,p=a.renderItem,q=a.visibleItems,r=a.isLoading,s=a.getGroupLabel,t=a.notFound,u=_objectWithoutProperties(a,_excluded),v="round"===l?"increased":"normal",w=useRef(null),x=useMemo(function(){return 0<q.filter(function(a){return isOptionForCreate(a)||Array.isArray(a.items)&&0<a.items.length}).length},[q]),y="none"===o?void 0:o;return React.createElement(Transition,{in:m,unmountOnExit:!0,nodeRef:w,timeout:animateTimeout},function(a){var j=fabricIndex();return React.createElement(Popover,Object.assign({},u,{anchorRef:b,direction:"downStartLeft",possibleDirections:["downStartLeft","upStartLeft","downStartRight","upStartRight"],offset:y,ref:w,role:"listbox",className:cnSelectDropdown(null,[cnListBox({size:c,form:l,border:!0,shadow:!0}),cnMixPopoverAnimate({animate:a}),g]),equalAnchorWidth:!0}),React.createElement("div",{className:cnSelectDropdown("List",[cnMixSpace({pV:mapVerticalSpase[c]}),cnMixScrollBar()]),ref:e},r&&React.createElement(SelectLoader,{mode:x?"blur":"empty"}),q.map(function(a){return isOptionForCreate(a)?React.createElement(SelectCreateButton,Object.assign({size:c,labelForCreate:f,inputValue:a.label,indent:v},d({index:j(),item:a}))):React.createElement(Fragment,{key:a.key},a.group&&s&&React.createElement(SelectGroupLabel,{label:s(a.group),size:c,indent:v}),a.items.map(function(b,e){return isOptionForSelectAll(b)?React.createElement(SelectItemAll,Object.assign({indent:v,size:c},d({index:j(),item:b}),{intermediate:!!(b.checkedCount&&b.totalCount)&&b.checkedCount!==b.totalCount,checked:b.checkedCount===b.totalCount,countItems:b.checkedCount,total:b.totalCount})):React.createElement(Fragment,{key:"".concat(a.key,"-").concat(e)},p(_objectSpread({item:b},d({index:j(),item:b}))))}))}),!r&&k&&t&&h&&React.createElement(ListItem,{size:c,label:h,innerOffset:v},h),!r&&!k&&i&&React.createElement(ListItem,{size:c,label:i,innerOffset:v},i)))})};
//# sourceMappingURL=SelectDropdown.js.map