How to use the numbro.languageData function in numbro

To help you get started, we’ve selected a few numbro examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github signumsoftware / framework / Signum.React / Scripts / Lines / ValueLine.tsx View on Github external
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);
  }