@woosmap/ui 2.43.0 → 2.47.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/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 +2 -1
- package/src/components/Dropdown/Dropdown.js +75 -2
- package/src/components/Dropdown/Dropdown.stories.js +29 -0
- package/src/components/Dropdown/Dropdown.styl +3 -0
- package/src/components/Icon/Icon.js +6 -0
- package/src/components/Map/drawOnMap.js +40 -0
- package/src/components/Modal/Modal.js +24 -0
- package/src/components/Modal/Modal.stories.js +12 -0
- package/src/components/Modal/Modal.test.js +18 -2
- 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/images/marker-dot.svg +15 -0
- package/src/styles/commons/base.styl +6 -6
package/package.json
CHANGED
|
@@ -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,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 { createWoosmapMap } from '../Map/drawOnMap';
|
|
14
15
|
import 'resize-observer-polyfill/dist/ResizeObserver.global';
|
|
15
16
|
|
|
16
17
|
export default class SearchDemo extends Component {
|
|
@@ -189,7 +190,7 @@ export default class SearchDemo extends Component {
|
|
|
189
190
|
if (this.timeoutMap) clearTimeout(this.timeoutMap);
|
|
190
191
|
|
|
191
192
|
if (window.woosmap && window.woosmap.map && this.mapDivRef.current) {
|
|
192
|
-
this.map =
|
|
193
|
+
this.map = createWoosmapMap(this.mapDivRef.current);
|
|
193
194
|
this.requestSearch();
|
|
194
195
|
} else {
|
|
195
196
|
this.timeoutMap = setTimeout(this.displayMap, 300);
|
|
@@ -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;
|
|
@@ -243,6 +289,28 @@ class Dropdown extends Component {
|
|
|
243
289
|
this.setOpen(false);
|
|
244
290
|
};
|
|
245
291
|
|
|
292
|
+
onMouseEnter = () => {
|
|
293
|
+
const { openOnMouseEnter } = this.props;
|
|
294
|
+
if (openOnMouseEnter) {
|
|
295
|
+
if (this.mouseLeaveTimeout) {
|
|
296
|
+
clearTimeout(this.mouseLeaveTimeout);
|
|
297
|
+
}
|
|
298
|
+
this.setOpen(true);
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
onMouseLeave = () => {
|
|
303
|
+
const { openOnMouseEnter } = this.props;
|
|
304
|
+
if (openOnMouseEnter) {
|
|
305
|
+
if (this.mouseLeaveTimeout) {
|
|
306
|
+
clearTimeout(this.mouseLeaveTimeout);
|
|
307
|
+
}
|
|
308
|
+
this.mouseLeaveTimeout = setTimeout(() => {
|
|
309
|
+
this.setOpen(false);
|
|
310
|
+
}, 500);
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
|
|
246
314
|
onClick = (e) => {
|
|
247
315
|
const { onClick } = this.props;
|
|
248
316
|
const { open } = this.state;
|
|
@@ -283,6 +351,8 @@ class Dropdown extends Component {
|
|
|
283
351
|
ref={this.clickOutsideRef}
|
|
284
352
|
className={cl('dropdown', { open }, `dropdown--${size}`, className)}
|
|
285
353
|
{...rest}
|
|
354
|
+
onMouseEnter={this.onMouseEnter}
|
|
355
|
+
onMouseLeave={this.onMouseLeave}
|
|
286
356
|
>
|
|
287
357
|
<Button
|
|
288
358
|
disabled={disabled}
|
|
@@ -311,6 +381,7 @@ Dropdown.defaultProps = {
|
|
|
311
381
|
label: null,
|
|
312
382
|
className: null,
|
|
313
383
|
closeCb: null,
|
|
384
|
+
openOnMouseEnter: false,
|
|
314
385
|
btnFace: 'link-flex',
|
|
315
386
|
btnFaceIcon: 'caret-bottom',
|
|
316
387
|
btnFaceIconSize: 24,
|
|
@@ -323,6 +394,7 @@ Dropdown.propTypes = {
|
|
|
323
394
|
onDoubleClick: PropTypes.func,
|
|
324
395
|
disabled: PropTypes.bool,
|
|
325
396
|
disableCloseOutside: PropTypes.bool,
|
|
397
|
+
openOnMouseEnter: PropTypes.bool,
|
|
326
398
|
label: PropTypes.string,
|
|
327
399
|
testId: PropTypes.string,
|
|
328
400
|
children: PropTypes.node.isRequired,
|
|
@@ -336,6 +408,7 @@ Dropdown.propTypes = {
|
|
|
336
408
|
|
|
337
409
|
export default Object.assign(withClickOutside(Dropdown, '.popover__content'), {
|
|
338
410
|
Menu: DropdownMenu,
|
|
411
|
+
MenuSection: DropdownMenuSection,
|
|
339
412
|
Item: DropdownItem,
|
|
340
413
|
ButtonItem: DropdownButtonItem,
|
|
341
414
|
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 = {};
|
|
@@ -114,6 +114,9 @@ import { ReactComponent as Localities } from '../../icons/localities.svg';
|
|
|
114
114
|
import { ReactComponent as Map } from '../../icons/map.svg';
|
|
115
115
|
import { ReactComponent as Merchant } from '../../icons/merchant.svg';
|
|
116
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';
|
|
117
120
|
|
|
118
121
|
const Icons = {
|
|
119
122
|
access: Access,
|
|
@@ -229,6 +232,9 @@ const Icons = {
|
|
|
229
232
|
maps: Map,
|
|
230
233
|
merchant: Merchant,
|
|
231
234
|
traffic: Traffic,
|
|
235
|
+
'social-facebook': SocialFacebook,
|
|
236
|
+
'social-linkedin': SocialLinkedin,
|
|
237
|
+
'social-twitter': SocialTwitter,
|
|
232
238
|
};
|
|
233
239
|
|
|
234
240
|
class Icon extends Component {
|
|
@@ -84,6 +84,46 @@ export const woosmapBoundsFromViewport = function woosmapBoundsFromViewport(view
|
|
|
84
84
|
);
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
+
export const createWoosmapMap = (node) =>
|
|
88
|
+
new window.woosmap.map.Map(node, {
|
|
89
|
+
styles: [
|
|
90
|
+
{
|
|
91
|
+
featureType: 'administrative',
|
|
92
|
+
elementType: 'all',
|
|
93
|
+
stylers: [{ visibility: 'on' }, { saturation: -100 }, { lightness: 20 }],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
featureType: 'road',
|
|
97
|
+
elementType: 'all',
|
|
98
|
+
stylers: [{ visibility: 'on' }, { saturation: -100 }, { lightness: 40 }],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
featureType: 'water',
|
|
102
|
+
elementType: 'all',
|
|
103
|
+
stylers: [{ visibility: 'on' }, { saturation: -10 }, { lightness: 30 }],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
featureType: 'landscape.man_made',
|
|
107
|
+
elementType: 'all',
|
|
108
|
+
stylers: [{ visibility: 'simplified' }, { saturation: -60 }, { lightness: 10 }],
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
featureType: 'landscape.natural',
|
|
112
|
+
elementType: 'all',
|
|
113
|
+
stylers: [{ visibility: 'simplified' }, { saturation: -60 }, { lightness: 60 }],
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
featureType: 'poi',
|
|
117
|
+
elementType: 'all',
|
|
118
|
+
stylers: [{ visibility: 'off' }, { saturation: -100 }, { lightness: 60 }],
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
featureType: 'transit',
|
|
122
|
+
elementType: 'all',
|
|
123
|
+
stylers: [{ visibility: 'off' }, { saturation: -100 }, { lightness: 60 }],
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
});
|
|
87
127
|
export class WoosmapMapBoundingBox {
|
|
88
128
|
constructor(bounds, padding) {
|
|
89
129
|
this.overlayView = new window.woosmap.map.OverlayView();
|
|
@@ -15,6 +15,10 @@ class Modal extends Component {
|
|
|
15
15
|
this.modalRef = React.createRef();
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
componentDidMount() {
|
|
19
|
+
this.handleEscFunction('add');
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
componentDidUpdate() {
|
|
19
23
|
const { isLoading } = this.state;
|
|
20
24
|
const { hasErrors } = this.props;
|
|
@@ -23,6 +27,10 @@ class Modal extends Component {
|
|
|
23
27
|
}
|
|
24
28
|
}
|
|
25
29
|
|
|
30
|
+
componentWillUnmount() {
|
|
31
|
+
this.handleEscFunction();
|
|
32
|
+
}
|
|
33
|
+
|
|
26
34
|
handleClickOutside = () => {
|
|
27
35
|
this.close();
|
|
28
36
|
};
|
|
@@ -31,6 +39,20 @@ class Modal extends Component {
|
|
|
31
39
|
this.setState({ isLoading: loading });
|
|
32
40
|
}
|
|
33
41
|
|
|
42
|
+
handleEscFunction = (key) => {
|
|
43
|
+
const { closesWithEscape } = this.props;
|
|
44
|
+
if (closesWithEscape) {
|
|
45
|
+
if (key === 'add') document.addEventListener('keydown', this.escFunction, false);
|
|
46
|
+
else document.removeEventListener('keydown', this.escFunction, false);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
escFunction = (event) => {
|
|
51
|
+
if (event.keyCode === 27) {
|
|
52
|
+
this.close();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
34
56
|
open = () => {
|
|
35
57
|
this.setState({ open: true });
|
|
36
58
|
};
|
|
@@ -141,6 +163,7 @@ Modal.defaultProps = {
|
|
|
141
163
|
validateBtnProps: {},
|
|
142
164
|
mainButtonType: 'primary',
|
|
143
165
|
testId: 'modal',
|
|
166
|
+
closesWithEscape: false,
|
|
144
167
|
};
|
|
145
168
|
|
|
146
169
|
Modal.propTypes = {
|
|
@@ -160,6 +183,7 @@ Modal.propTypes = {
|
|
|
160
183
|
validateBtnProps: PropTypes.object,
|
|
161
184
|
mainButtonType: PropTypes.string,
|
|
162
185
|
testId: PropTypes.string,
|
|
186
|
+
closesWithEscape: PropTypes.bool,
|
|
163
187
|
};
|
|
164
188
|
|
|
165
189
|
export default withClickOutside(Modal, '.ignore-click-outside-modal');
|
|
@@ -78,3 +78,15 @@ const TemplateConfirmationModal = () => {
|
|
|
78
78
|
};
|
|
79
79
|
export const ModalConfirmation = TemplateConfirmationModal.bind({});
|
|
80
80
|
Default.args = {};
|
|
81
|
+
|
|
82
|
+
const TemplateEscapeModal = () => {
|
|
83
|
+
const modalRef = React.createRef();
|
|
84
|
+
return (
|
|
85
|
+
<div style={{ paddingLeft: '50px' }}>
|
|
86
|
+
<Button onClick={() => modalRef.current.open()} label="Open modal" />
|
|
87
|
+
<Modal ref={modalRef} closesWithEscape title="My modal" />
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
export const ModalEscape = TemplateEscapeModal.bind({});
|
|
92
|
+
Default.args = {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
4
4
|
import { act } from 'react-dom/test-utils';
|
|
5
5
|
import userEvent from '@testing-library/user-event';
|
|
@@ -56,7 +56,7 @@ it('is hidden after clicking cancel', () => {
|
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
it('is hidden after clicking
|
|
59
|
+
it('is hidden after clicking validate', () => {
|
|
60
60
|
const modalRef = React.createRef();
|
|
61
61
|
const validateCb = jest.fn();
|
|
62
62
|
render(
|
|
@@ -72,3 +72,19 @@ it('is hidden after clicking cancel', () => {
|
|
|
72
72
|
userEvent.click(validate);
|
|
73
73
|
expect(validateCb.mock.calls.length).toBe(1);
|
|
74
74
|
});
|
|
75
|
+
|
|
76
|
+
it('is closing after escaping if it is set to be closed with it', () => {
|
|
77
|
+
const modalRef = React.createRef();
|
|
78
|
+
const closeCb = jest.fn();
|
|
79
|
+
render(
|
|
80
|
+
<Modal ref={modalRef} closesWithEscape closeCb={closeCb}>
|
|
81
|
+
content
|
|
82
|
+
</Modal>
|
|
83
|
+
);
|
|
84
|
+
act(() => {
|
|
85
|
+
modalRef.current.open();
|
|
86
|
+
});
|
|
87
|
+
expect(closeCb).not.toHaveBeenCalled();
|
|
88
|
+
fireEvent.keyDown(document, { keyCode: 27 });
|
|
89
|
+
expect(closeCb).toHaveBeenCalled();
|
|
90
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19.426 1.66H4.661a3 3 0 0 0-3 3v14.766a3 3 0 0 0 3 3H12.7v-8.095H10v-3.1h2.7V8.93a3.76 3.76 0 0 1 3.37-4.113 3.823 3.823 0 0 1 .642-.009 18.532 18.532 0 0 1 2.413.124v2.779H17.46c-1.3 0-1.53.607-1.53 1.516v2h3.075l-.4 3.1h-2.676v8.1h3.5a3 3 0 0 0 3-3V4.66a3 3 0 0 0-3.003-3Z" fill-rule="evenodd"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19.426 1.66H4.661a3 3 0 0 0-3 3v14.766a3 3 0 0 0 3 3h14.765a3 3 0 0 0 3-3V4.66a3 3 0 0 0-3-3ZM7.8 19.281H4.721V9.409H7.8ZM6.26 8.072h-.012a1.778 1.778 0 0 1-1.761-1.793v-.006a1.786 1.786 0 1 1 1.772 1.8Zm9.961 11.21v-4.8c0-1.144-.028-2.62-1.6-2.62-1.6 0-1.834 1.255-1.834 2.537v4.88H9.726v-9.87h2.935v1.349h.032a3.225 3.225 0 0 1 2.9-1.586c3.115 0 3.68 2.04 3.68 4.7l.007 5.41Z" fill-rule="evenodd"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M23.066 5.136a8.972 8.972 0 0 1-2.61.715 4.552 4.552 0 0 0 2-2.511 9.083 9.083 0 0 1-2.884 1.1 4.545 4.545 0 0 0-7.741 4.142 12.9 12.9 0 0 1-9.357-4.744A4.544 4.544 0 0 0 3.879 9.9a4.542 4.542 0 0 1-2.058-.567v.057a4.542 4.542 0 0 0 3.642 4.453 4.519 4.519 0 0 1-1.2.159 4.441 4.441 0 0 1-.853-.08 4.549 4.549 0 0 0 4.241 3.153 9.112 9.112 0 0 1-5.639 1.944 9.559 9.559 0 0 1-1.082-.062A12.88 12.88 0 0 0 7.892 21 12.832 12.832 0 0 0 20.814 8.254v-.179c0-.2 0-.393-.014-.588a9.2 9.2 0 0 0 2.267-2.348Z"/></svg>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32.64 32.64" width="32.64" height="32.64">
|
|
2
|
+
<defs>
|
|
3
|
+
<filter id="dropshadow" height="130%">
|
|
4
|
+
<feGaussianBlur in="SourceAlpha" stdDeviation="1.6"/>
|
|
5
|
+
<feOffset dx="0" dy="1" result="offsetblur"/>
|
|
6
|
+
<feComponentTransfer>
|
|
7
|
+
<feFuncA type="linear" slope="0.4"/>
|
|
8
|
+
</feComponentTransfer>
|
|
9
|
+
<feMerge>
|
|
10
|
+
<feMergeNode/>
|
|
11
|
+
<feMergeNode in="SourceGraphic"/>
|
|
12
|
+
</feMerge>
|
|
13
|
+
</filter>
|
|
14
|
+
</defs>
|
|
15
|
+
<path d="M16.15,27.67a12.486,12.486,0,0,1-8.857-3.663,12.637,12.637,0,0,1,.1-17.714A12.49,12.49,0,1,1,16.15,27.67Z" fill="#fff" filter="url(#dropshadow)" /><path d="M23.593,7.707a10.468,10.468,0,0,0-14.786,0A10.629,10.629,0,0,0,8.715,22.6,10.526,10.526,0,0,0,23.593,7.707Z" fill="#5587fd"/><path d="M16.3,7.9A5.335,5.335,0,0,0,11,13.2c0,3.8,4.8,5.8,4.8,9.4,0,.3.2.4.5.4a.458.458,0,0,0,.5-.4c0-3.5,4.8-5.5,4.8-9.4A5.271,5.271,0,0,0,16.3,7.9Z" fill="#fff"/><circle cx="16.3" cy="13.4" r="2.1" fill="#5587fd"/><rect width="32.6" height="32.6" fill="none"/></svg>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
html
|
|
2
|
-
font-size
|
|
3
|
-
width
|
|
4
|
-
height
|
|
5
|
-
-moz-text-size-adjust
|
|
6
|
-
-webkit-text-size-adjust
|
|
7
|
-
-ms-text-size-adjust
|
|
2
|
+
font-size 62.5%
|
|
3
|
+
width 100%
|
|
4
|
+
height 100%
|
|
5
|
+
-moz-text-size-adjust 100%
|
|
6
|
+
-webkit-text-size-adjust 100%
|
|
7
|
+
-ms-text-size-adjust 100%
|
|
8
8
|
|
|
9
9
|
body
|
|
10
10
|
width 100%
|