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 🙏

© 2026 – Pkg Stats / Ryan Hefner

flowform-component

v1.1.4

Published

FlowForm组件库

Readme

FlowForm 组件库

基于 Formily 和 Ant Design 的表单组件库,提供完整的表单解决方案。

安装

npm install @flowform/components
# 或
yarn add @flowform/components

基本用法

1. 创建表单实例

import { createForm } from '@formily/core';
import { FormProvider } from '@formily/react';

const form = createForm({
  initialValues: {
    name: '',
    age: ''
  }
});

2. 使用表单组件

import { Form, FormItem, Input } from '@flowform/components';

const MyForm = () => {
  return (
    <FormProvider form={form}>
      <Form>
        <FormItem label="姓名" name="name" required>
          <Input placeholder="请输入姓名" />
        </FormItem>
        
        <FormItem label="年龄" name="age" required>
          <Input placeholder="请输入年龄" />
        </FormItem>
      </Form>
    </FormProvider>
  );
};

重要说明:为什么 field 是 undefined?

在 Formily 中,useField() 返回 undefined 的主要原因:

1. 缺少 FormItem 包装

错误用法

<Input /> // 直接使用,没有 FormItem 包装

正确用法

<FormItem name="fieldName">
  <Input />
</FormItem>

2. FormItem 缺少 name 属性

错误用法

<FormItem label="姓名">
  <Input />
</FormItem>

正确用法

<FormItem label="姓名" name="name">
  <Input />
</FormItem>

3. 组件层级结构错误

错误用法

<Form>
  <Input /> {/* 直接放在 Form 下 */}
</Form>

正确用法

<Form>
  <FormItem name="name">
    <Input />
  </FormItem>
</Form>

字段调试

使用 FieldDebug 组件来调试字段连接状态:

import { FieldDebug } from '@flowform/components';

<FormItem label="姓名" name="name">
  <Input />
  <FieldDebug name="name" />
</FormItem>

这会显示:

  • 字段是否存在
  • 字段路径
  • 字段值
  • 字段错误信息

组件列表

基础组件

  • Form - 表单容器
  • FormItem - 表单项包装器
  • Input - 文本输入框
  • InputNumber - 数字输入框
  • TextArea - 多行文本输入框

选择组件

  • Select - 下拉选择器
  • Checkbox - 单选框
  • CheckboxGroup - 复选框组
  • Radio - 单选按钮
  • RadioGroup - 单选按钮组

其他组件

  • DatePicker - 日期选择器
  • Switch - 开关
  • Upload - 文件上传
  • FieldDebug - 字段调试器

常见问题

Q: 为什么 useField() 返回 undefined?

A: 确保组件被 FormItem 包装,且 FormItem 有 name 属性。

Q: 如何获取字段值?

A: 使用 field.value 或通过表单实例的 values 属性。

Q: 如何设置字段值?

A: 使用 field.setValue(value) 或表单实例的 setValues() 方法。

Q: 如何监听字段变化?

A: 使用 field.addPropertyListener() 或表单实例的 addPropertyListener() 方法。

示例

查看 src/example/example.tsx 文件获取完整的使用示例。