@open-pioneer/map-ui-components 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 +12 -0
- package/ToolButton.d.ts +6 -5
- package/ToolButton.js +37 -37
- package/ToolButton.js.map +1 -1
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @open-pioneer/map-ui-components
|
|
2
2
|
|
|
3
|
+
## 0.11.0-dev.20250515143825
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 738390e: **Breaking:** Rename `<ToolButton />` props for consistency with Chakra naming conventions:
|
|
8
|
+
|
|
9
|
+
- `isLoading` (old) --> `loading` (new)
|
|
10
|
+
- `isActive` (old) --> `active` (new)
|
|
11
|
+
- `isDisabled` (old) --> `disabled` (new)
|
|
12
|
+
|
|
13
|
+
- 738390e: Update to Chakra v3
|
|
14
|
+
|
|
3
15
|
## 0.10.0
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/ToolButton.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ButtonProps
|
|
2
|
-
import {
|
|
1
|
+
import { ButtonProps } from "@chakra-ui/react";
|
|
2
|
+
import { TooltipProps } from "@open-pioneer/chakra-snippets/tooltip";
|
|
3
3
|
import { CommonComponentProps } from "@open-pioneer/react-utils";
|
|
4
|
+
import { FC, MouseEventHandler, ReactElement, RefAttributes } from "react";
|
|
4
5
|
/**
|
|
5
6
|
* Properties supported by {@link ToolButton}.
|
|
6
7
|
*/
|
|
@@ -20,7 +21,7 @@ export interface ToolButtonProps extends CommonComponentProps, RefAttributes<HTM
|
|
|
20
21
|
* If `true`, the button will show a spinner.
|
|
21
22
|
* Defaults to `false`.
|
|
22
23
|
*/
|
|
23
|
-
|
|
24
|
+
loading?: boolean;
|
|
24
25
|
/**
|
|
25
26
|
* If `true`, indicates that the button is currently active with a different style.
|
|
26
27
|
* Defaults to `undefined`.
|
|
@@ -29,12 +30,12 @@ export interface ToolButtonProps extends CommonComponentProps, RefAttributes<HTM
|
|
|
29
30
|
* In that case the `aria-pressed` attribute will be configured automatically
|
|
30
31
|
* (see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-pressed).
|
|
31
32
|
*/
|
|
32
|
-
|
|
33
|
+
active?: boolean;
|
|
33
34
|
/**
|
|
34
35
|
* If `true`, the button will be disabled.
|
|
35
36
|
* Defaults to `false`.
|
|
36
37
|
*/
|
|
37
|
-
|
|
38
|
+
disabled?: boolean;
|
|
38
39
|
/**
|
|
39
40
|
* The callback that will be called when the user clicks the button.
|
|
40
41
|
*/
|
package/ToolButton.js
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Toggle, Button } from '@chakra-ui/react';
|
|
3
|
+
import { Tooltip } from '@open-pioneer/chakra-snippets/tooltip';
|
|
4
4
|
import { useCommonComponentProps } from '@open-pioneer/react-utils';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
|
+
import { memo, useState } from 'react';
|
|
6
7
|
|
|
7
|
-
const ToolButton =
|
|
8
|
+
const ToolButton = memo(function ToolButton2(props) {
|
|
8
9
|
const {
|
|
9
10
|
label,
|
|
10
11
|
icon,
|
|
11
12
|
onClick: onClickProp,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
loading,
|
|
14
|
+
disabled,
|
|
15
|
+
active,
|
|
15
16
|
tooltipProps,
|
|
16
|
-
buttonProps
|
|
17
|
+
buttonProps,
|
|
18
|
+
ref
|
|
17
19
|
} = props;
|
|
18
20
|
const {
|
|
19
21
|
containerProps: { className: baseClassName, ...containerProps }
|
|
20
22
|
} = useCommonComponentProps("tool-button", props);
|
|
21
23
|
const className = classNames(baseClassName, {
|
|
22
|
-
"tool-button--active":
|
|
23
|
-
"tool-button--loading":
|
|
24
|
-
"tool-button--disabled":
|
|
24
|
+
"tool-button--active": active,
|
|
25
|
+
"tool-button--loading": loading,
|
|
26
|
+
"tool-button--disabled": disabled
|
|
25
27
|
});
|
|
26
|
-
const ariaPressed = typeof isActive === "boolean" ? isActive ? "true" : "false" : void 0;
|
|
27
28
|
const [tooltipOpen, setTooltipOpen] = useState(false);
|
|
28
29
|
const onClick = (e) => {
|
|
29
30
|
setTooltipOpen(false);
|
|
30
31
|
onClickProp?.(e);
|
|
31
32
|
};
|
|
33
|
+
let button = /* @__PURE__ */ jsx(
|
|
34
|
+
ButtonIgnoringAriaProps,
|
|
35
|
+
{
|
|
36
|
+
className,
|
|
37
|
+
ref,
|
|
38
|
+
"aria-label": label,
|
|
39
|
+
padding: 0,
|
|
40
|
+
disabled,
|
|
41
|
+
loading,
|
|
42
|
+
...containerProps,
|
|
43
|
+
...buttonProps,
|
|
44
|
+
onClick,
|
|
45
|
+
children: icon
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
if (active != null) {
|
|
49
|
+
button = /* @__PURE__ */ jsx(Toggle.Root, { pressed: active, asChild: true, children: button });
|
|
50
|
+
}
|
|
32
51
|
return /* @__PURE__ */ jsx(
|
|
33
52
|
Tooltip,
|
|
34
53
|
{
|
|
35
|
-
label,
|
|
36
|
-
placement: "auto",
|
|
54
|
+
content: label,
|
|
37
55
|
openDelay: 500,
|
|
38
56
|
...tooltipProps,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
children: /* @__PURE__ */ jsx(
|
|
43
|
-
ButtonIgnoringAriaProps,
|
|
44
|
-
{
|
|
45
|
-
className,
|
|
46
|
-
ref,
|
|
47
|
-
"aria-label": label,
|
|
48
|
-
leftIcon: icon,
|
|
49
|
-
iconSpacing: 0,
|
|
50
|
-
padding: 0,
|
|
51
|
-
isDisabled,
|
|
52
|
-
isLoading,
|
|
53
|
-
isActive,
|
|
54
|
-
"aria-pressed": ariaPressed,
|
|
55
|
-
...containerProps,
|
|
56
|
-
...buttonProps,
|
|
57
|
-
onClick
|
|
58
|
-
}
|
|
59
|
-
)
|
|
57
|
+
open: tooltipOpen,
|
|
58
|
+
onOpenChange: (e) => setTooltipOpen(e.open),
|
|
59
|
+
children: button
|
|
60
60
|
}
|
|
61
61
|
);
|
|
62
62
|
});
|
|
63
|
-
const ButtonIgnoringAriaProps =
|
|
64
|
-
const { "aria-labelledby": _label, "aria-describedby": _describedBy, ...rest } = props;
|
|
63
|
+
const ButtonIgnoringAriaProps = function ButtonIgnoringAriaProps2(props) {
|
|
64
|
+
const { "aria-labelledby": _label, "aria-describedby": _describedBy, ref, ...rest } = props;
|
|
65
65
|
return /* @__PURE__ */ jsx(Button, { ref, ...rest });
|
|
66
|
-
}
|
|
66
|
+
};
|
|
67
67
|
|
|
68
68
|
export { ToolButton };
|
|
69
69
|
//# sourceMappingURL=ToolButton.js.map
|
package/ToolButton.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolButton.js","sources":["ToolButton.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Button, ButtonProps,
|
|
1
|
+
{"version":3,"file":"ToolButton.js","sources":["ToolButton.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Button, ButtonProps, Toggle } from \"@chakra-ui/react\";\nimport { Tooltip, TooltipProps } from \"@open-pioneer/chakra-snippets/tooltip\";\nimport { CommonComponentProps, useCommonComponentProps } from \"@open-pioneer/react-utils\";\nimport classNames from \"classnames\";\nimport {\n FC,\n MouseEvent,\n MouseEventHandler,\n ReactElement,\n RefAttributes,\n memo,\n useState\n} from \"react\";\n\n/**\n * Properties supported by {@link ToolButton}.\n */\nexport interface ToolButtonProps extends CommonComponentProps, RefAttributes<HTMLButtonElement> {\n /**\n * The label for the ToolButton.\n * This value services as the tooltip text and the aria-label.\n *\n * This property is required for a11y reasons because a ToolButton usually only displays an icon.\n */\n label: string;\n\n /**\n * The icon displayed by the button.\n */\n icon: ReactElement;\n\n /**\n * If `true`, the button will show a spinner.\n * Defaults to `false`.\n */\n loading?: boolean;\n\n /**\n * If `true`, indicates that the button is currently active with a different style.\n * Defaults to `undefined`.\n *\n * A value of `true` or `false` indicates that the button supports being active (i.e. pressed).\n * In that case the `aria-pressed` attribute will be configured automatically\n * (see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-pressed).\n */\n active?: boolean;\n\n /**\n * If `true`, the button will be disabled.\n * Defaults to `false`.\n */\n disabled?: boolean;\n\n /**\n * The callback that will be called when the user clicks the button.\n */\n onClick?: MouseEventHandler<HTMLButtonElement> | undefined;\n\n /**\n * Additional properties for the `Tooltip` element.\n *\n * Note that the ToolButton also defines some of these props.\n */\n tooltipProps?: Partial<TooltipProps>;\n\n /**\n * Additional properties for the `Button` element.\n *\n * Note that the ToolButton also defines some of these props.\n */\n buttonProps?: Partial<ButtonProps>;\n}\n\n/**\n * An button with a tooltip, used for tool buttons on a map.\n */\nexport const ToolButton: FC<ToolButtonProps> = memo(function ToolButton(props: ToolButtonProps) {\n const {\n label,\n icon,\n onClick: onClickProp,\n loading,\n disabled,\n active,\n tooltipProps,\n buttonProps,\n ref\n } = props;\n\n const {\n containerProps: { className: baseClassName, ...containerProps }\n } = useCommonComponentProps(\"tool-button\", props);\n\n const className = classNames(baseClassName, {\n \"tool-button--active\": active,\n \"tool-button--loading\": loading,\n \"tool-button--disabled\": disabled\n });\n\n const [tooltipOpen, setTooltipOpen] = useState(false);\n const onClick = (e: MouseEvent<HTMLButtonElement>) => {\n // Immediately hide the tooltip. When the label switches in reaction to the click,\n // the tooltip would flicker briefly with the new label.\n setTooltipOpen(false);\n onClickProp?.(e);\n };\n\n let button = (\n <ButtonIgnoringAriaProps\n className={className}\n ref={ref}\n aria-label={label}\n padding={0}\n disabled={disabled}\n loading={loading}\n {...containerProps}\n {...buttonProps}\n /* don't allow overwrite because component would break */\n onClick={onClick}\n >\n {icon}\n </ButtonIgnoringAriaProps>\n );\n if (active != null) {\n // Make sure that only \"pressable\" buttons receive the aria-pressed attribute.\n button = (\n <Toggle.Root pressed={active} asChild>\n {button}\n </Toggle.Root>\n );\n }\n\n return (\n <Tooltip\n content={label}\n openDelay={500}\n {...tooltipProps}\n /* don't allow overwrite because component would break */\n open={tooltipOpen}\n onOpenChange={(e) => setTooltipOpen(e.open)}\n >\n {button}\n </Tooltip>\n );\n});\n\n/**\n * The tooltip will automatically set 'aria-describedby' when it is being shown.\n * This is redundant because the aria-label already has the same content as the tooltip.\n * This component wraps chakra's button to ignore the *-by attributes.\n */\nconst ButtonIgnoringAriaProps = function ButtonIgnoringAriaProps(\n props: ButtonProps & { ref?: React.Ref<HTMLButtonElement> }\n) {\n const { \"aria-labelledby\": _label, \"aria-describedby\": _describedBy, ref, ...rest } = props;\n return <Button ref={ref} {...rest} />;\n};\n"],"names":["ToolButton","ButtonIgnoringAriaProps"],"mappings":";;;;;;;AA8EO,MAAM,UAAkC,GAAA,IAAA,CAAK,SAASA,WAAAA,CAAW,KAAwB,EAAA;AAC5F,EAAM,MAAA;AAAA,IACF,KAAA;AAAA,IACA,IAAA;AAAA,IACA,OAAS,EAAA,WAAA;AAAA,IACT,OAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA,YAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,GACA,GAAA,KAAA;AAEJ,EAAM,MAAA;AAAA,IACF,cAAgB,EAAA,EAAE,SAAW,EAAA,aAAA,EAAe,GAAG,cAAe;AAAA,GAClE,GAAI,uBAAwB,CAAA,aAAA,EAAe,KAAK,CAAA;AAEhD,EAAM,MAAA,SAAA,GAAY,WAAW,aAAe,EAAA;AAAA,IACxC,qBAAuB,EAAA,MAAA;AAAA,IACvB,sBAAwB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O,GAAW,EAAA,GAAG,IAAM,EAAA,CAAA;AACvC,CAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/map-ui-components",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.11.0-dev.20250515143825",
|
|
5
5
|
"description": "Contains ui components that can used together with the map",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -14,10 +14,11 @@
|
|
|
14
14
|
"directory": "src/packages/map-ui-components"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"@open-pioneer/react-utils": "
|
|
17
|
+
"@chakra-ui/react": "^3.17.0",
|
|
18
|
+
"@open-pioneer/react-utils": "4.0.0-dev.20250512105016",
|
|
19
19
|
"classnames": "^2.3.2",
|
|
20
|
-
"react": "^19.1.0"
|
|
20
|
+
"react": "^19.1.0",
|
|
21
|
+
"@open-pioneer/chakra-snippets": "4.0.0-dev.20250512105016"
|
|
21
22
|
},
|
|
22
23
|
"exports": {
|
|
23
24
|
"./package.json": "./package.json",
|