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

welife-kit

v1.0.19

Published

A component library implemented by Taro + Typescript

Downloads

3

Readme

Taro+React实现的多端组件库

组件介绍

WeForm

简单的表单验证组件,将组件内用户输入的 input、textarea、uploader、picker 等提交,需要和 Wefield 组合使用

示例代码

import React, { Component } from 'react';
import { View, Button } from '@tarojs/components';
import { WeInput, WeForm, WePicker, WeField } from 'welife-kit';
import './index.scss';

export default class Index extends Component {
  state = {
    selector: [
      { value: '海珠区', name: '海珠区' },
      { value: '天河区', name: '天河区' },
    ],
    formData: {
      name: '',
      dicts: 1,
    },
    rules: {
      name: [
        { required: true, message: '请输入姓名' },
        { patten: /[\u4E00-\u9FA5]+/, message: '请输入正确的姓名' },
      ],
      code: [
        { required: true, message: '请输入验证码' },
        { custom: this.codeLength, message: '请输入4位验证码' },
      ],
      dicts: [{ required: true, message: '请选择区县' }],
    },
  };

  formRefs = null;

  codeLength(value) {
    return value.length === 4;
  }

  onSubmit(event) {
    //点击提交后获取表单输入数据
    console.log(event);
  }

  handleClickSubmit() {
    //使用ref
    const current = this.formRefs;
    current &&
      current.submit().then((res) => {
        //表单输入数据
        console.log(res);
      });
  }

  render() {
    const { selector, rules, formData } = this.state;
    return (
      <WeForm rules={rules} data={formData} ref={(refs) => (this.formRefs = refs)} onSubmit={this.onSubmit.bind(this)}>
        <WeField label="姓名" name="name">
          <WeInput placeholder="请输入姓名"></WeInput>
        </WeField>
        <WeField label="验证码" name="code">
          <WeInput placeholder="请输入验证码"></WeInput>
        </WeField>
        <WeField label="选择区县" name="dicts">
          <WePicker range={selector} rangeKey="value" placeholder="请选择区县"></WePicker>
        </WeField>
        <Button formType="submit">使用formType提交</Button>
        <Button style="margin-top:10px;" onClick={this.handleClickSubmit.bind(this)}>
          使用form-refs提交
        </Button>
      </WeForm>
    );
  }
}

FormProps

| 参数 | 类型 | 说明 | 必填 | | :------- | :----- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :--- | | rules | object | 表单的校验规则,key 要对应 WeField 中设置的 name, value 为数组对象,属性有 required:boolean(是否必填)、message:string(提示文案)、patten:regex(正则表达式)、custom:void(自定义规则,必须返回 boolean) | ✔️ | | data | object | 表单中每个组件的初始值 | ✔️ | | onSubmit | void | 设置了 formType='submit'的 Button 组件点击时会触发,通过 ref 的 submit 提交也会触发,返回表单 state | |

RefHandler

| 名称 | 说明 | | :-------- | :------------------------------------------------------------- | | formState | 表单的数据 | | validate | 校验整个表单,获取校验结果(但不显示提示文案),不触发提交事件 | | submit | 校验表单并提交,显示校验错误的提示文案 | | setValue | 设置单个表单的输入内容 | | getValue | 获取表单的所有输入信息 |