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

fx-schema-form-extension

v3.1.13

Published

自动生成表单组件

Downloads

54

Readme

react-schema-form

爬虫前端核心组件。

react-schema-form-extension

这是一个扩展项目,包括许多实用的hoc。

目录

安装

npm

npm install --save fx-schema-form-extendsion

HOC列表

condition

条件hoc,可以设置需要使用的数据,一般不单独使用。

配置参数:

  • paths: ConditionPath[]; 配置需要的数据路径;
  • hoc: ComponentEnhancer<any, any>; 下层hoc;
export interface ConditionPath {
    /**
     * 数据的路径,可以是相对路径
     * example: ./height, ../height, /height
     */
    path: string;
    /**
     * 是否从meta中获取数据
     * 如果是从meta中获取数据,额需要配置metaKey
     */
    meta: boolean;
    /**
     * 需要获取的meta的字段
     * 例如 isLoading
     */
    metaKey: string;
}

返回属性:

  • condition: Immutable.Map<string, any>; 数据,数据的key使用全路径数组join("/")得到。

changed

数据变更后回调,需要配合condition来使用。

配置参数:

  • paths?: string[]; 需要监听变化的数据数组;(已废弃)
  • condition: ConditionHocSettings; condition的设置参数;
  • onChanged: (props: DefaultProps, data: any) => void; 数据变化时候的回调;

返回属性: null

实例: demo


// 下面是一个uiSchema的配置
// 监听高度的变化,做一些操作
{
  key: "width",
  hocs: ["utils", "theme", "field", "validate", "changed", "temp"],
  options: Immutable.fromJS({
      hoc: {
          changed: {
            //   paths: ["../height"],
              condition: {
                  paths: [{
                      path: "../height"
                  }]
              },
              onChanged: (props: any, data: any) => {
                  let height = props.getPathKeys(props.uiSchema.keys as any, "../height").join("/");

                  if (data[height] !== undefined) {
                    // do something
                  }
              }
          }
      }
  })
}

copytometa

把数据拷贝到meta中。

配置参数:

  • paths: CopyToMetaPath[];需要copy的数据配置。
  • condition: ConditionHocSettings; condition的设置参数;
export interface CopyToMetaPath {
    // 数据的路径
    path: string;
    // 拷贝到的路径
    to: string[];
    // 默认值
    defaultValue?: any;
}

返回属性: null

实例: demo

// 这是一个uiSchema的配置
// 这里当宽度变化的时候,把宽度的值设置到高度的meta中去
// 即宽度是高度的最大值
{
  key: "height",
  hocs: ["utils", "theme", "field", "validate", "copyToMeta", "temp"],
  options: Immutable.fromJS({
      hoc: {
          copyToMeta: {
              condition: {
                  paths: [{ path: "../width" }]
              },
              paths: [{ path: "../width", defaultValue: 0, to: ["options", "widget", "number", "options", "max"] }]
          }
      }
  })
}

datatometa

把data中的数据拷贝到meta。

配置参数: null 返回属性: null

format

根据schema中设置的format自动选择组件。

配置参数: null 返回属性: null

oneof

处理oneof关键字对应的表单。

配置参数:

  • path: string; 数据字段路径,根据这个的值来改变表单的展现。
  • key: anyOf|oneOf; schema中的关键字。
  • condition: ConditionHocSettings; condition的设置参数。
  • uiSchemas?: UiSchemas; 根据不同的值,来展现不同的uiSchema配置。
  export class UiSchemas {
    [key: string]: {
        // schemaId
        schemaId: string;
        // uiSchemas配置
        uiSchemas: Array<FxUiSchema | string>;
    };
}

返回属性: null

实例: demo

// 这里对type的值做检测
// 当type的值变化的时候,value的表单会变化
[{
  key: "type",
  widget: "select",
  options: Immutable.fromJS({
      widget: {
          select: {
              options: {
                  children: [1, 2, 3, 4].map((val: number, index: number) => {
                      return (<SelectOption key={index} value={val}>{val}</SelectOption>) as any;
                  })
              }
          }
      }
  })
}, {
  key: "value",
  hocs: ["utils", "theme", "field", "validate", "oneOf", "array", "temp"],
  options: Immutable.fromJS({
      hoc: {
          oneOf: {
              condition: {
                  paths: [{ path: "../type" }]
              },
              path: "../type",
              key: "oneOf",
              uiSchemas: {
                  1: { schemaId: "dnd-oneof-number", uiSchemas: ["*"] },
                  2: { schemaId: "dnd-oneof-string1", uiSchemas: ["*"] },
                  3: { schemaId: "dnd-oneof-boolean", uiSchemas: ["*"] },
                  4: {
                      schemaId: "dnd-oneof-object", uiSchemas: [{
                          key: "",
                          temps: ["formitem"],
                          children: ["*"]
                      }]
                  }
              }
          }
      }
  })
}]

resetkey

处理下一级hoc的props属性的列表。

配置参数: null

返回属性:

  • excludeKeys: string[]; 需要过滤掉的属性名。
  • includeKeys: string[]; 不需要过滤掉的属性名。

show

是否显示下层组件。

配置参数:

  • paths?: string[]; 需要验证的数据字段路径。(已废弃)
  • renderNothings?:boolean; 如果不显示,是否返回null,否则把display设置成none。
  • condition: ConditionHocSettings; condition的设置参数。

返回属性: null

实例: demo

// 这里户根据isEighteen的值,来决定现不现实textAlign这个字段
{
    key: "textAlign",
    hocs: ["utils", "theme", "field", "validate", "show", "temp"],
    options: Immutable.fromJS({
        hoc: {
            show: {
                condition: {
                    paths: [{ path: "../isEighteen" }]
                },
                // paths: ["../isEighteen"]
            }
        }
    })
}

wrapper

包装组件。

配置参数:

  • condition: ConditionHocSettings; condition的设置参数。
  • hoc?:any; 下层的hoc。
  • hocName?:string; 下层的hoc的name,用于获取hoc的设置参数。

返回属性: null

启动

  npm start

启动localhost:8004

License

MIT