expo-arcgis 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.
- package/build/Graphic.d.ts +7 -2
- package/build/Graphic.d.ts.map +1 -1
- package/build/Graphic.js +9 -4
- package/build/Graphic.js.map +1 -1
- package/package.json +1 -1
- package/src/Graphic.tsx +9 -4
package/build/Graphic.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { GraphicProps } from './ExpoArcgis.types';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { type GraphicRef } from './ExpoArcgisModule';
|
|
3
|
+
/**
|
|
4
|
+
* Declarative point graphic. Draws itself on the nearest `<GraphicsOverlay>`. Forwards its native
|
|
5
|
+
* `GraphicRef` so the graphic can be handed to a GeoElement-anchored analysis — e.g.
|
|
6
|
+
* `<Viewshed graphic={ref}>` / `<LineOfSight observerGraphic={ref}>`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const Graphic: import("react").ForwardRefExoticComponent<GraphicProps & import("react").RefAttributes<GraphicRef>>;
|
|
4
9
|
//# sourceMappingURL=Graphic.d.ts.map
|
package/build/Graphic.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Graphic.d.ts","sourceRoot":"","sources":["../src/Graphic.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"Graphic.d.ts","sourceRoot":"","sources":["../src/Graphic.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAyB,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAMvE;;;;GAIG;AACH,eAAO,MAAM,OAAO,qGA+BlB,CAAC"}
|
package/build/Graphic.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
1
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
2
2
|
import ExpoArcgisModule from './ExpoArcgisModule';
|
|
3
3
|
import { useGraphicsOverlay } from './contexts';
|
|
4
4
|
import { usePrevious } from './hooks/usePrevious';
|
|
5
5
|
import { useUpdateEffect } from './hooks/useUpdateEffect';
|
|
6
6
|
import { getPropsDiffs } from './utils/getPropsDiffs';
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Declarative point graphic. Draws itself on the nearest `<GraphicsOverlay>`. Forwards its native
|
|
9
|
+
* `GraphicRef` so the graphic can be handed to a GeoElement-anchored analysis — e.g.
|
|
10
|
+
* `<Viewshed graphic={ref}>` / `<LineOfSight observerGraphic={ref}>`.
|
|
11
|
+
*/
|
|
12
|
+
export const Graphic = forwardRef(function Graphic(props, fwdRef) {
|
|
9
13
|
const overlay = useGraphicsOverlay();
|
|
10
14
|
const ref = useRef(undefined);
|
|
11
15
|
if (!ref.current) {
|
|
12
16
|
ref.current = new ExpoArcgisModule.GraphicRef(props);
|
|
13
17
|
}
|
|
18
|
+
useImperativeHandle(fwdRef, () => ref.current, []);
|
|
14
19
|
const prev = usePrevious(props);
|
|
15
20
|
useEffect(() => {
|
|
16
21
|
const graphic = ref.current;
|
|
@@ -32,5 +37,5 @@ export function Graphic(props) {
|
|
|
32
37
|
ref.current?.applyProps(changed);
|
|
33
38
|
}, [props]);
|
|
34
39
|
return null;
|
|
35
|
-
}
|
|
40
|
+
});
|
|
36
41
|
//# sourceMappingURL=Graphic.js.map
|
package/build/Graphic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Graphic.js","sourceRoot":"","sources":["../src/Graphic.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Graphic.js","sourceRoot":"","sources":["../src/Graphic.tsx"],"names":[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QACzC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAC/B,MAAM,OAAO,GAA4B,EAAE,CAAC;QAC5C,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACpB,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QACH,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,IAAI,CAAC;AACd,CAAC,CAAC,CAAC","sourcesContent":["import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';\n\nimport type { GraphicProps } from './ExpoArcgis.types';\nimport ExpoArcgisModule, { type GraphicRef } from './ExpoArcgisModule';\nimport { useGraphicsOverlay } from './contexts';\nimport { usePrevious } from './hooks/usePrevious';\nimport { useUpdateEffect } from './hooks/useUpdateEffect';\nimport { getPropsDiffs } from './utils/getPropsDiffs';\n\n/**\n * Declarative point graphic. Draws itself on the nearest `<GraphicsOverlay>`. Forwards its native\n * `GraphicRef` so the graphic can be handed to a GeoElement-anchored analysis — e.g.\n * `<Viewshed graphic={ref}>` / `<LineOfSight observerGraphic={ref}>`.\n */\nexport const Graphic = forwardRef<GraphicRef, GraphicProps>(function Graphic(props, fwdRef) {\n const overlay = useGraphicsOverlay();\n const ref = useRef<GraphicRef | undefined>(undefined);\n if (!ref.current) {\n ref.current = new ExpoArcgisModule.GraphicRef(props);\n }\n useImperativeHandle(fwdRef, () => ref.current!, []);\n\n const prev = usePrevious(props);\n\n useEffect(() => {\n const graphic = ref.current!;\n overlay.addGraphic(graphic);\n return () => {\n overlay.removeGraphic(graphic);\n graphic.release();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useUpdateEffect(() => {\n const diffs = getPropsDiffs(prev, props);\n if (diffs.length === 0) return;\n const changed: Record<string, unknown> = {};\n diffs.forEach((key) => {\n changed[key] = props[key];\n });\n ref.current?.applyProps(changed);\n }, [props]);\n\n return null;\n});\n"]}
|
package/package.json
CHANGED
package/src/Graphic.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
1
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
2
2
|
|
|
3
3
|
import type { GraphicProps } from './ExpoArcgis.types';
|
|
4
4
|
import ExpoArcgisModule, { type GraphicRef } from './ExpoArcgisModule';
|
|
@@ -7,13 +7,18 @@ import { usePrevious } from './hooks/usePrevious';
|
|
|
7
7
|
import { useUpdateEffect } from './hooks/useUpdateEffect';
|
|
8
8
|
import { getPropsDiffs } from './utils/getPropsDiffs';
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Declarative point graphic. Draws itself on the nearest `<GraphicsOverlay>`. Forwards its native
|
|
12
|
+
* `GraphicRef` so the graphic can be handed to a GeoElement-anchored analysis — e.g.
|
|
13
|
+
* `<Viewshed graphic={ref}>` / `<LineOfSight observerGraphic={ref}>`.
|
|
14
|
+
*/
|
|
15
|
+
export const Graphic = forwardRef<GraphicRef, GraphicProps>(function Graphic(props, fwdRef) {
|
|
12
16
|
const overlay = useGraphicsOverlay();
|
|
13
17
|
const ref = useRef<GraphicRef | undefined>(undefined);
|
|
14
18
|
if (!ref.current) {
|
|
15
19
|
ref.current = new ExpoArcgisModule.GraphicRef(props);
|
|
16
20
|
}
|
|
21
|
+
useImperativeHandle(fwdRef, () => ref.current!, []);
|
|
17
22
|
|
|
18
23
|
const prev = usePrevious(props);
|
|
19
24
|
|
|
@@ -38,4 +43,4 @@ export function Graphic(props: GraphicProps) {
|
|
|
38
43
|
}, [props]);
|
|
39
44
|
|
|
40
45
|
return null;
|
|
41
|
-
}
|
|
46
|
+
});
|