text: var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireDefault(require("react"));var _hooks=require("../../../hooks");var _FormControl=require("../FormControl");var _Context=require("./Context");var _Box=_interopRequireDefault(require("../../primitives/Box"));var _useHasResponsiveProps=require("../../../hooks/useHasResponsiveProps");var _this=this,_jsxFileName="/Users/adityajamuar/Sites/projects/nativebase/NativeBase/src/components/composites/NumberInput/NumberInput.tsx";var NumberInput=function NumberInput(_ref,ref){var children=_ref.children,props=(0,_objectWithoutProperties2.default)(_ref,["children"]);var _useThemeProps=(0,_hooks.useThemeProps)('NumberInput',props),defaultValue=_useThemeProps.defaultValue,keepWithinRange=_useThemeProps.keepWithinRange,value=_useThemeProps.value,min=_useThemeProps.min,max=_useThemeProps.max,onChange=_useThemeProps.onChange,newProps=(0,_objectWithoutProperties2.default)(_useThemeProps,["defaultValue","keepWithinRange","value","min","max","onChange"]);var formControlContext=(0,_FormControl.useFormControlContext)();var _React$useState=_react.default.useState(parseInt(value||defaultValue,10)),_React$useState2=(0,_slicedToArray2.default)(_React$useState,2),numberInputValue=_React$useState2[0],setNumberInputValue=_React$useState2[1];var _React$useState3=_react.default.useState(null),_React$useState4=(0,_slicedToArray2.default)(_React$useState3,2),numberInputStepper=_React$useState4[0],setNumberInputStepper=_React$useState4[1];var handleChange=function handleChange(newValue){var temp=newValue;setNumberInputValue(temp);if(keepWithinRange){if(newValue<min)setNumberInputValue(min);else if(newValue>max)setNumberInputValue(max);}onChange&&onChange(temp);};var handleChangeWithoutCheck=function handleChangeWithoutCheck(newValue){var temp=newValue;setNumberInputValue(temp);};_react.default.useEffect(function(){if(value!==undefined&&value!=numberInputValue)setNumberInputValue(value);},[value,numberInputValue,setNumberInputValue]);if((0,_useHasResponsiveProps.useHasResponsiveProps)(props)){return null;}return _react.default.createElement(_Box.default,{ref:ref,__self:_this,__source:{fileName:_jsxFileName,lineNumber:49,columnNumber:5}},_react.default.createElement(_Context.NumberInputContext.Provider,{value:(0,_extends2.default)({},formControlContext,newProps,{min:min,max:max,handleChange:handleChange,handleChangeWithoutCheck:handleChangeWithoutCheck,numberInputValue:numberInputValue,numberInputStepper:numberInputStepper,setNumberInputStepper:setNumberInputStepper,isControlled:value!==undefined}),__self:_this,__source:{fileName:_jsxFileName,lineNumber:50,columnNumber:7}},children));};var _default=_react.default.memo(_react.default.forwardRef(NumberInput));exports.default=_default;
  //# sourceMappingURL=NumberInput.js.map