rc-leaflet
Version:
React Map Components of Leaflet
66 lines (65 loc) • 2.46 kB
JavaScript
;
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 };
}
};
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = require("react");
var prop_types_1 = __importDefault(require("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: prop_types_1.default.func,
onMouseOver: prop_types_1.default.func,
onMouseOut: prop_types_1.default.func
};
return Evented;
}(react_1.PureComponent));
exports.default = Evented;