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

my-mask-library

v3.0.1

Published

A Vue.js input mask component library

Downloads

7

Readme

My Mask Library

🚀 Overview

mask-input is a Vue.js component library that provides an easy-to-use input masking solution. With flexible masking options, you can format user input for phone numbers, credit cards, dates, and more. This library offers a seamless way to enforce input formats and ensure data consistency in your Vue.js applications.

📦 Installation

To get started with mask-input, follow these steps:

1. Install the Package

You can install the library via npm or yarn:

Using npm

npm install my-mask-library
or
yarn add my-mask-library

📘 Usage

Once installed, you can import and use the MaskInputComponent in your Vue.js application. Here's a step-by-step guide on how to integrate it:

1. Import and Register the Component

In your main entry file (e.g., main.js or main.ts), import the MaskInputComponent and register it globally or locally in your components.

Global Registration

import { createApp } from 'vue';
import App from './App.vue';
import MaskInputComponent from 'my-mask-library';

// Create your Vue app
const app = createApp(App);

// Register the component globally
app.component('MaskInputComponent', MaskInputComponent);

// Mount the app
app.mount('#app');

Local Registration

In the component where you want to use the masked input:

<template>
  <div>
    <MaskInputComponent
      v-model="maskedValue"
      mask="(###) ###-####"
      type="text"
      className="masked-input"
    />
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';
import MaskInputComponent from 'mask-input';

export default defineComponent({
  components: {
    MaskInputComponent
  },
  setup() {
    const maskedValue = ref('');
    return {
      maskedValue
    };
  }
});
</script>

2. Component Props

The MaskInputComponent accepts the following props:

  • mask (String, Required): The mask pattern to be applied to the input. Example: "(###) ###-####".
  • type (String, Optional): The type of the input. Defaults to "text".
  • className (String, Optional): Additional CSS class names to apply to the input.
  • placeholder (String, Optional): Placeholder text for the input. Defaults to an empty string.
  • disabled (Boolean, Optional): Disables the input if set to true. Defaults to false.
  • name (String, Optional): The name attribute for the input. Defaults to an empty string.
  • id (String, Optional): The id attribute for the input. Defaults to an empty string.
  • autocomplete (String, Optional): The autocomplete attribute for the input. Defaults to "off".
  • readonly (Boolean, Optional): Makes the input read-only if set to true. Defaults to false.

3. Handling Events

The component emits the following event:

update:modelValue: Emitted when the masked value changes. You can use this event to update your model value or handle changes in your application.

<template>
  <div>
    <MaskInputComponent
      v-model="maskedValue"
      mask="####-####-####-####"
      @update:modelValue="handleUpdate"
    />
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';
import MaskInputComponent from 'mask-input';

export default defineComponent({
  components: {
    MaskInputComponent
  },
  setup() {
    const maskedValue = ref('');

    function handleUpdate(newValue: string) {
      console.log('Updated masked value:', newValue);
      maskedValue.value = newValue;
    }

    return {
      maskedValue,
      handleUpdate
    };
  }
});
</script>

📝 Contributing

We welcome contributions! If you have any ideas, suggestions, or bug fixes, please feel free to open an issue or submit a pull request.

🔗 License

This project is licensed under the MIT License.