@open-pioneer/coordinate-search 1.4.0-dev.20260727093741 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/CoordinateInput.js +3 -3
- package/CoordinateInput.js.map +1 -1
- package/CoordinateInputField.js.map +1 -1
- package/CoordinateSearch.js.map +1 -1
- package/ProjectionSelect.js +1 -1
- package/ProjectionSelect.js.map +1 -1
- package/coordinates.js +1 -1
- package/coordinates.js.map +1 -1
- package/package.json +7 -7
- package/usePlaceholder.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
# @open-pioneer/coordinate-search
|
|
2
2
|
|
|
3
|
-
## 1.4.0
|
|
3
|
+
## 1.4.0
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
7
|
- c30396d: Update Chakra to 3.36.1
|
|
8
|
+
- d862003: Update to trails core-packages 4.7.0
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- c16a401: Migrated from eslint to oxlint and from prettier to oxfmt.
|
|
8
13
|
|
|
9
14
|
## 1.3.0
|
|
10
15
|
|
|
@@ -54,6 +59,7 @@
|
|
|
54
59
|
|
|
55
60
|
- 66179bc: Update to core-packages v4.0.0
|
|
56
61
|
- 888fc2b: improve a11y of coordinate search and coordinate input
|
|
62
|
+
|
|
57
63
|
- switch order of projection select and coordinate input (visually and tab order) in order to have the correct focus order
|
|
58
64
|
- add instructions to `aria-label` for coordinate input to improve usability for screenreader users
|
|
59
65
|
|
package/CoordinateInput.js
CHANGED
|
@@ -17,13 +17,13 @@ const DEFAULT_PRECISION = 3;
|
|
|
17
17
|
const DEFAULT_PROJECTIONS = [
|
|
18
18
|
{
|
|
19
19
|
label: "WGS 84",
|
|
20
|
-
//
|
|
20
|
+
// oxlint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
21
21
|
value: get("EPSG:4326"),
|
|
22
22
|
precision: 3
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
25
|
label: "Web Mercator",
|
|
26
|
-
//
|
|
26
|
+
// oxlint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
27
27
|
value: get("EPSG:3857"),
|
|
28
28
|
precision: 2
|
|
29
29
|
}
|
|
@@ -43,7 +43,7 @@ const CoordinateInput = (props) => {
|
|
|
43
43
|
const availableProjections = useProjectionItems(projections);
|
|
44
44
|
const [selectedProjection, setSelectedProjection] = useState(
|
|
45
45
|
// choose first option initially
|
|
46
|
-
//
|
|
46
|
+
// oxlint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
47
47
|
availableProjections[0]
|
|
48
48
|
);
|
|
49
49
|
const onSelect = useEvent((coordinatesResult) => {
|
package/CoordinateInput.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoordinateInput.js","sources":["CoordinateInput.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Flex, Group } from \"@chakra-ui/react\";\nimport { computed, Reactive, reactive } from \"@conterra/reactivity-core\";\nimport { Tooltip } from \"@open-pioneer/chakra-snippets/tooltip\";\nimport { MapModelProps, useMapModelValue } from \"@open-pioneer/map\";\nimport { CommonComponentProps, useCommonComponentProps, useEvent } from \"@open-pioneer/react-utils\";\nimport { useReactiveSnapshot } from \"@open-pioneer/reactivity\";\nimport { NumberParserService, PackageIntl } from \"@open-pioneer/runtime\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { get as getProjection, Projection, ProjectionLike, transform } from \"ol/proj\";\nimport { useIntl, useService } from \"open-pioneer:react-hooks\";\nimport { FC, useCallback, useEffect, useMemo, useState } from \"react\";\nimport { CoordinateInputField } from \"./CoordinateInputField\";\nimport { formatCoordinates, parseCoordinates, ParseResult } from \"./coordinates\";\nimport { ProjectionSelect } from \"./ProjectionSelect\";\nimport { usePlaceholder } from \"./usePlaceholder\";\n\nconst DEFAULT_PRECISION = 3;\nconst DEFAULT_PROJECTIONS = [\n {\n label: \"WGS 84\",\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n value: getProjection(\"EPSG:4326\")!,\n precision: 3\n },\n {\n label: \"Web Mercator\",\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n value: getProjection(\"EPSG:3857\")!,\n precision: 2\n }\n];\n\n/**\n * Dropdown item of projection selection with an optional coordinate precision\n */\nexport interface ProjectionInput {\n /**\n * Label to show the user.\n */\n label: string;\n\n /**\n * The map projection as projection or as string.\n */\n value: ProjectionLike;\n\n /**\n * The number of displayed decimal places.\n */\n precision?: number;\n}\n\n/**\n * Internal view of a (normalized) projection.\n * The projection has been looked up and optional values have been filled in.\n */\nexport interface ProjectionItem {\n /**\n * Label to show the user.\n */\n label: string;\n\n /**\n * The map projection.\n */\n value: Projection;\n\n /**\n * The number of displayed decimal places.\n */\n precision: number;\n}\n\n/**\n * Event type emitted when the user enters new coordinates or projection is changed by the user.\n */\nexport interface CoordinatesSelectEvent {\n /** coordinates in the projection of the object */\n coords: Coordinate;\n\n /** the projection of the coordinates. */\n projection: Projection;\n}\n\n/**\n * Props for the {@link CoordinateInput} component.\n */\nexport interface CoordinateInputProps extends CommonComponentProps, MapModelProps {\n /**\n * List of projection options, only projections that are known by the map as projection are shown.\n * Each projection can have an individual precision of coordinates.\n *\n * If no precision is given, the default precision is used.\n */\n projections?: ProjectionInput[];\n\n /**\n * Optional event that gets called if (valid) coordinates are entered or projection is changed by the user.\n */\n onSelect?: (event: CoordinatesSelectEvent) => void;\n\n /**\n * Optional event that gets called if the input is cleared.\n */\n onClear?: () => void;\n\n /**\n * Insert input value and overwrite user input.\n */\n input?: Coordinate;\n\n /**\n * Placeholder text to display when no input is present. Common usages:\n * * hint for the user (\"enter coordinate here\")\n * * example coordinate (\"12.345 67.890\")\n * * current mouse position\n *\n * If a coordinate is given, it has to be in the current projection of the map.\n */\n placeholder?: string | Coordinate;\n}\n\n/**\n * The `CoordinateInput` component can be used in an app to provide a validated input field for coordinates in a selected projection\n */\nexport const CoordinateInput: FC<CoordinateInputProps> = (props) => {\n const {\n onSelect: onSelectProp,\n onClear,\n projections = DEFAULT_PROJECTIONS,\n input,\n placeholder = \"\"\n } = props;\n const { containerProps } = useCommonComponentProps(\"coordinate-input\", props);\n const map = useMapModelValue(props);\n const intl = useIntl();\n const mapProjection = useReactiveSnapshot(() => map.projection, [map]);\n\n // Projection items (dropdown)\n const availableProjections = useProjectionItems(projections);\n const [selectedProjection, setSelectedProjection] = useState<ProjectionItem>(\n // choose first option initially\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n availableProjections[0]!\n );\n\n // Input state\n const onSelect = useEvent((coordinatesResult: ParseResult) => {\n if (!onSelectProp || coordinatesResult.kind !== \"success\" || mapProjection == null) {\n return;\n }\n\n const coords = transform(\n coordinatesResult.coordinates,\n coordinatesResult.projection,\n mapProjection\n );\n onSelectProp({ coords: coords, projection: mapProjection });\n });\n const [coordinateSearchInput, setCoordinateSearchInput, validationResult] = useCoordinateState(\n input,\n mapProjection,\n selectedProjection,\n onSelect\n );\n const placeholderString = usePlaceholder(placeholder, mapProjection, selectedProjection);\n const isInputValid = validationResult.kind === \"success\" || validationResult.kind === \"empty\";\n const errorMessage = !isInputValid\n ? intl.formatMessage({ id: validationResult.kind })\n : undefined;\n\n const onEnter = useEvent(() => {\n onSelect(validationResult);\n });\n\n return (\n <Flex flexDirection={\"row\"} flexDir={\"row\"} {...containerProps}>\n <Tooltip\n content={errorMessage}\n showArrow\n open={!isInputValid}\n // explicity mount / unmount the tooltip.\n // Previously an empty tooltip could be shown even though \"open\" was false.\n present={!isInputValid}\n >\n <Group className=\"coordinate-input-group\" attached w=\"full\">\n <ProjectionSelect\n currentProjection={selectedProjection}\n projections={availableProjections}\n onProjectionChange={setSelectedProjection}\n />\n <CoordinateInputField\n coordinateSearchInput={coordinateSearchInput}\n setCoordinateSearchInput={setCoordinateSearchInput}\n placeholder={placeholder}\n placeholderString={placeholderString}\n errorMessage={errorMessage}\n onClear={onClear}\n onEnter={onEnter}\n />\n </Group>\n </Tooltip>\n </Flex>\n );\n};\n\n/**\n * Returns the current text input and a callback to change it (used for interactive user input).\n * The current text may also change if the input prop changes (controlled usage).\n */\nfunction useCoordinateState(\n inputProp: Coordinate | undefined,\n mapProjection: Projection | undefined,\n selectedProjection: ProjectionItem,\n onSelect: (validationResult: ParseResult) => void\n): [string, (value: string) => void, ParseResult] {\n const intl = useIntl();\n const numberParser = useService<NumberParserService>(\"runtime.NumberParserService\");\n\n const [model] = useState(() => new StateModel(intl, selectedProjection, numberParser));\n useEffect(() => {\n const triggerSelect =\n inputProp !== model.inputProp || selectedProjection !== model.selectedProjection;\n\n model.setI18n(intl, numberParser);\n model.setInputProp(inputProp);\n model.setSelectedProjection(selectedProjection);\n model.setMapProjection(mapProjection);\n\n if (triggerSelect) {\n const validationResult = model.validationResult;\n onSelect(validationResult);\n }\n }, [model, intl, numberParser, inputProp, selectedProjection, mapProjection, onSelect]);\n\n const { rawInput, validationResult } = useReactiveSnapshot(() => {\n return {\n rawInput: model.rawInput,\n validationResult: model.validationResult\n };\n }, [model]);\n const setInputText = useCallback(\n (inputText: string) => {\n model.setText(inputText);\n },\n [model]\n );\n return [rawInput, setInputText, validationResult];\n}\n\nclass StateModel {\n #intl: Reactive<PackageIntl>;\n #selectedProjection: Reactive<ProjectionItem>;\n #mapProjection = reactive<Projection | undefined>();\n #inputProp = reactive<Coordinate | undefined>();\n #numberParser: Reactive<NumberParserService>;\n\n #rawInput = reactive(\"\");\n #validationResult = computed(() => {\n return parseCoordinates(\n this.#rawInput.value,\n this.#numberParser.value,\n this.#selectedProjection.value.value\n );\n });\n\n constructor(\n intl: PackageIntl,\n selectedProjection: ProjectionItem,\n numberParser: NumberParserService\n ) {\n this.#intl = reactive(intl);\n this.#selectedProjection = reactive(selectedProjection);\n this.#numberParser = reactive(numberParser);\n }\n\n get inputProp() {\n return this.#inputProp.value;\n }\n\n get rawInput() {\n return this.#rawInput.value;\n }\n\n get validationResult() {\n return this.#validationResult.value;\n }\n\n get selectedProjection() {\n return this.#selectedProjection.value;\n }\n\n setI18n(intl: PackageIntl, numberParser: NumberParserService) {\n this.#intl.value = intl;\n this.#numberParser.value = numberParser;\n }\n\n setText(text: string) {\n this.#rawInput.value = text;\n }\n\n setSelectedProjection(value: ProjectionItem) {\n if (value !== this.#selectedProjection.value) {\n this.#selectedProjection.value = value;\n this.#updateInput();\n }\n }\n\n setInputProp(value: Coordinate | undefined) {\n if (value !== this.#inputProp.value) {\n this.#inputProp.value = value;\n this.#updateInput();\n }\n }\n\n setMapProjection(value: Projection | undefined) {\n if (value !== this.#mapProjection.value) {\n this.#mapProjection.value = value;\n this.#updateInput();\n }\n }\n\n #updateInput() {\n const inputProp = this.#inputProp.value;\n const mapProjection = this.#mapProjection.value;\n const selectedProjection = this.#selectedProjection.value;\n const intl = this.#intl.value;\n if (mapProjection && inputProp) {\n // Update state based on input prop.\n const transformed = transform(inputProp, mapProjection, selectedProjection.value);\n const formatted = formatCoordinates(transformed, selectedProjection.precision, intl);\n this.#rawInput.value = formatted;\n }\n }\n}\n\n/**\n * Builds the list of available projection items based on the provided list of projections\n */\nfunction useProjectionItems(projections: ProjectionInput[]) {\n return useMemo(() => {\n // filter out projections that are not known\n const availableProjections: ProjectionItem[] = projections.flatMap((ele) => {\n const projection = getProjection(ele.value);\n if (projection != null)\n return {\n label: ele.label,\n value: projection,\n precision: ele.precision ?? DEFAULT_PRECISION\n };\n return [];\n });\n return availableProjections;\n }, [projections]);\n}\n"],"names":["getProjection","validationResult"],"mappings":";;;;;;;;;;;;;;;AAkBA,MAAM,iBAAA,GAAoB,CAAA;AAC1B,MAAM,mBAAA,GAAsB;AAAA,EACxB;AAAA,IACI,KAAA,EAAO,QAAA;AAAA;AAAA,IAEP,KAAA,EAAOA,IAAc,WAAW,CAAA;AAAA,IAChC,SAAA,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AAA,IAAA,CAAK,UAAU,KAAA,GAAQ,SAAA;AAAA,IAC3B;AAAA,EACJ;AACJ;AAKA,SAAS,mBAAmB,WAAA,EAAgC;AACxD,EAAA,OAAO,QAAQ,MAAM;AAEjB,IAAA,MAAM,oBAAA,GAAyC,WAAA,CAAY,OAAA,CAAQ,CAAC,GAAA,KAAQ;AACxE,MAAA,MAAM,UAAA,GAAaD,GAAA,CAAc,GAAA,CAAI,KAAK,CAAA;AAC1C,MAAA,IAAI,UAAA,IAAc,IAAA;AACd,QAAA,OAAO;AAAA,UACH,OAAO,GAAA,CAAI,KAAA;AAAA,UACX,KAAA,EAAO,UAAA;AAAA,UACP,SAAA,EAAW,IAAI,SAAA,IAAa;AAAA,SAChC;AACJ,MAAA,OAAO,EAAC;AAAA,IACZ,CAAC,CAAA;AACD,IAAA,OAAO,oBAAA;AAAA,EACX,CAAA,EAAG,CAAC,WAAW,CAAC,CAAA;AACpB;;;;"}
|
|
1
|
+
{"version":3,"file":"CoordinateInput.js","sources":["CoordinateInput.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Flex, Group } from \"@chakra-ui/react\";\nimport { computed, Reactive, reactive } from \"@conterra/reactivity-core\";\nimport { Tooltip } from \"@open-pioneer/chakra-snippets/tooltip\";\nimport { MapModelProps, useMapModelValue } from \"@open-pioneer/map\";\nimport { CommonComponentProps, useCommonComponentProps, useEvent } from \"@open-pioneer/react-utils\";\nimport { useReactiveSnapshot } from \"@open-pioneer/reactivity\";\nimport { NumberParserService, PackageIntl } from \"@open-pioneer/runtime\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { get as getProjection, Projection, ProjectionLike, transform } from \"ol/proj\";\nimport { useIntl, useService } from \"open-pioneer:react-hooks\";\nimport { FC, useCallback, useEffect, useMemo, useState } from \"react\";\nimport { CoordinateInputField } from \"./CoordinateInputField\";\nimport { formatCoordinates, parseCoordinates, ParseResult } from \"./coordinates\";\nimport { ProjectionSelect } from \"./ProjectionSelect\";\nimport { usePlaceholder } from \"./usePlaceholder\";\n\nconst DEFAULT_PRECISION = 3;\nconst DEFAULT_PROJECTIONS = [\n {\n label: \"WGS 84\",\n // oxlint-disable-next-line @typescript-eslint/no-non-null-assertion\n value: getProjection(\"EPSG:4326\")!,\n precision: 3\n },\n {\n label: \"Web Mercator\",\n // oxlint-disable-next-line @typescript-eslint/no-non-null-assertion\n value: getProjection(\"EPSG:3857\")!,\n precision: 2\n }\n];\n\n/**\n * Dropdown item of projection selection with an optional coordinate precision\n */\nexport interface ProjectionInput {\n /**\n * Label to show the user.\n */\n label: string;\n\n /**\n * The map projection as projection or as string.\n */\n value: ProjectionLike;\n\n /**\n * The number of displayed decimal places.\n */\n precision?: number;\n}\n\n/**\n * Internal view of a (normalized) projection.\n * The projection has been looked up and optional values have been filled in.\n */\nexport interface ProjectionItem {\n /**\n * Label to show the user.\n */\n label: string;\n\n /**\n * The map projection.\n */\n value: Projection;\n\n /**\n * The number of displayed decimal places.\n */\n precision: number;\n}\n\n/**\n * Event type emitted when the user enters new coordinates or projection is changed by the user.\n */\nexport interface CoordinatesSelectEvent {\n /** coordinates in the projection of the object */\n coords: Coordinate;\n\n /** the projection of the coordinates. */\n projection: Projection;\n}\n\n/**\n * Props for the {@link CoordinateInput} component.\n */\nexport interface CoordinateInputProps extends CommonComponentProps, MapModelProps {\n /**\n * List of projection options, only projections that are known by the map as projection are shown.\n * Each projection can have an individual precision of coordinates.\n *\n * If no precision is given, the default precision is used.\n */\n projections?: ProjectionInput[];\n\n /**\n * Optional event that gets called if (valid) coordinates are entered or projection is changed by the user.\n */\n onSelect?: (event: CoordinatesSelectEvent) => void;\n\n /**\n * Optional event that gets called if the input is cleared.\n */\n onClear?: () => void;\n\n /**\n * Insert input value and overwrite user input.\n */\n input?: Coordinate;\n\n /**\n * Placeholder text to display when no input is present. Common usages:\n * * hint for the user (\"enter coordinate here\")\n * * example coordinate (\"12.345 67.890\")\n * * current mouse position\n *\n * If a coordinate is given, it has to be in the current projection of the map.\n */\n placeholder?: string | Coordinate;\n}\n\n/**\n * The `CoordinateInput` component can be used in an app to provide a validated input field for coordinates in a selected projection\n */\nexport const CoordinateInput: FC<CoordinateInputProps> = (props) => {\n const {\n onSelect: onSelectProp,\n onClear,\n projections = DEFAULT_PROJECTIONS,\n input,\n placeholder = \"\"\n } = props;\n const { containerProps } = useCommonComponentProps(\"coordinate-input\", props);\n const map = useMapModelValue(props);\n const intl = useIntl();\n const mapProjection = useReactiveSnapshot(() => map.projection, [map]);\n\n // Projection items (dropdown)\n const availableProjections = useProjectionItems(projections);\n const [selectedProjection, setSelectedProjection] = useState<ProjectionItem>(\n // choose first option initially\n // oxlint-disable-next-line @typescript-eslint/no-non-null-assertion\n availableProjections[0]!\n );\n\n // Input state\n const onSelect = useEvent((coordinatesResult: ParseResult) => {\n if (!onSelectProp || coordinatesResult.kind !== \"success\" || mapProjection == null) {\n return;\n }\n\n const coords = transform(\n coordinatesResult.coordinates,\n coordinatesResult.projection,\n mapProjection\n );\n onSelectProp({ coords: coords, projection: mapProjection });\n });\n const [coordinateSearchInput, setCoordinateSearchInput, validationResult] = useCoordinateState(\n input,\n mapProjection,\n selectedProjection,\n onSelect\n );\n const placeholderString = usePlaceholder(placeholder, mapProjection, selectedProjection);\n const isInputValid = validationResult.kind === \"success\" || validationResult.kind === \"empty\";\n const errorMessage = !isInputValid\n ? intl.formatMessage({ id: validationResult.kind })\n : undefined;\n\n const onEnter = useEvent(() => {\n onSelect(validationResult);\n });\n\n return (\n <Flex flexDirection={\"row\"} flexDir={\"row\"} {...containerProps}>\n <Tooltip\n content={errorMessage}\n showArrow\n open={!isInputValid}\n // explicity mount / unmount the tooltip.\n // Previously an empty tooltip could be shown even though \"open\" was false.\n present={!isInputValid}\n >\n <Group className=\"coordinate-input-group\" attached w=\"full\">\n <ProjectionSelect\n currentProjection={selectedProjection}\n projections={availableProjections}\n onProjectionChange={setSelectedProjection}\n />\n <CoordinateInputField\n coordinateSearchInput={coordinateSearchInput}\n setCoordinateSearchInput={setCoordinateSearchInput}\n placeholder={placeholder}\n placeholderString={placeholderString}\n errorMessage={errorMessage}\n onClear={onClear}\n onEnter={onEnter}\n />\n </Group>\n </Tooltip>\n </Flex>\n );\n};\n\n/**\n * Returns the current text input and a callback to change it (used for interactive user input).\n * The current text may also change if the input prop changes (controlled usage).\n */\nfunction useCoordinateState(\n inputProp: Coordinate | undefined,\n mapProjection: Projection | undefined,\n selectedProjection: ProjectionItem,\n onSelect: (validationResult: ParseResult) => void\n): [string, (value: string) => void, ParseResult] {\n const intl = useIntl();\n const numberParser = useService<NumberParserService>(\"runtime.NumberParserService\");\n\n const [model] = useState(() => new StateModel(intl, selectedProjection, numberParser));\n useEffect(() => {\n const triggerSelect =\n inputProp !== model.inputProp || selectedProjection !== model.selectedProjection;\n\n model.setI18n(intl, numberParser);\n model.setInputProp(inputProp);\n model.setSelectedProjection(selectedProjection);\n model.setMapProjection(mapProjection);\n\n if (triggerSelect) {\n const validationResult = model.validationResult;\n onSelect(validationResult);\n }\n }, [model, intl, numberParser, inputProp, selectedProjection, mapProjection, onSelect]);\n\n const { rawInput, validationResult } = useReactiveSnapshot(() => {\n return {\n rawInput: model.rawInput,\n validationResult: model.validationResult\n };\n }, [model]);\n const setInputText = useCallback(\n (inputText: string) => {\n model.setText(inputText);\n },\n [model]\n );\n return [rawInput, setInputText, validationResult];\n}\n\nclass StateModel {\n #intl: Reactive<PackageIntl>;\n #selectedProjection: Reactive<ProjectionItem>;\n #mapProjection = reactive<Projection | undefined>();\n #inputProp = reactive<Coordinate | undefined>();\n #numberParser: Reactive<NumberParserService>;\n\n #rawInput = reactive(\"\");\n #validationResult = computed(() => {\n return parseCoordinates(\n this.#rawInput.value,\n this.#numberParser.value,\n this.#selectedProjection.value.value\n );\n });\n\n constructor(\n intl: PackageIntl,\n selectedProjection: ProjectionItem,\n numberParser: NumberParserService\n ) {\n this.#intl = reactive(intl);\n this.#selectedProjection = reactive(selectedProjection);\n this.#numberParser = reactive(numberParser);\n }\n\n get inputProp() {\n return this.#inputProp.value;\n }\n\n get rawInput() {\n return this.#rawInput.value;\n }\n\n get validationResult() {\n return this.#validationResult.value;\n }\n\n get selectedProjection() {\n return this.#selectedProjection.value;\n }\n\n setI18n(intl: PackageIntl, numberParser: NumberParserService) {\n this.#intl.value = intl;\n this.#numberParser.value = numberParser;\n }\n\n setText(text: string) {\n this.#rawInput.value = text;\n }\n\n setSelectedProjection(value: ProjectionItem) {\n if (value !== this.#selectedProjection.value) {\n this.#selectedProjection.value = value;\n this.#updateInput();\n }\n }\n\n setInputProp(value: Coordinate | undefined) {\n if (value !== this.#inputProp.value) {\n this.#inputProp.value = value;\n this.#updateInput();\n }\n }\n\n setMapProjection(value: Projection | undefined) {\n if (value !== this.#mapProjection.value) {\n this.#mapProjection.value = value;\n this.#updateInput();\n }\n }\n\n #updateInput() {\n const inputProp = this.#inputProp.value;\n const mapProjection = this.#mapProjection.value;\n const selectedProjection = this.#selectedProjection.value;\n const intl = this.#intl.value;\n if (mapProjection && inputProp) {\n // Update state based on input prop.\n const transformed = transform(inputProp, mapProjection, selectedProjection.value);\n const formatted = formatCoordinates(transformed, selectedProjection.precision, intl);\n this.#rawInput.value = formatted;\n }\n }\n}\n\n/**\n * Builds the list of available projection items based on the provided list of projections\n */\nfunction useProjectionItems(projections: ProjectionInput[]) {\n return useMemo(() => {\n // filter out projections that are not known\n const availableProjections: ProjectionItem[] = projections.flatMap((ele) => {\n const projection = getProjection(ele.value);\n if (projection != null)\n return {\n label: ele.label,\n value: projection,\n precision: ele.precision ?? DEFAULT_PRECISION\n };\n return [];\n });\n return availableProjections;\n }, [projections]);\n}\n"],"names":["getProjection","validationResult"],"mappings":";;;;;;;;;;;;;;;AAmBA,MAAM,iBAAA,GAAoB,CAAA;AAC1B,MAAM,mBAAA,GAAsB;AAAA,EACxB;AAAA,IACI,KAAA,EAAO,QAAA;AAAA;AAAA,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kB,WAAA,EAAa,kBAAA,CAAmB,WAAW,IAAI,CAAA;AACnF,MAAA,IAAA,CAAK,UAAU,KAAA,GAAQ,SAAA;AAAA,IAC3B;AAAA,EACJ;AACJ;AAKA,SAAS,mBAAmB,WAAA,EAAgC;AACxD,EAAA,OAAO,QAAQ,MAAM;AAEjB,IAAA,MAAM,oBAAA,GAAyC,WAAA,CAAY,OAAA,CAAQ,CAAC,GAAA,KAAQ;AACxE,MAAA,MAAM,UAAA,GAAaD,GAAA,CAAc,GAAA,CAAI,KAAK,CAAA;AAC1C,MAAA,IAAI,UAAA,IAAc,IAAA;AACd,QAAA,OAAO;AAAA,UACH,OAAO,GAAA,CAAI,KAAA;AAAA,UACX,KAAA,EAAO,UAAA;AAAA,UACP,SAAA,EAAW,IAAI,SAAA,IAAa;AAAA,SAChC;AACJ,MAAA,OAAO,EAAC;AAAA,IACZ,CAAC,CAAA;AACD,IAAA,OAAO,oBAAA;AAAA,EACX,CAAA,EAAG,CAAC,WAAW,CAAC,CAAA;AACpB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoordinateInputField.js","sources":["CoordinateInputField.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Field, Icon, IconButton, Input, InputGroup, VisuallyHidden } from \"@chakra-ui/react\";\nimport { Tooltip } from \"@open-pioneer/chakra-snippets/tooltip\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { useIntl } from \"open-pioneer:react-hooks\";\nimport { LuCopy, LuX } from \"react-icons/lu\";\n\n/**\n * Text input for coordinates.\n */\nexport function CoordinateInputField(props: {\n coordinateSearchInput: string;\n setCoordinateSearchInput: (searchInput: string) => void;\n placeholder: string | Coordinate;\n placeholderString: string;\n errorMessage: string | undefined;\n onClear: (() => void) | undefined;\n onEnter: () => void;\n}) {\n const {\n errorMessage,\n coordinateSearchInput,\n setCoordinateSearchInput,\n placeholder,\n placeholderString,\n onClear,\n onEnter\n } = props;\n const intl = useIntl();\n\n const inputField = (\n <InputField\n errorMessage={errorMessage}\n value={coordinateSearchInput}\n placeholder={placeholderString}\n onChange={(newValue) => {\n setCoordinateSearchInput(newValue);\n }}\n onEnter={onEnter}\n />\n );\n\n let attachedButton = null;\n if (coordinateSearchInput !== \"\") {\n attachedButton = (\n <AttachedButton\n className=\"coordinate-input-clear-button\"\n label={intl.formatMessage({\n id: \"coordinateInput.clearLabel\"\n })}\n onClick={() => {\n setCoordinateSearchInput(\"\");\n onClear?.();\n }}\n icon={\n <Icon>\n <LuX />\n </Icon>\n }\n />\n );\n } else if (typeof placeholder === \"object\") {\n attachedButton = (\n <AttachedButton\n className=\"coordinate-input-copy-button\"\n label={intl.formatMessage({\n id: \"coordinateInput.copyLabel\"\n })}\n onClick={() => {\n navigator.clipboard.writeText(placeholderString);\n }}\n icon={\n <Icon>\n <LuCopy />\n </Icon>\n }\n />\n );\n }\n return (\n <InputGroup\n className=\"coordinate-input-field-group\"\n endElement={attachedButton}\n endElementProps={{\n className: \"coordinate-input-field-attachment\",\n paddingInline: \"4px\"\n }}\n >\n {inputField}\n </InputGroup>\n );\n}\n\nfunction InputField(props: {\n value: string;\n placeholder: string;\n errorMessage: string | undefined;\n onChange: (newValue: string) => void;\n onEnter: () => void;\n}) {\n const intl = useIntl();\n const { errorMessage, value, placeholder, onChange, onEnter } = props;\n const isInvalid = !!errorMessage;\n return (\n <Field.Root invalid={isInvalid} flex=\"1 1 auto\">\n <Input\n type=\"text\"\n value={value}\n onChange={(e) => {\n onChange(e.target.value);\n }}\n backgroundColor={isInvalid ? \"red.100\" : undefined}\n placeholder={placeholder}\n aria-label={intl.formatMessage({\n id: \"coordinateInput.ariaLabel\"\n })}\n borderLeftRadius={0}\n borderLeftWidth={0}\n onKeyDown={(e) => {\n if (e.key == \"Enter\") {\n onEnter();\n }\n }}\n /*avoid that browser provides old user inputs as suggestions in some edge cases*/\n autoComplete={\"off\"}\n />\n {/* NOTE: Tooltip shows same information, this is for screen readers only */}\n <VisuallyHidden asChild>\n <Field.ErrorText>{errorMessage}</Field.ErrorText>\n </VisuallyHidden>\n </Field.Root>\n );\n}\n\nfunction AttachedButton(props: {\n className: string;\n label: string;\n onClick: () => void;\n icon: React.ReactElement;\n}) {\n const { className, label, onClick, icon } = props;\n return (\n <Tooltip content={label}>\n <IconButton className={className} size=\"xs\" onClick={onClick} aria-label={label}>\n {icon}\n </IconButton>\n </Tooltip>\n );\n}\n"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"CoordinateInputField.js","sources":["CoordinateInputField.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Field, Icon, IconButton, Input, InputGroup, VisuallyHidden } from \"@chakra-ui/react\";\nimport { Tooltip } from \"@open-pioneer/chakra-snippets/tooltip\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { useIntl } from \"open-pioneer:react-hooks\";\nimport { LuCopy, LuX } from \"react-icons/lu\";\n\n/**\n * Text input for coordinates.\n */\nexport function CoordinateInputField(props: {\n coordinateSearchInput: string;\n setCoordinateSearchInput: (searchInput: string) => void;\n placeholder: string | Coordinate;\n placeholderString: string;\n errorMessage: string | undefined;\n onClear: (() => void) | undefined;\n onEnter: () => void;\n}) {\n const {\n errorMessage,\n coordinateSearchInput,\n setCoordinateSearchInput,\n placeholder,\n placeholderString,\n onClear,\n onEnter\n } = props;\n const intl = useIntl();\n\n const inputField = (\n <InputField\n errorMessage={errorMessage}\n value={coordinateSearchInput}\n placeholder={placeholderString}\n onChange={(newValue) => {\n setCoordinateSearchInput(newValue);\n }}\n onEnter={onEnter}\n />\n );\n\n let attachedButton = null;\n if (coordinateSearchInput !== \"\") {\n attachedButton = (\n <AttachedButton\n className=\"coordinate-input-clear-button\"\n label={intl.formatMessage({\n id: \"coordinateInput.clearLabel\"\n })}\n onClick={() => {\n setCoordinateSearchInput(\"\");\n onClear?.();\n }}\n icon={\n <Icon>\n <LuX />\n </Icon>\n }\n />\n );\n } else if (typeof placeholder === \"object\") {\n attachedButton = (\n <AttachedButton\n className=\"coordinate-input-copy-button\"\n label={intl.formatMessage({\n id: \"coordinateInput.copyLabel\"\n })}\n onClick={() => {\n navigator.clipboard.writeText(placeholderString);\n }}\n icon={\n <Icon>\n <LuCopy />\n </Icon>\n }\n />\n );\n }\n return (\n <InputGroup\n className=\"coordinate-input-field-group\"\n endElement={attachedButton}\n endElementProps={{\n className: \"coordinate-input-field-attachment\",\n paddingInline: \"4px\"\n }}\n >\n {inputField}\n </InputGroup>\n );\n}\n\nfunction InputField(props: {\n value: string;\n placeholder: string;\n errorMessage: string | undefined;\n onChange: (newValue: string) => void;\n onEnter: () => void;\n}) {\n const intl = useIntl();\n const { errorMessage, value, placeholder, onChange, onEnter } = props;\n const isInvalid = !!errorMessage;\n return (\n <Field.Root invalid={isInvalid} flex=\"1 1 auto\">\n <Input\n type=\"text\"\n value={value}\n onChange={(e) => {\n onChange(e.target.value);\n }}\n backgroundColor={isInvalid ? \"red.100\" : undefined}\n placeholder={placeholder}\n aria-label={intl.formatMessage({\n id: \"coordinateInput.ariaLabel\"\n })}\n borderLeftRadius={0}\n borderLeftWidth={0}\n onKeyDown={(e) => {\n if (e.key == \"Enter\") {\n onEnter();\n }\n }}\n /*avoid that browser provides old user inputs as suggestions in some edge cases*/\n autoComplete={\"off\"}\n />\n {/* NOTE: Tooltip shows same information, this is for screen readers only */}\n <VisuallyHidden asChild>\n <Field.ErrorText>{errorMessage}</Field.ErrorText>\n </VisuallyHidden>\n </Field.Root>\n );\n}\n\nfunction AttachedButton(props: {\n className: string;\n label: string;\n onClick: () => void;\n icon: React.ReactElement;\n}) {\n const { className, label, onClick, icon } = props;\n return (\n <Tooltip content={label}>\n <IconButton className={className} size=\"xs\" onClick={onClick} aria-label={label}>\n {icon}\n </IconButton>\n </Tooltip>\n );\n}\n"],"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I,CAAA,CAAE,OAAO,OAAA,EAAS;AAClB,YAAA,OAAA,EAAQ;AAAA,UACZ;AAAA,QACJ,CAAA;AAAA,QAEA,YAAA,EAAc;AAAA;AAAA,KAClB;AAAA,oBAEA,GAAA,CAAC,kBAAe,OAAA,EAAO,IAAA,EACnB,8BAAC,KAAA,CAAM,SAAA,EAAN,EAAiB,QAAA,EAAA,YAAA,EAAa,CAAA,EACnC;AAAA,GAAA,EACJ,CAAA;AAER;AAEA,SAAS,eAAe,KAAA,EAKrB;AACC,EAAA,MAAM,EAAE,SAAA,EAAW,KAAA,EAAO,OAAA,EAAS,MAAK,GAAI,KAAA;AAC5C,EAAA,uBACI,GAAA,CAAC,OAAA,EAAA,EAAQ,OAAA,EAAS,KAAA,EACd,QAAA,kBAAA,GAAA,CAAC,UAAA,EAAA,EAAW,SAAA,EAAsB,IAAA,EAAK,IAAA,EAAK,OAAA,EAAkB,YAAA,EAAY,KAAA,EACrE,gBACL,CAAA,EACJ,CAAA;AAER;;;;"}
|
package/CoordinateSearch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoordinateSearch.js","sources":["CoordinateSearch.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { MapModelProps, useMapModelValue } from \"@open-pioneer/map\";\nimport { CommonComponentProps, useCommonComponentProps } from \"@open-pioneer/react-utils\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { EventsKey } from \"ol/events\";\nimport OlMap from \"ol/Map\";\nimport { unByKey } from \"ol/Observable\";\nimport { FC, useEffect, useState } from \"react\";\nimport { CoordinateInput, CoordinatesSelectEvent, ProjectionInput } from \"./CoordinateInput\";\n\n/**\n * Properties for the {@link CoordinateSearch}.\n */\nexport interface CoordinateSearchProps extends CommonComponentProps, MapModelProps {\n /**\n * Searchable projections, only projections that are known by the map as projection are shown.\n * Each projection can have an individual precision of coordinates. If no precision is given, the default precision is used.\n */\n projections?: ProjectionInput[];\n\n /**\n * Optional event that gets called if some coordinates are entered or projection is changed by the user.\n */\n onSelect?: (event: CoordinatesSelectEvent) => void;\n\n /**\n * Optional event that gets called if the input is cleared.\n */\n onClear?: () => void;\n}\n\n/**\n * The `CoordinateSearch` component can be used in an app to search for entered coordinates in a selected projection\n */\nexport const CoordinateSearch: FC<CoordinateSearchProps> = (props) => {\n const { onSelect, onClear, projections } = props;\n const { containerProps } = useCommonComponentProps(\"coordinate-search\", props);\n const map = useMapModelValue(props);\n const olMap = map.olMap;\n\n const { coordinates } = useCoordinates(olMap); // coordinates of the pointer in the map\n\n return (\n <CoordinateInput\n {...containerProps}\n map={map}\n onSelect={(event: CoordinatesSelectEvent) => {\n olMap.getView().setCenter(event.coords);\n onSelect?.(event);\n }}\n onClear={onClear}\n placeholder={coordinates ? coordinates : \"\"}\n projections={projections}\n />\n );\n};\n\n/* get the current coordinates of the pointer on the map */\nfunction useCoordinates(map: OlMap | undefined): { coordinates: Coordinate | undefined } {\n const [coordinates, setCoordinates] = useState<Coordinate | undefined>();\n\n useEffect(() => {\n if (!map) {\n return;\n }\n\n const eventsKey: EventsKey = map.on(\"pointermove\", (evt) => {\n setCoordinates(evt.coordinate);\n });\n\n return () => unByKey(eventsKey);\n }, [map]);\n\n return { coordinates };\n}\n"],"names":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"CoordinateSearch.js","sources":["CoordinateSearch.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { MapModelProps, useMapModelValue } from \"@open-pioneer/map\";\nimport { CommonComponentProps, useCommonComponentProps } from \"@open-pioneer/react-utils\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { EventsKey } from \"ol/events\";\nimport OlMap from \"ol/Map\";\nimport { unByKey } from \"ol/Observable\";\nimport { FC, useEffect, useState } from \"react\";\nimport { CoordinateInput, CoordinatesSelectEvent, ProjectionInput } from \"./CoordinateInput\";\n\n/**\n * Properties for the {@link CoordinateSearch}.\n */\nexport interface CoordinateSearchProps extends CommonComponentProps, MapModelProps {\n /**\n * Searchable projections, only projections that are known by the map as projection are shown.\n * Each projection can have an individual precision of coordinates. If no precision is given, the default precision is used.\n */\n projections?: ProjectionInput[];\n\n /**\n * Optional event that gets called if some coordinates are entered or projection is changed by the user.\n */\n onSelect?: (event: CoordinatesSelectEvent) => void;\n\n /**\n * Optional event that gets called if the input is cleared.\n */\n onClear?: () => void;\n}\n\n/**\n * The `CoordinateSearch` component can be used in an app to search for entered coordinates in a selected projection\n */\nexport const CoordinateSearch: FC<CoordinateSearchProps> = (props) => {\n const { onSelect, onClear, projections } = props;\n const { containerProps } = useCommonComponentProps(\"coordinate-search\", props);\n const map = useMapModelValue(props);\n const olMap = map.olMap;\n\n const { coordinates } = useCoordinates(olMap); // coordinates of the pointer in the map\n\n return (\n <CoordinateInput\n {...containerProps}\n map={map}\n onSelect={(event: CoordinatesSelectEvent) => {\n olMap.getView().setCenter(event.coords);\n onSelect?.(event);\n }}\n onClear={onClear}\n placeholder={coordinates ? coordinates : \"\"}\n projections={projections}\n />\n );\n};\n\n/* get the current coordinates of the pointer on the map */\nfunction useCoordinates(map: OlMap | undefined): { coordinates: Coordinate | undefined } {\n const [coordinates, setCoordinates] = useState<Coordinate | undefined>();\n\n useEffect(() => {\n if (!map) {\n return;\n }\n\n const eventsKey: EventsKey = map.on(\"pointermove\", (evt) => {\n setCoordinates(evt.coordinate);\n });\n\n return () => unByKey(eventsKey);\n }, [map]);\n\n return { coordinates };\n}\n"],"names":[],"mappings":";;;;;;;AAoCO,MAAM,gBAAA,GAA8C,CAAC,KAAA,KAAU;AAClE,EAAA,MAAM,EAAE,QAAA,EAAU,OAAA,EAAS,WAAA,EAAY,GAAI,KAAA;AAC3C,EAAA,MAAM,EAAE,cAAA,EAAe,GAAI,uBAAA,CAAwB,qBAAqB,KAAK,CAAA;AAC7E,EAAA,MAAM,GAAA,GAAM,iBAAiB,KAAK,CAAA;AAClC,EAAA,MAAM,QAAQ,GAAA,CAAI,KAAA;AAElB,EAAA,MAAM,EAAE,WAAA,EAAY,GAAI,cAAA,CAAe,KAAK,CAAA;AAE5C,EAAA,uBACI,GAAA;AAAA,IAAC,eAAA;AAAA,IAAA;AAAA,MACI,GAAG,cAAA;AAAA,MACJ,GAAA;AAAA,MACA,QAAA,EAAU,CAAC,KAAA,KAAkC;AACzC,QAAA,KAAA,CAAM,OAAA,EAAQ,CAAE,SAAA,CAAU,KAAA,CAAM,MAAM,CAAA;AACtC,QAAA,QAAA,GAAW,KAAK,CAAA;AAAA,MACpB,CAAA;AAAA,MACA,OAAA;AAAA,MACA,WAAA,EAAa,cAAc,WAAA,GAAc,EAAA;AAAA,MACzC;AAAA;AAAA,GACJ;AAER;AAGA,SAAS,eAAe,GAAA,EAAiE;AACrF,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,QAAA,EAAiC;AAEvE,EAAA,SAAA,CAAU,MAAM;AACZ,IAAA,IAAI,CAAC,GAAA,EAAK;AACN,MAAA;AAAA,IACJ;AAEA,IAAA,MAAM,SAAA,GAAuB,GAAA,CAAI,EAAA,CAAG,aAAA,EAAe,CAAC,GAAA,KAAQ;AACxD,MAAA,cAAA,CAAe,IAAI,UAAU,CAAA;AAAA,IACjC,CAAC,CAAA;AAED,IAAA,OAAO,MAAM,QAAQ,SAAS,CAAA;AAAA,EAClC,CAAA,EAAG,CAAC,GAAG,CAAC,CAAA;AAER,EAAA,OAAO,EAAE,WAAA,EAAY;AACzB;;;;"}
|
package/ProjectionSelect.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { createListCollection, Select, VisuallyHidden, Portal } from '@chakra-ui/react';
|
|
3
|
-
import { memo, useMemo } from 'react';
|
|
4
3
|
import { useIntl } from './_virtual/hooks.js';
|
|
4
|
+
import { memo, useMemo } from 'react';
|
|
5
5
|
|
|
6
6
|
const ProjectionSelect = memo(function ProjectionSelect2(props) {
|
|
7
7
|
const { currentProjection, projections, onProjectionChange } = props;
|
package/ProjectionSelect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectionSelect.js","sources":["ProjectionSelect.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createListCollection, Portal, Select, VisuallyHidden } from \"@chakra-ui/react\";\nimport {
|
|
1
|
+
{"version":3,"file":"ProjectionSelect.js","sources":["ProjectionSelect.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { createListCollection, Portal, Select, VisuallyHidden } from \"@chakra-ui/react\";\nimport { useIntl } from \"open-pioneer:react-hooks\";\nimport { memo, useMemo } from \"react\";\nimport { ProjectionItem } from \"./CoordinateInput\";\n\nexport const ProjectionSelect = memo(function ProjectionSelect(props: {\n currentProjection: ProjectionItem;\n projections: ProjectionItem[];\n onProjectionChange: (proj: ProjectionItem) => void;\n}) {\n const { currentProjection, projections, onProjectionChange } = props;\n const intl = useIntl();\n\n const projectionsCollection = useMemo(() => {\n return createListCollection({\n items: projections,\n isItemDisabled: () => false,\n itemToString: (p) => p.label,\n itemToValue: projectionCode\n });\n }, [projections]);\n\n return (\n <Select.Root\n className=\"coordinate-input-select-root\"\n width=\"14em\"\n collection={projectionsCollection}\n value={[projectionCode(currentProjection)]}\n onValueChange={(value) => {\n const projection = value.items[0];\n if (projection) {\n onProjectionChange(projection);\n }\n }}\n lazyMount={true}\n unmountOnExit={true}\n >\n <Select.Control className=\"coordinate-input-select\">\n <VisuallyHidden asChild>\n <Select.Label>\n {intl.formatMessage({ id: \"projections.ariaLabel\" })}\n </Select.Label>\n </VisuallyHidden>\n <Select.Trigger\n className=\"coordinate-input-select-trigger\"\n borderRightRadius={0}\n borderRightWidth={0}\n background=\"colorPalette.solid\"\n color=\"colorPalette.contrast\"\n focusVisibleRing=\"outside\"\n >\n <Select.ValueText className=\"coordinate-input-select-value\" />\n </Select.Trigger>\n <Select.IndicatorGroup>\n <Select.Indicator color=\"colorPalette.contrast\" />\n </Select.IndicatorGroup>\n </Select.Control>\n\n <Portal>\n <Select.Positioner>\n <Select.Content className=\"coordinate-input-select-content\">\n {projectionsCollection.items.map((item) => (\n <Select.Item\n className=\"coordinate-input-select-item\"\n item={item}\n key={projectionCode(item)}\n _highlighted={{\n background: \"colorPalette.muted\"\n }}\n >\n {item.label}\n </Select.Item>\n ))}\n </Select.Content>\n </Select.Positioner>\n </Portal>\n </Select.Root>\n );\n});\n\nfunction projectionCode(item: ProjectionItem) {\n return item.value.getCode();\n}\n"],"names":["ProjectionSelect"],"mappings":";;;;;AAQO,MAAM,gBAAA,GAAmB,IAAA,CAAK,SAASA,iBAAAA,CAAiB,KAAA,EAI5D;AACC,EAAA,MAAM,EAAE,iBAAA,EAAmB,WAAA,EAAa,kBAAA,EAAmB,GAAI,KAAA;AAC/D,EAAA,MAAM,OAAO,OAAA,EAAQ;AAErB,EAAA,MAAM,qBAAA,GAAwB,QAAQ,MAAM;AACxC,IAAA,OAAO,oBAAA,CAAqB;AAAA,MACxB,KAAA,EAAO,WAAA;AAAA,MACP,gBAAgB,MAAM,KAAA;AAAA,MACtB,YAAA,EAAc,CAAC,CAAA,KAAM,CAAA,CAAE,KAAA;AAAA,MACvB,WAAA,EAAa;AAAA,KAChB,CAAA;AAAA,EACL,CAAA,EAAG,CAAC,WAAW,CAAC,CAAA;AAEhB,EAAA,uBACI,IAAA;AAAA,IAAC,MAAA,CAAO,IAAA;AAAA,IAAP;AAAA,MACG,SAAA,EAAU,8BAAA;AAAA,MACV,KAAA,EAAM,MAAA;AAAA,MACN,UAAA,EAAY,qBAAA;AAAA,MACZ,KAAA,EAAO,CA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AAA,kBAAA,GAAA,CAAC,MAAA,CAAO,OAAA,EAAP,EAAe,WAAU,iCAAA,EACrB,QAAA,EAAA,qBAAA,CAAsB,KAAA,CAAM,GAAA,CAAI,CAAC,IAAA,qBAC9B,GAAA;AAAA,UAAC,MAAA,CAAO,IAAA;AAAA,UAAP;AAAA,YACG,SAAA,EAAU,8BAAA;AAAA,YACV,IAAA;AAAA,YAEA,YAAA,EAAc;AAAA,cACV,UAAA,EAAY;AAAA,aAChB;AAAA,YAEC,QAAA,EAAA,IAAA,CAAK;AAAA,WAAA;AAAA,UALD,eAAe,IAAI;AAAA,SAO/B,CAAA,EACL,CAAA,EACJ,CAAA,EACJ;AAAA;AAAA;AAAA,GACJ;AAER,CAAC;AAED,SAAS,eAAe,IAAA,EAAsB;AAC1C,EAAA,OAAO,IAAA,CAAK,MAAM,OAAA,EAAQ;AAC9B;;;;"}
|
package/coordinates.js
CHANGED
|
@@ -53,7 +53,7 @@ function checkIfCoordsInProjectionsExtent(projection, coords) {
|
|
|
53
53
|
throw new Error(`Internal error: invalid coordinates ${coords}.`);
|
|
54
54
|
}
|
|
55
55
|
return (
|
|
56
|
-
/*
|
|
56
|
+
/* oxlint-disable @typescript-eslint/no-non-null-assertion */
|
|
57
57
|
extent[0] <= coords[0] && extent[1] <= coords[1] && extent[2] >= coords[0] && extent[3] >= coords[1]
|
|
58
58
|
);
|
|
59
59
|
}
|
package/coordinates.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordinates.js","sources":["coordinates.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createLogger } from \"@open-pioneer/core\";\nimport { NumberParserService, PackageIntl } from \"@open-pioneer/runtime\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { get as getProjection, Projection, transform } from \"ol/proj\";\nimport { sourceId } from \"open-pioneer:source-info\";\n\nconst LOG = createLogger(sourceId);\n\nexport interface ParseSuccess {\n kind: \"success\";\n projection: Projection;\n coordinates: [number, number];\n}\n\nexport interface ParseError {\n // Double duty as i18n message at the moment\n kind:\n | \"empty\"\n | \"tooltip.space\"\n | \"tooltip.spaceOne\"\n | \"tooltip.2coords\"\n | \"tooltip.invalidNumbers\"\n | \"tooltip.extent\"\n | \"tooltip.projection\";\n}\n\nexport type ParseResult = ParseSuccess | ParseError;\n\nexport function parseCoordinates(\n input: string,\n numberParser: NumberParserService,\n projection: Projection\n): ParseResult {\n if (input == \"\") return err(\"empty\");\n\n if (!input.includes(\" \")) {\n return err(\"tooltip.space\");\n }\n if (input.indexOf(\" \") != input.lastIndexOf(\" \")) {\n return err(\"tooltip.spaceOne\");\n }\n\n const splitCoords = input.split(\" \");\n if (\n splitCoords[0] == undefined ||\n splitCoords[1] == undefined ||\n splitCoords[0] == \"\" ||\n splitCoords[1] == \"\"\n ) {\n return err(\"tooltip.2coords\");\n }\n\n const coordsString1 = numberParser.parseNumber(splitCoords[0]);\n const coordsString2 = numberParser.parseNumber(splitCoords[1]);\n\n const coords: [number, number] = [coordsString1, coordsString2];\n if (coords.some((number) => Number.isNaN(number))) {\n return err(\"tooltip.invalidNumbers\");\n }\n try {\n if (!checkIfCoordsInProjectionsExtent(projection, coords)) {\n return err(\"tooltip.extent\");\n }\n\n if (\n !checkIfCoordsInProjectionsExtent(\n getProjection(\"EPSG:4326\"),\n transform(coords, projection, \"EPSG:4326\")\n )\n ) {\n return err(\"tooltip.extent\");\n }\n } catch (e) {\n LOG.warn(\"Failed to check if coordinates are in projection extent\", e);\n return err(\"tooltip.projection\");\n }\n\n return {\n kind: \"success\",\n projection,\n coordinates: coords\n };\n}\n\nfunction err(kind: ParseError[\"kind\"]): ParseError {\n return { kind };\n}\n\n/* validate if the coordinates fit to the extent of the selected projection */\nfunction checkIfCoordsInProjectionsExtent(\n projection: Projection | null,\n coords: Coordinate\n): boolean {\n const extent = projection?.getExtent();\n if (!extent || extent.length !== 4) {\n // Some projections don't have an extent, cannot validate.\n return true;\n }\n if (!coords || coords.length !== 2) {\n throw new Error(`Internal error: invalid coordinates ${coords}.`);\n }\n\n return (\n /*
|
|
1
|
+
{"version":3,"file":"coordinates.js","sources":["coordinates.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { createLogger } from \"@open-pioneer/core\";\nimport { NumberParserService, PackageIntl } from \"@open-pioneer/runtime\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { get as getProjection, Projection, transform } from \"ol/proj\";\nimport { sourceId } from \"open-pioneer:source-info\";\n\nconst LOG = createLogger(sourceId);\n\nexport interface ParseSuccess {\n kind: \"success\";\n projection: Projection;\n coordinates: [number, number];\n}\n\nexport interface ParseError {\n // Double duty as i18n message at the moment\n kind:\n | \"empty\"\n | \"tooltip.space\"\n | \"tooltip.spaceOne\"\n | \"tooltip.2coords\"\n | \"tooltip.invalidNumbers\"\n | \"tooltip.extent\"\n | \"tooltip.projection\";\n}\n\nexport type ParseResult = ParseSuccess | ParseError;\n\nexport function parseCoordinates(\n input: string,\n numberParser: NumberParserService,\n projection: Projection\n): ParseResult {\n if (input == \"\") return err(\"empty\");\n\n if (!input.includes(\" \")) {\n return err(\"tooltip.space\");\n }\n if (input.indexOf(\" \") != input.lastIndexOf(\" \")) {\n return err(\"tooltip.spaceOne\");\n }\n\n const splitCoords = input.split(\" \");\n if (\n splitCoords[0] == undefined ||\n splitCoords[1] == undefined ||\n splitCoords[0] == \"\" ||\n splitCoords[1] == \"\"\n ) {\n return err(\"tooltip.2coords\");\n }\n\n const coordsString1 = numberParser.parseNumber(splitCoords[0]);\n const coordsString2 = numberParser.parseNumber(splitCoords[1]);\n\n const coords: [number, number] = [coordsString1, coordsString2];\n if (coords.some((number) => Number.isNaN(number))) {\n return err(\"tooltip.invalidNumbers\");\n }\n try {\n if (!checkIfCoordsInProjectionsExtent(projection, coords)) {\n return err(\"tooltip.extent\");\n }\n\n if (\n !checkIfCoordsInProjectionsExtent(\n getProjection(\"EPSG:4326\"),\n transform(coords, projection, \"EPSG:4326\")\n )\n ) {\n return err(\"tooltip.extent\");\n }\n } catch (e) {\n LOG.warn(\"Failed to check if coordinates are in projection extent\", e);\n return err(\"tooltip.projection\");\n }\n\n return {\n kind: \"success\",\n projection,\n coordinates: coords\n };\n}\n\nfunction err(kind: ParseError[\"kind\"]): ParseError {\n return { kind };\n}\n\n/* validate if the coordinates fit to the extent of the selected projection */\nfunction checkIfCoordsInProjectionsExtent(\n projection: Projection | null,\n coords: Coordinate\n): boolean {\n const extent = projection?.getExtent();\n if (!extent || extent.length !== 4) {\n // Some projections don't have an extent, cannot validate.\n return true;\n }\n if (!coords || coords.length !== 2) {\n throw new Error(`Internal error: invalid coordinates ${coords}.`);\n }\n\n return (\n /* oxlint-disable @typescript-eslint/no-non-null-assertion */\n extent[0]! <= coords[0]! &&\n extent[1]! <= coords[1]! &&\n extent[2]! >= coords[0]! &&\n extent[3]! >= coords[1]!\n /* eslint-enable @typescript-eslint/no-non-null-assertion */\n );\n}\n\n/* Formats the coordinates as a string with given precision considering locales */\nexport function formatCoordinates(\n coordinates: number[],\n precision: number,\n intl: PackageIntl\n): string {\n if (coordinates[0] == null || coordinates[1] == null) {\n return \"\";\n }\n\n const [x, y] = coordinates;\n\n const xString = intl.formatNumber(x, {\n maximumFractionDigits: precision,\n minimumFractionDigits: precision\n });\n const yString = intl.formatNumber(y, {\n maximumFractionDigits: precision,\n minimumFractionDigits: precision\n });\n\n return xString + \" \" + yString;\n}\n"],"names":["getProjection"],"mappings":";;;;AASA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAsB1B,SAAS,gBAAA,CACZ,KAAA,EACA,YAAA,EACA,UAAA,EACW;AACX,EAAA,IAAI,KAAA,IAAS,EAAA,EAAI,OAAO,GAAA,CAAI,OAAO,CAAA;AAEnC,EAAA,IAAI,CAAC,KAAA,CAAM,QAAA,CAAS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B,SAAA;AAAA,IACvB,qBAAA,EAAuB;AAAA,GAC1B,CAAA;AACD,EAAA,MAAM,OAAA,GAAU,IAAA,CAAK,YAAA,CAAa,CAAA,EAAG;AAAA,IACjC,qBAAA,EAAuB,SAAA;AAAA,IACvB,qBAAA,EAAuB;AAAA,GAC1B,CAAA;AAED,EAAA,OAAO,UAAU,GAAA,GAAM,OAAA;AAC3B;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/coordinate-search",
|
|
4
|
-
"version": "1.4.0
|
|
4
|
+
"version": "1.4.0",
|
|
5
5
|
"description": "This package provides a UI component to search for entered coordinates in the choosen projection.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@chakra-ui/react": "^3.36.1",
|
|
18
18
|
"@conterra/reactivity-core": "^0.8.6",
|
|
19
|
-
"@open-pioneer/chakra-snippets": "4.7.0
|
|
20
|
-
"@open-pioneer/core": "4.7.0
|
|
21
|
-
"@open-pioneer/
|
|
22
|
-
"@open-pioneer/
|
|
23
|
-
"@open-pioneer/
|
|
19
|
+
"@open-pioneer/chakra-snippets": "^4.7.0",
|
|
20
|
+
"@open-pioneer/core": "^4.7.0",
|
|
21
|
+
"@open-pioneer/react-utils": "^4.7.0",
|
|
22
|
+
"@open-pioneer/reactivity": "^4.7.0",
|
|
23
|
+
"@open-pioneer/runtime": "^4.7.0",
|
|
24
24
|
"ol": "^10.9.0",
|
|
25
25
|
"react": "^19.2.8",
|
|
26
26
|
"react-icons": "^5.7.0",
|
|
27
|
-
"@open-pioneer/map": "1.4.0
|
|
27
|
+
"@open-pioneer/map": "1.4.0"
|
|
28
28
|
},
|
|
29
29
|
"exports": {
|
|
30
30
|
"./package.json": "./package.json",
|
package/usePlaceholder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePlaceholder.js","sources":["usePlaceholder.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Coordinate } from \"ol/coordinate\";\nimport { Projection, transform } from \"ol/proj\";\nimport { useIntl } from \"open-pioneer:react-hooks\";\nimport { useMemo } from \"react\";\nimport { ProjectionItem } from \"./CoordinateInput\";\nimport { formatCoordinates } from \"./coordinates\";\n\n/**\n * Returns the current placeholder string.\n */\n//In a different file for HMR.\nexport function usePlaceholder(\n placeholderProp: string | Coordinate,\n mapProjection: Projection | undefined,\n selectedProjection: ProjectionItem\n) {\n const intl = useIntl();\n\n return useMemo(() => {\n let placeholder: string;\n if (typeof placeholderProp === \"string\") {\n placeholder = placeholderProp;\n } else if (!mapProjection) {\n placeholder = \"\";\n } else {\n const coords = transform(\n placeholderProp as Coordinate,\n mapProjection,\n selectedProjection.value\n );\n placeholder = formatCoordinates(coords, selectedProjection.precision, intl);\n }\n return placeholder;\n }, [placeholderProp, mapProjection, selectedProjection, intl]);\n}\n"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"usePlaceholder.js","sources":["usePlaceholder.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Coordinate } from \"ol/coordinate\";\nimport { Projection, transform } from \"ol/proj\";\nimport { useIntl } from \"open-pioneer:react-hooks\";\nimport { useMemo } from \"react\";\nimport { ProjectionItem } from \"./CoordinateInput\";\nimport { formatCoordinates } from \"./coordinates\";\n\n/**\n * Returns the current placeholder string.\n */\n//In a different file for HMR.\nexport function usePlaceholder(\n placeholderProp: string | Coordinate,\n mapProjection: Projection | undefined,\n selectedProjection: ProjectionItem\n) {\n const intl = useIntl();\n\n return useMemo(() => {\n let placeholder: string;\n if (typeof placeholderProp === \"string\") {\n placeholder = placeholderProp;\n } else if (!mapProjection) {\n placeholder = \"\";\n } else {\n const coords = transform(\n placeholderProp as Coordinate,\n mapProjection,\n selectedProjection.value\n );\n placeholder = formatCoordinates(coords, selectedProjection.precision, intl);\n }\n return placeholder;\n }, [placeholderProp, mapProjection, selectedProjection, intl]);\n}\n"],"names":[],"mappings":";;;;;AAcO,SAAS,cAAA,CACZ,eAAA,EACA,aAAA,EACA,kBAAA,EACF;AACE,EAAA,MAAM,OAAO,OAAA,EAAQ;AAErB,EAAA,OAAO,QAAQ,MAAM;AACjB,IAAA,IAAI,WAAA;AACJ,IAAA,IAAI,OAAO,oBAAoB,QAAA,EAAU;AACrC,MAAA,WAAA,GAAc,eAAA;AAAA,IAClB,CAAA,MAAA,IAAW,CAAC,aAAA,EAAe;AACvB,MAAA,WAAA,GAAc,EAAA;AAAA,IAClB,CAAA,MAAO;AACH,MAAA,MAAM,MAAA,GAAS,SAAA;AAAA,QACX,eAAA;AAAA,QACA,aAAA;AAAA,QACA,kBAAA,CAAmB;AAAA,OACvB;AACA,MAAA,WAAA,GAAc,iBAAA,CAAkB,MAAA,EAAQ,kBAAA,CAAmB,SAAA,EAAW,IAAI,CAAA;AAAA,IAC9E;AACA,IAAA,OAAO,WAAA;AAAA,EACX,GAAG,CAAC,eAAA,EAAiB,aAAA,EAAe,kBAAA,EAAoB,IAAI,CAAC,CAAA;AACjE;;;;"}
|