11'use strict' ;
22
3- var _createClass = function ( ) { function defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ( ) ;
4-
53Object . defineProperty ( exports , "__esModule" , {
64 value : true
75} ) ;
86
7+ var _createClass = function ( ) { function defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ( ) ;
8+
99var _react = require ( 'react' ) ;
1010
1111var _ReactDOMFactories = require ( 'react/lib/ReactDOMFactories' ) ;
1212
1313var _ReactDOMFactories2 = _interopRequireDefault ( _ReactDOMFactories ) ;
1414
15- var _lodash = require ( 'lodash' ) ;
16-
1715function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
1816
17+ function _objectWithoutProperties ( obj , keys ) { var target = { } ; for ( var i in obj ) { if ( keys . indexOf ( i ) >= 0 ) continue ; if ( ! Object . prototype . hasOwnProperty . call ( obj , i ) ) continue ; target [ i ] = obj [ i ] ; } return target ; }
18+
1919function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
2020
2121var _componentMap = null ;
@@ -30,7 +30,7 @@ var ReactJsonSchema = function () {
3030 value : function parseSchema ( schema ) {
3131 var element = null ;
3232 var elements = null ;
33- if ( ( 0 , _lodash . isArray ) ( schema ) ) {
33+ if ( Array . isArray ( schema ) ) {
3434 elements = this . parseSubSchemas ( schema ) ;
3535 } else {
3636 element = this . createComponent ( schema ) ;
@@ -39,35 +39,63 @@ var ReactJsonSchema = function () {
3939 }
4040 } , {
4141 key : 'parseSubSchemas' ,
42- value : function parseSubSchemas ( subSchemas ) {
43- var _this = this ;
42+ value : function parseSubSchemas ( ) {
43+ var subSchemas = arguments . length <= 0 || arguments [ 0 ] === undefined ? [ ] : arguments [ 0 ] ;
4444
4545 var Components = [ ] ;
46- ( 0 , _lodash . forEach ) ( subSchemas , function ( subSchema , index ) {
47- subSchema . key = index ;
48- Components . push ( _this . parseSchema ( subSchema ) ) ;
49- } ) ;
46+ var index = 0 ;
47+ var _iteratorNormalCompletion = true ;
48+ var _didIteratorError = false ;
49+ var _iteratorError = undefined ;
50+
51+ try {
52+ for ( var _iterator = subSchemas [ Symbol . iterator ] ( ) , _step ; ! ( _iteratorNormalCompletion = ( _step = _iterator . next ( ) ) . done ) ; _iteratorNormalCompletion = true ) {
53+ var subSchema = _step . value ;
54+
55+ subSchema . key = index ;
56+ Components . push ( this . parseSchema ( subSchema ) ) ;
57+ index ++ ;
58+ }
59+ } catch ( err ) {
60+ _didIteratorError = true ;
61+ _iteratorError = err ;
62+ } finally {
63+ try {
64+ if ( ! _iteratorNormalCompletion && _iterator . return ) {
65+ _iterator . return ( ) ;
66+ }
67+ } finally {
68+ if ( _didIteratorError ) {
69+ throw _iteratorError ;
70+ }
71+ }
72+ }
73+
5074 return Components ;
5175 }
5276 } , {
5377 key : 'createComponent' ,
5478 value : function createComponent ( schema ) {
55- var props = ( 0 , _lodash . clone ) ( schema ) ;
56- props = ( 0 , _lodash . omit ) ( props , [ 'component' , 'children' ] ) ;
79+ var component = schema . component ;
80+ var children = schema . children ;
81+ var text = schema . text ;
82+
83+ var rest = _objectWithoutProperties ( schema , [ 'component' , 'children' , 'text' ] ) ;
84+
5785 var Component = this . resolveComponent ( schema ) ;
58- var Children = props . text || this . resolveComponentChildren ( schema ) ;
59- return ( 0 , _react . createElement ) ( Component , props , Children ) ;
86+ var Children = typeof text !== 'undefined' ? text : this . resolveComponentChildren ( schema ) ;
87+ return ( 0 , _react . createElement ) ( Component , rest , Children ) ;
6088 }
6189 } , {
6290 key : 'resolveComponent' ,
6391 value : function resolveComponent ( schema ) {
6492 var Component = null ;
65- if ( ( 0 , _lodash . has ) ( schema , 'component' ) ) {
66- if ( ( 0 , _lodash . isObject ) ( schema . component ) ) {
93+ if ( schema . hasOwnProperty ( 'component' ) ) {
94+ if ( schema . component === Object ( schema . component ) ) {
6795 Component = schema . component ;
6896 } else if ( _componentMap && _componentMap [ schema . component ] ) {
6997 Component = _componentMap [ schema . component ] ;
70- } else if ( ( 0 , _lodash . has ) ( _ReactDOMFactories2 . default , schema . component ) ) {
98+ } else if ( _ReactDOMFactories2 . default . hasOwnProperty ( schema . component ) ) {
7199 Component = schema . component ;
72100 }
73101 } else {
@@ -78,7 +106,7 @@ var ReactJsonSchema = function () {
78106 } , {
79107 key : 'resolveComponentChildren' ,
80108 value : function resolveComponentChildren ( schema ) {
81- return ( 0 , _lodash . has ) ( schema , 'children' ) ? this . parseSchema ( schema . children ) : [ ] ;
109+ return schema . hasOwnProperty ( 'children' ) ? this . parseSchema ( schema . children ) : [ ] ;
82110 }
83111 } , {
84112 key : 'getComponentMap' ,
0 commit comments