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

@ophiuchus/password-input

v1.0.1

Published

### 介绍

Downloads

1

Readme

PasswordInput 密码输入框

介绍

带网格的输入框组件,可以用于输入密码、短信验证码等场景,通常与数字键盘组件配合使用。

引入

import Vue from 'vue';
import PasswordInput from '@ophiuchus/password-input';
import NumberKeyboard from '@ophiuchus/number-keyboard';

Vue.use(PasswordInput);
Vue.use(NumberKeyboard);

代码演示

基础用法

搭配数字键盘组件来实现密码输入功能。

<!-- 密码输入框 -->
<sf-password-input
  :value="value"
  :focused="showKeyboard"
  @focus="showKeyboard = true"
/>
<!-- 数字键盘 -->
<sf-number-keyboard
  v-model="value"
  :show="showKeyboard"
  @blur="showKeyboard = false"
/>
export default {
  data() {
    return {
      value: '123',
      showKeyboard: true,
    };
  },
};

自定义长度

通过 length 属性来设置密码长度。

<sf-password-input
  :value="value"
  :length="4"
  :focused="showKeyboard"
  @focus="showKeyboard = true"
/>

格子间距

通过 gutter 属性来设置格子之间的间距。

<sf-password-input
  :value="value"
  :gutter="10"
  :focused="showKeyboard"
  @focus="showKeyboard = true"
/>

明文展示

mask 设置为 false 可以明文展示输入的内容,适用于短信验证码等场景。

<sf-password-input
  :value="value"
  :mask="false"
  :focused="showKeyboard"
  @focus="showKeyboard = true"
/>

提示信息

通过 info 属性设置提示信息,通过 error-info 属性设置错误提示,例如当输入六位时提示密码错误。

<sf-password-input
  :value="value"
  info="密码为 6 位数字"
  :error-info="errorInfo"
  :focused="showKeyboard"
  @focus="showKeyboard = true"
/>
<sf-number-keyboard
  v-model="value"
  :show="showKeyboard"
  @blur="showKeyboard = false"
/>
export default {
  data() {
    return {
      value: '123',
      errorInfo: '',
      showKeyboard: true,
    };
  },
  watch: {
    value(value) {
      if (value.length === 6 && value !== '123456') {
        this.errorInfo = '密码错误';
      } else {
        this.errorInfo = '';
      }
    },
  },
};

API

Props

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | value | 密码值 | string | '' | | info | 输入框下方文字提示 | string | - | | error-info | 输入框下方错误提示 | string | - | | length | 密码最大长度 | number | string | 6 | | gutter | 输入框格子之间的间距,如 20px 2em,默认单位为px | number | string | 0 | | mask | 是否隐藏密码内容 | boolean | true | | focused | 是否已聚焦,聚焦时会显示光标 | boolean | false |

Events

| 事件名 | 说明 | 回调参数 | | ------ | ---------------- | -------- | | focus | 输入框聚焦时触发 | - |

样式变量

组件提供了下列 Less 变量,可用于自定义样式,使用方法请参考主题定制

| 名称 | 默认值 | 描述 | | -------------------------------- | --------------- | ---- | | @password-input-height | 50px | - | | @password-input-margin | 0 @padding-md | - | | @password-input-font-size | 20px | - | | @password-input-border-radius | 6px | - | | @password-input-background-color | @white | - | | @password-input-info-color | @gray-6 | - | | @password-input-info-font-size | @font-size-md | - | | @password-input-error-info-color | @red | - | | @password-input-dot-size | 10px | - | | @password-input-dot-color | @black | - |