@jotul/jotul-widgets 1.0.4 → 1.0.5
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.
|
@@ -12,19 +12,7 @@ import { ArrowRightIcon } from '../icons/ArrowRightIcon';
|
|
|
12
12
|
import dealerPin from '../images/dealer-pin.svg';
|
|
13
13
|
import dealerPinExclusive from '../images/dealer-pin-exclusive.svg';
|
|
14
14
|
import { R10 } from '../constants';
|
|
15
|
-
const
|
|
16
|
-
const MAPTILER_FALLBACK_KEY = 'get_your_own_D6rA4zTHduk6KOKTXzGB';
|
|
17
|
-
function getMapTilerKey() {
|
|
18
|
-
if (typeof window === 'undefined')
|
|
19
|
-
return MAPTILER_FALLBACK_KEY;
|
|
20
|
-
const w = window;
|
|
21
|
-
if (typeof w.JOTUL_WIDGET_MAPTILER_KEY === 'string') {
|
|
22
|
-
const key = w.JOTUL_WIDGET_MAPTILER_KEY.trim();
|
|
23
|
-
if (key.length > 0)
|
|
24
|
-
return key;
|
|
25
|
-
}
|
|
26
|
-
return MAPTILER_FALLBACK_KEY;
|
|
27
|
-
}
|
|
15
|
+
const OSM_SMOOTH_TILE_URL = 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png';
|
|
28
16
|
function readNumber(value) {
|
|
29
17
|
if (typeof value === 'number' && Number.isFinite(value))
|
|
30
18
|
return value;
|
|
@@ -151,13 +139,12 @@ export function ProductPageWidget({ t, buttonStyling, isSearching, locationError
|
|
|
151
139
|
setActiveDealerName(dealers.length > 0 ? getDealerName(dealers[0]) : null);
|
|
152
140
|
}, [dealers]);
|
|
153
141
|
const activeMapPoint = useMemo(() => mapPoints.find((p) => p.dealerName === activeDealerName) ?? null, [activeDealerName, mapPoints]);
|
|
154
|
-
const mapTilerTileUrl = useMemo(() => `${MAPTILER_BASIC_TILE_URL}?key=${encodeURIComponent(getMapTilerKey())}`, []);
|
|
155
142
|
const listMapPills = (_jsxs("div", { className: "jwi-inline-flex jwi-items-center jwi-gap-1 jwi-rounded-full jwi-p-1", children: [_jsx("button", { type: "button", onClick: () => setViewMode('list'), className: `jwi-cursor-pointer jwi-rounded-full jwi-px-4 jwi-py-1.5 jwi-text-sm jwi-font-medium ${viewMode === 'list'
|
|
156
143
|
? 'jwi-bg-[#f0f0f0] jwi-text-[#000000]'
|
|
157
144
|
: 'jwi-bg-transparent jwi-text-[#555555]'}`, children: t.listView }), _jsx("button", { type: "button", onClick: () => setViewMode('map'), className: `jwi-cursor-pointer jwi-rounded-full jwi-px-4 jwi-py-1.5 jwi-text-sm jwi-font-medium ${viewMode === 'map'
|
|
158
145
|
? 'jwi-bg-[#f0f0f0] jwi-text-[#000000]'
|
|
159
146
|
: 'jwi-bg-transparent jwi-text-[#555555]'}`, children: t.mapView })] }));
|
|
160
|
-
const mapCanvas = (_jsxs(MapContainer, { center: defaultCenter ?? [59.9139, 10.7522], zoom: 10, className: "jwi-h-full jwi-w-full", zoomControl: true, children: [_jsx(TileLayer, { attribution: '\u00A9 <a href="https://www.
|
|
147
|
+
const mapCanvas = (_jsxs(MapContainer, { center: defaultCenter ?? [59.9139, 10.7522], zoom: 10, className: "jwi-h-full jwi-w-full", zoomControl: true, children: [_jsx(TileLayer, { attribution: '\u00A9 <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noreferrer">OpenStreetMap</a> contributors \u00A9 <a href="https://carto.com/attributions" target="_blank" rel="noreferrer">CARTO</a>', url: OSM_SMOOTH_TILE_URL }), _jsx(FitMapBounds, { points: mapPoints, defaultCenter: defaultCenter }), _jsx(FocusActiveDealer, { point: activeMapPoint }), mapPoints.map((point) => {
|
|
161
148
|
const isActive = activeDealerName === point.dealerName;
|
|
162
149
|
return (_jsx(Marker, { position: [point.latitude, point.longitude], icon: createDealerPinIcon(point.isExclusive, isActive), eventHandlers: {
|
|
163
150
|
click: () => setActiveDealerName(point.dealerName),
|