react-bkoi-gl 1.0.1 → 1.0.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 (45) hide show
  1. package/dist/components/attribution-control.d.ts +1 -1
  2. package/dist/components/fullscreen-control.d.ts +1 -1
  3. package/dist/components/geolocate-control.d.ts +1 -1
  4. package/dist/components/geolocate-control.js +5 -5
  5. package/dist/components/geolocate-control.js.map +1 -1
  6. package/dist/components/layer.d.ts +3 -3
  7. package/dist/components/layer.js +5 -3
  8. package/dist/components/layer.js.map +1 -1
  9. package/dist/components/map.d.ts +4 -4
  10. package/dist/components/map.js +8 -6
  11. package/dist/components/map.js.map +1 -1
  12. package/dist/components/marker.d.ts +1 -1
  13. package/dist/components/marker.js +9 -7
  14. package/dist/components/marker.js.map +1 -1
  15. package/dist/components/navigation-control.d.ts +1 -1
  16. package/dist/components/popup.d.ts +1 -1
  17. package/dist/components/popup.js +6 -5
  18. package/dist/components/popup.js.map +1 -1
  19. package/dist/components/scale-control.d.ts +1 -1
  20. package/dist/components/source.d.ts +1 -1
  21. package/dist/components/source.js +4 -3
  22. package/dist/components/source.js.map +1 -1
  23. package/dist/components/use-control.d.ts +1 -1
  24. package/dist/components/use-map.d.ts +2 -2
  25. package/dist/components/use-map.js +8 -9
  26. package/dist/components/use-map.js.map +1 -1
  27. package/dist/exports-bkoi-gl.d.ts +22 -22
  28. package/dist/exports-mapbox.d.ts +23 -23
  29. package/dist/mapbox/create-ref.d.ts +1 -1
  30. package/dist/mapbox/mapbox.d.ts +1 -1
  31. package/dist/mapbox/mapbox.js +70 -67
  32. package/dist/mapbox/mapbox.js.map +1 -1
  33. package/dist/styles/react-bkoi-gl.css +1 -1
  34. package/dist/types/common.d.ts +7 -7
  35. package/dist/types/events-bkoi-gl.d.ts +3 -3
  36. package/dist/types/events-mapbox.d.ts +3 -3
  37. package/dist/types/events.d.ts +9 -9
  38. package/dist/types/index.d.ts +1 -1
  39. package/dist/types/lib.d.ts +3 -3
  40. package/dist/types/style-spec-bkoi-gl.d.ts +4 -4
  41. package/dist/types/style-spec-mapbox.d.ts +2 -2
  42. package/dist/utils/set-globals.d.ts +1 -1
  43. package/dist/utils/style-utils.js +5 -3
  44. package/dist/utils/style-utils.js.map +1 -1
  45. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  import type { IControl, ControlPosition } from '../types';
2
2
  import type { MapContextValue } from './map';
