@open-pioneer/scale-setter 0.1.0 → 0.7.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 +39 -0
- package/README.md +1 -1
- package/ScaleSetter.d.ts +2 -5
- package/ScaleSetter.js +2 -2
- package/ScaleSetter.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @open-pioneer/scale-setter
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 310800c: Switch from `peerDependencies` to normal `dependencies`. Peer dependencies have some usability problems when used at scale.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 310800c: Update core packages version.
|
|
12
|
+
- 583f1d6: The `mapId` or `map` properties are now optional on individual components.
|
|
13
|
+
You can use the `DefaultMapProvider` to configure an implicit default value.
|
|
14
|
+
|
|
15
|
+
Note that configuring _neither_ a default _nor_ an explicit `map` or `mapId` will trigger a runtime error.
|
|
16
|
+
|
|
17
|
+
- 583f1d6: All UI components in this project now accept the `mapId` (a `string`) _or_ the `map` (a `MapModel`) directly.
|
|
18
|
+
- a8b3449: Switch to a new versioning strategy.
|
|
19
|
+
From now on, packages released by this repository share a common version number.
|
|
20
|
+
- 900eb11: Update dependencies.
|
|
21
|
+
- Updated dependencies [310800c]
|
|
22
|
+
- Updated dependencies [2502050]
|
|
23
|
+
- Updated dependencies [583f1d6]
|
|
24
|
+
- Updated dependencies [583f1d6]
|
|
25
|
+
- Updated dependencies [397d617]
|
|
26
|
+
- Updated dependencies [a8b3449]
|
|
27
|
+
- Updated dependencies [310800c]
|
|
28
|
+
- Updated dependencies [900eb11]
|
|
29
|
+
- Updated dependencies [583f1d6]
|
|
30
|
+
- Updated dependencies [397d617]
|
|
31
|
+
- @open-pioneer/map@0.7.0
|
|
32
|
+
|
|
33
|
+
## 0.1.1
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- b152428: Update trails dependencies
|
|
38
|
+
- Updated dependencies [b152428]
|
|
39
|
+
- Updated dependencies [291ccb6]
|
|
40
|
+
- @open-pioneer/map@0.6.1
|
|
41
|
+
|
|
3
42
|
## 0.1.0
|
|
4
43
|
|
|
5
44
|
### Minor Changes
|
package/README.md
CHANGED
package/ScaleSetter.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
+
import { MapModelProps } from "@open-pioneer/map";
|
|
1
2
|
import { CommonComponentProps } from "@open-pioneer/react-utils";
|
|
2
3
|
import { FC } from "react";
|
|
3
4
|
/**
|
|
4
5
|
* These are the properties supported by the {@link ScaleSetter}.
|
|
5
6
|
*/
|
|
6
|
-
export interface ScaleSetterProps extends CommonComponentProps {
|
|
7
|
-
/**
|
|
8
|
-
* The map id.
|
|
9
|
-
*/
|
|
10
|
-
mapId: string;
|
|
7
|
+
export interface ScaleSetterProps extends CommonComponentProps, MapModelProps {
|
|
11
8
|
/**
|
|
12
9
|
* The set of scales that can be selected by the user.
|
|
13
10
|
*/
|
package/ScaleSetter.js
CHANGED
|
@@ -25,9 +25,9 @@ const DEFAULT_SCALES = [
|
|
|
25
25
|
2132
|
|
26
26
|
];
|
|
27
27
|
const ScaleSetter = (props) => {
|
|
28
|
-
const {
|
|
28
|
+
const { scales = DEFAULT_SCALES } = props;
|
|
29
29
|
const { containerProps } = useCommonComponentProps("scale-setter", props);
|
|
30
|
-
const { map } = useMapModel(
|
|
30
|
+
const { map } = useMapModel(props);
|
|
31
31
|
const intl = useIntl();
|
|
32
32
|
const activeScale = useScale(map?.olMap) ?? 1;
|
|
33
33
|
function setScale(scale) {
|
package/ScaleSetter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScaleSetter.js","sources":["ScaleSetter.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ChevronUpIcon } from \"@chakra-ui/icons\";\nimport {\n Box,\n Button,\n Menu,\n MenuButton,\n MenuItem,\n MenuList,\n Portal\n} from \"@open-pioneer/chakra-integration\";\nimport { useMapModel, useScale } from \"@open-pioneer/map\";\nimport { CommonComponentProps, useCommonComponentProps } from \"@open-pioneer/react-utils\";\nimport { PackageIntl } from \"@open-pioneer/runtime\";\nimport { getPointResolution } from \"ol/proj\";\nimport { useIntl } from \"open-pioneer:react-hooks\";\nimport { FC } from \"react\";\n\nconst DEFAULT_DPI = 25.4 / 0.28;\nconst INCHES_PER_METRE = 39.37;\nconst DEFAULT_SCALES = [\n 17471320, 8735660, 4367830, 2183915, 1091957, 545978, 272989, 136494, 68247, 34123, 17061, 8530,\n 4265, 2132\n];\n\n/**\n * These are the properties supported by the {@link ScaleSetter}.\n */\nexport interface ScaleSetterProps extends CommonComponentProps {\n /**\n * The
|
|
1
|
+
{"version":3,"file":"ScaleSetter.js","sources":["ScaleSetter.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ChevronUpIcon } from \"@chakra-ui/icons\";\nimport {\n Box,\n Button,\n Menu,\n MenuButton,\n MenuItem,\n MenuList,\n Portal\n} from \"@open-pioneer/chakra-integration\";\nimport { MapModelProps, useMapModel, useScale } from \"@open-pioneer/map\";\nimport { CommonComponentProps, useCommonComponentProps } from \"@open-pioneer/react-utils\";\nimport { PackageIntl } from \"@open-pioneer/runtime\";\nimport { getPointResolution } from \"ol/proj\";\nimport { useIntl } from \"open-pioneer:react-hooks\";\nimport { FC } from \"react\";\n\nconst DEFAULT_DPI = 25.4 / 0.28;\nconst INCHES_PER_METRE = 39.37;\nconst DEFAULT_SCALES = [\n 17471320, 8735660, 4367830, 2183915, 1091957, 545978, 272989, 136494, 68247, 34123, 17061, 8530,\n 4265, 2132\n];\n\n/**\n * These are the properties supported by the {@link ScaleSetter}.\n */\nexport interface ScaleSetterProps extends CommonComponentProps, MapModelProps {\n /**\n * The set of scales that can be selected by the user.\n */\n scales?: number[];\n}\n\n/**\n * Displays the current scale and allows the user to change it.\n */\nexport const ScaleSetter: FC<ScaleSetterProps> = (props) => {\n const { scales = DEFAULT_SCALES } = props;\n const { containerProps } = useCommonComponentProps(\"scale-setter\", props);\n const { map } = useMapModel(props);\n const intl = useIntl();\n\n const activeScale = useScale(map?.olMap) ?? 1;\n\n // TODO: Move to map model (reactivity API refactoring)\n function setScale(scale: number) {\n if (!map) {\n return;\n }\n\n const view = map.olMap.getView();\n const projection = map.olMap.getView().getProjection();\n const mpu = projection.getMetersPerUnit() ?? 1;\n const resolution = INCHES_PER_METRE * DEFAULT_DPI * mpu;\n const center = map.olMap.getView().getCenter();\n if (!center) {\n return;\n }\n\n const pointResolution = scale / getPointResolution(projection, resolution, center);\n view.setResolution(pointResolution);\n }\n\n const scaleSelectOptions = scales.map((sc) => {\n return (\n <MenuItem\n value={sc}\n key={sc}\n onClick={() => setScale(sc)}\n onFocus={(e) => {\n // Not available in unit tests\n e.target?.scrollIntoView?.({\n block: \"nearest\"\n });\n }}\n className=\"scale-setter-option\"\n >\n {renderDisplayScale(intl, sc)}\n </MenuItem>\n );\n });\n\n const renderedScale = renderDisplayScale(intl, activeScale);\n return (\n <Box {...containerProps}>\n <Menu isLazy>\n <MenuButton\n as={Button}\n rightIcon={<ChevronUpIcon />}\n className=\"scale-setter-menubutton\"\n aria-label={intl.formatMessage(\n {\n id: \"button.ariaLabel\"\n },\n { scale: renderedScale }\n )}\n // eslint-disable-next-line jsx-a11y/aria-props\n aria-description={intl.formatMessage({\n id: \"button.ariaDescription\"\n })}\n >\n {renderedScale}\n </MenuButton>\n <Portal>\n <MenuList\n className=\"scale-setter-menuoptions\"\n maxHeight=\"20em\"\n overflowY=\"auto\"\n >\n {scaleSelectOptions}\n </MenuList>\n </Portal>\n </Menu>\n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U,EAAA,yBAAA;AAAA,QACV,cAAY,IAAK,CAAA,aAAA;AAAA,UACb;AAAA,YACI,EAAI,EAAA,kBAAA;AAAA,WACR;AAAA,UACA,EAAE,OAAO,aAAc,EAAA;AAAA,SAC3B;AAAA,QAEA,kBAAA,EAAkB,KAAK,aAAc,CAAA;AAAA,UACjC,EAAI,EAAA,wBAAA;AAAA,SACP,CAAA;AAAA,QAEA,QAAA,EAAA,aAAA;AAAA,OAAA;AAAA,KACL;AAAA,wBACC,MACG,EAAA,EAAA,QAAA,kBAAA,GAAA;AAAA,MAAC,QAAA;AAAA,MAAA;AAAA,QACG,SAAU,EAAA,0BAAA;AAAA,QACV,SAAU,EAAA,MAAA;AAAA,QACV,SAAU,EAAA,MAAA;AAAA,QAET,QAAA,EAAA,kBAAA;AAAA,OAAA;AAAA,KAET,EAAA,CAAA;AAAA,GAAA,EACJ,CACJ,EAAA,CAAA,CAAA;AAER,EAAA;AAEA,SAAS,kBAAA,CAAmB,MAAmB,QAA0B,EAAA;AACrE,EAAO,OAAA,MAAA,GAAS,IAAK,CAAA,YAAA,CAAa,QAAQ,CAAA,CAAA;AAC9C;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/scale-setter",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"description": "This package provides a UI component to change the scale of the map.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"url": "https://github.com/open-pioneer/trails-openlayers-base-packages",
|
|
14
14
|
"directory": "src/packages/scale-setter"
|
|
15
15
|
},
|
|
16
|
-
"
|
|
17
|
-
"@chakra-ui/icons": "^2.
|
|
18
|
-
"@open-pioneer/chakra-integration": "^
|
|
19
|
-
"@open-pioneer/react-utils": "^
|
|
20
|
-
"@open-pioneer/runtime": "^2.
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@chakra-ui/icons": "^2.2.4",
|
|
18
|
+
"@open-pioneer/chakra-integration": "^2.3.0",
|
|
19
|
+
"@open-pioneer/react-utils": "^2.3.0",
|
|
20
|
+
"@open-pioneer/runtime": "^2.3.0",
|
|
21
21
|
"ol": "^9.2.4",
|
|
22
22
|
"react": "^18.3.1",
|
|
23
|
-
"@open-pioneer/map": "^0.
|
|
23
|
+
"@open-pioneer/map": "^0.7.0"
|
|
24
24
|
},
|
|
25
25
|
"exports": {
|
|
26
26
|
"./package.json": "./package.json",
|