UNPKG

rc-leaflet

Version:
61 lines (60 loc) 2.18 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __values = (this && this.__values) || function (o) { var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; if (m) return m.call(o); return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; }; import { PureComponent } from 'react'; import PropTypes from 'prop-types'; var Evented = /** @class */ (function (_super) { __extends(Evented, _super); function Evented() { return _super !== null && _super.apply(this, arguments) || this; } Evented.prototype.getEventHandler = function (name) { var _this = this; return function (e) { return _this.props[name] && _this.props[name](e); }; }; Evented.prototype.bindEvents = function () { var e_1, _a; var events = {}; try { for (var _b = __values(Object.keys(Evented.propTypes)), _c = _b.next(); !_c.done; _c = _b.next()) { var key = _c.value; events[key.replace('on', '').toLowerCase()] = this.getEventHandler(key); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } this.instance.on(events); }; Evented.propTypes = { onClick: PropTypes.func, onMouseOver: PropTypes.func, onMouseOut: PropTypes.func }; return Evented; }(PureComponent)); export default Evented;