npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@handcrafted-market/vue3-numeric

v1.0.4

Published

Input field component to display currency value based on vue-numeric.

Downloads

1,721

Readme

vue3-numeric

npm npm npm npm

This is an implementation for Vue 3 of the Original project vue-numeric in its version 2.4.3.

It initially existed at https://github.com/flvportafolio/vue3-numeric but seems to have been deleted. Since it has an MIT license, it's been reuploaded here in the state that it last existed in our deployments. We may or may not be able to actually support issues that are raised for the project.

Installation

# NPM
$ npm install @handcrafted-market/vue3-numeric

CDN

<html>
  <head>
    <script src="https://unpkg.com/vue@next"></script>
  </head>
  <body>
    <div id="app">
       {{price}}
      <hr>
      <vue-numeric
        currency="$"
        separator=","
        v-model="price"
        :precision="2"
      ></vue-numeric>
    </div>
    <script src="https://unpkg.com/[email protected]/dist/vue3-numeric.umd.js"></script>
    <script type="module">
      const VueNumeric = window["vue3-numeric"];
      Vue.createApp({
        setup() {
          const price = Vue.ref("123");
          return { price };
        }
      })
      .component("vue-numeric", VueNumeric)
      .mount("#app");
    </script>
  </body>
</html>

Register globally

import { createApp } from 'vue';
import App from './App.vue';
import VueNumeric from 'vue3-numeric';

createApp(App)
  .component("vue-numeric", VueNumeric)
  .mount('#app');

Register as Component (Composition Api)

<script>
import { ref } from 'vue';
import VueNumeric from 'vue3-numeric';
export default {
  components: { VueNumeric },
  setup() {
    const price = ref('');
    return { price };
  },
};
</script>
<template>
  <vue-numeric
    separator=","
    v-model="price"
    :precision="2"
  ></vue-numeric>
</template>

Register as Component (Composition Api - setup sugar)

<script setup>
import { ref } from 'vue';
import VueNumeric from 'vue3-numeric';
const price = ref('');
</script>
<template>
  <vue-numeric
    separator=","
    v-model="price"
    :precision="2"
  ></vue-numeric>
</template>

Usage

Quick example

<script>
import { ref } from 'vue';
import VueNumeric from 'vue3-numeric';
export default {
  components: { VueNumeric },
  setup() {
    const price = ref('');
    return { price };
  },
};
</script>
<template>
  <vue-numeric
    currency="$" 
    separator=","
    v-model="price"
    :precision="2"
  ></vue-numeric>
</template>

Currency symbol

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

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

Currency symbol Spacing

Set the currencySymbolSpacing prop to false to show $2.00. instead of $ 2.00. By default the value is true

<vue-numeric
  currency="$"
  :currencySymbolSpacing="false"
></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

MIT license

Recommended IDE Setup