@open-pioneer/selection 0.10.0 → 0.10.1-dev-chakra-v3.20250512110627
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 +7 -0
- package/Selection.js +85 -121
- package/Selection.js.map +1 -1
- package/package.json +10 -11
- package/selection.css +1 -1
- package/selection.css.map +1 -1
package/CHANGELOG.md
CHANGED
package/Selection.js
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { createListCollection, VStack, Select, Portal, Flex, Box, chakra, Icon } from '@chakra-ui/react';
|
|
3
|
+
import { Tooltip } from '@open-pioneer/chakra-snippets/tooltip';
|
|
4
|
+
import { Field } from '@open-pioneer/chakra-snippets/field';
|
|
3
5
|
import { useMapModel } from '@open-pioneer/map';
|
|
4
6
|
import { useCommonComponentProps, useEvent } from '@open-pioneer/react-utils';
|
|
5
|
-
import { Select, chakraComponents } from 'chakra-react-select';
|
|
6
7
|
import { useIntl, useService } from './_virtual/_virtual-pioneer-module_react-hooks.js';
|
|
7
|
-
import { useState,
|
|
8
|
+
import { useState, useEffect, useRef, useCallback } from 'react';
|
|
8
9
|
import { FiAlertTriangle } from 'react-icons/fi';
|
|
9
10
|
import { useReactiveSnapshot } from '@open-pioneer/reactivity';
|
|
10
11
|
import { DragController } from './DragController.js';
|
|
11
12
|
import { SelectionController } from './SelectionController.js';
|
|
12
13
|
|
|
13
|
-
const COMMON_SELECT_PROPS = {
|
|
14
|
-
classNamePrefix: "react-select",
|
|
15
|
-
menuPosition: "fixed",
|
|
16
|
-
isSearchable: false,
|
|
17
|
-
isClearable: false
|
|
18
|
-
};
|
|
19
14
|
const Selection = (props) => {
|
|
20
15
|
const intl = useIntl();
|
|
21
16
|
const { sources, onSelectionComplete, onSelectionSourceChanged } = props;
|
|
@@ -33,8 +28,6 @@ const Selection = (props) => {
|
|
|
33
28
|
currentSource,
|
|
34
29
|
onSelectionComplete
|
|
35
30
|
);
|
|
36
|
-
const chakraStyles = useChakraStyles();
|
|
37
|
-
const [isOpenSelect, setIsOpenSelect] = useState(false);
|
|
38
31
|
useDragSelection(
|
|
39
32
|
mapState.map,
|
|
40
33
|
intl,
|
|
@@ -42,86 +35,71 @@ const Selection = (props) => {
|
|
|
42
35
|
currentSourceStatus.kind === "available",
|
|
43
36
|
!!currentSource
|
|
44
37
|
);
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
(option) => option.value === currentSource
|
|
54
|
-
);
|
|
55
|
-
return foundOption || null;
|
|
56
|
-
}, [sourceOptions, currentSource]);
|
|
57
|
-
const onSourceOptionChanged = useEvent((newValue) => {
|
|
58
|
-
setCurrentSource(newValue?.value);
|
|
38
|
+
const getId = useSelectionSourceId();
|
|
39
|
+
const sourceOptionsCollection = createListCollection({
|
|
40
|
+
items: sources,
|
|
41
|
+
isItemDisabled: () => {
|
|
42
|
+
return false;
|
|
43
|
+
},
|
|
44
|
+
itemToString: (item) => item.label,
|
|
45
|
+
itemToValue: (item) => getId(item)
|
|
59
46
|
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
47
|
+
let triggerItem;
|
|
48
|
+
if (currentSource) {
|
|
49
|
+
triggerItem = /* @__PURE__ */ jsx(SelectionSourceItem, { source: currentSource });
|
|
50
|
+
} else {
|
|
51
|
+
triggerItem = null;
|
|
52
|
+
}
|
|
53
|
+
return /* @__PURE__ */ jsx(VStack, { ...containerProps, gap: 2, children: /* @__PURE__ */ jsx(Field, { label: intl.formatMessage({ id: "selectSource" }), children: /* @__PURE__ */ jsxs(
|
|
54
|
+
Select.Root,
|
|
55
|
+
{
|
|
56
|
+
collection: sourceOptionsCollection,
|
|
57
|
+
value: currentSource ? [getId(currentSource)] : void 0,
|
|
58
|
+
onValueChange: (option) => option && setCurrentSource(option.items[0]),
|
|
59
|
+
lazyMount: true,
|
|
60
|
+
unmountOnExit: true,
|
|
61
|
+
children: [
|
|
62
|
+
/* @__PURE__ */ jsxs(Select.Control, { children: [
|
|
63
|
+
/* @__PURE__ */ jsx(Select.Trigger, { children: /* @__PURE__ */ jsx(
|
|
64
|
+
Select.ValueText,
|
|
65
|
+
{
|
|
66
|
+
placeholder: intl.formatMessage({ id: "selectionPlaceholder" }),
|
|
67
|
+
children: triggerItem
|
|
68
|
+
}
|
|
69
|
+
) }),
|
|
70
|
+
/* @__PURE__ */ jsx(Select.IndicatorGroup, { children: /* @__PURE__ */ jsx(Select.Indicator, {}) })
|
|
71
|
+
] }),
|
|
72
|
+
/* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(Select.Positioner, { children: /* @__PURE__ */ jsx(Select.Content, { children: sourceOptionsCollection.items.map((item) => /* @__PURE__ */ jsx(SelectionSourceItemContent, { item }, getId(item))) }) }) })
|
|
73
|
+
]
|
|
63
74
|
}
|
|
64
|
-
});
|
|
65
|
-
return /* @__PURE__ */ jsx(VStack, { ...containerProps, spacing: 2, children: /* @__PURE__ */ jsxs(FormControl, { children: [
|
|
66
|
-
/* @__PURE__ */ jsx(FormLabel, { children: intl.formatMessage({ id: "selectSource" }) }),
|
|
67
|
-
/* @__PURE__ */ jsx(
|
|
68
|
-
Select,
|
|
69
|
-
{
|
|
70
|
-
className: "selection-source react-select",
|
|
71
|
-
...COMMON_SELECT_PROPS,
|
|
72
|
-
options: sourceOptions,
|
|
73
|
-
placeholder: intl.formatMessage({ id: "selectionPlaceholder" }),
|
|
74
|
-
value: currentSourceOption,
|
|
75
|
-
onChange: onSourceOptionChanged,
|
|
76
|
-
components: {
|
|
77
|
-
Option: SourceSelectOption,
|
|
78
|
-
SingleValue: SourceSelectValue
|
|
79
|
-
},
|
|
80
|
-
isOptionDisabled: () => false,
|
|
81
|
-
getOptionLabel: (option) => {
|
|
82
|
-
const label = option.label;
|
|
83
|
-
const status = getSourceStatus(option.value, defaultNotAvailableMessage);
|
|
84
|
-
if (status.kind == "available") return label;
|
|
85
|
-
return label + " " + status.reason;
|
|
86
|
-
},
|
|
87
|
-
ariaLiveMessages: {
|
|
88
|
-
guidance: () => "",
|
|
89
|
-
onChange: (props2) => {
|
|
90
|
-
if (props2.action == "select-option" || props2.action == "initial-input-focus")
|
|
91
|
-
return props2.label + " " + intl.formatMessage({ id: "selected" });
|
|
92
|
-
else return "";
|
|
93
|
-
},
|
|
94
|
-
onFilter: () => "",
|
|
95
|
-
onFocus: () => ""
|
|
96
|
-
},
|
|
97
|
-
chakraStyles,
|
|
98
|
-
onKeyDown: keyDown,
|
|
99
|
-
menuIsOpen: isOpenSelect,
|
|
100
|
-
onMenuOpen: () => setIsOpenSelect(true),
|
|
101
|
-
onMenuClose: () => setIsOpenSelect(false)
|
|
102
|
-
}
|
|
103
|
-
)
|
|
104
|
-
] }) });
|
|
75
|
+
) }) });
|
|
105
76
|
};
|
|
106
|
-
function
|
|
107
|
-
const
|
|
108
|
-
const
|
|
77
|
+
function useSelectionSourceId() {
|
|
78
|
+
const sourceIds = useRef(void 0);
|
|
79
|
+
const counter = useRef(0);
|
|
80
|
+
if (!sourceIds.current) {
|
|
81
|
+
sourceIds.current = /* @__PURE__ */ new WeakMap();
|
|
82
|
+
}
|
|
83
|
+
return useCallback((selectionSource) => {
|
|
84
|
+
const ids = sourceIds.current;
|
|
85
|
+
if (!ids.has(selectionSource)) {
|
|
86
|
+
ids.set(selectionSource, `source-${counter.current++}`);
|
|
87
|
+
}
|
|
88
|
+
return ids.get(selectionSource);
|
|
89
|
+
}, []);
|
|
90
|
+
}
|
|
91
|
+
function SelectionSourceItemContent(props) {
|
|
92
|
+
const { item } = props;
|
|
109
93
|
return /* @__PURE__ */ jsx(
|
|
110
|
-
|
|
94
|
+
Select.Item,
|
|
111
95
|
{
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
children:
|
|
96
|
+
item,
|
|
97
|
+
justifyContent: "flex-start",
|
|
98
|
+
pointerEvents: "auto",
|
|
99
|
+
children: /* @__PURE__ */ jsx(SelectionSourceItem, { source: item })
|
|
116
100
|
}
|
|
117
101
|
);
|
|
118
102
|
}
|
|
119
|
-
function SourceSelectValue(props) {
|
|
120
|
-
const { value } = props.data;
|
|
121
|
-
const { isAvailable, content } = useSourceItem(value, true);
|
|
122
|
-
const clazz = isAvailable ? "selection-source-value" : "selection-source-value selection-source-value--disabled";
|
|
123
|
-
return /* @__PURE__ */ jsx(chakraComponents.SingleValue, { ...props, isDisabled: !isAvailable, className: clazz, children: content });
|
|
124
|
-
}
|
|
125
103
|
function useCurrentSelectionSource(sources, onSourceChanged) {
|
|
126
104
|
const [currentSource, setCurrentSource] = useState(
|
|
127
105
|
() => sources[0]
|
|
@@ -140,27 +118,34 @@ function useCurrentSelectionSource(sources, onSourceChanged) {
|
|
|
140
118
|
}, [currentSource, onSourceChanged]);
|
|
141
119
|
return [currentSource, setCurrentSource];
|
|
142
120
|
}
|
|
143
|
-
function
|
|
121
|
+
function SelectionSourceItem(props) {
|
|
144
122
|
const intl = useIntl();
|
|
123
|
+
const source = props.source;
|
|
145
124
|
const label = source?.label;
|
|
146
125
|
const defaultNotAvailableMessage = intl.formatMessage({ id: "sourceNotAvailable" });
|
|
147
126
|
const status = useSourceStatus(source, defaultNotAvailableMessage);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
127
|
+
const isAvailable = status.kind === "available";
|
|
128
|
+
const clazz = isAvailable ? "selection-source-value" : "selection-source-value selection-source-value--disabled";
|
|
129
|
+
return /* @__PURE__ */ jsxs(Flex, { className: clazz, direction: "row", alignItems: "center", grow: 1, children: [
|
|
130
|
+
label,
|
|
131
|
+
status.kind === "unavailable" && /* @__PURE__ */ jsx(Box, { ml: 2, children: /* @__PURE__ */ jsx(
|
|
132
|
+
Tooltip,
|
|
133
|
+
{
|
|
134
|
+
content: status.reason,
|
|
135
|
+
positioning: { placement: "right" },
|
|
136
|
+
openDelay: 500,
|
|
137
|
+
children: /* @__PURE__ */ jsx(chakra.span, { children: /* @__PURE__ */ jsx(
|
|
138
|
+
Icon,
|
|
139
|
+
{
|
|
140
|
+
as: FiAlertTriangle,
|
|
141
|
+
color: "red",
|
|
142
|
+
className: "warning-icon",
|
|
143
|
+
"aria-label": status.reason
|
|
144
|
+
}
|
|
145
|
+
) })
|
|
146
|
+
}
|
|
147
|
+
) })
|
|
148
|
+
] });
|
|
164
149
|
}
|
|
165
150
|
function useSelectionController(mapModel, sources, currentSource, onSelectionComplete) {
|
|
166
151
|
const notifier = useService("notifier.NotificationService");
|
|
@@ -237,27 +222,6 @@ function useDragSelection(map, intl, onExtentSelected, isActive, hasSelectedSour
|
|
|
237
222
|
};
|
|
238
223
|
}, [map, intl, onExtentSelected, isActive, hasSelectedSource]);
|
|
239
224
|
}
|
|
240
|
-
function useChakraStyles() {
|
|
241
|
-
const [dropDownBackground, borderColor] = useToken(
|
|
242
|
-
"colors",
|
|
243
|
-
["background_body", "border"],
|
|
244
|
-
["#ffffff", "#ffffff"]
|
|
245
|
-
);
|
|
246
|
-
return useMemo(() => {
|
|
247
|
-
const chakraStyles = {
|
|
248
|
-
control: (styles) => ({ ...styles, cursor: "pointer" }),
|
|
249
|
-
indicatorSeparator: (styles) => ({
|
|
250
|
-
...styles,
|
|
251
|
-
borderColor
|
|
252
|
-
}),
|
|
253
|
-
dropdownIndicator: (provided) => ({
|
|
254
|
-
...provided,
|
|
255
|
-
backgroundColor: dropDownBackground
|
|
256
|
-
})
|
|
257
|
-
};
|
|
258
|
-
return chakraStyles;
|
|
259
|
-
}, [dropDownBackground, borderColor]);
|
|
260
|
-
}
|
|
261
225
|
|
|
262
226
|
export { Selection };
|
|
263
227
|
//# sourceMappingURL=Selection.js.map
|
package/Selection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Selection.js","sources":["Selection.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 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, MapModelProps, 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 ChakraStylesConfig,\n GroupBase,\n OptionProps,\n Select,\n Props as SelectProps,\n SingleValueProps,\n chakraComponents,\n type SingleValue\n} from \"chakra-react-select\";\nimport { Geometry } from \"ol/geom\";\nimport { useIntl, useService } from \"open-pioneer:react-hooks\";\nimport { FC, KeyboardEvent, ReactNode, useEffect, useMemo, useRef, useState } from \"react\";\nimport { FiAlertTriangle } from \"react-icons/fi\";\nimport { useReactiveSnapshot } from \"@open-pioneer/reactivity\";\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, MapModelProps {\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;\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 { sources, onSelectionComplete, onSelectionSourceChanged } = props;\n const { containerProps } = useCommonComponentProps(\"selection\", props);\n const defaultNotAvailableMessage = intl.formatMessage({ id: \"sourceNotAvailable\" });\n\n const [currentSource, setCurrentSource] = useCurrentSelectionSource(\n sources,\n onSelectionSourceChanged\n );\n\n const currentSourceStatus = useSourceStatus(currentSource, defaultNotAvailableMessage);\n\n const mapState = useMapModel(props);\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 useDragSelection(\n mapState.map,\n intl,\n onExtentSelected,\n currentSourceStatus.kind === \"available\",\n !!currentSource\n );\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 const foundOption: SelectionOption | undefined = sourceOptions.find(\n (option) => option.value === currentSource\n );\n return foundOption || null;\n }, [sourceOptions, currentSource]);\n\n const onSourceOptionChanged = useEvent((newValue: SingleValue<SelectionOption>) => {\n setCurrentSource(newValue?.value);\n });\n\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 <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={() => false} // allow to select disabled options; optical disabling is done in option\n // optionLabel is used by screenreaders\n getOptionLabel={(option) => {\n const label = option.label;\n const status = getSourceStatus(option.value, defaultNotAvailableMessage);\n if (status.kind == \"available\") return label;\n return label + \" \" + status.reason;\n }}\n ariaLiveMessages={{\n guidance: () => \"\",\n onChange: (props) => {\n if (\n props.action == \"select-option\" ||\n props.action == \"initial-input-focus\"\n )\n return props.label + \" \" + intl.formatMessage({ id: \"selected\" });\n else return \"\";\n },\n onFilter: () => \"\",\n onFocus: () => \"\"\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>): ReactNode {\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>): ReactNode {\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\nfunction useCurrentSelectionSource(\n sources: SelectionSource[],\n onSourceChanged: ((event: SelectionSourceChangedEvent) => void) | undefined\n): [SelectionSource | undefined, (source: SelectionSource | undefined) => void] {\n const [currentSource, setCurrentSource] = useState<SelectionSource | undefined>(\n () => sources[0]\n );\n\n // Reset to undefined if the current source is not in the list of sources\n useEffect(() => {\n if (currentSource && !sources.includes(currentSource)) {\n setCurrentSource(undefined);\n }\n }, [sources, currentSource]);\n\n // Track the current source and notify the parent component if it changes\n const prevSelectedSource = useRef<SelectionSource | undefined>(undefined);\n useEffect(() => {\n if (currentSource !== prevSelectedSource.current) {\n prevSelectedSource.current = currentSource;\n onSourceChanged?.({ source: currentSource });\n }\n }, [currentSource, onSourceChanged]);\n return [currentSource, setCurrentSource];\n}\n\n/**\n * Hook to manage source option in selection-source react-select\n */\nfunction useSourceItem(source: SelectionSource | undefined, isSelected: boolean) {\n const intl = useIntl();\n const label: string | undefined = source?.label;\n const defaultNotAvailableMessage = intl.formatMessage({ id: \"sourceNotAvailable\" });\n const status = useSourceStatus(source, defaultNotAvailableMessage);\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(\n source: SelectionSource | undefined,\n defaultNotAvailableMessage: string\n): SimpleStatus {\n const sourceStatus = useReactiveSnapshot((): SimpleStatus => {\n if (!source) {\n return { kind: \"unavailable\", reason: defaultNotAvailableMessage };\n }\n return getSourceStatus(source, defaultNotAvailableMessage);\n }, [source, defaultNotAvailableMessage]);\n return sourceStatus;\n}\n\n/**\n * Hook to manage map controls and tooltip\n */\nfunction useDragSelection(\n map: MapModel | undefined,\n intl: PackageIntl,\n onExtentSelected: (geometry: Geometry) => void,\n isActive: boolean,\n hasSelectedSource: boolean\n) {\n useEffect(() => {\n if (!map) {\n return;\n }\n\n const disabledMessage = hasSelectedSource\n ? intl.formatMessage({ id: \"disabledTooltip\" })\n : intl.formatMessage({ id: \"noSourceTooltip\" });\n\n const dragController = new DragController(\n map.olMap,\n intl.formatMessage({ id: \"tooltip\" }),\n disabledMessage,\n onExtentSelected\n );\n\n dragController.setActive(isActive);\n return () => {\n dragController?.destroy();\n };\n }, [map, intl, onExtentSelected, isActive, hasSelectedSource]);\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":["props","controller"],"mappings":";;;;;;;;;;;;AAsFA,MAAM,mBAAkD,GAAA;AAAA,EACpD,eAAiB,EAAA,cAAA;AAAA,EACjB,YAAc,EAAA,OAAA;AAAA,EACd,YAAc,EAAA,KAAA;AAAA,EACd,WAAa,EAAA;AACjB,CAAA;AAKa,MAAA,SAAA,GAAgC,CAAC,KAAU,KAAA;AACpD,EAAA,MAAM,OAAO,OAAQ,EAAA;AACrB,EAAA,MAAM,EAAE,OAAA,EAAS,mBAAqB,EAAA,wBAAA,EAA6B,GAAA,KAAA;AACnE,EAAA,MAAM,EAAE,cAAA,EAAmB,GAAA,uBAAA,CAAwB,aAAa,KAAK,CAAA;AACrE,EAAA,MAAM,6BAA6B,IAAK,CAAA,aAAA,CAAc,EAAE,EAAA,EAAI,sBAAsB,CAAA;AAElF,EAAM,MAAA,CAAC,aAAe,EAAA,gBAAgB,CAAI,GAAA,yBAAA;AAAA,IACtC,OAAA;AAAA,IACA;AAAA,GACJ;AAEA,EAAM,MAAA,mBAAA,GAAsB,eAAgB,CAAA,aAAA,EAAe,0BAA0B,CAAA;AAErF,EAAM,MAAA,QAAA,GAAW,YAAY,KAAK,CAAA;AAClC,EAAM,MAAA,EAAE,kBAAqB,GAAA,sB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c,EAAE,EAAI,EAAA,iBAAA,EAAmB,CAAA,GAC5C,IAAK,CAAA,aAAA,CAAc,EAAE,EAAA,EAAI,mBAAmB,CAAA;AAElD,IAAA,MAAM,iBAAiB,IAAI,cAAA;AAAA,MACvB,GAAI,CAAA,KAAA;AAAA,MACJ,IAAK,CAAA,aAAA,CAAc,EAAE,EAAA,EAAI,WAAW,CAAA;AAAA,MACpC,eAAA;AAAA,MACA;AAAA,KACJ;AAEA,IAAA,cAAA,CAAe,UAAU,QAAQ,CAAA;AACjC,IAAA,OAAO,MAAM;AACT,MAAA,cAAA,EAAgB,OAAQ,EAAA;AAAA,KAC5B;AAAA,KACD,CAAC,GAAA,EAAK,MAAM,gBAAkB,EAAA,QAAA,EAAU,iBAAiB,CAAC,CAAA;AACjE;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;AAAA,GACzB;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;AAAA,OACJ,CAAA;AAAA,MACA,iBAAA,EAAmB,CAAC,QAAc,MAAA;AAAA,QAC9B,GAAG,QAAA;AAAA,QACH,eAAiB,EAAA;AAAA,OACrB;AAAA,KACJ;AACA,IAAO,OAAA,YAAA;AAAA,GACR,EAAA,CAAC,kBAAoB,EAAA,WAAW,CAAC,CAAA;AACxC;;;;"}
|
|
1
|
+
{"version":3,"file":"Selection.js","sources":["Selection.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {\n Box,\n Icon,\n VStack,\n chakra,\n Select,\n Portal,\n createListCollection,\n Flex\n} from \"@chakra-ui/react\";\nimport { Tooltip } from \"@open-pioneer/chakra-snippets/tooltip\";\nimport { Field } from \"@open-pioneer/chakra-snippets/field\";\nimport { MapModel, MapModelProps, 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 { Geometry } from \"ol/geom\";\nimport { useIntl, useService } from \"open-pioneer:react-hooks\";\nimport { FC, useCallback, useEffect, useRef, useState } from \"react\";\nimport { FiAlertTriangle } from \"react-icons/fi\";\nimport { useReactiveSnapshot } from \"@open-pioneer/reactivity\";\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, MapModelProps {\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 * 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 { sources, onSelectionComplete, onSelectionSourceChanged } = props;\n const { containerProps } = useCommonComponentProps(\"selection\", props);\n const defaultNotAvailableMessage = intl.formatMessage({ id: \"sourceNotAvailable\" });\n\n const [currentSource, setCurrentSource] = useCurrentSelectionSource(\n sources,\n onSelectionSourceChanged\n );\n\n const currentSourceStatus = useSourceStatus(currentSource, defaultNotAvailableMessage);\n\n const mapState = useMapModel(props);\n const { onExtentSelected } = useSelectionController(\n mapState.map,\n sources,\n currentSource,\n onSelectionComplete\n );\n\n useDragSelection(\n mapState.map,\n intl,\n onExtentSelected,\n currentSourceStatus.kind === \"available\",\n !!currentSource\n );\n\n const getId = useSelectionSourceId();\n\n const sourceOptionsCollection = createListCollection({\n items: sources,\n isItemDisabled: () => {\n return false;\n },\n itemToString: (item) => item.label,\n itemToValue: (item) => getId(item)\n });\n\n let triggerItem;\n if (currentSource) {\n triggerItem = <SelectionSourceItem source={currentSource} />;\n } else {\n triggerItem = null;\n }\n\n return (\n <VStack {...containerProps} gap={2}>\n <Field label={intl.formatMessage({ id: \"selectSource\" })}>\n <Select.Root\n collection={sourceOptionsCollection}\n value={currentSource ? [getId(currentSource)] : undefined}\n onValueChange={(option) => option && setCurrentSource(option.items[0])}\n lazyMount={true}\n unmountOnExit={true}\n >\n <Select.Control>\n <Select.Trigger>\n <Select.ValueText\n placeholder={intl.formatMessage({ id: \"selectionPlaceholder\" })}\n >\n {triggerItem}\n </Select.ValueText>\n </Select.Trigger>\n <Select.IndicatorGroup>\n <Select.Indicator />\n </Select.IndicatorGroup>\n </Select.Control>\n\n <Portal>\n <Select.Positioner>\n <Select.Content>\n {sourceOptionsCollection.items.map((item) => (\n <SelectionSourceItemContent item={item} key={getId(item)} />\n ))}\n </Select.Content>\n </Select.Positioner>\n </Portal>\n </Select.Root>\n </Field>\n </VStack>\n );\n};\n\ntype GetSelectionSourceId = (selectionSource: SelectionSource) => string;\n\n/**\n * Assigns unique IDs to selection sources.\n */\nfunction useSelectionSourceId(): GetSelectionSourceId {\n const sourceIds = useRef<WeakMap<SelectionSource, string>>(undefined);\n const counter = useRef(0);\n if (!sourceIds.current) {\n sourceIds.current = new WeakMap();\n }\n\n return useCallback((selectionSource: SelectionSource) => {\n const ids = sourceIds.current!;\n if (!ids.has(selectionSource)) {\n ids.set(selectionSource, `source-${counter.current++}`);\n }\n return ids.get(selectionSource)!;\n }, []);\n}\n\nfunction SelectionSourceItemContent(props: { item: SelectionSource }) {\n const { item } = props;\n\n return (\n <Select.Item\n item={item}\n justifyContent=\"flex-start\"\n // Override pointer-events: none rule for disabled items; we want to show the tooltip on hover\n pointerEvents=\"auto\"\n >\n <SelectionSourceItem source={item} />\n </Select.Item>\n );\n}\n\nfunction useCurrentSelectionSource(\n sources: SelectionSource[],\n onSourceChanged: ((event: SelectionSourceChangedEvent) => void) | undefined\n): [SelectionSource | undefined, (source: SelectionSource | undefined) => void] {\n const [currentSource, setCurrentSource] = useState<SelectionSource | undefined>(\n () => sources[0]\n );\n\n // Reset to undefined if the current source is not in the list of sources\n useEffect(() => {\n if (currentSource && !sources.includes(currentSource)) {\n setCurrentSource(undefined);\n }\n }, [sources, currentSource]);\n\n // Track the current source and notify the parent component if it changes\n const prevSelectedSource = useRef<SelectionSource | undefined>(undefined);\n useEffect(() => {\n if (currentSource !== prevSelectedSource.current) {\n prevSelectedSource.current = currentSource;\n onSourceChanged?.({ source: currentSource });\n }\n }, [currentSource, onSourceChanged]);\n return [currentSource, setCurrentSource];\n}\n\n/**\n * Hook to manage source option in selection-source react-select\n */\nfunction SelectionSourceItem(props: { source: SelectionSource | undefined }) {\n const intl = useIntl();\n const source = props.source;\n const label: string | undefined = source?.label;\n const defaultNotAvailableMessage = intl.formatMessage({ id: \"sourceNotAvailable\" });\n const status = useSourceStatus(source, defaultNotAvailableMessage);\n const isAvailable = status.kind === \"available\";\n const clazz = isAvailable\n ? \"selection-source-value\"\n : \"selection-source-value selection-source-value--disabled\";\n\n return (\n <Flex className={clazz} direction=\"row\" alignItems=\"center\" grow={1}>\n {label}\n {status.kind === \"unavailable\" && (\n <Box ml={2}>\n <Tooltip\n content={status.reason}\n positioning={{ placement: \"right\" }}\n openDelay={500}\n >\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 </Flex>\n );\n}\n\n/**\n * Hook to manage selection controller\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(\n source: SelectionSource | undefined,\n defaultNotAvailableMessage: string\n): SimpleStatus {\n const sourceStatus = useReactiveSnapshot((): SimpleStatus => {\n if (!source) {\n return { kind: \"unavailable\", reason: defaultNotAvailableMessage };\n }\n return getSourceStatus(source, defaultNotAvailableMessage);\n }, [source, defaultNotAvailableMessage]);\n return sourceStatus;\n}\n\n/**\n * Hook to manage map controls and tooltip\n */\nfunction useDragSelection(\n map: MapModel | undefined,\n intl: PackageIntl,\n onExtentSelected: (geometry: Geometry) => void,\n isActive: boolean,\n hasSelectedSource: boolean\n) {\n useEffect(() => {\n if (!map) {\n return;\n }\n\n const disabledMessage = hasSelectedSource\n ? intl.formatMessage({ id: \"disabledTooltip\" })\n : intl.formatMessage({ id: \"noSourceTooltip\" });\n\n const dragController = new DragController(\n map.olMap,\n intl.formatMessage({ id: \"tooltip\" }),\n disabledMessage,\n onExtentSelected\n );\n\n dragController.setActive(isActive);\n return () => {\n dragController?.destroy();\n };\n }, [map, intl, onExtentSelected, isActive, hasSelectedSource]);\n}\n"],"names":["controller"],"mappings":";;;;;;;;;;;;;AAgEa,MAAA,SAAA,GAAgC,CAAC,KAAU,KAAA;AACpD,EAAA,MAAM,OAAO,OAAQ,EAAA;AACrB,EAAA,MAAM,EAAE,OAAA,EAAS,mBAAqB,EAAA,wBAAA,EAA6B,GAAA,KAAA;AACnE,EAAA,MAAM,EAAE,cAAA,EAAmB,GAAA,uBAAA,CAAwB,aAAa,KAAK,CAAA;AACrE,EAAA,MAAM,6BAA6B,IAAK,CAAA,aAAA,CAAc,EAAE,EAAA,EAAI,sBAAsB,CAAA;AAElF,EAAM,MAAA,CAAC,aAAe,EAAA,gBAAgB,CAAI,GAAA,yBAAA;AAAA,IACtC,OAAA;AAAA,IACA;AAAA,GACJ;AAEA,EAAM,MAAA,mBAAA,GAAsB,eAAgB,CAAA,aAAA,EAAe,0BAA0B,CAAA;AAErF,EAAM,MAAA,QAAA,GAAW,YAAY,KAAK,CAAA;AAClC,EAAM,MAAA,EAAE,kBAAqB,GAAA,sBAAA;AAAA,IACzB,QAAS,CAAA,GAAA;AAAA,IACT,OAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA,GACJ;AAEA,EAAA,gBAAA;AAAA,IACI,QAA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
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/selection",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.1-dev-chakra-v3.20250512110627",
|
|
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,20 @@
|
|
|
14
14
|
"directory": "src/packages/selection"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@chakra-ui/
|
|
18
|
-
"@open-pioneer/
|
|
19
|
-
"@open-pioneer/
|
|
20
|
-
"@open-pioneer/
|
|
21
|
-
"@open-pioneer/
|
|
22
|
-
"@open-pioneer/runtime": "^3.1.0",
|
|
17
|
+
"@chakra-ui/react": "^3.17.0",
|
|
18
|
+
"@open-pioneer/core": "4.0.0-dev.20250512105016",
|
|
19
|
+
"@open-pioneer/notifier": "4.0.0-dev.20250512105016",
|
|
20
|
+
"@open-pioneer/react-utils": "4.0.0-dev.20250512105016",
|
|
21
|
+
"@open-pioneer/runtime": "4.0.0-dev.20250512105016",
|
|
23
22
|
"classnames": "^2.3.2",
|
|
24
|
-
"chakra-react-select": "^5.0.4",
|
|
25
23
|
"ol": "^10.5.0",
|
|
26
24
|
"react": "^19.1.0",
|
|
27
25
|
"react-icons": "^5.3.0",
|
|
28
26
|
"uuid": "^11.1.0",
|
|
29
|
-
"@conterra/reactivity-core": "^0.
|
|
30
|
-
"@open-pioneer/reactivity": "
|
|
31
|
-
"@open-pioneer/
|
|
27
|
+
"@conterra/reactivity-core": "^0.6.0",
|
|
28
|
+
"@open-pioneer/reactivity": "4.0.0-dev.20250512105016",
|
|
29
|
+
"@open-pioneer/chakra-snippets": "4.0.0-dev.20250512105016",
|
|
30
|
+
"@open-pioneer/map": "0.10.1-dev-chakra-v3.20250512110627"
|
|
32
31
|
},
|
|
33
32
|
"exports": {
|
|
34
33
|
"./package.json": "./package.json",
|
package/selection.css
CHANGED
package/selection.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["selection.css"],"names":[],"mappings":"AAAA;IACI,qDAAqD;IACrD,
|
|
1
|
+
{"version":3,"sources":["selection.css"],"names":[],"mappings":"AAAA;IACI,qDAAqD;IACrD,8DAA8D;AAClE;;AAEA;IACI,kBAAkB;IAClB,oCAAoC;IACpC,kBAAkB;IAClB,YAAY;IACZ,gBAAgB;IAChB,UAAU;IACV,mBAAmB;IACnB,eAAe;IACf,eAAe;IACf,iBAAiB;IACjB,iBAAiB;AACrB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,iBAAiB;AACrB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,YAAY;AAChB;;AAEA;IACI,uBAAuB;AAC3B","file":"selection.css","sourcesContent":[".selection-drag-box {\n background-color: rgba(255, 255, 255, 0.3) !important;\n border: 3px solid var(--chakra-colors-trails-solid) !important;\n}\n\n.selection-tooltip {\n position: relative;\n background: rgba(255, 255, 255, 0.8);\n border-radius: 4px;\n color: black;\n padding: 4px 8px;\n opacity: 1;\n white-space: nowrap;\n font-size: 12px;\n cursor: default;\n user-select: none;\n font-weight: bold;\n}\n\n.selection .react-select {\n cursor: default;\n}\n\n.map-container .selection-active {\n cursor: crosshair;\n}\n\n.map-container .selection-inactive {\n cursor: no-drop;\n}\n\n.selection-source-value.selection-source-value--disabled {\n opacity: 0.4;\n}\n\n.selection-source-value.selection-source-value--disabled span {\n margin: 0px 6px 0px 0px;\n}\n"]}
|