Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

form-render-widgets

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

form-render-widgets

常用的form-render自定义组件

latest
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

form-render-widgets

NPM JavaScript Style Guide

Install

npm i form-render-widgets
# or
yarn add form-render-widgets

Usage

import React, { useState } from 'react'
import FormRender from 'form-render/lib/antd'
import SCHEMA from './schema.json'
import RichTextEditor from 'form-render-widgets'

export default function Demo() {
  const [formData, setData] = useState(SCHEMA.formData || {})
  const [valid, setValid] = useState([])

  const onSubmit = () => {
    console.log(formData)
    if (valid.length > 0) {
      alert(`校验未通过字段:${valid.toString()}`)
    } else {
      alert(JSON.stringify(formData, null, 2))
    }
  }

  return (
    <div style={{ padding: 60 }}>
      <FormRender
        {...SCHEMA}
        formData={formData}
        onChange={setData}
        onValidate={setValid}
        widgets={{
          editor: RichTextEditor
        }}
      />
      <button onClick={onSubmit}>提交</button>
    </div>
  )
}

schema.json file:

{
  "propsSchema": {
    "type": "object",
    "properties": {
      "inputName": {
        "title": "简单输入框",
        "type": "string"
      },
      "inputName2": {
        "title": "简单输入框",
        "type": "string",
        "ui:widget": "editor"
      }
    },
    "required": []
  },
  "formData": {}
}

License

MIT ©

FAQs

Package last updated on 29 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts