import{__rest as e}from"../../../_virtual/_tslib.js";import a,{forwardRef as t,useRef as n,useMemo as r}from"react";import i from"classnames";import o from"./hooks/useNumberFieldState.js";import l from"./hooks/useSpinButtonHandlers.js";import{BaseInput as s}from"@vibe/base/mockedClassNames";import m from"../FieldLabel/FieldLabel.js";import d from"../InfoText/InfoText.js";import{Icon as u}from"@vibe/icon/mockedClassNames";import c from"./components/NumberFieldSpinButton/NumberFieldSpinButton.js";import f from"./NumberField.module.scss.js";import{Flex as b}from"@vibe/layout/mockedClassNames";import p from"../../hooks/useMergeRef.js";import{ComponentVibeId as v}from"../../tests/constants.js";var h=t((function(t,h){var x=t.className,y=t.value,O=t.onChange,g=t.label,N=t.required,C=t.placeholder,j=t.infoText,F=t.error,I=t.success,B=t.disabled,E=t.readOnly,w=t.min,M=t.max,k=t.step,D=void 0===k?1:k,R=t.size,T=void 0===R?"medium":R,V=t.leftIcon,q=t["aria-label"],z=t.id,A=t["data-testid"],L=t.allowOutOfBounds,S=t.onValidityChange,_=e(t,["className","value","onChange","label","required","placeholder","infoText","error","success","disabled","readOnly","min","max","step","size","leftIcon","aria-label","id","data-testid","allowOutOfBounds","onValidityChange"]),K=n(null),H=p(h,K),U=o({value:y,onChange:O,min:w,max:M,step:D,disabled:B,readOnly:E,allowOutOfBounds:L,onValidityChange:S}),G=U.inputValue,J=U.numericValue,P=U.onChange,Q=U.onKeyDown,W=U.isAtMin,X=U.isAtMax,Y=l({onChange:O,value:J,step:D,min:w,max:M,allowOutOfBounds:L,readOnly:E,inputRef:K}),Z=Y.onIncrement,$=Y.onDecrement,ee=r((function(){return V?a.createElement(u,{icon:V,className:f.leftIcon}):null}),[V]),ae=r((function(){return a.createElement(c,{inputId:z,onIncrement:Z,onDecrement:$,disabled:B||E,size:T,isAtMin:W,isAtMax:X})}),[z,Z,$,B,E,T,W,X]),te=r((function(){return j&&z?"".concat(z,"-info-text"):void 0}),[j,z]),ne=r((function(){return g&&z?"".concat(z,"-label"):void 0}),[g,z]);return a.createElement(b,{direction:"column",align:"stretch",gap:"xs",className:i(f.numberField,x),"data-vibe":v.NUMBER_FIELD},a.createElement(m,{id:ne,className:f.label,labelText:g,required:N,labelFor:z}),a.createElement(s,Object.assign({},_,{"data-testid":A,ref:H,id:z,value:G,onChange:P,onKeyDown:Q,placeholder:C,type:"text",inputMode:"numeric",inputRole:"spinbutton","aria-valuenow":J,"aria-valuemin":w,"aria-valuemax":M,"aria-required":N,"aria-label":q||g,"aria-labelledby":ne,"aria-describedby":te,disabled:B,readOnly:E,size:T,error:F,success:I,renderLeft:ee,renderRight:ae})),a.createElement(d,{id:te,text:j,error:F,success:I,disabled:B,readOnly:E}))}));export{h as default};
//# sourceMappingURL=NumberField.js.map
