GithubHelp home page GithubHelp logo

qonto / ember-amount-input Goto Github PK

View Code? Open in Web Editor NEW
19.0 12.0 11.0 6.35 MB

An Ember.js component to input money amount.

License: MIT License

JavaScript 37.93% HTML 6.72% CSS 4.43% Handlebars 2.15% TypeScript 48.78%
input ember-addon ember

ember-amount-input's People

Contributors

alexis-falaise avatar anas7asia avatar antoinemoues avatar dannycalleri avatar dbendaou avatar dcyriller avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar ember-tomster avatar evidencefrank avatar hakilebara avatar izelnakri avatar joaodsv avatar mbinet avatar michelegera avatar mrloop avatar poulet42 avatar vscav avatar wandroll avatar zeppelin avatar

Stargazers

 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ember-amount-input's Issues

Property lookup fallback deprecation

ember-amount-input v2.1.0 triggers the following deprecation warning

DEPRECATION: The `value` property path was used in a template for the `ember-amount-input/components/amount-input/template.hbs` component without using `this`. This fallback behavior has been deprecated, all properties must be looked up on `this` when used in the template: {{this.value}} [deprecation id: this-property-fallback] See https://deprecations.emberjs.com/v3.x#toc_this-property-fallback for more details.\n

Wrong padding applied when currency is explicitly not defined

Today, it is possible to explicitly pass undefined or null to the @currency argument of the AmountInput component.

It is convenient when we want to benefit from the behavior of the amount input without showing any currency information (use case example: the currency information is displayed in another element, next to the input - here we wouldn't want to have the currency displayed twice for the same information).

However, when doing so, the padding stays the same, meaning we have a larger padding-right (i.e. 41px) in the input, that is usually set to be able to display the currency.

Capture d’écran 2024-02-02 à 14 52 41

If the currency is explicitly set to undefined, null, or to an empty string, we should reset the padding (from 41px to 12px).

Improve typing of the component API

Our official documentation refers to a number type for the value argument (see docs). However, we can in fact support both string and number (and that's what we defined when migrating to TypeScript and helped us figure out the issue - see PR). Plus, the documentation also mentions that the value should be updated using the update function argument, which for now only returns a string.

It seems we have a wobbly API for our component, as it requires us to parse the value returned by the update function before using it to set our new value.

A suggestion could be the following:

interface AmountInputArgs {
  ...
- update: (value: string) => void;
- value: number | string;
+ update: (value: number) => void;
+ value: number;
}

Note that if the suggestion is accepted and implemented, it will be a breaking change.

Value returned with "+" or "-" sign inside can be an empty string

Some browsers permits characters + and - to be typed into input with type number. These can be inserted anywhere in the input and not constrained to the first character (for example, using - to declare a negative value). This often leads to issue in JavaScript. One of them is the fact that the returned value by the input becomes inaccessible.

To avoid this kind of behavior, the e character is often prevented from being typed in input type number. This is the case for ember-amount-input.

Could this behavior also exists for + and - characters ? As they could be expected by users (for some negative values), should this be only accessible with an arg as absoluteOnly or integerOnly ?

Better handle pasted value

Often end user doesn't type the amount but copy-paste it from another source.

In that case , the value passed from the clipboard is a string and might have trailing whitespace or be formatted in the locale ( that is including white space for thousands separator).

As we're using input type text, we suffer in that case of inconsistencies between browser :

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.