import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["as","label","size","status","activeView","className","interactive","style","active","iconLeft","iconRight","onRightIconClick","onKeyUp","tabIndex"];import"./ChipsItem.css";import React,{useRef}from"react";import{Badge}from"../../Badge";import{useForkRef}from"../../../hooks/useForkRef";import{useKeys}from"../../../hooks/useKeys";import{cnMixFocus}from"../../../mixs/MixFocus";import{cn}from"../../../utils/bem";import{forwardRefWithAs}from"../../../utils/types/PropsWithAsAttributes";import{chipsPropActiveViewDefault,chipsPropSizeDefault}from"../types";var cnChip=cn("ChipsItem"),iconSizeMap={l:"m",m:"s",s:"s",xs:"xs"};export var ChipsItem=forwardRefWithAs(function(a,b){var c=a.as,d=void 0===c?"span":c,e=a.label,f=a.size,g=void 0===f?chipsPropSizeDefault:f,h=a.status,i=a.activeView,j=void 0===i?chipsPropActiveViewDefault:i,k=a.className,l=a.interactive,m=a.style,n=a.active,o=a.iconLeft,p=a.iconRight,q=a.onRightIconClick,r=a.onKeyUp,s=a.tabIndex,t=_objectWithoutProperties(a,_excluded),u=useRef(null),v=useRef(null),w=useKeys({keys:{Enter:function Enter(){if(v&&q){var a;null===(a=v.current)||void 0===a?void 0:a.focus()}else{var b;null===(b=u.current)||void 0===b?void 0:b.click()}},Escape:function Escape(){if(v&&q){var a;null===(a=u.current)||void 0===a?void 0:a.focus()}},Space:function Space(){var a;null===(a=u.current)||void 0===a?void 0:a.click()}},onEvent:r,isActive:!!l});return React.createElement(d,Object.assign({},t,{className:cnChip({size:g,interactive:l,activeView:j,active:n,status:!!h},[l?cnMixFocus():void 0,k]),ref:useForkRef([u,b]),onKeyUp:w,tabIndex:l?s||0:void 0,role:l?"button":void 0}),h&&React.createElement(Badge,{status:h,size:iconSizeMap[g],minified:!0}),!h&&o&&React.createElement(o,{size:iconSizeMap[g]}),e,p&&React.createElement(p,Object.assign({size:iconSizeMap[g]},q?{as:"button",role:"button",type:"button",onClick:q,className:cnChip("IconButton",[cnMixFocus()]),ref:v,tabIndex:-1}:{})))});
//# sourceMappingURL=ChipsItem.js.map