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","incrementButtons","max","min","step","onKeyDown","onKeyDownCapture","onKeyUp","onKeyUpCapture","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onClear","onWheel","iconClear"];import React,{forwardRef,useCallback,useMemo}from"react";import{FieldClearButton,FieldControlLayout,FieldCounter,FieldInput,renderSide}from"../../FieldComponents";import{useForkRef}from"../../../hooks/useForkRef";import{useKeys}from"../../../hooks/useKeys";import{useMutableRef}from"../../../hooks/useMutableRef/useMutableRef";import{useSortSteps}from"../../../hooks/useSortSteps";import{useTextField}from"../useTextField";import{cnTextFieldTypeNumber}from"./cnTextFieldTypeNumber";import{getValueByStep,stepIsActive}from"./helpers";export var TextFieldTypeNumber=forwardRef(function(a,b){var c=a.className,d=a.value,e=a.defaultValue,f=a.onChange,g=a.id,h=a.name,i=a.inputRef,j=a.maxLength,k=a.disabled,l=a.size,m=void 0===l?"m":l,n=a.view,o=void 0===n?"default":n,p=a.form,q=a.status,r=a.onBlur,s=a.onFocus,t=a.autoFocus,u=a.placeholder,v=a.leftSide,w=a.rightSide,x=a.autoComplete,y=a.clearButton,z=a.readOnly,A=a.type,B=a.tabIndex,C=a.ariaLabel,D=a.iconSize,E=a.onClick,F=a.incrementButtons,G=a.max,H=a.min,I=a.step,J=a.onKeyDown,K=a.onKeyDownCapture,L=a.onKeyUp,M=a.onKeyUpCapture,N=a.onCopy,O=a.onCopyCapture,P=a.onCut,Q=a.onCutCapture,R=a.onPaste,S=a.onPasteCapture,T=a.onClear,U=a.onWheel,V=a.iconClear,W=_objectWithoutProperties(a,_excluded),X=useTextField({onClick:E,onChange:f,onBlur:r,onFocus:s,disabled:k,onClear:T}),Y=X.handleBlur,Z=X.handleChange,$=X.handleClear,_=X.handleFocus,aa=X.focused,ba=X.withValue,ca=X.ref,da=X.inputRef,ea=X.handleClick,fa=X.mutableRefs,ga=X.setWithValue,ha=useSortSteps({step:I,min:H,max:G}),ia=useMutableRef([ha,H,G,J,stepIsActive(ha,k),U]),ja=useCallback(function(a,b){var c,d;if(da.current&&!fa.current[4]){var e=getValueByStep(ia.current[0],da.current.value,b,ia.current[1],ia.current[2]);null===(c=(d=fa.current)[0])||void 0===c?void 0:c.call(d,e,{e:a}),da.current.value=e,ga.on()}},[]),ka=useCallback(function(a){return ja(a,!0)},[]),la=useCallback(function(a){return ja(a,!1)},[]),ma=useKeys(useMemo(function(){return{isActive:!0,keys:{ArrowUp:function ArrowUp(a){a.preventDefault(),ia.current[4]&&ja(a,!0)},ArrowDown:function ArrowDown(a){a.preventDefault(),ia.current[4]&&ja(a,!1)}},onEvent:ia.current[3]}},[])),na=useCallback(function(a){if(ia.current[5])ia.current[5](a);else{var b;null===(b=da.current)||void 0===b?void 0:b.blur()}},[]);return React.createElement(FieldControlLayout,Object.assign({},W,{className:cnTextFieldTypeNumber({incrementButtons:F},[c]),form:p,status:q,size:m,leftSide:renderSide(v,m,D),rightSide:[y&&!k&&ba&&!F&&React.createElement(FieldClearButton,{size:m,onClick:$,icon:V}),F&&ia.current[4]&&React.createElement(FieldCounter,{onIncrementClick:ka,onIncrementFocus:_,onDecrementClick:la,onDecrementFocus:_})],focused:aa,view:o,ref:useForkRef([b,ca]),disabled:k,onClick:ea}),React.createElement(FieldInput,{className:cnTextFieldTypeNumber("Input"),placeholder:u,autoFocus:t,autoComplete:x,onBlur:Y,onChange:Z,onFocus:_,defaultValue:e||void 0,value:null===d?"":d,ref:useForkRef([i,da]),readOnly:z,tabIndex:B,"aria-label":C,onKeyDown:ma,onKeyDownCapture:K,onKeyUp:L,onKeyUpCapture:M,onWheel:na,maxLength:j,disabled:k,type:A,max:G,min:H,id:g,name:h,onCopy:N,onCopyCapture:O,onCut:P,onCutCapture:Q,onPaste:R,onPasteCapture:S}))});
//# sourceMappingURL=TextFieldTypeNumber.js.map