@woosmap/ui 3.28.0 → 3.29.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/package.json
CHANGED
|
@@ -6,14 +6,14 @@ import Button from '../Button/Button';
|
|
|
6
6
|
import ConfirmationPopover from '../Popover/ConfirmationPopover';
|
|
7
7
|
import withClickOutside from '../withClickOutside/withClickOutside';
|
|
8
8
|
|
|
9
|
-
function mapChildrenWithProps(children, childrenRefs,
|
|
9
|
+
function mapChildrenWithProps(children, childrenRefs, props) {
|
|
10
10
|
if (children) {
|
|
11
11
|
return React.Children.map(children, (child, index) => {
|
|
12
12
|
if (React.isValidElement(child)) {
|
|
13
13
|
// only add ref to non functional components
|
|
14
14
|
return React.cloneElement(child, {
|
|
15
15
|
...child.props,
|
|
16
|
-
|
|
16
|
+
...props,
|
|
17
17
|
ref:
|
|
18
18
|
!child.type.prototype || (child.type.prototype && child.type.prototype.render)
|
|
19
19
|
? (elem) => {
|
|
@@ -49,8 +49,8 @@ class DropdownMenu extends Component {
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
render() {
|
|
52
|
-
const { direction, children, closeCb, testId, isSection, ...rest } = this.props;
|
|
53
|
-
const childrenWithProps = mapChildrenWithProps(children, this.childrenRefs, closeCb);
|
|
52
|
+
const { direction, children, closeCb, onMouseEnter, onMouseLeave, testId, isSection, ...rest } = this.props;
|
|
53
|
+
const childrenWithProps = mapChildrenWithProps(children, this.childrenRefs, { closeCb });
|
|
54
54
|
if (isSection) {
|
|
55
55
|
return (
|
|
56
56
|
<div className="dropdown__container">
|
|
@@ -58,6 +58,9 @@ class DropdownMenu extends Component {
|
|
|
58
58
|
role="menu"
|
|
59
59
|
className={cl('dropdown__menu', direction, 'dropdown__menu--section')}
|
|
60
60
|
data-testid={testId}
|
|
61
|
+
tabIndex="-1"
|
|
62
|
+
onMouseEnter={onMouseEnter}
|
|
63
|
+
onMouseLeave={onMouseLeave}
|
|
61
64
|
{...rest}
|
|
62
65
|
>
|
|
63
66
|
{childrenWithProps}
|
|
@@ -66,7 +69,14 @@ class DropdownMenu extends Component {
|
|
|
66
69
|
);
|
|
67
70
|
}
|
|
68
71
|
return (
|
|
69
|
-
<ul
|
|
72
|
+
<ul
|
|
73
|
+
role="menu"
|
|
74
|
+
className={cl('dropdown__menu', direction)}
|
|
75
|
+
data-testid={testId}
|
|
76
|
+
{...rest}
|
|
77
|
+
onMouseEnter={onMouseEnter}
|
|
78
|
+
onMouseLeave={onMouseLeave}
|
|
79
|
+
>
|
|
70
80
|
{childrenWithProps}
|
|
71
81
|
</ul>
|
|
72
82
|
);
|
|
@@ -76,6 +86,8 @@ class DropdownMenu extends Component {
|
|
|
76
86
|
DropdownMenu.defaultProps = {
|
|
77
87
|
direction: 'sw',
|
|
78
88
|
closeCb: null,
|
|
89
|
+
onMouseEnter: null,
|
|
90
|
+
onMouseLeave: null,
|
|
79
91
|
testId: 'dropdown-menu',
|
|
80
92
|
isSection: false,
|
|
81
93
|
};
|
|
@@ -83,6 +95,8 @@ DropdownMenu.defaultProps = {
|
|
|
83
95
|
DropdownMenu.propTypes = {
|
|
84
96
|
children: PropTypes.node.isRequired,
|
|
85
97
|
closeCb: PropTypes.func,
|
|
98
|
+
onMouseEnter: PropTypes.func,
|
|
99
|
+
onMouseLeave: PropTypes.func,
|
|
86
100
|
testId: PropTypes.string,
|
|
87
101
|
isSection: PropTypes.bool,
|
|
88
102
|
direction: PropTypes.oneOf(['ne', 'e', 'se', 's', 'sw', 'w']),
|
|
@@ -100,7 +114,7 @@ class DropdownMenuSection extends Component {
|
|
|
100
114
|
|
|
101
115
|
render() {
|
|
102
116
|
const { title, children, closeCb, ...rest } = this.props;
|
|
103
|
-
const childrenWithProps = mapChildrenWithProps(children, this.childrenRefs, closeCb);
|
|
117
|
+
const childrenWithProps = mapChildrenWithProps(children, this.childrenRefs, { closeCb });
|
|
104
118
|
return (
|
|
105
119
|
<div className="dropdown__menu__section">
|
|
106
120
|
{title && <div className="dropdown__menu__item dropdown__menu__item__title">{title}</div>}
|
|
@@ -351,15 +365,17 @@ class Dropdown extends Component {
|
|
|
351
365
|
...rest
|
|
352
366
|
} = this.props;
|
|
353
367
|
const { open } = this.state;
|
|
354
|
-
const childrenWithProps = mapChildrenWithProps(children, this.childrenRefs,
|
|
368
|
+
const childrenWithProps = mapChildrenWithProps(children, this.childrenRefs, {
|
|
369
|
+
closeCb: this.handleClickOutside,
|
|
370
|
+
onMouseEnter: this.onMouseEnter,
|
|
371
|
+
onMouseLeave: this.onMouseLeave,
|
|
372
|
+
});
|
|
355
373
|
|
|
356
374
|
return (
|
|
357
375
|
<div
|
|
358
376
|
ref={openOnMouseEnter ? null : this.clickOutsideRef}
|
|
359
377
|
className={cl('dropdown', { open }, `dropdown--${size}`, className)}
|
|
360
378
|
{...rest}
|
|
361
|
-
onMouseEnter={this.onMouseEnter}
|
|
362
|
-
onMouseLeave={this.onMouseLeave}
|
|
363
379
|
>
|
|
364
380
|
<Button
|
|
365
381
|
disabled={disabled}
|
|
@@ -371,6 +387,8 @@ class Dropdown extends Component {
|
|
|
371
387
|
iconSize={btnFaceIconSize}
|
|
372
388
|
label={label}
|
|
373
389
|
testId={testId}
|
|
390
|
+
onMouseEnter={this.onMouseEnter}
|
|
391
|
+
onMouseLeave={this.onMouseLeave}
|
|
374
392
|
/>
|
|
375
393
|
{childrenWithProps}
|
|
376
394
|
</div>
|