national-metadata 0.1.4 → 0.1.5

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.
Files changed (129) hide show
  1. package/dist/mapping/index.d.ts +26 -0
  2. package/dist/mapping/index.d.ts.map +1 -0
  3. package/dist/mapping/index.js +16 -0
  4. package/dist/mapping/index.js.map +1 -0
  5. package/dist/mapping/src/components/Annotation.d.ts +13 -0
  6. package/dist/mapping/src/components/Annotation.d.ts.map +1 -0
  7. package/dist/mapping/src/components/Annotation.js +15 -0
  8. package/dist/mapping/src/components/Annotation.js.map +1 -0
  9. package/dist/mapping/src/components/ComposableMap.d.ts +13 -0
  10. package/dist/mapping/src/components/ComposableMap.d.ts.map +1 -0
  11. package/dist/mapping/src/components/ComposableMap.js +9 -0
  12. package/dist/mapping/src/components/ComposableMap.js.map +1 -0
  13. package/dist/mapping/src/components/Geographies.d.ts +20 -0
  14. package/dist/mapping/src/components/Geographies.d.ts.map +1 -0
  15. package/dist/mapping/src/components/Geographies.js +16 -0
  16. package/dist/mapping/src/components/Geographies.js.map +1 -0
  17. package/dist/mapping/src/components/Geography.d.ts +21 -0
  18. package/dist/mapping/src/components/Geography.d.ts.map +1 -0
  19. package/dist/mapping/src/components/Geography.js +44 -0
  20. package/dist/mapping/src/components/Geography.js.map +1 -0
  21. package/dist/mapping/src/components/Graticule.d.ts +10 -0
  22. package/dist/mapping/src/components/Graticule.d.ts.map +1 -0
  23. package/dist/mapping/src/components/Graticule.js +10 -0
  24. package/dist/mapping/src/components/Graticule.js.map +1 -0
  25. package/dist/mapping/src/components/Line.d.ts +13 -0
  26. package/dist/mapping/src/components/Line.d.ts.map +1 -0
  27. package/dist/mapping/src/components/Line.js +13 -0
  28. package/dist/mapping/src/components/Line.js.map +1 -0
  29. package/dist/mapping/src/components/MapProvider.d.ts +26 -0
  30. package/dist/mapping/src/components/MapProvider.d.ts.map +1 -0
  31. package/dist/mapping/src/components/MapProvider.js +62 -0
  32. package/dist/mapping/src/components/MapProvider.js.map +1 -0
  33. package/dist/mapping/src/components/Marker.d.ts +21 -0
  34. package/dist/mapping/src/components/Marker.d.ts.map +1 -0
  35. package/dist/mapping/src/components/Marker.js +48 -0
  36. package/dist/mapping/src/components/Marker.js.map +1 -0
  37. package/dist/mapping/src/components/Sphere.d.ts +11 -0
  38. package/dist/mapping/src/components/Sphere.d.ts.map +1 -0
  39. package/dist/mapping/src/components/Sphere.js +14 -0
  40. package/dist/mapping/src/components/Sphere.js.map +1 -0
  41. package/dist/mapping/src/components/ZoomPanProvider.d.ts +14 -0
  42. package/dist/mapping/src/components/ZoomPanProvider.d.ts.map +1 -0
  43. package/dist/mapping/src/components/ZoomPanProvider.js +16 -0
  44. package/dist/mapping/src/components/ZoomPanProvider.js.map +1 -0
  45. package/dist/mapping/src/components/ZoomableGroup.d.ts +30 -0
  46. package/dist/mapping/src/components/ZoomableGroup.d.ts.map +1 -0
  47. package/dist/mapping/src/components/ZoomableGroup.js +24 -0
  48. package/dist/mapping/src/components/ZoomableGroup.js.map +1 -0
  49. package/dist/mapping/src/components/useGeographies.d.ts +13 -0
  50. package/dist/mapping/src/components/useGeographies.d.ts.map +1 -0
  51. package/dist/mapping/src/components/useGeographies.js +41 -0
  52. package/dist/mapping/src/components/useGeographies.js.map +1 -0
  53. package/dist/mapping/src/components/useZoomPan.d.ts +36 -0
  54. package/dist/mapping/src/components/useZoomPan.d.ts.map +1 -0
  55. package/dist/mapping/src/components/useZoomPan.js +129 -0
  56. package/dist/mapping/src/components/useZoomPan.js.map +1 -0
  57. package/dist/mapping/src/index.d.ts +14 -0
  58. package/dist/mapping/src/index.d.ts.map +1 -0
  59. package/dist/mapping/src/index.js +14 -0
  60. package/dist/mapping/src/index.js.map +1 -0
  61. package/dist/mapping/src/utils.d.ts +29 -0
  62. package/dist/mapping/src/utils.d.ts.map +1 -0
  63. package/dist/mapping/src/utils.js +71 -0
  64. package/dist/mapping/src/utils.js.map +1 -0
  65. package/dist/react-simple-maps/index.d.ts +14 -0
  66. package/dist/react-simple-maps/index.d.ts.map +1 -0
  67. package/dist/react-simple-maps/index.js +16 -0
  68. package/dist/react-simple-maps/index.js.map +1 -0
  69. package/dist/react-simple-maps/src/components/Annotation.d.ts +3 -0
  70. package/dist/react-simple-maps/src/components/Annotation.d.ts.map +1 -0
  71. package/dist/react-simple-maps/src/components/Annotation.js +27 -0
  72. package/dist/react-simple-maps/src/components/Annotation.js.map +1 -0
  73. package/dist/react-simple-maps/src/components/ComposableMap.d.ts +3 -0
  74. package/dist/react-simple-maps/src/components/ComposableMap.d.ts.map +1 -0
  75. package/dist/react-simple-maps/src/components/ComposableMap.js +17 -0
  76. package/dist/react-simple-maps/src/components/ComposableMap.js.map +1 -0
  77. package/dist/react-simple-maps/src/components/Geographies.d.ts +3 -0
  78. package/dist/react-simple-maps/src/components/Geographies.d.ts.map +1 -0
  79. package/dist/react-simple-maps/src/components/Geographies.js +27 -0
  80. package/dist/react-simple-maps/src/components/Geographies.js.map +1 -0
  81. package/dist/react-simple-maps/src/components/Geography.d.ts +3 -0
  82. package/dist/react-simple-maps/src/components/Geography.d.ts.map +1 -0
  83. package/dist/react-simple-maps/src/components/Geography.js +59 -0
  84. package/dist/react-simple-maps/src/components/Geography.js.map +1 -0
  85. package/dist/react-simple-maps/src/components/Graticule.d.ts +3 -0
  86. package/dist/react-simple-maps/src/components/Graticule.d.ts.map +1 -0
  87. package/dist/react-simple-maps/src/components/Graticule.js +17 -0
  88. package/dist/react-simple-maps/src/components/Graticule.js.map +1 -0
  89. package/dist/react-simple-maps/src/components/Line.d.ts +3 -0
  90. package/dist/react-simple-maps/src/components/Line.d.ts.map +1 -0
  91. package/dist/react-simple-maps/src/components/Line.js +23 -0
  92. package/dist/react-simple-maps/src/components/Line.js.map +1 -0
  93. package/dist/react-simple-maps/src/components/MapProvider.d.ts +18 -0
  94. package/dist/react-simple-maps/src/components/MapProvider.d.ts.map +1 -0
  95. package/dist/react-simple-maps/src/components/MapProvider.js +63 -0
  96. package/dist/react-simple-maps/src/components/MapProvider.js.map +1 -0
  97. package/dist/react-simple-maps/src/components/Marker.d.ts +3 -0
  98. package/dist/react-simple-maps/src/components/Marker.d.ts.map +1 -0
  99. package/dist/react-simple-maps/src/components/Marker.js +66 -0
  100. package/dist/react-simple-maps/src/components/Marker.js.map +1 -0
  101. package/dist/react-simple-maps/src/components/Sphere.d.ts +3 -0
  102. package/dist/react-simple-maps/src/components/Sphere.d.ts.map +1 -0
  103. package/dist/react-simple-maps/src/components/Sphere.js +22 -0
  104. package/dist/react-simple-maps/src/components/Sphere.js.map +1 -0
  105. package/dist/react-simple-maps/src/components/ZoomPanProvider.d.ts +20 -0
  106. package/dist/react-simple-maps/src/components/ZoomPanProvider.d.ts.map +1 -0
  107. package/dist/react-simple-maps/src/components/ZoomPanProvider.js +23 -0
  108. package/dist/react-simple-maps/src/components/ZoomPanProvider.js.map +1 -0
  109. package/dist/react-simple-maps/src/components/ZoomableGroup.d.ts +3 -0
  110. package/dist/react-simple-maps/src/components/ZoomableGroup.d.ts.map +1 -0
  111. package/dist/react-simple-maps/src/components/ZoomableGroup.js +36 -0
  112. package/dist/react-simple-maps/src/components/ZoomableGroup.js.map +1 -0
  113. package/dist/react-simple-maps/src/components/useGeographies.d.ts +9 -0
  114. package/dist/react-simple-maps/src/components/useGeographies.d.ts.map +1 -0
  115. package/dist/react-simple-maps/src/components/useGeographies.js +40 -0
  116. package/dist/react-simple-maps/src/components/useGeographies.js.map +1 -0
  117. package/dist/react-simple-maps/src/components/useZoomPan.d.ts +15 -0
  118. package/dist/react-simple-maps/src/components/useZoomPan.d.ts.map +1 -0
  119. package/dist/react-simple-maps/src/components/useZoomPan.js +114 -0
  120. package/dist/react-simple-maps/src/components/useZoomPan.js.map +1 -0
  121. package/dist/react-simple-maps/src/index.d.ts +14 -0
  122. package/dist/react-simple-maps/src/index.d.ts.map +1 -0
  123. package/dist/react-simple-maps/src/index.js +14 -0
  124. package/dist/react-simple-maps/src/index.js.map +1 -0
  125. package/dist/react-simple-maps/src/utils.d.ts +18 -0
  126. package/dist/react-simple-maps/src/utils.d.ts.map +1 -0
  127. package/dist/react-simple-maps/src/utils.js +65 -0
  128. package/dist/react-simple-maps/src/utils.js.map +1 -0
  129. package/package.json +36 -2
