@woosmap/ui 2.53.0 → 2.57.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 +1 -1
- package/src/components/CopyClipboardButton/CopyClipboardButton.js +8 -5
- package/src/components/CopyClipboardButton/CopyToClipboard.stories.js +12 -1
- package/src/components/CopyClipboardButton/CopyToClipboard.test.js +7 -0
- package/src/components/Dropdown/Dropdown.js +13 -11
- package/src/components/Dropdown/Dropdown.styl +25 -24
package/package.json
CHANGED
|
@@ -17,25 +17,26 @@ export default class CopyClipboardButton extends Component {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
copy = () => {
|
|
20
|
-
const { text, getText } = this.props;
|
|
20
|
+
const { text, getText, copyCallback } = this.props;
|
|
21
21
|
const { copied } = this.state;
|
|
22
22
|
|
|
23
23
|
const textToCopy = text || (getText ? getText() : null);
|
|
24
24
|
|
|
25
25
|
if (textToCopy !== null && copy(textToCopy) && !copied) {
|
|
26
|
-
this.setState({ copied: true });
|
|
26
|
+
this.setState({ copied: true }, copyCallback);
|
|
27
27
|
this.copyTimeout = setTimeout(() => this.setState({ copied: false }), 1000);
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
render() {
|
|
32
|
-
const { type, noLabel, label, copiedLabel, copiedIcon, icon, getText, testId, ...rest } =
|
|
32
|
+
const { type, noLabel, label, copiedLabel, copiedIcon, icon, getText, testId, copyCallback, ...rest } =
|
|
33
|
+
this.props;
|
|
33
34
|
const { copied } = this.state;
|
|
34
35
|
return (
|
|
35
36
|
<Button
|
|
36
37
|
type={type}
|
|
37
|
-
label={copied &&
|
|
38
|
-
icon={copied ? copiedIcon : icon}
|
|
38
|
+
label={copied && copiedLabel ? copiedLabel : label}
|
|
39
|
+
icon={copied && copiedIcon ? copiedIcon : icon}
|
|
39
40
|
onClick={this.copy}
|
|
40
41
|
{...rest}
|
|
41
42
|
testId={testId}
|
|
@@ -54,6 +55,7 @@ CopyClipboardButton.defaultProps = {
|
|
|
54
55
|
text: null,
|
|
55
56
|
getText: null,
|
|
56
57
|
testId: 'copy-clipboard-button',
|
|
58
|
+
copyCallback: () => {},
|
|
57
59
|
};
|
|
58
60
|
|
|
59
61
|
CopyClipboardButton.propTypes = {
|
|
@@ -66,4 +68,5 @@ CopyClipboardButton.propTypes = {
|
|
|
66
68
|
copiedLabel: PropTypes.string,
|
|
67
69
|
copiedIcon: PropTypes.string,
|
|
68
70
|
icon: PropTypes.string,
|
|
71
|
+
copyCallback: PropTypes.func,
|
|
69
72
|
};
|
|
@@ -7,6 +7,17 @@ const Story = {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export default Story;
|
|
10
|
-
const Template = () =>
|
|
10
|
+
const Template = () => (
|
|
11
|
+
<div className="flex-column mbib">
|
|
12
|
+
<CopyClipboardButton type="primary" text="Text to be copied" />
|
|
13
|
+
<CopyClipboardButton
|
|
14
|
+
label="withCallback"
|
|
15
|
+
copiedLabel={null}
|
|
16
|
+
copiedIcon={null}
|
|
17
|
+
text="Text to be copied"
|
|
18
|
+
copyCallback={() => console.log('copy callback')}
|
|
19
|
+
/>
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
11
22
|
export const Default = Template.bind({});
|
|
12
23
|
Default.args = {};
|
|
@@ -23,3 +23,10 @@ it('copies the content from callback', () => {
|
|
|
23
23
|
userEvent.click(container.firstChild);
|
|
24
24
|
expect(document.execCommand).toHaveBeenCalledWith('copy');
|
|
25
25
|
});
|
|
26
|
+
|
|
27
|
+
it('copies the content and send a call back', () => {
|
|
28
|
+
const cb = jest.fn();
|
|
29
|
+
const { container } = render(<CopyClipboardButton text="text" copyCallback={cb} />);
|
|
30
|
+
userEvent.click(container.firstChild);
|
|
31
|
+
expect(cb).toHaveBeenCalledWith();
|
|
32
|
+
});
|
|
@@ -49,13 +49,15 @@ class DropdownMenu extends Component {
|
|
|
49
49
|
const childrenWithProps = mapChildrenWithProps(children, this.childrenRefs, closeCb);
|
|
50
50
|
if (isSection) {
|
|
51
51
|
return (
|
|
52
|
-
<div
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
<div className="dropdown__container">
|
|
53
|
+
<div
|
|
54
|
+
role="menu"
|
|
55
|
+
className={cl('dropdown__menu', direction, 'dropdown__menu--section')}
|
|
56
|
+
data-testid={testId}
|
|
57
|
+
{...rest}
|
|
58
|
+
>
|
|
59
|
+
{childrenWithProps}
|
|
60
|
+
</div>
|
|
59
61
|
</div>
|
|
60
62
|
);
|
|
61
63
|
}
|
|
@@ -97,7 +99,7 @@ class DropdownMenuSection extends Component {
|
|
|
97
99
|
const childrenWithProps = mapChildrenWithProps(children, this.childrenRefs, closeCb);
|
|
98
100
|
return (
|
|
99
101
|
<div className="dropdown__menu__section">
|
|
100
|
-
{title && <div className="
|
|
102
|
+
{title && <div className="dropdown__menu__item dropdown__menu__item__title">{title}</div>}
|
|
101
103
|
<ul {...rest}>{childrenWithProps}</ul>
|
|
102
104
|
</div>
|
|
103
105
|
);
|
|
@@ -134,7 +136,7 @@ class DropdownItem extends Component {
|
|
|
134
136
|
render() {
|
|
135
137
|
const { children, closeCb, testId, ...rest } = this.props;
|
|
136
138
|
return (
|
|
137
|
-
<li className={cl('
|
|
139
|
+
<li className={cl('dropdown__menu__item')} data-testid={testId} {...rest}>
|
|
138
140
|
{children}
|
|
139
141
|
</li>
|
|
140
142
|
);
|
|
@@ -166,7 +168,7 @@ class DropdownButtonItem extends Component {
|
|
|
166
168
|
render() {
|
|
167
169
|
const { onClick, btnIcon, btnLabel, isImportant, closeCb, ...rest } = this.props;
|
|
168
170
|
return (
|
|
169
|
-
<li className={cl('
|
|
171
|
+
<li className={cl('dropdown__menu__item')}>
|
|
170
172
|
<Button
|
|
171
173
|
className={cl({ 'btn--dropdown-item--important': isImportant })}
|
|
172
174
|
type="dropdown-item"
|
|
@@ -220,7 +222,7 @@ class DropdownConfirmButtonItem extends Component {
|
|
|
220
222
|
const { onConfirm, btnIcon, btnLabel, closeCb, confirmLabel, isImportant, placement, ...rest } = this.props;
|
|
221
223
|
// onConfirm and closeCb are put in this list to remove them from ...rest.
|
|
222
224
|
return (
|
|
223
|
-
<li className={cl('
|
|
225
|
+
<li className={cl('dropdown__menu__item')}>
|
|
224
226
|
<ConfirmationPopover
|
|
225
227
|
ref={this.confirmRef}
|
|
226
228
|
text={confirmLabel}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
display inline-block
|
|
4
4
|
&__separator
|
|
5
5
|
width 100%
|
|
6
|
-
border-bottom .1rem solid $
|
|
6
|
+
border-bottom .1rem solid $borderColor
|
|
7
7
|
&__menu
|
|
8
8
|
box()
|
|
9
9
|
display none
|
|
@@ -51,30 +51,31 @@
|
|
|
51
51
|
left auto
|
|
52
52
|
|
|
53
53
|
|
|
54
|
+
&__item
|
|
55
|
+
flexMiddle()
|
|
56
|
+
ellipsis()
|
|
57
|
+
height $buttonHeight + .6rem
|
|
58
|
+
.popover__child
|
|
59
|
+
width 100%
|
|
60
|
+
> :not(.btn):not(.popover__child)
|
|
61
|
+
flexMiddle()
|
|
62
|
+
ellipsis()
|
|
63
|
+
height $buttonHeight + .6rem
|
|
64
|
+
padding 0 $padding
|
|
65
|
+
width 100%
|
|
66
|
+
cursor default
|
|
67
|
+
&:hover
|
|
68
|
+
background-color $primary10
|
|
69
|
+
&:first-child
|
|
70
|
+
> *
|
|
71
|
+
border-radius $borderRadius $borderRadius 0 0
|
|
72
|
+
&:last-child
|
|
73
|
+
> *
|
|
74
|
+
border-radius 0 0 $borderRadius $borderRadius
|
|
75
|
+
&__title
|
|
76
|
+
padding 0 $padding 0 $padding
|
|
54
77
|
&.open
|
|
55
78
|
.dropdown__menu
|
|
56
79
|
display block
|
|
57
80
|
&--section
|
|
58
|
-
display flex
|
|
59
|
-
|
|
60
|
-
&__item
|
|
61
|
-
flexMiddle()
|
|
62
|
-
ellipsis()
|
|
63
|
-
height $buttonHeight + .6rem
|
|
64
|
-
.popover__child
|
|
65
|
-
width 100%
|
|
66
|
-
> :not(.btn):not(.popover__child)
|
|
67
|
-
flexMiddle()
|
|
68
|
-
ellipsis()
|
|
69
|
-
height $buttonHeight + .6rem
|
|
70
|
-
padding 0 $padding
|
|
71
|
-
width 100%
|
|
72
|
-
cursor default
|
|
73
|
-
&:hover
|
|
74
|
-
background-color $primary10
|
|
75
|
-
&:first-child
|
|
76
|
-
> *
|
|
77
|
-
border-radius $borderRadius $borderRadius 0 0
|
|
78
|
-
&:last-child
|
|
79
|
-
> *
|
|
80
|
-
border-radius 0 0 $borderRadius $borderRadius
|
|
81
|
+
display flex
|