@geops/rvf-mobility-web-component 0.1.84 → 0.1.86

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@geops/rvf-mobility-web-component",
3
3
  "license": "UNLICENSED",
4
4
  "description": "Web components for rvf in the domains of mobility and logistics.",
5
- "version": "0.1.84",
5
+ "version": "0.1.86",
6
6
  "homepage": "https://rvf-mobility-web-component-geops.vercel.app/",
7
7
  "type": "module",
8
8
  "main": "index.js",
@@ -12,7 +12,7 @@
12
12
  "jspdf": "^3.0.3",
13
13
  "lodash.debounce": "^4.0.8",
14
14
  "maplibre-gl": "^5.10.0",
15
- "mobility-toolbox-js": "3.5.1-beta.4",
15
+ "mobility-toolbox-js": "3.5.1-beta.5",
16
16
  "ol": "^10.6.1",
17
17
  "preact": "^10.27.2",
18
18
  "preact-custom-element": "^4.5.1",
@@ -92,7 +92,7 @@ function RouteStop({
92
92
  <RouteStopTime className="ml-4 flex w-10 shrink-0 flex-col justify-center text-xs" />
93
93
  <RouteStopDelay className="flex w-8 shrink-0 flex-col justify-center text-[0.6rem]" />
94
94
  <RouteStopProgress className="relative flex w-8 shrink-0 items-center" />
95
- <RouteStopStation className="flex grow flex-col items-start justify-center pr-2" />
95
+ <RouteStopStation className="flex grow items-center justify-center pr-2 text-sm font-medium" />
96
96
  </>
97
97
  )}
98
98
  </button>
@@ -56,7 +56,7 @@ function SearchHeadless({ ...props }: SearchProps) {
56
56
 
57
57
  const onSelectTrain = useCallback(
58
58
  (match: RealtimeRouteIdentifierMatch) => {
59
- setTrainId(match.trains[0].train_id);
59
+ setTrainId(match.train_id);
60
60
  fit.current(match, true);
61
61
  },
62
62
  [fit, setTrainId],
@@ -33,8 +33,8 @@ function SearchTrainsResult({
33
33
  onSelectItem?.(item, evt);
34
34
  }}
35
35
  >
36
- <RouteIcon line={item.trains[0].line}></RouteIcon>
37
- <div className="grow">{`${item.trains[0].line?.name} (${item.route_identifier})`}</div>
36
+ <RouteIcon line={item.line}></RouteIcon>
37
+ <div className="grow">{`${item.destination} (${item.route_identifier})`}</div>
38
38
  </button>
39
39
  );
40
40
  }
@@ -76,10 +76,7 @@ function SearchTrainsResults({
76
76
  >
77
77
  {results.map((item: RealtimeRouteIdentifierMatch) => {
78
78
  return (
79
- <SearchResult
80
- className={resultClassName}
81
- key={item.trains[0].train_id}
82
- >
79
+ <SearchResult className={resultClassName} key={item.train_id}>
83
80
  {toChildArray(children).map(
84
81
  (
85
82
  child: ReactElement<
@@ -1,5 +1,7 @@
1
1
  import { realtimeConfig } from "mobility-toolbox-js/ol";
2
2
 
3
+ import getTextColor from "./getTextColor";
4
+
3
5
  import type {
4
6
  RealtimeDeparture,
5
7
  RealtimeLine,
@@ -23,7 +25,7 @@ const getTextColorForVehicle = (object: unknown) => {
23
25
  (object as RealtimeStopSequence).type ||
24
26
  (object as RealtimeTrajectory).properties?.type;
25
27
 
26
- return realtimeConfig.getTextColorForType(type);
28
+ return getTextColor(type) || realtimeConfig.getTextColorForType(type);
27
29
  };
28
30
 
29
31
  export default getTextColorForVehicle;
@@ -5,10 +5,7 @@ import { useEffect, useRef } from "preact/hooks";
5
5
 
6
6
  import useFitOnFeatures from "./useFitOnFeatures";
7
7
 
8
- import type {
9
- RealtimeRouteIdentifierMatch,
10
- RealtimeTrainDetail,
11
- } from "mobility-toolbox-js/types";
8
+ import type { RealtimeRouteIdentifierMatch } from "mobility-toolbox-js/types";
12
9
  import type { GeoJSONFeature } from "ol/format/GeoJSON";
13
10
 
14
11
  import type { LnpLineInfo, LnpStopInfo } from "./useLnp";
@@ -20,7 +17,6 @@ export type FitObject =
20
17
  | LnpLineInfo
21
18
  | LnpStopInfo
22
19
  | RealtimeRouteIdentifierMatch
23
- | RealtimeTrainDetail
24
20
  | StopsFeature;
25
21
 
26
22
  function useFit() {
@@ -36,17 +32,9 @@ function useFit() {
36
32
  fitOnFeatures.current([obj as GeoJSONFeature], willOverlayOpen);
37
33
  return;
38
34
  }
39
- let extent =
40
- (obj as LnpLineInfo)?.extent || (obj as RealtimeTrainDetail)?.bounds;
41
-
42
- if ((obj as RealtimeRouteIdentifierMatch)?.trains?.length) {
43
- extent = (obj as RealtimeRouteIdentifierMatch).trains[0].bounds as [
44
- number,
45
- number,
46
- number,
47
- number,
48
- ];
49
- }
35
+ const extent =
36
+ (obj as LnpLineInfo)?.extent ||
37
+ (obj as RealtimeRouteIdentifierMatch)?.bounds;
50
38
 
51
39
  if (extent) {
52
40
  const feature = new Feature(fromExtent(extent));
@@ -1,15 +1,16 @@
1
1
  import { RealtimeRestAPI } from "mobility-toolbox-js/ol";
2
- import { type RealtimeTrainDetail } from "mobility-toolbox-js/types";
3
2
  import { useEffect, useMemo, useState } from "preact/hooks";
4
3
 
5
4
  import useMapContext from "./useMapContext";
6
5
 
6
+ import type { RealtimeRouteIdentifierMatch } from "mobility-toolbox-js/types";
7
+
7
8
  function useRealtimeTrainByRouteIdentifier(
8
9
  routeIdentifier: string,
9
- ): RealtimeTrainDetail {
10
+ ): RealtimeRouteIdentifierMatch | undefined {
10
11
  const { apikey, hasRealtime, realtimeresturl, realtimetenant, tenant } =
11
12
  useMapContext();
12
- const [train, setTrain] = useState<RealtimeTrainDetail>();
13
+ const [train, setTrain] = useState<RealtimeRouteIdentifierMatch>();
13
14
 
14
15
  const tenantMemo = useMemo(() => {
15
16
  return realtimetenant || tenant;
@@ -43,7 +44,7 @@ function useRealtimeTrainByRouteIdentifier(
43
44
  )
44
45
  .then((res) => {
45
46
  if (res.matches.length > 0) {
46
- setTrain(res.matches[0].trains[0]);
47
+ setTrain(res.matches[0]);
47
48
  } else {
48
49
  setTrain(undefined);
49
50
  }