react-simple-maps 3.0.0-beta.3 → 3.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +177 -138
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,10 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var PropTypes = require('prop-types');
|
|
7
|
+
var d3Geo = require('d3-geo');
|
|
8
|
+
var topojsonClient = require('topojson-client');
|
|
9
|
+
var d3Zoom = require('d3-zoom');
|
|
10
|
+
var d3Selection = require('d3-selection');
|
|
11
|
+
|
|
12
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
+
|
|
14
|
+
function _interopNamespace(e) {
|
|
15
|
+
if (e && e.__esModule) return e;
|
|
16
|
+
var n = Object.create(null);
|
|
17
|
+
if (e) {
|
|
18
|
+
Object.keys(e).forEach(function (k) {
|
|
19
|
+
if (k !== 'default') {
|
|
20
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
21
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return e[k]; }
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
n["default"] = e;
|
|
29
|
+
return Object.freeze(n);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
33
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
34
|
+
var d3Geo__namespace = /*#__PURE__*/_interopNamespace(d3Geo);
|
|
8
35
|
|
|
9
36
|
function ownKeys(object, enumerableOnly) {
|
|
10
37
|
var keys = Object.keys(object);
|
|
@@ -171,10 +198,10 @@ function _nonIterableRest() {
|
|
|
171
198
|
|
|
172
199
|
var _excluded$9 = ["width", "height", "projection", "projectionConfig"];
|
|
173
200
|
|
|
174
|
-
var geoPath =
|
|
175
|
-
projections = _objectWithoutProperties(
|
|
201
|
+
var geoPath = d3Geo__namespace.geoPath,
|
|
202
|
+
projections = _objectWithoutProperties(d3Geo__namespace, ["geoPath"]);
|
|
176
203
|
|
|
177
|
-
var MapContext = createContext();
|
|
204
|
+
var MapContext = React.createContext();
|
|
178
205
|
|
|
179
206
|
var makeProjection = function makeProjection(_ref) {
|
|
180
207
|
var _ref$projectionConfig = _ref.projectionConfig,
|
|
@@ -220,7 +247,7 @@ var MapProvider = function MapProvider(_ref2) {
|
|
|
220
247
|
p2 = _ref8[1];
|
|
221
248
|
|
|
222
249
|
var s = projectionConfig.scale || null;
|
|
223
|
-
var projMemo = useMemo(function () {
|
|
250
|
+
var projMemo = React.useMemo(function () {
|
|
224
251
|
return makeProjection({
|
|
225
252
|
projectionConfig: {
|
|
226
253
|
center: cx || cx === 0 || cy || cy === 0 ? [cx, cy] : null,
|
|
@@ -233,8 +260,8 @@ var MapProvider = function MapProvider(_ref2) {
|
|
|
233
260
|
height: height
|
|
234
261
|
});
|
|
235
262
|
}, [width, height, projection, cx, cy, rx, ry, rz, p1, p2, s]);
|
|
236
|
-
var proj = useCallback(projMemo, [projMemo]);
|
|
237
|
-
var value = useMemo(function () {
|
|
263
|
+
var proj = React.useCallback(projMemo, [projMemo]);
|
|
264
|
+
var value = React.useMemo(function () {
|
|
238
265
|
return {
|
|
239
266
|
width: width,
|
|
240
267
|
height: height,
|
|
@@ -242,16 +269,16 @@ var MapProvider = function MapProvider(_ref2) {
|
|
|
242
269
|
path: geoPath().projection(proj)
|
|
243
270
|
};
|
|
244
271
|
}, [width, height, proj]);
|
|
245
|
-
return /*#__PURE__*/
|
|
272
|
+
return /*#__PURE__*/React__default["default"].createElement(MapContext.Provider, _extends({
|
|
246
273
|
value: value
|
|
247
274
|
}, restProps));
|
|
248
275
|
};
|
|
249
276
|
|
|
250
277
|
MapProvider.propTypes = {
|
|
251
|
-
width:
|
|
252
|
-
height:
|
|
253
|
-
projection:
|
|
254
|
-
projectionConfig:
|
|
278
|
+
width: PropTypes__default["default"].number,
|
|
279
|
+
height: PropTypes__default["default"].number,
|
|
280
|
+
projection: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].func]),
|
|
281
|
+
projectionConfig: PropTypes__default["default"].object
|
|
255
282
|
};
|
|
256
283
|
|
|
257
284
|
var _excluded$8 = ["width", "height", "projection", "projectionConfig", "className"];
|
|
@@ -269,23 +296,23 @@ var ComposableMap = function ComposableMap(_ref) {
|
|
|
269
296
|
className = _ref$className === void 0 ? "" : _ref$className,
|
|
270
297
|
restProps = _objectWithoutProperties(_ref, _excluded$8);
|
|
271
298
|
|
|
272
|
-
return /*#__PURE__*/
|
|
299
|
+
return /*#__PURE__*/React__default["default"].createElement(MapProvider, {
|
|
273
300
|
width: width,
|
|
274
301
|
height: height,
|
|
275
302
|
projection: projection,
|
|
276
303
|
projectionConfig: projectionConfig
|
|
277
|
-
}, /*#__PURE__*/
|
|
304
|
+
}, /*#__PURE__*/React__default["default"].createElement("svg", _extends({
|
|
278
305
|
viewBox: "0 0 ".concat(width, " ").concat(height),
|
|
279
306
|
className: "rsm-svg ".concat(className)
|
|
280
307
|
}, restProps)));
|
|
281
308
|
};
|
|
282
309
|
|
|
283
310
|
ComposableMap.propTypes = {
|
|
284
|
-
width:
|
|
285
|
-
height:
|
|
286
|
-
projection:
|
|
287
|
-
projectionConfig:
|
|
288
|
-
className:
|
|
311
|
+
width: PropTypes__default["default"].number,
|
|
312
|
+
height: PropTypes__default["default"].number,
|
|
313
|
+
projection: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].func]),
|
|
314
|
+
projectionConfig: PropTypes__default["default"].object,
|
|
315
|
+
className: PropTypes__default["default"].string
|
|
289
316
|
};
|
|
290
317
|
|
|
291
318
|
function getCoords(w, h, t) {
|
|
@@ -311,16 +338,16 @@ function getFeatures(geographies, parseGeographies) {
|
|
|
311
338
|
return parseGeographies ? parseGeographies(geographies.features || geographies) : geographies.features || geographies;
|
|
312
339
|
}
|
|
313
340
|
|
|
314
|
-
var feats = feature(geographies, geographies.objects[Object.keys(geographies.objects)[0]]).features;
|
|
341
|
+
var feats = topojsonClient.feature(geographies, geographies.objects[Object.keys(geographies.objects)[0]]).features;
|
|
315
342
|
return parseGeographies ? parseGeographies(feats) : feats;
|
|
316
343
|
}
|
|
317
344
|
function getMesh(geographies) {
|
|
318
345
|
var isTopojson = geographies.type === "Topology";
|
|
319
346
|
if (!isTopojson) return null;
|
|
320
|
-
var outline = mesh(geographies, geographies.objects[Object.keys(geographies.objects)[0]], function (a, b) {
|
|
347
|
+
var outline = topojsonClient.mesh(geographies, geographies.objects[Object.keys(geographies.objects)[0]], function (a, b) {
|
|
321
348
|
return a === b;
|
|
322
349
|
});
|
|
323
|
-
var borders = mesh(geographies, geographies.objects[Object.keys(geographies.objects)[0]], function (a, b) {
|
|
350
|
+
var borders = topojsonClient.mesh(geographies, geographies.objects[Object.keys(geographies.objects)[0]], function (a, b) {
|
|
324
351
|
return a !== b;
|
|
325
352
|
});
|
|
326
353
|
return {
|
|
@@ -365,15 +392,15 @@ function useGeographies(_ref) {
|
|
|
365
392
|
var geography = _ref.geography,
|
|
366
393
|
parseGeographies = _ref.parseGeographies;
|
|
367
394
|
|
|
368
|
-
var _useContext = useContext(MapContext),
|
|
395
|
+
var _useContext = React.useContext(MapContext),
|
|
369
396
|
path = _useContext.path;
|
|
370
397
|
|
|
371
|
-
var _useState = useState({}),
|
|
398
|
+
var _useState = React.useState({}),
|
|
372
399
|
_useState2 = _slicedToArray(_useState, 2),
|
|
373
400
|
output = _useState2[0],
|
|
374
401
|
setOutput = _useState2[1];
|
|
375
402
|
|
|
376
|
-
useEffect(function () {
|
|
403
|
+
React.useEffect(function () {
|
|
377
404
|
if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === "undefined") return;
|
|
378
405
|
if (!geography) return;
|
|
379
406
|
|
|
@@ -394,7 +421,7 @@ function useGeographies(_ref) {
|
|
|
394
421
|
}
|
|
395
422
|
}, [geography, parseGeographies]);
|
|
396
423
|
|
|
397
|
-
var _useMemo = useMemo(function () {
|
|
424
|
+
var _useMemo = React.useMemo(function () {
|
|
398
425
|
var mesh = output.mesh || {};
|
|
399
426
|
var preparedMesh = prepareMesh(mesh.outline, mesh.borders, path);
|
|
400
427
|
return {
|
|
@@ -424,7 +451,7 @@ var Geographies = function Geographies(_ref) {
|
|
|
424
451
|
className = _ref$className === void 0 ? "" : _ref$className,
|
|
425
452
|
restProps = _objectWithoutProperties(_ref, _excluded$7);
|
|
426
453
|
|
|
427
|
-
var _useContext = useContext(MapContext),
|
|
454
|
+
var _useContext = React.useContext(MapContext),
|
|
428
455
|
path = _useContext.path,
|
|
429
456
|
projection = _useContext.projection;
|
|
430
457
|
|
|
@@ -436,7 +463,7 @@ var Geographies = function Geographies(_ref) {
|
|
|
436
463
|
outline = _useGeographies.outline,
|
|
437
464
|
borders = _useGeographies.borders;
|
|
438
465
|
|
|
439
|
-
return /*#__PURE__*/
|
|
466
|
+
return /*#__PURE__*/React__default["default"].createElement("g", _extends({
|
|
440
467
|
className: "rsm-geographies ".concat(className)
|
|
441
468
|
}, restProps), geographies && geographies.length > 0 && children({
|
|
442
469
|
geographies: geographies,
|
|
@@ -448,10 +475,10 @@ var Geographies = function Geographies(_ref) {
|
|
|
448
475
|
};
|
|
449
476
|
|
|
450
477
|
Geographies.propTypes = {
|
|
451
|
-
geography:
|
|
452
|
-
children:
|
|
453
|
-
parseGeographies:
|
|
454
|
-
className:
|
|
478
|
+
geography: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].object, PropTypes__default["default"].array]),
|
|
479
|
+
children: PropTypes__default["default"].func,
|
|
480
|
+
parseGeographies: PropTypes__default["default"].func,
|
|
481
|
+
className: PropTypes__default["default"].string
|
|
455
482
|
};
|
|
456
483
|
|
|
457
484
|
var _excluded$6 = ["geography", "onMouseEnter", "onMouseLeave", "onMouseDown", "onMouseUp", "onFocus", "onBlur", "style", "className"];
|
|
@@ -470,12 +497,12 @@ var Geography = function Geography(_ref) {
|
|
|
470
497
|
className = _ref$className === void 0 ? "" : _ref$className,
|
|
471
498
|
restProps = _objectWithoutProperties(_ref, _excluded$6);
|
|
472
499
|
|
|
473
|
-
var _useState = useState(false),
|
|
500
|
+
var _useState = React.useState(false),
|
|
474
501
|
_useState2 = _slicedToArray(_useState, 2),
|
|
475
502
|
isPressed = _useState2[0],
|
|
476
503
|
setPressed = _useState2[1];
|
|
477
504
|
|
|
478
|
-
var _useState3 = useState(false),
|
|
505
|
+
var _useState3 = React.useState(false),
|
|
479
506
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
480
507
|
isFocused = _useState4[0],
|
|
481
508
|
setFocus = _useState4[1];
|
|
@@ -512,7 +539,7 @@ var Geography = function Geography(_ref) {
|
|
|
512
539
|
if (onMouseUp) onMouseUp(evt);
|
|
513
540
|
}
|
|
514
541
|
|
|
515
|
-
return /*#__PURE__*/
|
|
542
|
+
return /*#__PURE__*/React__default["default"].createElement("path", _extends({
|
|
516
543
|
tabIndex: "0",
|
|
517
544
|
className: "rsm-geography ".concat(className),
|
|
518
545
|
d: geography.svgPath,
|
|
@@ -527,17 +554,17 @@ var Geography = function Geography(_ref) {
|
|
|
527
554
|
};
|
|
528
555
|
|
|
529
556
|
Geography.propTypes = {
|
|
530
|
-
geography:
|
|
531
|
-
onMouseEnter:
|
|
532
|
-
onMouseLeave:
|
|
533
|
-
onMouseDown:
|
|
534
|
-
onMouseUp:
|
|
535
|
-
onFocus:
|
|
536
|
-
onBlur:
|
|
537
|
-
style:
|
|
538
|
-
className:
|
|
557
|
+
geography: PropTypes__default["default"].object,
|
|
558
|
+
onMouseEnter: PropTypes__default["default"].func,
|
|
559
|
+
onMouseLeave: PropTypes__default["default"].func,
|
|
560
|
+
onMouseDown: PropTypes__default["default"].func,
|
|
561
|
+
onMouseUp: PropTypes__default["default"].func,
|
|
562
|
+
onFocus: PropTypes__default["default"].func,
|
|
563
|
+
onBlur: PropTypes__default["default"].func,
|
|
564
|
+
style: PropTypes__default["default"].object,
|
|
565
|
+
className: PropTypes__default["default"].string
|
|
539
566
|
};
|
|
540
|
-
var Geography$1 = memo(Geography);
|
|
567
|
+
var Geography$1 = React.memo(Geography);
|
|
541
568
|
|
|
542
569
|
var _excluded$5 = ["fill", "stroke", "step", "className"];
|
|
543
570
|
|
|
@@ -552,11 +579,11 @@ var Graticule = function Graticule(_ref) {
|
|
|
552
579
|
className = _ref$className === void 0 ? "" : _ref$className,
|
|
553
580
|
restProps = _objectWithoutProperties(_ref, _excluded$5);
|
|
554
581
|
|
|
555
|
-
var _useContext = useContext(MapContext),
|
|
582
|
+
var _useContext = React.useContext(MapContext),
|
|
556
583
|
path = _useContext.path;
|
|
557
584
|
|
|
558
|
-
return /*#__PURE__*/
|
|
559
|
-
d: path(geoGraticule().step(step)()),
|
|
585
|
+
return /*#__PURE__*/React__default["default"].createElement("path", _extends({
|
|
586
|
+
d: path(d3Geo.geoGraticule().step(step)()),
|
|
560
587
|
fill: fill,
|
|
561
588
|
stroke: stroke,
|
|
562
589
|
className: "rsm-graticule ".concat(className)
|
|
@@ -564,12 +591,12 @@ var Graticule = function Graticule(_ref) {
|
|
|
564
591
|
};
|
|
565
592
|
|
|
566
593
|
Graticule.propTypes = {
|
|
567
|
-
fill:
|
|
568
|
-
stroke:
|
|
569
|
-
step:
|
|
570
|
-
className:
|
|
594
|
+
fill: PropTypes__default["default"].string,
|
|
595
|
+
stroke: PropTypes__default["default"].string,
|
|
596
|
+
step: PropTypes__default["default"].array,
|
|
597
|
+
className: PropTypes__default["default"].string
|
|
571
598
|
};
|
|
572
|
-
var Graticule$1 = memo(Graticule);
|
|
599
|
+
var Graticule$1 = React.memo(Graticule);
|
|
573
600
|
|
|
574
601
|
function useZoomPan(_ref) {
|
|
575
602
|
var center = _ref.center,
|
|
@@ -582,9 +609,9 @@ function useZoomPan(_ref) {
|
|
|
582
609
|
_ref$scaleExtent = _ref.scaleExtent,
|
|
583
610
|
scaleExtent = _ref$scaleExtent === void 0 ? [1, 8] : _ref$scaleExtent,
|
|
584
611
|
_ref$zoom = _ref.zoom,
|
|
585
|
-
zoom
|
|
612
|
+
zoom = _ref$zoom === void 0 ? 1 : _ref$zoom;
|
|
586
613
|
|
|
587
|
-
var _useContext = useContext(MapContext),
|
|
614
|
+
var _useContext = React.useContext(MapContext),
|
|
588
615
|
width = _useContext.width,
|
|
589
616
|
height = _useContext.height,
|
|
590
617
|
projection = _useContext.projection;
|
|
@@ -593,7 +620,7 @@ function useZoomPan(_ref) {
|
|
|
593
620
|
lon = _center[0],
|
|
594
621
|
lat = _center[1];
|
|
595
622
|
|
|
596
|
-
var _useState = useState({
|
|
623
|
+
var _useState = React.useState({
|
|
597
624
|
x: 0,
|
|
598
625
|
y: 0,
|
|
599
626
|
k: 1
|
|
@@ -602,14 +629,14 @@ function useZoomPan(_ref) {
|
|
|
602
629
|
position = _useState2[0],
|
|
603
630
|
setPosition = _useState2[1];
|
|
604
631
|
|
|
605
|
-
var lastPosition = useRef({
|
|
632
|
+
var lastPosition = React.useRef({
|
|
606
633
|
x: 0,
|
|
607
634
|
y: 0,
|
|
608
635
|
k: 1
|
|
609
636
|
});
|
|
610
|
-
var mapRef = useRef();
|
|
611
|
-
var zoomRef = useRef();
|
|
612
|
-
var bypassEvents = useRef(false);
|
|
637
|
+
var mapRef = React.useRef();
|
|
638
|
+
var zoomRef = React.useRef();
|
|
639
|
+
var bypassEvents = React.useRef(false);
|
|
613
640
|
|
|
614
641
|
var _translateExtent = _slicedToArray(translateExtent, 2),
|
|
615
642
|
a = _translateExtent[0],
|
|
@@ -627,8 +654,8 @@ function useZoomPan(_ref) {
|
|
|
627
654
|
minZoom = _scaleExtent[0],
|
|
628
655
|
maxZoom = _scaleExtent[1];
|
|
629
656
|
|
|
630
|
-
useEffect(function () {
|
|
631
|
-
var svg = select(mapRef.current);
|
|
657
|
+
React.useEffect(function () {
|
|
658
|
+
var svg = d3Selection.select(mapRef.current);
|
|
632
659
|
|
|
633
660
|
function handleZoomStart(d3Event) {
|
|
634
661
|
if (!onMoveStart || bypassEvents.current) return;
|
|
@@ -688,29 +715,29 @@ function useZoomPan(_ref) {
|
|
|
688
715
|
return d3Event ? !d3Event.ctrlKey && !d3Event.button : false;
|
|
689
716
|
}
|
|
690
717
|
|
|
691
|
-
var zoom
|
|
692
|
-
zoomRef.current = zoom
|
|
693
|
-
svg.call(zoom
|
|
718
|
+
var zoom = d3Zoom.zoom().filter(filterFunc).scaleExtent([minZoom, maxZoom]).translateExtent([[a1, a2], [b1, b2]]).on("start", handleZoomStart).on("zoom", handleZoom).on("end", handleZoomEnd);
|
|
719
|
+
zoomRef.current = zoom;
|
|
720
|
+
svg.call(zoom);
|
|
694
721
|
}, [width, height, a1, a2, b1, b2, minZoom, maxZoom, projection, onMoveStart, onMove, onMoveEnd, filterZoomEvent]);
|
|
695
|
-
useEffect(function () {
|
|
696
|
-
if (lon === lastPosition.current.x && lat === lastPosition.current.y && zoom
|
|
722
|
+
React.useEffect(function () {
|
|
723
|
+
if (lon === lastPosition.current.x && lat === lastPosition.current.y && zoom === lastPosition.current.k) return;
|
|
697
724
|
var coords = projection([lon, lat]);
|
|
698
|
-
var x = coords[0] * zoom
|
|
699
|
-
var y = coords[1] * zoom
|
|
700
|
-
var svg = select(mapRef.current);
|
|
725
|
+
var x = coords[0] * zoom;
|
|
726
|
+
var y = coords[1] * zoom;
|
|
727
|
+
var svg = d3Selection.select(mapRef.current);
|
|
701
728
|
bypassEvents.current = true;
|
|
702
|
-
svg.call(zoomRef.current.transform, zoomIdentity.translate(width / 2 - x, height / 2 - y).scale(zoom
|
|
729
|
+
svg.call(zoomRef.current.transform, d3Zoom.zoomIdentity.translate(width / 2 - x, height / 2 - y).scale(zoom));
|
|
703
730
|
setPosition({
|
|
704
731
|
x: width / 2 - x,
|
|
705
732
|
y: height / 2 - y,
|
|
706
|
-
k: zoom
|
|
733
|
+
k: zoom
|
|
707
734
|
});
|
|
708
735
|
lastPosition.current = {
|
|
709
736
|
x: lon,
|
|
710
737
|
y: lat,
|
|
711
|
-
k: zoom
|
|
738
|
+
k: zoom
|
|
712
739
|
};
|
|
713
|
-
}, [lon, lat, zoom
|
|
740
|
+
}, [lon, lat, zoom, width, height, projection]);
|
|
714
741
|
return {
|
|
715
742
|
mapRef: mapRef,
|
|
716
743
|
position: position,
|
|
@@ -737,7 +764,7 @@ var ZoomableGroup = function ZoomableGroup(_ref) {
|
|
|
737
764
|
className = _ref.className,
|
|
738
765
|
restProps = _objectWithoutProperties(_ref, _excluded$4);
|
|
739
766
|
|
|
740
|
-
var _useContext = useContext(MapContext),
|
|
767
|
+
var _useContext = React.useContext(MapContext),
|
|
741
768
|
width = _useContext.width,
|
|
742
769
|
height = _useContext.height;
|
|
743
770
|
|
|
@@ -754,28 +781,28 @@ var ZoomableGroup = function ZoomableGroup(_ref) {
|
|
|
754
781
|
mapRef = _useZoomPan.mapRef,
|
|
755
782
|
transformString = _useZoomPan.transformString;
|
|
756
783
|
|
|
757
|
-
return /*#__PURE__*/
|
|
784
|
+
return /*#__PURE__*/React__default["default"].createElement("g", {
|
|
758
785
|
ref: mapRef
|
|
759
|
-
}, /*#__PURE__*/
|
|
786
|
+
}, /*#__PURE__*/React__default["default"].createElement("rect", {
|
|
760
787
|
width: width,
|
|
761
788
|
height: height,
|
|
762
789
|
fill: "transparent"
|
|
763
|
-
}), /*#__PURE__*/
|
|
790
|
+
}), /*#__PURE__*/React__default["default"].createElement("g", _extends({
|
|
764
791
|
transform: transformString,
|
|
765
792
|
className: "rsm-zoomable-group ".concat(className)
|
|
766
793
|
}, restProps)));
|
|
767
794
|
};
|
|
768
795
|
|
|
769
796
|
ZoomableGroup.propTypes = {
|
|
770
|
-
center:
|
|
771
|
-
zoom:
|
|
772
|
-
minZoom:
|
|
773
|
-
maxZoom:
|
|
774
|
-
translateExtent:
|
|
775
|
-
onMoveStart:
|
|
776
|
-
onMove:
|
|
777
|
-
onMoveEnd:
|
|
778
|
-
className:
|
|
797
|
+
center: PropTypes__default["default"].array,
|
|
798
|
+
zoom: PropTypes__default["default"].number,
|
|
799
|
+
minZoom: PropTypes__default["default"].number,
|
|
800
|
+
maxZoom: PropTypes__default["default"].number,
|
|
801
|
+
translateExtent: PropTypes__default["default"].arrayOf(PropTypes__default["default"].array),
|
|
802
|
+
onMoveStart: PropTypes__default["default"].func,
|
|
803
|
+
onMove: PropTypes__default["default"].func,
|
|
804
|
+
onMoveEnd: PropTypes__default["default"].func,
|
|
805
|
+
className: PropTypes__default["default"].string
|
|
779
806
|
};
|
|
780
807
|
|
|
781
808
|
var _excluded$3 = ["id", "fill", "stroke", "strokeWidth", "className"];
|
|
@@ -793,19 +820,19 @@ var Sphere = function Sphere(_ref) {
|
|
|
793
820
|
className = _ref$className === void 0 ? "" : _ref$className,
|
|
794
821
|
restProps = _objectWithoutProperties(_ref, _excluded$3);
|
|
795
822
|
|
|
796
|
-
var _useContext = useContext(MapContext),
|
|
823
|
+
var _useContext = React.useContext(MapContext),
|
|
797
824
|
path = _useContext.path;
|
|
798
825
|
|
|
799
|
-
var spherePath = useMemo(function () {
|
|
826
|
+
var spherePath = React.useMemo(function () {
|
|
800
827
|
return path({
|
|
801
828
|
type: "Sphere"
|
|
802
829
|
});
|
|
803
830
|
}, [path]);
|
|
804
|
-
return /*#__PURE__*/
|
|
831
|
+
return /*#__PURE__*/React__default["default"].createElement(React.Fragment, null, /*#__PURE__*/React__default["default"].createElement("defs", null, /*#__PURE__*/React__default["default"].createElement("clipPath", {
|
|
805
832
|
id: id
|
|
806
|
-
}, /*#__PURE__*/
|
|
833
|
+
}, /*#__PURE__*/React__default["default"].createElement("path", {
|
|
807
834
|
d: spherePath
|
|
808
|
-
}))), /*#__PURE__*/
|
|
835
|
+
}))), /*#__PURE__*/React__default["default"].createElement("path", _extends({
|
|
809
836
|
d: spherePath,
|
|
810
837
|
fill: fill,
|
|
811
838
|
stroke: stroke,
|
|
@@ -818,13 +845,13 @@ var Sphere = function Sphere(_ref) {
|
|
|
818
845
|
};
|
|
819
846
|
|
|
820
847
|
Sphere.propTypes = {
|
|
821
|
-
id:
|
|
822
|
-
fill:
|
|
823
|
-
stroke:
|
|
824
|
-
strokeWidth:
|
|
825
|
-
className:
|
|
848
|
+
id: PropTypes__default["default"].string,
|
|
849
|
+
fill: PropTypes__default["default"].string,
|
|
850
|
+
stroke: PropTypes__default["default"].string,
|
|
851
|
+
strokeWidth: PropTypes__default["default"].number,
|
|
852
|
+
className: PropTypes__default["default"].string
|
|
826
853
|
};
|
|
827
|
-
var Sphere$1 = memo(Sphere);
|
|
854
|
+
var Sphere$1 = React.memo(Sphere);
|
|
828
855
|
|
|
829
856
|
var _excluded$2 = ["coordinates", "children", "onMouseEnter", "onMouseLeave", "onMouseDown", "onMouseUp", "onFocus", "onBlur", "style", "className"];
|
|
830
857
|
|
|
@@ -843,15 +870,15 @@ var Marker = function Marker(_ref) {
|
|
|
843
870
|
className = _ref$className === void 0 ? "" : _ref$className,
|
|
844
871
|
restProps = _objectWithoutProperties(_ref, _excluded$2);
|
|
845
872
|
|
|
846
|
-
var _useContext = useContext(MapContext),
|
|
873
|
+
var _useContext = React.useContext(MapContext),
|
|
847
874
|
projection = _useContext.projection;
|
|
848
875
|
|
|
849
|
-
var _useState = useState(false),
|
|
876
|
+
var _useState = React.useState(false),
|
|
850
877
|
_useState2 = _slicedToArray(_useState, 2),
|
|
851
878
|
isPressed = _useState2[0],
|
|
852
879
|
setPressed = _useState2[1];
|
|
853
880
|
|
|
854
|
-
var _useState3 = useState(false),
|
|
881
|
+
var _useState3 = React.useState(false),
|
|
855
882
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
856
883
|
isFocused = _useState4[0],
|
|
857
884
|
setFocus = _useState4[1];
|
|
@@ -893,7 +920,7 @@ var Marker = function Marker(_ref) {
|
|
|
893
920
|
if (onMouseUp) onMouseUp(evt);
|
|
894
921
|
}
|
|
895
922
|
|
|
896
|
-
return /*#__PURE__*/
|
|
923
|
+
return /*#__PURE__*/React__default["default"].createElement("g", _extends({
|
|
897
924
|
transform: "translate(".concat(x, ", ").concat(y, ")"),
|
|
898
925
|
className: "rsm-marker ".concat(className),
|
|
899
926
|
onMouseEnter: handleMouseEnter,
|
|
@@ -907,16 +934,16 @@ var Marker = function Marker(_ref) {
|
|
|
907
934
|
};
|
|
908
935
|
|
|
909
936
|
Marker.propTypes = {
|
|
910
|
-
coordinates:
|
|
911
|
-
children:
|
|
912
|
-
onMouseEnter:
|
|
913
|
-
onMouseLeave:
|
|
914
|
-
onMouseDown:
|
|
915
|
-
onMouseUp:
|
|
916
|
-
onFocus:
|
|
917
|
-
onBlur:
|
|
918
|
-
style:
|
|
919
|
-
className:
|
|
937
|
+
coordinates: PropTypes__default["default"].array,
|
|
938
|
+
children: PropTypes__default["default"].oneOfType([PropTypes__default["default"].node, PropTypes__default["default"].arrayOf(PropTypes__default["default"].node)]),
|
|
939
|
+
onMouseEnter: PropTypes__default["default"].func,
|
|
940
|
+
onMouseLeave: PropTypes__default["default"].func,
|
|
941
|
+
onMouseDown: PropTypes__default["default"].func,
|
|
942
|
+
onMouseUp: PropTypes__default["default"].func,
|
|
943
|
+
onFocus: PropTypes__default["default"].func,
|
|
944
|
+
onBlur: PropTypes__default["default"].func,
|
|
945
|
+
style: PropTypes__default["default"].object,
|
|
946
|
+
className: PropTypes__default["default"].string
|
|
920
947
|
};
|
|
921
948
|
|
|
922
949
|
var _excluded$1 = ["from", "to", "coordinates", "stroke", "strokeWidth", "fill", "className"];
|
|
@@ -937,14 +964,14 @@ var Line = function Line(_ref) {
|
|
|
937
964
|
className = _ref$className === void 0 ? "" : _ref$className,
|
|
938
965
|
restProps = _objectWithoutProperties(_ref, _excluded$1);
|
|
939
966
|
|
|
940
|
-
var _useContext = useContext(MapContext),
|
|
967
|
+
var _useContext = React.useContext(MapContext),
|
|
941
968
|
path = _useContext.path;
|
|
942
969
|
|
|
943
970
|
var lineData = {
|
|
944
971
|
type: "LineString",
|
|
945
972
|
coordinates: coordinates || [from, to]
|
|
946
973
|
};
|
|
947
|
-
return /*#__PURE__*/
|
|
974
|
+
return /*#__PURE__*/React__default["default"].createElement("path", _extends({
|
|
948
975
|
d: path(lineData),
|
|
949
976
|
className: "rsm-line ".concat(className),
|
|
950
977
|
stroke: stroke,
|
|
@@ -954,13 +981,13 @@ var Line = function Line(_ref) {
|
|
|
954
981
|
};
|
|
955
982
|
|
|
956
983
|
Line.propTypes = {
|
|
957
|
-
from:
|
|
958
|
-
to:
|
|
959
|
-
coordinates:
|
|
960
|
-
stroke:
|
|
961
|
-
strokeWidth:
|
|
962
|
-
fill:
|
|
963
|
-
className:
|
|
984
|
+
from: PropTypes__default["default"].array,
|
|
985
|
+
to: PropTypes__default["default"].array,
|
|
986
|
+
coordinates: PropTypes__default["default"].array,
|
|
987
|
+
stroke: PropTypes__default["default"].string,
|
|
988
|
+
strokeWidth: PropTypes__default["default"].number,
|
|
989
|
+
fill: PropTypes__default["default"].string,
|
|
990
|
+
className: PropTypes__default["default"].string
|
|
964
991
|
};
|
|
965
992
|
|
|
966
993
|
var _excluded = ["subject", "children", "connectorProps", "dx", "dy", "curve", "className"];
|
|
@@ -979,7 +1006,7 @@ var Annotation = function Annotation(_ref) {
|
|
|
979
1006
|
className = _ref$className === void 0 ? "" : _ref$className,
|
|
980
1007
|
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
981
1008
|
|
|
982
|
-
var _useContext = useContext(MapContext),
|
|
1009
|
+
var _useContext = React.useContext(MapContext),
|
|
983
1010
|
projection = _useContext.projection;
|
|
984
1011
|
|
|
985
1012
|
var _projection = projection(subject),
|
|
@@ -988,10 +1015,10 @@ var Annotation = function Annotation(_ref) {
|
|
|
988
1015
|
y = _projection2[1];
|
|
989
1016
|
|
|
990
1017
|
var connectorPath = createConnectorPath(dx, dy, curve);
|
|
991
|
-
return /*#__PURE__*/
|
|
1018
|
+
return /*#__PURE__*/React__default["default"].createElement("g", _extends({
|
|
992
1019
|
transform: "translate(".concat(x + dx, ", ").concat(y + dy, ")"),
|
|
993
1020
|
className: "rsm-annotation ".concat(className)
|
|
994
|
-
}, restProps), /*#__PURE__*/
|
|
1021
|
+
}, restProps), /*#__PURE__*/React__default["default"].createElement("path", _extends({
|
|
995
1022
|
d: connectorPath,
|
|
996
1023
|
fill: "transparent",
|
|
997
1024
|
stroke: "#000"
|
|
@@ -999,13 +1026,25 @@ var Annotation = function Annotation(_ref) {
|
|
|
999
1026
|
};
|
|
1000
1027
|
|
|
1001
1028
|
Annotation.propTypes = {
|
|
1002
|
-
subject:
|
|
1003
|
-
children:
|
|
1004
|
-
dx:
|
|
1005
|
-
dy:
|
|
1006
|
-
curve:
|
|
1007
|
-
connectorProps:
|
|
1008
|
-
className:
|
|
1029
|
+
subject: PropTypes__default["default"].array,
|
|
1030
|
+
children: PropTypes__default["default"].oneOfType([PropTypes__default["default"].node, PropTypes__default["default"].arrayOf(PropTypes__default["default"].node)]),
|
|
1031
|
+
dx: PropTypes__default["default"].number,
|
|
1032
|
+
dy: PropTypes__default["default"].number,
|
|
1033
|
+
curve: PropTypes__default["default"].number,
|
|
1034
|
+
connectorProps: PropTypes__default["default"].object,
|
|
1035
|
+
className: PropTypes__default["default"].string
|
|
1009
1036
|
};
|
|
1010
1037
|
|
|
1011
|
-
|
|
1038
|
+
exports.Annotation = Annotation;
|
|
1039
|
+
exports.ComposableMap = ComposableMap;
|
|
1040
|
+
exports.Geographies = Geographies;
|
|
1041
|
+
exports.Geography = Geography$1;
|
|
1042
|
+
exports.Graticule = Graticule$1;
|
|
1043
|
+
exports.Line = Line;
|
|
1044
|
+
exports.MapContext = MapContext;
|
|
1045
|
+
exports.MapProvider = MapProvider;
|
|
1046
|
+
exports.Marker = Marker;
|
|
1047
|
+
exports.Sphere = Sphere$1;
|
|
1048
|
+
exports.ZoomableGroup = ZoomableGroup;
|
|
1049
|
+
exports.useGeographies = useGeographies;
|
|
1050
|
+
exports.useZoomPan = useZoomPan;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-simple-maps",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.4",
|
|
4
4
|
"description": "An svg map chart component built with and for React",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"react-dom": "^16.8.0 || 17.x || 18.x"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"d3-geo": "^
|
|
60
|
-
"d3-selection": "^
|
|
61
|
-
"d3-zoom": "^
|
|
59
|
+
"d3-geo": "^2.0.2",
|
|
60
|
+
"d3-selection": "^2.0.0",
|
|
61
|
+
"d3-zoom": "^2.0.0",
|
|
62
62
|
"topojson-client": "^3.1.0"
|
|
63
63
|
}
|
|
64
64
|
}
|