@woosmap/ui 2.39.0 → 2.43.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/Button/Button.js +4 -0
- package/src/components/Button/Button.stories.js +1 -1
- package/src/components/Button/Button.test.js +3 -3
- package/src/components/Button/ButtonGroup.js +4 -1
- package/src/components/Button/ButtonSwitch.js +4 -2
- package/src/components/Button/ButtonWithDropdown.js +22 -8
- package/src/components/Button/ButtonWithDropdown.test.js +35 -0
- package/src/components/Card/Card.js +5 -0
- package/src/components/Card/Card.test.js +3 -3
- package/src/components/Card/SimpleCard.js +25 -5
- package/src/components/Card/SimpleCard.test.js +2 -2
- package/src/components/CopyClipboardButton/CopyClipboardButton.js +4 -1
- package/src/components/CopyClipboardButton/CopyToClipboard.test.js +2 -2
- package/src/components/Demo/SearchDemo.js +1 -0
- package/src/components/Dropdown/Dropdown.js +30 -5
- package/src/components/Dropdown/Dropdown.test.js +2 -2
- package/src/components/DynamicTag/DynamicTag.js +8 -4
- package/src/components/Flash/Flash.js +4 -1
- package/src/components/Icon/Icon.js +45 -21
- package/src/components/Icon/Icon.test.js +4 -4
- package/src/components/InfoMessage/InfoMessage.js +5 -2
- package/src/components/InfoMessage/InfoMessage.test.js +2 -2
- package/src/components/Input/Input.test.js +26 -0
- package/src/components/Label/Label.js +18 -3
- package/src/components/Label/Label.styl +1 -1
- package/src/components/Modal/ConfirmationModal.js +4 -1
- package/src/components/Modal/Modal.js +13 -6
- package/src/components/Modal/Modal.test.js +3 -3
- package/src/components/Panel/Panel.js +5 -3
- package/src/components/Panel/Panel.test.js +2 -2
- package/src/components/Popover/ConfirmationPopover.js +5 -3
- package/src/components/ScrollBar/ScrollBar.js +4 -1
- package/src/components/ScrollBar/ScrollBar.test.js +2 -2
- package/src/components/ServiceMessage/ServiceMessage.js +8 -4
- package/src/components/SnackBar/SnackBar.test.js +2 -2
- package/src/components/Tab/Tab.js +6 -3
- package/src/components/Tab/Tab.test.js +9 -9
- package/src/components/Tooltip/Tooltip.js +4 -2
- package/src/components/Tooltip/Tooltip.test.js +4 -4
- package/src/components/withFormValidation/withFormValidation.test.js +1 -5
- package/src/icons/autocomplete.svg +1 -0
- package/src/icons/buildings.svg +1 -0
- package/src/icons/github.svg +1 -0
- package/src/icons/position.svg +1 -0
- package/src/icons/quote.svg +1 -0
- package/src/icons/save-money.svg +1 -0
- package/src/icons/world.svg +1 -0
- package/src/styles/console/button.styl +69 -43
- package/src/styles/console/mixins.styl +2 -2
- package/src/styles/console/select.styl +0 -1
- package/src/styles/style-next-website.styl +25 -0
package/package.json
CHANGED
|
@@ -24,6 +24,7 @@ export default class Button extends Component {
|
|
|
24
24
|
isLoading,
|
|
25
25
|
active,
|
|
26
26
|
children,
|
|
27
|
+
testId,
|
|
27
28
|
...rest
|
|
28
29
|
} = this.props;
|
|
29
30
|
const classes = cl(
|
|
@@ -51,6 +52,7 @@ export default class Button extends Component {
|
|
|
51
52
|
onClick={isLoading || disabled ? undefined : onClick}
|
|
52
53
|
{...rest}
|
|
53
54
|
className={classes}
|
|
55
|
+
data-testid={testId}
|
|
54
56
|
>
|
|
55
57
|
{iconComponent}
|
|
56
58
|
{label && <span className="btn__label">{isLoading ? tr('Loading...') : label}</span>}
|
|
@@ -61,6 +63,7 @@ export default class Button extends Component {
|
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
Button.defaultProps = {
|
|
66
|
+
testId: 'button',
|
|
64
67
|
isBtnIcon: false,
|
|
65
68
|
disabled: false,
|
|
66
69
|
children: null,
|
|
@@ -76,6 +79,7 @@ Button.defaultProps = {
|
|
|
76
79
|
};
|
|
77
80
|
|
|
78
81
|
Button.propTypes = {
|
|
82
|
+
testId: PropTypes.string,
|
|
79
83
|
isBtnIcon: PropTypes.bool,
|
|
80
84
|
disabled: PropTypes.bool,
|
|
81
85
|
size: PropTypes.oneOf(['large', 'small', 'mini', undefined]),
|
|
@@ -209,7 +209,7 @@ const TemplateBtnWithDropdown = () => {
|
|
|
209
209
|
],
|
|
210
210
|
dropdownDirection: 'se',
|
|
211
211
|
};
|
|
212
|
-
return <ButtonWithDropdown {...args} />;
|
|
212
|
+
return <ButtonWithDropdown disabled {...args} />;
|
|
213
213
|
};
|
|
214
214
|
export const WithDropdown = TemplateBtnWithDropdown.bind({});
|
|
215
215
|
|
|
@@ -12,8 +12,8 @@ it('renders a Button component ', () => {
|
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
it('renders a small Button', () => {
|
|
15
|
-
const {
|
|
16
|
-
expect(
|
|
15
|
+
const { getByTestId } = render(<Button label="label" size="small" />);
|
|
16
|
+
expect(getByTestId('button')).toHaveClass('btn--small');
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
it('renders a mini Button', () => {
|
|
@@ -23,7 +23,7 @@ it('renders a mini Button', () => {
|
|
|
23
23
|
|
|
24
24
|
it('renders a loading Button', () => {
|
|
25
25
|
const { container } = render(<Button label="label" isLoading />);
|
|
26
|
-
expect(container.firstChild).toHaveClass('btn--loading')
|
|
26
|
+
expect(container.firstChild).toHaveClass('btn--loading');
|
|
27
27
|
expect(container.firstChild.firstChild).toHaveClass('icon');
|
|
28
28
|
});
|
|
29
29
|
|
|
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
|
|
5
5
|
export default class ButtonGroup extends Component {
|
|
6
6
|
render() {
|
|
7
|
-
const { children, isLight, isTooltipBtn, ...rest } = this.props;
|
|
7
|
+
const { children, isLight, isTooltipBtn, testId, ...rest } = this.props;
|
|
8
8
|
return (
|
|
9
9
|
<div
|
|
10
10
|
className={cl(
|
|
@@ -13,6 +13,7 @@ export default class ButtonGroup extends Component {
|
|
|
13
13
|
{ 'btn--group-container--btn-tooltip': isTooltipBtn }
|
|
14
14
|
)}
|
|
15
15
|
{...rest}
|
|
16
|
+
data-testid={testId}
|
|
16
17
|
>
|
|
17
18
|
{children}
|
|
18
19
|
</div>
|
|
@@ -21,12 +22,14 @@ export default class ButtonGroup extends Component {
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
ButtonGroup.defaultProps = {
|
|
25
|
+
testId: 'button-group',
|
|
24
26
|
children: null,
|
|
25
27
|
isLight: false,
|
|
26
28
|
isTooltipBtn: false,
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
ButtonGroup.propTypes = {
|
|
32
|
+
testId: PropTypes.string,
|
|
30
33
|
children: PropTypes.array,
|
|
31
34
|
isLight: PropTypes.bool,
|
|
32
35
|
isTooltipBtn: PropTypes.bool,
|
|
@@ -4,13 +4,14 @@ import Button from './Button';
|
|
|
4
4
|
|
|
5
5
|
export default class ButtonSwitch extends Component {
|
|
6
6
|
render() {
|
|
7
|
-
const { active, icon, activeIcon, iconSize } = this.props;
|
|
7
|
+
const { active, icon, activeIcon, iconSize, testId } = this.props;
|
|
8
8
|
const iconToDisplay = active && activeIcon ? activeIcon : icon;
|
|
9
|
-
return <Button iconSize={iconSize} type="switch" {...this.props} icon={iconToDisplay} />;
|
|
9
|
+
return <Button iconSize={iconSize} type="switch" {...this.props} icon={iconToDisplay} testId={testId} />;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
ButtonSwitch.defaultProps = {
|
|
14
|
+
testId: 'button-switch',
|
|
14
15
|
isBtnIcon: false,
|
|
15
16
|
disabled: false,
|
|
16
17
|
children: null,
|
|
@@ -26,6 +27,7 @@ ButtonSwitch.defaultProps = {
|
|
|
26
27
|
};
|
|
27
28
|
|
|
28
29
|
ButtonSwitch.propTypes = {
|
|
30
|
+
testId: PropTypes.string,
|
|
29
31
|
isBtnIcon: PropTypes.bool,
|
|
30
32
|
disabled: PropTypes.bool,
|
|
31
33
|
size: PropTypes.oneOf(['large', 'small', 'mini', undefined]),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
2
|
+
import PropTypes, { bool } from 'prop-types';
|
|
3
3
|
import uniqueid from '../uniqueid';
|
|
4
4
|
import Dropdown from '../Dropdown/Dropdown';
|
|
5
5
|
import Button from './Button';
|
|
@@ -9,30 +9,40 @@ class ButtonWithDropdown extends Component {
|
|
|
9
9
|
const { dropdownItems } = this.props;
|
|
10
10
|
return dropdownItems.map((item) => (
|
|
11
11
|
<React.Fragment key={`dropdown-${item.type || 'item'}-${uniqueid('')}`}>
|
|
12
|
-
{item.separatorTop && <Dropdown.Separator />}
|
|
12
|
+
{item.separatorTop && <Dropdown.Separator testId={item.testId} />}
|
|
13
13
|
{item.type === 'confirm' && (
|
|
14
14
|
<Dropdown.ConfirmButtonItem
|
|
15
15
|
btnIcon={item.icon}
|
|
16
16
|
btnLabel={item.label}
|
|
17
17
|
confirmLabel={item.confirmLabel}
|
|
18
18
|
onConfirm={item.onConfirm}
|
|
19
|
+
testId={item.testId}
|
|
19
20
|
/>
|
|
20
21
|
)}
|
|
21
22
|
{item.type === 'button' && (
|
|
22
|
-
<Dropdown.ButtonItem
|
|
23
|
+
<Dropdown.ButtonItem
|
|
24
|
+
btnIcon={item.icon}
|
|
25
|
+
btnLabel={item.label}
|
|
26
|
+
onClick={item.onClick}
|
|
27
|
+
testId={item.testId}
|
|
28
|
+
/>
|
|
29
|
+
)}
|
|
30
|
+
{(item.type === 'item' || !item.type) && (
|
|
31
|
+
<Dropdown.Item testId={item.testId}>{item.label}</Dropdown.Item>
|
|
23
32
|
)}
|
|
24
|
-
{(item.type === 'item' || !item.type) && <Dropdown.Item>{item.label}</Dropdown.Item>}
|
|
25
33
|
</React.Fragment>
|
|
26
34
|
));
|
|
27
35
|
};
|
|
28
36
|
|
|
29
37
|
render() {
|
|
30
|
-
const { btnProps, dropdownProps, dropdownDirection } = this.props;
|
|
38
|
+
const { btnProps, dropdownProps, dropdownDirection, testId, disabled } = this.props;
|
|
31
39
|
return (
|
|
32
40
|
<div className="btn--multi-options">
|
|
33
|
-
<Button {...btnProps} />
|
|
34
|
-
<Dropdown {...dropdownProps}>
|
|
35
|
-
<Dropdown.Menu direction={dropdownDirection}
|
|
41
|
+
<Button disabled={disabled} {...btnProps} testId={`${testId}-button`} />
|
|
42
|
+
<Dropdown disabled={disabled} {...dropdownProps} testId={`${testId}-dropdown`}>
|
|
43
|
+
<Dropdown.Menu direction={dropdownDirection} testId={`${testId}-menu`}>
|
|
44
|
+
{this.renderDropdown()}
|
|
45
|
+
</Dropdown.Menu>
|
|
36
46
|
</Dropdown>
|
|
37
47
|
</div>
|
|
38
48
|
);
|
|
@@ -40,17 +50,21 @@ class ButtonWithDropdown extends Component {
|
|
|
40
50
|
}
|
|
41
51
|
|
|
42
52
|
ButtonWithDropdown.propTypes = {
|
|
53
|
+
testId: PropTypes.string,
|
|
43
54
|
btnProps: PropTypes.object,
|
|
44
55
|
dropdownProps: PropTypes.object,
|
|
45
56
|
dropdownDirection: PropTypes.string,
|
|
46
57
|
dropdownItems: PropTypes.array,
|
|
58
|
+
disabled: bool,
|
|
47
59
|
};
|
|
48
60
|
|
|
49
61
|
ButtonWithDropdown.defaultProps = {
|
|
62
|
+
testId: 'button-with-dropdown',
|
|
50
63
|
btnProps: {},
|
|
51
64
|
dropdownProps: {},
|
|
52
65
|
dropdownItems: [],
|
|
53
66
|
dropdownDirection: 'se',
|
|
67
|
+
disabled: false,
|
|
54
68
|
};
|
|
55
69
|
|
|
56
70
|
export default ButtonWithDropdown;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
+
import 'resize-observer-polyfill/dist/ResizeObserver.global';
|
|
5
|
+
|
|
6
|
+
import ButtonWithDropdown from './ButtonWithDropdown';
|
|
7
|
+
|
|
8
|
+
it('renders a small Button', () => {
|
|
9
|
+
const args = {
|
|
10
|
+
btnProps: {
|
|
11
|
+
label: 'Button',
|
|
12
|
+
},
|
|
13
|
+
dropdownProps: {
|
|
14
|
+
btnFace: 'primary',
|
|
15
|
+
},
|
|
16
|
+
dropdownItems: [
|
|
17
|
+
{
|
|
18
|
+
label: 'dropdown item',
|
|
19
|
+
type: 'item',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: 'dropdown confirm button',
|
|
23
|
+
confirmLabel: 'Are you sure?',
|
|
24
|
+
type: 'confirm',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
label: 'dropdown button',
|
|
28
|
+
type: 'button',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
dropdownDirection: 'se',
|
|
32
|
+
};
|
|
33
|
+
const { getByTestId } = render(<ButtonWithDropdown {...args} />);
|
|
34
|
+
expect(getByTestId('button-with-dropdown-dropdown')).toBeInTheDocument();
|
|
35
|
+
});
|
|
@@ -59,6 +59,7 @@ const productImgSm = {
|
|
|
59
59
|
TRAFFIC: trafficImgSm,
|
|
60
60
|
MERCHANTS: merchantImgSm,
|
|
61
61
|
};
|
|
62
|
+
|
|
62
63
|
class Header extends Component {
|
|
63
64
|
render() {
|
|
64
65
|
const { children, ...rest } = this.props;
|
|
@@ -118,6 +119,7 @@ class Card extends Component {
|
|
|
118
119
|
onClick,
|
|
119
120
|
useIcon,
|
|
120
121
|
size,
|
|
122
|
+
testId,
|
|
121
123
|
isNew,
|
|
122
124
|
...rest
|
|
123
125
|
} = this.props;
|
|
@@ -154,6 +156,7 @@ class Card extends Component {
|
|
|
154
156
|
onClick={onClick}
|
|
155
157
|
onKeyDown={onClick}
|
|
156
158
|
tabIndex="0"
|
|
159
|
+
data-testid={testId}
|
|
157
160
|
>
|
|
158
161
|
<div className={itemClass}>
|
|
159
162
|
{useIcon ? (
|
|
@@ -184,10 +187,12 @@ Card.defaultProps = {
|
|
|
184
187
|
isClickable: false,
|
|
185
188
|
noBorder: false,
|
|
186
189
|
isNew: false,
|
|
190
|
+
testId: 'card',
|
|
187
191
|
};
|
|
188
192
|
|
|
189
193
|
Card.propTypes = {
|
|
190
194
|
size: PropTypes.oneOf(['small', 'large', 'normal']),
|
|
195
|
+
testId: PropTypes.string,
|
|
191
196
|
children: PropTypes.node.isRequired,
|
|
192
197
|
useIcon: PropTypes.bool,
|
|
193
198
|
className: PropTypes.string,
|
|
@@ -5,15 +5,15 @@ import '@testing-library/jest-dom/extend-expect';
|
|
|
5
5
|
import Card from './Card';
|
|
6
6
|
|
|
7
7
|
it('renders a Card component ', () => {
|
|
8
|
-
const {
|
|
8
|
+
const { getByTestId } = render(
|
|
9
9
|
<Card>
|
|
10
10
|
<Card.Header>header</Card.Header>
|
|
11
11
|
<Card.Body>body</Card.Body>
|
|
12
12
|
<Card.Footer>footer</Card.Footer>
|
|
13
13
|
</Card>
|
|
14
14
|
);
|
|
15
|
-
expect(
|
|
16
|
-
expect(
|
|
15
|
+
expect(getByTestId('card')).toHaveClass('card');
|
|
16
|
+
expect(getByTestId('card').firstChild).toHaveClass('card__image');
|
|
17
17
|
expect(screen.getByText('header')).toHaveClass('card__header');
|
|
18
18
|
expect(screen.getByText('body')).toHaveClass('card__body');
|
|
19
19
|
expect(screen.getByText('footer')).toHaveClass('card__footer');
|
|
@@ -7,7 +7,7 @@ import { tr } from '../utils/locale';
|
|
|
7
7
|
|
|
8
8
|
class SimpleCard extends Component {
|
|
9
9
|
render() {
|
|
10
|
-
const { title, subtitle, className, children, isSelected, isActive, isDisabled, isFavorite, ...rest } =
|
|
10
|
+
const { title, subtitle, className, testId, children, isSelected, isActive, isDisabled, isFavorite, ...rest } =
|
|
11
11
|
this.props;
|
|
12
12
|
return (
|
|
13
13
|
<div
|
|
@@ -18,14 +18,32 @@ class SimpleCard extends Component {
|
|
|
18
18
|
{ 'simplecard--selected': isSelected },
|
|
19
19
|
className
|
|
20
20
|
)}
|
|
21
|
+
data-testid={testId}
|
|
21
22
|
{...rest}
|
|
22
23
|
>
|
|
23
|
-
{title &&
|
|
24
|
+
{title && (
|
|
25
|
+
<div className="simplecard__title" data-testid={`${testId}-title`}>
|
|
26
|
+
{title}
|
|
27
|
+
</div>
|
|
28
|
+
)}
|
|
24
29
|
{isFavorite && (
|
|
25
|
-
<Icon
|
|
30
|
+
<Icon
|
|
31
|
+
className="simplecard__favorite"
|
|
32
|
+
title={tr('Favorite project')}
|
|
33
|
+
icon="star-filled"
|
|
34
|
+
data-testid={`${testId}-icon`}
|
|
35
|
+
/>
|
|
36
|
+
)}
|
|
37
|
+
{subtitle && (
|
|
38
|
+
<div className="simplecard__subtitle" data-testid={`${testId}-subtitle`}>
|
|
39
|
+
{subtitle}
|
|
40
|
+
</div>
|
|
41
|
+
)}
|
|
42
|
+
{children && (
|
|
43
|
+
<div className="simplecard__content" data-testid={`${testId}-content`}>
|
|
44
|
+
{children}
|
|
45
|
+
</div>
|
|
26
46
|
)}
|
|
27
|
-
{subtitle && <div className="simplecard__subtitle">{subtitle}</div>}
|
|
28
|
-
{children && <div className="simplecard__content">{children}</div>}
|
|
29
47
|
</div>
|
|
30
48
|
);
|
|
31
49
|
}
|
|
@@ -35,6 +53,7 @@ SimpleCard.defaultProps = {
|
|
|
35
53
|
title: '',
|
|
36
54
|
subtitle: '',
|
|
37
55
|
className: '',
|
|
56
|
+
testId: 'simple-card',
|
|
38
57
|
children: null,
|
|
39
58
|
isSelected: false,
|
|
40
59
|
isActive: false,
|
|
@@ -50,6 +69,7 @@ SimpleCard.propTypes = {
|
|
|
50
69
|
title: PropTypes.string,
|
|
51
70
|
subtitle: PropTypes.string,
|
|
52
71
|
className: PropTypes.string,
|
|
72
|
+
testId: PropTypes.string,
|
|
53
73
|
isFavorite: PropTypes.bool,
|
|
54
74
|
};
|
|
55
75
|
|
|
@@ -5,12 +5,12 @@ import '@testing-library/jest-dom/extend-expect';
|
|
|
5
5
|
import SimpleCard from './SimpleCard';
|
|
6
6
|
|
|
7
7
|
it('renders a SimpleCard component ', () => {
|
|
8
|
-
const {
|
|
8
|
+
const { getByTestId } = render(
|
|
9
9
|
<SimpleCard title="title" subtitle="subtitle">
|
|
10
10
|
Content
|
|
11
11
|
</SimpleCard>
|
|
12
12
|
);
|
|
13
|
-
expect(
|
|
13
|
+
expect(getByTestId('simple-card')).toHaveClass('simplecard');
|
|
14
14
|
expect(screen.getByText('title')).toHaveClass('simplecard__title');
|
|
15
15
|
expect(screen.getByText('subtitle')).toHaveClass('simplecard__subtitle');
|
|
16
16
|
expect(screen.getByText('Content')).toHaveClass('simplecard__content');
|
|
@@ -29,7 +29,7 @@ export default class CopyClipboardButton extends Component {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
render() {
|
|
32
|
-
const { type, noLabel, label, copiedLabel, copiedIcon, icon, getText, ...rest } = this.props;
|
|
32
|
+
const { type, noLabel, label, copiedLabel, copiedIcon, icon, getText, testId, ...rest } = this.props;
|
|
33
33
|
const { copied } = this.state;
|
|
34
34
|
return (
|
|
35
35
|
<Button
|
|
@@ -38,6 +38,7 @@ export default class CopyClipboardButton extends Component {
|
|
|
38
38
|
icon={copied ? copiedIcon : icon}
|
|
39
39
|
onClick={this.copy}
|
|
40
40
|
{...rest}
|
|
41
|
+
testId={testId}
|
|
41
42
|
/>
|
|
42
43
|
);
|
|
43
44
|
}
|
|
@@ -52,10 +53,12 @@ CopyClipboardButton.defaultProps = {
|
|
|
52
53
|
icon: 'copy',
|
|
53
54
|
text: null,
|
|
54
55
|
getText: null,
|
|
56
|
+
testId: 'copy-clipboard-button',
|
|
55
57
|
};
|
|
56
58
|
|
|
57
59
|
CopyClipboardButton.propTypes = {
|
|
58
60
|
text: PropTypes.string,
|
|
61
|
+
testId: PropTypes.string,
|
|
59
62
|
getText: PropTypes.func,
|
|
60
63
|
type: PropTypes.string,
|
|
61
64
|
label: PropTypes.string,
|
|
@@ -6,8 +6,8 @@ import '@testing-library/jest-dom/extend-expect';
|
|
|
6
6
|
import CopyClipboardButton from './CopyClipboardButton';
|
|
7
7
|
|
|
8
8
|
it('renders a CopyClipboardButton component ', () => {
|
|
9
|
-
const {
|
|
10
|
-
expect(
|
|
9
|
+
const { getByTestId } = render(<CopyClipboardButton text="Text" />);
|
|
10
|
+
expect(getByTestId('copy-clipboard-button')).toHaveClass('btn');
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
it('copies the content', () => {
|
|
@@ -11,6 +11,7 @@ import { tr } from '../utils/locale';
|
|
|
11
11
|
import markerIcon from '../../images/marker.png';
|
|
12
12
|
import markerIconAlt from '../../images/marker-alt.png';
|
|
13
13
|
import Script from '../utils/Script';
|
|
14
|
+
import 'resize-observer-polyfill/dist/ResizeObserver.global';
|
|
14
15
|
|
|
15
16
|
export default class SearchDemo extends Component {
|
|
16
17
|
constructor(props) {
|
|
@@ -45,11 +45,11 @@ class DropdownMenu extends Component {
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
render() {
|
|
48
|
-
const { direction, children, closeCb, ...rest } = this.props;
|
|
48
|
+
const { direction, children, closeCb, testId, ...rest } = this.props;
|
|
49
49
|
const childrenWithProps = mapChildrenWithProps(children, this.childrenRefs, closeCb);
|
|
50
50
|
|
|
51
51
|
return (
|
|
52
|
-
<ul role="menu" className={cl('dropdown__menu', direction)} {...rest}>
|
|
52
|
+
<ul role="menu" className={cl('dropdown__menu', direction)} data-testid={testId} {...rest}>
|
|
53
53
|
{childrenWithProps}
|
|
54
54
|
</ul>
|
|
55
55
|
);
|
|
@@ -59,25 +59,36 @@ class DropdownMenu extends Component {
|
|
|
59
59
|
DropdownMenu.defaultProps = {
|
|
60
60
|
direction: 'sw',
|
|
61
61
|
closeCb: null,
|
|
62
|
+
testId: 'dropdown-menu',
|
|
62
63
|
};
|
|
63
64
|
|
|
64
65
|
DropdownMenu.propTypes = {
|
|
65
66
|
children: PropTypes.node.isRequired,
|
|
66
67
|
closeCb: PropTypes.func,
|
|
68
|
+
testId: PropTypes.string,
|
|
67
69
|
direction: PropTypes.oneOf(['ne', 'e', 'se', 's', 'sw', 'w']),
|
|
68
70
|
};
|
|
69
71
|
|
|
70
72
|
class DropdownSeparator extends Component {
|
|
71
73
|
render() {
|
|
72
|
-
|
|
74
|
+
const { testId } = this.props;
|
|
75
|
+
return <li className={cl('dropdown__separator')} data-testid={testId} />;
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
78
|
|
|
79
|
+
DropdownSeparator.defaultProps = {
|
|
80
|
+
testId: 'dropdown-separator',
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
DropdownSeparator.propTypes = {
|
|
84
|
+
testId: PropTypes.string,
|
|
85
|
+
};
|
|
86
|
+
|
|
76
87
|
class DropdownItem extends Component {
|
|
77
88
|
render() {
|
|
78
|
-
const { children, closeCb, ...rest } = this.props;
|
|
89
|
+
const { children, closeCb, testId, ...rest } = this.props;
|
|
79
90
|
return (
|
|
80
|
-
<li className={cl('dropdown__item')} {...rest}>
|
|
91
|
+
<li className={cl('dropdown__item')} data-testid={testId} {...rest}>
|
|
81
92
|
{children}
|
|
82
93
|
</li>
|
|
83
94
|
);
|
|
@@ -86,11 +97,13 @@ class DropdownItem extends Component {
|
|
|
86
97
|
|
|
87
98
|
DropdownItem.defaultProps = {
|
|
88
99
|
closeCb: null,
|
|
100
|
+
testId: 'dropdown-item',
|
|
89
101
|
};
|
|
90
102
|
|
|
91
103
|
DropdownItem.propTypes = {
|
|
92
104
|
children: PropTypes.node.isRequired,
|
|
93
105
|
closeCb: PropTypes.func,
|
|
106
|
+
testId: PropTypes.string,
|
|
94
107
|
};
|
|
95
108
|
|
|
96
109
|
class DropdownButtonItem extends Component {
|
|
@@ -125,6 +138,7 @@ DropdownButtonItem.defaultProps = {
|
|
|
125
138
|
onClick: null,
|
|
126
139
|
btnIcon: null,
|
|
127
140
|
btnLabel: '',
|
|
141
|
+
testId: 'dropdown-button-item',
|
|
128
142
|
isImportant: false,
|
|
129
143
|
closeCb: null,
|
|
130
144
|
};
|
|
@@ -133,6 +147,7 @@ DropdownButtonItem.propTypes = {
|
|
|
133
147
|
onClick: PropTypes.func,
|
|
134
148
|
btnIcon: PropTypes.string,
|
|
135
149
|
btnLabel: PropTypes.string,
|
|
150
|
+
testId: PropTypes.string,
|
|
136
151
|
isImportant: PropTypes.bool,
|
|
137
152
|
closeCb: PropTypes.func,
|
|
138
153
|
};
|
|
@@ -183,6 +198,7 @@ class DropdownConfirmButtonItem extends Component {
|
|
|
183
198
|
}
|
|
184
199
|
|
|
185
200
|
DropdownConfirmButtonItem.defaultProps = {
|
|
201
|
+
testId: 'dropdown-confirm-button-item',
|
|
186
202
|
onConfirm: null,
|
|
187
203
|
btnIcon: null,
|
|
188
204
|
closeCb: null,
|
|
@@ -195,6 +211,7 @@ DropdownConfirmButtonItem.defaultProps = {
|
|
|
195
211
|
DropdownConfirmButtonItem.propTypes = {
|
|
196
212
|
onConfirm: PropTypes.func,
|
|
197
213
|
btnIcon: PropTypes.string,
|
|
214
|
+
testId: PropTypes.string,
|
|
198
215
|
confirmLabel: PropTypes.string,
|
|
199
216
|
btnLabel: PropTypes.string,
|
|
200
217
|
closeCb: PropTypes.func,
|
|
@@ -246,6 +263,7 @@ class Dropdown extends Component {
|
|
|
246
263
|
const {
|
|
247
264
|
children,
|
|
248
265
|
size,
|
|
266
|
+
disabled,
|
|
249
267
|
className,
|
|
250
268
|
label,
|
|
251
269
|
btnFace,
|
|
@@ -254,6 +272,7 @@ class Dropdown extends Component {
|
|
|
254
272
|
btnFaceIconSize,
|
|
255
273
|
closeCb,
|
|
256
274
|
disableCloseOutside,
|
|
275
|
+
testId,
|
|
257
276
|
...rest
|
|
258
277
|
} = this.props;
|
|
259
278
|
const { open } = this.state;
|
|
@@ -266,6 +285,7 @@ class Dropdown extends Component {
|
|
|
266
285
|
{...rest}
|
|
267
286
|
>
|
|
268
287
|
<Button
|
|
288
|
+
disabled={disabled}
|
|
269
289
|
type={btnFace}
|
|
270
290
|
onClick={this.onClick}
|
|
271
291
|
onDoubleClick={this.onDoubleClick}
|
|
@@ -273,6 +293,7 @@ class Dropdown extends Component {
|
|
|
273
293
|
size={btnSize}
|
|
274
294
|
iconSize={btnFaceIconSize}
|
|
275
295
|
label={label}
|
|
296
|
+
testId={testId}
|
|
276
297
|
/>
|
|
277
298
|
{childrenWithProps}
|
|
278
299
|
</div>
|
|
@@ -284,6 +305,7 @@ Dropdown.defaultProps = {
|
|
|
284
305
|
size: 'normal',
|
|
285
306
|
btnSize: null,
|
|
286
307
|
onClick: null,
|
|
308
|
+
disabled: false,
|
|
287
309
|
disableCloseOutside: false,
|
|
288
310
|
onDoubleClick: null,
|
|
289
311
|
label: null,
|
|
@@ -292,14 +314,17 @@ Dropdown.defaultProps = {
|
|
|
292
314
|
btnFace: 'link-flex',
|
|
293
315
|
btnFaceIcon: 'caret-bottom',
|
|
294
316
|
btnFaceIconSize: 24,
|
|
317
|
+
testId: 'dropdown',
|
|
295
318
|
};
|
|
296
319
|
|
|
297
320
|
Dropdown.propTypes = {
|
|
298
321
|
onClick: PropTypes.func,
|
|
299
322
|
closeCb: PropTypes.func,
|
|
300
323
|
onDoubleClick: PropTypes.func,
|
|
324
|
+
disabled: PropTypes.bool,
|
|
301
325
|
disableCloseOutside: PropTypes.bool,
|
|
302
326
|
label: PropTypes.string,
|
|
327
|
+
testId: PropTypes.string,
|
|
303
328
|
children: PropTypes.node.isRequired,
|
|
304
329
|
className: PropTypes.string,
|
|
305
330
|
btnFace: PropTypes.oneOf(['link-flex', 'primary', 'secondary', 'important', 'transparent', 'link']),
|
|
@@ -7,14 +7,14 @@ import 'resize-observer-polyfill/dist/ResizeObserver.global';
|
|
|
7
7
|
import Dropdown from './Dropdown';
|
|
8
8
|
|
|
9
9
|
it('renders a Dropdown component ', () => {
|
|
10
|
-
const {
|
|
10
|
+
const { getByTestId } = render(
|
|
11
11
|
<Dropdown label="My dropdown">
|
|
12
12
|
<Dropdown.Menu>
|
|
13
13
|
<Dropdown.Item>Item 1</Dropdown.Item>
|
|
14
14
|
</Dropdown.Menu>
|
|
15
15
|
</Dropdown>
|
|
16
16
|
);
|
|
17
|
-
expect(
|
|
17
|
+
expect(getByTestId('dropdown').parentElement).toHaveClass('dropdown');
|
|
18
18
|
const menu = screen.getByRole('menu');
|
|
19
19
|
expect(menu).toHaveClass('dropdown__menu');
|
|
20
20
|
});
|
|
@@ -50,7 +50,7 @@ export default class DynamicTag extends Component {
|
|
|
50
50
|
|
|
51
51
|
renderInput = () => {
|
|
52
52
|
const { inputValue, error } = this.state;
|
|
53
|
-
const { placeholder } = this.props;
|
|
53
|
+
const { placeholder, testId } = this.props;
|
|
54
54
|
|
|
55
55
|
return (
|
|
56
56
|
<>
|
|
@@ -61,17 +61,18 @@ export default class DynamicTag extends Component {
|
|
|
61
61
|
onBlur={this.handleInputConfirm}
|
|
62
62
|
onPressEnter={this.handleInputConfirm}
|
|
63
63
|
error={error}
|
|
64
|
+
testId={`${testId}-input`}
|
|
64
65
|
/>
|
|
65
|
-
<Button label={tr('Add')} onClick={this.handleInputConfirm} />
|
|
66
|
+
<Button label={tr('Add')} onClick={this.handleInputConfirm} testId={`${testId}-button`} />
|
|
66
67
|
</>
|
|
67
68
|
);
|
|
68
69
|
};
|
|
69
70
|
|
|
70
71
|
render() {
|
|
71
72
|
const { tags } = this.state;
|
|
72
|
-
const { color } = this.props;
|
|
73
|
+
const { color, testId } = this.props;
|
|
73
74
|
return (
|
|
74
|
-
<div className={cl('dynamic-tag')}>
|
|
75
|
+
<div className={cl('dynamic-tag')} data-testid={testId}>
|
|
75
76
|
<div className={cl('dynamic-tag__input')}>{this.renderInput()}</div>
|
|
76
77
|
<div className={cl('dynamic-tag__tags')}>
|
|
77
78
|
{tags.map((item) => (
|
|
@@ -83,6 +84,7 @@ export default class DynamicTag extends Component {
|
|
|
83
84
|
closeCb={() => {
|
|
84
85
|
this.handleTagRemove(item);
|
|
85
86
|
}}
|
|
87
|
+
testId={`${testId}-label`}
|
|
86
88
|
/>
|
|
87
89
|
))}
|
|
88
90
|
</div>
|
|
@@ -95,10 +97,12 @@ DynamicTag.defaultProps = {
|
|
|
95
97
|
defaultTags: [],
|
|
96
98
|
placeholder: '',
|
|
97
99
|
color: '',
|
|
100
|
+
testId: 'dynamic-tag',
|
|
98
101
|
};
|
|
99
102
|
|
|
100
103
|
DynamicTag.propTypes = {
|
|
101
104
|
defaultTags: PropTypes.array,
|
|
102
105
|
placeholder: PropTypes.string,
|
|
103
106
|
color: PropTypes.string,
|
|
107
|
+
testId: PropTypes.string,
|
|
104
108
|
};
|