esrieact 0.1.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.
Files changed (82) hide show
  1. package/README.md +309 -0
  2. package/dist/core/Graphic.d.ts +16 -0
  3. package/dist/core/Graphic.js +67 -0
  4. package/dist/core/index.d.ts +3 -0
  5. package/dist/core/index.js +3 -0
  6. package/dist/core/renderers/Renderer.d.ts +11 -0
  7. package/dist/core/renderers/Renderer.js +11 -0
  8. package/dist/core/renderers/SimpleRenderer.d.ts +11 -0
  9. package/dist/core/renderers/SimpleRenderer.js +12 -0
  10. package/dist/core/renderers/UniqueValueRenderer.d.ts +12 -0
  11. package/dist/core/renderers/UniqueValueRenderer.js +12 -0
  12. package/dist/core/renderers/createRendererComponent.d.ts +13 -0
  13. package/dist/core/renderers/createRendererComponent.js +63 -0
  14. package/dist/core/renderers/index.d.ts +4 -0
  15. package/dist/core/renderers/index.js +4 -0
  16. package/dist/core/symbols/PictureMarkerSymbol.d.ts +9 -0
  17. package/dist/core/symbols/PictureMarkerSymbol.js +43 -0
  18. package/dist/core/symbols/SimpleFillSymbol.d.ts +9 -0
  19. package/dist/core/symbols/SimpleFillSymbol.js +34 -0
  20. package/dist/core/symbols/index.d.ts +2 -0
  21. package/dist/core/symbols/index.js +2 -0
  22. package/dist/index.d.ts +4 -0
  23. package/dist/index.js +4 -0
  24. package/dist/layers/FeatureLayer.d.ts +27 -0
  25. package/dist/layers/FeatureLayer.js +13 -0
  26. package/dist/layers/GraphicsLayer.d.ts +14 -0
  27. package/dist/layers/GraphicsLayer.js +13 -0
  28. package/dist/layers/GroupLayer.d.ts +14 -0
  29. package/dist/layers/GroupLayer.js +30 -0
  30. package/dist/layers/ImageryLayer.d.ts +14 -0
  31. package/dist/layers/ImageryLayer.js +13 -0
  32. package/dist/layers/ImageryTileLayer.d.ts +14 -0
  33. package/dist/layers/ImageryTileLayer.js +13 -0
  34. package/dist/layers/KMLLayer.d.ts +14 -0
  35. package/dist/layers/KMLLayer.js +13 -0
  36. package/dist/layers/LayerView.d.ts +52 -0
  37. package/dist/layers/LayerView.js +70 -0
  38. package/dist/layers/VectorTileLayer.d.ts +14 -0
  39. package/dist/layers/VectorTileLayer.js +13 -0
  40. package/dist/layers/WMSLayer.d.ts +14 -0
  41. package/dist/layers/WMSLayer.js +13 -0
  42. package/dist/layers/WebTileLayer.d.ts +14 -0
  43. package/dist/layers/WebTileLayer.js +13 -0
  44. package/dist/layers/createLayerComponent.d.ts +36 -0
  45. package/dist/layers/createLayerComponent.js +54 -0
  46. package/dist/layers/index.d.ts +11 -0
  47. package/dist/layers/index.js +11 -0
  48. package/dist/map/MapView.d.ts +144 -0
  49. package/dist/map/MapView.js +109 -0
  50. package/dist/map/index.d.ts +1 -0
  51. package/dist/map/index.js +1 -0
  52. package/dist/symbols/SymbolPreview.d.ts +16 -0
  53. package/dist/symbols/SymbolPreview.js +21 -0
  54. package/dist/symbols/index.d.ts +1 -0
  55. package/dist/symbols/index.js +1 -0
  56. package/dist/utils/index.d.ts +3 -0
  57. package/dist/utils/index.js +30 -0
  58. package/dist/utils/useEsriPropertyUpdates.d.ts +10 -0
  59. package/dist/utils/useEsriPropertyUpdates.js +26 -0
  60. package/dist/utils/useEvents.d.ts +20 -0
  61. package/dist/utils/useEvents.js +38 -0
  62. package/dist/utils/usePrevious.d.ts +2 -0
  63. package/dist/utils/usePrevious.js +9 -0
  64. package/dist/widgets/BasemapGallery.d.ts +14 -0
  65. package/dist/widgets/BasemapGallery.js +13 -0
  66. package/dist/widgets/Expand.d.ts +14 -0
  67. package/dist/widgets/Expand.js +15 -0
  68. package/dist/widgets/LayerList/ListItem.d.ts +14 -0
  69. package/dist/widgets/LayerList/ListItem.js +13 -0
  70. package/dist/widgets/LayerList/index.d.ts +14 -0
  71. package/dist/widgets/LayerList/index.js +13 -0
  72. package/dist/widgets/Legend.d.ts +14 -0
  73. package/dist/widgets/Legend.js +15 -0
  74. package/dist/widgets/SearchBar.d.ts +14 -0
  75. package/dist/widgets/SearchBar.js +13 -0
  76. package/dist/widgets/Sketch.d.ts +24 -0
  77. package/dist/widgets/Sketch.js +13 -0
  78. package/dist/widgets/createWidgetComponent.d.ts +29 -0
  79. package/dist/widgets/createWidgetComponent.js +47 -0
  80. package/dist/widgets/index.d.ts +7 -0
  81. package/dist/widgets/index.js +7 -0
  82. package/package.json +39 -0
