import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["size","form","view","width","onlyIcon","iconSize","value","multiple","items","getItemLabel","onChange","getItemIcon","getItemAttributes","getItemRef","getItemDisabled","name","className","disabled","truncate"];import"./ChoiceGroup.css";import React,{forwardRef}from"react";import{useChoiceGroup}from"../../hooks/useChoiceGroup/useChoiceGroup";import{cn}from"../../utils/bem";import{getByMap}from"../../utils/getByMap";import{withDefaultGetters}from"./helper";import{ChoiceGroupItem}from"./Item/ChoiceGroup-Item";import{choiceGroupDefaultForm,choiceGroupDefaultSize,choiceGroupDefaultView,choiceGroupWidthDefault}from"./types";var sizeMap={xs:"xs",s:"xs",m:"s",l:"m"};export var cnChoiceGroup=cn("ChoiceGroup");var ChoiceGroupRender=function(a,b){var c=withDefaultGetters(a),d=c.size,e=void 0===d?choiceGroupDefaultSize:d,f=c.form,g=void 0===f?choiceGroupDefaultForm:f,h=c.view,i=void 0===h?choiceGroupDefaultView:h,j=c.width,k=void 0===j?choiceGroupWidthDefault:j,l=c.onlyIcon,m=c.iconSize,n=c.value,o=void 0===n?null:n,p=c.multiple,q=void 0!==p&&p,r=c.items,s=c.getItemLabel,t=c.onChange,u=c.getItemIcon,v=c.getItemAttributes,w=c.getItemRef,x=c.getItemDisabled,y=c.name,z=c.className,A=c.disabled,B=void 0!==A&&A,C=c.truncate,D=_objectWithoutProperties(c,_excluded),E=useChoiceGroup({value:o,getKey:s,callBack:t,multiple:q}),F=E.getOnChange,G=E.getChecked,H=getByMap(sizeMap,e,m);return React.createElement("div",Object.assign({},D,{ref:b,className:cnChoiceGroup({size:e,form:g,view:i,width:k,onlyIcon:l,disabled:B,truncate:C},[z])}),r.map(function(a,b){var c,d=G(a),e=!!x&&x(a),f=null!==(c=v(a))&&void 0!==c?c:{};return React.createElement(React.Fragment,{key:s(a)},0<b&&React.createElement("div",{className:cnChoiceGroup("Divider",{checked:d,disabled:e})}),React.createElement(ChoiceGroupItem,Object.assign({onChange:F(a),checked:d,label:s(a).toString(),icon:u&&u(a),iconSize:H,multiple:q,onlyIcon:l,ref:w(a),name:y,disabled:B||e},f)))}))};export var ChoiceGroup=forwardRef(ChoiceGroupRender);export*from"./types";
//# sourceMappingURL=ChoiceGroup.js.map