1.0.11 • Published 2 years ago

react-make-currency v1.0.11

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

React Make Currency

npm NPM

Work with front-end pricing in a simplified way

Install

npm install react-make-currency

or

yarn add react-make-currency

Usage

import { useState } from 'react'
import { currencyStr, onValueChange, isValid } from 'react-make-currency'
import pt from 'react-make-currency/locale/pt-BR'

// types and interfaces
import type { TOnValueChange } from 'react-make-currency'

const App = () => {
  const [value, setValue] = useState(2.99)

  const handleChange = ({ floatValue }: TOnValueChange) => setValue(floatValue)

  return (
    <div>
      <span>
        {currencyStr(value, { addPrefix: true, locale: pt })}
      </span>
      <input
        type="tel"
        value={currencyStr(useInput, { locale: pt })}
        onChange={(e) => isValid(e, 13) && handleChange(onValueChange(e))}
        placeholder="0,00"
      />
    </div>
  )
}

export default App

Display values

In the current version BRL for floatValue or stringValue

typedinput valuefloat valuestring value
10,010.010,01
120,120.120,12
1231,231.231,23
74899748,99748.99748,99
1234561.234,5612345.561.234,56
12345678123.456,78123456.78123,456,78
123456789012.345.678,9012345678.9012.345.678,90

Announcement

en: More coins will be available soon!

pt: Em breve mais moedas estará disponível!

es: ¡Más monedas estarán disponibles pronto!

Issues

Feel free to raise an issue on Github if you find a bug or have a feature request

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago