@woosmap/ui 2.42.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 +1 -1
- package/src/components/Button/Button.js +4 -0
- 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 +19 -7
- 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/DistanceDemo.js +2 -1
- package/src/components/Demo/GeolocationDemo.js +9 -12
- package/src/components/Demo/LocalitiesAddressDemo.js +2 -1
- package/src/components/Demo/LocalitiesDemo.js +2 -2
- package/src/components/Demo/SearchDemo.js +3 -1
- package/src/components/Dropdown/Dropdown.js +74 -6
- package/src/components/Dropdown/Dropdown.stories.js +29 -0
- package/src/components/Dropdown/Dropdown.styl +3 -0
- 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 +51 -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/Map/drawOnMap.js +40 -0
- 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/social-facebook.svg +1 -0
- package/src/icons/social-linkedin.svg +1 -0
- package/src/icons/social-twitter.svg +1 -0
- package/src/icons/world.svg +1 -0
- package/src/images/marker-dot.svg +15 -0
- package/src/styles/commons/base.styl +6 -6
- package/src/styles/style-next-website.styl +25 -0
|
@@ -45,11 +45,22 @@ 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, 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
|
-
<ul role="menu" className={cl('dropdown__menu', direction)} {...rest}>
|
|
63
|
+
<ul role="menu" className={cl('dropdown__menu', direction)} data-testid={testId} {...rest}>
|
|
53
64
|
{childrenWithProps}
|
|
54
65
|
</ul>
|
|
55
66
|
);
|
|
@@ -59,25 +70,71 @@ class DropdownMenu extends Component {
|
|
|
59
70
|
DropdownMenu.defaultProps = {
|
|
60
71
|
direction: 'sw',
|
|
61
72
|
closeCb: null,
|
|
73
|
+
testId: 'dropdown-menu',
|
|
74
|
+
isSection: false,
|
|
62
75
|
};
|
|
63
76
|
|
|
64
77
|
DropdownMenu.propTypes = {
|
|
65
78
|
children: PropTypes.node.isRequired,
|
|
66
79
|
closeCb: PropTypes.func,
|
|
80
|
+
testId: PropTypes.string,
|
|
81
|
+
isSection: PropTypes.bool,
|
|
67
82
|
direction: PropTypes.oneOf(['ne', 'e', 'se', 's', 'sw', 'w']),
|
|
68
83
|
};
|
|
69
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
|
+
|
|
70
118
|
class DropdownSeparator extends Component {
|
|
71
119
|
render() {
|
|
72
|
-
|
|
120
|
+
const { testId } = this.props;
|
|
121
|
+
return <li className={cl('dropdown__separator')} data-testid={testId} />;
|
|
73
122
|
}
|
|
74
123
|
}
|
|
75
124
|
|
|
125
|
+
DropdownSeparator.defaultProps = {
|
|
126
|
+
testId: 'dropdown-separator',
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
DropdownSeparator.propTypes = {
|
|
130
|
+
testId: PropTypes.string,
|
|
131
|
+
};
|
|
132
|
+
|
|
76
133
|
class DropdownItem extends Component {
|
|
77
134
|
render() {
|
|
78
|
-
const { children, closeCb, ...rest } = this.props;
|
|
135
|
+
const { children, closeCb, testId, ...rest } = this.props;
|
|
79
136
|
return (
|
|
80
|
-
<li className={cl('dropdown__item')} {...rest}>
|
|
137
|
+
<li className={cl('dropdown__item')} data-testid={testId} {...rest}>
|
|
81
138
|
{children}
|
|
82
139
|
</li>
|
|
83
140
|
);
|
|
@@ -86,11 +143,13 @@ class DropdownItem extends Component {
|
|
|
86
143
|
|
|
87
144
|
DropdownItem.defaultProps = {
|
|
88
145
|
closeCb: null,
|
|
146
|
+
testId: 'dropdown-item',
|
|
89
147
|
};
|
|
90
148
|
|
|
91
149
|
DropdownItem.propTypes = {
|
|
92
150
|
children: PropTypes.node.isRequired,
|
|
93
151
|
closeCb: PropTypes.func,
|
|
152
|
+
testId: PropTypes.string,
|
|
94
153
|
};
|
|
95
154
|
|
|
96
155
|
class DropdownButtonItem extends Component {
|
|
@@ -125,6 +184,7 @@ DropdownButtonItem.defaultProps = {
|
|
|
125
184
|
onClick: null,
|
|
126
185
|
btnIcon: null,
|
|
127
186
|
btnLabel: '',
|
|
187
|
+
testId: 'dropdown-button-item',
|
|
128
188
|
isImportant: false,
|
|
129
189
|
closeCb: null,
|
|
130
190
|
};
|
|
@@ -133,6 +193,7 @@ DropdownButtonItem.propTypes = {
|
|
|
133
193
|
onClick: PropTypes.func,
|
|
134
194
|
btnIcon: PropTypes.string,
|
|
135
195
|
btnLabel: PropTypes.string,
|
|
196
|
+
testId: PropTypes.string,
|
|
136
197
|
isImportant: PropTypes.bool,
|
|
137
198
|
closeCb: PropTypes.func,
|
|
138
199
|
};
|
|
@@ -183,6 +244,7 @@ class DropdownConfirmButtonItem extends Component {
|
|
|
183
244
|
}
|
|
184
245
|
|
|
185
246
|
DropdownConfirmButtonItem.defaultProps = {
|
|
247
|
+
testId: 'dropdown-confirm-button-item',
|
|
186
248
|
onConfirm: null,
|
|
187
249
|
btnIcon: null,
|
|
188
250
|
closeCb: null,
|
|
@@ -195,6 +257,7 @@ DropdownConfirmButtonItem.defaultProps = {
|
|
|
195
257
|
DropdownConfirmButtonItem.propTypes = {
|
|
196
258
|
onConfirm: PropTypes.func,
|
|
197
259
|
btnIcon: PropTypes.string,
|
|
260
|
+
testId: PropTypes.string,
|
|
198
261
|
confirmLabel: PropTypes.string,
|
|
199
262
|
btnLabel: PropTypes.string,
|
|
200
263
|
closeCb: PropTypes.func,
|
|
@@ -255,6 +318,7 @@ class Dropdown extends Component {
|
|
|
255
318
|
btnFaceIconSize,
|
|
256
319
|
closeCb,
|
|
257
320
|
disableCloseOutside,
|
|
321
|
+
testId,
|
|
258
322
|
...rest
|
|
259
323
|
} = this.props;
|
|
260
324
|
const { open } = this.state;
|
|
@@ -275,6 +339,7 @@ class Dropdown extends Component {
|
|
|
275
339
|
size={btnSize}
|
|
276
340
|
iconSize={btnFaceIconSize}
|
|
277
341
|
label={label}
|
|
342
|
+
testId={testId}
|
|
278
343
|
/>
|
|
279
344
|
{childrenWithProps}
|
|
280
345
|
</div>
|
|
@@ -295,6 +360,7 @@ Dropdown.defaultProps = {
|
|
|
295
360
|
btnFace: 'link-flex',
|
|
296
361
|
btnFaceIcon: 'caret-bottom',
|
|
297
362
|
btnFaceIconSize: 24,
|
|
363
|
+
testId: 'dropdown',
|
|
298
364
|
};
|
|
299
365
|
|
|
300
366
|
Dropdown.propTypes = {
|
|
@@ -304,6 +370,7 @@ Dropdown.propTypes = {
|
|
|
304
370
|
disabled: PropTypes.bool,
|
|
305
371
|
disableCloseOutside: PropTypes.bool,
|
|
306
372
|
label: PropTypes.string,
|
|
373
|
+
testId: PropTypes.string,
|
|
307
374
|
children: PropTypes.node.isRequired,
|
|
308
375
|
className: PropTypes.string,
|
|
309
376
|
btnFace: PropTypes.oneOf(['link-flex', 'primary', 'secondary', 'important', 'transparent', 'link']),
|
|
@@ -315,6 +382,7 @@ Dropdown.propTypes = {
|
|
|
315
382
|
|
|
316
383
|
export default Object.assign(withClickOutside(Dropdown, '.popover__content'), {
|
|
317
384
|
Menu: DropdownMenu,
|
|
385
|
+
MenuSection: DropdownMenuSection,
|
|
318
386
|
Item: DropdownItem,
|
|
319
387
|
ButtonItem: DropdownButtonItem,
|
|
320
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 = {};
|
|
@@ -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
|
};
|
|
@@ -5,7 +5,7 @@ import Icon from '../Icon/Icon';
|
|
|
5
5
|
|
|
6
6
|
export default class Flash extends Component {
|
|
7
7
|
render() {
|
|
8
|
-
const { children, icon, inverse, fill, type, shadowed, ...rest } = this.props;
|
|
8
|
+
const { children, icon, inverse, fill, type, shadowed, testId, ...rest } = this.props;
|
|
9
9
|
const iconComponent = icon ? <Icon size={24} icon={icon} /> : null;
|
|
10
10
|
return (
|
|
11
11
|
<div
|
|
@@ -17,6 +17,7 @@ export default class Flash extends Component {
|
|
|
17
17
|
{ 'flash--fill': fill },
|
|
18
18
|
{ 'flash--shadowed': shadowed && !inverse }
|
|
19
19
|
)}
|
|
20
|
+
data-testid={testId}
|
|
20
21
|
{...rest}
|
|
21
22
|
>
|
|
22
23
|
{iconComponent}
|
|
@@ -32,6 +33,7 @@ Flash.defaultProps = {
|
|
|
32
33
|
inverse: false,
|
|
33
34
|
fill: false,
|
|
34
35
|
shadowed: false,
|
|
36
|
+
testId: 'flash',
|
|
35
37
|
};
|
|
36
38
|
|
|
37
39
|
Flash.propTypes = {
|
|
@@ -41,4 +43,5 @@ Flash.propTypes = {
|
|
|
41
43
|
inverse: PropTypes.bool,
|
|
42
44
|
fill: PropTypes.bool,
|
|
43
45
|
shadowed: PropTypes.bool,
|
|
46
|
+
testId: PropTypes.string,
|
|
44
47
|
};
|
|
@@ -19,10 +19,12 @@ import { ReactComponent as ArrowTop } from '../../icons/arrow-top.svg';
|
|
|
19
19
|
import { ReactComponent as Asset } from '../../icons/asset.svg';
|
|
20
20
|
import { ReactComponent as AssetAddFile } from '../../icons/asset-add-file.svg';
|
|
21
21
|
import { ReactComponent as AssetAdd } from '../../icons/asset-add.svg';
|
|
22
|
+
import { ReactComponent as Autocomplete } from '../../icons/autocomplete.svg';
|
|
22
23
|
import { ReactComponent as Bank } from '../../icons/bank.svg';
|
|
23
24
|
import { ReactComponent as Beaker } from '../../icons/beaker.svg';
|
|
24
25
|
import { ReactComponent as Bell } from '../../icons/bell.svg';
|
|
25
26
|
import { ReactComponent as Bookmark } from '../../icons/bookmark.svg';
|
|
27
|
+
import { ReactComponent as Buildings } from '../../icons/buildings.svg';
|
|
26
28
|
import { ReactComponent as Bulb } from '../../icons/bulb.svg';
|
|
27
29
|
import { ReactComponent as CaretBotton } from '../../icons/caret-bottom.svg';
|
|
28
30
|
import { ReactComponent as CaretLeft } from '../../icons/caret-left.svg';
|
|
@@ -54,6 +56,7 @@ import { ReactComponent as Exchange } from '../../icons/exchange.svg';
|
|
|
54
56
|
import { ReactComponent as Expand } from '../../icons/expand.svg';
|
|
55
57
|
import { ReactComponent as Export } from '../../icons/export.svg';
|
|
56
58
|
import { ReactComponent as Flag } from '../../icons/flag.svg';
|
|
59
|
+
import { ReactComponent as Github } from '../../icons/github.svg';
|
|
57
60
|
import { ReactComponent as Globe } from '../../icons/globe.svg';
|
|
58
61
|
import { ReactComponent as Home } from '../../icons/home.svg';
|
|
59
62
|
import { ReactComponent as HomeUser } from '../../icons/home-user.svg';
|
|
@@ -75,17 +78,25 @@ import { ReactComponent as Organization } from '../../icons/organization.svg';
|
|
|
75
78
|
import { ReactComponent as Organizations } from '../../icons/organizations.svg';
|
|
76
79
|
import { ReactComponent as Phone } from '../../icons/phone.svg';
|
|
77
80
|
import { ReactComponent as Platform } from '../../icons/platform.svg';
|
|
81
|
+
import { ReactComponent as Position } from '../../icons/position.svg';
|
|
78
82
|
import { ReactComponent as ProductActivated } from '../../icons/product-activated.svg';
|
|
79
83
|
import { ReactComponent as ProductAdd } from '../../icons/product-add.svg';
|
|
80
84
|
import { ReactComponent as Products } from '../../icons/products.svg';
|
|
81
85
|
import { ReactComponent as Projects } from '../../icons/projects.svg';
|
|
82
86
|
import { ReactComponent as Puzzle } from '../../icons/puzzle.svg';
|
|
83
87
|
import { ReactComponent as Question } from '../../icons/question.svg';
|
|
88
|
+
import { ReactComponent as Quote } from '../../icons/quote.svg';
|
|
84
89
|
import { ReactComponent as Receipt } from '../../icons/receipt.svg';
|
|
90
|
+
import { ReactComponent as SaveMoney } from '../../icons/save-money.svg';
|
|
85
91
|
import { ReactComponent as Search } from '../../icons/search.svg';
|
|
86
92
|
import { ReactComponent as SeePage } from '../../icons/see-page.svg';
|
|
87
93
|
import { ReactComponent as Settings } from '../../icons/settings.svg';
|
|
88
94
|
import { ReactComponent as Shield } from '../../icons/shield.svg';
|
|
95
|
+
import { ReactComponent as Star } from '../../icons/star.svg';
|
|
96
|
+
import { ReactComponent as StarFilled } from '../../icons/star-filled.svg';
|
|
97
|
+
import { ReactComponent as Stores } from '../../icons/stores.svg';
|
|
98
|
+
import { ReactComponent as Support } from '../../icons/support.svg';
|
|
99
|
+
import { ReactComponent as Switch } from '../../icons/switch.svg';
|
|
89
100
|
import { ReactComponent as Team } from '../../icons/team.svg';
|
|
90
101
|
import { ReactComponent as Time } from '../../icons/time.svg';
|
|
91
102
|
import { ReactComponent as Tool } from '../../icons/tool.svg';
|
|
@@ -95,18 +106,17 @@ import { ReactComponent as ViewList } from '../../icons/view-list.svg';
|
|
|
95
106
|
import { ReactComponent as ViewMiniCard } from '../../icons/view-mini-card.svg';
|
|
96
107
|
import { ReactComponent as Warning } from '../../icons/warning.svg';
|
|
97
108
|
import { ReactComponent as Woosmap } from '../../icons/woosmap.svg';
|
|
98
|
-
import { ReactComponent as
|
|
99
|
-
import { ReactComponent as
|
|
100
|
-
import { ReactComponent as Map } from '../../icons/map.svg';
|
|
109
|
+
import { ReactComponent as World } from '../../icons/world.svg';
|
|
110
|
+
import { ReactComponent as Address } from '../../icons/address.svg';
|
|
101
111
|
import { ReactComponent as Distance } from '../../icons/distance.svg';
|
|
102
112
|
import { ReactComponent as Geolocation } from '../../icons/geolocation.svg';
|
|
103
|
-
import { ReactComponent as
|
|
104
|
-
import { ReactComponent as
|
|
105
|
-
import { ReactComponent as StarFilled } from '../../icons/star-filled.svg';
|
|
106
|
-
import { ReactComponent as Stores } from '../../icons/stores.svg';
|
|
107
|
-
import { ReactComponent as Support } from '../../icons/support.svg';
|
|
108
|
-
import { ReactComponent as Switch } from '../../icons/switch.svg';
|
|
113
|
+
import { ReactComponent as Localities } from '../../icons/localities.svg';
|
|
114
|
+
import { ReactComponent as Map } from '../../icons/map.svg';
|
|
109
115
|
import { ReactComponent as Merchant } from '../../icons/merchant.svg';
|
|
116
|
+
import { ReactComponent as Traffic } from '../../icons/traffic.svg';
|
|
117
|
+
import { ReactComponent as SocialFacebook } from '../../icons/social-facebook.svg';
|
|
118
|
+
import { ReactComponent as SocialLinkedin } from '../../icons/social-linkedin.svg';
|
|
119
|
+
import { ReactComponent as SocialTwitter } from '../../icons/social-twitter.svg';
|
|
110
120
|
|
|
111
121
|
const Icons = {
|
|
112
122
|
access: Access,
|
|
@@ -127,10 +137,12 @@ const Icons = {
|
|
|
127
137
|
asset: Asset,
|
|
128
138
|
'asset-add-file': AssetAddFile,
|
|
129
139
|
'asset-add': AssetAdd,
|
|
140
|
+
autocomplete: Autocomplete,
|
|
130
141
|
bank: Bank,
|
|
131
142
|
beaker: Beaker,
|
|
132
143
|
bell: Bell,
|
|
133
144
|
bookmark: Bookmark,
|
|
145
|
+
buildings: Buildings,
|
|
134
146
|
bulb: Bulb,
|
|
135
147
|
'caret-bottom': CaretBotton,
|
|
136
148
|
'caret-left': CaretLeft,
|
|
@@ -163,6 +175,7 @@ const Icons = {
|
|
|
163
175
|
export: Export,
|
|
164
176
|
flag: Flag,
|
|
165
177
|
globe: Globe,
|
|
178
|
+
github: Github,
|
|
166
179
|
home: Home,
|
|
167
180
|
'home-user': HomeUser,
|
|
168
181
|
import: Import,
|
|
@@ -183,17 +196,25 @@ const Icons = {
|
|
|
183
196
|
organizations: Organizations,
|
|
184
197
|
phone: Phone,
|
|
185
198
|
platform: Platform,
|
|
199
|
+
position: Position,
|
|
186
200
|
'product-activated': ProductActivated,
|
|
187
201
|
'product-add': ProductAdd,
|
|
188
202
|
products: Products,
|
|
189
203
|
projects: Projects,
|
|
190
204
|
puzzle: Puzzle,
|
|
191
|
-
receipt: Receipt,
|
|
192
205
|
question: Question,
|
|
206
|
+
quote: Quote,
|
|
207
|
+
receipt: Receipt,
|
|
208
|
+
'save-money': SaveMoney,
|
|
193
209
|
search: Search,
|
|
194
210
|
'see-page': SeePage,
|
|
195
211
|
settings: Settings,
|
|
196
212
|
shield: Shield,
|
|
213
|
+
star: Star,
|
|
214
|
+
'star-filled': StarFilled,
|
|
215
|
+
stores: Stores,
|
|
216
|
+
support: Support,
|
|
217
|
+
switch: Switch,
|
|
197
218
|
team: Team,
|
|
198
219
|
time: Time,
|
|
199
220
|
tool: Tool,
|
|
@@ -203,25 +224,32 @@ const Icons = {
|
|
|
203
224
|
'view-mini-card': ViewMiniCard,
|
|
204
225
|
warning: Warning,
|
|
205
226
|
woosmap: Woosmap,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
maps: Map,
|
|
227
|
+
world: World,
|
|
228
|
+
address: Address,
|
|
209
229
|
distance: Distance,
|
|
210
230
|
geolocation: Geolocation,
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
'star-filled': StarFilled,
|
|
214
|
-
stores: Stores,
|
|
215
|
-
support: Support,
|
|
216
|
-
switch: Switch,
|
|
231
|
+
localities: Localities,
|
|
232
|
+
maps: Map,
|
|
217
233
|
merchant: Merchant,
|
|
234
|
+
traffic: Traffic,
|
|
235
|
+
'social-facebook': SocialFacebook,
|
|
236
|
+
'social-linkedin': SocialLinkedin,
|
|
237
|
+
'social-twitter': SocialTwitter,
|
|
218
238
|
};
|
|
219
239
|
|
|
220
240
|
class Icon extends Component {
|
|
221
241
|
render() {
|
|
222
|
-
const { icon, size, className, title } = this.props;
|
|
242
|
+
const { icon, size, className, title, testId } = this.props;
|
|
223
243
|
const IconComponent = Icons[icon];
|
|
224
|
-
return
|
|
244
|
+
return (
|
|
245
|
+
<IconComponent
|
|
246
|
+
className={cl('icon', className)}
|
|
247
|
+
data-testid={testId}
|
|
248
|
+
width={size}
|
|
249
|
+
height={size}
|
|
250
|
+
title={title}
|
|
251
|
+
/>
|
|
252
|
+
);
|
|
225
253
|
}
|
|
226
254
|
}
|
|
227
255
|
|
|
@@ -229,6 +257,7 @@ Icon.defaultProps = {
|
|
|
229
257
|
size: 24,
|
|
230
258
|
className: null,
|
|
231
259
|
title: null,
|
|
260
|
+
testId: 'icon',
|
|
232
261
|
};
|
|
233
262
|
|
|
234
263
|
Icon.propTypes = {
|
|
@@ -236,6 +265,7 @@ Icon.propTypes = {
|
|
|
236
265
|
className: PropTypes.string,
|
|
237
266
|
icon: PropTypes.string.isRequired,
|
|
238
267
|
title: PropTypes.string,
|
|
268
|
+
testId: PropTypes.string,
|
|
239
269
|
};
|
|
240
270
|
export default Object.assign(Icon, {
|
|
241
271
|
Icons,
|
|
@@ -5,10 +5,10 @@ import '@testing-library/jest-dom/extend-expect';
|
|
|
5
5
|
import Icon from './Icon';
|
|
6
6
|
|
|
7
7
|
it('renders an icon component', () => {
|
|
8
|
-
const {
|
|
9
|
-
expect(
|
|
10
|
-
expect(
|
|
11
|
-
expect(
|
|
8
|
+
const { getByTestId } = render(<Icon icon="home" size={64} />);
|
|
9
|
+
expect(getByTestId('icon')).toHaveClass('icon');
|
|
10
|
+
expect(getByTestId('icon')).toHaveAttribute('width', '64');
|
|
11
|
+
expect(getByTestId('icon')).toHaveTextContent('home');
|
|
12
12
|
});
|
|
13
13
|
/*
|
|
14
14
|
it('renders all icon components', () => {
|
|
@@ -10,7 +10,7 @@ export default class InfoMessage extends Component {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
render() {
|
|
13
|
-
const { modalProps, actionLabel, children, ...rest } = this.props;
|
|
13
|
+
const { modalProps, actionLabel, children, testId, ...rest } = this.props;
|
|
14
14
|
return (
|
|
15
15
|
<>
|
|
16
16
|
<Button
|
|
@@ -19,8 +19,9 @@ export default class InfoMessage extends Component {
|
|
|
19
19
|
type="link-flex-info"
|
|
20
20
|
{...rest}
|
|
21
21
|
onClick={() => this.modalRef.current.open()}
|
|
22
|
+
testId={`${testId}-button`}
|
|
22
23
|
/>
|
|
23
|
-
<Modal ref={this.modalRef} footer={false} {...modalProps}>
|
|
24
|
+
<Modal ref={this.modalRef} footer={false} testId={`${testId}-modal`} {...modalProps}>
|
|
24
25
|
{children}
|
|
25
26
|
</Modal>
|
|
26
27
|
</>
|
|
@@ -30,8 +31,10 @@ export default class InfoMessage extends Component {
|
|
|
30
31
|
InfoMessage.defaultProps = {
|
|
31
32
|
actionLabel: '',
|
|
32
33
|
modalProps: {},
|
|
34
|
+
testId: 'info-message',
|
|
33
35
|
};
|
|
34
36
|
InfoMessage.propTypes = {
|
|
37
|
+
testId: PropTypes.string,
|
|
35
38
|
children: PropTypes.node.isRequired,
|
|
36
39
|
actionLabel: PropTypes.string,
|
|
37
40
|
modalProps: PropTypes.object,
|
|
@@ -14,12 +14,12 @@ it('renders a InfoMessage component ', () => {
|
|
|
14
14
|
it('opens a modal with the content when clicking the button ', () => {
|
|
15
15
|
const { container } = render(<InfoMessage actionLabel="action">Content</InfoMessage>);
|
|
16
16
|
try {
|
|
17
|
-
screen.getByTestId('modal');
|
|
17
|
+
screen.getByTestId('info-message-modal');
|
|
18
18
|
expect('Modal displayed').toBeFalsy();
|
|
19
19
|
} catch (e) {
|
|
20
20
|
// nothink
|
|
21
21
|
}
|
|
22
22
|
userEvent.click(container.firstChild);
|
|
23
|
-
const modal = screen.getByTestId('modal');
|
|
23
|
+
const modal = screen.getByTestId('info-message-modal');
|
|
24
24
|
expect(modal).toHaveClass('modal');
|
|
25
25
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, fireEvent } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
+
|
|
5
|
+
import Input from './Input';
|
|
6
|
+
|
|
7
|
+
it('renders an input component ', () => {
|
|
8
|
+
const { container } = render(<Input>input</Input>);
|
|
9
|
+
expect(container.firstChild).toHaveClass('input');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should call func if Enter key is pressed', () => {
|
|
13
|
+
const fakeFunc = jest.fn();
|
|
14
|
+
const { container } = render(<Input onPressEnter={fakeFunc}>input</Input>);
|
|
15
|
+
const [input] = container.querySelectorAll('input');
|
|
16
|
+
fireEvent.keyDown(input, { keyCode: 13 });
|
|
17
|
+
expect(fakeFunc).toHaveBeenCalled();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should not accept input if disabled', () => {
|
|
21
|
+
const { container } = render(<Input disabled>input</Input>);
|
|
22
|
+
expect(container.firstChild).toHaveClass('input--disabled');
|
|
23
|
+
const [input] = container.querySelectorAll('input');
|
|
24
|
+
fireEvent.click(input);
|
|
25
|
+
expect(input).not.toHaveFocus();
|
|
26
|
+
});
|
|
@@ -18,6 +18,7 @@ export default class Label extends Component {
|
|
|
18
18
|
isPill,
|
|
19
19
|
noWrap,
|
|
20
20
|
plan,
|
|
21
|
+
testId,
|
|
21
22
|
...rest
|
|
22
23
|
} = this.props;
|
|
23
24
|
const classes = cl(
|
|
@@ -33,9 +34,21 @@ export default class Label extends Component {
|
|
|
33
34
|
className
|
|
34
35
|
);
|
|
35
36
|
return (
|
|
36
|
-
<span className={classes} {...rest}>
|
|
37
|
-
{label &&
|
|
38
|
-
|
|
37
|
+
<span className={classes} data-testid={testId} {...rest}>
|
|
38
|
+
{label && (
|
|
39
|
+
<span className="label__name" data-testid={`${testId}-label`}>
|
|
40
|
+
{label}
|
|
41
|
+
</span>
|
|
42
|
+
)}
|
|
43
|
+
{closable && (
|
|
44
|
+
<Button
|
|
45
|
+
type="link-flex"
|
|
46
|
+
iconSize={12}
|
|
47
|
+
icon="close-thick"
|
|
48
|
+
onClick={closeCb}
|
|
49
|
+
testId={`${testId}-button`}
|
|
50
|
+
/>
|
|
51
|
+
)}
|
|
39
52
|
</span>
|
|
40
53
|
);
|
|
41
54
|
}
|
|
@@ -54,10 +67,12 @@ Label.defaultProps = {
|
|
|
54
67
|
isPill: null,
|
|
55
68
|
noWrap: null,
|
|
56
69
|
plan: undefined,
|
|
70
|
+
testId: 'label',
|
|
57
71
|
};
|
|
58
72
|
|
|
59
73
|
Label.propTypes = {
|
|
60
74
|
label: PropTypes.string,
|
|
75
|
+
testId: PropTypes.string,
|
|
61
76
|
color: PropTypes.oneOf(['bleu', 'mauve', 'green', 'grey', 'orange', 'red', 'white', undefined, '']),
|
|
62
77
|
className: PropTypes.string,
|
|
63
78
|
product: PropTypes.oneOf([
|