@bpd-library/components 1.2.4 → 1.2.5-beta.3

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.
Files changed (49) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js +0 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/molecules/map/hooks/index.d.ts +1 -0
  5. package/dist/molecules/map/hooks/index.js +2 -0
  6. package/dist/molecules/map/hooks/index.js.map +1 -0
  7. package/dist/molecules/map/hooks/use-map-instance.d.ts +2 -0
  8. package/dist/molecules/map/hooks/use-map-instance.js +15 -0
  9. package/dist/molecules/map/hooks/use-map-instance.js.map +1 -0
  10. package/dist/molecules/map/index.d.ts +2 -1
  11. package/dist/molecules/map/index.js +2 -1
  12. package/dist/molecules/map/index.js.map +1 -1
  13. package/dist/molecules/map/map.d.ts +4 -1
  14. package/dist/molecules/map/map.js +33 -52
  15. package/dist/molecules/map/map.js.map +1 -1
  16. package/dist/molecules/map/store/index.d.ts +1 -0
  17. package/dist/molecules/map/store/index.js +2 -0
  18. package/dist/molecules/map/store/index.js.map +1 -0
  19. package/dist/molecules/map/store/map/hooks/index.d.ts +1 -0
  20. package/dist/molecules/map/store/map/hooks/index.js +2 -0
  21. package/dist/molecules/map/store/map/hooks/index.js.map +1 -0
  22. package/dist/molecules/map/store/map/hooks/use-map-instance.d.ts +2 -0
  23. package/dist/molecules/map/store/map/hooks/use-map-instance.js +15 -0
  24. package/dist/molecules/map/store/map/hooks/use-map-instance.js.map +1 -0
  25. package/dist/molecules/map/store/map/index.d.ts +1 -0
  26. package/dist/molecules/map/store/map/index.js +1 -0
  27. package/dist/molecules/map/store/map/index.js.map +1 -1
  28. package/dist/molecules/map/store/store.d.ts +65 -0
  29. package/dist/molecules/map/store/store.js +179 -0
  30. package/dist/molecules/map/store/store.js.map +1 -0
  31. package/dist/molecules/map/utilities/mapbox/add-data.d.ts +3 -2
  32. package/dist/molecules/map/utilities/mapbox/add-data.js +37 -5
  33. package/dist/molecules/map/utilities/mapbox/add-data.js.map +1 -1
  34. package/dist/molecules/map/utilities/mapbox/directions/directions.d.ts +5 -0
  35. package/dist/molecules/map/utilities/mapbox/directions/directions.js +96 -0
  36. package/dist/molecules/map/utilities/mapbox/directions/directions.js.map +1 -0
  37. package/dist/molecules/map/utilities/mapbox/mapbox.d.ts +6 -4
  38. package/dist/molecules/map/utilities/mapbox/mapbox.js +7 -4
  39. package/dist/molecules/map/utilities/mapbox/mapbox.js.map +1 -1
  40. package/dist/molecules/map/utilities/mapbox/pointers/setup-pointers.js +1 -1
  41. package/dist/molecules/map/utilities/mapbox/pointers/setup-pointers.js.map +1 -1
  42. package/dist/molecules/map/utilities/mapbox/polygons/interaction.js +1 -1
  43. package/dist/molecules/map/utilities/mapbox/polygons/interaction.js.map +1 -1
  44. package/dist/molecules/map/utilities/mapbox/raster.d.ts +1 -1
  45. package/dist/molecules/map/utilities/mapbox/raster.js.map +1 -1
  46. package/dist/molecules/map/utilities/mapbox/search/search.d.ts +1 -1
  47. package/dist/molecules/map/utilities/mapbox/search/search.js +14 -9
  48. package/dist/molecules/map/utilities/mapbox/search/search.js.map +1 -1
  49. package/package.json +7 -4
package/dist/index.d.ts CHANGED
@@ -8,4 +8,3 @@ export * from './atoms/row/row';
8
8
  export * from './atoms/svg/svg';
9
9
  export * from './molecules/infobox';
10
10
  export * from './molecules/map';
11
- export * from './molecules/tooltip';
package/dist/index.js CHANGED
@@ -8,5 +8,4 @@ export * from './atoms/row/row';
8
8
  export * from './atoms/svg/svg';
9
9
  export * from './molecules/infobox';
10
10
  export * from './molecules/map';
