Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-simple-maps

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-simple-maps - npm Package Compare versions

Comparing version 4.0.0-beta.5 to 4.0.0-beta.6

159

dist/index.js

@@ -1,31 +0,8 @@

'use strict';
import React, { createContext, useMemo, useCallback, useContext, forwardRef, useState, useEffect, memo, useRef, Fragment } from 'react';
import PropTypes from 'prop-types';
import * as d3 from 'd3-geo';
import { feature, mesh } from 'topojson-client';
import * as d3$1 from 'd3-selection';
import * as d3$2 from 'd3-zoom';
var React = require('react');
var PropTypes = require('prop-types');
var d3 = require('d3-geo');
var topojsonClient = require('topojson-client');
var d3$1 = require('d3-selection');
var d3$2 = require('d3-zoom');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var d3__namespace = /*#__PURE__*/_interopNamespaceDefault(d3);
var d3__namespace$1 = /*#__PURE__*/_interopNamespaceDefault(d3$1);
var d3__namespace$2 = /*#__PURE__*/_interopNamespaceDefault(d3$2);
function _iterableToArrayLimit(arr, i) {

@@ -181,5 +158,5 @@ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];

var _excluded$a = ["width", "height", "projection", "projectionConfig"];
var geoPath = d3__namespace.geoPath,
projections = _objectWithoutProperties(d3__namespace, ["geoPath"]);
var MapContext = React.createContext();
var geoPath = d3.geoPath,
projections = _objectWithoutProperties(d3, ["geoPath"]);
var MapContext = createContext();
var makeProjection = function makeProjection(_ref) {

@@ -224,3 +201,3 @@ var _ref$projectionConfig = _ref.projectionConfig,

var s = projectionConfig.scale || null;
var projMemo = React.useMemo(function () {
var projMemo = useMemo(function () {
return makeProjection({

@@ -238,4 +215,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 {

@@ -259,7 +236,7 @@ width: width,

var useMapContext = function useMapContext() {
return React.useContext(MapContext);
return useContext(MapContext);
};
var _excluded$9 = ["width", "height", "projection", "projectionConfig", "className"];
var ComposableMap = React.forwardRef(function (_ref, ref) {
var ComposableMap = forwardRef(function (_ref, ref) {
var _ref$width = _ref.width,

@@ -297,3 +274,3 @@ width = _ref$width === void 0 ? 800 : _ref$width,

function select(ref) {
return d3__namespace$1.select(ref);
return d3$1.select(ref);
}

@@ -320,3 +297,3 @@ function getCoords(w, h, t) {

}
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;

@@ -327,6 +304,6 @@ }

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;

@@ -375,9 +352,9 @@ });

parseGeographies = _ref.parseGeographies;
var _useContext = React.useContext(MapContext),
var _useContext = useContext(MapContext),
path = _useContext.path;
var _useState = React.useState({}),
var _useState = useState({}),
_useState2 = _slicedToArray(_useState, 2),
output = _useState2[0],
setOutput = _useState2[1];
React.useEffect(function () {
useEffect(function () {
if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === "undefined") return;

@@ -401,3 +378,3 @@ if (!geography) return;

}, [geography, parseGeographies]);
var _useMemo = React.useMemo(function () {
var _useMemo = useMemo(function () {
var mesh = output.mesh || {};

@@ -422,3 +399,3 @@ var preparedMesh = prepareMesh(mesh.outline, mesh.borders, path);

var _excluded$8 = ["geography", "children", "parseGeographies", "className"];
var Geographies = React.forwardRef(function (_ref, ref) {
var Geographies = forwardRef(function (_ref, ref) {
var geography = _ref.geography,

@@ -430,3 +407,3 @@ children = _ref.children,

restProps = _objectWithoutProperties(_ref, _excluded$8);
var _useContext = React.useContext(MapContext),
var _useContext = useContext(MapContext),
path = _useContext.path,

@@ -461,3 +438,3 @@ projection = _useContext.projection;

var _excluded$7 = ["geography", "onMouseEnter", "onMouseLeave", "onMouseDown", "onMouseUp", "onFocus", "onBlur", "style", "className"];
var Geography = React.forwardRef(function (_ref, ref) {
var Geography = forwardRef(function (_ref, ref) {
var geography = _ref.geography,

@@ -475,7 +452,7 @@ onMouseEnter = _ref.onMouseEnter,

restProps = _objectWithoutProperties(_ref, _excluded$7);
var _useState = React.useState(false),
var _useState = useState(false),
_useState2 = _slicedToArray(_useState, 2),
isPressed = _useState2[0],
setPressed = _useState2[1];
var _useState3 = React.useState(false),
var _useState3 = useState(false),
_useState4 = _slicedToArray(_useState3, 2),

@@ -536,6 +513,6 @@ isFocused = _useState4[0],

};
var Geography$1 = React.memo(Geography);
var Geography$1 = memo(Geography);
var _excluded$6 = ["fill", "stroke", "step", "className"];
var Graticule = React.forwardRef(function (_ref, ref) {
var Graticule = forwardRef(function (_ref, ref) {
var _ref$fill = _ref.fill,

@@ -550,7 +527,7 @@ fill = _ref$fill === void 0 ? "transparent" : _ref$fill,

restProps = _objectWithoutProperties(_ref, _excluded$6);
var _useContext = React.useContext(MapContext),
var _useContext = useContext(MapContext),
path = _useContext.path;
return /*#__PURE__*/React.createElement("path", _extends({
ref: ref,
d: path(d3__namespace.geoGraticule().step(step)()),
d: path(d3.geoGraticule().step(step)()),
fill: fill,

@@ -568,6 +545,6 @@ stroke: stroke,

};
var Graticule$1 = React.memo(Graticule);
var Graticule$1 = memo(Graticule);
var _excluded$5 = ["value"];
var ZoomPanContext = React.createContext();
var ZoomPanContext = createContext();
var defaultValue = {

@@ -594,3 +571,3 @@ x: 0,

var useZoomPanContext = function useZoomPanContext() {
return React.useContext(ZoomPanContext);
return useContext(ZoomPanContext);
};

@@ -610,3 +587,3 @@

zoom = _ref$zoom === void 0 ? 1 : _ref$zoom;
var _useContext = React.useContext(MapContext),
var _useContext = useContext(MapContext),
width = _useContext.width,

@@ -618,3 +595,3 @@ height = _useContext.height,

lat = _center[1];
var _useState = React.useState({
var _useState = useState({
x: 0,

@@ -627,3 +604,3 @@ y: 0,

setPosition = _useState2[1];
var lastPosition = React.useRef({
var lastPosition = useRef({
x: 0,

@@ -633,5 +610,5 @@ y: 0,

});
var mapRef = React.useRef();
var zoomRef = React.useRef();
var bypassEvents = React.useRef(false);
var mapRef = useRef();
var zoomRef = useRef();
var bypassEvents = useRef(false);
var _translateExtent = _slicedToArray(translateExtent, 2),

@@ -649,3 +626,3 @@ a = _translateExtent[0],

maxZoom = _scaleExtent[1];
React.useEffect(function () {
useEffect(function () {
var svg = select(mapRef.current);

@@ -703,7 +680,7 @@ function handleZoomStart(d3Event) {

}
var zoom = d3__namespace$2.zoom().filter(filterFunc).scaleExtent([minZoom, maxZoom]).translateExtent([[a1, a2], [b1, b2]]).on("start", handleZoomStart).on("zoom", handleZoom).on("end", handleZoomEnd);
var zoom = d3$2.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);
}, [width, height, a1, a2, b1, b2, minZoom, maxZoom, projection, onMoveStart, onMove, onMoveEnd, filterZoomEvent]);
React.useEffect(function () {
useEffect(function () {
if (lon === lastPosition.current.x && lat === lastPosition.current.y && zoom === lastPosition.current.k) return;

@@ -715,3 +692,3 @@ var coords = projection([lon, lat]);

bypassEvents.current = true;
svg.call(zoomRef.current.transform, d3__namespace$2.zoomIdentity.translate(width / 2 - x, height / 2 - y).scale(zoom));
svg.call(zoomRef.current.transform, d3$2.zoomIdentity.translate(width / 2 - x, height / 2 - y).scale(zoom));
setPosition({

@@ -736,3 +713,3 @@ x: width / 2 - x,

var _excluded$4 = ["center", "zoom", "minZoom", "maxZoom", "translateExtent", "filterZoomEvent", "onMoveStart", "onMove", "onMoveEnd", "className"];
var ZoomableGroup = React.forwardRef(function (_ref, ref) {
var ZoomableGroup = forwardRef(function (_ref, ref) {
var _ref$center = _ref.center,

@@ -753,3 +730,3 @@ center = _ref$center === void 0 ? [0, 0] : _ref$center,

restProps = _objectWithoutProperties(_ref, _excluded$4);
var _useContext = React.useContext(MapContext),
var _useContext = useContext(MapContext),
width = _useContext.width,

@@ -803,3 +780,3 @@ height = _useContext.height;

var _excluded$3 = ["id", "fill", "stroke", "strokeWidth", "className"];
var Sphere = React.forwardRef(function (_ref, ref) {
var Sphere = forwardRef(function (_ref, ref) {
var _ref$id = _ref.id,

@@ -816,5 +793,5 @@ id = _ref$id === void 0 ? "rsm-sphere" : _ref$id,

restProps = _objectWithoutProperties(_ref, _excluded$3);
var _useContext = React.useContext(MapContext),
var _useContext = useContext(MapContext),
path = _useContext.path;
var spherePath = React.useMemo(function () {
var spherePath = useMemo(function () {
return path({

@@ -824,3 +801,3 @@ type: "Sphere"

}, [path]);
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
id: id

@@ -849,6 +826,6 @@ }, /*#__PURE__*/React.createElement("path", {

};
var Sphere$1 = React.memo(Sphere);
var Sphere$1 = memo(Sphere);
var _excluded$2 = ["coordinates", "children", "onMouseEnter", "onMouseLeave", "onMouseDown", "onMouseUp", "onFocus", "onBlur", "style", "className"];
var Marker = React.forwardRef(function (_ref, ref) {
var Marker = forwardRef(function (_ref, ref) {
var coordinates = _ref.coordinates,

@@ -867,9 +844,9 @@ children = _ref.children,

restProps = _objectWithoutProperties(_ref, _excluded$2);
var _useContext = React.useContext(MapContext),
var _useContext = useContext(MapContext),
projection = _useContext.projection;
var _useState = React.useState(false),
var _useState = useState(false),
_useState2 = _slicedToArray(_useState, 2),
isPressed = _useState2[0],
setPressed = _useState2[1];
var _useState3 = React.useState(false),
var _useState3 = useState(false),
_useState4 = _slicedToArray(_useState3, 2),

@@ -936,3 +913,3 @@ isFocused = _useState4[0],

var _excluded$1 = ["from", "to", "coordinates", "stroke", "strokeWidth", "fill", "className"];
var Line = React.forwardRef(function (_ref, ref) {
var Line = forwardRef(function (_ref, ref) {
var _ref$from = _ref.from,

@@ -952,3 +929,3 @@ from = _ref$from === void 0 ? [0, 0] : _ref$from,

restProps = _objectWithoutProperties(_ref, _excluded$1);
var _useContext = React.useContext(MapContext),
var _useContext = useContext(MapContext),
path = _useContext.path;

@@ -980,3 +957,3 @@ var lineData = {

var _excluded = ["subject", "children", "connectorProps", "dx", "dy", "curve", "className"];
var Annotation = React.forwardRef(function (_ref, ref) {
var Annotation = forwardRef(function (_ref, ref) {
var subject = _ref.subject,

@@ -994,3 +971,3 @@ children = _ref.children,

restProps = _objectWithoutProperties(_ref, _excluded);
var _useContext = React.useContext(MapContext),
var _useContext = useContext(MapContext),
projection = _useContext.projection;

@@ -1023,18 +1000,2 @@ var _projection = projection(subject),

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.ZoomPanContext = ZoomPanContext;
exports.ZoomPanProvider = ZoomPanProvider;
exports.ZoomableGroup = ZoomableGroup;
exports.useGeographies = useGeographies;
exports.useMapContext = useMapContext;
exports.useZoomPan = useZoomPan;
exports.useZoomPanContext = useZoomPanContext;
export { Annotation, ComposableMap, Geographies, Geography$1 as Geography, Graticule$1 as Graticule, Line, MapContext, MapProvider, Marker, Sphere$1 as Sphere, ZoomPanContext, ZoomPanProvider, ZoomableGroup, useGeographies, useMapContext, useZoomPan, useZoomPanContext };
{
"name": "react-simple-maps",
"version": "4.0.0-beta.5",
"version": "4.0.0-beta.6",
"description": "An svg map chart component built with and for React",
"main": "dist/index.js",
"module": "dist/index.es.js",
"module": "dist/index.js",
"type": "module",

@@ -8,0 +8,0 @@ "files": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc