Radouch / vue-num-locale-input

Vue 3 component: input numeric field which is rendered as language sensitive string.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vue-num-locale-input

npm version Monthly Downloads MIT License

Vue 3 form input field component edited as numeric input field, displayed as language sensitive text field.

  • For language-sensitive representation of numbers see Number.prototype.toLocaleString()
  • Locale formatted number is displayed only if the field does not have focus. Otherwise it looks and behaves as normal numeric input field.
  • Especially useful for creating clear and easy to read tables containing numbers.

Samples

Bootstrap table, Czech locale, first field edited

Table, first item is edited

Bootstrap table, English locale, first field edited

Table, first item is edited

Installation

npm install vue-num-locale-input

Usage

<script>
import VueNumLocaleInput from "vue-num-locale-input";
</script>

<template>
  <VueNumLocaleInput
    v-model="yourNumericVariable"
    class="some-class"
    min="-10"
    max="10"
    step="2"
    :options="{minimumFractionDigits: 1, maximumFractionDigits: 1}"
  />
</template>

Important notes

  • Default locales is used (= browser settings). This version of the component does not allow to set it manually by props.
  • Property options is the same as documented in Intl.NumberFormat. Likely the most useful options are minimumFractionDigits and maximumFractionDigits, especially for tables.
  • You must not use html attribute type (e.g. type="number") on the component. It breaks its functionality.

About

Vue 3 component: input numeric field which is rendered as language sensitive string.


Languages

Language:JavaScript 43.9%Language:MDX 23.2%Language:Vue 14.9%Language:TypeScript 14.2%Language:HTML 3.7%