@geops/rvf-mobility-web-component 0.1.45 → 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 (195) hide show
  1. package/.prettierrc.js +3 -1
  2. package/CHANGELOG.md +7 -0
  3. package/README.md +1 -1
  4. package/doc/package.json +4 -3
  5. package/doc/postcss.config.mjs +1 -1
  6. package/doc/src/app/components/GeopsMobilityDoc.tsx +13 -224
  7. package/doc/src/app/components/GeopsMobilitySearchDoc.tsx +11 -107
  8. package/doc/src/app/components/WebComponentDoc.tsx +45 -56
  9. package/doc/src/app/geops-mobility/page.tsx +7 -2
  10. package/doc/src/app/geops-mobility-search/page.tsx +6 -2
  11. package/doc/src/app/globals.css +47 -27
  12. package/doc/src/app/layout.tsx +4 -2
  13. package/docutils.js +33 -17
  14. package/eslint.config.mjs +28 -34
  15. package/iframe.html +5624 -201
  16. package/index.html +108 -88
  17. package/index.js +2229 -1976
  18. package/input.css +21 -3
  19. package/package.json +37 -40
  20. package/scripts/build.mjs +2 -2
  21. package/scripts/dev.mjs +3 -3
  22. package/search.html +70 -23
  23. package/src/BaseLayer/BaseLayer.tsx +2 -1
  24. package/src/Copyright/Copyright.tsx +4 -2
  25. package/src/DebugDeparture/DebugDeparture.tsx +16 -12
  26. package/src/DebugStop/DebugStop.tsx +2 -2
  27. package/src/Departure/Departure.tsx +2 -3
  28. package/src/EmbedNavigation/DragPanWarning.ts +125 -0
  29. package/src/EmbedNavigation/EmbedNavigation.tsx +52 -0
  30. package/src/EmbedNavigation/index.js +1 -0
  31. package/src/EmbedNavigation/index.tsx +1 -0
  32. package/src/GeolocationButton/GeolocationButton.tsx +11 -35
  33. package/src/GeolocationButton/index.tsx +1 -1
  34. package/src/Map/Map.tsx +5 -3
  35. package/src/MapDispatchEvents/MapDispatchEvents.tsx +78 -0
  36. package/src/MapDispatchEvents/index.tsx +1 -0
  37. package/src/MobilityMap/MobilityMap.tsx +117 -162
  38. package/src/MobilityMap/MobilityMapAttributes.test.ts +21 -0
  39. package/src/MobilityMap/MobilityMapAttributes.ts +243 -0
  40. package/src/MobilityMap/index.tsx +1 -0
  41. package/src/MobilitySearch/MobilitySearch.tsx +35 -0
  42. package/src/MobilitySearch/MobilitySearchAttributes.test.ts +21 -0
  43. package/src/MobilitySearch/MobilitySearchAttributes.ts +68 -0
  44. package/src/MobilitySearch/index.ts +2 -0
  45. package/src/NotificationLayer/NotificationLayer.tsx +27 -4
  46. package/src/Overlay/Overlay.tsx +24 -11
  47. package/src/Permalink/Permalink.tsx +77 -0
  48. package/src/Permalink/index.tsx +1 -0
  49. package/src/RealtimeLayer/RealtimeLayer.tsx +72 -33
  50. package/src/RouteDestination/RouteDestination.tsx +3 -3
  51. package/src/RouteIcon/RouteIcon.tsx +33 -25
  52. package/src/RouteIcon/index.tsx +1 -1
  53. package/src/RouteIdentifier/RouteIdentifer.tsx +6 -5
  54. package/src/RouteInfos/RouteInfos.tsx +7 -3
  55. package/src/RouteSchedule/RouteSchedule.tsx +3 -3
  56. package/src/RouteScheduleFooter/RouteScheduleFooter.tsx +1 -1
  57. package/src/RouteScheduleHeader/RouteScheduleHeader.tsx +7 -29
  58. package/src/RouteStop/RouteStop.tsx +8 -11
  59. package/src/RouteStopDelay/RouteStopDelay.tsx +2 -1
  60. package/src/RouteStopName/RouteStopName.tsx +2 -2
  61. package/src/RouteStopPlatform/RouteStopPlatform.tsx +2 -2
  62. package/src/RouteStopProgress/RouteStopProgress.tsx +2 -1
  63. package/src/RouteStopServices/RouteStopServices.tsx +2 -2
  64. package/src/RouteStopStation/RouteStopStation.tsx +8 -2
  65. package/src/RouteStopTime/RouteStopTime.tsx +2 -1
  66. package/src/RvfButton/RvfButton.tsx +14 -5
  67. package/src/RvfCheckbox/RvfCheckbox.tsx +8 -8
  68. package/src/RvfEmbedNavigation/DragPanWarning.ts +5 -5
  69. package/src/RvfEmbedNavigation/RvfEmbedNavigation.tsx +1 -0
  70. package/src/RvfExportMenu/RvfExportMenu.tsx +14 -12
  71. package/src/RvfExportMenuButton/RvfExportMenuButton.tsx +6 -7
  72. package/src/RvfFeatureDetails/RvfFeatureDetails.tsx +5 -5
  73. package/src/RvfFeatureDetails/RvfLineNetworkDetails/RvfLineNetworkDetails.tsx +164 -138
  74. package/src/RvfFeatureDetails/RvfNotificationDetails/RvfNotificationDetails.tsx +151 -109
  75. package/src/RvfFeatureDetails/RvfSellingPointDetails/RvfSellingPointDetails.tsx +2 -2
  76. package/src/RvfFeatureDetails/RvfSharedMobilityDetail/FloatingVehiclesDetails/FloatingVehiclesDetails.tsx +3 -3
  77. package/src/RvfFeatureDetails/RvfSharedMobilityDetail/RvfSharedMobilityDetails.tsx +8 -6
  78. package/src/RvfFeatureDetails/RvfSharedMobilityDetail/StationDetails/StationDetails.tsx +5 -4
  79. package/src/RvfFeatureDetailsTitle/RvfFeatureDetailsTitle.tsx +81 -0
  80. package/src/RvfFeatureDetailsTitle/index.tsx +1 -0
  81. package/src/RvfFloatingMenu/RvfFloatingMenu.tsx +4 -4
  82. package/src/RvfGeolocationButton/GeolocationButton.tsx +98 -0
  83. package/src/RvfGeolocationButton/index.tsx +1 -0
  84. package/src/RvfIconButton/RvfIconButton.tsx +20 -9
  85. package/src/RvfInputCopy/RvfInputCopy.tsx +8 -8
  86. package/src/RvfLayerTree/RvfLayerTree.tsx +5 -2
  87. package/src/RvfLayerTree/TreeItem/TreeItem.tsx +13 -16
  88. package/src/RvfLayerTree/layersTreeReducer.ts +23 -18
  89. package/src/RvfLayerTreeButton/RvfLayerTreeButton.tsx +6 -6
  90. package/src/RvfLineNetworkPlanLayer/RvfLineNetworkPlanLayer.tsx +2 -1
  91. package/src/RvfLink/RvfLink.tsx +4 -3
  92. package/src/RvfMobilityMap/RvfMobilityMap.tsx +314 -322
  93. package/src/RvfModal/RvfModal.tsx +4 -3
  94. package/src/RvfOverlayContent/RvfOverlayContent.tsx +126 -0
  95. package/src/RvfOverlayContent/index.ts +0 -0
  96. package/src/RvfOverlayHeader/RvfOverlayHeader.tsx +13 -10
  97. package/src/RvfPermalink/RvfPermalink.tsx +2 -2
  98. package/src/RvfPoisLayer/RvfPoisLayer.tsx +2 -1
  99. package/src/RvfRadioButton/RvfRadioButton.tsx +1 -1
  100. package/src/RvfRouteIcon/RvfRouteIcon.tsx +10 -0
  101. package/src/RvfRouteIcon/index.tsx +1 -0
  102. package/src/RvfSearch/RvfSearch.tsx +4 -1
  103. package/src/RvfSearchButton/RvfSearchButton.tsx +27 -0
  104. package/src/RvfSearchButton/index.tsx +1 -0
  105. package/src/RvfSelect/RvfSelect.tsx +7 -5
  106. package/src/RvfSelectedFeatureHighlightLayer/RvfSelectedFeatureHighlightLayer.tsx +1 -2
  107. package/src/RvfSellingPointsLayer/RvfSellingPointsLayer.tsx +2 -1
  108. package/src/RvfShare/RvfPermalinkButton/RvfPermalinkButton.tsx +13 -12
  109. package/src/RvfShare/RvfShare.tsx +11 -10
  110. package/src/RvfShareMenuButton/RvfShareMenuButton.tsx +5 -5
  111. package/src/RvfSharedMobilityLayerGroup/RvfSharedMobilityLayerGroup.tsx +25 -22
  112. package/src/RvfSingleClickListener/RvfSingleClickListener.tsx +46 -31
  113. package/src/RvfTarifZonenLayer/RvfTarifZonenLayer.tsx +2 -1
  114. package/src/RvfTopics/RvfTopics.tsx +6 -5
  115. package/src/RvfZoomButtons/RvfZoomButtons.tsx +3 -3
  116. package/src/ScaleLine/ScaleLine.tsx +5 -4
  117. package/src/ScrollableHandler/ScrollableHandler.tsx +2 -1
  118. package/src/ScrollableHandler/index.tsx +1 -1
  119. package/src/SingleClickListener/SingleClickListener.tsx +47 -4
  120. package/src/Station/Station.tsx +5 -5
  121. package/src/StationName/StationName.tsx +3 -3
  122. package/src/StationServices/StationServices.tsx +3 -3
  123. package/src/StationsLayer/StationsLayer.tsx +5 -4
  124. package/src/StopsSearch/StopsSearch.tsx +115 -84
  125. package/src/WindowMessageListener/WindowMessageListener.tsx +67 -0
  126. package/src/WindowMessageListener/index.tsx +1 -0
  127. package/src/icons/Airport/Airport.tsx +4 -4
  128. package/src/icons/ArrowDown/ArrowDown.tsx +1 -1
  129. package/src/icons/ArrowUp/ArrowUp.tsx +1 -1
  130. package/src/icons/ArrowUpRight/ArrowUpRight.tsx +1 -1
  131. package/src/icons/BarAndRestaurants/BarAndRestaurants.tsx +2 -2
  132. package/src/icons/Bathroom/Bathroom.tsx +1 -1
  133. package/src/icons/Copy/Copy.tsx +1 -1
  134. package/src/icons/Doc/Doc.tsx +1 -1
  135. package/src/icons/Email/Email.tsx +1 -1
  136. package/src/icons/FilePdf/FilePdf.tsx +1 -1
  137. package/src/icons/Geolocation/Geolocation.tsx +3 -5
  138. package/src/icons/Image/Image.tsx +1 -1
  139. package/src/icons/Menu/Menu.tsx +1 -1
  140. package/src/icons/Minus/Minus.tsx +1 -1
  141. package/src/icons/NoRealtime/NoRealtime.tsx +1 -1
  142. package/src/icons/Plus/Plus.tsx +1 -1
  143. package/src/icons/Police/Police.tsx +3 -3
  144. package/src/icons/Share/Share.tsx +1 -1
  145. package/src/icons/Stack/Stack.tsx +1 -1
  146. package/src/icons/Tracking/Tracking.tsx +29 -0
  147. package/src/icons/Tracking/airport-14-svgrepo-com.svg +41 -0
  148. package/src/icons/Tracking/index.tsx +1 -0
  149. package/src/icons/WaitingAreas/WaitingAreas.tsx +1 -1
  150. package/src/icons/WheelChair/WheelChair.tsx +1 -1
  151. package/src/index.tsx +8 -46
  152. package/src/indexDoc.ts +13 -0
  153. package/src/ui/Button/Button.tsx +57 -0
  154. package/src/ui/Button/index.tsx +1 -0
  155. package/src/ui/IconButton/IconButton.tsx +44 -0
  156. package/src/ui/IconButton/index.tsx +1 -0
  157. package/src/utils/MobilityEvent.ts +4 -3
  158. package/src/utils/applyInitialLayerVisibility.ts +3 -3
  159. package/src/utils/centerOnStation.ts +3 -2
  160. package/src/utils/centerOnVehicle.ts +5 -4
  161. package/src/utils/constants.ts +17 -3
  162. package/src/utils/exportPdf.ts +26 -20
  163. package/src/utils/fullTrajectoryStyle.ts +2 -2
  164. package/src/utils/getAllLayers.ts +4 -3
  165. package/src/utils/getDelayColor.test.ts +1 -0
  166. package/src/utils/getDelayColorForVehicle.test.ts +2 -0
  167. package/src/utils/getDelayString.test.ts +3 -0
  168. package/src/utils/getDelayTextForVehicle.test.ts +4 -0
  169. package/src/utils/getFullTrajectoryAndFit.ts +4 -3
  170. package/src/utils/getHoursAndMinutes.test.ts +1 -0
  171. package/src/utils/getLayersAsFlatArray.ts +2 -2
  172. package/src/utils/getLinkByDevice.ts +1 -1
  173. package/src/utils/getMainColorForVehicle.ts +3 -3
  174. package/src/utils/getPermalinkParameters.ts +2 -2
  175. package/src/utils/getStopStatus.test.ts +2 -1
  176. package/src/utils/getStopStatus.ts +1 -1
  177. package/src/utils/getTextForVehicle.ts +1 -1
  178. package/src/utils/hooks/useDeparture.tsx +6 -5
  179. package/src/utils/hooks/useI18n.tsx +6 -4
  180. package/src/utils/hooks/useInitialLayersVisiblity.tsx +2 -1
  181. package/src/utils/hooks/useLayerConfig.tsx +39 -0
  182. package/src/utils/hooks/useMapContext.tsx +30 -18
  183. package/src/utils/hooks/useRouteStop.tsx +3 -2
  184. package/src/utils/hooks/useRvfContext.tsx +11 -3
  185. package/src/utils/hooks/useStation.tsx +2 -1
  186. package/src/utils/hooks/useUpdatePermalink.tsx +25 -24
  187. package/src/utils/hooks/useZoom.tsx +4 -4
  188. package/src/utils/realtimeRVFStyle.ts +5 -4
  189. package/src/utils/sharingGraphqlUtils.ts +3 -2
  190. package/src/utils/sharingStylesUtils.ts +7 -7
  191. package/src/utils/sharingWFSUtils.ts +9 -15
  192. package/tailwind.config.mjs +1 -0
  193. package/tsconfig.json +1 -1
  194. package/doc/tailwind.config.ts +0 -20
  195. package/src/utils/getFeatureInformationTitle.tsx +0 -54
