0.111.0 • Published 7 years ago

react-talend-forms v0.111.0

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
7 years ago

react-talend-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 react-talend-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 'react-talend-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 :

propertypropTyperequireddefaultdoc
iconPositionotherno-
iconstringno-
hideLabelboolno-
disabledboolno{false}
stylestringno"default"equivalent to action bsStyle props
iconTransformstringno-
idstringno-
inProgressboolno{false}
labelstringyes-
linkboolno-
modelobjectno-
namestringno-render a name button html property
onClickfuncyes-execute the callback with formData, formId, propertyName, propertyValue as parameters
tooltipboolno-
tooltipPlacementotherno"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 'react-talend-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 'react-talend-forms'

LICENSE

Copyright (c) 2006-2016 Talend

Licensed under the Apache V2 License

0.111.0

7 years ago

0.110.0

7 years ago

0.109.0

7 years ago

0.108.0

7 years ago

0.107.0

7 years ago

0.106.0

7 years ago

0.105.0

7 years ago

0.104.0

7 years ago

0.103.0

7 years ago

0.102.4

7 years ago

0.102.3

7 years ago

0.102.1

7 years ago

0.102.0

7 years ago

0.101.0

7 years ago

0.100.0

7 years ago

0.99.0

7 years ago

0.98.0

7 years ago

0.97.0

7 years ago

0.96.0

7 years ago

0.95.0

7 years ago

0.94.0

7 years ago

0.93.0

7 years ago

0.92.0

7 years ago

0.91.0

7 years ago

0.90.0

7 years ago

0.89.0

7 years ago

0.88.0

7 years ago

0.87.0

7 years ago

0.86.0

7 years ago

0.85.1

7 years ago

0.85.0

7 years ago

0.84.0

7 years ago

0.83.1

7 years ago

0.83.0

7 years ago

0.82.0

7 years ago

0.81.0

7 years ago

0.80.0

7 years ago

0.79.0

7 years ago

0.78.0

7 years ago

0.77.0

7 years ago

0.76.0

7 years ago

0.75.1

7 years ago

0.75.0

7 years ago

0.74.2

7 years ago

0.74.1

7 years ago

0.74.0

7 years ago

0.73.0

7 years ago

0.72.3

7 years ago

0.72.2

7 years ago

0.72.1

7 years ago

0.72.0

7 years ago

0.71.2

7 years ago

0.71.1

7 years ago

0.71.0

7 years ago

0.70.1

7 years ago

0.70.0

7 years ago

0.69.0

7 years ago

0.68.1

7 years ago

0.68.0

7 years ago

0.67.0

7 years ago

0.66.4

7 years ago

0.66.3

7 years ago

0.66.2

7 years ago

0.66.1

7 years ago

0.66.0

7 years ago

0.65.0

7 years ago

0.64.0

7 years ago

0.63.1

7 years ago

0.63.0

7 years ago

0.62.0

7 years ago

0.61.4

7 years ago

0.61.3

7 years ago

0.61.2

7 years ago

0.61.1

7 years ago

0.61.0

7 years ago

0.60.7

7 years ago

0.60.6

7 years ago

0.60.5

7 years ago

0.60.4

7 years ago

0.60.3

7 years ago

0.14.0

7 years ago

0.13.0

7 years ago

0.12.0

7 years ago

0.11.1

7 years ago

0.11.0

7 years ago

0.10.0

7 years ago

0.9.1

7 years ago

0.9.0

7 years ago

0.8.1

7 years ago

0.8.0

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.0

7 years ago

0.5.0

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.0

8 years ago

0.2.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.1

8 years ago

0.0.0

8 years ago

1.0.0

8 years ago