import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["className","value","defaultValue","onChange","id","name","inputRef","maxLength","disabled","size","view","form","status","onBlur","onFocus","autoFocus","placeholder","leftSide","rightSide","autoComplete","clearButton","readOnly","type","tabIndex","ariaLabel","iconSize","onClick","resize","rows","minRows","maxRows","onKeyDown","onKeyDownCapture","onKeyUp","onKeyUpCapture","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onClear","onWheel","iconClear"];import"./TextFieldTypeTextArea.css";import React,{forwardRef}from"react";import TextAreaAutoSize from"react-textarea-autosize";import{cnFieldInput,FieldClearButton,FieldControlLayout,renderSide}from"../../FieldComponents";import{useForkRef}from"../../../hooks/useForkRef";import{useRefs}from"../../../hooks/useRefs";import{getElementWidth,useResizeObserved}from"../../../hooks/useResizeObserved";import{cnMixScrollBar}from"../../../mixs/MixScrollBar";import{cn}from"../../../utils/bem";import{useTextField}from"../useTextField";export var cnTextFieldTypeTextArea=cn("TextFieldTypeTextArea");export var TextFieldTypeTextArea=forwardRef(function(a,b){var c,d=a.className,e=a.value,f=a.defaultValue,g=a.onChange,h=a.id,i=a.name,j=a.inputRef,k=a.maxLength,l=a.disabled,m=a.size,n=void 0===m?"m":m,o=a.view,p=void 0===o?"default":o,q=a.form,r=a.status,s=a.onBlur,t=a.onFocus,u=a.autoFocus,v=a.placeholder,w=a.leftSide,x=a.rightSide,y=a.autoComplete,z=a.clearButton,A=a.readOnly,B=a.type,C=a.tabIndex,D=a.ariaLabel,E=a.iconSize,F=a.onClick,G=a.resize,H=a.rows,I=a.minRows,J=a.maxRows,K=a.onKeyDown,L=a.onKeyDownCapture,M=a.onKeyUp,N=a.onKeyUpCapture,O=a.onCopy,P=a.onCopyCapture,Q=a.onCut,R=a.onCutCapture,S=a.onPaste,T=a.onPasteCapture,U=a.onClear,V=a.onWheel,W=a.iconClear,X=_objectWithoutProperties(a,_excluded),Y=useTextField({onClick:F,onChange:g,onBlur:s,onFocus:t,disabled:l,onClear:U}),Z=Y.handleBlur,$=Y.handleChange,_=Y.handleClear,aa=Y.handleFocus,ba=Y.focused,ca=Y.withValue,da=Y.ref,ea=Y.inputRef,fa=Y.handleClick,ga=useRefs(2,[!!x,z&&!l&&ca]),ha=useResizeObserved(ga,getElementWidth),ia={className:cnTextFieldTypeTextArea("TextArea",[cnFieldInput(),cnMixScrollBar({size:"xs",trackSize:"native"})]),placeholder:v,autoComplete:y,onBlur:Z,onChange:$,onFocus:aa,defaultValue:f||void 0,value:null===e?"":e,ref:useForkRef([j,ea]),readOnly:A,tabIndex:C,"aria-label":D,onKeyDown:K,onKeyDownCapture:L,onKeyUp:M,onKeyUpCapture:N,maxLength:k,disabled:l,id:h,name:i,autoFocus:u,onCopy:O,onCopyCapture:P,onCut:Q,onCutCapture:R,onPaste:S,onPasteCapture:T,onWheel:V};return React.createElement(FieldControlLayout,Object.assign({},X,{className:cnTextFieldTypeTextArea({resize:G},[d]),form:q,status:r,size:n,leftSide:renderSide(w,n,E),rightSide:[z&&!l&&ca&&React.createElement(FieldClearButton,{size:n,onClick:_,icon:W}),renderSide(x,n,E)],focused:ba,view:p,ref:useForkRef([b,da]),disabled:l,onClick:fa,style:(c={},_defineProperty(c,"--text-field-textarea-slot-sizes-width","".concat(ha.reduce(function(c,a){return c+a}),"px")),_defineProperty(c,"--text-field-textarea-slot-sizes-length",ha.filter(function(a){return!!a}).length),c),rightSlotsRefs:ga}),"auto"===G?React.createElement(TextAreaAutoSize,Object.assign({},ia,{minRows:I||H,maxRows:J||H})):React.createElement("textarea",Object.assign({},ia,{rows:H})))});
//# sourceMappingURL=TextFieldTypeTextArea.js.map