@@ -0,0 +1,114 @@
1
+ import { useEffect, useRef, useState, useContext } from "react";
2
+ import { zoom as d3Zoom, zoomIdentity as d3ZoomIdentity } from "d3-zoom";
3
+ import { select as d3Select } from "d3-selection";
4
+ import { MapContext } from "./MapProvider";
5
+ import { getCoords } from "../utils";
6
+ export default function useZoomPan({ center, filterZoomEvent, onMoveStart, onMoveEnd, onMove, translateExtent = [
7
+ [-Infinity, -Infinity],
8
+ [Infinity, Infinity],
9
+ ], scaleExtent = [1, 8], zoom = 1, }) {
10
+ const { width, height, projection } = useContext(MapContext);
11
+ const [lon, lat] = center;
12
+ const [position, setPosition] = useState({ x: 0, y: 0, k: 1 });
13
+ const lastPosition = useRef({ x: 0, y: 0, k: 1 });
14
+ const mapRef = useRef();
15
+ const zoomRef = useRef();
16
+ const bypassEvents = useRef(false);
17
+ const [a, b] = translateExtent;
18
+ const [a1, a2] = a;
19
+ const [b1, b2] = b;
20
+ const [minZoom, maxZoom] = scaleExtent;
21
+ useEffect(() => {
22
+ const svg = d3Select(mapRef.current);
23
+ function handleZoomStart(d3Event) {
24
+ if (!onMoveStart || bypassEvents.current)
25
+ return;
26
+ onMoveStart({
27
+ coordinates: projection.invert(getCoords(width, height, d3Event.transform)),
28
+ zoom: d3Event.transform.k,
29
+ }, d3Event);
30
+ }
31
+ function handleZoom(d3Event) {
32
+ if (bypassEvents.current)
33
+ return;
34
+ const { transform, sourceEvent } = d3Event;
35
+ setPosition({
36
+ x: transform.x,
37
+ y: transform.y,
38
+ k: transform.k,
39
+ dragging: sourceEvent,
40
+ });
41
+ if (!onMove)
42
+ return;
43
+ onMove({
44
+ x: transform.x,
45
+ y: transform.y,
46
+ zoom: transform.k,
47
+ dragging: sourceEvent,
48
+ }, d3Event);
49
+ }
50
+ function handleZoomEnd(d3Event) {
51
+ if (bypassEvents.current) {
52
+ bypassEvents.current = false;
53
+ return;
54
+ }
55
+ const [x, y] = projection.invert(getCoords(width, height, d3Event.transform));
56
+ lastPosition.current = { x, y, k: d3Event.transform.k };
57
+ if (!onMoveEnd)
58
+ return;
59
+ onMoveEnd({ coordinates: [x, y], zoom: d3Event.transform.k }, d3Event);
60
+ }
61
+ function filterFunc(d3Event) {
62
+ if (filterZoomEvent) {
63
+ return filterZoomEvent(d3Event);
64
+ }
65
+ return d3Event ? !d3Event.ctrlKey && !d3Event.button : false;
66
+ }
67
+ const zoom = d3Zoom()
68
+ .filter(filterFunc)
69
+ .scaleExtent([minZoom, maxZoom])
70
+ .translateExtent([
71
+ [a1, a2],
72
+ [b1, b2],
73
+ ])
74
+ .on("start", handleZoomStart)
75
+ .on("zoom", handleZoom)
76
+ .on("end", handleZoomEnd);
77
+ zoomRef.current = zoom;
78
+ svg.call(zoom);
79
+ }, [
80
+ width,
81
+ height,
82
+ a1,
83
+ a2,
84
+ b1,
85
+ b2,
86
+ minZoom,
87
+ maxZoom,
88
+ projection,
89
+ onMoveStart,
90
+ onMove,
91
+ onMoveEnd,
92
+ filterZoomEvent,
93
+ ]);
94
+ useEffect(() => {
95
+ if (lon === lastPosition.current.x &&
96
+ lat === lastPosition.current.y &&
97
+ zoom === lastPosition.current.k)
98
+ return;
99
+ const coords = projection([lon, lat]);
100
+ const x = coords[0] * zoom;
101
+ const y = coords[1] * zoom;
102
+ const svg = d3Select(mapRef.current);
103
+ bypassEvents.current = true;
104
+ svg.call(zoomRef.current.transform, d3ZoomIdentity.translate(width / 2 - x, height / 2 - y).scale(zoom));
105
+ setPosition({ x: width / 2 - x, y: height / 2 - y, k: zoom });
106
+ lastPosition.current = { x: lon, y: lat, k: zoom };
107
+ }, [lon, lat, zoom, width, height, projection]);
108
+ return {
109
+ mapRef,
110
+ position,
111
+ transformString: `translate(${position.x} ${position.y}) scale(${position.k})`,
112
+ };
113
+ }
114
+ //# sourceMappingURL=useZoomPan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useZoomPan.js","sourceRoot":"","sources":["../../../../src/react-simple-maps/src/components/useZoomPan.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAC/D,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,YAAY,IAAI,cAAc,EAAE,MAAM,SAAS,CAAA;AACxE,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,MAAM,EACN,eAAe,EACf,WAAW,EACX,SAAS,EACT,MAAM,EACN,eAAe,GAAG;IAChB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC;IACtB,CAAC,QAAQ,EAAE,QAAQ,CAAC;CACrB,EACD,WAAW,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,IAAI,GAAG,CAAC,GACT;IACC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CAAC,UAAU,CAAC,CAAA;IAE5D,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,MAAM,CAAA;IACzB,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;IAC9D,MAAM,YAAY,GAAG,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;IACjD,MAAM,MAAM,GAAG,MAA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E,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAA;IACpD,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;IAE/C,OAAO;QACL,MAAM;QACN,QAAQ;QACR,eAAe,EAAE,aAAa,QAAQ,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,WAAW,QAAQ,CAAC,CAAC,GAAG;KAC/E,CAAA;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ export { default as ComposableMap } from "./components/ComposableMap";
2
+ export { default as Geographies } from "./components/Geographies";
3
+ export { default as Geography } from "./components/Geography";
4
+ export { default as Graticule } from "./components/Graticule";
5
+ export { default as ZoomableGroup } from "./components/ZoomableGroup";
6
+ export { default as Sphere } from "./components/Sphere";
7
+ export { default as Marker } from "./components/Marker";
8
+ export { default as Line } from "./components/Line";
9
+ export { default as Annotation } from "./components/Annotation";
10
+ export { default as useGeographies } from "./components/useGeographies";
11
+ export { default as useZoomPan } from "./components/useZoomPan";
12
+ export { MapProvider, MapContext, useMapContext } from "./components/MapProvider";
13
+ export { ZoomPanProvider, ZoomPanContext, useZoomPanContext } from "./components/ZoomPanProvider";
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react-simple-maps/src/index.js"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ export { default as ComposableMap } from "./components/ComposableMap";
2
+ export { default as Geographies } from "./components/Geographies";
3
+ export { default as Geography } from "./components/Geography";
4
+ export { default as Graticule } from "./components/Graticule";
5
+ export { default as ZoomableGroup } from "./components/ZoomableGroup";
6
+ export { default as Sphere } from "./components/Sphere";
7
+ export { default as Marker } from "./components/Marker";
8
+ export { default as Line } from "./components/Line";
9
+ export { default as Annotation } from "./components/Annotation";
10
+ export { MapProvider, MapContext, useMapContext, } from "./components/MapProvider";
11
+ export { ZoomPanProvider, ZoomPanContext, useZoomPanContext, } from "./components/ZoomPanProvider";
12
+ export { default as useGeographies } from "./components/useGeographies";
13
+ export { default as useZoomPan } from "./components/useZoomPan";
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react-simple-maps/src/index.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EACL,WAAW,EACX,UAAU,EACV,aAAa,GACd,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,GAClB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACvE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAA"}
@@ -0,0 +1,18 @@
1
+ export function getCoords(w: any, h: any, t: any): number[];
2
+ export function fetchGeographies(url: any): Promise<any>;
3
+ export function getFeatures(geographies: any, parseGeographies: any): any;
4
+ export function getMesh(geographies: any): {
5
+ outline: any;
6
+ borders: any;
7
+ } | null;
8
+ export function prepareMesh(outline: any, borders: any, path: any): {
9
+ outline: any;
10
+ borders: any;
11
+ } | {
12
+ outline?: undefined;
13
+ borders?: undefined;
14
+ };
15
+ export function prepareFeatures(geographies: any, path: any): any;
16
+ export function createConnectorPath(dx?: number, dy?: number, curve?: number): string;
17
+ export function isString(geo: any): geo is string;
18
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/react-simple-maps/src/utils.js"],"names":[],"mappings":"AAEA,4DAIC;AAED,yDAWC;AAED,0EAYC;AAED;;;SAcC;AAED;;;;;;EAOC;AAED,kEAUC;AAED,sFAKC;AAED,kDAEC"}
@@ -0,0 +1,65 @@
1
+ import { feature, mesh } from "topojson-client";
2
+ export function getCoords(w, h, t) {
3
+ const xOffset = (w * t.k - w) / 2;
4
+ const yOffset = (h * t.k - h) / 2;
5
+ return [w / 2 - (xOffset + t.x) / t.k, h / 2 - (yOffset + t.y) / t.k];
6
+ }
7
+ export function fetchGeographies(url) {
8
+ return fetch(url)
9
+ .then((res) => {
10
+ if (!res.ok) {
11
+ throw Error(res.statusText);
12
+ }
13
+ return res.json();
14
+ })
15
+ .catch((error) => {
16
+ console.log("There was a problem when fetching the data: ", error);
17
+ });
18
+ }
19
+ export function getFeatures(geographies, parseGeographies) {
20
+ const isTopojson = geographies.type === "Topology";
21
+ if (!isTopojson) {
22
+ return parseGeographies
23
+ ? parseGeographies(geographies.features || geographies)
24
+ : geographies.features || geographies;
25
+ }
26
+ const feats = feature(geographies, geographies.objects[Object.keys(geographies.objects)[0]]).features;
27
+ return parseGeographies ? parseGeographies(feats) : feats;
28
+ }
29
+ export function getMesh(geographies) {
30
+ const isTopojson = geographies.type === "Topology";
31
+ if (!isTopojson)
32
+ return null;
33
+ const outline = mesh(geographies, geographies.objects[Object.keys(geographies.objects)[0]], (a, b) => a === b);
34
+ const borders = mesh(geographies, geographies.objects[Object.keys(geographies.objects)[0]], (a, b) => a !== b);
35
+ return { outline, borders };
36
+ }
37
+ export function prepareMesh(outline, borders, path) {
38
+ return outline && borders
39
+ ? {
40
+ outline: { ...outline, rsmKey: "outline", svgPath: path(outline) },
41
+ borders: { ...borders, rsmKey: "borders", svgPath: path(borders) },
42
+ }
43
+ : {};
44
+ }
45
+ export function prepareFeatures(geographies, path) {
46
+ return geographies
47
+ ? geographies.map((d, i) => {
48
+ return {
49
+ ...d,
50
+ rsmKey: `geo-${i}`,
51
+ svgPath: path(d),
52
+ };
53
+ })
54
+ : [];
55
+ }
56
+ export function createConnectorPath(dx = 30, dy = 30, curve = 0.5) {
57
+ const curvature = Array.isArray(curve) ? curve : [curve, curve];
58
+ const curveX = (dx / 2) * curvature[0];
59
+ const curveY = (dy / 2) * curvature[1];
60
+ return `M${0},${0} Q${-dx / 2 - curveX},${-dy / 2 + curveY} ${-dx},${-dy}`;
61
+ }
62
+ export function isString(geo) {
63
+ return typeof geo === "string";
64
+ }
65
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/react-simple-maps/src/utils.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAE/C,MAAM,UAAU,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAA;IACjC,MAAM,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAA;IACjC,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,GAA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E,KAAK,GAAG,GAAG;IAC/D,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IAC/D,MAAM,MAAM,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;IACtC,MAAM,MAAM,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;IACtC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAA;AAC5E,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,GAAG;IAC1B,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAA;AAChC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "national-metadata",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Comprehensive country, city, visa, and prosperity data including ISO codes, coordinates, 1300+ city slugs, visa requirements, and Legatum rankings",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -13,6 +13,11 @@
13
13
  "require": "./dist/index.js",
