@carto/ps-react-maps 2.1.0 → 3.0.0-canary.0

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 (87) hide show
  1. package/LICENSE.md +29 -0
  2. package/README.md +16 -13
  3. package/dist/index.js +2317 -1433
  4. package/dist/index.js.map +1 -0
  5. package/dist/styles.css +1 -0
  6. package/dist/types/common/common.d.ts +3 -0
  7. package/dist/types/common/index.d.ts +25 -0
  8. package/dist/types/common/lasso-tools.d.ts +33 -0
  9. package/dist/types/common/measurement-tools.d.ts +66 -0
  10. package/dist/types/const.d.ts +31 -0
  11. package/dist/types/deckgl.d.ts +2 -0
  12. package/dist/types/editable/const.d.ts +8 -0
  13. package/dist/types/editable/lasso-tools/const.d.ts +31 -0
  14. package/dist/types/editable/lasso-tools/lasso-tools-control.d.ts +2 -0
  15. package/dist/types/editable/lasso-tools/lasso-tools.d.ts +28 -0
  16. package/dist/types/editable/lasso-tools/layer.d.ts +3 -0
  17. package/dist/types/editable/lasso-tools/modes/custom-edit-mode.class.d.ts +5 -0
  18. package/dist/types/editable/lasso-tools/provider/provider.d.ts +4 -0
  19. package/dist/types/editable/lasso-tools/provider/store.d.ts +2 -0
  20. package/dist/types/editable/lasso-tools/provider/types.d.ts +14 -0
  21. package/dist/types/editable/lasso-tools/types.d.ts +77 -0
  22. package/dist/types/editable/measurement-tools/const.d.ts +67 -0
  23. package/dist/types/editable/measurement-tools/layer.d.ts +3 -0
  24. package/dist/types/editable/measurement-tools/measurement-tools-control.d.ts +2 -0
  25. package/dist/types/editable/measurement-tools/measurement-tools.d.ts +8 -0
  26. package/dist/types/editable/measurement-tools/modes/custom-measurement-area.class.d.ts +30 -0
  27. package/dist/types/editable/measurement-tools/modes/custom-measurement-buffer.class.d.ts +28 -0
  28. package/dist/types/editable/measurement-tools/modes/custom-measurement-distance.class.d.ts +16 -0
  29. package/dist/types/editable/measurement-tools/provider/provider.d.ts +4 -0
  30. package/dist/types/editable/measurement-tools/provider/store.d.ts +2 -0
  31. package/dist/types/editable/measurement-tools/provider/types.d.ts +18 -0
  32. package/dist/types/editable/measurement-tools/types.d.ts +97 -0
  33. package/dist/types/editable/measurement-tools/use-measurement-tools.d.ts +36 -0
  34. package/dist/types/editable/measurement-tools/utils.d.ts +17 -0
  35. package/dist/types/helpers.d.ts +12 -0
  36. package/dist/types/index.d.ts +41 -4
  37. package/dist/types/map.d.ts +2 -0
  38. package/dist/types/providers/layers/store.d.ts +2 -0
  39. package/dist/types/providers/layers/types.d.ts +9 -0
  40. package/dist/types/providers/map/const.d.ts +2 -0
  41. package/dist/types/providers/map/provider.d.ts +4 -0
  42. package/dist/types/providers/map/store.d.ts +2 -0
  43. package/dist/types/providers/map/types.d.ts +59 -0
  44. package/dist/types/providers/sources/const.d.ts +2 -0
  45. package/dist/types/providers/sources/store.d.ts +2 -0
  46. package/dist/types/providers/sources/types.d.ts +17 -0
  47. package/dist/types/types.d.ts +56 -0
  48. package/dist/types/use-get-layers.d.ts +4 -0
  49. package/dist/types/use-map-screenshot.d.ts +8 -0
  50. package/dist/types/utils/object-to-html/const.d.ts +5 -0
  51. package/dist/types/utils/object-to-html/object-to-html.test.d.ts +1 -0
  52. package/dist/types/utils/object-to-html/types.d.ts +3 -6
  53. package/dist/types/zoom-controls.d.ts +2 -0
  54. package/package.json +78 -42
  55. package/dist/index.cjs +0 -30
  56. package/dist/types/assets/icons/ruler.d.ts +0 -2
  57. package/dist/types/common-stories/maps/deckgl-maps.component.d.ts +0 -2
  58. package/dist/types/common-stories/maps/google-maps.component.d.ts +0 -3
  59. package/dist/types/common-stories/maps/map-container.component.d.ts +0 -4
  60. package/dist/types/common-stories/maps/map.component.d.ts +0 -2
  61. package/dist/types/event-manager/index.d.ts +0 -1
  62. package/dist/types/event-manager/use-event-manager.hook.d.ts +0 -14
  63. package/dist/types/map-measurement-tool/custom-editable-geojson-layer.class.d.ts +0 -10
  64. package/dist/types/map-measurement-tool/custom-measurement-distance-mode.class.d.ts +0 -6
  65. package/dist/types/map-measurement-tool/index.d.ts +0 -9
  66. package/dist/types/map-measurement-tool/map-measurement-tool.component.d.ts +0 -6
  67. package/dist/types/map-measurement-tool/map-measurement-tool.const.d.ts +0 -34
  68. package/dist/types/map-measurement-tool/map-measurement-tool.context.d.ts +0 -5
  69. package/dist/types/map-measurement-tool/map-measurement-tool.hook.d.ts +0 -10
  70. package/dist/types/map-measurement-tool/map-measurement-tool.layer.d.ts +0 -10
  71. package/dist/types/map-measurement-tool/map-measurement-tool.provider.d.ts +0 -8
  72. package/dist/types/map-measurement-tool/map-measurement-tool.reducer.d.ts +0 -15
  73. package/dist/types/map-measurement-tool/map-measurement-tool.styles.d.ts +0 -28
  74. package/dist/types/map-measurement-tool/map-measurement-tool.types.d.ts +0 -91
  75. package/dist/types/map-measurement-tool/map-measurement-tool.util.d.ts +0 -12
  76. package/dist/types/map-provider/index.d.ts +0 -6
  77. package/dist/types/map-provider/map-provider.const.d.ts +0 -33
  78. package/dist/types/map-provider/map-provider.context.d.ts +0 -6
  79. package/dist/types/map-provider/map-provider.hook.d.ts +0 -87
  80. package/dist/types/map-provider/map-provider.provider.d.ts +0 -13
  81. package/dist/types/map-provider/map-provider.reducer.d.ts +0 -24
  82. package/dist/types/map-provider/map-provider.types.d.ts +0 -122
  83. package/dist/types/utils/get-map-type/get-map-type.d.ts +0 -1
  84. package/dist/types/utils/get-map-type/index.d.ts +0 -2
  85. package/dist/types/utils/get-map-type/is-gmaps.d.ts +0 -1
  86. package/dist/types/utils/index.d.ts +0 -2
  87. package/dist/types/utils/object-to-html/index.d.ts +0 -2