@@ -0,0 +1,144 @@
1
+ import React, { HTMLAttributes, ReactNode, Dispatch, SetStateAction } from "react";
2
+ import EsriMap from "@arcgis/core/Map";
3
+ import EsriMapView from "@arcgis/core/views/MapView";
4
+ import "@arcgis/core/assets/esri/themes/light/main.css";
5
+ import { HandlerWithOptionalModifiers } from "../utils";
6
+ /**
7
+ * View event handler function map, key is the event name, value is the handler functionm
8
+ * or an object that defines the handler function and optional modifiers
9
+ */
10
+ export type ViewEventHandlerFnMap = Partial<{
11
+ resize: __esri.ViewResizeEventHandler;
12
+ "layerview-create": __esri.ViewLayerviewCreateEventHandler;
13
+ "layerview-create-error": __esri.ViewLayerviewCreateErrorEventHandler;
14
+ "layerview-destroy": __esri.ViewLayerviewDestroyEventHandler;
15
+ click: HandlerWithOptionalModifiers<__esri.ViewClickEventHandler>;
16
+ "double-click": HandlerWithOptionalModifiers<__esri.ViewDoubleClickEventHandler>;
17
+ "immediate-double-click": HandlerWithOptionalModifiers<__esri.ViewImmediateDoubleClickEventHandler>;
18
+ "immediate-click": HandlerWithOptionalModifiers<__esri.ViewImmediateClickEventHandler>;
19
+ hold: HandlerWithOptionalModifiers<__esri.ViewHoldEventHandler>;
20
+ drag: HandlerWithOptionalModifiers<__esri.ViewDragEventHandler>;
21
+ "mouse-wheel": HandlerWithOptionalModifiers<__esri.ViewMouseWheelEventHandler>;
22
+ "key-down": HandlerWithOptionalModifiers<__esri.ViewKeyDownEventHandler>;
23
+ "key-up": HandlerWithOptionalModifiers<__esri.ViewKeyUpEventHandler>;
24
+ "pointer-down": HandlerWithOptionalModifiers<__esri.ViewPointerDownEventHandler>;
25
+ "pointer-move": HandlerWithOptionalModifiers<__esri.ViewPointerMoveEventHandler>;
26
+ "pointer-up": HandlerWithOptionalModifiers<__esri.ViewPointerUpEventHandler>;
27
+ "pointer-enter": HandlerWithOptionalModifiers<__esri.ViewPointerEnterEventHandler>;
28
+ "pointer-leave": HandlerWithOptionalModifiers<__esri.ViewPointerLeaveEventHandler>;
29
+ focus: __esri.ViewFocusEventHandler;
30
+ blur: __esri.ViewBlurEventHandler;
31
+ }>;
32
+ /**
33
+ * Properties that the MapContext provides to all consumers
34
+ */
35
+ interface MapReference {
36
+ /**
37
+ * The esri [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) instance
38
+ */
39
+ map: EsriMap;
40
+ /**
41
+ * The esri [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) instance
42
+ */
43
+ view: EsriMapView;
44
+ }
45
+ /**
46
+ * The react ref object describing the MapView component's ref
47
+ */
48
+ export interface MapRef extends MapReference {
49
+ /**
50
+ * The HTML element that the map is rendered in
51
+ */
52
+ element?: HTMLDivElement;
53
+ }
54
+ interface MapContextProps extends MapReference {
55
+ /**
56
+ * Callback to set map
57
+ */
58
+ setMap: Dispatch<SetStateAction<EsriMap>>;
59
+ /**
60
+ * Callback to set map
61
+ */
62
+ setView: Dispatch<SetStateAction<EsriMapView>>;
63
+ }
64
+ /**
65
+ * The map context that holds references to the underlying Map and MapView objects
66
+ */
67
+ export declare const MapContext: React.Context<MapContextProps>;
68
+ interface MapContextProviderProps {
69
+ children?: ReactNode | ReactNode[];
70
+ }
71
+ /**
72
+ * Provider which provides the map context to all descedants
73
+ */
74
+ export declare const MapContextProvider: React.FC<MapContextProviderProps>;
75
+ interface Props extends HTMLAttributes<HTMLDivElement> {
76
+ /**
77
+ * Properties passed to the [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html)
78
+ */
79
+ MapProperties?: __esri.MapProperties;
80
+ /**
81
+ * Properties passed to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html)
82
+ */
83
+ ViewProperties?: __esri.MapViewProperties & {
84
+ /**
85
+ * Events that are attached to the MapView. Can be an event handler function map, or a function of the `view`
86
+ * which return an event handler function map
87
+ */
88
+ events?: ViewEventHandlerFnMap | ((view: __esri.MapView) => ViewEventHandlerFnMap);
89
+ };
90
+ /**
91
+ * Any layers or controls to be rendered as part of the map
92
+ */
93
+ children?: ReactNode | ReactNode[];
94
+ }
95
+ /**
96
+ * MapView Component for 2D map. Accepts properties for both the Map and the MapView. Renders the container
97
+ * div, and once mounted, renders the map to it.
98
+ *
99
+ * ***Does not provide its own Map Context, and as such, will fail if you do not manuaaly provide one***
100
+ *
101
+ * @example
102
+ * // App.tsx
103
+ * import { MapViewCore, MapContextProvider } from 'lib/map/MapView';
104
+ *
105
+ * const App = () => {
106
+ * return (
107
+ * <MapContextProvider>
108
+ * <MapViewCore />
109
+ * <OtherUI />
110
+ * </MapContextProvider>
111
+ * )
112
+ * }
113
+ *
114
+ * // OtherUI.tsx
115
+ * import { useContext } from 'react';
116
+ * import { MapContext } from 'lib/map/MapView';
117
+ *
118
+ * const OtherUI = () => {
119
+ * const { view } = useContext(MapContext);
120
+ *
121
+ * return <button onClick={() => view.zoom = view.zoom + 1}>Zoom in!</button>
122
+ * }
123
+ *
124
+ * ArcGIS JS API Source Components:
125
+ * - [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html)
126
+ * - [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html)
127
+ */
128
+ export declare const MapViewCore: React.ForwardRefExoticComponent<Props & React.RefAttributes<MapReference & {
129
+ element?: HTMLElement | undefined;
130
+ }>>;
131
+ /**
132
+ * MapView Component for 2D map. Accepts properties for both the Map and the MapView. Renders the container
133
+ * div, and once mounted, renders the map to it.
134
+ *
135
+ * ArcGIS JS API Source Components:
136
+ * - [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html)
137
+ * - [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html)
138
+ */
139
+ export declare const MapView: React.ForwardRefExoticComponent<Props & React.RefAttributes<MapReference>>;
140
+ /**
141
+ * Utility hook to get the undnerlying `map` and `view` instances of a MapView
142
+ */
143
+ export declare const useMap: () => MapReference;
144
+ export {};
@@ -0,0 +1,109 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React, { useState, useEffect, useContext, useImperativeHandle, } from "react";
3
+ import EsriMap from "@arcgis/core/Map";
4
+ import EsriMapView from "@arcgis/core/views/MapView";
5
+ import "@arcgis/core/assets/esri/themes/light/main.css";
6
+ import { useEsriPropertyUpdates, useEvents, } from "../utils";
7
+ /**
8
+ * The map context that holds references to the underlying Map and MapView objects
9
+ */
10
+ export const MapContext = React.createContext({});
11
+ /**
12
+ * Provider which provides the map context to all descedants
13
+ */
14
+ export const MapContextProvider = ({ children, }) => {
15
+ const [map, setMap] = useState(undefined);
16
+ const [view, setView] = useState(undefined);
17
+ return (_jsx(MapContext.Provider, { value: {
18
+ map,
19
+ setMap,
20
+ view,
21
+ setView,
22
+ }, children: children }));
23
+ };
24
+ /**
25
+ * MapView Component for 2D map. Accepts properties for both the Map and the MapView. Renders the container
26
+ * div, and once mounted, renders the map to it.
27
+ *
28
+ * ***Does not provide its own Map Context, and as such, will fail if you do not manuaaly provide one***
29
+ *
30
+ * @example
31
+ * // App.tsx
32
+ * import { MapViewCore, MapContextProvider } from 'lib/map/MapView';
33
+ *
34
+ * const App = () => {
35
+ * return (
36
+ * <MapContextProvider>
37
+ * <MapViewCore />
38
+ * <OtherUI />
39
+ * </MapContextProvider>
40
+ * )
41
+ * }
42
+ *
43
+ * // OtherUI.tsx
44
+ * import { useContext } from 'react';
45
+ * import { MapContext } from 'lib/map/MapView';
46
+ *
47
+ * const OtherUI = () => {
48
+ * const { view } = useContext(MapContext);
49
+ *
50
+ * return <button onClick={() => view.zoom = view.zoom + 1}>Zoom in!</button>
51
+ * }
52
+ *
53
+ * ArcGIS JS API Source Components:
54
+ * - [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html)
55
+ * - [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html)
56
+ */
57
+ export const MapViewCore = React.forwardRef((props, ref) => {
58
+ //
59
+ const { MapProperties, ViewProperties: { events: viewEvents, ...ViewProperties } = {}, children, ...rest } = props;
60
+ const [containerRef, setContainerRef] = useState();
61
+ const { map, setMap, view, setView } = useContext(MapContext);
62
+ useImperativeHandle(ref, () => ({ map, view, element: containerRef }));
63
+ useEvents(view, typeof viewEvents === "function" ? viewEvents(view) : viewEvents);
64
+ /**
65
+ * On mount, once the container reference is ready, create the map and the view
66
+ */
67
+ useEffect(() => {
68
+ if (containerRef) {
69
+ const map = new EsriMap(MapProperties);
70
+ const view = new EsriMapView({
71
+ map,
72
+ container: containerRef,
73
+ ...ViewProperties,
74
+ });
75
+ setMap(map);
76
+ setView(view);
77
+ }
78
+ }, [containerRef]);
79
+ /**
80
+ * Imperatively set properties on esri view instance if properties change
81
+ */
82
+ useEsriPropertyUpdates(map, MapProperties);
83
+ useEsriPropertyUpdates(view, ViewProperties);
84
+ return (_jsxs(_Fragment, { children: [_jsx("div", { ref: (element) => {
85
+ if (element)
86
+ setContainerRef(element);
87
+ }, ...rest }), map && view && children] }));
88
+ });
89
+ /**
90
+ * MapView Component for 2D map. Accepts properties for both the Map and the MapView. Renders the container
91
+ * div, and once mounted, renders the map to it.
92
+ *
93
+ * ArcGIS JS API Source Components:
94
+ * - [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html)
95
+ * - [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html)
96
+ */
97
+ export const MapView = React.forwardRef((props, ref) => {
98
+ return (_jsx(MapContextProvider, { children: _jsx(MapViewCore, { ...props, ref: ref }) }));
99
+ });
100
+ /**
101
+ * Utility hook to get the undnerlying `map` and `view` instances of a MapView
102
+ */
103
+ export const useMap = () => {
104
+ const { map, view } = useContext(MapContext);
105
+ if (!map || !view) {
106
+ throw new Error("Cannot find esrieact map context, are you sure your component is a descendent of a MapContext?");
107
+ }
108
+ return { map, view };
109
+ };
@@ -0,0 +1 @@
1
+ export * from "./MapView";
@@ -0,0 +1 @@
1
+ export * from "./MapView";
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+ interface Props {
3
+ /**
4
+ * The symbol to render in HTML
5
+ */
6
+ symbol: __esri.Symbol;
7
+ /**
8
+ * HTML rendering options to be passed to `renderPreviewHTML`
9
+ */
10
+ options?: __esri.symbolUtilsRenderPreviewHTMLOptions;
11
+ }
12
+ /**
13
+ * Component which renders HTML markup for a symbol based on its renderer.symbol JSON
14
+ */
15
+ export declare const SymbolPreview: React.FC<Props>;
16
+ export {};
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useRef, useState } from "react";
3
+ import * as symbolUtils from "@arcgis/core/symbols/support/symbolUtils.js";
4
+ /**
5
+ * Component which renders HTML markup for a symbol based on its renderer.symbol JSON
6
+ */
7
+ export const SymbolPreview = ({ symbol, options }) => {
8
+ const ref = useRef(null);
9
+ const [result, setResult] = useState(null);
10
+ useEffect(() => {
11
+ if (result && !ref.current?.innerHTML) {
12
+ ref.current?.appendChild(result);
13
+ }
14
+ }, [result, JSON.stringify(symbol.toJSON())]);
15
+ useMemo(async () => {
16
+ const localOptions = symbol.type === "simple-fill" ? { size: 12 } : undefined;
17
+ const symbolNode = await symbolUtils.renderPreviewHTML(symbol, options ?? localOptions);
18
+ setResult(symbolNode);
19
+ }, [JSON.stringify(symbol.toJSON())]);
20
+ return _jsx("div", { ref: ref });
21
+ };
@@ -0,0 +1 @@
1
+ export * from "./SymbolPreview";
@@ -0,0 +1 @@
1
+ export * from "./SymbolPreview";
@@ -0,0 +1,3 @@
1
+ export * from "./useEsriPropertyUpdates";
2
+ export * from "./useEvents";
3
+ export declare function getObjectDiff(obj1: Record<string, any>, obj2: Record<string, any>): string[];
@@ -0,0 +1,30 @@
1
+ import isEqual from "lodash.isequal";
2
+ export * from "./useEsriPropertyUpdates";
3
+ export * from "./useEvents";
4
+ /*
5
+ * Compare two objects by reducing an array of keys in obj1, having the
6
+ * keys in obj2 as the intial value of the result. Key points:
7
+ *
8
+ * - All keys of obj2 are initially in the result.
9
+ *
10
+ * - If the loop finds a key (from obj1, remember) not in obj2, it adds
11
+ * it to the result.
12
+ *
13
+ * - If the loop finds a key that are both in obj1 and obj2, it compares
14
+ * the value. If it's the same value, the key is removed from the result.
15
+ *
16
+ * From https://stackoverflow.com/a/40610459/12010984
17
+ */
18
+ export function getObjectDiff(obj1, obj2) {
19
+ const diff = Object.keys(obj1).reduce((result, key) => {
20
+ if (!obj2.hasOwnProperty(key)) {
21
+ result.push(key);
22
+ }
23
+ else if (isEqual(obj1[key], obj2[key])) {
24
+ const resultKeyIndex = result.indexOf(key);
25
+ result.splice(resultKeyIndex, 1);
26
+ }
27
+ return result;
28
+ }, Object.keys(obj2));
29
+ return diff;
30
+ }
@@ -0,0 +1,10 @@
1
+ interface EsriClassable {
2
+ constructor: Function;
3
+ }
4
+ /**
5
+ * Generic hook to update an existing ESRI class object instance with new properties
6
+ * @param instance The ESRI item instance to update
7
+ * @param properties The properties passed to the esri instance
8
+ */
9
+ export declare const useEsriPropertyUpdates: <T extends EsriClassable, P>(instance: T | undefined, properties: P) => void;
10
+ export {};
@@ -0,0 +1,26 @@
1
+ import { useUpdateEffect } from "usehooks-ts";
2
+ import { usePrevious } from "./usePrevious";
3
+ import { getObjectDiff } from ".";
4
+ /**
5
+ * Generic hook to update an existing ESRI class object instance with new properties
6
+ * @param instance The ESRI item instance to update
7
+ * @param properties The properties passed to the esri instance
8
+ */
9
+ export const useEsriPropertyUpdates = (instance, properties) => {
10
+ const prevProperties = usePrevious(properties);
11
+ /**
12
+ * Imperatively set properties on ESRI instance if properties change, based on the setter
13
+ * technique described here: https://developers.arcgis.com/javascript/latest/programming-patterns/#setters
14
+ */
15
+ useUpdateEffect(() => {
16
+ if (prevProperties) {
17
+ const updatedProperties = getObjectDiff(properties, prevProperties);
18
+ if (updatedProperties.length) {
19
+ updatedProperties.forEach((property) => {
20
+ // @ts-expect-error Need to properly type this
21
+ instance[property] = properties[property];
22
+ });
23
+ }
24
+ }
25
+ }, [JSON.stringify(properties)]);
26
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Event handler that takes in modifier parameter
3
+ */
4
+ export type WithMofidiers<T extends Function = Function> = {
5
+ modifiers: string[];
6
+ handler: T;
7
+ };
8
+ /**
9
+ * View event callback that may or may not take optional modifiers
10
+ */
11
+ export type HandlerWithOptionalModifiers<T extends Function = Function> = T | WithMofidiers<T>;
12
+ export type EventHandlerMap = Record<string, Function | HandlerWithOptionalModifiers>;
13
+ /**
14
+ * Utility hook to attach event handlers to an esri [Accessor](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Accessor.html)
15
+ * instance, and refresh those event handlers if they are updated
16
+ *
17
+ * @param instance The esri item instance to attach events to
18
+ * @param events The events to attach, in the form of an event handler function map
19
+ */
20
+ export declare function useEvents<I extends __esri.Accessor, E extends EventHandlerMap>(instance: I, events?: E): void;
@@ -0,0 +1,38 @@
1
+ import { useEffect, useRef } from "react";
2
+ /**
3
+ * Utility hook to attach event handlers to an esri [Accessor](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Accessor.html)
4
+ * instance, and refresh those event handlers if they are updated
5
+ *
6
+ * @param instance The esri item instance to attach events to
7
+ * @param events The events to attach, in the form of an event handler function map
8
+ */
9
+ export function useEvents(instance, events) {
10
+ const handlers = useRef([]);
11
+ /**
12
+ * Attach event listeners on mount, if there are any
13
+ */
14
+ useEffect(() => {
15
+ if (instance && events) {
16
+ handlers.current.forEach((handler) => handler.remove());
17
+ handlers.current = Object.keys(events).map((eventName) => {
18
+ const eventHandler = events[eventName];
19
+ if (eventHandler) {
20
+ if (eventHandler.modifiers) {
21
+ const { modifiers, handler } = eventHandler;
22
+ // @ts-expect-error allow events to be handled
23
+ return instance.on(eventName, modifiers, handler);
24
+ }
25
+ else {
26
+ // @ts-expect-error allow events to be handled
27
+ return instance.on(eventName, eventHandler);
28
+ }
29
+ }
30
+ });
31
+ }
32
+ // Remove listeners and flush listener ref on unmount
33
+ return () => {
34
+ handlers.current.forEach((handler) => handler.remove());
35
+ handlers.current = [];
36
+ };
37
+ }, [instance, events]);
38
+ }
@@ -0,0 +1,2 @@
1
+ export declare function usePrevious<T>(value: T): T | undefined;
2
+ export default usePrevious;
@@ -0,0 +1,9 @@
1
+ import { useEffect, useRef } from "react";
2
+ export function usePrevious(value) {
3
+ const ref = useRef();
4
+ useEffect(() => {
5
+ ref.current = value;
6
+ }, [value]);
7
+ return ref.current;
8
+ }
9
+ export default usePrevious;
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import EsriBasemapGallery from "@arcgis/core/widgets/BasemapGallery";
3
+ /**
4
+ * An BasemapGallery Widget component
5
+ *
6
+ * ArcGIS JS API Source Components:
7
+ * - [BasemapGallery](https://developers.arcgis.com/javascript/latest/sample-code/widgets-basemapgallery/)
8
+ */
9
+ export declare const BasemapGallery: React.ForwardRefExoticComponent<__esri.BasemapGalleryProperties & {
10
+ children?: React.ReactNode;
11
+ } & {
12
+ events?: {} | undefined;
13
+ position?: string | __esri.UIAddPosition | undefined;
14
+ } & React.RefAttributes<EsriBasemapGallery>>;
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import EsriBasemapGallery from "@arcgis/core/widgets/BasemapGallery";
3
+ import { createWidgetComponent } from ".";
4
+ const createWidget = (properties) => {
5
+ return new EsriBasemapGallery(properties);
6
+ };
7
+ /**
8
+ * An BasemapGallery Widget component
9
+ *
10
+ * ArcGIS JS API Source Components:
11
+ * - [BasemapGallery](https://developers.arcgis.com/javascript/latest/sample-code/widgets-basemapgallery/)
12
+ */
13
+ export const BasemapGallery = React.forwardRef((properties, ref) => createWidgetComponent(createWidget, ref, properties));
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import EsriExpandWidget from "@arcgis/core/widgets/Expand";
3
+ /**
4
+ * An Expand Widget component
5
+ *
6
+ * ArcGIS JS API Source Components:
7
+ * - [Expand](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html)
8
+ */
9
+ export declare const Expand: React.ForwardRefExoticComponent<__esri.ExpandProperties & {
10
+ children?: React.ReactNode;
11
+ } & {
12
+ events?: {} | undefined;
13
+ position?: string | __esri.UIAddPosition | undefined;
14
+ } & React.RefAttributes<EsriExpandWidget>>;
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import EsriExpandWidget from "@arcgis/core/widgets/Expand";
3
+ import { createWidgetComponent } from ".";
4
+ const createWidget = (properties) => {
5
+ return new EsriExpandWidget(properties);
6
+ };
7
+ /**
8
+ * An Expand Widget component
9
+ *
10
+ * ArcGIS JS API Source Components:
11
+ * - [Expand](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html)
12
+ */
13
+ export const Expand = React.forwardRef((properties, ref) => {
14
+ return createWidgetComponent(createWidget, ref, properties);
15
+ });
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import EsriListItem from "@arcgis/core/widgets/LayerList/ListItem";
3
+ /**
4
+ * An LayerList ListItem component
5
+ *
6
+ * ArcGIS JS API Source Components:
7
+ * - [ListItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html)
8
+ */
9
+ export declare const LayerList: React.ForwardRefExoticComponent<__esri.ListItemProperties & {
10
+ children?: React.ReactNode;
11
+ } & {
12
+ events?: {} | undefined;
13
+ position?: string | __esri.UIAddPosition | undefined;
14
+ } & React.RefAttributes<EsriListItem>>;
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import EsriListItem from "@arcgis/core/widgets/LayerList/ListItem";
3
+ import { createWidgetComponent } from "..";
4
+ const createWidget = (properties) => {
5
+ return new EsriListItem(properties);
6
+ };
7
+ /**
8
+ * An LayerList ListItem component
9
+ *
10
+ * ArcGIS JS API Source Components:
11
+ * - [ListItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html)
12
+ */
13
+ export const LayerList = React.forwardRef((properties, ref) => createWidgetComponent(createWidget, ref, properties));
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import EsriLayerList from "@arcgis/core/widgets/LayerList";
3
+ /**
4
+ * An LayerList Widget component
5
+ *
6
+ * ArcGIS JS API Source Components:
7
+ * - [LayerList](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html)
8
+ */
9
+ export declare const LayerList: React.ForwardRefExoticComponent<__esri.LayerListProperties & {
10
+ children?: React.ReactNode;
11
+ } & {
12
+ events?: {} | undefined;
13
+ position?: string | __esri.UIAddPosition | undefined;
14
+ } & React.RefAttributes<EsriLayerList>>;
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import EsriLayerList from "@arcgis/core/widgets/LayerList";
3
+ import { createWidgetComponent } from "..";
4
+ const createWidget = (properties) => {
5
+ return new EsriLayerList(properties);
6
+ };
7
+ /**
8
+ * An LayerList Widget component
9
+ *
10
+ * ArcGIS JS API Source Components:
11
+ * - [LayerList](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html)
12
+ */
13
+ export const LayerList = React.forwardRef((properties, ref) => createWidgetComponent(createWidget, ref, properties));
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import EsriLegendWidget from "@arcgis/core/widgets/Legend";
3
+ /**
4
+ * A Legend Widget component
5
+ *
6
+ * ArcGIS JS API Source Components:
7
+ * - [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html)
8
+ */
9
+ export declare const Legend: React.ForwardRefExoticComponent<__esri.LegendProperties & {
10
+ children?: React.ReactNode;
11
+ } & {
12
+ events?: {} | undefined;
13
+ position?: string | __esri.UIAddPosition | undefined;
14
+ } & React.RefAttributes<EsriLegendWidget>>;
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import EsriLegendWidget from "@arcgis/core/widgets/Legend";
3
+ import { createWidgetComponent } from ".";
4
+ const createWidget = (properties) => {
5
+ return new EsriLegendWidget(properties);
6
+ };
7
+ /**
8
+ * A Legend Widget component
9
+ *
10
+ * ArcGIS JS API Source Components:
11
+ * - [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html)
12
+ */
13
+ export const Legend = React.forwardRef((properties, ref) => {
14
+ return createWidgetComponent(createWidget, ref, properties);
15
+ });
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import EsriSearch from "@arcgis/core/widgets/Search";
3
+ /**
4
+ * A Search Widget component
5
+ *
6
+ * ArcGIS JS API Source Components:
7
+ * - [Search](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html)
8
+ */
9
+ export declare const SearchBar: React.ForwardRefExoticComponent<__esri.SearchProperties & __esri.WidgetProperties & {
10
+ children?: React.ReactNode;
11
+ } & {
12
+ events?: {} | undefined;
13
+ position?: string | __esri.UIAddPosition | undefined;
14
+ } & React.RefAttributes<EsriSearch>>;
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import EsriSearch from "@arcgis/core/widgets/Search";
3
+ import { createWidgetComponent } from ".";
4
+ const createSearchWidget = (properties) => {
5
+ return new EsriSearch(properties);
6
+ };
7
+ /**
8
+ * A Search Widget component
9
+ *
10
+ * ArcGIS JS API Source Components:
11
+ * - [Search](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html)
12
+ */
13
+ export const SearchBar = React.forwardRef((properties, ref) => createWidgetComponent(createSearchWidget, ref, properties));