@geops/rvf-mobility-web-component 0.1.46 → 0.1.47-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/.prettierrc.js +3 -1
  2. package/README.md +1 -1
  3. package/doc/package.json +4 -3
  4. package/doc/postcss.config.mjs +1 -1
  5. package/doc/src/app/components/GeopsMobilityDoc.tsx +13 -224
  6. package/doc/src/app/components/GeopsMobilitySearchDoc.tsx +11 -107
  7. package/doc/src/app/components/WebComponentDoc.tsx +45 -56
  8. package/doc/src/app/geops-mobility/page.tsx +7 -2
  9. package/doc/src/app/geops-mobility-search/page.tsx +6 -2
  10. package/doc/src/app/globals.css +47 -27
  11. package/doc/src/app/layout.tsx +4 -2
  12. package/docutils.js +33 -17
  13. package/eslint.config.mjs +28 -34
  14. package/iframe.html +5624 -201
  15. package/index.html +108 -88
  16. package/index.js +2229 -1976
  17. package/input.css +21 -3
  18. package/package.json +37 -40
  19. package/scripts/build.mjs +2 -2
  20. package/scripts/dev.mjs +3 -3
  21. package/search.html +70 -23
  22. package/src/BaseLayer/BaseLayer.tsx +2 -1
  23. package/src/Copyright/Copyright.tsx +4 -2
  24. package/src/DebugDeparture/DebugDeparture.tsx +16 -12
  25. package/src/DebugStop/DebugStop.tsx +2 -2
  26. package/src/Departure/Departure.tsx +2 -3
  27. package/src/EmbedNavigation/DragPanWarning.ts +125 -0
  28. package/src/EmbedNavigation/EmbedNavigation.tsx +52 -0
  29. package/src/EmbedNavigation/index.js +1 -0
  30. package/src/EmbedNavigation/index.tsx +1 -0
  31. package/src/GeolocationButton/GeolocationButton.tsx +11 -35
  32. package/src/GeolocationButton/index.tsx +1 -1
  33. package/src/Map/Map.tsx +5 -3
  34. package/src/MapDispatchEvents/MapDispatchEvents.tsx +78 -0
  35. package/src/MapDispatchEvents/index.tsx +1 -0
  36. package/src/MobilityMap/MobilityMap.tsx +117 -162
  37. package/src/MobilityMap/MobilityMapAttributes.test.ts +21 -0
  38. package/src/MobilityMap/MobilityMapAttributes.ts +243 -0
  39. package/src/MobilityMap/index.tsx +1 -0
  40. package/src/MobilitySearch/MobilitySearch.tsx +35 -0
  41. package/src/MobilitySearch/MobilitySearchAttributes.test.ts +21 -0
  42. package/src/MobilitySearch/MobilitySearchAttributes.ts +68 -0
  43. package/src/MobilitySearch/index.ts +2 -0
  44. package/src/NotificationLayer/NotificationLayer.tsx +27 -4
  45. package/src/Overlay/Overlay.tsx +24 -11
  46. package/src/Permalink/Permalink.tsx +77 -0
  47. package/src/Permalink/index.tsx +1 -0
  48. package/src/RealtimeLayer/RealtimeLayer.tsx +72 -33
  49. package/src/RouteDestination/RouteDestination.tsx +3 -3
  50. package/src/RouteIcon/RouteIcon.tsx +33 -25
  51. package/src/RouteIcon/index.tsx +1 -1
  52. package/src/RouteIdentifier/RouteIdentifer.tsx +6 -5
  53. package/src/RouteInfos/RouteInfos.tsx +7 -3
  54. package/src/RouteSchedule/RouteSchedule.tsx +3 -3
  55. package/src/RouteScheduleFooter/RouteScheduleFooter.tsx +1 -1
  56. package/src/RouteScheduleHeader/RouteScheduleHeader.tsx +7 -29
  57. package/src/RouteStop/RouteStop.tsx +8 -11
  58. package/src/RouteStopDelay/RouteStopDelay.tsx +2 -1
  59. package/src/RouteStopName/RouteStopName.tsx +2 -2
  60. package/src/RouteStopPlatform/RouteStopPlatform.tsx +2 -2
  61. package/src/RouteStopProgress/RouteStopProgress.tsx +2 -1
  62. package/src/RouteStopServices/RouteStopServices.tsx +2 -2
  63. package/src/RouteStopStation/RouteStopStation.tsx +8 -2
  64. package/src/RouteStopTime/RouteStopTime.tsx +2 -1
  65. package/src/RvfButton/RvfButton.tsx +14 -5
  66. package/src/RvfCheckbox/RvfCheckbox.tsx +8 -8
  67. package/src/RvfEmbedNavigation/DragPanWarning.ts +5 -5
  68. package/src/RvfEmbedNavigation/RvfEmbedNavigation.tsx +1 -0
  69. package/src/RvfExportMenu/RvfExportMenu.tsx +14 -12
  70. package/src/RvfExportMenuButton/RvfExportMenuButton.tsx +6 -7
  71. package/src/RvfFeatureDetails/RvfFeatureDetails.tsx +5 -5
  72. package/src/RvfFeatureDetails/RvfLineNetworkDetails/RvfLineNetworkDetails.tsx +164 -138
  73. package/src/RvfFeatureDetails/RvfNotificationDetails/RvfNotificationDetails.tsx +151 -109
  74. package/src/RvfFeatureDetails/RvfSellingPointDetails/RvfSellingPointDetails.tsx +2 -2
  75. package/src/RvfFeatureDetails/RvfSharedMobilityDetail/FloatingVehiclesDetails/FloatingVehiclesDetails.tsx +3 -3
  76. package/src/RvfFeatureDetails/RvfSharedMobilityDetail/RvfSharedMobilityDetails.tsx +8 -6
  77. package/src/RvfFeatureDetails/RvfSharedMobilityDetail/StationDetails/StationDetails.tsx +5 -4
  78. package/src/RvfFeatureDetailsTitle/RvfFeatureDetailsTitle.tsx +81 -0
  79. package/src/RvfFeatureDetailsTitle/index.tsx +1 -0
  80. package/src/RvfFloatingMenu/RvfFloatingMenu.tsx +4 -4
  81. package/src/RvfGeolocationButton/GeolocationButton.tsx +98 -0
  82. package/src/RvfGeolocationButton/index.tsx +1 -0
  83. package/src/RvfIconButton/RvfIconButton.tsx +20 -9
  84. package/src/RvfInputCopy/RvfInputCopy.tsx +8 -8
  85. package/src/RvfLayerTree/RvfLayerTree.tsx +5 -2
  86. package/src/RvfLayerTree/TreeItem/TreeItem.tsx +13 -16
  87. package/src/RvfLayerTree/layersTreeReducer.ts +23 -18
  88. package/src/RvfLayerTreeButton/RvfLayerTreeButton.tsx +6 -6
  89. package/src/RvfLineNetworkPlanLayer/RvfLineNetworkPlanLayer.tsx +2 -1
  90. package/src/RvfLink/RvfLink.tsx +4 -3
  91. package/src/RvfMobilityMap/RvfMobilityMap.tsx +314 -322
  92. package/src/RvfModal/RvfModal.tsx +4 -3
  93. package/src/RvfOverlayContent/RvfOverlayContent.tsx +126 -0
  94. package/src/RvfOverlayContent/index.ts +0 -0
  95. package/src/RvfOverlayHeader/RvfOverlayHeader.tsx +13 -10
  96. package/src/RvfPermalink/RvfPermalink.tsx +2 -2
  97. package/src/RvfPoisLayer/RvfPoisLayer.tsx +2 -1
  98. package/src/RvfRadioButton/RvfRadioButton.tsx +1 -1
  99. package/src/RvfRouteIcon/RvfRouteIcon.tsx +10 -0
  100. package/src/RvfRouteIcon/index.tsx +1 -0
  101. package/src/RvfSearch/RvfSearch.tsx +4 -1
  102. package/src/RvfSearchButton/RvfSearchButton.tsx +27 -0
  103. package/src/RvfSearchButton/index.tsx +1 -0
  104. package/src/RvfSelect/RvfSelect.tsx +7 -5
  105. package/src/RvfSelectedFeatureHighlightLayer/RvfSelectedFeatureHighlightLayer.tsx +1 -2
  106. package/src/RvfSellingPointsLayer/RvfSellingPointsLayer.tsx +2 -1
  107. package/src/RvfShare/RvfPermalinkButton/RvfPermalinkButton.tsx +13 -12
  108. package/src/RvfShare/RvfShare.tsx +11 -10
  109. package/src/RvfShareMenuButton/RvfShareMenuButton.tsx +5 -5
  110. package/src/RvfSharedMobilityLayerGroup/RvfSharedMobilityLayerGroup.tsx +25 -22
  111. package/src/RvfSingleClickListener/RvfSingleClickListener.tsx +46 -31
  112. package/src/RvfTarifZonenLayer/RvfTarifZonenLayer.tsx +2 -1
  113. package/src/RvfTopics/RvfTopics.tsx +6 -5
  114. package/src/RvfZoomButtons/RvfZoomButtons.tsx +3 -3
  115. package/src/ScaleLine/ScaleLine.tsx +5 -4
  116. package/src/ScrollableHandler/ScrollableHandler.tsx +2 -1
  117. package/src/ScrollableHandler/index.tsx +1 -1
  118. package/src/SingleClickListener/SingleClickListener.tsx +47 -4
  119. package/src/Station/Station.tsx +5 -5
  120. package/src/StationName/StationName.tsx +3 -3
  121. package/src/StationServices/StationServices.tsx +3 -3
  122. package/src/StationsLayer/StationsLayer.tsx +5 -4
  123. package/src/StopsSearch/StopsSearch.tsx +115 -84
  124. package/src/WindowMessageListener/WindowMessageListener.tsx +67 -0
  125. package/src/WindowMessageListener/index.tsx +1 -0
  126. package/src/icons/Airport/Airport.tsx +4 -4
  127. package/src/icons/ArrowDown/ArrowDown.tsx +1 -1
  128. package/src/icons/ArrowUp/ArrowUp.tsx +1 -1
  129. package/src/icons/ArrowUpRight/ArrowUpRight.tsx +1 -1
  130. package/src/icons/BarAndRestaurants/BarAndRestaurants.tsx +2 -2
  131. package/src/icons/Bathroom/Bathroom.tsx +1 -1
  132. package/src/icons/Copy/Copy.tsx +1 -1
  133. package/src/icons/Doc/Doc.tsx +1 -1
  134. package/src/icons/Email/Email.tsx +1 -1
  135. package/src/icons/FilePdf/FilePdf.tsx +1 -1
  136. package/src/icons/Geolocation/Geolocation.tsx +3 -5
  137. package/src/icons/Image/Image.tsx +1 -1
  138. package/src/icons/Menu/Menu.tsx +1 -1
  139. package/src/icons/Minus/Minus.tsx +1 -1
  140. package/src/icons/NoRealtime/NoRealtime.tsx +1 -1
  141. package/src/icons/Plus/Plus.tsx +1 -1
  142. package/src/icons/Police/Police.tsx +3 -3
  143. package/src/icons/Share/Share.tsx +1 -1
  144. package/src/icons/Stack/Stack.tsx +1 -1
  145. package/src/icons/Tracking/Tracking.tsx +29 -0
  146. package/src/icons/Tracking/airport-14-svgrepo-com.svg +41 -0
  147. package/src/icons/Tracking/index.tsx +1 -0
  148. package/src/icons/WaitingAreas/WaitingAreas.tsx +1 -1
  149. package/src/icons/WheelChair/WheelChair.tsx +1 -1
  150. package/src/index.tsx +8 -46
  151. package/src/indexDoc.ts +13 -0
  152. package/src/ui/Button/Button.tsx +57 -0
  153. package/src/ui/Button/index.tsx +1 -0
  154. package/src/ui/IconButton/IconButton.tsx +44 -0
  155. package/src/ui/IconButton/index.tsx +1 -0
  156. package/src/utils/MobilityEvent.ts +4 -3
  157. package/src/utils/applyInitialLayerVisibility.ts +3 -3
  158. package/src/utils/centerOnStation.ts +3 -2
  159. package/src/utils/centerOnVehicle.ts +5 -4
  160. package/src/utils/constants.ts +17 -3
  161. package/src/utils/exportPdf.ts +26 -20
  162. package/src/utils/fullTrajectoryStyle.ts +2 -2
  163. package/src/utils/getAllLayers.ts +4 -3
  164. package/src/utils/getDelayColor.test.ts +1 -0
  165. package/src/utils/getDelayColorForVehicle.test.ts +2 -0
  166. package/src/utils/getDelayString.test.ts +3 -0
  167. package/src/utils/getDelayTextForVehicle.test.ts +4 -0
  168. package/src/utils/getFullTrajectoryAndFit.ts +4 -3
  169. package/src/utils/getHoursAndMinutes.test.ts +1 -0
  170. package/src/utils/getLayersAsFlatArray.ts +2 -2
  171. package/src/utils/getLinkByDevice.ts +1 -1
  172. package/src/utils/getMainColorForVehicle.ts +3 -3
  173. package/src/utils/getPermalinkParameters.ts +2 -2
  174. package/src/utils/getStopStatus.test.ts +2 -1
  175. package/src/utils/getStopStatus.ts +1 -1
  176. package/src/utils/getTextForVehicle.ts +1 -1
  177. package/src/utils/hooks/useDeparture.tsx +6 -5
  178. package/src/utils/hooks/useI18n.tsx +6 -4
  179. package/src/utils/hooks/useInitialLayersVisiblity.tsx +2 -1
  180. package/src/utils/hooks/useLayerConfig.tsx +39 -0
  181. package/src/utils/hooks/useMapContext.tsx +30 -18
  182. package/src/utils/hooks/useRouteStop.tsx +3 -2
  183. package/src/utils/hooks/useRvfContext.tsx +11 -3
  184. package/src/utils/hooks/useStation.tsx +2 -1
  185. package/src/utils/hooks/useUpdatePermalink.tsx +25 -24
  186. package/src/utils/hooks/useZoom.tsx +4 -4
  187. package/src/utils/realtimeRVFStyle.ts +5 -4
  188. package/src/utils/sharingGraphqlUtils.ts +3 -2
  189. package/src/utils/sharingStylesUtils.ts +7 -7
  190. package/src/utils/sharingWFSUtils.ts +9 -15
  191. package/tailwind.config.mjs +1 -0
  192. package/tsconfig.json +1 -1
  193. package/doc/tailwind.config.ts +0 -20
  194. package/src/utils/getFeatureInformationTitle.tsx +0 -54
