@woosmap/ui 2.45.0 → 2.46.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
|
@@ -45,9 +45,20 @@ class DropdownMenu extends Component {
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
render() {
|
|
48
|
-
const { direction, children, closeCb, testId, ...rest } = this.props;
|
|
48
|
+
const { direction, children, closeCb, testId, isSection, ...rest } = this.props;
|
|
49
49
|
const childrenWithProps = mapChildrenWithProps(children, this.childrenRefs, closeCb);
|
|
50
|
-
|
|
50
|
+
if (isSection) {
|
|
51
|
+
return (
|
|
52
|
+
<div
|
|
53
|
+
role="menu"
|
|
54
|
+
className={cl('dropdown__menu', direction, 'dropdown__menu--section')}
|
|
55
|
+
data-testid={testId}
|
|
56
|
+
{...rest}
|
|
57
|
+
>
|
|
58
|
+
{childrenWithProps}
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
51
62
|
return (
|
|
52
63
|
<ul role="menu" className={cl('dropdown__menu', direction)} data-testid={testId} {...rest}>
|
|
53
64
|
{childrenWithProps}
|
|
@@ -60,15 +71,50 @@ DropdownMenu.defaultProps = {
|
|
|
60
71
|
direction: 'sw',
|
|
61
72
|
closeCb: null,
|
|
62
73
|
testId: 'dropdown-menu',
|
|
74
|
+
isSection: false,
|
|
63
75
|
};
|
|
64
76
|
|
|
65
77
|
DropdownMenu.propTypes = {
|
|
66
78
|
children: PropTypes.node.isRequired,
|
|
67
79
|
closeCb: PropTypes.func,
|
|
68
80
|
testId: PropTypes.string,
|
|
81
|
+
isSection: PropTypes.bool,
|
|
69
82
|
direction: PropTypes.oneOf(['ne', 'e', 'se', 's', 'sw', 'w']),
|
|
70
83
|
};
|
|
71
84
|
|
|
85
|
+
class DropdownMenuSection extends Component {
|
|
86
|
+
constructor(props) {
|
|
87
|
+
super(props);
|
|
88
|
+
this.childrenRefs = {};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
close = () => {
|
|
92
|
+
closeChildren(this.childrenRefs);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
render() {
|
|
96
|
+
const { title, children, closeCb, ...rest } = this.props;
|
|
97
|
+
const childrenWithProps = mapChildrenWithProps(children, this.childrenRefs, closeCb);
|
|
98
|
+
return (
|
|
99
|
+
<div className="dropdown__menu__section">
|
|
100
|
+
{title && <div className="dropdown__menu__section__title">{title}</div>}
|
|
101
|
+
<ul {...rest}>{childrenWithProps}</ul>
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
DropdownMenuSection.defaultProps = {
|
|
108
|
+
title: null,
|
|
109
|
+
closeCb: null,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
DropdownMenuSection.propTypes = {
|
|
113
|
+
children: PropTypes.node.isRequired,
|
|
114
|
+
title: PropTypes.string,
|
|
115
|
+
closeCb: PropTypes.func,
|
|
116
|
+
};
|
|
117
|
+
|
|
72
118
|
class DropdownSeparator extends Component {
|
|
73
119
|
render() {
|
|
74
120
|
const { testId } = this.props;
|
|
@@ -336,6 +382,7 @@ Dropdown.propTypes = {
|
|
|
336
382
|
|
|
337
383
|
export default Object.assign(withClickOutside(Dropdown, '.popover__content'), {
|
|
338
384
|
Menu: DropdownMenu,
|
|
385
|
+
MenuSection: DropdownMenuSection,
|
|
339
386
|
Item: DropdownItem,
|
|
340
387
|
ButtonItem: DropdownButtonItem,
|
|
341
388
|
ConfirmButtonItem: DropdownConfirmButtonItem,
|
|
@@ -52,3 +52,32 @@ const Template = () => (
|
|
|
52
52
|
);
|
|
53
53
|
export const Default = Template.bind({});
|
|
54
54
|
Default.args = {};
|
|
55
|
+
|
|
56
|
+
const MultiMenuTemplate = () => (
|
|
57
|
+
<div className="mbi" id="menuid">
|
|
58
|
+
<Dropdown btnFace="link" btnFaceIcon="clock" label="My dropdown">
|
|
59
|
+
<Dropdown.Menu isSection direction="se">
|
|
60
|
+
<Dropdown.MenuSection title="Section title">
|
|
61
|
+
<Dropdown.ButtonItem btnIcon="delete" isImportant btnLabel="Delete" />
|
|
62
|
+
<Dropdown.ConfirmButtonItem
|
|
63
|
+
btnIcon="delete"
|
|
64
|
+
isImportant
|
|
65
|
+
btnLabel="Delete confirm"
|
|
66
|
+
onConfirm={() => null}
|
|
67
|
+
/>
|
|
68
|
+
</Dropdown.MenuSection>
|
|
69
|
+
<Dropdown.MenuSection title="Section title 2">
|
|
70
|
+
<Dropdown.ButtonItem btnIcon="delete" isImportant btnLabel="Delete" />
|
|
71
|
+
<Dropdown.ConfirmButtonItem
|
|
72
|
+
btnIcon="delete"
|
|
73
|
+
isImportant
|
|
74
|
+
btnLabel="Delete confirm"
|
|
75
|
+
onConfirm={() => null}
|
|
76
|
+
/>
|
|
77
|
+
</Dropdown.MenuSection>
|
|
78
|
+
</Dropdown.Menu>
|
|
79
|
+
</Dropdown>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
export const MultiMenuTemplateDropdown = MultiMenuTemplate.bind({});
|
|
83
|
+
MultiMenuTemplateDropdown.args = {};
|