@geops/rvf-mobility-web-component 0.1.52 → 0.1.53

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.52",
5
+ "version": "0.1.53",
6
6
  "homepage": "https://rvf-mobility-web-component-geops.vercel.app/",
7
7
  "type": "module",
8
8
  "main": "index.js",
@@ -45,7 +45,7 @@ function RvfSharedMobilityDetails({
45
45
  }, [features, isStationDetails]);
46
46
 
47
47
  return (
48
- <>
48
+ <div className={"space-y-4"}>
49
49
  {isStationDetails && (
50
50
  <>
51
51
  <img
@@ -72,7 +72,7 @@ function RvfSharedMobilityDetails({
72
72
  </Fragment>
73
73
  );
74
74
  })}
75
- </>
75
+ </div>
76
76
  );
77
77
  }
78
78
 
@@ -2,10 +2,8 @@ import { useContext, useEffect, useId, useState } from "preact/compat";
2
2
 
3
3
  import ArrowDown from "../../icons/ArrowDown";
4
4
  import ArrowUp from "../../icons/ArrowUp";
5
- import minusGrey from "../../icons/Minus/minus-grey.svg";
6
5
  import RvfCheckbox from "../../RvfCheckbox";
7
6
  import RvfRadioButton from "../../RvfRadioButton";
8
- import useLayerConfig from "../../utils/hooks/useLayerConfig";
9
7
  import { LayersTreeDispatchContext } from "../layersTreeContext";
10
8
 
11
9
  import type BaseLayer from "ol/layer/Base";
