Giter Site home page Giter Site logo

tianzhich / easy-schema-form Goto Github PK

View Code? Open in Web Editor NEW

This project forked from open-federation/easy-schema-form

0.0 0.0 0.0 253 KB

A React component for building Web forms from JSON Schema.

Home Page: https://hellosean1025.github.io/jsf/

License: Apache License 2.0

Shell 1.17% JavaScript 96.20% HTML 0.57% SCSS 2.06%

easy-schema-form's Introduction

easy-schema-form

一个基于 jsonschema 生成form 表单的 react 组件

目标

  1. 采用标准化交互,满足大部分需求

    • 为了实现这个目的,我们对 object 类型统一为左右两栏布局;
    • 对 object Array 类型,采用了表格式布局,可以设置不常用编辑项或一些比较占用空间的编辑项通过弹层的方式打开编辑;
  2. 使用了 ajv 验证库

  3. 支持通过 js 表达式自定义部分交互(比如隐藏、禁用等)

  4. 支持自定义组件

Live PlayGround

快速开始

Install

npm i easy-schema-form

Usage

import EasyForm from 'easy-schema-form'
import 'easy-schema-form/dist/main.css'


const schema = {
  type: "object",
  required: ['name'],
  properties: {
    name: {
      title: '用户名',
      type: "string",
      description: "zzzzzz",
      pattern: "[0-9]+"
    },
  }
}

export default class App extends React.PureComponent {
  static propTypes = {
    curTab: Proptypes.string.isRequired,
    match: Proptypes.object,
  };
  state = {
    data: {}
  };

  onChange =(value)=>{
    this.setState({
      data: value
    })
  }

  render () {
    return (
      <EasyForm onChange={this.onChange} value={this.state.data} schema={schema} />
    );
  }
}

License

MIT

easy-schema-form's People

Contributors

hellosean1025 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.