Comparing version 0.0.26 to 0.0.27
@@ -162,5 +162,2 @@ 'use strict'; | ||
console.log(_formItems); | ||
console.log(headers); | ||
(0, _axios2.default)({ | ||
@@ -367,6 +364,9 @@ url: postUrl, | ||
function Select() { | ||
function Select(props) { | ||
_classCallCheck(this, Select); | ||
return _possibleConstructorReturn(this, (Select.__proto__ || Object.getPrototypeOf(Select)).apply(this, arguments)); | ||
var _this6 = _possibleConstructorReturn(this, (Select.__proto__ || Object.getPrototypeOf(Select)).call(this, props)); | ||
_this6.props.store.setFormItem(_this6.props); | ||
return _this6; | ||
} | ||
@@ -380,8 +380,22 @@ | ||
children = _props4.children, | ||
otherProps = _objectWithoutProperties(_props4, ['store', 'children']); | ||
className = _props4.className, | ||
otherProps = _objectWithoutProperties(_props4, ['store', 'children', 'className']); | ||
var thisItem = store.state.formItems[this.props.name]; | ||
return _react2.default.createElement( | ||
'select', | ||
_extends({}, otherProps, { onChange: store.handleInput }), | ||
children | ||
_react2.default.Fragment, | ||
null, | ||
_react2.default.createElement( | ||
'select', | ||
_extends({}, otherProps, { | ||
onChange: store.handleInput, | ||
className: '' + (className || '') + thisItem.className }), | ||
children | ||
), | ||
_react2.default.createElement( | ||
'div', | ||
{ className: store.state.classNames.invalidFeedback }, | ||
thisItem.invalidFeedback | ||
) | ||
); | ||
@@ -388,0 +402,0 @@ } |
import React from 'react' | ||
import ReactDOM from 'react-dom' | ||
import { Form, Input, Textarea } from './../src/Recassfov' | ||
import { Form, Input, Select, Textarea } from './../src/Recassfov' | ||
@@ -39,2 +39,9 @@ const validations = { | ||
], | ||
yesOrNo: [ | ||
{ | ||
rule: 'isLength', | ||
args: { min: 1 }, | ||
invalidFeedback: 'please select an option' | ||
} | ||
], | ||
message: [ | ||
@@ -103,4 +110,3 @@ { | ||
placeholder='username' | ||
validations={validations.username} | ||
/> | ||
validations={validations.username} /> | ||
</div> | ||
@@ -113,4 +119,3 @@ | ||
placeholder='email' | ||
validations={validations.email} | ||
/> | ||
validations={validations.email} /> | ||
</div> | ||
@@ -123,4 +128,3 @@ | ||
placeholder='password' | ||
validations={validations.password} | ||
/> | ||
validations={validations.password} /> | ||
</div> | ||
@@ -133,12 +137,20 @@ | ||
placeholder='number' | ||
validations={validations.number} | ||
/> | ||
validations={validations.number} /> | ||
</div> | ||
<div> | ||
<Select | ||
name='yesOrNo' | ||
validations={validations.yesOrNo}> | ||
<option value=''>select</option> | ||
<option value='yes'>yes</option> | ||
<option value='no'>no</option> | ||
</Select> | ||
</div> | ||
<div> | ||
<Textarea | ||
name='message' | ||
placeholder='message' | ||
validations={validations.message} | ||
/> | ||
validations={validations.message} /> | ||
</div> | ||
@@ -145,0 +157,0 @@ |
{ | ||
"name": "recassfov", | ||
"version": "0.0.26", | ||
"version": "0.0.27", | ||
"description": "React client and server side form validation", | ||
@@ -5,0 +5,0 @@ "main": "./build/Recassfov.js", |
@@ -127,5 +127,2 @@ import React from 'react' | ||
console.log(_formItems) | ||
console.log(headers) | ||
axios({ | ||
@@ -292,9 +289,22 @@ url: postUrl, | ||
class Select extends React.Component { | ||
constructor (props) { | ||
super(props) | ||
this.props.store.setFormItem(this.props) | ||
} | ||
render () { | ||
const { store, children, ...otherProps } = this.props | ||
const { store, children, className, ...otherProps } = this.props | ||
const thisItem = store.state.formItems[this.props.name] | ||
return ( | ||
<select {...otherProps} onChange={store.handleInput}> | ||
{children} | ||
</select> | ||
<React.Fragment> | ||
<select | ||
{...otherProps} | ||
onChange={store.handleInput} | ||
className={`${className || ''}${thisItem.className}`}> | ||
{children} | ||
</select> | ||
<div className={store.state.classNames.invalidFeedback}>{thisItem.invalidFeedback}</div> | ||
</React.Fragment> | ||
) | ||
@@ -301,0 +311,0 @@ } |
173704
828