3
- declare type ControlOptions = {
3
+ type ControlOptions = {
4
4
  position?: ControlPosition;
5
5
  };
6
6
  declare function useControl<T extends IControl>(onCreate: (context: MapContextValue) => T, opts?: ControlOptions): T;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { MapRef } from '../mapbox/create-ref';
3
3
  import { MapInstance } from '../types';
4
- declare type MountedMapsContextValue = {
4
+ type MountedMapsContextValue = {
5
5
  maps: {
6
6
  [id: string]: MapRef<MapInstance>;
7
7
  };
@@ -12,7 +12,7 @@ export declare const MountedMapsContext: React.Context<MountedMapsContextValue>;
12
12
  export declare const MapProvider: React.FC<{
13
13
  children?: React.ReactNode;
14
14
  }>;
15
- export declare type MapCollection<MapT extends MapInstance> = {
15
+ export type MapCollection<MapT extends MapInstance> = {
16
16
  [id: string]: MapRef<MapT> | undefined;
17
17
  current?: MapRef<MapT>;
18
18
  };
@@ -1,3 +1,6 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1
4
  import * as React from 'react';
2
5
  import { useState, useCallback, useMemo, useContext } from 'react';
3
6
  import { MapContext } from "./map.js";
@@ -13,19 +16,16 @@ export const MapProvider = props => {
13
16
  if (currMaps[id]) {
14
17
  throw new Error(`Multiple maps with the same id: ${id}`);
15
18
  }
16
- return {
17
- ...currMaps,
19
+ return _objectSpread(_objectSpread({}, currMaps), {}, {
18
20
  [id]: map
19
- };
21
+ });
20
22
  });
21
23
  }, []);
22
24
  const onMapUnmount = useCallback(function () {
23
25
  let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
24
26
  setMaps(currMaps => {
25
27
  if (currMaps[id]) {
26
- const nextMaps = {
27
- ...currMaps
28
- };
28
+ const nextMaps = _objectSpread({}, currMaps);
29
29
  delete nextMaps[id];
30
30
  return nextMaps;
31
31
  }
@@ -45,10 +45,9 @@ export function useMap() {
45
45
  const maps = (_useContext = useContext(MountedMapsContext)) === null || _useContext === void 0 ? void 0 : _useContext.maps;
46
46
  const currentMap = useContext(MapContext);
47
47
  const mapsWithCurrent = useMemo(() => {
48
- return {
49
- ...maps,
48
+ return _objectSpread(_objectSpread({}, maps), {}, {
50
49
  current: currentMap === null || currentMap === void 0 ? void 0 : currentMap.map
51
- };
50
+ });
52
51
  }, [maps, currentMap]);
53
52
  return mapsWithCurrent;
54
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"use-map.js","names":["React","useState","useCallback","useMemo","useContext","MapContext","MountedMapsContext","createContext","MapProvider","props","maps","setMaps","onMapMount","map","id","arguments","length","undefined","currMaps","Error","onMapUnmount","nextMaps","createElement","Provider","value","children","useMap","_useContext","currentMap","mapsWithCurrent","current"],"sources":["../../src/components/use-map.tsx"],"sourcesContent":["import * as React from 'react';\nimport {useState, useCallback, useMemo, useContext} from 'react';\n\nimport {MapRef} from '../mapbox/create-ref';\nimport {MapContext} from './map';\nimport {MapInstance} from '../types';\n\ntype MountedMapsContextValue = {\n maps: {[id: string]: MapRef<MapInstance>};\n onMapMount: (map: MapRef<MapInstance>, id: string) => void;\n onMapUnmount: (id: string) => void;\n};\n\nexport const MountedMapsContext = React.createContext<MountedMapsContextValue>(null);\n\nexport const MapProvider: React.FC<{children?: React.ReactNode}> = props => {\n const [maps, setMaps] = useState<{[id: string]: MapRef<MapInstance>}>({});\n\n const onMapMount = useCallback((map: MapRef<MapInstance>, id: string = 'default') => {\n setMaps(currMaps => {\n if (id === 'current') {\n throw new Error(\"'current' cannot be used as map id\");\n }\n if (currMaps[id]) {\n throw new Error(`Multiple maps with the same id: ${id}`);\n }\n return {...currMaps, [id]: map};\n });\n }, []);\n\n const onMapUnmount = useCallback((id: string = 'default') => {\n setMaps(currMaps => {\n if (currMaps[id]) {\n const nextMaps = {...currMaps};\n delete nextMaps[id];\n return nextMaps;\n }\n return currMaps;\n });\n }, []);\n\n return (\n <MountedMapsContext.Provider\n value={{\n maps,\n onMapMount,\n onMapUnmount\n }}\n >\n {props.children}\n </MountedMapsContext.Provider>\n );\n};\n\nexport type MapCollection<MapT extends MapInstance> = {\n [id: string]: MapRef<MapT> | undefined;\n current?: MapRef<MapT>;\n};\n\nexport function useMap<MapT extends MapInstance>(): MapCollection<MapT> {\n const maps = useContext(MountedMapsContext)?.maps;\n const currentMap = useContext(MapContext);\n\n const mapsWithCurrent = useMemo(() => {\n return {...maps, current: currentMap?.map};\n }, [maps, currentMap]);\n\n return mapsWithCurrent as MapCollection<MapT>;\n}\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAAQC,QAAQ,EAAEC,WAAW,EAAEC,OAAO,EAAEC,UAAU,QAAO,OAAO;AAAC,SAGzDC,UAAU;AASlB,OAAO,MAAMC,kBAAkB,GAAGN,KAAK,CAACO,aAAa,CAA0B,IAAI,CAAC;AAEpF,OAAO,MAAMC,WAAmD,GAAGC,KAAK,IAAI;EAC1E,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGV,QAAQ,CAAsC,CAAC,CAAC,CAAC;EAEzE,MAAMW,UAAU,GAAGV,WAAW,CAAC,UAACW,GAAwB,EAA6B;IAAA,IAA3BC,EAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,SAAS;IAC9EJ,OAAO,CAACO,QAAQ,IAAI;MAClB,IAAIJ,EAAE,KAAK,SAAS,EAAE;QACpB,MAAM,IAAIK,KAAK,CAAC,oCAAoC,CAAC;MACvD;MACA,IAAID,QAAQ,CAACJ,EAAE,CAAC,EAAE;QAChB,MAAM,IAAIK,KAAK,CAAC,mCAAmCL,EAAE,EAAE,CAAC;MAC1D;MACA,OAAO;QAAC,GAAGI,QAAQ;QAAE,CAACJ,EAAE,GAAGD;MAAG,CAAC;IACjC,CAAC,CAAC;EACJ,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMO,YAAY,GAAGlB,WAAW,CAAC,YAA4B;IAAA,IAA3BY,EAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,SAAS;IACtDJ,OAAO,CAACO,QAAQ,IAAI;MAClB,IAAIA,QAAQ,CAACJ,EAAE,CAAC,EAAE;QAChB,MAAMO,QAAQ,GAAG;UAAC,GAAGH;QAAQ,CAAC;QAC9B,OAAOG,QAAQ,CAACP,EAAE,CAAC;QACnB,OAAOO,QAAQ;MACjB;MACA,OAAOH,QAAQ;IACjB,CAAC,CAAC;EACJ,CAAC,EAAE,EAAE,CAAC;EAEN,OACElB,KAAA,CAAAsB,aAAA,CAAChB,kBAAkB,CAACiB,QAAQ;IAC1BC,KAAK,EAAE;MACLd,IAAI;MACJE,UAAU;MACVQ;IACF;EAAE,GAEDX,KAAK,CAACgB,QACoB,CAAC;AAElC,CAAC;AAOD,OAAO,SAASC,MAAMA,CAAA,EAAkD;EAAA,IAAAC,WAAA;EACtE,MAAMjB,IAAI,IAAAiB,WAAA,GAAGvB,UAAU,CAACE,kBAAkB,CAAC,cAAAqB,WAAA,uBAA9BA,WAAA,CAAgCjB,IAAI;EACjD,MAAMkB,UAAU,GAAGxB,UAAU,CAACC,UAAU,CAAC;EAEzC,MAAMwB,eAAe,GAAG1B,OAAO,CAAC,MAAM;IACpC,OAAO;MAAC,GAAGO,IAAI;MAAEoB,OAAO,EAAEF,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEf;IAAG,CAAC;EAC5C,CAAC,EAAE,CAACH,IAAI,EAAEkB,UAAU,CAAC,CAAC;EAEtB,OAAOC,eAAe;AACxB","ignoreList":[]}
1
+ {"version":3,"file":"use-map.js","names":["React","useState","useCallback","useMemo","useContext","MapContext","MountedMapsContext","createContext","MapProvider","props","maps","setMaps","onMapMount","map","id","arguments","length","undefined","currMaps","Error","_objectSpread","onMapUnmount","nextMaps","createElement","Provider","value","children","useMap","_useContext","currentMap","mapsWithCurrent","current"],"sources":["../../src/components/use-map.tsx"],"sourcesContent":["import * as React from 'react';\nimport {useState, useCallback, useMemo, useContext} from 'react';\n\nimport {MapRef} from '../mapbox/create-ref';\nimport {MapContext} from './map';\nimport {MapInstance} from '../types';\n\ntype MountedMapsContextValue = {\n maps: {[id: string]: MapRef<MapInstance>};\n onMapMount: (map: MapRef<MapInstance>, id: string) => void;\n onMapUnmount: (id: string) => void;\n};\n\nexport const MountedMapsContext = React.createContext<MountedMapsContextValue>(null);\n\nexport const MapProvider: React.FC<{children?: React.ReactNode}> = props => {\n const [maps, setMaps] = useState<{[id: string]: MapRef<MapInstance>}>({});\n\n const onMapMount = useCallback((map: MapRef<MapInstance>, id: string = 'default') => {\n setMaps(currMaps => {\n if (id === 'current') {\n throw new Error(\"'current' cannot be used as map id\");\n }\n if (currMaps[id]) {\n throw new Error(`Multiple maps with the same id: ${id}`);\n }\n return {...currMaps, [id]: map};\n });\n }, []);\n\n const onMapUnmount = useCallback((id: string = 'default') => {\n setMaps(currMaps => {\n if (currMaps[id]) {\n const nextMaps = {...currMaps};\n delete nextMaps[id];\n return nextMaps;\n }\n return currMaps;\n });\n }, []);\n\n return (\n <MountedMapsContext.Provider\n value={{\n maps,\n onMapMount,\n onMapUnmount\n }}\n >\n {props.children}\n </MountedMapsContext.Provider>\n );\n};\n\nexport type MapCollection<MapT extends MapInstance> = {\n [id: string]: MapRef<MapT> | undefined;\n current?: MapRef<MapT>;\n};\n\nexport function useMap<MapT extends MapInstance>(): MapCollection<MapT> {\n const maps = useContext(MountedMapsContext)?.maps;\n const currentMap = useContext(MapContext);\n\n const mapsWithCurrent = useMemo(() => {\n return {...maps, current: currentMap?.map};\n }, [maps, currentMap]);\n\n return mapsWithCurrent as MapCollection<MapT>;\n}\n"],"mappings":";;;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAAQC,QAAQ,EAAEC,WAAW,EAAEC,OAAO,EAAEC,UAAU,QAAO,OAAO;AAAC,SAGzDC,UAAU;AASlB,OAAO,MAAMC,kBAAkB,GAAGN,KAAK,CAACO,aAAa,CAA0B,IAAI,CAAC;AAEpF,OAAO,MAAMC,WAAmD,GAAGC,KAAK,IAAI;EAC1E,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGV,QAAQ,CAAsC,CAAC,CAAC,CAAC;EAEzE,MAAMW,UAAU,GAAGV,WAAW,CAAC,UAACW,GAAwB,EAA6B;IAAA,IAA3BC,EAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,SAAS;IAC9EJ,OAAO,CAACO,QAAQ,IAAI;MAClB,IAAIJ,EAAE,KAAK,SAAS,EAAE;QACpB,MAAM,IAAIK,KAAK,CAAC,oCAAoC,CAAC;MACvD;MACA,IAAID,QAAQ,CAACJ,EAAE,CAAC,EAAE;QAChB,MAAM,IAAIK,KAAK,CAAC,mCAAmCL,EAAE,EAAE,CAAC;MAC1D;MACA,OAAAM,aAAA,CAAAA,aAAA,KAAWF,QAAQ;QAAE,CAACJ,EAAE,GAAGD;MAAG;IAChC,CAAC,CAAC;EACJ,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMQ,YAAY,GAAGnB,WAAW,CAAC,YAA4B;IAAA,IAA3BY,EAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,SAAS;IACtDJ,OAAO,CAACO,QAAQ,IAAI;MAClB,IAAIA,QAAQ,CAACJ,EAAE,CAAC,EAAE;QAChB,MAAMQ,QAAQ,GAAAF,aAAA,KAAOF,QAAQ,CAAC;QAC9B,OAAOI,QAAQ,CAACR,EAAE,CAAC;QACnB,OAAOQ,QAAQ;MACjB;MACA,OAAOJ,QAAQ;IACjB,CAAC,CAAC;EACJ,CAAC,EAAE,EAAE,CAAC;EAEN,OACElB,KAAA,CAAAuB,aAAA,CAACjB,kBAAkB,CAACkB,QAAQ;IAC1BC,KAAK,EAAE;MACLf,IAAI;MACJE,UAAU;MACVS;IACF;EAAE,GAEDZ,KAAK,CAACiB,QACoB,CAAC;AAElC,CAAC;AAOD,OAAO,SAASC,MAAMA,CAAA,EAAkD;EAAA,IAAAC,WAAA;EACtE,MAAMlB,IAAI,IAAAkB,WAAA,GAAGxB,UAAU,CAACE,kBAAkB,CAAC,cAAAsB,WAAA,uBAA9BA,WAAA,CAAgClB,IAAI;EACjD,MAAMmB,UAAU,GAAGzB,UAAU,CAACC,UAAU,CAAC;EAEzC,MAAMyB,eAAe,GAAG3B,OAAO,CAAC,MAAM;IACpC,OAAAiB,aAAA,CAAAA,aAAA,KAAWV,IAAI;MAAEqB,OAAO,EAAEF,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEhB;IAAG;EAC3C,CAAC,EAAE,CAACH,IAAI,EAAEmB,UAAU,CAAC,CAAC;EAEtB,OAAOC,eAAe;AACxB","ignoreList":[]}
@@ -15,8 +15,8 @@ import type { MapRef as _MapRef } from './mapbox/create-ref';
15
15
  import type * as events from './types/events';
16
16
  import type { MapCallbacks } from './types/events-bkoi-gl';
17
17
  export declare function useMap(): import("./components/use-map").MapCollection<BkoiMap>;
18
- export declare type MapProps = _MapProps<MapOptions, MapStyle, MapCallbacks, BkoiMap>;
19
- export declare type MapRef = _MapRef<BkoiMap>;
18
+ export type MapProps = _MapProps<MapOptions, MapStyle, MapCallbacks, BkoiMap>;
19
+ export type MapRef = _MapRef<BkoiMap>;
20
20
  export declare const Map: React.ForwardRefExoticComponent<Pick<{
21
21
  [x: string]: MapOptions;
22
22
  [x: number]: MapOptions;
@@ -51,28 +51,28 @@ export declare const Map: React.ForwardRefExoticComponent<Pick<{
51
51
  style?: React.CSSProperties;
52
52
  children?: any;
53
53
  }, string | number | symbol> & React.RefAttributes<MapRef>>;
54
- export declare type MarkerProps = _MarkerProps<MarkerOptions, BkoiMarker>;
54
+ export type MarkerProps = _MarkerProps<MarkerOptions, BkoiMarker>;
55
55
  export declare const Marker: (props: MarkerProps & React.RefAttributes<BkoiMarker>) => React.ReactElement | null;
56
- export declare type PopupProps = _PopupProps<PopupOptions, BkoiPopup>;
56
+ export type PopupProps = _PopupProps<PopupOptions, BkoiPopup>;
57
57
  export declare const Popup: (props: PopupProps & React.RefAttributes<BkoiPopup>) => React.ReactElement | null;
58
- declare type AttributionControlOptions = ConstructorParameters<typeof BkoiAttributionControl>[0];
59
- export declare type AttributionControlProps = _AttributionControlProps<AttributionControlOptions>;
58
+ type AttributionControlOptions = ConstructorParameters<typeof BkoiAttributionControl>[0];
59
+ export type AttributionControlProps = _AttributionControlProps<AttributionControlOptions>;
60
60
  export declare const AttributionControl: (props: AttributionControlProps) => React.ReactElement | null;
61
- declare type FullscreenControlOptions = ConstructorParameters<typeof BkoiFullscreenControl>[0];
62
- export declare type FullscreenControlProps = _FullscreenControlProps<FullscreenControlOptions>;
61
+ type FullscreenControlOptions = ConstructorParameters<typeof BkoiFullscreenControl>[0];
62
+ export type FullscreenControlProps = _FullscreenControlProps<FullscreenControlOptions>;
63
63
  export declare const FullscreenControl: (props: FullscreenControlProps) => React.ReactElement | null;
64
- declare type NavigationControlOptions = ConstructorParameters<typeof BkoiNavigationControl>[0];
65
- export declare type NavigationControlProps = _NavigationControlProps<NavigationControlOptions>;
64
+ type NavigationControlOptions = ConstructorParameters<typeof BkoiNavigationControl>[0];
65
+ export type NavigationControlProps = _NavigationControlProps<NavigationControlOptions>;
66
66
  export declare const NavigationControl: (props: NavigationControlProps) => React.ReactElement | null;
67
- declare type GeolocateControlOptions = ConstructorParameters<typeof BkoiGeolocateControl>[0];
68
- export declare type GeolocateControlProps = _GeolocateControlProps<GeolocateControlOptions, BkoiGeolocateControl>;
67
+ type GeolocateControlOptions = ConstructorParameters<typeof BkoiGeolocateControl>[0];
68
+ export type GeolocateControlProps = _GeolocateControlProps<GeolocateControlOptions, BkoiGeolocateControl>;
69
69
  export declare const GeolocateControl: (props: GeolocateControlProps & React.RefAttributes<BkoiGeolocateControl>) => React.ReactElement | null;
70
- declare type ScaleControlOptions = ConstructorParameters<typeof BkoiScaleControl>[0];
71
- export declare type ScaleControlProps = _ScaleControlProps<ScaleControlOptions>;
70
+ type ScaleControlOptions = ConstructorParameters<typeof BkoiScaleControl>[0];
71
+ export type ScaleControlProps = _ScaleControlProps<ScaleControlOptions>;
72
72
  export declare const ScaleControl: (props: ScaleControlProps) => React.ReactElement | null;
73
- export declare type LayerProps = _LayerProps<AnyLayer>;
73
+ export type LayerProps = _LayerProps<AnyLayer>;
74
74
  export declare const Layer: (props: LayerProps) => React.ReactElement | null;
75
- export declare type SourceProps = _SourceProps<AnySource>;
75
+ export type SourceProps = _SourceProps<AnySource>;
76
76
  export declare const Source: (props: SourceProps) => React.ReactElement | null;
77
77
  export { default as useControl } from './components/use-control';
78
78
  export { MapProvider } from './components/use-map';
@@ -81,9 +81,9 @@ export * from './types/public';
81
81
  export type { default as Point } from '@mapbox/point-geometry';
82
82
  export * from './types/style-spec-bkoi-gl';
83
83
  export type { MapEvent, MapMouseEvent, MapLayerMouseEvent, MapTouchEvent, MapLayerTouchEvent, MapStyleDataEvent, MapSourceDataEvent, MapWheelEvent, MapBoxZoomEvent, ErrorEvent, ViewStateChangeEvent } from './types/events-bkoi-gl';
84
- export declare type PopupEvent = events.PopupEvent<BkoiPopup>;
85
- export declare type MarkerEvent = events.MarkerEvent<BkoiMarker>;
86
- export declare type MarkerDragEvent = events.MarkerDragEvent<BkoiMarker>;
87
- export declare type GeolocateEvent = events.GeolocateEvent<BkoiGeolocateControl>;
88
- export declare type GeolocateResultEvent = events.GeolocateResultEvent<BkoiGeolocateControl>;
89
- export declare type GeolocateErrorEvent = events.GeolocateErrorEvent<BkoiGeolocateControl>;
84
+ export type PopupEvent = events.PopupEvent<BkoiPopup>;
85
+ export type MarkerEvent = events.MarkerEvent<BkoiMarker>;
86
+ export type MarkerDragEvent = events.MarkerDragEvent<BkoiMarker>;
87
+ export type GeolocateEvent = events.GeolocateEvent<BkoiGeolocateControl>;
88
+ export type GeolocateResultEvent = events.GeolocateResultEvent<BkoiGeolocateControl>;
89
+ export type GeolocateErrorEvent = events.GeolocateErrorEvent<BkoiGeolocateControl>;
@@ -15,8 +15,8 @@ import type { MapRef as _MapRef } from './mapbox/create-ref';
15
15
  import type * as events from './types/events';
16
16
  import type { MapCallbacks } from './types/events-mapbox';
17
17
  export declare function useMap(): import("./components/use-map").MapCollection<MapboxMap>;
18
- export declare type MapProps = _MapProps<MapboxOptions, MapStyle, MapCallbacks, MapboxMap>;
19
- export declare type MapRef = _MapRef<MapboxMap>;
18
+ export type MapProps = _MapProps<MapboxOptions, MapStyle, MapCallbacks, MapboxMap>;
19
+ export type MapRef = _MapRef<MapboxMap>;
20
20
  export declare const Map: React.ForwardRefExoticComponent<{
21
21
  zoom?: number;
22
22
  pitch?: number;
@@ -98,28 +98,28 @@ export declare const Map: React.ForwardRefExoticComponent<{
98
98
  style?: React.CSSProperties;
99
99
  children?: any;
100
100
  } & React.RefAttributes<MapRef>>;
101
- export declare type MarkerProps = _MarkerProps<MarkerOptions, MapboxMarker>;
101
+ export type MarkerProps = _MarkerProps<MarkerOptions, MapboxMarker>;
102
102
  export declare const Marker: (props: MarkerProps & React.RefAttributes<MapboxMarker>) => React.ReactElement | null;
103
- export declare type PopupProps = _PopupProps<PopupOptions, MapboxPopup>;
103
+ export type PopupProps = _PopupProps<PopupOptions, MapboxPopup>;
104
104
  export declare const Popup: (props: PopupProps & React.RefAttributes<MapboxPopup>) => React.ReactElement | null;
105
- declare type AttributionControlOptions = ConstructorParameters<typeof MapboxAttributionControl>[0];
106
- export declare type AttributionControlProps = _AttributionControlProps<AttributionControlOptions>;
105
+ type AttributionControlOptions = ConstructorParameters<typeof MapboxAttributionControl>[0];
106
+ export type AttributionControlProps = _AttributionControlProps<AttributionControlOptions>;
107
107
  export declare const AttributionControl: (props: AttributionControlProps) => React.ReactElement | null;
108
- declare type FullscreenControlOptions = ConstructorParameters<typeof MapboxFullscreenControl>[0];
109
- export declare type FullscreenControlProps = _FullscreenControlProps<FullscreenControlOptions>;
108
+ type FullscreenControlOptions = ConstructorParameters<typeof MapboxFullscreenControl>[0];
109
+ export type FullscreenControlProps = _FullscreenControlProps<FullscreenControlOptions>;
110
110
  export declare const FullscreenControl: (props: FullscreenControlProps) => React.ReactElement | null;
111
- declare type NavigationControlOptions = ConstructorParameters<typeof MapboxNavigationControl>[0];
112
- export declare type NavigationControlProps = _NavigationControlProps<NavigationControlOptions>;
111
+ type NavigationControlOptions = ConstructorParameters<typeof MapboxNavigationControl>[0];
112
+ export type NavigationControlProps = _NavigationControlProps<NavigationControlOptions>;
113
113
  export declare const NavigationControl: (props: NavigationControlProps) => React.ReactElement | null;
114
- declare type GeolocateControlOptions = ConstructorParameters<typeof MapboxGeolocateControl>[0];
115
- export declare type GeolocateControlProps = _GeolocateControlProps<GeolocateControlOptions, MapboxGeolocateControl>;
114
+ type GeolocateControlOptions = ConstructorParameters<typeof MapboxGeolocateControl>[0];
115
+ export type GeolocateControlProps = _GeolocateControlProps<GeolocateControlOptions, MapboxGeolocateControl>;
116
116
  export declare const GeolocateControl: (props: GeolocateControlProps & React.RefAttributes<MapboxGeolocateControl>) => React.ReactElement | null;
117
- declare type ScaleControlOptions = ConstructorParameters<typeof MapboxScaleControl>[0];
118
- export declare type ScaleControlProps = _ScaleControlProps<ScaleControlOptions>;
117
+ type ScaleControlOptions = ConstructorParameters<typeof MapboxScaleControl>[0];
118
+ export type ScaleControlProps = _ScaleControlProps<ScaleControlOptions>;
119
119
  export declare const ScaleControl: (props: ScaleControlProps) => React.ReactElement | null;
120
- export declare type LayerProps = _LayerProps<AnyLayer>;
120
+ export type LayerProps = _LayerProps<AnyLayer>;
121
121
  export declare const Layer: (props: LayerProps) => React.ReactElement | null;
122
- export declare type SourceProps = _SourceProps<AnySource>;
122
+ export type SourceProps = _SourceProps<AnySource>;
123
123
  export declare const Source: (props: SourceProps) => React.ReactElement | null;
124
124
  export { default as useControl } from './components/use-control';
125
125
  export { MapProvider } from './components/use-map';
@@ -128,12 +128,12 @@ export * from './types/public';
128
128
  export type { Point, PointLike, LngLat, LngLatLike, LngLatBounds, LngLatBoundsLike, PaddingOptions, MapboxGeoJSONFeature as MapGeoJSONFeature, GeoJSONSource, VideoSource, ImageSource, CanvasSource, VectorSourceImpl as VectorTileSource } from 'mapbox-gl';
129
129
  export * from './types/style-spec-mapbox';
130
130
  export type { MapEvent, MapMouseEvent, MapLayerMouseEvent, MapTouchEvent, MapLayerTouchEvent, MapStyleDataEvent, MapSourceDataEvent, MapWheelEvent, MapBoxZoomEvent, ErrorEvent, ViewStateChangeEvent } from './types/events-mapbox';
131
- export declare type PopupEvent = events.PopupEvent<MapboxPopup>;
132
- export declare type MarkerEvent = events.MarkerEvent<MapboxMarker>;
133
- export declare type MarkerDragEvent = events.MarkerDragEvent<MapboxMarker>;
134
- export declare type GeolocateEvent = events.GeolocateEvent<MapboxGeolocateControl>;
135
- export declare type GeolocateResultEvent = events.GeolocateResultEvent<MapboxGeolocateControl>;
136
- export declare type GeolocateErrorEvent = events.GeolocateErrorEvent<MapboxGeolocateControl>;
131
+ export type PopupEvent = events.PopupEvent<MapboxPopup>;
132
+ export type MarkerEvent = events.MarkerEvent<MapboxMarker>;
133
+ export type MarkerDragEvent = events.MarkerDragEvent<MapboxMarker>;
134
+ export type GeolocateEvent = events.GeolocateEvent<MapboxGeolocateControl>;
135
+ export type GeolocateResultEvent = events.GeolocateResultEvent<MapboxGeolocateControl>;
136
+ export type GeolocateErrorEvent = events.GeolocateErrorEvent<MapboxGeolocateControl>;
137
137
  /** @deprecated use `MapStyle` */
138
- export declare type MapboxStyle = MapStyle;
138
+ export type MapboxStyle = MapStyle;
139
139
  export type { Map as MapboxMap, MapboxEvent, MapboxGeoJSONFeature } from 'mapbox-gl';
@@ -2,7 +2,7 @@ import type { MapInstance, MapStyle, Callbacks } from '../types';
2
2
  import type Mapbox from './mapbox';
3
3
  /** These methods may break the react binding if called directly */
4
4
  declare const skipMethods: readonly ["setMaxBounds", "setMinZoom", "setMaxZoom", "setMinPitch", "setMaxPitch", "setRenderWorldCopies", "setProjection", "setStyle", "addSource", "removeSource", "addLayer", "removeLayer", "setLayerZoomRange", "setFilter", "setPaintProperty", "setLayoutProperty", "setLight", "setTerrain", "setFog", "remove"];
5
- export declare type MapRef<MapT extends MapInstance> = {
5
+ export type MapRef<MapT extends MapInstance> = {
6
6
  getMap(): MapT;
7
7
  } & Omit<MapT, typeof skipMethods[number]>;
8
8
  export default function createRef<StyleT extends MapStyle, CallbacksT extends Callbacks, MapT extends MapInstance>(mapInstance: Mapbox<StyleT, CallbacksT, MapT>): MapRef<MapT> | null;
@@ -1,5 +1,5 @@
1
1
  import type { Transform, ViewState, ViewStateChangeEvent, PointLike, PaddingOptions, MapStyle, ImmutableLike, LngLatBoundsLike, Callbacks, MapEvent, MapMouseEvent, MapInstance, MapInstanceInternal } from '../types';
2
- export declare type MapboxProps<StyleT extends MapStyle = MapStyle, CallbacksT extends Callbacks = {}> = Partial<ViewState> & CallbacksT & {
2
+ export type MapboxProps<StyleT extends MapStyle = MapStyle, CallbacksT extends Callbacks = {}> = Partial<ViewState> & CallbacksT & {
3
3
  mapboxAccessToken?: string;
4
4
  /** Camera options used when constructing the Map instance */
5
5
  initialViewState?: Partial<ViewState> & {
@@ -1,3 +1,7 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ var _Mapbox;
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1
5
  import { transformToViewState, applyViewStateToTransform, cloneTransform, syncProjection } from "../utils/transform.js";
2
6
  import { normalizeStyle } from "../utils/style-utils.js";
3
7
  import { deepEqual } from "../utils/deep-equal.js";
@@ -57,18 +61,53 @@ const otherEvents = {
57
61
  const settingNames = ['minZoom', 'maxZoom', 'minPitch', 'maxPitch', 'maxBounds', 'projection', 'renderWorldCopies'];
58
62
  const handlerNames = ['scrollZoom', 'boxZoom', 'dragRotate', 'dragPan', 'keyboard', 'doubleClickZoom', 'touchZoomRotate', 'touchPitch'];
59
63
  export default class Mapbox {
60
- _map = null;
61
- _internalUpdate = false;
62
- _inRender = false;
63
- _hoveredFeatures = null;
64
- _deferredEvents = {
65
- move: false,
66
- zoom: false,
67
- pitch: false,
68
- rotate: false
69
- };
70
- static savedMaps = [];
71
64
  constructor(MapClass, props, container) {
65
+ this._MapClass = void 0;
66
+ this._map = null;
67
+ this.props = void 0;
68
+ this._renderTransform = void 0;
69
+ this._internalUpdate = false;
70
+ this._inRender = false;
71
+ this._hoveredFeatures = null;
72
+ this._deferredEvents = {
73
+ move: false,
74
+ zoom: false,
75
+ pitch: false,
76
+ rotate: false
77
+ };
78
+ this._onEvent = e => {
79
+ const cb = this.props[otherEvents[e.type]];
80
+ if (cb) {
81
+ cb(e);
82
+ } else if (e.type === 'error') {
83
+ console.error(e.error);
84
+ }
85
+ };
86
+ this._onPointerEvent = e => {
87
+ if (e.type === 'mousemove' || e.type === 'mouseout') {
88
+ this._updateHover(e);
89
+ }
90
+ const cb = this.props[pointerEvents[e.type]];
91
+ if (cb) {
92
+ if (this.props.interactiveLayerIds && e.type !== 'mouseover' && e.type !== 'mouseout') {
93
+ e.features = this._hoveredFeatures || this._queryRenderedFeatures(e.point);
94
+ }
95
+ cb(e);
96
+ delete e.features;
97
+ }
98
+ };
99
+ this._onCameraEvent = e => {
100
+ if (!this._internalUpdate) {
101
+ const cb = this.props[cameraEvents[e.type]];
102
+ if (cb) {
103
+ cb(e);
104
+ }
105
+ }
106
+ if (e.type in this._deferredEvents) {
107
+ this._deferredEvents[e.type] = false;
108
+ }
109
+ };
110
+ this._onAfterRepaint = void 0;
72
111
  this._MapClass = MapClass;
73
112
  this.props = props;
74
113
  this._initialize(container);
@@ -112,20 +151,18 @@ export default class Mapbox {
112
151
  resizeObserver.disconnect();
113
152
  resizeObserver.observe(container);
114
153
  }
115
- that.setProps({
116
- ...props,
154
+ that.setProps(_objectSpread(_objectSpread({}, props), {}, {
117
155
  styleDiffing: false
118
- });
156
+ }));
119
157
  map.resize();
120
158
  const {
121
159
  initialViewState
122
160
  } = props;
123
161
  if (initialViewState) {
124
162
  if (initialViewState.bounds) {
125
- map.fitBounds(initialViewState.bounds, {
126
- ...initialViewState.fitBoundsOptions,
163
+ map.fitBounds(initialViewState.bounds, _objectSpread(_objectSpread({}, initialViewState.fitBoundsOptions), {}, {
127
164
  duration: 0
128
- });
165
+ }));
129
166
  } else {
130
167
  that._updateViewState(initialViewState, false);
131
168
  }
@@ -145,13 +182,11 @@ export default class Mapbox {
145
182
  const {
146
183
  mapStyle = DEFAULT_STYLE
147
184
  } = props;
148
- const mapOptions = {
149
- ...props,
150
- ...props.initialViewState,
185
+ const mapOptions = _objectSpread(_objectSpread(_objectSpread({}, props), props.initialViewState), {}, {
151
186
  accessToken: props.mapboxAccessToken || getAccessTokenFromEnv() || null,
152
187
  container,
153
188
  style: normalizeStyle(mapStyle)
154
- };
189
+ });
155
190
  const viewState = mapOptions.initialViewState || mapOptions.viewState || mapOptions;
156
191
  Object.assign(mapOptions, {
157
192
  center: [viewState.longitude || 0, viewState.latitude || 0],
@@ -210,7 +245,7 @@ export default class Mapbox {
210
245
  recycle() {
211
246
  const container = this.map.getContainer();
212
247
  const children = container.querySelector('[mapboxgl-children]');
213
- children === null || children === void 0 ? void 0 : children.remove();
248
+ children === null || children === void 0 || children.remove();
214
249
  Mapbox.savedMaps.push(this);
215
250
  }
216
251
  destroy() {
@@ -259,19 +294,16 @@ export default class Mapbox {
259
294
  if (isMoving) {
260
295
  tr.cameraElevationReference = 'sea';
261
296
  }
262
- const changed = applyViewStateToTransform(tr, {
263
- ...transformToViewState(map.transform),
264
- ...nextProps
265
- });
297
+ const changed = applyViewStateToTransform(tr, _objectSpread(_objectSpread({}, transformToViewState(map.transform)), nextProps));
266
298
  if (isMoving) {
267
299
  tr.cameraElevationReference = 'ground';
268
300
  }
269
301
  if (changed && triggerEvents) {
270
302
  const deferredEvents = this._deferredEvents;
271
303
  deferredEvents.move = true;
272
- deferredEvents.zoom ||= zoom !== tr.zoom;
273
- deferredEvents.rotate ||= bearing !== tr.bearing;
274
- deferredEvents.pitch ||= pitch !== tr.pitch;
304
+ deferredEvents.zoom || (deferredEvents.zoom = zoom !== tr.zoom);
305
+ deferredEvents.rotate || (deferredEvents.rotate = bearing !== tr.bearing);
306
+ deferredEvents.pitch || (deferredEvents.pitch = pitch !== tr.pitch);
275
307
  }
276
308
  if (!isMoving) {
277
309
  applyViewStateToTransform(map.transform, nextProps);
@@ -285,7 +317,7 @@ export default class Mapbox {
285
317
  if (propName in nextProps && !deepEqual(nextProps[propName], currProps[propName])) {
286
318
  changed = true;
287
319
  const setter = map[`set${propName[0].toUpperCase()}${propName.slice(1)}`];
288
- setter === null || setter === void 0 ? void 0 : setter.call(map, nextProps[propName]);
320
+ setter === null || setter === void 0 || setter.call(map, nextProps[propName]);
289
321
  }
290
322
  }
291
323
  return changed;
@@ -335,8 +367,9 @@ export default class Mapbox {
335
367
  const map = this._map;
336
368
  let changed = false;
337
369
  for (const propName of handlerNames) {
338
- const newValue = nextProps[propName] ?? true;
339
- const oldValue = currProps[propName] ?? true;
370
+ var _nextProps$propName, _currProps$propName;
371
+ const newValue = (_nextProps$propName = nextProps[propName]) !== null && _nextProps$propName !== void 0 ? _nextProps$propName : true;
372
+ const oldValue = (_currProps$propName = currProps[propName]) !== null && _currProps$propName !== void 0 ? _currProps$propName : true;
340
373
  if (!deepEqual(newValue, oldValue)) {
341
374
  changed = true;
342
375
  if (newValue) {
@@ -348,14 +381,6 @@ export default class Mapbox {
348
381
  }
349
382
  return changed;
350
383
  }
351
- _onEvent = e => {
352
- const cb = this.props[otherEvents[e.type]];
353
- if (cb) {
354
- cb(e);
355
- } else if (e.type === 'error') {
356
- console.error(e.error);
357
- }
358
- };
359
384
  _queryRenderedFeatures(point) {
360
385
  const map = this._map;
361
386
  const tr = map.transform;
@@ -367,7 +392,7 @@ export default class Mapbox {
367
392
  return map.queryRenderedFeatures(point, {
368
393
  layers: interactiveLayerIds.filter(map.getLayer.bind(map))
369
394
  });
370
- } catch {
395
+ } catch (_unused) {
371
396
  return [];
372
397
  } finally {
373
398
  map.transform = tr;
@@ -398,30 +423,6 @@ export default class Mapbox {
398
423
  this._hoveredFeatures = null;
399
424
  }
400
425
  }
401
- _onPointerEvent = e => {
402
- if (e.type === 'mousemove' || e.type === 'mouseout') {
403
- this._updateHover(e);
404
- }
405
- const cb = this.props[pointerEvents[e.type]];
406
- if (cb) {
407
- if (this.props.interactiveLayerIds && e.type !== 'mouseover' && e.type !== 'mouseout') {
408
- e.features = this._hoveredFeatures || this._queryRenderedFeatures(e.point);
409
- }
410
- cb(e);
411
- delete e.features;
412
- }
413
- };
414
- _onCameraEvent = e => {
415
- if (!this._internalUpdate) {
416
- const cb = this.props[cameraEvents[e.type]];
417
- if (cb) {
418
- cb(e);
419
- }
420
- }
421
- if (e.type in this._deferredEvents) {
422
- this._deferredEvents[e.type] = false;
423
- }
424
- };
425
426
  _fireEvent(baseFire, event, properties) {
426
427
  const map = this._map;
427
428
  const tr = map.transform;
@@ -460,6 +461,8 @@ export default class Mapbox {
460
461
  };
461
462
  }
462
463
  }
464
+ _Mapbox = Mapbox;
465
+ Mapbox.savedMaps = [];
463
466
  function getAccessTokenFromEnv() {
464
467
  let accessToken = null;
465
468
  if (typeof location !== 'undefined') {
@@ -468,10 +471,10 @@ function getAccessTokenFromEnv() {
468
471
  }
469
472
  try {
470
473
  accessToken = accessToken || process.env.MapboxAccessToken;
471
- } catch {}
474
+ } catch (_unused2) {}
472
475
  try {
473
476
  accessToken = accessToken || process.env.REACT_APP_MAPBOX_ACCESS_TOKEN;
474
- } catch {}
477
+ } catch (_unused3) {}
475
478
  return accessToken;
476
479
  }
477
480
  //# sourceMappingURL=mapbox.js.map