flux_on_rails 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +45 -0
  6. data/Rakefile +1 -0
  7. data/flux_on_rails-1.0.0.gem +0 -0
  8. data/flux_on_rails.gemspec +23 -0
  9. data/lib/flux_on_rails.rb +5 -0
  10. data/lib/flux_on_rails/version.rb +3 -0
  11. data/lib/generators/flux_on_rails/install_generator.rb +51 -0
  12. data/lib/generators/flux_on_rails/templates/actions/example-actions.js +22 -0
  13. data/lib/generators/flux_on_rails/templates/application.js +3 -0
  14. data/lib/generators/flux_on_rails/templates/components/.gitkeep +0 -0
  15. data/lib/generators/flux_on_rails/templates/constants/app-constants.js +5 -0
  16. data/lib/generators/flux_on_rails/templates/dispatcher.js +280 -0
  17. data/lib/generators/flux_on_rails/templates/dispatchers/app-dispatcher.js +29 -0
  18. data/lib/generators/flux_on_rails/templates/form-for.js +1 -0
  19. data/lib/generators/flux_on_rails/templates/react-form-for-object/.bower.json +15 -0
  20. data/lib/generators/flux_on_rails/templates/react-form-for-object/.bowerrc +3 -0
  21. data/lib/generators/flux_on_rails/templates/react-form-for-object/.gitignore +2 -0
  22. data/lib/generators/flux_on_rails/templates/react-form-for-object/README.md +94 -0
  23. data/lib/generators/flux_on_rails/templates/react-form-for-object/components/checkbox-input.react.js +11 -0
  24. data/lib/generators/flux_on_rails/templates/react-form-for-object/components/color-input.react.js +11 -0
  25. data/lib/generators/flux_on_rails/templates/react-form-for-object/components/date-input.react.js +11 -0
  26. data/lib/generators/flux_on_rails/templates/react-form-for-object/components/datetime-input.react.js +11 -0
  27. data/lib/generators/flux_on_rails/templates/react-form-for-object/components/email-input.react.js +11 -0
  28. data/lib/generators/flux_on_rails/templates/react-form-for-object/components/form-errors.react.js +13 -0
  29. data/lib/generators/flux_on_rails/templates/react-form-for-object/components/form-for.react.js +78 -0
  30. data/lib/generators/flux_on_rails/templates/react-form-for-object/components/hidden-input.react.js +10 -0
  31. data/lib/generators/flux_on_rails/templates/react-form-for-object/components/input.react.js +92 -0
  32. data/lib/generators/flux_on_rails/templates/react-form-for-object/components/number-input.react.js +11 -0
  33. data/lib/generators/flux_on_rails/templates/react-form-for-object/components/options-for-select.react.js +10 -0
  34. data/lib/generators/flux_on_rails/templates/react-form-for-object/components/password-input.react.js +11 -0
  35. data/lib/generators/flux_on_rails/templates/react-form-for-object/components/radio-input.react.js +10 -0
  36. data/lib/generators/flux_on_rails/templates/react-form-for-object/components/select-input.react.js +17 -0
  37. data/lib/generators/flux_on_rails/templates/react-form-for-object/components/submit-input.react.js +11 -0
  38. data/lib/generators/flux_on_rails/templates/react-form-for-object/components/text-input.react.js +11 -0
  39. data/lib/generators/flux_on_rails/templates/react-form-for-object/components/textarea-input.react.js +10 -0
  40. data/lib/generators/flux_on_rails/templates/react-form-for-object/components/time-input.react.js +11 -0
  41. data/lib/generators/flux_on_rails/templates/react-form-for-object/example/bower.json +11 -0
  42. data/lib/generators/flux_on_rails/templates/react-form-for-object/example/index.html +6 -0
  43. data/lib/generators/flux_on_rails/templates/react-form-for-object/example/js/app.js +76 -0
  44. data/lib/generators/flux_on_rails/templates/react-form-for-object/example/react/app.jsx +76 -0
  45. data/lib/generators/flux_on_rails/templates/react-form-for-object/gulpfile.js +39 -0
  46. data/lib/generators/flux_on_rails/templates/react-form-for-object/package.json +12 -0
  47. data/lib/generators/flux_on_rails/templates/react-form-for-object/src/bower.json +27 -0
  48. data/lib/generators/flux_on_rails/templates/react-form-for-object/src/form-for.js +362 -0
  49. data/lib/generators/flux_on_rails/templates/react.js +18095 -0
  50. data/lib/generators/flux_on_rails/templates/stores/example-store.js +110 -0
  51. data/lib/generators/flux_on_rails/templates/tasks/react_tasks.rake +14 -0
  52. metadata +122 -0
@@ -0,0 +1,11 @@
1
+ var PasswordInput = React.createClass({
2
+ render: function() {
3
+ var data = this.props.data;
4
+ return (
5
+ <input ref={data.name} type="password" defaultValue={data.defaultValue} placeholder={data.placeholder} className={data.className}/>
6
+ );
7
+ }
8
+
9
+ });
10
+
11
+ module.exports = PasswordInput;
@@ -0,0 +1,10 @@
1
+ var RadioInput = React.createClass({
2
+ render: function() {
3
+ var data = this.props.data;
4
+ return (
5
+ <input ref={data.name} type="radio" className={data.className} />
6
+ );
7
+ }
8
+ })
9
+
10
+ module.exports = RadioInput;
@@ -0,0 +1,17 @@
1
+ var OptionForSelect = require('./options-for-select.react')
2
+ var SelectInput = React.createClass({
3
+ render: function() {
4
+ var data = this.props.data;
5
+ var options = [];
6
+ data.values.forEach(function(value) {
7
+ options.push(<OptionForSelect key={value.value} value={value.value} show={value.show}/>)
8
+ }.bind(this))
9
+ return (
10
+ <select ref={data.name} defaultValue={data.value} className={data.className} id={data.id}>
11
+ {options}
12
+ </select>
13
+ );
14
+ }
15
+
16
+ });
17
+ module.exports = SelectInput;
@@ -0,0 +1,11 @@
1
+ var SubmitInput = React.createClass({
2
+ render: function() {
3
+ var data = this.props.data;
4
+ return (
5
+ <input ref={data.value} type="submit" value={data.value} className={data.className} />
6
+ );
7
+ }
8
+
9
+ });
10
+
11
+ module.exports = SubmitInput;
@@ -0,0 +1,11 @@
1
+ var TextInput = React.createClass({
2
+ render: function() {
3
+ var data = this.props.data;
4
+ return (
5
+ <input ref={data.name} type="text" defaultValue={data.defaultValue} placeholder={data.placeholder} className={data.className} />
6
+ );
7
+ }
8
+
9
+ });
10
+
11
+ module.exports = TextInput;
@@ -0,0 +1,10 @@
1
+ var TextareaInput = React.createClass({
2
+ render: function() {
3
+ var data = this.props.data;
4
+ return (
5
+ <textarea ref={data.name} defaultValue={data.defaultValue} placeholder={data.placeholder} className={data.className} />
6
+ );
7
+ }
8
+
9
+ });
10
+ module.exports = TextareaInput;
@@ -0,0 +1,11 @@
1
+ var TimeInput = React.createClass({
2
+ render: function() {
3
+ var data = this.props.data;
4
+ return (
5
+ <input ref={data.name} type="time" defaultValue={data.defaultValue} placeholder={data.placeholder} className={data.className} />
6
+ );
7
+ }
8
+
9
+ });
10
+
11
+ module.exports = TimeInput;
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "react-form-for example",
3
+ "authors": [
4
+ "Ed Shadi <edshadi@gmail.com>"
5
+ ],
6
+ "description": "React FormFor example useage",
7
+ "devDependencies": {
8
+ "react": "~0.12.2",
9
+ "react-form-for": "../src"
10
+ }
11
+ }
@@ -0,0 +1,6 @@
1
+ <html>
2
+ <body></body>
3
+ <script type="text/javascript" src="./bower_components/react/react.js"></script>
4
+ <script type="text/javascript" src="../src/form-for.js"></script>
5
+ <script type="text/javascript" src="./js/app.js"></script>
6
+ </html>
@@ -0,0 +1,76 @@
1
+ var TodoStore = {
2
+ all: function() {
3
+ return [{
4
+ id: 1, // this will be hidden field by default.
5
+ name: "Clean my room",
6
+ description: "My room needs some serious cleaning",
7
+ priority: 3,
8
+ createAt: "2014-10-09",
9
+ completed: false,
10
+ password: "sweet todo",
11
+ list: "Home",
12
+ email: "myemail@gmail.com",
13
+ color: "#fc5803",
14
+ due: new Date()
15
+ }]
16
+ },
17
+ new: function() {
18
+ return {
19
+ name: null,
20
+ description: null,
21
+ priority: null,
22
+ createAt: null,
23
+ completed: null,
24
+ password: null,
25
+ list: null,
26
+ email: null,
27
+ color: null,
28
+ due: new Date()
29
+ }
30
+ },
31
+ find: function(index) {
32
+ return this.all()[index];
33
+ }
34
+ }
35
+ var App = React.createClass({displayName: "App",
36
+ getInitialState: function() {
37
+ return {
38
+ errors: [],
39
+ alert: undefined
40
+ };
41
+ },
42
+
43
+ render: function() {
44
+ var formOptions = {
45
+ onSubmit: this.handleSubmit,
46
+ onCancel: this.handleCancel,
47
+ description: { type: 'textarea' },
48
+ createAt: { type: 'date' },
49
+ list: { type: 'select', values: [{value:"Home", show: "Home"}, {value:"Work", show: "Work"}] },
50
+ color: { type: 'color' },
51
+ due: { type: 'datetime' }
52
+ }
53
+ return(
54
+ React.createElement("div", null,
55
+ React.createElement("span", null, this.state.alert),
56
+ React.createElement(FormFor, {object: TodoStore.find(0), options: formOptions, errors: this.state.errors}),
57
+ React.createElement(FormFor, {object: TodoStore.new(), options: formOptions, errors: this.state.errors})
58
+ )
59
+ )
60
+ },
61
+
62
+ handleSubmit: function(data) {
63
+ // this is where you call an action, e.g. TodoActions.createTodo. For this example
64
+ // I will just simulate errors and success here.
65
+ if(data.name === "") return this.setState({errors: ["name can't be blank"]});
66
+ return this.setState({alert: "Success!", errors: []});
67
+ },
68
+ handleCancel: function() {
69
+ console.log('cancelling');
70
+ }
71
+ });
72
+
73
+ React.render(
74
+ React.createElement(App, null),
75
+ document.body
76
+ );
@@ -0,0 +1,76 @@
1
+ var TodoStore = {
2
+ all: function() {
3
+ return [{
4
+ id: 1, // this will be hidden field by default.
5
+ name: "Clean my room",
6
+ description: "My room needs some serious cleaning",
7
+ priority: 3,
8
+ createAt: "2014-10-09",
9
+ completed: false,
10
+ password: "sweet todo",
11
+ list: "Home",
12
+ email: "myemail@gmail.com",
13
+ color: "#fc5803",
14
+ due: new Date()
15
+ }]
16
+ },
17
+ new: function() {
18
+ return {
19
+ name: null,
20
+ description: null,
21
+ priority: null,
22
+ createAt: null,
23
+ completed: null,
24
+ password: null,
25
+ list: null,
26
+ email: null,
27
+ color: null,
28
+ due: new Date()
29
+ }
30
+ },
31
+ find: function(index) {
32
+ return this.all()[index];
33
+ }
34
+ }
35
+ var App = React.createClass({
36
+ getInitialState: function() {
37
+ return {
38
+ errors: [],
39
+ alert: undefined
40
+ };
41
+ },
42
+
43
+ render: function() {
44
+ var formOptions = {
45
+ onSubmit: this.handleSubmit,
46
+ onCancel: this.handleCancel,
47
+ description: { type: 'textarea' },
48
+ createAt: { type: 'date' },
49
+ list: { type: 'select', values: [{value:"Home", show: "Home"}, {value:"Work", show: "Work"}] },
50
+ color: { type: 'color' },
51
+ due: { type: 'datetime' }
52
+ }
53
+ return(
54
+ <div>
55
+ <span>{this.state.alert}</span>
56
+ <FormFor object={TodoStore.find(0)} options={formOptions} errors={this.state.errors} />
57
+ <FormFor object={TodoStore.new()} options={formOptions} errors={this.state.errors} />
58
+ </div>
59
+ )
60
+ },
61
+
62
+ handleSubmit: function(data) {
63
+ // this is where you call an action, e.g. TodoActions.createTodo. For this example
64
+ // I will just simulate errors and success here.
65
+ if(data.name === "") return this.setState({errors: ["name can't be blank"]});
66
+ return this.setState({alert: "Success!", errors: []});
67
+ },
68
+ handleCancel: function() {
69
+ console.log('cancelling');
70
+ }
71
+ });
72
+
73
+ React.render(
74
+ <App />,
75
+ document.body
76
+ );
@@ -0,0 +1,39 @@
1
+ /* gulpfile.js */
2
+
3
+ // Load some modules which are installed through NPM.
4
+ var gulp = require('gulp');
5
+ var browserify = require('browserify'); // Bundles JS.
6
+ var del = require('del'); // Deletes files.
7
+ var reactify = require('reactify'); // Transforms React JSX to JS.
8
+ var source = require('vinyl-source-stream');
9
+
10
+ // Define some paths.
11
+ var paths = {
12
+ app_js: ['./components/form-for.react.js'],
13
+ js: ['./components/*.js'],
14
+ };
15
+
16
+ // An example of a dependency task, it will be run before the css/js tasks.
17
+ // Dependency tasks should call the callback to tell the parent task that
18
+ // they're done.
19
+ gulp.task('clean', function(done) {
20
+ del(['build'], done);
21
+ });
22
+
23
+ // Our JS task. It will Browserify our code and compile React JSX files.
24
+ gulp.task('js', ['clean'], function() {
25
+ // Browserify/bundle the JS.
26
+ browserify(paths.app_js)
27
+ .transform(reactify)
28
+ .bundle()
29
+ .pipe(source('form-for.js'))
30
+ .pipe(gulp.dest('./src/'));
31
+ });
32
+
33
+ // Rerun tasks whenever a file changes.
34
+ gulp.task('watch', function() {
35
+ gulp.watch(paths.js, ['js']);
36
+ });
37
+
38
+ // The default task (called when we run `gulp` from cli)
39
+ gulp.task('default', ['watch', 'js']);
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "react-form-for",
3
+ "description": "A starter project for AngularJS working with ExpressJS",
4
+ "repository": "https://github.com/edshadi/react-form-for",
5
+ "devDependencies": {
6
+ "browserify": "~6.3.2",
7
+ "reactify": "~0.15.2",
8
+ "vinyl-source-stream": "~1.0.0",
9
+ "del": "~0.1.3",
10
+ "gulp": "~3.8.10"
11
+ }
12
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "react-form-for-object",
3
+ "version": "1.0.0",
4
+ "authors": [
5
+ "Ed Shadi <edshadi@gmail.com>"
6
+ ],
7
+ "description": "Rails inspired form builder that makes building forms in React a breeze.",
8
+ "main": "src/form-for.js",
9
+ "keywords": [
10
+ "react",
11
+ "addon",
12
+ "form",
13
+ "rails",
14
+ "flux"
15
+ ],
16
+ "license": "MIT",
17
+ "private": false,
18
+ "ignore": [
19
+ "**/.*",
20
+ "node_modules",
21
+ "bower_components",
22
+ "app/bower_components",
23
+ "test",
24
+ "tests",
25
+ "node_modules"
26
+ ]
27
+ }
@@ -0,0 +1,362 @@
1
+ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
+ var Input = require('./input.react');
3
+ var FormErrors = require('./form-errors.react');
4
+ module.exports = FormFor = React.createClass({displayName: 'FormFor',
5
+ render: function() {
6
+ if(Object.keys(this.props.object).length === 0) return(React.createElement("div", null));
7
+ return (
8
+ React.createElement("form", {onSubmit: this.handleSubmit, className: "form-for"},
9
+ React.createElement(FormErrors, {errors: this.props.errors}),
10
+ this.inputs(),
11
+ React.createElement("input", {type: "submit", value: this.submitText(), className: "btn btn-default"}),
12
+ this.renderCancelButton()
13
+ )
14
+ );
15
+ },
16
+ inputs: function() {
17
+ var object = this.props.object;
18
+ var inputs = [];
19
+ Object.keys(object).forEach(function(key, i) {
20
+ var value = object[key];
21
+ var dataForInput = {value: value, name: key}
22
+ var options = this.options()[key] || {};
23
+ inputs.push(React.createElement(Input, {key: key, ref: key, data: dataForInput, options: options}));
24
+ }.bind(this));
25
+ return inputs;
26
+ },
27
+ options: function() {
28
+ return this.props.options || {};
29
+ },
30
+ submitText: function() {
31
+ var submit = this.options().submit;
32
+ if(submit && submit.value) return submit.value
33
+ submit = this.props.object.id ? 'Update' : 'Create';
34
+ if(this.options().objectName) submit = submit + ' ' + this.options().objectName;
35
+ return submit;
36
+ },
37
+ handleSubmit: function(e) {
38
+ e.preventDefault();
39
+ var submitHandler = this.options().onSubmit
40
+ if(submitHandler) {
41
+ var data = {};
42
+ Object.keys(this.refs).forEach(function(ref) {
43
+ var value = this.getInputValue(ref);
44
+ data[ref] = value;
45
+ }.bind(this));
46
+ submitHandler(data, {clearInputs: this.clearInputs});
47
+ } else {
48
+ console.log("You must pass an onSubmit function in your options.");
49
+ }
50
+ },
51
+ renderCancelButton: function() {
52
+ if(!this.options().onCancel) return;
53
+ return(React.createElement("input", {type: "button", value: "Cancel", onClick: this.handleCancel}));
54
+ },
55
+ handleCancel: function() {
56
+ this.clearInputs();
57
+ this.options().onCancel();
58
+ },
59
+ getInputValue: function(ref) {
60
+ // find the ref component
61
+ // find the refs of the found component
62
+ // find the input ref from the found component
63
+ // get the getDOMNode and the value
64
+ if(this.refs[ref] && this.refs[ref].refs && this.refs[ref].refs.input && this.refs[ref].refs.input.getDOMNode) {
65
+ var input = this.refs[ref].refs.input.getDOMNode();
66
+ if(input.type === "checkbox") return input.checked;
67
+ return input.value;
68
+ }
69
+ },
70
+ // Utility function to clear inputs.
71
+ clearInputs: function() {
72
+ Object.keys(this.refs).forEach(function(ref) {
73
+ if(this.refs[ref] && this.refs[ref].refs && this.refs[ref].refs.input && this.refs[ref].refs.input.getDOMNode) {
74
+ this.refs[ref].refs.input.getDOMNode().value = "";
75
+ }
76
+ }.bind(this));
77
+ }
78
+
79
+ });
80
+
81
+ },{"./form-errors.react":7,"./input.react":9}],2:[function(require,module,exports){
82
+ var CheckboxInput = React.createClass({displayName: 'CheckboxInput',
83
+ render: function() {
84
+ var data = this.props.data;
85
+ return (
86
+ React.createElement("input", {ref: data.name, type: "checkbox", defaultChecked: data.defaultChecked, className: data.className, value: data.value})
87
+ );
88
+ }
89
+
90
+ });
91
+
92
+ module.exports = CheckboxInput;
93
+
94
+ },{}],3:[function(require,module,exports){
95
+ var ColorInput = React.createClass({displayName: 'ColorInput',
96
+ render: function() {
97
+ var data = this.props.data;
98
+ return (
99
+ React.createElement("input", {ref: data.name, name: data.name, type: "color", defaultValue: data.defaultValue, className: data.className})
100
+ );
101
+ }
102
+
103
+ });
104
+
105
+ module.exports = ColorInput;
106
+
107
+ },{}],4:[function(require,module,exports){
108
+ var DateInput = React.createClass({displayName: 'DateInput',
109
+ render: function() {
110
+ var data = this.props.data;
111
+ return (
112
+ React.createElement("input", {ref: data.name, type: "date", defaultValue: data.defaultValue, placeholder: data.placeholder, className: data.className})
113
+ );
114
+ }
115
+
116
+ });
117
+
118
+ module.exports = DateInput;
119
+
120
+ },{}],5:[function(require,module,exports){
121
+ var DatetimeInput = React.createClass({displayName: 'DatetimeInput',
122
+ render: function() {
123
+ var data = this.props.data;
124
+ return (
125
+ React.createElement("input", {ref: data.name, type: "datetime-local", defaultValue: data.defaultValue, className: data.className})
126
+ );
127
+ }
128
+
129
+ });
130
+
131
+ module.exports = DatetimeInput;
132
+
133
+ },{}],6:[function(require,module,exports){
134
+ var EmailInput = React.createClass({displayName: 'EmailInput',
135
+ render: function() {
136
+ var data = this.props.data;
137
+ return (
138
+ React.createElement("input", {ref: data.name, type: "email", defaultValue: data.defaultValue, placeholder: data.placeholder, className: data.className})
139
+ );
140
+ }
141
+
142
+ });
143
+
144
+ module.exports = EmailInput;
145
+
146
+ },{}],7:[function(require,module,exports){
147
+ var FormErrors = React.createClass({displayName: 'FormErrors',
148
+ render: function() {
149
+ var errors = [];
150
+ this.props.errors.forEach(function(err) {
151
+ errors.push(React.createElement("li", null, err))
152
+ })
153
+ return (
154
+ React.createElement("ul", {className: "form-errors"}, errors)
155
+ );
156
+ }
157
+ });
158
+
159
+ module.exports = FormErrors;
160
+
161
+ },{}],8:[function(require,module,exports){
162
+ var HiddenInput = React.createClass({displayName: 'HiddenInput',
163
+ render: function() {
164
+ var data = this.props.data;
165
+ return (
166
+ React.createElement("input", {ref: data.name, type: "hidden", value: data.value, className: data.className})
167
+ );
168
+ }
169
+
170
+ });
171
+ module.exports = HiddenInput;
172
+
173
+ },{}],9:[function(require,module,exports){
174
+ var TextInput = require('./text-input.react');
175
+ var CheckboxInput = require('./checkbox-input.react');
176
+ var NumberInput = require('./number-input.react');
177
+ var HiddenInput = require('./hidden-input.react');
178
+ var SelectInput = require('./select-input.react');
179
+ var PasswordInput = require('./password-input.react');
180
+ var TextareaInput = require('./textarea-input.react');
181
+ var DateInput = require('./date-input.react');
182
+ var ColorInput = require('./color-input.react');
183
+ var DatetimeInput = require('./datetime-input.react');
184
+ var EmailInput = require('./email-input.react');
185
+ var TimeInput = require('./time-input.react');
186
+ var Input = React.createClass({displayName: 'Input',
187
+ render: function() {
188
+ var data = this.props.data;
189
+ return (
190
+ React.createElement("div", null,
191
+ React.createElement("div", {className: "form-group"},
192
+ this.input()
193
+ )
194
+ )
195
+ );
196
+ },
197
+ input: function() {
198
+ var data = this.props.data;
199
+ switch(this.type()) {
200
+ case 'boolean':
201
+ return(React.createElement("span", null, React.createElement(CheckboxInput, {ref: "input", data: {name: data.name, defaultChecked: data.value, className: this.props.options.className, value: data.value}}), React.createElement("span", null, this.placeholder())))
202
+ break;
203
+ case 'number':
204
+ return(React.createElement(NumberInput, {ref: "input", data: {name: data.name, defaultValue: data.value, placeholder: this.placeholder(), className: this.props.options.className}}))
205
+ break;
206
+ case 'color':
207
+ return(React.createElement(ColorInput, {ref: "input", data: {name: data.name, defaultValue: data.value, className: this.props.options.className}}))
208
+ break;
209
+ case 'email':
210
+ return(React.createElement(EmailInput, {ref: "input", data: {name: data.name, defaultValue: data.value, placeholder: this.placeholder(), className: this.props.options.className}}))
211
+ break;
212
+ case 'date':
213
+ return(React.createElement(DateInput, {ref: "input", data: {name: data.name, defaultValue: data.value, placeholder: this.placeholder(), className: this.props.options.className}}))
214
+ break;
215
+ case 'datetime':
216
+ return(React.createElement(DatetimeInput, {ref: "input", data: {name: data.name, defaultValue: data.value, className: this.props.options.className}}))
217
+ break;
218
+ case 'time':
219
+ return(React.createElement(TimeInput, {ref: "input", data: {name: data.name, defaultValue: data.value, className: this.props.options.className}}))
220
+ break;
221
+ case 'hidden':
222
+ return(React.createElement(HiddenInput, {ref: "input", data: {name: data.name, value: data.value, placeholder: this.placeholder(), className: this.props.options.className}}))
223
+ break;
224
+ case 'select':
225
+ return(React.createElement(SelectInput, {ref: "input", data: {name: data.name, value: data.value, values: this.props.options.values , className: this.props.options.className}}))
226
+ break;
227
+ case 'password':
228
+ return(React.createElement(PasswordInput, {ref: "input", data: {name: data.name, defaultChecked: data.value, placeholder: this.placeholder(), className: this.props.options.className}}))
229
+ break;
230
+ case 'textarea':
231
+ return(React.createElement(TextareaInput, {ref: "input", data: {name: data.name, defaultValue: data.value, placeholder: this.placeholder(), className: this.props.options.className}}))
232
+ break;
233
+ default:
234
+ return(React.createElement(TextInput, {ref: "input", data: {name: data.name, defaultValue: data.value, placeholder: this.placeholder(), className: this.props.options.className}}))
235
+ }
236
+
237
+ },
238
+ type: function() {
239
+ var type = typeof(this.props.data.value);
240
+ if(this.props.options.type) type = this.props.options.type;
241
+ if(this.isId()) type = 'hidden';
242
+ if(this.isPassword()) type = 'password';
243
+ if(this.isEmail()) type = 'email';
244
+ return type;
245
+ },
246
+ isId: function() {
247
+ if(this.props.data.name === 'id') return true;
248
+ return false;
249
+ },
250
+ isPassword: function() {
251
+ if(this.props.data.name === 'password' || this.props.data.name === 'password_confirmation') return true;
252
+ return false;
253
+ },
254
+ isEmail: function() {
255
+ var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
256
+ if(this.props.data.name === 'email' || re.test(this.props.data.value)) return true;
257
+ return false;
258
+ },
259
+ placeholder: function() {
260
+ var name = this.props.options.placeholder || this.props.data.name;
261
+ return name.charAt(0).toUpperCase() + name.slice(1);
262
+ }
263
+ });
264
+
265
+ module.exports = Input;
266
+
267
+ },{"./checkbox-input.react":2,"./color-input.react":3,"./date-input.react":4,"./datetime-input.react":5,"./email-input.react":6,"./hidden-input.react":8,"./number-input.react":10,"./password-input.react":12,"./select-input.react":13,"./text-input.react":14,"./textarea-input.react":15,"./time-input.react":16}],10:[function(require,module,exports){
268
+ var NumberInput = React.createClass({displayName: 'NumberInput',
269
+ render: function() {
270
+ var data = this.props.data;
271
+ return (
272
+ React.createElement("input", {ref: data.name, type: "number", defaultValue: data.defaultValue, placeholder: data.placeholder, className: data.className})
273
+ );
274
+ }
275
+
276
+ });
277
+
278
+ module.exports = NumberInput;
279
+
280
+ },{}],11:[function(require,module,exports){
281
+ var OptionForSelect = React.createClass({displayName: 'OptionForSelect',
282
+
283
+ render: function() {
284
+ return (
285
+ React.createElement("option", {value: this.props.value}, this.props.show)
286
+ );
287
+ }
288
+
289
+ });
290
+ module.exports = OptionForSelect;
291
+
292
+ },{}],12:[function(require,module,exports){
293
+ var PasswordInput = React.createClass({displayName: 'PasswordInput',
294
+ render: function() {
295
+ var data = this.props.data;
296
+ return (
297
+ React.createElement("input", {ref: data.name, type: "password", defaultValue: data.defaultValue, placeholder: data.placeholder, className: data.className})
298
+ );
299
+ }
300
+
301
+ });
302
+
303
+ module.exports = PasswordInput;
304
+
305
+ },{}],13:[function(require,module,exports){
306
+ var OptionForSelect = require('./options-for-select.react')
307
+ var SelectInput = React.createClass({displayName: 'SelectInput',
308
+ render: function() {
309
+ var data = this.props.data;
310
+ var options = [];
311
+ data.values.forEach(function(value) {
312
+ options.push(React.createElement(OptionForSelect, {key: value.value, value: value.value, show: value.show}))
313
+ }.bind(this))
314
+ return (
315
+ React.createElement("select", {ref: data.name, defaultValue: data.value, className: data.className, id: data.id},
316
+ options
317
+ )
318
+ );
319
+ }
320
+
321
+ });
322
+ module.exports = SelectInput;
323
+
324
+ },{"./options-for-select.react":11}],14:[function(require,module,exports){
325
+ var TextInput = React.createClass({displayName: 'TextInput',
326
+ render: function() {
327
+ var data = this.props.data;
328
+ return (
329
+ React.createElement("input", {ref: data.name, type: "text", defaultValue: data.defaultValue, placeholder: data.placeholder, className: data.className})
330
+ );
331
+ }
332
+
333
+ });
334
+
335
+ module.exports = TextInput;
336
+
337
+ },{}],15:[function(require,module,exports){
338
+ var TextareaInput = React.createClass({displayName: 'TextareaInput',
339
+ render: function() {
340
+ var data = this.props.data;
341
+ return (
342
+ React.createElement("textarea", {ref: data.name, defaultValue: data.defaultValue, placeholder: data.placeholder, className: data.className})
343
+ );
344
+ }
345
+
346
+ });
347
+ module.exports = TextareaInput;
348
+
349
+ },{}],16:[function(require,module,exports){
350
+ var TimeInput = React.createClass({displayName: 'TimeInput',
351
+ render: function() {
352
+ var data = this.props.data;
353
+ return (
354
+ React.createElement("input", {ref: data.name, type: "time", defaultValue: data.defaultValue, placeholder: data.placeholder, className: data.className})
355
+ );
356
+ }
357
+
358
+ });
359
+
360
+ module.exports = TimeInput;
361
+
362
+ },{}]},{},[1]);