Skip to content

Commit 4b3cf70

Browse files
committed
Revert "Add dist to gitignore"
This reverts commit 01ad915.
1 parent 64607e4 commit 4b3cf70

File tree

13 files changed

+2074
-1
lines changed

13 files changed

+2074
-1
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ npm-debug.log
88
node_modules
99
.env
1010
public/
11-
dist/

dist/GoogleApiComponent.js

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
(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+
}
13+
})(this, function (exports, _react, _reactDom, _ScriptCache, _GoogleApi) {
14+
'use strict';
15+
16+
Object.defineProperty(exports, "__esModule", {
17+
value: true
18+
});
19+
exports.wrapper = undefined;
20+
21+
var _react2 = _interopRequireDefault(_react);
22+
23+
var _reactDom2 = _interopRequireDefault(_reactDom);
24+
25+
var _GoogleApi2 = _interopRequireDefault(_GoogleApi);
26+
27+
function _interopRequireDefault(obj) {
28+
return obj && obj.__esModule ? obj : {
29+
default: obj
30+
};
31+
}
32+
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+
}
48+
}
49+
50+
return function (Constructor, protoProps, staticProps) {
51+
if (protoProps) defineProperties(Constructor.prototype, protoProps);
52+
if (staticProps) defineProperties(Constructor, staticProps);
53+
return Constructor;
54+
};
55+
}();
56+
57+
function _possibleConstructorReturn(self, call) {
58+
if (!self) {
59+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
60+
}
61+
62+
return call && (typeof call === "object" || typeof call === "function") ? call : self;
63+
}
64+
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);
68+
}
69+
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;
131+
}
132+
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);
147+
}
148+
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);
165+
166+
return Wrapper;
167+
};
168+
};
169+
170+
exports.default = wrapper;
171+
});

0 commit comments

Comments
 (0)