14
14
  "types": "./dist/index.d.ts"
15
15
  },
16
+ "./maps": {
17
+ "import": "./dist/mapping/index.js",
18
+ "require": "./dist/mapping/index.js",
19
+ "types": "./dist/mapping/index.d.ts"
20
+ },
16
21
  "./flags/*": "./dist/flag-svg/*"
17
22
  },
18
23
  "scripts": {
@@ -53,11 +58,40 @@
53
58
  },
54
59
  "homepage": "https://github.com/mikhael28/national-metadata#readme",
55
60
  "devDependencies": {
56
- "typescript": "^5.0.0"
61
+ "@types/d3-geo": "3.1.0",
62
+ "@types/d3-selection": "3.0.11",
63
+ "@types/d3-zoom": "3.0.8",
64
+ "@types/geojson": "7946.0.16",
65
+ "@types/react": "19.2.7",
66
+ "@types/react-dom": "19.2.3",
67
+ "@types/topojson-client": "3.1.5",
68
+ "@types/topojson-specification": "1.0.5",
69
+ "typescript": "5.9.3"
70
+ },
71
+ "dependencies": {
72
+ "d3-color": "3.1.0",
73
+ "d3-geo": "3.1.1",
74
+ "d3-interpolate": "3.0.1",
75
+ "d3-selection": "3.0.0",
76
+ "d3-zoom": "3.0.0",
77
+ "topojson-client": "3.1.0"
78
+ },
79
+ "peerDependencies": {
80
+ "react": "17.x || 18.x || 19.x",
81
+ "react-dom": "17.x || 18.x || 19.x"
82
+ },
83
+ "peerDependenciesMeta": {
84
+ "react": {
85
+ "optional": true
86
+ },
87
+ "react-dom": {
88
+ "optional": true
89
+ }
57
90
  },
58
91
  "files": [
59
92
  "dist/**/*",
60
93
  "dist/flag-svg/*.svg",
94
+ "dist/mapping/**/*",
61
95
  "README.md",
62
96
  "LICENSE"
63
97
  ]