esrieact 0.3.1 → 0.4.1

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.
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import EsriColorSliderWidget from "@arcgis/core/widgets/smartMapping/ColorSlider.js";
3
+ export type ColorSliderEventHandlerFnMap = Partial<{
4
+ "max-change": __esri.SmartMappingSliderBaseMaxChangeEventHandler;
5
+ "min-change": __esri.SmartMappingSliderBaseMinChangeEventHandler;
6
+ "segment-drag": __esri.SmartMappingSliderBaseSegmentDragEventHandler;
7
+ "thumb-change": __esri.SmartMappingSliderBaseThumbChangeEventHandler;
8
+ "thumb-drag": __esri.SmartMappingSliderBaseThumbDragEventHandler;
9
+ }>;
10
+ /**
11
+ * A ColorSlider Widget component
12
+ *
13
+ * ArcGIS JS API Source Components:
14
+ * - [ColorSlider](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-smartMapping-ColorSlider.html)
15
+ */
16
+ export declare const ColorSlider: React.ForwardRefExoticComponent<__esri.ColorSliderProperties & {
17
+ children?: React.ReactNode;
18
+ } & {
19
+ events?: {} | ((widgetInstance: __esri.Widget) => {}) | undefined;
20
+ position?: string | __esri.UIAddPosition | undefined;
21
+ } & React.RefAttributes<EsriColorSliderWidget>>;
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+ import EsriColorSliderWidget from "@arcgis/core/widgets/smartMapping/ColorSlider.js";
3
+ import { createWidgetComponent } from ".";
4
+ const createWidget = (properties) => {
5
+ return new EsriColorSliderWidget(properties);
6
+ };
7
+ /**
8
+ * A ColorSlider Widget component
9
+ *
10
+ * ArcGIS JS API Source Components:
11
+ * - [ColorSlider](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-smartMapping-ColorSlider.html)
12
+ */
13
+ export const ColorSlider = React.forwardRef((properties, ref) => {
14
+ // @ts-expect-error internal mismatch of arcgis types?
15
+ return createWidgetComponent(createWidget, ref, properties);
16
+ });
@@ -21,16 +21,29 @@ export function createWidgetComponent(createWidget, ref, { children, events, pos
21
21
  const parentWidgetContext = useContext(WidgetContext);
22
22
  const childrenRef = useRef(null);
23
23
  const instance = useMemo(() => {
24
- const instance = createWidget({ ...properties, view });
25
- if (parentWidgetContext instanceof Expand) {
26
- parentWidgetContext.content = instance;
27
- return instance;
28
- }
29
- if (!properties.container) {
30
- view.ui.add(instance, position);
24
+ return createWidget({ ...properties, view, position });
25
+ }, []);
26
+ useEffect(() => {
27
+ if (instance && view) {
28
+ if (parentWidgetContext instanceof Expand) {
29
+ parentWidgetContext.content = instance;
30
+ }
31
+ else {
32
+ if (!properties.container) {
33
+ view.ui.add(instance, position);
34
+ }
35
+ }
31
36
  }
32
- return instance;
33
- }, [view]);
37
+ /**
38
+ * Remove widget on unmount
39
+ */
40
+ return () => {
41
+ if (parentWidgetContext instanceof Expand) {
42
+ parentWidgetContext.content = "";
43
+ }
44
+ view.ui.remove(instance);
45
+ };
46
+ }, [instance, view, parentWidgetContext]);
34
47
  useImperativeHandle(ref, () => instance);
35
48
  useEsriPropertyUpdates(instance, properties);
36
49
  useEvents(instance, typeof events === "function" ? events(instance) : events);
@@ -47,14 +60,6 @@ export function createWidgetComponent(createWidget, ref, { children, events, pos
47
60
  }
48
61
  }
49
62
  }, [children, instance]);
50
- /**
51
- * Remove widget on unmount
52
- */
53
- useEffect(() => {
54
- return () => {
55
- view.ui.remove(instance);
56
- };
57
- }, []);
58
63
  if (!children)
59
64
  return null;
60
65
  // Pass ref to the child element - works for both HTML elements and forwardRef components
@@ -1,9 +1,10 @@
1
1
  export * from "./createWidgetComponent";
2
2
  export * from "./BasemapGallery";
3
+ export * from "./ColorSlider";
3
4
  export * from "./Expand";
5
+ export * from "./Histogram";
6
+ export * from "./HistogramRangeSlider";
4
7
  export * from "./LayerList";
5
8
  export * from "./Legend";
6
9
  export * from "./SearchBar";
7
10
  export * from "./Sketch";
8
- export * from "./Histogram";
9
- export * from "./HistogramRangeSlider";
@@ -1,9 +1,10 @@
1
1
  export * from "./createWidgetComponent";
2
2
  export * from "./BasemapGallery";
3
+ export * from "./ColorSlider";
3
4
  export * from "./Expand";
5
+ export * from "./Histogram";
6
+ export * from "./HistogramRangeSlider";
4
7
  export * from "./LayerList";
5
8
  export * from "./Legend";
6
9
  export * from "./SearchBar";
7
10
  export * from "./Sketch";
8
- export * from "./Histogram";
9
- export * from "./HistogramRangeSlider";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "esrieact",
3
3
  "private": false,
4
- "version": "0.3.1",
4
+ "version": "0.4.1",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [