jam-cloud/jam-ui/node_modules/react-leaflet/es/Path.js

60 lines
1.6 KiB
JavaScript

"use strict";
import _extends from "@babel/runtime/helpers/esm/extends";
import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
import isEqual from 'fast-deep-equal';
import MapLayer from './MapLayer';
import pick from './utils/pick';
var OPTIONS = ['stroke', 'color', 'weight', 'opacity', 'lineCap', 'lineJoin', 'dashArray', 'dashOffset', 'fill', 'fillColor', 'fillOpacity', 'fillRule', 'bubblingMouseEvents', 'renderer', 'className', // Interactive Layer
'interactive', // Layer
'pane', 'attribution'];
var Path = /*#__PURE__*/function (_MapLayer) {
_inheritsLoose(Path, _MapLayer);
function Path(props) {
var _this;
_this = _MapLayer.call(this, props) || this;
if (_this.contextValue == null) {
_this.contextValue = _extends({}, props.leaflet, {
popupContainer: _this.leafletElement
});
}
return _this;
}
var _proto = Path.prototype;
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
_MapLayer.prototype.componentDidUpdate.call(this, prevProps);
this.setStyleIfChanged(prevProps, this.props);
};
_proto.getPathOptions = function getPathOptions(props) {
return pick(props, OPTIONS);
};
_proto.setStyle = function setStyle(options) {
if (options === void 0) {
options = {};
}
this.leafletElement.setStyle(options);
};
_proto.setStyleIfChanged = function setStyleIfChanged(fromProps, toProps) {
var nextStyle = this.getPathOptions(toProps);
if (!isEqual(nextStyle, this.getPathOptions(fromProps))) {
this.setStyle(nextStyle);
}
};
return Path;
}(MapLayer);
export { Path as default };