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

phone-code-verify

v1.0.5

Published

Inputs for phone code verification

Downloads

15

Readme

phone-code-verify 简介

中文 | English

phone-code-verify是一个手机验证码输入组件,它封装了在验证码输入时的交互与UI,是一个开箱即用的React小组件。

功能

  • 支持4-6单字符位输入
  • 支持输入框内容校验,校验未通过时实时展示自定义信息以及UI提醒
  • 支持框和下划线两种布局方式
  • 支持粘贴自动填入
  • 支持键盘左右键选择输入框、删除键回退、回车键提交
  • 支持样式修改等等

演示

方框样式

UI演示视频

默认样式 自动校验 成功提交

单线模式

UI演示视频

默认样式 自动校验 成功提交

使用

import { PhoneCodeVerify } from 'phone-code-verify'
import type { PhoneCodeVerifyProps } from 'phone-code-verify'

function YourApp () {
  const handleConfirm = (values) => {
    console.log('Got values onConfirm: ', values)
    return new Promise((resolve, reject) => {
      setTimeout(() => {
        resolve('ok')
      }, 1000)
    })
  }
  const handleChange = (values) => {
    console.log('Got values onChange: ', values)
  }
  const customProps = {
    wrapperClass: "yourCuntomClass",
    tip:"手机验证码", // 展示在输入框上面的说明文字内容
    maxWidth: 400, // 输入区域最大宽度
    num: 4, // 几个输入框
    mode: "line", // 'default'是输入框样式, 'line' 是单线样式
    pattern:"[0-3]", // 输入框校验规则, 见https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern
    patternMessage: "请输入0-3的数字", // 校验未通过时展示的文字
    button: true, // 是否展示输入框下方提交按钮
    buttonText: "输入验证", // 按钮文字
    onConfirm: handleConfirm, // 提交事件
    onChange: handleChange // 输入事件
  } as PhoneCodeVerifyProps
  return (
    <div>
      <PhoneCodeVerify {...customProps} />
    </div>
  )
}

样式修改

样式可以使用自定义样式覆盖组件样式。 也可以使用以下方式覆盖PCV_xxx样式。

function YourApp () {
  return (
    <div>
      <style>
        {`.PCV_container {
          color: red;
        }`}
      </style>
      <PhoneCodeVerify {...customProps} />
    </div>
  )
}