@@ -1,87 +0,0 @@
1
- import type { DeckGLMapsProps, MapProviderMapProps, MapReferences, MapResize, MapViewState, OverlayMapRef, ViewportRect } from './map-provider.types';
2
- import type { Deck, WebMercatorViewport } from '@deck.gl/core';
3
- /**
4
- * Custom hook that retrieves the map configuration for a given ID.
5
- * @param id - The ID of the map.
6
- * @returns The map configuration for the specified ID.
7
- */
8
- export declare function useMap(id: string): MapProviderMapProps;
9
- /**
10
- * Custom hook that provides access to the map references and related functions.
11
- *
12
- * @param id - The ID of the map reference.
13
- * @returns An object containing the map references and functions.
14
- */
15
- export declare function useMapReferences(id: string): MapReferences & {
16
- getDeckInstance: () => Deck | undefined;
17
- getOverlayInstance: () => OverlayMapRef | undefined;
18
- getViewState: () => DeckGLMapsProps['viewState'];
19
- getViewports: (rect?: ViewportRect) => WebMercatorViewport[];
20
- getViewport: (index?: number, rect?: ViewportRect) => WebMercatorViewport;
21
- };
22
- /**
23
- * Custom hook that provides map actions for a specific map ID.
24
- * @param id - The ID of the map.
25
- * @returns An object containing map actions.
26
- */
27
- export declare function useMapActions(id: string): {
28
- setBasemap: (basemap: any) => void;
29
- setResize: (props: MapResize) => void;
30
- setViewState: (viewState: MapViewState) => void;
31
- setZoom: (zoom: number) => void;
32
- setLoaded: (loaded: boolean) => void;
33
- fitBounds: (bounds: Parameters<WebMercatorViewport['fitBounds']>[0], { boundsOptions, viewStateOptions, }?: {
34
- boundsOptions?: Parameters<WebMercatorViewport['fitBounds']>[1];
35
- viewStateOptions?: any;
36
- }) => void;
37
- };
38
- /**
39
- * Returns the map with the given ID from the current map state.
40
- * @param {string} id - The ID of the map to retrieve.
41
- * @returns {MapContextInterface['state']['maps'][string]} The map with the given ID.
42
- *
43
- * @deprecated Use `useMap` with id param instead.
44
- */
45
- export declare function useMapByID(id: string): MapProviderMapProps;
46
- /**
47
- * @deprecated Use `useMapReferences` with id param instead.
48
- */
49
- export declare function useMapReferencesByID(id: string): MapReferences & {
50
- getDeckInstance: () => Deck<null> | undefined;
51
- getOverlayInstance: () => OverlayMapRef | undefined;
52
- getViewState: () => ({
53
- longitude: number;
54
- latitude: number;
55
- zoom: number;
56
- pitch?: number | undefined;
57
- bearing?: number | undefined;
58
- minZoom?: number | undefined;
59
- maxZoom?: number | undefined;
60
- minPitch?: number | undefined;
61
- maxPitch?: number | undefined;
62
- position?: number[] | undefined;
63
- } & import("@deck.gl/core/dist/controllers/transition-manager").TransitionProps) | undefined;
64
- getViewports: (rect?: ViewportRect | undefined) => WebMercatorViewport[];
65
- getViewport: (index?: number | undefined, rect?: ViewportRect | undefined) => WebMercatorViewport;
66
- };
67
- /**
68
- @deprecated Use `useMapActions` with id param instead.
69
- */
70
- export declare function useMapActionsByID(id: string): {
71
- setBasemap: (basemap: any) => void;
72
- setResize: (props: MapResize) => void;
73
- setViewState: (viewState: import("@deck.gl/core").MapViewState) => void;
74
- setZoom: (zoom: number) => void;
75
- setLoaded: (loaded: boolean) => void;
76
- fitBounds: (bounds: [[number, number], [number, number]], { boundsOptions, viewStateOptions, }?: {
77
- boundsOptions?: {
78
- width?: number | undefined;
79
- height?: number | undefined;
80
- minExtent?: number | undefined;
81
- maxZoom?: number | undefined;
82
- padding?: number | Required<import("@deck.gl/core/dist/viewports/viewport").Padding> | undefined;
83
- offset?: number[] | undefined;
84
- } | undefined;
85
- viewStateOptions?: any;
86
- }) => void;
87
- };
@@ -1,13 +0,0 @@
1
- import type { MapProviderProps } from './map-provider.types';
2
- /**
3
- * Provides a context for maps and their state management.
4
- * @param {MapProviderProps} props - The props for the MapProvider component.
5
- * @returns {JSX.Element} - The MapProvider component.
6
- *
7
- * @remarks
8
- * The MapProvider component is used to manage the state of multiple maps.
9
- *
10
- * The externalSync prop is used to sync the state with an external source, such as C4R. The externalSync function should accept an action object with a type and payload property.
11
- * The type property should be a string that matches the action type described in the Action enum. The payload property should be an object that contains the data to be synced.
12
- */
13
- export declare function MapProvider({ children, maps, externalSync, }: MapProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -1,24 +0,0 @@
1
- import type { MapResize, MapsProps, MapState, MapViewState } from './map-provider.types';
2
- export declare enum Actions {
3
- SetViewState = "SetViewState",
4
- SetBasemap = "SetBasemap",
5
- SetResize = "SetResize",
6
- SetZoom = "SetZoom",
7
- SetLoaded = "SetLoaded"
8
- }
9
- type Action = {
10
- type: Actions;
11
- payload: MapsProps | MapResize | {
12
- viewState: MapViewState;
13
- } | {
14
- zoom: MapViewState['zoom'];
15
- } | boolean;
16
- };
17
- /**
18
- * Reducer function for the MapProvider component.
19
- * @param state - The current state of the MapProvider.
20
- * @param action - The action to be performed on the state.
21
- * @returns The new state of the MapProvider.
22
- */
23
- export declare function reducer(state: MapState, { type, payload }: Action): MapState;
24
- export {};
@@ -1,122 +0,0 @@
1
- /// <reference types="google.maps" />
2
- import type { MapViewState as _MapViewState, PickingInfo } from '@deck.gl/core';
3
- import type { GoogleMapsOverlay, GoogleMapsOverlayProps } from '@deck.gl/google-maps';
4
- import type { DeckGLProps, DeckGLRef } from '@deck.gl/react';
5
- import type { Properties } from 'csstype';
6
- import type { MutableRefObject, ReactNode } from 'react';
7
- import type { MapRef } from 'react-map-gl';
8
- import { CartoBasemapsNames, GMapsBasemap } from './map-provider.const';
9
- import type { Actions } from './map-provider.reducer';
10
- import type { ControllerOptions } from '@deck.gl/core/dist/controllers/controller';
11
- export type MapViewState = _MapViewState;
12
- export type MapProviderMapProps = {
13
- id: MapsProps['id'];
14
- basemap: MapsProps['basemap'];
15
- viewState: MapViewState;
16
- isLoaded?: boolean;
17
- } & Partial<MapResize>;
18
- /**
19
- * Props for the MapProvider component.
20
- */
21
- export type MapProviderProps = {
22
- children: ReactNode;
23
- maps: MapProviderMapProps[];
24
- externalSync?: ExternalSync;
25
- };
26
- export type ExternalSync = (data: ExternalSyncProps) => void;
27
- export type ExternalSyncProps = {
28
- type: Actions.SetViewState | Actions.SetResize;
29
- payload: MapViewState | MapResize;
30
- };
31
- /**
32
- * State for the MapProvider component.
33
- */
34
- export type MapState = {
35
- maps: Record<MapsProps['id'], MapProviderMapProps>;
36
- };
37
- /**
38
- * Resize properties for the map.
39
- */
40
- export type MapResize = {
41
- width: MapsProps['width'];
42
- height: MapsProps['height'];
43
- };
44
- export type MapReferences = {
45
- instanceRef: MutableRefObject<InstanceMapRef>;
46
- overlayRef: MutableRefObject<OverlayMapRef>;
47
- };
48
- export type MapReferencesState = Record<MapsProps['id'], MapReferences>;
49
- /**
50
- * Actions that can be performed on the map.
51
- */
52
- export type MapActionsState = {
53
- setViewState: (viewState: MapViewState, id: MapsProps['id']) => void;
54
- setResize: (props: MapResize, id: MapsProps['id']) => void;
55
- setBasemap: (basemap: Basemap, id: MapsProps['id']) => void;
56
- setZoom: (zoom: number, id: MapsProps['id']) => void;
57
- setLoaded: (loaded: boolean, id: MapsProps['id']) => void;
58
- };
59
- /**
60
- * Context interface for the MapProvider component.
61
- */
62
- export type MapContextInterface = {
63
- state: MapState;
64
- references: MutableRefObject<MapReferencesState>;
65
- actions: MapActionsState;
66
- };
67
- /**
68
- * Basemap types.
69
- */
70
- export type Basemap = (typeof GMapsBasemap)[keyof typeof GMapsBasemap] | (typeof CartoBasemapsNames)[keyof typeof CartoBasemapsNames] | string;
71
- /**
72
- * Common properties for the map.
73
- */
74
- export type CommonProps = {
75
- id: string;
76
- basemap: Basemap;
77
- viewState?: MapViewState;
78
- initialViewState?: MapViewState;
79
- controller?: ControllerOptions;
80
- } & DeckGLProps & Partial<MapReferences>;
81
- /**
82
- * Properties for the maps.
83
- */
84
- export type MapsProps = DeckGLMapsProps & GoogleMapsProps;
85
- /**
86
- * Reference to the instance map.
87
- */
88
- export type InstanceMapRef = GoogleMapsOverlay | DeckGLRef | null;
89
- /**
90
- * Reference to the overlay map.
91
- */
92
- export type OverlayMapRef = google.maps.Map | MapRef | null;
93
- /**
94
- * Properties for the DeckGL maps.
95
- */
96
- export type DeckGLMapsProps = CommonProps;
97
- /**
98
- * Properties for the Google Maps.
99
- */
100
- export type GoogleMapsProps = {
101
- apiKey?: string;
102
- language?: string;
103
- mapId?: string;
104
- mapOptions?: Record<string, number | string>;
105
- style?: Properties;
106
- version?: string;
107
- } & CommonProps & GoogleMapsOverlayProps;
108
- /**
109
- * Tooltip properties.
110
- */
111
- export type Tooltip = {
112
- text?: string | undefined;
113
- html?: string | undefined;
114
- className?: string | undefined;
115
- style?: Partial<CSSStyleDeclaration> | undefined;
116
- } & PickingInfo;
117
- export type ViewportRect = {
118
- x: number;
119
- y: number;
120
- width?: number;
121
- height?: number;
122
- };
@@ -1 +0,0 @@
1
- export declare function getMapType(basemap: string): import("@/map-provider").MapsTypes;
@@ -1,2 +0,0 @@
1
- export * from './get-map-type';
2
- export * from './is-gmaps';
@@ -1 +0,0 @@
1
- export declare function isGmaps(basemap: string): boolean;
@@ -1,2 +0,0 @@
1
- export * from './object-to-html';
2
- export * from './get-map-type';
@@ -1,2 +0,0 @@
1
- export { objectToHtml } from './object-to-html';
2
- export * from './types';