@react-fabric/map 1.0.0-beta.61 → 1.0.0-beta.63

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 (50) hide show
  1. package/dist/cjs/layers/Json.js +3 -3
  2. package/dist/cjs/layers/Marker.js +4 -8
  3. package/dist/cjs/markers/Fill.js +6 -7
  4. package/dist/cjs/markers/Pin.js +4 -4
  5. package/dist/cjs/markers/context.js +34 -0
  6. package/dist/cjs/renderers/Heatmap.js +7 -7
  7. package/dist/cjs/tools/BasemapGallery.js +2 -2
  8. package/dist/cjs/tools/Home.js +4 -4
  9. package/dist/cjs/tools/Zoom.js +2 -2
  10. package/dist/cjs/viewer/{Context.js → Provider.js} +2 -6
  11. package/dist/cjs/viewer/Viewer.js +2 -2
  12. package/dist/cjs/viewer/context.js +34 -0
  13. package/dist/esm/layers/Json.js +2 -2
  14. package/dist/esm/layers/Marker.js +4 -7
  15. package/dist/esm/markers/Fill.js +4 -5
  16. package/dist/esm/markers/Pin.js +2 -2
  17. package/dist/esm/markers/context.js +33 -0
  18. package/dist/esm/renderers/Heatmap.js +7 -7
  19. package/dist/esm/tools/BasemapGallery.js +1 -1
  20. package/dist/esm/tools/Home.js +3 -3
  21. package/dist/esm/tools/Zoom.js +1 -1
  22. package/dist/esm/viewer/{Context.js → Provider.js} +4 -7
  23. package/dist/esm/viewer/Viewer.js +1 -1
  24. package/dist/esm/viewer/context.js +33 -0
  25. package/dist/types/index.d.ts +10 -10
  26. package/dist/types/layers/Json.d.ts +2 -1
  27. package/dist/types/layers/Marker.d.ts +2 -3
  28. package/dist/types/markers/Fill.d.ts +2 -1
  29. package/dist/types/markers/Pin.d.ts +2 -1
  30. package/dist/types/markers/context.d.ts +3 -0
  31. package/dist/types/renderers/Cluster.d.ts +3 -3
  32. package/dist/types/renderers/Heatmap.d.ts +3 -3
  33. package/dist/types/viewer/Provider.d.ts +5 -0
  34. package/dist/types/viewer/context.d.ts +25 -0
  35. package/package.json +13 -13
  36. package/src/layers/Json.tsx +4 -4
  37. package/src/layers/Marker.tsx +6 -19
  38. package/src/markers/Fill.tsx +8 -17
  39. package/src/markers/Pin.tsx +5 -12
  40. package/src/markers/context.ts +29 -0
  41. package/src/renderers/Cluster.tsx +10 -14
  42. package/src/renderers/Heatmap.tsx +10 -14
  43. package/src/renderers/Simple.tsx +1 -1
  44. package/src/tools/BasemapGallery.tsx +4 -22
  45. package/src/tools/Home.tsx +3 -11
  46. package/src/tools/Zoom.tsx +1 -1
  47. package/src/viewer/{Context.tsx → Provider.tsx} +14 -29
  48. package/src/viewer/Viewer.tsx +1 -1
  49. package/src/viewer/context.ts +42 -0
  50. package/dist/types/viewer/Context.d.ts +0 -16
@@ -29,7 +29,7 @@ import "@arcgis/map-components/components/arcgis-placement";
29
29
  import { CalciteButton } from "@esri/calcite-components-react";
30
30
  import { debounce, getLatitudeLongitude } from "@react-fabric/utilities";
31
31
  import { useCallback, useEffect, useRef, useState } from "react";
32
- import { useMap } from "../viewer/Context";
32
+ import { useMap } from "../viewer/context";
33
33
 
