@rio-cloud/rio-uikit 2.3.0 → 2.4.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.
- package/MapPreviousViewportButton.d.ts +2 -0
- package/MapPreviousViewportButton.js +5 -0
- package/MapPreviousViewportButton.js.map +1 -0
- package/Table.js +15 -14
- package/TableNext.js +15 -14
- package/components/map/components/Map.js +175 -157
- package/components/map/components/Map.js.map +1 -1
- package/components/map/components/MapContext.d.ts +2 -0
- package/components/map/components/MapContext.js +8 -6
- package/components/map/components/MapContext.js.map +1 -1
- package/components/map/components/MapPosition.d.ts +1 -1
- package/components/map/components/MapPosition.js +20 -13
- package/components/map/components/MapPosition.js.map +1 -1
- package/components/map/components/features/MapZoom.d.ts +0 -1
- package/components/map/components/features/MapZoom.js +12 -20
- package/components/map/components/features/MapZoom.js.map +1 -1
- package/components/map/components/features/settings/MapSettingsTile.d.ts +27 -0
- package/components/map/components/features/settings/MapSettingsTile.js +17 -17
- package/components/map/components/features/settings/MapSettingsTile.js.map +1 -1
- package/components/map/components/features/settings/buttons/MapPreviousViewportButton.d.ts +10 -0
- package/components/map/components/features/settings/buttons/MapPreviousViewportButton.js +23 -0
- package/components/map/components/features/settings/buttons/MapPreviousViewportButton.js.map +1 -0
- package/components/map/hooks/useMapViewportHistory.d.ts +19 -0
- package/components/map/hooks/useMapViewportHistory.js +116 -0
- package/components/map/hooks/useMapViewportHistory.js.map +1 -0
- package/components/map/icons/MapIcon.d.ts +1 -0
- package/components/map/icons/MapIcon.js +46 -37
- package/components/map/icons/MapIcon.js.map +1 -1
- package/components/map/utils/mapTypes.d.ts +6 -0
- package/components/map/utils/mapTypes.js.map +1 -1
- package/components/selects/Multiselect.d.ts +6 -0
- package/components/selects/Multiselect.js +85 -83
- package/components/selects/Multiselect.js.map +1 -1
- package/components/selects/Select.d.ts +6 -0
- package/components/selects/Select.js +79 -71
- package/components/selects/Select.js.map +1 -1
- package/components/table/Table.d.ts +2 -0
- package/components/table/Table.js +162 -158
- package/components/table/Table.js.map +1 -1
- package/components/table/Table.types.d.ts +6 -0
- package/components/table/TableExpandAllGroupsButton.d.ts +25 -0
- package/components/table/TableExpandAllGroupsButton.js +27 -0
- package/components/table/TableExpandAllGroupsButton.js.map +1 -0
- package/components/table/TableExpandedRow.js +77 -63
- package/components/table/TableExpandedRow.js.map +1 -1
- package/components/table/TableExpanderButton.js +11 -11
- package/components/table/TableExpanderButton.js.map +1 -1
- package/components/table/TableGroupRow.d.ts +13 -1
- package/components/table/TableGroupRow.js +57 -23
- package/components/table/TableGroupRow.js.map +1 -1
- package/components/table/TableHeader.js +40 -39
- package/components/table/TableHeader.js.map +1 -1
- package/components/table/TableRow.js +66 -52
- package/components/table/TableRow.js.map +1 -1
- package/components/table/context/TableRenderConfigContext.d.ts +2 -1
- package/components/table/context/TableRenderConfigContext.js.map +1 -1
- package/components/table/render/header/TableHeaderCellContent.js +4 -4
- package/components/table/render/header/TableHeaderCellContent.js.map +1 -1
- package/components/table/render/header/TableHeaderSelectionCell.d.ts +2 -0
- package/components/table/render/header/TableHeaderSelectionCell.js +22 -12
- package/components/table/render/header/TableHeaderSelectionCell.js.map +1 -1
- package/components/table/runtime/useRenderDraftState.js +1 -0
- package/components/table/runtime/useRenderDraftState.js.map +1 -1
- package/components/table/selection/useInternalTableSelectionState.js +12 -10
- package/components/table/selection/useInternalTableSelectionState.js.map +1 -1
- package/package.json +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Map.js","sources":["../../../../src/components/map/components/Map.tsx"],"sourcesContent":["import { useRef, useState, useEffect, type CSSProperties } from 'react';\nimport { isEmpty } from 'es-toolkit/compat';\nimport { isEqual } from 'es-toolkit/predicate';\n\nimport {\n MAP_TYPE_DEFAULT,\n MAP_TYPE_FLEET_STYLE,\n MAP_TYPE_SATELLITE,\n MAP_TYPE_TERRAIN,\n MAP_TYPE_NIGHT,\n MAP_LAYER_INCIDENTS,\n MAP_LAYER_TRAFFIC,\n MAP_LAYER_ROAD_RESTRICTIONS,\n DEFAULT_MIN_ZOOM,\n DEFAULT_MAX_ZOOM,\n DEFAULT_PIXEL_RATIO,\n} from './constants';\n\nimport { addEventListenerMap, removeEventListenerMap } from '../utils/eventHandling';\nimport { MapContext } from './MapContext';\nimport { createUtils, getMapBounds } from '../utils/mapUtils';\nimport { getHereUi } from '../utils/mapUi';\nimport useDarkMode from '../../../hooks/useDarkMode';\nimport MapZoom from './features/MapZoom';\nimport MapOverlayLayers from './features/layers/MapOverlayLayers';\nimport MapSize from './MapSize';\nimport MapPosition from './MapPosition';\nimport MapElements from './MapElements';\nimport type { MapApi, MapLayer, MapProps, MapType } from '../utils/mapTypes';\nimport { getPlatform, getEngineType, getBaseLayer } from '../utils/rendering';\n\nconst MARKER_POINTER_EVENTS_DISABLED_CLASS = 'map-disable-marker-pointer-events';\nconst MARKER_POINTER_EVENTS_RESET_DELAY_MS = 140;\n\nconst Map = (props: MapProps) => {\n const {\n children,\n credentials,\n width,\n height,\n language: lang = 'en',\n center,\n zoom,\n zoomAnimation = false,\n boundingBox,\n hideClusterSettings = false,\n hideMapLayerSettings = false,\n disableMapEvents,\n disableBehavior = false,\n disableZoomMomentum = true,\n enableFractionalZoom = false,\n eventListenerMap,\n mapType = MAP_TYPE_DEFAULT,\n mapLayer = [],\n showCluster: externalShowCluster = true,\n showScaleBar = false,\n onMapLayerChange = () => {},\n onMapTypeChange = () => {},\n onShowClusterChange = () => {},\n onZoomIn = () => {},\n onZoomOut = () => {},\n onIncidentsChange = () => {},\n mapSettingsTooltip,\n mapSettings,\n enableWebGL = true,\n enableDevicePixelRatio = true,\n enableMarkerIconCache = true,\n disableMarkerPointerEventsWhileZooming = false,\n pixelRatio = DEFAULT_PIXEL_RATIO,\n minZoom = DEFAULT_MIN_ZOOM,\n maxZoom = DEFAULT_MAX_ZOOM,\n } = props;\n\n let safeMaxZoom = maxZoom;\n\n if (minZoom > maxZoom) {\n // Avoid crashing the map for invalid zoom limits\n safeMaxZoom = DEFAULT_MAX_ZOOM;\n console.error('Invalid condition for zoom limits: min <= max)');\n }\n\n const mapRef = useRef<HTMLDivElement>(null);\n const markerPointerEventsResetTimeoutRef = useRef<number | undefined>();\n const markerPointerEventsDisabledRef = useRef(false);\n const disableMarkerPointerEventsWhileZoomingRef = useRef(disableMarkerPointerEventsWhileZooming);\n\n const [isMapInitialized, setMapInitialized] = useState(false);\n const [isZoomInteractionActive, setIsZoomInteractionActive] = useState(false);\n\n const [api, setApi] = useState<MapApi>();\n\n const [baseLayer, setBaseLayer] = useState<MapType>(mapType);\n const [activeLayers, setActiveLayers] = useState<MapLayer[]>(mapLayer);\n const [showCluster, setShowCluster] = useState(externalShowCluster);\n\n const devicePixelRatio = enableDevicePixelRatio ? window.devicePixelRatio || pixelRatio : pixelRatio;\n\n // Only short locale is supported by HERE Map\n const language = (locale => (locale === 'nb' ? 'no' : locale))(lang.split('-')[0].toLowerCase());\n\n const setMarkerPointerEventsDisabled = (disabled: boolean) => {\n if (disabled && !disableMarkerPointerEventsWhileZoomingRef.current) {\n return;\n }\n\n const mapElement = mapRef.current;\n\n if (!mapElement) {\n return;\n }\n\n mapElement.classList.toggle(MARKER_POINTER_EVENTS_DISABLED_CLASS, disabled);\n markerPointerEventsDisabledRef.current = disabled;\n };\n\n const clearMarkerPointerEventsResetTimeout = () => {\n if (markerPointerEventsResetTimeoutRef.current !== undefined) {\n window.clearTimeout(markerPointerEventsResetTimeoutRef.current);\n markerPointerEventsResetTimeoutRef.current = undefined;\n }\n };\n\n const scheduleMarkerPointerEventsEnable = () => {\n clearMarkerPointerEventsResetTimeout();\n markerPointerEventsResetTimeoutRef.current = window.setTimeout(() => {\n setMarkerPointerEventsDisabled(false);\n setIsZoomInteractionActive(false);\n markerPointerEventsResetTimeoutRef.current = undefined;\n }, MARKER_POINTER_EVENTS_RESET_DELAY_MS);\n };\n\n const temporarilyDisableMarkerPointerEvents = () => {\n setIsZoomInteractionActive(true);\n\n clearMarkerPointerEventsResetTimeout();\n\n if (disableMarkerPointerEventsWhileZoomingRef.current && !markerPointerEventsDisabledRef.current) {\n setMarkerPointerEventsDisabled(true);\n }\n };\n\n useEffect(() => {\n disableMarkerPointerEventsWhileZoomingRef.current = disableMarkerPointerEventsWhileZooming;\n }, [disableMarkerPointerEventsWhileZooming]);\n\n useEffect(() => {\n const mapElement = mapRef.current;\n\n if (!mapElement) {\n return;\n }\n\n const handleWheel = () => {\n temporarilyDisableMarkerPointerEvents();\n scheduleMarkerPointerEventsEnable();\n };\n\n mapElement.addEventListener('wheel', handleWheel, { passive: true, capture: true });\n\n return () => {\n mapElement.removeEventListener('wheel', handleWheel, { capture: true });\n };\n }, []);\n\n useEffect(() => {\n let allMapObjects: H.map.Object[] = [];\n let removeMapViewChangeListeners = () => {};\n\n if (api?.map) {\n allMapObjects = api.map.getObjects();\n console.debug('re-initialize here map');\n } else {\n console.debug('initialize here map');\n }\n\n if (api?.map) {\n // Cleanup any previously initialized map before doing anything else\n console.debug('disposing previous map');\n removeEventListenerMap(api.map);\n\n if (api.mapEvents) {\n api.mapEvents.dispose();\n }\n\n api.map.dispose();\n }\n\n const bounds = boundingBox && getMapBounds(boundingBox);\n\n // Initialize communication with the platform\n const platform = getPlatform(credentials);\n\n // Specify engine type. In this example, we use HARP rendering engine, which is capable\n // of rendering vector data using the style configuration exported from the HERE Style Editor.\n // HARP engine is not the default engine, and it's not included in the mapsjs-core.js module.\n // To use this engine, you need to include mapsjs-harp.js file to your HTML page\n const engineType = getEngineType(baseLayer, enableWebGL);\n\n // Obtain the default map types from the platform object\n // @ts-expect-error-next-line: according to the Here docs, the engine type exists\n // see https://www.here.com/docs/bundle/maps-api-for-javascript-developer-guide/page/topics/harp-migrate.html\n const defaultLayers = platform.createDefaultLayers({ engineType, lg: language, pois: true });\n\n getBaseLayer({\n baseLayerName: baseLayer,\n defaultLayers,\n enableWebGL,\n platform,\n engineType,\n vehicleRestrictions: activeLayers.includes(MAP_LAYER_ROAD_RESTRICTIONS),\n language,\n minZoom,\n maxZoom: safeMaxZoom,\n }).then(defaultLayerMap => {\n const handleMapViewChangeStart = () => {\n temporarilyDisableMarkerPointerEvents();\n };\n\n const handleMapViewChangeEnd = () => {\n scheduleMarkerPointerEventsEnable();\n };\n\n // Initialize the map\n const hereMap = new H.Map(mapRef.current as Element, defaultLayerMap.baseLayer, {\n zoom,\n center,\n bounds,\n engineType,\n pixelRatio: devicePixelRatio,\n fixedCenter: true,\n });\n\n if (defaultLayerMap.overlayLayer) {\n // Special case for satellite map where we render street labels and road signs as well as additional pois as vector data\n // hereMap.setBaseLayer(defaultLayerMap.baseLayer);\n hereMap.addLayer(defaultLayerMap.overlayLayer);\n }\n\n setMapInitialized(true);\n\n let hereMapEvents: H.mapevents.MapEvents | false = false;\n let hereBehavior: H.mapevents.Behavior | undefined;\n\n if (!disableMapEvents) {\n // Enable the map event system\n hereMapEvents = new H.mapevents.MapEvents(hereMap);\n }\n\n if (!(disableMapEvents || disableBehavior)) {\n hereBehavior = new H.mapevents.Behavior(hereMapEvents as H.mapevents.MapEvents);\n if (!enableFractionalZoom) {\n // Fractional zoom feels less predictable with mouse wheels in some setups,\n // but keeping it enabled can noticeably improve trackpad zoom smoothness.\n // @ts-expect-error-next-line\n hereBehavior.disable(H.mapevents.Behavior.Feature.FRACTIONAL_ZOOM);\n }\n\n if (disableZoomMomentum) {\n // Disable the inertia that occurs on WebGL maps when scrolling/zooming.\n // This resulted in a very high scroll sensitivity.\n // @ts-expect-error-next-line\n hereBehavior.disable(H.mapevents.Behavior.Feature.ZOOM_MOMENTUM);\n }\n }\n\n addEventListenerMap(hereMap, eventListenerMap, hereMap);\n hereMap.addEventListener('mapviewchangestart', handleMapViewChangeStart as EventListener);\n hereMap.addEventListener('mapviewchangeend', handleMapViewChangeEnd as EventListener);\n\n const hereUi = getHereUi(hereMap, defaultLayers, showScaleBar, language);\n\n // The api will be passed to services when using a render function.\n // This allows the service to access the map internals\n setApi({\n credentials,\n defaultLayers,\n map: hereMap,\n mapEvents: hereMapEvents,\n behavior: hereBehavior,\n platform,\n ui: hereUi,\n utils: createUtils(hereMap),\n // Put settings back into the map API object so the invoking service\n // can check on these settings for instance inside a test\n settings: {\n enableWebGL,\n baseLayer,\n activeLayers,\n showCluster,\n minZoom,\n maxZoom: safeMaxZoom,\n },\n });\n\n if (allMapObjects) {\n // If the base layer changed, re-add all previous objects again,\n // otherwise the map would be empty\n hereMap.addObjects(allMapObjects);\n }\n\n removeMapViewChangeListeners = () => {\n hereMap.removeEventListener('mapviewchangestart', handleMapViewChangeStart as EventListener);\n hereMap.removeEventListener('mapviewchangeend', handleMapViewChangeEnd as EventListener);\n };\n });\n\n return () => {\n removeMapViewChangeListeners();\n clearMarkerPointerEventsResetTimeout();\n setMarkerPointerEventsDisabled(false);\n setIsZoomInteractionActive(false);\n };\n }, [\n enableWebGL,\n enableDevicePixelRatio,\n language,\n baseLayer,\n minZoom,\n maxZoom,\n disableZoomMomentum,\n enableFractionalZoom,\n ]);\n\n useEffect(() => {\n if (!disableMarkerPointerEventsWhileZooming) {\n clearMarkerPointerEventsResetTimeout();\n setMarkerPointerEventsDisabled(false);\n }\n\n return () => {\n clearMarkerPointerEventsResetTimeout();\n setMarkerPointerEventsDisabled(false);\n setIsZoomInteractionActive(false);\n };\n }, [disableMarkerPointerEventsWhileZooming]);\n\n const isDarkMode = useDarkMode();\n useEffect(() => {\n // Toggle night map only if current map type is default\n if (isDarkMode && baseLayer === MAP_TYPE_DEFAULT) {\n handleMapTypeChange(MAP_TYPE_NIGHT);\n }\n // Toggle back to default map only if current map type is night\n else if (!isDarkMode && baseLayer === MAP_TYPE_NIGHT) {\n handleMapTypeChange(MAP_TYPE_DEFAULT);\n }\n }, [isDarkMode, language]);\n\n // Update MapType from outside\n useEffect(() => handleMapTypeChange(mapType), [mapType]);\n\n // Update MapLayer from outside\n const [previousMapLayer, setPreviousMapLayer] = useState(mapLayer);\n if (!isEqual(mapLayer, previousMapLayer)) {\n setActiveLayers(mapLayer);\n setPreviousMapLayer(mapLayer);\n }\n\n // Update Cluster setting from outside\n useEffect(() => setShowCluster(externalShowCluster), [externalShowCluster]);\n\n const handleMapTypeChange = (newMapType: MapType) => {\n setBaseLayer(newMapType);\n onMapTypeChange(newMapType, mapType);\n };\n\n const handleMapLayerChange = (layer: MapLayer) => {\n const removeLayer = (layerToRemove: string) => activeLayers.filter(item => item !== layerToRemove);\n const newActiveLayers = activeLayers.includes(layer) ? removeLayer(layer) : [...activeLayers, layer];\n setActiveLayers(newActiveLayers);\n onMapLayerChange(newActiveLayers, activeLayers);\n };\n\n const handleShowClusterChange = (newShowCluster: boolean) => {\n setShowCluster(newShowCluster);\n onShowClusterChange(newShowCluster);\n };\n\n // Note: For performance reasons, we deactivate pointer events and hence CSS style recalculation for the\n // the body. Having for instance many assets in the tree causes a performance loss when clicking on the map\n // to move it and zoom in/out since the map triggers a style invalidation and recalculation and\n // due to the nature of the AssetTree with it's hundreds DOM nodes, applying the CSS selectors\n // takes time.\n const handleMapInteractionStart = () => {\n document.querySelector('.AssetTree')?.classList.add('pointer-events-none');\n };\n const handleMapInteractionEnd = () => {\n document.querySelector('.AssetTree')?.classList.remove('pointer-events-none');\n };\n\n const style: CSSProperties = {};\n if (height) {\n style.height = height;\n }\n if (width) {\n style.width = width;\n }\n const autoHeightClass = isEmpty(style) ? 'height-100pct' : '';\n\n return (\n <div\n className={`Map position-relative map-type-${baseLayer.toLowerCase()} ${autoHeightClass}`}\n style={style}\n ref={mapRef}\n onTouchStart={handleMapInteractionStart}\n onTouchEnd={handleMapInteractionEnd}\n onMouseEnter={handleMapInteractionStart}\n onMouseOut={handleMapInteractionEnd}\n onBlur={handleMapInteractionEnd}\n >\n {isMapInitialized && api && (\n <MapContext.Provider\n value={{\n api,\n language,\n enableWebGL,\n enableMarkerIconCache,\n enableFractionalZoom,\n isZoomInteractionActive,\n showCluster,\n activeLayers,\n baseLayer,\n hideMapLayerSettings,\n hideClusterSettings,\n onMapTypeChange: handleMapTypeChange,\n onMapLayerChange: handleMapLayerChange,\n onShowClusterChange: handleShowClusterChange,\n mapSettingsTooltip,\n onIncidentsChange,\n devicePixelRatio,\n }}\n >\n <MapPosition api={api} boundingBox={boundingBox} center={center} zoomAnimation={zoomAnimation} />\n <MapSize api={api} />\n <MapZoom\n zoom={zoom}\n hideZoomButtons={disableBehavior}\n onZoomIn={onZoomIn}\n onZoomOut={onZoomOut}\n zoomAnimation={zoomAnimation}\n />\n {mapSettings && mapSettings}\n <MapOverlayLayers layers={activeLayers} />\n <MapElements api={api}>{children}</MapElements>\n </MapContext.Provider>\n )}\n </div>\n );\n};\n\nMap.TYPE_DEFAULT = MAP_TYPE_DEFAULT;\nMap.TYPE_FLEET_STYLE = MAP_TYPE_FLEET_STYLE;\nMap.TYPE_SATELLITE = MAP_TYPE_SATELLITE;\nMap.TYPE_TERRAIN = MAP_TYPE_TERRAIN;\nMap.TYPE_NIGHT = MAP_TYPE_NIGHT;\n\nMap.LAYER_INCIDENTS = MAP_LAYER_INCIDENTS;\nMap.LAYER_TRAFFIC = MAP_LAYER_TRAFFIC;\nMap.LAYER_ROAD_RESTRICTIONS = MAP_LAYER_ROAD_RESTRICTIONS;\n\nexport default Map;\n"],"names":["MARKER_POINTER_EVENTS_DISABLED_CLASS","MARKER_POINTER_EVENTS_RESET_DELAY_MS","Map","props","children","credentials","width","height","lang","center","zoom","zoomAnimation","boundingBox","hideClusterSettings","hideMapLayerSettings","disableMapEvents","disableBehavior","disableZoomMomentum","enableFractionalZoom","eventListenerMap","mapType","MAP_TYPE_DEFAULT","mapLayer","externalShowCluster","showScaleBar","onMapLayerChange","onMapTypeChange","onShowClusterChange","onZoomIn","onZoomOut","onIncidentsChange","mapSettingsTooltip","mapSettings","enableWebGL","enableDevicePixelRatio","enableMarkerIconCache","disableMarkerPointerEventsWhileZooming","pixelRatio","DEFAULT_PIXEL_RATIO","minZoom","DEFAULT_MIN_ZOOM","maxZoom","DEFAULT_MAX_ZOOM","safeMaxZoom","mapRef","useRef","markerPointerEventsResetTimeoutRef","markerPointerEventsDisabledRef","disableMarkerPointerEventsWhileZoomingRef","isMapInitialized","setMapInitialized","useState","isZoomInteractionActive","setIsZoomInteractionActive","api","setApi","baseLayer","setBaseLayer","activeLayers","setActiveLayers","showCluster","setShowCluster","devicePixelRatio","language","locale","setMarkerPointerEventsDisabled","disabled","mapElement","clearMarkerPointerEventsResetTimeout","scheduleMarkerPointerEventsEnable","temporarilyDisableMarkerPointerEvents","useEffect","handleWheel","allMapObjects","removeMapViewChangeListeners","removeEventListenerMap","bounds","getMapBounds","platform","getPlatform","engineType","getEngineType","defaultLayers","getBaseLayer","MAP_LAYER_ROAD_RESTRICTIONS","defaultLayerMap","handleMapViewChangeStart","handleMapViewChangeEnd","hereMap","hereMapEvents","hereBehavior","addEventListenerMap","hereUi","getHereUi","createUtils","isDarkMode","useDarkMode","handleMapTypeChange","MAP_TYPE_NIGHT","previousMapLayer","setPreviousMapLayer","isEqual","newMapType","handleMapLayerChange","layer","removeLayer","layerToRemove","item","newActiveLayers","handleShowClusterChange","newShowCluster","handleMapInteractionStart","handleMapInteractionEnd","style","autoHeightClass","isEmpty","jsx","jsxs","MapContext","MapPosition","MapSize","MapZoom","MapOverlayLayers","MapElements","MAP_TYPE_FLEET_STYLE","MAP_TYPE_SATELLITE","MAP_TYPE_TERRAIN","MAP_LAYER_INCIDENTS","MAP_LAYER_TRAFFIC"],"mappings":";;;;;;;;;;;;;;;;AA+BA,MAAMA,KAAuC,qCACvCC,KAAuC,KAEvCC,IAAM,CAACC,OAAoB;AAC7B,QAAM;AAAA,IACF,UAAAC;AAAA,IACA,aAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,UAAUC,KAAO;AAAA,IACjB,QAAAC;AAAA,IACA,MAAAC;AAAA,IACA,eAAAC,IAAgB;AAAA,IAChB,aAAAC;AAAA,IACA,qBAAAC,KAAsB;AAAA,IAC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IAAA,EAAY,KAAArE,GAAW,UAAAlD,GAAA,CAAS;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACrC;AAAA,EAAA;AAIhB;AAEAF,EAAI,eAAemB;AACnBnB,EAAI,mBAAmB0H;AACvB1H,EAAI,iBAAiB2H;AACrB3H,EAAI,eAAe4H;AACnB5H,EAAI,aAAagG;AAEjBhG,EAAI,kBAAkB6H;AACtB7H,EAAI,gBAAgB8H;AACpB9H,EAAI,0BAA0BkF;"}
|
|
1
|
+
{"version":3,"file":"Map.js","sources":["../../../../src/components/map/components/Map.tsx"],"sourcesContent":["import { useRef, useState, useEffect, useMemo, type CSSProperties } from 'react';\nimport { isEmpty } from 'es-toolkit/compat';\nimport { isEqual } from 'es-toolkit/predicate';\n\nimport {\n MAP_TYPE_DEFAULT,\n MAP_TYPE_FLEET_STYLE,\n MAP_TYPE_SATELLITE,\n MAP_TYPE_TERRAIN,\n MAP_TYPE_NIGHT,\n MAP_LAYER_INCIDENTS,\n MAP_LAYER_TRAFFIC,\n MAP_LAYER_ROAD_RESTRICTIONS,\n DEFAULT_MIN_ZOOM,\n DEFAULT_MAX_ZOOM,\n DEFAULT_PIXEL_RATIO,\n} from './constants';\n\nimport { addEventListenerMap, removeEventListenerMap } from '../utils/eventHandling';\nimport { MapContext } from './MapContext';\nimport { createUtils, getMapBounds } from '../utils/mapUtils';\nimport { getHereUi } from '../utils/mapUi';\nimport useDarkMode from '../../../hooks/useDarkMode';\nimport MapZoom from './features/MapZoom';\nimport MapOverlayLayers from './features/layers/MapOverlayLayers';\nimport MapSize from './MapSize';\nimport MapPosition from './MapPosition';\nimport MapElements from './MapElements';\nimport type { MapApi, MapLayer, MapProps, MapType } from '../utils/mapTypes';\nimport { getPlatform, getEngineType, getBaseLayer } from '../utils/rendering';\nimport { useMapViewportHistory } from '../hooks/useMapViewportHistory';\n\nconst MARKER_POINTER_EVENTS_DISABLED_CLASS = 'map-disable-marker-pointer-events';\nconst MARKER_POINTER_EVENTS_RESET_DELAY_MS = 140;\n\nconst Map = (props: MapProps) => {\n const {\n children,\n credentials,\n width,\n height,\n language: lang = 'en',\n center,\n zoom,\n zoomAnimation = false,\n boundingBox,\n hideClusterSettings = false,\n hideMapLayerSettings = false,\n disableMapEvents,\n disableBehavior = false,\n disableZoomMomentum = true,\n enableFractionalZoom = false,\n eventListenerMap,\n mapType = MAP_TYPE_DEFAULT,\n mapLayer = [],\n showCluster: externalShowCluster = true,\n showScaleBar = false,\n onMapLayerChange = () => {},\n onMapTypeChange = () => {},\n onShowClusterChange = () => {},\n onZoomIn = () => {},\n onZoomOut = () => {},\n onIncidentsChange = () => {},\n mapSettingsTooltip,\n mapSettings,\n maxViewportHistoryEntries,\n enableWebGL = true,\n enableDevicePixelRatio = true,\n enableMarkerIconCache = true,\n disableMarkerPointerEventsWhileZooming = false,\n pixelRatio = DEFAULT_PIXEL_RATIO,\n minZoom = DEFAULT_MIN_ZOOM,\n maxZoom = DEFAULT_MAX_ZOOM,\n } = props;\n\n let safeMaxZoom = maxZoom;\n\n if (minZoom > maxZoom) {\n // Avoid crashing the map for invalid zoom limits\n safeMaxZoom = DEFAULT_MAX_ZOOM;\n console.error('Invalid condition for zoom limits: min <= max)');\n }\n\n const mapRef = useRef<HTMLDivElement>(null);\n const markerPointerEventsResetTimeoutRef = useRef<number | undefined>();\n const markerPointerEventsDisabledRef = useRef(false);\n const disableMarkerPointerEventsWhileZoomingRef = useRef(disableMarkerPointerEventsWhileZooming);\n\n const [isMapInitialized, setMapInitialized] = useState(false);\n const [isZoomInteractionActive, setIsZoomInteractionActive] = useState(false);\n\n const [api, setApi] = useState<MapApi>();\n\n const [baseLayer, setBaseLayer] = useState<MapType>(mapType);\n const [activeLayers, setActiveLayers] = useState<MapLayer[]>(mapLayer);\n const [showCluster, setShowCluster] = useState(externalShowCluster);\n const controlledViewport = useMemo(\n () => (center && zoom !== undefined ? { center, zoom } : undefined),\n [center?.lat, center?.lng, zoom]\n );\n const viewportHistory = useMapViewportHistory(api, {\n maxEntries: maxViewportHistoryEntries,\n zoomAnimation,\n controlledViewport,\n });\n\n const devicePixelRatio = enableDevicePixelRatio ? window.devicePixelRatio || pixelRatio : pixelRatio;\n\n // Only short locale is supported by HERE Map\n const language = (locale => (locale === 'nb' ? 'no' : locale))(lang.split('-')[0].toLowerCase());\n\n const setMarkerPointerEventsDisabled = (disabled: boolean) => {\n if (disabled && !disableMarkerPointerEventsWhileZoomingRef.current) {\n return;\n }\n\n const mapElement = mapRef.current;\n\n if (!mapElement) {\n return;\n }\n\n mapElement.classList.toggle(MARKER_POINTER_EVENTS_DISABLED_CLASS, disabled);\n markerPointerEventsDisabledRef.current = disabled;\n };\n\n const clearMarkerPointerEventsResetTimeout = () => {\n if (markerPointerEventsResetTimeoutRef.current !== undefined) {\n window.clearTimeout(markerPointerEventsResetTimeoutRef.current);\n markerPointerEventsResetTimeoutRef.current = undefined;\n }\n };\n\n const scheduleMarkerPointerEventsEnable = () => {\n clearMarkerPointerEventsResetTimeout();\n markerPointerEventsResetTimeoutRef.current = window.setTimeout(() => {\n setMarkerPointerEventsDisabled(false);\n setIsZoomInteractionActive(false);\n markerPointerEventsResetTimeoutRef.current = undefined;\n }, MARKER_POINTER_EVENTS_RESET_DELAY_MS);\n };\n\n const temporarilyDisableMarkerPointerEvents = () => {\n setIsZoomInteractionActive(true);\n\n clearMarkerPointerEventsResetTimeout();\n\n if (disableMarkerPointerEventsWhileZoomingRef.current && !markerPointerEventsDisabledRef.current) {\n setMarkerPointerEventsDisabled(true);\n }\n };\n\n useEffect(() => {\n disableMarkerPointerEventsWhileZoomingRef.current = disableMarkerPointerEventsWhileZooming;\n }, [disableMarkerPointerEventsWhileZooming]);\n\n useEffect(() => {\n const mapElement = mapRef.current;\n\n if (!mapElement) {\n return;\n }\n\n const handleWheel = () => {\n temporarilyDisableMarkerPointerEvents();\n scheduleMarkerPointerEventsEnable();\n };\n\n mapElement.addEventListener('wheel', handleWheel, { passive: true, capture: true });\n\n return () => {\n mapElement.removeEventListener('wheel', handleWheel, { capture: true });\n };\n }, []);\n\n useEffect(() => {\n let allMapObjects: H.map.Object[] = [];\n let removeMapViewChangeListeners = () => {};\n\n if (api?.map) {\n allMapObjects = api.map.getObjects();\n console.debug('re-initialize here map');\n } else {\n console.debug('initialize here map');\n }\n\n if (api?.map) {\n // Cleanup any previously initialized map before doing anything else\n console.debug('disposing previous map');\n removeEventListenerMap(api.map);\n\n if (api.mapEvents) {\n api.mapEvents.dispose();\n }\n\n api.map.dispose();\n }\n\n const bounds = boundingBox && getMapBounds(boundingBox);\n\n // Initialize communication with the platform\n const platform = getPlatform(credentials);\n\n // Specify engine type. In this example, we use HARP rendering engine, which is capable\n // of rendering vector data using the style configuration exported from the HERE Style Editor.\n // HARP engine is not the default engine, and it's not included in the mapsjs-core.js module.\n // To use this engine, you need to include mapsjs-harp.js file to your HTML page\n const engineType = getEngineType(baseLayer, enableWebGL);\n\n // Obtain the default map types from the platform object\n // @ts-expect-error-next-line: according to the Here docs, the engine type exists\n // see https://www.here.com/docs/bundle/maps-api-for-javascript-developer-guide/page/topics/harp-migrate.html\n const defaultLayers = platform.createDefaultLayers({ engineType, lg: language, pois: true });\n\n getBaseLayer({\n baseLayerName: baseLayer,\n defaultLayers,\n enableWebGL,\n platform,\n engineType,\n vehicleRestrictions: activeLayers.includes(MAP_LAYER_ROAD_RESTRICTIONS),\n language,\n minZoom,\n maxZoom: safeMaxZoom,\n }).then(defaultLayerMap => {\n const handleMapViewChangeStart = () => {\n temporarilyDisableMarkerPointerEvents();\n };\n\n const handleMapViewChangeEnd = () => {\n scheduleMarkerPointerEventsEnable();\n };\n\n // Initialize the map\n const hereMap = new H.Map(mapRef.current as Element, defaultLayerMap.baseLayer, {\n zoom,\n center,\n bounds,\n engineType,\n pixelRatio: devicePixelRatio,\n fixedCenter: true,\n });\n\n if (defaultLayerMap.overlayLayer) {\n // Special case for satellite map where we render street labels and road signs as well as additional pois as vector data\n // hereMap.setBaseLayer(defaultLayerMap.baseLayer);\n hereMap.addLayer(defaultLayerMap.overlayLayer);\n }\n\n setMapInitialized(true);\n\n let hereMapEvents: H.mapevents.MapEvents | false = false;\n let hereBehavior: H.mapevents.Behavior | undefined;\n\n if (!disableMapEvents) {\n // Enable the map event system\n hereMapEvents = new H.mapevents.MapEvents(hereMap);\n }\n\n if (!(disableMapEvents || disableBehavior)) {\n hereBehavior = new H.mapevents.Behavior(hereMapEvents as H.mapevents.MapEvents);\n if (!enableFractionalZoom) {\n // Fractional zoom feels less predictable with mouse wheels in some setups,\n // but keeping it enabled can noticeably improve trackpad zoom smoothness.\n // @ts-expect-error-next-line\n hereBehavior.disable(H.mapevents.Behavior.Feature.FRACTIONAL_ZOOM);\n }\n\n if (disableZoomMomentum) {\n // Disable the inertia that occurs on WebGL maps when scrolling/zooming.\n // This resulted in a very high scroll sensitivity.\n // @ts-expect-error-next-line\n hereBehavior.disable(H.mapevents.Behavior.Feature.ZOOM_MOMENTUM);\n }\n }\n\n addEventListenerMap(hereMap, eventListenerMap, hereMap);\n hereMap.addEventListener('mapviewchangestart', handleMapViewChangeStart as EventListener);\n hereMap.addEventListener('mapviewchangeend', handleMapViewChangeEnd as EventListener);\n\n const hereUi = getHereUi(hereMap, defaultLayers, showScaleBar, language);\n\n // The api will be passed to services when using a render function.\n // This allows the service to access the map internals\n setApi({\n credentials,\n defaultLayers,\n map: hereMap,\n mapEvents: hereMapEvents,\n behavior: hereBehavior,\n platform,\n ui: hereUi,\n utils: createUtils(hereMap),\n // Put settings back into the map API object so the invoking service\n // can check on these settings for instance inside a test\n settings: {\n enableWebGL,\n baseLayer,\n activeLayers,\n showCluster,\n minZoom,\n maxZoom: safeMaxZoom,\n },\n });\n\n if (allMapObjects) {\n // If the base layer changed, re-add all previous objects again,\n // otherwise the map would be empty\n hereMap.addObjects(allMapObjects);\n }\n\n removeMapViewChangeListeners = () => {\n hereMap.removeEventListener('mapviewchangestart', handleMapViewChangeStart as EventListener);\n hereMap.removeEventListener('mapviewchangeend', handleMapViewChangeEnd as EventListener);\n };\n });\n\n return () => {\n removeMapViewChangeListeners();\n clearMarkerPointerEventsResetTimeout();\n setMarkerPointerEventsDisabled(false);\n setIsZoomInteractionActive(false);\n };\n }, [\n enableWebGL,\n enableDevicePixelRatio,\n language,\n baseLayer,\n minZoom,\n maxZoom,\n disableZoomMomentum,\n enableFractionalZoom,\n ]);\n\n useEffect(() => {\n if (!disableMarkerPointerEventsWhileZooming) {\n clearMarkerPointerEventsResetTimeout();\n setMarkerPointerEventsDisabled(false);\n }\n\n return () => {\n clearMarkerPointerEventsResetTimeout();\n setMarkerPointerEventsDisabled(false);\n setIsZoomInteractionActive(false);\n };\n }, [disableMarkerPointerEventsWhileZooming]);\n\n const isDarkMode = useDarkMode();\n useEffect(() => {\n // Toggle night map only if current map type is default\n if (isDarkMode && baseLayer === MAP_TYPE_DEFAULT) {\n handleMapTypeChange(MAP_TYPE_NIGHT);\n }\n // Toggle back to default map only if current map type is night\n else if (!isDarkMode && baseLayer === MAP_TYPE_NIGHT) {\n handleMapTypeChange(MAP_TYPE_DEFAULT);\n }\n }, [isDarkMode, language]);\n\n // Update MapType from outside\n useEffect(() => handleMapTypeChange(mapType), [mapType]);\n\n // Update MapLayer from outside\n const [previousMapLayer, setPreviousMapLayer] = useState(mapLayer);\n if (!isEqual(mapLayer, previousMapLayer)) {\n setActiveLayers(mapLayer);\n setPreviousMapLayer(mapLayer);\n }\n\n // Update Cluster setting from outside\n useEffect(() => setShowCluster(externalShowCluster), [externalShowCluster]);\n\n const handleMapTypeChange = (newMapType: MapType) => {\n setBaseLayer(newMapType);\n onMapTypeChange(newMapType, mapType);\n };\n\n const handleMapLayerChange = (layer: MapLayer) => {\n const removeLayer = (layerToRemove: string) => activeLayers.filter(item => item !== layerToRemove);\n const newActiveLayers = activeLayers.includes(layer) ? removeLayer(layer) : [...activeLayers, layer];\n setActiveLayers(newActiveLayers);\n onMapLayerChange(newActiveLayers, activeLayers);\n };\n\n const handleShowClusterChange = (newShowCluster: boolean) => {\n setShowCluster(newShowCluster);\n onShowClusterChange(newShowCluster);\n };\n\n // Note: For performance reasons, we deactivate pointer events and hence CSS style recalculation for the\n // the body. Having for instance many assets in the tree causes a performance loss when clicking on the map\n // to move it and zoom in/out since the map triggers a style invalidation and recalculation and\n // due to the nature of the AssetTree with it's hundreds DOM nodes, applying the CSS selectors\n // takes time.\n const handleMapInteractionStart = () => {\n document.querySelector('.AssetTree')?.classList.add('pointer-events-none');\n };\n const handleMapInteractionEnd = () => {\n document.querySelector('.AssetTree')?.classList.remove('pointer-events-none');\n };\n\n const style: CSSProperties = {};\n if (height) {\n style.height = height;\n }\n if (width) {\n style.width = width;\n }\n const autoHeightClass = isEmpty(style) ? 'height-100pct' : '';\n\n return (\n <div\n className={`Map position-relative map-type-${baseLayer.toLowerCase()} ${autoHeightClass}`}\n style={style}\n ref={mapRef}\n onTouchStart={handleMapInteractionStart}\n onTouchEnd={handleMapInteractionEnd}\n onMouseEnter={handleMapInteractionStart}\n onMouseOut={handleMapInteractionEnd}\n onBlur={handleMapInteractionEnd}\n >\n {isMapInitialized && api && (\n <MapContext.Provider\n value={{\n api,\n language,\n enableWebGL,\n enableMarkerIconCache,\n enableFractionalZoom,\n isZoomInteractionActive,\n showCluster,\n activeLayers,\n baseLayer,\n hideMapLayerSettings,\n hideClusterSettings,\n viewportHistory,\n onMapTypeChange: handleMapTypeChange,\n onMapLayerChange: handleMapLayerChange,\n onShowClusterChange: handleShowClusterChange,\n mapSettingsTooltip,\n onIncidentsChange,\n devicePixelRatio,\n }}\n >\n <MapPosition\n api={api}\n boundingBox={boundingBox}\n center={center}\n zoom={zoom}\n zoomAnimation={zoomAnimation}\n />\n <MapSize api={api} />\n <MapZoom\n hideZoomButtons={disableBehavior}\n onZoomIn={onZoomIn}\n onZoomOut={onZoomOut}\n zoomAnimation={zoomAnimation}\n />\n {mapSettings && mapSettings}\n <MapOverlayLayers layers={activeLayers} />\n <MapElements api={api}>{children}</MapElements>\n </MapContext.Provider>\n )}\n </div>\n );\n};\n\nMap.TYPE_DEFAULT = MAP_TYPE_DEFAULT;\nMap.TYPE_FLEET_STYLE = MAP_TYPE_FLEET_STYLE;\nMap.TYPE_SATELLITE = MAP_TYPE_SATELLITE;\nMap.TYPE_TERRAIN = MAP_TYPE_TERRAIN;\nMap.TYPE_NIGHT = MAP_TYPE_NIGHT;\n\nMap.LAYER_INCIDENTS = MAP_LAYER_INCIDENTS;\nMap.LAYER_TRAFFIC = MAP_LAYER_TRAFFIC;\nMap.LAYER_ROAD_RESTRICTIONS = MAP_LAYER_ROAD_RESTRICTIONS;\n\nexport default Map;\n"],"names":["MARKER_POINTER_EVENTS_DISABLED_CLASS","MARKER_POINTER_EVENTS_RESET_DELAY_MS","Map","props","children","credentials","width","height","lang","center","zoom","zoomAnimation","boundingBox","hideClusterSettings","hideMapLayerSettings","disableMapEvents","disableBehavior","disableZoomMomentum","enableFractionalZoom","eventListenerMap","mapType","MAP_TYPE_DEFAULT","mapLayer","externalShowCluster","showScaleBar","onMapLayerChange","onMapTypeChange","onShowClusterChange","onZoomIn","onZoomOut","onIncidentsChange","mapSettingsTooltip","mapSettings","maxViewportHistoryEntries","enableWebGL","enableDevicePixelRatio","enableMarkerIconCache","disableMarkerPointerEventsWhileZooming","pixelRatio","DEFAULT_PIXEL_RATIO","minZoom","DEFAULT_MIN_ZOOM","maxZoom","DEFAULT_MAX_ZOOM","safeMaxZoom","mapRef","useRef","markerPointerEventsResetTimeoutRef","markerPointerEventsDisabledRef","disableMarkerPointerEventsWhileZoomingRef","isMapInitialized","setMapInitialized","useState","isZoomInteractionActive","setIsZoomInteractionActive","api","setApi","baseLayer","setBaseLayer","activeLayers","setActiveLayers","showCluster","setShowCluster","controlledViewport","useMemo","viewportHistory","useMapViewportHistory","devicePixelRatio","language","locale","setMarkerPointerEventsDisabled","disabled","mapElement","clearMarkerPointerEventsResetTimeout","scheduleMarkerPointerEventsEnable","temporarilyDisableMarkerPointerEvents","useEffect","handleWheel","allMapObjects","removeMapViewChangeListeners","removeEventListenerMap","bounds","getMapBounds","platform","getPlatform","engineType","getEngineType","defaultLayers","getBaseLayer","MAP_LAYER_ROAD_RESTRICTIONS","defaultLayerMap","handleMapViewChangeStart","handleMapViewChangeEnd","hereMap","hereMapEvents","hereBehavior","addEventListenerMap","hereUi","getHereUi","createUtils","isDarkMode","useDarkMode","handleMapTypeChange","MAP_TYPE_NIGHT","previousMapLayer","setPreviousMapLayer","isEqual","newMapType","handleMapLayerChange","layer","removeLayer","layerToRemove","item","newActiveLayers","handleShowClusterChange","newShowCluster","handleMapInteractionStart","handleMapInteractionEnd","style","autoHeightClass","isEmpty","jsx","jsxs","MapContext","MapPosition","MapSize","MapZoom","MapOverlayLayers","MapElements","MAP_TYPE_FLEET_STYLE","MAP_TYPE_SATELLITE","MAP_TYPE_TERRAIN","MAP_LAYER_INCIDENTS","MAP_LAYER_TRAFFIC"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,MAAMA,KAAuC,qCACvCC,KAAuC,KAEvCC,IAAM,CAACC,OAAoB;AAC7B,QAAM;AAAA,IACF,UAAAC;AAAA,IACA,aAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,UAAUC,KAAO;AAAA,IACjB,QAAAC;AAAA,IACA,MAAAC;AAAA,IACA,eAAAC,IAAgB;AAAA,IAChB,aAAAC;AAAA,IACA,qBAAAC,KAAsB;AAAA,IACtB,sBAAAC,KAAuB;AAAA,IACvB,kBAAAC;AAAA,IACA,iBAAAC,IAAkB;AAAA,IAClB,qBAAAC,IAAsB;AAAA,IACtB,sBAAAC,IAAuB;AAAA,IACvB,kBAAAC;AAAA,IACA,SAAAC,IAAUC;AAAA,IACV,UAAAC,IAAW,CAAA;AAAA,IACX,aAAaC,IAAsB;AAAA,IACnC,cAAAC,KAAe;AAAA,IACf,kBAAAC,KAAmB,MAAM;AAAA,IAAC;AAAA,IAC1B,iBAAAC,KAAkB,MAAM;AAAA,IAAC;AAAA,IACzB,qBAA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AY,KAAAzE,GAAW,UAAAnD,GAAA,CAAS;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACrC;AAAA,EAAA;AAIhB;AAEAF,EAAI,eAAemB;AACnBnB,EAAI,mBAAmB+H;AACvB/H,EAAI,iBAAiBgI;AACrBhI,EAAI,eAAeiI;AACnBjI,EAAI,aAAaqG;AAEjBrG,EAAI,kBAAkBkI;AACtBlI,EAAI,gBAAgBmI;AACpBnI,EAAI,0BAA0BuF;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MapApi, MapIncidents, MapLayer, MapType } from '../utils/mapTypes';
|
|
2
|
+
import { MapViewportHistory } from '../hooks/useMapViewportHistory';
|
|
2
3
|
export type MapContextType = {
|
|
3
4
|
api: MapApi;
|
|
4
5
|
language: string;
|
|
@@ -16,6 +17,7 @@ export type MapContextType = {
|
|
|
16
17
|
mapSettingsTooltip?: string | React.ReactNode;
|
|
17
18
|
hideMapLayerSettings?: boolean;
|
|
18
19
|
hideClusterSettings?: boolean;
|
|
20
|
+
viewportHistory: MapViewportHistory;
|
|
19
21
|
onIncidentsChange: (incidentsResult: MapIncidents) => void;
|
|
20
22
|
};
|
|
21
23
|
export declare const defaultMapContext: MapContextType;
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import { createContext as e, useContext as t } from "react";
|
|
2
|
-
import { MAP_TYPE_DEFAULT as
|
|
3
|
-
|
|
2
|
+
import { MAP_TYPE_DEFAULT as o } from "./constants.js";
|
|
3
|
+
import { defaultMapViewportHistory as a } from "../hooks/useMapViewportHistory.js";
|
|
4
|
+
const r = {
|
|
4
5
|
api: {},
|
|
5
6
|
language: "en",
|
|
6
7
|
enableWebGL: !0,
|
|
7
8
|
enableMarkerIconCache: !0,
|
|
8
9
|
enableFractionalZoom: !1,
|
|
9
10
|
isZoomInteractionActive: !1,
|
|
10
|
-
baseLayer:
|
|
11
|
+
baseLayer: o,
|
|
11
12
|
activeLayers: [],
|
|
12
13
|
showCluster: !0,
|
|
13
14
|
devicePixelRatio: 1,
|
|
15
|
+
viewportHistory: a,
|
|
14
16
|
onIncidentsChange: () => {
|
|
15
17
|
}
|
|
16
|
-
}, n = e(
|
|
18
|
+
}, n = e(r), l = () => t(n);
|
|
17
19
|
export {
|
|
18
20
|
n as MapContext,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
r as defaultMapContext,
|
|
22
|
+
l as useMapContext
|
|
21
23
|
};
|
|
22
24
|
//# sourceMappingURL=MapContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapContext.js","sources":["../../../../src/components/map/components/MapContext.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nimport type { MapApi, MapIncidents, MapLayer, MapType } from '../utils/mapTypes';\nimport { MAP_TYPE_DEFAULT } from './constants';\n\nexport type MapContextType = {\n api: MapApi;\n language: string;\n enableWebGL: boolean;\n enableMarkerIconCache: boolean;\n enableFractionalZoom: boolean;\n isZoomInteractionActive: boolean;\n baseLayer: MapType;\n activeLayers: MapLayer[];\n showCluster: boolean;\n devicePixelRatio: number;\n onMapTypeChange?: (type: MapType) => void;\n onMapLayerChange?: (layer: MapLayer) => void;\n onShowClusterChange?: (showCluster: boolean) => void;\n mapSettingsTooltip?: string | React.ReactNode;\n hideMapLayerSettings?: boolean;\n hideClusterSettings?: boolean;\n onIncidentsChange: (incidentsResult: MapIncidents) => void;\n};\n\nexport const defaultMapContext: MapContextType = {\n api: {},\n language: 'en',\n enableWebGL: true,\n enableMarkerIconCache: true,\n enableFractionalZoom: false,\n isZoomInteractionActive: false,\n baseLayer: MAP_TYPE_DEFAULT,\n activeLayers: [],\n showCluster: true,\n devicePixelRatio: 1,\n onIncidentsChange: () => {},\n};\n\nexport const MapContext = createContext<MapContextType>(defaultMapContext);\n\nexport const useMapContext = () => useContext(MapContext);\n"],"names":["defaultMapContext","MAP_TYPE_DEFAULT","MapContext","createContext","useMapContext","useContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapContext.js","sources":["../../../../src/components/map/components/MapContext.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nimport type { MapApi, MapIncidents, MapLayer, MapType } from '../utils/mapTypes';\nimport { MAP_TYPE_DEFAULT } from './constants';\nimport { defaultMapViewportHistory, type MapViewportHistory } from '../hooks/useMapViewportHistory';\n\nexport type MapContextType = {\n api: MapApi;\n language: string;\n enableWebGL: boolean;\n enableMarkerIconCache: boolean;\n enableFractionalZoom: boolean;\n isZoomInteractionActive: boolean;\n baseLayer: MapType;\n activeLayers: MapLayer[];\n showCluster: boolean;\n devicePixelRatio: number;\n onMapTypeChange?: (type: MapType) => void;\n onMapLayerChange?: (layer: MapLayer) => void;\n onShowClusterChange?: (showCluster: boolean) => void;\n mapSettingsTooltip?: string | React.ReactNode;\n hideMapLayerSettings?: boolean;\n hideClusterSettings?: boolean;\n viewportHistory: MapViewportHistory;\n onIncidentsChange: (incidentsResult: MapIncidents) => void;\n};\n\nexport const defaultMapContext: MapContextType = {\n api: {},\n language: 'en',\n enableWebGL: true,\n enableMarkerIconCache: true,\n enableFractionalZoom: false,\n isZoomInteractionActive: false,\n baseLayer: MAP_TYPE_DEFAULT,\n activeLayers: [],\n showCluster: true,\n devicePixelRatio: 1,\n viewportHistory: defaultMapViewportHistory,\n onIncidentsChange: () => {},\n};\n\nexport const MapContext = createContext<MapContextType>(defaultMapContext);\n\nexport const useMapContext = () => useContext(MapContext);\n"],"names":["defaultMapContext","MAP_TYPE_DEFAULT","defaultMapViewportHistory","MapContext","createContext","useMapContext","useContext"],"mappings":";;;AA2BO,MAAMA,IAAoC;AAAA,EAC7C,KAAK,CAAA;AAAA,EACL,UAAU;AAAA,EACV,aAAa;AAAA,EACb,uBAAuB;AAAA,EACvB,sBAAsB;AAAA,EACtB,yBAAyB;AAAA,EACzB,WAAWC;AAAA,EACX,cAAc,CAAA;AAAA,EACd,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,iBAAiBC;AAAA,EACjB,mBAAmB,MAAM;AAAA,EAAC;AAC9B,GAEaC,IAAaC,EAA8BJ,CAAiB,GAE5DK,IAAgB,MAAMC,EAAWH,CAAU;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MapApi, MapProps } from '../utils/mapTypes';
|
|
2
|
-
export type MapPositionProps = Pick<MapProps, 'boundingBox' | 'center' | 'zoomAnimation'> & {
|
|
2
|
+
export type MapPositionProps = Pick<MapProps, 'boundingBox' | 'center' | 'zoom' | 'zoomAnimation'> & {
|
|
3
3
|
api: MapApi;
|
|
4
4
|
};
|
|
5
5
|
declare const MapPosition: (props: MapPositionProps) => null;
|
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
import { useEffect as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { useRef as f, useEffect as h } from "react";
|
|
2
|
+
import { useMapContext as P } from "./MapContext.js";
|
|
3
|
+
const C = 1e-6, Z = 1e-3, N = (b) => {
|
|
4
|
+
const { api: o, boundingBox: a, center: t, zoom: e, zoomAnimation: r = !1 } = b, { enableFractionalZoom: g } = P(), p = f(), c = f(t), d = f(e);
|
|
5
|
+
return h(() => {
|
|
6
|
+
if (o && a) {
|
|
7
|
+
const { top: n, left: i, bottom: l, right: u } = a;
|
|
8
|
+
o.map?.getViewModel().setLookAtData({ bounds: new H.geo.Rect(n, i, l, u) }, r);
|
|
8
9
|
}
|
|
9
|
-
}, [
|
|
10
|
-
|
|
10
|
+
}, [a]), h(() => {
|
|
11
|
+
const n = o.map;
|
|
12
|
+
if (!(n && (t || e !== void 0)))
|
|
11
13
|
return;
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
const i = p.current !== n, l = t?.lat !== c.current?.lat || t?.lng !== c.current?.lng, u = e !== d.current;
|
|
15
|
+
if (!(i || l || u))
|
|
16
|
+
return;
|
|
17
|
+
const s = {}, m = o.utils?.getCenter();
|
|
18
|
+
t && m && (Math.abs(m.lat - t.lat) > C || Math.abs(m.lng - t.lng) > C) && (s.position = t);
|
|
19
|
+
const M = g ? o.utils?.getPreciseZoom() : o.utils?.getZoom();
|
|
20
|
+
e !== void 0 && M !== void 0 && Math.abs(M - e) > Z && (s.zoom = e), Object.keys(s).length > 0 && n.getViewModel().setLookAtData(s, r), p.current = n, c.current = t, d.current = e;
|
|
21
|
+
}, [o, t, e, r, g]), null;
|
|
15
22
|
};
|
|
16
23
|
export {
|
|
17
|
-
|
|
24
|
+
N as default
|
|
18
25
|
};
|
|
19
26
|
//# sourceMappingURL=MapPosition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapPosition.js","sources":["../../../../src/components/map/components/MapPosition.tsx"],"sourcesContent":["import { useEffect } from 'react';\n\nimport type { MapApi, MapProps } from '../utils/mapTypes';\n\nexport type MapPositionProps = Pick<MapProps, 'boundingBox' | 'center' | 'zoomAnimation'> & {\n api: MapApi;\n};\n\nconst MapPosition = (props: MapPositionProps) => {\n const { api, boundingBox, center, zoomAnimation = false } = props;\n\n // Update BoundingBox from outside\n useEffect(() => {\n if (api && boundingBox) {\n const { top, left, bottom, right } = boundingBox;\n api.map?.getViewModel().setLookAtData({ bounds: new H.geo.Rect(top, left, bottom, right) }, zoomAnimation);\n }\n }, [boundingBox]);\n\n // Update
|
|
1
|
+
{"version":3,"file":"MapPosition.js","sources":["../../../../src/components/map/components/MapPosition.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nimport type { MapApi, MapProps } from '../utils/mapTypes';\nimport { useMapContext } from './MapContext';\n\nconst CENTER_SYNC_EPSILON = 0.000001;\nconst ZOOM_SYNC_EPSILON = 0.001;\n\n// Keeps externally controlled viewport props in sync with HERE.\n// `center` and `zoom` may change together, but either value must also work independently.\nexport type MapPositionProps = Pick<MapProps, 'boundingBox' | 'center' | 'zoom' | 'zoomAnimation'> & {\n api: MapApi;\n};\n\nconst MapPosition = (props: MapPositionProps) => {\n const { api, boundingBox, center, zoom, zoomAnimation = false } = props;\n const { enableFractionalZoom } = useMapContext();\n const lastProcessedMapRef = useRef<H.Map>();\n const lastProcessedCenterRef = useRef(center);\n const lastProcessedZoomRef = useRef(zoom);\n\n // Update BoundingBox from outside\n useEffect(() => {\n if (api && boundingBox) {\n const { top, left, bottom, right } = boundingBox;\n api.map?.getViewModel().setLookAtData({ bounds: new H.geo.Rect(top, left, bottom, right) }, zoomAnimation);\n }\n }, [boundingBox]);\n\n // Update viewport from outside if center or zoom value is different.\n // If only zoom changed, HERE receives only `{ zoom }`; if only center changed, only `{ position }`.\n // If both changed in the same render, they are applied atomically to avoid animated zooming around the old center.\n useEffect(() => {\n const map = api.map;\n\n if (!(map && (center || zoom !== undefined))) {\n return;\n }\n\n const hasMapChanged = lastProcessedMapRef.current !== map;\n const hasCenterChanged =\n center?.lat !== lastProcessedCenterRef.current?.lat || center?.lng !== lastProcessedCenterRef.current?.lng;\n const hasZoomChanged = zoom !== lastProcessedZoomRef.current;\n\n if (!(hasMapChanged || hasCenterChanged || hasZoomChanged)) {\n return;\n }\n\n const lookAtData: H.map.ViewModel.ILookAtData = {};\n\n const currentMapCenter = api.utils?.getCenter();\n if (\n center &&\n currentMapCenter &&\n (Math.abs(currentMapCenter.lat - center.lat) > CENTER_SYNC_EPSILON ||\n Math.abs(currentMapCenter.lng - center.lng) > CENTER_SYNC_EPSILON)\n ) {\n lookAtData.position = center;\n }\n\n const currentMapZoom = enableFractionalZoom ? api.utils?.getPreciseZoom() : api.utils?.getZoom();\n if (zoom !== undefined && currentMapZoom !== undefined && Math.abs(currentMapZoom - zoom) > ZOOM_SYNC_EPSILON) {\n lookAtData.zoom = zoom;\n }\n\n if (Object.keys(lookAtData).length > 0) {\n map.getViewModel().setLookAtData(lookAtData, zoomAnimation);\n }\n\n lastProcessedMapRef.current = map;\n lastProcessedCenterRef.current = center;\n lastProcessedZoomRef.current = zoom;\n }, [api, center, zoom, zoomAnimation, enableFractionalZoom]);\n\n return null;\n};\n\nexport default MapPosition;\n"],"names":["CENTER_SYNC_EPSILON","ZOOM_SYNC_EPSILON","MapPosition","props","api","boundingBox","center","zoom","zoomAnimation","enableFractionalZoom","useMapContext","lastProcessedMapRef","useRef","lastProcessedCenterRef","lastProcessedZoomRef","useEffect","top","left","bottom","right","map","hasMapChanged","hasCenterChanged","hasZoomChanged","lookAtData","currentMapCenter","currentMapZoom"],"mappings":";;AAKA,MAAMA,IAAsB,MACtBC,IAAoB,MAQpBC,IAAc,CAACC,MAA4B;AAC7C,QAAM,EAAE,KAAAC,GAAK,aAAAC,GAAa,QAAAC,GAAQ,MAAAC,GAAM,eAAAC,IAAgB,OAAUL,GAC5D,EAAE,sBAAAM,EAAA,IAAyBC,EAAA,GAC3BC,IAAsBC,EAAA,GACtBC,IAAyBD,EAAON,CAAM,GACtCQ,IAAuBF,EAAOL,CAAI;AAGxC,SAAAQ,EAAU,MAAM;AACZ,QAAIX,KAAOC,GAAa;AACpB,YAAM,EAAE,KAAAW,GAAK,MAAAC,GAAM,QAAAC,GAAQ,OAAAC,MAAUd;AACrC,MAAAD,EAAI,KAAK,aAAA,EAAe,cAAc,EAAE,QAAQ,IAAI,EAAE,IAAI,KAAKY,GAAKC,GAAMC,GAAQC,CAAK,EAAA,GAAKX,CAAa;AAAA,IAC7G;AAAA,EACJ,GAAG,CAACH,CAAW,CAAC,GAKhBU,EAAU,MAAM;AACZ,UAAMK,IAAMhB,EAAI;AAEhB,QAAI,EAAEgB,MAAQd,KAAUC,MAAS;AAC7B;AAGJ,UAAMc,IAAgBV,EAAoB,YAAYS,GAChDE,IACFhB,GAAQ,QAAQO,EAAuB,SAAS,OAAOP,GAAQ,QAAQO,EAAuB,SAAS,KACrGU,IAAiBhB,MAASO,EAAqB;AAErD,QAAI,EAAEO,KAAiBC,KAAoBC;AACvC;AAGJ,UAAMC,IAA0C,CAAA,GAE1CC,IAAmBrB,EAAI,OAAO,UAAA;AACpC,IACIE,KACAmB,MACC,KAAK,IAAIA,EAAiB,MAAMnB,EAAO,GAAG,IAAIN,KAC3C,KAAK,IAAIyB,EAAiB,MAAMnB,EAAO,GAAG,IAAIN,OAElDwB,EAAW,WAAWlB;AAG1B,UAAMoB,IAAiBjB,IAAuBL,EAAI,OAAO,mBAAmBA,EAAI,OAAO,QAAA;AACvF,IAAIG,MAAS,UAAamB,MAAmB,UAAa,KAAK,IAAIA,IAAiBnB,CAAI,IAAIN,MACxFuB,EAAW,OAAOjB,IAGlB,OAAO,KAAKiB,CAAU,EAAE,SAAS,KACjCJ,EAAI,aAAA,EAAe,cAAcI,GAAYhB,CAAa,GAG9DG,EAAoB,UAAUS,GAC9BP,EAAuB,UAAUP,GACjCQ,EAAqB,UAAUP;AAAA,EACnC,GAAG,CAACH,GAAKE,GAAQC,GAAMC,GAAeC,CAAoB,CAAC,GAEpD;AACX;"}
|
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
n !== void 0 && (m ? Math.abs(n - t) > g : n !== t) && o.utils?.setZoom(t, r), u.current = t;
|
|
12
|
-
}, [o, t, r, m, s]);
|
|
13
|
-
const l = () => {
|
|
14
|
-
const e = (o?.utils?.getZoom() ?? 0) + 1;
|
|
15
|
-
c(e), o?.utils?.setZoom(e, r);
|
|
16
|
-
}, f = () => {
|
|
17
|
-
const e = (o?.utils?.getZoom() ?? 0) - 1;
|
|
18
|
-
a(e), o?.utils?.setZoom(e, r);
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import l from "./settings/ZoomButtons.js";
|
|
3
|
+
import { useMapContext as a } from "../MapContext.js";
|
|
4
|
+
const h = (m) => {
|
|
5
|
+
const { hideZoomButtons: s, zoomAnimation: n, onZoomIn: e, onZoomOut: r } = m, { api: t } = a(), Z = () => {
|
|
6
|
+
const o = (t?.utils?.getZoom() ?? 0) + 1;
|
|
7
|
+
e(o), t?.utils?.setZoom(o, n);
|
|
8
|
+
}, u = () => {
|
|
9
|
+
const o = (t?.utils?.getZoom() ?? 0) - 1;
|
|
10
|
+
r(o), t?.utils?.setZoom(o, n);
|
|
19
11
|
};
|
|
20
|
-
return
|
|
12
|
+
return s ? null : /* @__PURE__ */ i(l, { onZoomIn: Z, onZoomOut: u });
|
|
21
13
|
};
|
|
22
14
|
export {
|
|
23
|
-
|
|
15
|
+
h as default
|
|
24
16
|
};
|
|
25
17
|
//# sourceMappingURL=MapZoom.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapZoom.js","sources":["../../../../../src/components/map/components/features/MapZoom.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"MapZoom.js","sources":["../../../../../src/components/map/components/features/MapZoom.tsx"],"sourcesContent":["import ZoomButtons from './settings/ZoomButtons';\nimport { useMapContext } from '../MapContext';\n\nexport type MapZoomProps = {\n hideZoomButtons: boolean;\n zoomAnimation: boolean;\n onZoomIn: (zoom: number) => void;\n onZoomOut: (zoom: number) => void;\n};\n\nconst MapZoom = (props: MapZoomProps) => {\n const { hideZoomButtons, zoomAnimation, onZoomIn, onZoomOut } = props;\n\n const { api } = useMapContext();\n\n const handleZoomIn = () => {\n const currentZoom = api?.utils?.getZoom() ?? 0;\n const newZoom = currentZoom + 1;\n\n onZoomIn(newZoom);\n api?.utils?.setZoom(newZoom, zoomAnimation);\n };\n\n const handleZoomOut = () => {\n const currentZoom = api?.utils?.getZoom() ?? 0;\n const newZoom = currentZoom - 1;\n\n onZoomOut(newZoom);\n api?.utils?.setZoom(newZoom, zoomAnimation);\n };\n\n if (hideZoomButtons) {\n return null;\n }\n\n return <ZoomButtons onZoomIn={handleZoomIn} onZoomOut={handleZoomOut} />;\n};\n\nexport default MapZoom;\n"],"names":["MapZoom","props","hideZoomButtons","zoomAnimation","onZoomIn","onZoomOut","api","useMapContext","handleZoomIn","newZoom","handleZoomOut","jsx","ZoomButtons"],"mappings":";;;AAUA,MAAMA,IAAU,CAACC,MAAwB;AACrC,QAAM,EAAE,iBAAAC,GAAiB,eAAAC,GAAe,UAAAC,GAAU,WAAAC,MAAcJ,GAE1D,EAAE,KAAAK,EAAA,IAAQC,EAAA,GAEVC,IAAe,MAAM;AAEvB,UAAMC,KADcH,GAAK,OAAO,QAAA,KAAa,KACf;AAE9B,IAAAF,EAASK,CAAO,GAChBH,GAAK,OAAO,QAAQG,GAASN,CAAa;AAAA,EAC9C,GAEMO,IAAgB,MAAM;AAExB,UAAMD,KADcH,GAAK,OAAO,QAAA,KAAa,KACf;AAE9B,IAAAD,EAAUI,CAAO,GACjBH,GAAK,OAAO,QAAQG,GAASN,CAAa;AAAA,EAC9C;AAEA,SAAID,IACO,OAGJ,gBAAAS,EAACC,GAAA,EAAY,UAAUJ,GAAc,WAAWE,GAAe;AAC1E;"}
|
|
@@ -1,13 +1,40 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
export type MapSettingsTileProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Callback fired when the settings tile opens or closes.
|
|
5
|
+
*/
|
|
3
6
|
onToggle?: (newState: boolean) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Tooltip shown while the settings tile is closed.
|
|
9
|
+
*/
|
|
4
10
|
tooltip?: React.ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Custom panel rendered below the settings tile when it is open.
|
|
13
|
+
*/
|
|
5
14
|
panel?: React.ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Dropdown menu items rendered when the settings tile is open.
|
|
17
|
+
*/
|
|
6
18
|
items?: JSX.Element[] | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Icon shown when the tile is active.
|
|
21
|
+
*/
|
|
7
22
|
activeIcon?: JSX.Element | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Icon shown when the tile is inactive.
|
|
25
|
+
*/
|
|
8
26
|
inactiveIcon?: JSX.Element | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Controls whether the active or inactive icon is shown.
|
|
29
|
+
*/
|
|
9
30
|
isActive?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Additional class name for the clickable settings button.
|
|
33
|
+
*/
|
|
10
34
|
buttonClassName?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Additional class name for the settings tile wrapper.
|
|
37
|
+
*/
|
|
11
38
|
className?: string;
|
|
12
39
|
};
|
|
13
40
|
declare const MapSettingsTile: (props: MapSettingsTileProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as p, Fragment as L, jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import I, { useState as T } from "react";
|
|
3
3
|
import { AnimatePresence as M, motion as O } from "motion/react";
|
|
4
4
|
import { noop as j } from "es-toolkit/function";
|
|
5
5
|
import { usePopper as U } from "react-popper";
|
|
6
|
-
import
|
|
6
|
+
import s from "../../../../../utils/classNames.js";
|
|
7
7
|
import B from "../../../../overlay/OverlayTrigger.js";
|
|
8
8
|
import S from "../../../../tooltip/Tooltip.js";
|
|
9
9
|
import F, { useClickOutsideWithRef as q } from "../../../../../hooks/useClickOutside.js";
|
|
@@ -30,10 +30,10 @@ const K = 800, Q = 100, n = {
|
|
|
30
30
|
inactiveIcon: f,
|
|
31
31
|
isActive: v = !1,
|
|
32
32
|
panel: u,
|
|
33
|
-
items:
|
|
33
|
+
items: a,
|
|
34
34
|
className: C,
|
|
35
35
|
buttonClassName: w,
|
|
36
|
-
tooltip:
|
|
36
|
+
tooltip: l,
|
|
37
37
|
...x
|
|
38
38
|
} = m, [e, h] = T(!1), P = () => {
|
|
39
39
|
const t = !e;
|
|
@@ -52,20 +52,20 @@ const K = 800, Q = 100, n = {
|
|
|
52
52
|
] : []
|
|
53
53
|
});
|
|
54
54
|
q(y, (t) => {
|
|
55
|
-
const
|
|
56
|
-
|
|
55
|
+
const c = t.target instanceof Node ? t.target : null;
|
|
56
|
+
c && N?.contains(c) || e && (h(!1), o(!1));
|
|
57
57
|
});
|
|
58
|
-
const D =
|
|
58
|
+
const D = s("MapSettingsTile", C), W = s("MapSettingsButton", e && "active", w), A = s(
|
|
59
59
|
"MapSettingsTileIcon",
|
|
60
60
|
"hover-scale-110",
|
|
61
61
|
v ? "display-block" : "display-none",
|
|
62
62
|
d?.props.className || ""
|
|
63
|
-
), H =
|
|
63
|
+
), H = s(
|
|
64
64
|
"MapSettingsTileIcon",
|
|
65
65
|
"hover-scale-110",
|
|
66
66
|
v ? "display-none" : "display-block",
|
|
67
67
|
f?.props.className || ""
|
|
68
|
-
),
|
|
68
|
+
), r = /* @__PURE__ */ p("div", { className: W, onClick: P, children: [
|
|
69
69
|
d && I.cloneElement(d, {
|
|
70
70
|
className: A
|
|
71
71
|
}),
|
|
@@ -73,9 +73,9 @@ const K = 800, Q = 100, n = {
|
|
|
73
73
|
className: H
|
|
74
74
|
})
|
|
75
75
|
] });
|
|
76
|
-
return /* @__PURE__ */
|
|
77
|
-
!
|
|
78
|
-
|
|
76
|
+
return /* @__PURE__ */ p("div", { className: D, ref: g, ...x, children: [
|
|
77
|
+
!a && /* @__PURE__ */ p(L, { children: [
|
|
78
|
+
l && !e ? b(r, l) : r,
|
|
79
79
|
/* @__PURE__ */ i("div", { className: "overflow-hidden", children: /* @__PURE__ */ i(M, { children: e && u && /* @__PURE__ */ i(
|
|
80
80
|
O.div,
|
|
81
81
|
{
|
|
@@ -87,12 +87,12 @@ const K = 800, Q = 100, n = {
|
|
|
87
87
|
}
|
|
88
88
|
) }) })
|
|
89
89
|
] }),
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
/* @__PURE__ */ i(M, { children: e &&
|
|
90
|
+
a && /* @__PURE__ */ p("div", { className: "MapSettingsTile-inner position-relative", ref: _, children: [
|
|
91
|
+
l && !e ? b(r, l) : r,
|
|
92
|
+
/* @__PURE__ */ i(M, { children: e && a && /* @__PURE__ */ i(
|
|
93
93
|
O.div,
|
|
94
94
|
{
|
|
95
|
-
className: "dropdown",
|
|
95
|
+
className: s("dropdown", e && "open"),
|
|
96
96
|
initial: n.initial,
|
|
97
97
|
animate: n.animate,
|
|
98
98
|
exit: n.exit,
|
|
@@ -104,7 +104,7 @@ const K = 800, Q = 100, n = {
|
|
|
104
104
|
ref: R,
|
|
105
105
|
style: { ...k.popper, minWidth: "180px" },
|
|
106
106
|
...E.popper,
|
|
107
|
-
children:
|
|
107
|
+
children: a?.map((t, c) => t.type.isMapSettingsDropdownHeader ? t : /* @__PURE__ */ i(G, { value: t }, c))
|
|
108
108
|
}
|
|
109
109
|
)
|
|
110
110
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapSettingsTile.js","sources":["../../../../../../src/components/map/components/features/settings/MapSettingsTile.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { AnimatePresence, motion, type Transition } from 'motion/react';\nimport { noop } from 'es-toolkit/function';\nimport { usePopper } from 'react-popper';\n\nimport classNames from '../../../../../utils/classNames';\nimport OverlayTrigger from '../../../../overlay/OverlayTrigger';\nimport Tooltip from '../../../../tooltip/Tooltip';\nimport useClickOutside, { useClickOutsideWithRef } from '../../../../../hooks/useClickOutside';\nimport MenuItemList from '../../../../menuItems/MenuItemList';\nimport MenuItem from '../../../../menuItems/MenuItem';\nimport { isMobileScreen } from '../../../../../utils/deviceUtils';\n\nconst TOOLTIP_SHOW_TIMEOUT_IN_MS = 800;\nconst TOOLTIP_HIDE_TIMEOUT_IN_MS = 100;\n\nconst tileAnimation = {\n initial: { opacity: 0, y: 10 },\n animate: { opacity: 1, y: 0 },\n exit: { opacity: 0, y: 10 },\n transition: { duration: 0.08, ease: 'easeOut' } as Transition,\n};\n\nconst getComponentWithTooltip = (component: React.ReactNode, tooltip: React.ReactNode) => (\n <OverlayTrigger\n placement={Tooltip.TOP}\n delay={{ show: TOOLTIP_SHOW_TIMEOUT_IN_MS, hide: TOOLTIP_HIDE_TIMEOUT_IN_MS }}\n overlay={\n <Tooltip id='tooltip' width='auto'>\n {tooltip}\n </Tooltip>\n }\n >\n {component}\n </OverlayTrigger>\n);\n\nexport type MapSettingsTileProps = {\n onToggle?: (newState: boolean) => void;\n tooltip?: React.ReactNode;\n panel?: React.ReactNode;\n items?: JSX.Element[] | undefined;\n activeIcon?: JSX.Element | undefined;\n inactiveIcon?: JSX.Element | undefined;\n isActive?: boolean;\n buttonClassName?: string;\n className?: string;\n};\n\nconst MapSettingsTile = (props: MapSettingsTileProps) => {\n const {\n onToggle = noop,\n activeIcon,\n inactiveIcon,\n isActive = false,\n panel,\n items,\n className,\n buttonClassName,\n tooltip,\n ...remainingProps\n } = props;\n\n const [isOpen, setIsOpen] = useState(false);\n\n const handleToggle = () => {\n const newState = !isOpen;\n setIsOpen(newState);\n onToggle(newState);\n\n buttonRef.current.blur();\n };\n\n const handleClosePanel = () => {\n if (isOpen && panel) {\n setIsOpen(false);\n onToggle(false);\n buttonRef.current.blur();\n }\n };\n\n const buttonRef = useClickOutside(handleClosePanel);\n\n const [toggleRef, setToggleRef] = useState<HTMLDivElement | null>(null);\n const [refDropdownMenu, setRefDropdownMenu] = useState<HTMLUListElement | null>(null);\n\n const { styles, attributes } = usePopper(toggleRef, refDropdownMenu, {\n placement: 'top-end',\n modifiers:\n isOpen && isMobileScreen()\n ? [\n {\n name: 'offset',\n options: {\n offset: [-60, -60],\n },\n },\n ]\n : [],\n });\n\n useClickOutsideWithRef(refDropdownMenu, (event: MouseEvent | TouchEvent) => {\n const target = event.target instanceof Node ? event.target : null;\n\n if (target && toggleRef?.contains(target)) {\n return;\n }\n\n if (isOpen) {\n setIsOpen(false);\n onToggle(false);\n }\n });\n\n const wrapperClasses = classNames('MapSettingsTile', className);\n\n const buttonClasses = classNames('MapSettingsButton', isOpen && 'active', buttonClassName);\n\n const activeIconClassNames = classNames(\n 'MapSettingsTileIcon',\n 'hover-scale-110',\n isActive ? 'display-block' : 'display-none',\n activeIcon?.props.className || ''\n );\n\n const inactiveIconClassNames = classNames(\n 'MapSettingsTileIcon',\n 'hover-scale-110',\n isActive ? 'display-none' : 'display-block',\n inactiveIcon?.props.className || ''\n );\n\n const button = (\n <div className={buttonClasses} onClick={handleToggle}>\n {activeIcon &&\n React.cloneElement(activeIcon, {\n className: activeIconClassNames,\n })}\n {inactiveIcon &&\n React.cloneElement(inactiveIcon, {\n className: inactiveIconClassNames,\n })}\n </div>\n );\n\n return (\n <div className={wrapperClasses} ref={buttonRef} {...remainingProps}>\n {/* backwards compatible way of still showing a panel without labels */}\n {!items && (\n <>\n {tooltip && !isOpen ? getComponentWithTooltip(button, tooltip) : button}\n <div className='overflow-hidden'>\n <AnimatePresence>\n {isOpen && panel && (\n <motion.div\n initial={tileAnimation.initial}\n animate={tileAnimation.animate}\n exit={tileAnimation.exit}\n transition={tileAnimation.transition}\n >\n {panel}\n </motion.div>\n )}\n </AnimatePresence>\n </div>\n </>\n )}\n {/* new way of showing a dropdown without labels */}\n {items && (\n <div className='MapSettingsTile-inner position-relative' ref={setToggleRef}>\n {tooltip && !isOpen ? getComponentWithTooltip(button, tooltip) : button}\n <AnimatePresence>\n {isOpen && items && (\n <motion.div\n className='dropdown'\n initial={tileAnimation.initial}\n animate={tileAnimation.animate}\n exit={tileAnimation.exit}\n transition={tileAnimation.transition}\n >\n <MenuItemList\n className='margin-bottom-5 shadow-smooth border-none'\n ref={setRefDropdownMenu}\n style={{ ...styles.popper, minWidth: '180px' }}\n {...attributes.popper}\n >\n {items?.map((item, index) => {\n if (item.type.isMapSettingsDropdownHeader) {\n return item;\n }\n return <MenuItem key={index} value={item} />;\n })}\n </MenuItemList>\n </motion.div>\n )}\n </AnimatePresence>\n </div>\n )}\n </div>\n );\n};\n\nexport default MapSettingsTile;\n"],"names":["TOOLTIP_SHOW_TIMEOUT_IN_MS","TOOLTIP_HIDE_TIMEOUT_IN_MS","tileAnimation","getComponentWithTooltip","component","tooltip","jsx","OverlayTrigger","Tooltip","MapSettingsTile","props","onToggle","noop","activeIcon","inactiveIcon","isActive","panel","items","className","buttonClassName","remainingProps","isOpen","setIsOpen","useState","handleToggle","newState","buttonRef","useClickOutside","toggleRef","setToggleRef","refDropdownMenu","setRefDropdownMenu","styles","attributes","usePopper","isMobileScreen","useClickOutsideWithRef","event","target","wrapperClasses","classNames","buttonClasses","activeIconClassNames","inactiveIconClassNames","button","jsxs","React","Fragment","AnimatePresence","motion","MenuItemList","item","index","MenuItem"],"mappings":";;;;;;;;;;;;AAaA,MAAMA,IAA6B,KAC7BC,IAA6B,KAE7BC,IAAgB;AAAA,EAClB,SAAS,EAAE,SAAS,GAAG,GAAG,GAAA;AAAA,EAC1B,SAAS,EAAE,SAAS,GAAG,GAAG,EAAA;AAAA,EAC1B,MAAM,EAAE,SAAS,GAAG,GAAG,GAAA;AAAA,EACvB,YAAY,EAAE,UAAU,MAAM,MAAM,UAAA;AACxC,GAEMC,IAA0B,CAACC,GAA4BC,MACzD,gBAAAC;AAAA,EAACC;AAAA,EAAA;AAAA,IACG,WAAWC,EAAQ;AAAA,IACnB,OAAO,EAAE,MAAMR,GAA4B,MAAMC,EAAA;AAAA,IACjD,SACI,gBAAAK,EAACE,GAAA,EAAQ,IAAG,WAAU,OAAM,QACvB,UAAAH,GACL;AAAA,IAGH,UAAAD;AAAA,EAAA;AACL,GAeEK,KAAkB,CAACC,MAAgC;AACrD,QAAM;AAAA,IACF,UAAAC,IAAWC;AAAA,IACX,YAAAC;AAAA,IACA,cAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,OAAAC;AAAA,IACA,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,SAAAd;AAAA,IACA,GAAGe;AAAA,EAAA,IACHV,GAEE,CAACW,GAAQC,CAAS,IAAIC,EAAS,EAAK,GAEpCC,IAAe,MAAM;AACvB,UAAMC,IAAW,CAACJ;AAClB,IAAAC,EAAUG,CAAQ,GAClBd,EAASc,CAAQ,GAEjBC,EAAU,QAAQ,KAAA;AA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AAA;AAAA,UAAA;AAAA,QACL;AAAA,MAAA,EACJ,CAER;AAAA,IAAA,EAAA,CACJ;AAAA,EAAA,GAER;AAER;"}
|
|
1
|
+
{"version":3,"file":"MapSettingsTile.js","sources":["../../../../../../src/components/map/components/features/settings/MapSettingsTile.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { AnimatePresence, motion, type Transition } from 'motion/react';\nimport { noop } from 'es-toolkit/function';\nimport { usePopper } from 'react-popper';\n\nimport classNames from '../../../../../utils/classNames';\nimport OverlayTrigger from '../../../../overlay/OverlayTrigger';\nimport Tooltip from '../../../../tooltip/Tooltip';\nimport useClickOutside, { useClickOutsideWithRef } from '../../../../../hooks/useClickOutside';\nimport MenuItemList from '../../../../menuItems/MenuItemList';\nimport MenuItem from '../../../../menuItems/MenuItem';\nimport { isMobileScreen } from '../../../../../utils/deviceUtils';\n\nconst TOOLTIP_SHOW_TIMEOUT_IN_MS = 800;\nconst TOOLTIP_HIDE_TIMEOUT_IN_MS = 100;\n\nconst tileAnimation = {\n initial: { opacity: 0, y: 10 },\n animate: { opacity: 1, y: 0 },\n exit: { opacity: 0, y: 10 },\n transition: { duration: 0.08, ease: 'easeOut' } as Transition,\n};\n\nconst getComponentWithTooltip = (component: React.ReactNode, tooltip: React.ReactNode) => (\n <OverlayTrigger\n placement={Tooltip.TOP}\n delay={{ show: TOOLTIP_SHOW_TIMEOUT_IN_MS, hide: TOOLTIP_HIDE_TIMEOUT_IN_MS }}\n overlay={\n <Tooltip id='tooltip' width='auto'>\n {tooltip}\n </Tooltip>\n }\n >\n {component}\n </OverlayTrigger>\n);\n\nexport type MapSettingsTileProps = {\n /**\n * Callback fired when the settings tile opens or closes.\n */\n onToggle?: (newState: boolean) => void;\n\n /**\n * Tooltip shown while the settings tile is closed.\n */\n tooltip?: React.ReactNode;\n\n /**\n * Custom panel rendered below the settings tile when it is open.\n */\n panel?: React.ReactNode;\n\n /**\n * Dropdown menu items rendered when the settings tile is open.\n */\n items?: JSX.Element[] | undefined;\n\n /**\n * Icon shown when the tile is active.\n */\n activeIcon?: JSX.Element | undefined;\n\n /**\n * Icon shown when the tile is inactive.\n */\n inactiveIcon?: JSX.Element | undefined;\n\n /**\n * Controls whether the active or inactive icon is shown.\n */\n isActive?: boolean;\n\n /**\n * Additional class name for the clickable settings button.\n */\n buttonClassName?: string;\n\n /**\n * Additional class name for the settings tile wrapper.\n */\n className?: string;\n};\n\nconst MapSettingsTile = (props: MapSettingsTileProps) => {\n const {\n onToggle = noop,\n activeIcon,\n inactiveIcon,\n isActive = false,\n panel,\n items,\n className,\n buttonClassName,\n tooltip,\n ...remainingProps\n } = props;\n\n const [isOpen, setIsOpen] = useState(false);\n\n const handleToggle = () => {\n const newState = !isOpen;\n setIsOpen(newState);\n onToggle(newState);\n\n buttonRef.current.blur();\n };\n\n const handleClosePanel = () => {\n if (isOpen && panel) {\n setIsOpen(false);\n onToggle(false);\n buttonRef.current.blur();\n }\n };\n\n const buttonRef = useClickOutside(handleClosePanel);\n\n const [toggleRef, setToggleRef] = useState<HTMLDivElement | null>(null);\n const [refDropdownMenu, setRefDropdownMenu] = useState<HTMLUListElement | null>(null);\n\n const { styles, attributes } = usePopper(toggleRef, refDropdownMenu, {\n placement: 'top-end',\n modifiers:\n isOpen && isMobileScreen()\n ? [\n {\n name: 'offset',\n options: {\n offset: [-60, -60],\n },\n },\n ]\n : [],\n });\n\n useClickOutsideWithRef(refDropdownMenu, (event: MouseEvent | TouchEvent) => {\n const target = event.target instanceof Node ? event.target : null;\n\n if (target && toggleRef?.contains(target)) {\n return;\n }\n\n if (isOpen) {\n setIsOpen(false);\n onToggle(false);\n }\n });\n\n const wrapperClasses = classNames('MapSettingsTile', className);\n\n const buttonClasses = classNames('MapSettingsButton', isOpen && 'active', buttonClassName);\n\n const activeIconClassNames = classNames(\n 'MapSettingsTileIcon',\n 'hover-scale-110',\n isActive ? 'display-block' : 'display-none',\n activeIcon?.props.className || ''\n );\n\n const inactiveIconClassNames = classNames(\n 'MapSettingsTileIcon',\n 'hover-scale-110',\n isActive ? 'display-none' : 'display-block',\n inactiveIcon?.props.className || ''\n );\n\n const button = (\n <div className={buttonClasses} onClick={handleToggle}>\n {activeIcon &&\n React.cloneElement(activeIcon, {\n className: activeIconClassNames,\n })}\n {inactiveIcon &&\n React.cloneElement(inactiveIcon, {\n className: inactiveIconClassNames,\n })}\n </div>\n );\n\n return (\n <div className={wrapperClasses} ref={buttonRef} {...remainingProps}>\n {/* backwards compatible way of still showing a panel without labels */}\n {!items && (\n <>\n {tooltip && !isOpen ? getComponentWithTooltip(button, tooltip) : button}\n <div className='overflow-hidden'>\n <AnimatePresence>\n {isOpen && panel && (\n <motion.div\n initial={tileAnimation.initial}\n animate={tileAnimation.animate}\n exit={tileAnimation.exit}\n transition={tileAnimation.transition}\n >\n {panel}\n </motion.div>\n )}\n </AnimatePresence>\n </div>\n </>\n )}\n {/* new way of showing a dropdown without labels */}\n {items && (\n <div className='MapSettingsTile-inner position-relative' ref={setToggleRef}>\n {tooltip && !isOpen ? getComponentWithTooltip(button, tooltip) : button}\n <AnimatePresence>\n {isOpen && items && (\n <motion.div\n className={classNames('dropdown', isOpen && 'open')}\n initial={tileAnimation.initial}\n animate={tileAnimation.animate}\n exit={tileAnimation.exit}\n transition={tileAnimation.transition}\n >\n <MenuItemList\n className='margin-bottom-5 shadow-smooth border-none'\n ref={setRefDropdownMenu}\n style={{ ...styles.popper, minWidth: '180px' }}\n {...attributes.popper}\n >\n {items?.map((item, index) => {\n if (item.type.isMapSettingsDropdownHeader) {\n return item;\n }\n return <MenuItem key={index} value={item} />;\n })}\n </MenuItemList>\n </motion.div>\n )}\n </AnimatePresence>\n </div>\n )}\n </div>\n );\n};\n\nexport default MapSettingsTile;\n"],"names":["TOOLTIP_SHOW_TIMEOUT_IN_MS","TOOLTIP_HIDE_TIMEOUT_IN_MS","tileAnimation","getComponentWithTooltip","component","tooltip","jsx","OverlayTrigger","Tooltip","MapSettingsTile","props","onToggle","noop","activeIcon","inactiveIcon","isActive","panel","items","className","buttonClassName","remainingProps","isOpen","setIsOpen","useState","handleToggle","newState","buttonRef","useClickOutside","toggleRef","setToggleRef","refDropdownMenu","setRefDropdownMenu","styles","attributes","usePopper","isMobileScreen","useClickOutsideWithRef","event","target","wrapperClasses","classNames","buttonClasses","activeIconClassNames","inactiveIconClassNames","button","jsxs","React","Fragment","AnimatePresence","motion","MenuItemList","item","index","MenuItem"],"mappings":";;;;;;;;;;;;AAaA,MAAMA,IAA6B,KAC7BC,IAA6B,KAE7BC,IAAgB;AAAA,EAClB,SAAS,EAAE,SAAS,GAAG,GAAG,GAAA;AAAA,EAC1B,SAAS,EAAE,SAAS,GAAG,GAAG,EAAA;AAAA,EAC1B,MAAM,EAAE,SAAS,GAAG,GAAG,GAAA;AAAA,EACvB,YAAY,EAAE,UAAU,MAAM,MAAM,UAAA;AACxC,GAEMC,IAA0B,CAACC,GAA4BC,MACzD,gBAAAC;AAAA,EAACC;AAAA,EAAA;AAAA,IACG,WAAWC,EAAQ;AAAA,IACnB,OAAO,EAAE,MAAMR,GAA4B,MAAMC,EAAA;AAAA,IACjD,SACI,gBAAAK,EAACE,GAAA,EAAQ,IAAG,WAAU,OAAM,QACvB,UAAAH,GACL;AAAA,IAGH,UAAAD;AAAA,EAAA;AACL,GAkDEK,KAAkB,CAACC,MAAgC;AACrD,QAAM;AAAA,IACF,UAAAC,IAAWC;AAAA,IACX,YAAAC;AAAA,IACA,cAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,OAAAC;AAAA,IACA,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,SAAAd;AAAA,IACA,GAAGe;AAAA,EAAA,IACHV,GAEE,CAACW,GAAQC,CAAS,IAAIC,EAAS,EAAK,GAEpCC,IAAe,MAAM;AACvB,UAAMC,IAAW,CAACJ;AAClB,IAAAC,EAAUG,CAAQ,GAClBd,EAASc,CAAQ,GAEjBC,EAAU,QAAQ,KAAA;AAAA,EACtB,GA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,CAC7C;AAAA,YAAA;AAAA,UAAA;AAAA,QACL;AAAA,MAAA,EACJ,CAER;AAAA,IAAA,EAAA,CACJ;AAAA,EAAA,GAER;AAER;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { default as MapSettingsTile } from '../MapSettingsTile';
|
|
3
|
+
export type MapPreviousViewportButtonProps = Omit<React.ComponentProps<typeof MapSettingsTile>, 'activeIcon' | 'inactiveIcon' | 'isActive' | 'onToggle'> & {
|
|
4
|
+
/**
|
|
5
|
+
* Callback fired after the map viewport history jumps back to the previous viewport.
|
|
6
|
+
*/
|
|
7
|
+
onGoBack?: () => void;
|
|
8
|
+
};
|
|
9
|
+
declare const MapPreviousViewportButton: (props: MapPreviousViewportButtonProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
10
|
+
export default MapPreviousViewportButton;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import c from "../MapSettingsTile.js";
|
|
3
|
+
import { useMapContext as s } from "../../../MapContext.js";
|
|
4
|
+
import { MapIcon as p } from "../../../../icons/MapIcon.js";
|
|
5
|
+
const g = (t) => {
|
|
6
|
+
const { onGoBack: r, ...e } = t, { viewportHistory: a } = s(), { canGoBack: n, goBack: i } = a;
|
|
7
|
+
return n ? /* @__PURE__ */ o(
|
|
8
|
+
c,
|
|
9
|
+
{
|
|
10
|
+
className: "MapPreviousViewportButton",
|
|
11
|
+
isActive: !0,
|
|
12
|
+
activeIcon: /* @__PURE__ */ o(p, { name: "rioglyph-arrow-left", className: "MapPreviousViewportButtonIcon text-color-gray" }),
|
|
13
|
+
onToggle: () => {
|
|
14
|
+
i(), r?.();
|
|
15
|
+
},
|
|
16
|
+
...e
|
|
17
|
+
}
|
|
18
|
+
) : null;
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
g as default
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=MapPreviousViewportButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapPreviousViewportButton.js","sources":["../../../../../../../src/components/map/components/features/settings/buttons/MapPreviousViewportButton.tsx"],"sourcesContent":["import type React from 'react';\n\nimport MapSettingsTile from '../MapSettingsTile';\nimport { useMapContext } from '../../../MapContext';\nimport { MapIcon } from '../../../../icons/MapIcon';\n\nexport type MapPreviousViewportButtonProps = Omit<\n React.ComponentProps<typeof MapSettingsTile>,\n 'activeIcon' | 'inactiveIcon' | 'isActive' | 'onToggle'\n> & {\n /**\n * Callback fired after the map viewport history jumps back to the previous viewport.\n */\n onGoBack?: () => void;\n};\n\nconst MapPreviousViewportButton = (props: MapPreviousViewportButtonProps) => {\n const { onGoBack, ...remainingProps } = props;\n const { viewportHistory } = useMapContext();\n const { canGoBack, goBack } = viewportHistory;\n\n if (!canGoBack) {\n return null;\n }\n\n const handleGoBack = () => {\n goBack();\n onGoBack?.();\n };\n\n return (\n <MapSettingsTile\n className='MapPreviousViewportButton'\n isActive\n activeIcon={\n <MapIcon name='rioglyph-arrow-left' className='MapPreviousViewportButtonIcon text-color-gray' />\n }\n onToggle={handleGoBack}\n {...remainingProps}\n />\n );\n};\n\nexport default MapPreviousViewportButton;\n"],"names":["MapPreviousViewportButton","props","onGoBack","remainingProps","viewportHistory","useMapContext","canGoBack","goBack","jsx","MapSettingsTile","MapIcon"],"mappings":";;;;AAgBA,MAAMA,IAA4B,CAACC,MAA0C;AACzE,QAAM,EAAE,UAAAC,GAAU,GAAGC,EAAA,IAAmBF,GAClC,EAAE,iBAAAG,EAAA,IAAoBC,EAAA,GACtB,EAAE,WAAAC,GAAW,QAAAC,EAAA,IAAWH;AAE9B,SAAKE,IAUD,gBAAAE;AAAA,IAACC;AAAA,IAAA;AAAA,MACG,WAAU;AAAA,MACV,UAAQ;AAAA,MACR,YACI,gBAAAD,EAACE,GAAA,EAAQ,MAAK,uBAAsB,WAAU,iDAAgD;AAAA,MAElG,UAZa,MAAM;AACvB,QAAAH,EAAA,GACAL,IAAA;AAAA,MACJ;AAAA,MAUS,GAAGC;AAAA,IAAA;AAAA,EAAA,IAhBD;AAmBf;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MapApi, Position } from '../utils/mapTypes';
|
|
2
|
+
export type MapViewport = {
|
|
3
|
+
center: Position;
|
|
4
|
+
zoom: number;
|
|
5
|
+
};
|
|
6
|
+
export type MapViewportHistory = {
|
|
7
|
+
entries: MapViewport[];
|
|
8
|
+
canGoBack: boolean;
|
|
9
|
+
goBack: () => void;
|
|
10
|
+
};
|
|
11
|
+
export type UseMapViewportHistoryOptions = {
|
|
12
|
+
maxEntries?: number;
|
|
13
|
+
centerDistanceThresholdMeters?: number;
|
|
14
|
+
zoomThreshold?: number;
|
|
15
|
+
zoomAnimation?: boolean;
|
|
16
|
+
controlledViewport?: MapViewport;
|
|
17
|
+
};
|
|
18
|
+
export declare const defaultMapViewportHistory: MapViewportHistory;
|
|
19
|
+
export declare const useMapViewportHistory: (api: MapApi | undefined, { maxEntries, centerDistanceThresholdMeters, zoomThreshold, zoomAnimation, controlledViewport, }?: UseMapViewportHistoryOptions) => MapViewportHistory;
|