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

react-conf-form

v1.2.18

Published

> 集成了[antd](https://ant.design/index-cn)的配置化表单(思路来源于[jsonschema form]( https://github.com/rjsf-team/react-jsonschema-form)) > 不同的是,简化了配置的书写以及数据的提取

Downloads

43

Readme

React Conf Form

集成了antd的配置化表单(思路来源于jsonschema form) 不同的是,简化了配置的书写以及数据的提取

继承了控件Input, Button, Select, Upload等常用控件,可自定义扩展控件

自带校验规则,可扩展校验规则

表单数据自动提取

安装install

yarn add react-conf-form 
or 
npm install react-conf-form

使用usage

import * as React from 'react'
import Form from 'react-conf-form'
import 'react-conf-form/dist/index.css' // import once

export default class FormDemo extends React.Component {
    onSubmit = (data) => { console.log(data) }
    
    render() {
      return (
        <Form
          fields={FIELDS_CONF}
          dataSource={DATA_SOURCE}
          onSubmit={this.onSubmit}
        />
      )
    }
}

参数 props

| 参数 | 类型 | 默认值 | 描述 | | ----------------- | -------------------------- | ------------- | ----------------------- | | spinning? | boolean | false | 是否显示加载状态 | | validateOnChange? | boolean | true | 是否在onChange自动进行校验 | | labelDirection? | 'vertical' | 'horizontal' | horizontal | label位置 | | labelWidth? | number | 120 | label的宽度 | | fields | Array<...> | - | fields | | dataSource? | Object | - | 初始值对象(对应fields的key相应的属性值) | | onSubmit? | (data) => void | - | 提交(data为最新的值) | | onChange? | (key, value, data) => void | - | 任意表单项修改触发 | | onReset? | () => void | - | 重置触发 | | extendFields? | Array | - | 扩展表单控件 | | extendValidators? | Array | - | 扩展校验规则 |


onSubmit = (data) => console.log(data)

onChange = (name, value, data) => console.log(name, value, data)

onReset = () => {}

render() {
  const FIELDS = [...]

  return (
    <Form
      spinning={false}
      validateOnChange={true}
      labelDirection="horizontal"
      labelWidth={120}
      fields={FIELDS}
      dataSource={{}}
      onSubmit={this.onSubmit}
      onChange={this.onChange}
      onReset={this.onReset}
      extendFields={[]}
      extendValidators={[]}
    />
  )
}

配置

行 Row

| 参数 | 类型 | 默认值 | 描述 | | ---------- | ----------------------- | ------------- | ------------------------ | | span? | number | 8 | 行内单元格所占珊格,最大24 | | gutter? | number | 16(px) | 间隔 | | type? | 'FormButtons' | string | - | 按钮行 / 常规控件行 | | style? | object | - | 自定义样式 | | className? | string | - | 自定义样式class | | display? | string | true | 是否显示 | | fields | array | | 单元格配置 | | align? | center | left | right | - | 适用于按钮行(FormButtons), 按钮的对齐方式 |

const FIELDS = [
  { // row 
    span: 8,
    gutter: 16,
    display: true,
    type: 'fields',
    fields: [...], // field's cols
  }
]

列 (fields: [field, ...])

| 参数 | 类型 | 默认值 | 描述 | | ---------- | ----------------------------------------- | ------------- | ------------------------------------ | | key | string(唯一) | - | field & data对应的key | | span? | number(1~24) | 继承row | 栅格宽度 | | offset? | number(1~24) | 0 | 偏移栅格 | | label | string | - | | | type | string | - | input, render, timepicker... | | display? | boolean | true | 是否展示 | | readOnly? | boolean | false | 是否只读 | | className? | string | - | css class | | props | | | 控件内部的参数 | | | className? | - | css class | | | rules: Array | [] | rules for validation | | | onChange?: (name, value) => void | - | | | | beforeChange?: (name, value) => new value | - | onChange触发前调用,用于覆盖处理onChange的值 | | | onClick?: (data) => any | | 当type="button",点击回调 | | | render?: string | Node | (data) => any | | 当type="render",render方法/对象 | | | addon?: string | Node | (data) => any | | 额外的render | | | ...others | | |