Giter Club home page Giter Club logo

vue-numeric-input's Introduction

Vue Numeric Input

npm npm Build Status codecov npm

Number input component based on Vue that is a replacement of native input number with optional control.

vue-numeric-input

Live Demo & Doc

Installation

Install via NPM

$ npm install vue-numeric-input --save

Install via CDN

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

Global

Register VueNumericInput globally:

import Vue from 'Vue';
import VueNumericInput from 'vue-numeric-input';

Vue.use(VueNumericInput)

Local

Include the VueNumericInput directly into your component using import:

import VueNumericInput from 'vue-numeric-input'

export default {
  components: {
    VueNumericInput
  }
}

Usage

Basic usage

<template>
  <div>
    <vue-numeric-input  v-model="value" :min="1" :max="10" :step="2"></vue-numeric-input>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        value: 1,
      };
    },
  };
</script>

PROPS:

Name Description Type Default Options
name Component name String - -
value Binding value Number - -
placeholder Input placeholder String - -
min Minimum allowed value Number -Infinity -
max Maximum allowed value Number Infinity -
step Incremental Step Number 1 -
align Alignment of Numeric Value String left left, center, right
width Component Width String 150px width in px, em, rem etc e.g. โ€˜20pxโ€™
size Component Size String normal size value can be 'small', 'normal', 'large'
precision Number of decimals Number 0 Integer value
controls Enable/Disable Controls Boolean true true/false
controlsType Controls Type String plusminus plusminus/updown
autofocus Autofocus on Page Load Boolean false true/false
readonly Is Readonly Boolean false true/false
disabled Is Disabled Boolean false true/false
isinput enable/disable keyboard input of number Boolean false true/false
mousewheel Enable increment/decrement with mousewheel event Boolean false true/false
className Css Class for Input Component String - css class name

EVENTS:

Event Name Description Parameters
input triggers when input (newValue)
change triggers when the value changes (newValue)
blur triggers when Input blurs (event: Event)
focus triggers when Input focus (event: Event)

METHODS:

Method Description Parameters
focus focus the Input component -
blur blur the Input component -

Inspired by react-numeric-input

License

MIT

vue-numeric-input's People

Contributors

jayeshlab avatar jsancho-gpl avatar jvachhani21 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

vue-numeric-input's Issues

Release after long press on up/down should trigger change

When you press up/down or +/- for a longer period it starts to "speed scroll" which is nice. But after you release it I was expecting a @change event to be triggered, but that does not seem to happen. At least not for me. I have to press a button again to get the event.

Validate value on blur

Is there any way to prevent min\max validation after the key event, and wait until blur?

Let's say I set the minimum to 700 and the maximum to 800. The user cannot enter values using the keyboard. Because when she hits a digit, the value will be set to 800. And if she erases the digit, the value will be set to 700.
How for example she would enter 750?

Any way to style the input itself?

I use bootstrap and it's nice to be able to apply form-control class to each input. Is there a way to set the class on the input itself (not the vue-numeric-input wrapper) ?

entering zero(0) after dot(.) not working

Hi!

I am facing issue with entering zero after dot(.).

For example:
I have added numeric input as following to my component:

<vue-numeric-input class="form-control" v-model="data.amount" :controls="false" :precision="2"></vue-numeric-input>

But when I try to enter 300.01 it is not allowing to input zero after dot(.). Instead dot(.) is cleared when I input zero.

Thanks!

The .native modifier

The .native modifier for v-on is only valid on components but it was used on .
found in
--->

why this error happens for default?

Will Vue 3 be supported?

From a quick look at package.json, it seems this only supports Vue 2. I'd like to have a version that's usable in Vue 3.

Zoom less than 100% -,+ icons dissapper

When i zoom less than 100%, for exmaple 90% the Plus(+) and Minus(-) icons disapear.
image

I was able to get back the minus icon atleast with below css. But not the plus
.vue-numeric-input .btn-decrement .btn-icon::before { -webkit-transform: translate(-50%,50%) !important; transform: translate(-50%,50%) !important; } .vue-numeric-input .btn-increment .btn-icon::before { -webkit-transform: translate(-50%,50%) !important; transform: translate(-50%,50%) !important; }

Vue-numeric-input submits form

If the vue-numeric-input component appears within form tags, then it will attempt to submit the form every time the updown button is clicked.

The standalone Test component below demonstrates the issue.

Workaround: replace the form tag with a div tag (which may cause CSS selectors to not fire if they rely on form).

Version: 1.0.3
Browsers: Chrome, Edge, Firefox, Safari mobile

<template>
  <div class="container">
      <form v-on:submit.prevent="submit">
        <div class="field">
            <label class="label">Personal best for 200m</label>
            <div class="control">
              <div class="columns">
                <div class="column is-2">
                  <label class="label is-size-6 has-text-right has-text-weight-light">Minutes:</label>
                </div>
                <div class="column is-3">
                  <vue-numeric-input 
                    v-model="form.pb200mMinutes"
                    :align="'center'" 
                    :controlsType="'updown'" 
                    :min="0" :max="20" :step="1"
                    @change="change">
                  </vue-numeric-input>
                </div>
                <div class="column is-2">
                  <label class="label is-size-6 has-text-right has-text-weight-light">Seconds:</label></div>
                <div class="column is-3">
                  <vue-numeric-input 
                    v-model="form.pb200mSeconds"
                    :align="'center'" 
                    :controlsType="'updown'" 
                    :min="0" :max="59" :step="1">
                  </vue-numeric-input>  
                </div>
              </div>
            </div>
            <p class="help">Your personal best time for 200m in minutes and seconds</p>
        </div>
      </form>
  </div>
</template>

<script>
import Vue from 'vue';

import VueNumericInput from 'vue-numeric-input';
Vue.use(VueNumericInput)

export default {
  name: 'Test',
  data() {
    return {form:{
            pb200mMinutes: 0,
            pb200mSeconds: 0
            }
    }
  },
  methods: {
      submit(){
          console.log('submit');
      },
      change(){
          console.log('changed');
      }
    
  },
  created() {
   
  },
    components: {
        VueNumericInput: VueNumericInput
    },
};
</script>

P.S. Thank you for the cool module!

How to bind "change" on multiple inputs on the page

Example:
I have a shopping cart form with items that user added. And each of items has own numeric input with name "item[item_id]". When I bind onChange event it returns only his value.
So, how to get his name or how to pass additional params to @change="onMyFunc(..., ...)"?

onMyFunc(id, value) {
    ...
}

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.