@tmlmobilidade/ui 20250403.1817.10 → 20250403.1846.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/attribution-control.js +15 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/attribution-control.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/fullscreen-control.js +17 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/fullscreen-control.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/geolocate-control.js +45 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/geolocate-control.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/layer.js +102 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/layer.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/logo-control.js +13 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/logo-control.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/map.js +91 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/map.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/marker.js +93 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/marker.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/navigation-control.js +17 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/navigation-control.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/popup.js +67 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/popup.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/scale-control.js +27 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/scale-control.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/source.js +117 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/source.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/terrain-control.js +15 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/terrain-control.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/use-control.js +32 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/use-control.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/use-map.js +45 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/components/use-map.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/maplibre/create-ref.js +58 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/maplibre/create-ref.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/maplibre/maplibre.js +456 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/maplibre/maplibre.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/utils/apply-react-style.js +21 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/utils/apply-react-style.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/utils/assert.js +8 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/utils/assert.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/utils/compare-class-names.js +26 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/utils/compare-class-names.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/utils/deep-equal.js +62 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/utils/deep-equal.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/utils/set-globals.js +26 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/utils/set-globals.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/utils/style-utils.js +51 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/utils/style-utils.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/utils/transform.js +53 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/utils/transform.js.map +1 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/utils/use-isomorphic-layout-effect.js +8 -0
- package/dist/node_modules/@vis.gl/react-maplibre/dist/utils/use-isomorphic-layout-effect.js.map +1 -0
- package/dist/src/components/AppProvider/index.js +12 -1
- package/dist/src/components/AppProvider/index.js.map +1 -1
- package/dist/src/components/map/MapView/index.js +11 -1
- package/dist/src/components/map/MapView/index.js.map +1 -1
- package/dist/src/components/map/MapViewStyleActiveStops/index.js +14 -1
- package/dist/src/components/map/MapViewStyleActiveStops/index.js.map +1 -1
- package/dist/src/components/map/MapViewStylePath/index.js +14 -1
- package/dist/src/components/map/MapViewStylePath/index.js.map +1 -1
- package/dist/src/components/map/MapViewStyleStops/index.js +14 -1
- package/dist/src/components/map/MapViewStyleStops/index.js.map +1 -1
- package/dist/src/components/map/MapViewStyleVehicles/index.js +14 -1
- package/dist/src/components/map/MapViewStyleVehicles/index.js.map +1 -1
- package/dist/styles-no-reset.css +1 -0
- package/dist/styles.css +1 -0
- package/package.json +5 -9
package/dist/index.d.ts
CHANGED
@@ -5,7 +5,7 @@ import { BadgeProps as BadgeProps$1, CheckboxProps as CheckboxProps$1, ComboboxP
|
|
5
5
|
export { RenderTreeNodePayload, Tree, TreeNodeData, getTreeExpandedState, useTree } from '@mantine/core';
|
6
6
|
import { DateTimePickerProps as DateTimePickerProps$1 } from '@mantine/dates';
|
7
7
|
import { Permission, User } from '@tmlmobilidade/types';
|
8
|
-
import { MapRef, MapLayerMouseEvent, ViewStateChangeEvent } from '
|
8
|
+
import { MapRef, MapLayerMouseEvent, ViewStateChangeEvent } from 'react-map-gl/maplibre';
|
9
9
|
import { NotificationData } from '@mantine/notifications';
|
10
10
|
export * from '@mantine/form';
|
11
11
|
export * from '@mantine/hooks';
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { memo, useEffect } from 'react';
|
2
|
+
import { applyReactStyle } from '../utils/apply-react-style.js';
|
3
|
+
import { useControl } from './use-control.js';
|
4
|
+
|
5
|
+
function _AttributionControl(props) {
|
6
|
+
const ctrl = useControl(({ mapLib }) => new mapLib.AttributionControl(props), {
|
7
|
+
position: props.position
|
8
|
+
});
|
9
|
+
useEffect(() => {
|
10
|
+
applyReactStyle(ctrl._container, props.style);
|
11
|
+
}, [props.style]);
|
12
|
+
return null;
|
13
|
+
}
|
14
|
+
memo(_AttributionControl);
|
15
|
+
//# sourceMappingURL=attribution-control.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"attribution-control.js","sources":["../../../../../../../../node_modules/@vis.gl/react-maplibre/dist/components/attribution-control.js"],"sourcesContent":["import { useEffect, memo } from 'react';\nimport { applyReactStyle } from \"../utils/apply-react-style.js\";\nimport { useControl } from \"./use-control.js\";\nfunction _AttributionControl(props) {\n const ctrl = useControl(({ mapLib }) => new mapLib.AttributionControl(props), {\n position: props.position\n });\n useEffect(() => {\n applyReactStyle(ctrl._container, props.style);\n }, [props.style]);\n return null;\n}\nexport const AttributionControl = memo(_AttributionControl);\n//# sourceMappingURL=attribution-control.js.map"],"names":[],"mappings":";;;;AAGA,SAAS,mBAAmB,CAAC,KAAK,EAAE;AACpC,IAAI,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE;AAClF,QAAQ,QAAQ,EAAE,KAAK,CAAC;AACxB,KAAK,CAAC;AACN,IAAI,SAAS,CAAC,MAAM;AACpB,QAAQ,eAAe,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC;AACrD,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACrB,IAAI,OAAO,IAAI;AACf;AACkC,IAAI,CAAC,mBAAmB","x_google_ignoreList":[0]}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { memo, useEffect } from 'react';
|
2
|
+
import { applyReactStyle } from '../utils/apply-react-style.js';
|
3
|
+
import { useControl } from './use-control.js';
|
4
|
+
|
5
|
+
function _FullscreenControl(props) {
|
6
|
+
const ctrl = useControl(({ mapLib }) => new mapLib.FullscreenControl({
|
7
|
+
container: props.containerId && document.getElementById(props.containerId)
|
8
|
+
}), { position: props.position });
|
9
|
+
useEffect(() => {
|
10
|
+
applyReactStyle(ctrl._controlContainer, props.style);
|
11
|
+
}, [props.style]);
|
12
|
+
return null;
|
13
|
+
}
|
14
|
+
const FullscreenControl = memo(_FullscreenControl);
|
15
|
+
|
16
|
+
export { FullscreenControl };
|
17
|
+
//# sourceMappingURL=fullscreen-control.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"fullscreen-control.js","sources":["../../../../../../../../node_modules/@vis.gl/react-maplibre/dist/components/fullscreen-control.js"],"sourcesContent":["import { useEffect, memo } from 'react';\nimport { applyReactStyle } from \"../utils/apply-react-style.js\";\nimport { useControl } from \"./use-control.js\";\nfunction _FullscreenControl(props) {\n const ctrl = useControl(({ mapLib }) => new mapLib.FullscreenControl({\n container: props.containerId && document.getElementById(props.containerId)\n }), { position: props.position });\n useEffect(() => {\n applyReactStyle(ctrl._controlContainer, props.style);\n }, [props.style]);\n return null;\n}\nexport const FullscreenControl = memo(_FullscreenControl);\n//# sourceMappingURL=fullscreen-control.js.map"],"names":[],"mappings":";;;;AAGA,SAAS,kBAAkB,CAAC,KAAK,EAAE;AACnC,IAAI,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,MAAM,CAAC,iBAAiB,CAAC;AACzE,QAAQ,SAAS,EAAE,KAAK,CAAC,WAAW,IAAI,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW;AACjF,KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;AACrC,IAAI,SAAS,CAAC,MAAM;AACpB,QAAQ,eAAe,CAAC,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,KAAK,CAAC;AAC5D,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACrB,IAAI,OAAO,IAAI;AACf;AACY,MAAC,iBAAiB,GAAG,IAAI,CAAC,kBAAkB;;;;","x_google_ignoreList":[0]}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import { memo, forwardRef, useRef, useImperativeHandle, useEffect } from 'react';
|
2
|
+
import { applyReactStyle } from '../utils/apply-react-style.js';
|
3
|
+
import { useControl } from './use-control.js';
|
4
|
+
|
5
|
+
function _GeolocateControl(props, ref) {
|
6
|
+
const thisRef = useRef({ props });
|
7
|
+
const ctrl = useControl(({ mapLib }) => {
|
8
|
+
const gc = new mapLib.GeolocateControl(props);
|
9
|
+
// Hack: fix GeolocateControl reuse
|
10
|
+
// When using React strict mode, the component is mounted twice.
|
11
|
+
// GeolocateControl's UI creation is asynchronous. Removing and adding it back causes the UI to be initialized twice.
|
12
|
+
const setupUI = gc._setupUI;
|
13
|
+
gc._setupUI = () => {
|
14
|
+
if (!gc._container.hasChildNodes()) {
|
15
|
+
setupUI();
|
16
|
+
}
|
17
|
+
};
|
18
|
+
gc.on('geolocate', e => {
|
19
|
+
thisRef.current.props.onGeolocate?.(e);
|
20
|
+
});
|
21
|
+
gc.on('error', e => {
|
22
|
+
thisRef.current.props.onError?.(e);
|
23
|
+
});
|
24
|
+
gc.on('outofmaxbounds', e => {
|
25
|
+
thisRef.current.props.onOutOfMaxBounds?.(e);
|
26
|
+
});
|
27
|
+
gc.on('trackuserlocationstart', e => {
|
28
|
+
thisRef.current.props.onTrackUserLocationStart?.(e);
|
29
|
+
});
|
30
|
+
gc.on('trackuserlocationend', e => {
|
31
|
+
thisRef.current.props.onTrackUserLocationEnd?.(e);
|
32
|
+
});
|
33
|
+
return gc;
|
34
|
+
}, { position: props.position });
|
35
|
+
thisRef.current.props = props;
|
36
|
+
useImperativeHandle(ref, () => ctrl, []);
|
37
|
+
useEffect(() => {
|
38
|
+
applyReactStyle(ctrl._container, props.style);
|
39
|
+
}, [props.style]);
|
40
|
+
return null;
|
41
|
+
}
|
42
|
+
const GeolocateControl = memo(forwardRef(_GeolocateControl));
|
43
|
+
|
44
|
+
export { GeolocateControl };
|
45
|
+
//# sourceMappingURL=geolocate-control.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"geolocate-control.js","sources":["../../../../../../../../node_modules/@vis.gl/react-maplibre/dist/components/geolocate-control.js"],"sourcesContent":["import { useImperativeHandle, useRef, useEffect, forwardRef, memo } from 'react';\nimport { applyReactStyle } from \"../utils/apply-react-style.js\";\nimport { useControl } from \"./use-control.js\";\nfunction _GeolocateControl(props, ref) {\n const thisRef = useRef({ props });\n const ctrl = useControl(({ mapLib }) => {\n const gc = new mapLib.GeolocateControl(props);\n // Hack: fix GeolocateControl reuse\n // When using React strict mode, the component is mounted twice.\n // GeolocateControl's UI creation is asynchronous. Removing and adding it back causes the UI to be initialized twice.\n const setupUI = gc._setupUI;\n gc._setupUI = () => {\n if (!gc._container.hasChildNodes()) {\n setupUI();\n }\n };\n gc.on('geolocate', e => {\n thisRef.current.props.onGeolocate?.(e);\n });\n gc.on('error', e => {\n thisRef.current.props.onError?.(e);\n });\n gc.on('outofmaxbounds', e => {\n thisRef.current.props.onOutOfMaxBounds?.(e);\n });\n gc.on('trackuserlocationstart', e => {\n thisRef.current.props.onTrackUserLocationStart?.(e);\n });\n gc.on('trackuserlocationend', e => {\n thisRef.current.props.onTrackUserLocationEnd?.(e);\n });\n return gc;\n }, { position: props.position });\n thisRef.current.props = props;\n useImperativeHandle(ref, () => ctrl, []);\n useEffect(() => {\n applyReactStyle(ctrl._container, props.style);\n }, [props.style]);\n return null;\n}\nexport const GeolocateControl = memo(forwardRef(_GeolocateControl));\n//# sourceMappingURL=geolocate-control.js.map"],"names":[],"mappings":";;;;AAGA,SAAS,iBAAiB,CAAC,KAAK,EA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AQ,OAAO,EAAE;AACjB,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;AACpC,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK;AACjC,IAAI,mBAAmB,CAAC,GAAG,EAAE,MAAM,IAAI,EAAE,EAAE,CAAC;AAC5C,IAAI,SAAS,CAAC,MAAM;AACpB,QAAQ,eAAe,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC;AACrD,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACrB,IAAI,OAAO,IAAI;AACf;AACY,MAAC,gBAAgB,GAAG,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC;;;;","x_google_ignoreList":[0]}
|
@@ -0,0 +1,102 @@
|
|
1
|
+
import { useContext, useRef, useState, useMemo, useEffect } from 'react';
|
2
|
+
import { MapContext } from './map.js';
|
3
|
+
import assert from '../utils/assert.js';
|
4
|
+
import { deepEqual } from '../utils/deep-equal.js';
|
5
|
+
|
6
|
+
/* eslint-disable complexity, max-statements */
|
7
|
+
function updateLayer(map, id, props, prevProps) {
|
8
|
+
assert(props.id === prevProps.id, 'layer id changed');
|
9
|
+
assert(props.type === prevProps.type, 'layer type changed');
|
10
|
+
if (props.type === 'custom' || prevProps.type === 'custom') {
|
11
|
+
return;
|
12
|
+
}
|
13
|
+
// @ts-ignore filter does not exist in some Layer types
|
14
|
+
const { layout = {}, paint = {}, filter, minzoom, maxzoom, beforeId } = props;
|
15
|
+
if (beforeId !== prevProps.beforeId) {
|
16
|
+
map.moveLayer(id, beforeId);
|
17
|
+
}
|
18
|
+
if (layout !== prevProps.layout) {
|
19
|
+
const prevLayout = prevProps.layout || {};
|
20
|
+
for (const key in layout) {
|
21
|
+
if (!deepEqual(layout[key], prevLayout[key])) {
|
22
|
+
map.setLayoutProperty(id, key, layout[key]);
|
23
|
+
}
|
24
|
+
}
|
25
|
+
for (const key in prevLayout) {
|
26
|
+
if (!layout.hasOwnProperty(key)) {
|
27
|
+
map.setLayoutProperty(id, key, undefined);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
if (paint !== prevProps.paint) {
|
32
|
+
const prevPaint = prevProps.paint || {};
|
33
|
+
for (const key in paint) {
|
34
|
+
if (!deepEqual(paint[key], prevPaint[key])) {
|
35
|
+
map.setPaintProperty(id, key, paint[key]);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
for (const key in prevPaint) {
|
39
|
+
if (!paint.hasOwnProperty(key)) {
|
40
|
+
map.setPaintProperty(id, key, undefined);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
// @ts-ignore filter does not exist in some Layer types
|
45
|
+
if (!deepEqual(filter, prevProps.filter)) {
|
46
|
+
map.setFilter(id, filter);
|
47
|
+
}
|
48
|
+
if (minzoom !== prevProps.minzoom || maxzoom !== prevProps.maxzoom) {
|
49
|
+
map.setLayerZoomRange(id, minzoom, maxzoom);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
function createLayer(map, id, props) {
|
53
|
+
// @ts-ignore
|
54
|
+
if (map.style && map.style._loaded && (!('source' in props) || map.getSource(props.source))) {
|
55
|
+
const options = { ...props, id };
|
56
|
+
delete options.beforeId;
|
57
|
+
// @ts-ignore
|
58
|
+
map.addLayer(options, props.beforeId);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
/* eslint-enable complexity, max-statements */
|
62
|
+
let layerCounter = 0;
|
63
|
+
function Layer(props) {
|
64
|
+
const map = useContext(MapContext).map.getMap();
|
65
|
+
const propsRef = useRef(props);
|
66
|
+
const [, setStyleLoaded] = useState(0);
|
67
|
+
const id = useMemo(() => props.id || `jsx-layer-${layerCounter++}`, []);
|
68
|
+
useEffect(() => {
|
69
|
+
if (map) {
|
70
|
+
const forceUpdate = () => setStyleLoaded(version => version + 1);
|
71
|
+
map.on('styledata', forceUpdate);
|
72
|
+
forceUpdate();
|
73
|
+
return () => {
|
74
|
+
map.off('styledata', forceUpdate);
|
75
|
+
// @ts-ignore
|
76
|
+
if (map.style && map.style._loaded && map.getLayer(id)) {
|
77
|
+
map.removeLayer(id);
|
78
|
+
}
|
79
|
+
};
|
80
|
+
}
|
81
|
+
return undefined;
|
82
|
+
}, [map]);
|
83
|
+
// @ts-ignore
|
84
|
+
const layer = map && map.style && map.getLayer(id);
|
85
|
+
if (layer) {
|
86
|
+
try {
|
87
|
+
updateLayer(map, id, props, propsRef.current);
|
88
|
+
}
|
89
|
+
catch (error) {
|
90
|
+
console.warn(error); // eslint-disable-line
|
91
|
+
}
|
92
|
+
}
|
93
|
+
else {
|
94
|
+
createLayer(map, id, props);
|
95
|
+
}
|
96
|
+
// Store last rendered props
|
97
|
+
propsRef.current = props;
|
98
|
+
return null;
|
99
|
+
}
|
100
|
+
|
101
|
+
export { Layer };
|
102
|
+
//# sourceMappingURL=layer.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"layer.js","sources":["../../../../../../../../node_modules/@vis.gl/react-maplibre/dist/components/layer.js"],"sourcesContent":["import { useContext, useEffect, useMemo, useState, useRef } from 'react';\nimport { MapContext } from \"./map.js\";\nimport assert from \"../utils/assert.js\";\nimport { deepEqual } from \"../utils/deep-equal.js\";\n/* eslint-disable complexity, max-statements */\nfunction updateLayer(map, id, props, prevProps) {\n assert(props.id === prevProps.id, 'layer id changed');\n assert(props.type === prevProps.type, 'layer type changed');\n if (props.type === 'custom' || prevProps.type === 'custom') {\n return;\n }\n // @ts-ignore filter does not exist in some Layer types\n const { layout = {}, paint = {}, filter, minzoom, maxzoom, beforeId } = props;\n if (beforeId !== prevProps.beforeId) {\n map.moveLayer(id, beforeId);\n }\n if (layout !== prevProps.layout) {\n const prevLayout = prevProps.layout || {};\n for (const key in layout) {\n if (!deepEqual(layout[key], prevLayout[key])) {\n map.setLayoutProperty(id, key, layout[key]);\n }\n }\n for (const key in prevLayout) {\n if (!layout.hasOwnProperty(key)) {\n map.setLayoutProperty(id, key, undefined);\n }\n }\n }\n if (paint !== prevProps.paint) {\n const prevPaint = prevProps.paint || {};\n for (const key in paint) {\n if (!deepEqual(paint[key], prevPaint[key])) {\n map.setPaintProperty(id, key, paint[key]);\n }\n }\n for (const key in prevPaint) {\n if (!paint.hasOwnProperty(key)) {\n map.setPaintProperty(id, key, undefined);\n }\n }\n }\n // @ts-ignore filter does not exist in some Layer types\n if (!deepEqual(filter, prevProps.filter)) {\n map.setFilter(id, filter);\n }\n if (minzoom !== prevProps.minzoom || maxzoom !== prevProps.maxzoom) {\n map.setLayerZoomRange(id, minzoom, maxzoom);\n }\n}\nfunction createLayer(map, id, props) {\n // @ts-ignore\n if (map.style && map.style._loaded && (!('source' in props) || map.getSource(props.source))) {\n const options = { ...props, id };\n delete options.beforeId;\n // @ts-ignore\n map.addLayer(options, props.beforeId);\n }\n}\n/* eslint-enable complexity, max-statements */\nlet layerCounter = 0;\nexport function Layer(props) {\n const map = useContext(MapContext).map.getMap();\n const propsRef = useRef(props);\n const [, setStyleLoaded] = useState(0);\n const id = useMemo(() => props.id || `jsx-layer-${layerCounter++}`, []);\n useEffect(() => {\n if (map) {\n const forceUpdate = () => setStyleLoaded(version => version + 1);\n map.on('styledata', forceUpdate);\n forceUpdate();\n return () => {\n map.off('styledata', forceUpdate);\n // @ts-ignore\n if (map.style && map.style._loaded && map.getLayer(id)) {\n map.removeLayer(id);\n }\n };\n }\n return undefined;\n }, [map]);\n // @ts-ignore\n const layer = map && map.style && map.getLayer(id);\n if (layer) {\n try {\n updateLayer(map, id, props, propsRef.current);\n }\n catch (error) {\n console.warn(error); // eslint-disable-line\n }\n }\n else {\n createLayer(map, id, props);\n }\n // Store last rendered props\n propsRef.current = props;\n return null;\n}\n//# sourceMappingURL=layer.js.map"],"names":[],"mappings":";;;;;AAIA;AACA,SAAS,WAAW,CAAC,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE;AAChD,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,SAAS,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AACtB,YAAY,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAChC;AACA;AACA,SAAS;AACT,QAAQ,WAAW,CAAC,GAAG,EAAE,EAAE,EAAE,KAAK,CAAC;AACnC;AACA;AACA,IAAI,QAAQ,CAAC,OAAO,GAAG,KAAK;AAC5B,IAAI,OAAO,IAAI;AACf;;;;","x_google_ignoreList":[0]}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { memo, useEffect } from 'react';
|
2
|
+
import { applyReactStyle } from '../utils/apply-react-style.js';
|
3
|
+
import { useControl } from './use-control.js';
|
4
|
+
|
5
|
+
function _LogoControl(props) {
|
6
|
+
const ctrl = useControl(({ mapLib }) => new mapLib.LogoControl(props), { position: props.position });
|
7
|
+
useEffect(() => {
|
8
|
+
applyReactStyle(ctrl._container, props.style);
|
9
|
+
}, [props.style]);
|
10
|
+
return null;
|
11
|
+
}
|
12
|
+
memo(_LogoControl);
|
13
|
+
//# sourceMappingURL=logo-control.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"logo-control.js","sources":["../../../../../../../../node_modules/@vis.gl/react-maplibre/dist/components/logo-control.js"],"sourcesContent":["import { useEffect, memo } from 'react';\nimport { applyReactStyle } from \"../utils/apply-react-style.js\";\nimport { useControl } from \"./use-control.js\";\nfunction _LogoControl(props) {\n const ctrl = useControl(({ mapLib }) => new mapLib.LogoControl(props), { position: props.position });\n useEffect(() => {\n applyReactStyle(ctrl._container, props.style);\n }, [props.style]);\n return null;\n}\nexport const LogoControl = memo(_LogoControl);\n//# sourceMappingURL=logo-control.js.map"],"names":[],"mappings":";;;;AAGA,SAAS,YAAY,CAAC,KAAK,EAAE;AAC7B,IAAI,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;AACxG,IAAI,SAAS,CAAC,MAAM;AACpB,QAAQ,eAAe,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC;AACrD,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACrB,IAAI,OAAO,IAAI;AACf;AAC2B,IAAI,CAAC,YAAY","x_google_ignoreList":[0]}
|
@@ -0,0 +1,91 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { useContext, useState, useRef, useEffect, useImperativeHandle, useMemo } from 'react';
|
3
|
+
import { MountedMapsContext } from './use-map.js';
|
4
|
+
import Maplibre from '../maplibre/maplibre.js';
|
5
|
+
import createRef from '../maplibre/create-ref.js';
|
6
|
+
import useIsomorphicLayoutEffect from '../utils/use-isomorphic-layout-effect.js';
|
7
|
+
import setGlobals from '../utils/set-globals.js';
|
8
|
+
|
9
|
+
const MapContext = React.createContext(null);
|
10
|
+
function _Map(props, ref) {
|
11
|
+
const mountedMapsContext = useContext(MountedMapsContext);
|
12
|
+
const [mapInstance, setMapInstance] = useState(null);
|
13
|
+
const containerRef = useRef();
|
14
|
+
const { current: contextValue } = useRef({ mapLib: null, map: null });
|
15
|
+
useEffect(() => {
|
16
|
+
const mapLib = props.mapLib;
|
17
|
+
let isMounted = true;
|
18
|
+
let maplibre;
|
19
|
+
Promise.resolve(mapLib || import('maplibre-gl'))
|
20
|
+
.then((module) => {
|
21
|
+
if (!isMounted) {
|
22
|
+
return;
|
23
|
+
}
|
24
|
+
if (!module) {
|
25
|
+
throw new Error('Invalid mapLib');
|
26
|
+
}
|
27
|
+
const mapboxgl = 'Map' in module ? module : module.default;
|
28
|
+
if (!mapboxgl.Map) {
|
29
|
+
throw new Error('Invalid mapLib');
|
30
|
+
}
|
31
|
+
setGlobals(mapboxgl, props);
|
32
|
+
if (props.reuseMaps) {
|
33
|
+
maplibre = Maplibre.reuse(props, containerRef.current);
|
34
|
+
}
|
35
|
+
if (!maplibre) {
|
36
|
+
maplibre = new Maplibre(mapboxgl.Map, props, containerRef.current);
|
37
|
+
}
|
38
|
+
contextValue.map = createRef(maplibre);
|
39
|
+
contextValue.mapLib = mapboxgl;
|
40
|
+
setMapInstance(maplibre);
|
41
|
+
mountedMapsContext?.onMapMount(contextValue.map, props.id);
|
42
|
+
})
|
43
|
+
.catch(error => {
|
44
|
+
const { onError } = props;
|
45
|
+
if (onError) {
|
46
|
+
onError({
|
47
|
+
type: 'error',
|
48
|
+
target: null,
|
49
|
+
originalEvent: null,
|
50
|
+
error
|
51
|
+
});
|
52
|
+
}
|
53
|
+
else {
|
54
|
+
console.error(error); // eslint-disable-line
|
55
|
+
}
|
56
|
+
});
|
57
|
+
return () => {
|
58
|
+
isMounted = false;
|
59
|
+
if (maplibre) {
|
60
|
+
mountedMapsContext?.onMapUnmount(props.id);
|
61
|
+
if (props.reuseMaps) {
|
62
|
+
maplibre.recycle();
|
63
|
+
}
|
64
|
+
else {
|
65
|
+
maplibre.destroy();
|
66
|
+
}
|
67
|
+
}
|
68
|
+
};
|
69
|
+
}, []);
|
70
|
+
useIsomorphicLayoutEffect(() => {
|
71
|
+
if (mapInstance) {
|
72
|
+
mapInstance.setProps(props);
|
73
|
+
}
|
74
|
+
});
|
75
|
+
useImperativeHandle(ref, () => contextValue.map, [mapInstance]);
|
76
|
+
const style = useMemo(() => ({
|
77
|
+
position: 'relative',
|
78
|
+
width: '100%',
|
79
|
+
height: '100%',
|
80
|
+
...props.style
|
81
|
+
}), [props.style]);
|
82
|
+
const CHILD_CONTAINER_STYLE = {
|
83
|
+
height: '100%'
|
84
|
+
};
|
85
|
+
return (React.createElement("div", { id: props.id, ref: containerRef, style: style }, mapInstance && (React.createElement(MapContext.Provider, { value: contextValue },
|
86
|
+
React.createElement("div", { "mapboxgl-children": "", style: CHILD_CONTAINER_STYLE }, props.children)))));
|
87
|
+
}
|
88
|
+
const Map = React.forwardRef(_Map);
|
89
|
+
|
90
|
+
export { Map, MapContext };
|
91
|
+
//# sourceMappingURL=map.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"map.js","sources":["../../../../../../../../node_modules/@vis.gl/react-maplibre/dist/components/map.js"],"sourcesContent":["import * as React from 'react';\nimport { useState, useRef, useEffect, useContext, useMemo, useImperativeHandle } from 'react';\nimport { MountedMapsContext } from \"./use-map.js\";\nimport Maplibre from \"../maplibre/maplibre.js\";\nimport createRef from \"../maplibre/create-ref.js\";\nimport useIsomorphicLayoutEffect from \"../utils/use-isomorphic-layout-effect.js\";\nimport setGlobals from \"../utils/set-globals.js\";\nexport const MapContext = React.createContext(null);\nfunction _Map(props, ref) {\n const mountedMapsContext = useContext(MountedMapsContext);\n const [mapInstance, setMapInstance] = useState(null);\n const containerRef = useRef();\n const { current: contextValue } = useRef({ mapLib: null, map: null });\n useEffect(() => {\n const mapLib = props.mapLib;\n let isMounted = true;\n let maplibre;\n Promise.resolve(mapLib || import('maplibre-gl'))\n .then((module) => {\n if (!isMounted) {\n return;\n }\n if (!module) {\n throw new Error('Invalid mapLib');\n }\n const mapboxgl = 'Map' in module ? module : module.default;\n if (!mapboxgl.Map) {\n throw new Error('Invalid mapLib');\n }\n setGlobals(mapboxgl, props);\n if (props.reuseMaps) {\n maplibre = Maplibre.reuse(props, containerRef.current);\n }\n if (!maplibre) {\n maplibre = new Maplibre(mapboxgl.Map, props, containerRef.current);\n }\n contextValue.map = createRef(maplibre);\n contextValue.mapLib = mapboxgl;\n setMapInstance(maplibre);\n mountedMapsContext?.onMapMount(contextValue.map, props.id);\n })\n .catch(error => {\n const { onError } = props;\n if (onError) {\n onError({\n type: 'error',\n target: null,\n originalEvent: null,\n error\n });\n }\n else {\n console.error(error); // eslint-disable-line\n }\n });\n return () => {\n isMounted = false;\n if (maplibre) {\n mountedMapsContext?.onMapUnmount(props.id);\n if (props.reuseMaps) {\n maplibre.recycle();\n }\n else {\n maplibre.destroy();\n }\n }\n };\n }, []);\n useIsomorphicLayoutEffect(() => {\n if (mapInstance) {\n mapInstance.setProps(props);\n }\n });\n useImperativeHandle(ref, () => contextValue.map, [mapInstance]);\n const style = useMemo(() => ({\n position: 'relative',\n width: '100%',\n height: '100%',\n ...props.style\n }), [props.style]);\n const CHILD_CONTAINER_STYLE = {\n height: '100%'\n };\n return (React.createElement(\"div\", { id: props.id, ref: containerRef, style: style }, mapInstance && (React.createElement(MapContext.Provider, { value: contextValue },\n React.createElement(\"div\", { \"mapboxgl-children\": \"\", style: CHILD_CONTAINER_STYLE }, props.children)))));\n}\nexport const Map = React.forwardRef(_Map);\n//# sourceMappingURL=map.js.map"],"names":[],"mappings":";;;;;;;;AAOY,MAAC,UAAU,GAAG,KAAK,CAAC,aAAa,CAAC,IAAI;AAClD,SAAS,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE;AAC1B,IAAI,MAAM,kBAAkB,GAAG,UAAU,CAAC,kBAAkB,CAAC;AAC7D,IAAI,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC;AACxD,IAAI,MAAM,YAAY,GAAG,MAAM,EAAE;AACjC,IAAI,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;AACzE,IAAI,SAAS,CAAC,MAAM;AACpB,QAAQ,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM;AACnC,QAAQ,IAAI,SAAS,GAAG,IAAI;AAC5B,QAAQ,IAAI,QAAQ;AACpB,QAAQ,OAAO,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO,aAAa,CAAC;AACvD,aAAa,IAAI,CAAC,CAAC,MAAM,KAAK;AAC9B,YAAY,IAAI,CAAC,SAAS,EAAE;AAC5B,gBAAgB;AAChB;AACA,YAAY,IAAI,CAAC,MAAM,EAAE;AACzB,gBAAgB,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC;AACjD;AACA,YAAY,MAAM,QAAQ,GAAG,KAAK,IAAI,MAAM,GAAG,MAAM,GAAG,MAA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|
+
import * as React from 'react';
|
2
|
+
import { memo, forwardRef, useContext, useRef, useMemo, useEffect, useImperativeHandle } from 'react';
|
3
|
+
import { createPortal } from 'react-dom';
|
4
|
+
import { applyReactStyle } from '../utils/apply-react-style.js';
|
5
|
+
import { MapContext } from './map.js';
|
6
|
+
import { arePointsEqual } from '../utils/deep-equal.js';
|
7
|
+
import { compareClassNames } from '../utils/compare-class-names.js';
|
8
|
+
|
9
|
+
/* global document */
|
10
|
+
/* eslint-disable complexity,max-statements */
|
11
|
+
memo(forwardRef((props, ref) => {
|
12
|
+
const { map, mapLib } = useContext(MapContext);
|
13
|
+
const thisRef = useRef({ props });
|
14
|
+
const marker = useMemo(() => {
|
15
|
+
let hasChildren = false;
|
16
|
+
React.Children.forEach(props.children, el => {
|
17
|
+
if (el) {
|
18
|
+
hasChildren = true;
|
19
|
+
}
|
20
|
+
});
|
21
|
+
const options = {
|
22
|
+
...props,
|
23
|
+
element: hasChildren ? document.createElement('div') : undefined
|
24
|
+
};
|
25
|
+
const mk = new mapLib.Marker(options);
|
26
|
+
mk.setLngLat([props.longitude, props.latitude]);
|
27
|
+
mk.getElement().addEventListener('click', (e) => {
|
28
|
+
thisRef.current.props.onClick?.({
|
29
|
+
type: 'click',
|
30
|
+
target: mk,
|
31
|
+
originalEvent: e
|
32
|
+
});
|
33
|
+
});
|
34
|
+
mk.on('dragstart', e => {
|
35
|
+
const evt = e;
|
36
|
+
evt.lngLat = marker.getLngLat();
|
37
|
+
thisRef.current.props.onDragStart?.(evt);
|
38
|
+
});
|
39
|
+
mk.on('drag', e => {
|
40
|
+
const evt = e;
|
41
|
+
evt.lngLat = marker.getLngLat();
|
42
|
+
thisRef.current.props.onDrag?.(evt);
|
43
|
+
});
|
44
|
+
mk.on('dragend', e => {
|
45
|
+
const evt = e;
|
46
|
+
evt.lngLat = marker.getLngLat();
|
47
|
+
thisRef.current.props.onDragEnd?.(evt);
|
48
|
+
});
|
49
|
+
return mk;
|
50
|
+
}, []);
|
51
|
+
useEffect(() => {
|
52
|
+
marker.addTo(map.getMap());
|
53
|
+
return () => {
|
54
|
+
marker.remove();
|
55
|
+
};
|
56
|
+
}, []);
|
57
|
+
const { longitude, latitude, offset, style, draggable = false, popup = null, rotation = 0, rotationAlignment = 'auto', pitchAlignment = 'auto' } = props;
|
58
|
+
useEffect(() => {
|
59
|
+
applyReactStyle(marker.getElement(), style);
|
60
|
+
}, [style]);
|
61
|
+
useImperativeHandle(ref, () => marker, []);
|
62
|
+
const oldProps = thisRef.current.props;
|
63
|
+
if (marker.getLngLat().lng !== longitude || marker.getLngLat().lat !== latitude) {
|
64
|
+
marker.setLngLat([longitude, latitude]);
|
65
|
+
}
|
66
|
+
if (offset && !arePointsEqual(marker.getOffset(), offset)) {
|
67
|
+
marker.setOffset(offset);
|
68
|
+
}
|
69
|
+
if (marker.isDraggable() !== draggable) {
|
70
|
+
marker.setDraggable(draggable);
|
71
|
+
}
|
72
|
+
if (marker.getRotation() !== rotation) {
|
73
|
+
marker.setRotation(rotation);
|
74
|
+
}
|
75
|
+
if (marker.getRotationAlignment() !== rotationAlignment) {
|
76
|
+
marker.setRotationAlignment(rotationAlignment);
|
77
|
+
}
|
78
|
+
if (marker.getPitchAlignment() !== pitchAlignment) {
|
79
|
+
marker.setPitchAlignment(pitchAlignment);
|
80
|
+
}
|
81
|
+
if (marker.getPopup() !== popup) {
|
82
|
+
marker.setPopup(popup);
|
83
|
+
}
|
84
|
+
const classNameDiff = compareClassNames(oldProps.className, props.className);
|
85
|
+
if (classNameDiff) {
|
86
|
+
for (const c of classNameDiff) {
|
87
|
+
marker.toggleClassName(c);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
thisRef.current.props = props;
|
91
|
+
return createPortal(props.children, marker.getElement());
|
92
|
+
}));
|
93
|
+
//# sourceMappingURL=marker.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"marker.js","sources":["../../../../../../../../node_modules/@vis.gl/react-maplibre/dist/components/marker.js"],"sourcesContent":["/* global document */\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { useImperativeHandle, useEffect, useMemo, useRef, useContext, forwardRef, memo } from 'react';\nimport { applyReactStyle } from \"../utils/apply-react-style.js\";\nimport { MapContext } from \"./map.js\";\nimport { arePointsEqual } from \"../utils/deep-equal.js\";\nimport { compareClassNames } from \"../utils/compare-class-names.js\";\n/* eslint-disable complexity,max-statements */\nexport const Marker = memo(forwardRef((props, ref) => {\n const { map, mapLib } = useContext(MapContext);\n const thisRef = useRef({ props });\n const marker = useMemo(() => {\n let hasChildren = false;\n React.Children.forEach(props.children, el => {\n if (el) {\n hasChildren = true;\n }\n });\n const options = {\n ...props,\n element: hasChildren ? document.createElement('div') : undefined\n };\n const mk = new mapLib.Marker(options);\n mk.setLngLat([props.longitude, props.latitude]);\n mk.getElement().addEventListener('click', (e) => {\n thisRef.current.props.onClick?.({\n type: 'click',\n target: mk,\n originalEvent: e\n });\n });\n mk.on('dragstart', e => {\n const evt = e;\n evt.lngLat = marker.getLngLat();\n thisRef.current.props.onDragStart?.(evt);\n });\n mk.on('drag', e => {\n const evt = e;\n evt.lngLat = marker.getLngLat();\n thisRef.current.props.onDrag?.(evt);\n });\n mk.on('dragend', e => {\n const evt = e;\n evt.lngLat = marker.getLngLat();\n thisRef.current.props.onDragEnd?.(evt);\n });\n return mk;\n }, []);\n useEffect(() => {\n marker.addTo(map.getMap());\n return () => {\n marker.remove();\n };\n }, []);\n const { longitude, latitude, offset, style, draggable = false, popup = null, rotation = 0, rotationAlignment = 'auto', pitchAlignment = 'auto' } = props;\n useEffect(() => {\n applyReactStyle(marker.getElement(), style);\n }, [style]);\n useImperativeHandle(ref, () => marker, []);\n const oldProps = thisRef.current.props;\n if (marker.getLngLat().lng !== longitude || marker.getLngLat().lat !== latitude) {\n marker.setLngLat([longitude, latitude]);\n }\n if (offset && !arePointsEqual(marker.getOffset(), offset)) {\n marker.setOffset(offset);\n }\n if (marker.isDraggable() !== draggable) {\n marker.setDraggable(draggable);\n }\n if (marker.getRotation() !== rotation) {\n marker.setRotation(rotation);\n }\n if (marker.getRotationAlignment() !== rotationAlignment) {\n marker.setRotationAlignment(rotationAlignment);\n }\n if (marker.getPitchAlignment() !== pitchAlignment) {\n marker.setPitchAlignment(pitchAlignment);\n }\n if (marker.getPopup() !== popup) {\n marker.setPopup(popup);\n }\n const classNameDiff = compareClassNames(oldProps.className, props.className);\n if (classNameDiff) {\n for (const c of classNameDiff) {\n marker.toggleClassName(c);\n }\n }\n thisRef.current.props = props;\n return createPortal(props.children, marker.getElement());\n}));\n//# sourceMappingURL=marker.js.map"],"names":[],"mappings":";;;;;;;;AAAA;AAQA;AACsB,IAAI,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AACtD,IAAI,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,UAAU,CAAC;AAClD,IAAI,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;AACrC,IAAI,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM;AACjC,QAAQ,IAAI,WAAW,GAAG,KAAK;AAC/B,QAAQ,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,IAAI;AACrD,YAAY,IAAI,EAAE,EAAE;AACpB,gBAAgB,WAAW,GAAG,IAAI;AAClC;AACA,SAAS,CAAC;AACV,QAAQ,MAAM,OAAO,GAAG;AACxB,YAAY,GAAG,KAAK;AACpB,YAAY,OAAO,EAAE,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG;AACnE,SAAS;AACT,QAAQ,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;AAC7C,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;AACvD,QAAQ,EAAE,CAAC,UAAU,EAAE,CAA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AC,iBAAiB,EAAE,KAAK,cAAc,EAAE;AACvD,QAAQ,MAAM,CAAC,iBAAiB,CAAC,cAAc,CAAC;AAChD;AACA,IAAI,IAAI,MAAM,CAAC,QAAQ,EAAE,KAAK,KAAK,EAAE;AACrC,QAAQ,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;AAC9B;AACA,IAAI,MAAM,aAAa,GAAG,iBAAiB,CAAC,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC;AAChF,IAAI,IAAI,aAAa,EAAE;AACvB,QAAQ,KAAK,MAAM,CAAC,IAAI,aAAa,EAAE;AACvC,YAAY,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC;AACrC;AACA;AACA,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK;AACjC,IAAI,OAAO,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC;AAC5D,CAAC,CAAC","x_google_ignoreList":[0]}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { memo, useEffect } from 'react';
|
2
|
+
import { applyReactStyle } from '../utils/apply-react-style.js';
|
3
|
+
import { useControl } from './use-control.js';
|
4
|
+
|
5
|
+
function _NavigationControl(props) {
|
6
|
+
const ctrl = useControl(({ mapLib }) => new mapLib.NavigationControl(props), {
|
7
|
+
position: props.position
|
8
|
+
});
|
9
|
+
useEffect(() => {
|
10
|
+
applyReactStyle(ctrl._container, props.style);
|
11
|
+
}, [props.style]);
|
12
|
+
return null;
|
13
|
+
}
|
14
|
+
const NavigationControl = memo(_NavigationControl);
|
15
|
+
|
16
|
+
export { NavigationControl };
|
17
|
+
//# sourceMappingURL=navigation-control.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"navigation-control.js","sources":["../../../../../../../../node_modules/@vis.gl/react-maplibre/dist/components/navigation-control.js"],"sourcesContent":["import { useEffect, memo } from 'react';\nimport { applyReactStyle } from \"../utils/apply-react-style.js\";\nimport { useControl } from \"./use-control.js\";\nfunction _NavigationControl(props) {\n const ctrl = useControl(({ mapLib }) => new mapLib.NavigationControl(props), {\n position: props.position\n });\n useEffect(() => {\n applyReactStyle(ctrl._container, props.style);\n }, [props.style]);\n return null;\n}\nexport const NavigationControl = memo(_NavigationControl);\n//# sourceMappingURL=navigation-control.js.map"],"names":[],"mappings":";;;;AAGA,SAAS,kBAAkB,CAAC,KAAK,EAAE;AACnC,IAAI,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE;AACjF,QAAQ,QAAQ,EAAE,KAAK,CAAC;AACxB,KAAK,CAAC;AACN,IAAI,SAAS,CAAC,MAAM;AACpB,QAAQ,eAAe,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC;AACrD,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACrB,IAAI,OAAO,IAAI;AACf;AACY,MAAC,iBAAiB,GAAG,IAAI,CAAC,kBAAkB;;;;","x_google_ignoreList":[0]}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import { createPortal } from 'react-dom';
|
2
|
+
import { memo, forwardRef, useContext, useMemo, useRef, useEffect, useImperativeHandle } from 'react';
|
3
|
+
import { applyReactStyle } from '../utils/apply-react-style.js';
|
4
|
+
import { MapContext } from './map.js';
|
5
|
+
import { deepEqual } from '../utils/deep-equal.js';
|
6
|
+
import { compareClassNames } from '../utils/compare-class-names.js';
|
7
|
+
|
8
|
+
/* eslint-disable complexity,max-statements */
|
9
|
+
memo(forwardRef((props, ref) => {
|
10
|
+
const { map, mapLib } = useContext(MapContext);
|
11
|
+
const container = useMemo(() => {
|
12
|
+
return document.createElement('div');
|
13
|
+
}, []);
|
14
|
+
const thisRef = useRef({ props });
|
15
|
+
const popup = useMemo(() => {
|
16
|
+
const options = { ...props };
|
17
|
+
const pp = new mapLib.Popup(options);
|
18
|
+
pp.setLngLat([props.longitude, props.latitude]);
|
19
|
+
pp.once('open', e => {
|
20
|
+
thisRef.current.props.onOpen?.(e);
|
21
|
+
});
|
22
|
+
return pp;
|
23
|
+
}, []);
|
24
|
+
useEffect(() => {
|
25
|
+
const onClose = e => {
|
26
|
+
thisRef.current.props.onClose?.(e);
|
27
|
+
};
|
28
|
+
popup.on('close', onClose);
|
29
|
+
popup.setDOMContent(container).addTo(map.getMap());
|
30
|
+
return () => {
|
31
|
+
// https://github.com/visgl/react-map-gl/issues/1825
|
32
|
+
// onClose should not be fired if the popup is removed by unmounting
|
33
|
+
// When using React strict mode, the component is mounted twice.
|
34
|
+
// Firing the onClose callback here would be a false signal to remove the component.
|
35
|
+
popup.off('close', onClose);
|
36
|
+
if (popup.isOpen()) {
|
37
|
+
popup.remove();
|
38
|
+
}
|
39
|
+
};
|
40
|
+
}, []);
|
41
|
+
useEffect(() => {
|
42
|
+
applyReactStyle(popup.getElement(), props.style);
|
43
|
+
}, [props.style]);
|
44
|
+
useImperativeHandle(ref, () => popup, []);
|
45
|
+
if (popup.isOpen()) {
|
46
|
+
const oldProps = thisRef.current.props;
|
47
|
+
if (popup.getLngLat().lng !== props.longitude || popup.getLngLat().lat !== props.latitude) {
|
48
|
+
popup.setLngLat([props.longitude, props.latitude]);
|
49
|
+
}
|
50
|
+
if (props.offset && !deepEqual(oldProps.offset, props.offset)) {
|
51
|
+
popup.setOffset(props.offset);
|
52
|
+
}
|
53
|
+
if (oldProps.anchor !== props.anchor || oldProps.maxWidth !== props.maxWidth) {
|
54
|
+
popup.options.anchor = props.anchor;
|
55
|
+
popup.setMaxWidth(props.maxWidth);
|
56
|
+
}
|
57
|
+
const classNameDiff = compareClassNames(oldProps.className, props.className);
|
58
|
+
if (classNameDiff) {
|
59
|
+
for (const c of classNameDiff) {
|
60
|
+
popup.toggleClassName(c);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
thisRef.current.props = props;
|
64
|
+
}
|
65
|
+
return createPortal(props.children, container);
|
66
|
+
}));
|
67
|
+
//# sourceMappingURL=popup.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"popup.js","sources":["../../../../../../../../node_modules/@vis.gl/react-maplibre/dist/components/popup.js"],"sourcesContent":["import { createPortal } from 'react-dom';\nimport { useImperativeHandle, useEffect, useMemo, useRef, useContext, forwardRef, memo } from 'react';\nimport { applyReactStyle } from \"../utils/apply-react-style.js\";\nimport { MapContext } from \"./map.js\";\nimport { deepEqual } from \"../utils/deep-equal.js\";\nimport { compareClassNames } from \"../utils/compare-class-names.js\";\n/* eslint-disable complexity,max-statements */\nexport const Popup = memo(forwardRef((props, ref) => {\n const { map, mapLib } = useContext(MapContext);\n const container = useMemo(() => {\n return document.createElement('div');\n }, []);\n const thisRef = useRef({ props });\n const popup = useMemo(() => {\n const options = { ...props };\n const pp = new mapLib.Popup(options);\n pp.setLngLat([props.longitude, props.latitude]);\n pp.once('open', e => {\n thisRef.current.props.onOpen?.(e);\n });\n return pp;\n }, []);\n useEffect(() => {\n const onClose = e => {\n thisRef.current.props.onClose?.(e);\n };\n popup.on('close', onClose);\n popup.setDOMContent(container).addTo(map.getMap());\n return () => {\n // https://github.com/visgl/react-map-gl/issues/1825\n // onClose should not be fired if the popup is removed by unmounting\n // When using React strict mode, the component is mounted twice.\n // Firing the onClose callback here would be a false signal to remove the component.\n popup.off('close', onClose);\n if (popup.isOpen()) {\n popup.remove();\n }\n };\n }, []);\n useEffect(() => {\n applyReactStyle(popup.getElement(), props.style);\n }, [props.style]);\n useImperativeHandle(ref, () => popup, []);\n if (popup.isOpen()) {\n const oldProps = thisRef.current.props;\n if (popup.getLngLat().lng !== props.longitude || popup.getLngLat().lat !== props.latitude) {\n popup.setLngLat([props.longitude, props.latitude]);\n }\n if (props.offset && !deepEqual(oldProps.offset, props.offset)) {\n popup.setOffset(props.offset);\n }\n if (oldProps.anchor !== props.anchor || oldProps.maxWidth !== props.maxWidth) {\n popup.options.anchor = props.anchor;\n popup.setMaxWidth(props.maxWidth);\n }\n const classNameDiff = compareClassNames(oldProps.className, props.className);\n if (classNameDiff) {\n for (const c of classNameDiff) {\n popup.toggleClassName(c);\n }\n }\n thisRef.current.props = props;\n }\n return createPortal(props.children, container);\n}));\n//# sourceMappingURL=popup.js.map"],"names":[],"mappings":";;;;;;;AAMA;AACqB,IAAI,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AACrD,IAAI,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,UAAU,CAAC;AAClD,IAAI,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM;AACpC,QAAQ,OAAO,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC;AAC5C,KAAK,EAAE,EAAE,CAAC;AACV,IAAI,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;AACrC,IAAI,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM;AAChC,QAAQ,MAAM,OAAO,GAAG,EAAE,GAAG,KAAK,EAAE;AACpC,QAAQ,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;AAC5C,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;AACvD,QAAQ,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI;AAC7B,YAAY,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AAC7C,SAAS,CAAC;AACV,QAAQ,OAAO,EAAE;AACjB,KAAK,EAAE,EAAE,CAAC;AACV,IAAI,SAAS,CAAC,MAAM;AACpB,QAAQ,MAAM,OAAO,GAAG,CAAC,IAAI;AAC7B,YAAY,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;AAC9C,SAAS;AACT,QAAQ,KAAK,CAAC,EAAE,CAAC,OAAO,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KAAK,CAAC,QAAQ,EAAE;AACtF,YAAY,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM;AAC/C,YAAY,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC;AAC7C;AACA,QAAQ,MAAM,aAAa,GAAG,iBAAiB,CAAC,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC;AACpF,QAAQ,IAAI,aAAa,EAAE;AAC3B,YAAY,KAAK,MAAM,CAAC,IAAI,aAAa,EAAE;AAC3C,gBAAgB,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;AACxC;AACA;AACA,QAAQ,OAAO,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK;AACrC;AACA,IAAI,OAAO,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC;AAClD,CAAC,CAAC","x_google_ignoreList":[0]}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { memo, useRef, useEffect } from 'react';
|
2
|
+
import { applyReactStyle } from '../utils/apply-react-style.js';
|
3
|
+
import { useControl } from './use-control.js';
|
4
|
+
|
5
|
+
function _ScaleControl(props) {
|
6
|
+
const ctrl = useControl(({ mapLib }) => new mapLib.ScaleControl(props), {
|
7
|
+
position: props.position
|
8
|
+
});
|
9
|
+
const propsRef = useRef(props);
|
10
|
+
const prevProps = propsRef.current;
|
11
|
+
propsRef.current = props;
|
12
|
+
const { style } = props;
|
13
|
+
if (props.maxWidth !== undefined && props.maxWidth !== prevProps.maxWidth) {
|
14
|
+
ctrl.options.maxWidth = props.maxWidth;
|
15
|
+
}
|
16
|
+
if (props.unit !== undefined && props.unit !== prevProps.unit) {
|
17
|
+
ctrl.setUnit(props.unit);
|
18
|
+
}
|
19
|
+
useEffect(() => {
|
20
|
+
applyReactStyle(ctrl._container, style);
|
21
|
+
}, [style]);
|
22
|
+
return null;
|
23
|
+
}
|
24
|
+
const ScaleControl = memo(_ScaleControl);
|
25
|
+
|
26
|
+
export { ScaleControl };
|
27
|
+
//# sourceMappingURL=scale-control.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"scale-control.js","sources":["../../../../../../../../node_modules/@vis.gl/react-maplibre/dist/components/scale-control.js"],"sourcesContent":["import { useEffect, useRef, memo } from 'react';\nimport { applyReactStyle } from \"../utils/apply-react-style.js\";\nimport { useControl } from \"./use-control.js\";\nfunction _ScaleControl(props) {\n const ctrl = useControl(({ mapLib }) => new mapLib.ScaleControl(props), {\n position: props.position\n });\n const propsRef = useRef(props);\n const prevProps = propsRef.current;\n propsRef.current = props;\n const { style } = props;\n if (props.maxWidth !== undefined && props.maxWidth !== prevProps.maxWidth) {\n ctrl.options.maxWidth = props.maxWidth;\n }\n if (props.unit !== undefined && props.unit !== prevProps.unit) {\n ctrl.setUnit(props.unit);\n }\n useEffect(() => {\n applyReactStyle(ctrl._container, style);\n }, [style]);\n return null;\n}\nexport const ScaleControl = memo(_ScaleControl);\n//# sourceMappingURL=scale-control.js.map"],"names":[],"mappings":";;;;AAGA,SAAS,aAAa,CAAC,KAAK,EAAE;AAC9B,IAAI,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;AAC5E,QAAQ,QAAQ,EAAE,KAAK,CAAC;AACxB,KAAK,CAAC;AACN,IAAI,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC;AAClC,IAAI,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO;AACtC,IAAI,QAAQ,CAAC,OAAO,GAAG,KAAK;AAC5B,IAAI,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK;AAC3B,IAAI,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,QAAQ,EAAE;AAC/E,QAAQ,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ;AAC9C;AACA,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,EAAE;AACnE,QAAQ,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;AAChC;AACA,IAAI,SAAS,CAAC,MAAM;AACpB,QAAQ,eAAe,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC;AAC/C,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;AACf,IAAI,OAAO,IAAI;AACf;AACY,MAAC,YAAY,GAAG,IAAI,CAAC,aAAa;;;;","x_google_ignoreList":[0]}
|