34
34
  export const Home = ({ enableHistory }: { enableHistory?: boolean }) => {
35
35
  const { map, view, disableDrag, center, zoom } = useMap();
@@ -100,10 +100,7 @@ export const Home = ({ enableHistory }: { enableHistory?: boolean }) => {
100
100
 
101
101
  return (
102
102
  !disableDrag && (
103
- <ArcgisPlacement
104
- slot="top-left"
105
- className="mb-2 flex flex-col divide-y divide-tint-100"
106
- >
103
+ <ArcgisPlacement slot="top-left" className="mb-2 flex flex-col divide-y divide-tint-100">
107
104
  {enableHistory && (
108
105
  <CalciteButton
109
106
  appearance="solid"
@@ -113,12 +110,7 @@ export const Home = ({ enableHistory }: { enableHistory?: boolean }) => {
113
110
  onClick={() => navigate(activeIndex - 1)}
114
111
  />
115
112
  )}
116
- <CalciteButton
117
- appearance="solid"
118
- kind="neutral"
119
- iconStart="home"
120
- onClick={() => gotoHome()}
121
- />
113
+ <CalciteButton appearance="solid" kind="neutral" iconStart="home" onClick={() => gotoHome()} />
122
114
  {enableHistory && (
123
115
  <CalciteButton
124
116
  appearance="solid"
@@ -23,7 +23,7 @@
23
23
 
24
24
  import { ArcgisZoom } from "@arcgis/map-components-react";
25
25
  import "@arcgis/map-components/components/arcgis-zoom";
26
- import { useMap } from "../viewer/Context";
26
+ import { useMap } from "../viewer/context";
27
27
 
28
28
  export const Zoom = () => {
29
29
  const { disableZoom } = useMap();
@@ -25,26 +25,19 @@ import Basemap from "@arcgis/core/Basemap";
25
25
  import Point from "@arcgis/core/geometry/Point";
26
26
  import SpatialReference from "@arcgis/core/geometry/SpatialReference";
27
27
  import VectorTileLayer from "@arcgis/core/layers/VectorTileLayer";
28
+ import type Map from "@arcgis/core/Map";
29
+ import type MapView from "@arcgis/core/views/MapView";
30
+ import type SceneView from "@arcgis/core/views/SceneView";
28
31
  import { ArcgisMap, ArcgisScene } from "@arcgis/map-components-react";
29
32
  import "@arcgis/map-components/components/arcgis-map";
30
33
  import "@arcgis/map-components/components/arcgis-popup";
31
34
  import "@arcgis/map-components/components/arcgis-scene";
32
35
  import { CalciteButton } from "@esri/calcite-components-react";
33
- import { getLatitudeLongitude, type LngLatLike } from "@react-fabric/utilities";
34
- import { createContext, useContext, useEffect, useMemo, useState } from "react";
36
+ import { getLatitudeLongitude } from "@react-fabric/utilities";
37
+ import { useEffect, useMemo, useState } from "react";
35
38
  import { BASEMAPS, DEFAULT_VIEWPOINT } from "../constants";
36
- import { type FabricBaseMap, type MapViewerProps } from "../types";
37
-
38
- const Context = createContext<{
39
- map?: __esri.Map | null;
40
- view?: __esri.MapView | __esri.SceneView;
41
- disableDrag?: boolean;
42
- disableZoom?: boolean;
43
- basemaps: FabricBaseMap[];
44
- center: LngLatLike;
45
- zoom: number;
46
- is3D: boolean;
47
- }>({} as any);
39
+ import { type MapViewerProps } from "../types";
40
+ import { MapContext } from "./context";
48
41
 
49
42
  export const MapProvider = ({
50
43
  children,
@@ -56,14 +49,11 @@ export const MapProvider = ({
56
49
  disableDrag = false,
57
50
  disableZoom = false,
58
51
  }: MapViewerProps) => {
59
- const [map, setMap] = useState<__esri.Map | null>(null);
60
- const [view, setView] = useState<__esri.MapView | __esri.SceneView>();
52
+ const [map, setMap] = useState<Map | null>(null);
53
+ const [view, setView] = useState<MapView | SceneView>();
61
54
  const [is3D, setIs3D] = useState(false);
62
55
 
63
- const defaultBaseMap = useMemo(
64
- () => basemaps.find((b) => b.default) ?? basemaps[0],
65
- [basemaps],
66
- );
56
+ const defaultBaseMap = useMemo(() => basemaps.find((b) => b.default) ?? basemaps[0], [basemaps]);
67
57
 
68
58
  useEffect(() => {
69
59
  view?.navigation.set("actionMap", {
@@ -76,7 +66,7 @@ export const MapProvider = ({
76
66
 
77
67
  useEffect(() => {
78
68
  if (view && onClick) {
79
- const handleClick = view.on("click", (event: __esri.ViewClickEvent) => {
69
+ const handleClick = view.on("click", (event) => {
80
70
  event.button === 0 &&
81
71
  onClick({
82
72
  latitude: event.mapPoint.latitude ?? 0,
@@ -89,13 +79,10 @@ export const MapProvider = ({
89
79
  }
90
80
  }, [view, onClick]);
91
81
 
92
- const E = useMemo(
93
- () => (enable3D && is3D ? ArcgisScene : ArcgisMap),
94
- [is3D, enable3D],
95
- );
82
+ const E = useMemo(() => (enable3D && is3D ? ArcgisScene : ArcgisMap), [is3D, enable3D]);
96
83
 
97
84
  return (
98
- <Context.Provider
85
+ <MapContext.Provider
99
86
  value={{
100
87
  map,
101
88
  view,
@@ -153,8 +140,6 @@ export const MapProvider = ({
153
140
  )}
154
141
  {children}
155
142
  </E>
156
- </Context.Provider>
143
+ </MapContext.Provider>
157
144
  );
158
145
  };
159
-
160
- export const useMap = () => useContext(Context);
@@ -25,7 +25,7 @@ import "@arcgis/core/assets/esri/themes/light/main.css";
25
25
  import { Section, useIsDark } from "@react-fabric/core";
26
26
  import { useEffect } from "react";
27
27
  import { type MapViewerProps } from "../types";
28
- import { MapProvider } from "./Context";
28
+ import { MapProvider } from "./Provider";
29
29
 
30
30
  export const MapViewer = ({ children, ...props }: MapViewerProps) => {
31
31
  const isDark = useIsDark();
@@ -0,0 +1,42 @@
1
+ /*
2
+ * React Fabric
3
+ * @version: 1.0.0
4
+ *
5
+ *
6
+ * The MIT License (MIT)
7
+ * Copyright (c) 2026 Adarsh Pastakia
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
10
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
11
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
13
+ * subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
16
+ * portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ import Map from "@arcgis/core/Map";
25
+ import MapView from "@arcgis/core/views/MapView";
26
+ import SceneView from "@arcgis/core/views/SceneView";
27
+ import { LngLatLike } from "@react-fabric/utilities";
28
+ import { createContext, useContext } from "react";
29
+ import { FabricBaseMap } from "../types";
30
+
31
+ export const MapContext = createContext<{
32
+ map?: Map | null;
33
+ view?: MapView | SceneView;
34
+ disableDrag?: boolean;
35
+ disableZoom?: boolean;
36
+ basemaps: FabricBaseMap[];
37
+ center: LngLatLike;
38
+ zoom: number;
39
+ is3D: boolean;
40
+ }>({} as any);
41
+
42
+ export const useMap = () => useContext(MapContext);
@@ -1,16 +0,0 @@
1
- import "@arcgis/map-components/components/arcgis-map";
2
- import "@arcgis/map-components/components/arcgis-popup";
3
- import "@arcgis/map-components/components/arcgis-scene";
4
- import { type LngLatLike } from "@react-fabric/utilities";
5
- import { type FabricBaseMap, type MapViewerProps } from "../types";
6
- export declare const MapProvider: ({ children, onClick, basemaps, center, zoom, enable3D, disableDrag, disableZoom, }: MapViewerProps) => import("react/jsx-runtime").JSX.Element;
7
- export declare const useMap: () => {
8
- map?: __esri.Map | null;
9
- view?: __esri.MapView | __esri.SceneView;
10
- disableDrag?: boolean;
11
- disableZoom?: boolean;
12
- basemaps: FabricBaseMap[];
13
- center: LngLatLike;
14
- zoom: number;
15
- is3D: boolean;
16
- };