2.0.0 • Published 4 years ago
@mtcmedia/vue-number-input v2.0.0
@mtcmedia/vue-number-input
Install to production site
npm install @mtcmedia/vue-number-inputUsage
import MNumberInput from '@mtcmedia/vue-number-input'
import '@mtcmedia/vue-number-input/dist/MtcNumberInput.css'
Vue.component('MNumberInput', MNumberInput)<MNumberInput
:min="18"
>
<template v-slot:add><i class="fa fa-angle-up"></i></template>
<template v-slot:subtract><i class="fa fa-angle-down"></i></template>
</MNumberInput>Props
The component accepts these props:
| Attribute | Type | Default | Description |
|---|---|---|---|
| input-class | String | '' | Used to add class to the input field |
| id | String | '' | Add id to input field |
| name | String | '' | Add name to input field |
| value | Number, String | 0 | Add initial value to input field on load with v-model on component |
| min | Number | 0 | Set min value for input field |
| max | Number | Infinity | Set max value for input field |
| autocomplete | String | '' | Add autocomplete |
| readonly | String | '' | Add readonly |
| disabled | String | '' | Add disabled |
| maxlength | Number | '' | Add maxlength |
Slots
The component accepts these slots:
add: Slot to add a custom icon/content for the add buttonsubtract: Slot to add a custom icon/content for the subtract button
Events
The component fires the following events:
| Attribute | Description |
|---|---|
| input | Emits value of input to parent component |
To emit event to DOM
// add this line before for legacy js e.g. jQuery
window.vueEventBus = new Vue()
// this as a method on the parent component
emitEvent (value, oldValue) {
// legacy jquery event - sends event to the DOM
window.vueEventBus.$emit('numberInput', {
value: value,
oldValue: oldValue,
$el: this.$el
})
}Development Setup
npm installCompiles and hot-reloads for development
npm run serveCompiles and minifies for production
npm run buildRun your unit tests
npm run test:unitLints and fixes files
npm run lint