Skip to content

Commit 32297a8

Browse files
committed
build
1 parent 93c7ca6 commit 32297a8

File tree

8 files changed

+9513
-0
lines changed

8 files changed

+9513
-0
lines changed

dist/components/Polygon.js

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
(function (global, factory) {
2+
if (typeof define === "function" && define.amd) {
3+
define(['exports', 'react', 'prop-types', '../lib/String'], factory);
4+
} else if (typeof exports !== "undefined") {
5+
factory(exports, require('react'), require('prop-types'), require('../lib/String'));
6+
} else {
7+
var mod = {
8+
exports: {}
9+
};
10+
factory(mod.exports, global.react, global.propTypes, global.String);
11+
global.Polygon = mod.exports;
12+
}
13+
})(this, function (exports, _react, _propTypes, _String) {
14+
'use strict';
15+
16+
Object.defineProperty(exports, "__esModule", {
17+
value: true
18+
});
19+
exports.Polygon = undefined;
20+
21+
var _react2 = _interopRequireDefault(_react);
22+
23+
var _propTypes2 = _interopRequireDefault(_propTypes);
24+
25+
function _interopRequireDefault(obj) {
26+
return obj && obj.__esModule ? obj : {
27+
default: obj
28+
};
29+
}
30+
31+
function _classCallCheck(instance, Constructor) {
32+
if (!(instance instanceof Constructor)) {
33+
throw new TypeError("Cannot call a class as a function");
34+
}
35+
}
36+
37+
var _createClass = function () {
38+
function defineProperties(target, props) {
39+
for (var i = 0; i < props.length; i++) {
40+
var descriptor = props[i];
41+
descriptor.enumerable = descriptor.enumerable || false;
42+
descriptor.configurable = true;
43+
if ("value" in descriptor) descriptor.writable = true;
44+
Object.defineProperty(target, descriptor.key, descriptor);
45+
}
46+
}
47+
48+
return function (Constructor, protoProps, staticProps) {
49+
if (protoProps) defineProperties(Constructor.prototype, protoProps);
50+
if (staticProps) defineProperties(Constructor, staticProps);
51+
return Constructor;
52+
};
53+
}();
54+
55+
function _possibleConstructorReturn(self, call) {
56+
if (!self) {
57+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
58+
}
59+
60+
return call && (typeof call === "object" || typeof call === "function") ? call : self;
61+
}
62+
63+
function _inherits(subClass, superClass) {
64+
if (typeof superClass !== "function" && superClass !== null) {
65+
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
66+
}
67+
68+
subClass.prototype = Object.create(superClass && superClass.prototype, {
69+
constructor: {
70+
value: subClass,
71+
enumerable: false,
72+
writable: true,
73+
configurable: true
74+
}
75+
});
76+
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
77+
}
78+
79+
var evtNames = ['click', 'mouseout', 'mouseover'];
80+
81+
var wrappedPromise = function wrappedPromise() {
82+
var wrappedPromise = {},
83+
promise = new Promise(function (resolve, reject) {
84+
wrappedPromise.resolve = resolve;
85+
wrappedPromise.reject = reject;
86+
});
87+
wrappedPromise.then = promise.then.bind(promise);
88+
wrappedPromise.catch = promise.catch.bind(promise);
89+
wrappedPromise.promise = promise;
90+
91+
return wrappedPromise;
92+
};
93+
94+
var Polygon = exports.Polygon = function (_React$Component) {
95+
_inherits(Polygon, _React$Component);
96+
97+
function Polygon() {
98+
_classCallCheck(this, Polygon);
99+
100+
return _possibleConstructorReturn(this, (Polygon.__proto__ || Object.getPrototypeOf(Polygon)).apply(this, arguments));
101+
}
102+
103+
_createClass(Polygon, [{
104+
key: 'componentDidMount',
105+
value: function componentDidMount() {
106+
this.polygonPromise = wrappedPromise();
107+
this.renderPolygon();
108+
}
109+
}, {
110+
key: 'componentDidUpdate',
111+
value: function componentDidUpdate(prevProps) {
112+
if (this.props.map !== prevProps.map) {
113+
if (this.polygon) {
114+
this.polygon.setMap(null);
115+
this.renderPolygon();
116+
}
117+
}
118+
}
119+
}, {
120+
key: 'componentWillUnmount',
121+
value: function componentWillUnmount() {
122+
if (this.polygon) {
123+
this.polygon.setMap(null);
124+
}
125+
}
126+
}, {
127+
key: 'renderPolygon',
128+
value: function renderPolygon() {
129+
var _this2 = this;
130+
131+
var _props = this.props,
132+
map = _props.map,
133+
google = _props.google,
134+
paths = _props.paths,
135+
strokeColor = _props.strokeColor,
136+
strokeOpacity = _props.strokeOpacity,
137+
strokeWeight = _props.strokeWeight,
138+
fillColor = _props.fillColor,
139+
fillOpacity = _props.fillOpacity;
140+
141+
142+
if (!google) {
143+
return null;
144+
}
145+
146+
var params = {
147+
map: map,
148+
paths: paths,
149+
strokeColor: strokeColor,
150+
strokeOpacity: strokeOpacity,
151+
strokeWeight: strokeWeight,
152+
fillColor: fillColor,
153+
fillOpacity: fillOpacity
154+
};
155+
156+
this.polygon = new google.maps.Polygon(params);
157+
158+
evtNames.forEach(function (e) {
159+
_this2.polygon.addListener(e, _this2.handleEvent(e));
160+
});
161+
162+
this.polygonPromise.resolve(this.polygon);
163+
}
164+
}, {
165+
key: 'getPolygon',
166+
value: function getPolygon() {
167+
return this.polygonPromise;
168+
}
169+
}, {
170+
key: 'handleEvent',
171+
value: function handleEvent(evt) {
172+
var _this3 = this;
173+
174+
return function (e) {
175+
var evtName = 'on' + (0, _String.camelize)(evt);
176+
if (_this3.props[evtName]) {
177+
_this3.props[evtName](_this3.props, _this3.polygon, e);
178+
}
179+
};
180+
}
181+
}, {
182+
key: 'render',
183+
value: function render() {
184+
return null;
185+
}
186+
}]);
187+
188+
return Polygon;
189+
}(_react2.default.Component);
190+
191+
Polygon.propTypes = {
192+
paths: _propTypes2.default.array,
193+
strokeColor: _propTypes2.default.string,
194+
strokeOpacity: _propTypes2.default.number,
195+
strokeWeight: _propTypes2.default.number,
196+
fillColor: _propTypes2.default.string,
197+
fillOpacity: _propTypes2.default.number
198+
};
199+
200+
evtNames.forEach(function (e) {
201+
return Polygon.propTypes[e] = _propTypes2.default.func;
202+
});
203+
204+
Polygon.defaultProps = {
205+
name: 'Polygon'
206+
};
207+
208+
exports.default = Polygon;
209+
});

0 commit comments

Comments
 (0)