Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-autonumeric

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-autonumeric

An AutoNumeric wrapper for Vue.js

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

vue-autoNumeric

A Vue.js component that wraps the awesome autoNumeric input formatter library


vue-autoNumeric wrap the awesome autoNumeric library and generate an <input> element managed by AutoNumeric.

Installation

yarn add vue-autonumeric
# or
npm install vue-autonumeric --save

You also need to link the AutoNumeric library in your html <head> tag like so:

<script src="//unpkg.com/autonumeric"></script>

How to use?

The AutoNumeric component can be instantiated the same way AutoNumeric can.

With an option object:

<autonumeric
     v-model="myValue"
     :options="{
         digitGroupSeparator: '.',
         decimalCharacter: ',',
         decimalCharacterAlternative: '.',
         currencySymbol: '\u00a0€',
         currencySymbolPlacement: 's',
         roundingMethod: 'U',
         minimumValue: '0'
     }"
/>

With a predefined option name:

<autonumeric
    v-model="myValue"
    :options="'French'"
/>

With multiple option objects/predefined options:

<autonumeric
    v-model="myValue"
    :options="['euro', { minimumValue: '0' }]"
/>
Other props

You can define the input placeholder using:

<autonumeric
    v-model="myValue"
    :options="'euro'"
    :placeholder="'Enter your value here'"
/>

In the future, you'll be able to define the type of element tag (<p>, <div>, etc.) you want that component to generate.
This will allow you to create any supported tag with the contenteditable attribute set to true, instead of <input> one as it is for now.

Integration with other scripts & events support

This wrapper supports setting the AutoNumeric options via an :options prop.
It also supports external value changes (via aNElement.set(42) for instance) and update the formatting and the v-model accordingly.

The paste, drop and wheel events are supported as well.

Caveats

Please note that directly setting a :value='42' on the <autonumeric> component will break it (really!).
Do NOT do that:

<autonumeric
    v-model="myValue"
    :options="{ minimumValue: '0' }"
    :value="42042.69" <!-- This fails -->
/>

Demo

The official AutoNumeric documentation is will soon be using this component extensively :)

An editable live example is available on Codepen.

Requirements

Browser support

This supports the same browsers than AutoNumeric supports:

  • Firefox and
  • Chrome

(latest 2 versions)

If you use IE/Edge/Safari/Opera, this might work ;)

License

vue-autoNumeric is open source and released under the MIT License.

Support

As always, if you find this useful, please consider supporting its development!
Huge Thanks :)


Copyright © 2016 Alexandre Bonneau

PS:
I would love to know how you're using vue-autonumeric.


Contact me!

Keywords

FAQs

Package last updated on 19 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc