react-simple-maps
Advanced tools
Comparing version 3.0.0-beta.2 to 3.0.0-beta.3
import React, { createContext, useMemo, useCallback, useContext, useState, useEffect, memo, useRef, Fragment } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import * as d3Geo from 'd3-geo'; | ||
import { geoPath as geoPath$1, geoGraticule } from 'd3-geo'; | ||
import { geoGraticule } from 'd3-geo'; | ||
import { feature, mesh } from 'topojson-client'; | ||
@@ -9,70 +9,170 @@ import { zoom, zoomIdentity } from 'd3-zoom'; | ||
var _extends = Object.assign || function (target) { | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
enumerableOnly && (symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
})), keys.push.apply(keys, symbols); | ||
} | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
var source = null != arguments[i] ? arguments[i] : {}; | ||
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
return target; | ||
} | ||
function _typeof(obj) { | ||
"@babel/helpers - typeof"; | ||
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { | ||
return typeof obj; | ||
} : function (obj) { | ||
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}, _typeof(obj); | ||
} | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _extends() { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {}; | ||
var target = {}; | ||
var sourceKeys = Object.keys(source); | ||
var key, i; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
target[key] = source[key]; | ||
} | ||
return target; | ||
}; | ||
} | ||
var objectWithoutProperties = function (obj, keys) { | ||
var target = {}; | ||
function _objectWithoutProperties(source, excluded) { | ||
if (source == null) return {}; | ||
for (var i in obj) { | ||
if (keys.indexOf(i) >= 0) continue; | ||
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; | ||
target[i] = obj[i]; | ||
var target = _objectWithoutPropertiesLoose(source, excluded); | ||
var key, i; | ||
if (Object.getOwnPropertySymbols) { | ||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source); | ||
for (i = 0; i < sourceSymbolKeys.length; i++) { | ||
key = sourceSymbolKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; | ||
target[key] = source[key]; | ||
} | ||
} | ||
return target; | ||
}; | ||
} | ||
var slicedToArray = function () { | ||
function sliceIterator(arr, i) { | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
} | ||
function _arrayWithHoles(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
} | ||
function _iterableToArrayLimit(arr, i) { | ||
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; | ||
if (_i == null) return; | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _s, _e; | ||
try { | ||
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
if (!_n && _i["return"] != null) _i["return"](); | ||
} finally { | ||
try { | ||
if (!_n && _i["return"]) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
if (_d) throw _e; | ||
} | ||
return _arr; | ||
} | ||
return function (arr, i) { | ||
if (Array.isArray(arr)) { | ||
return arr; | ||
} else if (Symbol.iterator in Object(arr)) { | ||
return sliceIterator(arr, i); | ||
} else { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
} | ||
}; | ||
}(); | ||
return _arr; | ||
} | ||
var geoPath = geoPath$1, | ||
projections = objectWithoutProperties(d3Geo, ["geoPath"]); | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
var _excluded$9 = ["width", "height", "projection", "projectionConfig"]; | ||
var geoPath = d3Geo.geoPath, | ||
projections = _objectWithoutProperties(d3Geo, ["geoPath"]); | ||
var MapContext = createContext(); | ||
@@ -82,18 +182,13 @@ | ||
var _ref$projectionConfig = _ref.projectionConfig, | ||
projectionConfig = _ref$projectionConfig === undefined ? {} : _ref$projectionConfig, | ||
projectionConfig = _ref$projectionConfig === void 0 ? {} : _ref$projectionConfig, | ||
_ref$projection = _ref.projection, | ||
projection = _ref$projection === undefined ? "geoEqualEarth" : _ref$projection, | ||
projection = _ref$projection === void 0 ? "geoEqualEarth" : _ref$projection, | ||
_ref$width = _ref.width, | ||
width = _ref$width === undefined ? 800 : _ref$width, | ||
width = _ref$width === void 0 ? 800 : _ref$width, | ||
_ref$height = _ref.height, | ||
height = _ref$height === undefined ? 600 : _ref$height; | ||
height = _ref$height === void 0 ? 600 : _ref$height; | ||
var isFunc = typeof projection === "function"; | ||
if (isFunc) return projection; | ||
var proj = projections[projection]().translate([width / 2, height / 2]); | ||
var supported = [proj.center ? "center" : null, proj.rotate ? "rotate" : null, proj.scale ? "scale" : null, proj.parallels ? "parallels" : null]; | ||
supported.forEach(function (d) { | ||
@@ -103,3 +198,2 @@ if (!d) return; | ||
}); | ||
return proj; | ||
@@ -113,6 +207,6 @@ }; | ||
projectionConfig = _ref2.projectionConfig, | ||
restProps = objectWithoutProperties(_ref2, ["width", "height", "projection", "projectionConfig"]); | ||
restProps = _objectWithoutProperties(_ref2, _excluded$9); | ||
var _ref3 = projectionConfig.center || [], | ||
_ref4 = slicedToArray(_ref3, 2), | ||
_ref4 = _slicedToArray(_ref3, 2), | ||
cx = _ref4[0], | ||
@@ -122,3 +216,3 @@ cy = _ref4[1]; | ||
var _ref5 = projectionConfig.rotate || [], | ||
_ref6 = slicedToArray(_ref5, 3), | ||
_ref6 = _slicedToArray(_ref5, 3), | ||
rx = _ref6[0], | ||
@@ -129,3 +223,3 @@ ry = _ref6[1], | ||
var _ref7 = projectionConfig.parallels || [], | ||
_ref8 = slicedToArray(_ref7, 2), | ||
_ref8 = _slicedToArray(_ref7, 2), | ||
p1 = _ref8[0], | ||
@@ -135,3 +229,2 @@ p2 = _ref8[1]; | ||
var s = projectionConfig.scale || null; | ||
var projMemo = useMemo(function () { | ||
@@ -150,5 +243,3 @@ return makeProjection({ | ||
}, [width, height, projection, cx, cy, rx, ry, rz, p1, p2, s]); | ||
var proj = useCallback(projMemo, [projMemo]); | ||
var value = useMemo(function () { | ||
@@ -162,4 +253,5 @@ return { | ||
}, [width, height, proj]); | ||
return React.createElement(MapContext.Provider, _extends({ value: value }, restProps)); | ||
return /*#__PURE__*/React.createElement(MapContext.Provider, _extends({ | ||
value: value | ||
}, restProps)); | ||
}; | ||
@@ -174,28 +266,26 @@ | ||
var _excluded$8 = ["width", "height", "projection", "projectionConfig", "className"]; | ||
var ComposableMap = function ComposableMap(_ref) { | ||
var _ref$width = _ref.width, | ||
width = _ref$width === undefined ? 800 : _ref$width, | ||
width = _ref$width === void 0 ? 800 : _ref$width, | ||
_ref$height = _ref.height, | ||
height = _ref$height === undefined ? 600 : _ref$height, | ||
height = _ref$height === void 0 ? 600 : _ref$height, | ||
_ref$projection = _ref.projection, | ||
projection = _ref$projection === undefined ? "geoEqualEarth" : _ref$projection, | ||
projection = _ref$projection === void 0 ? "geoEqualEarth" : _ref$projection, | ||
_ref$projectionConfig = _ref.projectionConfig, | ||
projectionConfig = _ref$projectionConfig === undefined ? {} : _ref$projectionConfig, | ||
projectionConfig = _ref$projectionConfig === void 0 ? {} : _ref$projectionConfig, | ||
_ref$className = _ref.className, | ||
className = _ref$className === undefined ? "" : _ref$className, | ||
restProps = objectWithoutProperties(_ref, ["width", "height", "projection", "projectionConfig", "className"]); | ||
className = _ref$className === void 0 ? "" : _ref$className, | ||
restProps = _objectWithoutProperties(_ref, _excluded$8); | ||
return React.createElement( | ||
MapProvider, | ||
{ | ||
width: width, | ||
height: height, | ||
projection: projection, | ||
projectionConfig: projectionConfig | ||
}, | ||
React.createElement("svg", _extends({ | ||
viewBox: "0 0 " + width + " " + height, | ||
className: "rsm-svg " + className | ||
}, restProps)) | ||
); | ||
return /*#__PURE__*/React.createElement(MapProvider, { | ||
width: width, | ||
height: height, | ||
projection: projection, | ||
projectionConfig: projectionConfig | ||
}, /*#__PURE__*/React.createElement("svg", _extends({ | ||
viewBox: "0 0 ".concat(width, " ").concat(height), | ||
className: "rsm-svg ".concat(className) | ||
}, restProps))); | ||
}; | ||
@@ -216,3 +306,2 @@ | ||
} | ||
function fetchGeographies(url) { | ||
@@ -223,17 +312,18 @@ return fetch(url).then(function (res) { | ||
} | ||
return res.json(); | ||
}).catch(function (error) { | ||
})["catch"](function (error) { | ||
console.log("There was a problem when fetching the data: ", error); | ||
}); | ||
} | ||
function getFeatures(geographies, parseGeographies) { | ||
var isTopojson = geographies.type === "Topology"; | ||
if (!isTopojson) { | ||
return parseGeographies ? parseGeographies(geographies.features || geographies) : geographies.features || geographies; | ||
} | ||
var feats = feature(geographies, geographies.objects[Object.keys(geographies.objects)[0]]).features; | ||
return parseGeographies ? parseGeographies(feats) : feats; | ||
} | ||
function getMesh(geographies) { | ||
@@ -248,16 +338,23 @@ var isTopojson = geographies.type === "Topology"; | ||
}); | ||
return { outline: outline, borders: borders }; | ||
return { | ||
outline: outline, | ||
borders: borders | ||
}; | ||
} | ||
function prepareMesh(outline, borders, path) { | ||
return outline && borders ? { | ||
outline: _extends({}, outline, { rsmKey: "outline", svgPath: path(outline) }), | ||
borders: _extends({}, borders, { rsmKey: "borders", svgPath: path(borders) }) | ||
outline: _objectSpread2(_objectSpread2({}, outline), {}, { | ||
rsmKey: "outline", | ||
svgPath: path(outline) | ||
}), | ||
borders: _objectSpread2(_objectSpread2({}, borders), {}, { | ||
rsmKey: "borders", | ||
svgPath: path(borders) | ||
}) | ||
} : {}; | ||
} | ||
function prepareFeatures(geographies, path) { | ||
return geographies ? geographies.map(function (d, i) { | ||
return _extends({}, d, { | ||
rsmKey: "geo-" + i, | ||
return _objectSpread2(_objectSpread2({}, d), {}, { | ||
rsmKey: "geo-".concat(i), | ||
svgPath: path(d) | ||
@@ -267,3 +364,2 @@ }); | ||
} | ||
function createConnectorPath() { | ||
@@ -273,9 +369,7 @@ var dx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 30; | ||
var curve = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.5; | ||
var curvature = Array.isArray(curve) ? curve : [curve, curve]; | ||
var curveX = dx / 2 * curvature[0]; | ||
var curveY = dy / 2 * curvature[1]; | ||
return "M" + 0 + "," + 0 + " Q" + (-dx / 2 - curveX) + "," + (-dy / 2 + curveY) + " " + -dx + "," + -dy; | ||
return "M".concat(0, ",", 0, " Q", -dx / 2 - curveX, ",").concat(-dy / 2 + curveY, " ").concat(-dx, ",").concat(-dy); | ||
} | ||
function isString(geo) { | ||
@@ -293,3 +387,3 @@ return typeof geo === "string"; | ||
var _useState = useState({}), | ||
_useState2 = slicedToArray(_useState, 2), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
output = _useState2[0], | ||
@@ -299,4 +393,3 @@ setOutput = _useState2[1]; | ||
useEffect(function () { | ||
if (typeof window === "undefined") return; | ||
if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === "undefined") return; | ||
if (!geography) return; | ||
@@ -334,5 +427,11 @@ | ||
return { geographies: geographies, outline: outline, borders: borders }; | ||
return { | ||
geographies: geographies, | ||
outline: outline, | ||
borders: borders | ||
}; | ||
} | ||
var _excluded$7 = ["geography", "children", "parseGeographies", "className"]; | ||
var Geographies = function Geographies(_ref) { | ||
@@ -343,4 +442,4 @@ var geography = _ref.geography, | ||
_ref$className = _ref.className, | ||
className = _ref$className === undefined ? "" : _ref$className, | ||
restProps = objectWithoutProperties(_ref, ["geography", "children", "parseGeographies", "className"]); | ||
className = _ref$className === void 0 ? "" : _ref$className, | ||
restProps = _objectWithoutProperties(_ref, _excluded$7); | ||
@@ -351,3 +450,6 @@ var _useContext = useContext(MapContext), | ||
var _useGeographies = useGeographies({ geography: geography, parseGeographies: parseGeographies }), | ||
var _useGeographies = useGeographies({ | ||
geography: geography, | ||
parseGeographies: parseGeographies | ||
}), | ||
geographies = _useGeographies.geographies, | ||
@@ -357,7 +459,11 @@ outline = _useGeographies.outline, | ||
return React.createElement( | ||
"g", | ||
_extends({ className: "rsm-geographies " + className }, restProps), | ||
geographies && geographies.length > 0 && children({ geographies: geographies, outline: outline, borders: borders, path: path, projection: projection }) | ||
); | ||
return /*#__PURE__*/React.createElement("g", _extends({ | ||
className: "rsm-geographies ".concat(className) | ||
}, restProps), geographies && geographies.length > 0 && children({ | ||
geographies: geographies, | ||
outline: outline, | ||
borders: borders, | ||
path: path, | ||
projection: projection | ||
})); | ||
}; | ||
@@ -372,2 +478,4 @@ | ||
var _excluded$6 = ["geography", "onMouseEnter", "onMouseLeave", "onMouseDown", "onMouseUp", "onFocus", "onBlur", "style", "className"]; | ||
var Geography = function Geography(_ref) { | ||
@@ -382,9 +490,9 @@ var geography = _ref.geography, | ||
_ref$style = _ref.style, | ||
style = _ref$style === undefined ? {} : _ref$style, | ||
style = _ref$style === void 0 ? {} : _ref$style, | ||
_ref$className = _ref.className, | ||
className = _ref$className === undefined ? "" : _ref$className, | ||
restProps = objectWithoutProperties(_ref, ["geography", "onMouseEnter", "onMouseLeave", "onMouseDown", "onMouseUp", "onFocus", "onBlur", "style", "className"]); | ||
className = _ref$className === void 0 ? "" : _ref$className, | ||
restProps = _objectWithoutProperties(_ref, _excluded$6); | ||
var _useState = useState(false), | ||
_useState2 = slicedToArray(_useState, 2), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
isPressed = _useState2[0], | ||
@@ -394,3 +502,3 @@ setPressed = _useState2[1]; | ||
var _useState3 = useState(false), | ||
_useState4 = slicedToArray(_useState3, 2), | ||
_useState4 = _slicedToArray(_useState3, 2), | ||
isFocused = _useState4[0], | ||
@@ -431,5 +539,5 @@ setFocus = _useState4[1]; | ||
return React.createElement("path", _extends({ | ||
return /*#__PURE__*/React.createElement("path", _extends({ | ||
tabIndex: "0", | ||
className: "rsm-geography " + className, | ||
className: "rsm-geography ".concat(className), | ||
d: geography.svgPath, | ||
@@ -457,15 +565,16 @@ onMouseEnter: handleMouseEnter, | ||
}; | ||
var Geography$1 = memo(Geography); | ||
var _excluded$5 = ["fill", "stroke", "step", "className"]; | ||
var Graticule = function Graticule(_ref) { | ||
var _ref$fill = _ref.fill, | ||
fill = _ref$fill === undefined ? "transparent" : _ref$fill, | ||
fill = _ref$fill === void 0 ? "transparent" : _ref$fill, | ||
_ref$stroke = _ref.stroke, | ||
stroke = _ref$stroke === undefined ? "currentcolor" : _ref$stroke, | ||
stroke = _ref$stroke === void 0 ? "currentcolor" : _ref$stroke, | ||
_ref$step = _ref.step, | ||
step = _ref$step === undefined ? [10, 10] : _ref$step, | ||
step = _ref$step === void 0 ? [10, 10] : _ref$step, | ||
_ref$className = _ref.className, | ||
className = _ref$className === undefined ? "" : _ref$className, | ||
restProps = objectWithoutProperties(_ref, ["fill", "stroke", "step", "className"]); | ||
className = _ref$className === void 0 ? "" : _ref$className, | ||
restProps = _objectWithoutProperties(_ref, _excluded$5); | ||
@@ -475,7 +584,7 @@ var _useContext = useContext(MapContext), | ||
return React.createElement("path", _extends({ | ||
return /*#__PURE__*/React.createElement("path", _extends({ | ||
d: path(geoGraticule().step(step)()), | ||
fill: fill, | ||
stroke: stroke, | ||
className: "rsm-graticule " + className | ||
className: "rsm-graticule ".concat(className) | ||
}, restProps)); | ||
@@ -490,3 +599,2 @@ }; | ||
}; | ||
var Graticule$1 = memo(Graticule); | ||
@@ -501,7 +609,7 @@ | ||
_ref$translateExtent = _ref.translateExtent, | ||
translateExtent = _ref$translateExtent === undefined ? [[-Infinity, -Infinity], [Infinity, Infinity]] : _ref$translateExtent, | ||
translateExtent = _ref$translateExtent === void 0 ? [[-Infinity, -Infinity], [Infinity, Infinity]] : _ref$translateExtent, | ||
_ref$scaleExtent = _ref.scaleExtent, | ||
scaleExtent = _ref$scaleExtent === undefined ? [1, 8] : _ref$scaleExtent, | ||
scaleExtent = _ref$scaleExtent === void 0 ? [1, 8] : _ref$scaleExtent, | ||
_ref$zoom = _ref.zoom, | ||
zoom$1 = _ref$zoom === undefined ? 1 : _ref$zoom; | ||
zoom$1 = _ref$zoom === void 0 ? 1 : _ref$zoom; | ||
@@ -513,12 +621,20 @@ var _useContext = useContext(MapContext), | ||
var _center = slicedToArray(center, 2), | ||
var _center = _slicedToArray(center, 2), | ||
lon = _center[0], | ||
lat = _center[1]; | ||
var _useState = useState({ x: 0, y: 0, k: 1 }), | ||
_useState2 = slicedToArray(_useState, 2), | ||
var _useState = useState({ | ||
x: 0, | ||
y: 0, | ||
k: 1 | ||
}), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
position = _useState2[0], | ||
setPosition = _useState2[1]; | ||
var lastPosition = useRef({ x: 0, y: 0, k: 1 }); | ||
var lastPosition = useRef({ | ||
x: 0, | ||
y: 0, | ||
k: 1 | ||
}); | ||
var mapRef = useRef(); | ||
@@ -528,15 +644,15 @@ var zoomRef = useRef(); | ||
var _translateExtent = slicedToArray(translateExtent, 2), | ||
var _translateExtent = _slicedToArray(translateExtent, 2), | ||
a = _translateExtent[0], | ||
b = _translateExtent[1]; | ||
var _a = slicedToArray(a, 2), | ||
var _a = _slicedToArray(a, 2), | ||
a1 = _a[0], | ||
a2 = _a[1]; | ||
var _b = slicedToArray(b, 2), | ||
var _b = _slicedToArray(b, 2), | ||
b1 = _b[0], | ||
b2 = _b[1]; | ||
var _scaleExtent = slicedToArray(scaleExtent, 2), | ||
var _scaleExtent = _slicedToArray(scaleExtent, 2), | ||
minZoom = _scaleExtent[0], | ||
@@ -550,3 +666,6 @@ maxZoom = _scaleExtent[1]; | ||
if (!onMoveStart || bypassEvents.current) return; | ||
onMoveStart({ coordinates: projection.invert(getCoords(width, height, d3Event.transform)), zoom: d3Event.transform.k }, d3Event); | ||
onMoveStart({ | ||
coordinates: projection.invert(getCoords(width, height, d3Event.transform)), | ||
zoom: d3Event.transform.k | ||
}, d3Event); | ||
} | ||
@@ -558,6 +677,15 @@ | ||
sourceEvent = d3Event.sourceEvent; | ||
setPosition({ x: transform.x, y: transform.y, k: transform.k, dragging: sourceEvent }); | ||
setPosition({ | ||
x: transform.x, | ||
y: transform.y, | ||
k: transform.k, | ||
dragging: sourceEvent | ||
}); | ||
if (!onMove) return; | ||
onMove({ x: transform.x, y: transform.y, zoom: transform.k, dragging: sourceEvent }, d3Event); | ||
onMove({ | ||
x: transform.x, | ||
y: transform.y, | ||
zoom: transform.k, | ||
dragging: sourceEvent | ||
}, d3Event); | ||
} | ||
@@ -572,9 +700,16 @@ | ||
var _projection$invert = projection.invert(getCoords(width, height, d3Event.transform)), | ||
_projection$invert2 = slicedToArray(_projection$invert, 2), | ||
_projection$invert2 = _slicedToArray(_projection$invert, 2), | ||
x = _projection$invert2[0], | ||
y = _projection$invert2[1]; | ||
lastPosition.current = { x: x, y: y, k: d3Event.transform.k }; | ||
lastPosition.current = { | ||
x: x, | ||
y: y, | ||
k: d3Event.transform.k | ||
}; | ||
if (!onMoveEnd) return; | ||
onMoveEnd({ coordinates: [x, y], zoom: d3Event.transform.k }, d3Event); | ||
onMoveEnd({ | ||
coordinates: [x, y], | ||
zoom: d3Event.transform.k | ||
}, d3Event); | ||
} | ||
@@ -586,2 +721,3 @@ | ||
} | ||
return d3Event ? !d3Event.ctrlKey && !d3Event.button : false; | ||
@@ -591,10 +727,7 @@ } | ||
var zoom$1 = zoom().filter(filterFunc).scaleExtent([minZoom, maxZoom]).translateExtent([[a1, a2], [b1, b2]]).on("start", handleZoomStart).on("zoom", handleZoom).on("end", handleZoomEnd); | ||
zoomRef.current = zoom$1; | ||
svg.call(zoom$1); | ||
}, [width, height, a1, a2, b1, b2, minZoom, maxZoom, projection, onMoveStart, onMove, onMoveEnd, filterZoomEvent]); | ||
useEffect(function () { | ||
if (lon === lastPosition.current.x && lat === lastPosition.current.y && zoom$1 === lastPosition.current.k) return; | ||
var coords = projection([lon, lat]); | ||
@@ -604,27 +737,33 @@ var x = coords[0] * zoom$1; | ||
var svg = select(mapRef.current); | ||
bypassEvents.current = true; | ||
svg.call(zoomRef.current.transform, zoomIdentity.translate(width / 2 - x, height / 2 - y).scale(zoom$1)); | ||
setPosition({ x: width / 2 - x, y: height / 2 - y, k: zoom$1 }); | ||
lastPosition.current = { x: lon, y: lat, k: zoom$1 }; | ||
setPosition({ | ||
x: width / 2 - x, | ||
y: height / 2 - y, | ||
k: zoom$1 | ||
}); | ||
lastPosition.current = { | ||
x: lon, | ||
y: lat, | ||
k: zoom$1 | ||
}; | ||
}, [lon, lat, zoom$1, width, height, projection]); | ||
return { | ||
mapRef: mapRef, | ||
position: position, | ||
transformString: "translate(" + position.x + " " + position.y + ") scale(" + position.k + ")" | ||
transformString: "translate(".concat(position.x, " ").concat(position.y, ") scale(").concat(position.k, ")") | ||
}; | ||
} | ||
var _excluded$4 = ["center", "zoom", "minZoom", "maxZoom", "translateExtent", "filterZoomEvent", "onMoveStart", "onMove", "onMoveEnd", "className"]; | ||
var ZoomableGroup = function ZoomableGroup(_ref) { | ||
var _ref$center = _ref.center, | ||
center = _ref$center === undefined ? [0, 0] : _ref$center, | ||
center = _ref$center === void 0 ? [0, 0] : _ref$center, | ||
_ref$zoom = _ref.zoom, | ||
zoom = _ref$zoom === undefined ? 1 : _ref$zoom, | ||
zoom = _ref$zoom === void 0 ? 1 : _ref$zoom, | ||
_ref$minZoom = _ref.minZoom, | ||
minZoom = _ref$minZoom === undefined ? 1 : _ref$minZoom, | ||
minZoom = _ref$minZoom === void 0 ? 1 : _ref$minZoom, | ||
_ref$maxZoom = _ref.maxZoom, | ||
maxZoom = _ref$maxZoom === undefined ? 8 : _ref$maxZoom, | ||
maxZoom = _ref$maxZoom === void 0 ? 8 : _ref$maxZoom, | ||
translateExtent = _ref.translateExtent, | ||
@@ -636,3 +775,3 @@ filterZoomEvent = _ref.filterZoomEvent, | ||
className = _ref.className, | ||
restProps = objectWithoutProperties(_ref, ["center", "zoom", "minZoom", "maxZoom", "translateExtent", "filterZoomEvent", "onMoveStart", "onMove", "onMoveEnd", "className"]); | ||
restProps = _objectWithoutProperties(_ref, _excluded$4); | ||
@@ -656,8 +795,12 @@ var _useContext = useContext(MapContext), | ||
return React.createElement( | ||
"g", | ||
{ ref: mapRef }, | ||
React.createElement("rect", { width: width, height: height, fill: "transparent" }), | ||
React.createElement("g", _extends({ transform: transformString, className: "rsm-zoomable-group " + className }, restProps)) | ||
); | ||
return /*#__PURE__*/React.createElement("g", { | ||
ref: mapRef | ||
}, /*#__PURE__*/React.createElement("rect", { | ||
width: width, | ||
height: height, | ||
fill: "transparent" | ||
}), /*#__PURE__*/React.createElement("g", _extends({ | ||
transform: transformString, | ||
className: "rsm-zoomable-group ".concat(className) | ||
}, restProps))); | ||
}; | ||
@@ -677,14 +820,16 @@ | ||
var _excluded$3 = ["id", "fill", "stroke", "strokeWidth", "className"]; | ||
var Sphere = function Sphere(_ref) { | ||
var _ref$id = _ref.id, | ||
id = _ref$id === undefined ? "rsm-sphere" : _ref$id, | ||
id = _ref$id === void 0 ? "rsm-sphere" : _ref$id, | ||
_ref$fill = _ref.fill, | ||
fill = _ref$fill === undefined ? "transparent" : _ref$fill, | ||
fill = _ref$fill === void 0 ? "transparent" : _ref$fill, | ||
_ref$stroke = _ref.stroke, | ||
stroke = _ref$stroke === undefined ? "currentcolor" : _ref$stroke, | ||
stroke = _ref$stroke === void 0 ? "currentcolor" : _ref$stroke, | ||
_ref$strokeWidth = _ref.strokeWidth, | ||
strokeWidth = _ref$strokeWidth === undefined ? 0.5 : _ref$strokeWidth, | ||
strokeWidth = _ref$strokeWidth === void 0 ? 0.5 : _ref$strokeWidth, | ||
_ref$className = _ref.className, | ||
className = _ref$className === undefined ? "" : _ref$className, | ||
restProps = objectWithoutProperties(_ref, ["id", "fill", "stroke", "strokeWidth", "className"]); | ||
className = _ref$className === void 0 ? "" : _ref$className, | ||
restProps = _objectWithoutProperties(_ref, _excluded$3); | ||
@@ -695,25 +840,20 @@ var _useContext = useContext(MapContext), | ||
var spherePath = useMemo(function () { | ||
return path({ type: "Sphere" }); | ||
return path({ | ||
type: "Sphere" | ||
}); | ||
}, [path]); | ||
return React.createElement( | ||
Fragment, | ||
null, | ||
React.createElement( | ||
"defs", | ||
null, | ||
React.createElement( | ||
"clipPath", | ||
{ id: id }, | ||
React.createElement("path", { d: spherePath }) | ||
) | ||
), | ||
React.createElement("path", _extends({ | ||
d: spherePath, | ||
fill: fill, | ||
stroke: stroke, | ||
strokeWidth: strokeWidth, | ||
style: { pointerEvents: "none" }, | ||
className: "rsm-sphere " + className | ||
}, restProps)) | ||
); | ||
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", { | ||
id: id | ||
}, /*#__PURE__*/React.createElement("path", { | ||
d: spherePath | ||
}))), /*#__PURE__*/React.createElement("path", _extends({ | ||
d: spherePath, | ||
fill: fill, | ||
stroke: stroke, | ||
strokeWidth: strokeWidth, | ||
style: { | ||
pointerEvents: "none" | ||
}, | ||
className: "rsm-sphere ".concat(className) | ||
}, restProps))); | ||
}; | ||
@@ -728,5 +868,6 @@ | ||
}; | ||
var Sphere$1 = memo(Sphere); | ||
var _excluded$2 = ["coordinates", "children", "onMouseEnter", "onMouseLeave", "onMouseDown", "onMouseUp", "onFocus", "onBlur", "style", "className"]; | ||
var Marker = function Marker(_ref) { | ||
@@ -742,6 +883,6 @@ var coordinates = _ref.coordinates, | ||
_ref$style = _ref.style, | ||
style = _ref$style === undefined ? {} : _ref$style, | ||
style = _ref$style === void 0 ? {} : _ref$style, | ||
_ref$className = _ref.className, | ||
className = _ref$className === undefined ? "" : _ref$className, | ||
restProps = objectWithoutProperties(_ref, ["coordinates", "children", "onMouseEnter", "onMouseLeave", "onMouseDown", "onMouseUp", "onFocus", "onBlur", "style", "className"]); | ||
className = _ref$className === void 0 ? "" : _ref$className, | ||
restProps = _objectWithoutProperties(_ref, _excluded$2); | ||
@@ -752,3 +893,3 @@ var _useContext = useContext(MapContext), | ||
var _useState = useState(false), | ||
_useState2 = slicedToArray(_useState, 2), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
isPressed = _useState2[0], | ||
@@ -758,3 +899,3 @@ setPressed = _useState2[1]; | ||
var _useState3 = useState(false), | ||
_useState4 = slicedToArray(_useState3, 2), | ||
_useState4 = _slicedToArray(_useState3, 2), | ||
isFocused = _useState4[0], | ||
@@ -764,3 +905,3 @@ setFocus = _useState4[1]; | ||
var _projection = projection(coordinates), | ||
_projection2 = slicedToArray(_projection, 2), | ||
_projection2 = _slicedToArray(_projection, 2), | ||
x = _projection2[0], | ||
@@ -801,17 +942,13 @@ y = _projection2[1]; | ||
return React.createElement( | ||
"g", | ||
_extends({ | ||
transform: "translate(" + x + ", " + y + ")", | ||
className: "rsm-marker " + className, | ||
onMouseEnter: handleMouseEnter, | ||
onMouseLeave: handleMouseLeave, | ||
onFocus: handleFocus, | ||
onBlur: handleBlur, | ||
onMouseDown: handleMouseDown, | ||
onMouseUp: handleMouseUp, | ||
style: style[isPressed || isFocused ? isPressed ? "pressed" : "hover" : "default"] | ||
}, restProps), | ||
children | ||
); | ||
return /*#__PURE__*/React.createElement("g", _extends({ | ||
transform: "translate(".concat(x, ", ").concat(y, ")"), | ||
className: "rsm-marker ".concat(className), | ||
onMouseEnter: handleMouseEnter, | ||
onMouseLeave: handleMouseLeave, | ||
onFocus: handleFocus, | ||
onBlur: handleBlur, | ||
onMouseDown: handleMouseDown, | ||
onMouseUp: handleMouseUp, | ||
style: style[isPressed || isFocused ? isPressed ? "pressed" : "hover" : "default"] | ||
}, restProps), children); | ||
}; | ||
@@ -832,17 +969,19 @@ | ||
var _excluded$1 = ["from", "to", "coordinates", "stroke", "strokeWidth", "fill", "className"]; | ||
var Line = function Line(_ref) { | ||
var _ref$from = _ref.from, | ||
from = _ref$from === undefined ? [0, 0] : _ref$from, | ||
from = _ref$from === void 0 ? [0, 0] : _ref$from, | ||
_ref$to = _ref.to, | ||
to = _ref$to === undefined ? [0, 0] : _ref$to, | ||
to = _ref$to === void 0 ? [0, 0] : _ref$to, | ||
coordinates = _ref.coordinates, | ||
_ref$stroke = _ref.stroke, | ||
stroke = _ref$stroke === undefined ? "currentcolor" : _ref$stroke, | ||
stroke = _ref$stroke === void 0 ? "currentcolor" : _ref$stroke, | ||
_ref$strokeWidth = _ref.strokeWidth, | ||
strokeWidth = _ref$strokeWidth === undefined ? 3 : _ref$strokeWidth, | ||
strokeWidth = _ref$strokeWidth === void 0 ? 3 : _ref$strokeWidth, | ||
_ref$fill = _ref.fill, | ||
fill = _ref$fill === undefined ? "transparent" : _ref$fill, | ||
fill = _ref$fill === void 0 ? "transparent" : _ref$fill, | ||
_ref$className = _ref.className, | ||
className = _ref$className === undefined ? "" : _ref$className, | ||
restProps = objectWithoutProperties(_ref, ["from", "to", "coordinates", "stroke", "strokeWidth", "fill", "className"]); | ||
className = _ref$className === void 0 ? "" : _ref$className, | ||
restProps = _objectWithoutProperties(_ref, _excluded$1); | ||
@@ -856,6 +995,5 @@ var _useContext = useContext(MapContext), | ||
}; | ||
return React.createElement("path", _extends({ | ||
return /*#__PURE__*/React.createElement("path", _extends({ | ||
d: path(lineData), | ||
className: "rsm-line " + className, | ||
className: "rsm-line ".concat(className), | ||
stroke: stroke, | ||
@@ -877,2 +1015,4 @@ strokeWidth: strokeWidth, | ||
var _excluded = ["subject", "children", "connectorProps", "dx", "dy", "curve", "className"]; | ||
var Annotation = function Annotation(_ref) { | ||
@@ -883,10 +1023,10 @@ var subject = _ref.subject, | ||
_ref$dx = _ref.dx, | ||
dx = _ref$dx === undefined ? 30 : _ref$dx, | ||
dx = _ref$dx === void 0 ? 30 : _ref$dx, | ||
_ref$dy = _ref.dy, | ||
dy = _ref$dy === undefined ? 30 : _ref$dy, | ||
dy = _ref$dy === void 0 ? 30 : _ref$dy, | ||
_ref$curve = _ref.curve, | ||
curve = _ref$curve === undefined ? 0 : _ref$curve, | ||
curve = _ref$curve === void 0 ? 0 : _ref$curve, | ||
_ref$className = _ref.className, | ||
className = _ref$className === undefined ? "" : _ref$className, | ||
restProps = objectWithoutProperties(_ref, ["subject", "children", "connectorProps", "dx", "dy", "curve", "className"]); | ||
className = _ref$className === void 0 ? "" : _ref$className, | ||
restProps = _objectWithoutProperties(_ref, _excluded); | ||
@@ -897,3 +1037,3 @@ var _useContext = useContext(MapContext), | ||
var _projection = projection(subject), | ||
_projection2 = slicedToArray(_projection, 2), | ||
_projection2 = _slicedToArray(_projection, 2), | ||
x = _projection2[0], | ||
@@ -903,12 +1043,10 @@ y = _projection2[1]; | ||
var connectorPath = createConnectorPath(dx, dy, curve); | ||
return React.createElement( | ||
"g", | ||
_extends({ | ||
transform: "translate(" + (x + dx) + ", " + (y + dy) + ")", | ||
className: "rsm-annotation " + className | ||
}, restProps), | ||
React.createElement("path", _extends({ d: connectorPath, fill: "transparent", stroke: "#000" }, connectorProps)), | ||
children | ||
); | ||
return /*#__PURE__*/React.createElement("g", _extends({ | ||
transform: "translate(".concat(x + dx, ", ").concat(y + dy, ")"), | ||
className: "rsm-annotation ".concat(className) | ||
}, restProps), /*#__PURE__*/React.createElement("path", _extends({ | ||
d: connectorPath, | ||
fill: "transparent", | ||
stroke: "#000" | ||
}, connectorProps)), children); | ||
}; | ||
@@ -915,0 +1053,0 @@ |
@@ -1,103 +0,192 @@ | ||
'use strict'; | ||
import React, { createContext, useMemo, useCallback, useContext, useState, useEffect, memo, useRef, Fragment } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import * as d3Geo from 'd3-geo'; | ||
import { geoGraticule } from 'd3-geo'; | ||
import { feature, mesh } from 'topojson-client'; | ||
import { zoom, zoomIdentity } from 'd3-zoom'; | ||
import { select } from 'd3-selection'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
if (Object.getOwnPropertySymbols) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
enumerableOnly && (symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
})), keys.push.apply(keys, symbols); | ||
} | ||
var React = require('react'); | ||
var React__default = _interopDefault(React); | ||
var PropTypes = _interopDefault(require('prop-types')); | ||
var d3Geo = require('d3-geo'); | ||
var topojsonClient = require('topojson-client'); | ||
var d3Zoom = require('d3-zoom'); | ||
var d3Selection = require('d3-selection'); | ||
return keys; | ||
} | ||
var _extends = Object.assign || function (target) { | ||
function _objectSpread2(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
var source = null != arguments[i] ? arguments[i] : {}; | ||
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
return target; | ||
} | ||
function _typeof(obj) { | ||
"@babel/helpers - typeof"; | ||
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { | ||
return typeof obj; | ||
} : function (obj) { | ||
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}, _typeof(obj); | ||
} | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _extends() { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {}; | ||
var target = {}; | ||
var sourceKeys = Object.keys(source); | ||
var key, i; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
target[key] = source[key]; | ||
} | ||
return target; | ||
}; | ||
} | ||
var objectWithoutProperties = function (obj, keys) { | ||
var target = {}; | ||
function _objectWithoutProperties(source, excluded) { | ||
if (source == null) return {}; | ||
for (var i in obj) { | ||
if (keys.indexOf(i) >= 0) continue; | ||
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; | ||
target[i] = obj[i]; | ||
var target = _objectWithoutPropertiesLoose(source, excluded); | ||
var key, i; | ||
if (Object.getOwnPropertySymbols) { | ||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source); | ||
for (i = 0; i < sourceSymbolKeys.length; i++) { | ||
key = sourceSymbolKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; | ||
target[key] = source[key]; | ||
} | ||
} | ||
return target; | ||
}; | ||
} | ||
var slicedToArray = function () { | ||
function sliceIterator(arr, i) { | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
} | ||
function _arrayWithHoles(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
} | ||
function _iterableToArrayLimit(arr, i) { | ||
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; | ||
if (_i == null) return; | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _s, _e; | ||
try { | ||
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
if (!_n && _i["return"] != null) _i["return"](); | ||
} finally { | ||
try { | ||
if (!_n && _i["return"]) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
if (_d) throw _e; | ||
} | ||
return _arr; | ||
} | ||
return function (arr, i) { | ||
if (Array.isArray(arr)) { | ||
return arr; | ||
} else if (Symbol.iterator in Object(arr)) { | ||
return sliceIterator(arr, i); | ||
} else { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
} | ||
}; | ||
}(); | ||
return _arr; | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
var _excluded$9 = ["width", "height", "projection", "projectionConfig"]; | ||
var geoPath = d3Geo.geoPath, | ||
projections = objectWithoutProperties(d3Geo, ["geoPath"]); | ||
projections = _objectWithoutProperties(d3Geo, ["geoPath"]); | ||
var MapContext = createContext(); | ||
var MapContext = React.createContext(); | ||
var makeProjection = function makeProjection(_ref) { | ||
var _ref$projectionConfig = _ref.projectionConfig, | ||
projectionConfig = _ref$projectionConfig === undefined ? {} : _ref$projectionConfig, | ||
projectionConfig = _ref$projectionConfig === void 0 ? {} : _ref$projectionConfig, | ||
_ref$projection = _ref.projection, | ||
projection = _ref$projection === undefined ? "geoEqualEarth" : _ref$projection, | ||
projection = _ref$projection === void 0 ? "geoEqualEarth" : _ref$projection, | ||
_ref$width = _ref.width, | ||
width = _ref$width === undefined ? 800 : _ref$width, | ||
width = _ref$width === void 0 ? 800 : _ref$width, | ||
_ref$height = _ref.height, | ||
height = _ref$height === undefined ? 600 : _ref$height; | ||
height = _ref$height === void 0 ? 600 : _ref$height; | ||
var isFunc = typeof projection === "function"; | ||
if (isFunc) return projection; | ||
var proj = projections[projection]().translate([width / 2, height / 2]); | ||
var supported = [proj.center ? "center" : null, proj.rotate ? "rotate" : null, proj.scale ? "scale" : null, proj.parallels ? "parallels" : null]; | ||
supported.forEach(function (d) { | ||
@@ -107,3 +196,2 @@ if (!d) return; | ||
}); | ||
return proj; | ||
@@ -117,6 +205,6 @@ }; | ||
projectionConfig = _ref2.projectionConfig, | ||
restProps = objectWithoutProperties(_ref2, ["width", "height", "projection", "projectionConfig"]); | ||
restProps = _objectWithoutProperties(_ref2, _excluded$9); | ||
var _ref3 = projectionConfig.center || [], | ||
_ref4 = slicedToArray(_ref3, 2), | ||
_ref4 = _slicedToArray(_ref3, 2), | ||
cx = _ref4[0], | ||
@@ -126,3 +214,3 @@ cy = _ref4[1]; | ||
var _ref5 = projectionConfig.rotate || [], | ||
_ref6 = slicedToArray(_ref5, 3), | ||
_ref6 = _slicedToArray(_ref5, 3), | ||
rx = _ref6[0], | ||
@@ -133,3 +221,3 @@ ry = _ref6[1], | ||
var _ref7 = projectionConfig.parallels || [], | ||
_ref8 = slicedToArray(_ref7, 2), | ||
_ref8 = _slicedToArray(_ref7, 2), | ||
p1 = _ref8[0], | ||
@@ -139,4 +227,3 @@ p2 = _ref8[1]; | ||
var s = projectionConfig.scale || null; | ||
var projMemo = React.useMemo(function () { | ||
var projMemo = useMemo(function () { | ||
return makeProjection({ | ||
@@ -154,6 +241,4 @@ projectionConfig: { | ||
}, [width, height, projection, cx, cy, rx, ry, rz, p1, p2, s]); | ||
var proj = React.useCallback(projMemo, [projMemo]); | ||
var value = React.useMemo(function () { | ||
var proj = useCallback(projMemo, [projMemo]); | ||
var value = useMemo(function () { | ||
return { | ||
@@ -166,4 +251,5 @@ width: width, | ||
}, [width, height, proj]); | ||
return React__default.createElement(MapContext.Provider, _extends({ value: value }, restProps)); | ||
return /*#__PURE__*/React.createElement(MapContext.Provider, _extends({ | ||
value: value | ||
}, restProps)); | ||
}; | ||
@@ -178,28 +264,26 @@ | ||
var _excluded$8 = ["width", "height", "projection", "projectionConfig", "className"]; | ||
var ComposableMap = function ComposableMap(_ref) { | ||
var _ref$width = _ref.width, | ||
width = _ref$width === undefined ? 800 : _ref$width, | ||
width = _ref$width === void 0 ? 800 : _ref$width, | ||
_ref$height = _ref.height, | ||
height = _ref$height === undefined ? 600 : _ref$height, | ||
height = _ref$height === void 0 ? 600 : _ref$height, | ||
_ref$projection = _ref.projection, | ||
projection = _ref$projection === undefined ? "geoEqualEarth" : _ref$projection, | ||
projection = _ref$projection === void 0 ? "geoEqualEarth" : _ref$projection, | ||
_ref$projectionConfig = _ref.projectionConfig, | ||
projectionConfig = _ref$projectionConfig === undefined ? {} : _ref$projectionConfig, | ||
projectionConfig = _ref$projectionConfig === void 0 ? {} : _ref$projectionConfig, | ||
_ref$className = _ref.className, | ||
className = _ref$className === undefined ? "" : _ref$className, | ||
restProps = objectWithoutProperties(_ref, ["width", "height", "projection", "projectionConfig", "className"]); | ||
className = _ref$className === void 0 ? "" : _ref$className, | ||
restProps = _objectWithoutProperties(_ref, _excluded$8); | ||
return React__default.createElement( | ||
MapProvider, | ||
{ | ||
width: width, | ||
height: height, | ||
projection: projection, | ||
projectionConfig: projectionConfig | ||
}, | ||
React__default.createElement("svg", _extends({ | ||
viewBox: "0 0 " + width + " " + height, | ||
className: "rsm-svg " + className | ||
}, restProps)) | ||
); | ||
return /*#__PURE__*/React.createElement(MapProvider, { | ||
width: width, | ||
height: height, | ||
projection: projection, | ||
projectionConfig: projectionConfig | ||
}, /*#__PURE__*/React.createElement("svg", _extends({ | ||
viewBox: "0 0 ".concat(width, " ").concat(height), | ||
className: "rsm-svg ".concat(className) | ||
}, restProps))); | ||
}; | ||
@@ -220,3 +304,2 @@ | ||
} | ||
function fetchGeographies(url) { | ||
@@ -227,40 +310,48 @@ return fetch(url).then(function (res) { | ||
} | ||
return res.json(); | ||
}).catch(function (error) { | ||
})["catch"](function (error) { | ||
console.log("There was a problem when fetching the data: ", error); | ||
}); | ||
} | ||
function getFeatures(geographies, parseGeographies) { | ||
var isTopojson = geographies.type === "Topology"; | ||
if (!isTopojson) { | ||
return parseGeographies ? parseGeographies(geographies.features || geographies) : geographies.features || geographies; | ||
} | ||
var feats = topojsonClient.feature(geographies, geographies.objects[Object.keys(geographies.objects)[0]]).features; | ||
var feats = feature(geographies, geographies.objects[Object.keys(geographies.objects)[0]]).features; | ||
return parseGeographies ? parseGeographies(feats) : feats; | ||
} | ||
function getMesh(geographies) { | ||
var isTopojson = geographies.type === "Topology"; | ||
if (!isTopojson) return null; | ||
var outline = topojsonClient.mesh(geographies, geographies.objects[Object.keys(geographies.objects)[0]], function (a, b) { | ||
var outline = mesh(geographies, geographies.objects[Object.keys(geographies.objects)[0]], function (a, b) { | ||
return a === b; | ||
}); | ||
var borders = topojsonClient.mesh(geographies, geographies.objects[Object.keys(geographies.objects)[0]], function (a, b) { | ||
var borders = mesh(geographies, geographies.objects[Object.keys(geographies.objects)[0]], function (a, b) { | ||
return a !== b; | ||
}); | ||
return { outline: outline, borders: borders }; | ||
return { | ||
outline: outline, | ||
borders: borders | ||
}; | ||
} | ||
function prepareMesh(outline, borders, path) { | ||
return outline && borders ? { | ||
outline: _extends({}, outline, { rsmKey: "outline", svgPath: path(outline) }), | ||
borders: _extends({}, borders, { rsmKey: "borders", svgPath: path(borders) }) | ||
outline: _objectSpread2(_objectSpread2({}, outline), {}, { | ||
rsmKey: "outline", | ||
svgPath: path(outline) | ||
}), | ||
borders: _objectSpread2(_objectSpread2({}, borders), {}, { | ||
rsmKey: "borders", | ||
svgPath: path(borders) | ||
}) | ||
} : {}; | ||
} | ||
function prepareFeatures(geographies, path) { | ||
return geographies ? geographies.map(function (d, i) { | ||
return _extends({}, d, { | ||
rsmKey: "geo-" + i, | ||
return _objectSpread2(_objectSpread2({}, d), {}, { | ||
rsmKey: "geo-".concat(i), | ||
svgPath: path(d) | ||
@@ -270,3 +361,2 @@ }); | ||
} | ||
function createConnectorPath() { | ||
@@ -276,9 +366,7 @@ var dx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 30; | ||
var curve = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.5; | ||
var curvature = Array.isArray(curve) ? curve : [curve, curve]; | ||
var curveX = dx / 2 * curvature[0]; | ||
var curveY = dy / 2 * curvature[1]; | ||
return "M" + 0 + "," + 0 + " Q" + (-dx / 2 - curveX) + "," + (-dy / 2 + curveY) + " " + -dx + "," + -dy; | ||
return "M".concat(0, ",", 0, " Q", -dx / 2 - curveX, ",").concat(-dy / 2 + curveY, " ").concat(-dx, ",").concat(-dy); | ||
} | ||
function isString(geo) { | ||
@@ -292,13 +380,12 @@ return typeof geo === "string"; | ||
var _useContext = React.useContext(MapContext), | ||
var _useContext = useContext(MapContext), | ||
path = _useContext.path; | ||
var _useState = React.useState({}), | ||
_useState2 = slicedToArray(_useState, 2), | ||
var _useState = useState({}), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
output = _useState2[0], | ||
setOutput = _useState2[1]; | ||
React.useEffect(function () { | ||
if (typeof window === "undefined") return; | ||
useEffect(function () { | ||
if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === "undefined") return; | ||
if (!geography) return; | ||
@@ -323,3 +410,3 @@ | ||
var _useMemo = React.useMemo(function () { | ||
var _useMemo = useMemo(function () { | ||
var mesh = output.mesh || {}; | ||
@@ -337,5 +424,11 @@ var preparedMesh = prepareMesh(mesh.outline, mesh.borders, path); | ||
return { geographies: geographies, outline: outline, borders: borders }; | ||
return { | ||
geographies: geographies, | ||
outline: outline, | ||
borders: borders | ||
}; | ||
} | ||
var _excluded$7 = ["geography", "children", "parseGeographies", "className"]; | ||
var Geographies = function Geographies(_ref) { | ||
@@ -346,10 +439,13 @@ var geography = _ref.geography, | ||
_ref$className = _ref.className, | ||
className = _ref$className === undefined ? "" : _ref$className, | ||
restProps = objectWithoutProperties(_ref, ["geography", "children", "parseGeographies", "className"]); | ||
className = _ref$className === void 0 ? "" : _ref$className, | ||
restProps = _objectWithoutProperties(_ref, _excluded$7); | ||
var _useContext = React.useContext(MapContext), | ||
var _useContext = useContext(MapContext), | ||
path = _useContext.path, | ||
projection = _useContext.projection; | ||
var _useGeographies = useGeographies({ geography: geography, parseGeographies: parseGeographies }), | ||
var _useGeographies = useGeographies({ | ||
geography: geography, | ||
parseGeographies: parseGeographies | ||
}), | ||
geographies = _useGeographies.geographies, | ||
@@ -359,7 +455,11 @@ outline = _useGeographies.outline, | ||
return React__default.createElement( | ||
"g", | ||
_extends({ className: "rsm-geographies " + className }, restProps), | ||
geographies && geographies.length > 0 && children({ geographies: geographies, outline: outline, borders: borders, path: path, projection: projection }) | ||
); | ||
return /*#__PURE__*/React.createElement("g", _extends({ | ||
className: "rsm-geographies ".concat(className) | ||
}, restProps), geographies && geographies.length > 0 && children({ | ||
geographies: geographies, | ||
outline: outline, | ||
borders: borders, | ||
path: path, | ||
projection: projection | ||
})); | ||
}; | ||
@@ -374,2 +474,4 @@ | ||
var _excluded$6 = ["geography", "onMouseEnter", "onMouseLeave", "onMouseDown", "onMouseUp", "onFocus", "onBlur", "style", "className"]; | ||
var Geography = function Geography(_ref) { | ||
@@ -384,14 +486,14 @@ var geography = _ref.geography, | ||
_ref$style = _ref.style, | ||
style = _ref$style === undefined ? {} : _ref$style, | ||
style = _ref$style === void 0 ? {} : _ref$style, | ||
_ref$className = _ref.className, | ||
className = _ref$className === undefined ? "" : _ref$className, | ||
restProps = objectWithoutProperties(_ref, ["geography", "onMouseEnter", "onMouseLeave", "onMouseDown", "onMouseUp", "onFocus", "onBlur", "style", "className"]); | ||
className = _ref$className === void 0 ? "" : _ref$className, | ||
restProps = _objectWithoutProperties(_ref, _excluded$6); | ||
var _useState = React.useState(false), | ||
_useState2 = slicedToArray(_useState, 2), | ||
var _useState = useState(false), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
isPressed = _useState2[0], | ||
setPressed = _useState2[1]; | ||
var _useState3 = React.useState(false), | ||
_useState4 = slicedToArray(_useState3, 2), | ||
var _useState3 = useState(false), | ||
_useState4 = _slicedToArray(_useState3, 2), | ||
isFocused = _useState4[0], | ||
@@ -432,5 +534,5 @@ setFocus = _useState4[1]; | ||
return React__default.createElement("path", _extends({ | ||
return /*#__PURE__*/React.createElement("path", _extends({ | ||
tabIndex: "0", | ||
className: "rsm-geography " + className, | ||
className: "rsm-geography ".concat(className), | ||
d: geography.svgPath, | ||
@@ -458,24 +560,25 @@ onMouseEnter: handleMouseEnter, | ||
}; | ||
var Geography$1 = memo(Geography); | ||
var Geography$1 = React.memo(Geography); | ||
var _excluded$5 = ["fill", "stroke", "step", "className"]; | ||
var Graticule = function Graticule(_ref) { | ||
var _ref$fill = _ref.fill, | ||
fill = _ref$fill === undefined ? "transparent" : _ref$fill, | ||
fill = _ref$fill === void 0 ? "transparent" : _ref$fill, | ||
_ref$stroke = _ref.stroke, | ||
stroke = _ref$stroke === undefined ? "currentcolor" : _ref$stroke, | ||
stroke = _ref$stroke === void 0 ? "currentcolor" : _ref$stroke, | ||
_ref$step = _ref.step, | ||
step = _ref$step === undefined ? [10, 10] : _ref$step, | ||
step = _ref$step === void 0 ? [10, 10] : _ref$step, | ||
_ref$className = _ref.className, | ||
className = _ref$className === undefined ? "" : _ref$className, | ||
restProps = objectWithoutProperties(_ref, ["fill", "stroke", "step", "className"]); | ||
className = _ref$className === void 0 ? "" : _ref$className, | ||
restProps = _objectWithoutProperties(_ref, _excluded$5); | ||
var _useContext = React.useContext(MapContext), | ||
var _useContext = useContext(MapContext), | ||
path = _useContext.path; | ||
return React__default.createElement("path", _extends({ | ||
d: path(d3Geo.geoGraticule().step(step)()), | ||
return /*#__PURE__*/React.createElement("path", _extends({ | ||
d: path(geoGraticule().step(step)()), | ||
fill: fill, | ||
stroke: stroke, | ||
className: "rsm-graticule " + className | ||
className: "rsm-graticule ".concat(className) | ||
}, restProps)); | ||
@@ -490,5 +593,4 @@ }; | ||
}; | ||
var Graticule$1 = memo(Graticule); | ||
var Graticule$1 = React.memo(Graticule); | ||
function useZoomPan(_ref) { | ||
@@ -501,9 +603,9 @@ var center = _ref.center, | ||
_ref$translateExtent = _ref.translateExtent, | ||
translateExtent = _ref$translateExtent === undefined ? [[-Infinity, -Infinity], [Infinity, Infinity]] : _ref$translateExtent, | ||
translateExtent = _ref$translateExtent === void 0 ? [[-Infinity, -Infinity], [Infinity, Infinity]] : _ref$translateExtent, | ||
_ref$scaleExtent = _ref.scaleExtent, | ||
scaleExtent = _ref$scaleExtent === undefined ? [1, 8] : _ref$scaleExtent, | ||
scaleExtent = _ref$scaleExtent === void 0 ? [1, 8] : _ref$scaleExtent, | ||
_ref$zoom = _ref.zoom, | ||
zoom = _ref$zoom === undefined ? 1 : _ref$zoom; | ||
zoom$1 = _ref$zoom === void 0 ? 1 : _ref$zoom; | ||
var _useContext = React.useContext(MapContext), | ||
var _useContext = useContext(MapContext), | ||
width = _useContext.width, | ||
@@ -513,38 +615,49 @@ height = _useContext.height, | ||
var _center = slicedToArray(center, 2), | ||
var _center = _slicedToArray(center, 2), | ||
lon = _center[0], | ||
lat = _center[1]; | ||
var _useState = React.useState({ x: 0, y: 0, k: 1 }), | ||
_useState2 = slicedToArray(_useState, 2), | ||
var _useState = useState({ | ||
x: 0, | ||
y: 0, | ||
k: 1 | ||
}), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
position = _useState2[0], | ||
setPosition = _useState2[1]; | ||
var lastPosition = React.useRef({ x: 0, y: 0, k: 1 }); | ||
var mapRef = React.useRef(); | ||
var zoomRef = React.useRef(); | ||
var bypassEvents = React.useRef(false); | ||
var lastPosition = useRef({ | ||
x: 0, | ||
y: 0, | ||
k: 1 | ||
}); | ||
var mapRef = useRef(); | ||
var zoomRef = useRef(); | ||
var bypassEvents = useRef(false); | ||
var _translateExtent = slicedToArray(translateExtent, 2), | ||
var _translateExtent = _slicedToArray(translateExtent, 2), | ||
a = _translateExtent[0], | ||
b = _translateExtent[1]; | ||
var _a = slicedToArray(a, 2), | ||
var _a = _slicedToArray(a, 2), | ||
a1 = _a[0], | ||
a2 = _a[1]; | ||
var _b = slicedToArray(b, 2), | ||
var _b = _slicedToArray(b, 2), | ||
b1 = _b[0], | ||
b2 = _b[1]; | ||
var _scaleExtent = slicedToArray(scaleExtent, 2), | ||
var _scaleExtent = _slicedToArray(scaleExtent, 2), | ||
minZoom = _scaleExtent[0], | ||
maxZoom = _scaleExtent[1]; | ||
React.useEffect(function () { | ||
var svg = d3Selection.select(mapRef.current); | ||
useEffect(function () { | ||
var svg = select(mapRef.current); | ||
function handleZoomStart(d3Event) { | ||
if (!onMoveStart || bypassEvents.current) return; | ||
onMoveStart({ coordinates: projection.invert(getCoords(width, height, d3Event.transform)), zoom: d3Event.transform.k }, d3Event); | ||
onMoveStart({ | ||
coordinates: projection.invert(getCoords(width, height, d3Event.transform)), | ||
zoom: d3Event.transform.k | ||
}, d3Event); | ||
} | ||
@@ -556,6 +669,15 @@ | ||
sourceEvent = d3Event.sourceEvent; | ||
setPosition({ x: transform.x, y: transform.y, k: transform.k, dragging: sourceEvent }); | ||
setPosition({ | ||
x: transform.x, | ||
y: transform.y, | ||
k: transform.k, | ||
dragging: sourceEvent | ||
}); | ||
if (!onMove) return; | ||
onMove({ x: transform.x, y: transform.y, zoom: transform.k, dragging: sourceEvent }, d3Event); | ||
onMove({ | ||
x: transform.x, | ||
y: transform.y, | ||
zoom: transform.k, | ||
dragging: sourceEvent | ||
}, d3Event); | ||
} | ||
@@ -570,9 +692,16 @@ | ||
var _projection$invert = projection.invert(getCoords(width, height, d3Event.transform)), | ||
_projection$invert2 = slicedToArray(_projection$invert, 2), | ||
_projection$invert2 = _slicedToArray(_projection$invert, 2), | ||
x = _projection$invert2[0], | ||
y = _projection$invert2[1]; | ||
lastPosition.current = { x: x, y: y, k: d3Event.transform.k }; | ||
lastPosition.current = { | ||
x: x, | ||
y: y, | ||
k: d3Event.transform.k | ||
}; | ||
if (!onMoveEnd) return; | ||
onMoveEnd({ coordinates: [x, y], zoom: d3Event.transform.k }, d3Event); | ||
onMoveEnd({ | ||
coordinates: [x, y], | ||
zoom: d3Event.transform.k | ||
}, d3Event); | ||
} | ||
@@ -584,43 +713,47 @@ | ||
} | ||
return d3Event ? !d3Event.ctrlKey && !d3Event.button : false; | ||
} | ||
var zoom = d3Zoom.zoom().filter(filterFunc).scaleExtent([minZoom, maxZoom]).translateExtent([[a1, a2], [b1, b2]]).on("start", handleZoomStart).on("zoom", handleZoom).on("end", handleZoomEnd); | ||
zoomRef.current = zoom; | ||
svg.call(zoom); | ||
var zoom$1 = zoom().filter(filterFunc).scaleExtent([minZoom, maxZoom]).translateExtent([[a1, a2], [b1, b2]]).on("start", handleZoomStart).on("zoom", handleZoom).on("end", handleZoomEnd); | ||
zoomRef.current = zoom$1; | ||
svg.call(zoom$1); | ||
}, [width, height, a1, a2, b1, b2, minZoom, maxZoom, projection, onMoveStart, onMove, onMoveEnd, filterZoomEvent]); | ||
React.useEffect(function () { | ||
if (lon === lastPosition.current.x && lat === lastPosition.current.y && zoom === lastPosition.current.k) return; | ||
useEffect(function () { | ||
if (lon === lastPosition.current.x && lat === lastPosition.current.y && zoom$1 === lastPosition.current.k) return; | ||
var coords = projection([lon, lat]); | ||
var x = coords[0] * zoom; | ||
var y = coords[1] * zoom; | ||
var svg = d3Selection.select(mapRef.current); | ||
var x = coords[0] * zoom$1; | ||
var y = coords[1] * zoom$1; | ||
var svg = select(mapRef.current); | ||
bypassEvents.current = true; | ||
svg.call(zoomRef.current.transform, d3Zoom.zoomIdentity.translate(width / 2 - x, height / 2 - y).scale(zoom)); | ||
setPosition({ x: width / 2 - x, y: height / 2 - y, k: zoom }); | ||
lastPosition.current = { x: lon, y: lat, k: zoom }; | ||
}, [lon, lat, zoom, width, height, projection]); | ||
svg.call(zoomRef.current.transform, zoomIdentity.translate(width / 2 - x, height / 2 - y).scale(zoom$1)); | ||
setPosition({ | ||
x: width / 2 - x, | ||
y: height / 2 - y, | ||
k: zoom$1 | ||
}); | ||
lastPosition.current = { | ||
x: lon, | ||
y: lat, | ||
k: zoom$1 | ||
}; | ||
}, [lon, lat, zoom$1, width, height, projection]); | ||
return { | ||
mapRef: mapRef, | ||
position: position, | ||
transformString: "translate(" + position.x + " " + position.y + ") scale(" + position.k + ")" | ||
transformString: "translate(".concat(position.x, " ").concat(position.y, ") scale(").concat(position.k, ")") | ||
}; | ||
} | ||
var _excluded$4 = ["center", "zoom", "minZoom", "maxZoom", "translateExtent", "filterZoomEvent", "onMoveStart", "onMove", "onMoveEnd", "className"]; | ||
var ZoomableGroup = function ZoomableGroup(_ref) { | ||
var _ref$center = _ref.center, | ||
center = _ref$center === undefined ? [0, 0] : _ref$center, | ||
center = _ref$center === void 0 ? [0, 0] : _ref$center, | ||
_ref$zoom = _ref.zoom, | ||
zoom = _ref$zoom === undefined ? 1 : _ref$zoom, | ||
zoom = _ref$zoom === void 0 ? 1 : _ref$zoom, | ||
_ref$minZoom = _ref.minZoom, | ||
minZoom = _ref$minZoom === undefined ? 1 : _ref$minZoom, | ||
minZoom = _ref$minZoom === void 0 ? 1 : _ref$minZoom, | ||
_ref$maxZoom = _ref.maxZoom, | ||
maxZoom = _ref$maxZoom === undefined ? 8 : _ref$maxZoom, | ||
maxZoom = _ref$maxZoom === void 0 ? 8 : _ref$maxZoom, | ||
translateExtent = _ref.translateExtent, | ||
@@ -632,5 +765,5 @@ filterZoomEvent = _ref.filterZoomEvent, | ||
className = _ref.className, | ||
restProps = objectWithoutProperties(_ref, ["center", "zoom", "minZoom", "maxZoom", "translateExtent", "filterZoomEvent", "onMoveStart", "onMove", "onMoveEnd", "className"]); | ||
restProps = _objectWithoutProperties(_ref, _excluded$4); | ||
var _useContext = React.useContext(MapContext), | ||
var _useContext = useContext(MapContext), | ||
width = _useContext.width, | ||
@@ -652,8 +785,12 @@ height = _useContext.height; | ||
return React__default.createElement( | ||
"g", | ||
{ ref: mapRef }, | ||
React__default.createElement("rect", { width: width, height: height, fill: "transparent" }), | ||
React__default.createElement("g", _extends({ transform: transformString, className: "rsm-zoomable-group " + className }, restProps)) | ||
); | ||
return /*#__PURE__*/React.createElement("g", { | ||
ref: mapRef | ||
}, /*#__PURE__*/React.createElement("rect", { | ||
width: width, | ||
height: height, | ||
fill: "transparent" | ||
}), /*#__PURE__*/React.createElement("g", _extends({ | ||
transform: transformString, | ||
className: "rsm-zoomable-group ".concat(className) | ||
}, restProps))); | ||
}; | ||
@@ -673,42 +810,39 @@ | ||
var _excluded$3 = ["id", "fill", "stroke", "strokeWidth", "className"]; | ||
var Sphere = function Sphere(_ref) { | ||
var _ref$id = _ref.id, | ||
id = _ref$id === undefined ? "rsm-sphere" : _ref$id, | ||
id = _ref$id === void 0 ? "rsm-sphere" : _ref$id, | ||
_ref$fill = _ref.fill, | ||
fill = _ref$fill === undefined ? "transparent" : _ref$fill, | ||
fill = _ref$fill === void 0 ? "transparent" : _ref$fill, | ||
_ref$stroke = _ref.stroke, | ||
stroke = _ref$stroke === undefined ? "currentcolor" : _ref$stroke, | ||
stroke = _ref$stroke === void 0 ? "currentcolor" : _ref$stroke, | ||
_ref$strokeWidth = _ref.strokeWidth, | ||
strokeWidth = _ref$strokeWidth === undefined ? 0.5 : _ref$strokeWidth, | ||
strokeWidth = _ref$strokeWidth === void 0 ? 0.5 : _ref$strokeWidth, | ||
_ref$className = _ref.className, | ||
className = _ref$className === undefined ? "" : _ref$className, | ||
restProps = objectWithoutProperties(_ref, ["id", "fill", "stroke", "strokeWidth", "className"]); | ||
className = _ref$className === void 0 ? "" : _ref$className, | ||
restProps = _objectWithoutProperties(_ref, _excluded$3); | ||
var _useContext = React.useContext(MapContext), | ||
var _useContext = useContext(MapContext), | ||
path = _useContext.path; | ||
var spherePath = React.useMemo(function () { | ||
return path({ type: "Sphere" }); | ||
var spherePath = useMemo(function () { | ||
return path({ | ||
type: "Sphere" | ||
}); | ||
}, [path]); | ||
return React__default.createElement( | ||
React.Fragment, | ||
null, | ||
React__default.createElement( | ||
"defs", | ||
null, | ||
React__default.createElement( | ||
"clipPath", | ||
{ id: id }, | ||
React__default.createElement("path", { d: spherePath }) | ||
) | ||
), | ||
React__default.createElement("path", _extends({ | ||
d: spherePath, | ||
fill: fill, | ||
stroke: stroke, | ||
strokeWidth: strokeWidth, | ||
style: { pointerEvents: "none" }, | ||
className: "rsm-sphere " + className | ||
}, restProps)) | ||
); | ||
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", { | ||
id: id | ||
}, /*#__PURE__*/React.createElement("path", { | ||
d: spherePath | ||
}))), /*#__PURE__*/React.createElement("path", _extends({ | ||
d: spherePath, | ||
fill: fill, | ||
stroke: stroke, | ||
strokeWidth: strokeWidth, | ||
style: { | ||
pointerEvents: "none" | ||
}, | ||
className: "rsm-sphere ".concat(className) | ||
}, restProps))); | ||
}; | ||
@@ -723,4 +857,5 @@ | ||
}; | ||
var Sphere$1 = memo(Sphere); | ||
var Sphere$1 = React.memo(Sphere); | ||
var _excluded$2 = ["coordinates", "children", "onMouseEnter", "onMouseLeave", "onMouseDown", "onMouseUp", "onFocus", "onBlur", "style", "className"]; | ||
@@ -737,17 +872,17 @@ var Marker = function Marker(_ref) { | ||
_ref$style = _ref.style, | ||
style = _ref$style === undefined ? {} : _ref$style, | ||
style = _ref$style === void 0 ? {} : _ref$style, | ||
_ref$className = _ref.className, | ||
className = _ref$className === undefined ? "" : _ref$className, | ||
restProps = objectWithoutProperties(_ref, ["coordinates", "children", "onMouseEnter", "onMouseLeave", "onMouseDown", "onMouseUp", "onFocus", "onBlur", "style", "className"]); | ||
className = _ref$className === void 0 ? "" : _ref$className, | ||
restProps = _objectWithoutProperties(_ref, _excluded$2); | ||
var _useContext = React.useContext(MapContext), | ||
var _useContext = useContext(MapContext), | ||
projection = _useContext.projection; | ||
var _useState = React.useState(false), | ||
_useState2 = slicedToArray(_useState, 2), | ||
var _useState = useState(false), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
isPressed = _useState2[0], | ||
setPressed = _useState2[1]; | ||
var _useState3 = React.useState(false), | ||
_useState4 = slicedToArray(_useState3, 2), | ||
var _useState3 = useState(false), | ||
_useState4 = _slicedToArray(_useState3, 2), | ||
isFocused = _useState4[0], | ||
@@ -757,3 +892,3 @@ setFocus = _useState4[1]; | ||
var _projection = projection(coordinates), | ||
_projection2 = slicedToArray(_projection, 2), | ||
_projection2 = _slicedToArray(_projection, 2), | ||
x = _projection2[0], | ||
@@ -794,17 +929,13 @@ y = _projection2[1]; | ||
return React__default.createElement( | ||
"g", | ||
_extends({ | ||
transform: "translate(" + x + ", " + y + ")", | ||
className: "rsm-marker " + className, | ||
onMouseEnter: handleMouseEnter, | ||
onMouseLeave: handleMouseLeave, | ||
onFocus: handleFocus, | ||
onBlur: handleBlur, | ||
onMouseDown: handleMouseDown, | ||
onMouseUp: handleMouseUp, | ||
style: style[isPressed || isFocused ? isPressed ? "pressed" : "hover" : "default"] | ||
}, restProps), | ||
children | ||
); | ||
return /*#__PURE__*/React.createElement("g", _extends({ | ||
transform: "translate(".concat(x, ", ").concat(y, ")"), | ||
className: "rsm-marker ".concat(className), | ||
onMouseEnter: handleMouseEnter, | ||
onMouseLeave: handleMouseLeave, | ||
onFocus: handleFocus, | ||
onBlur: handleBlur, | ||
onMouseDown: handleMouseDown, | ||
onMouseUp: handleMouseUp, | ||
style: style[isPressed || isFocused ? isPressed ? "pressed" : "hover" : "default"] | ||
}, restProps), children); | ||
}; | ||
@@ -825,19 +956,21 @@ | ||
var _excluded$1 = ["from", "to", "coordinates", "stroke", "strokeWidth", "fill", "className"]; | ||
var Line = function Line(_ref) { | ||
var _ref$from = _ref.from, | ||
from = _ref$from === undefined ? [0, 0] : _ref$from, | ||
from = _ref$from === void 0 ? [0, 0] : _ref$from, | ||
_ref$to = _ref.to, | ||
to = _ref$to === undefined ? [0, 0] : _ref$to, | ||
to = _ref$to === void 0 ? [0, 0] : _ref$to, | ||
coordinates = _ref.coordinates, | ||
_ref$stroke = _ref.stroke, | ||
stroke = _ref$stroke === undefined ? "currentcolor" : _ref$stroke, | ||
stroke = _ref$stroke === void 0 ? "currentcolor" : _ref$stroke, | ||
_ref$strokeWidth = _ref.strokeWidth, | ||
strokeWidth = _ref$strokeWidth === undefined ? 3 : _ref$strokeWidth, | ||
strokeWidth = _ref$strokeWidth === void 0 ? 3 : _ref$strokeWidth, | ||
_ref$fill = _ref.fill, | ||
fill = _ref$fill === undefined ? "transparent" : _ref$fill, | ||
fill = _ref$fill === void 0 ? "transparent" : _ref$fill, | ||
_ref$className = _ref.className, | ||
className = _ref$className === undefined ? "" : _ref$className, | ||
restProps = objectWithoutProperties(_ref, ["from", "to", "coordinates", "stroke", "strokeWidth", "fill", "className"]); | ||
className = _ref$className === void 0 ? "" : _ref$className, | ||
restProps = _objectWithoutProperties(_ref, _excluded$1); | ||
var _useContext = React.useContext(MapContext), | ||
var _useContext = useContext(MapContext), | ||
path = _useContext.path; | ||
@@ -849,6 +982,5 @@ | ||
}; | ||
return React__default.createElement("path", _extends({ | ||
return /*#__PURE__*/React.createElement("path", _extends({ | ||
d: path(lineData), | ||
className: "rsm-line " + className, | ||
className: "rsm-line ".concat(className), | ||
stroke: stroke, | ||
@@ -870,2 +1002,4 @@ strokeWidth: strokeWidth, | ||
var _excluded = ["subject", "children", "connectorProps", "dx", "dy", "curve", "className"]; | ||
var Annotation = function Annotation(_ref) { | ||
@@ -876,16 +1010,16 @@ var subject = _ref.subject, | ||
_ref$dx = _ref.dx, | ||
dx = _ref$dx === undefined ? 30 : _ref$dx, | ||
dx = _ref$dx === void 0 ? 30 : _ref$dx, | ||
_ref$dy = _ref.dy, | ||
dy = _ref$dy === undefined ? 30 : _ref$dy, | ||
dy = _ref$dy === void 0 ? 30 : _ref$dy, | ||
_ref$curve = _ref.curve, | ||
curve = _ref$curve === undefined ? 0 : _ref$curve, | ||
curve = _ref$curve === void 0 ? 0 : _ref$curve, | ||
_ref$className = _ref.className, | ||
className = _ref$className === undefined ? "" : _ref$className, | ||
restProps = objectWithoutProperties(_ref, ["subject", "children", "connectorProps", "dx", "dy", "curve", "className"]); | ||
className = _ref$className === void 0 ? "" : _ref$className, | ||
restProps = _objectWithoutProperties(_ref, _excluded); | ||
var _useContext = React.useContext(MapContext), | ||
var _useContext = useContext(MapContext), | ||
projection = _useContext.projection; | ||
var _projection = projection(subject), | ||
_projection2 = slicedToArray(_projection, 2), | ||
_projection2 = _slicedToArray(_projection, 2), | ||
x = _projection2[0], | ||
@@ -895,12 +1029,10 @@ y = _projection2[1]; | ||
var connectorPath = createConnectorPath(dx, dy, curve); | ||
return React__default.createElement( | ||
"g", | ||
_extends({ | ||
transform: "translate(" + (x + dx) + ", " + (y + dy) + ")", | ||
className: "rsm-annotation " + className | ||
}, restProps), | ||
React__default.createElement("path", _extends({ d: connectorPath, fill: "transparent", stroke: "#000" }, connectorProps)), | ||
children | ||
); | ||
return /*#__PURE__*/React.createElement("g", _extends({ | ||
transform: "translate(".concat(x + dx, ", ").concat(y + dy, ")"), | ||
className: "rsm-annotation ".concat(className) | ||
}, restProps), /*#__PURE__*/React.createElement("path", _extends({ | ||
d: connectorPath, | ||
fill: "transparent", | ||
stroke: "#000" | ||
}, connectorProps)), children); | ||
}; | ||
@@ -918,14 +1050,2 @@ | ||
exports.Annotation = Annotation; | ||
exports.ComposableMap = ComposableMap; | ||
exports.Geographies = Geographies; | ||
exports.Geography = Geography$1; | ||
exports.Graticule = Graticule$1; | ||
exports.Line = Line; | ||
exports.MapContext = MapContext; | ||
exports.MapProvider = MapProvider; | ||
exports.Marker = Marker; | ||
exports.Sphere = Sphere$1; | ||
exports.ZoomableGroup = ZoomableGroup; | ||
exports.useGeographies = useGeographies; | ||
exports.useZoomPan = useZoomPan; | ||
export { Annotation, ComposableMap, Geographies, Geography$1 as Geography, Graticule$1 as Graticule, Line, MapContext, MapProvider, Marker, Sphere$1 as Sphere, ZoomableGroup, useGeographies, useZoomPan }; |
@@ -1,1 +0,1 @@ | ||
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports,require("react"),require("prop-types"),require("d3-geo"),require("topojson-client"),require("d3-zoom"),require("d3-selection")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","d3-geo","topojson-client","d3-zoom","d3-selection"],o):o((e=e||self).reactSimpleMaps=e.reactSimpleMaps||{},e.React,e.PropTypes,e.d3,e.topojson,e.d3,e.d3)}(this,(function(e,o,t,r,n,a,s){"use strict";var i="default"in o?o.default:o;t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var c=Object.assign||function(e){for(var o=1;o<arguments.length;o++){var t=arguments[o];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},u=function(e,o){var t={};for(var r in e)o.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},l=function(e,o){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,o){var t=[],r=!0,n=!1,a=void 0;try{for(var s,i=e[Symbol.iterator]();!(r=(s=i.next()).done)&&(t.push(s.value),!o||t.length!==o);r=!0);}catch(e){n=!0,a=e}finally{try{!r&&i.return&&i.return()}finally{if(n)throw a}}return t}(e,o);throw new TypeError("Invalid attempt to destructure non-iterable instance")},p=r.geoPath,f=u(r,["geoPath"]),d=o.createContext(),m=function(e){var t=e.width,r=e.height,n=e.projection,a=e.projectionConfig,s=u(e,["width","height","projection","projectionConfig"]),m=a.center||[],h=l(m,2),v=h[0],g=h[1],y=a.rotate||[],M=l(y,3),b=M[0],E=M[1],j=M[2],x=a.parallels||[],k=l(x,2),N=k[0],w=k[1],C=a.scale||null,O=o.useMemo((function(){return function(e){var o=e.projectionConfig,t=void 0===o?{}:o,r=e.projection,n=void 0===r?"geoEqualEarth":r,a=e.width,s=void 0===a?800:a,i=e.height,c=void 0===i?600:i;if("function"==typeof n)return n;var u=f[n]().translate([s/2,c/2]);return[u.center?"center":null,u.rotate?"rotate":null,u.scale?"scale":null,u.parallels?"parallels":null].forEach((function(e){e&&(u=u[e](t[e]||u[e]()))})),u}({projectionConfig:{center:v||0===v||g||0===g?[v,g]:null,rotate:b||0===b||E||0===E?[b,E,j]:null,parallels:N||0===N||w||0===w?[N,w]:null,scale:C},projection:n,width:t,height:r})}),[t,r,n,v,g,b,E,j,N,w,C]),T=o.useCallback(O,[O]),S=o.useMemo((function(){return{width:t,height:r,projection:T,path:p().projection(T)}}),[t,r,T]);return i.createElement(d.Provider,c({value:S},s))};m.propTypes={width:t.number,height:t.number,projection:t.oneOfType([t.string,t.func]),projectionConfig:t.object};var h=function(e){var o=e.width,t=void 0===o?800:o,r=e.height,n=void 0===r?600:r,a=e.projection,s=void 0===a?"geoEqualEarth":a,l=e.projectionConfig,p=void 0===l?{}:l,f=e.className,d=void 0===f?"":f,h=u(e,["width","height","projection","projectionConfig","className"]);return i.createElement(m,{width:t,height:n,projection:s,projectionConfig:p},i.createElement("svg",c({viewBox:"0 0 "+t+" "+n,className:"rsm-svg "+d},h)))};function v(e,o,t){var r=(e*t.k-e)/2,n=(o*t.k-o)/2;return[e/2-(r+t.x)/t.k,o/2-(n+t.y)/t.k]}function g(e,o){if(!("Topology"===e.type))return o?o(e.features||e):e.features||e;var t=n.feature(e,e.objects[Object.keys(e.objects)[0]]).features;return o?o(t):t}function y(e){return"Topology"===e.type?{outline:n.mesh(e,e.objects[Object.keys(e.objects)[0]],(function(e,o){return e===o})),borders:n.mesh(e,e.objects[Object.keys(e.objects)[0]],(function(e,o){return e!==o}))}:null}function M(e,o){return e?e.map((function(e,t){return c({},e,{rsmKey:"geo-"+t,svgPath:o(e)})})):[]}function b(e){var t=e.geography,r=e.parseGeographies,n=o.useContext(d).path,a=o.useState({}),s=l(a,2),i=s[0],u=s[1];o.useEffect((function(){var e;"undefined"!=typeof window&&(t&&("string"==typeof t?(e=t,fetch(e).then((function(e){if(!e.ok)throw Error(e.statusText);return e.json()})).catch((function(e){console.log("There was a problem when fetching the data: ",e)}))).then((function(e){e&&u({geographies:g(e,r),mesh:y(e)})})):u({geographies:g(t,r),mesh:y(t)})))}),[t,r]);var p=o.useMemo((function(){var e=i.mesh||{},o=function(e,o,t){return e&&o?{outline:c({},e,{rsmKey:"outline",svgPath:t(e)}),borders:c({},o,{rsmKey:"borders",svgPath:t(o)})}:{}}(e.outline,e.borders,n);return{geographies:M(i.geographies,n),outline:o.outline,borders:o.borders}}),[i,n]);return{geographies:p.geographies,outline:p.outline,borders:p.borders}}h.propTypes={width:t.number,height:t.number,projection:t.oneOfType([t.string,t.func]),projectionConfig:t.object,className:t.string};var E=function(e){var t=e.geography,r=e.children,n=e.parseGeographies,a=e.className,s=void 0===a?"":a,l=u(e,["geography","children","parseGeographies","className"]),p=o.useContext(d),f=p.path,m=p.projection,h=b({geography:t,parseGeographies:n}),v=h.geographies,g=h.outline,y=h.borders;return i.createElement("g",c({className:"rsm-geographies "+s},l),v&&v.length>0&&r({geographies:v,outline:g,borders:y,path:f,projection:m}))};E.propTypes={geography:t.oneOfType([t.string,t.object,t.array]),children:t.func,parseGeographies:t.func,className:t.string};var j=function(e){var t=e.geography,r=e.onMouseEnter,n=e.onMouseLeave,a=e.onMouseDown,s=e.onMouseUp,p=e.onFocus,f=e.onBlur,d=e.style,m=void 0===d?{}:d,h=e.className,v=void 0===h?"":h,g=u(e,["geography","onMouseEnter","onMouseLeave","onMouseDown","onMouseUp","onFocus","onBlur","style","className"]),y=o.useState(!1),M=l(y,2),b=M[0],E=M[1],j=o.useState(!1),x=l(j,2),k=x[0],N=x[1];return i.createElement("path",c({tabIndex:"0",className:"rsm-geography "+v,d:t.svgPath,onMouseEnter:function(e){N(!0),r&&r(e)},onMouseLeave:function(e){N(!1),b&&E(!1),n&&n(e)},onFocus:function(e){N(!0),p&&p(e)},onBlur:function(e){N(!1),b&&E(!1),f&&f(e)},onMouseDown:function(e){E(!0),a&&a(e)},onMouseUp:function(e){E(!1),s&&s(e)},style:m[b||k?b?"pressed":"hover":"default"]},g))};j.propTypes={geography:t.object,onMouseEnter:t.func,onMouseLeave:t.func,onMouseDown:t.func,onMouseUp:t.func,onFocus:t.func,onBlur:t.func,style:t.object,className:t.string};var x=o.memo(j),k=function(e){var t=e.fill,n=void 0===t?"transparent":t,a=e.stroke,s=void 0===a?"currentcolor":a,l=e.step,p=void 0===l?[10,10]:l,f=e.className,m=void 0===f?"":f,h=u(e,["fill","stroke","step","className"]),v=o.useContext(d).path;return i.createElement("path",c({d:v(r.geoGraticule().step(p)()),fill:n,stroke:s,className:"rsm-graticule "+m},h))};k.propTypes={fill:t.string,stroke:t.string,step:t.array,className:t.string};var N=o.memo(k);function w(e){var t=e.center,r=e.filterZoomEvent,n=e.onMoveStart,i=e.onMoveEnd,c=e.onMove,u=e.translateExtent,p=void 0===u?[[-1/0,-1/0],[1/0,1/0]]:u,f=e.scaleExtent,m=void 0===f?[1,8]:f,h=e.zoom,g=void 0===h?1:h,y=o.useContext(d),M=y.width,b=y.height,E=y.projection,j=l(t,2),x=j[0],k=j[1],N=o.useState({x:0,y:0,k:1}),w=l(N,2),C=w[0],O=w[1],T=o.useRef({x:0,y:0,k:1}),S=o.useRef(),P=o.useRef(),z=o.useRef(!1),Z=l(p,2),G=Z[0],L=Z[1],B=l(G,2),F=B[0],q=B[1],D=l(L,2),U=D[0],W=D[1],R=l(m,2),A=R[0],K=R[1];return o.useEffect((function(){var e=s.select(S.current);var o=a.zoom().filter((function(e){return r?r(e):!!e&&(!e.ctrlKey&&!e.button)})).scaleExtent([A,K]).translateExtent([[F,q],[U,W]]).on("start",(function(e){n&&!z.current&&n({coordinates:E.invert(v(M,b,e.transform)),zoom:e.transform.k},e)})).on("zoom",(function(e){if(!z.current){var o=e.transform,t=e.sourceEvent;O({x:o.x,y:o.y,k:o.k,dragging:t}),c&&c({x:o.x,y:o.y,zoom:o.k,dragging:t},e)}})).on("end",(function(e){if(z.current)z.current=!1;else{var o=E.invert(v(M,b,e.transform)),t=l(o,2),r=t[0],n=t[1];T.current={x:r,y:n,k:e.transform.k},i&&i({coordinates:[r,n],zoom:e.transform.k},e)}}));P.current=o,e.call(o)}),[M,b,F,q,U,W,A,K,E,n,c,i,r]),o.useEffect((function(){if(x!==T.current.x||k!==T.current.y||g!==T.current.k){var e=E([x,k]),o=e[0]*g,t=e[1]*g,r=s.select(S.current);z.current=!0,r.call(P.current.transform,a.zoomIdentity.translate(M/2-o,b/2-t).scale(g)),O({x:M/2-o,y:b/2-t,k:g}),T.current={x:x,y:k,k:g}}}),[x,k,g,M,b,E]),{mapRef:S,position:C,transformString:"translate("+C.x+" "+C.y+") scale("+C.k+")"}}var C=function(e){var t=e.center,r=void 0===t?[0,0]:t,n=e.zoom,a=void 0===n?1:n,s=e.minZoom,l=void 0===s?1:s,p=e.maxZoom,f=void 0===p?8:p,m=e.translateExtent,h=e.filterZoomEvent,v=e.onMoveStart,g=e.onMove,y=e.onMoveEnd,M=e.className,b=u(e,["center","zoom","minZoom","maxZoom","translateExtent","filterZoomEvent","onMoveStart","onMove","onMoveEnd","className"]),E=o.useContext(d),j=E.width,x=E.height,k=w({center:r,filterZoomEvent:h,onMoveStart:v,onMove:g,onMoveEnd:y,scaleExtent:[l,f],translateExtent:m,zoom:a}),N=k.mapRef,C=k.transformString;return i.createElement("g",{ref:N},i.createElement("rect",{width:j,height:x,fill:"transparent"}),i.createElement("g",c({transform:C,className:"rsm-zoomable-group "+M},b)))};C.propTypes={center:t.array,zoom:t.number,minZoom:t.number,maxZoom:t.number,translateExtent:t.arrayOf(t.array),onMoveStart:t.func,onMove:t.func,onMoveEnd:t.func,className:t.string};var O=function(e){var t=e.id,r=void 0===t?"rsm-sphere":t,n=e.fill,a=void 0===n?"transparent":n,s=e.stroke,l=void 0===s?"currentcolor":s,p=e.strokeWidth,f=void 0===p?.5:p,m=e.className,h=void 0===m?"":m,v=u(e,["id","fill","stroke","strokeWidth","className"]),g=o.useContext(d).path,y=o.useMemo((function(){return g({type:"Sphere"})}),[g]);return i.createElement(o.Fragment,null,i.createElement("defs",null,i.createElement("clipPath",{id:r},i.createElement("path",{d:y}))),i.createElement("path",c({d:y,fill:a,stroke:l,strokeWidth:f,style:{pointerEvents:"none"},className:"rsm-sphere "+h},v)))};O.propTypes={id:t.string,fill:t.string,stroke:t.string,strokeWidth:t.number,className:t.string};var T=o.memo(O),S=function(e){var t=e.coordinates,r=e.children,n=e.onMouseEnter,a=e.onMouseLeave,s=e.onMouseDown,p=e.onMouseUp,f=e.onFocus,m=e.onBlur,h=e.style,v=void 0===h?{}:h,g=e.className,y=void 0===g?"":g,M=u(e,["coordinates","children","onMouseEnter","onMouseLeave","onMouseDown","onMouseUp","onFocus","onBlur","style","className"]),b=o.useContext(d).projection,E=o.useState(!1),j=l(E,2),x=j[0],k=j[1],N=o.useState(!1),w=l(N,2),C=w[0],O=w[1],T=b(t),S=l(T,2),P=S[0],z=S[1];return i.createElement("g",c({transform:"translate("+P+", "+z+")",className:"rsm-marker "+y,onMouseEnter:function(e){O(!0),n&&n(e)},onMouseLeave:function(e){O(!1),x&&k(!1),a&&a(e)},onFocus:function(e){O(!0),f&&f(e)},onBlur:function(e){O(!1),x&&k(!1),m&&m(e)},onMouseDown:function(e){k(!0),s&&s(e)},onMouseUp:function(e){k(!1),p&&p(e)},style:v[x||C?x?"pressed":"hover":"default"]},M),r)};S.propTypes={coordinates:t.array,children:t.oneOfType([t.node,t.arrayOf(t.node)]),onMouseEnter:t.func,onMouseLeave:t.func,onMouseDown:t.func,onMouseUp:t.func,onFocus:t.func,onBlur:t.func,style:t.object,className:t.string};var P=function(e){var t=e.from,r=void 0===t?[0,0]:t,n=e.to,a=void 0===n?[0,0]:n,s=e.coordinates,l=e.stroke,p=void 0===l?"currentcolor":l,f=e.strokeWidth,m=void 0===f?3:f,h=e.fill,v=void 0===h?"transparent":h,g=e.className,y=void 0===g?"":g,M=u(e,["from","to","coordinates","stroke","strokeWidth","fill","className"]),b=o.useContext(d).path,E={type:"LineString",coordinates:s||[r,a]};return i.createElement("path",c({d:b(E),className:"rsm-line "+y,stroke:p,strokeWidth:m,fill:v},M))};P.propTypes={from:t.array,to:t.array,coordinates:t.array,stroke:t.string,strokeWidth:t.number,fill:t.string,className:t.string};var z=function(e){var t=e.subject,r=e.children,n=e.connectorProps,a=e.dx,s=void 0===a?30:a,p=e.dy,f=void 0===p?30:p,m=e.curve,h=void 0===m?0:m,v=e.className,g=void 0===v?"":v,y=u(e,["subject","children","connectorProps","dx","dy","curve","className"]),M=(0,o.useContext(d).projection)(t),b=l(M,2),E=b[0],j=b[1],x=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:30,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.5,r=Array.isArray(t)?t:[t,t],n=e/2*r[0],a=o/2*r[1];return"M0,0 Q"+(-e/2-n)+","+(-o/2+a)+" "+-e+","+-o}(s,f,h);return i.createElement("g",c({transform:"translate("+(E+s)+", "+(j+f)+")",className:"rsm-annotation "+g},y),i.createElement("path",c({d:x,fill:"transparent",stroke:"#000"},n)),r)};z.propTypes={subject:t.array,children:t.oneOfType([t.node,t.arrayOf(t.node)]),dx:t.number,dy:t.number,curve:t.number,connectorProps:t.object,className:t.string},e.Annotation=z,e.ComposableMap=h,e.Geographies=E,e.Geography=x,e.Graticule=N,e.Line=P,e.MapContext=d,e.MapProvider=m,e.Marker=S,e.Sphere=T,e.ZoomableGroup=C,e.useGeographies=b,e.useZoomPan=w,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types"),require("d3-geo"),require("topojson-client"),require("d3-zoom"),require("d3-selection")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","d3-geo","topojson-client","d3-zoom","d3-selection"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).reactSimpleMaps=e.reactSimpleMaps||{},e.React,e.PropTypes,e.d3,e.topojson,e.d3,e.d3)}(this,(function(e,t,o,r,n,a,u){"use strict";function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function c(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:function(){return e[o]}})}})),t.default=e,Object.freeze(t)}var l=s(t),i=s(o),f=c(r);function d(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,r)}return o}function p(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?d(Object(o),!0).forEach((function(t){g(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):d(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}function g(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function h(){return h=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},h.apply(this,arguments)}function v(e,t){if(null==e)return{};var o,r,n=function(e,t){if(null==e)return{};var o,r,n={},a=Object.keys(e);for(r=0;r<a.length;r++)o=a[r],t.indexOf(o)>=0||(n[o]=e[o]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)o=a[r],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}return n}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==o)return;var r,n,a=[],u=!0,s=!1;try{for(o=o.call(e);!(u=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);u=!0);}catch(e){s=!0,n=e}finally{try{u||null==o.return||o.return()}finally{if(s)throw n}}return a}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return b(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);"Object"===o&&e.constructor&&(o=e.constructor.name);if("Map"===o||"Set"===o)return Array.from(e);if("Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return b(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,r=new Array(t);o<t;o++)r[o]=e[o];return r}var j=["width","height","projection","projectionConfig"],M=f.geoPath,E=v(f,["geoPath"]),O=t.createContext(),k=function(e){var o=e.width,r=e.height,n=e.projection,a=e.projectionConfig,u=v(e,j),s=y(a.center||[],2),c=s[0],i=s[1],f=y(a.rotate||[],3),d=f[0],p=f[1],m=f[2],g=y(a.parallels||[],2),b=g[0],k=g[1],x=a.scale||null,w=t.useMemo((function(){return function(e){var t=e.projectionConfig,o=void 0===t?{}:t,r=e.projection,n=void 0===r?"geoEqualEarth":r,a=e.width,u=void 0===a?800:a,s=e.height,c=void 0===s?600:s;if("function"==typeof n)return n;var l=E[n]().translate([u/2,c/2]);return[l.center?"center":null,l.rotate?"rotate":null,l.scale?"scale":null,l.parallels?"parallels":null].forEach((function(e){e&&(l=l[e](o[e]||l[e]()))})),l}({projectionConfig:{center:c||0===c||i||0===i?[c,i]:null,rotate:d||0===d||p||0===p?[d,p,m]:null,parallels:b||0===b||k||0===k?[b,k]:null,scale:x},projection:n,width:o,height:r})}),[o,r,n,c,i,d,p,m,b,k,x]),N=t.useCallback(w,[w]),S=t.useMemo((function(){return{width:o,height:r,projection:N,path:M().projection(N)}}),[o,r,N]);return l.default.createElement(O.Provider,h({value:S},u))};k.propTypes={width:i.default.number,height:i.default.number,projection:i.default.oneOfType([i.default.string,i.default.func]),projectionConfig:i.default.object};var x=["width","height","projection","projectionConfig","className"],w=function(e){var t=e.width,o=void 0===t?800:t,r=e.height,n=void 0===r?600:r,a=e.projection,u=void 0===a?"geoEqualEarth":a,s=e.projectionConfig,c=void 0===s?{}:s,i=e.className,f=void 0===i?"":i,d=v(e,x);return l.default.createElement(k,{width:o,height:n,projection:u,projectionConfig:c},l.default.createElement("svg",h({viewBox:"0 0 ".concat(o," ").concat(n),className:"rsm-svg ".concat(f)},d)))};function N(e,t,o){var r=(e*o.k-e)/2,n=(t*o.k-t)/2;return[e/2-(r+o.x)/o.k,t/2-(n+o.y)/o.k]}function S(e,t){if(!("Topology"===e.type))return t?t(e.features||e):e.features||e;var o=n.feature(e,e.objects[Object.keys(e.objects)[0]]).features;return t?t(o):o}function P(e){return"Topology"===e.type?{outline:n.mesh(e,e.objects[Object.keys(e.objects)[0]],(function(e,t){return e===t})),borders:n.mesh(e,e.objects[Object.keys(e.objects)[0]],(function(e,t){return e!==t}))}:null}function C(e,t){return e?e.map((function(e,o){return p(p({},e),{},{rsmKey:"geo-".concat(o),svgPath:t(e)})})):[]}function T(e){var o=e.geography,r=e.parseGeographies,n=t.useContext(O).path,a=y(t.useState({}),2),u=a[0],s=a[1];t.useEffect((function(){var e;"undefined"!==("undefined"==typeof window?"undefined":m(window))&&(o&&("string"==typeof o?(e=o,fetch(e).then((function(e){if(!e.ok)throw Error(e.statusText);return e.json()})).catch((function(e){console.log("There was a problem when fetching the data: ",e)}))).then((function(e){e&&s({geographies:S(e,r),mesh:P(e)})})):s({geographies:S(o,r),mesh:P(o)})))}),[o,r]);var c=t.useMemo((function(){var e=u.mesh||{},t=function(e,t,o){return e&&t?{outline:p(p({},e),{},{rsmKey:"outline",svgPath:o(e)}),borders:p(p({},t),{},{rsmKey:"borders",svgPath:o(t)})}:{}}(e.outline,e.borders,n);return{geographies:C(u.geographies,n),outline:t.outline,borders:t.borders}}),[u,n]);return{geographies:c.geographies,outline:c.outline,borders:c.borders}}w.propTypes={width:i.default.number,height:i.default.number,projection:i.default.oneOfType([i.default.string,i.default.func]),projectionConfig:i.default.object,className:i.default.string};var z=["geography","children","parseGeographies","className"],D=function(e){var o=e.geography,r=e.children,n=e.parseGeographies,a=e.className,u=void 0===a?"":a,s=v(e,z),c=t.useContext(O),i=c.path,f=c.projection,d=T({geography:o,parseGeographies:n}),p=d.geographies,m=d.outline,g=d.borders;return l.default.createElement("g",h({className:"rsm-geographies ".concat(u)},s),p&&p.length>0&&r({geographies:p,outline:m,borders:g,path:i,projection:f}))};D.propTypes={geography:i.default.oneOfType([i.default.string,i.default.object,i.default.array]),children:i.default.func,parseGeographies:i.default.func,className:i.default.string};var Z=["geography","onMouseEnter","onMouseLeave","onMouseDown","onMouseUp","onFocus","onBlur","style","className"],G=function(e){var o=e.geography,r=e.onMouseEnter,n=e.onMouseLeave,a=e.onMouseDown,u=e.onMouseUp,s=e.onFocus,c=e.onBlur,i=e.style,f=void 0===i?{}:i,d=e.className,p=void 0===d?"":d,m=v(e,Z),g=y(t.useState(!1),2),b=g[0],j=g[1],M=y(t.useState(!1),2),E=M[0],O=M[1];return l.default.createElement("path",h({tabIndex:"0",className:"rsm-geography ".concat(p),d:o.svgPath,onMouseEnter:function(e){O(!0),r&&r(e)},onMouseLeave:function(e){O(!1),b&&j(!1),n&&n(e)},onFocus:function(e){O(!0),s&&s(e)},onBlur:function(e){O(!1),b&&j(!1),c&&c(e)},onMouseDown:function(e){j(!0),a&&a(e)},onMouseUp:function(e){j(!1),u&&u(e)},style:f[b||E?b?"pressed":"hover":"default"]},m))};G.propTypes={geography:i.default.object,onMouseEnter:i.default.func,onMouseLeave:i.default.func,onMouseDown:i.default.func,onMouseUp:i.default.func,onFocus:i.default.func,onBlur:i.default.func,style:i.default.object,className:i.default.string};var L=t.memo(G),A=["fill","stroke","step","className"],B=function(e){var o=e.fill,n=void 0===o?"transparent":o,a=e.stroke,u=void 0===a?"currentcolor":a,s=e.step,c=void 0===s?[10,10]:s,i=e.className,f=void 0===i?"":i,d=v(e,A),p=t.useContext(O).path;return l.default.createElement("path",h({d:p(r.geoGraticule().step(c)()),fill:n,stroke:u,className:"rsm-graticule ".concat(f)},d))};B.propTypes={fill:i.default.string,stroke:i.default.string,step:i.default.array,className:i.default.string};var F=t.memo(B);function U(e){var o=e.center,r=e.filterZoomEvent,n=e.onMoveStart,s=e.onMoveEnd,c=e.onMove,l=e.translateExtent,i=void 0===l?[[-1/0,-1/0],[1/0,1/0]]:l,f=e.scaleExtent,d=void 0===f?[1,8]:f,p=e.zoom,m=void 0===p?1:p,g=t.useContext(O),h=g.width,v=g.height,b=g.projection,j=y(o,2),M=j[0],E=j[1],k=y(t.useState({x:0,y:0,k:1}),2),x=k[0],w=k[1],S=t.useRef({x:0,y:0,k:1}),P=t.useRef(),C=t.useRef(),T=t.useRef(!1),z=y(i,2),D=z[0],Z=z[1],G=y(D,2),L=G[0],A=G[1],B=y(Z,2),F=B[0],U=B[1],q=y(d,2),W=q[0],R=q[1];return t.useEffect((function(){var e=u.select(P.current);var t=a.zoom().filter((function(e){return r?r(e):!!e&&(!e.ctrlKey&&!e.button)})).scaleExtent([W,R]).translateExtent([[L,A],[F,U]]).on("start",(function(e){n&&!T.current&&n({coordinates:b.invert(N(h,v,e.transform)),zoom:e.transform.k},e)})).on("zoom",(function(e){if(!T.current){var t=e.transform,o=e.sourceEvent;w({x:t.x,y:t.y,k:t.k,dragging:o}),c&&c({x:t.x,y:t.y,zoom:t.k,dragging:o},e)}})).on("end",(function(e){if(T.current)T.current=!1;else{var t=y(b.invert(N(h,v,e.transform)),2),o=t[0],r=t[1];S.current={x:o,y:r,k:e.transform.k},s&&s({coordinates:[o,r],zoom:e.transform.k},e)}}));C.current=t,e.call(t)}),[h,v,L,A,F,U,W,R,b,n,c,s,r]),t.useEffect((function(){if(M!==S.current.x||E!==S.current.y||m!==S.current.k){var e=b([M,E]),t=e[0]*m,o=e[1]*m,r=u.select(P.current);T.current=!0,r.call(C.current.transform,a.zoomIdentity.translate(h/2-t,v/2-o).scale(m)),w({x:h/2-t,y:v/2-o,k:m}),S.current={x:M,y:E,k:m}}}),[M,E,m,h,v,b]),{mapRef:P,position:x,transformString:"translate(".concat(x.x," ").concat(x.y,") scale(").concat(x.k,")")}}var q=["center","zoom","minZoom","maxZoom","translateExtent","filterZoomEvent","onMoveStart","onMove","onMoveEnd","className"],W=function(e){var o=e.center,r=void 0===o?[0,0]:o,n=e.zoom,a=void 0===n?1:n,u=e.minZoom,s=void 0===u?1:u,c=e.maxZoom,i=void 0===c?8:c,f=e.translateExtent,d=e.filterZoomEvent,p=e.onMoveStart,m=e.onMove,g=e.onMoveEnd,y=e.className,b=v(e,q),j=t.useContext(O),M=j.width,E=j.height,k=U({center:r,filterZoomEvent:d,onMoveStart:p,onMove:m,onMoveEnd:g,scaleExtent:[s,i],translateExtent:f,zoom:a}),x=k.mapRef,w=k.transformString;return l.default.createElement("g",{ref:x},l.default.createElement("rect",{width:M,height:E,fill:"transparent"}),l.default.createElement("g",h({transform:w,className:"rsm-zoomable-group ".concat(y)},b)))};W.propTypes={center:i.default.array,zoom:i.default.number,minZoom:i.default.number,maxZoom:i.default.number,translateExtent:i.default.arrayOf(i.default.array),onMoveStart:i.default.func,onMove:i.default.func,onMoveEnd:i.default.func,className:i.default.string};var R=["id","fill","stroke","strokeWidth","className"],I=function(e){var o=e.id,r=void 0===o?"rsm-sphere":o,n=e.fill,a=void 0===n?"transparent":n,u=e.stroke,s=void 0===u?"currentcolor":u,c=e.strokeWidth,i=void 0===c?.5:c,f=e.className,d=void 0===f?"":f,p=v(e,R),m=t.useContext(O).path,g=t.useMemo((function(){return m({type:"Sphere"})}),[m]);return l.default.createElement(t.Fragment,null,l.default.createElement("defs",null,l.default.createElement("clipPath",{id:r},l.default.createElement("path",{d:g}))),l.default.createElement("path",h({d:g,fill:a,stroke:s,strokeWidth:i,style:{pointerEvents:"none"},className:"rsm-sphere ".concat(d)},p)))};I.propTypes={id:i.default.string,fill:i.default.string,stroke:i.default.string,strokeWidth:i.default.number,className:i.default.string};var K=t.memo(I),_=["coordinates","children","onMouseEnter","onMouseLeave","onMouseDown","onMouseUp","onFocus","onBlur","style","className"],Q=function(e){var o=e.coordinates,r=e.children,n=e.onMouseEnter,a=e.onMouseLeave,u=e.onMouseDown,s=e.onMouseUp,c=e.onFocus,i=e.onBlur,f=e.style,d=void 0===f?{}:f,p=e.className,m=void 0===p?"":p,g=v(e,_),b=t.useContext(O).projection,j=y(t.useState(!1),2),M=j[0],E=j[1],k=y(t.useState(!1),2),x=k[0],w=k[1],N=y(b(o),2),S=N[0],P=N[1];return l.default.createElement("g",h({transform:"translate(".concat(S,", ").concat(P,")"),className:"rsm-marker ".concat(m),onMouseEnter:function(e){w(!0),n&&n(e)},onMouseLeave:function(e){w(!1),M&&E(!1),a&&a(e)},onFocus:function(e){w(!0),c&&c(e)},onBlur:function(e){w(!1),M&&E(!1),i&&i(e)},onMouseDown:function(e){E(!0),u&&u(e)},onMouseUp:function(e){E(!1),s&&s(e)},style:d[M||x?M?"pressed":"hover":"default"]},g),r)};Q.propTypes={coordinates:i.default.array,children:i.default.oneOfType([i.default.node,i.default.arrayOf(i.default.node)]),onMouseEnter:i.default.func,onMouseLeave:i.default.func,onMouseDown:i.default.func,onMouseUp:i.default.func,onFocus:i.default.func,onBlur:i.default.func,style:i.default.object,className:i.default.string};var $=["from","to","coordinates","stroke","strokeWidth","fill","className"],H=function(e){var o=e.from,r=void 0===o?[0,0]:o,n=e.to,a=void 0===n?[0,0]:n,u=e.coordinates,s=e.stroke,c=void 0===s?"currentcolor":s,i=e.strokeWidth,f=void 0===i?3:i,d=e.fill,p=void 0===d?"transparent":d,m=e.className,g=void 0===m?"":m,y=v(e,$),b=t.useContext(O).path,j={type:"LineString",coordinates:u||[r,a]};return l.default.createElement("path",h({d:b(j),className:"rsm-line ".concat(g),stroke:c,strokeWidth:f,fill:p},y))};H.propTypes={from:i.default.array,to:i.default.array,coordinates:i.default.array,stroke:i.default.string,strokeWidth:i.default.number,fill:i.default.string,className:i.default.string};var J=["subject","children","connectorProps","dx","dy","curve","className"],V=function(e){var o=e.subject,r=e.children,n=e.connectorProps,a=e.dx,u=void 0===a?30:a,s=e.dy,c=void 0===s?30:s,i=e.curve,f=void 0===i?0:i,d=e.className,p=void 0===d?"":d,m=v(e,J),g=y((0,t.useContext(O).projection)(o),2),b=g[0],j=g[1],M=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:30,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.5,r=Array.isArray(o)?o:[o,o],n=e/2*r[0],a=t/2*r[1];return"M".concat(0,",",0," Q",-e/2-n,",").concat(-t/2+a," ").concat(-e,",").concat(-t)}(u,c,f);return l.default.createElement("g",h({transform:"translate(".concat(b+u,", ").concat(j+c,")"),className:"rsm-annotation ".concat(p)},m),l.default.createElement("path",h({d:M,fill:"transparent",stroke:"#000"},n)),r)};V.propTypes={subject:i.default.array,children:i.default.oneOfType([i.default.node,i.default.arrayOf(i.default.node)]),dx:i.default.number,dy:i.default.number,curve:i.default.number,connectorProps:i.default.object,className:i.default.string},e.Annotation=V,e.ComposableMap=w,e.Geographies=D,e.Geography=L,e.Graticule=F,e.Line=H,e.MapContext=O,e.MapProvider=k,e.Marker=Q,e.Sphere=K,e.ZoomableGroup=W,e.useGeographies=T,e.useZoomPan=U,Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "react-simple-maps", | ||
"version": "3.0.0-beta.2", | ||
"version": "3.0.0-beta.3", | ||
"description": "An svg map chart component built with and for React", | ||
@@ -36,24 +36,23 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"babel-core": "^6.26.0", | ||
"babel-preset-env": "^1.7.0", | ||
"babel-plugin-external-helpers": "^6.22.0", | ||
"babel-plugin-transform-object-rest-spread": "^6.26.0", | ||
"babel-plugin-transform-react-jsx": "^6.24.1", | ||
"babelrc-rollup": "^3.0.0", | ||
"rollup": "^1.17.0", | ||
"rollup-plugin-babel": "^3.0.3", | ||
"rollup-plugin-commonjs": "^10.0.1", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-terser": "^5.1.1", | ||
"@babel/core": "^7.18.6", | ||
"@babel/plugin-external-helpers": "^7.18.6", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.18.6", | ||
"@babel/plugin-transform-react-jsx": "^7.18.6", | ||
"@babel/preset-env": "^7.18.6", | ||
"@rollup/plugin-babel": "^5.3.1", | ||
"@rollup/plugin-commonjs": "^22.0.1", | ||
"@rollup/plugin-node-resolve": "^13.3.0", | ||
"expect": "^23.5.0", | ||
"mocha": "^5.2.0", | ||
"prop-types": "^15.7.2", | ||
"react": "^17.0.1", | ||
"react-dom": "^17.0.1", | ||
"prop-types": "^15.7.2", | ||
"react-test-utils": "^0.0.1" | ||
"react-test-utils": "^0.0.1", | ||
"rollup": "^2.75.7", | ||
"rollup-plugin-terser": "^7.0.2" | ||
}, | ||
"peerDependencies": { | ||
"prop-types": "^15.7.2", | ||
"react": "^16.8.0 || 17.x || 18.x", | ||
"react-dom": "^16.8.0 || 17.x || 18.x", | ||
"prop-types": "^15.7.2" | ||
"react-dom": "^16.8.0 || 17.x || 18.x" | ||
}, | ||
@@ -60,0 +59,0 @@ "dependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
84522
16
1808