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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@talend/react-forms

v15.2.0

Published

React forms library based on json schema form.

Downloads

2,400

Readme

@talend/react-forms

Build Status

Introduction

This library is designed to be used on top of react-jsonschema-form, a React component for building Web forms from JSONSchema.

In addition of Mozilla lib, this wrapper uses react-bootstrap to not have to maintain Bootstrap markup.

Installation

Run npm install --save @talend/react-forms.

Usage

The forms can be used like any other React components. You'll have to pass it a JSONSchema and a onSubmit callback as a minimum to handle forms rendering and get the data back.

import Form from '@talend/react-forms';

class MyForm extends React.Component {
	onSubmit(formData) {
		console.log(formData);
	}

	onCancel() {
		console.log('Cancelled');
	}

	render() {
		const actions = [
			{ style: 'link', onClick: this.onCancel, type: 'button', label: 'CANCEL' },
			{ style: 'primary', type: 'submit', label: 'VALIDATE' },
		];
		return <Form data={this.props.data} actions={actions} onSubmit={this.onSubmit} />;
	}
}

Here is the archetype of the data property required to render the form:

{
	"jsonSchema": {},
	"uiSchema": {},
	"properties": {}
}

Actions

Forms now render a react-talend-components Action component for each action given to it. Each action accept the following properties :

| property | propType | required | default | doc | | ---------------- | :----------------: | :------: | :-------: | :-------------------------------------------------------------------------------------------: | | iconPosition | other | no | - | | icon | string | no | - | | hideLabel | bool | no | - | | disabled | bool | no | {false} | | style | string | no | "default" | equivalent to action bsStyle props | | iconTransform | string | no | - | | id | string | no | - | | inProgress | bool | no | {false} | | label | string | yes | - | | link | bool | no | - | | model | object | no | - | | name | string | no | - | render a name button html property | | onClick | func | yes | - | execute the callback with formData, formId, propertyName, propertyValue as parameters | | tooltip | bool | no | - | | tooltipPlacement | other | no | "top" | | type | 'submit'|'button' | no | - | by default render a button without submit type |

Handlers

If uiSchema has some triggers like

{
	"jsonSchema": {
		"id": "ListExample",
		"type": "object",
		"properties": {
			"propertyName": {
				"type": "string",
				"enum": ["option 0", "option 1", "option 2"]
			}
		}
	},
	"uiSchema": {
		"propertyName": {
			"ui:trigger": ["after"]
		}
	},
	"properties": {}
}

Then onChange will be triggered when propertyName field value has changed.

import Form from '@talend/react-forms';

class MyForm extends React.Component {
	onChange(formData, formId, propertyName, propertyValue) {
		console.log(formData, formId, propertyName, propertyValue);
	}

	onSubmit(formData) {
		console.log(formData);
	}

	render() {
		return <Form data={this.props.data} onChange={this.onChange} onSubmit={this.onSubmit} />;
	}
}

PropTypes

The data and actions PropTypes are exported for easy reuse. You can use them by importing the DataPropTypes and ActionsPropTypes functions.

import Form, { DataPropTypes, ActionsPropTypes } from '@talend/react-forms';

Validation

You can use validation from outside (let say button outside the form) this way:

import validate from '@talend/react-forms/lib/validate';

function isValid({ payload }) {
	return validate(payload.jsonSchema, payload.formData);
}

Build with webpack

@talend/react-forms comes with react-ace lazy loaded. Modes are loaded from CDN. No more additional config is required.

LICENSE

Copyright (c) 2006-2016 Talend

Licensed under the Apache V2 License