11
- export * from './molecules/tooltip';
12
11
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iDAAiD,CAAC;AAChE,cAAc,8CAA8C,CAAC;AAC7D,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAKhC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC","sourcesContent":["/**\n * Atoms\n */\nexport * from './atoms/button';\nexport * from './atoms/col/col';\nexport * from './atoms/container/container';\nexport * from './atoms/form-elements/range-slider/range-slider';\nexport * from './atoms/form-elements/utilities/range-slider';\nexport * from './atoms/image';\nexport * from './atoms/row/row';\nexport * from './atoms/svg/svg';\n\n/**\n * Molecules\n */\nexport * from './molecules/infobox';\nexport * from './molecules/map';\nexport * from './molecules/tooltip';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iDAAiD,CAAC;AAChE,cAAc,8CAA8C,CAAC;AAC7D,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAKhC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC","sourcesContent":["/**\n * Atoms\n */\nexport * from './atoms/button';\nexport * from './atoms/col/col';\nexport * from './atoms/container/container';\nexport * from './atoms/form-elements/range-slider/range-slider';\nexport * from './atoms/form-elements/utilities/range-slider';\nexport * from './atoms/image';\nexport * from './atoms/row/row';\nexport * from './atoms/svg/svg';\n\n/**\n * Molecules\n */\nexport * from './molecules/infobox';\nexport * from './molecules/map';\n"]}
@@ -0,0 +1 @@
1
+ export * from './use-map-instance';
@@ -0,0 +1,2 @@
1
+ export * from './use-map-instance';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/molecules/map/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC","sourcesContent":["export * from './use-map-instance';\n"]}
@@ -0,0 +1,2 @@
1
+ declare const useMapInstance: (callback: (mapInstance: mapboxgl.Map) => void) => void;
2
+ export { useMapInstance };
@@ -0,0 +1,15 @@
1
+ import { getMapInstance, mapStore } from '../store';
2
+ const useMapInstance = (callback) => {
3
+ const mapInstance = getMapInstance();
4
+ if (mapInstance) {
5
+ callback(mapInstance);
6
+ }
7
+ else {
8
+ mapStore.subscribe(({ mapInstance }) => {
9
+ if (mapInstance)
10
+ callback(mapInstance);
11
+ }, ['mapInstance']);
12
+ }
13
+ };
14
+ export { useMapInstance };
15
+ //# sourceMappingURL=use-map-instance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-map-instance.js","sourceRoot":"","sources":["../../../../src/molecules/map/hooks/use-map-instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAUpD,MAAM,cAAc,GAAG,CAAC,QAA6C,EAAE,EAAE;IACrE,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IAErC,IAAI,WAAW,EAAE;QACb,QAAQ,CAAC,WAAW,CAAC,CAAC;KACzB;SAAM;QACH,QAAQ,CAAC,SAAS,CACd,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE;YAChB,IAAI,WAAW;gBAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC3C,CAAC,EACD,CAAC,aAAa,CAAC,CAClB,CAAC;KACL;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { getMapInstance, mapStore } from '../store';\n\n/**\n * @description Callback will be called as soon as mapbox is initialized and the mapInstance is added to the store.\n * @example\n * useMapInstance(mapInstance => {\n * mapInstance.setCenter([51, 9]);\n * });\n * @param {(mapInstance: mapboxgl.Map) => void} callback\n */\nconst useMapInstance = (callback: (mapInstance: mapboxgl.Map) => void) => {\n const mapInstance = getMapInstance();\n\n if (mapInstance) {\n callback(mapInstance);\n } else {\n mapStore.subscribe(\n ({ mapInstance }) => {\n if (mapInstance) callback(mapInstance);\n },\n ['mapInstance'],\n );\n }\n};\n\nexport { useMapInstance };\n"]}
@@ -1,2 +1,3 @@
1
1
  export * from './utilities/fit-bounds';
2
- export * from './store/map';
2
+ export * from './store';
3
+ export * from './hooks';
@@ -1,3 +1,4 @@
1
1
  export * from './utilities/fit-bounds';
2
- export * from './store/map';
2
+ export * from './store';
3
+ export * from './hooks';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/molecules/map/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC","sourcesContent":["export * from './utilities/fit-bounds';\nexport * from './store/map';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/molecules/map/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC","sourcesContent":["export * from './utilities/fit-bounds';\nexport * from './store';\nexport * from './hooks';\n"]}
@@ -1 +1,4 @@
1
- export {};
1
+ import { Component } from '@atomify/hooks';
2
+ export interface MapProps extends Component {
3
+ pointerExists: (id: string) => boolean;
4
+ }
@@ -1,16 +1,15 @@
1
- import { defineElement, onDidLoad, useElement, useProp } from '@atomify/hooks';
1
+ import { defineElement, onDidLoad, useBindMethod, useElement, useProp, } from '@atomify/hooks';
2
2
  import { Fragment, h } from '@atomify/jsx';
3
- import { calculateMapDataBoundingBox, calculateMapDataCenter, detectTouch, expandBoundingBox, functionIsTrue, getCountryBoundingBox, } from '@bpd-library/utilities';
3
+ import { calculateMapDataBoundingBox, calculateMapDataCenter, expandBoundingBox, functionIsTrue, getCountryBoundingBox, } from '@bpd-library/utilities';
4
4
  import MapboxLanguage from '@mapbox/mapbox-gl-language';
5
5
  import mapboxgl from 'mapbox-gl';
6
6
  import { Button } from '../../atoms/button';
7
7
  import { Infobox } from '../infobox';
8
- import { clearHover, mapStore, setMapInstance } from './store/map';
8
+ import { clearHover, mapStore, setMapInstance } from './store';
9
9
  import mapbox from './utilities/mapbox';
