fr-generator
<img src="https://gw.alipayobjects.com/mdn/rms_e18934/afts/img/A*4QYNTbKU6xAAAAAAAAAAAABkARQnAQ?raw=true" width="750px"/>
Last updated 16 hours ago by fateriddle .
Original npm · Tarball · package.json
$ cnpm install fr-generator 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.5.3-beta.0                                ...           beta (6 days ago)
  • 0.5.5                                ...           latest (16 hours ago)

16 Versions

  • 0.5.5                                ...           16 hours ago
  • 0.5.4                                ...           2 days ago
  • 0.5.3-beta.0                                ...           6 days ago
  • 0.5.2                                ...           10 days ago
  • 0.5.1                                ...           a month ago
  • 0.5.0                                ...           2 months ago
  • 0.4.0                                ...           2 months ago
  • 0.3.4                                ...           2 months ago
  • 0.3.3                                ...           2 months ago
  • 0.3.2                                ...           2 months ago
  • 0.3.1                                ...           2 months ago
  • 0.3.0                                ...           2 months ago
  • 0.2.3-0                                ...           2 months ago
  • 0.2.2                                ...           2 months ago
  • 0.2.1                                ...           2 months ago
  • 0.2.0                                ...           2 months ago
Maintainers (1)
Downloads
Today 1
This Week 62
This Month 194
Last Day 30
Last Week 87
Last Month 209
Dependencies (9)
Dev Dependencies (9)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |