@woosmap/ui 3.106.0 → 3.109.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
CHANGED
|
@@ -7,8 +7,19 @@ import { tr } from '../utils/locale';
|
|
|
7
7
|
|
|
8
8
|
class SimpleCard extends Component {
|
|
9
9
|
render() {
|
|
10
|
-
const {
|
|
11
|
-
|
|
10
|
+
const {
|
|
11
|
+
title,
|
|
12
|
+
subtitle,
|
|
13
|
+
className,
|
|
14
|
+
testId,
|
|
15
|
+
children,
|
|
16
|
+
isSelected,
|
|
17
|
+
isActive,
|
|
18
|
+
isDisabled,
|
|
19
|
+
isFavorite,
|
|
20
|
+
isInline,
|
|
21
|
+
...rest
|
|
22
|
+
} = this.props;
|
|
12
23
|
return (
|
|
13
24
|
<div
|
|
14
25
|
className={cl(
|
|
@@ -16,6 +27,7 @@ class SimpleCard extends Component {
|
|
|
16
27
|
{ active: isActive },
|
|
17
28
|
{ disabled: isDisabled },
|
|
18
29
|
{ 'simplecard--selected': isSelected },
|
|
30
|
+
{ inline: isInline },
|
|
19
31
|
className
|
|
20
32
|
)}
|
|
21
33
|
data-testid={testId}
|
|
@@ -59,6 +71,7 @@ SimpleCard.defaultProps = {
|
|
|
59
71
|
isActive: false,
|
|
60
72
|
isDisabled: false,
|
|
61
73
|
isFavorite: false,
|
|
74
|
+
isInline: false,
|
|
62
75
|
};
|
|
63
76
|
|
|
64
77
|
SimpleCard.propTypes = {
|
|
@@ -71,6 +84,7 @@ SimpleCard.propTypes = {
|
|
|
71
84
|
className: PropTypes.string,
|
|
72
85
|
testId: PropTypes.string,
|
|
73
86
|
isFavorite: PropTypes.bool,
|
|
87
|
+
isInline: PropTypes.bool,
|
|
74
88
|
};
|
|
75
89
|
|
|
76
90
|
export default SimpleCard;
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
padding 1.6rem
|
|
8
8
|
border .1rem solid $secondary20
|
|
9
9
|
cursor pointer
|
|
10
|
+
&.inline
|
|
11
|
+
flex-direction row
|
|
12
|
+
align-items center
|
|
10
13
|
&:hover
|
|
11
14
|
box-shadow 0 0 .6rem $secondary20
|
|
12
15
|
border .1rem solid $secondary60
|
|
@@ -29,9 +32,18 @@
|
|
|
29
32
|
&__title
|
|
30
33
|
font-weight 600
|
|
31
34
|
margin-bottom .2rem
|
|
35
|
+
.inline &
|
|
36
|
+
ellipsis()
|
|
37
|
+
order 1
|
|
38
|
+
margin-right 1.2rem
|
|
39
|
+
margin-bottom 0
|
|
32
40
|
&__subtitle
|
|
33
41
|
font-size $fontSizeSmall
|
|
34
42
|
color $secondary60
|
|
43
|
+
.inline &
|
|
44
|
+
order 3
|
|
45
|
+
margin-left auto
|
|
46
|
+
white-space nowrap
|
|
35
47
|
&__content
|
|
36
48
|
margin-top auto
|
|
37
49
|
padding-top 1rem
|
|
@@ -43,6 +55,14 @@
|
|
|
43
55
|
right 1rem
|
|
44
56
|
top 1.3rem
|
|
45
57
|
fill $favorite
|
|
58
|
+
.inline &
|
|
59
|
+
sq(1.8)
|
|
60
|
+
position unset
|
|
61
|
+
top unset
|
|
62
|
+
right unset
|
|
63
|
+
order 2
|
|
64
|
+
flex-shrink 0
|
|
65
|
+
margin-right 1.2rem
|
|
46
66
|
.tooltip
|
|
47
67
|
position relative
|
|
48
68
|
$mr = -.2rem
|
|
@@ -37,6 +37,12 @@ const units = [
|
|
|
37
37
|
{ value: 'metric', label: 'Metric' },
|
|
38
38
|
{ value: 'imperial', label: 'Imperial' },
|
|
39
39
|
];
|
|
40
|
+
|
|
41
|
+
const methods = [
|
|
42
|
+
{ value: 'distance', label: 'Shortest' },
|
|
43
|
+
{ value: 'time', label: 'Fastest' },
|
|
44
|
+
];
|
|
45
|
+
|
|
40
46
|
export default class DistanceDemo extends Component {
|
|
41
47
|
constructor(props) {
|
|
42
48
|
super(props);
|
|
@@ -60,6 +66,7 @@ export default class DistanceDemo extends Component {
|
|
|
60
66
|
originLocation: this.defaultOrigin.location,
|
|
61
67
|
destinationLocation: this.defaultDestination.location,
|
|
62
68
|
unit: units[0],
|
|
69
|
+
method: methods[0],
|
|
63
70
|
travelMode: travelModes[0],
|
|
64
71
|
language: (defaultLang || languages[1]).value,
|
|
65
72
|
alternatives: false,
|
|
@@ -161,12 +168,14 @@ export default class DistanceDemo extends Component {
|
|
|
161
168
|
})
|
|
162
169
|
.catch((error) => {
|
|
163
170
|
const errorResult = error?.data?.error_message ?? 'Unhandled error';
|
|
164
|
-
this.
|
|
171
|
+
if (this.mounted) {
|
|
172
|
+
this.setState({ error: errorResult });
|
|
173
|
+
}
|
|
165
174
|
});
|
|
166
175
|
};
|
|
167
176
|
|
|
168
177
|
getRequestparams = () => {
|
|
169
|
-
const { language, originLocation, destinationLocation, unit, travelMode, alternatives } = this.state;
|
|
178
|
+
const { language, originLocation, destinationLocation, unit, method, travelMode, alternatives } = this.state;
|
|
170
179
|
|
|
171
180
|
return {
|
|
172
181
|
key: Constants.woosmapKey,
|
|
@@ -174,6 +183,7 @@ export default class DistanceDemo extends Component {
|
|
|
174
183
|
destination: `${destinationLocation.lat},${destinationLocation.lng}`,
|
|
175
184
|
language,
|
|
176
185
|
units: unit.value,
|
|
186
|
+
method: method.value,
|
|
177
187
|
mode: travelMode.value,
|
|
178
188
|
alternatives,
|
|
179
189
|
};
|
|
@@ -264,7 +274,7 @@ export default class DistanceDemo extends Component {
|
|
|
264
274
|
};
|
|
265
275
|
|
|
266
276
|
renderFooterFilters = () => {
|
|
267
|
-
const { unit, travelMode, language, alternatives } = this.state;
|
|
277
|
+
const { unit, method, travelMode, language, alternatives } = this.state;
|
|
268
278
|
|
|
269
279
|
const filterTravelMode = {
|
|
270
280
|
key: 'travelmode',
|
|
@@ -304,7 +314,26 @@ export default class DistanceDemo extends Component {
|
|
|
304
314
|
),
|
|
305
315
|
};
|
|
306
316
|
|
|
317
|
+
const filterMethod = {
|
|
318
|
+
key: 'method',
|
|
319
|
+
component: (
|
|
320
|
+
<ButtonGroup isLight>
|
|
321
|
+
{methods.map((item) => (
|
|
322
|
+
<Button
|
|
323
|
+
type="group"
|
|
324
|
+
size="small"
|
|
325
|
+
key={item.value}
|
|
326
|
+
label={item.label}
|
|
327
|
+
active={item === method}
|
|
328
|
+
onClick={() => this.setState({ method: item }, this.requestDistance)}
|
|
329
|
+
/>
|
|
330
|
+
))}
|
|
331
|
+
</ButtonGroup>
|
|
332
|
+
),
|
|
333
|
+
};
|
|
334
|
+
|
|
307
335
|
const filterLanguage = {
|
|
336
|
+
key: 'language',
|
|
308
337
|
label: tr('Language'),
|
|
309
338
|
component: (
|
|
310
339
|
<ButtonGroup className="language" isLight>
|
|
@@ -326,6 +355,7 @@ export default class DistanceDemo extends Component {
|
|
|
326
355
|
};
|
|
327
356
|
|
|
328
357
|
const filterAlternatives = {
|
|
358
|
+
key: 'alternatives',
|
|
329
359
|
label: '',
|
|
330
360
|
component: (
|
|
331
361
|
<Input
|
|
@@ -339,7 +369,7 @@ export default class DistanceDemo extends Component {
|
|
|
339
369
|
),
|
|
340
370
|
};
|
|
341
371
|
|
|
342
|
-
return [filterAlternatives, filterTravelMode,
|
|
372
|
+
return [filterAlternatives, filterTravelMode, filterMethod, filterLanguage, filterUnit];
|
|
343
373
|
};
|
|
344
374
|
|
|
345
375
|
render() {
|
|
@@ -23,6 +23,13 @@ it('test metrics button', () => {
|
|
|
23
23
|
expect(screen.getByText('units=imperial&\\')).toBeVisible();
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
+
it('test method button', () => {
|
|
27
|
+
render(<DistanceDemo />);
|
|
28
|
+
expect(screen.getByText('method=distance&\\')).toBeVisible();
|
|
29
|
+
fireEvent.click(screen.getByLabelText('Fastest'));
|
|
30
|
+
expect(screen.getByText('method=time&\\')).toBeVisible();
|
|
31
|
+
});
|
|
32
|
+
|
|
26
33
|
it('test language button', () => {
|
|
27
34
|
render(<DistanceDemo />);
|
|
28
35
|
expect(screen.getByText('language=gb&\\')).toBeVisible();
|
|
@@ -33,11 +40,11 @@ it('test language button', () => {
|
|
|
33
40
|
it('test alternative route checkbox', () => {
|
|
34
41
|
render(<DistanceDemo />);
|
|
35
42
|
expect(screen.getByText('alternatives=false"')).toBeVisible();
|
|
36
|
-
|
|
37
|
-
const checkbox = screen.getByText('Alternative routes').parentElement.querySelectorAll('input')[0];
|
|
43
|
+
const [checkbox] = screen.getByText('Alternative routes').parentElement.querySelectorAll('input');
|
|
38
44
|
fireEvent.click(checkbox);
|
|
39
45
|
expect(screen.getByText('alternatives=true"')).toBeVisible();
|
|
40
46
|
});
|
|
47
|
+
|
|
41
48
|
it('catches 200 with error', async () => {
|
|
42
49
|
const backup = axios.create;
|
|
43
50
|
axios.create = () => ({
|
|
@@ -147,16 +147,12 @@ export default class SkeletonDemo extends Component {
|
|
|
147
147
|
if (!footerFilters || footerFilters.length === 0) {
|
|
148
148
|
return null;
|
|
149
149
|
}
|
|
150
|
-
return (
|
|
151
|
-
|
|
152
|
-
{
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
</div>
|
|
157
|
-
))}
|
|
158
|
-
</>
|
|
159
|
-
);
|
|
150
|
+
return footerFilters.map((filter) => (
|
|
151
|
+
<div className="demo__input-container" key={filter.label || filter.key}>
|
|
152
|
+
{filter.label ? <p className="demo__label demo__label--filter">{filter.label}</p> : false}
|
|
153
|
+
{filter.component}
|
|
154
|
+
</div>
|
|
155
|
+
));
|
|
160
156
|
};
|
|
161
157
|
|
|
162
158
|
render() {
|