UNPKG

kepler.gl

Version:

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

77 lines (75 loc) 12.9 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 _toolbarItem = _interopRequireDefault(require("../common/toolbar-item")); var _styledComponents = require("../common/styled-components"); var _mapControlTooltip = _interopRequireDefault(require("./map-control-tooltip")); var _mapControlToolbar = _interopRequireDefault(require("./map-control-toolbar")); 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 LocalePanelFactory.deps = [_mapControlTooltip["default"], _mapControlToolbar["default"]]; function LocalePanelFactory(MapControlTooltip, MapControlToolbar) { var LocalePanel = /*#__PURE__*/_react["default"].memo(function (_ref) { var availableLocales = _ref.availableLocales, onToggleMapControl = _ref.onToggleMapControl, onSetLocale = _ref.onSetLocale, currentLocal = _ref.locale, mapControls = _ref.mapControls; var _ref2 = mapControls.mapLocale || {}, isActive = _ref2.active, show = _ref2.show; var onClickItem = (0, _react.useCallback)(function (locale) { onSetLocale(locale); }, [onSetLocale]); var onClickButton = (0, _react.useCallback)(function (e) { e.preventDefault(); onToggleMapControl('mapLocale'); }, [onToggleMapControl]); var getLabel = (0, _react.useCallback)(function (locale) { return "toolbar.".concat(locale); }, []); if (!show) { return null; } return /*#__PURE__*/_react["default"].createElement("div", { className: "locale-panel-controls", style: { position: 'relative' } }, isActive ? /*#__PURE__*/_react["default"].createElement(MapControlToolbar, { show: isActive }, availableLocales.map(function (locale) { return /*#__PURE__*/_react["default"].createElement(_toolbarItem["default"], { key: locale, onClick: function onClick() { return onClickItem(locale); }, label: getLabel(locale), active: currentLocal === locale }); })) : null, /*#__PURE__*/_react["default"].createElement(MapControlTooltip, { id: "locale", message: "tooltip.selectLocale" }, /*#__PURE__*/_react["default"].createElement(_styledComponents.MapControlButton, { className: (0, _classnames["default"])('map-control-button', 'locale-panel', { isActive: isActive }), onClick: onClickButton, active: isActive }, /*#__PURE__*/_react["default"].createElement("span", { className: "map-control-button__locale" }, currentLocal.toUpperCase())))); }); LocalePanel.displayName = 'LocalePanel'; return LocalePanel; } var _default = exports["default"] = LocalePanelFactory; //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfcmVhY3QiLCJfaW50ZXJvcFJlcXVpcmVXaWxkY2FyZCIsInJlcXVpcmUiLCJfY2xhc3NuYW1lcyIsIl9pbnRlcm9wUmVxdWlyZURlZmF1bHQiLCJfdG9vbGJhckl0ZW0iLCJfc3R5bGVkQ29tcG9uZW50cyIsIl9tYXBDb250cm9sVG9vbHRpcCIsIl9tYXBDb250cm9sVG9vbGJhciIsIl9nZXRSZXF1aXJlV2lsZGNhcmRDYWNoZSIsImUiLCJXZWFrTWFwIiwiciIsInQiLCJfX2VzTW9kdWxlIiwiX3R5cGVvZiIsImhhcyIsImdldCIsIm4iLCJfX3Byb3RvX18iLCJhIiwiT2JqZWN0IiwiZGVmaW5lUHJvcGVydHkiLCJnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IiLCJ1IiwiaGFzT3duUHJvcGVydH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bGUgPT4gKFxuICAgICAgICAgICAgICAgIDxUb29sYmFySXRlbVxuICAgICAgICAgICAgICAgICAga2V5PXtsb2NhbGV9XG4gICAgICAgICAgICAgICAgICBvbkNsaWNrPXsoKSA9PiBvbkNsaWNrSXRlbShsb2NhbGUpfVxuICAgICAgICAgICAgICAgICAgbGFiZWw9e2dldExhYmVsKGxvY2FsZSl9XG4gICAgICAgICAgICAgICAgICBhY3RpdmU9e2N1cnJlbnRMb2NhbCA9PT0gbG9jYWxlfVxuICAgICAgICAgICAgICAgIC8+XG4gICAgICAgICAgICAgICkpfVxuICAgICAgICAgICAgPC9NYXBDb250cm9sVG9vbGJhcj5cbiAgICAgICAgICApIDogbnVsbH1cbiAgICAgICAgICA8TWFwQ29udHJvbFRvb2x0aXAgaWQ9XCJsb2NhbGVcIiBtZXNzYWdlPVwidG9vbHRpcC5zZWxlY3RMb2NhbGVcIj5cbiAgICAgICAgICAgIDxNYXBDb250cm9sQnV0dG9uXG4gICAgICAgICAgICAgIGNsYXNzTmFtZT17Y2xhc3NuYW1lcygnbWFwLWNvbnRyb2wtYnV0dG9uJywgJ2xvY2FsZS1wYW5lbCcsIHtpc0FjdGl2ZX0pfVxuICAgICAgICAgICAgICBvbkNsaWNrPXtvbkNsaWNrQnV0dG9ufVxuICAgICAgICAgICAgICBhY3RpdmU9e2lzQWN0aXZlfVxuICAgICAgICAgICAgPlxuICAgICAgICAgICAgICA8c3BhbiBjbGFzc05hbWU9XCJtYXAtY29udHJvbC1idXR0b25fX2xvY2FsZVwiPntjdXJyZW50TG9jYWwudG9VcHBlckNhc2UoKX08L3NwYW4+XG4gICAgICAgICAgICA8L01hcENvbnRyb2xCdXR0b24+XG4gICAgICAgICAgPC9NYXBDb250cm9sVG9vbHRpcD5cbiAgICAgICAgPC9kaXY+XG4gICAgICApO1xuICAgIH1cbiAgKTtcblxuICBMb2NhbGVQYW5lbC5kaXNwbGF5TmFtZSA9ICdMb2NhbGVQYW5lbCc7XG5cbiAgcmV0dX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