11import React from 'react' ;
22import Typography from '@material-ui/core/Typography' ;
33
4+ import PropTypes from 'prop-types' ;
5+
46export const docsLinks = {
57 mui : 'https://material-ui.com/api/' ,
68 pf4 : 'http://patternfly-react.surge.sh/patternfly-4/components/' ,
7- pf3 : 'http://patternfly-react.surge.sh/patternfly-3/index.html' ,
9+ pf3 : 'http://patternfly-react.surge.sh/patternfly-3/index.html'
810} ;
911
10- export default ( { activeMapper, component } ) => {
12+ const GenericMuiComponent = ( { activeMapper, component } ) => {
1113 const originalComponent = component ;
12- if ( activeMapper === 'pf4' ) {
13- switch ( component ) {
14+ if ( activeMapper === 'pf4' ) {
15+ switch ( component ) {
1416 case 'date-picker' :
1517 component = 'textinput' ;
1618 break ;
@@ -32,9 +34,11 @@ export default ({ activeMapper, component }) => {
3234 case 'checkbox-multiple' :
3335 component = 'checkbox' ;
3436 break ;
37+ default :
38+ break ;
3539 }
36- } else if ( activeMapper === 'mui' ) {
37- switch ( component ) {
40+ } else if ( activeMapper === 'mui' ) {
41+ switch ( component ) {
3842 case 'date-picker' :
3943 component = 'text-field' ;
4044 break ;
@@ -53,22 +57,33 @@ export default ({ activeMapper, component }) => {
5357 case 'checkbox-multiple' :
5458 component = 'checkbox' ;
5559 break ;
60+ default :
61+ break ;
5662 }
5763 }
5864
59- return < React . Fragment >
60- < Typography variant = 'body1' gutterBottom >
61- This component also accepts all other original props, please see < a
62- href = { `${ docsLinks [ activeMapper ] } ${ activeMapper === 'pf4' || activeMapper === 'mui' ? component : '' } ` } >
63- here</ a > !
64- </ Typography >
65-
66- { activeMapper === 'mui' ?
67- ( originalComponent === 'date-picker' || originalComponent === 'time-picker' ) &&
68- < Typography variant = 'body1' >
69- This component also use API from material-ui-pickers, please see < a
70- href = { `https://material-ui-pickers.firebaseapp.com/api/${ originalComponent . replace ( '-' , '' ) } ` } >
71- here</ a > !
65+ return (
66+ < React . Fragment >
67+ < Typography variant = "body1" gutterBottom >
68+ This component also accepts all other original props, please see{ ' ' }
69+ < a href = { `${ docsLinks [ activeMapper ] } ${ activeMapper === 'pf4' || activeMapper === 'mui' ? component : '' } ` } > here</ a > !
7270 </ Typography >
73- : '' }
74- </ React . Fragment > ; } ;
71+
72+ { activeMapper === 'mui'
73+ ? ( originalComponent === 'date-picker' || originalComponent === 'time-picker' ) && (
74+ < Typography variant = "body1" >
75+ This component also use API from material-ui-pickers, please see{ ' ' }
76+ < a href = { `https://material-ui-pickers.firebaseapp.com/api/${ originalComponent . replace ( '-' , '' ) } ` } > here</ a > !
77+ </ Typography >
78+ )
79+ : '' }
80+ </ React . Fragment >
81+ ) ;
82+ } ;
83+
84+ GenericMuiComponent . propTypes = {
85+ activeMapper : PropTypes . string ,
86+ component : PropTypes . string
87+ } ;
88+
89+ export default GenericMuiComponent ;
0 commit comments