{"id":15405111,"url":"https://github.com/fnando/amount-input","last_synced_at":"2025-08-24T12:32:55.773Z","repository":{"id":66031416,"uuid":"149190279","full_name":"fnando/amount-input","owner":"fnando","description":" Add amount masking to inputs with this teeny-tiny-lib.","archived":false,"fork":false,"pushed_at":"2020-09-24T04:30:25.000Z","size":126,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T05:51:09.996Z","etag":null,"topics":["form","input-mask","javascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fnando.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["fnando"]}},"created_at":"2018-09-17T21:28:17.000Z","updated_at":"2020-09-24T04:30:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"6533b918-3eb9-42b5-b4bd-ae4e9e66c67f","html_url":"https://github.com/fnando/amount-input","commit_stats":{"total_commits":31,"total_committers":2,"mean_commits":15.5,"dds":0.06451612903225812,"last_synced_commit":"b09f821fd63832c6ea151d98d2e1607b0ad7e0b4"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Famount-input","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Famount-input/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Famount-input/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Famount-input/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fnando","download_url":"https://codeload.github.com/fnando/amount-input/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249294814,"owners_count":21246004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["form","input-mask","javascript"],"created_at":"2024-10-01T16:15:03.674Z","updated_at":"2025-04-17T00:50:58.378Z","avatar_url":"https://github.com/fnando.png","language":"JavaScript","funding_links":["https://github.com/sponsors/fnando"],"categories":[],"sub_categories":[],"readme":"# amount-input\n\nAdd amount masking to inputs with this teeny-tiny-lib.\n\n## Instalation\n\nThis lib is available as a NPM package. To install it, use the following command:\n\n```\nnpm install @fnando/amount-input --save\n```\n\nIf you're using Yarn (and you should):\n\n```\nyarn add @fnando/amount-input\n```\n\nYou'll have to call `amountInput.amountInput(input, options)` directly if you're loading the script without compiling your script (e.g. [webpack](https://webpack.js.org/)). Otherwise you can simply `import amountInput from \"@fnando/amount-input\";`.\n\n## API\n\n### `amountInput(input, options = {})`\n\nEnable the amountInput behaviour on `input`. You can customize it with the following `options`:\n\n- `input`: The `\u003cinput\u003e` element you want to control.\n- `options`: This optional argument allows you to further customize the input behaviour. The available options are:\n    - `precision`: Sets the level of precision (defaults to `2`). When precision is `0`, then only integers will be accepted.\n    - `separator`: Sets the separator between the units (defaults to `.`).\n    - `delimiter`: Sets the thousands delimiter (defaults to `,`).\n    - `willAcceptAmount`: Sets the callback that will validate the acceptance of the new amount. If this callback returns `false`, then the amount won't be accepted and the `onRejectAmount` callback will be executed. Defaults to a callback that accepts any amount. The callback signature is `callback(newAmount)`.\n    - `onAcceptAmount`: Sets the the callback that will be executed after an amount has been accepted. Default to a no-op callback. The callback signature is `callback(input, amount)`.\n    - `onRejectAmount`: Sets the the callback that will be executed when an amount is rejected by `willAcceptAmount`. The callback signature is `callback(input, rejectedAmount, amount)`.\n\nThis function allow us to update the amount hold by amountInput. Otherwise, you won't be able to set an arbitrary value. Notice that the new amount that's being set is subjected to the `willAcceptAmount` condition.\n\n### `amountInput.format(number, options)`\n\nStand-alone formatting numbers. Accept `precision`, `separator`, and `delimiter` options, like described above.\n\n## Usage\n\nThis is the minimum working example:\n\n```html\n\u003cinput value=\"0.00\"\u003e\n\n\u003cscript\u003e\n  amountInput(document.querySelector(\"input\"));\n\u003c/script\u003e\n```\n\n## Examples\n\nAvailable at https://codepen.io/fnando/pen/VGExVv\n\n## License\n\n(The MIT License)\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Famount-input","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffnando%2Famount-input","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Famount-input/lists"}