Skip to content

Commit

Permalink
Update dependencies. Some minor changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Semigradsky committed Apr 19, 2016
1 parent 4931256 commit 112819f
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 159 deletions.
7 changes: 7 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"presets": [
"react",
"es2015",
"stage-2"
]
}
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
.DS_Store
build
node_modules
lib
11 changes: 8 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
build/
bower.json
Gulpfile.js
.babelrc
.editorconfig
.travis.yml
testrunner.js
webpack.production.config.js
examples/
release/
tests/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014 Gloppens EDB Lag
Copyright (c) 2014-2016 Gloppens EDB Lag

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
67 changes: 21 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ A form input builder and validator for React JS
| [How to use](#how-to-use) | [API](/API.md) | [Examples](/examples) |
|---|---|---|

### From version 0.12.0 Formsy only supports React 0.13.1 and up

## <a name="background">Background</a>
I wrote an article on forms and validation with React JS, [Nailing that validation with React JS](http://christianalfoni.github.io/javascript/2014/10/22/nailing-that-validation-with-reactjs.html), the result of that was this extension.

Expand Down Expand Up @@ -48,29 +46,29 @@ Complete API reference is available [here](/API.md).

#### Formsy gives you a form straight out of the box

```javascript
/** @jsx React.DOM */
var Formsy = require('formsy-react');
var MyAppForm = React.createClass({
getInitialState: function () {
```jsx
import Formsy from 'formsy-react';

const MyAppForm = React.createClass({
getInitialState() {
return {
canSubmit: false
}
},
enableButton: function () {
enableButton() {
this.setState({
canSubmit: true
});
},
disableButton: function () {
disableButton() {
this.setState({
canSubmit: false
});
},
submit: function (model) {
submit(model) {
someDep.saveEmail(model.email);
},
render: function () {
render() {
return (
<Formsy.Form onValidSubmit={this.submit} onValid={this.enableButton} onInvalid={this.disableButton}>
<MyOwnInput name="email" validations="isEmail" validationError="This is not a valid email" required/>
Expand All @@ -84,31 +82,31 @@ Complete API reference is available [here](/API.md).
This code results in a form with a submit button that will run the `submit` method when the submit button is clicked with a valid email. The submit button is disabled as long as the input is empty ([required](/API.md#required)) or the value is not an email ([isEmail](/API.md#validators)). On validation error it will show the message: "This is not a valid email".

#### Building a form element (required)
```javascript
/** @jsx React.DOM */
var Formsy = require('formsy-react');
var MyOwnInput = React.createClass({
```jsx
import Formsy from 'formsy-react';

const MyOwnInput = React.createClass({

// Add the Formsy Mixin
mixins: [Formsy.Mixin],

// setValue() will set the value of the component, which in
// turn will validate it and the rest of the form
changeValue: function (event) {
changeValue(event) {
this.setValue(event.currentTarget.value);
},
render: function () {

render() {
// 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
// value typed is invalid
var className = this.showRequired() ? 'required' : this.showError() ? 'error' : null;
const className = this.showRequired() ? 'required' : this.showError() ? 'error' : null;

// An error message is returned ONLY if the component is invalid
// or the server has returned an error message
var errorMessage = this.getErrorMessage();
const errorMessage = this.getErrorMessage();

return (
<div className={className}>
Expand All @@ -130,32 +128,9 @@ The form element component is what gives the form validation functionality to wh
## Contribute
- Fork repo
- `npm install`
- `npm start` runs the development server on `localhost:8080`
- `npm run examples` runs the development server on `localhost:8080`
- `npm test` runs the tests

License
-------

formsy-react is licensed under the [MIT license](LICENSE).

> The MIT License (MIT)
>
> Copyright (c) 2015 Gloppens EDB Lag
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.
## License

[MIT](/LICENSE)
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "formsy-react",
"version": "0.16.0",
"version": "0.18.0",
"description": "A form input builder and validator for React JS",
"repository": {
"type": "git",
Expand All @@ -13,7 +13,7 @@
"Gulpfile.js"
],
"dependencies": {
"react": "^0.13.1"
"react": "^0.14.7 || ^15.0.0"
},
"keywords": [
"react",
Expand Down
9 changes: 0 additions & 9 deletions build/index.html

This file was deleted.

55 changes: 0 additions & 55 deletions build/test.js

This file was deleted.

28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
},
"main": "lib/main.js",
"scripts": {
"start": "webpack-dev-server --content-base build",
"deploy": "NODE_ENV=production webpack -p --config webpack.production.config.js",
"test": "babel-node testrunner",
"examples": "webpack-dev-server --config examples/webpack.config.js --content-base examples",
Expand All @@ -24,24 +23,25 @@
"react-component"
],
"dependencies": {
"form-data-to-object": "^0.1.0"
"form-data-to-object": "^0.2.0"
},
"devDependencies": {
"babel": "^5.6.4",
"babel-core": "^5.1.11",
"babel-loader": "^5.0.0",
"babel-cli": "^6.6.5",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-2": "^6.5.0",
"jsdom": "^6.5.1",
"lolex": "^1.3.2",
"nodeunit": "^0.9.1",
"react": "^0.14.0-rc1",
"react-addons-pure-render-mixin": "^0.14.2",
"react-addons-test-utils": "^0.14.0-rc1",
"react-dom": "^0.14.0-rc1",
"sinon": "^1.17.1",
"webpack": "^1.7.3",
"webpack-dev-server": "^1.7.0"
"react": "^15.0.0",
"react-addons-pure-render-mixin": "^15.0.0",
"react-addons-test-utils": "^15.0.0",
"react-dom": "^15.0.0",
"sinon": "^1.17.3",
"webpack": "^1.12.14",
"webpack-dev-server": "^1.14.1"
},
"peerDependencies": {
"react": "^0.14.0"
"react": "^0.14.0 || ^15.0.0"
}
}
Loading

0 comments on commit 112819f

Please sign in to comment.