@@ -1,10 +1,11 @@
1
- import { Map } from "ol";
2
1
  import { unByKey } from "ol/Observable";
3
2
  import { useEffect } from "preact/hooks";
4
3
 
5
4
  import applyInitialLayerVisibility from "../applyInitialLayerVisibility";
6
5
  import getLayersAsFlatArray from "../getLayersAsFlatArray";
7
6
 
7
+ import type { Map } from "ol";
8
+
8
9
  const useInitialLayersVisiblity = (map: Map, layers: string) => {
9
10
  // Apply initial visibility of layers from layers attribute
10
11
  useEffect(() => {
@@ -0,0 +1,39 @@
1
+ import { useEffect, useState } from "preact/hooks";
2
+
3
+ import { RVF_LAYERS_TITLES } from "../constants";
4
+
5
+ import useMapContext from "./useMapContext";
6
+
7
+ export interface LayerConfig {
8
+ link?: {
9
+ href?: string;
10
+ text?: string;
11
+ };
12
+ title?: string;
13
+ }
14
+ export type LayersConfig = Record<string, LayerConfig>;
15
+
16
+ function useLayerConfig(layerName) {
17
+ const { layersconfig } = useMapContext();
18
+ const [layersConfig, setLayersConfig] = useState<LayersConfig>({});
19
+
20
+ useEffect(() => {
21
+ try {
22
+ const config = JSON.parse(layersconfig || "{}");
23
+ setLayersConfig(config);
24
+ } catch (error) {
25
+ // eslint-disable-next-line no-console
26
+ console.error("Error parsing layersconfig:", error);
27
+ }
28
+ }, [layersconfig]);
29
+
30
+ // Set defaultstyle if not present in layersconfig
31
+ const layerConfig = layersConfig[layerName] || ({} as LayerConfig);
32
+ if (!layerConfig.title) {
33
+ layerConfig.title = RVF_LAYERS_TITLES[layerName];
34
+ }
35
+
36
+ return layerConfig;
37
+ }
38
+
39
+ export default useLayerConfig;
@@ -1,37 +1,47 @@
1
- /* eslint-disable @typescript-eslint/no-empty-function */
2
- import {
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import { createContext } from "preact";
3
+ import { useContext } from "preact/hooks";
4
+
5
+ import type {
3
6
  MaplibreLayer,
4
7
  MaplibreStyleLayer,
5
8
  RealtimeLayer,
6
9
  } from "mobility-toolbox-js/ol";
7
- import {
8
- MocoNotification,
10
+ import type {
9
11
  RealtimeStation,
10
12
  RealtimeStationId,
11
13
  RealtimeStopSequence,
12
14
  RealtimeTrainId,
15
+ SituationType,
13
16
  } from "mobility-toolbox-js/types";
14
- import { Map } from "ol";
15
- import { createContext } from "preact";
16
- /* eslint-disable @typescript-eslint/no-unused-vars */
17
- import { useContext } from "preact/hooks";
17
+ import type { Feature, Map } from "ol";
18
18
 
19
19
  import type { MobilityMapProps } from "../../MobilityMap/MobilityMap";
20
20
 
21
21
  export type MapContextType = {
22
22
  baseLayer: MaplibreLayer;
23
+ isEmbed: boolean;
23
24
  isFollowing: boolean;
24
25
  isTracking: boolean;
25
26
  layers: string;
26
27
  map: Map;
27
- previewNotification?: MocoNotification;
28
+ permalinkUrlSearchParams: URLSearchParams;
29
+ previewNotifications?: SituationType[];
30
+ queryablelayers: string;
28
31
  realtimeLayer: RealtimeLayer;
32
+ selectedFeature: Feature;
33
+ selectedFeatures: Feature[];
29
34
  setBaseLayer: (baseLayer: MaplibreLayer) => void;
30
35
  setIsFollowing: (isFollowing: boolean) => void;
31
36
  setIsTracking: (isTracking: boolean) => void;
32
37
  setMap: (map?: Map) => void;
33
- setPreviewNotification: (previewNotification?: MocoNotification) => void;
38
+ setPermalinkUrlSearchParams: (
39
+ permalinkUrlSearchParams: URLSearchParams,
40
+ ) => void;
41
+ setPreviewNotifications: (setPreviewNotifications?: SituationType[]) => void;
34
42
  setRealtimeLayer: (realtimeLayer?: RealtimeLayer) => void;
43
+ setSelectedFeature: (feature: Feature) => void;
44
+ setSelectedFeatures: (features: Feature[]) => void;
35
45
  setStation: (station?: RealtimeStation) => void;
36
46
  setStationId: (stationId?: RealtimeStationId) => void;
37
47
  setStationsLayer: (stationsLayer?: MaplibreStyleLayer) => void;
@@ -45,29 +55,31 @@ export type MapContextType = {
45
55
  } & MobilityMapProps;
46
56
 
47
57
  export const MapContext = createContext<MapContextType>({
48
- baseLayer: null,
58
+ isEmbed: false,
49
59
  isFollowing: false,
50
60
  isTracking: false,
51
61
  layers: null,
52
62
  map: null,
53
- previewNotification: null,
63
+ previewNotifications: null,
64
+ queryablelayers: null,
54
65
  realtimeLayer: null,
66
+ selectedFeatures: [],
55
67
  setBaseLayer: (baseLayer?: MaplibreLayer) => {},
56
68
  setIsFollowing: (isFollowing: boolean) => {},
57
69
  setIsTracking: (isTracking: boolean) => {},
58
70
  setMap: (map?: Map) => {},
59
- setPreviewNotification: (previewNotification?: MocoNotification) => {},
71
+ setPermalinkUrlSearchParams: (
72
+ permalinkUrlSearchParams: URLSearchParams,
73
+ ) => {},
74
+ setPreviewNotifications: (previewNotifications?: SituationType[]) => {},
60
75
  setRealtimeLayer: (realtimeLayer?: RealtimeLayer) => {},
76
+ setSelectedFeature: (feature: Feature) => {},
77
+ setSelectedFeatures: (features: Feature[]) => {},
61
78
  setStation: (station?: RealtimeStation) => {},
62
79
  setStationId: (stationId?: RealtimeStationId) => {},
63
80
  setStationsLayer: (stationsLayer?: MaplibreStyleLayer) => {},
64
81
  setStopSequence: (stopSequence?: RealtimeStopSequence) => {},
65
82
  setTrainId: (trainId?: RealtimeTrainId) => {},
66
- station: null,
67
- stationId: null,
68
- stationsLayer: null,
69
- stopSequence: null,
70
- trainId: null,
71
83
  } as MapContextType);
72
84
 
73
85
  const useMapContext = (): MapContextType => {
@@ -1,8 +1,9 @@
1
- import { RealtimeStation, RealtimeStop } from "mobility-toolbox-js/types";
2
1
  import { createContext } from "preact";
3
2
  import { useContext } from "preact/hooks";
4
3
 
5
- import { StopStatus } from "../getStopStatus";
4
+ import type { RealtimeStation, RealtimeStop } from "mobility-toolbox-js/types";
5
+
6
+ import type { StopStatus } from "../getStopStatus";
6
7
 
7
8
  export interface RouteStopContextType {
8
9
  index?: number;
@@ -1,12 +1,15 @@
1
- import { MaplibreStyleLayer } from "mobility-toolbox-js/ol";
2
- import { Feature } from "ol";
3
- import { Group } from "ol/layer";
1
+ /* eslint-disable no-console */
4
2
  import { createContext } from "preact";
5
3
  import { useContext } from "preact/hooks";
6
4
 
5
+ import type { MaplibreStyleLayer } from "mobility-toolbox-js/ol";
6
+ import type { Feature } from "ol";
7
+ import type { Group } from "ol/layer";
8
+
7
9
  export interface RvfContextType {
8
10
  isExportMenuOpen: boolean;
9
11
  isLayerTreeOpen: boolean;
12
+ isSearchOpen: boolean;
10
13
  isShareMenuOpen: boolean;
11
14
  lineNetworkPlanLayer: MaplibreStyleLayer;
12
15
  poisLayer: MaplibreStyleLayer;
@@ -15,6 +18,7 @@ export interface RvfContextType {
15
18
  sellingPointsLayer: MaplibreStyleLayer;
16
19
  setIsExportMenuOpen: (isOpen: boolean) => void;
17
20
  setIsLayerTreeOpen: (isOpen: boolean) => void;
21
+ setIsSearchOpen: (isOpen: boolean) => void;
18
22
  setIsShareMenuOpen: (isOpen: boolean) => void;
19
23
  setLineNetworkPlanLayer: (layer: MaplibreStyleLayer) => void;
20
24
  setPoisLayer: (layer: MaplibreStyleLayer) => void;
@@ -30,6 +34,7 @@ export interface RvfContextType {
30
34
  export const RvfContext = createContext<RvfContextType>({
31
35
  isExportMenuOpen: false,
32
36
  isLayerTreeOpen: false,
37
+ isSearchOpen: false,
33
38
  isShareMenuOpen: false,
34
39
  lineNetworkPlanLayer: null,
35
40
  poisLayer: null,
@@ -42,6 +47,9 @@ export const RvfContext = createContext<RvfContextType>({
42
47
  setIsLayerTreeOpen: () => {
43
48
  console.warn("setIsLayerTreeOpen is not implemented");
44
49
  },
50
+ setIsSearchOpen: () => {
51
+ console.warn("setIsSearchOpen is not implemented");
52
+ },
45
53
  setIsShareMenuOpen: () => {
46
54
  console.warn("setIsShareMenuOpen is not implemented");
47
55
  },
@@ -1,7 +1,8 @@
1
- import { RealtimeStation } from "mobility-toolbox-js/types";
2
1
  import { createContext } from "preact";
3
2
  import { useContext } from "preact/hooks";
4
3
 
4
+ import type { RealtimeStation } from "mobility-toolbox-js/types";
5
+
5
6
  export interface StationContextType {
6
7
  station?: RealtimeStation;
7
8
  }
@@ -1,18 +1,38 @@
1
1
  import debounce from "lodash.debounce";
2
- import { Map } from "ol";
3
- import { EventsKey } from "ol/events";
2
+ import { getLayersAsFlatArray } from "mobility-toolbox-js/ol";
4
3
  import { unByKey } from "ol/Observable";
5
- import { MutableRef, useEffect } from "preact/hooks";
4
+ import { useEffect } from "preact/hooks";
6
5
 
7
6
  import { LAYER_PROP_IS_EXPORTING } from "../constants";
8
- import getLayersAsFlatArray from "../getLayersAsFlatArray";
9
7
  import getPermalinkParameters from "../getPermalinkParameters";
10
8
  import MobilityEvent from "../MobilityEvent";
11
9
 
10
+ import type { Map } from "ol";
11
+ import type { EventsKey } from "ol/events";
12
+ import type { MutableRef } from "preact/hooks";
13
+
14
+ const updatePermalink = (
15
+ map: Map,
16
+ eventNodeRef: MutableRef<HTMLDivElement>,
17
+ ) => {
18
+ // No update when exporting
19
+ if (map.get(LAYER_PROP_IS_EXPORTING)) {
20
+ return;
21
+ }
22
+ const currentUrlParams = new URLSearchParams(window.location.search);
23
+ const urlParams = getPermalinkParameters(map, currentUrlParams);
24
+ urlParams.set("permalink", "true");
25
+ window.history.replaceState(null, null, `?${urlParams.toString()}`);
26
+ eventNodeRef?.current?.dispatchEvent(
27
+ new MobilityEvent<string>("mwc:permalink", window.location.href),
28
+ );
29
+ };
30
+
31
+ const updatePermalinkDebounced = debounce(updatePermalink, 1000);
32
+
12
33
  /**
13
34
  * This hook only update parameters in the url, it does not apply the url parameters.
14
35
  */
15
-
16
36
  const useUpdatePermalink = (
17
37
  map: Map,
18
38
  permalink: boolean,
@@ -53,23 +73,4 @@ const useUpdatePermalink = (
53
73
  return null;
54
74
  };
55
75
 
56
- const updatePermalink = (
57
- map: Map,
58
- eventNodeRef: MutableRef<HTMLDivElement>,
59
- ) => {
60
- // No update when exporting
61
- if (map.get(LAYER_PROP_IS_EXPORTING)) {
62
- return;
63
- }
64
- const currentUrlParams = new URLSearchParams(window.location.search);
65
- const urlParams = getPermalinkParameters(map, currentUrlParams);
66
- urlParams.set("permalink", "true");
67
- window.history.replaceState(null, null, `?${urlParams.toString()}`);
68
- eventNodeRef?.current?.dispatchEvent(
69
- new MobilityEvent<string>("mwc:permalink", window.location.href),
70
- );
71
- };
72
-
73
- const updatePermalinkDebounced = debounce(updatePermalink, 1000);
74
-
75
76
  export default useUpdatePermalink;
@@ -24,12 +24,12 @@ const useZoom = () => {
24
24
  let zoomListener = view.on("change:resolution", onZoomChange);
25
25
 
26
26
  const key = map.on("change:view", () => {
27
- const view = map.getView();
27
+ const vieww = map.getView();
28
28
  unByKey(zoomListener);
29
- if (view) {
30
- setZoom(view.getZoom());
29
+ if (vieww) {
30
+ setZoom(vieww.getZoom());
31
31
  }
32
- zoomListener = view.on("change:resolution", onZoomChange);
32
+ zoomListener = vieww.on("change:resolution", onZoomChange);
33
33
  });
34
34
 
35
35
  return () => {
@@ -1,5 +1,9 @@
1
1
  import { createCanvas } from "mobility-toolbox-js/ol";
2
- import {
2
+
3
+ // @ts-expect-error - svg loaded as dataurl
4
+ import noRealtime from "../icons/NoRealtime/norealtime.svg";
5
+
6
+ import type {
3
7
  AnyCanvasContext,
4
8
  RealtimeStyleFunction,
5
9
  RealtimeStyleOptions,
@@ -7,9 +11,6 @@ import {
7
11
  StyleCache,
8
12
  ViewState,
9
13
  } from "mobility-toolbox-js/types";
10
-
11
- // @ts-expect-error - svg loaded as dataurl
12
- import noRealtime from "../icons/NoRealtime/norealtime.svg";
13
14
  const cacheNoRealtime: StyleCache = {};
14
15
 
15
16
  const image = new Image(42, 42); // Using optional size for image
@@ -1,9 +1,10 @@
1
- import { FeatureCollection, Point } from "geojson";
2
1
  import { gql, GraphQLClient } from "graphql-request";
3
- import { Extent } from "ol/extent";
4
2
 
5
3
  import { RVF_EXTENT_4326 } from "./constants";
6
4
 
5
+ import type { FeatureCollection, Point } from "geojson";
6
+ import type { Extent } from "ol/extent";
7
+
7
8
  const GQL_URL = "https://api.mobidata-bw.de/sharing/graphql";
8
9
 
9
10
  export interface SharingStation {
@@ -4,7 +4,7 @@ export const getSharingStyleLayers = (
4
4
  ) => {
5
5
  return [
6
6
  {
7
- id: sourceId + "_circle",
7
+ id: `${sourceId}_circle`,
8
8
  maxZoom: 16,
9
9
  minzoom: 14,
10
10
  paint: {
@@ -17,7 +17,7 @@ export const getSharingStyleLayers = (
17
17
  type: "circle",
18
18
  },
19
19
  {
20
- id: sourceId + "_image_text",
20
+ id: `${sourceId}_image_text`,
21
21
  layout: {
22
22
  "icon-image": image,
23
23
  "icon-size": 1,
@@ -51,7 +51,7 @@ export const getSharingStyleLayers = (
51
51
  },
52
52
  {
53
53
  filter: ["==", "is_free_float", false],
54
- id: sourceId + "_availability",
54
+ id: `${sourceId}_availability`,
55
55
  layout: {
56
56
  "icon-allow-overlap": true,
57
57
  "icon-anchor": "center",
@@ -86,7 +86,7 @@ export const getSharingStyleLayers = (
86
86
  // freefloat style
87
87
  {
88
88
  filter: ["==", "is_free_float", true],
89
- id: sourceId + "_availability_freefloat",
89
+ id: `${sourceId}_availability_freefloat`,
90
90
  layout: {
91
91
  "icon-allow-overlap": true,
92
92
  "icon-anchor": "center",
@@ -122,7 +122,7 @@ export const getSharingClusterStyleLayers = (
122
122
  ) => {
123
123
  return [
124
124
  {
125
- id: sourceId + "_image_text",
125
+ id: `${sourceId}_image_text`,
126
126
  layout: {
127
127
  "icon-allow-overlap": true,
128
128
  "icon-ignore-placement": true,
@@ -161,7 +161,7 @@ export const getSharingClusterStyleLayers = (
161
161
  // cluster style
162
162
  {
163
163
  filter: ["has", "point_count"],
164
- id: sourceId + "_availability2",
164
+ id: `${sourceId}_availability2`,
165
165
  layout: {
166
166
  "icon-allow-overlap": true,
167
167
  "icon-anchor": "center",
@@ -191,7 +191,7 @@ export const getSharingClusterStyleLayers = (
191
191
  // non cluster style
192
192
  {
193
193
  filter: ["!", ["has", "point_count"]],
194
- id: sourceId + "_availability3",
194
+ id: `${sourceId}_availability3`,
195
195
  layout: {
196
196
  "icon-allow-overlap": true,
197
197
  "icon-anchor": "center",
@@ -1,8 +1,8 @@
1
- import { Feature, FeatureCollection, Point } from "geojson";
2
- import { Extent } from "ol/extent";
3
-
4
1
  import { PROVIDER_BY_FEED_ID, RVF_EXTENT_4326 } from "./constants";
5
2
 
3
+ import type { Feature, FeatureCollection, Point } from "geojson";
4
+ import type { Extent } from "ol/extent";
5
+
6
6
  // This info are added on each request
7
7
  export interface SharingDynamicInfo {
8
8
  display_num_vehicles_available: boolean; // added dynamically, used to avoid display this info when printing
@@ -51,18 +51,12 @@ export const getSharingWFSUrl = (
51
51
  extent4326: Extent = RVF_EXTENT_4326,
52
52
  ) => {
53
53
  return (
54
- "https://api.mobidata-bw.de/geoserver/MobiData-BW/" +
55
- wfsTypeName +
56
- "/ows" +
57
- "?service=WFS&" +
58
- "version=1.1.0&request=GetFeature&typename=" +
59
- "MobiData-BW:" +
60
- wfsTypeName +
61
- "&" +
62
- "outputFormat=application/json&" +
63
- "bbox=" +
64
- extent4326.toString() +
65
- ",EPSG:4326"
54
+ `https://api.mobidata-bw.de/geoserver/MobiData-BW/${wfsTypeName}/ows` +
55
+ `?service=WFS&` +
56
+ `version=1.1.0&request=GetFeature&typename=` +
57
+ `MobiData-BW:${wfsTypeName}&` +
58
+ `outputFormat=application/json&` +
59
+ `bbox=${extent4326.toString()},EPSG:4326`
66
60
  );
67
61
  };
68
62
 
@@ -62,6 +62,7 @@ export default {
62
62
  ultralightgrey: "#F5F5F5", // ultralight grey
63
63
  },
64
64
  rounded: {
65
+ "2xl": "16px",
65
66
  xl: "12px",
66
67
  },
67
68
  width: {
package/tsconfig.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "resolveJsonModule": true,
7
7
  "downlevelIteration": true,
8
8
  "lib": ["ES2015"],
9
- },
9
+ },
10
10
  "exclude": ["node_modules", "**/*.png"],
11
11
  "types": ["esbuild-style-plugin"]
12
12
  }
@@ -1,20 +0,0 @@
1
- import type { Config } from "tailwindcss";
2
-
3
- const config: Config = {
4
- content: [
5
- "./src/pages/**/*.{js,ts,jsx,tsx,mdx}",
6
- "./src/components/**/*.{js,ts,jsx,tsx,mdx}",
7
- "./src/app/**/*.{js,ts,jsx,tsx,mdx}",
8
- ],
9
- plugins: [],
10
- theme: {
11
- extend: {
12
- colors: {},
13
- fontFamily: {
14
- sans: ["Lato", "sans-serif"],
15
- serif: ["Merriweather", "serif"],
16
- },
17
- },
18
- },
19
- };
20
- export default config;
@@ -1,54 +0,0 @@
1
- import { Feature } from "ol";
2
-
3
- import { icons } from "./addSourceAndLayers";
4
- import {
5
- RVF_LAYERS_TITLES,
6
- TITLE_BY_CATEGORY,
7
- TITLE_BY_FEED_ID,
8
- } from "./constants";
9
-
10
- const defaultTitle = "Informations";
11
-
12
- const getFeatureInformationTitle = (feature: Feature) => {
13
- const features = feature.get("features");
14
- const selectedFeature = features?.[0] || feature;
15
- const {
16
- category,
17
- disruption_type: disruptionType,
18
- feed_id: feedId,
19
- line_id: lineId,
20
- tickets,
21
- title,
22
- } = selectedFeature.getProperties();
23
-
24
- if (disruptionType) {
25
- return (
26
- <div className={"flex items-center gap-2 text-sm"}>
27
- <div className="min-w-8 shrink-0 grow-0">
28
- <img
29
- alt={disruptionType}
30
- className={"w-8"}
31
- src={icons[disruptionType]}
32
- ></img>
33
- </div>
34
- <div className={"flex flex-col gap-2 text-base font-bold"}>{title}</div>
35
- </div>
36
- );
37
- }
38
- if (category) {
39
- return TITLE_BY_CATEGORY[category] || defaultTitle;
40
- }
41
- if (feedId) {
42
- return TITLE_BY_FEED_ID[feedId] || defaultTitle;
43
- }
44
-
45
- if (lineId) {
46
- return RVF_LAYERS_TITLES.liniennetz;
47
- }
48
- if (tickets) {
49
- return RVF_LAYERS_TITLES.verkaufsstellen;
50
- }
51
- return defaultTitle;
52
- };
53
-
54
- export default getFeatureInformationTitle;