@geops/rvf-mobility-web-component 0.1.85 → 0.1.88
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/CHANGELOG.md +39 -0
- package/index.js +137 -117
- package/package.json +2 -2
- package/src/FeaturesInfosListener/FeaturesInfosListener.tsx +21 -11
- package/src/I18n/I18n.tsx +38 -0
- package/src/I18n/index.tsx +1 -0
- package/src/LayoutState/LayoutState.tsx +4 -30
- package/src/MapLayout/MapLayout.tsx +2 -1
- package/src/MobilityMap/MobilityMap.tsx +4 -9
- package/src/MobilityNotifications/MobilityNotifications.tsx +3 -9
- package/src/MobilitySearch/MobilitySearch.tsx +4 -4
- package/src/MobilitySearch/MobilitySearchAttributes.ts +7 -0
- package/src/NotificationDetails/NotificationDetails.tsx +5 -6
- package/src/RouteStop/RouteStop.tsx +1 -1
- package/src/RvfMapLayout/RvfMapLayout.tsx +1 -1
- package/src/RvfSearch/RvfSearch.tsx +3 -1
- package/src/Search/Search.tsx +3 -3
- package/src/Search/SearchBase.tsx +19 -1
- package/src/Search/SearchHeadless.tsx +4 -4
- package/src/SearchTrainsResult/SearchTrainsResult.tsx +2 -2
- package/src/SearchTrainsResults/SearchTrainsResults.tsx +1 -4
- package/src/SingleClickListener/SingleClickListener.tsx +20 -7
- package/src/SituationDetails/SituationDetails.tsx +8 -6
- package/src/StopsSearch/StopsSearch.tsx +6 -1
- package/src/icons/Warning/exported_features_20251029101203.kml +4 -1
- package/src/ui/Input/Input.tsx +16 -9
- package/src/ui/InputSearch/InputSearch.tsx +4 -3
- package/src/utils/hooks/useFit.tsx +4 -16
- package/src/utils/hooks/useI18n.tsx +4 -3
- package/src/utils/hooks/useMocoSituation.tsx +10 -2
- package/src/utils/hooks/useRealtimeTrainsByRouteIdentifier.tsx +5 -4
- package/src/utils/translations.ts +5 -5
- package/src/utils/i18n.ts +0 -7
|
@@ -36,6 +36,7 @@ export type StopsSearchProps = {
|
|
|
36
36
|
field?: string;
|
|
37
37
|
inputClassName?: string;
|
|
38
38
|
inputContainerClassName?: string;
|
|
39
|
+
lang?: string;
|
|
39
40
|
limit?: number;
|
|
40
41
|
mots?: string;
|
|
41
42
|
onselect?: (arg: StopsFeature) => void;
|
|
@@ -70,6 +71,7 @@ function StopsSearch({
|
|
|
70
71
|
field,
|
|
71
72
|
inputClassName,
|
|
72
73
|
inputContainerClassName,
|
|
74
|
+
lang,
|
|
73
75
|
limit,
|
|
74
76
|
mots,
|
|
75
77
|
onselect,
|
|
@@ -97,6 +99,7 @@ function StopsSearch({
|
|
|
97
99
|
countrycode,
|
|
98
100
|
event,
|
|
99
101
|
field,
|
|
102
|
+
lang,
|
|
100
103
|
limit,
|
|
101
104
|
mots,
|
|
102
105
|
onselect,
|
|
@@ -119,6 +122,7 @@ function StopsSearch({
|
|
|
119
122
|
prefagencies,
|
|
120
123
|
reflocation,
|
|
121
124
|
url,
|
|
125
|
+
lang,
|
|
122
126
|
]);
|
|
123
127
|
|
|
124
128
|
const api: StopsAPI = useMemo(() => {
|
|
@@ -211,7 +215,7 @@ function StopsSearch({
|
|
|
211
215
|
|
|
212
216
|
useEffect(() => {
|
|
213
217
|
setResults(undefined);
|
|
214
|
-
|
|
218
|
+
console.log("StopsSearch selectedStation", selectedStation);
|
|
215
219
|
if (selectedStation) {
|
|
216
220
|
setQuery(getQueryForSelectedStation(selectedStation));
|
|
217
221
|
}
|
|
@@ -320,6 +324,7 @@ function StopsSearch({
|
|
|
320
324
|
<button
|
|
321
325
|
className="flex w-full items-center gap-3 text-left"
|
|
322
326
|
onClick={() => {
|
|
327
|
+
console.log("StopsSearch selected station", station);
|
|
323
328
|
setSelectedStation(station);
|
|
324
329
|
}}
|
|
325
330
|
>
|
|
@@ -14,4 +14,7 @@
|
|
|
14
14
|
- add a tool to select an area by bbox -> 1d
|
|
15
15
|
- add a tool to select an area by "Frei Skizze" -> 1d
|
|
16
16
|
- use the area drawn to recalculate the "KM von" and "KM bis" of all Linien -> 3h
|
|
17
|
-
-
|
|
17
|
+
- add a button in the popup to send information to the window.opener (both window must have the same origin) -> 3h
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
https://trenord-mobility-web-component.vercel.app/?permalink=true¬ification=false&search=false&realtime=false&geolocation=false&queryablelayers=notifications&details=false&toolbar=false&lnp=true&layers=stations,notifications,linesnetworkplan&fullscreen=true
|
package/src/ui/Input/Input.tsx
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
+
import { forwardRef } from "preact/compat";
|
|
1
2
|
import { twMerge } from "tailwind-merge";
|
|
2
3
|
|
|
3
4
|
import type { InputHTMLAttributes, PreactDOMAttributes } from "preact";
|
|
4
5
|
|
|
5
|
-
export type InputProps = {
|
|
6
|
+
export type InputProps = {
|
|
7
|
+
className?: string;
|
|
8
|
+
focusOnFirstRender?: boolean;
|
|
9
|
+
} & InputHTMLAttributes &
|
|
6
10
|
PreactDOMAttributes;
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const Input = forwardRef<HTMLInputElement, InputProps>(
|
|
13
|
+
({ className, ...props }, ref) => {
|
|
14
|
+
return (
|
|
15
|
+
<input
|
|
16
|
+
ref={ref}
|
|
17
|
+
{...props}
|
|
18
|
+
className={twMerge("p-2 text-sm read-only:text-gray-400", className)}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
},
|
|
22
|
+
);
|
|
16
23
|
|
|
17
24
|
export default Input;
|
|
@@ -54,7 +54,7 @@ function InputSearch({
|
|
|
54
54
|
<>
|
|
55
55
|
<div
|
|
56
56
|
className={twMerge(
|
|
57
|
-
"flex h-
|
|
57
|
+
"flex h-12 items-center gap-1 rounded-md bg-white p-3 shadow",
|
|
58
58
|
className,
|
|
59
59
|
withResultsClassName,
|
|
60
60
|
)}
|
|
@@ -70,7 +70,7 @@ function InputSearch({
|
|
|
70
70
|
</div>
|
|
71
71
|
<div
|
|
72
72
|
className={twMerge(
|
|
73
|
-
"@container/inputsearch flex grow items-center gap-2 border-b-2 border-solid",
|
|
73
|
+
"@container/inputsearch relative flex grow items-center gap-2 border-b-2 border-solid",
|
|
74
74
|
inputContainerClassName,
|
|
75
75
|
)}
|
|
76
76
|
>
|
|
@@ -79,6 +79,7 @@ function InputSearch({
|
|
|
79
79
|
className={twMerge(
|
|
80
80
|
"h-8 w-1 grow overflow-hidden text-ellipsis placeholder:text-zinc-400",
|
|
81
81
|
inputClassName,
|
|
82
|
+
inputProps?.value ? "pr-4" : "",
|
|
82
83
|
)}
|
|
83
84
|
type="text"
|
|
84
85
|
{...(inputProps || {})}
|
|
@@ -86,7 +87,7 @@ function InputSearch({
|
|
|
86
87
|
{!!inputProps.value && (
|
|
87
88
|
<IconButton
|
|
88
89
|
className={twMerge(
|
|
89
|
-
"flex
|
|
90
|
+
"absolute right-0 flex h-full w-6 items-center rounded-none border-none bg-transparent p-0 px-1 shadow-none",
|
|
90
91
|
cancelButtonClassName,
|
|
91
92
|
)}
|
|
92
93
|
title={t("search_input_cancel")}
|
|
@@ -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
|
-
|
|
40
|
-
(obj as LnpLineInfo)?.extent ||
|
|
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,9 +1,10 @@
|
|
|
1
1
|
import { createContext } from "preact";
|
|
2
2
|
import { useContext } from "preact/hooks";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export interface I18NContextType {
|
|
5
|
+
locale(lang?: string): string;
|
|
6
|
+
t: (id: string, templateValues?: Record<string, string>) => string;
|
|
7
|
+
}
|
|
7
8
|
|
|
8
9
|
export const I18nContext = createContext<I18NContextType>({
|
|
9
10
|
t: (id: string, templateValues?: Record<string, string>) => {
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
} from "mobility-toolbox-js/types";
|
|
10
10
|
|
|
11
11
|
function useMocoSituation(situationId?: string, params?: MocoExportParameters) {
|
|
12
|
-
const { lang, notificationsLayer } = useMapContext();
|
|
12
|
+
const { lang, notificationsLayer, previewNotifications } = useMapContext();
|
|
13
13
|
const [situation, setSituation] = useState<SituationType>();
|
|
14
14
|
|
|
15
15
|
const api: MocoAPI | undefined = useMemo(() => {
|
|
@@ -17,6 +17,14 @@ function useMocoSituation(situationId?: string, params?: MocoExportParameters) {
|
|
|
17
17
|
}, [notificationsLayer]);
|
|
18
18
|
|
|
19
19
|
useEffect(() => {
|
|
20
|
+
const previewSituation = previewNotifications?.find((item) => {
|
|
21
|
+
return item.id === situationId;
|
|
22
|
+
});
|
|
23
|
+
if (previewSituation) {
|
|
24
|
+
setSituation(previewSituation);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
20
28
|
const abortController = new AbortController();
|
|
21
29
|
api
|
|
22
30
|
?.exportById(situationId, {
|
|
@@ -46,7 +54,7 @@ function useMocoSituation(situationId?: string, params?: MocoExportParameters) {
|
|
|
46
54
|
return () => {
|
|
47
55
|
abortController.abort();
|
|
48
56
|
};
|
|
49
|
-
}, [api, situationId, params, lang]);
|
|
57
|
+
}, [api, situationId, params, lang, previewNotifications]);
|
|
50
58
|
|
|
51
59
|
return situation;
|
|
52
60
|
}
|
|
@@ -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
|
-
):
|
|
10
|
+
): RealtimeRouteIdentifierMatch | undefined {
|
|
10
11
|
const { apikey, hasRealtime, realtimeresturl, realtimetenant, tenant } =
|
|
11
12
|
useMapContext();
|
|
12
|
-
const [train, setTrain] = useState<
|
|
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]
|
|
47
|
+
setTrain(res.matches[0]);
|
|
47
48
|
} else {
|
|
48
49
|
setTrain(undefined);
|
|
49
50
|
}
|
|
@@ -35,7 +35,7 @@ const translations: Translations = {
|
|
|
35
35
|
[LAYERS_NAMES.notifications]: "Meldungen",
|
|
36
36
|
[LAYERS_NAMES.pois]: "POIs",
|
|
37
37
|
[LAYERS_NAMES.realtime]: "Echtzeit",
|
|
38
|
-
[LAYERS_NAMES.sharedMobility]: "Shared
|
|
38
|
+
[LAYERS_NAMES.sharedMobility]: "Shared-Angebote",
|
|
39
39
|
[LAYERS_NAMES.stations]: "Stationen",
|
|
40
40
|
[LAYERS_NAMES.tarifzonen]: "Tarifzonen",
|
|
41
41
|
[LAYERS_NAMES.verkaufsstellen]: "Verkaufsstellen",
|
|
@@ -62,7 +62,7 @@ const translations: Translations = {
|
|
|
62
62
|
share_email_send: "E-Mail senden",
|
|
63
63
|
share_image_save: "Bild speichern",
|
|
64
64
|
share_menu_title: "Teilen",
|
|
65
|
-
stops_search_placeholder: "
|
|
65
|
+
stops_search_placeholder: "Haltestelle suchen",
|
|
66
66
|
zoomin: "Hineinzoomen",
|
|
67
67
|
zoomout: "Herauszoomen",
|
|
68
68
|
},
|
|
@@ -97,7 +97,7 @@ const translations: Translations = {
|
|
|
97
97
|
[LAYERS_NAMES.notifications]: "Notifications",
|
|
98
98
|
[LAYERS_NAMES.pois]: "POIs",
|
|
99
99
|
[LAYERS_NAMES.realtime]: "Realtime",
|
|
100
|
-
[LAYERS_NAMES.sharedMobility]: "
|
|
100
|
+
[LAYERS_NAMES.sharedMobility]: "Mobility offers",
|
|
101
101
|
[LAYERS_NAMES.stations]: "Stations",
|
|
102
102
|
[LAYERS_NAMES.tarifzonen]: "Tariff Zones",
|
|
103
103
|
[LAYERS_NAMES.verkaufsstellen]: "Sales Outlets",
|
|
@@ -155,7 +155,7 @@ const translations: Translations = {
|
|
|
155
155
|
[LAYERS_NAMES.notifications]: "Notifications",
|
|
156
156
|
[LAYERS_NAMES.pois]: "POIs",
|
|
157
157
|
[LAYERS_NAMES.realtime]: "Temps réel",
|
|
158
|
-
[LAYERS_NAMES.sharedMobility]: "
|
|
158
|
+
[LAYERS_NAMES.sharedMobility]: "Offres de mobilité",
|
|
159
159
|
[LAYERS_NAMES.stations]: "Stations",
|
|
160
160
|
[LAYERS_NAMES.tarifzonen]: "Zones tarifaires",
|
|
161
161
|
[LAYERS_NAMES.verkaufsstellen]: "Points de vente",
|
|
@@ -213,7 +213,7 @@ const translations: Translations = {
|
|
|
213
213
|
[LAYERS_NAMES.notifications]: "Notifiche",
|
|
214
214
|
[LAYERS_NAMES.pois]: "POI",
|
|
215
215
|
[LAYERS_NAMES.realtime]: "In tempo reale",
|
|
216
|
-
[LAYERS_NAMES.sharedMobility]: "
|
|
216
|
+
[LAYERS_NAMES.sharedMobility]: "Offerte Mobility",
|
|
217
217
|
[LAYERS_NAMES.stations]: "Stazioni",
|
|
218
218
|
[LAYERS_NAMES.tarifzonen]: "Zone tariffarie",
|
|
219
219
|
[LAYERS_NAMES.verkaufsstellen]: "Punti vendita",
|