10
10
  const DEFAULT_OPTIONS = {
11
11
  zoomButtons: true,
12
12
  mobileToggle: false,
13
- tooltipMode: 'hover',
14
13
  openInTab: false,
15
14
  autoOpenUrl: true,
16
15
  language: window.__ENVIRONMENT_DETAILS__.language || 'nl',
@@ -20,18 +19,17 @@ const CONTAINER_VISIBLE = 'map--is-visible';
20
19
  const MOBILE_TOGGLE_CLASS = 'map--mobile-toggle';
21
20
  const MAP_HOVERING_CLASS = 'map--hovering';
22
21
  const POINTER_FOCUS_CLASS = 'map__pointer--focus';
23
- const Map = () => {
22
+ const Map = ({ element }) => {
24
23
  let [options] = useProp('options', {});
25
24
  const [theme] = useProp('theme');
26
25
  const container = useElement('[js-hook-map-container]');
27
26
  const infoboxWrapper = useElement('[js-hook-infobox-wrapper]');
28
- const element = useElement('[js-hook-map]');
29
27
  let map;
30
28
  let mapboxHelpers;
31
- let focusTimeout;
29
+ useBindMethod('pointerExists', pointerExists);
32
30
  onDidLoad(async () => {
33
31
  if (options.mobileToggle)
34
- element.current.classList.add(MOBILE_TOGGLE_CLASS);
32
+ element.classList.add(MOBILE_TOGGLE_CLASS);
35
33
  options = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
36
34
  map = createMapboxInstance();
37
35
  mapboxHelpers = mapbox(map, options, theme);
@@ -49,19 +47,15 @@ const Map = () => {
49
47
  mapStore.subscribe(handleHover, ['hover']);
50
48
  mapStore.subscribe(handleClick, ['click']);
51
49
  mapStore.subscribe(handleFocus, ['focus']);
50
+ mapStore.subscribe(handleIsochrone, ['isochroneSetting']);
51
+ mapStore.subscribe(handleDirections, ['directionsSetting']);
52
52
  mapStore.subscribe(({ filter, data }) => addData(filter ? filter : data), ['filter']);
53
53
  mapStore.subscribe(({ layerRasterSettings }) => layerRasterSettings && mapboxHelpers.raster(layerRasterSettings), ['layerRasterSettings']);
54
54
  }
55
55
  function handleHover({ hover }) {
56
56
  const { current, previous } = hover;
57
57
  const canvasStyle = map.getCanvas().style;
58
- const { setFeatureState, addTooltip, removeTooltip } = mapboxHelpers;
59
- if (options.tooltipMode === 'hover') {
60
- if ((current === null || current === void 0 ? void 0 : current.tooltip) && !detectTouch.touch)
61
- addTooltip(current.coordinates, current);
62
- if (!current && !detectTouch.touch)
63
- removeTooltip();
64
- }
58
+ const { setFeatureState } = mapboxHelpers;
65
59
  if (hasHoverTheme()) {
66
60
  if (current)
67
61
  setFeatureState(current.variant, current.id, 'hover', true);
@@ -73,20 +67,8 @@ const Map = () => {
73
67
  function handleClick({ click }) {
74
68
  if (!click)
75
69
  return;
76
- const { addTooltip } = mapboxHelpers;
77
- const { infobox, coordinates, tooltip, url } = click;
70
+ const { infobox } = click;
78
71
  clearHover();
79
- if (options.tooltipMode === 'click' && tooltip) {
80
- addTooltip(coordinates, click);
81
- }
82
- if (options.tooltipMode === 'hover') {
83
- if (url && !detectTouch.touch && options.autoOpenUrl) {
84
- window.open(url, options.openInTab ? '_blank' : '_self');
85
- }
86
- else if ((url && tooltip) || (detectTouch.touch && !url && tooltip)) {
87
- addTooltip(coordinates, click);
88
- }
89
- }
90
72
  if (infobox) {
91
73
  showInfobox(infobox);
92
74
  }
@@ -96,9 +78,7 @@ const Map = () => {
96
78
  }
97
79
  function handleFocus({ focus }) {
98
80
  const { current, previous, options } = focus;
99
- const { setFeatureState, center, addTooltip, removeTooltip } = mapboxHelpers;
100
- if (focusTimeout)
101
- clearTimeout(focusTimeout);
81
+ const { setFeatureState, center } = mapboxHelpers;
102
82
  if (previous) {
103
83
  previous.forEach(({ id, variant }) => {
104
84
  if (hasHoverTheme())
@@ -108,25 +88,11 @@ const Map = () => {
108
88
  }
109
89
  if (current) {
110
90
  current.forEach((item) => {
111
- const { variant, id, coordinates, tooltip } = item;
112
- function handleTooltip() {
113
- const showTooltip = (options === null || options === void 0 ? void 0 : options.toggleTooltip) && tooltip;
114
- if (theme.polygon || pointerExists(id)) {
115
- if (showTooltip)
116
- addTooltip(coordinates, item);
117
- pointerFocusToggle(id, 'add');
118
- }
119
- }
91
+ const { variant, id } = item;
120
92
  if (theme.polygon) {
121
93
  if (hasHoverTheme())
122
94
  setFeatureState(variant, id, 'focus', true);
123
95
  }
124
- if (pointerExists(id)) {
125
- handleTooltip();
126
- }
127
- else {
128
- map.once('idle', handleTooltip);
129
- }
130
96
  });
131
97
  if (options === null || options === void 0 ? void 0 : options.zoom) {
132
98
  let bounds = calculateMapDataBoundingBox(current);
@@ -137,15 +103,30 @@ const Map = () => {
137
103
  center([[calculateMapDataCenter(current)]]);
138
104
  }
139
105
  }
106
+ }
107
+ function handleIsochrone({ isochroneSetting }) {
108
+ const { removeIsochrone, addIsochrone } = mapboxHelpers;
109
+ if (isochroneSetting) {
110
+ addIsochrone(isochroneSetting);
111
+ }
112
+ else {
113
+ removeIsochrone();
114
+ }
115
+ }
116
+ function handleDirections({ directionsSetting }) {
117
+ const { addDirections, removeDirections } = mapboxHelpers;
118
+ if (directionsSetting) {
119
+ addDirections(directionsSetting);
120
+ }
140
121
  else {
141
- removeTooltip();
122
+ removeDirections();
142
123
  }
143
124
  }
144
125
  function pointerFocusToggle(id, action) {
145
126
  const pointer = getPointerElementById(id);
146
127
  if (pointer) {
147
128
  pointer.classList[action](POINTER_FOCUS_CLASS);
148
- element.current.classList[action](MAP_HOVERING_CLASS);
129
+ element.classList[action](MAP_HOVERING_CLASS);
149
130
  }
150
131
  }
151
132
  function showInfobox(infobox) {
@@ -156,7 +137,7 @@ const Map = () => {
156
137
  infoboxWrapper.current.innerHTML = '';
157
138
  }
158
139
  function toggleMap() {
159
- element.current.classList.toggle(CONTAINER_VISIBLE);
140
+ element.classList.toggle(CONTAINER_VISIBLE);
160
141
  map.resize();
161
142
  }
162
143
  function hasHoverTheme() {
@@ -216,18 +197,18 @@ const Map = () => {
216
197
  });
217
198
  }
218
199
  if (theme.pointer) {
219
- setupPointers(element.current);
200
+ setupPointers(element);
220
201
  }
221
202
  map.resize();
222
203
  }
223
204
  function getPointerElementById(id) {
224
- return element.current.querySelector(`#pointer-${id}`);
205
+ return element.querySelector(`#pointer-${id}`);
225
206
  }
226
207
  function pointerExists(id) {
227
208
  return !!getPointerElementById(id);
228
209
  }
229
210
  return (h(Fragment, null,
230
- h("div", { class: "c-map", "js-hook-map": true },
211
+ h("div", { class: "c-map" },
231
212
  h("div", { className: "map__container", "js-hook-map-container": true },
232
213
  options.zoomButtons && (h("div", { class: "map__navigation" },
233
214
  h("button", { class: "map__button", onClick: () => map.zoomIn() },
@@ -1 +1 @@
1
- {"version":3,"file":"map.js","sourceRoot":"","sources":["../../../src/molecules/map/map.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAM,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EACH,2BAA2B,EAC3B,sBAAsB,EACtB,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,qBAAqB,GACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,cAAc,MAAM,4BAA4B,CAAC;AACxD,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAY,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAExC,MAAM,eAAe,GAAe;IAChC,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,KAAK;IACnB,WAAW,EAAE,OAAO;IACpB,SAAS,EAAE,KAAK;IAChB,WAAW,EAAE,IAAI;IACjB,QAAQ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;QAEL,OAAO,CAAC,YAAY,IAAI,CACrB,EAAC,QAAQ;YACL,EAAC,MAAM,IACH,OAAO,EAAC,IAAI,EACZ,KAAK,EAAE,OAAO,CAAC,iBAAiB,IAAI,YAAY,EAChD,OAAO,EAAC,WAAW,EACnB,OAAO,EAAE,SAAS,GAAW,CAC1B,CACd,CACM,CACd,CAAC;AACN,CAAC,CAAC;AAEF,GAAG,CAAC,KAAK,GAAG;IACR,OAAO,EAAE;QACL,IAAI,EAAE,MAAM;KACf;IACD,KAAK,EAAE;QACH,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACjB;IACD,WAAW,EAAE;QACT,IAAI,EAAE,OAAO;KAChB;CACJ,CAAC;AAEF,aAAa,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC","sourcesContent":["import { defineElement, FC, onDidLoad, useElement, useProp } from '@atomify/hooks';\nimport { Fragment, h } from '@atomify/jsx';\nimport { MapInfobox, MapOptions, MapSearchOptions, MapTheme } from '@bpd-library/types';\nimport {\n calculateMapDataBoundingBox,\n calculateMapDataCenter,\n detectTouch,\n expandBoundingBox,\n functionIsTrue,\n getCountryBoundingBox,\n} from '@bpd-library/utilities';\nimport MapboxLanguage from '@mapbox/mapbox-gl-language';\nimport mapboxgl from 'mapbox-gl';\n\nimport { Button } from '../../atoms/button';\nimport { Infobox } from '../infobox';\nimport { clearHover, MapState, mapStore, setMapInstance } from './store/map';\nimport mapbox from './utilities/mapbox';\n\nconst DEFAULT_OPTIONS: MapOptions = {\n zoomButtons: true,\n mobileToggle: false,\n tooltipMode: 'hover',\n openInTab: false,\n autoOpenUrl: true,\n language: window.__ENVIRONMENT_DETAILS__.language || 'nl',\n searchCountryIsoCodes: ['nl', 'de'],\n};\n\nconst CONTAINER_VISIBLE = 'map--is-visible';\nconst MOBILE_TOGGLE_CLASS = 'map--mobile-toggle';\nconst MAP_HOVERING_CLASS = 'map--hovering';\nconst POINTER_FOCUS_CLASS = 'map__pointer--focus';\n\nconst Map: FC = () => {\n let [options] = useProp<MapOptions>('options', {});\n const [theme] = useProp<MapTheme>('theme');\n const container = useElement<HTMLDivElement>('[js-hook-map-container]');\n const infoboxWrapper = useElement<HTMLDivElement>('[js-hook-infobox-wrapper]');\n const element = useElement<HTMLDivElement>('[js-hook-map]');\n\n let map: mapboxgl.Map;\n let mapboxHelpers: ReturnType<typeof mapbox>;\n let focusTimeout: ReturnType<typeof setTimeout> | undefined;\n\n onDidLoad(async () => {\n if (options.mobileToggle) element.current!.classList.add(MOBILE_TOGGLE_CLASS);\n options = { ...DEFAULT_OPTIONS, ...options };\n\n map = createMapboxInstance();\n mapboxHelpers = mapbox(map, options, theme);\n setMapInstance(map);\n\n await setupMapbox();\n\n subscribe();\n\n if (options.search)\n options.search.forEach((e: MapSearchOptions) => mapboxHelpers.search(e));\n });\n\n function subscribe() {\n const { filter, data } = mapStore.getState();\n const { addData } = mapboxHelpers;\n\n addData(filter ? filter : data);\n\n mapStore.subscribe(({ data }) => addData(data), ['data']);\n mapStore.subscribe(handleHover, ['hover']);\n mapStore.subscribe(handleClick, ['click']);\n mapStore.subscribe(handleFocus, ['focus']);\n mapStore.subscribe(({ filter, data }) => addData(filter ? filter : data), ['filter']);\n mapStore.subscribe(\n ({ layerRasterSettings }) =>\n layerRasterSettings && mapboxHelpers.raster(layerRasterSettings),\n ['layerRasterSettings'],\n );\n }\n\n function handleHover({ hover }: MapState) {\n const { current, previous } = hover;\n const canvasStyle = map.getCanvas().style;\n const { setFeatureState, addTooltip, removeTooltip } = mapboxHelpers;\n\n /*\n Add / Remove tooltip\n */\n if (options.tooltipMode === 'hover') {\n if (current?.tooltip && !detectTouch.touch) addTooltip(current.coordinates, current);\n if (!current && !detectTouch.touch) removeTooltip();\n }\n\n /*\n Set hover state\n */\n if (hasHoverTheme()) {\n if (current) setFeatureState(current.variant, current.id, 'hover', true);\n if (previous) setFeatureState(previous.variant, previous.id, 'hover', false);\n }\n\n canvasStyle.cursor = current ? 'pointer' : '';\n }\n\n function handleClick({ click }: MapState) {\n if (!click) return;\n\n const { addTooltip } = mapboxHelpers;\n const { infobox, coordinates, tooltip, url } = click;\n\n clearHover();\n\n if (options.tooltipMode === 'click' && tooltip) {\n addTooltip(coordinates, click);\n }\n\n if (options.tooltipMode === 'hover') {\n if (url && !detectTouch.touch && options.autoOpenUrl) {\n window.open(url, options.openInTab ? '_blank' : '_self');\n } else if ((url && tooltip) || (detectTouch.touch && !url && tooltip)) {\n addTooltip(coordinates, click);\n }\n }\n\n if (infobox) {\n showInfobox(infobox);\n } else {\n clearInfobox();\n }\n }\n\n function handleFocus({ focus }: MapState) {\n const { current, previous, options } = focus;\n const { setFeatureState, center, addTooltip, removeTooltip } = mapboxHelpers;\n\n if (focusTimeout) clearTimeout(focusTimeout);\n\n if (previous) {\n previous.forEach(({ id, variant }) => {\n if (hasHoverTheme()) setFeatureState(variant, id, 'focus', false);\n pointerFocusToggle(id, 'remove');\n });\n }\n\n if (current) {\n current.forEach((item) => {\n const { variant, id, coordinates, tooltip } = item;\n\n function handleTooltip() {\n const showTooltip = options?.toggleTooltip && tooltip;\n\n if (theme.polygon || pointerExists(id)) {\n if (showTooltip) addTooltip(coordinates, item);\n\n pointerFocusToggle(id, 'add');\n }\n }\n\n if (theme.polygon) {\n if (hasHoverTheme()) setFeatureState(variant, id, 'focus', true);\n }\n\n if (pointerExists(id)) {\n handleTooltip();\n } else {\n /*\n If a pointer doesn't exist, it means it's inside a cluster or outside of the view.\n When the map is idle, all newly centered pointers are drawn and the tooltip can be shown. (if not in a cluster)\n */\n map.once('idle', handleTooltip);\n }\n });\n\n if (options?.zoom) {\n let bounds = calculateMapDataBoundingBox(current);\n bounds = expandBoundingBox(bounds, 0.05);\n\n map.fitBounds(bounds);\n } else if (!options?.static) {\n center([[calculateMapDataCenter(current)]]);\n }\n } else {\n removeTooltip();\n }\n }\n\n function pointerFocusToggle(id: string, action: 'add' | 'remove') {\n const pointer = getPointerElementById(id);\n\n if (pointer) {\n pointer.classList[action](POINTER_FOCUS_CLASS);\n element.current!.classList[action](MAP_HOVERING_CLASS);\n }\n }\n\n function showInfobox(infobox: MapInfobox) {\n clearInfobox();\n infoboxWrapper.current!.appendChild(\n <Infobox {...infobox} onClose={clearInfobox} openInTab={options.openInTab} />,\n );\n }\n\n function clearInfobox() {\n infoboxWrapper.current!.innerHTML = '';\n }\n\n function toggleMap() {\n element.current!.classList.toggle(CONTAINER_VISIBLE);\n map.resize();\n }\n\n function hasHoverTheme() {\n return theme.polygon && theme.polygon.settings[0].hover;\n }\n\n function createMapboxInstance() {\n mapboxgl.accessToken = window.__ENVIRONMENT_DETAILS__.mapbox.accessToken;\n\n const mapboxOptions: mapboxgl.MapboxOptions = {\n container: container.current!,\n style: `mapbox://styles/${window.__ENVIRONMENT_DETAILS__.mapbox.style}`,\n minZoom: 4,\n maxZoom: 30,\n dragPan: true,\n scrollZoom: false,\n };\n\n if (options.center) mapboxOptions.center = options.center;\n if (options.zoom) mapboxOptions.zoom = options.zoom;\n if (options.boundingBox) mapboxOptions.bounds = options.boundingBox;\n\n if (!options.zoom && !options.center && !options.boundingBox) {\n mapboxOptions.bounds = getCountryBoundingBox(['nl']);\n }\n\n return new mapboxgl.Map(mapboxOptions);\n }\n\n function getMapboxLanguageString(): string {\n let language: string | undefined;\n\n // If language could be nl-NL etc., make sure to strip first two characters\n if (options.language) {\n language = options.language.substr(0, 2);\n }\n\n // nl is not supported, use multilanguage instead\n language = !language || language === 'nl' ? 'mul' : language;\n\n return language;\n }\n\n async function setupMapbox() {\n const { raster, geojson, layer, interaction, setupPointers } = mapboxHelpers;\n\n await functionIsTrue(() => map.isStyleLoaded());\n\n // Setup Mapbox Language\n const languageControl = new MapboxLanguage({\n defaultLanguage: getMapboxLanguageString(),\n });\n map.addControl(languageControl);\n\n // Setup Layer Raster\n // Layer raster can be set via the store and options attribute\n const optionsLayerRaster = options.layerRaster\n ? { layerRaster: options.layerRaster }\n : undefined;\n const storeLayerRaster = mapStore.getState().layerRasterSettings;\n\n if (optionsLayerRaster) {\n raster(optionsLayerRaster);\n } else if (storeLayerRaster) {\n raster(storeLayerRaster);\n }\n\n // Setup in case of polygons\n if (theme.polygon) {\n theme.polygon.settings.forEach((setting) => {\n geojson(setting);\n layer(setting);\n interaction(setting);\n });\n }\n\n // Setup in case of pointers\n if (theme.pointer) {\n setupPointers(element.current!);\n }\n\n map.resize();\n }\n\n function getPointerElementById(id: string) {\n return element.current!.querySelector(`#pointer-${id}`);\n }\n\n function pointerExists(id: string) {\n return !!getPointerElementById(id);\n }\n\n return (\n <Fragment>\n <div class=\"c-map\" js-hook-map>\n <div className=\"map__container\" js-hook-map-container>\n {options.zoomButtons && (\n <div class=\"map__navigation\">\n <button class=\"map__button\" onClick={() => map.zoomIn()}>\n <bpd-svg name=\"icons-plus\"></bpd-svg>\n </button>\n <button class=\"map__button\" onClick={() => map.zoomOut()}>\n <span class=\"map__minus\"></span>\n </button>\n </div>\n )}\n\n {options.mobileToggle && (\n <button type=\"button\" class=\"map__close\" onClick={toggleMap}>\n <bpd-svg name=\"icons-close\" />\n </button>\n )}\n\n <div class=\"map__infobox-wrapper\" js-hook-infobox-wrapper></div>\n </div>\n </div>\n\n {options.mobileToggle && (\n <Fragment>\n <Button\n variant=\"bg\"\n label={options.mobileToggleLabel || 'Toon kaart'}\n classes=\"map__open\"\n onClick={toggleMap}></Button>\n </Fragment>\n )}\n </Fragment>\n );\n};\n\nMap.props = {\n options: {\n type: Object,\n },\n theme: {\n type: Object,\n required: true,\n },\n zoomButtons: {\n type: Boolean,\n },\n};\n\ndefineElement('bpd-map', Map);\n"]}
1
+ {"version":3,"file":"map.js","sourceRoot":"","sources":["../../../src/molecules/map/map.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEH,aAAa,EAEb,SAAS,EACT,aAAa,EACb,UAAU,EACV,OAAO,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EACH,2BA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ineElement,\n FC,\n onDidLoad,\n useBindMethod,\n useElement,\n useProp,\n} from '@atomify/hooks';\nimport { Fragment, h } from '@atomify/jsx';\nimport { MapInfobox, MapOptions, MapSearchOptions, MapTheme } from '@bpd-library/types';\nimport {\n calculateMapDataBoundingBox,\n calculateMapDataCenter,\n expandBoundingBox,\n functionIsTrue,\n getCountryBoundingBox,\n} from '@bpd-library/utilities';\nimport MapboxLanguage from '@mapbox/mapbox-gl-language';\nimport mapboxgl from 'mapbox-gl';\n\nimport { Button } from '../../atoms/button';\nimport { Infobox } from '../infobox';\nimport { clearHover, MapState, mapStore, setMapInstance } from './store';\nimport mapbox from './utilities/mapbox';\n\nconst DEFAULT_OPTIONS: MapOptions = {\n zoomButtons: true,\n mobileToggle: false,\n openInTab: false,\n autoOpenUrl: true,\n language: window.__ENVIRONMENT_DETAILS__.language || 'nl',\n searchCountryIsoCodes: ['nl', 'de'],\n};\n\nconst CONTAINER_VISIBLE = 'map--is-visible';\nconst MOBILE_TOGGLE_CLASS = 'map--mobile-toggle';\nconst MAP_HOVERING_CLASS = 'map--hovering';\nconst POINTER_FOCUS_CLASS = 'map__pointer--focus';\n\nexport interface MapProps extends Component {\n pointerExists: (id: string) => boolean;\n}\n\nconst Map: FC<MapProps> = ({ element }) => {\n let [options] = useProp<MapOptions>('options', {});\n const [theme] = useProp<MapTheme>('theme');\n const container = useElement<HTMLDivElement>('[js-hook-map-container]');\n const infoboxWrapper = useElement<HTMLDivElement>('[js-hook-infobox-wrapper]');\n\n let map: mapboxgl.Map;\n let mapboxHelpers: ReturnType<typeof mapbox>;\n\n useBindMethod('pointerExists', pointerExists);\n\n onDidLoad(async () => {\n if (options.mobileToggle) element.classList.add(MOBILE_TOGGLE_CLASS);\n options = { ...DEFAULT_OPTIONS, ...options };\n\n map = createMapboxInstance();\n mapboxHelpers = mapbox(map, options, theme);\n setMapInstance(map);\n\n await setupMapbox();\n\n subscribe();\n\n if (options.search)\n options.search.forEach((e: MapSearchOptions) => mapboxHelpers.search(e));\n });\n\n function subscribe() {\n const { filter, data } = mapStore.getState();\n const { addData } = mapboxHelpers;\n\n addData(filter ? filter : data);\n\n mapStore.subscribe(({ data }) => addData(data), ['data']);\n mapStore.subscribe(handleHover, ['hover']);\n mapStore.subscribe(handleClick, ['click']);\n mapStore.subscribe(handleFocus, ['focus']);\n mapStore.subscribe(handleIsochrone, ['isochroneSetting']);\n mapStore.subscribe(handleDirections, ['directionsSetting']);\n mapStore.subscribe(({ filter, data }) => addData(filter ? filter : data), ['filter']);\n mapStore.subscribe(\n ({ layerRasterSettings }) =>\n layerRasterSettings && mapboxHelpers.raster(layerRasterSettings),\n ['layerRasterSettings'],\n );\n }\n\n function handleHover({ hover }: MapState) {\n const { current, previous } = hover;\n const canvasStyle = map.getCanvas().style;\n const { setFeatureState } = mapboxHelpers;\n\n /*\n Set hover state\n */\n if (hasHoverTheme()) {\n if (current) setFeatureState(current.variant, current.id, 'hover', true);\n if (previous) setFeatureState(previous.variant, previous.id, 'hover', false);\n }\n\n canvasStyle.cursor = current ? 'pointer' : '';\n }\n\n function handleClick({ click }: MapState) {\n if (!click) return;\n\n const { infobox } = click;\n\n clearHover();\n\n if (infobox) {\n showInfobox(infobox);\n } else {\n clearInfobox();\n }\n }\n\n function handleFocus({ focus }: MapState) {\n const { current, previous, options } = focus;\n const { setFeatureState, center } = mapboxHelpers;\n\n if (previous) {\n previous.forEach(({ id, variant }) => {\n if (hasHoverTheme()) setFeatureState(variant, id, 'focus', false);\n pointerFocusToggle(id, 'remove');\n });\n }\n\n if (current) {\n current.forEach((item) => {\n const { variant, id } = item;\n\n if (theme.polygon) {\n if (hasHoverTheme()) setFeatureState(variant, id, 'focus', true);\n }\n });\n\n if (options?.zoom) {\n let bounds = calculateMapDataBoundingBox(current);\n bounds = expandBoundingBox(bounds, 0.05);\n\n map.fitBounds(bounds);\n } else if (!options?.static) {\n center([[calculateMapDataCenter(current)]]);\n }\n }\n }\n\n function handleIsochrone({ isochroneSetting }: MapState) {\n const { removeIsochrone, addIsochrone } = mapboxHelpers;\n\n if (isochroneSetting) {\n addIsochrone(isochroneSetting);\n } else {\n removeIsochrone();\n }\n }\n\n function handleDirections({ directionsSetting }: MapState) {\n const { addDirections, removeDirections } = mapboxHelpers;\n\n if (directionsSetting) {\n addDirections(directionsSetting);\n } else {\n removeDirections();\n }\n }\n\n function pointerFocusToggle(id: string, action: 'add' | 'remove') {\n const pointer = getPointerElementById(id);\n\n if (pointer) {\n pointer.classList[action](POINTER_FOCUS_CLASS);\n element.classList[action](MAP_HOVERING_CLASS);\n }\n }\n\n function showInfobox(infobox: MapInfobox) {\n clearInfobox();\n infoboxWrapper.current!.appendChild(\n <Infobox {...infobox} onClose={clearInfobox} openInTab={options.openInTab} />,\n );\n }\n\n function clearInfobox() {\n infoboxWrapper.current!.innerHTML = '';\n }\n\n function toggleMap() {\n element.classList.toggle(CONTAINER_VISIBLE);\n map.resize();\n }\n\n function hasHoverTheme() {\n return theme.polygon && theme.polygon.settings[0].hover;\n }\n\n function createMapboxInstance() {\n mapboxgl.accessToken = window.__ENVIRONMENT_DETAILS__.mapbox.accessToken;\n\n const mapboxOptions: mapboxgl.MapboxOptions = {\n container: container.current!,\n style: `mapbox://styles/${window.__ENVIRONMENT_DETAILS__.mapbox.style}`,\n minZoom: 4,\n maxZoom: 30,\n dragPan: true,\n scrollZoom: false,\n };\n\n if (options.center) mapboxOptions.center = options.center;\n if (options.zoom) mapboxOptions.zoom = options.zoom;\n if (options.boundingBox) mapboxOptions.bounds = options.boundingBox;\n\n if (!options.zoom && !options.center && !options.boundingBox) {\n mapboxOptions.bounds = getCountryBoundingBox(['nl']);\n }\n\n return new mapboxgl.Map(mapboxOptions);\n }\n\n function getMapboxLanguageString(): string {\n let language: string | undefined;\n\n // If language could be nl-NL etc., make sure to strip first two characters\n if (options.language) {\n language = options.language.substr(0, 2);\n }\n\n // nl is not supported, use multilanguage instead\n language = !language || language === 'nl' ? 'mul' : language;\n\n return language;\n }\n\n async function setupMapbox() {\n const { raster, geojson, layer, interaction, setupPointers } = mapboxHelpers;\n\n await functionIsTrue(() => map.isStyleLoaded());\n\n // Setup Mapbox Language\n const languageControl = new MapboxLanguage({\n defaultLanguage: getMapboxLanguageString(),\n });\n map.addControl(languageControl);\n\n // Setup Layer Raster\n // Layer raster can be set via the store and options attribute\n const optionsLayerRaster = options.layerRaster\n ? { layerRaster: options.layerRaster }\n : undefined;\n const storeLayerRaster = mapStore.getState().layerRasterSettings;\n\n if (optionsLayerRaster) {\n raster(optionsLayerRaster);\n } else if (storeLayerRaster) {\n raster(storeLayerRaster);\n }\n\n // Setup in case of polygons\n if (theme.polygon) {\n theme.polygon.settings.forEach((setting) => {\n geojson(setting);\n layer(setting);\n interaction(setting);\n });\n }\n\n // Setup in case of pointers\n if (theme.pointer) {\n setupPointers(element);\n }\n\n map.resize();\n }\n\n function getPointerElementById(id: string) {\n return element.querySelector(`#pointer-${id}`);\n }\n\n function pointerExists(id: string) {\n return !!getPointerElementById(id);\n }\n\n return (\n <Fragment>\n <div class=\"c-map\">\n <div className=\"map__container\" js-hook-map-container>\n {options.zoomButtons && (\n <div class=\"map__navigation\">\n <button class=\"map__button\" onClick={() => map.zoomIn()}>\n <bpd-svg name=\"icons-plus\"></bpd-svg>\n </button>\n <button class=\"map__button\" onClick={() => map.zoomOut()}>\n <span class=\"map__minus\"></span>\n </button>\n </div>\n )}\n\n {options.mobileToggle && (\n <button type=\"button\" class=\"map__close\" onClick={toggleMap}>\n <bpd-svg name=\"icons-close\" />\n </button>\n )}\n\n <div class=\"map__infobox-wrapper\" js-hook-infobox-wrapper></div>\n </div>\n </div>\n\n {options.mobileToggle && (\n <Fragment>\n <Button\n variant=\"bg\"\n label={options.mobileToggleLabel || 'Toon kaart'}\n classes=\"map__open\"\n onClick={toggleMap}></Button>\n </Fragment>\n )}\n </Fragment>\n );\n};\n\nMap.props = {\n options: {\n type: Object,\n },\n theme: {\n type: Object,\n required: true,\n },\n zoomButtons: {\n type: Boolean,\n },\n};\n\ndefineElement('bpd-map', Map);\n"]}
@@ -0,0 +1 @@
1
+ export * from './store';
@@ -0,0 +1,2 @@
1
+ export * from './store';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/molecules/map/store/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC","sourcesContent":["export * from './store';\n"]}
@@ -0,0 +1 @@
1
+ export * from './use-map-instance';
@@ -0,0 +1,2 @@
1
+ export * from './use-map-instance';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/molecules/map/store/map/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC","sourcesContent":["export * from './use-map-instance';\n"]}
@@ -0,0 +1,2 @@
1
+ declare const useMapInstance: (callback: (mapInstance: mapboxgl.Map) => void) => void;
2
+ export { useMapInstance };
@@ -0,0 +1,15 @@
1
+ import { getMapInstance, mapStore } from '../store';
2
+ const useMapInstance = (callback) => {
3
+ const mapInstance = getMapInstance();
4
+ if (mapInstance) {
5
+ callback(mapInstance);
6
+ }
7
+ else {
8
+ mapStore.subscribe(({ mapInstance }) => {
9
+ if (mapInstance)
10
+ callback(mapInstance);
11
+ }, ['mapInstance']);
12
+ }
13
+ };
14
+ export { useMapInstance };
15
+ //# sourceMappingURL=use-map-instance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-map-instance.js","sourceRoot":"","sources":["../../../../../../src/molecules/map/store/map/hooks/use-map-instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAYpD,MAAM,cAAc,GAAG,CAAC,QAA6C,EAAE,EAAE;IACrE,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IAErC,IAAI,WAAW,EAAE;QACb,QAAQ,CAAC,WAAW,CAAC,CAAC;KACzB;SAAM;QACH,QAAQ,CAAC,SAAS,CACd,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE;YAChB,IAAI,WAAW;gBAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC3C,CAAC,EACD,CAAC,aAAa,CAAC,CAClB,CAAC;KACL;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { getMapInstance, mapStore } from '../store';\n\n/**\n * @description Callback will be called as soon as mapbox is initialized and the mapInstance is added to the store.\n * @example\n * ```\n * useMapInstance(mapInstance => {\n * mapInstance.setCenter([51, 9]);\n * });\n * ```\n * @param {(mapInstance: mapboxgl.Map) => void} callback\n */\nconst useMapInstance = (callback: (mapInstance: mapboxgl.Map) => void) => {\n const mapInstance = getMapInstance();\n\n if (mapInstance) {\n callback(mapInstance);\n } else {\n mapStore.subscribe(\n ({ mapInstance }) => {\n if (mapInstance) callback(mapInstance);\n },\n ['mapInstance'],\n );\n }\n};\n\nexport { useMapInstance };\n"]}
@@ -1 +1,2 @@
1
1
  export * from './store';
2
+ export * from './hooks';
@@ -1,2 +1,3 @@
1
1
  export * from './store';
2
+ export * from './hooks';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/molecules/map/store/map/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC","sourcesContent":["export * from './store';\nexport * from './hooks';\n"]}
@@ -0,0 +1,65 @@
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
+ static?: boolean;
12
+ }
13
+ export interface MapLayerRasterSettings {
14
+ layerRaster: string;
15
+ minzoom?: number;
16
+ maxzoom?: number;
17
+ }
18
+ export interface MapState {
19
+ data: MapDataItem[];
20
+ mapInstance?: mapboxgl.Map;
21
+ hover: {
22
+ current?: MapDataItem;
23
+ previous?: MapDataItem;
24
+ };
25
+ filter?: MapDataItem[];
26
+ click?: MapDataItem;
27
+ focus: {
28
+ current?: MapDataItem[];
29
+ previous?: MapDataItem[];
30
+ options?: MapFocusOptions;
31
+ };
32
+ searchResult?: SearchResult;
33
+ searchIsMoving: boolean;
34
+ manualSearch?: string;
35
+ layerRasterSettings?: MapLayerRasterSettings;
36
+ isochroneSetting?: MapIsochroneSetting;
37
+ directionsSetting?: MapDirectionsSetting;
38
+ }
39
+ export declare const mapStore: import("@atomify/kit/dist/utilities/store/store.types").Store<MapState>;
40
+ export declare const updateMapData: (data: MapDataItem[]) => void;
41
+ export declare const clearHover: () => void;
42
+ export declare const updateHover: (hover: MapDataItem) => void;
43
+ export declare const updateClick: (click: MapDataItem) => void;
44
+ export declare const setFocus: (ids: string[], options?: MapFocusOptions) => void;
45
+ export declare const clearFocus: () => void;
46
+ export declare const updateSearchResult: (searchResult: SearchResult) => void;
47
+ export declare const clearSearchResult: () => void;
48
+ export declare const setFilter: (data: MapDataItem[]) => void;
49
+ export declare const clearFilter: () => void;
50
+ export declare const setMapInstance: (mapInstance: mapboxgl.Map) => void;
51
+ export declare const manualSearch: (query: string) => void;
52
+ export declare const updateSearchIsMoving: (isMoving: boolean) => void;
53
+ export declare const setLayerRaster: (layerRasterSettings: MapLayerRasterSettings) => void;
54
+ export declare const setIsochrone: (isochroneSetting: MapIsochroneSetting) => void;
55
+ export declare const clearIsochrone: () => void;
56
+ export declare const setDirections: (directionsSetting: MapDirectionsSetting) => void;
57
+ export declare const clearDirections: () => void;
58
+ export declare const getMapboxData: () => MapDataItem[];
59
+ export declare const getHover: () => {
60
+ current?: MapDataItem | undefined;
61
+ previous?: MapDataItem | undefined;
62
+ };
63
+ export declare const getMapInstance: () => import("mapbox-gl").Map | undefined;
64
+ export declare const getSearchIsMoving: () => boolean;
65
+ export {};