esrieact 0.1.1 → 0.2.0
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/layers/MapImageLayer.d.ts +14 -0
- package/dist/layers/MapImageLayer.js +13 -0
- package/dist/layers/createLayerComponent.js +7 -2
- package/dist/layers/index.d.ts +1 -0
- package/dist/layers/index.js +1 -0
- package/dist/map/MapView.js +3 -2
- package/dist/symbols/SymbolPreview.d.ts +1 -1
- package/dist/utils/useEsriPropertyUpdates.js +1 -1
- package/dist/utils/usePrevious.js +1 -1
- package/dist/utils/useUpdateEffect.d.ts +5 -0
- package/dist/utils/useUpdateEffect.js +14 -0
- package/dist/widgets/Expand.js +1 -0
- package/dist/widgets/Legend.js +1 -0
- package/dist/widgets/SearchBar.js +1 -0
- package/package.json +7 -8
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EsriMapImageLayer from "@arcgis/core/layers/MapImageLayer";
|
|
3
|
+
/**
|
|
4
|
+
* A MapImageLayer component
|
|
5
|
+
*
|
|
6
|
+
* ArcGIS JS API Source Components:
|
|
7
|
+
* - [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html)
|
|
8
|
+
*/
|
|
9
|
+
export declare const MapImageLayer: React.ForwardRefExoticComponent<__esri.MapImageLayerProperties & {
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
} & {
|
|
12
|
+
events?: {} | undefined;
|
|
13
|
+
layerOrder?: number | undefined;
|
|
14
|
+
} & React.RefAttributes<EsriMapImageLayer>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EsriMapImageLayer from "@arcgis/core/layers/MapImageLayer";
|
|
3
|
+
import { createLayerComponent, } from "./createLayerComponent";
|
|
4
|
+
const createLayer = (properties) => {
|
|
5
|
+
return new EsriMapImageLayer(properties);
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A MapImageLayer component
|
|
9
|
+
*
|
|
10
|
+
* ArcGIS JS API Source Components:
|
|
11
|
+
* - [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html)
|
|
12
|
+
*/
|
|
13
|
+
export const MapImageLayer = React.forwardRef((properties, ref) => createLayerComponent(createLayer, ref, properties));
|
|
@@ -23,7 +23,7 @@ export const createLayerComponent = (createLayer, ref, { children, events, layer
|
|
|
23
23
|
*/
|
|
24
24
|
const instance = useMemo(() => {
|
|
25
25
|
const layer = createLayer(properties);
|
|
26
|
-
// If the parent
|
|
26
|
+
// If the parent is a GroupLayer (or any EsriInstance that has the .add(layer) method), add it to that,
|
|
27
27
|
// otherwise, add directly to the map
|
|
28
28
|
if (parent && parent.add) {
|
|
29
29
|
parent.add(layer, layerOrder);
|
|
@@ -44,7 +44,12 @@ export const createLayerComponent = (createLayer, ref, { children, events, layer
|
|
|
44
44
|
*/
|
|
45
45
|
useEffect(() => {
|
|
46
46
|
return () => {
|
|
47
|
-
|
|
47
|
+
if (parent && parent.remove) {
|
|
48
|
+
parent.remove(instance);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
map.remove(instance);
|
|
52
|
+
}
|
|
48
53
|
};
|
|
49
54
|
}, []);
|
|
50
55
|
// If no children, there is no need to render a context provider
|
package/dist/layers/index.d.ts
CHANGED
package/dist/layers/index.js
CHANGED
package/dist/map/MapView.js
CHANGED
|
@@ -110,8 +110,9 @@ export const MapView = React.forwardRef((props, ref) => {
|
|
|
110
110
|
* Utility hook to get the undnerlying `map` and `view` instances of a MapView
|
|
111
111
|
*/
|
|
112
112
|
export const useMap = () => {
|
|
113
|
-
const
|
|
114
|
-
|
|
113
|
+
const context = useContext(MapContext);
|
|
114
|
+
const { map, view } = context;
|
|
115
|
+
if (!context) {
|
|
115
116
|
throw new Error("Cannot find esrieact map context, are you sure your component is a descendent of a MapContext?");
|
|
116
117
|
}
|
|
117
118
|
return { map, view };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Like useEffect, but skips the initial mount.
|
|
4
|
+
*/
|
|
5
|
+
export function useUpdateEffect(effect, deps) {
|
|
6
|
+
const isFirst = useRef(true);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (isFirst.current) {
|
|
9
|
+
isFirst.current = false;
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
return effect();
|
|
13
|
+
}, deps);
|
|
14
|
+
}
|
package/dist/widgets/Expand.js
CHANGED
|
@@ -11,5 +11,6 @@ const createWidget = (properties) => {
|
|
|
11
11
|
* - [Expand](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html)
|
|
12
12
|
*/
|
|
13
13
|
export const Expand = React.forwardRef((properties, ref) => {
|
|
14
|
+
// @ts-expect-error internal mismatch of arcgis types?
|
|
14
15
|
return createWidgetComponent(createWidget, ref, properties);
|
|
15
16
|
});
|
package/dist/widgets/Legend.js
CHANGED
|
@@ -11,5 +11,6 @@ const createWidget = (properties) => {
|
|
|
11
11
|
* - [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html)
|
|
12
12
|
*/
|
|
13
13
|
export const Legend = React.forwardRef((properties, ref) => {
|
|
14
|
+
// @ts-expect-error internal mismatch of arcgis types?
|
|
14
15
|
return createWidgetComponent(createWidget, ref, properties);
|
|
15
16
|
});
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import EsriSearch from "@arcgis/core/widgets/Search";
|
|
3
3
|
import { createWidgetComponent } from ".";
|
|
4
4
|
const createSearchWidget = (properties) => {
|
|
5
|
+
// @ts-expect-error internal mismatch of arcgis types?
|
|
5
6
|
return new EsriSearch(properties);
|
|
6
7
|
};
|
|
7
8
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esrieact",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -23,17 +23,16 @@
|
|
|
23
23
|
"./widgets/*": "./dist/widgets/*"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"lodash.isequal": "^4.5.0"
|
|
27
|
-
"usehooks-ts": "^2.9.1"
|
|
26
|
+
"lodash.isequal": "^4.5.0"
|
|
28
27
|
},
|
|
29
28
|
"peerDependencies": {
|
|
30
|
-
"@arcgis/core": "^4.
|
|
31
|
-
"react": "^
|
|
32
|
-
"react-dom": "^
|
|
29
|
+
"@arcgis/core": "^4.30.0",
|
|
30
|
+
"react": "^19.0.0",
|
|
31
|
+
"react-dom": "^19.0.0"
|
|
33
32
|
},
|
|
34
33
|
"devDependencies": {
|
|
35
|
-
"@types/react": "^
|
|
36
|
-
"@types/react-dom": "^
|
|
34
|
+
"@types/react": "^19.0.0",
|
|
35
|
+
"@types/react-dom": "^19.0.0",
|
|
37
36
|
"typescript": "^5.2.2"
|
|
38
37
|
}
|
|
39
38
|
}
|