Socket
Socket
Sign inDemoInstall

vue-autonumeric

Package Overview
Dependencies
1
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vue-autonumeric

An AutoNumeric wrapper for Vue.js


Version published
Maintainers
1
Created

Changelog

Source

1.0.3

  • Fix importing issues with the AutoNumeric library
  • Complete the documentation on how to install and use the component
  • Add a link to the examples page and its source in the Readme
  • Fix the example script imports by removing the unneeded AutoNumeric link
  • Fix issue #4 Error when building with webpack 2 on linux

Readme

Source

vue-autoNumeric

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

NPM
NPM version Downloads Known Vulnerabilities

Get in touch on Gitter chat


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

Checkout the demo!

Installation

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

Note: In order to minimize the size of the vue-autoNumeric component, the AutoNumeric library dependency is not bundled with it.

This means you need to link the AutoNumeric library with either ways:

...in your html <head> tag

In the html <head> tag directly, or by using a CDN like so:

<script src="../node_modules/autonumeric/dist/autonumeric.min.js"></script>
<!-- or -->
<script src="//unpkg.com/autonumeric"></script>
...or by importing it directly as a module

You can choose to directly import the AutoNumeric library in your source code using:

yarn add autonumeric
# or
npm install autonumeric --save

You'll then be able to use the vue-autonumeric component in your scripts using:

import AutoNumeric from 'autonumeric';
import VueAutonumeric from 'vue-autonumeric';

How to use?

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

With an option object:

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

With a predefined option name:

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

With multiple option objects/predefined options:

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

You can define the input placeholder using:

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

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.

Moreover, if you modify the :options prop, the AutoNumeric settings will be automatically updated with the new options.

Caveats

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

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

Demo

The official AutoNumeric documentation is using this component extensively :)

An editable live example is available on Codepen.

Moreover, you can check the shipped examples in your browser, and study its source here.

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

Last updated on 28 Nov 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc