'use strict';

var blacklist = require('blacklist');
var React = require('react');
var Element = require('./element');

module.exports = React.createClass({
  displayName: 'ModelForm',

  getDefaultProps: function getDefaultProps() {
    return {
      model: {
        attrs: [],
        values: {}
      }
    };
  },
  renderAttr: function renderAttr(attr, i) {
    var model = this.props.model;
    var values = model.values || {};

    return React.createElement(Element, {
      key: i,
      attr: attr,
      value: values[attr.name],
      onChange: this.props.onChange
    });
  },
  render: function render() {
    var model = this.props.model;
    var attrs = model.attrs;
    var props = blacklist(this.props, 'onChange', 'children');

    return React.createElement(
      'form',
      props,
      attrs.map(this.renderAttr),
      this.props.children
    );
  }
});
@@ -80,61 +80,505 @@
 ');%0A
-var Element = require('./element');%0A%0Amodule.exports =
+%0Amodule.exports = function (elements) %7B%0A%0A  var Element = function Element(props) %7B%0A    var attr = props.attr;%0A    var value = props.value;%0A    var onChange = props.onChange;%0A%0A    var type = attr.type;%0A    var name = attr.name;%0A    var label = attr.label;%0A    var handleChange = function handleChange(value) %7B%0A      onChange(name, value);%0A    %7D;%0A%0A    if (!elements%5Btype%5D) throw new Error('type ' + type + ' element not defined');%0A    return elements%5Btype%5D(attr, value, handleChange);%0A  %7D;%0A%0A  return
  Rea
@@ -594,16 +594,18 @@
 Class(%7B%0A
+  
   displa
@@ -625,16 +625,18 @@
 Form',%0A%0A
+  
   getDef
@@ -675,24 +675,26 @@
 ops() %7B%0A    
+  
 return %7B%0A   
@@ -690,16 +690,18 @@
 eturn %7B%0A
+  
       mo
@@ -711,24 +711,26 @@
 : %7B%0A        
+  
 attrs: %5B%5D,%0A 
@@ -728,16 +728,18 @@
 rs: %5B%5D,%0A
+  
         
@@ -759,22 +759,30 @@
     
-%7D%0A
+  %7D%0A  
     %7D;%0A
+  
   %7D,%0A
+  
   re
@@ -818,32 +818,34 @@
 (attr, i) %7B%0A    
+  
 var model = this
@@ -850,32 +850,34 @@
 is.props.model;%0A
+  
     var values =
@@ -898,24 +898,26 @@
 %7C%7C %7B%7D;%0A%0A    
+  
 return React
@@ -952,16 +952,18 @@
     
+  
 key: i,%0A
     
@@ -958,16 +958,18 @@
 key: i,%0A
+  
       at
@@ -978,16 +978,18 @@
 : attr,%0A
+  
       va
@@ -1014,24 +1014,26 @@
 ame%5D,%0A      
+  
 onChange: th
@@ -1058,17 +1058,23 @@
     
+  
 %7D);%0A  
+ 
+ 
 %7D,%0A
+  
   re
@@ -1099,24 +1099,26 @@
 der() %7B%0A    
+ 
+ 
 var model = 
@@ -1135,24 +1135,26 @@
 .model;%0A    
+  
 var attrs = 
@@ -1166,24 +1166,26 @@
 .attrs;%0A    
+ 
+ 
 var props = 
@@ -1232,24 +1232,26 @@
 ren');%0A%0A    
+  
 return React
@@ -1272,16 +1272,18 @@
 (%0A      
+ 
+ 
 'form',%0A
@@ -1288,16 +1288,18 @@
 ,%0A      
+  
 props,%0A 
@@ -1299,24 +1299,26 @@
 rops,%0A      
+ 
+ 
 attrs.map(th
@@ -1339,16 +1339,18 @@
 ,%0A      
+  
 this.pro
@@ -1369,14 +1369,23 @@
     
+ 
+ 
 );%0A  
+ 
+ 
 %7D%0A
+  
 %7D);
+%0A%7D;

update builds