@@ -1,11 +1,11 @@
1
- import type { Map, MapBrowserEvent } from "ol";
2
- import type { Options } from "ol/control/Control";
3
-
4
1
  import { Control } from "ol/control";
5
- import { EventsKey } from "ol/events";
6
2
  import { DragPan } from "ol/interaction";
7
3
  import { unByKey } from "ol/Observable";
8
4
 
5
+ import type { Map, MapBrowserEvent } from "ol";
6
+ import type { Options } from "ol/control/Control";
7
+ import type { EventsKey } from "ol/events";
8
+
9
9
  type DragPanWarningOptions = {
10
10
  className?: string;
11
11
  } & Options;
@@ -88,7 +88,7 @@ class DragPanWarning extends Control {
88
88
  .getArray()
89
89
  .find((interaction) => {
90
90
  return interaction instanceof DragPan;
91
- }) as DragPan;
91
+ });
92
92
 
93
93
  if (!this.dragPan) {
94
94
  console.error(
@@ -2,6 +2,7 @@ import { MouseWheelZoom } from "ol/interaction";
2
2
  import { useEffect, useState } from "preact/hooks";
3
3
 
4
4
  import useMapContext from "../utils/hooks/useMapContext";
5
+
5
6
  import DragPanWarning from "./DragPanWarning";
6
7
 
7
8
  function RvfEmbedNavigation() {
@@ -1,15 +1,15 @@
1
- import type { JSX, PreactDOMAttributes } from "preact";
2
-
3
1
  import { memo, useId, useState } from "preact/compat";
4
2
 
5
- import RvfButton from "../RvfButton";
6
3
  import RvfCheckbox from "../RvfCheckbox";
7
4
  import RvfSelect from "../RvfSelect";
5
+ import Button from "../ui/Button";
8
6
  import { LAYER_PROP_IS_EXPORTING } from "../utils/constants";
9
7
  import exportPdf from "../utils/exportPdf";
10
8
  import getAllLayers from "../utils/getAllLayers";
11
9
  import useMapContext from "../utils/hooks/useMapContext";
12
10
 
11
+ import type { JSX, PreactDOMAttributes } from "preact";
12
+
13
13
  export type RvfExportMenuButtonProps = JSX.HTMLAttributes<HTMLDivElement> &
14
14
  PreactDOMAttributes;
15
15
 
@@ -28,7 +28,7 @@ function RvfExportMenu({ ...props }: RvfExportMenuButtonProps) {
28
28
  return (
29
29
  <div {...props}>
30
30
  {/* <!-- Content --> */}
31
- <div className="flex flex-1 flex-col gap-2">
31
+ <div className="flex flex-1 flex-col gap-4">
32
32
  <div className={"flex flex-wrap items-center gap-2"}>
33
33
  <RvfCheckbox
34
34
  checked={useMaxExtent}
@@ -48,16 +48,17 @@ function RvfExportMenu({ ...props }: RvfExportMenuButtonProps) {
48
48
  setFormat((evt.target as HTMLSelectElement).value);
49
49
  }}
50
50
  >
51
- {formats.map((format) => {
52
- return <option key={format}>{format}</option>;
51
+ {formats.map((formatt) => {
52
+ return <option key={formatt}>{formatt}</option>;
53
53
  })}
54
54
  </RvfSelect>
55
55
  </div>
56
56
  </div>
57
57
  {/* <!-- Footer --> */}
58
58
  <div>
59
- <RvfButton
59
+ <Button
60
60
  disabled={isExporting}
61
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
61
62
  onClick={async () => {
62
63
  setIsExportingError(false);
63
64
  setIsExporting(true);
@@ -65,7 +66,7 @@ function RvfExportMenu({ ...props }: RvfExportMenuButtonProps) {
65
66
  map,
66
67
  { format },
67
68
  {
68
- onAfter: (map, layers) => {
69
+ onAfter: (mapp, layers) => {
69
70
  if (
70
71
  realtimeLayer &&
71
72
  prevRealtimeLayerVisibility !== realtimeLayer?.getVisible()
@@ -75,11 +76,11 @@ function RvfExportMenu({ ...props }: RvfExportMenuButtonProps) {
75
76
  getAllLayers(layers).forEach((layer) => {
76
77
  layer.set(LAYER_PROP_IS_EXPORTING, false);
77
78
  });
78
- map.set(LAYER_PROP_IS_EXPORTING, false);
79
+ mapp.set(LAYER_PROP_IS_EXPORTING, false);
79
80
  },
80
81
 
81
- onBefore: (map, layers) => {
82
- map.set(LAYER_PROP_IS_EXPORTING, true);
82
+ onBefore: (mapp, layers) => {
83
+ mapp.set(LAYER_PROP_IS_EXPORTING, true);
83
84
  if (realtimeLayer) {
84
85
  prevRealtimeLayerVisibility = realtimeLayer.getVisible();
85
86
  if (realtimeLayer.getVisible()) {
@@ -99,12 +100,13 @@ function RvfExportMenu({ ...props }: RvfExportMenuButtonProps) {
99
100
  }, 1000);
100
101
  }}
101
102
  >
103
+ {/* eslint-disable-next-line no-nested-ternary */}
102
104
  {isExporting
103
105
  ? "Exporting..."
104
106
  : isExportingError
105
107
  ? "Error"
106
108
  : "Download"}
107
- </RvfButton>
109
+ </Button>
108
110
  </div>
109
111
  </div>
110
112
  );
@@ -1,14 +1,13 @@
1
- import type { JSX, PreactDOMAttributes } from "preact";
2
-
3
1
  import { memo } from "preact/compat";
4
2
  import { useCallback } from "preact/hooks";
5
3
 
6
4
  import Download from "../icons/Download";
7
- import RvfIconButton from "../RvfIconButton";
5
+ import IconButton from "../ui/IconButton";
8
6
  import useRvfContext from "../utils/hooks/useRvfContext";
9
7
 
10
- export type RvfExportMenuButtonProps = JSX.HTMLAttributes<HTMLButtonElement> &
11
- PreactDOMAttributes;
8
+ import type { IconButtonProps } from "../ui/IconButton/IconButton";
9
+
10
+ export type RvfExportMenuButtonProps = IconButtonProps;
12
11
 
13
12
  function RvfExportMenuButton({ ...props }: RvfExportMenuButtonProps) {
14
13
  const { isExportMenuOpen, setIsExportMenuOpen } = useRvfContext();
@@ -18,9 +17,9 @@ function RvfExportMenuButton({ ...props }: RvfExportMenuButtonProps) {
18
17
  }, [isExportMenuOpen, setIsExportMenuOpen]);
19
18
 
20
19
  return (
21
- <RvfIconButton {...props} onClick={onClick} selected={isExportMenuOpen}>
20
+ <IconButton {...props} onClick={onClick} selected={isExportMenuOpen}>
22
21
  <Download />
23
- </RvfIconButton>
22
+ </IconButton>
24
23
  );
25
24
  }
26
25
 
@@ -1,13 +1,14 @@
1
- import type { JSX, PreactDOMAttributes } from "preact";
2
-
3
1
  import { memo } from "preact/compat";
4
2
 
5
3
  import useRvfContext from "../utils/hooks/useRvfContext";
4
+
6
5
  import RvfLineNetworkDetails from "./RvfLineNetworkDetails/RvfLineNetworkDetails";
7
- // import RvfNotificationDetails from "./RvfNotificationDetails";
6
+ import RvfNotificationDetails from "./RvfNotificationDetails";
8
7
  import RvfSellingPointDetails from "./RvfSellingPointDetails";
9
8
  import RvfSharedMobilityDetails from "./RvfSharedMobilityDetail";
10
9
 
10
+ import type { JSX, PreactDOMAttributes } from "preact";
11
+
11
12
  export type RvfFeatureDetailsProps = JSX.HTMLAttributes<HTMLDivElement> &
12
13
  PreactDOMAttributes;
13
14
 
@@ -49,8 +50,7 @@ function RvfFeatureDetails(props: RvfFeatureDetailsProps) {
49
50
  {isSharedMobility && (
50
51
  <RvfSharedMobilityDetails selectedFeature={selectedFeature} />
51
52
  )}
52
- {isNotification && null}
53
- {/* <RvfNotificationDetails feature={selectedFeature} />} */}
53
+ {isNotification && <RvfNotificationDetails feature={selectedFeature} />}
54
54
  {isLineNetwork && (
55
55
  <RvfLineNetworkDetails
56
56
  feature={selectedFeature}
@@ -1,14 +1,13 @@
1
- import { VectorTileSource } from "maplibre-gl";
2
- import { RealtimeLine } from "mobility-toolbox-js/types";
3
- import { Feature } from "ol";
4
1
  import { useEffect, useMemo, useState } from "preact/hooks";
5
2
 
6
- import ArrowDown from "../../icons/ArrowDown";
7
- import ArrowUp from "../../icons/ArrowUp";
8
3
  import RouteIcon from "../../RouteIcon";
9
- import RouteStopProgress from "../../RouteStopProgress";
4
+ import Button from "../../ui/Button";
5
+ import { RVF_LAYERS_NAMES } from "../../utils/constants";
6
+ import useLayerConfig from "../../utils/hooks/useLayerConfig";
10
7
  import useMapContext from "../../utils/hooks/useMapContext";
11
- import { RouteStopContext } from "../../utils/hooks/useRouteStop";
8
+
9
+ import type { RealtimeLine } from "mobility-toolbox-js/types";
10
+ import type { Feature } from "ol";
12
11
 
13
12
  let cacheLineInfosById = null;
14
13
  let cacheStopInfosById = null;
@@ -52,14 +51,14 @@ function RvfLineNetworkDetails({
52
51
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
53
52
  const [stopInfosOpenId, setStopInfosOpenId] = useState<string>(null);
54
53
 
54
+ const layerConfig = useLayerConfig(RVF_LAYERS_NAMES.liniennetz);
55
+
55
56
  const isRunsDisplay = useMemo(() => {
56
57
  return new URLSearchParams(window.location.search).get("runs") === "true";
57
58
  }, []);
58
59
 
59
60
  useEffect(() => {
60
- const source = baseLayer?.mapLibreMap?.getSource(
61
- LNP_SOURCE_ID,
62
- ) as VectorTileSource;
61
+ const source = baseLayer?.mapLibreMap?.getSource(LNP_SOURCE_ID);
63
62
  const abortController = new AbortController();
64
63
  const fetchInfos = async (url) => {
65
64
  if (!cacheLineInfosById) {
@@ -71,8 +70,10 @@ function RvfLineNetworkDetails({
71
70
  setLineInfos(cacheLineInfosById);
72
71
  setStopInfos(cacheStopInfosById);
73
72
  };
73
+ // @ts-expect-error --- IGNORE ---
74
74
  if (source?.url) {
75
- fetchInfos(source?.url);
75
+ // @ts-expect-error --- IGNORE ---git as
76
+ void fetchInfos(source?.url);
76
77
  }
77
78
  return () => {
78
79
  abortController?.abort();
@@ -104,8 +105,8 @@ function RvfLineNetworkDetails({
104
105
  .filter((f) => {
105
106
  return f.get(ORIGINAL_LINE_ID_PROP) === id;
106
107
  })
107
- .reduce((acc, feature) => {
108
- return acc + feature.get(RUNS_PROP);
108
+ .reduce((acc, featuree) => {
109
+ return acc + featuree.get(RUNS_PROP);
109
110
  }, 0);
110
111
  lineInfos[id].id = id;
111
112
  lineInfos[id].runs = runs;
@@ -139,144 +140,169 @@ function RvfLineNetworkDetails({
139
140
 
140
141
  return (
141
142
  <div className="flex flex-col gap-4">
142
- {Object.entries(lineInfosByOperator)
143
- .sort(([operatorNameA], [operatorNameB]) => {
144
- return lineInfosByOperator[operatorNameA].runs <
145
- lineInfosByOperator[operatorNameB].runs
146
- ? 1
147
- : -1;
148
- })
149
- .map(([operatorName, linesInfos]) => {
150
- return (
151
- <div className={"flex flex-col gap-2"} key={operatorName}>
152
- <div>{operatorName}</div>
153
- {linesInfos
154
- .sort((a, b) => {
155
- return a.runs < b.runs ? 1 : -1;
156
- })
157
- .map((lineInfo) => {
158
- const {
159
- color: backgroundColor,
160
- id,
161
- // color,
162
- // external_id,
163
- long_name,
164
- mot,
165
- runs,
166
- short_name: shortName,
167
- text_color: textColor,
168
- } = lineInfo;
169
- let longName = long_name;
170
-
171
- let stops = null;
172
- //stopInfoIdsByLineId?.[id] || null;
173
- if (!stops?.length) {
174
- stops = null;
175
- }
143
+ <div className="flex flex-col gap-4">
144
+ {Object.entries(lineInfosByOperator)
145
+ .sort(([operatorNameA], [operatorNameB]) => {
146
+ return lineInfosByOperator[operatorNameA].runs <
147
+ lineInfosByOperator[operatorNameB].runs
148
+ ? 1
149
+ : -1;
150
+ })
151
+ .map(([operatorName, linesInfos]) => {
152
+ return (
153
+ <div className={"flex flex-col gap-2"} key={operatorName}>
154
+ <div>{operatorName}</div>
155
+ <div className="flex flex-wrap gap-2">
156
+ {linesInfos
157
+ .sort((a, b) => {
158
+ return a.runs < b.runs ? 1 : -1;
159
+ })
160
+ .map((lineInfo) => {
161
+ const {
162
+ color: backgroundColor,
163
+ // color,
164
+ // external_id,
165
+ long_name,
166
+ mot,
167
+ runs,
168
+ short_name: shortName,
169
+ text_color: textColor,
170
+ } = lineInfo;
171
+ let longName = long_name;
176
172
 
177
- if (!longName && stops) {
178
- const names = stops.map((stopId) => {
179
- return stopInfos[stopId].short_name;
180
- });
173
+ let stops = null;
174
+ //stopInfoIdsByLineId?.[id] || null;
175
+ if (!stops?.length) {
176
+ stops = null;
177
+ }
181
178
 
182
- longName = [
183
- ...new Set([names[0], names[names.length - 1]]),
184
- ].join(" - ");
185
- }
179
+ if (!longName && stops) {
180
+ const names = stops.map((stopId) => {
181
+ return stopInfos[stopId].short_name;
182
+ });
186
183
 
187
- // Build a line object
188
- const line: { type: string } & RealtimeLine = {
189
- color: null,
190
- id: null,
191
- name: shortName,
192
- stroke: null,
193
- text_color: null,
194
- type: mot,
195
- };
184
+ longName = [
185
+ ...new Set([names[0], names[names.length - 1]]),
186
+ ].join(" - ");
187
+ }
196
188
 
197
- if (textColor) {
198
- line.text_color =
199
- textColor[0] === "#" ? textColor : "#" + textColor;
200
- }
189
+ // Build a line object
190
+ const line: { type: string } & RealtimeLine = {
191
+ color: null,
192
+ id: null,
193
+ name: shortName,
194
+ stroke: null,
195
+ text_color: null,
196
+ type: mot,
197
+ };
201
198
 
202
- if (backgroundColor) {
203
- line.color =
204
- backgroundColor[0] === "#"
205
- ? backgroundColor
206
- : "#" + backgroundColor;
207
- }
199
+ if (textColor) {
200
+ line.text_color = textColor.startsWith("#")
201
+ ? textColor
202
+ : `#${textColor}`;
203
+ }
208
204
 
209
- return (
210
- <div key={shortName}>
211
- <div
212
- className={
213
- "flex w-full items-center justify-between gap-2"
214
- }
215
- // onClick={() => {
216
- // setStopInfosOpenId(stopInfosOpenId === id ? null : id);
217
- // }}
218
- >
219
- <div>
220
- <RouteIcon line={line}></RouteIcon>
221
- </div>
222
- {!!longName && (
223
- <div className={"flex-1 text-left"}>{longName}</div>
224
- )}
225
- {isRunsDisplay && (
226
- <div className={"text-xs"}>{runs}</div>
227
- )}
205
+ if (backgroundColor) {
206
+ line.color = backgroundColor.startsWith("#")
207
+ ? backgroundColor
208
+ : `#${backgroundColor}`;
209
+ }
228
210
 
229
- {!!stops && (
230
- <button className={"shrink-0"}>
231
- {stopInfosOpenId === id ? (
232
- <ArrowUp />
233
- ) : (
234
- <ArrowDown />
235
- )}
236
- </button>
237
- )}
238
- </div>
239
- {!!stops && (
211
+ return (
240
212
  <div
241
- className={`${stopInfosOpenId === id ? "" : "hidden"}`}
213
+ className={longName ? "w-full" : ""}
214
+ key={shortName}
242
215
  >
243
- {stops?.map((stopId, index, arr) => {
244
- const stop = stopInfos[stopId];
245
- return (
216
+ <div
217
+ className={"flex justify-between gap-2"}
218
+ // onClick={() => {
219
+ // setStopInfosOpenId(stopInfosOpenId === id ? null : id);
220
+ // }}
221
+ >
222
+ <div>
223
+ <RouteIcon line={line}></RouteIcon>
224
+ </div>
225
+ {!!longName && (
246
226
  <div
247
- className={"flex items-center gap-2"}
248
- key={stopId}
227
+ className={
228
+ "flex-1 text-left *:before:content-['_–'] *:first:font-semibold *:first:before:!content-[_p] *:last:font-semibold *:last:before:!content-[_p]"
229
+ }
249
230
  >
250
- <RouteStopContext.Provider
251
- value={{
252
- index,
253
- status: {
254
- isFirst: !index,
255
- isLast: index === arr.length - 1,
256
- isLeft: false,
257
- isPassed: false,
258
- progress: !index ? 50 : 0,
259
- },
260
- stop,
261
- }}
262
- >
263
- <RouteStopProgress
264
- className="relative flex size-8 shrink-0 items-center justify-center"
265
- lineColor={line.color}
266
- />
267
- <div>{stop.short_name}</div>
268
- </RouteStopContext.Provider>
231
+ {longName.split("-").map((name) => {
232
+ return <div key={name}>{name}</div>;
233
+ })}
269
234
  </div>
270
- );
271
- })}
235
+ )}
236
+ {isRunsDisplay && (
237
+ <div className={"text-xs"}>{runs}</div>
238
+ )}
239
+
240
+ {/* We deactivate the list of stopsfor now */}
241
+ {/* {!!stops && (
242
+ <button className={"shrink-0"}>
243
+ {stopInfosOpenId === id ? (
244
+ <ArrowUp />
245
+ ) : (
246
+ <ArrowDown />
247
+ )}
248
+ </button>
249
+ )} */}
250
+ </div>
251
+ {/* {!!stops && (
252
+ <div
253
+ className={`${stopInfosOpenId === id ? "" : "hidden"}`}
254
+ >
255
+ {stops?.map((stopId, index, arr) => {
256
+ const stop = stopInfos[stopId];
257
+ return (
258
+ <div
259
+ className={"flex items-center gap-2"}
260
+ key={stopId}
261
+ >
262
+ <RouteStopContext.Provider
263
+ value={{
264
+ index,
265
+ status: {
266
+ isFirst: !index,
267
+ isLast: index === arr.length - 1,
268
+ isLeft: false,
269
+ isPassed: false,
270
+ progress: !index ? 50 : 0,
271
+ },
272
+ stop,
273
+ }}
274
+ >
275
+ <RouteStopProgress
276
+ className="relative flex size-8 shrink-0 items-center justify-center"
277
+ lineColor={line.color}
278
+ />
279
+ <div>{stop.short_name}</div>
280
+ </RouteStopContext.Provider>
281
+ </div>
282
+ );
283
+ })}
284
+ </div>
285
+ )} */}
272
286
  </div>
273
- )}
274
- </div>
275
- );
276
- })}
277
- </div>
278
- );
279
- })}
287
+ );
288
+ })}
289
+ </div>
290
+ </div>
291
+ );
292
+ })}
293
+ </div>
294
+ {layerConfig.link && (
295
+ <div className={"flex"}>
296
+ <Button
297
+ className={"text-base"}
298
+ href={layerConfig.link.href}
299
+ target="_blank"
300
+ theme="primary"
301
+ >
302
+ {layerConfig.link.text || "Mehr erfahren"}
303
+ </Button>
304
+ </div>
305
+ )}
280
306
  </div>
281
307
  );
282
308
  }