Browse Source

BOOM MODULARITY

sxoinas12 5 years ago
parent
commit
2f43c27d14
5 changed files with 22 additions and 8 deletions
  1. 1 1
      App.js
  2. 0 0
      dist/lib/Types.js
  3. 0 0
      dist/modules/Form.js
  4. 14 1
      lib/Types.js
  5. 7 6
      modules/Form.js

+ 1 - 1
App.js

@@ -180,7 +180,7 @@ export default function App() {
         {React.createElement(ImageComp)}
       </Div>
       <Div style={{width: 200, height:400}}>
-      {React.createElement(FormComp)}
+      {CS.ModuleSystem.createElementCtor(FormComp)}
       </Div>
       <Text>Open up App.js to start working on your app!</Text>
       

File diff suppressed because it is too large
+ 0 - 0
dist/lib/Types.js


File diff suppressed because it is too large
+ 0 - 0
dist/modules/Form.js


+ 14 - 1
lib/Types.js

@@ -115,6 +115,18 @@ class JSObject extends Type {
 }
 
 
+class JSArray extends Type{
+	constructor(){
+		super(Types.Array)
+	}
+	resolve(value){
+		if(Array.isArray(value))
+			return true;
+		else if ((value === undefined || value === null) && !this.isRequired)
+			return true;
+		return false;
+	}
+}
 
 export default {
 	Bool,
@@ -123,7 +135,8 @@ export default {
 	Integer,
 	Text,
 	Types,
-	Type
+	Type,
+	Array: JSArray
 }
 
 

+ 7 - 6
modules/Form.js

@@ -38,9 +38,10 @@ export default class FormComp extends Module {
 		//Init
 		
 		if(!inputsMargin) inputsMargin = 7
+		console.log("@@@@@")
+		console.log(this.props)
 
-
-		let Inputs = Object.keys(inputs).map((key,indx) => {
+		let Inputs = (inputs || []).map((item,indx) => {
 			let state = {}
 			return (<TextInput key={indx}
 				        style={[{height: 20, borderColor: 'gray', borderWidth: 1 , marginBottom:inputsMargin},StaticRules.text]}
@@ -48,9 +49,9 @@ export default class FormComp extends Module {
 				        state[indx] = text;
 				        	this.setState(state)}}
 				        value={this.state.key}
-				        placeholder={inputs[key].placeholder}
-				        textContentType={inputs[key].textContentType}
-				        secureTextEntry={ inputs[key].textContentType === "password" ? true :false}
+				        placeholder={item.placeholder}
+				        textContentType={item.textContentType}
+				        secureTextEntry={ item.textContentType === "password" ? true :false}
 				      />)
 		})
 		
@@ -94,7 +95,7 @@ FormComp.Inputs = {
 		placeholder:"password"
 		},
 	],*/
-	inputs:new Types.Object().require().default(Inp),
+	inputs:new Types.Array().require().default(Inp),
 	ButtonText:new Types.Text().require().default('Submit'),
 	ButtonColor: new Types.Text().require().color().default('rgba(3, 218, 198, 1)'),
 	backgroundColor: new Types.Text().require().color().default('rgba(0, 140, 186, 1)'),

Some files were not shown because too many files changed in this diff