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

vue-password

v3.1.0

Published

[View Demo](https://codesandbox.io/s/vue-template-t1vmc?fontsize=14)

Downloads

5,370

Readme

vue-password 3.x

View Demo

Please note, VuePassword 3.x removes support for the zxcvbn library. The library appears to no longer be maintained. If you would still like to use it, you can still pull in the library and pass the VuePassword value to it to calculate the strength. Examples coming soon.

Install

Install the package using npm.

npm install --save vue-password

The VuePassword component adds support for a toggle to hide and show the password as well as a meter to show the current strength of the password. This component does not automatically calculate the strength, however, a library like zxcvbn can be used to pass the strength values as props.

import VuePassword from 'vue-password';

export default {
    ...
    components: {
        VuePassword,
    },
    ...
};

Usage

Use the props in your HTML and apply a v-model attribute for the password and any additional props for the desired configuration. The password input uses the $attrs attributes, so form validation props such as required, minlength, and maxlength will function on the input element. The following example shows how vue-password could be used in a registration form using Tailwind CSS.

Javascript

import Vue from 'vue'
import VuePassword from 'vue-password'

new Vue({
  el: '#app',
  components: {
    VuePassword
  },
  data {
    user: {
      email: '',
      password: ''
    }
  }
})

HTML

<form>
    <div class="mb-4">
        <label for="password">Password</label>
        <VuePassword
            v-model="password1"
            id="password1"
            :strength="strength"
            type="text"
        />
    </div>
</form>

Props

Use the following props to configure the password input.

| Prop | Default | Description | | ---- | :-----: | ----------- | | classes | 'form-control' | Set the classes for the input element. The default is the 'form-control' class used by Twitter Bootstrap. A string or array of classes can be passed in the prop. | | disableStrength | false | Disable the password strength meter and messages. | | disableToggle | false | Disable the password input toggle to show/hide the password. | | strengthClasses | ['VuePassword--very-weak', 'VuePassword--weak', 'VuePassword--medium', 'VuePassword--good', 'VuePassword--great'] | Set the classes used to style the strength message and strength meter. This should be an array of five classes. The classes are applied depending on the current strength score of the password (0-4). | | strengthMessages | ['Very Weak Password', 'Weak Password', 'Medium Password', 'Strong Password' 'Very Strong Password'] | Set the messages that appear depending on the strength score of the password. This should be an array of five messages. |

Events

The password input emits an input event to use with v-model. Other events are binded use v-on="listeners".

Slots

Named slots can be used to change the layout of the password toggle, strength meter, and strength messages.

| Slot | Scope | Description | | ---- | ----- | ----------- | | password-input | strength: Strength valuetype: Current element type ('password or text')updatePassword: Method to update the password value.value: Current password value | Use this to replace the input element. The content provided by the slot must include an input field, preferably of type password. | | password-toggle | toggle: Method to change the input type attribute from 'password' to 'type' | Use this named slot to change the layout of the password toggle. | | password-hide | | Use this named slot to change the password hide icon. | | password-show | | Use this named slot to change the password show icon. | | strength-meter | strength: Strength valuestrength-class: Current strength classstrength-classes: The array of strength classesstrength-message: Current strength messagestrength-messages: The array of strength messages | Use this named slot to change the layout of the password strength meter. |

Example: Use custom input

<VuePassword
    v-model="user.password"
>
    <div
        v-slot:password-input="props"
        class="control has-icons-left"
    >
        <input
            class="input"
            type="password"
            placeholder="Text input"
            :value="props.value"
            @input="props.updatePassword"
        />
    </div>
</VuePassword>

Custom Strength Example

HTML

<form>
    <label for="password">Password</label>
    <VuePassword
        v-model="user.password"
        :strength="score"
        @input="updateStrength"
    />
</form>

Javascript

import VuePassword from 'vue-password'

new Vue({
    el: '#app',
    components: {
        VuePassword,
    },
    data: {
        score: 0,
        user: {
            password: ''
        }
    },
    methods: {
        updateStrength(password) {
            /**
             * The input event sends the current password and
             * any included user inputs (email in this case).
             *
             * Calculate the score here either using a custom
             * javascript library or a request to the server.
             *
             * The strength must be an integer between 0 and 4.
             */
        }
    }
});