@@ -42,7 +40,6 @@ function TreeItem({
42
40
  const dispatch = useContext(LayersTreeDispatchContext);
43
41
  const inputId = useId();
44
42
  const buttonId = useId();
45
- const layerConfig = useLayerConfig(layer.get("name"));
46
43
 
47
44
  useEffect(() => {
48
45
  if (isCollapsedOnControlClick) {
@@ -82,7 +79,7 @@ function TreeItem({
82
79
  return <TreeItem key={idx} {...item} />;
83
80
  });
84
81
 
85
- if (!title && !layerConfig.title) {
82
+ if (!title) {
86
83
  return null;
87
84
  }
88
85
 
@@ -125,7 +122,7 @@ function TreeItem({
125
122
  className={`flex-1 cursor-pointer`}
126
123
  htmlFor={renderedLayers.length > 0 ? buttonId : inputId}
127
124
  >
128
- {layerConfig.title || title}
125
+ {title}
129
126
  </label>
130
127
  {renderedLayers.length > 0 && (
131
128
  <button
@@ -17,7 +17,6 @@ import {
17
17
  LAYER_PROP_IS_EXPORTING,
18
18
  RVF_EXTENT_4326,
19
19
  RVF_LAYERS_NAMES,
20
- RVF_LAYERS_TITLES,
21
20
  SCOOTER_FORM_FACTOR,
22
21
  SOURCE_FREE_FLOAT_BIKE,
23
22
  SOURCE_FREE_FLOAT_CAR,
@@ -29,6 +28,7 @@ import {
29
28
  WFS_FREE_FLOAT_TYPE,
30
29
  WFS_STATIONS_TYPE,
31
30
  } from "../utils/constants";
31
+ import useLayersConfig from "../utils/hooks/useLayersConfig";
32
32
  import useMapContext from "../utils/hooks/useMapContext";
33
33
  import useRvfContext from "../utils/hooks/useRvfContext";
34
34
  import { fetchSharingWFS } from "../utils/sharingWFSUtils";
@@ -67,6 +67,7 @@ const fetchStations = async (
67
67
  function RvfSharedMobilityLayerGroup(props: GroupOptions) {
68
68
  const { baseLayer, map } = useMapContext();
69
69
  const { setSharedMobilityLayerGroup } = useRvfContext();
70
+ const layersConfig = useLayersConfig();
70
71
 
71
72
  // Layers
72
73
  // const [bikeFreloLayer, setBikeFreloLayer] = useState<MaplibreStyleLayer>();
@@ -313,7 +314,7 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
313
314
  },
314
315
  title: (
315
316
  <div className="flex items-center justify-between gap-2">
316
- {"Fahrrad, andere Anbieter"}
317
+ {layersConfig[RVF_LAYERS_NAMES.bikeOthers]?.title}
317
318
  <Bicycle />
318
319
  </div>
319
320
  ),
@@ -329,7 +330,7 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
329
330
  name: RVF_LAYERS_NAMES.cargobikeFrelo,
330
331
  title: (
331
332
  <div className="flex items-center justify-between gap-2">
332
- {"Lastenfrelo"}
333
+ {layersConfig[RVF_LAYERS_NAMES.cargobikeFrelo]?.title}
333
334
  <CargoBike />
334
335
  </div>
335
336
  ),
@@ -345,7 +346,7 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
345
346
  name: RVF_LAYERS_NAMES.cargobikeOthers,
346
347
  title: (
347
348
  <div className="flex items-center justify-between gap-2">
348
- {"Lastenrad, andere Anbieter"}
349
+ {layersConfig[RVF_LAYERS_NAMES.cargobikeOthers]?.title}
349
350
  <CargoBike />
350
351
  </div>
351
352
  ),
@@ -361,7 +362,7 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
361
362
  name: RVF_LAYERS_NAMES.carGrf,
362
363
  title: (
363
364
  <div className="flex items-center justify-between gap-2">
364
- {"Grüne Flotte"}
365
+ {layersConfig[RVF_LAYERS_NAMES.carGrf]?.title}
365
366
  <Car />
366
367
  </div>
367
368
  ),
@@ -377,7 +378,7 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
377
378
  name: RVF_LAYERS_NAMES.carNatur,
378
379
  title: (
379
380
  <div className="flex items-center justify-between gap-2">
380
- {"Naturenergie-Sharing"}
381
+ {layersConfig[RVF_LAYERS_NAMES.carNatur]?.title}
381
382
  <Car />
382
383
  </div>
383
384
  ),
@@ -390,11 +391,10 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
390
391
  return metadata?.["rvf.filter"] === "car.other";
391
392
  },
392
393
  maplibreLayer: baseLayer,
393
-
394
394
  name: RVF_LAYERS_NAMES.carOthers,
395
395
  title: (
396
396
  <div className="flex items-center justify-between gap-2">
397
- {"Auto, andere Anbieter"}
397
+ {layersConfig[RVF_LAYERS_NAMES.carOthers]?.title}
398
398
  <Car />
399
399
  </div>
400
400
  ),
@@ -410,7 +410,7 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
410
410
  name: RVF_LAYERS_NAMES.eroller,
411
411
  title: (
412
412
  <div className="flex items-center justify-between gap-2">
413
- {RVF_LAYERS_TITLES.eroller}
413
+ {layersConfig[RVF_LAYERS_NAMES.eroller]?.title}
414
414
  <Scooter />
415
415
  </div>
416
416
  ),
@@ -426,7 +426,7 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
426
426
  name: RVF_LAYERS_NAMES.mitfahrpunkte,
427
427
  title: (
428
428
  <div className="flex items-center justify-between gap-2">
429
- {RVF_LAYERS_TITLES.mitfahrpunkte}
429
+ {layersConfig[RVF_LAYERS_NAMES.mitfahrpunkte]?.title}
430
430
  <Ride />
431
431
  </div>
432
432
  ),
@@ -446,7 +446,7 @@ function RvfSharedMobilityLayerGroup(props: GroupOptions) {
446
446
  ],
447
447
  ...props,
448
448
  } as GroupOptions);
449
- }, [baseLayer, props]);
449
+ }, [baseLayer, layersConfig, props]);
450
450
 
451
451
  // Reload features every minute
452
452
  useEffect(() => {
@@ -2,7 +2,7 @@
2
2
  import src from "./rvf_shared_ride.svg";
3
3
 
4
4
  function Ride({ ...props }) {
5
- return <img alt="Ride" src={src} title="Mitfahrpunkte" {...props} />;
5
+ return <img alt="Ride" src={src} {...props} />;
6
6
  }
7
7
 
8
8
  export default Ride;
@@ -31,14 +31,21 @@ export const LAYER_PROP_IS_EXPORTING = "isExporting";
31
31
 
32
32
  export const RVF_LAYERS_TITLES = {
33
33
  auto: "Auto",
34
+ autoandere: "Auto, andere Anbieter",
34
35
  cargobike: "Cargobike",
36
+ cargobikeandere: "Lastenrad, andere Anbieter",
37
+ cargobikefrelo: "Lastenfrelo",
38
+ "e-roller": "E-Roller",
35
39
  echtzeit: "Echtzeit",
36
40
  eroller: "E-Roller",
37
41
  fahrrad: "Fahrrad",
42
+ fahrradandere: "Fahrrad, andere Anbieter",
43
+ grueneflotte: "Grüne Flotte",
38
44
  haltestellen: "Haltestellen",
39
45
  liniennetz: "Liniennetz",
40
46
  meldungen: "Meldungen",
41
47
  mitfahrpunkte: "Mitfahrpunkte",
48
+ naturenergie: "Naturenergie-Sharing",
42
49
  pois: "POIs",
43
50
  sharedMobility: "Shared Mobility",
44
51
  tarifzonen: "Tarifzonen",
@@ -64,17 +71,18 @@ export const RVF_LAYERS_NAMES = {
64
71
  verkaufsstellen: "verkaufsstellen",
65
72
  };
66
73
 
67
- export const DEFAULT_QUERYABLE_LAYERS = Object.keys(RVF_LAYERS_NAMES)
74
+ export const DEFAULT_QUERYABLE_LAYERS = Object.values(RVF_LAYERS_NAMES)
68
75
  .filter((name) => {
69
76
  return ![
70
77
  RVF_LAYERS_NAMES.haltestellen,
78
+ RVF_LAYERS_NAMES.mitfahrpunkte,
71
79
  RVF_LAYERS_NAMES.pois,
72
80
  RVF_LAYERS_NAMES.tarifzonen,
73
81
  ].includes(name);
74
82
  })
75
83
  .toString();
76
84
 
77
- export const LAYERS_WITH_LINK = Object.keys(RVF_LAYERS_NAMES)
85
+ export const LAYERS_WITH_LINK = Object.values(RVF_LAYERS_NAMES)
78
86
  .filter((name) => {
79
87
  return (
80
88
  name !== RVF_LAYERS_NAMES.tarifzonen &&
@@ -1,32 +1,11 @@
1
- import { useEffect, useState } from "preact/hooks";
2
-
3
1
  import { RVF_LAYERS_TITLES } from "../constants";
4
2
 
5
- import useMapContext from "./useMapContext";
6
-
7
- export interface LayerConfig {
8
- link?: {
9
- href?: string;
10
- show?: boolean;
11
- text?: string;
12
- };
13
- title?: string;
14
- }
15
- export type LayersConfig = Record<string, LayerConfig>;
3
+ import useLayersConfig from "./useLayersConfig";
16
4
 
17
- function useLayerConfig(layerName) {
18
- const { layersconfig } = useMapContext();
19
- const [layersConfig, setLayersConfig] = useState<LayersConfig>({});
5
+ import type { LayerConfig } from "./useLayersConfig";
20
6
 
21
- useEffect(() => {
22
- try {
23
- const config = JSON.parse(layersconfig || "{}");
24
- setLayersConfig(config);
25
- } catch (error) {
26
- // eslint-disable-next-line no-console
27
- console.error("Error parsing layersconfig:", error);
28
- }
29
- }, [layersconfig]);
7
+ function useLayerConfig(layerName: string) {
8
+ const layersConfig = useLayersConfig();
30
9
 
31
10
  // Set defaultstyle if not present in layersconfig
32
11
  const layerConfig = layersConfig[layerName] || ({} as LayerConfig);
@@ -0,0 +1,42 @@
1
+ import { useEffect, useState } from "preact/hooks";
2
+
3
+ import { RVF_LAYERS_NAMES, RVF_LAYERS_TITLES } from "../constants";
4
+
5
+ import useMapContext from "./useMapContext";
6
+
7
+ export interface LayerConfig {
8
+ link?: {
9
+ href?: string;
10
+ show?: boolean;
11
+ text?: string;
12
+ };
13
+ title?: string;
14
+ }
15
+ export type LayersConfig = Record<string, LayerConfig>;
16
+
17
+ function useLayersConfig() {
18
+ const { layersconfig } = useMapContext();
19
+ const [layersConfig, setLayersConfig] = useState<LayersConfig>({});
20
+
21
+ useEffect(() => {
22
+ try {
23
+ const config = JSON.parse(layersconfig || "{}");
24
+
25
+ // Set the default title if not present in layersconfig
26
+ Object.values(RVF_LAYERS_NAMES).forEach((name) => {
27
+ config[name] = {
28
+ title: RVF_LAYERS_TITLES[name],
29
+ ...(config[name] || {}),
30
+ };
31
+ });
32
+ setLayersConfig(config);
33
+ } catch (error) {
34
+ // eslint-disable-next-line no-console
35
+ console.error("Error parsing layersconfig:", error);
36
+ }
37
+ }, [layersconfig]);
38
+
39
+ return layersConfig;
40
+ }
41
+
42
+ export default useLayersConfig;