11( function ( global , factory ) {
2- if ( typeof define === "function" && define . amd ) {
3- define ( [ 'exports' , 'react' , 'react-dom' , './lib/ScriptCache' , './lib/GoogleApi' ] , factory ) ;
4- } else if ( typeof exports !== "undefined" ) {
5- factory ( exports , require ( 'react' ) , require ( 'react-dom' ) , require ( './lib/ScriptCache' ) , require ( './lib/GoogleApi' ) ) ;
6- } else {
7- var mod = {
8- exports : { }
9- } ;
10- factory ( mod . exports , global . react , global . reactDom , global . ScriptCache , global . GoogleApi ) ;
11- global . GoogleApiComponent = mod . exports ;
12- }
2+ if ( typeof define === "function" && define . amd ) {
3+ define ( [ 'exports' , 'react' , 'react-dom' , './lib/ScriptCache' , './lib/GoogleApi' ] , factory ) ;
4+ } else if ( typeof exports !== "undefined" ) {
5+ factory ( exports , require ( 'react' ) , require ( 'react-dom' ) , require ( './lib/ScriptCache' ) , require ( './lib/GoogleApi' ) ) ;
6+ } else {
7+ var mod = {
8+ exports : { }
9+ } ;
10+ factory ( mod . exports , global . react , global . reactDom , global . ScriptCache , global . GoogleApi ) ;
11+ global . GoogleApiComponent = mod . exports ;
12+ }
1313} ) ( this , function ( exports , _react , _reactDom , _ScriptCache , _GoogleApi ) {
14- 'use strict' ;
14+ 'use strict' ;
1515
16- Object . defineProperty ( exports , "__esModule" , {
17- value : true
18- } ) ;
19- exports . wrapper = undefined ;
16+ Object . defineProperty ( exports , "__esModule" , {
17+ value : true
18+ } ) ;
19+ exports . wrapper = undefined ;
2020
21- var _react2 = _interopRequireDefault ( _react ) ;
21+ var _react2 = _interopRequireDefault ( _react ) ;
2222
23- var _reactDom2 = _interopRequireDefault ( _reactDom ) ;
23+ var _reactDom2 = _interopRequireDefault ( _reactDom ) ;
2424
25- var _GoogleApi2 = _interopRequireDefault ( _GoogleApi ) ;
25+ var _GoogleApi2 = _interopRequireDefault ( _GoogleApi ) ;
2626
27- function _interopRequireDefault ( obj ) {
28- return obj && obj . __esModule ? obj : {
29- default : obj
30- } ;
31- }
27+ function _interopRequireDefault ( obj ) {
28+ return obj && obj . __esModule ? obj : {
29+ default : obj
30+ } ;
31+ }
3232
33- function _classCallCheck ( instance , Constructor ) {
34- if ( ! ( instance instanceof Constructor ) ) {
35- throw new TypeError ( "Cannot call a class as a function" ) ;
36- }
33+ function _classCallCheck ( instance , Constructor ) {
34+ if ( ! ( instance instanceof Constructor ) ) {
35+ throw new TypeError ( "Cannot call a class as a function" ) ;
36+ }
37+ }
38+
39+ var _createClass = function ( ) {
40+ function defineProperties ( target , props ) {
41+ for ( var i = 0 ; i < props . length ; i ++ ) {
42+ var descriptor = props [ i ] ;
43+ descriptor . enumerable = descriptor . enumerable || false ;
44+ descriptor . configurable = true ;
45+ if ( "value" in descriptor ) descriptor . writable = true ;
46+ Object . defineProperty ( target , descriptor . key , descriptor ) ;
47+ }
3748 }
3849
39- var _createClass = function ( ) {
40- function defineProperties ( target , props ) {
41- for ( var i = 0 ; i < props . length ; i ++ ) {
42- var descriptor = props [ i ] ;
43- descriptor . enumerable = descriptor . enumerable || false ;
44- descriptor . configurable = true ;
45- if ( "value" in descriptor ) descriptor . writable = true ;
46- Object . defineProperty ( target , descriptor . key , descriptor ) ;
47- }
48- }
50+ return function ( Constructor , protoProps , staticProps ) {
51+ if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ;
52+ if ( staticProps ) defineProperties ( Constructor , staticProps ) ;
53+ return Constructor ;
54+ } ;
55+ } ( ) ;
4956
50- return function ( Constructor , protoProps , staticProps ) {
51- if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ;
52- if ( staticProps ) defineProperties ( Constructor , staticProps ) ;
53- return Constructor ;
54- } ;
55- } ( ) ;
57+ function _possibleConstructorReturn ( self , call ) {
58+ if ( ! self ) {
59+ throw new ReferenceError ( "this hasn't been initialised - super() hasn't been called" ) ;
60+ }
5661
57- function _possibleConstructorReturn ( self , call ) {
58- if ( ! self ) {
59- throw new ReferenceError ( "this hasn't been initialised - super() hasn't been called" ) ;
60- }
62+ return call && ( typeof call === "object" || typeof call === "function" ) ? call : self ;
63+ }
6164
62- return call && ( typeof call === "object" || typeof call === "function" ) ? call : self ;
65+ function _inherits ( subClass , superClass ) {
66+ if ( typeof superClass !== "function" && superClass !== null ) {
67+ throw new TypeError ( "Super expression must either be null or a function, not " + typeof superClass ) ;
6368 }
6469
65- function _inherits ( subClass , superClass ) {
66- if ( typeof superClass !== "function" && superClass !== null ) {
67- throw new TypeError ( "Super expression must either be null or a function, not " + typeof superClass ) ;
70+ subClass . prototype = Object . create ( superClass && superClass . prototype , {
71+ constructor : {
72+ value : subClass ,
73+ enumerable : false ,
74+ writable : true ,
75+ configurable : true
76+ }
77+ } ) ;
78+ if ( superClass ) Object . setPrototypeOf ? Object . setPrototypeOf ( subClass , superClass ) : subClass . __proto__ = superClass ;
79+ }
80+
81+ var defaultMapConfig = { } ;
82+ var defaultCreateCache = function defaultCreateCache ( options ) {
83+ options = options || { } ;
84+ var apiKey = options . apiKey ;
85+ var libraries = options . libraries || [ 'places' ] ;
86+ var version = options . version || '3' ;
87+ var language = options . language || 'en' ;
88+ var url = options . url ;
89+
90+ return ( 0 , _ScriptCache . ScriptCache ) ( {
91+ google : ( 0 , _GoogleApi2 . default ) ( {
92+ apiKey : apiKey ,
93+ language : language ,
94+ libraries : libraries ,
95+ version : version ,
96+ url : url
97+ } )
98+ } ) ;
99+ } ;
100+
101+ var DefaultLoadingContainer = function DefaultLoadingContainer ( props ) {
102+ return _react2 . default . createElement (
103+ 'div' ,
104+ null ,
105+ 'Loading...'
106+ ) ;
107+ } ;
108+
109+ var wrapper = exports . wrapper = function wrapper ( options ) {
110+ return function ( WrappedComponent ) {
111+ var createCache = options . createCache || defaultCreateCache ;
112+
113+ var Wrapper = function ( _React$Component ) {
114+ _inherits ( Wrapper , _React$Component ) ;
115+
116+ function Wrapper ( props , context ) {
117+ _classCallCheck ( this , Wrapper ) ;
118+
119+ var _this = _possibleConstructorReturn ( this , ( Wrapper . __proto__ || Object . getPrototypeOf ( Wrapper ) ) . call ( this , props , context ) ) ;
120+
121+ _this . scriptCache = createCache ( options ) ;
122+ _this . scriptCache . google . onLoad ( _this . onLoad . bind ( _this ) ) ;
123+ _this . LoadingContainer = options . LoadingContainer || DefaultLoadingContainer ;
124+
125+ _this . state = {
126+ loaded : false ,
127+ map : null ,
128+ google : null
129+ } ;
130+ return _this ;
68131 }
69132
70- subClass . prototype = Object . create ( superClass && superClass . prototype , {
71- constructor : {
72- value : subClass ,
73- enumerable : false ,
74- writable : true ,
75- configurable : true
133+ _createClass ( Wrapper , [ {
134+ key : 'onLoad' ,
135+ value : function onLoad ( err , tag ) {
136+ this . _gapi = window . google ;
137+
138+ this . setState ( { loaded : true , google : this . _gapi } ) ;
139+ }
140+ } , {
141+ key : 'render' ,
142+ value : function render ( ) {
143+ var LoadingContainer = this . LoadingContainer ;
144+
145+ if ( ! this . state . loaded ) {
146+ return _react2 . default . createElement ( LoadingContainer , null ) ;
76147 }
77- } ) ;
78- if ( superClass ) Object . setPrototypeOf ? Object . setPrototypeOf ( subClass , superClass ) : subClass . __proto__ = superClass ;
79- }
80148
81- var defaultMapConfig = { } ;
82- var defaultCreateCache = function defaultCreateCache ( options ) {
83- options = options || { } ;
84- var apiKey = options . apiKey ;
85- var libraries = options . libraries || [ 'places' ] ;
86- var version = options . version || '3.29' ;
87- var language = options . language || 'en' ;
88- var url = options . url ;
89-
90- return ( 0 , _ScriptCache . ScriptCache ) ( {
91- google : ( 0 , _GoogleApi2 . default ) ( {
92- apiKey : apiKey ,
93- language : language ,
94- libraries : libraries ,
95- version : version ,
96- url : url
97- } )
98- } ) ;
99- } ;
149+ var props = Object . assign ( { } , this . props , {
150+ loaded : this . state . loaded ,
151+ google : window . google
152+ } ) ;
153+
154+ return _react2 . default . createElement (
155+ 'div' ,
156+ null ,
157+ _react2 . default . createElement ( WrappedComponent , props ) ,
158+ _react2 . default . createElement ( 'div' , { ref : 'map' } )
159+ ) ;
160+ }
161+ } ] ) ;
162+
163+ return Wrapper ;
164+ } ( _react2 . default . Component ) ;
100165
101- var wrapper = exports . wrapper = function wrapper ( options ) {
102- return function ( WrappedComponent ) {
103- var createCache = options . createCache || defaultCreateCache ;
104-
105- var Wrapper = function ( _React$Component ) {
106- _inherits ( Wrapper , _React$Component ) ;
107-
108- function Wrapper ( props , context ) {
109- _classCallCheck ( this , Wrapper ) ;
110-
111- var _this = _possibleConstructorReturn ( this , ( Wrapper . __proto__ || Object . getPrototypeOf ( Wrapper ) ) . call ( this , props , context ) ) ;
112-
113- _this . scriptCache = createCache ( options ) ;
114- _this . scriptCache . google . onLoad ( _this . onLoad . bind ( _this ) ) ;
115-
116- _this . state = {
117- loaded : false ,
118- map : null ,
119- google : null
120- } ;
121- return _this ;
122- }
123-
124- _createClass ( Wrapper , [ {
125- key : 'onLoad' ,
126- value : function onLoad ( err , tag ) {
127- this . _gapi = window . google ;
128-
129- this . setState ( { loaded : true , google : this . _gapi } ) ;
130- }
131- } , {
132- key : 'render' ,
133- value : function render ( ) {
134- var props = Object . assign ( { } , this . props , {
135- loaded : this . state . loaded ,
136- google : window . google
137- } ) ;
138-
139- return _react2 . default . createElement (
140- 'div' ,
141- null ,
142- _react2 . default . createElement ( WrappedComponent , props ) ,
143- _react2 . default . createElement ( 'div' , { ref : 'map' } )
144- ) ;
145- }
146- } ] ) ;
147-
148- return Wrapper ;
149- } ( _react2 . default . Component ) ;
150-
151- return Wrapper ;
152- } ;
166+ return Wrapper ;
153167 } ;
168+ } ;
154169
155- exports . default = wrapper ;
170+ exports . default = wrapper ;
156171} ) ;
0 commit comments