@@ -9,7 +9,7 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
99
1010var _react = require ( 'react' ) ;
1111
12- var _storybook = require ( '@kadira/storybook' ) ;
12+ var _storybookAddonActions = require ( '@kadira/storybook-addon-actions ' ) ;
1313
1414var _storybookAddonKnobs = require ( '@kadira/storybook-addon-knobs' ) ;
1515
@@ -44,7 +44,7 @@ var propTypeKnobResolver = exports.propTypeKnobResolver = function propTypeKnobR
4444/* eslint-disable no-multi-spaces */
4545// Default simple PropType based knob map.
4646var propTypeKnobsMap = [ { name : 'string' , knob : _storybookAddonKnobs . text } , { name : 'number' , knob : _storybookAddonKnobs . number } , { name : 'bool' , knob : _storybookAddonKnobs . boolean } , { name : 'func' , knob : function knob ( name , value ) {
47- return value || ( 0 , _storybook . action ) ( name ) ;
47+ return value || ( 0 , _storybookAddonActions . action ) ( name ) ;
4848 } } , { name : 'object' , knob : _storybookAddonKnobs . object } , { name : 'node' , knob : _storybookAddonKnobs . text } , { name : 'element' , knob : _storybookAddonKnobs . text } ] ;
4949
5050propTypeKnobsMap . forEach ( function ( _ref2 , weight ) {
@@ -90,19 +90,17 @@ var withSmartKnobs = exports.withSmartKnobs = function withSmartKnobs(story, con
9090
9191 var defaultProps = _extends ( { } , component . type . defaultProps || { } , component . props ) ;
9292
93- var finalProps = Object . keys ( props ) . reduce ( function ( acc , n ) {
93+ var finalProps = props ? Object . keys ( props ) . reduce ( function ( acc , n ) {
9494 var item = props [ n ] ;
9595 if ( ! item . type ) {
9696 console . warn ( 'There is a prop with defaultValue ' + item . defaultValue . value + ' but it wasnt specified on element.propTypes. Check story: "' + context . kind + '".' ) ;
9797 return acc ;
9898 }
9999
100100 return _extends ( { } , acc , _defineProperty ( { } , n , item ) ) ;
101- } , { } ) ;
101+ } , { } ) : { } ;
102102
103- return ( 0 , _storybookAddonKnobs . withKnobs ) ( function ( ) {
104- return ( 0 , _react . cloneElement ) ( component , resolvePropValues ( finalProps , defaultProps ) ) ;
105- } , context ) ;
103+ return ( 0 , _react . cloneElement ) ( component , resolvePropValues ( finalProps , defaultProps ) ) ;
106104} ;
107105
108106var resolvePropValues = function resolvePropValues ( propTypes , defaultProps ) {
@@ -118,6 +116,6 @@ var resolvePropValues = function resolvePropValues(propTypes, defaultProps) {
118116 return value !== undefined ? value : resolver ( propName , propTypes [ propName ] , defaultProps [ propName ] , propTypes , defaultProps ) ;
119117 } , undefined ) ;
120118 } ) . reduce ( function ( props , value , i ) {
121- return _extends ( { } , props , _defineProperty ( { } , propNames [ i ] , value ) ) ;
119+ return _extends ( { } , props , _defineProperty ( { } , propNames [ i ] , value !== undefined ? value : defaultProps [ propNames [ i ] ] ) ) ;
122120 } , defaultProps ) ;
123121} ;
0 commit comments