@bpd-library/components 1.3.2-beta.12 → 1.3.2-beta.13
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 +4 -4
- package/dist/esm/atoms/button/button.js +0 -33
- package/dist/esm/atoms/button/button.js.map +0 -1
- package/dist/esm/atoms/col/col.js +0 -22
- package/dist/esm/atoms/col/col.js.map +0 -1
- package/dist/esm/atoms/container/container.js +0 -6
- package/dist/esm/atoms/container/container.js.map +0 -1
- package/dist/esm/atoms/form-elements/range-slider/range-slider.js +0 -21
- package/dist/esm/atoms/form-elements/range-slider/range-slider.js.map +0 -1
- package/dist/esm/atoms/form-elements/utilities/range-slider.js +0 -100
- package/dist/esm/atoms/form-elements/utilities/range-slider.js.map +0 -1
- package/dist/esm/atoms/image/image.js +0 -18
- package/dist/esm/atoms/image/image.js.map +0 -1
- package/dist/esm/atoms/image/utilities/create-image-url.js +0 -15
- package/dist/esm/atoms/image/utilities/create-image-url.js.map +0 -1
- package/dist/esm/atoms/row/row.js +0 -6
- package/dist/esm/atoms/row/row.js.map +0 -1
- package/dist/esm/atoms/svg/svg.js +0 -25
- package/dist/esm/atoms/svg/svg.js.map +0 -1
- package/dist/esm/index.js +0 -14
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/molecules/infobox/infobox.js +0 -20
- package/dist/esm/molecules/infobox/infobox.js.map +0 -1
- package/dist/esm/molecules/map/map.js +0 -256
- package/dist/esm/molecules/map/map.js.map +0 -1
- package/dist/esm/molecules/map/store/map/store.js +0 -150
- package/dist/esm/molecules/map/store/map/store.js.map +0 -1
- package/dist/esm/molecules/map/utilities/fit-bounds.js +0 -4
- package/dist/esm/molecules/map/utilities/fit-bounds.js.map +0 -1
- package/dist/esm/molecules/map/utilities/mapbox/add-data.js +0 -54
- package/dist/esm/molecules/map/utilities/mapbox/add-data.js.map +0 -1
- package/dist/esm/molecules/map/utilities/mapbox/center.js +0 -15
- package/dist/esm/molecules/map/utilities/mapbox/center.js.map +0 -1
- package/dist/esm/molecules/map/utilities/mapbox/constants.js +0 -5
- package/dist/esm/molecules/map/utilities/mapbox/constants.js.map +0 -1
- package/dist/esm/molecules/map/utilities/mapbox/index.js +0 -3
- package/dist/esm/molecules/map/utilities/mapbox/index.js.map +0 -1
- package/dist/esm/molecules/map/utilities/mapbox/mapbox.js +0 -27
- package/dist/esm/molecules/map/utilities/mapbox/mapbox.js.map +0 -1
- package/dist/esm/molecules/map/utilities/mapbox/parse-feature-properties.js +0 -18
- package/dist/esm/molecules/map/utilities/mapbox/parse-feature-properties.js.map +0 -1
- package/dist/esm/molecules/map/utilities/mapbox/pointers/setup-pointers.js +0 -151
- package/dist/esm/molecules/map/utilities/mapbox/pointers/setup-pointers.js.map +0 -1
- package/dist/esm/molecules/map/utilities/mapbox/polygons/feature-state.js +0 -11
- package/dist/esm/molecules/map/utilities/mapbox/polygons/feature-state.js.map +0 -1
- package/dist/esm/molecules/map/utilities/mapbox/polygons/geojson.js +0 -10
- package/dist/esm/molecules/map/utilities/mapbox/polygons/geojson.js.map +0 -1
- package/dist/esm/molecules/map/utilities/mapbox/polygons/interaction.js +0 -34
- package/dist/esm/molecules/map/utilities/mapbox/polygons/interaction.js.map +0 -1
- package/dist/esm/molecules/map/utilities/mapbox/polygons/layer.js +0 -110
- package/dist/esm/molecules/map/utilities/mapbox/polygons/layer.js.map +0 -1
- package/dist/esm/molecules/map/utilities/mapbox/raster.js +0 -43
- package/dist/esm/molecules/map/utilities/mapbox/raster.js.map +0 -1
- package/dist/esm/molecules/map/utilities/mapbox/search/alternative-city-suggestions.js +0 -27
- package/dist/esm/molecules/map/utilities/mapbox/search/alternative-city-suggestions.js.map +0 -1
- package/dist/esm/molecules/map/utilities/mapbox/search/search.js +0 -174
- package/dist/esm/molecules/map/utilities/mapbox/search/search.js.map +0 -1
- package/dist/esm/molecules/map/utilities/mapbox/tooltip.js +0 -26
- package/dist/esm/molecules/map/utilities/mapbox/tooltip.js.map +0 -1
- package/dist/esm/molecules/tooltip/tooltip.js +0 -14
- package/dist/esm/molecules/tooltip/tooltip.js.map +0 -1
- package/dist/esm/node_modules/tslib/tslib.es6.js +0 -24
- package/dist/esm/node_modules/tslib/tslib.es6.js.map +0 -1
- package/dist/lib/atoms/button/button.js +0 -31
- package/dist/lib/atoms/button/button.js.map +0 -1
- package/dist/lib/atoms/button/index.js +0 -2
- package/dist/lib/atoms/button/index.js.map +0 -1
- package/dist/lib/atoms/col/col.js +0 -19
- package/dist/lib/atoms/col/col.js.map +0 -1
- package/dist/lib/atoms/container/container.js +0 -3
- package/dist/lib/atoms/container/container.js.map +0 -1
- package/dist/lib/atoms/form-elements/range-slider/range-slider.js +0 -18
- package/dist/lib/atoms/form-elements/range-slider/range-slider.js.map +0 -1
- package/dist/lib/atoms/form-elements/utilities/range-slider.js +0 -97
- package/dist/lib/atoms/form-elements/utilities/range-slider.js.map +0 -1
- package/dist/lib/atoms/image/image.js +0 -15
- package/dist/lib/atoms/image/image.js.map +0 -1
- package/dist/lib/atoms/image/index.js +0 -2
- package/dist/lib/atoms/image/index.js.map +0 -1
- package/dist/lib/atoms/image/utilities/create-image-url.js +0 -14
- package/dist/lib/atoms/image/utilities/create-image-url.js.map +0 -1
- package/dist/lib/atoms/image/utilities/detect-responsive-images.js +0 -24
- package/dist/lib/atoms/image/utilities/detect-responsive-images.js.map +0 -1
- package/dist/lib/atoms/image/utilities/image.js +0 -86
- package/dist/lib/atoms/image/utilities/image.js.map +0 -1
- package/dist/lib/atoms/image/utilities/object-fit.js +0 -35
- package/dist/lib/atoms/image/utilities/object-fit.js.map +0 -1
- package/dist/lib/atoms/row/row.js +0 -3
- package/dist/lib/atoms/row/row.js.map +0 -1
- package/dist/lib/atoms/svg/svg.js +0 -23
- package/dist/lib/atoms/svg/svg.js.map +0 -1
- package/dist/lib/index.js +0 -12
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/molecules/infobox/index.js +0 -2
- package/dist/lib/molecules/infobox/index.js.map +0 -1
- package/dist/lib/molecules/infobox/infobox.js +0 -17
- package/dist/lib/molecules/infobox/infobox.js.map +0 -1
- package/dist/lib/molecules/map/hooks/use-style-loaded.js +0 -14
- package/dist/lib/molecules/map/hooks/use-style-loaded.js.map +0 -1
- package/dist/lib/molecules/map/index.js +0 -4
- package/dist/lib/molecules/map/index.js.map +0 -1
- package/dist/lib/molecules/map/map.js +0 -256
- package/dist/lib/molecules/map/map.js.map +0 -1
- package/dist/lib/molecules/map/store/map/index.js +0 -2
- package/dist/lib/molecules/map/store/map/index.js.map +0 -1
- package/dist/lib/molecules/map/store/map/store.js +0 -147
- package/dist/lib/molecules/map/store/map/store.js.map +0 -1
- package/dist/lib/molecules/map/storybook/themes.js +0 -54
- package/dist/lib/molecules/map/storybook/themes.js.map +0 -1
- package/dist/lib/molecules/map/utilities/fit-bounds.js +0 -2
- package/dist/lib/molecules/map/utilities/fit-bounds.js.map +0 -1
- package/dist/lib/molecules/map/utilities/mapbox/add-data.js +0 -52
- package/dist/lib/molecules/map/utilities/mapbox/add-data.js.map +0 -1
- package/dist/lib/molecules/map/utilities/mapbox/center.js +0 -13
- package/dist/lib/molecules/map/utilities/mapbox/center.js.map +0 -1
- package/dist/lib/molecules/map/utilities/mapbox/constants.js +0 -3
- package/dist/lib/molecules/map/utilities/mapbox/constants.js.map +0 -1
- package/dist/lib/molecules/map/utilities/mapbox/index.js +0 -3
- package/dist/lib/molecules/map/utilities/mapbox/index.js.map +0 -1
- package/dist/lib/molecules/map/utilities/mapbox/mapbox.js +0 -25
- package/dist/lib/molecules/map/utilities/mapbox/mapbox.js.map +0 -1
- package/dist/lib/molecules/map/utilities/mapbox/parse-feature-properties.js +0 -16
- package/dist/lib/molecules/map/utilities/mapbox/parse-feature-properties.js.map +0 -1
- package/dist/lib/molecules/map/utilities/mapbox/pointers/setup-pointers.js +0 -151
- package/dist/lib/molecules/map/utilities/mapbox/pointers/setup-pointers.js.map +0 -1
- package/dist/lib/molecules/map/utilities/mapbox/polygons/feature-state.js +0 -10
- package/dist/lib/molecules/map/utilities/mapbox/polygons/feature-state.js.map +0 -1
- package/dist/lib/molecules/map/utilities/mapbox/polygons/geojson.js +0 -9
- package/dist/lib/molecules/map/utilities/mapbox/polygons/geojson.js.map +0 -1
- package/dist/lib/molecules/map/utilities/mapbox/polygons/interaction.js +0 -32
- package/dist/lib/molecules/map/utilities/mapbox/polygons/interaction.js.map +0 -1
- package/dist/lib/molecules/map/utilities/mapbox/polygons/layer.js +0 -109
- package/dist/lib/molecules/map/utilities/mapbox/polygons/layer.js.map +0 -1
- package/dist/lib/molecules/map/utilities/mapbox/raster.js +0 -42
- package/dist/lib/molecules/map/utilities/mapbox/raster.js.map +0 -1
- package/dist/lib/molecules/map/utilities/mapbox/search/alternative-city-suggestions.js +0 -26
- package/dist/lib/molecules/map/utilities/mapbox/search/alternative-city-suggestions.js.map +0 -1
- package/dist/lib/molecules/map/utilities/mapbox/search/search.js +0 -172
- package/dist/lib/molecules/map/utilities/mapbox/search/search.js.map +0 -1
- package/dist/lib/molecules/map/utilities/mapbox/tooltip.js +0 -24
- package/dist/lib/molecules/map/utilities/mapbox/tooltip.js.map +0 -1
- package/dist/lib/molecules/tooltip/index.js +0 -2
- package/dist/lib/molecules/tooltip/index.js.map +0 -1
- package/dist/lib/molecules/tooltip/tooltip.js +0 -11
- package/dist/lib/molecules/tooltip/tooltip.js.map +0 -1
- package/dist/molecules/map/hooks/use-style-loaded.d.ts +0 -2
- package/dist/molecules/map/hooks/use-style-loaded.js +0 -14
- package/dist/molecules/map/hooks/use-style-loaded.js.map +0 -1
- package/dist/molecules/map/store/map/index.d.ts +0 -1
- package/dist/molecules/map/store/map/index.js +0 -2
- package/dist/molecules/map/store/map/index.js.map +0 -1
- package/dist/molecules/map/store/map/store.d.ts +0 -66
- package/dist/molecules/map/store/map/store.js +0 -179
- package/dist/molecules/map/store/map/store.js.map +0 -1
- package/dist/molecules/map/utilities/mapbox/tooltip.d.ts +0 -4
- package/dist/molecules/map/utilities/mapbox/tooltip.js +0 -24
- package/dist/molecules/map/utilities/mapbox/tooltip.js.map +0 -1
- package/dist/molecules/tooltip/index.d.ts +0 -1
- package/dist/molecules/tooltip/index.js +0 -2
- package/dist/molecules/tooltip/index.js.map +0 -1
- package/dist/molecules/tooltip/tooltip.d.ts +0 -7
- package/dist/molecules/tooltip/tooltip.js +0 -11
- package/dist/molecules/tooltip/tooltip.js.map +0 -1
- package/dist/types/atoms/button/button.d.ts +0 -17
- package/dist/types/atoms/button/index.d.ts +0 -1
- package/dist/types/atoms/col/col.d.ts +0 -11
- package/dist/types/atoms/container/container.d.ts +0 -6
- package/dist/types/atoms/form-elements/range-slider/range-slider.d.ts +0 -11
- package/dist/types/atoms/form-elements/utilities/range-slider.d.ts +0 -7
- package/dist/types/atoms/image/image.d.ts +0 -14
- package/dist/types/atoms/image/index.d.ts +0 -1
- package/dist/types/atoms/image/utilities/create-image-url.d.ts +0 -6
- package/dist/types/atoms/image/utilities/detect-responsive-images.d.ts +0 -7
- package/dist/types/atoms/image/utilities/image.d.ts +0 -18
- package/dist/types/atoms/image/utilities/object-fit.d.ts +0 -7
- package/dist/types/atoms/row/row.d.ts +0 -6
- package/dist/types/atoms/svg/svg.d.ts +0 -4
- package/dist/types/index.d.ts +0 -11
- package/dist/types/molecules/infobox/index.d.ts +0 -1
- package/dist/types/molecules/infobox/infobox.d.ts +0 -7
- package/dist/types/molecules/map/hooks/use-style-loaded.d.ts +0 -2
- package/dist/types/molecules/map/index.d.ts +0 -3
- package/dist/types/molecules/map/map.d.ts +0 -2
- package/dist/types/molecules/map/store/map/index.d.ts +0 -1
- package/dist/types/molecules/map/store/map/store.d.ts +0 -60
- package/dist/types/molecules/map/storybook/themes.d.ts +0 -3
- package/dist/types/molecules/map/utilities/fit-bounds.d.ts +0 -3
- package/dist/types/molecules/map/utilities/mapbox/add-data.d.ts +0 -3
- package/dist/types/molecules/map/utilities/mapbox/center.d.ts +0 -3
- package/dist/types/molecules/map/utilities/mapbox/constants.d.ts +0 -2
- package/dist/types/molecules/map/utilities/mapbox/index.d.ts +0 -2
- package/dist/types/molecules/map/utilities/mapbox/mapbox.d.ts +0 -16
- package/dist/types/molecules/map/utilities/mapbox/parse-feature-properties.d.ts +0 -6
- package/dist/types/molecules/map/utilities/mapbox/pointers/setup-pointers.d.ts +0 -3
- package/dist/types/molecules/map/utilities/mapbox/polygons/feature-state.d.ts +0 -2
- package/dist/types/molecules/map/utilities/mapbox/polygons/geojson.d.ts +0 -3
- package/dist/types/molecules/map/utilities/mapbox/polygons/interaction.d.ts +0 -3
- package/dist/types/molecules/map/utilities/mapbox/polygons/layer.d.ts +0 -3
- package/dist/types/molecules/map/utilities/mapbox/raster.d.ts +0 -3
- package/dist/types/molecules/map/utilities/mapbox/search/alternative-city-suggestions.d.ts +0 -3
- package/dist/types/molecules/map/utilities/mapbox/search/search.d.ts +0 -4
- package/dist/types/molecules/map/utilities/mapbox/tooltip.d.ts +0 -4
- package/dist/types/molecules/tooltip/index.d.ts +0 -1
- package/dist/types/molecules/tooltip/tooltip.d.ts +0 -7
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const TRANSITION_ZOOM_MARGIN = 0.75;
|
|
2
|
-
const raster = (map, settings) => {
|
|
3
|
-
const accessToken = window.__ENVIRONMENT_DETAILS__.mapbox.accessToken;
|
|
4
|
-
const tile = `${settings.layerRaster}/{z}/{x}/{y}.png?access_token=${accessToken}`;
|
|
5
|
-
if (map.getSource('raster')) {
|
|
6
|
-
console.warn('Adding multiple layerRasters is not possible');
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
map.addSource('raster', {
|
|
10
|
-
type: 'raster',
|
|
11
|
-
tiles: [tile],
|
|
12
|
-
});
|
|
13
|
-
map.addLayer({
|
|
14
|
-
id: 'raster-image',
|
|
15
|
-
type: 'raster',
|
|
16
|
-
source: 'raster',
|
|
17
|
-
minzoom: 10,
|
|
18
|
-
maxzoom: 24,
|
|
19
|
-
}, 'bridge_minor');
|
|
20
|
-
if (settings.minzoom && settings.maxzoom) {
|
|
21
|
-
setTransitionPaintProperty(map, settings.minzoom, settings.maxzoom);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
function setTransitionPaintProperty(map, minzoom, maxzoom) {
|
|
25
|
-
if (!minzoom || !maxzoom)
|
|
26
|
-
return;
|
|
27
|
-
map.setPaintProperty('raster-image', 'raster-opacity', [
|
|
28
|
-
'interpolate',
|
|
29
|
-
['exponential', TRANSITION_ZOOM_MARGIN],
|
|
30
|
-
['zoom'],
|
|
31
|
-
minzoom - TRANSITION_ZOOM_MARGIN,
|
|
32
|
-
0,
|
|
33
|
-
minzoom,
|
|
34
|
-
1,
|
|
35
|
-
maxzoom,
|
|
36
|
-
1,
|
|
37
|
-
maxzoom + TRANSITION_ZOOM_MARGIN,
|
|
38
|
-
0,
|
|
39
|
-
]);
|
|
40
|
-
}
|
|
41
|
-
export default raster;
|
|
42
|
-
//# sourceMappingURL=raster.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"raster.js","sourceRoot":"","sources":["../../../../../../src/molecules/map/utilities/mapbox/raster.ts"],"names":[],"mappings":"AAEA,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAEpC,MAAM,MAAM,GAAG,CAAC,GAAiB,EAAE,QAAgC,EAAE,EAAE;IACnE,MAAM,WAAW,GAAG,MAAM,CAAC,uBAAuB,CAAC,MAAM,CAAC,WAAW,CAAC;IACtE,MAAM,IAAI,GAAG,GAAG,QAAQ,CAAC,WAAW,iCAAiC,WAAW,EAAE,CAAC;IAEnF,IAAI,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE;QACzB,OAAO,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;QAC7D,OAAO;KACV;IAED,GAAG,CAAC,SAAS,CAAC,QAAQ,EAAE;QACpB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,CAAC,IAAI,CAAC;KAChB,CAAC,CAAC;IAEH,GAAG,CAAC,QAAQ,CACR;QACI,EAAE,EAAE,cAAc;QAClB,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,QAAQ;QAChB,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,EAAE;KACd,EACD,cAAc,CACjB,CAAC;IAEF,IAAI,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE;QACtC,0BAA0B,CAAC,GAAG,EAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;KACvE;AACL,CAAC,CAAC;AASF,SAAS,0BAA0B,CAAC,GAAiB,EAAE,OAAe,EAAE,OAAe;IACnF,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO;QAAE,OAAO;IAEjC,GAAG,CAAC,gBAAgB,CAAC,cAAc,EAAE,gBAAgB,EAAE;QACnD,aAAa;QACb,CAAC,aAAa,EAAE,sBAAsB,CAAC;QACvC,CAAC,MAAM,CAAC;QACR,OAAO,GAAG,sBAAsB;QAChC,CAAC;QACD,OAAO;QACP,CAAC;QACD,OAAO;QACP,CAAC;QACD,OAAO,GAAG,sBAAsB;QAChC,CAAC;KACJ,CAAC,CAAC;AACP,CAAC;AAED,eAAe,MAAM,CAAC","sourcesContent":["import { MapLayerRasterSettings } from '../../store/map';\n\nconst TRANSITION_ZOOM_MARGIN = 0.75;\n\nconst raster = (map: mapboxgl.Map, settings: MapLayerRasterSettings) => {\n const accessToken = window.__ENVIRONMENT_DETAILS__.mapbox.accessToken;\n const tile = `${settings.layerRaster}/{z}/{x}/{y}.png?access_token=${accessToken}`;\n\n if (map.getSource('raster')) {\n console.warn('Adding multiple layerRasters is not possible');\n return;\n }\n\n map.addSource('raster', {\n type: 'raster',\n tiles: [tile],\n });\n\n map.addLayer(\n {\n id: 'raster-image',\n type: 'raster',\n source: 'raster',\n minzoom: 10,\n maxzoom: 24,\n },\n 'bridge_minor',\n );\n\n if (settings.minzoom && settings.maxzoom) {\n setTransitionPaintProperty(map, settings.minzoom, settings.maxzoom);\n }\n};\n\n/**\n * @description Creates a fade-in effect when zooming in or out, based on a minzoom and maxzoom\n * @param {string} layer\n * @param {RGBA} color\n * @param {string} property\n * @return {*}\n */\nfunction setTransitionPaintProperty(map: mapboxgl.Map, minzoom: number, maxzoom: number) {\n if (!minzoom || !maxzoom) return;\n\n map.setPaintProperty('raster-image', 'raster-opacity', [\n 'interpolate',\n ['exponential', TRANSITION_ZOOM_MARGIN],\n ['zoom'],\n minzoom - TRANSITION_ZOOM_MARGIN,\n 0,\n minzoom,\n 1,\n maxzoom,\n 1,\n maxzoom + TRANSITION_ZOOM_MARGIN,\n 0,\n ]);\n}\n\nexport default raster;\n"]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const ALTERNATIVES = [
|
|
2
|
-
{
|
|
3
|
-
query: 'Den Bosch',
|
|
4
|
-
title: 'Den Bosch, Noord-Brabant, Nederland',
|
|
5
|
-
bbox: [5.206494, 51.663997, 5.377136, 51.755477],
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
query: "'s-Gravenhage",
|
|
9
|
-
title: "'s-Gravenhage, Zuid-Holland, Nederland",
|
|
10
|
-
bbox: [4.1962, 52.014848, 4.42249, 52.128324],
|
|
11
|
-
},
|
|
12
|
-
];
|
|
13
|
-
function getCityAlternativeSuggestions(searchQuery) {
|
|
14
|
-
const suggestions = [];
|
|
15
|
-
ALTERNATIVES.forEach(({ title, query, bbox }) => {
|
|
16
|
-
if (query.toLowerCase().indexOf(searchQuery) > -1) {
|
|
17
|
-
suggestions.push({
|
|
18
|
-
title,
|
|
19
|
-
bbox,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
return suggestions;
|
|
24
|
-
}
|
|
25
|
-
export default getCityAlternativeSuggestions;
|
|
26
|
-
//# sourceMappingURL=alternative-city-suggestions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"alternative-city-suggestions.js","sourceRoot":"","sources":["../../../../../../../src/molecules/map/utilities/mapbox/search/alternative-city-suggestions.ts"],"names":[],"mappings":"AAQA,MAAM,YAAY,GAAsB;IACpC;QACI,KAAK,EAAE,WAAW;QAClB,KAAK,EAAE,qCAAqC;QAC5C,IAAI,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC;KACnD;IACD;QACI,KAAK,EAAE,eAAe;QACtB,KAAK,EAAE,wCAAwC;QAC/C,IAAI,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC;KAChD;CACJ,CAAC;AAEF,SAAS,6BAA6B,CAAC,WAAmB;IACtD,MAAM,WAAW,GAA0B,EAAE,CAAC;IAE9C,YAAY,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE;QAC5C,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE;YAC/C,WAAW,CAAC,IAAI,CAAC;gBACb,KAAK;gBACL,IAAI;aACP,CAAC,CAAC;SACN;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACvB,CAAC;AAED,eAAe,6BAA6B,CAAC","sourcesContent":["import { BoundingBox, MapSearchSuggestion } from '@bpd-library/types';\n\ninterface CityAlternative {\n query: string;\n title: string;\n bbox: BoundingBox;\n}\n\nconst ALTERNATIVES: CityAlternative[] = [\n {\n query: 'Den Bosch',\n title: 'Den Bosch, Noord-Brabant, Nederland',\n bbox: [5.206494, 51.663997, 5.377136, 51.755477],\n },\n {\n query: \"'s-Gravenhage\",\n title: \"'s-Gravenhage, Zuid-Holland, Nederland\",\n bbox: [4.1962, 52.014848, 4.42249, 52.128324],\n },\n];\n\nfunction getCityAlternativeSuggestions(searchQuery: string): MapSearchSuggestion[] {\n const suggestions: MapSearchSuggestion[] = [];\n\n ALTERNATIVES.forEach(({ title, query, bbox }) => {\n if (query.toLowerCase().indexOf(searchQuery) > -1) {\n suggestions.push({\n title,\n bbox,\n });\n }\n });\n\n return suggestions;\n}\n\nexport default getCityAlternativeSuggestions;\n"]}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { h } from '@atomify/jsx';
|
|
2
|
-
import { calculateBoundingBoxCenter, debounce, environment, expandBoundingBox, getCountryBoundingBox, useClickOutside, withinBoundingBox, } from '@bpd-library/utilities';
|
|
3
|
-
import mapboxgl from 'mapbox-gl';
|
|
4
|
-
import { clearSearchResult, getMapboxData, mapStore, updateSearchIsMoving, updateSearchResult, } from '../../../store/map';
|
|
5
|
-
import { fitBounds } from '../../fit-bounds';
|
|
6
|
-
import getCityAlternativeSuggestions from './alternative-city-suggestions';
|
|
7
|
-
const MIN_KM_PADDING = 10;
|
|
8
|
-
const search = async (map, { hook, kmPadding = MIN_KM_PADDING, onSearchSuggestion }, { searchCountryIsoCodes = ['nl', 'de'], language = 'nl' }) => {
|
|
9
|
-
const element = document.querySelector(hook);
|
|
10
|
-
const bounds = getCountryBoundingBox(searchCountryIsoCodes);
|
|
11
|
-
if (!element) {
|
|
12
|
-
if (environment.isLocal)
|
|
13
|
-
console.error(`Search element can't be found: ${hook}`);
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
const inputElement = element.querySelector('[js-hook-map-search-input]');
|
|
17
|
-
const form = inputElement.closest('form');
|
|
18
|
-
const suggestionsElement = element.querySelector('[js-hook-map-search-suggestions]');
|
|
19
|
-
const buttonElement = element.querySelector('[js-hook-map-search-button]');
|
|
20
|
-
let geocoder;
|
|
21
|
-
let suggestions;
|
|
22
|
-
init();
|
|
23
|
-
async function init() {
|
|
24
|
-
const { default: MapboxGeocoder } = await import('@mapbox/mapbox-gl-geocoder');
|
|
25
|
-
geocoder = new MapboxGeocoder({
|
|
26
|
-
accessToken: mapboxgl.accessToken,
|
|
27
|
-
mapboxgl,
|
|
28
|
-
countries: searchCountryIsoCodes.join(',').toUpperCase(),
|
|
29
|
-
types: 'region,district,place,neighborhood',
|
|
30
|
-
localGeocoder,
|
|
31
|
-
language,
|
|
32
|
-
enableEventLogging: false,
|
|
33
|
-
marker: false,
|
|
34
|
-
});
|
|
35
|
-
map.addControl(geocoder);
|
|
36
|
-
bindEvents();
|
|
37
|
-
subscribe();
|
|
38
|
-
}
|
|
39
|
-
function bindEvents() {
|
|
40
|
-
const debouncedOnKeyDown = debounce(onKeyDown, 300);
|
|
41
|
-
inputElement.addEventListener('keydown', debouncedOnKeyDown);
|
|
42
|
-
buttonElement.addEventListener('click', handleButtonClick);
|
|
43
|
-
form === null || form === void 0 ? void 0 : form.addEventListener('submit', (e) => e.preventDefault());
|
|
44
|
-
useClickOutside(inputElement, handleClickOutside);
|
|
45
|
-
geocoder.on('results', (results) => {
|
|
46
|
-
suggestions = results;
|
|
47
|
-
renderSuggestions(suggestions);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
function subscribe() {
|
|
51
|
-
handleManualSearch(mapStore.getState());
|
|
52
|
-
mapStore.subscribe(handleManualSearch, ['manualSearch']);
|
|
53
|
-
}
|
|
54
|
-
function handleManualSearch({ manualSearch }) {
|
|
55
|
-
if (manualSearch) {
|
|
56
|
-
geocoder.setInput(manualSearch).on('results', function handleResults(results) {
|
|
57
|
-
suggestions = results;
|
|
58
|
-
submitFirstSuggestion();
|
|
59
|
-
geocoder.off('results', handleResults);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function handleClickOutside() {
|
|
64
|
-
clearSuggestionsContainer();
|
|
65
|
-
}
|
|
66
|
-
function handleFitBounds() {
|
|
67
|
-
return fitBounds(map, bounds);
|
|
68
|
-
}
|
|
69
|
-
function onKeyDown(e) {
|
|
70
|
-
const { value } = inputElement;
|
|
71
|
-
if (e.key === 'Enter') {
|
|
72
|
-
if (!value) {
|
|
73
|
-
clearAll();
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
geocoder.on('results', function handleEnter() {
|
|
78
|
-
submitFirstSuggestion();
|
|
79
|
-
inputElement === null || inputElement === void 0 ? void 0 : inputElement.blur();
|
|
80
|
-
geocoder.off('results', handleEnter);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (value.length >= 3) {
|
|
85
|
-
geocoder.setInput(value);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
suggestions = undefined;
|
|
89
|
-
handleFitBounds();
|
|
90
|
-
clearSuggestionsContainer();
|
|
91
|
-
clearSearchResult();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function handleButtonClick() {
|
|
95
|
-
const { value } = inputElement;
|
|
96
|
-
if (!value) {
|
|
97
|
-
clearAll();
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
submitFirstSuggestion();
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
function submitFirstSuggestion() {
|
|
104
|
-
const firstSuggestion = suggestions === null || suggestions === void 0 ? void 0 : suggestions.features[0];
|
|
105
|
-
updateStore(firstSuggestion);
|
|
106
|
-
clearSuggestionsContainer();
|
|
107
|
-
}
|
|
108
|
-
function clearSuggestionsContainer() {
|
|
109
|
-
suggestionsElement.innerHTML = '';
|
|
110
|
-
}
|
|
111
|
-
function clearAll() {
|
|
112
|
-
suggestions = undefined;
|
|
113
|
-
handleFitBounds();
|
|
114
|
-
clearSuggestionsContainer();
|
|
115
|
-
clearSearchResult();
|
|
116
|
-
inputElement === null || inputElement === void 0 ? void 0 : inputElement.blur();
|
|
117
|
-
}
|
|
118
|
-
function localGeocoder(query) {
|
|
119
|
-
const createSuggestion = ({ title, bbox, type, id }) => {
|
|
120
|
-
const center = calculateBoundingBoxCenter(bbox);
|
|
121
|
-
return {
|
|
122
|
-
place_name: title,
|
|
123
|
-
bbox,
|
|
124
|
-
center,
|
|
125
|
-
type,
|
|
126
|
-
id,
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
const customSuggestions = onSearchSuggestion
|
|
130
|
-
? onSearchSuggestion(query.toLowerCase()).map(createSuggestion)
|
|
131
|
-
: [];
|
|
132
|
-
const cityAlternatives = getCityAlternativeSuggestions(query.toLowerCase()).map(createSuggestion);
|
|
133
|
-
return [...customSuggestions, ...cityAlternatives].slice(0, 4);
|
|
134
|
-
}
|
|
135
|
-
function updateStore(result) {
|
|
136
|
-
if (!result) {
|
|
137
|
-
updateSearchResult({
|
|
138
|
-
items: [],
|
|
139
|
-
result: false,
|
|
140
|
-
});
|
|
141
|
-
handleFitBounds();
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
const expandedBoundingBox = expandBoundingBox(result.bbox, kmPadding);
|
|
145
|
-
const originalBoundingBox = result.bbox;
|
|
146
|
-
const mapData = getMapboxData();
|
|
147
|
-
const filteredData = mapData.filter((item) => withinBoundingBox(item.coordinates, expandedBoundingBox));
|
|
148
|
-
map.fitBounds(expandedBoundingBox);
|
|
149
|
-
updateSearchIsMoving(true);
|
|
150
|
-
map.once('moveend', () => {
|
|
151
|
-
updateSearchIsMoving(false);
|
|
152
|
-
});
|
|
153
|
-
updateSearchResult({
|
|
154
|
-
items: filteredData,
|
|
155
|
-
result,
|
|
156
|
-
originalBoundingBox,
|
|
157
|
-
expandedBoundingBox,
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
function handleSuggestionClick(feature) {
|
|
161
|
-
inputElement.value = feature.place_name;
|
|
162
|
-
clearSuggestionsContainer();
|
|
163
|
-
updateStore(feature);
|
|
164
|
-
}
|
|
165
|
-
function renderSuggestions(suggestions) {
|
|
166
|
-
clearSuggestionsContainer();
|
|
167
|
-
suggestionsElement.append(h("ul", { class: "map-search__suggestions" }, suggestions.features.map((feature) => (h("li", { class: "map-search__suggestion" },
|
|
168
|
-
h("button", { onClick: () => handleSuggestionClick(feature) }, feature.place_name))))));
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
export default search;
|
|
172
|
-
//# sourceMappingURL=search.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../../../../../src/molecules/map/utilities/mapbox/search/search.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAEjC,OAAO,EACH,0BAA0B,EAC1B,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,iBAAiB,GACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,OAAO,EACH,iBAAiB,EACjB,aAAa,EAEb,QAAQ,EACR,oBAAoB,EACpB,kBAAkB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,6BAA6B,MAAM,gCAAgC,CAAC;AAE3E,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,MAAM,MAAM,GAAG,KAAK,EAChB,GAAiB,EACjB,EAAE,IAAI,EAAE,SAAS,GAAG,cAAc,EAAE,kBAAkB,EAAoB,EAC1E,EAAE,qBAAqB,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,EAAc,EACvE,EAAE;IACA,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,CAAC;IAE5D,IAAI,CAAC,OAAO,EAAE;QACV,IAAI,WAAW,CAAC,OAAO;YAAE,OAAO,CAAC,KAAK,CAAC,kCAAkC,IAAI,EAAE,CAAC,CAAC;QACjF,OAAO;KACV;IAED,MAAM,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,4BAA4B,CAAqB,CAAC;IAC7F,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAkB,MAAM,CAAC,CAAC;IAC3D,MAAM,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAC5C,kCAAkC,CACtB,CAAC;IACj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,kBAAkB,CAAC,MAAM,CACrB,UAAI,KAAK,EAAC,yBAAyB,IAC9B,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,CACxC,UAAI,KAAK,EAAC,wBAAwB;YAC9B,cAAQ,OAAO,EAAE,GAAG,EAAE,CAAC,qBAAqB,CAAC,OAAO,CAAC,IAChD,OAAO,CAAC,UAAU,CACd,CACR,CACR,CAAC,CACD,CACR,CAAC;IACN,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import { h } from '@atomify/jsx';\nimport { BoundingBox, MapOptions, MapSearchOptions, MapSearchSuggestion } from '@bpd-library/types';\nimport {\n calculateBoundingBoxCenter,\n debounce,\n environment,\n expandBoundingBox,\n getCountryBoundingBox,\n useClickOutside,\n withinBoundingBox,\n} from '@bpd-library/utilities';\nimport mapboxgl from 'mapbox-gl';\n\nimport {\n clearSearchResult,\n getMapboxData,\n MapState,\n mapStore,\n updateSearchIsMoving,\n updateSearchResult,\n} from '../../../store/map';\nimport { fitBounds } from '../../fit-bounds';\nimport getCityAlternativeSuggestions from './alternative-city-suggestions';\n\nconst MIN_KM_PADDING = 10;\n\nconst search = async (\n map: mapboxgl.Map,\n { hook, kmPadding = MIN_KM_PADDING, onSearchSuggestion }: MapSearchOptions,\n { searchCountryIsoCodes = ['nl', 'de'], language = 'nl' }: MapOptions,\n) => {\n const element = document.querySelector(hook);\n const bounds = getCountryBoundingBox(searchCountryIsoCodes);\n\n if (!element) {\n if (environment.isLocal) console.error(`Search element can't be found: ${hook}`);\n return;\n }\n\n const inputElement = element.querySelector('[js-hook-map-search-input]') as HTMLInputElement;\n const form = inputElement.closest<HTMLFormElement>('form');\n const suggestionsElement = element.querySelector(\n '[js-hook-map-search-suggestions]',\n ) as HTMLElement;\n const buttonElement = element.querySelector('[js-hook-map-search-button]') as HTMLButtonElement;\n\n let geocoder: any | undefined;\n let suggestions: any | undefined;\n\n init();\n\n async function init() {\n // Dynamically import geocoder library\n const { default: MapboxGeocoder } = await import('@mapbox/mapbox-gl-geocoder');\n\n geocoder = new MapboxGeocoder({\n accessToken: mapboxgl.accessToken,\n mapboxgl,\n countries: searchCountryIsoCodes.join(',').toUpperCase(),\n types: 'region,district,place,neighborhood',\n localGeocoder,\n language,\n enableEventLogging: false,\n marker: false,\n });\n\n map.addControl(geocoder);\n\n bindEvents();\n subscribe();\n }\n\n function bindEvents() {\n const debouncedOnKeyDown = debounce(onKeyDown, 300);\n\n inputElement.addEventListener('keydown', debouncedOnKeyDown);\n buttonElement.addEventListener('click', handleButtonClick);\n form?.addEventListener('submit', (e) => e.preventDefault());\n\n useClickOutside(inputElement!, handleClickOutside);\n\n geocoder.on('results', (results: any) => {\n suggestions = results;\n\n renderSuggestions(suggestions);\n });\n }\n\n function subscribe() {\n handleManualSearch(mapStore.getState());\n mapStore.subscribe(handleManualSearch, ['manualSearch']);\n }\n\n function handleManualSearch({ manualSearch }: MapState) {\n if (manualSearch) {\n geocoder.setInput(manualSearch).on('results', function handleResults(results: any) {\n suggestions = results;\n\n submitFirstSuggestion();\n\n geocoder.off('results', handleResults);\n });\n }\n }\n\n function handleClickOutside() {\n clearSuggestionsContainer();\n }\n\n function handleFitBounds() {\n return fitBounds(map, bounds);\n }\n\n function onKeyDown(e: KeyboardEvent) {\n const { value } = inputElement!;\n\n if (e.key === 'Enter') {\n if (!value) {\n clearAll();\n return;\n } else {\n geocoder.on('results', function handleEnter() {\n submitFirstSuggestion();\n inputElement?.blur();\n\n geocoder.off('results', handleEnter);\n });\n }\n }\n\n if (value.length >= 3) {\n geocoder.setInput(value);\n } else {\n suggestions = undefined;\n handleFitBounds();\n clearSuggestionsContainer();\n clearSearchResult();\n }\n }\n\n function handleButtonClick() {\n const { value } = inputElement!;\n\n if (!value) {\n clearAll();\n } else {\n submitFirstSuggestion();\n }\n }\n\n function submitFirstSuggestion() {\n const firstSuggestion = suggestions?.features[0];\n\n updateStore(firstSuggestion);\n clearSuggestionsContainer();\n }\n\n function clearSuggestionsContainer() {\n suggestionsElement.innerHTML = '';\n }\n\n function clearAll() {\n suggestions = undefined;\n handleFitBounds();\n clearSuggestionsContainer();\n clearSearchResult();\n inputElement?.blur();\n }\n\n function localGeocoder(query: string) {\n const createSuggestion = ({ title, bbox, type, id }: MapSearchSuggestion) => {\n const center = calculateBoundingBoxCenter(bbox);\n\n return {\n place_name: title,\n bbox,\n center,\n type,\n id,\n };\n };\n\n const customSuggestions = onSearchSuggestion\n ? onSearchSuggestion(query.toLowerCase()).map(createSuggestion)\n : [];\n const cityAlternatives = getCityAlternativeSuggestions(query.toLowerCase()).map(\n createSuggestion,\n );\n\n return [...customSuggestions, ...cityAlternatives].slice(0, 4);\n }\n\n function updateStore(result: any) {\n if (!result) {\n updateSearchResult({\n items: [],\n result: false,\n });\n\n handleFitBounds();\n\n return;\n }\n\n const expandedBoundingBox = expandBoundingBox(result.bbox as BoundingBox, kmPadding);\n const originalBoundingBox = result.bbox as BoundingBox;\n\n const mapData = getMapboxData();\n const filteredData = mapData.filter((item) =>\n withinBoundingBox(item.coordinates, expandedBoundingBox),\n );\n\n map.fitBounds(expandedBoundingBox);\n\n // Update searchIsMoving boolean in store. Is used to block other focus interactions when searched.\n updateSearchIsMoving(true);\n\n map.once('moveend', () => {\n updateSearchIsMoving(false);\n });\n\n updateSearchResult({\n items: filteredData,\n result,\n originalBoundingBox,\n expandedBoundingBox,\n });\n }\n\n function handleSuggestionClick(feature: any) {\n inputElement.value = feature.place_name;\n\n clearSuggestionsContainer();\n updateStore(feature);\n }\n\n function renderSuggestions(suggestions: any) {\n clearSuggestionsContainer();\n\n suggestionsElement.append(\n <ul class=\"map-search__suggestions\">\n {suggestions.features.map((feature: any) => (\n <li class=\"map-search__suggestion\">\n <button onClick={() => handleSuggestionClick(feature)}>\n {feature.place_name}\n </button>\n </li>\n ))}\n </ul>,\n );\n }\n};\n\nexport default search;\n"]}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { h } from '@atomify/jsx';
|
|
2
|
-
import { calculateCenter } from '@bpd-library/utilities';
|
|
3
|
-
import { Popup } from 'mapbox-gl';
|
|
4
|
-
import { Tooltip } from '../../../tooltip';
|
|
5
|
-
let currentTooltip;
|
|
6
|
-
const addTooltip = (map, coordinates, mapDataItem, openInTab) => {
|
|
7
|
-
removeTooltip();
|
|
8
|
-
const { tooltip, url } = mapDataItem;
|
|
9
|
-
if (!tooltip)
|
|
10
|
-
return;
|
|
11
|
-
const center = calculateCenter(coordinates);
|
|
12
|
-
currentTooltip = new Popup({
|
|
13
|
-
closeButton: false,
|
|
14
|
-
offset: 20,
|
|
15
|
-
})
|
|
16
|
-
.setLngLat(center)
|
|
17
|
-
.setDOMContent(h(Tooltip, Object.assign({}, tooltip, { url: url, openInTab: openInTab })))
|
|
18
|
-
.addTo(map);
|
|
19
|
-
};
|
|
20
|
-
const removeTooltip = () => {
|
|
21
|
-
currentTooltip === null || currentTooltip === void 0 ? void 0 : currentTooltip.remove();
|
|
22
|
-
};
|
|
23
|
-
export { addTooltip, removeTooltip };
|
|
24
|
-
//# sourceMappingURL=tooltip.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","sourceRoot":"","sources":["../../../../../../src/molecules/map/utilities/mapbox/tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAEjC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,IAAI,cAA0C,CAAC;AAE/C,MAAM,UAAU,GAAG,CACf,GAAiB,EACjB,WAAwB,EACxB,WAAwB,EACxB,SAAmB,EACrB,EAAE;IACA,aAAa,EAAE,CAAC;IAEhB,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,WAAW,CAAC;IAErC,IAAI,CAAC,OAAO;QAAE,OAAO;IAErB,MAAM,MAAM,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IAE5C,cAAc,GAAG,IAAI,KAAK,CAAC;QACvB,WAAW,EAAE,KAAK;QAClB,MAAM,EAAE,EAAE;KACb,CAAC;SACG,SAAS,CAAC,MAAM,CAAC;SACjB,aAAa,CAAC,EAAC,OAAO,oBAAK,OAAO,IAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,IAAI,CAAC;SACvE,KAAK,CAAC,GAAG,CAAC,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,GAAG,EAAE;IACvB,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,MAAM,GAAG;AAC7B,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import { h } from '@atomify/jsx';\nimport { Coordinates, MapDataItem } from '@bpd-library/types';\nimport { calculateCenter } from '@bpd-library/utilities';\nimport { Popup } from 'mapbox-gl';\n\nimport { Tooltip } from '../../../tooltip';\n\nlet currentTooltip: mapboxgl.Popup | undefined;\n\nconst addTooltip = (\n map: mapboxgl.Map,\n coordinates: Coordinates,\n mapDataItem: MapDataItem,\n openInTab?: boolean,\n) => {\n removeTooltip();\n\n const { tooltip, url } = mapDataItem;\n\n if (!tooltip) return;\n\n const center = calculateCenter(coordinates);\n\n currentTooltip = new Popup({\n closeButton: false,\n offset: 20,\n })\n .setLngLat(center)\n .setDOMContent(<Tooltip {...tooltip} url={url} openInTab={openInTab} />)\n .addTo(map);\n};\n\nconst removeTooltip = () => {\n currentTooltip?.remove();\n};\n\nexport { addTooltip, removeTooltip };\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/molecules/tooltip/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC","sourcesContent":["export * from './tooltip';\n"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { h } from '@atomify/jsx';
|
|
2
|
-
import { ButtonA } from '../../atoms/button';
|
|
3
|
-
import { Image } from '../../atoms/image';
|
|
4
|
-
export const Tooltip = ({ title, image, tags, buttonLabel, url, openInTab }) => (h("div", { class: "c-tooltip" },
|
|
5
|
-
image && (h("div", { class: "tooltip__image" },
|
|
6
|
-
h(Image, { image: image, preload: { width: 180, height: 100 }, alt: title }))),
|
|
7
|
-
h("div", { class: "tooltip__wrapper" },
|
|
8
|
-
h("h3", { class: "tooltip__title" }, title), tags === null || tags === void 0 ? void 0 :
|
|
9
|
-
tags.map((tag) => (h("span", { class: "tooltip__meta" }, tag))),
|
|
10
|
-
url && buttonLabel && (h(ButtonA, { classes: "tooltip__button", url: url, target: openInTab ? '_blank' : '_self', label: buttonLabel, size: "small" })))));
|
|
11
|
-
//# sourceMappingURL=tooltip.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","sourceRoot":"","sources":["../../../../src/molecules/tooltip/tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAGjC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAO1C,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,SAAS,EAAW,EAAE,EAAE,CAAC,CACrF,WAAK,KAAK,EAAC,WAAW;IACjB,KAAK,IAAI,CACN,WAAK,KAAK,EAAC,gBAAgB;QACvB,EAAC,KAAK,IAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,GAAI,CACvE,CACT;IACD,WAAK,KAAK,EAAC,kBAAkB;QACzB,UAAI,KAAK,EAAC,gBAAgB,IAAE,KAAK,CAAM,EACtC,IAAI,aAAJ,IAAI;QAAJ,IAAI,CAAE,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAChB,YAAM,KAAK,EAAC,eAAe,IAAE,GAAG,CAAQ,CAC3C;QAEA,GAAG,IAAI,WAAW,IAAI,CACnB,EAAC,OAAO,IACJ,OAAO,EAAC,iBAAiB,EACzB,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EACtC,KAAK,EAAE,WAAW,EAClB,IAAI,EAAC,OAAO,GACd,CACL,CACC,CACJ,CACT,CAAC","sourcesContent":["import { h } from '@atomify/jsx';\nimport { MapTooltip } from '@bpd-library/types';\n\nimport { ButtonA } from '../../atoms/button';\nimport { Image } from '../../atoms/image';\n\ninterface Tooltip extends MapTooltip {\n url?: string | null;\n openInTab?: boolean;\n}\n\nexport const Tooltip = ({ title, image, tags, buttonLabel, url, openInTab }: Tooltip) => (\n <div class=\"c-tooltip\">\n {image && (\n <div class=\"tooltip__image\">\n <Image image={image} preload={{ width: 180, height: 100 }} alt={title} />\n </div>\n )}\n <div class=\"tooltip__wrapper\">\n <h3 class=\"tooltip__title\">{title}</h3>\n {tags?.map((tag) => (\n <span class=\"tooltip__meta\">{tag}</span>\n ))}\n\n {url && buttonLabel && (\n <ButtonA\n classes=\"tooltip__button\"\n url={url}\n target={openInTab ? '_blank' : '_self'}\n label={buttonLabel}\n size=\"small\"\n />\n )}\n </div>\n </div>\n);\n"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const useStyleLoaded = (map, cb) => {
|
|
2
|
-
if (map.isStyleLoaded()) {
|
|
3
|
-
cb();
|
|
4
|
-
return;
|
|
5
|
-
}
|
|
6
|
-
let isCalled = false;
|
|
7
|
-
map.on('styledata', () => {
|
|
8
|
-
if (!isCalled)
|
|
9
|
-
cb();
|
|
10
|
-
isCalled = true;
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
export default useStyleLoaded;
|
|
14
|
-
//# sourceMappingURL=use-style-loaded.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-style-loaded.js","sourceRoot":"","sources":["../../../../src/molecules/map/hooks/use-style-loaded.ts"],"names":[],"mappings":"AAAA,MAAM,cAAc,GAAG,CAAC,GAAiB,EAAE,EAAY,EAAE,EAAE;IACvD,IAAI,GAAG,CAAC,aAAa,EAAE,EAAE;QACrB,EAAE,EAAE,CAAC;QACL,OAAO;KACV;IAED,IAAI,QAAQ,GAAY,KAAK,CAAC;IAE9B,GAAG,CAAC,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE;QACrB,IAAI,CAAC,QAAQ;YAAE,EAAE,EAAE,CAAC;QACpB,QAAQ,GAAG,IAAI,CAAC;IACpB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["const useStyleLoaded = (map: mapboxgl.Map, cb: Function) => {\n if (map.isStyleLoaded()) {\n cb();\n return;\n }\n\n let isCalled: boolean = false;\n\n map.on('styledata', () => {\n if (!isCalled) cb();\n isCalled = true;\n });\n};\n\nexport default useStyleLoaded;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './store';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/molecules/map/store/map/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC","sourcesContent":["export * from './store';\n"]}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/// <reference types="mapbox-gl" />
|
|
2
|
-
import { BoundingBox, MapDataItem, MapDirectionsSetting, MapIsochroneSetting } from '@bpd-library/types';
|
|
3
|
-
export declare type SearchResult = {
|
|
4
|
-
items: MapDataItem[];
|
|
5
|
-
result: any;
|
|
6
|
-
originalBoundingBox?: BoundingBox;
|
|
7
|
-
expandedBoundingBox?: BoundingBox;
|
|
8
|
-
};
|
|
9
|
-
interface MapFocusOptions {
|
|
10
|
-
zoom?: boolean;
|
|
11
|
-
toggleTooltip?: boolean;
|
|
12
|
-
static?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface MapLayerRasterSettings {
|
|
15
|
-
layerRaster: string;
|
|
16
|
-
minzoom?: number;
|
|
17
|
-
maxzoom?: number;
|
|
18
|
-
}
|
|
19
|
-
export interface MapState {
|
|
20
|
-
data: MapDataItem[];
|
|
21
|
-
mapInstance?: mapboxgl.Map;
|
|
22
|
-
hover: {
|
|
23
|
-
current?: MapDataItem;
|
|
24
|
-
previous?: MapDataItem;
|
|
25
|
-
};
|
|
26
|
-
filter?: MapDataItem[];
|
|
27
|
-
click?: MapDataItem;
|
|
28
|
-
focus: {
|
|
29
|
-
current?: MapDataItem[];
|
|
30
|
-
previous?: MapDataItem[];
|
|
31
|
-
options?: MapFocusOptions;
|
|
32
|
-
};
|
|
33
|
-
searchResult?: SearchResult;
|
|
34
|
-
searchIsMoving: boolean;
|
|
35
|
-
manualSearch?: string;
|
|
36
|
-
layerRasterSettings?: MapLayerRasterSettings;
|
|
37
|
-
isochroneSetting?: MapIsochroneSetting;
|
|
38
|
-
directionsSetting?: MapDirectionsSetting;
|
|
39
|
-
}
|
|
40
|
-
export declare const mapStore: import("@atomify/kit/dist/utilities/store/store.types").Store<MapState>;
|
|
41
|
-
export declare const updateMapData: (data: MapDataItem[]) => void;
|
|
42
|
-
export declare const clearHover: () => void;
|
|
43
|
-
export declare const updateHover: (hover: MapDataItem) => void;
|
|
44
|
-
export declare const updateClick: (click: MapDataItem) => void;
|
|
45
|
-
export declare const setFocus: (ids: string[], options?: MapFocusOptions) => void;
|
|
46
|
-
export declare const clearFocus: () => void;
|
|
47
|
-
export declare const updateSearchResult: (searchResult: SearchResult) => void;
|
|
48
|
-
export declare const clearSearchResult: () => void;
|
|
49
|
-
export declare const setFilter: (data: MapDataItem[]) => void;
|
|
50
|
-
export declare const clearFilter: () => void;
|
|
51
|
-
export declare const setMapInstance: (mapInstance: mapboxgl.Map) => void;
|
|
52
|
-
export declare const manualSearch: (query: string) => void;
|
|
53
|
-
export declare const updateSearchIsMoving: (isMoving: boolean) => void;
|
|
54
|
-
export declare const setLayerRaster: (layerRasterSettings: MapLayerRasterSettings) => void;
|
|
55
|
-
export declare const setIsochrone: (isochroneSetting: MapIsochroneSetting) => void;
|
|
56
|
-
export declare const clearIsochrone: () => void;
|
|
57
|
-
export declare const setDirections: (directionsSetting: MapDirectionsSetting) => void;
|
|
58
|
-
export declare const clearDirections: () => void;
|
|
59
|
-
export declare const getMapboxData: () => MapDataItem[];
|
|
60
|
-
export declare const getHover: () => {
|
|
61
|
-
current?: MapDataItem | undefined;
|
|
62
|
-
previous?: MapDataItem | undefined;
|
|
63
|
-
};
|
|
64
|
-
export declare const getMapInstance: () => import("mapbox-gl").Map | undefined;
|
|
65
|
-
export declare const getSearchIsMoving: () => boolean;
|
|
66
|
-
export {};
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { createStore } from '@atomify/kit';
|
|
2
|
-
const initialState = {
|
|
3
|
-
data: [],
|
|
4
|
-
hover: {},
|
|
5
|
-
focus: {},
|
|
6
|
-
searchIsMoving: false,
|
|
7
|
-
};
|
|
8
|
-
const UPDATE_MAP_DATA = 'updateMapData';
|
|
9
|
-
const UPDATE_HOVER = 'updateHover';
|
|
10
|
-
const CLEAR_HOVER = 'clearHover';
|
|
11
|
-
const UPDATE_CLICK = 'updateClick';
|
|
12
|
-
const SET_FOCUS = 'setFocus';
|
|
13
|
-
const CLEAR_FOCUS = 'clearFocus';
|
|
14
|
-
const UPDATE_SEARCH_RESULT = 'updateSearchResult';
|
|
15
|
-
const CLEAR_SEARCH_RESULT = 'clearSearchResult';
|
|
16
|
-
const UPDATE_SEARCH_IS_MOVING = 'updateSearchIsMoving';
|
|
17
|
-
const SET_FILTER = 'setFilter';
|
|
18
|
-
const CLEAR_FILTER = 'clearFilter';
|
|
19
|
-
const SET_MAP_INSTANCE = 'setMapInstance';
|
|
20
|
-
const SET_LAYER_RASTER = 'SET_LAYER_RASTER';
|
|
21
|
-
const MANUAL_SEARCH = 'manualSearch';
|
|
22
|
-
const SET_ISOCHRONE = 'setIsochrone';
|
|
23
|
-
const CLEAR_ISOCHRONE = 'clearIsochrone';
|
|
24
|
-
const SET_DIRECTIONS = 'setDirections';
|
|
25
|
-
const CLEAR_DIRECTIONS = 'clearDirections';
|
|
26
|
-
const actions = {
|
|
27
|
-
[UPDATE_MAP_DATA]: (state, data) => {
|
|
28
|
-
state.data = data;
|
|
29
|
-
return state;
|
|
30
|
-
},
|
|
31
|
-
[UPDATE_HOVER]: (state, hover) => {
|
|
32
|
-
state.hover = {
|
|
33
|
-
current: hover,
|
|
34
|
-
previous: state.hover.current,
|
|
35
|
-
};
|
|
36
|
-
return state;
|
|
37
|
-
},
|
|
38
|
-
[CLEAR_HOVER]: (state) => {
|
|
39
|
-
state.hover = {
|
|
40
|
-
current: undefined,
|
|
41
|
-
previous: state.hover.current,
|
|
42
|
-
};
|
|
43
|
-
return state;
|
|
44
|
-
},
|
|
45
|
-
[UPDATE_CLICK]: (state, click) => {
|
|
46
|
-
state.click = Object.assign({}, click);
|
|
47
|
-
return state;
|
|
48
|
-
},
|
|
49
|
-
[SET_FOCUS]: (state, { ids, options }) => {
|
|
50
|
-
var _a;
|
|
51
|
-
const dataItems = state.data.filter(({ id }) => ids.indexOf(id) > -1);
|
|
52
|
-
if (dataItems.length) {
|
|
53
|
-
state.focus = {
|
|
54
|
-
current: dataItems,
|
|
55
|
-
previous: (_a = state.focus) === null || _a === void 0 ? void 0 : _a.current,
|
|
56
|
-
options,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
return state;
|
|
60
|
-
},
|
|
61
|
-
[CLEAR_FOCUS]: (state) => {
|
|
62
|
-
state.focus = {
|
|
63
|
-
current: undefined,
|
|
64
|
-
previous: state.focus.current,
|
|
65
|
-
};
|
|
66
|
-
return state;
|
|
67
|
-
},
|
|
68
|
-
[UPDATE_SEARCH_RESULT]: (state, searchResult) => {
|
|
69
|
-
state.searchResult = searchResult;
|
|
70
|
-
return state;
|
|
71
|
-
},
|
|
72
|
-
[CLEAR_SEARCH_RESULT]: (state) => {
|
|
73
|
-
state.searchResult = undefined;
|
|
74
|
-
return state;
|
|
75
|
-
},
|
|
76
|
-
[SET_FILTER]: (state, data) => {
|
|
77
|
-
state.filter = data;
|
|
78
|
-
return state;
|
|
79
|
-
},
|
|
80
|
-
[CLEAR_FILTER]: (state) => {
|
|
81
|
-
state.filter = undefined;
|
|
82
|
-
return state;
|
|
83
|
-
},
|
|
84
|
-
[SET_MAP_INSTANCE]: (state, mapInstance) => {
|
|
85
|
-
state.mapInstance = mapInstance;
|
|
86
|
-
return state;
|
|
87
|
-
},
|
|
88
|
-
[MANUAL_SEARCH]: (state, query) => {
|
|
89
|
-
state.manualSearch = query;
|
|
90
|
-
return state;
|
|
91
|
-
},
|
|
92
|
-
[UPDATE_SEARCH_IS_MOVING]: (state, searchIsMoving) => {
|
|
93
|
-
state.searchIsMoving = searchIsMoving;
|
|
94
|
-
return state;
|
|
95
|
-
},
|
|
96
|
-
[SET_LAYER_RASTER]: (state, layerRasterSettings) => {
|
|
97
|
-
state.layerRasterSettings = layerRasterSettings;
|
|
98
|
-
return state;
|
|
99
|
-
},
|
|
100
|
-
[SET_ISOCHRONE]: (state, isochroneSetting) => {
|
|
101
|
-
state.isochroneSetting = isochroneSetting;
|
|
102
|
-
return state;
|
|
103
|
-
},
|
|
104
|
-
[CLEAR_ISOCHRONE]: (state) => {
|
|
105
|
-
state.isochroneSetting = undefined;
|
|
106
|
-
return state;
|
|
107
|
-
},
|
|
108
|
-
[SET_DIRECTIONS]: (state, directionsSetting) => {
|
|
109
|
-
state.directionsSetting = directionsSetting;
|
|
110
|
-
return state;
|
|
111
|
-
},
|
|
112
|
-
[CLEAR_DIRECTIONS]: (state) => {
|
|
113
|
-
state.directionsSetting = undefined;
|
|
114
|
-
return state;
|
|
115
|
-
},
|
|
116
|
-
};
|
|
117
|
-
export const mapStore = createStore({
|
|
118
|
-
initialState,
|
|
119
|
-
actions: actions,
|
|
120
|
-
});
|
|
121
|
-
export const updateMapData = (data) => {
|
|
122
|
-
mapStore.dispatch(UPDATE_MAP_DATA, data);
|
|
123
|
-
};
|
|
124
|
-
export const clearHover = () => {
|
|
125
|
-
mapStore.dispatch(CLEAR_HOVER);
|
|
126
|
-
};
|
|
127
|
-
export const updateHover = (hover) => {
|
|
128
|
-
mapStore.dispatch(UPDATE_HOVER, hover);
|
|
129
|
-
};
|
|
130
|
-
export const updateClick = (click) => {
|
|
131
|
-
mapStore.dispatch(UPDATE_CLICK, click);
|
|
132
|
-
};
|
|
133
|
-
export const setFocus = (ids, options = {}) => {
|
|
134
|
-
mapStore.dispatch(SET_FOCUS, { ids, options });
|
|
135
|
-
};
|
|
136
|
-
export const clearFocus = () => {
|
|
137
|
-
mapStore.dispatch(CLEAR_FOCUS);
|
|
138
|
-
};
|
|
139
|
-
export const updateSearchResult = (searchResult) => {
|
|
140
|
-
mapStore.dispatch(UPDATE_SEARCH_RESULT, searchResult);
|
|
141
|
-
};
|
|
142
|
-
export const clearSearchResult = () => {
|
|
143
|
-
mapStore.dispatch(CLEAR_SEARCH_RESULT);
|
|
144
|
-
};
|
|
145
|
-
export const setFilter = (data) => {
|
|
146
|
-
mapStore.dispatch(SET_FILTER, data);
|
|
147
|
-
};
|
|
148
|
-
export const clearFilter = () => {
|
|
149
|
-
mapStore.dispatch(CLEAR_FILTER);
|
|
150
|
-
};
|
|
151
|
-
export const setMapInstance = (mapInstance) => {
|
|
152
|
-
mapStore.dispatch(SET_MAP_INSTANCE, mapInstance);
|
|
153
|
-
};
|
|
154
|
-
export const manualSearch = (query) => {
|
|
155
|
-
mapStore.dispatch(MANUAL_SEARCH, query);
|
|
156
|
-
};
|
|
157
|
-
export const updateSearchIsMoving = (isMoving) => {
|
|
158
|
-
mapStore.dispatch(UPDATE_SEARCH_IS_MOVING, isMoving);
|
|
159
|
-
};
|
|
160
|
-
export const setLayerRaster = (layerRasterSettings) => {
|
|
161
|
-
mapStore.dispatch(SET_LAYER_RASTER, layerRasterSettings);
|
|
162
|
-
};
|
|
163
|
-
export const setIsochrone = (isochroneSetting) => {
|
|
164
|
-
mapStore.dispatch(SET_ISOCHRONE, isochroneSetting);
|
|
165
|
-
};
|
|
166
|
-
export const clearIsochrone = () => {
|
|
167
|
-
mapStore.dispatch(CLEAR_ISOCHRONE);
|
|
168
|
-
};
|
|
169
|
-
export const setDirections = (directionsSetting) => {
|
|
170
|
-
mapStore.dispatch(SET_DIRECTIONS, directionsSetting);
|
|
171
|
-
};
|
|
172
|
-
export const clearDirections = () => {
|
|
173
|
-
mapStore.dispatch(CLEAR_DIRECTIONS);
|
|
174
|
-
};
|
|
175
|
-
export const getMapboxData = () => mapStore.getState().data;
|
|
176
|
-
export const getHover = () => mapStore.getState().hover;
|
|
177
|
-
export const getMapInstance = () => mapStore.getState().mapInstance;
|
|
178
|
-
export const getSearchIsMoving = () => mapStore.getState().searchIsMoving;
|
|
179
|
-
//# sourceMappingURL=store.js.map
|