UNPKG

kepler.gl

Version:

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

65 lines (62 loc) 11.4 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _typeof = require("@babel/runtime/helpers/typeof"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireWildcard(require("react")); var _classnames = _interopRequireDefault(require("classnames")); var _styledComponents = require("../common/styled-components"); var _icons = require("../common/icons"); var _mapControlTooltip = _interopRequireDefault(require("./map-control-tooltip")); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; } // SPDX-License-Identifier: MIT // Copyright contributors to the kepler.gl project SplitMapButtonFactory.deps = [_mapControlTooltip["default"]]; function SplitMapButtonFactory(MapControlTooltip) { var defaultActionIcons = { "delete": _icons.Delete, split: _icons.Split }; /** @type {import('./split-map-button').SplitMapButtonComponent} */ var SplitMapButton = function SplitMapButton(_ref) { var isSplit = _ref.isSplit, mapIndex = _ref.mapIndex, onToggleSplitMap = _ref.onToggleSplitMap, _ref$actionIcons = _ref.actionIcons, actionIcons = _ref$actionIcons === void 0 ? defaultActionIcons : _ref$actionIcons, mapControls = _ref.mapControls, readOnly = _ref.readOnly; var splitMap = (mapControls === null || mapControls === void 0 ? void 0 : mapControls.splitMap) || {}; var onClick = (0, _react.useCallback)(function (event) { event.preventDefault(); onToggleSplitMap(isSplit ? mapIndex : undefined); }, [isSplit, mapIndex, onToggleSplitMap]); var isVisible = (0, _react.useMemo)(function () { return splitMap.show && readOnly !== true; }, [splitMap.show, readOnly]); if (!splitMap.show) { return null; } return isVisible ? /*#__PURE__*/_react["default"].createElement(MapControlTooltip, { id: "action-toggle", message: isSplit ? 'tooltip.closePanel' : 'tooltip.switchToDualView' }, /*#__PURE__*/_react["default"].createElement(_styledComponents.MapControlButton, { active: isSplit, onClick: onClick, className: (0, _classnames["default"])('map-control-button', 'split-map', { 'close-map': isSplit }) }, isSplit ? /*#__PURE__*/_react["default"].createElement(actionIcons["delete"], { height: "18px" }) : /*#__PURE__*/_react["default"].createElement(actionIcons.split, { height: "18px" }))) : null; }; SplitMapButton.displayName = 'SplitMapButton'; return /*#__PURE__*/_react["default"].memo(SplitMapButton); } var _default = exports["default"] = SplitMapButtonFactory; //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfcmVhY3QiLCJfaW50ZXJvcFJlcXVpcmVXaWxkY2FyZCIsInJlcXVpcmUiLCJfY2xhc3NuYW1lcyIsIl9pbnRlcm9wUmVxdWlyZURlZmF1bHQiLCJfc3R5bGVkQ29tcG9uZW50cyIsIl9pY29ucyIsIl9tYXBDb250cm9sVG9vbHRpcCIsIl9nZXRSZXF1aXJlV2lsZGNhcmRDYWNoZSIsImUiLCJXZWFrTWFwIiwiciIsInQiLCJfX2VzTW9kdWxlIiwiX3R5cGVvZiIsImhhcyIsImdldCIsIm4iLCJfX3Byb3RvX18iLCJhIiwiT2JqZWN0IiwiZGVmaW5lUHJvcGVydHkiLCJnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IiLCJ1IiwiaGFzT3duUHJvcGVydHkiLCJjYWxsIiwiaSIsInNldCIsIlNwbGl0TWFwQnV0dG9uRmFjdG9yeSIsImRlcHMiLCJNYXBDb250cm9sVG9vbHRpcEZhY3RvcnkiLCJNY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