GithubHelp home page GithubHelp logo

tidianerolland / vue-numeric Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kevinongko/vue-numeric

0.0 0.0 0.0 462 KB

Input field component to display a formatted currency value based on Vue.js

Home Page: https://kevinongko.github.io/vue-numeric/

License: MIT License

JavaScript 61.55% Vue 38.45%

vue-numeric's Introduction

vue-numeric

npm npm npm Build Status Codecov npm

Input field component to display a formatted currency value based on Vue.

Live Demo

Works with Vue 2.*

Installation

Install via CDN

<script src="https://unpkg.com/accounting-js"></script>
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/vue-numeric"></script>

<script>
  Vue.use(VueNumeric.default)
</script>

Install via NPM

$ npm install vue-numeric --save

Register as Component

import Vue from 'vue'
import VueNumeric from 'vue-numeric'

export default {
  name: 'App',

  components: {
    VueNumeric
  }
}

Register as Plugin

import Vue from 'vue'
import VueNumeric from 'vue-numeric'

Vue.use(VueNumeric)

Usage

screen shot 2016-12-08 at 2 19 31 pm

Quick example

<template>
  <vue-numeric currency="$" separator="," v-model="price"></vue-numeric>
</template>

<script>
import VueNumeric from 'vue-numeric'

export default {
  name: 'App',

  components: {
    VueNumeric
  },

  data: () => ({
    price: ''
  }),
}
</script>

Currency symbol

Set the currency prop to add a currency symbol within the input.

<vue-numeric currency="$"></vue-numeric>

Minimum & maximum constraint

Limit the minimum and maximum value by using min and max props.

  • min defaults to 0.
  • min and max accept String or Number values.
<vue-numeric v-bind:min="2000" v-bind:max="10000"></vue-numeric>

Disable/enable negative values

minus defaults to false (no negative numbers).

<vue-numeric v-bind:minus="false"></vue-numeric>

Enable decimal precision

By default the decimal value is disabled. To use decimals in the value, add the precision prop.

  • precision accept a String or Number numeric value.
<vue-numeric v-bind:precision="2"></vue-numeric>

Thousands separator

  • Default thousand separator's symbol is ,.
  • Use the separator prop to change the thousands separator.
  • separator only accepts space, , or ..
  • When using the . or space as thousand separator, the decimal separator will be ,.
<vue-numeric separator="."></vue-numeric>

Input placeholder when empty

<vue-numeric placeholder="only number allowed"></vue-numeric>

Value when empty

By default, when you clean the input the value is set to 0. You can change this value to fit your needs.

<vue-numeric :empty-value="1"></vue-numeric>

Output Type

By default the value emitted for the input event is of type Number. However you may choose to get a String instead by setting the property output-type to String.

<vue-numeric output-type="String"></vue-numeric>

Props

Props Description Required Type Default
currency Currency prefix false String -
currency-symbol-position Position of the symbol (accepted values: prefix or suffix) false String prefix
max Maximum value allowed false Number 9007199254740991
min Minimum value allowed false Number -9007199254740991
minus Enable/disable negative values false Boolean false
placeholder Input placeholder false String -
empty-value Value when input is empty false Number 0
output-type Output Type for input event false String String
precision Number of decimals false Number -
separator Thousand separator symbol (accepts space, . or ,) false String ,
decimal-separator Custom decimal separator false String -
thousand-separator Custom thousand separator false String -
read-only Hide input field and show the value as text false Boolean false
read-only-class Class for read-only element false String ''

License

Vue-Numeric is open-sourced software licensed under the MIT license

Support

Hello, I'm Kevin the maintainer of this project in my free time (which is getting lessen these days), if this project does help you in any way please consider to support me. Thanks ๐Ÿ˜ƒ

vue-numeric's People

Contributors

kevinongko avatar emilioeduardob avatar mo3rfan avatar darrylhein avatar tochoromero avatar knagyorg avatar desertsnow avatar morloderex avatar dimailn avatar

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.