@open-pioneer/scale-setter 0.10.0 → 0.11.0-dev.20250515143825

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @open-pioneer/scale-setter
2
2
 
3
+ ## 0.11.0-dev.20250515143825
4
+
5
+ ### Minor Changes
6
+
7
+ - 738390e: Update to Chakra v3
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [738390e]
12
+ - Updated dependencies [738390e]
13
+ - @open-pioneer/map@0.11.0-dev.20250515143825
14
+
3
15
  ## 0.10.0
4
16
 
5
17
  ### Minor Changes
package/ScaleSetter.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { ChevronUpIcon } from '@chakra-ui/icons';
3
- import { MenuItem, Box, Menu, MenuButton, Button, Portal, MenuList } from '@open-pioneer/chakra-integration';
2
+ import { Menu, Box, Button, Portal } from '@chakra-ui/react';
4
3
  import { useMapModel } from '@open-pioneer/map';
5
4
  import { useCommonComponentProps } from '@open-pioneer/react-utils';
6
5
  import { useReactiveSnapshot } from '@open-pioneer/reactivity';
7
6
  import { useIntl } from './_virtual/_virtual-pioneer-module_react-hooks.js';
7
+ import { useMemo } from 'react';
8
+ import { FiChevronUp } from 'react-icons/fi';
8
9
 
