@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
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]),
|
|
@@ -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]),
|
|
@@ -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, disabled } = this.props;
|
|
38
|
+
const { btnProps, dropdownProps, dropdownDirection, testId, disabled } = this.props;
|
|
31
39
|
return (
|
|
32
40
|
<div className="btn--multi-options">
|
|
33
|
-
<Button disabled={disabled} {...btnProps} />
|
|
34
|
-
<Dropdown disabled={disabled} {...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,6 +50,7 @@ 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,
|
|
@@ -48,6 +59,7 @@ ButtonWithDropdown.propTypes = {
|
|
|
48
59
|
};
|
|
49
60
|
|
|
50
61
|
ButtonWithDropdown.defaultProps = {
|
|
62
|
+
testId: 'button-with-dropdown',
|
|
51
63
|
btnProps: {},
|
|
52
64
|
dropdownProps: {},
|
|
53
65
|
dropdownItems: [],
|
|
@@ -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', () => {
|
|
@@ -16,6 +16,7 @@ import WalkingImg from '../../images/walk.png';
|
|
|
16
16
|
import { tr } from '../utils/locale';
|
|
17
17
|
import markerIcon from '../../images/marker.png';
|
|
18
18
|
import Script from '../utils/Script';
|
|
19
|
+
import { createWoosmapMap } from '../Map/drawOnMap';
|
|
19
20
|
|
|
20
21
|
const languages = [
|
|
21
22
|
{ value: 'fr', label: 'French' },
|
|
@@ -209,7 +210,7 @@ export default class DistanceDemo extends Component {
|
|
|
209
210
|
}
|
|
210
211
|
|
|
211
212
|
if (window.woosmap && window.woosmap.map && this.mapDivRef.current) {
|
|
212
|
-
this.map =
|
|
213
|
+
this.map = createWoosmapMap(this.mapDivRef.current);
|
|
213
214
|
this.requestDistance();
|
|
214
215
|
} else {
|
|
215
216
|
this.timeoutMap = setTimeout(this.displayMap, 300);
|
|
@@ -6,12 +6,12 @@ import Demo from './SkeletonDemo';
|
|
|
6
6
|
|
|
7
7
|
import Constants from '../../Constants';
|
|
8
8
|
import { tr } from '../utils/locale';
|
|
9
|
-
import markerIcon from '../../images/marker.
|
|
10
|
-
import
|
|
9
|
+
import markerIcon from '../../images/marker-dot.svg';
|
|
10
|
+
import markerGeolocationIcon from '../../images/marker-alt.png';
|
|
11
11
|
import Script from '../utils/Script';
|
|
12
12
|
import Input from '../Input/Input';
|
|
13
13
|
|
|
14
|
-
import { WoosmapMapBoundingBox, woosmapBoundsFromViewport } from '../Map/drawOnMap';
|
|
14
|
+
import { WoosmapMapBoundingBox, woosmapBoundsFromViewport, createWoosmapMap } from '../Map/drawOnMap';
|
|
15
15
|
|
|
16
16
|
export default class GeolocationDemo extends Component {
|
|
17
17
|
constructor(props) {
|
|
@@ -56,20 +56,17 @@ export default class GeolocationDemo extends Component {
|
|
|
56
56
|
getRequestparams = () => ({
|
|
57
57
|
key: Constants.geolocationWoosmapSearchKey,
|
|
58
58
|
radius: 200000,
|
|
59
|
+
limit: 20,
|
|
59
60
|
});
|
|
60
61
|
|
|
61
|
-
processMarker = (latLng, icon, forceMap = null) => {
|
|
62
|
+
processMarker = (latLng, icon, forceMap = null, scaledSize = { height: 24, width: 24 }) => {
|
|
62
63
|
const { showStores } = this.state;
|
|
63
64
|
|
|
64
65
|
let map;
|
|
65
66
|
if (!forceMap) map = showStores ? this.map : null;
|
|
66
67
|
else map = forceMap;
|
|
67
68
|
|
|
68
|
-
return new window.woosmap.map.Marker({
|
|
69
|
-
icon: { url: icon, scaledSize: { height: 46, width: 30 } },
|
|
70
|
-
position: latLng,
|
|
71
|
-
map,
|
|
72
|
-
});
|
|
69
|
+
return new window.woosmap.map.Marker({ icon: { url: icon, scaledSize }, position: latLng, map });
|
|
73
70
|
};
|
|
74
71
|
|
|
75
72
|
displayOnMap = () => {
|
|
@@ -93,8 +90,6 @@ export default class GeolocationDemo extends Component {
|
|
|
93
90
|
this.overlay = null;
|
|
94
91
|
}
|
|
95
92
|
|
|
96
|
-
this.marker = this.processMarker(location, markerIconAlt, this.map);
|
|
97
|
-
|
|
98
93
|
if (geolocation?.stores?.features) {
|
|
99
94
|
geolocation.stores.features.forEach((feature) => {
|
|
100
95
|
const [lng, lat] = feature.geometry.coordinates;
|
|
@@ -102,6 +97,8 @@ export default class GeolocationDemo extends Component {
|
|
|
102
97
|
});
|
|
103
98
|
}
|
|
104
99
|
|
|
100
|
+
this.marker = this.processMarker(location, markerGeolocationIcon, this.map, { height: 46, width: 30 });
|
|
101
|
+
|
|
105
102
|
const bounds = woosmapBoundsFromViewport(geolocation.viewport);
|
|
106
103
|
|
|
107
104
|
this.overlay = new WoosmapMapBoundingBox(bounds, { top: 55, left: 30, bottom: 10, right: 30 });
|
|
@@ -182,7 +179,7 @@ export default class GeolocationDemo extends Component {
|
|
|
182
179
|
}
|
|
183
180
|
|
|
184
181
|
if (window.woosmap && window.woosmap.map && this.mapDivRef.current) {
|
|
185
|
-
this.map =
|
|
182
|
+
this.map = createWoosmapMap(this.mapDivRef.current);
|
|
186
183
|
this.requestGeolocation();
|
|
187
184
|
} else {
|
|
188
185
|
this.timeoutMap = setTimeout(this.displayMap, 300);
|
|
@@ -10,6 +10,7 @@ import { tr } from '../utils/locale';
|
|
|
10
10
|
import Input from '../Input/Input';
|
|
11
11
|
import markerIcon from '../../images/marker.png';
|
|
12
12
|
import Script from '../utils/Script';
|
|
13
|
+
import { createWoosmapMap } from '../Map/drawOnMap';
|
|
13
14
|
|
|
14
15
|
export default class LocalitiesAddressDemo extends Component {
|
|
15
16
|
constructor(props) {
|
|
@@ -326,7 +327,7 @@ export default class LocalitiesAddressDemo extends Component {
|
|
|
326
327
|
}
|
|
327
328
|
|
|
328
329
|
if (window.woosmap && window.woosmap.map && this.mapDivRef.current) {
|
|
329
|
-
this.map =
|
|
330
|
+
this.map = createWoosmapMap(this.mapDivRef.current);
|
|
330
331
|
this.requestAddress();
|
|
331
332
|
} else {
|
|
332
333
|
this.timeoutMap = setTimeout(this.displayMap, 300);
|
|
@@ -13,7 +13,7 @@ import Constants from '../../Constants';
|
|
|
13
13
|
import { tr } from '../utils/locale';
|
|
14
14
|
import markerIcon from '../../images/marker.png';
|
|
15
15
|
import Script from '../utils/Script';
|
|
16
|
-
import { WoosmapMapBoundingBox } from '../Map/drawOnMap';
|
|
16
|
+
import { WoosmapMapBoundingBox, createWoosmapMap } from '../Map/drawOnMap';
|
|
17
17
|
|
|
18
18
|
const languages = [
|
|
19
19
|
{ value: 'fr', label: 'French' },
|
|
@@ -195,7 +195,7 @@ export default class LocalitiesDemo extends Component {
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
if (window.woosmap && window.woosmap.map && this.mapDivRef.current) {
|
|
198
|
-
this.map =
|
|
198
|
+
this.map = createWoosmapMap(this.mapDivRef.current);
|
|
199
199
|
this.requestLocalities();
|
|
200
200
|
} else {
|
|
201
201
|
this.timeoutMap = setTimeout(this.displayMap, 300);
|
|
@@ -11,6 +11,8 @@ 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 { createWoosmapMap } from '../Map/drawOnMap';
|
|
15
|
+
import 'resize-observer-polyfill/dist/ResizeObserver.global';
|
|
14
16
|
|
|
15
17
|
export default class SearchDemo extends Component {
|
|
16
18
|
constructor(props) {
|
|
@@ -188,7 +190,7 @@ export default class SearchDemo extends Component {
|
|
|
188
190
|
if (this.timeoutMap) clearTimeout(this.timeoutMap);
|
|
189
191
|
|
|
190
192
|
if (window.woosmap && window.woosmap.map && this.mapDivRef.current) {
|
|
191
|
-
this.map =
|
|
193
|
+
this.map = createWoosmapMap(this.mapDivRef.current);
|
|
192
194
|
this.requestSearch();
|
|
193
195
|
} else {
|
|
194
196
|
this.timeoutMap = setTimeout(this.displayMap, 300);
|