kepler.gl
Version:
kepler.gl is a webgl based application to visualize large scale location data in the browser
47 lines (44 loc) • 7.92 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useCloudListProvider = exports.CloudListProvider = void 0;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _react = _interopRequireWildcard(require("react"));
var _context = require("../context");
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
var CloudListProvider = exports.CloudListProvider = function CloudListProvider(_ref) {
var children = _ref.children,
_ref$providers = _ref.providers,
providers = _ref$providers === void 0 ? [] : _ref$providers;
var _useState = (0, _react.useState)(null),
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
currentCloudProvider = _useState2[0],
setCurrentCloudProvider = _useState2[1];
var cloudProviders = (0, _react.useRef)(providers);
var setProvider = (0, _react.useCallback)(function (provider) {
setCurrentCloudProvider(currentCloudProvider === provider ? null : provider);
}, [currentCloudProvider]);
var value = (0, _react.useMemo)(function () {
return {
provider: currentCloudProvider,
setProvider: setProvider,
cloudProviders: cloudProviders.current
};
}, [currentCloudProvider, setProvider]);
return /*#__PURE__*/_react["default"].createElement(_context.CloudProviderContext.Provider, {
value: value
}, children);
};
/**
* this hook provides access the CloudList provider context
*/
var useCloudListProvider = exports.useCloudListProvider = function useCloudListProvider() {
return (0, _react.useContext)(_context.CloudProviderContext);
};
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfcmVhY3QiLCJfaW50ZXJvcFJlcXVpcmVXaWxkY2FyZCIsInJlcXVpcmUiLCJfY29udGV4dCIsIl9nZXRSZXF1aXJlV2lsZGNhcmRDYWNoZSIsImUiLCJXZWFrTWFwIiwiciIsInQiLCJfX2VzTW9kdWxlIiwiX3R5cGVvZiIsImhhcyIsImdldCIsIm4iLCJfX3Byb3RvX18iLCJhIiwiT2JqZWN0IiwiZGVmaW5lUHJvcGVydHkiLCJnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IiLCJ1IiwiaGFzT3duUHJvcGVydHkiLCJjYWxsIiwiaSIsInNldCIsIkNsb3VkTGlzdFByb3ZpZGVyIiwiZXhwb3J0cyIsIl9yZWYiLCJjaGlsZHJlbiIsIl9yZWYkcHJvdmlkZXJzIiwicHJvdmlkZXJzIiwiX3VzZVN0YXRlIiwidXNlU3RhdGUiLCJfdXNlU3RhdGUyIiwiX3NsaWNlZFRvQXJyYXkyIiwiY3VycmVudENsb3VkUHJvdmlkZXIiLCJzZXRDdXJyZW50Q2xvdWRQcm92aWRlciIsImNsb3VkUHJvdmlkZXJzIiwidXNlUmVmIiwic2V0UHJvdmlkZXIiLCJ1c2VDYWxsYmFjayIsInByb3ZpZGVyIiwidmFsdWUiLCJ1c2VNZW1vIiwiY3VycmVudCIsImNyZWF0ZUVsZW1lbnQiLCJDbG91ZFByb3ZpZGVyQ29udGV4dCIsIlByb3ZpZGVyIiwidXNlQ2xvdWRMaXN0UHJvdmlkZXIiLCJ1c2VDb250ZXh0Il0sInNvdXJjZXMiOlsiLi4vLi4vc3JjL2hvb2tzL3VzZS1jbG91ZC1saXN0LXByb3ZpZ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