1.1.3 • Published 3 years ago

nice-numeric-input v1.1.3

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Nice-Numeric-Input

npm npm bundle size NPM npm peer dependency version npm

Nice-Numeric-Input is a modern, rich featured and highly customisable numeric input built on Vue. Capable of formatting as the user types, including currency formatting. With no extra dependencies other than Vue itself.

Demo

Basic Demo

nice-numeric-input-demo-gif

Getting Started

Installation

> npm install nice-numeric-input

Usage

Import

import NiceNumericInput from 'nice-numeric-input'

Register

export default Vue.extend({
    //...
    components: { NiceNumericInput }
    //...
});

For a full list of props see the Reference Props section.

<nice-numeric-input v-model="cashValue"
                    placeholder="Enter a cash value"
                    label="Cash"
                    name="example"
                    currency="GBP"
                    locale="en-GB"
                    :max="100"
                    :min="0" />

Reference

Props

PropTypeRequiredDefault ValueNotes
valueNumberYes0Use v-model to get two-way binding
idStringNo"nice-numeric-input"
nameStringNo"nice-numeric-input"
labelStringYesRequired for accessibility, use hide-label to remove the visual label
placeholderStringNo
stepNumberNo1The amount to increase or decrease when using the step buttons
minNumberNoNEGATIVE_INFINITYAnything entered below this will fail the isValid check
maxNumberNoPOSITIVE_INFINITYAnything entered above this will fail the isValid check
isValidBooleanNoBasic internal validation, use the .sync modifier to get changes
disabledBooleanNofalseDisable the entire component
localeStringNowindow.navigator.language \|\| "en-US"Standard BCP 47 language tag
currencyStringNonullWhen null currency formatting is turned off. Otherwise it can be any currency code e.g. USD, EUR, JPY
minDecimalPlacesNumberNo0
maxDecimalPlacesNumberNo2
integerOnlyBooleanNofalsePrevents decimal numbers being entered, entries are rounded to the nearest integer
noControlsBooleanNofalseRemoves the step buttons
hideLabelBooleanNofalseRemoves the visual label
decreaseTitleStringNo"Decrease"The button title for accessibility
increaseTitleStringNo"Increase"The button title for accessibility
increaseTextStringNo"+"The text displayed on the increase step button
decreaseTextStringNo"-"The text displayed on the decrease step button
superIncreaseTextStringNo"++"The text displayed on the increase step button when super step is active (Ctrl or Alt)
superDecreaseTextStringNo"--"The text displayed on the decrease step button when super step is active (Ctrl or Alt)
ultraIncreaseTextStringNo"+++"The text displayed on the increase step button when ultra step is active (Ctrl + Alt)
ultraDecreaseTextStringNo"---"The text displayed on the decrease step button when ultra step is active (Ctrl + Alt)
superStepNumberNo10The amount to change during a super step
ultraStepNumberNo100The amount to change during an ultra step
labelClassStringNoA custom class to apply to the visual label
inputClassStringNoA custom class to apply to the input field
decreaseButtonClassStringNoA custom class to apply to the decrease step button
increaseButtonClassStringNoA custom class to apply to the increase step button
wrapperClassStringNoA custom class to apply to the top level component element
superStepClassStringNoA custom class to apply to both step buttons when super step is active
ultraStepClassStringNoA custom class to apply to both step buttons when ultra step is active

Events

EventEmitted TypeNotes
inputNumberUsed automatically by a v-model binding. Can be bound manually, fires when the value is changed
update:isValidBooleanUsed automatically by the .sync modifier on isValid prop. Can be bound manually, fires when the valid value changes.

Bug Reporting and Feature Request

If you run into any bugs please open an issue and I'll fix it as soon as possible.

Got an idea for a new feature to add? Open an issue with the title prefixed "Feature Request".

Support This Project

ko-fi

BTC: bc1qpss998j2j06fmdrycn4fvh3vrdu7vttkjsngwd

ETH: 0xab04C5D9Dd7145fFf2dD94db7D7A50ae7Ce4Ab25

ADA: addr1qxhk3mptca7l0qk2p7hhh5tp4qfqvqj5tpj5vcgkcy5zx6d0drkzh3ma77pv5ra000gkr2qjqcp9gkr9ges3dsfgyd5srdnl4c