mgr-form-react
Advanced tools
Comparing version
29
index.js
@@ -28,2 +28,3 @@ 'use strict'; | ||
case 'input': | ||
case 'textarea': | ||
{ | ||
@@ -36,2 +37,3 @@ state[control.id] = { | ||
} | ||
case 'select': | ||
@@ -45,5 +47,6 @@ { | ||
} | ||
default: | ||
{ | ||
console.warning('Control ' + control.element + ' is unknown.'); | ||
console.warn('Control ' + control.element + ' is unknown.'); | ||
} | ||
@@ -187,3 +190,3 @@ } | ||
_react2.default.createElement('input', { | ||
type: control.type || text, | ||
type: control.type || 'text', | ||
placeholder: control.placeholder, | ||
@@ -202,2 +205,22 @@ id: control.id, | ||
} | ||
case 'textarea': | ||
{ | ||
return _react2.default.createElement( | ||
'div', | ||
{ className: controlClassName, key: control.id }, | ||
_react2.default.createElement( | ||
'label', | ||
{ htmlFor: control.id }, | ||
control.label | ||
), | ||
_react2.default.createElement('textarea', { | ||
type: control.type || 'text', | ||
placeholder: control.placeholder, | ||
id: control.id, | ||
disabled: !editable, | ||
onInput: _this5.handleInput(control.id), | ||
value: _this5.state[control.id].value | ||
}) | ||
); | ||
} | ||
case 'select': | ||
@@ -233,3 +256,3 @@ { | ||
{ | ||
console.warning('Control ' + control.element + ' is unknown.'); | ||
console.warn('Control ' + control.element + ' is unknown.'); | ||
return _react2.default.createElement('div', null); | ||
@@ -236,0 +259,0 @@ } |
{ | ||
"name": "mgr-form-react", | ||
"version": "0.0.2", | ||
"version": "0.0.4", | ||
"description": "Simple react form component. Generates a form based on json description", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -12,3 +12,3 @@ # mgr-form-react | ||
## Minimal configurations example: | ||
``` | ||
```js | ||
import Form from 'mgr-form-react'; | ||
@@ -48,3 +48,3 @@ | ||
## Full configurations example: | ||
``` | ||
```js | ||
import Form from 'mgr-form-react'; | ||
@@ -148,3 +148,3 @@ | ||
Example: | ||
``` | ||
```js | ||
{ | ||
@@ -167,2 +167,2 @@ 'Signup.Client.Form.Control.Name': 'Name field error that is generated by someone outside of the form (e.g. server response error)', | ||
* `.mgrform-submit-btn`: submit button class. Can be suffixed by the user defined class. | ||
* `.mgrform-error`: general error div class. | ||
* `.mgrform-error`: general error div class. |
@@ -9,3 +9,4 @@ import React, { PropTypes } from 'react'; | ||
switch (control.element) { | ||
case 'input': { | ||
case 'input': | ||
case 'textarea': { | ||
state[control.id] = { | ||
@@ -17,2 +18,3 @@ value: control.default || '', | ||
} | ||
case 'select': { | ||
@@ -25,4 +27,5 @@ state[control.id] = { | ||
} | ||
default: { | ||
console.warning(`Control ${control.element} is unknown.`); | ||
console.warn(`Control ${control.element} is unknown.`); | ||
} | ||
@@ -131,3 +134,3 @@ } | ||
<input | ||
type={control.type || text} | ||
type={control.type || 'text'} | ||
placeholder={control.placeholder} | ||
@@ -144,2 +147,15 @@ id={control.id} | ||
} | ||
case 'textarea': { | ||
return (<div className={controlClassName} key={control.id}> | ||
<label htmlFor={control.id}>{control.label}</label> | ||
<textarea | ||
type={control.type || 'text'} | ||
placeholder={control.placeholder} | ||
id={control.id} | ||
disabled={!editable} | ||
onInput={this.handleInput(control.id)} | ||
value={this.state[control.id].value} | ||
/> | ||
</div>); | ||
} | ||
case 'select': { | ||
@@ -159,3 +175,3 @@ return (<div className={controlClassName} key={control.id}> | ||
default: { | ||
console.warning(`Control ${control.element} is unknown.`); | ||
console.warn(`Control ${control.element} is unknown.`); | ||
return <div />; | ||
@@ -162,0 +178,0 @@ } |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
23298
6.16%418
9.14%165
0.61%0
-100%