9
10
  const DEFAULT_SCALES = [
10
11
  17471320,
@@ -28,30 +29,32 @@ const ScaleSetter = (props) => {
28
29
  const { map } = useMapModel(props);
29
30
  const intl = useIntl();
30
31
  const activeScale = useReactiveSnapshot(() => map?.scale ?? 1, [map]);
31
- const scaleSelectOptions = scales.map((scaleValue) => {
32
- return /* @__PURE__ */ jsx(
33
- MenuItem,
34
- {
35
- value: scaleValue,
36
- onClick: () => map?.setScale(scaleValue),
37
- onFocus: (e) => {
38
- e.target?.scrollIntoView?.({
39
- block: "nearest"
40
- });
32
+ const scaleSelectOptions = useMemo(
33
+ () => scales.map((scaleValue) => {
34
+ const displayScale = renderDisplayScale(intl, scaleValue);
35
+ return /* @__PURE__ */ jsx(
36
+ Menu.Item,
37
+ {
38
+ className: "scale-setter-option",
39
+ value: String(scaleValue),
40
+ onClick: () => map?.setScale(scaleValue),
41
+ onFocus: (e) => {
42
+ e.target?.scrollIntoView?.({
43
+ block: "nearest"
44
+ });
45
+ },
46
+ children: displayScale
41
47
  },
42
- className: "scale-setter-option",
43
- children: renderDisplayScale(intl, scaleValue)
44
- },
45
- scaleValue
46
- );
47
- });
48
+ scaleValue
49
+ );
50
+ }),
51
+ [intl, map, scales]
52
+ );
48
53
  const renderedScale = renderDisplayScale(intl, activeScale);
49
- return /* @__PURE__ */ jsx(Box, { ...containerProps, children: /* @__PURE__ */ jsxs(Menu, { isLazy: true, children: [
50
- /* @__PURE__ */ jsx(
51
- MenuButton,
54
+ return /* @__PURE__ */ jsx(Box, { ...containerProps, children: /* @__PURE__ */ jsxs(Menu.Root, { children: [
55
+ /* @__PURE__ */ jsx(Menu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs(
56
+ Button,
52
57
  {
53
- as: Button,
54
- rightIcon: /* @__PURE__ */ jsx(ChevronUpIcon, {}),
55
58
  className: "scale-setter-menubutton",
56
59
  "aria-label": intl.formatMessage(
57
60
  {
@@ -62,18 +65,21 @@ const ScaleSetter = (props) => {
62
65
  "aria-description": intl.formatMessage({
63
66
  id: "button.ariaDescription"
64
67
  }),
65
- children: renderedScale
68
+ children: [
69
+ renderedScale,
70
+ /* @__PURE__ */ jsx(FiChevronUp, {})
71
+ ]
66
72
  }
67
- ),
68
- /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(
69
- MenuList,
73
+ ) }),
74
+ /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(Menu.Positioner, { children: /* @__PURE__ */ jsx(
75
+ Menu.Content,
70
76
  {
71
77
  className: "scale-setter-menuoptions",
72
78
  maxHeight: "20em",
73
79
  overflowY: "auto",
74
80
  children: scaleSelectOptions
75
81
  }
76
- ) })
82
+ ) }) })
77
83
  ] }) });
78
84
  };
79
85
  function renderDisplayScale(intl, rawScale) {
@@ -1 +1 @@
1
- {"version":3,"file":"ScaleSetter.js","sources":["ScaleSetter.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 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,EAAS,OAAA;AAAA,EAAS,OAAA;AAAA,EAAS,OAAA;AAAA,EAAS,MAAA;AAAA,EAAQ,MAAA;AAAA,EAAQ,MAAA;AAAA,EAAQ,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,IAAA;AAAA,EAC3F,IAAA;AAAA,EAAM;AACV,CAAA;AAea,MAAA,WAAA,GAAoC,CAAC,KAAU,KAAA;AACxD,EAAM,MAAA,EAAE,MAAS,GAAA,cAAA,EAAmB,GAAA,KAAA;AACpC,EAAA,MAAM,EAAE,cAAA,EAAmB,GAAA,uBAAA,CAAwB,gBAAgB,KAAK,CAAA;AACxE,EAAA,MAAM,EAAE,GAAA,EAAQ,GAAA,WAAA,CAAY,KAAK,CAAA;AACjC,EAAA,MAAM,OAAO,OAAQ,EAAA;AAErB,EAAM,MAAA,WAAA,GAAc,oBAAoB,MAAM,GAAA,EAAK,SAAS,CAAG,EAAA,CAAC,GAAG,CAAC,CAAA;A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;AAAA,QACV,SAAU,EAAA,MAAA;AAAA,QAET,QAAA,EAAA;AAAA;AAAA,KAET,EAAA;AAAA,GAAA,EACJ,CACJ,EAAA,CAAA;AAER;AAEA,SAAS,kBAAA,CAAmB,MAAmB,QAA0B,EAAA;AACrE,EAAO,OAAA,MAAA,GAAS,IAAK,CAAA,YAAA,CAAa,QAAQ,CAAA;AAC9C;;;;"}
1
+ {"version":3,"file":"ScaleSetter.js","sources":["ScaleSetter.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Box, Button, Menu, Portal } from \"@chakra-ui/react\";\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, useMemo } from \"react\";\nimport { FiChevronUp } from \"react-icons/fi\";\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 = useMemo(\n () =>\n scales.map((scaleValue) => {\n const displayScale = renderDisplayScale(intl, scaleValue);\n return (\n <Menu.Item\n className=\"scale-setter-option\"\n value={String(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 >\n {displayScale}\n </Menu.Item>\n );\n }),\n [intl, map, scales]\n );\n\n const renderedScale = renderDisplayScale(intl, activeScale);\n return (\n <Box {...containerProps}>\n <Menu.Root>\n <Menu.Trigger asChild>\n <Button\n className=\"scale-setter-menubutton\"\n aria-label={intl.formatMessage(\n {\n id: \"button.ariaLabel\"\n },\n { scale: renderedScale }\n )}\n aria-description={intl.formatMessage({\n id: \"button.ariaDescription\"\n })}\n >\n {renderedScale}\n {<FiChevronUp />}\n </Button>\n </Menu.Trigger>\n <Portal>\n <Menu.Positioner>\n <Menu.Content\n className=\"scale-setter-menuoptions\"\n maxHeight=\"20em\"\n overflowY=\"auto\"\n >\n {scaleSelectOptions}\n </Menu.Content>\n </Menu.Positioner>\n </Portal>\n </Menu.Root>\n </Box>\n );\n};\n\nfunction renderDisplayScale(intl: PackageIntl, rawScale: number): string {\n return \"1 : \" + intl.formatNumber(rawScale);\n}\n"],"names":[],"mappings":";;;;;;;;;AAWA,MAAM,cAAiB,GAAA;AAAA,EACnB,QAAA;AAAA,EAAU,OAAA;AAAA,EAAS,OAAA;AAAA,EAAS,OAAA;AAAA,EAAS,OAAA;AAAA,EAAS,MAAA;AAAA,EAAQ,MAAA;AAAA,EAAQ,MAAA;AAAA,EAAQ,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,IAAA;AAAA,EAC3F,IAAA;AAAA,EAAM;AACV,CAAA;AAea,MAAA,WAAA,GAAoC,CAAC,KAAU,KAAA;AACxD,EAAM,MAAA,EAAE,MAAS,GAAA,cAAA,EAAmB,GAAA,KAAA;AACpC,EAAA,MAAM,EAAE,cAAA,EAAmB,GAAA,uBAAA,CAAwB,gBAAgB,KAAK,CAAA;AACxE,EAAA,MAAM,EAAE,GAAA,EAAQ,GAAA,WAAA,CA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OAAO,aAAc;AAAA,SAC3B;AAAA,QACA,kBAAA,EAAkB,KAAK,aAAc,CAAA;AAAA,UACjC,EAAI,EAAA;AAAA,SACP,CAAA;AAAA,QAEA,QAAA,EAAA;AAAA,UAAA,aAAA;AAAA,8BACC,WAAY,EAAA,EAAA;AAAA;AAAA;AAAA,KAEtB,EAAA,CAAA;AAAA,oBACC,GAAA,CAAA,MAAA,EAAA,EACG,QAAC,kBAAA,GAAA,CAAA,IAAA,CAAK,YAAL,EACG,QAAA,kBAAA,GAAA;AAAA,MAAC,IAAK,CAAA,OAAA;AAAA,MAAL;AAAA,QACG,SAAU,EAAA,0BAAA;AAAA,QACV,SAAU,EAAA,MAAA;AAAA,QACV,SAAU,EAAA,MAAA;AAAA,QAET,QAAA,EAAA;AAAA;AAAA,OAET,CACJ,EAAA;AAAA,GAAA,EACJ,CACJ,EAAA,CAAA;AAER;AAEA,SAAS,kBAAA,CAAmB,MAAmB,QAA0B,EAAA;AACrE,EAAO,OAAA,MAAA,GAAS,IAAK,CAAA,YAAA,CAAa,QAAQ,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.10.0",
4
+ "version": "0.11.0-dev.20250515143825",
5
5
  "description": "This package provides a UI component to change the scale of the map.",
6
6
  "keywords": [
7
7
  "open-pioneer-trails"
@@ -14,14 +14,14 @@
14
14
  "directory": "src/packages/scale-setter"
15
15
  },
16
16
  "dependencies": {
17
- "@chakra-ui/icons": "^2.2.4",
18
- "@open-pioneer/chakra-integration": "^3.1.0",
19
- "@open-pioneer/react-utils": "^3.1.0",
20
- "@open-pioneer/runtime": "^3.1.0",
21
- "@open-pioneer/reactivity": "^3.1.0",
17
+ "@chakra-ui/react": "^3.17.0",
18
+ "@open-pioneer/react-utils": "4.0.0-dev.20250512105016",
19
+ "@open-pioneer/runtime": "4.0.0-dev.20250512105016",
20
+ "@open-pioneer/reactivity": "4.0.0-dev.20250512105016",
22
21
  "ol": "^10.5.0",
23
22
  "react": "^19.1.0",
24
- "@open-pioneer/map": "^0.10.0"
23
+ "react-icons": "^5.3.0",
24
+ "@open-pioneer/map": "0.11.0-dev.20250515143825"
25
25
  },
26
26
  "exports": {
27
27
  "./package.json": "./package.json",