GithubHelp home page GithubHelp logo

react-currency-format's People

Contributors

abhay-oodles avatar alandelonga avatar alexandrapersea avatar dependabot[bot] avatar filiphsps avatar isnifer avatar mohitgupta8888 avatar mquandalle avatar pandaiolo avatar s-yadav avatar styks1987 avatar tommasobertagnin avatar vinogradov-m avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

react-currency-format's Issues

Disable Filed

Hello,
I want to disable the textbox for some condition and enable for some condition so can you tell me how can it be done??

Could not find a declaration file for module 'react-currency-format'

Received this error when I tried to import the file after running a yarn add react-currency-format, Could not find a declaration file for module 'react-currency-format'. '....../node_modules/react-currency-format/lib/currency-format.js' implicitly has an 'any' type.

I tried removing and re-installing the package but was still running into the issue. Any help is greatly appreciated.

Warning: Failed prop type: Invalid prop `customInput` of type `object`

Hey! I'm the customInput prop and passing in a TextField from Material UI like the docs show and I keep throwing this Failed prop type error:

Warning: Failed prop type: Invalid prop "customInput" of type "object" supplied to "CurrencyFormat:, expected "function"

My component looks like this:

<CurrencyFormat
                    className={classes.budgetField}
                    variant='standard'
                    margin='normal'
                    required
                    name='total_budget'
                    label='Budget Total'
                    placeholder='0.00'
                    InputProps={{inputProps: {min: 0}}}
                    id='total_budget'
                    value={total_budget}
                    onValueChange={(values) => {
                      const {value} = values;
                      setFormData({
                        ...formData,
                        total_budget: value,
                      });
                    }}
                    thousandSeparator={true}
                    decimalScale={2}
                    allowNegative={false}
                    prefix={
                      getSymbolFromCurrency(home_currency) !== undefined
                        ? getSymbolFromCurrency(home_currency)
                        : '$'
                    }
                    customInput={TextField}
                  />

The error goes away if I pass TextField as a function like customInput={()=> <TextField {...props}/> } however, it doesn't render correctly because on every new render the component is rebuilt (I think) and the user loses focus from the field.

Anyway, the component works as is with the error. I was just wondering if there was a way around this. Thanks!

"@material-ui/core": "^4.11.0"
"react": "^16.13.1"
"react-currency-format": "^1.0.0"
node v12.0.0

Unable to remove dash symbol

In case of use any prefix unable to remove first dash symbol.
Here the example of code
<CurrencyFormat prefix="$" placeholder="placeholder" />

Type "-" symbol and then try to remove it.

Is it possible to define max value?

I need to define a dynamic max value for this field. Is it possible?

Maybe something like this:

<CurrencyFormat {...} maxValue={9999999} />

Prevent rounding value

I need different behavior from the plugin as per my business requirements & I believe that this requirement is everywhere.

HOW THE PLUGIN IS HANDLING ROUNDING?

  1. When the last digit is greater than 5 then it increments the 2nd last digit and drops the last digit
  2. When the last digit is smaller than 5 then it drops the last digit only.
  3. When the last digit is 5 increments then it increments the 2nd last digit and drops the last digit
  4. When the last digit is 5 then it drops the last digit only.

WHAT DO I EXPECT?
I want to combine the 3rd and 4th rule into one and that is: If the last digit is 5 then the plugin should increment the 2nd last digit and drops the last digit

So, is there a way to handle this issue?

Fixed "Failed prop type: Invalid prop customInput of type object"

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch [email protected] for the project I'm working on.

Fixed "Failed prop type: Invalid prop customInput of type object" #15

Here is the diff that solved my problem:

diff --git a/node_modules/react-currency-format/src/currency-format.js b/node_modules/react-currency-format/src/currency-format.js
index 8ce11c8..14a80bb 100644
--- a/node_modules/react-currency-format/src/currency-format.js
+++ b/node_modules/react-currency-format/src/currency-format.js
@@ -37,7 +37,7 @@ const propTypes = {
     PropTypes.string
   ]),
   isNumericString: PropTypes.bool,
-  customInput: PropTypes.func,
+  customInput: PropTypes.node,
   allowNegative: PropTypes.bool,
   onValueChange: PropTypes.func,
   onKeyDown: PropTypes.func,

This issue body was partially generated by patch-package.

Forward ref to input component

Problem

Currently it's not possible to access the actual input element through a ref i.e. the input ref is not forwarded from CurrencyFormat to the input element. This is a problem when you want to do things like place the caret at the beginning or end of the value, or highlight the full value for quick editing. e.g. element.select()

Possible solution

In the constructor of the CurrencyFormat component add a field called inputRef which is the ref of the input element.

class CurrencyFormat extends React.Component {
  constructor(props) {
    this.inputRef = React.createRef()
  }
  render() {
    return (
        <input ref={this.inputRef} />
    )
  }
}

I would be happy to create a PR for this issue. Let me know if this solution is good.

Can't use it with TS

I am importing it as import * as CurrencyFormat from 'react-currency-format'; but still getting next error:

image

Round number with decimalScale to 0 results in NaN00

Hello!

I've encountered this bug, not sure if it's supposed to be like this, so please let me know.

currency-bug

When values arrive like this:

<CurrencyFormat value={-99.49} decimalScale={0} displayType={'text'} />
<CurrencyFormat value={-99.50} decimalScale={0} displayType={'text'} />
<CurrencyFormat value={-99.99} decimalScale={0} displayType={'text'} />
<CurrencyFormat value={-100} decimalScale={0} displayType={'text'} />

Screenshot from 2023-08-01 14-48-30

From -99.50 to -99.99 it results to NaN00, is it supposed to do that? I would expect it to round to -100

I'm using:

  • react-currency-format 1.1.0
  • react 17.0.2
  • node 16.18.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.