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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@swiftcrab/crab

v1.0.11

Published

react-Ui库

Downloads

1,102

Readme

可参看 antd 官方文档

额外提供

FormArea

  import { FormArea } from '@swiftcrab/crab'
  import { IFormItem, IForm } from '@swiftcrab/crab/es/form-area/type'
  import { useForm } from '@swiftcrab/crab/es/hooks'

  const initialValues = {}

  const form = useForm<typeof initialValues>(initialValues)
  const { values, set, ValidateTooltip, setFieldProps } = form

  const item = useMemo((): Array<IFormItem<Init>> => [
    {
      label: '输入框',
      dataKey: '输入框',
      dataType: 'Input',
      rules: [{ required: true, message: '必填' }],
      onChange: (values, form, e) => {
        form.set({ ...values, 输入框: e.target.value })
      }
    },
    {
      label: '多选框',
      dataKey: '多选框',
      dataType: 'Checkbox',
      dataProps: {
        options: [
          { value: 1, label: '打球' },
          { value: 2, label: '跑步' },
          { value: 3, label: '敲代码' }
        ]
      }
    },
    {
      label: '日期选择框',
      dataKey: '日期选择框',
      dataType: 'DateRangePicker',
      dataProps: {
        className: 'w'
      },
      hidden: data => data['单选框'] === 1
    },
  ], [])

  <FormArea
    item={item}
    form={form}
    initialValues={initialValues}
    colon={false}
    buttonLocation="nextLast"
    hasResetBtn={true}
    hiddenField={true}
    onSubmit={async (value: Init) => {}}
  />
| 参数    |   说明   |   类型    |   默认值  |
| ------ | ------- | -------- | ------- |
| initialValues        | 初始值   | `Record<string, any>` | -    | 
| item                 | 表单元素    | `Array<FormItem<any>>` | -    | 
| form                 | useForm 返回结果。表单数据和操作的集合 | `IFormState<any>`   | -   | 
| colon                | 所有 label 后面是否带冒号 | `boolean`  | `false`   | 
| allLabelClassName    | 所有 label 的 className | `string`  | -  | 
| allLabelStyle        | 所有 label 的 style  | `CSSProperties` | -  |
| onSubmit             | 点击提交按钮触发事件 | - | `(values, form) => void` |
| onReset              | 点击重置按钮触发事件 | `() => void` | -  |
| hasSubmitBtn         | 是否有提交按钮 | `boolean` | `true`|
| hasResetBtn          | 是否有重置按钮 | `boolean` | `true`  |
| submitProps          | 自定义提交按钮属性 | `ButtonProps & { text: string }`  | - |
| resetProps           | 自定义重置按钮属性 | `ButtonProps & { text: string }` | -  |
| columnGapWidth       | 每列之间的间距 | `number` | `16`  |
| rowGapWidth          | 每行之间的间距 | `number` | `0`  |
| numberOfInline       | 一行元素显示个数 | `number`  | `4`  |
| buttonLocation       | 提交,重置按钮的位置 | `'first', 'last', 'next', 'nextLast'`| `nextLast`|
| buttonWrapExtra      | 提交,重置按钮后追加内容| `ReactNode` | - |
| formClassName        | Form 的 className | `string` | -  |
| formStyle            | Form 的 style | `CSSProperties` | -   |
| buttonWrapClassName  | 提交,重置按钮区域的 className  | `string`  | -  |
| buttonWrapStyle      | 提交,重置按钮区域的 style | `CSSProperties` | -  |
| labelWrap            | 所有元素 label 是否换行 | `boolean` | `true` |
| layout               | 所有元素布局 | `'horizontal', 'vertical'` | `horizontal` |
| hiddenField         | 提交表单是否过滤隐藏元素数据 | `boolean` | `true`  |

## FormArea.Item
| 参数               | 说明     | 类型    | 默认值  |
| ----------------- | ---------------- | ---------------- | ------- |
| dataKey           | 值的键  | `string` | -  |
| dataType          | 表单元素类型 | `string`, `(values, form, name) => void`, `ReactNode` | - |
| label             | 标签名称 | `string`, `ReactNode`| -  |
| colon             | label 后面是否带冒号 | `boolean`| `false` | 
| labelClassName    | label 的 className | `string`  | -   | 
| labelStyle        | label 的 style  | `CSSProperties` | -   | 
| dataProps         | 元素类型的属性 |  `{}` 或 `(value, form) => boolean`   | -       | 
| rules             | 元素类型的校验规则  | `Rule[]` 或 `(value, form) => Rule[]`  | -   | 
| hidden            | 元素类型是否展示  | `boolean` 或 `(value, form) => boolean`   | `true`  | 
| disabled          | 元素类型是否禁用 | `boolean` 或 `(value, form) => boolean` | `false` |
| tooltip           | label 后的问号提示 | `ReactNode`  | -   |
| extraLayout       | 元素右侧和下侧额外内容 | `{ bottom?: ReactNode, right?: ReactNode }`  | - |
| occupyColumns     | 元素类型跨占列数,不能大于 numberOfInline  | `number`  | `1`     | 
| validateStatus    | 元素类型校验状态  | `’success‘, ’warning‘, ’error‘, ’validating‘`  | - | 
| required          | 元素是否显示必填 \* 号  | `boolean` | `true`  |
| onChange          | 元素的 change 事件,args 表单元素 onChange 事件的参数 | `(values, form, ...args) => void` | - |

## useForm
| 参数              | 说明           |
| ----------------- | -------------- |
| `values`          | 当前表单值     |
| `set`             | 修改表单值     |
| `reset`           | 重置表单值     |
| `validateFields`  | 校验当前表单    |
| `setFieldProps`   | 设置目标字段其他属性    |
| `ValidateTooltip` | 使用Tooltip组件展示错误信息 |
| `其他属性` | [useForm](https://ant-design.antgroup.com/components/form-cn#forminstance) |

## dataKey
| 类型              | 说明           |
| ----------------- | -------------- |
| `Input`           | 普通输入框     |
| `InputPassword`   | 密码输入框     |
| `TextArea`        | 多行输入框     |
| `InputNumber`     | 数字输入框     |
| `AutoComplete`    | 自动完成输入框 |
| `Mentions`        | 提及输入框     |
| `Select`          | 选择器         |
| `MultiSelect`     | 多选选择器     |
| `TreeSelect`      | 树形选择器     |
| `Cascader`        | 级联选择器     |
| `DatePicker`      | 日期选择器     |
| `DateRangePicker` | 日期范围选择器 |
| `TimePicker`      | 时间选择器     |
| `Radio`           | 单选按钮       |
| `Checkbox`        | 多选按钮       |
| `Slider`          | 滑动输入条     |
| `Switch`          | 开关           |
| `Upload`          | 上传           |
| `Transfer`        | 穿梭框         |
| `FormList`        | 可增删表单项   |