@open-pioneer/selection 0.2.1 → 0.2.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # @open-pioneer/selection
2
2
 
3
+ ## 0.2.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 28e092a: Update dependencies
8
+ - 28e092a: Adapt to OpenLayers type changes.
9
+
10
+ When creating a selection source for a `VectorLayer`, the precise type of that vector layer must now be `VectorLayer<Feature>` (instead of `VectorLayer<VectorSource>`).
11
+ This is a TypeScript-only change that has no effects on the JavaScript code at runtime.
12
+
13
+ - 65a14f4: Open select-menu on enter (fixes issue [#320](https://github.com/open-pioneer/trails-openlayers-base-packages/issues/320))
14
+ - 484ad86: Add tooltip role to tooltip divs (See https://github.com/open-pioneer/trails-openlayers-base-packages/issues/309).
15
+ - Updated dependencies [28e092a]
16
+ - Updated dependencies [0d51d2f]
17
+ - Updated dependencies [76f8863]
18
+ - @open-pioneer/map@0.6.0
19
+
20
+ ## 0.2.2
21
+
22
+ ### Patch Changes
23
+
24
+ - 4140646: Fix imports.
25
+ - 4140646: Update trails dependencies
26
+ - 4140646: Update to react 18.3.1
27
+ - 81bc7da: Update trails dependencies
28
+ - 2c092dc: Update dependencies
29
+ - Updated dependencies [4140646]
30
+ - Updated dependencies [4140646]
31
+ - Updated dependencies [b5bb7a1]
32
+ - Updated dependencies [81bc7da]
33
+ - Updated dependencies [2c092dc]
34
+ - Updated dependencies [4140646]
35
+ - @open-pioneer/react-utils@0.2.3
36
+ - @open-pioneer/map@0.5.1
37
+
3
38
  ## 0.2.1
4
39
 
5
40
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import { Resource } from "@open-pioneer/core/resources";
1
+ import { Resource } from "@open-pioneer/core";
2
2
  import OlMap from "ol/Map";
3
3
  import Geometry from "ol/geom/Geometry";
4
4
  import PointerInteraction from "ol/interaction/Pointer";
package/DragController.js CHANGED
@@ -1,8 +1,8 @@
1
- import { unByKey } from 'ol/Observable';
2
- import Overlay from 'ol/Overlay';
3
- import { mouseActionButton } from 'ol/events/condition';
1
+ import { unByKey } from 'ol/Observable.js';
2
+ import Overlay from 'ol/Overlay.js';
3
+ import { mouseActionButton } from 'ol/events/condition.js';
4
4
  import { SelectionMethods } from './Selection.js';
5
- import { DragBox, DragPan } from 'ol/interaction';
5
+ import { DragBox, DragPan } from 'ol/interaction.js';
6
6
 
7
7
  const ACTIVE_CLASS = "selection-active";
8
8
  const INACTIVE_CLASS = "selection-inactive";
@@ -51,14 +51,13 @@ class DragController {
51
51
  });
52
52
  }
53
53
  setActive(isActive) {
54
- if (this.isActive === isActive)
55
- return;
54
+ if (this.isActive === isActive) return;
56
55
  const viewPort = this.olMap.getViewport();
57
56
  if (isActive) {
58
57
  this.interactionResources.forEach(
59
58
  (interaction) => this.olMap.addInteraction(interaction.interaction)
60
59
  );
61
- this.tooltip.element.textContent = this.tooltipMessage;
60
+ this.tooltip.setText(this.tooltipMessage);
62
61
  viewPort.classList.remove(INACTIVE_CLASS);
63
62
  viewPort.classList.add(ACTIVE_CLASS);
64
63
  this.isActive = true;
@@ -66,7 +65,7 @@ class DragController {
66
65
  this.interactionResources.forEach(
67
66
  (interaction) => this.olMap.removeInteraction(interaction.interaction)
68
67
  );
69
- this.tooltip.element.textContent = this.tooltipDisabledMessage;
68
+ this.tooltip.setText(this.tooltipDisabledMessage);
70
69
  viewPort.classList.remove(ACTIVE_CLASS);
71
70
  viewPort.classList.add(INACTIVE_CLASS);
72
71
  this.isActive = false;
@@ -131,7 +130,10 @@ class DragController {
131
130
  createHelpTooltip(olMap, message) {
132
131
  const element = document.createElement("div");
133
132
  element.className = "selection-tooltip printing-hide";
134
- element.textContent = message;
133
+ element.role = "tooltip";
134
+ const content = document.createElement("span");
135
+ content.textContent = message;
136
+ element.appendChild(content);
135
137
  const overlay = new Overlay({
136
138
  element,
137
139
  offset: [15, 0],
@@ -148,6 +150,9 @@ class DragController {
148
150
  olMap.removeOverlay(overlay);
149
151
  overlay.dispose();
150
152
  unByKey(pointHandler);
153
+ },
154
+ setText(value) {
155
+ content.textContent = value;
151
156
  }
152
157
  };
153
158
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DragController.js","sources":["DragController.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Resource } from \"@open-pioneer/core/resources\";\nimport OlMap from \"ol/Map\";\nimport { unByKey } from \"ol/Observable\";\nimport Overlay from \"ol/Overlay\";\nimport { mouseActionButton } from \"ol/events/condition\";\nimport Geometry from \"ol/geom/Geometry\";\nimport { SelectionMethods } from \"./Selection\";\nimport { DragBox, DragPan } from \"ol/interaction\";\nimport PointerInteraction from \"ol/interaction/Pointer\";\n\ninterface InteractionResource extends Resource {\n interaction: PointerInteraction;\n}\n/** Represents a tooltip rendered on the OpenLayers map. */\ninterface Tooltip extends Resource {\n overlay: Overlay;\n element: HTMLDivElement;\n}\n\nconst ACTIVE_CLASS = \"selection-active\";\nconst INACTIVE_CLASS = \"selection-inactive\";\n\nexport class DragController {\n private tooltip: Tooltip;\n private interactionResources: InteractionResource[] = [];\n private olMap: OlMap;\n private isActive: boolean = true;\n private tooltipMessage: string;\n private tooltipDisabledMessage: string;\n\n constructor(\n olMap: OlMap,\n selectMethode: string,\n tooltipMessage: string,\n tooltipDisabledMessage: string,\n onExtentSelected: (geometry: Geometry) => void\n ) {\n let viewPort;\n /**\n * Notice for Projectdeveloper\n * Add cases for more Selectionmethods\n */\n switch (selectMethode) {\n case SelectionMethods.extent:\n default:\n viewPort = this.initViewport(olMap);\n this.interactionResources.push(\n this.createDragBox(olMap, onExtentSelected, viewPort, this.interactionResources)\n );\n this.interactionResources.push(\n this.createDrag(olMap, viewPort, this.interactionResources)\n );\n break;\n }\n\n this.tooltip = this.createHelpTooltip(olMap, tooltipMessage);\n this.olMap = olMap;\n this.tooltipMessage = tooltipMessage;\n this.tooltipDisabledMessage = tooltipDisabledMessage;\n }\n\n initViewport(olMap: OlMap) {\n const viewPort = olMap.getViewport();\n viewPort.classList.add(ACTIVE_CLASS);\n\n viewPort.oncontextmenu = (e) => {\n e.preventDefault();\n return false;\n };\n return viewPort;\n }\n\n /**\n * Method for destroying the controller when it is no longer needed\n */\n destroy() {\n this.tooltip.destroy();\n this.interactionResources.forEach((interaction) => {\n interaction.destroy();\n });\n }\n\n setActive(isActive: boolean) {\n if (this.isActive === isActive) return;\n const viewPort = this.olMap.getViewport();\n if (isActive) {\n this.interactionResources.forEach((interaction) =>\n this.olMap.addInteraction(interaction.interaction)\n );\n this.tooltip.element.textContent = this.tooltipMessage;\n viewPort.classList.remove(INACTIVE_CLASS);\n viewPort.classList.add(ACTIVE_CLASS);\n this.isActive = true;\n } else {\n this.interactionResources.forEach((interaction) =>\n this.olMap.removeInteraction(interaction.interaction)\n );\n this.tooltip.element.textContent = this.tooltipDisabledMessage;\n viewPort.classList.remove(ACTIVE_CLASS);\n viewPort.classList.add(INACTIVE_CLASS);\n this.isActive = false;\n }\n }\n\n /**\n * Method to create a simple extent-selection\n */\n private createDragBox(\n olMap: OlMap,\n onExtentSelected: (geometry: Geometry) => void,\n viewPort: HTMLElement,\n interactionResources: InteractionResource[]\n ): InteractionResource {\n const dragBox = new DragBox({\n className: \"selection-drag-box\",\n condition: mouseActionButton\n });\n\n olMap.addInteraction(dragBox);\n dragBox.on(\"boxend\", function () {\n onExtentSelected(dragBox.getGeometry());\n });\n\n const interactionResource: InteractionResource = {\n interaction: dragBox,\n destroy() {\n olMap.removeInteraction(dragBox);\n interactionResources.splice(interactionResources.indexOf(this));\n dragBox.dispose();\n viewPort.classList.remove(ACTIVE_CLASS);\n viewPort.classList.remove(INACTIVE_CLASS);\n viewPort.oncontextmenu = null;\n }\n };\n return interactionResource;\n }\n\n /**\n * Method to activate pan with right-mouse-click\n */\n private createDrag(\n olMap: OlMap,\n viewPort: HTMLElement,\n interactionResources: InteractionResource[]\n ): InteractionResource {\n const condition = function (mapBrowserEvent: {\n originalEvent: MouseEvent;\n dragging: unknown;\n }) {\n const originalEvent = /** @type {MouseEvent} */ mapBrowserEvent.originalEvent;\n return originalEvent.button == 2;\n };\n const drag = new DragPan({\n condition: condition\n });\n\n olMap.addInteraction(drag);\n\n const interactionResource: InteractionResource = {\n interaction: drag,\n destroy() {\n olMap.removeInteraction(drag);\n interactionResources.splice(interactionResources.indexOf(this));\n drag.dispose();\n viewPort.classList.remove(ACTIVE_CLASS);\n viewPort.classList.remove(INACTIVE_CLASS);\n viewPort.oncontextmenu = null;\n }\n };\n\n return interactionResource;\n }\n\n /**\n * Method to generate a tooltip on the mouse cursor\n */\n private createHelpTooltip(olMap: OlMap, message: string) {\n const element = document.createElement(\"div\");\n element.className = \"selection-tooltip printing-hide\";\n element.textContent = message;\n\n const overlay = new Overlay({\n element: element,\n offset: [15, 0],\n positioning: \"center-left\"\n });\n\n const pointHandler = olMap.on(\"pointermove\", (evt) => {\n overlay.setPosition(evt.coordinate);\n });\n\n olMap.addOverlay(overlay);\n return {\n overlay,\n element,\n destroy() {\n olMap.removeOverlay(overlay);\n overlay.dispose();\n unByKey(pointHandler);\n }\n };\n }\n\n /**\n * Method for testing purposes only\n * @returns InteractionResource of class DragBox\n */\n getDragboxInteraction() {\n return this.interactionResources.find(\n (interactionResource) => interactionResource.interaction instanceof DragBox\n );\n }\n\n /**\n * Method for testing purposes only\n * @returns InteractionResource of class DragPan\n */\n getDragPanInteraction() {\n return this.interactionResources.find(\n (interactionResource) => interactionResource.interaction instanceof DragPan\n );\n }\n}\n"],"names":[],"mappings":";;;;;;AAqBA,MAAM,YAAe,GAAA,kBAAA,CAAA;AACrB,MAAM,cAAiB,GAAA,oBAAA,CAAA;AAEhB,MAAM,cAAe,CAAA;AAAA,EAChB,OAAA,CAAA;AAAA,EACA,uBAA8C,EAAC,CAAA;AAAA,EAC/C,KAAA,CAAA;AAAA,EACA,QAAoB,GAAA,IAAA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AAA,CAAM,WAAW,OAAO,CAAA,CAAA;AACxB,IAAO,OAAA;AAAA,MACH,OAAA;AAAA,MACA,OAAA;AAAA,MACA,OAAU,GAAA;AACN,QAAA,KAAA,CAAM,cAAc,OAAO,CAAA,CAAA;AAC3B,QAAA,OAAA,CAAQ,OAAQ,EAAA,CAAA;AAChB,QAAA,OAAA,CAAQ,YAAY,CAAA,CAAA;AAAA,OACxB;AAAA,KACJ,CAAA;AAAA,GACJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,qBAAwB,GAAA;AACpB,IAAA,OAAO,KAAK,oBAAqB,CAAA,IAAA;AAAA,MAC7B,CAAC,mBAAwB,KAAA,mBAAA,CAAoB,WAAuB,YAAA,OAAA;AAAA,KACxE,CAAA;AAAA,GACJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,qBAAwB,GAAA;AACpB,IAAA,OAAO,KAAK,oBAAqB,CAAA,IAAA;AAAA,MAC7B,CAAC,mBAAwB,KAAA,mBAAA,CAAoB,WAAuB,YAAA,OAAA;AAAA,KACxE,CAAA;AAAA,GACJ;AACJ;;;;"}
1
+ {"version":3,"file":"DragController.js","sources":["DragController.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Resource } from \"@open-pioneer/core\";\nimport OlMap from \"ol/Map\";\nimport { unByKey } from \"ol/Observable\";\nimport Overlay from \"ol/Overlay\";\nimport { mouseActionButton } from \"ol/events/condition\";\nimport Geometry from \"ol/geom/Geometry\";\nimport { SelectionMethods } from \"./Selection\";\nimport { DragBox, DragPan } from \"ol/interaction\";\nimport PointerInteraction from \"ol/interaction/Pointer\";\n\ninterface InteractionResource extends Resource {\n interaction: PointerInteraction;\n}\n/** Represents a tooltip rendered on the OpenLayers map. */\ninterface Tooltip extends Resource {\n overlay: Overlay;\n element: HTMLDivElement;\n setText(value: string): void;\n}\n\nconst ACTIVE_CLASS = \"selection-active\";\nconst INACTIVE_CLASS = \"selection-inactive\";\n\nexport class DragController {\n private tooltip: Tooltip;\n private interactionResources: InteractionResource[] = [];\n private olMap: OlMap;\n private isActive: boolean = true;\n private tooltipMessage: string;\n private tooltipDisabledMessage: string;\n\n constructor(\n olMap: OlMap,\n selectMethode: string,\n tooltipMessage: string,\n tooltipDisabledMessage: string,\n onExtentSelected: (geometry: Geometry) => void\n ) {\n let viewPort;\n /**\n * Notice for Projectdeveloper\n * Add cases for more Selectionmethods\n */\n switch (selectMethode) {\n case SelectionMethods.extent:\n default:\n viewPort = this.initViewport(olMap);\n this.interactionResources.push(\n this.createDragBox(olMap, onExtentSelected, viewPort, this.interactionResources)\n );\n this.interactionResources.push(\n this.createDrag(olMap, viewPort, this.interactionResources)\n );\n break;\n }\n\n this.tooltip = this.createHelpTooltip(olMap, tooltipMessage);\n this.olMap = olMap;\n this.tooltipMessage = tooltipMessage;\n this.tooltipDisabledMessage = tooltipDisabledMessage;\n }\n\n initViewport(olMap: OlMap) {\n const viewPort = olMap.getViewport();\n viewPort.classList.add(ACTIVE_CLASS);\n\n viewPort.oncontextmenu = (e) => {\n e.preventDefault();\n return false;\n };\n return viewPort;\n }\n\n /**\n * Method for destroying the controller when it is no longer needed\n */\n destroy() {\n this.tooltip.destroy();\n this.interactionResources.forEach((interaction) => {\n interaction.destroy();\n });\n }\n\n setActive(isActive: boolean) {\n if (this.isActive === isActive) return;\n const viewPort = this.olMap.getViewport();\n if (isActive) {\n this.interactionResources.forEach((interaction) =>\n this.olMap.addInteraction(interaction.interaction)\n );\n this.tooltip.setText(this.tooltipMessage);\n viewPort.classList.remove(INACTIVE_CLASS);\n viewPort.classList.add(ACTIVE_CLASS);\n this.isActive = true;\n } else {\n this.interactionResources.forEach((interaction) =>\n this.olMap.removeInteraction(interaction.interaction)\n );\n this.tooltip.setText(this.tooltipDisabledMessage);\n viewPort.classList.remove(ACTIVE_CLASS);\n viewPort.classList.add(INACTIVE_CLASS);\n this.isActive = false;\n }\n }\n\n /**\n * Method to create a simple extent-selection\n */\n private createDragBox(\n olMap: OlMap,\n onExtentSelected: (geometry: Geometry) => void,\n viewPort: HTMLElement,\n interactionResources: InteractionResource[]\n ): InteractionResource {\n const dragBox = new DragBox({\n className: \"selection-drag-box\",\n condition: mouseActionButton\n });\n\n olMap.addInteraction(dragBox);\n dragBox.on(\"boxend\", function () {\n onExtentSelected(dragBox.getGeometry());\n });\n\n const interactionResource: InteractionResource = {\n interaction: dragBox,\n destroy() {\n olMap.removeInteraction(dragBox);\n interactionResources.splice(interactionResources.indexOf(this));\n dragBox.dispose();\n viewPort.classList.remove(ACTIVE_CLASS);\n viewPort.classList.remove(INACTIVE_CLASS);\n viewPort.oncontextmenu = null;\n }\n };\n return interactionResource;\n }\n\n /**\n * Method to activate pan with right-mouse-click\n */\n private createDrag(\n olMap: OlMap,\n viewPort: HTMLElement,\n interactionResources: InteractionResource[]\n ): InteractionResource {\n const condition = function (mapBrowserEvent: {\n originalEvent: MouseEvent;\n dragging: unknown;\n }) {\n const originalEvent = /** @type {MouseEvent} */ mapBrowserEvent.originalEvent;\n return originalEvent.button == 2;\n };\n const drag = new DragPan({\n condition: condition\n });\n\n olMap.addInteraction(drag);\n\n const interactionResource: InteractionResource = {\n interaction: drag,\n destroy() {\n olMap.removeInteraction(drag);\n interactionResources.splice(interactionResources.indexOf(this));\n drag.dispose();\n viewPort.classList.remove(ACTIVE_CLASS);\n viewPort.classList.remove(INACTIVE_CLASS);\n viewPort.oncontextmenu = null;\n }\n };\n\n return interactionResource;\n }\n\n /**\n * Method to generate a tooltip on the mouse cursor\n */\n private createHelpTooltip(olMap: OlMap, message: string): Tooltip {\n const element = document.createElement(\"div\");\n element.className = \"selection-tooltip printing-hide\";\n element.role = \"tooltip\";\n\n const content = document.createElement(\"span\");\n content.textContent = message;\n element.appendChild(content);\n\n const overlay = new Overlay({\n element: element,\n offset: [15, 0],\n positioning: \"center-left\"\n });\n\n const pointHandler = olMap.on(\"pointermove\", (evt) => {\n overlay.setPosition(evt.coordinate);\n });\n\n olMap.addOverlay(overlay);\n return {\n overlay,\n element,\n destroy() {\n olMap.removeOverlay(overlay);\n overlay.dispose();\n unByKey(pointHandler);\n },\n setText(value) {\n content.textContent = value;\n }\n };\n }\n\n /**\n * Method for testing purposes only\n * @returns InteractionResource of class DragBox\n */\n getDragboxInteraction() {\n return this.interactionResources.find(\n (interactionResource) => interactionResource.interaction instanceof DragBox\n );\n }\n\n /**\n * Method for testing purposes only\n * @returns InteractionResource of class DragPan\n */\n getDragPanInteraction() {\n return this.interactionResources.find(\n (interactionResource) => interactionResource.interaction instanceof DragPan\n );\n }\n}\n"],"names":[],"mappings":";;;;;;AAsBA,MAAM,YAAe,GAAA,kBAAA,CAAA;AACrB,MAAM,cAAiB,GAAA,oBAAA,CAAA;AAEhB,MAAM,cAAe,CAAA;AAAA,EAChB,OAAA,CAAA;AAAA,EACA,uBAA8C,EAAC,CAAA;AAAA,EAC/C,KAAA,CAAA;AAAA,EACA,QAAoB,GAAA,IAAA,CAAA;AAAA,EACpB,cAAA,CAAA;AAAA,EACA,sBAAA,CAAA;AAAA,EAER,WACI,CAAA,KAAA,EACA,aACA,EAAA,cAAA,EACA,wBACA,gBACF,EAAA;AACE,IAAI,IAAA,QAAA,CAAA;AAKJ,IAAA,QAAQ,aAAe;AAAA,MACnB,KAAK,gBAAiB,CAAA,MAAA,CAAA;AAAA,MACtB;AACI,QAAW,QAAA,GAAA,IAAA,CAAK,aAAa,KAAK,CAAA,CAAA;AAClC,QAAA,IAAA,CAAK,oBAAqB,CAAA,IAAA;AAAA,UACtB,KAAK,aAAc,CAAA,KAAA,EAAO,gBAAkB,EAAA,QAAA,EAAU,KAAK,oBAAoB,CAAA;AAAA,SACnF,CAAA;AACA,QAAA,IAAA,CAAK,oBAAqB,CAAA,IAAA;AAAA,UACtB,IAAK,CAAA,UAAA,CAAW,KAAO,EAAA,QAAA,EAAU,KAAK,oBAAoB,CAAA;AAAA,SAC9D,CAAA;AACA,QAAA,M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AAK,oBAAqB,CAAA,IAAA;AAAA,MAC7B,CAAC,mBAAwB,KAAA,mBAAA,CAAoB,WAAuB,YAAA,OAAA;AAAA,KACxE,CAAA;AAAA,GACJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,qBAAwB,GAAA;AACpB,IAAA,OAAO,KAAK,oBAAqB,CAAA,IAAA;AAAA,MAC7B,CAAC,mBAAwB,KAAA,mBAAA,CAAoB,WAAuB,YAAA,OAAA;AAAA,KACxE,CAAA;AAAA,GACJ;AACJ;;;;"}
package/Selection.js CHANGED
@@ -37,17 +37,16 @@ const Selection = (props) => {
37
37
  onSelectionComplete
38
38
  );
39
39
  const chakraStyles = useChakraStyles();
40
+ const [isOpenSelect, setIsOpenSelect] = useState(false);
40
41
  const buildMethodOptions = useCallback(
41
42
  (methods) => {
42
43
  const objects = [];
43
- if (!methods)
44
- methods = ["EXTENT" /* extent */];
44
+ if (!methods) methods = ["EXTENT" /* extent */];
45
45
  methods.forEach((item) => {
46
46
  if (Object.values(SelectionMethods).includes(item))
47
47
  objects.push({ label: intl.formatMessage({ id: item }), value: item });
48
48
  });
49
- if (objects.length === 0)
50
- throw new Error("methods does not contain valid values");
49
+ if (objects.length === 0) throw new Error("methods does not contain valid values");
51
50
  return objects;
52
51
  },
53
52
  [intl]
@@ -88,6 +87,11 @@ const Selection = (props) => {
88
87
  });
89
88
  return () => handle.destroy();
90
89
  }, [currentSource, setDragControllerActive, intl]);
90
+ const keyDown = useEvent((event) => {
91
+ if (!isOpenSelect && event.key === "Enter") {
92
+ setIsOpenSelect(true);
93
+ }
94
+ });
91
95
  return /* @__PURE__ */ jsxs(VStack, { ...containerProps, spacing: 2, children: [
92
96
  methodOptions.length > 1 && /* @__PURE__ */ jsxs(FormControl, { children: [
93
97
  /* @__PURE__ */ jsx(FormLabel, { children: intl.formatMessage({ id: "selectMethod" }) }),
@@ -120,7 +124,11 @@ const Selection = (props) => {
120
124
  },
121
125
  isOptionDisabled: (option) => option.value === void 0 || option.value.status === "unavailable",
122
126
  getOptionLabel: (option) => option.label + (option.value === void 0 || option.value.status === "unavailable" ? " " + intl.formatMessage({ id: "sourceNotAvailable" }) : ""),
123
- chakraStyles
127
+ chakraStyles,
128
+ onKeyDown: keyDown,
129
+ menuIsOpen: isOpenSelect,
130
+ onMenuOpen: () => setIsOpenSelect(true),
131
+ onMenuClose: () => setIsOpenSelect(false)
124
132
  }
125
133
  )
126
134
  ] })
package/Selection.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Selection.js","sources":["Selection.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {\n Box,\n Flex,\n FormControl,\n FormLabel,\n Icon,\n Tooltip,\n VStack,\n chakra,\n useToken\n} from \"@open-pioneer/chakra-integration\";\nimport { MapModel, useMapModel } from \"@open-pioneer/map\";\nimport { NotificationService } from \"@open-pioneer/notifier\";\nimport { CommonComponentProps, useCommonComponentProps, useEvent } from \"@open-pioneer/react-utils\";\nimport { PackageIntl } from \"@open-pioneer/runtime\";\nimport {\n OptionProps,\n Select,\n Props as SelectProps,\n SingleValueProps,\n chakraComponents,\n type SingleValue,\n ChakraStylesConfig,\n GroupBase\n} from \"chakra-react-select\";\nimport { Geometry } from \"ol/geom\";\nimport { useIntl, useService } from \"open-pioneer:react-hooks\";\nimport { FC, useCallback, useEffect, useMemo, useState } from \"react\";\nimport { FiAlertTriangle } from \"react-icons/fi\";\nimport { DragController } from \"./DragController\";\nimport { SelectionController } from \"./SelectionController\";\nimport { SelectionResult, SelectionSource, SelectionSourceStatusObject } from \"./api\";\n\n/**\n * Properties supported by the {@link Selection} component.\n */\nexport interface SelectionProps extends CommonComponentProps {\n /**\n * The id of the map.\n */\n mapId: string;\n\n /**\n * Array of selection sources available for spatial selection.\n */\n sources: SelectionSource[];\n\n /**\n * This handler is called whenever the user has successfully selected\n * some items.\n */\n onSelectionComplete?(event: SelectionCompleteEvent): void;\n\n /**\n * This handler is called whenever the user has changed the selected source\n */\n onSelectionSourceChanged?(event: SelectionSourceChangedEvent): void;\n}\n\nexport interface SelectionCompleteEvent {\n /** The source that returned the {@link results}. */\n source: SelectionSource;\n\n /** Results selected by the user. */\n results: SelectionResult[];\n}\n\nexport interface SelectionSourceChangedEvent {\n /** The new selected source */\n source: SelectionSource | undefined;\n}\n\n/**\n * Properties for single select options.\n */\ninterface SelectionOption {\n /**\n * The label of the selection source option.\n */\n label: string;\n\n /**\n * The value (SelectionSource) of the selection source option.\n */\n value: SelectionSource | undefined;\n}\n\n/**\n * Properties for single selection method options.\n */\ninterface MethodOption {\n /**\n * The label of the select method option.\n */\n label: string;\n\n /**\n * The value of the select method option.\n */\n value: string;\n}\n\n/**\n * Supported selection methods\n */\nexport enum SelectionMethods {\n extent = \"EXTENT\",\n polygon = \"POLYGON\",\n free = \"FREEPOLYGON\",\n circle = \"CIRCLE\"\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst COMMON_SELECT_PROPS: SelectProps<any, any, any> = {\n classNamePrefix: \"react-select\",\n menuPosition: \"fixed\",\n isSearchable: false,\n isClearable: false\n};\n\n/**\n * A component that allows the user to perform a spatial selection on a given set of {@link SelectionSource}.\n */\nexport const Selection: FC<SelectionProps> = (props) => {\n const intl = useIntl();\n const { mapId, sources, onSelectionComplete, onSelectionSourceChanged } = props;\n const { containerProps } = useCommonComponentProps(\"selection\", props);\n const [currentSource, setCurrentSource] = useState<SelectionSource | undefined>(() =>\n sources.find((s) => (s.status ?? \"available\") === \"available\")\n );\n const mapState = useMapModel(mapId);\n const { onExtentSelected } = useSelectionController(\n mapState.map,\n sources,\n currentSource,\n onSelectionComplete\n );\n const chakraStyles = useChakraStyles();\n\n /**\n * Method to build Option-Array from the supported selection methods for the selection-method react-select\n * If there is no configuration => Default selection method: EXTENT\n */\n const buildMethodOptions = useCallback(\n (methods: string[] | undefined) => {\n const objects: MethodOption[] = [];\n if (!methods) methods = [SelectionMethods.extent];\n methods.forEach((item) => {\n if (Object.values(SelectionMethods as unknown as string[]).includes(item))\n objects.push({ label: intl.formatMessage({ id: item }), value: item });\n });\n if (objects.length === 0) throw new Error(\"methods does not contain valid values\");\n return objects;\n },\n [intl]\n );\n\n const methodOptions: MethodOption[] = buildMethodOptions(undefined);\n const [selectedMethod, setSelectedMethod] = useState(methodOptions[0] as MethodOption);\n\n /**\n * Method to change used selectmethod\n */\n const onMethodeOptionChance = useEvent((newValue: MethodOption) => {\n setSelectedMethod(newValue);\n });\n\n const [dragControllerActive, setDragControllerActive] = useState<boolean>(true);\n useDragSelection(mapState.map, selectedMethod, intl, onExtentSelected, dragControllerActive);\n\n /**\n * Method to build Option-Array from sources for the selection-source react-select\n */\n const sourceOptions = useMemo(\n () =>\n sources.map<SelectionOption>((source) => {\n return { label: source.label, value: source };\n }),\n [sources]\n );\n const currentSourceOption = useMemo(\n () => sourceOptions.find((option) => option.value === currentSource),\n [sourceOptions, currentSource]\n );\n\n /**\n * Method to change used source\n */\n const onSourceOptionChanged = useEvent((newValue: SingleValue<SelectionOption>) => {\n setCurrentSource(newValue?.value);\n onSelectionSourceChanged && onSelectionSourceChanged({ source: newValue?.value });\n });\n\n useEffect(() => {\n if (!currentSource) {\n setDragControllerActive(false);\n return;\n }\n\n const sourceNotAvailableReason = intl.formatMessage({ id: \"sourceNotAvailable\" });\n const isCurrentSourceAvailable = () => {\n return (\n currentSource &&\n getSourceStatus(currentSource, sourceNotAvailableReason).kind === \"available\"\n );\n };\n\n setDragControllerActive(isCurrentSourceAvailable());\n // Why can this be undefined after test above?!\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const handle = currentSource.on(\"changed:status\", () => {\n setDragControllerActive(isCurrentSourceAvailable());\n });\n return () => handle.destroy();\n }, [currentSource, setDragControllerActive, intl]);\n\n return (\n <VStack {...containerProps} spacing={2}>\n {methodOptions.length > 1 && (\n <FormControl>\n <FormLabel>{intl.formatMessage({ id: \"selectMethod\" })}</FormLabel>\n <Select\n className=\"selection-method react-select\"\n {...COMMON_SELECT_PROPS}\n options={methodOptions}\n onChange={onMethodeOptionChance}\n value={selectedMethod}\n chakraStyles={chakraStyles}\n />\n </FormControl>\n )}\n <FormControl>\n <FormLabel>{intl.formatMessage({ id: \"selectSource\" })}</FormLabel>\n <Select<SelectionOption>\n className=\"selection-source react-select\"\n {...COMMON_SELECT_PROPS}\n options={sourceOptions}\n placeholder={intl.formatMessage({ id: \"selectionPlaceholder\" })}\n value={currentSourceOption}\n onChange={onSourceOptionChanged}\n components={{\n Option: SourceSelectOption,\n SingleValue: SourceSelectValue\n }}\n isOptionDisabled={(option) =>\n option.value === undefined || option.value.status === \"unavailable\"\n }\n // optionLabel is used by screenreaders\n getOptionLabel={(option) =>\n option.label +\n (option.value === undefined || option.value.status === \"unavailable\"\n ? \" \" + intl.formatMessage({ id: \"sourceNotAvailable\" })\n : \"\")\n }\n chakraStyles={chakraStyles}\n />\n </FormControl>\n </VStack>\n );\n};\n\nfunction SourceSelectOption(props: OptionProps<SelectionOption>): JSX.Element {\n const { value } = props.data;\n const { isAvailable, content } = useSourceItem(value, false);\n\n return (\n <chakraComponents.Option\n {...props}\n isDisabled={!isAvailable}\n className=\"selection-source-option\"\n >\n {content}\n </chakraComponents.Option>\n );\n}\n\nfunction SourceSelectValue(props: SingleValueProps<SelectionOption>): JSX.Element {\n const { value } = props.data;\n const { isAvailable, content } = useSourceItem(value, true);\n const clazz = isAvailable\n ? \"selection-source-value\"\n : \"selection-source-value selection-source-value--disabled\";\n\n return (\n <chakraComponents.SingleValue {...props} isDisabled={!isAvailable} className={clazz}>\n {content}\n </chakraComponents.SingleValue>\n );\n}\n\n/**\n * Hook to manage source option in selection-source react-select\n */\nfunction useSourceItem(source: SelectionSource | undefined, isSelected: boolean) {\n const label: string | undefined = source?.label;\n const status = useSourceStatus(source);\n\n return {\n isAvailable: status.kind === \"available\",\n content: (\n <Flex direction=\"row\" alignItems=\"center\" grow={1}>\n {!isSelected && <Flex grow={1}>{label}</Flex>}\n {status.kind === \"unavailable\" && (\n <Box ml={2}>\n <Tooltip label={status.reason} placement=\"right\" openDelay={500}>\n <chakra.span>\n <Icon\n as={FiAlertTriangle}\n color=\"red\"\n className=\"warning-icon\"\n aria-label={status.reason}\n />\n </chakra.span>\n </Tooltip>\n </Box>\n )}\n {isSelected && label}\n </Flex>\n )\n };\n}\n\n/**\n * Hook to manage selection sources\n */\nfunction useSelectionController(\n mapModel: MapModel | undefined,\n sources: SelectionSource[],\n currentSource: SelectionSource | undefined,\n onSelectionComplete: ((event: SelectionCompleteEvent) => void) | undefined\n) {\n const notifier = useService<NotificationService>(\"notifier.NotificationService\");\n const intl = useIntl();\n const [controller, setController] = useState<SelectionController | undefined>(undefined);\n useEffect(() => {\n if (!mapModel) {\n return;\n }\n const controller = new SelectionController({\n mapModel,\n onError() {\n notifier.notify({\n level: \"error\",\n message: intl.formatMessage({ id: \"selectionFailed\" })\n });\n }\n });\n setController(controller);\n return () => {\n controller.destroy();\n };\n }, [mapModel, notifier, sources, intl]);\n\n const onExtentSelected = useEvent(async (geometry: Geometry) => {\n if (!controller || !currentSource) {\n return;\n }\n\n const selectionResult = await controller.select(currentSource, geometry.getExtent());\n if (!selectionResult) {\n return;\n }\n\n onSelectionComplete?.(selectionResult);\n });\n return {\n controller,\n onExtentSelected\n };\n}\n\ntype SimpleStatus =\n | {\n kind: \"available\";\n }\n | {\n kind: \"unavailable\";\n reason: string;\n };\n\nfunction getSourceStatus(source: SelectionSource, sourceNotAvailableReason: string): SimpleStatus {\n const rawCurrent = source.status ?? \"available\";\n const current: SelectionSourceStatusObject =\n typeof rawCurrent === \"string\" ? { kind: rawCurrent } : rawCurrent;\n if (current.kind === \"available\") {\n return current;\n }\n\n return {\n kind: \"unavailable\",\n reason: current.reason ?? sourceNotAvailableReason\n };\n}\n\n/**\n * Hook to manage source status\n */\nfunction useSourceStatus(source: SelectionSource | undefined): SimpleStatus {\n const intl = useIntl();\n const [status, setStatus] = useState<SimpleStatus>(() => ({ kind: \"available\" }));\n useEffect(() => {\n if (!source) {\n setStatus({ kind: \"available\" });\n return;\n }\n const sourceNotAvailableReason = intl.formatMessage({ id: \"sourceNotAvailable\" });\n setStatus(getSourceStatus(source, sourceNotAvailableReason));\n const resource = source.on?.(\"changed:status\", () => {\n setStatus(getSourceStatus(source, sourceNotAvailableReason));\n });\n return () => resource?.destroy();\n }, [source, intl]);\n return status;\n}\n\n/**\n * Hook to manage map controls and tooltip\n */\nfunction useDragSelection(\n map: MapModel | undefined,\n selectMethode: MethodOption,\n intl: PackageIntl,\n onExtentSelected: (geometry: Geometry) => void,\n isActive: boolean\n) {\n useEffect(() => {\n if (!map) {\n return;\n }\n\n const dragController = new DragController(\n map.olMap,\n selectMethode.value,\n intl.formatMessage({ id: \"tooltip\" }),\n intl.formatMessage({ id: \"disabledTooltip\" }),\n onExtentSelected\n );\n dragController.setActive(isActive);\n\n return () => {\n dragController?.destroy();\n };\n }, [map, selectMethode, intl, onExtentSelected, isActive]);\n}\n\n/**\n * Customizes components styles within the select component.\n */\nfunction useChakraStyles() {\n const [dropDownBackground, borderColor] = useToken(\n \"colors\",\n [\"background_body\", \"border\"],\n [\"#ffffff\", \"#ffffff\"]\n );\n return useMemo(() => {\n const chakraStyles: ChakraStylesConfig<\n SelectionOption,\n false,\n GroupBase<SelectionOption>\n > = {\n control: (styles) => ({ ...styles, cursor: \"pointer\" }),\n indicatorSeparator: (styles) => ({\n ...styles,\n borderColor: borderColor\n }),\n dropdownIndicator: (provided) => ({\n ...provided,\n backgroundColor: dropDownBackground\n })\n };\n return chakraStyles;\n }, [dropDownBackground, borderColor]);\n}\n"],"names":["SelectionMethods","controller"],"mappings":";;;;;;;;;;;AA2GY,IAAA,gBAAA,qBAAAA,iBAAL,KAAA;AACH,EAAAA,kBAAA,QAAS,CAAA,GAAA,QAAA,CAAA;AACT,EAAAA,kBAAA,SAAU,CAAA,GAAA,SAAA,CAAA;AACV,EAAAA,kBAAA,MAA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mB,CAAA;AAAA,MAC5C,gBAAA;AAAA,KACJ,CAAA;AACA,IAAA,cAAA,CAAe,UAAU,QAAQ,CAAA,CAAA;AAEjC,IAAA,OAAO,MAAM;AACT,MAAA,cAAA,EAAgB,OAAQ,EAAA,CAAA;AAAA,KAC5B,CAAA;AAAA,KACD,CAAC,GAAA,EAAK,eAAe,IAAM,EAAA,gBAAA,EAAkB,QAAQ,CAAC,CAAA,CAAA;AAC7D,CAAA;AAKA,SAAS,eAAkB,GAAA;AACvB,EAAM,MAAA,CAAC,kBAAoB,EAAA,WAAW,CAAI,GAAA,QAAA;AAAA,IACtC,QAAA;AAAA,IACA,CAAC,mBAAmB,QAAQ,CAAA;AAAA,IAC5B,CAAC,WAAW,SAAS,CAAA;AAAA,GACzB,CAAA;AACA,EAAA,OAAO,QAAQ,MAAM;AACjB,IAAA,MAAM,YAIF,GAAA;AAAA,MACA,SAAS,CAAC,MAAA,MAAY,EAAE,GAAG,MAAA,EAAQ,QAAQ,SAAU,EAAA,CAAA;AAAA,MACrD,kBAAA,EAAoB,CAAC,MAAY,MAAA;AAAA,QAC7B,GAAG,MAAA;AAAA,QACH,WAAA;AAAA,OACJ,CAAA;AAAA,MACA,iBAAA,EAAmB,CAAC,QAAc,MAAA;AAAA,QAC9B,GAAG,QAAA;AAAA,QACH,eAAiB,EAAA,kBAAA;AAAA,OACrB,CAAA;AAAA,KACJ,CAAA;AACA,IAAO,OAAA,YAAA,CAAA;AAAA,GACR,EAAA,CAAC,kBAAoB,EAAA,WAAW,CAAC,CAAA,CAAA;AACxC;;;;"}
1
+ {"version":3,"file":"Selection.js","sources":["Selection.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {\n Box,\n Flex,\n FormControl,\n FormLabel,\n Icon,\n Tooltip,\n VStack,\n chakra,\n useToken\n} from \"@open-pioneer/chakra-integration\";\nimport { MapModel, useMapModel } from \"@open-pioneer/map\";\nimport { NotificationService } from \"@open-pioneer/notifier\";\nimport { CommonComponentProps, useCommonComponentProps, useEvent } from \"@open-pioneer/react-utils\";\nimport { PackageIntl } from \"@open-pioneer/runtime\";\nimport {\n OptionProps,\n Select,\n Props as SelectProps,\n SingleValueProps,\n chakraComponents,\n type SingleValue,\n ChakraStylesConfig,\n GroupBase\n} from \"chakra-react-select\";\nimport { Geometry } from \"ol/geom\";\nimport { useIntl, useService } from \"open-pioneer:react-hooks\";\nimport { FC, useCallback, useEffect, useMemo, useState } from \"react\";\nimport { FiAlertTriangle } from \"react-icons/fi\";\nimport { DragController } from \"./DragController\";\nimport { SelectionController } from \"./SelectionController\";\nimport { SelectionResult, SelectionSource, SelectionSourceStatusObject } from \"./api\";\nimport { KeyboardEvent } from \"react\";\n\n/**\n * Properties supported by the {@link Selection} component.\n */\nexport interface SelectionProps extends CommonComponentProps {\n /**\n * The id of the map.\n */\n mapId: string;\n\n /**\n * Array of selection sources available for spatial selection.\n */\n sources: SelectionSource[];\n\n /**\n * This handler is called whenever the user has successfully selected\n * some items.\n */\n onSelectionComplete?(event: SelectionCompleteEvent): void;\n\n /**\n * This handler is called whenever the user has changed the selected source\n */\n onSelectionSourceChanged?(event: SelectionSourceChangedEvent): void;\n}\n\nexport interface SelectionCompleteEvent {\n /** The source that returned the {@link results}. */\n source: SelectionSource;\n\n /** Results selected by the user. */\n results: SelectionResult[];\n}\n\nexport interface SelectionSourceChangedEvent {\n /** The new selected source */\n source: SelectionSource | undefined;\n}\n\n/**\n * Properties for single select options.\n */\ninterface SelectionOption {\n /**\n * The label of the selection source option.\n */\n label: string;\n\n /**\n * The value (SelectionSource) of the selection source option.\n */\n value: SelectionSource | undefined;\n}\n\n/**\n * Properties for single selection method options.\n */\ninterface MethodOption {\n /**\n * The label of the select method option.\n */\n label: string;\n\n /**\n * The value of the select method option.\n */\n value: string;\n}\n\n/**\n * Supported selection methods\n */\nexport enum SelectionMethods {\n extent = \"EXTENT\",\n polygon = \"POLYGON\",\n free = \"FREEPOLYGON\",\n circle = \"CIRCLE\"\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst COMMON_SELECT_PROPS: SelectProps<any, any, any> = {\n classNamePrefix: \"react-select\",\n menuPosition: \"fixed\",\n isSearchable: false,\n isClearable: false\n};\n\n/**\n * A component that allows the user to perform a spatial selection on a given set of {@link SelectionSource}.\n */\nexport const Selection: FC<SelectionProps> = (props) => {\n const intl = useIntl();\n const { mapId, sources, onSelectionComplete, onSelectionSourceChanged } = props;\n const { containerProps } = useCommonComponentProps(\"selection\", props);\n const [currentSource, setCurrentSource] = useState<SelectionSource | undefined>(() =>\n sources.find((s) => (s.status ?? \"available\") === \"available\")\n );\n const mapState = useMapModel(mapId);\n const { onExtentSelected } = useSelectionController(\n mapState.map,\n sources,\n currentSource,\n onSelectionComplete\n );\n const chakraStyles = useChakraStyles();\n const [isOpenSelect, setIsOpenSelect] = useState(false);\n\n /**\n * Method to build Option-Array from the supported selection methods for the selection-method react-select\n * If there is no configuration => Default selection method: EXTENT\n */\n const buildMethodOptions = useCallback(\n (methods: string[] | undefined) => {\n const objects: MethodOption[] = [];\n if (!methods) methods = [SelectionMethods.extent];\n methods.forEach((item) => {\n if (Object.values(SelectionMethods as unknown as string[]).includes(item))\n objects.push({ label: intl.formatMessage({ id: item }), value: item });\n });\n if (objects.length === 0) throw new Error(\"methods does not contain valid values\");\n return objects;\n },\n [intl]\n );\n\n const methodOptions: MethodOption[] = buildMethodOptions(undefined);\n const [selectedMethod, setSelectedMethod] = useState(methodOptions[0] as MethodOption);\n\n /**\n * Method to change used selectmethod\n */\n const onMethodeOptionChance = useEvent((newValue: MethodOption) => {\n setSelectedMethod(newValue);\n });\n\n const [dragControllerActive, setDragControllerActive] = useState<boolean>(true);\n useDragSelection(mapState.map, selectedMethod, intl, onExtentSelected, dragControllerActive);\n\n /**\n * Method to build Option-Array from sources for the selection-source react-select\n */\n const sourceOptions = useMemo(\n () =>\n sources.map<SelectionOption>((source) => {\n return { label: source.label, value: source };\n }),\n [sources]\n );\n const currentSourceOption = useMemo(\n () => sourceOptions.find((option) => option.value === currentSource),\n [sourceOptions, currentSource]\n );\n\n /**\n * Method to change used source\n */\n const onSourceOptionChanged = useEvent((newValue: SingleValue<SelectionOption>) => {\n setCurrentSource(newValue?.value);\n onSelectionSourceChanged && onSelectionSourceChanged({ source: newValue?.value });\n });\n\n useEffect(() => {\n if (!currentSource) {\n setDragControllerActive(false);\n return;\n }\n\n const sourceNotAvailableReason = intl.formatMessage({ id: \"sourceNotAvailable\" });\n const isCurrentSourceAvailable = () => {\n return (\n currentSource &&\n getSourceStatus(currentSource, sourceNotAvailableReason).kind === \"available\"\n );\n };\n\n setDragControllerActive(isCurrentSourceAvailable());\n // Why can this be undefined after test above?!\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const handle = currentSource.on(\"changed:status\", () => {\n setDragControllerActive(isCurrentSourceAvailable());\n });\n return () => handle.destroy();\n }, [currentSource, setDragControllerActive, intl]);\n const keyDown = useEvent((event: KeyboardEvent<HTMLDivElement>) => {\n //if the menu is already open, do noting\n if (!isOpenSelect && event.key === \"Enter\") {\n setIsOpenSelect(true);\n }\n });\n\n return (\n <VStack {...containerProps} spacing={2}>\n {methodOptions.length > 1 && (\n <FormControl>\n <FormLabel>{intl.formatMessage({ id: \"selectMethod\" })}</FormLabel>\n <Select\n className=\"selection-method react-select\"\n {...COMMON_SELECT_PROPS}\n options={methodOptions}\n onChange={onMethodeOptionChance}\n value={selectedMethod}\n chakraStyles={chakraStyles}\n />\n </FormControl>\n )}\n <FormControl>\n <FormLabel>{intl.formatMessage({ id: \"selectSource\" })}</FormLabel>\n <Select<SelectionOption>\n className=\"selection-source react-select\"\n {...COMMON_SELECT_PROPS}\n options={sourceOptions}\n placeholder={intl.formatMessage({ id: \"selectionPlaceholder\" })}\n value={currentSourceOption}\n onChange={onSourceOptionChanged}\n components={{\n Option: SourceSelectOption,\n SingleValue: SourceSelectValue\n }}\n isOptionDisabled={(option) =>\n option.value === undefined || option.value.status === \"unavailable\"\n }\n // optionLabel is used by screenreaders\n getOptionLabel={(option) =>\n option.label +\n (option.value === undefined || option.value.status === \"unavailable\"\n ? \" \" + intl.formatMessage({ id: \"sourceNotAvailable\" })\n : \"\")\n }\n chakraStyles={chakraStyles}\n onKeyDown={keyDown}\n menuIsOpen={isOpenSelect}\n onMenuOpen={() => setIsOpenSelect(true)}\n onMenuClose={() => setIsOpenSelect(false)}\n />\n </FormControl>\n </VStack>\n );\n};\n\nfunction SourceSelectOption(props: OptionProps<SelectionOption>): JSX.Element {\n const { value } = props.data;\n const { isAvailable, content } = useSourceItem(value, false);\n\n return (\n <chakraComponents.Option\n {...props}\n isDisabled={!isAvailable}\n className=\"selection-source-option\"\n >\n {content}\n </chakraComponents.Option>\n );\n}\n\nfunction SourceSelectValue(props: SingleValueProps<SelectionOption>): JSX.Element {\n const { value } = props.data;\n const { isAvailable, content } = useSourceItem(value, true);\n const clazz = isAvailable\n ? \"selection-source-value\"\n : \"selection-source-value selection-source-value--disabled\";\n\n return (\n <chakraComponents.SingleValue {...props} isDisabled={!isAvailable} className={clazz}>\n {content}\n </chakraComponents.SingleValue>\n );\n}\n\n/**\n * Hook to manage source option in selection-source react-select\n */\nfunction useSourceItem(source: SelectionSource | undefined, isSelected: boolean) {\n const label: string | undefined = source?.label;\n const status = useSourceStatus(source);\n\n return {\n isAvailable: status.kind === \"available\",\n content: (\n <Flex direction=\"row\" alignItems=\"center\" grow={1}>\n {!isSelected && <Flex grow={1}>{label}</Flex>}\n {status.kind === \"unavailable\" && (\n <Box ml={2}>\n <Tooltip label={status.reason} placement=\"right\" openDelay={500}>\n <chakra.span>\n <Icon\n as={FiAlertTriangle}\n color=\"red\"\n className=\"warning-icon\"\n aria-label={status.reason}\n />\n </chakra.span>\n </Tooltip>\n </Box>\n )}\n {isSelected && label}\n </Flex>\n )\n };\n}\n\n/**\n * Hook to manage selection sources\n */\nfunction useSelectionController(\n mapModel: MapModel | undefined,\n sources: SelectionSource[],\n currentSource: SelectionSource | undefined,\n onSelectionComplete: ((event: SelectionCompleteEvent) => void) | undefined\n) {\n const notifier = useService<NotificationService>(\"notifier.NotificationService\");\n const intl = useIntl();\n const [controller, setController] = useState<SelectionController | undefined>(undefined);\n useEffect(() => {\n if (!mapModel) {\n return;\n }\n const controller = new SelectionController({\n mapModel,\n onError() {\n notifier.notify({\n level: \"error\",\n message: intl.formatMessage({ id: \"selectionFailed\" })\n });\n }\n });\n setController(controller);\n return () => {\n controller.destroy();\n };\n }, [mapModel, notifier, sources, intl]);\n\n const onExtentSelected = useEvent(async (geometry: Geometry) => {\n if (!controller || !currentSource) {\n return;\n }\n\n const selectionResult = await controller.select(currentSource, geometry.getExtent());\n if (!selectionResult) {\n return;\n }\n\n onSelectionComplete?.(selectionResult);\n });\n return {\n controller,\n onExtentSelected\n };\n}\n\ntype SimpleStatus =\n | {\n kind: \"available\";\n }\n | {\n kind: \"unavailable\";\n reason: string;\n };\n\nfunction getSourceStatus(source: SelectionSource, sourceNotAvailableReason: string): SimpleStatus {\n const rawCurrent = source.status ?? \"available\";\n const current: SelectionSourceStatusObject =\n typeof rawCurrent === \"string\" ? { kind: rawCurrent } : rawCurrent;\n if (current.kind === \"available\") {\n return current;\n }\n\n return {\n kind: \"unavailable\",\n reason: current.reason ?? sourceNotAvailableReason\n };\n}\n\n/**\n * Hook to manage source status\n */\nfunction useSourceStatus(source: SelectionSource | undefined): SimpleStatus {\n const intl = useIntl();\n const [status, setStatus] = useState<SimpleStatus>(() => ({ kind: \"available\" }));\n useEffect(() => {\n if (!source) {\n setStatus({ kind: \"available\" });\n return;\n }\n const sourceNotAvailableReason = intl.formatMessage({ id: \"sourceNotAvailable\" });\n setStatus(getSourceStatus(source, sourceNotAvailableReason));\n const resource = source.on?.(\"changed:status\", () => {\n setStatus(getSourceStatus(source, sourceNotAvailableReason));\n });\n return () => resource?.destroy();\n }, [source, intl]);\n return status;\n}\n\n/**\n * Hook to manage map controls and tooltip\n */\nfunction useDragSelection(\n map: MapModel | undefined,\n selectMethode: MethodOption,\n intl: PackageIntl,\n onExtentSelected: (geometry: Geometry) => void,\n isActive: boolean\n) {\n useEffect(() => {\n if (!map) {\n return;\n }\n\n const dragController = new DragController(\n map.olMap,\n selectMethode.value,\n intl.formatMessage({ id: \"tooltip\" }),\n intl.formatMessage({ id: \"disabledTooltip\" }),\n onExtentSelected\n );\n dragController.setActive(isActive);\n\n return () => {\n dragController?.destroy();\n };\n }, [map, selectMethode, intl, onExtentSelected, isActive]);\n}\n\n/**\n * Customizes components styles within the select component.\n */\nfunction useChakraStyles() {\n const [dropDownBackground, borderColor] = useToken(\n \"colors\",\n [\"background_body\", \"border\"],\n [\"#ffffff\", \"#ffffff\"]\n );\n return useMemo(() => {\n const chakraStyles: ChakraStylesConfig<\n SelectionOption,\n false,\n GroupBase<SelectionOption>\n > = {\n control: (styles) => ({ ...styles, cursor: \"pointer\" }),\n indicatorSeparator: (styles) => ({\n ...styles,\n borderColor: borderColor\n }),\n dropdownIndicator: (provided) => ({\n ...provided,\n backgroundColor: dropDownBackground\n })\n };\n return chakraStyles;\n }, [dropDownBackground, borderColor]);\n}\n"],"names":["SelectionMethods","controller"],"mappings":";;;;;;;;;;;AA4GY,IAAA,gBAAA,qBAAAA,iBAAL,KAAA;AACH,EAAAA,kBAAA,QAAS,CAAA,GAAA,QAAA,CAAA;AACT,EAAAA,kBAAA,SAAU,CAAA,GAAA,SAAA,CAAA;AACV,EAAAA,kBAAA,MAAO,CAAA,GAAA,aAAA,CAAA;AACP,EAAAA,kBAAA,QAAS,CAAA,GAAA,QAAA,CAAA;AAJD,EAAAA,OAAAA,iBAAAA,CAAAA;AAAA,CAAA,EAAA,gBAAA,IAAA,EAAA,EAAA;AAQZ,MAAM,mBAAkD,GAAA;AAAA,EACpD,eAAiB,EAAA,cAAA;AAAA,EACjB,YAAc,EAAA,OAAA;AAAA,EACd,YAAc,EAAA,KAAA;AAAA,EACd,WAAa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
6
6
  import { DeclaredService } from "@open-pioneer/runtime";
7
7
  import VectorLayer from "ol/layer/Vector";
8
- import VectorSource from "ol/source/Vector";
8
+ import Feature from "ol/Feature";
9
9
  /**
10
10
  * The status of a selection source.
11
11
  *
@@ -115,7 +115,7 @@ export interface SelectionSource extends Partial<SelectionSourceEventBase> {
115
115
  select(selectionKind: SelectionKind, options: SelectionOptions): Promise<SelectionResult[]>;
116
116
  }
117
117
  export interface VectorLayerSelectionSourceOptions {
118
- vectorLayer: VectorLayer<VectorSource>;
118
+ vectorLayer: VectorLayer<Feature>;
119
119
  label: string;
120
120
  }
121
121
  export interface VectorLayerSelectionSource extends Required<SelectionSource>, Resource {
@@ -128,7 +128,7 @@ export interface VectorLayerSelectionSource extends Required<SelectionSource>, R
128
128
  */
129
129
  export interface VectorLayerSelectionSourceFactory extends DeclaredService<"selection.VectorSelectionSourceFactory"> {
130
130
  /**
131
- * Returns a new {@link VectorLayerSelectionSourceImpl} that operates on the given OpenLayers VectorLayer.
131
+ * Returns a new {@link VectorLayerSelectionSource} that operates on the given OpenLayers VectorLayer.
132
132
  */
133
133
  createSelectionSource(options: VectorLayerSelectionSourceOptions): VectorLayerSelectionSource;
134
134
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/selection",
4
- "version": "0.2.1",
4
+ "version": "0.2.3",
5
5
  "description": "This package provides a UI component to perform a selection on given selection sources from the map.",
6
6
  "keywords": [
7
7
  "open-pioneer-trails"
@@ -14,21 +14,21 @@
14
14
  "directory": "src/packages/selection"
15
15
  },
16
16
  "dependencies": {
17
- "uuid": "^9.0.1",
18
- "classnames": "^2.3.2"
17
+ "classnames": "^2.3.2",
18
+ "uuid": "^10.0.0"
19
19
  },
20
20
  "peerDependencies": {
21
- "@open-pioneer/chakra-integration": "^1.1.1",
22
- "@open-pioneer/runtime": "^2.1.2",
23
- "@open-pioneer/core": "^1.2.1",
24
- "@open-pioneer/notifier": "^0.3.1",
25
- "ol": "^9.0.0",
26
- "react": "^18.2.0",
27
- "chakra-react-select": "^4.7.6",
28
21
  "@chakra-ui/icons": "^2.1.1",
29
- "react-icons": "^4.12.0",
30
- "@open-pioneer/map": "^0.5.0",
31
- "@open-pioneer/react-utils": "^0.2.2"
22
+ "@open-pioneer/chakra-integration": "^1.1.3",
23
+ "@open-pioneer/core": "^1.2.3",
24
+ "@open-pioneer/notifier": "^0.3.5",
25
+ "@open-pioneer/react-utils": "^1.0.0",
26
+ "@open-pioneer/runtime": "^2.1.6",
27
+ "chakra-react-select": "^4.7.6",
28
+ "ol": "^9.2.4",
29
+ "react": "^18.3.1",
30
+ "react-icons": "^5.2.1",
31
+ "@open-pioneer/map": "^0.6.0"
32
32
  },
33
33
  "exports": {
34
34
  "./package.json": "./package.json",
@@ -1,8 +1,8 @@
1
1
  import { SelectionSource, SelectionResult, SelectionOptions, SelectionSourceStatus, SelectionSourceEvents, SelectionKind, VectorLayerSelectionSource } from "./api";
2
2
  import { Point } from "ol/geom";
3
3
  import { EventEmitter } from "@open-pioneer/core";
4
- import VectorSource from "ol/source/Vector";
5
4
  import VectorLayer from "ol/layer/Vector";
5
+ import Feature from "ol/Feature";
6
6
  export declare const fakeSelectedPointFeatures: Point[];
7
7
  export declare class FakePointSelectionSource extends EventEmitter<SelectionSourceEvents> implements SelectionSource {
8
8
  #private;
@@ -23,7 +23,7 @@ export declare class FakePointSelectionSource extends EventEmitter<SelectionSour
23
23
  export declare class VectorLayerSelectionSourceImpl extends EventEmitter<SelectionSourceEvents> implements VectorLayerSelectionSource {
24
24
  #private;
25
25
  readonly label: string;
26
- constructor(vectorLayer: VectorLayer<VectorSource>, label: string, layerNotVisibleReason: string);
26
+ constructor(vectorLayer: VectorLayer<Feature>, label: string, layerNotVisibleReason: string);
27
27
  destroy(): void;
28
28
  get status(): import("./api").SelectionSourceStatusObject;
29
29
  select(selectionKind: SelectionKind, options: SelectionOptions): Promise<SelectionResult[]>;
@@ -1,6 +1,6 @@
1
- import { Point } from 'ol/geom';
1
+ import { Point } from 'ol/geom.js';
2
2
  import { EventEmitter } from '@open-pioneer/core';
3
- import { unByKey } from 'ol/Observable';
3
+ import { unByKey } from 'ol/Observable.js';
4
4
  import { v4 } from 'uuid';
5
5
 
6
6
  [
@@ -35,12 +35,10 @@ class VectorLayerSelectionSourceImpl extends EventEmitter {
35
35
  if (selectionKind.type !== "extent") {
36
36
  throw new Error(`Unsupported selection kind: ${selectionKind.type}`);
37
37
  }
38
- if (this.#status.kind !== "available" || this.#vectorLayer.getSource() === null)
39
- return [];
38
+ if (this.#status.kind !== "available" || this.#vectorLayer.getSource() === null) return [];
40
39
  const allResults = [];
41
40
  this.#vectorLayer.getSource().forEachFeatureIntersectingExtent(selectionKind.extent, (feature) => {
42
- if (!feature.getGeometry())
43
- return;
41
+ if (!feature.getGeometry()) return;
44
42
  const filteredProperties = { ...feature.getProperties() };
45
43
  delete filteredProperties.geometries;
46
44
  const result = {
@@ -1 +1 @@
1
- {"version":3,"file":"selectionSources.js","sources":["selectionSources.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {\n SelectionSource,\n SelectionResult,\n SelectionOptions,\n SelectionSourceStatus,\n SelectionSourceEvents,\n SelectionKind,\n VectorLayerSelectionSource\n} from \"./api\";\nimport { Point } from \"ol/geom\";\nimport { EventEmitter } from \"@open-pioneer/core\";\nimport VectorSource from \"ol/source/Vector\";\nimport VectorLayer from \"ol/layer/Vector\";\nimport { EventsKey } from \"ol/events\";\nimport { unByKey } from \"ol/Observable\";\nimport { v4 as uuid4v } from \"uuid\";\n\nexport const fakeSelectedPointFeatures = [\n new Point([407354, 5754673]), // con terra (Bottom Right)\n new Point([404740, 5757893]) // Schloss (Top Left)\n];\n\nlet count = 0;\n\nexport class FakePointSelectionSource\n extends EventEmitter<SelectionSourceEvents>\n implements SelectionSource\n{\n readonly label = `Fake Selection Source #${++count}`;\n #timeout: number;\n #status: SelectionSourceStatus;\n #pointFeatures: Point[];\n\n constructor(\n timeout?: number,\n status?: SelectionSourceStatus,\n pointFeatures: Point[] = fakeSelectedPointFeatures\n ) {\n super();\n this.#timeout = timeout || 0;\n this.#status = status || \"unavailable\";\n this.#pointFeatures = pointFeatures;\n }\n\n get status(): SelectionSourceStatus {\n return this.#status;\n }\n\n set status(value: SelectionSourceStatus) {\n if (value !== this.#status) {\n this.#status = value;\n this.emit(\"changed:status\");\n }\n }\n\n async select(\n selectionKind: SelectionKind,\n options: SelectionOptions\n ): Promise<SelectionResult[]> {\n if (selectionKind.type !== \"extent\") {\n throw new Error(`Unsupported selection kind: ${selectionKind.type}`);\n }\n\n if (this.#status !== \"available\") return [];\n\n await new Promise((resolve) => setTimeout(resolve, this.#timeout));\n\n const allPoints = this.#pointFeatures.map((point, index) => {\n const result: SelectionResult = {\n id: index,\n geometry: point\n };\n if (!point.intersectsExtent(selectionKind.extent)) {\n return undefined;\n }\n return result;\n });\n\n const selectedPoints = allPoints.filter((s): s is SelectionResult => s != null);\n const limitedResults =\n selectedPoints.length > options.maxResults\n ? selectedPoints.slice(0, options.maxResults)\n : selectedPoints;\n return limitedResults;\n }\n}\n\n/**\n * A SelectionSource to use an OpenLayers VectorLayer with an OpenLayers VectorSource (e.g. layer of the map).\n * Features are:\n * - using only the extent as selection kind\n * - listening to layer visibility changes and updating the status of the source\n * - limiting the number of returned selection results to the corresponding selection option\n * - throwing an event `changed:status` when the status updates\n */\nexport class VectorLayerSelectionSourceImpl\n extends EventEmitter<SelectionSourceEvents>\n implements VectorLayerSelectionSource\n{\n readonly label: string;\n #status: Exclude<SelectionSourceStatus, string> = { kind: \"available\" };\n #vectorLayer: VectorLayer<VectorSource>;\n #eventHandler: EventsKey;\n #layerNotVisibleReason: string;\n\n constructor(\n vectorLayer: VectorLayer<VectorSource>,\n label: string,\n layerNotVisibleReason: string\n ) {\n super();\n this.label = label;\n this.#vectorLayer = vectorLayer;\n this.#layerNotVisibleReason = layerNotVisibleReason;\n this.#updateStatus();\n this.#eventHandler = this.#vectorLayer.on(\"change:visible\", () => {\n this.#updateStatus();\n });\n }\n\n destroy() {\n unByKey(this.#eventHandler);\n }\n\n get status() {\n return this.#status;\n }\n\n async select(\n selectionKind: SelectionKind,\n options: SelectionOptions\n ): Promise<SelectionResult[]> {\n if (selectionKind.type !== \"extent\") {\n throw new Error(`Unsupported selection kind: ${selectionKind.type}`);\n }\n\n if (this.#status.kind !== \"available\" || this.#vectorLayer.getSource() === null) return [];\n\n const allResults: SelectionResult[] = [];\n this.#vectorLayer\n .getSource()!\n .forEachFeatureIntersectingExtent(selectionKind.extent, (feature) => {\n if (!feature.getGeometry()) return;\n\n // TODO: Think about where to implement Date-Formatting, if the dates are already\n // encoded as Strings...\n\n const filteredProperties = { ...feature.getProperties() };\n delete filteredProperties.geometries;\n\n const result: SelectionResult = {\n id: feature.getId()?.toString() || uuid4v(),\n geometry: feature.getGeometry()!,\n properties: filteredProperties\n };\n\n allResults.push(result);\n });\n const selectedFeatures = allResults.filter((s): s is SelectionResult => s != null);\n const limitedFeatures =\n selectedFeatures.length > options.maxResults\n ? selectedFeatures.slice(0, options.maxResults)\n : selectedFeatures;\n return limitedFeatures;\n }\n\n #updateStatus() {\n const layerIsVisible = this.#vectorLayer.getVisible();\n const newStatus: SelectionSourceStatus = layerIsVisible\n ? { kind: \"available\" }\n : { kind: \"unavailable\", reason: this.#layerNotVisibleReason };\n if (newStatus.kind !== this.#status.kind) {\n this.#status = newStatus;\n this.emit(\"changed:status\");\n }\n }\n}\n\n/**\n * For testing purposes only\n */\nexport class NoStatusSelectionSource\n extends EventEmitter<SelectionSourceEvents>\n implements SelectionSource\n{\n readonly label: string = \"Testlabel\";\n\n async select(_: SelectionKind, __: SelectionOptions): Promise<SelectionResult[]> {\n const allPoints = fakeSelectedPointFeatures.map((point, index) => {\n const result: SelectionResult = {\n id: index,\n geometry: point\n };\n return result;\n });\n return allPoints;\n }\n}\n"],"names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CAAA;AACjE,IAAA,IAAI,SAAU,CAAA,IAAA,KAAS,IAAK,CAAA,OAAA,CAAQ,IAAM,EAAA;AACtC,MAAA,IAAA,CAAK,OAAU,GAAA,SAAA,CAAA;AACf,MAAA,IAAA,CAAK,KAAK,gBAAgB,CAAA,CAAA;AAAA,KAC9B;AAAA,GACJ;AACJ;;;;"}
1
+ {"version":3,"file":"selectionSources.js","sources":["selectionSources.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {\n SelectionSource,\n SelectionResult,\n SelectionOptions,\n SelectionSourceStatus,\n SelectionSourceEvents,\n SelectionKind,\n VectorLayerSelectionSource\n} from \"./api\";\nimport { Point } from \"ol/geom\";\nimport { EventEmitter } from \"@open-pioneer/core\";\nimport VectorLayer from \"ol/layer/Vector\";\nimport { EventsKey } from \"ol/events\";\nimport { unByKey } from \"ol/Observable\";\nimport { v4 as uuid4v } from \"uuid\";\nimport Feature from \"ol/Feature\";\n\nexport const fakeSelectedPointFeatures = [\n new Point([407354, 5754673]), // con terra (Bottom Right)\n new Point([404740, 5757893]) // Schloss (Top Left)\n];\n\nlet count = 0;\n\nexport class FakePointSelectionSource\n extends EventEmitter<SelectionSourceEvents>\n implements SelectionSource\n{\n readonly label = `Fake Selection Source #${++count}`;\n #timeout: number;\n #status: SelectionSourceStatus;\n #pointFeatures: Point[];\n\n constructor(\n timeout?: number,\n status?: SelectionSourceStatus,\n pointFeatures: Point[] = fakeSelectedPointFeatures\n ) {\n super();\n this.#timeout = timeout || 0;\n this.#status = status || \"unavailable\";\n this.#pointFeatures = pointFeatures;\n }\n\n get status(): SelectionSourceStatus {\n return this.#status;\n }\n\n set status(value: SelectionSourceStatus) {\n if (value !== this.#status) {\n this.#status = value;\n this.emit(\"changed:status\");\n }\n }\n\n async select(\n selectionKind: SelectionKind,\n options: SelectionOptions\n ): Promise<SelectionResult[]> {\n if (selectionKind.type !== \"extent\") {\n throw new Error(`Unsupported selection kind: ${selectionKind.type}`);\n }\n\n if (this.#status !== \"available\") return [];\n\n await new Promise((resolve) => setTimeout(resolve, this.#timeout));\n\n const allPoints = this.#pointFeatures.map((point, index) => {\n const result: SelectionResult = {\n id: index,\n geometry: point\n };\n if (!point.intersectsExtent(selectionKind.extent)) {\n return undefined;\n }\n return result;\n });\n\n const selectedPoints = allPoints.filter((s): s is SelectionResult => s != null);\n const limitedResults =\n selectedPoints.length > options.maxResults\n ? selectedPoints.slice(0, options.maxResults)\n : selectedPoints;\n return limitedResults;\n }\n}\n\n/**\n * A SelectionSource to use an OpenLayers VectorLayer with an OpenLayers VectorSource (e.g. layer of the map).\n * Features are:\n * - using only the extent as selection kind\n * - listening to layer visibility changes and updating the status of the source\n * - limiting the number of returned selection results to the corresponding selection option\n * - throwing an event `changed:status` when the status updates\n */\nexport class VectorLayerSelectionSourceImpl\n extends EventEmitter<SelectionSourceEvents>\n implements VectorLayerSelectionSource\n{\n readonly label: string;\n #status: Exclude<SelectionSourceStatus, string> = { kind: \"available\" };\n #vectorLayer: VectorLayer<Feature>;\n #eventHandler: EventsKey;\n #layerNotVisibleReason: string;\n\n constructor(vectorLayer: VectorLayer<Feature>, label: string, layerNotVisibleReason: string) {\n super();\n this.label = label;\n this.#vectorLayer = vectorLayer;\n this.#layerNotVisibleReason = layerNotVisibleReason;\n this.#updateStatus();\n this.#eventHandler = this.#vectorLayer.on(\"change:visible\", () => {\n this.#updateStatus();\n });\n }\n\n destroy() {\n unByKey(this.#eventHandler);\n }\n\n get status() {\n return this.#status;\n }\n\n async select(\n selectionKind: SelectionKind,\n options: SelectionOptions\n ): Promise<SelectionResult[]> {\n if (selectionKind.type !== \"extent\") {\n throw new Error(`Unsupported selection kind: ${selectionKind.type}`);\n }\n\n if (this.#status.kind !== \"available\" || this.#vectorLayer.getSource() === null) return [];\n\n const allResults: SelectionResult[] = [];\n this.#vectorLayer\n .getSource()!\n .forEachFeatureIntersectingExtent(selectionKind.extent, (feature) => {\n if (!feature.getGeometry()) return;\n\n // TODO: Think about where to implement Date-Formatting, if the dates are already\n // encoded as Strings...\n\n const filteredProperties = { ...feature.getProperties() };\n delete filteredProperties.geometries;\n\n const result: SelectionResult = {\n id: feature.getId()?.toString() || uuid4v(),\n geometry: feature.getGeometry()!,\n properties: filteredProperties\n };\n\n allResults.push(result);\n });\n const selectedFeatures = allResults.filter((s): s is SelectionResult => s != null);\n const limitedFeatures =\n selectedFeatures.length > options.maxResults\n ? selectedFeatures.slice(0, options.maxResults)\n : selectedFeatures;\n return limitedFeatures;\n }\n\n #updateStatus() {\n const layerIsVisible = this.#vectorLayer.getVisible();\n const newStatus: SelectionSourceStatus = layerIsVisible\n ? { kind: \"available\" }\n : { kind: \"unavailable\", reason: this.#layerNotVisibleReason };\n if (newStatus.kind !== this.#status.kind) {\n this.#status = newStatus;\n this.emit(\"changed:status\");\n }\n }\n}\n\n/**\n * For testing purposes only\n */\nexport class NoStatusSelectionSource\n extends EventEmitter<SelectionSourceEvents>\n implements SelectionSource\n{\n readonly label: string = \"Testlabel\";\n\n async select(_: SelectionKind, __: SelectionOptions): Promise<SelectionResult[]> {\n const allPoints = fakeSelectedPointFeatures.map((point, index) => {\n const result: SelectionResult = {\n id: index,\n geometry: point\n };\n return result;\n });\n return allPoints;\n }\n}\n"],"names":["uuid4v"],"mappings":";;;;;AAmByC;AAAA,EACrC,IAAI,KAAA,CAAM,CAAC,MAAA,EAAQ,OAAO,CAAC,CAAA;AAAA;AAAA,EAC3B,IAAI,KAAA,CAAM,CAAC,MAAA,EAAQ,OAAO,CAAC,CAAA;AAAA;AAC/B,EAAA;AA2EO,MAAM,uCACD,YAEZ,CAAA;AAAA,EACa,KAAA,CAAA;AAAA,EACT,OAAA,GAAkD,EAAE,IAAA,EAAM,WAAY,EAAA,CAAA;AAAA,EACtE,YAAA,CAAA;AAAA,EACA,aAAA,CAAA;AAAA,EACA,sBAAA,CAAA;AAAA,EAEA,WAAA,CAAY,WAAmC,E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