UNPKG

kepler.gl

Version:

kepler.gl is a webgl based application to visualize large scale location data in the browser

148 lines (112 loc) 13.5 kB
"use strict"; var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = exports.FeatureActionPanel = void 0; var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); var _getPrototypeOf3 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral")); var _react = _interopRequireWildcard(require("react")); var _actionPanel = _interopRequireWildcard(require("../common/action-panel")); var _styledComponents = _interopRequireDefault(require("styled-components")); var _reactOnclickoutside = _interopRequireDefault(require("react-onclickoutside")); var _propTypes = _interopRequireDefault(require("prop-types")); var _classnames = _interopRequireDefault(require("classnames")); var _icons = require("../common/icons"); function _templateObject() { var data = (0, _taggedTemplateLiteral2["default"])(["\n position: absolute;\n"]); _templateObject = function _templateObject() { return data; }; return data; } var LAYOVER_OFFSET = 4; var StyledActionsLayer = _styledComponents["default"].div(_templateObject()); var FeatureActionPanel = /*#__PURE__*/ function (_PureComponent) { (0, _inherits2["default"])(FeatureActionPanel, _PureComponent); function FeatureActionPanel() { var _getPrototypeOf2; var _this; (0, _classCallCheck2["default"])(this, FeatureActionPanel); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = (0, _possibleConstructorReturn2["default"])(this, (_getPrototypeOf2 = (0, _getPrototypeOf3["default"])(FeatureActionPanel)).call.apply(_getPrototypeOf2, [this].concat(args))); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleClickOutside", function (e) { e.preventDefault(); e.stopPropagation(); _this.props.onClose(); }); return _this; } (0, _createClass2["default"])(FeatureActionPanel, [{ key: "render", value: function render() { var _this$props = this.props, className = _this$props.className, datasets = _this$props.datasets, position = _this$props.position, layers = _this$props.layers, currentFilter = _this$props.currentFilter, onToggleLayer = _this$props.onToggleLayer, onDeleteFeature = _this$props.onDeleteFeature; var _ref = currentFilter || {}, _ref$layerId = _ref.layerId, layerId = _ref$layerId === void 0 ? [] : _ref$layerId; return _react["default"].createElement(StyledActionsLayer, { className: (0, _classnames["default"])('feature-action-panel', className), style: { top: "".concat(position.y + LAYOVER_OFFSET, "px"), left: "".concat(position.x + LAYOVER_OFFSET, "px") } }, _react["default"].createElement(_actionPanel["default"], null, _react["default"].createElement(_actionPanel.ActionPanelItem, { className: "editor-layers-list", label: "layers", Icon: _icons.Layers }, layers.map(function (layer, index) { return _react["default"].createElement(_actionPanel.ActionPanelItem, { key: index, label: layer.config.label, color: datasets[layer.config.dataId].color, isSelection: true, isActive: layerId.includes(layer.id), onClick: function onClick() { return onToggleLayer(layer); }, className: "layer-panel-item" }); })), _react["default"].createElement(_actionPanel.ActionPanelItem, { label: "delete", className: "delete-panel-item", Icon: _icons.Trash, onClick: onDeleteFeature }))); } }]); return FeatureActionPanel; }(_react.PureComponent); exports.FeatureActionPanel = FeatureActionPanel; (0, _defineProperty2["default"])(FeatureActionPanel, "propTypes", { className: _propTypes["default"].string, datasets: _propTypes["default"].object.isRequired, position: _propTypes["default"].object.isRequired, layers: _propTypes["default"].arrayOf(_propTypes["default"].object).isRequired, currentFilter: _propTypes["default"].object, onClose: _propTypes["default"].func.isRequired, onDeleteFeature: _propTypes["default"].func.isRequired }); (0, _defineProperty2["default"])(FeatureActionPanel, "defaultProps", { position: {} }); var _default = (0, _reactOnclickoutside["default"])(FeatureActionPanel); exports["default"] = _default; //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jb21wb25lbnRzL2VkaXRvci9mZWF0dXJlLWFjdGlvbi1wYW5lbC5qcyJdLCJuYW1lcyI6WyJMQVlPVkVSX09GRlNFVCIsIlN0eWxlZEFjdGlvbnNMYXllciIsInN0eWxlZCIsImRpdiIsIkZlYXR1cmVBY3Rpb25QYW5lbCIsImUiLCJwcmV2ZW50RGVmYXVsdCIsInN0b3BQcm9wYWdhdGlvbiIsInByb3BzIiwib25DbG9zZSIsImNsYXNzTmFtZSIsImRhdGFzZXRzIiwicG9zaXRpb24iLCJsYXllcnMiLCJjdXJyZW50RmlsdGVyIiwib25Ub2dnbGVMYXllciIsIm9uRGVsZXRlRmVhdHVyZSIsImxheWVySWQiLCJ0b3AiLCJ5IiwibGVmdCIsIngiLCJMYXllcnMiLCJtYXAiLCJsYXllciIsImluZGV4IiwiY29uZmlnIiwibGFiZWwiLCJkYXRhSWQiLCJjb2xvciIsImluY2x1ZGVzIiwiaWQiLCJUcmFzaCIsIlB1cmVDb21wb25lbnQiLCJQcm9wVHlwZXMiLCJzdHJpbmciLCJvYmplY3QiLCJpc1JlcXVpcmVkIiwiYXJyYXlPZiIsImZ1bmMiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQW9CQTs7QUFDQTs7QUFDQTs7QUFDQTs7QUFDQTs7QUFDQTs7QUFDQTs7Ozs7Ozs7Ozs7O0FBRUEsSUFBTUEsY0FBYyxHQUFHLENBQXZCOztBQUVBLElBQU1DLGtCQUFrQixHQUFHQyw2QkFBT0MsR0FBVixtQkFBeEI7O0lBSWFDLGtCOzs7Ozs7Ozs7Ozs7Ozs7OzsyR0FnQlUsVUFBQUMsQ0FBQyxFQUFJO0FBQ3hCQSxNQUFBQSx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c3Qge1xuICAgICAgY2xhc3NOYW1lLFxuICAgICAgZGF0YXNldHMsXG4gICAgICBwb3NpdGlvbixcbiAgICAgIGxheWVycyxcbiAgICAgIGN1cnJlbnRGaWx0ZXIsXG4gICAgICBvblRvZ2dsZUxheWVyLFxuICAgICAgb25EZWxldGVGZWF0dXJlXG4gICAgfSA9IHRoaXMucHJvcHM7XG5cbiAgICBjb25zdCB7bGF5ZXJJZCA9IFtdfSA9IGN1cnJlbnRGaWx0ZXIgfHwge307XG5cbiAgICByZXR1cm4gKFxuICAgICAgPFN0eWxlZEFjdGlvbnNMYXllclxuICAgICAgICBjbGFzc05hbWU9e2NsYXNzbmFtZXMoJ2ZlYXR1cmUtYWN0aW9uLXBhbmVsJywgY2xhc3NOYW1lKX1cbiAgICAgICAgc3R5bGU9e3tcbiAgICAgICAgICB0b3A6IGAke3Bvc2l0aW9uLnkgKyBMQVlPVkVSX09GRlNFVH1weGAsXG4gICAgICAgICAgbGVmdDogYCR7cG9zaXRpb24ueCArIExBWU9WRVJfT0ZGU0VUfXB4YFxuICAgICAgICB9fVxuICAgICAgPlxuICAgICAgICA8QWN0aW9uUGFuZWw+XG4gICAgICAgICAgPEFjdGlvblBhbmVsSXRlbSBjbGFzc05hbWU9XCJlZGl0b3ItbGF5ZXJzLWxpc3RcIiBsYWJlbD1cImxheWVyc1wiIEljb249e0xheWVyc30+XG4gICAgICAgICAgICB7bGF5ZXJzLm1hcCgobGF5ZXIsIGluZGV4KSA9PiAoXG4gICAgICAgICAgICAgIDxBY3Rpb25QYW5lbEl0ZW1cbiAgICAgICAgICAgICAgICBrZXk9e2luZGV4fVxuICAgICAgICAgICAgICAgIGxhYmVsPXtsYXllci5jb25maWcubGFiZWx9XG4gICAgICAgICAgICAgICAgY29sb3I9e2RhdGFzZXRzW2xheWVyLmNvbmZpZy5kYXRhSWRdLmNvbG9yfVxuICAgICAgICAgICAgICAgIGlzU2VsZWN0aW9uPXt0cnVlfVxuICAgICAgICAgICAgICAgIGlzQWN0aXZlPXtsYXllcklkLmluY2x1ZGVzKGxheWVyLmlkKX1cbiAgICAgICAgICAgICAgICBvbkNsaWNrPXsoKSA9PiBvblRvZ2dsZUxheWVyKGxheWVyKX1cbiAgICAgICAgICAgICAgICBjbGFzc05hbWU9XCJsYXllci1wYW5lbC1pdGVtXCJcbiAgICAgICAgICAgICAgLz5cbiAgICAgICAgICAgICkpfVxuICAgICAgICAgIDwvQWN0aW9uUGFuZWxJdGVtPlxuICAgICAgICAgIDxBY3Rpb25QYW5lbEl0ZW1cbiAgICAgICAgICAgIGxhYmVsPVwiZGVsZXRlXCJcbiAgICAgICAgICAgIGNsYXNzTmFtZT1cImRlbGV0ZS1wYW5lbC1pdGVtXCJcbiAgICAgICAgICAgIEljb249e1RyYXNofVxuICAgICAgICAgICAgb25DbGljaz17b25EZWxldGVGZWF0dXJlfVxuICAgICAgICAgIC8+XG4gICAgICAgIDwvQWN0aW9uUGFuZWw+XG4gICAgICA8L1N0eWxlZEFjdGlvbnNMYXllcj5cbiAgICApO1xuICB9XG59XG5cbmV4cG9ydCBkZWZhdWx0IG9uQ2xpY2tPdXRzaWRlKEZlYXR1cmVBY3Rpb25QYW5lbCk7XG4iXX0=