Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function handleOnBlur(e: React.FocusEvent) {
const input = e.currentTarget as HTMLInputElement;
let value = ValueLineController.autoFixString(input.value, false);
if (numbro.languageData().delimiters.decimal == ',' && !value.contains(",") && value.trim().length > 0) //Numbro transforms 1.000 to 1,0 in spanish or german
value = value + ",00";
if (p.format && p.format.endsWith("%")) {
if (value && !value.endsWith("%"))
value += "%";
}
const result = value == undefined || value.length == 0 ? null : numbro.unformat(value, p.format);
setText(undefined);
if (result != p.value)
p.onChange(result);
if (p.htmlAttributes && p.htmlAttributes.onBlur)
p.htmlAttributes.onBlur(e);
}