@bpd-library/components 1.2.8-beta.10 → 1.2.8-beta.11
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/dist/esm/atoms/button/button.js +33 -0
- package/dist/esm/atoms/button/button.js.map +1 -0
- package/dist/esm/atoms/col/col.js +22 -0
- package/dist/esm/atoms/col/col.js.map +1 -0
- package/dist/esm/atoms/container/container.js +6 -0
- package/dist/esm/atoms/container/container.js.map +1 -0
- package/dist/esm/atoms/form-elements/range-slider/range-slider.js +21 -0
- package/dist/esm/atoms/form-elements/range-slider/range-slider.js.map +1 -0
- package/dist/esm/atoms/form-elements/utilities/range-slider.js +100 -0
- package/dist/esm/atoms/form-elements/utilities/range-slider.js.map +1 -0
- package/dist/esm/atoms/image/image.js +18 -0
- package/dist/esm/atoms/image/image.js.map +1 -0
- package/dist/esm/atoms/image/utilities/create-image-url.js +15 -0
- package/dist/esm/atoms/image/utilities/create-image-url.js.map +1 -0
- package/dist/esm/atoms/row/row.js +6 -0
- package/dist/esm/atoms/row/row.js.map +1 -0
- package/dist/esm/atoms/svg/svg.js +25 -0
- package/dist/esm/atoms/svg/svg.js.map +1 -0
- package/dist/esm/index.js +14 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/molecules/infobox/infobox.js +20 -0
- package/dist/esm/molecules/infobox/infobox.js.map +1 -0
- package/dist/esm/molecules/map/map.js +256 -0
- package/dist/esm/molecules/map/map.js.map +1 -0
- package/dist/esm/molecules/map/store/map/store.js +150 -0
- package/dist/esm/molecules/map/store/map/store.js.map +1 -0
- package/dist/esm/molecules/map/utilities/fit-bounds.js +4 -0
- package/dist/esm/molecules/map/utilities/fit-bounds.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/add-data.js +54 -0
- package/dist/esm/molecules/map/utilities/mapbox/add-data.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/center.js +15 -0
- package/dist/esm/molecules/map/utilities/mapbox/center.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/constants.js +5 -0
- package/dist/esm/molecules/map/utilities/mapbox/constants.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/index.js +3 -0
- package/dist/esm/molecules/map/utilities/mapbox/index.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/mapbox.js +27 -0
- package/dist/esm/molecules/map/utilities/mapbox/mapbox.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/parse-feature-properties.js +18 -0
- package/dist/esm/molecules/map/utilities/mapbox/parse-feature-properties.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/pointers/setup-pointers.js +151 -0
- package/dist/esm/molecules/map/utilities/mapbox/pointers/setup-pointers.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/polygons/feature-state.js +11 -0
- package/dist/esm/molecules/map/utilities/mapbox/polygons/feature-state.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/polygons/geojson.js +10 -0
- package/dist/esm/molecules/map/utilities/mapbox/polygons/geojson.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/polygons/interaction.js +34 -0
- package/dist/esm/molecules/map/utilities/mapbox/polygons/interaction.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/polygons/layer.js +110 -0
- package/dist/esm/molecules/map/utilities/mapbox/polygons/layer.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/raster.js +43 -0
- package/dist/esm/molecules/map/utilities/mapbox/raster.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/search/alternative-city-suggestions.js +27 -0
- package/dist/esm/molecules/map/utilities/mapbox/search/alternative-city-suggestions.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/search/search.js +174 -0
- package/dist/esm/molecules/map/utilities/mapbox/search/search.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/tooltip.js +26 -0
- package/dist/esm/molecules/map/utilities/mapbox/tooltip.js.map +1 -0
- package/dist/esm/molecules/tooltip/tooltip.js +14 -0
- package/dist/esm/molecules/tooltip/tooltip.js.map +1 -0
- package/dist/esm/node_modules/tslib/tslib.es6.js +24 -0
- package/dist/esm/node_modules/tslib/tslib.es6.js.map +1 -0
- package/dist/lib/atoms/button/button.js +31 -0
- package/dist/lib/atoms/button/button.js.map +1 -0
- package/dist/lib/atoms/button/index.js +2 -0
- package/dist/lib/atoms/button/index.js.map +1 -0
- package/dist/lib/atoms/col/col.js +19 -0
- package/dist/lib/atoms/col/col.js.map +1 -0
- package/dist/lib/atoms/container/container.js +3 -0
- package/dist/lib/atoms/container/container.js.map +1 -0
- package/dist/lib/atoms/form-elements/range-slider/range-slider.js +18 -0
- package/dist/lib/atoms/form-elements/range-slider/range-slider.js.map +1 -0
- package/dist/lib/atoms/form-elements/utilities/range-slider.js +97 -0
- package/dist/lib/atoms/form-elements/utilities/range-slider.js.map +1 -0
- package/dist/lib/atoms/image/image.js +15 -0
- package/dist/lib/atoms/image/image.js.map +1 -0
- package/dist/lib/atoms/image/index.js +2 -0
- package/dist/lib/atoms/image/index.js.map +1 -0
- package/dist/lib/atoms/image/utilities/create-image-url.js +14 -0
- package/dist/lib/atoms/image/utilities/create-image-url.js.map +1 -0
- package/dist/lib/atoms/image/utilities/detect-responsive-images.js +24 -0
- package/dist/lib/atoms/image/utilities/detect-responsive-images.js.map +1 -0
- package/dist/lib/atoms/image/utilities/image.js +86 -0
- package/dist/lib/atoms/image/utilities/image.js.map +1 -0
- package/dist/lib/atoms/image/utilities/object-fit.js +35 -0
- package/dist/lib/atoms/image/utilities/object-fit.js.map +1 -0
- package/dist/lib/atoms/row/row.js +3 -0
- package/dist/lib/atoms/row/row.js.map +1 -0
- package/dist/lib/atoms/svg/svg.js +23 -0
- package/dist/lib/atoms/svg/svg.js.map +1 -0
- package/dist/lib/index.js +12 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/molecules/infobox/index.js +2 -0
- package/dist/lib/molecules/infobox/index.js.map +1 -0
- package/dist/lib/molecules/infobox/infobox.js +17 -0
- package/dist/lib/molecules/infobox/infobox.js.map +1 -0
- package/dist/lib/molecules/map/hooks/use-style-loaded.js +14 -0
- package/dist/lib/molecules/map/hooks/use-style-loaded.js.map +1 -0
- package/dist/lib/molecules/map/index.js +4 -0
- package/dist/lib/molecules/map/index.js.map +1 -0
- package/dist/lib/molecules/map/map.js +256 -0
- package/dist/lib/molecules/map/map.js.map +1 -0
- package/dist/lib/molecules/map/store/map/index.js +2 -0
- package/dist/lib/molecules/map/store/map/index.js.map +1 -0
- package/dist/lib/molecules/map/store/map/store.js +147 -0
- package/dist/lib/molecules/map/store/map/store.js.map +1 -0
- package/dist/lib/molecules/map/storybook/themes.js +54 -0
- package/dist/lib/molecules/map/storybook/themes.js.map +1 -0
- package/dist/lib/molecules/map/utilities/fit-bounds.js +2 -0
- package/dist/lib/molecules/map/utilities/fit-bounds.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/add-data.js +52 -0
- package/dist/lib/molecules/map/utilities/mapbox/add-data.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/center.js +13 -0
- package/dist/lib/molecules/map/utilities/mapbox/center.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/constants.js +3 -0
- package/dist/lib/molecules/map/utilities/mapbox/constants.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/index.js +3 -0
- package/dist/lib/molecules/map/utilities/mapbox/index.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/mapbox.js +25 -0
- package/dist/lib/molecules/map/utilities/mapbox/mapbox.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/parse-feature-properties.js +16 -0
- package/dist/lib/molecules/map/utilities/mapbox/parse-feature-properties.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/pointers/setup-pointers.js +151 -0
- package/dist/lib/molecules/map/utilities/mapbox/pointers/setup-pointers.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/polygons/feature-state.js +10 -0
- package/dist/lib/molecules/map/utilities/mapbox/polygons/feature-state.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/polygons/geojson.js +9 -0
- package/dist/lib/molecules/map/utilities/mapbox/polygons/geojson.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/polygons/interaction.js +32 -0
- package/dist/lib/molecules/map/utilities/mapbox/polygons/interaction.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/polygons/layer.js +109 -0
- package/dist/lib/molecules/map/utilities/mapbox/polygons/layer.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/raster.js +42 -0
- package/dist/lib/molecules/map/utilities/mapbox/raster.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/search/alternative-city-suggestions.js +26 -0
- package/dist/lib/molecules/map/utilities/mapbox/search/alternative-city-suggestions.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/search/search.js +172 -0
- package/dist/lib/molecules/map/utilities/mapbox/search/search.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/tooltip.js +24 -0
- package/dist/lib/molecules/map/utilities/mapbox/tooltip.js.map +1 -0
- package/dist/lib/molecules/tooltip/index.js +2 -0
- package/dist/lib/molecules/tooltip/index.js.map +1 -0
- package/dist/lib/molecules/tooltip/tooltip.js +11 -0
- package/dist/lib/molecules/tooltip/tooltip.js.map +1 -0
- package/dist/molecules/map/store/map/store.d.ts +3 -4
- package/dist/molecules/map/store/map/store.js.map +1 -1
- package/dist/types/atoms/button/button.d.ts +17 -0
- package/dist/types/atoms/button/index.d.ts +1 -0
- package/dist/types/atoms/col/col.d.ts +11 -0
- package/dist/types/atoms/container/container.d.ts +6 -0
- package/dist/types/atoms/form-elements/range-slider/range-slider.d.ts +11 -0
- package/dist/types/atoms/form-elements/utilities/range-slider.d.ts +7 -0
- package/dist/types/atoms/image/image.d.ts +14 -0
- package/dist/types/atoms/image/index.d.ts +1 -0
- package/dist/types/atoms/image/utilities/create-image-url.d.ts +6 -0
- package/dist/types/atoms/image/utilities/detect-responsive-images.d.ts +7 -0
- package/dist/types/atoms/image/utilities/image.d.ts +18 -0
- package/dist/types/atoms/image/utilities/object-fit.d.ts +7 -0
- package/dist/types/atoms/row/row.d.ts +6 -0
- package/dist/types/atoms/svg/svg.d.ts +4 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/molecules/infobox/index.d.ts +1 -0
- package/dist/types/molecules/infobox/infobox.d.ts +7 -0
- package/dist/types/molecules/map/hooks/use-style-loaded.d.ts +2 -0
- package/dist/types/molecules/map/index.d.ts +3 -0
- package/dist/types/molecules/map/map.d.ts +2 -0
- package/dist/types/molecules/map/store/map/index.d.ts +1 -0
- package/dist/types/molecules/map/store/map/store.d.ts +60 -0
- package/dist/types/molecules/map/storybook/themes.d.ts +3 -0
- package/dist/types/molecules/map/utilities/fit-bounds.d.ts +3 -0
- package/dist/types/molecules/map/utilities/mapbox/add-data.d.ts +3 -0
- package/dist/types/molecules/map/utilities/mapbox/center.d.ts +3 -0
- package/dist/types/molecules/map/utilities/mapbox/constants.d.ts +2 -0
- package/dist/types/molecules/map/utilities/mapbox/index.d.ts +2 -0
- package/dist/types/molecules/map/utilities/mapbox/mapbox.d.ts +16 -0
- package/dist/types/molecules/map/utilities/mapbox/parse-feature-properties.d.ts +6 -0
- package/dist/types/molecules/map/utilities/mapbox/pointers/setup-pointers.d.ts +3 -0
- package/dist/types/molecules/map/utilities/mapbox/polygons/feature-state.d.ts +2 -0
- package/dist/types/molecules/map/utilities/mapbox/polygons/geojson.d.ts +3 -0
- package/dist/types/molecules/map/utilities/mapbox/polygons/interaction.d.ts +3 -0
- package/dist/types/molecules/map/utilities/mapbox/polygons/layer.d.ts +3 -0
- package/dist/types/molecules/map/utilities/mapbox/raster.d.ts +3 -0
- package/dist/types/molecules/map/utilities/mapbox/search/alternative-city-suggestions.d.ts +3 -0
- package/dist/types/molecules/map/utilities/mapbox/search/search.d.ts +4 -0
- package/dist/types/molecules/map/utilities/mapbox/tooltip.d.ts +4 -0
- package/dist/types/molecules/tooltip/index.d.ts +1 -0
- package/dist/types/molecules/tooltip/tooltip.d.ts +7 -0
- package/package.json +4 -4
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -79
- package/coverage/index.html +0 -95
- package/coverage/lcov.info +0 -0
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -170
- package/dist/molecules/map/store/map/hooks/index.d.ts +0 -1
- package/dist/molecules/map/store/map/hooks/index.js +0 -2
- package/dist/molecules/map/store/map/hooks/index.js.map +0 -1
- package/dist/molecules/map/store/map/hooks/use-map-instance.d.ts +0 -2
- package/dist/molecules/map/store/map/hooks/use-map-instance.js +0 -15
- package/dist/molecules/map/store/map/hooks/use-map-instance.js.map +0 -1
|
@@ -0,0 +1,172 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,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,EAAE,GAAG,EAAE;YACrB,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;QAEH,kBAAkB,CAAC;YACf,KAAK,EAAE,YAAY;YACnB,MAAM;YACN,mBAAmB;YACnB,mBAAmB;SACtB,CAAC,CAAC;IACP,CAAC;IAED,SAAS,qBAAqB,CAAC,OAAY;QACvC,YAAY,CAAC,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC;QAExC,yBAAyB,EAAE,CAAC;QAC5B,WAAW,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAED,SAAS,iBAAiB,CAAC,WAAgB;QACvC,yBAAyB,EAAE,CAAC;QAE5B,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"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/molecules/tooltip/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC","sourcesContent":["export * from './tooltip';\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="mapbox-gl" />
|
|
2
|
-
import { BoundingBox,
|
|
2
|
+
import { BoundingBox, MapDataItem, MapDirectionsSetting, MapIsochroneSetting } from '@bpd-library/types';
|
|
3
3
|
export declare type SearchResult = {
|
|
4
4
|
items: MapDataItem[];
|
|
5
5
|
result: any;
|
|
@@ -16,7 +16,6 @@ export interface MapLayerRasterSettings {
|
|
|
16
16
|
minzoom?: number;
|
|
17
17
|
maxzoom?: number;
|
|
18
18
|
}
|
|
19
|
-
export declare type MapManualSearch = string | Coordinate;
|
|
20
19
|
export interface MapState {
|
|
21
20
|
data: MapDataItem[];
|
|
22
21
|
mapInstance?: mapboxgl.Map;
|
|
@@ -33,7 +32,7 @@ export interface MapState {
|
|
|
33
32
|
};
|
|
34
33
|
searchResult?: SearchResult;
|
|
35
34
|
searchIsMoving: boolean;
|
|
36
|
-
manualSearch?:
|
|
35
|
+
manualSearch?: string;
|
|
37
36
|
layerRasterSettings?: MapLayerRasterSettings;
|
|
38
37
|
isochroneSetting?: MapIsochroneSetting;
|
|
39
38
|
directionsSetting?: MapDirectionsSetting;
|
|
@@ -50,7 +49,7 @@ export declare const clearSearchResult: () => void;
|
|
|
50
49
|
export declare const setFilter: (data: MapDataItem[]) => void;
|
|
51
50
|
export declare const clearFilter: () => void;
|
|
52
51
|
export declare const setMapInstance: (mapInstance: mapboxgl.Map) => void;
|
|
53
|
-
export declare const manualSearch: (query:
|
|
52
|
+
export declare const manualSearch: (query: string) => void;
|
|
54
53
|
export declare const updateSearchIsMoving: (isMoving: boolean) => void;
|
|
55
54
|
export declare const setLayerRaster: (layerRasterSettings: MapLayerRasterSettings) => void;
|
|
56
55
|
export declare const setIsochrone: (isochroneSetting: MapIsochroneSetting) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../../../../src/molecules/map/store/map/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAoD3C,MAAM,YAAY,GAAa;IAC3B,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,EAAE;IACT,KAAK,EAAE,EAAE;IACT,cAAc,EAAE,KAAK;CACxB,CAAC;AAEF,MAAM,eAAe,GAAG,eAAe,CAAC;AACxC,MAAM,YAAY,GAAG,aAAa,CAAC;AACnC,MAAM,WAAW,GAAG,YAAY,CAAC;AACjC,MAAM,YAAY,GAAG,aAAa,CAAC;AACnC,MAAM,SAAS,GAAG,UAAU,CAAC;AAC7B,MAAM,WAAW,GAAG,YAAY,CAAC;AACjC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AAClD,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AAChD,MAAM,uBAAuB,GAAG,sBAAsB,CAAC;AACvD,MAAM,UAAU,GAAG,WAAW,CAAC;AAC/B,MAAM,YAAY,GAAG,aAAa,CAAC;AACnC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAC1C,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAC5C,MAAM,aAAa,GAAG,cAAc,CAAC;AACrC,MAAM,aAAa,GAAG,cAAc,CAAC;AACrC,MAAM,eAAe,GAAG,gBAAgB,CAAC;AACzC,MAAM,cAAc,GAAG,eAAe,CAAC;AACvC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAE3C,MAAM,OAAO,GAAG;IACZ,CAAC,eAAe,CAAC,EAAE,CAAC,KAAe,EAAE,IAAmB,EAAE,EAAE;QACxD,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QAClB,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,CAAC,YAAY,CAAC,EAAE,CAAC,KAAe,EAAE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1E,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,CAAC;AAC7D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,gBAAqC,EAAE,EAAE;IAClE,QAAQ,CAAC,QAAQ,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IAC/B,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,iBAAuC,EAAE,EAAE;IACrE,QAAQ,CAAC,QAAQ,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;AACzD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAChC,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AACxC,CAAC,CAAC;AAKF,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC;AAC5D,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC;AACxD,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC;AACpE,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,cAAc,CAAC","sourcesContent":["import { createStore } from '@atomify/kit';\nimport {\n BoundingBox,\n Coordinate,\n MapDataItem,\n MapDirectionsSetting,\n MapIsochroneSetting,\n} from '@bpd-library/types';\n\nexport type SearchResult = {\n items: MapDataItem[];\n result: any;\n originalBoundingBox?: BoundingBox;\n expandedBoundingBox?: BoundingBox;\n};\n\ninterface MapFocusOptions {\n zoom?: boolean;\n toggleTooltip?: boolean;\n static?: boolean;\n}\n\nexport interface MapLayerRasterSettings {\n layerRaster: string;\n minzoom?: number;\n maxzoom?: number;\n}\n\nexport type MapManualSearch = string | Coordinate;\n\nexport interface MapState {\n data: MapDataItem[];\n mapInstance?: mapboxgl.Map;\n hover: {\n current?: MapDataItem;\n previous?: MapDataItem;\n };\n filter?: MapDataItem[];\n click?: MapDataItem;\n focus: {\n current?: MapDataItem[];\n previous?: MapDataItem[];\n options?: MapFocusOptions;\n };\n searchResult?: SearchResult;\n searchIsMoving: boolean;\n manualSearch?: MapManualSearch;\n layerRasterSettings?: MapLayerRasterSettings;\n isochroneSetting?: MapIsochroneSetting;\n directionsSetting?: MapDirectionsSetting;\n}\n\nconst initialState: MapState = {\n data: [],\n hover: {},\n focus: {},\n searchIsMoving: false,\n};\n\nconst UPDATE_MAP_DATA = 'updateMapData';\nconst UPDATE_HOVER = 'updateHover';\nconst CLEAR_HOVER = 'clearHover';\nconst UPDATE_CLICK = 'updateClick';\nconst SET_FOCUS = 'setFocus';\nconst CLEAR_FOCUS = 'clearFocus';\nconst UPDATE_SEARCH_RESULT = 'updateSearchResult';\nconst CLEAR_SEARCH_RESULT = 'clearSearchResult';\nconst UPDATE_SEARCH_IS_MOVING = 'updateSearchIsMoving';\nconst SET_FILTER = 'setFilter';\nconst CLEAR_FILTER = 'clearFilter';\nconst SET_MAP_INSTANCE = 'setMapInstance';\nconst SET_LAYER_RASTER = 'SET_LAYER_RASTER';\nconst MANUAL_SEARCH = 'manualSearch';\nconst SET_ISOCHRONE = 'setIsochrone';\nconst CLEAR_ISOCHRONE = 'clearIsochrone';\nconst SET_DIRECTIONS = 'setDirections';\nconst CLEAR_DIRECTIONS = 'clearDirections';\n\nconst actions = {\n [UPDATE_MAP_DATA]: (state: MapState, data: MapDataItem[]) => {\n state.data = data;\n return state;\n },\n [UPDATE_HOVER]: (state: MapState, hover: MapDataItem) => {\n state.hover = {\n current: hover,\n previous: state.hover.current,\n };\n\n return state;\n },\n [CLEAR_HOVER]: (state: MapState) => {\n state.hover = {\n current: undefined,\n previous: state.hover.current,\n };\n\n return state;\n },\n [UPDATE_CLICK]: (state: MapState, click: MapDataItem) => {\n state.click = { ...click };\n return state;\n },\n [SET_FOCUS]: (\n state: MapState,\n { ids, options }: { ids: string[]; options: MapFocusOptions },\n ) => {\n const dataItems = state.data.filter(({ id }) => ids.indexOf(id) > -1);\n\n if (dataItems.length) {\n state.focus = {\n current: dataItems,\n previous: state.focus?.current,\n options,\n };\n }\n\n return state;\n },\n [CLEAR_FOCUS]: (state: MapState) => {\n state.focus = {\n current: undefined,\n previous: state.focus.current,\n };\n\n return state;\n },\n [UPDATE_SEARCH_RESULT]: (state: MapState, searchResult: SearchResult) => {\n state.searchResult = searchResult;\n return state;\n },\n [CLEAR_SEARCH_RESULT]: (state: MapState) => {\n state.searchResult = undefined;\n return state;\n },\n [SET_FILTER]: (state: MapState, data: MapDataItem[]) => {\n state.filter = data;\n return state;\n },\n [CLEAR_FILTER]: (state: MapState) => {\n state.filter = undefined;\n return state;\n },\n [SET_MAP_INSTANCE]: (state: MapState, mapInstance: mapboxgl.Map) => {\n state.mapInstance = mapInstance;\n return state;\n },\n [MANUAL_SEARCH]: (state: MapState, query: MapManualSearch) => {\n state.manualSearch = query;\n return state;\n },\n [UPDATE_SEARCH_IS_MOVING]: (state: MapState, searchIsMoving: boolean) => {\n state.searchIsMoving = searchIsMoving;\n return state;\n },\n [SET_LAYER_RASTER]: (state: MapState, layerRasterSettings: MapLayerRasterSettings) => {\n state.layerRasterSettings = layerRasterSettings;\n return state;\n },\n [SET_ISOCHRONE]: (state: MapState, isochroneSetting: MapIsochroneSetting) => {\n state.isochroneSetting = isochroneSetting;\n return state;\n },\n [CLEAR_ISOCHRONE]: (state: MapState) => {\n state.isochroneSetting = undefined;\n return state;\n },\n [SET_DIRECTIONS]: (state: MapState, directionsSetting: MapDirectionsSetting) => {\n state.directionsSetting = directionsSetting;\n return state;\n },\n [CLEAR_DIRECTIONS]: (state: MapState) => {\n state.directionsSetting = undefined;\n return state;\n },\n};\n\nexport const mapStore = createStore<MapState>({\n initialState,\n actions: actions as any,\n});\n\n/*\n Setters\n*/\nexport const updateMapData = (data: MapDataItem[]) => {\n mapStore.dispatch(UPDATE_MAP_DATA, data);\n};\n\nexport const clearHover = () => {\n mapStore.dispatch(CLEAR_HOVER);\n};\n\nexport const updateHover = (hover: MapDataItem) => {\n mapStore.dispatch(UPDATE_HOVER, hover);\n};\n\nexport const updateClick = (click: MapDataItem) => {\n mapStore.dispatch(UPDATE_CLICK, click);\n};\n\nexport const setFocus = (ids: string[], options: MapFocusOptions = {}) => {\n mapStore.dispatch(SET_FOCUS, { ids, options });\n};\n\nexport const clearFocus = () => {\n mapStore.dispatch(CLEAR_FOCUS);\n};\n\nexport const updateSearchResult = (searchResult: SearchResult) => {\n mapStore.dispatch(UPDATE_SEARCH_RESULT, searchResult);\n};\n\nexport const clearSearchResult = () => {\n mapStore.dispatch(CLEAR_SEARCH_RESULT);\n};\n\nexport const setFilter = (data: MapDataItem[]) => {\n mapStore.dispatch(SET_FILTER, data);\n};\n\nexport const clearFilter = () => {\n mapStore.dispatch(CLEAR_FILTER);\n};\n\nexport const setMapInstance = (mapInstance: mapboxgl.Map) => {\n mapStore.dispatch(SET_MAP_INSTANCE, mapInstance);\n};\n\nexport const manualSearch = (query: MapManualSearch) => {\n mapStore.dispatch(MANUAL_SEARCH, query);\n};\n\nexport const updateSearchIsMoving = (isMoving: boolean) => {\n mapStore.dispatch(UPDATE_SEARCH_IS_MOVING, isMoving);\n};\n\nexport const setLayerRaster = (layerRasterSettings: MapLayerRasterSettings) => {\n mapStore.dispatch(SET_LAYER_RASTER, layerRasterSettings);\n};\n\nexport const setIsochrone = (isochroneSetting: MapIsochroneSetting) => {\n mapStore.dispatch(SET_ISOCHRONE, isochroneSetting);\n};\n\nexport const clearIsochrone = () => {\n mapStore.dispatch(CLEAR_ISOCHRONE);\n};\n\nexport const setDirections = (directionsSetting: MapDirectionsSetting) => {\n mapStore.dispatch(SET_DIRECTIONS, directionsSetting);\n};\n\nexport const clearDirections = () => {\n mapStore.dispatch(CLEAR_DIRECTIONS);\n};\n\n/*\n Getters\n*/\nexport const getMapboxData = () => mapStore.getState().data;\nexport const getHover = () => mapStore.getState().hover;\nexport const getMapInstance = () => mapStore.getState().mapInstance;\nexport const getSearchIsMoving = () => mapStore.getState().searchIsMoving;\n"]}
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../../../../src/molecules/map/store/map/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAiD3C,MAAM,YAAY,GAAa;IAC3B,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,EAAE;IACT,KAAK,EAAE,EAAE;IACT,cAAc,EAAE,KAAK;CACxB,CAAC;AAEF,MAAM,eAAe,GAAG,eAAe,CAAC;AACxC,MAAM,YAAY,GAAG,aAAa,CAAC;AACnC,MAAM,WAAW,GAAG,YAAY,CAAC;AACjC,MAAM,YAAY,GAAG,aAAa,CAAC;AACnC,MAAM,SAAS,GAAG,UAAU,CAAC;AAC7B,MAAM,WAAW,GAAG,YAAY,CAAC;AACjC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AAClD,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AAChD,MAAM,uBAAuB,GAAG,sBAAsB,CAAC;AACvD,MAAM,UAAU,GAAG,WAAW,CAAC;AAC/B,MAAM,YAAY,GAAG,aAAa,CAAC;AACnC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAC1C,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAC5C,MAAM,aAAa,GAAG,cAAc,CAAC;AACrC,MAAM,aAAa,GAAG,cAAc,CAAC;AACrC,MAAM,eAAe,GAAG,gBAAgB,CAAC;AACzC,MAAM,cAAc,GAAG,eAAe,CAAC;AACvC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC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esContent":["import { createStore } from '@atomify/kit';\nimport {\n BoundingBox,\n MapDataItem,\n MapDirectionsSetting,\n MapIsochroneSetting,\n} from '@bpd-library/types';\n\nexport type SearchResult = {\n items: MapDataItem[];\n result: any;\n originalBoundingBox?: BoundingBox;\n expandedBoundingBox?: BoundingBox;\n};\n\ninterface MapFocusOptions {\n zoom?: boolean;\n toggleTooltip?: boolean;\n static?: boolean;\n}\n\nexport interface MapLayerRasterSettings {\n layerRaster: string;\n minzoom?: number;\n maxzoom?: number;\n}\n\nexport interface MapState {\n data: MapDataItem[];\n mapInstance?: mapboxgl.Map;\n hover: {\n current?: MapDataItem;\n previous?: MapDataItem;\n };\n filter?: MapDataItem[];\n click?: MapDataItem;\n focus: {\n current?: MapDataItem[];\n previous?: MapDataItem[];\n options?: MapFocusOptions;\n };\n searchResult?: SearchResult;\n searchIsMoving: boolean;\n manualSearch?: string;\n layerRasterSettings?: MapLayerRasterSettings;\n isochroneSetting?: MapIsochroneSetting;\n directionsSetting?: MapDirectionsSetting;\n}\n\nconst initialState: MapState = {\n data: [],\n hover: {},\n focus: {},\n searchIsMoving: false,\n};\n\nconst UPDATE_MAP_DATA = 'updateMapData';\nconst UPDATE_HOVER = 'updateHover';\nconst CLEAR_HOVER = 'clearHover';\nconst UPDATE_CLICK = 'updateClick';\nconst SET_FOCUS = 'setFocus';\nconst CLEAR_FOCUS = 'clearFocus';\nconst UPDATE_SEARCH_RESULT = 'updateSearchResult';\nconst CLEAR_SEARCH_RESULT = 'clearSearchResult';\nconst UPDATE_SEARCH_IS_MOVING = 'updateSearchIsMoving';\nconst SET_FILTER = 'setFilter';\nconst CLEAR_FILTER = 'clearFilter';\nconst SET_MAP_INSTANCE = 'setMapInstance';\nconst SET_LAYER_RASTER = 'SET_LAYER_RASTER';\nconst MANUAL_SEARCH = 'manualSearch';\nconst SET_ISOCHRONE = 'setIsochrone';\nconst CLEAR_ISOCHRONE = 'clearIsochrone';\nconst SET_DIRECTIONS = 'setDirections';\nconst CLEAR_DIRECTIONS = 'clearDirections';\n\nconst actions = {\n [UPDATE_MAP_DATA]: (state: MapState, data: MapDataItem[]) => {\n state.data = data;\n return state;\n },\n [UPDATE_HOVER]: (state: MapState, hover: MapDataItem) => {\n state.hover = {\n current: hover,\n previous: state.hover.current,\n };\n\n return state;\n },\n [CLEAR_HOVER]: (state: MapState) => {\n state.hover = {\n current: undefined,\n previous: state.hover.current,\n };\n\n return state;\n },\n [UPDATE_CLICK]: (state: MapState, click: MapDataItem) => {\n state.click = { ...click };\n return state;\n },\n [SET_FOCUS]: (\n state: MapState,\n { ids, options }: { ids: string[]; options: MapFocusOptions },\n ) => {\n const dataItems = state.data.filter(({ id }) => ids.indexOf(id) > -1);\n\n if (dataItems.length) {\n state.focus = {\n current: dataItems,\n previous: state.focus?.current,\n options,\n };\n }\n\n return state;\n },\n [CLEAR_FOCUS]: (state: MapState) => {\n state.focus = {\n current: undefined,\n previous: state.focus.current,\n };\n\n return state;\n },\n [UPDATE_SEARCH_RESULT]: (state: MapState, searchResult: SearchResult) => {\n state.searchResult = searchResult;\n return state;\n },\n [CLEAR_SEARCH_RESULT]: (state: MapState) => {\n state.searchResult = undefined;\n return state;\n },\n [SET_FILTER]: (state: MapState, data: MapDataItem[]) => {\n state.filter = data;\n return state;\n },\n [CLEAR_FILTER]: (state: MapState) => {\n state.filter = undefined;\n return state;\n },\n [SET_MAP_INSTANCE]: (state: MapState, mapInstance: mapboxgl.Map) => {\n state.mapInstance = mapInstance;\n return state;\n },\n [MANUAL_SEARCH]: (state: MapState, query: string) => {\n state.manualSearch = query;\n return state;\n },\n [UPDATE_SEARCH_IS_MOVING]: (state: MapState, searchIsMoving: boolean) => {\n state.searchIsMoving = searchIsMoving;\n return state;\n },\n [SET_LAYER_RASTER]: (state: MapState, layerRasterSettings: MapLayerRasterSettings) => {\n state.layerRasterSettings = layerRasterSettings;\n return state;\n },\n [SET_ISOCHRONE]: (state: MapState, isochroneSetting: MapIsochroneSetting) => {\n state.isochroneSetting = isochroneSetting;\n return state;\n },\n [CLEAR_ISOCHRONE]: (state: MapState) => {\n state.isochroneSetting = undefined;\n return state;\n },\n [SET_DIRECTIONS]: (state: MapState, directionsSetting: MapDirectionsSetting) => {\n state.directionsSetting = directionsSetting;\n return state;\n },\n [CLEAR_DIRECTIONS]: (state: MapState) => {\n state.directionsSetting = undefined;\n return state;\n },\n};\n\nexport const mapStore = createStore<MapState>({\n initialState,\n actions: actions as any,\n});\n\n/*\n Setters\n*/\nexport const updateMapData = (data: MapDataItem[]) => {\n mapStore.dispatch(UPDATE_MAP_DATA, data);\n};\n\nexport const clearHover = () => {\n mapStore.dispatch(CLEAR_HOVER);\n};\n\nexport const updateHover = (hover: MapDataItem) => {\n mapStore.dispatch(UPDATE_HOVER, hover);\n};\n\nexport const updateClick = (click: MapDataItem) => {\n mapStore.dispatch(UPDATE_CLICK, click);\n};\n\nexport const setFocus = (ids: string[], options: MapFocusOptions = {}) => {\n mapStore.dispatch(SET_FOCUS, { ids, options });\n};\n\nexport const clearFocus = () => {\n mapStore.dispatch(CLEAR_FOCUS);\n};\n\nexport const updateSearchResult = (searchResult: SearchResult) => {\n mapStore.dispatch(UPDATE_SEARCH_RESULT, searchResult);\n};\n\nexport const clearSearchResult = () => {\n mapStore.dispatch(CLEAR_SEARCH_RESULT);\n};\n\nexport const setFilter = (data: MapDataItem[]) => {\n mapStore.dispatch(SET_FILTER, data);\n};\n\nexport const clearFilter = () => {\n mapStore.dispatch(CLEAR_FILTER);\n};\n\nexport const setMapInstance = (mapInstance: mapboxgl.Map) => {\n mapStore.dispatch(SET_MAP_INSTANCE, mapInstance);\n};\n\nexport const manualSearch = (query: string) => {\n mapStore.dispatch(MANUAL_SEARCH, query);\n};\n\nexport const updateSearchIsMoving = (isMoving: boolean) => {\n mapStore.dispatch(UPDATE_SEARCH_IS_MOVING, isMoving);\n};\n\nexport const setLayerRaster = (layerRasterSettings: MapLayerRasterSettings) => {\n mapStore.dispatch(SET_LAYER_RASTER, layerRasterSettings);\n};\n\nexport const setIsochrone = (isochroneSetting: MapIsochroneSetting) => {\n mapStore.dispatch(SET_ISOCHRONE, isochroneSetting);\n};\n\nexport const clearIsochrone = () => {\n mapStore.dispatch(CLEAR_ISOCHRONE);\n};\n\nexport const setDirections = (directionsSetting: MapDirectionsSetting) => {\n mapStore.dispatch(SET_DIRECTIONS, directionsSetting);\n};\n\nexport const clearDirections = () => {\n mapStore.dispatch(CLEAR_DIRECTIONS);\n};\n\n/*\n Getters\n*/\nexport const getMapboxData = () => mapStore.getState().data;\nexport const getHover = () => mapStore.getState().hover;\nexport const getMapInstance = () => mapStore.getState().mapInstance;\nexport const getSearchIsMoving = () => mapStore.getState().searchIsMoving;\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface ButtonInterface {
|
|
2
|
+
label: string | Text;
|
|
3
|
+
variant?: string;
|
|
4
|
+
icon?: string;
|
|
5
|
+
size?: string;
|
|
6
|
+
classes?: string;
|
|
7
|
+
type?: string;
|
|
8
|
+
url?: string;
|
|
9
|
+
hook?: string;
|
|
10
|
+
controls?: string;
|
|
11
|
+
onClick?: Function;
|
|
12
|
+
target?: string;
|
|
13
|
+
attr?: {};
|
|
14
|
+
}
|
|
15
|
+
declare const Button: (data: ButtonInterface) => any;
|
|
16
|
+
declare const ButtonA: (data: ButtonInterface) => any;
|
|
17
|
+
export { Button, ButtonA };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './button';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface ColInterface {
|
|
2
|
+
extraClass?: string;
|
|
3
|
+
children?: NodeList;
|
|
4
|
+
cols?: (number | undefined)[];
|
|
5
|
+
push?: (number | undefined)[];
|
|
6
|
+
pull?: (number | undefined)[];
|
|
7
|
+
pre?: (number | undefined)[];
|
|
8
|
+
post?: (number | undefined)[];
|
|
9
|
+
}
|
|
10
|
+
export declare const Col: ({ extraClass, children, cols, push, pull, pre, post, }: ColInterface) => any;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface RangeSliderProps {
|
|
2
|
+
min: number;
|
|
3
|
+
max: number;
|
|
4
|
+
increment: number;
|
|
5
|
+
start: number[];
|
|
6
|
+
onChange: (e: CustomEvent) => void;
|
|
7
|
+
name: string;
|
|
8
|
+
classes?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const RangeSliderElement: ({ classes, disabled, min, max, increment, start, name, onChange, }: RangeSliderProps) => any;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Setting, Settings } from './utilities/image';
|
|
2
|
+
export interface ImageInterface {
|
|
3
|
+
image: string;
|
|
4
|
+
alt: string;
|
|
5
|
+
settings?: Settings;
|
|
6
|
+
preload?: Setting;
|
|
7
|
+
srcset?: string;
|
|
8
|
+
classes?: string;
|
|
9
|
+
caption?: string;
|
|
10
|
+
hidden?: boolean;
|
|
11
|
+
objectFit?: boolean | 'contain';
|
|
12
|
+
disableCrossFade?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const Image: (data: ImageInterface) => any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './image';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface Setting {
|
|
2
|
+
width?: number;
|
|
3
|
+
height?: number;
|
|
4
|
+
src?: boolean | undefined;
|
|
5
|
+
}
|
|
6
|
+
export interface Settings {
|
|
7
|
+
[key: string]: Setting;
|
|
8
|
+
}
|
|
9
|
+
export declare class BPDImage extends HTMLElement {
|
|
10
|
+
img: HTMLImageElement;
|
|
11
|
+
componentDidLoad(): void;
|
|
12
|
+
disconnectedCallback(): void;
|
|
13
|
+
private parseSettings;
|
|
14
|
+
private generateSrc;
|
|
15
|
+
private generateSrcset;
|
|
16
|
+
private loadImage;
|
|
17
|
+
private renderImage;
|
|
18
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare type ImageElement = HTMLImageElement | HTMLImageElement[];
|
|
2
|
+
export default class ObjectFit {
|
|
3
|
+
static polyfillObjectFit(element: ImageElement): void;
|
|
4
|
+
static getObjectfitImages(element: ImageElement): HTMLImageElement[];
|
|
5
|
+
private static polyfillImage;
|
|
6
|
+
}
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './atoms/button';
|
|
2
|
+
export * from './atoms/col/col';
|
|
3
|
+
export * from './atoms/container/container';
|
|
4
|
+
export * from './atoms/form-elements/range-slider/range-slider';
|
|
5
|
+
export * from './atoms/form-elements/utilities/range-slider';
|
|
6
|
+
export * from './atoms/image';
|
|
7
|
+
export * from './atoms/row/row';
|
|
8
|
+
export * from './atoms/svg/svg';
|
|
9
|
+
export * from './molecules/infobox';
|
|
10
|
+
export * from './molecules/map';
|
|
11
|
+
export * from './molecules/tooltip';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './infobox';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MapInfobox } from '@bpd-library/types';
|
|
2
|
+
interface InfoboxInterface extends MapInfobox {
|
|
3
|
+
onClose: () => void;
|
|
4
|
+
openInTab?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const Infobox: ({ title, image, tags, description, link, onClose, openInTab, }: InfoboxInterface) => any;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './store';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/// <reference types="mapbox-gl" />
|
|
2
|
+
import { BoundingBox, MapDataItem } 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
|
+
}
|
|
38
|
+
export declare const mapStore: import("@atomify/kit/dist/utilities/store/store.types").Store<MapState>;
|
|
39
|
+
export declare const updateMapData: (data: MapDataItem[]) => void;
|
|
40
|
+
export declare const clearHover: () => void;
|
|
41
|
+
export declare const updateHover: (hover: MapDataItem) => void;
|
|
42
|
+
export declare const updateClick: (click: MapDataItem) => void;
|
|
43
|
+
export declare const setFocus: (ids: string[], options?: MapFocusOptions) => void;
|
|
44
|
+
export declare const clearFocus: () => void;
|
|
45
|
+
export declare const updateSearchResult: (searchResult: SearchResult) => void;
|
|
46
|
+
export declare const clearSearchResult: () => void;
|
|
47
|
+
export declare const setFilter: (data: MapDataItem[]) => void;
|
|
48
|
+
export declare const clearFilter: () => void;
|
|
49
|
+
export declare const setMapInstance: (mapInstance: mapboxgl.Map) => void;
|
|
50
|
+
export declare const manualSearch: (query: string) => void;
|
|
51
|
+
export declare const updateSearchIsMoving: (isMoving: boolean) => void;
|
|
52
|
+
export declare const setLayerRaster: (layerRasterSettings: MapLayerRasterSettings) => void;
|
|
53
|
+
export declare const getMapboxData: () => MapDataItem[];
|
|
54
|
+
export declare const getHover: () => {
|
|
55
|
+
current?: MapDataItem | undefined;
|
|
56
|
+
previous?: MapDataItem | undefined;
|
|
57
|
+
};
|
|
58
|
+
export declare const getMapInstance: () => import("mapbox-gl").Map | undefined;
|
|
59
|
+
export declare const getSearchIsMoving: () => boolean;
|
|
60
|
+
export {};
|