@controleonline/ui-default 1.0.263
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/.github/agents/developer.agent.md +30 -0
- package/.github/agents/devops.agent.md +30 -0
- package/.github/agents/qa.agent.md +30 -0
- package/.github/agents/security.agent.md +30 -0
- package/.scrutinizer.yml +20 -0
- package/AGENTS.md +47 -0
- package/FUNDING.yml +1 -0
- package/package.json +21 -0
- package/src/react/components/errors/DefaultErrors.js +360 -0
- package/src/react/components/files/DefaultFile.js +46 -0
- package/src/react/components/filters/CompactFilterSelector.js +262 -0
- package/src/react/components/filters/CompactFilterSelector.styles.js +124 -0
- package/src/react/components/filters/DateShortcutFilter.js +264 -0
- package/src/react/components/filters/DateShortcutFilter.styles.js +82 -0
- package/src/react/components/filters/DefaultColumnFilter.js +97 -0
- package/src/react/components/filters/DefaultColumnFilter.styles.js +21 -0
- package/src/react/components/filters/DefaultExternalFilters.js +441 -0
- package/src/react/components/filters/DefaultExternalFilters.styles.js +177 -0
- package/src/react/components/filters/DefaultSearch.js +103 -0
- package/src/react/components/filters/DefaultSearch.styles.js +70 -0
- package/src/react/components/filters/dateFilterSelection.js +29 -0
- package/src/react/components/form/DefaultForm.js +198 -0
- package/src/react/components/form/DefaultForm.styles.js +70 -0
- package/src/react/components/help/DefaultTooltip.js +87 -0
- package/src/react/components/help/DefaultTooltip.styles.js +61 -0
- package/src/react/components/inputs/DefaultInput.js +160 -0
- package/src/react/components/inputs/DefaultInput.styles.js +93 -0
- package/src/react/components/inputs/DefaultSelect.js +192 -0
- package/src/react/components/inputs/DefaultSelect.styles.js +65 -0
- package/src/react/components/inputs/defaultInputUtils.js +230 -0
- package/src/react/components/map/DefaultGoogleMap.styles.js +9 -0
- package/src/react/components/map/DefaultGoogleMap.web.js +698 -0
- package/src/react/components/map/DefaultMap.native.js +71 -0
- package/src/react/components/map/DefaultMap.shared.js +762 -0
- package/src/react/components/map/DefaultMap.styles.js +16 -0
- package/src/react/components/map/DefaultMap.web.js +66 -0
- package/src/react/components/map/DefaultNativeMap.native.js +615 -0
- package/src/react/components/map/DefaultNativeMap.shared.js +532 -0
- package/src/react/components/map/DefaultNativeMap.styles.js +122 -0
- package/src/react/components/table/DefaultTable.js +1897 -0
- package/src/react/components/table/DefaultTable.styles.js +610 -0
- package/src/react/index.js +10 -0
- package/src/react/utils/tableVisibleColumnsPreferences.js +264 -0
- package/src/store/default/actions.js +444 -0
- package/src/store/default/getters.js +28 -0
- package/src/store/default/mutation_types.js +26 -0
- package/src/store/default/mutations.js +138 -0
- package/src/tests/react/components/DateShortcutFilter.test.js +96 -0
- package/src/tests/react/components/errors/DefaultErrors.test.js +162 -0
- package/src/tests/react/components/files/DefaultFile.test.js +80 -0
- package/src/tests/react/components/map/DefaultMap.shared.test.js +162 -0
- package/src/tests/react/filters/dateFilterSelection.test.js +46 -0
- package/src/tests/react/inputs/defaultInputUtils.test.js +45 -0
- package/src/tests/react/store/defaultActions.test.js +112 -0
- package/src/tests/react/utils/tableVisibleColumnsPreferences.test.js +223 -0
- package/src/utils/filters.js +56 -0
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
import {resolveAppDomain} from '@controleonline/ui-common/src/utils/appDomain';
|
|
2
|
+
|
|
3
|
+
const serializeForHtml = value =>
|
|
4
|
+
JSON.stringify(value).replace(/</g, '\\u003c');
|
|
5
|
+
|
|
6
|
+
export const resolveWebViewBaseUrlForDomain = configuredDomain => {
|
|
7
|
+
const host = resolveAppDomain(configuredDomain);
|
|
8
|
+
return host ? `https://${host}/` : 'https://app.controleonline.com/';
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const buildAndroidWebMapHtml = ({
|
|
12
|
+
apiKey,
|
|
13
|
+
markerPayloads = [],
|
|
14
|
+
paths = [],
|
|
15
|
+
routeColor = '#0EA5E9',
|
|
16
|
+
userCoordinates = null,
|
|
17
|
+
}) => {
|
|
18
|
+
const markers = Array.isArray(markerPayloads) ? markerPayloads : [];
|
|
19
|
+
const routes = Array.isArray(paths) ? paths : [];
|
|
20
|
+
|
|
21
|
+
return `<!DOCTYPE html>
|
|
22
|
+
<html lang="pt-BR">
|
|
23
|
+
<head>
|
|
24
|
+
<meta charset="utf-8" />
|
|
25
|
+
<meta
|
|
26
|
+
name="viewport"
|
|
27
|
+
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
|
|
28
|
+
/>
|
|
29
|
+
<style>
|
|
30
|
+
html, body, #map {
|
|
31
|
+
margin: 0;
|
|
32
|
+
width: 100%;
|
|
33
|
+
height: 100%;
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
background: #f8fafc;
|
|
36
|
+
font-family: Arial, sans-serif;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
#error {
|
|
40
|
+
position: absolute;
|
|
41
|
+
inset: 0;
|
|
42
|
+
display: none;
|
|
43
|
+
align-items: center;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
padding: 24px;
|
|
46
|
+
background: rgba(15, 23, 42, 0.78);
|
|
47
|
+
color: #ffffff;
|
|
48
|
+
text-align: center;
|
|
49
|
+
font-size: 14px;
|
|
50
|
+
font-weight: 700;
|
|
51
|
+
z-index: 10;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.popup {
|
|
55
|
+
min-width: 220px;
|
|
56
|
+
max-width: 280px;
|
|
57
|
+
color: #0f172a;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.popup-company {
|
|
61
|
+
font-size: 11px;
|
|
62
|
+
font-weight: 700;
|
|
63
|
+
text-transform: uppercase;
|
|
64
|
+
letter-spacing: 0.08em;
|
|
65
|
+
color: #0369a1;
|
|
66
|
+
margin-bottom: 6px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.popup-title {
|
|
70
|
+
font-size: 16px;
|
|
71
|
+
font-weight: 700;
|
|
72
|
+
margin-bottom: 8px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.popup-line {
|
|
76
|
+
font-size: 13px;
|
|
77
|
+
line-height: 1.45;
|
|
78
|
+
color: #0f172a;
|
|
79
|
+
margin-bottom: 4px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.popup-meta-list {
|
|
83
|
+
display: grid;
|
|
84
|
+
gap: 6px;
|
|
85
|
+
margin-top: 10px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.popup-meta {
|
|
89
|
+
display: flex;
|
|
90
|
+
justify-content: space-between;
|
|
91
|
+
gap: 10px;
|
|
92
|
+
font-size: 12px;
|
|
93
|
+
color: #334155;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.popup-meta-label {
|
|
97
|
+
color: #64748b;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.popup-actions {
|
|
101
|
+
display: flex;
|
|
102
|
+
gap: 8px;
|
|
103
|
+
margin-top: 14px;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.popup-action {
|
|
107
|
+
flex: 1;
|
|
108
|
+
border-radius: 999px;
|
|
109
|
+
border: 1px solid #cbd5e1;
|
|
110
|
+
padding: 10px 12px;
|
|
111
|
+
text-align: center;
|
|
112
|
+
text-decoration: none;
|
|
113
|
+
color: #0f172a;
|
|
114
|
+
font-size: 12px;
|
|
115
|
+
font-weight: 700;
|
|
116
|
+
background: #ffffff;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.popup-action.primary {
|
|
120
|
+
border-color: transparent;
|
|
121
|
+
background: #0ea5e9;
|
|
122
|
+
color: #ffffff;
|
|
123
|
+
}
|
|
124
|
+
</style>
|
|
125
|
+
</head>
|
|
126
|
+
<body>
|
|
127
|
+
<div id="map"></div>
|
|
128
|
+
<div id="error"></div>
|
|
129
|
+
<script>
|
|
130
|
+
window.__SHOP_MAP_MARKERS__ = ${serializeForHtml(markers)};
|
|
131
|
+
window.__SHOP_MAP_PATHS__ = ${serializeForHtml(routes)};
|
|
132
|
+
window.__SHOP_MAP_USER__ = ${serializeForHtml(userCoordinates || null)};
|
|
133
|
+
|
|
134
|
+
function escapeHtml(value) {
|
|
135
|
+
return String(value || '')
|
|
136
|
+
.replace(/&/g, '&')
|
|
137
|
+
.replace(/</g, '<')
|
|
138
|
+
.replace(/>/g, '>')
|
|
139
|
+
.replace(/"/g, '"')
|
|
140
|
+
.replace(/'/g, ''');
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function postMessage(payload) {
|
|
144
|
+
if (!window.ReactNativeWebView) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
window.ReactNativeWebView.postMessage(JSON.stringify(payload));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function bridgeConsole(method) {
|
|
152
|
+
var original = console[method];
|
|
153
|
+
|
|
154
|
+
console[method] = function bridgedConsole() {
|
|
155
|
+
var args = Array.prototype.slice.call(arguments).map(function (item) {
|
|
156
|
+
if (typeof item === 'string') {
|
|
157
|
+
return item;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
try {
|
|
161
|
+
return JSON.stringify(item);
|
|
162
|
+
} catch (error) {
|
|
163
|
+
return String(item);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
postMessage({
|
|
168
|
+
type: 'console',
|
|
169
|
+
level: method,
|
|
170
|
+
message: args.join(' '),
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
if (typeof original === 'function') {
|
|
174
|
+
return original.apply(console, arguments);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return undefined;
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
bridgeConsole('log');
|
|
182
|
+
bridgeConsole('warn');
|
|
183
|
+
bridgeConsole('error');
|
|
184
|
+
|
|
185
|
+
function showError(message) {
|
|
186
|
+
var errorElement = document.getElementById('error');
|
|
187
|
+
errorElement.textContent = message;
|
|
188
|
+
errorElement.style.display = 'flex';
|
|
189
|
+
postMessage({type: 'error', message: message});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function buildPopupLine(value) {
|
|
193
|
+
if (!value) {
|
|
194
|
+
return '';
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return '<div class="popup-line">' + escapeHtml(value) + '</div>';
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function buildPopupMeta(label, value) {
|
|
201
|
+
if (!value) {
|
|
202
|
+
return '';
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
'<div class="popup-meta">' +
|
|
207
|
+
'<span class="popup-meta-label">' + escapeHtml(label) + '</span>' +
|
|
208
|
+
'<span>' + escapeHtml(value) + '</span>' +
|
|
209
|
+
'</div>'
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function buildPopupAction(url, label, className) {
|
|
214
|
+
return (
|
|
215
|
+
'<a class="popup-action ' +
|
|
216
|
+
className +
|
|
217
|
+
'" href="' + escapeHtml(url) + '">' +
|
|
218
|
+
escapeHtml(label) +
|
|
219
|
+
'</a>'
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function buildNavigationUrl(provider, latitude, longitude) {
|
|
224
|
+
if (!Number.isFinite(latitude) || !Number.isFinite(longitude)) {
|
|
225
|
+
return '';
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
var coordinates = latitude + ',' + longitude;
|
|
229
|
+
|
|
230
|
+
if (provider === 'waze') {
|
|
231
|
+
return 'https://waze.com/ul?ll=' + encodeURIComponent(coordinates) + '&navigate=yes';
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return 'https://www.google.com/maps/search/?api=1&query=' + encodeURIComponent(coordinates);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function resolveMarkerNavigationUrls(item) {
|
|
238
|
+
var latitude = Number(item && item.latitude);
|
|
239
|
+
var longitude = Number(item && item.longitude);
|
|
240
|
+
|
|
241
|
+
return {
|
|
242
|
+
googleMapsUrl: item && item.googleMapsUrl ? item.googleMapsUrl : buildNavigationUrl('google', latitude, longitude),
|
|
243
|
+
wazeUrl: item && item.wazeUrl ? item.wazeUrl : buildNavigationUrl('waze', latitude, longitude),
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function buildPopupContent(item) {
|
|
248
|
+
var navigationUrls = resolveMarkerNavigationUrls(item);
|
|
249
|
+
|
|
250
|
+
return (
|
|
251
|
+
'<div class="popup">' +
|
|
252
|
+
'<div class="popup-company">' + escapeHtml(item.companyName) + '</div>' +
|
|
253
|
+
'<div class="popup-title">' + escapeHtml(item.title) + '</div>' +
|
|
254
|
+
buildPopupLine(item.addressLine) +
|
|
255
|
+
buildPopupLine(item.addressExtra) +
|
|
256
|
+
'<div class="popup-meta-list">' +
|
|
257
|
+
buildPopupMeta('Telefone', item.phoneLabel) +
|
|
258
|
+
buildPopupMeta('Distancia', item.distanceLabel) +
|
|
259
|
+
buildPopupMeta('Horario', item.openingHours) +
|
|
260
|
+
'</div>' +
|
|
261
|
+
'<div class="popup-actions">' +
|
|
262
|
+
buildPopupAction(navigationUrls.googleMapsUrl, 'Abrir no Maps', 'primary') +
|
|
263
|
+
buildPopupAction(navigationUrls.wazeUrl, 'Waze', '') +
|
|
264
|
+
'</div>' +
|
|
265
|
+
'</div>'
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
window.handleMapError = function handleMapError() {
|
|
270
|
+
showError('Nao foi possivel carregar o Google Maps.');
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
window.gm_authFailure = function gmAuthFailure() {
|
|
274
|
+
showError('Nao foi possivel autenticar a chave do Google Maps.');
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
window.addEventListener('error', function handleWindowError(event) {
|
|
278
|
+
var message =
|
|
279
|
+
event && event.message
|
|
280
|
+
? event.message
|
|
281
|
+
: 'Ocorreu um erro ao carregar o mapa.';
|
|
282
|
+
postMessage({type: 'window-error', message: message});
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
function resolveMarkerPosition(item) {
|
|
286
|
+
var latitude = Number(item && item.latitude);
|
|
287
|
+
var longitude = Number(item && item.longitude);
|
|
288
|
+
|
|
289
|
+
if (Number.isFinite(latitude) && Number.isFinite(longitude)) {
|
|
290
|
+
return Promise.resolve({
|
|
291
|
+
item: item,
|
|
292
|
+
position: {
|
|
293
|
+
lat: latitude,
|
|
294
|
+
lng: longitude,
|
|
295
|
+
},
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (!item || !item.geocodeQuery || !window.google || !window.google.maps || !window.google.maps.Geocoder) {
|
|
300
|
+
return Promise.resolve(null);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
var geocoder = new window.google.maps.Geocoder();
|
|
304
|
+
|
|
305
|
+
return new Promise(function (resolve) {
|
|
306
|
+
geocoder.geocode({address: item.geocodeQuery}, function (results, status) {
|
|
307
|
+
if (status !== 'OK' || !results || !results[0] || !results[0].geometry || !results[0].geometry.location) {
|
|
308
|
+
resolve(null);
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
var location = results[0].geometry.location;
|
|
313
|
+
var resolvedLatitude = Number(location.lat());
|
|
314
|
+
var resolvedLongitude = Number(location.lng());
|
|
315
|
+
|
|
316
|
+
if (!Number.isFinite(resolvedLatitude) || !Number.isFinite(resolvedLongitude)) {
|
|
317
|
+
resolve(null);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
resolve({
|
|
322
|
+
item: item,
|
|
323
|
+
position: {
|
|
324
|
+
lat: resolvedLatitude,
|
|
325
|
+
lng: resolvedLongitude,
|
|
326
|
+
},
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
window.initMap = function initMap() {
|
|
333
|
+
try {
|
|
334
|
+
var markers = window.__SHOP_MAP_MARKERS__ || [];
|
|
335
|
+
var paths = window.__SHOP_MAP_PATHS__ || [];
|
|
336
|
+
var userCoordinates = window.__SHOP_MAP_USER__;
|
|
337
|
+
|
|
338
|
+
if (!window.google || (!markers.length && !paths.length && !userCoordinates)) {
|
|
339
|
+
showError('Nao foi possivel localizar as franquias no mapa.');
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
Promise.all(markers.map(resolveMarkerPosition)).then(function (resolvedMarkers) {
|
|
344
|
+
resolvedMarkers = (resolvedMarkers || []).filter(function (entry) {
|
|
345
|
+
return entry && entry.position;
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
var map = new window.google.maps.Map(document.getElementById('map'), {
|
|
349
|
+
mapTypeControl: false,
|
|
350
|
+
streetViewControl: false,
|
|
351
|
+
fullscreenControl: false,
|
|
352
|
+
clickableIcons: false,
|
|
353
|
+
gestureHandling: 'greedy',
|
|
354
|
+
zoomControl: false,
|
|
355
|
+
disableDefaultUI: true,
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
var bounds = new window.google.maps.LatLngBounds();
|
|
359
|
+
var infoWindow = new window.google.maps.InfoWindow({maxWidth: 320});
|
|
360
|
+
var hasUserCoordinates =
|
|
361
|
+
userCoordinates &&
|
|
362
|
+
Number.isFinite(userCoordinates.latitude) &&
|
|
363
|
+
Number.isFinite(userCoordinates.longitude);
|
|
364
|
+
var directionsService = hasUserCoordinates
|
|
365
|
+
? new window.google.maps.DirectionsService()
|
|
366
|
+
: null;
|
|
367
|
+
var directionsRenderer = directionsService
|
|
368
|
+
? new window.google.maps.DirectionsRenderer({
|
|
369
|
+
map: map,
|
|
370
|
+
suppressMarkers: true,
|
|
371
|
+
preserveViewport: false,
|
|
372
|
+
polylineOptions: {
|
|
373
|
+
strokeColor: ${serializeForHtml(routeColor)},
|
|
374
|
+
strokeOpacity: 0.92,
|
|
375
|
+
strokeWeight: 5,
|
|
376
|
+
},
|
|
377
|
+
})
|
|
378
|
+
: null;
|
|
379
|
+
var activeRouteRequestId = 0;
|
|
380
|
+
var resolvePathPosition = function resolvePathPosition(point) {
|
|
381
|
+
if (!point) {
|
|
382
|
+
return null;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
var latitude = Number(point.latitude);
|
|
386
|
+
var longitude = Number(point.longitude);
|
|
387
|
+
|
|
388
|
+
if (!Number.isFinite(latitude) || !Number.isFinite(longitude)) {
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
return {
|
|
393
|
+
lat: latitude,
|
|
394
|
+
lng: longitude,
|
|
395
|
+
};
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
if (hasUserCoordinates) {
|
|
399
|
+
var userPosition = {
|
|
400
|
+
lat: userCoordinates.latitude,
|
|
401
|
+
lng: userCoordinates.longitude,
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
new window.google.maps.Marker({
|
|
405
|
+
position: userPosition,
|
|
406
|
+
map: map,
|
|
407
|
+
title: 'Sua localizacao',
|
|
408
|
+
zIndex: 999,
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
bounds.extend(userPosition);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
resolvedMarkers.forEach(function (entry) {
|
|
415
|
+
var item = entry.item;
|
|
416
|
+
var position = entry.position;
|
|
417
|
+
var markerOptions = {
|
|
418
|
+
position: position,
|
|
419
|
+
map: map,
|
|
420
|
+
title: item.title,
|
|
421
|
+
animation: window.google.maps.Animation.DROP,
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
if (item.markerIconUrl) {
|
|
425
|
+
markerOptions.icon = {
|
|
426
|
+
url: item.markerIconUrl,
|
|
427
|
+
scaledSize: new window.google.maps.Size(42, 42),
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
var marker = new window.google.maps.Marker(markerOptions);
|
|
432
|
+
|
|
433
|
+
bounds.extend(position);
|
|
434
|
+
|
|
435
|
+
marker.addListener('click', function () {
|
|
436
|
+
infoWindow.setContent(buildPopupContent(item));
|
|
437
|
+
infoWindow.open({
|
|
438
|
+
anchor: marker,
|
|
439
|
+
map: map,
|
|
440
|
+
shouldFocus: false,
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
if (!directionsService || !directionsRenderer) {
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
var routeRequestId = activeRouteRequestId + 1;
|
|
448
|
+
activeRouteRequestId = routeRequestId;
|
|
449
|
+
|
|
450
|
+
directionsService.route(
|
|
451
|
+
{
|
|
452
|
+
origin: {
|
|
453
|
+
lat: userCoordinates.latitude,
|
|
454
|
+
lng: userCoordinates.longitude,
|
|
455
|
+
},
|
|
456
|
+
destination: position,
|
|
457
|
+
travelMode: window.google.maps.TravelMode.DRIVING,
|
|
458
|
+
},
|
|
459
|
+
function (response, status) {
|
|
460
|
+
if (routeRequestId !== activeRouteRequestId) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
if (status === 'OK' && response) {
|
|
465
|
+
directionsRenderer.setDirections(response);
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
directionsRenderer.set('directions', null);
|
|
470
|
+
},
|
|
471
|
+
);
|
|
472
|
+
});
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
paths.forEach(function (path) {
|
|
476
|
+
var from = resolvePathPosition(path && path.from);
|
|
477
|
+
var to = resolvePathPosition(path && path.to);
|
|
478
|
+
|
|
479
|
+
if (!from || !to) {
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
bounds.extend(from);
|
|
484
|
+
bounds.extend(to);
|
|
485
|
+
|
|
486
|
+
new window.google.maps.Polyline({
|
|
487
|
+
path: [from, to],
|
|
488
|
+
geodesic: true,
|
|
489
|
+
strokeColor: path && path.color ? path.color : ${serializeForHtml(routeColor)},
|
|
490
|
+
strokeOpacity: 0.72,
|
|
491
|
+
strokeWeight: 4,
|
|
492
|
+
map: map,
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
if (bounds.isEmpty()) {
|
|
497
|
+
showError('Nao foi possivel localizar as franquias no mapa.');
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
map.fitBounds(bounds, {
|
|
502
|
+
top: 56,
|
|
503
|
+
right: 32,
|
|
504
|
+
bottom: 56,
|
|
505
|
+
left: 32,
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
postMessage({type: 'ready'});
|
|
509
|
+
|
|
510
|
+
window.google.maps.event.addListenerOnce(map, 'idle', function () {
|
|
511
|
+
if (resolvedMarkers.length === 1 && map.getZoom() > 15) {
|
|
512
|
+
map.setZoom(15);
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
}).catch(function () {
|
|
516
|
+
showError('Nao foi possivel localizar as franquias no mapa.');
|
|
517
|
+
});
|
|
518
|
+
} catch (error) {
|
|
519
|
+
showError('Nao foi possivel carregar o Google Maps.');
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
</script>
|
|
523
|
+
<script
|
|
524
|
+
async
|
|
525
|
+
defer
|
|
526
|
+
src="https://maps.googleapis.com/maps/api/js?key=${encodeURIComponent(
|
|
527
|
+
apiKey,
|
|
528
|
+
)}&loading=async&callback=initMap"
|
|
529
|
+
onerror="handleMapError()"></script>
|
|
530
|
+
</body>
|
|
531
|
+
</html>`;
|
|
532
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import {StyleSheet} from 'react-native';
|
|
2
|
+
|
|
3
|
+
export default StyleSheet.create({
|
|
4
|
+
mapContainer: {
|
|
5
|
+
width: '100%',
|
|
6
|
+
height: '100%',
|
|
7
|
+
position: 'relative',
|
|
8
|
+
backgroundColor: '#E5EEF5',
|
|
9
|
+
},
|
|
10
|
+
mapViewport: {
|
|
11
|
+
width: '100%',
|
|
12
|
+
height: '100%',
|
|
13
|
+
},
|
|
14
|
+
mapOverlay: {
|
|
15
|
+
...StyleSheet.absoluteFillObject,
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
justifyContent: 'center',
|
|
18
|
+
paddingHorizontal: 24,
|
|
19
|
+
backgroundColor: 'rgba(248, 250, 252, 0.9)',
|
|
20
|
+
gap: 12,
|
|
21
|
+
},
|
|
22
|
+
mapOverlayText: {
|
|
23
|
+
fontSize: 14,
|
|
24
|
+
lineHeight: 20,
|
|
25
|
+
color: '#0F172A',
|
|
26
|
+
textAlign: 'center',
|
|
27
|
+
fontWeight: '600',
|
|
28
|
+
},
|
|
29
|
+
markerWrap: {
|
|
30
|
+
width: 44,
|
|
31
|
+
height: 44,
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
justifyContent: 'center',
|
|
34
|
+
},
|
|
35
|
+
markerIcon: {
|
|
36
|
+
width: 42,
|
|
37
|
+
height: 42,
|
|
38
|
+
},
|
|
39
|
+
calloutCard: {
|
|
40
|
+
minWidth: 228,
|
|
41
|
+
maxWidth: 288,
|
|
42
|
+
borderRadius: 18,
|
|
43
|
+
paddingHorizontal: 14,
|
|
44
|
+
paddingVertical: 14,
|
|
45
|
+
backgroundColor: '#FFFFFF',
|
|
46
|
+
shadowColor: '#0F172A',
|
|
47
|
+
shadowOpacity: 0.18,
|
|
48
|
+
shadowRadius: 16,
|
|
49
|
+
shadowOffset: {
|
|
50
|
+
width: 0,
|
|
51
|
+
height: 8,
|
|
52
|
+
},
|
|
53
|
+
elevation: 10,
|
|
54
|
+
},
|
|
55
|
+
companyName: {
|
|
56
|
+
fontSize: 11,
|
|
57
|
+
fontWeight: '700',
|
|
58
|
+
textTransform: 'uppercase',
|
|
59
|
+
letterSpacing: 0.6,
|
|
60
|
+
color: '#0369A1',
|
|
61
|
+
marginBottom: 6,
|
|
62
|
+
},
|
|
63
|
+
title: {
|
|
64
|
+
fontSize: 16,
|
|
65
|
+
fontWeight: '700',
|
|
66
|
+
color: '#0F172A',
|
|
67
|
+
marginBottom: 8,
|
|
68
|
+
},
|
|
69
|
+
line: {
|
|
70
|
+
fontSize: 13,
|
|
71
|
+
lineHeight: 19,
|
|
72
|
+
color: '#0F172A',
|
|
73
|
+
marginBottom: 4,
|
|
74
|
+
},
|
|
75
|
+
metaList: {
|
|
76
|
+
marginTop: 10,
|
|
77
|
+
gap: 6,
|
|
78
|
+
},
|
|
79
|
+
metaRow: {
|
|
80
|
+
flexDirection: 'row',
|
|
81
|
+
justifyContent: 'space-between',
|
|
82
|
+
gap: 10,
|
|
83
|
+
},
|
|
84
|
+
metaLabel: {
|
|
85
|
+
fontSize: 12,
|
|
86
|
+
color: '#64748B',
|
|
87
|
+
},
|
|
88
|
+
metaValue: {
|
|
89
|
+
flex: 1,
|
|
90
|
+
fontSize: 12,
|
|
91
|
+
color: '#334155',
|
|
92
|
+
textAlign: 'right',
|
|
93
|
+
},
|
|
94
|
+
actionsRow: {
|
|
95
|
+
flexDirection: 'row',
|
|
96
|
+
gap: 8,
|
|
97
|
+
marginTop: 14,
|
|
98
|
+
},
|
|
99
|
+
actionButton: {
|
|
100
|
+
flex: 1,
|
|
101
|
+
minHeight: 38,
|
|
102
|
+
borderRadius: 999,
|
|
103
|
+
borderWidth: 1,
|
|
104
|
+
borderColor: '#CBD5E1',
|
|
105
|
+
alignItems: 'center',
|
|
106
|
+
justifyContent: 'center',
|
|
107
|
+
paddingHorizontal: 12,
|
|
108
|
+
backgroundColor: '#FFFFFF',
|
|
109
|
+
},
|
|
110
|
+
actionButtonPrimary: {
|
|
111
|
+
borderColor: 'transparent',
|
|
112
|
+
backgroundColor: '#0EA5E9',
|
|
113
|
+
},
|
|
114
|
+
actionText: {
|
|
115
|
+
fontSize: 12,
|
|
116
|
+
fontWeight: '700',
|
|
117
|
+
color: '#0F172A',
|
|
118
|
+
},
|
|
119
|
+
actionTextPrimary: {
|
|
120
|
+
color: '#FFFFFF',
|
|
121
|
+
},
|
|
122
|
+
});
|