@open-pioneer/scale-setter 0.7.0 → 0.8.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 +26 -0
- package/ScaleSetter.js +8 -25
- package/ScaleSetter.js.map +1 -1
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @open-pioneer/scale-setter
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2fa8020: Update trails core package dependencies.
|
|
8
|
+
|
|
9
|
+
- Also updates Chakra UI to the latest 2.x version and Chakra React Select to version 5.
|
|
10
|
+
- Removes any obsolete references to `@chakra-ui/system`.
|
|
11
|
+
This dependency seems to be no longer required and may lead to duplicate packages in your dependency tree.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 49f0207: Update trails core packages to version 2.4.0
|
|
16
|
+
- d8337a6: Refactor implementation to use the new reactive properties of the map model.
|
|
17
|
+
- Updated dependencies [b717121]
|
|
18
|
+
- Updated dependencies [e7978a8]
|
|
19
|
+
- Updated dependencies [7a5f1e1]
|
|
20
|
+
- Updated dependencies [7ae9f90]
|
|
21
|
+
- Updated dependencies [d8337a6]
|
|
22
|
+
- Updated dependencies [49f0207]
|
|
23
|
+
- Updated dependencies [b2127df]
|
|
24
|
+
- Updated dependencies [2fa8020]
|
|
25
|
+
- Updated dependencies [7ae9f90]
|
|
26
|
+
- Updated dependencies [d8337a6]
|
|
27
|
+
- @open-pioneer/map@0.8.0
|
|
28
|
+
|
|
3
29
|
## 0.7.0
|
|
4
30
|
|
|
5
31
|
### Minor Changes
|
package/ScaleSetter.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { ChevronUpIcon } from '@chakra-ui/icons';
|
|
3
3
|
import { MenuItem, Box, Menu, MenuButton, Button, Portal, MenuList } from '@open-pioneer/chakra-integration';
|
|
4
|
-
import { useMapModel
|
|
4
|
+
import { useMapModel } from '@open-pioneer/map';
|
|
5
5
|
import { useCommonComponentProps } from '@open-pioneer/react-utils';
|
|
6
|
-
import {
|
|
6
|
+
import { useReactiveSnapshot } from '@open-pioneer/reactivity';
|
|
7
7
|
import { useIntl } from './_virtual/_virtual-pioneer-module_react-hooks.js';
|
|
8
8
|
|
|
9
|
-
const DEFAULT_DPI = 25.4 / 0.28;
|
|
10
|
-
const INCHES_PER_METRE = 39.37;
|
|
11
9
|
const DEFAULT_SCALES = [
|
|
12
10
|
17471320,
|
|
13
11
|
8735660,
|
|
@@ -29,37 +27,22 @@ const ScaleSetter = (props) => {
|
|
|
29
27
|
const { containerProps } = useCommonComponentProps("scale-setter", props);
|
|
30
28
|
const { map } = useMapModel(props);
|
|
31
29
|
const intl = useIntl();
|
|
32
|
-
const activeScale =
|
|
33
|
-
|
|
34
|
-
if (!map) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
const view = map.olMap.getView();
|
|
38
|
-
const projection = map.olMap.getView().getProjection();
|
|
39
|
-
const mpu = projection.getMetersPerUnit() ?? 1;
|
|
40
|
-
const resolution = INCHES_PER_METRE * DEFAULT_DPI * mpu;
|
|
41
|
-
const center = map.olMap.getView().getCenter();
|
|
42
|
-
if (!center) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const pointResolution = scale / getPointResolution(projection, resolution, center);
|
|
46
|
-
view.setResolution(pointResolution);
|
|
47
|
-
}
|
|
48
|
-
const scaleSelectOptions = scales.map((sc) => {
|
|
30
|
+
const activeScale = useReactiveSnapshot(() => map?.scale ?? 1, [map]);
|
|
31
|
+
const scaleSelectOptions = scales.map((scaleValue) => {
|
|
49
32
|
return /* @__PURE__ */ jsx(
|
|
50
33
|
MenuItem,
|
|
51
34
|
{
|
|
52
|
-
value:
|
|
53
|
-
onClick: () => setScale(
|
|
35
|
+
value: scaleValue,
|
|
36
|
+
onClick: () => map?.setScale(scaleValue),
|
|
54
37
|
onFocus: (e) => {
|
|
55
38
|
e.target?.scrollIntoView?.({
|
|
56
39
|
block: "nearest"
|
|
57
40
|
});
|
|
58
41
|
},
|
|
59
42
|
className: "scale-setter-option",
|
|
60
|
-
children: renderDisplayScale(intl,
|
|
43
|
+
children: renderDisplayScale(intl, scaleValue)
|
|
61
44
|
},
|
|
62
|
-
|
|
45
|
+
scaleValue
|
|
63
46
|
);
|
|
64
47
|
});
|
|
65
48
|
const renderedScale = renderDisplayScale(intl, activeScale);
|
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 { MapModelProps, useMapModel
|
|
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 } from \"@open-pioneer/map\";\nimport { CommonComponentProps, useCommonComponentProps } from \"@open-pioneer/react-utils\";\nimport { useReactiveSnapshot } from \"@open-pioneer/reactivity\";\nimport { PackageIntl } from \"@open-pioneer/runtime\";\nimport { useIntl } from \"open-pioneer:react-hooks\";\nimport { FC } from \"react\";\n\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 = useReactiveSnapshot(() => map?.scale ?? 1, [map]);\n\n const scaleSelectOptions = scales.map((scaleValue) => {\n return (\n <MenuItem\n value={scaleValue}\n key={scaleValue}\n onClick={() => map?.setScale(scaleValue)}\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, scaleValue)}\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 </Box>\n );\n};\n\nfunction renderDisplayScale(intl: PackageIntl, rawScale: number): string {\n return \"1 : \" + intl.formatNumber(rawScale);\n}\n"],"names":[],"mappings":";;;;;;;;AAmBA,MAAM,cAAiB,GAAA;AAAA,EACnB,QAAA;AAAA,EAAU,OAAA;AAAA,EA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AAM,WAAW,CAAA,CAAA;AAC1D,EAAA,2BACK,GAAK,EAAA,EAAA,GAAG,gBACL,QAAC,kBAAA,IAAA,CAAA,IAAA,EAAA,EAAK,QAAM,IACR,EAAA,QAAA,EAAA;AAAA,oBAAA,GAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACG,EAAI,EAAA,MAAA;AAAA,QACJ,SAAA,sBAAY,aAAc,EAAA,EAAA,CAAA;AAAA,QAC1B,SAAU,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.8.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"
|
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@chakra-ui/icons": "^2.2.4",
|
|
18
|
-
"@open-pioneer/chakra-integration": "^2.
|
|
19
|
-
"@open-pioneer/react-utils": "^2.
|
|
20
|
-
"@open-pioneer/runtime": "^2.
|
|
21
|
-
"
|
|
18
|
+
"@open-pioneer/chakra-integration": "^2.4.0",
|
|
19
|
+
"@open-pioneer/react-utils": "^2.4.0",
|
|
20
|
+
"@open-pioneer/runtime": "^2.4.0",
|
|
21
|
+
"@open-pioneer/reactivity": "^2.4.0",
|
|
22
|
+
"ol": "^10.2.1",
|
|
22
23
|
"react": "^18.3.1",
|
|
23
|
-
"@open-pioneer/map": "^0.
|
|
24
|
+
"@open-pioneer/map": "^0.8.0"
|
|
24
25
|
},
|
|
25
26
|
"exports": {
|
|
26
27
|
"./package.json": "./package.json",
|