@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.
- package/.prettierrc.js +3 -1
- package/README.md +1 -1
- package/doc/package.json +4 -3
- package/doc/postcss.config.mjs +1 -1
- package/doc/src/app/components/GeopsMobilityDoc.tsx +13 -224
- package/doc/src/app/components/GeopsMobilitySearchDoc.tsx +11 -107
- package/doc/src/app/components/WebComponentDoc.tsx +45 -56
- package/doc/src/app/geops-mobility/page.tsx +7 -2
- package/doc/src/app/geops-mobility-search/page.tsx +6 -2
- package/doc/src/app/globals.css +47 -27
- package/doc/src/app/layout.tsx +4 -2
- package/docutils.js +33 -17
- package/eslint.config.mjs +28 -34
- package/iframe.html +5624 -201
- package/index.html +108 -88
- package/index.js +2229 -1976
- package/input.css +21 -3
- package/package.json +37 -40
- package/scripts/build.mjs +2 -2
- package/scripts/dev.mjs +3 -3
- package/search.html +70 -23
- package/src/BaseLayer/BaseLayer.tsx +2 -1
- package/src/Copyright/Copyright.tsx +4 -2
- package/src/DebugDeparture/DebugDeparture.tsx +16 -12
- package/src/DebugStop/DebugStop.tsx +2 -2
- package/src/Departure/Departure.tsx +2 -3
- package/src/EmbedNavigation/DragPanWarning.ts +125 -0
- package/src/EmbedNavigation/EmbedNavigation.tsx +52 -0
- package/src/EmbedNavigation/index.js +1 -0
- package/src/EmbedNavigation/index.tsx +1 -0
- package/src/GeolocationButton/GeolocationButton.tsx +11 -35
- package/src/GeolocationButton/index.tsx +1 -1
- package/src/Map/Map.tsx +5 -3
- package/src/MapDispatchEvents/MapDispatchEvents.tsx +78 -0
- package/src/MapDispatchEvents/index.tsx +1 -0
- package/src/MobilityMap/MobilityMap.tsx +117 -162
- package/src/MobilityMap/MobilityMapAttributes.test.ts +21 -0
- package/src/MobilityMap/MobilityMapAttributes.ts +243 -0
- package/src/MobilityMap/index.tsx +1 -0
- package/src/MobilitySearch/MobilitySearch.tsx +35 -0
- package/src/MobilitySearch/MobilitySearchAttributes.test.ts +21 -0
- package/src/MobilitySearch/MobilitySearchAttributes.ts +68 -0
- package/src/MobilitySearch/index.ts +2 -0
- package/src/NotificationLayer/NotificationLayer.tsx +27 -4
- package/src/Overlay/Overlay.tsx +24 -11
- package/src/Permalink/Permalink.tsx +77 -0
- package/src/Permalink/index.tsx +1 -0
- package/src/RealtimeLayer/RealtimeLayer.tsx +72 -33
- package/src/RouteDestination/RouteDestination.tsx +3 -3
- package/src/RouteIcon/RouteIcon.tsx +33 -25
- package/src/RouteIcon/index.tsx +1 -1
- package/src/RouteIdentifier/RouteIdentifer.tsx +6 -5
- package/src/RouteInfos/RouteInfos.tsx +7 -3
- package/src/RouteSchedule/RouteSchedule.tsx +3 -3
- package/src/RouteScheduleFooter/RouteScheduleFooter.tsx +1 -1
- package/src/RouteScheduleHeader/RouteScheduleHeader.tsx +7 -29
- package/src/RouteStop/RouteStop.tsx +8 -11
- package/src/RouteStopDelay/RouteStopDelay.tsx +2 -1
- package/src/RouteStopName/RouteStopName.tsx +2 -2
- package/src/RouteStopPlatform/RouteStopPlatform.tsx +2 -2
- package/src/RouteStopProgress/RouteStopProgress.tsx +2 -1
- package/src/RouteStopServices/RouteStopServices.tsx +2 -2
- package/src/RouteStopStation/RouteStopStation.tsx +8 -2
- package/src/RouteStopTime/RouteStopTime.tsx +2 -1
- package/src/RvfButton/RvfButton.tsx +14 -5
- package/src/RvfCheckbox/RvfCheckbox.tsx +8 -8
- package/src/RvfEmbedNavigation/DragPanWarning.ts +5 -5
- package/src/RvfEmbedNavigation/RvfEmbedNavigation.tsx +1 -0
- package/src/RvfExportMenu/RvfExportMenu.tsx +14 -12
- package/src/RvfExportMenuButton/RvfExportMenuButton.tsx +6 -7
- package/src/RvfFeatureDetails/RvfFeatureDetails.tsx +5 -5
- package/src/RvfFeatureDetails/RvfLineNetworkDetails/RvfLineNetworkDetails.tsx +164 -138
- package/src/RvfFeatureDetails/RvfNotificationDetails/RvfNotificationDetails.tsx +151 -109
- package/src/RvfFeatureDetails/RvfSellingPointDetails/RvfSellingPointDetails.tsx +2 -2
- package/src/RvfFeatureDetails/RvfSharedMobilityDetail/FloatingVehiclesDetails/FloatingVehiclesDetails.tsx +3 -3
- package/src/RvfFeatureDetails/RvfSharedMobilityDetail/RvfSharedMobilityDetails.tsx +8 -6
- package/src/RvfFeatureDetails/RvfSharedMobilityDetail/StationDetails/StationDetails.tsx +5 -4
- package/src/RvfFeatureDetailsTitle/RvfFeatureDetailsTitle.tsx +81 -0
- package/src/RvfFeatureDetailsTitle/index.tsx +1 -0
- package/src/RvfFloatingMenu/RvfFloatingMenu.tsx +4 -4
- package/src/RvfGeolocationButton/GeolocationButton.tsx +98 -0
- package/src/RvfGeolocationButton/index.tsx +1 -0
- package/src/RvfIconButton/RvfIconButton.tsx +20 -9
- package/src/RvfInputCopy/RvfInputCopy.tsx +8 -8
- package/src/RvfLayerTree/RvfLayerTree.tsx +5 -2
- package/src/RvfLayerTree/TreeItem/TreeItem.tsx +13 -16
- package/src/RvfLayerTree/layersTreeReducer.ts +23 -18
- package/src/RvfLayerTreeButton/RvfLayerTreeButton.tsx +6 -6
- package/src/RvfLineNetworkPlanLayer/RvfLineNetworkPlanLayer.tsx +2 -1
- package/src/RvfLink/RvfLink.tsx +4 -3
- package/src/RvfMobilityMap/RvfMobilityMap.tsx +314 -322
- package/src/RvfModal/RvfModal.tsx +4 -3
- package/src/RvfOverlayContent/RvfOverlayContent.tsx +126 -0
- package/src/RvfOverlayContent/index.ts +0 -0
- package/src/RvfOverlayHeader/RvfOverlayHeader.tsx +13 -10
- package/src/RvfPermalink/RvfPermalink.tsx +2 -2
- package/src/RvfPoisLayer/RvfPoisLayer.tsx +2 -1
- package/src/RvfRadioButton/RvfRadioButton.tsx +1 -1
- package/src/RvfRouteIcon/RvfRouteIcon.tsx +10 -0
- package/src/RvfRouteIcon/index.tsx +1 -0
- package/src/RvfSearch/RvfSearch.tsx +4 -1
- package/src/RvfSearchButton/RvfSearchButton.tsx +27 -0
- package/src/RvfSearchButton/index.tsx +1 -0
- package/src/RvfSelect/RvfSelect.tsx +7 -5
- package/src/RvfSelectedFeatureHighlightLayer/RvfSelectedFeatureHighlightLayer.tsx +1 -2
- package/src/RvfSellingPointsLayer/RvfSellingPointsLayer.tsx +2 -1
- package/src/RvfShare/RvfPermalinkButton/RvfPermalinkButton.tsx +13 -12
- package/src/RvfShare/RvfShare.tsx +11 -10
- package/src/RvfShareMenuButton/RvfShareMenuButton.tsx +5 -5
- package/src/RvfSharedMobilityLayerGroup/RvfSharedMobilityLayerGroup.tsx +25 -22
- package/src/RvfSingleClickListener/RvfSingleClickListener.tsx +46 -31
- package/src/RvfTarifZonenLayer/RvfTarifZonenLayer.tsx +2 -1
- package/src/RvfTopics/RvfTopics.tsx +6 -5
- package/src/RvfZoomButtons/RvfZoomButtons.tsx +3 -3
- package/src/ScaleLine/ScaleLine.tsx +5 -4
- package/src/ScrollableHandler/ScrollableHandler.tsx +2 -1
- package/src/ScrollableHandler/index.tsx +1 -1
- package/src/SingleClickListener/SingleClickListener.tsx +47 -4
- package/src/Station/Station.tsx +5 -5
- package/src/StationName/StationName.tsx +3 -3
- package/src/StationServices/StationServices.tsx +3 -3
- package/src/StationsLayer/StationsLayer.tsx +5 -4
- package/src/StopsSearch/StopsSearch.tsx +115 -84
- package/src/WindowMessageListener/WindowMessageListener.tsx +67 -0
- package/src/WindowMessageListener/index.tsx +1 -0
- package/src/icons/Airport/Airport.tsx +4 -4
- package/src/icons/ArrowDown/ArrowDown.tsx +1 -1
- package/src/icons/ArrowUp/ArrowUp.tsx +1 -1
- package/src/icons/ArrowUpRight/ArrowUpRight.tsx +1 -1
- package/src/icons/BarAndRestaurants/BarAndRestaurants.tsx +2 -2
- package/src/icons/Bathroom/Bathroom.tsx +1 -1
- package/src/icons/Copy/Copy.tsx +1 -1
- package/src/icons/Doc/Doc.tsx +1 -1
- package/src/icons/Email/Email.tsx +1 -1
- package/src/icons/FilePdf/FilePdf.tsx +1 -1
- package/src/icons/Geolocation/Geolocation.tsx +3 -5
- package/src/icons/Image/Image.tsx +1 -1
- package/src/icons/Menu/Menu.tsx +1 -1
- package/src/icons/Minus/Minus.tsx +1 -1
- package/src/icons/NoRealtime/NoRealtime.tsx +1 -1
- package/src/icons/Plus/Plus.tsx +1 -1
- package/src/icons/Police/Police.tsx +3 -3
- package/src/icons/Share/Share.tsx +1 -1
- package/src/icons/Stack/Stack.tsx +1 -1
- package/src/icons/Tracking/Tracking.tsx +29 -0
- package/src/icons/Tracking/airport-14-svgrepo-com.svg +41 -0
- package/src/icons/Tracking/index.tsx +1 -0
- package/src/icons/WaitingAreas/WaitingAreas.tsx +1 -1
- package/src/icons/WheelChair/WheelChair.tsx +1 -1
- package/src/index.tsx +8 -46
- package/src/indexDoc.ts +13 -0
- package/src/ui/Button/Button.tsx +57 -0
- package/src/ui/Button/index.tsx +1 -0
- package/src/ui/IconButton/IconButton.tsx +44 -0
- package/src/ui/IconButton/index.tsx +1 -0
- package/src/utils/MobilityEvent.ts +4 -3
- package/src/utils/applyInitialLayerVisibility.ts +3 -3
- package/src/utils/centerOnStation.ts +3 -2
- package/src/utils/centerOnVehicle.ts +5 -4
- package/src/utils/constants.ts +17 -3
- package/src/utils/exportPdf.ts +26 -20
- package/src/utils/fullTrajectoryStyle.ts +2 -2
- package/src/utils/getAllLayers.ts +4 -3
- package/src/utils/getDelayColor.test.ts +1 -0
- package/src/utils/getDelayColorForVehicle.test.ts +2 -0
- package/src/utils/getDelayString.test.ts +3 -0
- package/src/utils/getDelayTextForVehicle.test.ts +4 -0
- package/src/utils/getFullTrajectoryAndFit.ts +4 -3
- package/src/utils/getHoursAndMinutes.test.ts +1 -0
- package/src/utils/getLayersAsFlatArray.ts +2 -2
- package/src/utils/getLinkByDevice.ts +1 -1
- package/src/utils/getMainColorForVehicle.ts +3 -3
- package/src/utils/getPermalinkParameters.ts +2 -2
- package/src/utils/getStopStatus.test.ts +2 -1
- package/src/utils/getStopStatus.ts +1 -1
- package/src/utils/getTextForVehicle.ts +1 -1
- package/src/utils/hooks/useDeparture.tsx +6 -5
- package/src/utils/hooks/useI18n.tsx +6 -4
- package/src/utils/hooks/useInitialLayersVisiblity.tsx +2 -1
- package/src/utils/hooks/useLayerConfig.tsx +39 -0
- package/src/utils/hooks/useMapContext.tsx +30 -18
- package/src/utils/hooks/useRouteStop.tsx +3 -2
- package/src/utils/hooks/useRvfContext.tsx +11 -3
- package/src/utils/hooks/useStation.tsx +2 -1
- package/src/utils/hooks/useUpdatePermalink.tsx +25 -24
- package/src/utils/hooks/useZoom.tsx +4 -4
- package/src/utils/realtimeRVFStyle.ts +5 -4
- package/src/utils/sharingGraphqlUtils.ts +3 -2
- package/src/utils/sharingStylesUtils.ts +7 -7
- package/src/utils/sharingWFSUtils.ts +9 -15
- package/tailwind.config.mjs +1 -0
- package/tsconfig.json +1 -1
- package/doc/tailwind.config.ts +0 -20
- 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
|
-
})
|
|
91
|
+
});
|
|
92
92
|
|
|
93
93
|
if (!this.dragPan) {
|
|
94
94
|
console.error(
|
|
@@ -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-
|
|
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((
|
|
52
|
-
return <option key={
|
|
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
|
-
<
|
|
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: (
|
|
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
|
-
|
|
79
|
+
mapp.set(LAYER_PROP_IS_EXPORTING, false);
|
|
79
80
|
},
|
|
80
81
|
|
|
81
|
-
onBefore: (
|
|
82
|
-
|
|
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
|
-
</
|
|
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
|
|
5
|
+
import IconButton from "../ui/IconButton";
|
|
8
6
|
import useRvfContext from "../utils/hooks/useRvfContext";
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
<
|
|
20
|
+
<IconButton {...props} onClick={onClick} selected={isExportMenuOpen}>
|
|
22
21
|
<Download />
|
|
23
|
-
</
|
|
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
|
-
|
|
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 &&
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
108
|
-
return acc +
|
|
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
|
-
|
|
143
|
-
.
|
|
144
|
-
|
|
145
|
-
lineInfosByOperator[
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
<div
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
173
|
+
let stops = null;
|
|
174
|
+
//stopInfoIdsByLineId?.[id] || null;
|
|
175
|
+
if (!stops?.length) {
|
|
176
|
+
stops = null;
|
|
177
|
+
}
|
|
181
178
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
179
|
+
if (!longName && stops) {
|
|
180
|
+
const names = stops.map((stopId) => {
|
|
181
|
+
return stopInfos[stopId].short_name;
|
|
182
|
+
});
|
|
186
183
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
199
|
+
if (textColor) {
|
|
200
|
+
line.text_color = textColor.startsWith("#")
|
|
201
|
+
? textColor
|
|
202
|
+
: `#${textColor}`;
|
|
203
|
+
}
|
|
208
204
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
|
|
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={
|
|
213
|
+
className={longName ? "w-full" : ""}
|
|
214
|
+
key={shortName}
|
|
242
215
|
>
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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={
|
|
248
|
-
|
|
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
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
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
|
}
|