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

@aimake/form

v0.0.12

Published

@aimake/form

Downloads

58

Readme

@aimake/form

@aimake/form 是一个基于 AntD Form 的表单组件,用于快速生成一个 PC 端的表单,和 AntD Form 不同,@aimake/form 中集成了 AntD 组件库中所有的 "数据录入"类型的组件,用户无需再引入这些表单组件,可以通过配置化的方式快速产出一个表单。除了默认已经记载了 AntD "数据输入" 组件,@aimake/form 还同时支持用户自定义组件,只需要用户遵守统一的属性和接口规范。

@aimake/form 将表单中的所有涉及到数据抽象成三个属性:config(定义表单项内容)、options(选择类组件的选项)、defaultValues(表单项初始值)。无论是哪种联动逻辑,无一例外均是对这三个属性的修改,可以通过 Form 组件的 onFieldsChange 函数监听用户操作,修改以上三个属性。

安装

npm install @aimake/form

配置文件范例

[
  {
    "label": "日期范围",
    "name": "range",
    "type": "RangePicker",
    "format": "YYYY/MM/DD HH:mm:ss"
  },
  {
    "label": "日期",
    "name": "date",
    "type": "DatePicker",
    "format": "YYYY/MM/DD HH:mm:ss"
  },
  {
    "label": "比对阈值",
    "name": "threshold",
    "type": "Input",
    "addonBefore": ">=",
    "pattern": "^\\d+(\\.\\d+)?$",
    "required": true
  },
  {
    "label": "门店",
    "name": "shopId",
    "type": "Select"
  },
  {
    "label": "线索",
    "name": "haveClue",
    "type": "Radio"
  },
  {
    "label": "年龄",
    "name": "age",
    "type": "Slider",
    "defaultValue": 50,
    "min": 0,
    "max": 120
  },
  {
    "label": "数量",
    "name": "count",
    "type": "InputNumber"
  },
  {
    "label": "开关",
    "name": "switch",
    "type": "Switch"
  },
  {
    "label": "邮箱",
    "name": "email",
    "type": "AutoComplete"
  }
]

代码范例

<AiMakeForm
    form={form}
    layout="horizontal"
    onSubmit={this.handleSubmit}
    config={formConfig}
    options={formOptions}
    defaultValues={formDefaultValue}
    submitText="搜索"
    formComponents={{"Uploader": Uploader}}
    clear
/>

详细代码可见 @aimake/form 下 examples 目录中的代码。运行方法:在 @aimake/form 目录下运行 npm run start,浏览器输入 localhost:8080,即可预览页面。(需要先绑定 127.0.0.1 localhost)

API

AiMakeForm

AiMakeForm 组件本身是对 AntD Form 组件的包装,接受 AntD Form 的所有属性,除此以外还有以下属性。

props:

组件配置项

每个表单项组件均是对 AntD "数据录入"类型组件的封装,接受该组件的全部属性,除此以外还有以下属性。

props: