1 Star 0 Fork 3

fei33423 / schema-generator

forked from 牛虻 / schema-generator 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

FR 可视化 schema 编辑器

schema编辑器

安装

npm i fr-generator

使用

import React from 'react';
import Generator from 'fr-generator';

const defaultValue = {
  schema: {
    type: 'object',
    properties: {
      inputName: {
        title: '简单输入框',
        type: 'string',
      },
    },
  },
  displayType: 'row',
  showDescIcon: true,
  labelWidth: 120,
};

const templates = [
  {
    text: '模板1',
    name: 'something',
    schema: {
      title: '对象',
      description: '这是一个对象类型',
      type: 'object',
      properties: {
        inputName: {
          title: '简单输入框',
          type: 'string',
        },
        selectName: {
          title: '单选',
          type: 'string',
          enum: ['a', 'b', 'c'],
          enumNames: ['', '', ''],
        },
        dateName: {
          title: '时间选择',
          type: 'string',
          format: 'date',
        },
      },
    },
  },
];

const Demo = () => {
  const submit = schema => {
    alert(JSON.stringify(schema));
  };

  return (
    <Generator
      defaultValue={defaultValue}
      templates={templates}
      submit={submit}
    />
  );
};

export default Demo;

代码展示效果见 Demo。 目前支持 3 个 props:defaultValuetemplatessubmit

  • defaultValue: 默认一进入编辑器展示的表单对应的 schema。格式参考 schema 生成器的输出 schema
  • templates: 常用的 schema 模板,模板方便用户点击使用。格式参照上面代码:text 按钮文案,name 对应的字段
  • submit: 提交按钮的 callback,入参是导出的 schema

空文件

简介

FR的schema的可视化生成器 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/philcode/schema-generator.git
git@gitee.com:philcode/schema-generator.git
philcode
schema-generator
schema-generator
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891