@woosmap/ui 3.122.0 → 3.125.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/.eslintrc +27 -6
- package/package.json +1 -1
- package/src/Constants.js +3 -2
- package/src/components/Button/Button.js +4 -0
- package/src/components/Button/Button.stories.js +1 -1
- package/src/components/Card/Card.js +1 -0
- package/src/components/Card/Card.styl +6 -0
- package/src/components/Demo/AddressDemo.js +15 -19
- package/src/components/Demo/DistanceDemo.js +16 -20
- package/src/components/Demo/GeolocationDemo.js +17 -21
- package/src/components/Demo/LocalitiesAddressDemo.js +17 -21
- package/src/components/Demo/LocalitiesDemo.js +17 -21
- package/src/components/Demo/MapDemo.js +30 -21
- package/src/components/Demo/SearchDemo.js +16 -20
- package/src/components/Demo/SkeletonDemo.js +104 -68
- package/src/components/Demo/SkeletonDemo.test.js +17 -0
- package/src/images/products/product-localities-uk.png +0 -0
- package/src/styles/console/button.styl +19 -0
package/.eslintrc
CHANGED
|
@@ -38,12 +38,23 @@
|
|
|
38
38
|
}
|
|
39
39
|
],
|
|
40
40
|
"no-plusplus": 0,
|
|
41
|
-
"no-console": [
|
|
41
|
+
"no-console": [
|
|
42
|
+
"warn",
|
|
43
|
+
{
|
|
44
|
+
"allow": [
|
|
45
|
+
"warn",
|
|
46
|
+
"error"
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
],
|
|
42
50
|
"semi": 1,
|
|
43
|
-
"prefer-destructuring": [
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
"prefer-destructuring": [
|
|
52
|
+
"warn",
|
|
53
|
+
{
|
|
54
|
+
"array": true,
|
|
55
|
+
"object": true
|
|
56
|
+
}
|
|
57
|
+
],
|
|
47
58
|
"prettier/prettier": [
|
|
48
59
|
"error",
|
|
49
60
|
{
|
|
@@ -53,5 +64,15 @@
|
|
|
53
64
|
"printWidth": 120
|
|
54
65
|
}
|
|
55
66
|
]
|
|
56
|
-
}
|
|
67
|
+
},
|
|
68
|
+
"overrides": [
|
|
69
|
+
{
|
|
70
|
+
"files": [
|
|
71
|
+
"**/*stories.js"
|
|
72
|
+
],
|
|
73
|
+
"rules": {
|
|
74
|
+
"no-console": "off"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
]
|
|
57
78
|
}
|
package/package.json
CHANGED
package/src/Constants.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export default {
|
|
1
|
+
export default Object.freeze({
|
|
2
2
|
woosmapKey: 'woos-5ec4eecd-d907-3da0-90f0-f2f3b7e4e672',
|
|
3
3
|
geolocationWoosmapSearchKey: 'woos-81a699ca-5082-3ffd-9f54-a684a4b82853',
|
|
4
4
|
gmapKey: 'AIzaSyAogtvSQJ8e1LO6WH6GzSI-QtwaRPCV5C8',
|
|
5
|
-
|
|
5
|
+
woosmapMapSdkUrl: 'https://sdk.woosmap.com/map/map.js',
|
|
6
|
+
});
|
|
@@ -26,6 +26,7 @@ export default class Button extends Component {
|
|
|
26
26
|
children,
|
|
27
27
|
testId,
|
|
28
28
|
iconRight,
|
|
29
|
+
isNotification,
|
|
29
30
|
...rest
|
|
30
31
|
} = this.props;
|
|
31
32
|
const classes = cl(
|
|
@@ -36,6 +37,7 @@ export default class Button extends Component {
|
|
|
36
37
|
size ? `btn--${size}` : null,
|
|
37
38
|
type ? `btn--${type}` : null,
|
|
38
39
|
{ active },
|
|
40
|
+
isNotification ? 'btn--notification' : null,
|
|
39
41
|
{ 'btn--loading': isLoading },
|
|
40
42
|
{ 'btn--no-label': !label },
|
|
41
43
|
{ 'btn--custom-icon-size': iconSize && iconSize !== 24 },
|
|
@@ -80,6 +82,7 @@ Button.defaultProps = {
|
|
|
80
82
|
active: false,
|
|
81
83
|
onClick: null,
|
|
82
84
|
iconRight: false,
|
|
85
|
+
isNotification: false,
|
|
83
86
|
};
|
|
84
87
|
|
|
85
88
|
Button.propTypes = {
|
|
@@ -115,4 +118,5 @@ Button.propTypes = {
|
|
|
115
118
|
onClick: PropTypes.func,
|
|
116
119
|
children: PropTypes.node,
|
|
117
120
|
iconRight: PropTypes.bool,
|
|
121
|
+
isNotification: PropTypes.bool,
|
|
118
122
|
};
|
|
@@ -28,7 +28,7 @@ const Template = (args) => {
|
|
|
28
28
|
<Button label={label} disabled />
|
|
29
29
|
</div>
|
|
30
30
|
<div className="flex mbi">
|
|
31
|
-
<Button icon="
|
|
31
|
+
<Button icon="puzzle" isNotification label="4" type="secondary" />
|
|
32
32
|
<Button label={label} type="secondary" />
|
|
33
33
|
<Button label={label} type="secondary" icon="marker" />
|
|
34
34
|
<Button label={label} type="secondary" isLoading />
|
|
@@ -10,7 +10,6 @@ import ButtonGroup from '../Button/ButtonGroup';
|
|
|
10
10
|
import CountrySelect from '../Select/CountrySelect';
|
|
11
11
|
import { tr } from '../utils/locale';
|
|
12
12
|
import Input from '../Input/Input';
|
|
13
|
-
import Script from '../utils/Script';
|
|
14
13
|
import markerIcon from '../../images/marker.png';
|
|
15
14
|
import AddressAutocomplete from '../Woosmap/AddressAutocomplete';
|
|
16
15
|
|
|
@@ -289,11 +288,11 @@ export default class AddressDemo extends Component {
|
|
|
289
288
|
};
|
|
290
289
|
const filterGeometry = {
|
|
291
290
|
label: false,
|
|
291
|
+
key: 'geometry',
|
|
292
292
|
component: (
|
|
293
293
|
<Input
|
|
294
294
|
label={tr('Geometry only')}
|
|
295
295
|
type="checkbox"
|
|
296
|
-
key="geometry"
|
|
297
296
|
checked={geometry}
|
|
298
297
|
onChange={(e) => {
|
|
299
298
|
this.setState({ geometry: e.target.checked });
|
|
@@ -446,23 +445,20 @@ export default class AddressDemo extends Component {
|
|
|
446
445
|
}
|
|
447
446
|
}
|
|
448
447
|
return (
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
withMap
|
|
464
|
-
/>
|
|
465
|
-
</>
|
|
448
|
+
<Demo
|
|
449
|
+
noheader
|
|
450
|
+
id="address-demo"
|
|
451
|
+
className="demo--address"
|
|
452
|
+
footerFilters={this.renderFooterFilters()}
|
|
453
|
+
headerFilters={this.renderHeaderFilters()}
|
|
454
|
+
request={request}
|
|
455
|
+
params={this.getRequestparams()}
|
|
456
|
+
referer="http://localhost/"
|
|
457
|
+
response={error || response}
|
|
458
|
+
result={this.renderAddress()}
|
|
459
|
+
ref={this.demoRef}
|
|
460
|
+
withMap
|
|
461
|
+
/>
|
|
466
462
|
);
|
|
467
463
|
}
|
|
468
464
|
}
|
|
@@ -15,7 +15,6 @@ import CyclingImg from '../../images/cycle.png';
|
|
|
15
15
|
import WalkingImg from '../../images/walk.png';
|
|
16
16
|
import { tr } from '../utils/locale';
|
|
17
17
|
import markerIcon from '../../images/marker.png';
|
|
18
|
-
import Script from '../utils/Script';
|
|
19
18
|
import { createWoosmapMap } from '../Map/drawOnMap';
|
|
20
19
|
|
|
21
20
|
const languages = [
|
|
@@ -382,25 +381,22 @@ export default class DistanceDemo extends Component {
|
|
|
382
381
|
),
|
|
383
382
|
};
|
|
384
383
|
return (
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
ref={this.demoRef}
|
|
402
|
-
/>
|
|
403
|
-
</>
|
|
384
|
+
<Demo
|
|
385
|
+
id="distance-demo"
|
|
386
|
+
className="demo--distance"
|
|
387
|
+
docLink="https://developers.woosmap.com/products/distance-api/get-started/"
|
|
388
|
+
header={headerLabels}
|
|
389
|
+
footerFilters={this.renderFooterFilters()}
|
|
390
|
+
headerFilters={this.renderHeaderFilters()}
|
|
391
|
+
request={this.requestUrl}
|
|
392
|
+
noheader={noheader}
|
|
393
|
+
params={this.getRequestparams()}
|
|
394
|
+
referer="http://localhost/"
|
|
395
|
+
response={error || routes}
|
|
396
|
+
result={this.renderRoutesSummary()}
|
|
397
|
+
withMap
|
|
398
|
+
ref={this.demoRef}
|
|
399
|
+
/>
|
|
404
400
|
);
|
|
405
401
|
}
|
|
406
402
|
}
|
|
@@ -8,7 +8,6 @@ import Constants from '../../Constants';
|
|
|
8
8
|
import { tr } from '../utils/locale';
|
|
9
9
|
import markerIcon from '../../images/marker-dot.svg';
|
|
10
10
|
import markerGeolocationIcon from '../../images/marker-alt.png';
|
|
11
|
-
import Script from '../utils/Script';
|
|
12
11
|
import Input from '../Input/Input';
|
|
13
12
|
|
|
14
13
|
import { WoosmapMapBoundingBox, woosmapBoundsFromViewport, createWoosmapMap } from '../Map/drawOnMap';
|
|
@@ -117,11 +116,11 @@ export default class GeolocationDemo extends Component {
|
|
|
117
116
|
|
|
118
117
|
const filterStores = {
|
|
119
118
|
label: '',
|
|
119
|
+
key: 'stores',
|
|
120
120
|
component: (
|
|
121
121
|
<Input
|
|
122
122
|
label={tr('Display Geolocation POIs')}
|
|
123
123
|
type="checkbox"
|
|
124
|
-
key="stores"
|
|
125
124
|
checked={showStores}
|
|
126
125
|
onChange={(e) => {
|
|
127
126
|
this.setState({ showStores: e.target.checked }, this.displayMap);
|
|
@@ -211,25 +210,22 @@ export default class GeolocationDemo extends Component {
|
|
|
211
210
|
}
|
|
212
211
|
}
|
|
213
212
|
return (
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
ref={this.demoRef}
|
|
231
|
-
/>
|
|
232
|
-
</>
|
|
213
|
+
<Demo
|
|
214
|
+
className="demo--geolocation"
|
|
215
|
+
docLink="https://developers.woosmap.com/products/geolocation-api/location/"
|
|
216
|
+
id="geolocation-demo"
|
|
217
|
+
header={headerLabels}
|
|
218
|
+
headerTagline={precisionInfo}
|
|
219
|
+
request={this.requestUrl}
|
|
220
|
+
params={this.getRequestparams()}
|
|
221
|
+
referer="http://localhost/"
|
|
222
|
+
noheader={noheader}
|
|
223
|
+
response={error || geolocation}
|
|
224
|
+
result={this.renderGeolocationInfo()}
|
|
225
|
+
withMap
|
|
226
|
+
footerFilters={this.renderFooterFilters()}
|
|
227
|
+
ref={this.demoRef}
|
|
228
|
+
/>
|
|
233
229
|
);
|
|
234
230
|
}
|
|
235
231
|
}
|
|
@@ -9,7 +9,6 @@ import CountrySelect from '../Select/CountrySelect';
|
|
|
9
9
|
import { tr } from '../utils/locale';
|
|
10
10
|
import Input from '../Input/Input';
|
|
11
11
|
import markerIcon from '../../images/marker.png';
|
|
12
|
-
import Script from '../utils/Script';
|
|
13
12
|
import { createWoosmapMap } from '../Map/drawOnMap';
|
|
14
13
|
|
|
15
14
|
export default class LocalitiesAddressDemo extends Component {
|
|
@@ -209,11 +208,11 @@ export default class LocalitiesAddressDemo extends Component {
|
|
|
209
208
|
};
|
|
210
209
|
const filterGeometry = {
|
|
211
210
|
label: '',
|
|
211
|
+
key: 'geometry',
|
|
212
212
|
component: (
|
|
213
213
|
<Input
|
|
214
214
|
label={tr('Geometry only')}
|
|
215
215
|
type="checkbox"
|
|
216
|
-
key="geometry"
|
|
217
216
|
checked={geometry}
|
|
218
217
|
onChange={(e) => {
|
|
219
218
|
this.setState({ geometry: e.target.checked });
|
|
@@ -344,25 +343,22 @@ export default class LocalitiesAddressDemo extends Component {
|
|
|
344
343
|
request = this.requestDetailsUrl;
|
|
345
344
|
}
|
|
346
345
|
return (
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
ref={this.demoRef}
|
|
364
|
-
/>
|
|
365
|
-
</>
|
|
346
|
+
<Demo
|
|
347
|
+
noheader={noheader}
|
|
348
|
+
header={headerLabels}
|
|
349
|
+
subHeader={subHeader}
|
|
350
|
+
id="localities-demo"
|
|
351
|
+
className="demo--localitiesaddress"
|
|
352
|
+
footerFilters={this.renderFooterFilters()}
|
|
353
|
+
headerFilters={this.renderHeaderFilters()}
|
|
354
|
+
request={request}
|
|
355
|
+
params={this.getRequestparams()}
|
|
356
|
+
referer="http://localhost/"
|
|
357
|
+
response={error || response}
|
|
358
|
+
result={this.renderAddress()}
|
|
359
|
+
withMap
|
|
360
|
+
ref={this.demoRef}
|
|
361
|
+
/>
|
|
366
362
|
);
|
|
367
363
|
}
|
|
368
364
|
}
|
|
@@ -12,7 +12,6 @@ import CountrySelect from '../Select/CountrySelect';
|
|
|
12
12
|
import Constants from '../../Constants';
|
|
13
13
|
import { tr } from '../utils/locale';
|
|
14
14
|
import markerIcon from '../../images/marker.png';
|
|
15
|
-
import Script from '../utils/Script';
|
|
16
15
|
import { WoosmapMapBoundingBox, createWoosmapMap } from '../Map/drawOnMap';
|
|
17
16
|
|
|
18
17
|
const languages = [
|
|
@@ -268,26 +267,23 @@ export default class LocalitiesDemo extends Component {
|
|
|
268
267
|
const { localities, error } = this.state;
|
|
269
268
|
const { noheader, headerLabels, subHeader } = this.props;
|
|
270
269
|
return (
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
ref={this.demoRef}
|
|
289
|
-
/>
|
|
290
|
-
</>
|
|
270
|
+
<Demo
|
|
271
|
+
id="localities-demo"
|
|
272
|
+
header={headerLabels}
|
|
273
|
+
subHeader={subHeader}
|
|
274
|
+
docLink="https://developers.woosmap.com/products/localities/get-started/"
|
|
275
|
+
className="demo--localities"
|
|
276
|
+
footerFilters={this.renderFooterFilters()}
|
|
277
|
+
headerFilters={this.renderHeaderFilters()}
|
|
278
|
+
request={this.requestUrl}
|
|
279
|
+
noheader={noheader}
|
|
280
|
+
params={this.getRequestparams()}
|
|
281
|
+
referer="http://localhost/"
|
|
282
|
+
response={error || localities}
|
|
283
|
+
result={this.renderAutocompleteList()}
|
|
284
|
+
withMap
|
|
285
|
+
ref={this.demoRef}
|
|
286
|
+
/>
|
|
291
287
|
);
|
|
292
288
|
}
|
|
293
289
|
}
|
|
@@ -8,7 +8,6 @@ import marker from '../../images/marker.png';
|
|
|
8
8
|
import markerAlt from '../../images/marker-alt.png';
|
|
9
9
|
import { tr } from '../utils/locale';
|
|
10
10
|
import Input from '../Input/Input';
|
|
11
|
-
import Script from '../utils/Script';
|
|
12
11
|
|
|
13
12
|
export default class MapDemo extends Component {
|
|
14
13
|
constructor(props) {
|
|
@@ -145,11 +144,11 @@ storesOverlay.setMap(map);
|
|
|
145
144
|
const { hasStores, hasPois } = this.state;
|
|
146
145
|
const filterPois = {
|
|
147
146
|
label: '',
|
|
147
|
+
key: 'pois',
|
|
148
148
|
component: (
|
|
149
149
|
<Input
|
|
150
150
|
label={tr('Display Map POIs')}
|
|
151
151
|
type="checkbox"
|
|
152
|
-
key="pois"
|
|
153
152
|
checked={hasPois}
|
|
154
153
|
onChange={(e) => {
|
|
155
154
|
this.setState({ hasPois: e.target.checked }, this.displayMap);
|
|
@@ -160,11 +159,11 @@ storesOverlay.setMap(map);
|
|
|
160
159
|
|
|
161
160
|
const filterStores = {
|
|
162
161
|
label: '',
|
|
162
|
+
key: 'stores',
|
|
163
163
|
component: (
|
|
164
164
|
<Input
|
|
165
165
|
label={tr('Display Woosmap Stores overlay')}
|
|
166
166
|
type="checkbox"
|
|
167
|
-
key="stores"
|
|
168
167
|
checked={hasStores}
|
|
169
168
|
onChange={(e) => {
|
|
170
169
|
this.setState({ hasStores: e.target.checked }, this.displayMap);
|
|
@@ -177,11 +176,16 @@ storesOverlay.setMap(map);
|
|
|
177
176
|
|
|
178
177
|
displayMap = () => {
|
|
179
178
|
const { style, hasStores, hasPois } = this.state;
|
|
179
|
+
|
|
180
180
|
if (this.timeoutMap) {
|
|
181
181
|
clearTimeout(this.timeoutMap);
|
|
182
182
|
}
|
|
183
|
-
|
|
183
|
+
|
|
184
|
+
const MapHTMLElement = this.demoRef?.current?.getMap();
|
|
185
|
+
|
|
186
|
+
if (window?.woosmap?.map && MapHTMLElement) {
|
|
184
187
|
window.woosmap.map.config.setApiKey('woos-48c80350-88aa-333e-835a-07f4b658a9a4');
|
|
188
|
+
|
|
185
189
|
if (!this.storeOverlay) {
|
|
186
190
|
this.storesOverlay = new window.woosmap.map.StoresOverlay({
|
|
187
191
|
breakPoint: 14,
|
|
@@ -207,12 +211,15 @@ storesOverlay.setMap(map);
|
|
|
207
211
|
},
|
|
208
212
|
});
|
|
209
213
|
}
|
|
214
|
+
|
|
210
215
|
const styles = [{ featureType: 'poi', stylers: [{ visibility: hasPois ? 'on' : 'off' }] }];
|
|
211
216
|
const colorStyle = this.applyStyle(style);
|
|
217
|
+
|
|
212
218
|
if (colorStyle) {
|
|
213
219
|
styles.push(colorStyle);
|
|
214
220
|
}
|
|
215
|
-
|
|
221
|
+
|
|
222
|
+
this.map = new window.woosmap.map.Map(MapHTMLElement, {
|
|
216
223
|
styles,
|
|
217
224
|
center: {
|
|
218
225
|
lat: 51.51,
|
|
@@ -220,9 +227,11 @@ storesOverlay.setMap(map);
|
|
|
220
227
|
},
|
|
221
228
|
zoom: 14,
|
|
222
229
|
});
|
|
230
|
+
|
|
223
231
|
if (hasStores) {
|
|
224
232
|
this.storesOverlay.setMap(this.map);
|
|
225
233
|
}
|
|
234
|
+
|
|
226
235
|
this.forceUpdate();
|
|
227
236
|
} else {
|
|
228
237
|
this.timeoutMap = setTimeout(this.displayMap, 300);
|
|
@@ -244,29 +253,28 @@ storesOverlay.setMap(map);
|
|
|
244
253
|
|
|
245
254
|
render() {
|
|
246
255
|
const { noheader } = this.props;
|
|
256
|
+
|
|
247
257
|
const headerLabels = {
|
|
248
258
|
title: tr('Map API'),
|
|
249
259
|
desc: tr(
|
|
250
260
|
'Woosmap Map is a vector tiles map based, which guarantees smooth zooming and panning transitions, a mobile-optimised loading and clear rendering at every scale. It provides a worldwide cover, cutting edge details and ability to display 3D buildings at closest/street zoom levels.'
|
|
251
261
|
),
|
|
252
262
|
};
|
|
263
|
+
|
|
253
264
|
return (
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
response={null}
|
|
268
|
-
/>
|
|
269
|
-
</>
|
|
265
|
+
<Demo
|
|
266
|
+
ref={this.demoRef}
|
|
267
|
+
header={headerLabels}
|
|
268
|
+
id="map-demo"
|
|
269
|
+
className="demo--map"
|
|
270
|
+
footerFilters={this.renderFooterFilters()}
|
|
271
|
+
headerFilters={this.renderHeaderFilters()}
|
|
272
|
+
renderCode={this.renderCode}
|
|
273
|
+
noheader={noheader}
|
|
274
|
+
referer="http://localhost/"
|
|
275
|
+
withMap
|
|
276
|
+
response={null}
|
|
277
|
+
/>
|
|
270
278
|
);
|
|
271
279
|
}
|
|
272
280
|
}
|
|
@@ -274,6 +282,7 @@ storesOverlay.setMap(map);
|
|
|
274
282
|
MapDemo.defaultProps = {
|
|
275
283
|
noheader: false,
|
|
276
284
|
};
|
|
285
|
+
|
|
277
286
|
MapDemo.propTypes = {
|
|
278
287
|
noheader: PropTypes.bool,
|
|
279
288
|
};
|
|
@@ -10,7 +10,6 @@ import LocalitiesAutocomplete from '../Woosmap/LocalitiesAutocomplete';
|
|
|
10
10
|
import { tr } from '../utils/locale';
|
|
11
11
|
import markerIcon from '../../images/marker.png';
|
|
12
12
|
import markerIconAlt from '../../images/marker-alt.png';
|
|
13
|
-
import Script from '../utils/Script';
|
|
14
13
|
import { createWoosmapMap } from '../Map/drawOnMap';
|
|
15
14
|
import 'resize-observer-polyfill/dist/ResizeObserver.global';
|
|
16
15
|
|
|
@@ -310,25 +309,22 @@ export default class SearchDemo extends Component {
|
|
|
310
309
|
),
|
|
311
310
|
};
|
|
312
311
|
return (
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
ref={this.demoRef}
|
|
330
|
-
/>
|
|
331
|
-
</>
|
|
312
|
+
<Demo
|
|
313
|
+
id="search-demo"
|
|
314
|
+
className="demo--search"
|
|
315
|
+
docLink="https://developers.woosmap.com/products/search-api/get-started/"
|
|
316
|
+
header={headerLabels}
|
|
317
|
+
footerFilters={this.renderFooterFilters()}
|
|
318
|
+
headerFilters={this.renderHeaderFilters()}
|
|
319
|
+
request={this.requestUrl}
|
|
320
|
+
params={this.getRequestparams(true)}
|
|
321
|
+
referer="http://localhost/"
|
|
322
|
+
response={error || data}
|
|
323
|
+
noheader={noheader}
|
|
324
|
+
result={this.renderStoreList()}
|
|
325
|
+
withMap
|
|
326
|
+
ref={this.demoRef}
|
|
327
|
+
/>
|
|
332
328
|
);
|
|
333
329
|
}
|
|
334
330
|
}
|
|
@@ -9,16 +9,20 @@ import Tab from '../Tab/Tab';
|
|
|
9
9
|
import CodeSnippet from '../CodeSnippet/CodeSnippet';
|
|
10
10
|
import uniqueid from '../uniqueid';
|
|
11
11
|
import TrackEventContext from '../utils/TrackEventContext';
|
|
12
|
+
import Script from '../utils/Script';
|
|
13
|
+
|
|
14
|
+
const MAP_CLASSNAME = 'map';
|
|
12
15
|
|
|
13
16
|
export default class SkeletonDemo extends Component {
|
|
14
17
|
constructor(props) {
|
|
15
18
|
super(props);
|
|
19
|
+
|
|
16
20
|
this.state = {
|
|
17
21
|
copied: false,
|
|
18
22
|
};
|
|
23
|
+
|
|
19
24
|
this.copyActionIdRequest = uniqueid();
|
|
20
25
|
this.copyActionIdResponse = uniqueid();
|
|
21
|
-
this.mapDivRef = React.createRef();
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
componentWillUnmount() {
|
|
@@ -29,9 +33,11 @@ export default class SkeletonDemo extends Component {
|
|
|
29
33
|
|
|
30
34
|
serializedParams = () => {
|
|
31
35
|
const { params } = this.props;
|
|
36
|
+
|
|
32
37
|
if (!params) {
|
|
33
38
|
return '';
|
|
34
39
|
}
|
|
40
|
+
|
|
35
41
|
return Object.entries({ ...params })
|
|
36
42
|
.map(([key, value]) => `${key}=${value}`)
|
|
37
43
|
.join('&\\\n');
|
|
@@ -40,9 +46,11 @@ export default class SkeletonDemo extends Component {
|
|
|
40
46
|
copy = (text) => {
|
|
41
47
|
const { copied } = this.state;
|
|
42
48
|
let textToCopy = text;
|
|
49
|
+
|
|
43
50
|
if (textToCopy) {
|
|
44
51
|
textToCopy = textToCopy.replace(Constants.woosmapKey, tr('YOUR_KEY_HERE'));
|
|
45
52
|
}
|
|
53
|
+
|
|
46
54
|
if (textToCopy !== null && copy(textToCopy) && !copied) {
|
|
47
55
|
this.setState({ copied: true });
|
|
48
56
|
this.copyTimeout = setTimeout(() => this.setState({ copied: false }), 1000);
|
|
@@ -59,10 +67,8 @@ export default class SkeletonDemo extends Component {
|
|
|
59
67
|
};
|
|
60
68
|
|
|
61
69
|
getMap = () => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
return null;
|
|
70
|
+
const { id } = this.props;
|
|
71
|
+
return document.querySelector(`#${id} .${MAP_CLASSNAME}`);
|
|
66
72
|
};
|
|
67
73
|
|
|
68
74
|
renderJsCode = () => {
|
|
@@ -93,17 +99,23 @@ export default class SkeletonDemo extends Component {
|
|
|
93
99
|
renderCurlCode = (removeLineBreak) => {
|
|
94
100
|
const { request, referer, body, method } = this.props;
|
|
95
101
|
let xMethod = '';
|
|
102
|
+
|
|
96
103
|
if (method) {
|
|
97
104
|
xMethod = `-X ${method} `;
|
|
98
105
|
}
|
|
106
|
+
|
|
99
107
|
let serializedParams = '';
|
|
108
|
+
|
|
100
109
|
if (this.serializedParams()) {
|
|
101
110
|
serializedParams = `?\\\n${this.serializedParams()}`;
|
|
102
111
|
}
|
|
112
|
+
|
|
103
113
|
let curl = `curl ${xMethod}"${request}${serializedParams}" `;
|
|
114
|
+
|
|
104
115
|
if (referer) {
|
|
105
116
|
curl += `\\\n -H 'referer: ${referer}'`;
|
|
106
117
|
}
|
|
118
|
+
|
|
107
119
|
if (body) {
|
|
108
120
|
curl += `\\\n -d '${body}'`;
|
|
109
121
|
}
|
|
@@ -111,14 +123,17 @@ export default class SkeletonDemo extends Component {
|
|
|
111
123
|
if (removeLineBreak) {
|
|
112
124
|
curl = curl.replaceAll('\\\n', '');
|
|
113
125
|
}
|
|
126
|
+
|
|
114
127
|
return curl;
|
|
115
128
|
};
|
|
116
129
|
|
|
117
130
|
renderHeaderTagline = () => {
|
|
118
131
|
const { headerTagline } = this.props;
|
|
132
|
+
|
|
119
133
|
if (!headerTagline) {
|
|
120
134
|
return null;
|
|
121
135
|
}
|
|
136
|
+
|
|
122
137
|
return (
|
|
123
138
|
<div className="demo__input-container">
|
|
124
139
|
<p className="demo__label demo__label--wide">{headerTagline}</p>
|
|
@@ -128,9 +143,11 @@ export default class SkeletonDemo extends Component {
|
|
|
128
143
|
|
|
129
144
|
renderHeaderFilters = () => {
|
|
130
145
|
const { headerFilters } = this.props;
|
|
146
|
+
|
|
131
147
|
if (!headerFilters) {
|
|
132
148
|
return null;
|
|
133
149
|
}
|
|
150
|
+
|
|
134
151
|
return headerFilters.map(
|
|
135
152
|
(filter) =>
|
|
136
153
|
filter && (
|
|
@@ -144,9 +161,11 @@ export default class SkeletonDemo extends Component {
|
|
|
144
161
|
|
|
145
162
|
renderFooterFilters = () => {
|
|
146
163
|
const { footerFilters } = this.props;
|
|
164
|
+
|
|
147
165
|
if (!footerFilters || footerFilters.length === 0) {
|
|
148
166
|
return null;
|
|
149
167
|
}
|
|
168
|
+
|
|
150
169
|
return footerFilters.map((filter) => (
|
|
151
170
|
<div className="demo__input-container" key={filter.label || filter.key}>
|
|
152
171
|
{filter.label ? <p className="demo__label demo__label--filter">{filter.label}</p> : false}
|
|
@@ -156,77 +175,91 @@ export default class SkeletonDemo extends Component {
|
|
|
156
175
|
};
|
|
157
176
|
|
|
158
177
|
render() {
|
|
159
|
-
const { result, request, response, renderCode, withMap, mainContent, className } = this.props;
|
|
178
|
+
const { result, request, response, renderCode, withMap, mainContent, className, id } = this.props;
|
|
160
179
|
const { copied } = this.state;
|
|
180
|
+
|
|
161
181
|
const filters = this.renderHeaderFilters();
|
|
162
182
|
const filters2 = this.renderFooterFilters();
|
|
163
183
|
const tagLine = this.renderHeaderTagline();
|
|
184
|
+
|
|
164
185
|
return (
|
|
165
|
-
|
|
166
|
-
<
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
<div className="
|
|
185
|
-
|
|
186
|
-
|
|
186
|
+
<>
|
|
187
|
+
{withMap && <Script url={Constants.woosmapMapSdkUrl} />}
|
|
188
|
+
<article className={cl('demo', className)} id={id}>
|
|
189
|
+
<div className="demo__content">
|
|
190
|
+
<div className="demo__showcase">
|
|
191
|
+
{(tagLine || filters || filters2) && (
|
|
192
|
+
<div className="demo__filters">
|
|
193
|
+
{tagLine}
|
|
194
|
+
{filters}
|
|
195
|
+
{filters2}
|
|
196
|
+
</div>
|
|
197
|
+
)}
|
|
198
|
+
|
|
199
|
+
{withMap && (
|
|
200
|
+
<div className="demo__map">
|
|
201
|
+
<div className={MAP_CLASSNAME} />
|
|
202
|
+
</div>
|
|
203
|
+
)}
|
|
204
|
+
|
|
205
|
+
{mainContent && <div className="demo__content">{mainContent}</div>}
|
|
206
|
+
</div>
|
|
207
|
+
|
|
208
|
+
<div className="demo__data">
|
|
209
|
+
{result && (
|
|
210
|
+
<div className="demo__results">
|
|
211
|
+
<div className="demo__results__header">{tr('Results')}</div>
|
|
212
|
+
<div className="demo__results__content">{result}</div>
|
|
213
|
+
</div>
|
|
214
|
+
)}
|
|
215
|
+
|
|
216
|
+
<div className="demo__code">
|
|
217
|
+
<Tab
|
|
218
|
+
actions={[
|
|
219
|
+
{
|
|
220
|
+
title: tr('Request'),
|
|
221
|
+
callback: this.copyRequest,
|
|
222
|
+
label: copied ? tr('Copied!') : tr('Copy'),
|
|
223
|
+
'data-clipboard-text': tr('Copied!'),
|
|
224
|
+
id: this.copyActionIdRequest,
|
|
225
|
+
className: copied ? 'copied' : '',
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
title: tr('Response'),
|
|
229
|
+
callback: this.copyResponse,
|
|
230
|
+
label: copied ? tr('Copied!') : tr('Copy'),
|
|
231
|
+
'data-clipboard-text': tr('Copied!'),
|
|
232
|
+
id: this.copyActionIdResponse,
|
|
233
|
+
className: copied ? 'copied' : '',
|
|
234
|
+
},
|
|
235
|
+
]}
|
|
236
|
+
>
|
|
237
|
+
{request ? (
|
|
238
|
+
<div title={tr('Request')} className="demo-api-request">
|
|
239
|
+
<CodeSnippet language="bash" codeString={this.renderCurlCode()} />
|
|
240
|
+
</div>
|
|
241
|
+
) : null}
|
|
242
|
+
|
|
243
|
+
{response ? (
|
|
244
|
+
<div title={tr('Response')} className="demo-api-response">
|
|
245
|
+
<CodeSnippet
|
|
246
|
+
language="json"
|
|
247
|
+
codeString={JSON.stringify(response, null, 2)}
|
|
248
|
+
/>
|
|
249
|
+
</div>
|
|
250
|
+
) : null}
|
|
251
|
+
|
|
252
|
+
{renderCode && (
|
|
253
|
+
<div title={tr('Code')} className="demo-api-code">
|
|
254
|
+
<CodeSnippet language="javascript" codeString={renderCode()} />
|
|
255
|
+
</div>
|
|
256
|
+
)}
|
|
257
|
+
</Tab>
|
|
187
258
|
</div>
|
|
188
|
-
)}
|
|
189
|
-
<div className="demo__code">
|
|
190
|
-
<Tab
|
|
191
|
-
actions={[
|
|
192
|
-
{
|
|
193
|
-
title: tr('Request'),
|
|
194
|
-
callback: this.copyRequest,
|
|
195
|
-
label: copied ? tr('Copied!') : tr('Copy'),
|
|
196
|
-
'data-clipboard-text': tr('Copied!'),
|
|
197
|
-
id: this.copyActionIdRequest,
|
|
198
|
-
className: copied ? 'copied' : '',
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
title: tr('Response'),
|
|
202
|
-
callback: this.copyResponse,
|
|
203
|
-
label: copied ? tr('Copied!') : tr('Copy'),
|
|
204
|
-
'data-clipboard-text': tr('Copied!'),
|
|
205
|
-
id: this.copyActionIdResponse,
|
|
206
|
-
className: copied ? 'copied' : '',
|
|
207
|
-
},
|
|
208
|
-
]}
|
|
209
|
-
>
|
|
210
|
-
{request ? (
|
|
211
|
-
<div title={tr('Request')} className="demo-api-request">
|
|
212
|
-
<CodeSnippet language="bash" codeString={this.renderCurlCode()} />
|
|
213
|
-
</div>
|
|
214
|
-
) : null}
|
|
215
|
-
{response ? (
|
|
216
|
-
<div title={tr('Response')} className="demo-api-response">
|
|
217
|
-
<CodeSnippet language="json" codeString={JSON.stringify(response, null, 2)} />
|
|
218
|
-
</div>
|
|
219
|
-
) : null}
|
|
220
|
-
{renderCode && (
|
|
221
|
-
<div title={tr('Code')} className="demo-api-code">
|
|
222
|
-
<CodeSnippet language="javascript" codeString={renderCode()} />
|
|
223
|
-
</div>
|
|
224
|
-
)}
|
|
225
|
-
</Tab>
|
|
226
259
|
</div>
|
|
227
260
|
</div>
|
|
228
|
-
</
|
|
229
|
-
|
|
261
|
+
</article>
|
|
262
|
+
</>
|
|
230
263
|
);
|
|
231
264
|
}
|
|
232
265
|
}
|
|
@@ -248,7 +281,9 @@ SkeletonDemo.defaultProps = {
|
|
|
248
281
|
method: '',
|
|
249
282
|
withMap: false,
|
|
250
283
|
className: '',
|
|
284
|
+
id: '',
|
|
251
285
|
};
|
|
286
|
+
|
|
252
287
|
SkeletonDemo.propTypes = {
|
|
253
288
|
renderCode: PropTypes.func,
|
|
254
289
|
params: PropTypes.object,
|
|
@@ -264,4 +299,5 @@ SkeletonDemo.propTypes = {
|
|
|
264
299
|
method: PropTypes.string,
|
|
265
300
|
response: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
266
301
|
className: PropTypes.string,
|
|
302
|
+
id: PropTypes.string,
|
|
267
303
|
};
|
|
@@ -3,6 +3,13 @@ import { render, screen, fireEvent } from '@testing-library/react';
|
|
|
3
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
4
4
|
|
|
5
5
|
import SkeletonDemo from './SkeletonDemo';
|
|
6
|
+
import Constants from '../../Constants';
|
|
7
|
+
|
|
8
|
+
const mockScript = jest.fn();
|
|
9
|
+
jest.mock('../utils/Script', () => (props) => {
|
|
10
|
+
mockScript(props);
|
|
11
|
+
return <mock-script />;
|
|
12
|
+
});
|
|
6
13
|
|
|
7
14
|
it('renders a SkeletonDemo component ', () => {
|
|
8
15
|
const { container } = render(<SkeletonDemo noheader id="skeleton-test" />);
|
|
@@ -15,3 +22,13 @@ it('calls copy exec command when click on copy button', () => {
|
|
|
15
22
|
fireEvent.click(screen.getByLabelText('Copy'));
|
|
16
23
|
expect(document.execCommand).toHaveBeenCalledWith('copy');
|
|
17
24
|
});
|
|
25
|
+
|
|
26
|
+
it("doesn't load woosmap sdk when withMap is falsy", () => {
|
|
27
|
+
render(<SkeletonDemo noheader id="skeleton-test" />);
|
|
28
|
+
expect(mockScript).not.toHaveBeenCalled();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('loads woosmap sdk when withMap is truthy', () => {
|
|
32
|
+
render(<SkeletonDemo noheader id="skeleton-test" withMap />);
|
|
33
|
+
expect(mockScript).toHaveBeenCalledWith({ url: Constants.woosmapMapSdkUrl });
|
|
34
|
+
});
|
|
Binary file
|
|
@@ -600,6 +600,25 @@
|
|
|
600
600
|
background-color $dark20
|
|
601
601
|
.icon
|
|
602
602
|
fill $light
|
|
603
|
+
&--notification
|
|
604
|
+
position relative
|
|
605
|
+
padding 0 .6rem !important
|
|
606
|
+
.icon
|
|
607
|
+
margin 0 !important
|
|
608
|
+
.btn__label
|
|
609
|
+
sq(1.7)
|
|
610
|
+
br(50)
|
|
611
|
+
textShadow()
|
|
612
|
+
border .1rem solid darken($success2, 20%)
|
|
613
|
+
display flex
|
|
614
|
+
align-items center
|
|
615
|
+
justify-content center
|
|
616
|
+
background-color $success2
|
|
617
|
+
font-size $fontSizeSmall
|
|
618
|
+
position absolute
|
|
619
|
+
color $light
|
|
620
|
+
top -.85rem
|
|
621
|
+
right -.85rem
|
|
603
622
|
&--small
|
|
604
623
|
buttonSmall()
|
|
605
624
|
&.btn--group
|