All Projects → autoNumeric → Vue Autonumeric

autoNumeric / Vue Autonumeric

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

Projects that are alternatives of or similar to Vue Autonumeric

Apprun
AppRun is a JavaScript library for developing high-performance and reliable web applications using the elm inspired architecture, events and components.
Stars: ✭ 1,087 (+1498.53%)
Mutual labels:  component
Stf Vue Select
stf vue select - most flexible and customized select
Stars: ✭ 61 (-10.29%)
Mutual labels:  component
Horsey
🐴 Progressive and customizable autocomplete component
Stars: ✭ 1,146 (+1585.29%)
Mutual labels:  component
Any Ui
❄️ 一个移动端组件库
Stars: ✭ 58 (-14.71%)
Mutual labels:  component
Redemo
react demo component
Stars: ✭ 60 (-11.76%)
Mutual labels:  component
React Pin Field
📟 React component for entering PIN codes.
Stars: ✭ 63 (-7.35%)
Mutual labels:  component
Uxcore Table
Table Component based on React
Stars: ✭ 55 (-19.12%)
Mutual labels:  component
Security Http
Security provides an infrastructure for sophisticated authorization systems, which makes it possible to easily separate the actual authorization logic from so called user providers that hold the users credentials. It is inspired by the Java Spring framework.
Stars: ✭ 1,146 (+1585.29%)
Mutual labels:  component
Dzhtmltext
Delphi and Lazarus HTML Label component
Stars: ✭ 60 (-11.76%)
Mutual labels:  component
Daggraph
Dagger dependency graph generator for Android Developers
Stars: ✭ 1,140 (+1576.47%)
Mutual labels:  component
Region Picker
A region picker based on Vue and ElementUI.
Stars: ✭ 59 (-13.24%)
Mutual labels:  component
React Qmap
💡react腾讯地图开源组件
Stars: ✭ 60 (-11.76%)
Mutual labels:  component
Class Loader
[DEPRECATED] The ClassLoader component provides tools to autoload your classes and cache their locations for performance.
Stars: ✭ 1,131 (+1563.24%)
Mutual labels:  component
Reacom
ReaCOM has got a lot of tools to use and is related to component object model
Stars: ✭ 57 (-16.18%)
Mutual labels:  component
Vue Clock2
vue clock component 😀
Stars: ✭ 67 (-1.47%)
Mutual labels:  component
Checkview
An animated toggling Plus/Check button for Android
Stars: ✭ 56 (-17.65%)
Mutual labels:  component
Selectivity
Modular and light-weight selection library
Stars: ✭ 1,113 (+1536.76%)
Mutual labels:  component
React Native X Bar
🎩 A flexible, lightweight bar component for common UI patterns in React Native
Stars: ✭ 68 (+0%)
Mutual labels:  component
Made With Love
🚀 An experimental project which demonstrates an Angular Package which contains Angular Elements and Schematics
Stars: ✭ 67 (-1.47%)
Mutual labels:  component
Vue Virtual Keyboard
⌨️ Vue Virtual Keyboard
Stars: ✭ 65 (-4.41%)
Mutual labels:  component

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!

Alternatively you can check the examples directly in your browser to see how to integrate the component with Vue and AutoNumeric.

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 directly

<!-- locally... -->
<script src="../node_modules/autonumeric/dist/autonumeric.min.js"></script>
<!-- ...or by using a CDN -->
<script src="https://unpkg.com/autonumeric"></script>

Then you need to tell Webpack to treat the AutoNumeric dependency as external so that it does not try to bundle it.
Here is a really simple webpack.config.js example that does that:

module.exports = {
    entry  : './src/vueAutonumericTest.js',
    output : {
        filename: './dist/bundle.js'
    },
    externals: {
        autonumeric: 'AutoNumeric',
    },
};

...or by importing it directly as an ES6 module

You can choose to directly import the AutoNumeric library in your source code.
First, install the autonumeric dependency so that Webpack can find it using:

yarn add autonumeric
# or
npm install autonumeric --save

You will as usual be able to use the vue-autonumeric component in your Vue components using:

import VueAutonumeric from '../src/components/VueAutonumeric.vue';

export default {
    name      : 'myComponent',

    components: {
        VueAutonumeric,
    },
}

However, when doing that if you want to be able to bundle all the scripts together with Webpack, you'll need to define an alias for the AutoNumeric library in your Webpack config, otherwise Webpack will complain about the npm package autonumeric case.

The alias that you need to declare in your Webpack configuration:

module.exports = {
    entry  : './src/vueAutonumericTest.js',
    output : {
        filename: './dist/bundle.js'
    },
    resolve: {
        alias: {
            AutoNumeric: 'node_modules/autonumeric/dist/autoNumeric.min',
        },
    },
};

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

Placeholder

You can define the input placeholder using:

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

You can also specify the type of html tag (within the AutoNumeric supported list) this component should generate using the tag prop. By default, an <input> element is generated, but if you want a <div> element, you can use:

<vue-autonumeric
    v-model="myValue"
    options="euro"
    tag="div"
></vue-autonumeric>

Note: this will automatically set the contenteditable attribute to true for that generated element.

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.

Examples

You can also check the shipped examples in your browser, and study their source here.
To do so, first compile the example using:

# this will build the component *and* the examples
yarn build 

Then check the resulting html file in your browser using:

firefox ./examples/index.html # or `chrome`

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 ;)

Contributing

Whenever you change the source code, you can check how it affects the default examples by first building those in examples/index.html with:

yarn build:examples

The contribution guidelines for vue-autoNumeric are the same than for the parent AutoNumeric project.

Support

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

License

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


Copyright © 2016-2018 Alexandre Bonneau

PS:
I would love to know how you're using vue-autonumeric.
Contact and tell me! :)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].