UNPKG

kepler.gl

Version:

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

65 lines (61 loc) 10.8 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"] = AiAssistantControlFactory; var _react = _interopRequireWildcard(require("react")); var _aiStar = _interopRequireDefault(require("../icons/ai-star")); var _components = require("@kepler.gl/components"); 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 /** * AiAssistantControlProps * @param mapControls MapControls from kepler.gl * @param onToggleMapControl (control: string) => void * @param actionIcons AiAssistantControlIcons * @returns */ AiAssistantControlFactory.deps = [_components.MapControlTooltipFactory]; /** * AiAssistantControlFactory * @param MapControlTooltip * @returns */ function AiAssistantControlFactory(MapControlTooltip) { var defaultActionIcons = { aiAssistantIcon: _aiStar["default"] }; var AiAssistantControl = function AiAssistantControl(_ref) { var _mapControls$aiAssist, _mapControls$aiAssist2; var mapControls = _ref.mapControls, onToggleMapControl = _ref.onToggleMapControl, _ref$actionIcons = _ref.actionIcons, actionIcons = _ref$actionIcons === void 0 ? defaultActionIcons : _ref$actionIcons; var onClick = (0, _react.useCallback)(function (event) { event.preventDefault(); onToggleMapControl('aiAssistant'); }, [onToggleMapControl]); var showControl = mapControls === null || mapControls === void 0 || (_mapControls$aiAssist = mapControls.aiAssistant) === null || _mapControls$aiAssist === void 0 ? void 0 : _mapControls$aiAssist.show; if (!showControl) { return null; } var active = mapControls === null || mapControls === void 0 || (_mapControls$aiAssist2 = mapControls.aiAssistant) === null || _mapControls$aiAssist2 === void 0 ? void 0 : _mapControls$aiAssist2.active; return /*#__PURE__*/_react["default"].createElement(MapControlTooltip, { id: "show-ai-assistant", message: active ? 'tooltip.hideAiAssistantPanel' : 'tooltip.showAiAssistantPanel' }, /*#__PURE__*/_react["default"].createElement(_components.MapControlButton, { className: "map-control-button toggle-ai-assistant", onClick: onClick, active: active }, /*#__PURE__*/_react["default"].createElement(actionIcons.aiAssistantIcon, { height: "22px" }))); }; AiAssistantControl.displayName = 'AiAssistantControl'; return /*#__PURE__*/_react["default"].memo(AiAssistantControl); } //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfcmVhY3QiLCJfaW50ZXJvcFJlcXVpcmVXaWxkY2FyZCIsInJlcXVpcmUiLCJfYWlTdGFyIiwiX2ludGVyb3BSZXF1aXJlRGVmYXVsdCIsIl9jb21wb25lbnRzIiwiX2dldFJlcXVpcmVXaWxkY2FyZENhY2hlIiwiZSIsIldlYWtNYXAiLCJyIiwidCIsIl9fZXNNb2R1bGUiLCJfdHlwZW9mIiwiaGFzIiwiZ2V0IiwibiIsIl9fcHJvdG9fXyIsImEiLCJPYmplY3QiLCJkZWZpbmVQcm9wZXJ0eSIsImdldE93blByb3BlcnR5RGVzY3JpcHRvciIsInUiLCJoYXNPd25Qcm9wZXJ0eSIsImNhbGwiLCJpIiwic2V0IiwiQWlBc3Npc3RhbnRDb250cm9sRmFjdG9yeSIsImRlcHMiLCJNYXBDb250cm9sVG9vbHRpcEZhY3RvcnkiLCJNYXBDb250cm9sVG9vbHRpcCIsImRlZmF1bHRBY3Rpb25JY29ucyIsImFpQXNza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