@spaced-out/ui-design-system 0.0.12 → 0.0.13
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
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.0.13](https://github.com/spaced-out/ui-design-system/compare/v0.0.12...v0.0.13) (2023-01-04)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* button dropdown carat standalone fix ([507e1e4](https://github.com/spaced-out/ui-design-system/commit/507e1e4dbd834dfff36e96a569211aea4d84eeb2))
|
|
11
|
+
* button dropdown props change ([542d6e1](https://github.com/spaced-out/ui-design-system/commit/542d6e1bb299d95c29a793e32bd384037572ae00))
|
|
12
|
+
* emit more events from button dropdown ([faa9bf1](https://github.com/spaced-out/ui-design-system/commit/faa9bf15ce9f7fa5a7be4e2b1c24784f4654cb9e))
|
|
13
|
+
|
|
5
14
|
### [0.0.12](https://github.com/spaced-out/ui-design-system/compare/v0.0.11...v0.0.12) (2022-12-28)
|
|
6
15
|
|
|
7
16
|
|
|
@@ -22,9 +22,15 @@ const ButtonDropdown = _ref => {
|
|
|
22
22
|
anchorPosition = 'bottom-start',
|
|
23
23
|
size,
|
|
24
24
|
onOptionSelect,
|
|
25
|
-
|
|
25
|
+
menu,
|
|
26
26
|
classNames,
|
|
27
|
-
disabled
|
|
27
|
+
disabled,
|
|
28
|
+
onMenuOpen,
|
|
29
|
+
onMenuClose,
|
|
30
|
+
children,
|
|
31
|
+
iconRightName,
|
|
32
|
+
iconRightType,
|
|
33
|
+
...restButtonProps
|
|
28
34
|
} = _ref;
|
|
29
35
|
const menuBtnRef = React.useRef();
|
|
30
36
|
const {
|
|
@@ -39,7 +45,12 @@ const ButtonDropdown = _ref => {
|
|
|
39
45
|
whileElementsMounted: _reactDom.autoUpdate,
|
|
40
46
|
middleware: [(0, _reactDom.shift)(), (0, _reactDom.flip)(), (0, _reactDom.offset)(parseInt(_space.spaceXXSmall))]
|
|
41
47
|
});
|
|
42
|
-
|
|
48
|
+
const onMenuToggle = isOpen => {
|
|
49
|
+
isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
|
|
50
|
+
};
|
|
51
|
+
return /*#__PURE__*/React.createElement(_clickAway.ClickAway, {
|
|
52
|
+
onChange: onMenuToggle
|
|
53
|
+
}, _ref2 => {
|
|
43
54
|
let {
|
|
44
55
|
isOpen,
|
|
45
56
|
onOpen,
|
|
@@ -50,9 +61,9 @@ const ButtonDropdown = _ref => {
|
|
|
50
61
|
"data-testid": "ButtonDropdown",
|
|
51
62
|
className: (0, _classify.classify)(_ButtonDropdownModule.default.buttonDropdownContainer, classNames?.wrapper),
|
|
52
63
|
ref: menuBtnRef
|
|
53
|
-
}, /*#__PURE__*/React.createElement(_Button.Button, _extends({},
|
|
54
|
-
iconRightName:
|
|
55
|
-
iconRightType:
|
|
64
|
+
}, /*#__PURE__*/React.createElement(_Button.Button, _extends({}, restButtonProps, {
|
|
65
|
+
iconRightName: children ? isOpen ? 'caret-up' : 'caret-down' : iconRightName ? iconRightName : isOpen ? 'caret-up' : 'caret-down',
|
|
66
|
+
iconRightType: children ? 'solid' : iconRightType,
|
|
56
67
|
disabled: disabled,
|
|
57
68
|
size: size,
|
|
58
69
|
ref: reference,
|
|
@@ -60,7 +71,7 @@ const ButtonDropdown = _ref => {
|
|
|
60
71
|
e.stopPropagation();
|
|
61
72
|
onOpen();
|
|
62
73
|
}
|
|
63
|
-
})), isOpen &&
|
|
74
|
+
}), children), isOpen && menu && /*#__PURE__*/React.createElement("div", {
|
|
64
75
|
onClickCapture: cancelNext,
|
|
65
76
|
ref: floating,
|
|
66
77
|
style: {
|
|
@@ -70,7 +81,7 @@ const ButtonDropdown = _ref => {
|
|
|
70
81
|
left: x ?? _space.spaceNone,
|
|
71
82
|
width: _size.sizeFluid
|
|
72
83
|
}
|
|
73
|
-
}, /*#__PURE__*/React.createElement(_Menu.Menu, _extends({},
|
|
84
|
+
}, /*#__PURE__*/React.createElement(_Menu.Menu, _extends({}, menu, {
|
|
74
85
|
onSelect: option => {
|
|
75
86
|
onOptionSelect && onOptionSelect(option);
|
|
76
87
|
clickAway();
|
|
@@ -26,9 +26,9 @@ import {Menu} from '../Menu';
|
|
|
26
26
|
import css from './ButtonDropdown.module.css';
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
type ClassNames = $ReadOnly<{wrapper?: string}>;
|
|
30
|
-
|
|
31
29
|
export type ButtonDropdownProps = {
|
|
30
|
+
...ButtonProps,
|
|
31
|
+
menu: MenuProps,
|
|
32
32
|
anchorPosition?:
|
|
33
33
|
| 'top'
|
|
34
34
|
| 'top-start'
|
|
@@ -36,23 +36,25 @@ export type ButtonDropdownProps = {
|
|
|
36
36
|
| 'bottom'
|
|
37
37
|
| 'bottom-start'
|
|
38
38
|
| 'bottom-end',
|
|
39
|
-
size?: 'medium' | 'small',
|
|
40
|
-
props?: {
|
|
41
|
-
button: ButtonProps,
|
|
42
|
-
menu: MenuProps,
|
|
43
|
-
},
|
|
44
39
|
onOptionSelect?: (option: MenuOption) => mixed,
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
onMenuOpen?: () => mixed,
|
|
41
|
+
onMenuClose?: () => mixed,
|
|
42
|
+
...
|
|
47
43
|
};
|
|
48
44
|
|
|
49
45
|
export const ButtonDropdown = ({
|
|
50
46
|
anchorPosition = 'bottom-start',
|
|
51
47
|
size,
|
|
52
48
|
onOptionSelect,
|
|
53
|
-
|
|
49
|
+
menu,
|
|
54
50
|
classNames,
|
|
55
51
|
disabled,
|
|
52
|
+
onMenuOpen,
|
|
53
|
+
onMenuClose,
|
|
54
|
+
children,
|
|
55
|
+
iconRightName,
|
|
56
|
+
iconRightType,
|
|
57
|
+
...restButtonProps
|
|
56
58
|
}: ButtonDropdownProps): React.Node => {
|
|
57
59
|
const menuBtnRef = React.useRef();
|
|
58
60
|
const {x, y, reference, floating, strategy} = useFloating({
|
|
@@ -62,8 +64,12 @@ export const ButtonDropdown = ({
|
|
|
62
64
|
middleware: [shift(), flip(), offset(parseInt(spaceXXSmall))],
|
|
63
65
|
});
|
|
64
66
|
|
|
67
|
+
const onMenuToggle = (isOpen: boolean) => {
|
|
68
|
+
isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
|
|
69
|
+
};
|
|
70
|
+
|
|
65
71
|
return (
|
|
66
|
-
<ClickAway>
|
|
72
|
+
<ClickAway onChange={onMenuToggle}>
|
|
67
73
|
{({isOpen, onOpen, cancelNext, clickAway}) => (
|
|
68
74
|
<div
|
|
69
75
|
data-testid="ButtonDropdown"
|
|
@@ -71,17 +77,19 @@ export const ButtonDropdown = ({
|
|
|
71
77
|
ref={menuBtnRef}
|
|
72
78
|
>
|
|
73
79
|
<Button
|
|
74
|
-
{...
|
|
80
|
+
{...restButtonProps}
|
|
75
81
|
iconRightName={
|
|
76
|
-
|
|
82
|
+
children
|
|
77
83
|
? isOpen
|
|
78
84
|
? 'caret-up'
|
|
79
85
|
: 'caret-down'
|
|
80
|
-
:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
: iconRightName
|
|
87
|
+
? iconRightName
|
|
88
|
+
: isOpen
|
|
89
|
+
? 'caret-up'
|
|
90
|
+
: 'caret-down'
|
|
84
91
|
}
|
|
92
|
+
iconRightType={children ? 'solid' : iconRightType}
|
|
85
93
|
disabled={disabled}
|
|
86
94
|
size={size}
|
|
87
95
|
ref={reference}
|
|
@@ -89,8 +97,10 @@ export const ButtonDropdown = ({
|
|
|
89
97
|
e.stopPropagation();
|
|
90
98
|
onOpen();
|
|
91
99
|
}}
|
|
92
|
-
|
|
93
|
-
|
|
100
|
+
>
|
|
101
|
+
{children}
|
|
102
|
+
</Button>
|
|
103
|
+
{isOpen && menu && (
|
|
94
104
|
<div
|
|
95
105
|
onClickCapture={cancelNext}
|
|
96
106
|
ref={floating}
|
|
@@ -103,7 +113,7 @@ export const ButtonDropdown = ({
|
|
|
103
113
|
}}
|
|
104
114
|
>
|
|
105
115
|
<Menu
|
|
106
|
-
{...
|
|
116
|
+
{...menu}
|
|
107
117
|
onSelect={(option) => {
|
|
108
118
|
onOptionSelect && onOptionSelect(option);
|
|
109
119
|
clickAway();
|