Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
2ef73a2ec2
|
|
@ -1,5 +1,6 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- "0.12"
|
||||
- "0.11"
|
||||
- "0.10"
|
||||
- 'iojs'
|
||||
- '0.12'
|
||||
- '0.11'
|
||||
- '0.10'
|
||||
|
|
|
|||
|
|
@ -113,6 +113,11 @@ This code results in a form with a submit button that will run the `submit` meth
|
|||
```
|
||||
The form element component is what gives the form validation functionality to whatever you want to put inside this wrapper. You do not have to use traditional inputs, it can be anything you want and the value of the form element can also be anything you want. As you can see it is very flexible, you just have a small API to help you identify the state of the component and set its value.
|
||||
|
||||
## Related projects
|
||||
- [formsy-react-components](https://github.com/twisty/formsy-react-components) - A set of React JS components for use in a formsy-react form
|
||||
- ...
|
||||
- Send PR for adding your project to this list!
|
||||
|
||||
## Contribute
|
||||
- Fork repo
|
||||
- `npm install`
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
var React = require('react');
|
||||
var Formsy = require('./../..');
|
||||
var Formsy = require('formsy-react');
|
||||
|
||||
var currentYear = new Date().getFullYear();
|
||||
|
||||
|
|
@ -120,4 +120,4 @@ var Validations = React.createClass({
|
|||
}
|
||||
});
|
||||
|
||||
React.render(<App/>, document.getElementById('example'));
|
||||
React.render(<App/>, document.getElementById('example'));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
var React = require('react');
|
||||
var Formsy = require('./../..');
|
||||
var Formsy = require('formsy-react');
|
||||
|
||||
var App = React.createClass({
|
||||
getInitialState: function() {
|
||||
|
|
@ -34,7 +34,7 @@ var MyOwnInput = React.createClass({
|
|||
// Add the Formsy Mixin
|
||||
mixins: [Formsy.Mixin],
|
||||
|
||||
// setValue() will set the value of the component, which in
|
||||
// setValue() will set the value of the component, which in
|
||||
// turn will validate it and the rest of the form
|
||||
changeValue: function (event) {
|
||||
this.setValue(event.currentTarget.value);
|
||||
|
|
@ -42,9 +42,9 @@ var MyOwnInput = React.createClass({
|
|||
render: function () {
|
||||
|
||||
// Set a specific className based on the validation
|
||||
// state of this component. showRequired() is true
|
||||
// when the value is empty and the required prop is
|
||||
// passed to the input. showError() is true when the
|
||||
// state of this component. showRequired() is true
|
||||
// when the value is empty and the required prop is
|
||||
// passed to the input. showError() is true when the
|
||||
// value typed is invalid
|
||||
var className = this.props.className + ' ' + (this.showRequired() ? 'required' : this.showError() ? 'error' : null);
|
||||
|
||||
|
|
@ -62,4 +62,4 @@ var MyOwnInput = React.createClass({
|
|||
}
|
||||
});
|
||||
|
||||
React.render(<App/>, document.getElementById('example'));
|
||||
React.render(<App/>, document.getElementById('example'));
|
||||
|
|
|
|||
|
|
@ -13,8 +13,9 @@ module.exports = {
|
|||
entry: fs.readdirSync(__dirname).reduce(function (entries, dir) {
|
||||
var isDraft = dir.charAt(0) === '_';
|
||||
|
||||
if (!isDraft && isDirectory(path.join(__dirname, dir)))
|
||||
if (!isDraft && isDirectory(path.join(__dirname, dir))) {
|
||||
entries[dir] = path.join(__dirname, dir, 'app.js');
|
||||
}
|
||||
|
||||
return entries;
|
||||
}, {}),
|
||||
|
|
@ -28,13 +29,13 @@ module.exports = {
|
|||
|
||||
module: {
|
||||
loaders: [
|
||||
{ test: /\.js$/, exclude: /node_modules/, loader: 'jsx-loader' }
|
||||
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel' }
|
||||
]
|
||||
},
|
||||
|
||||
resolve: {
|
||||
alias: {
|
||||
'react-router': '../../modules/index'
|
||||
'formsy-react': '../../src/main'
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -45,4 +46,4 @@ module.exports = {
|
|||
})
|
||||
]
|
||||
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,9 +11,21 @@ describe('Utils', function() {
|
|||
var objD = [{
|
||||
foo: ['bar']
|
||||
}];
|
||||
var objE, objF;
|
||||
var objG = null;
|
||||
var objH = null;
|
||||
|
||||
expect(utils.isSame(objA, objB)).toBe(true);
|
||||
expect(utils.isSame(objC, objD)).toBe(true);
|
||||
expect(utils.isSame(objA, objD)).toBe(false);
|
||||
|
||||
expect(utils.isSame(objE, objF)).toBe(true);
|
||||
expect(utils.isSame(objA, objF)).toBe(false);
|
||||
expect(utils.isSame(objE, objA)).toBe(false);
|
||||
|
||||
expect(utils.isSame(objG, objH)).toBe(true);
|
||||
expect(utils.isSame(objA, objH)).toBe(false);
|
||||
expect(utils.isSame(objG, objA)).toBe(false);
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ Formsy.Form = React.createClass({
|
|||
var component = this.inputs[name];
|
||||
|
||||
if (!component) {
|
||||
throw new Error('You are trying to update an input that does not exists. Verify errors object with input names. ' + JSON.stringify(errors));
|
||||
throw new Error('You are trying to update an input that does not exist. Verify errors object with input names. ' + JSON.stringify(errors));
|
||||
}
|
||||
|
||||
var args = [{
|
||||
|
|
|
|||
11
src/utils.js
11
src/utils.js
|
|
@ -12,6 +12,7 @@ module.exports = {
|
|||
}
|
||||
return isDifferent;
|
||||
},
|
||||
|
||||
objectsDiffer: function (a, b) {
|
||||
var isDifferent = false;
|
||||
if (Object.keys(a).length !== Object.keys(b).length) {
|
||||
|
|
@ -23,13 +24,15 @@ module.exports = {
|
|||
}
|
||||
}, this);
|
||||
}
|
||||
return isDifferent;
|
||||
return isDifferent;
|
||||
},
|
||||
isSame: function (a, b) {
|
||||
|
||||
if (Array.isArray(a)) {
|
||||
isSame: function (a, b) {
|
||||
if (typeof a !== typeof b) {
|
||||
return false;
|
||||
} else if (Array.isArray(a)) {
|
||||
return !this.arraysDiffer(a, b);
|
||||
} else if (typeof a === 'object' && a !== null) {
|
||||
} else if (typeof a === 'object' && a !== null && b !== null) {
|
||||
return !this.objectsDiffer(a, b);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue