@geops/rvf-mobility-web-component 0.1.90 → 0.1.91

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.90",
5
+ "version": "0.1.91",
6
6
  "homepage": "https://rvf-mobility-web-component-geops.vercel.app/",
7
7
  "type": "module",
8
8
  "main": "index.js",
@@ -65,7 +65,7 @@
65
65
  "dev": "node scripts/dev.mjs",
66
66
  "doc": "yarn build && cd doc && yarn build",
67
67
  "doc:dev": "yarn build && cd doc && yarn dev",
68
- "format": "prettier --write 'src/**/*.(tsx|ts)' && eslint 'src/**/*.tsx' 'src/**/*.ts' --fix ",
68
+ "format": "prettier --write 'src/**/*.(tsx|ts)' && eslint 'src/**/*.tsx' 'src/**/*.ts' --fix",
69
69
  "lint": "eslint 'src/**/*.tsx' 'src/**/*.ts'",
70
70
  "prepare": "husky",
71
71
  "publish:beta": "HUSKY=0 yarn release -- --prerelease beta --skip.changelog && yarn run build && HUSKY=0 yarn publish --access public --tag beta && git push origin HEAD && git push --tags ",
@@ -6,8 +6,9 @@ import type { Map, MapBrowserEvent } from "ol";
6
6
  import type { Options } from "ol/control/Control";
7
7
  import type { EventsKey } from "ol/events";
8
8
 
9
- type DragPanWarningOptions = {
9
+ export type DragPanWarningOptions = {
10
10
  className?: string;
11
+ element?: HTMLElement;
11
12
  } & Options;
12
13
 
13
14
  class DragPanWarning extends Control {
@@ -20,11 +21,16 @@ class DragPanWarning extends Control {
20
21
  text: HTMLParagraphElement;
21
22
 
22
23
  constructor(options: DragPanWarningOptions = {}) {
23
- const element = document.createElement("div");
24
- element.className =
25
- options.className !== undefined
26
- ? options.className
27
- : "ol-drag-pan-warning";
24
+ let element = options.element;
25
+
26
+ if (!element) {
27
+ element = document.createElement("div");
28
+ element.className =
29
+ options.className !== undefined
30
+ ? options.className
31
+ : "ol-drag-pan-warning";
32
+ }
33
+
28
34
  element.style.display = "none";
29
35
  element.style.pointerEvents = "auto";
30
36
 
@@ -34,21 +40,23 @@ class DragPanWarning extends Control {
34
40
  target: options.target,
35
41
  });
36
42
 
37
- this.icon = document.createElement("div");
38
- this.icon.className = `${element.className}-icon`;
43
+ if (!options.element) {
44
+ this.icon = document.createElement("div");
45
+ this.icon.className = `${element.className}-icon`;
39
46
 
40
- // sbb icons: sbb/two-finger-tap-large.svg';
41
- this.icon.innerHTML = `
47
+ // sbb icons: sbb/two-finger-tap-large.svg';
48
+ this.icon.innerHTML = `
42
49
  <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48">
43
50
  <path fill="none" stroke="currentColor" stroke-width="2" d="M22.999,25 L22.997,13.002 C22.997,11.896 23.893,11 24.999,11 C26.105,11 27.001,11.896 27.001,13.002 L26.999,26.002 M31,25.003 C31,23.897 31.896,23.001 33.002,23.001 C34.11,23.001 35.006,23.897 35.006,25.003 C35.006,25.003 35,26.125 35,32.001 C35,37.875 33.2,41.001 33.2,41.001 L19,41.001 C19,41.001 12.21,29.483 11.586,28.419 C10.962,27.355 10.804,26.369 11.586,25.587 C12.37,24.805 13.636,24.805 14.418,25.587 L18.998,30.169 L19,30.169 L19,25.001 L18.996,15.003 C18.996,13.897 19.894,13.001 21,13.001 C22.106,13.001 23.002,13.897 23.002,15.003 L23,26.015 M26.9942,22.997 C26.9942,21.891 27.8902,20.995 28.9962,20.995 C30.1042,20.995 31.0002,21.891 31.0002,22.997 L31.0002,26.001 M30,16.3046 C30.632,15.3606 31,14.2246 31,13.0006 C31,9.6846 28.314,7.0006 25,7.0006 C23.208,7.0006 21.616,7.8026 20.518,9.0486 C17.432,9.2986 15,11.8506 15,15.0006 C15,16.2166 15.368,17.3426 15.988,18.2866"/>
44
51
  </svg>
45
52
  `;
46
- this.element.appendChild(this.icon);
53
+ this.element.appendChild(this.icon);
47
54
 
48
- this.text = document.createElement("p");
49
- this.text.className = `${element.className}-text`;
50
- this.text.innerHTML = "Benutzen Sie 2 Finger um die Karte zu bedienen.";
51
- this.element.appendChild(this.text);
55
+ this.text = document.createElement("p");
56
+ this.text.className = `${element.className}-text`;
57
+ this.text.innerHTML = "Benutzen Sie 2 Finger um die Karte zu bedienen.";
58
+ this.element.appendChild(this.text);
59
+ }
52
60
 
53
61
  this.dragPan = undefined;
54
62
  this.onPointerDragRef = undefined;
@@ -1,18 +1,36 @@
1
1
  import { MouseWheelZoom } from "ol/interaction";
2
2
  import { useEffect, useState } from "preact/hooks";
3
+ import { twMerge } from "tailwind-merge";
3
4
 
5
+ import TouchFingers from "../icons/TouchFingers";
6
+ import useI18n from "../utils/hooks/useI18n";
4
7
  import useMapContext from "../utils/hooks/useMapContext";
5
8
 
6
9
  import DragPanWarning from "./DragPanWarning";
7
10
 
8
- function EmbedNavigation() {
11
+ import type { HTMLAttributes, PreactDOMAttributes } from "preact";
12
+
13
+ export type EmbedNavigationProps = {
14
+ contentClassName?: string;
15
+ elementClassName?: string;
16
+ iconProps?: React.SVGProps<SVGSVGElement>;
17
+ } & HTMLAttributes<HTMLDivElement> &
18
+ PreactDOMAttributes;
19
+
20
+ function EmbedNavigation({
21
+ contentClassName,
22
+ elementClassName,
23
+ iconProps,
24
+ }: EmbedNavigationProps) {
25
+ const { t } = useI18n();
9
26
  const { isEmbed, map } = useMapContext();
10
27
  const [target, setTarget] = useState(null);
28
+ const [element, setElement] = useState(null);
11
29
 
12
30
  useEffect(() => {
13
31
  let dragPanWarningControl = null;
14
32
 
15
- if (!map || !target || !isEmbed) {
33
+ if (!map || !target || !isEmbed || !element) {
16
34
  return;
17
35
  }
18
36
 
@@ -23,7 +41,10 @@ function EmbedNavigation() {
23
41
  }
24
42
  });
25
43
 
26
- dragPanWarningControl = new DragPanWarning({ target: target });
44
+ dragPanWarningControl = new DragPanWarning({
45
+ element: element,
46
+ target: target,
47
+ });
27
48
  map.addControl(dragPanWarningControl);
28
49
 
29
50
  return () => {
@@ -38,14 +59,35 @@ function EmbedNavigation() {
38
59
  }
39
60
  });
40
61
  };
41
- }, [map, target, isEmbed]);
62
+ }, [map, target, isEmbed, element]);
42
63
 
43
64
  return (
44
65
  <div
45
66
  ref={(node) => {
46
67
  return setTarget(node);
47
68
  }}
48
- ></div>
69
+ >
70
+ <div
71
+ className={twMerge(
72
+ "absolute inset-0 z-100000 flex h-full w-full flex-col items-center justify-center font-bold",
73
+ elementClassName,
74
+ "hidden",
75
+ )}
76
+ ref={(node) => {
77
+ return setElement(node);
78
+ }}
79
+ >
80
+ <div
81
+ className={twMerge(
82
+ "flex flex-col items-center gap-2 rounded-2xl bg-white p-10 shadow-lg",
83
+ contentClassName,
84
+ )}
85
+ >
86
+ <TouchFingers height="48" width="48" {...iconProps}></TouchFingers>
87
+ <p>{t("use_2_fingers")}</p>
88
+ </div>
89
+ </div>
90
+ </div>
49
91
  );
50
92
  }
51
93
 
@@ -102,12 +102,9 @@ function ExportMenu({ ...props }: ExportMenuButtonProps) {
102
102
  }, 1000);
103
103
  }}
104
104
  >
105
- {/* eslint-disable-next-line no-nested-ternary */}
106
- {isExporting
107
- ? t("exporting")
108
- : isExportingError
109
- ? t("error")
110
- : t("download")}
105
+ {isExporting && t("exporting")}
106
+ {!isExporting && isExportingError && t("error")}
107
+ {!isExporting && !isExportingError && t("download")}
111
108
  </Button>
112
109
  </div>
113
110
  </div>
@@ -14,12 +14,7 @@ export type OverlayDetailsHeaderProps = {
14
14
  layer?: BaseLayer;
15
15
  } & OverlayHeaderProps;
16
16
 
17
- function OverlayDetailsHeader({
18
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
- feature,
20
- layer,
21
- ...props
22
- }: OverlayDetailsHeaderProps) {
17
+ function OverlayDetailsHeader({ layer, ...props }: OverlayDetailsHeaderProps) {
23
18
  const { t } = useI18n();
24
19
  const layerConfig = useLayerConfig(layer?.get("name"));
25
20
  if (!layer) {
@@ -0,0 +1,20 @@
1
+ function TouchFingers(props: React.SVGProps<SVGSVGElement>) {
2
+ return (
3
+ <svg
4
+ height="24"
5
+ viewBox="0 0 48 48"
6
+ width="24"
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ {...props}
9
+ >
10
+ <path
11
+ d="M22.999,25 L22.997,13.002 C22.997,11.896 23.893,11 24.999,11 C26.105,11 27.001,11.896 27.001,13.002 L26.999,26.002 M31,25.003 C31,23.897 31.896,23.001 33.002,23.001 C34.11,23.001 35.006,23.897 35.006,25.003 C35.006,25.003 35,26.125 35,32.001 C35,37.875 33.2,41.001 33.2,41.001 L19,41.001 C19,41.001 12.21,29.483 11.586,28.419 C10.962,27.355 10.804,26.369 11.586,25.587 C12.37,24.805 13.636,24.805 14.418,25.587 L18.998,30.169 L19,30.169 L19,25.001 L18.996,15.003 C18.996,13.897 19.894,13.001 21,13.001 C22.106,13.001 23.002,13.897 23.002,15.003 L23,26.015 M26.9942,22.997 C26.9942,21.891 27.8902,20.995 28.9962,20.995 C30.1042,20.995 31.0002,21.891 31.0002,22.997 L31.0002,26.001 M30,16.3046 C30.632,15.3606 31,14.2246 31,13.0006 C31,9.6846 28.314,7.0006 25,7.0006 C23.208,7.0006 21.616,7.8026 20.518,9.0486 C17.432,9.2986 15,11.8506 15,15.0006 C15,16.2166 15.368,17.3426 15.988,18.2866"
12
+ fill="none"
13
+ stroke="currentColor"
14
+ strokeWidth="2"
15
+ />
16
+ </svg>
17
+ );
18
+ }
19
+
20
+ export default TouchFingers;
@@ -0,0 +1 @@
1
+ export { default } from "./TouchFingers";
@@ -63,6 +63,7 @@ const translations: Translations = {
63
63
  share_image_save: "Bild speichern",
64
64
  share_menu_title: "Teilen",
65
65
  stops_search_placeholder: "Haltestelle suchen",
66
+ use_2_fingers: "Benutzen Sie 2 Finger um die Karte zu bedienen.",
66
67
  zoomin: "Hineinzoomen",
67
68
  zoomout: "Herauszoomen",
68
69
  },
@@ -121,6 +122,7 @@ const translations: Translations = {
121
122
  share_image_save: "Save image",
122
123
  share_menu_title: "Share",
123
124
  stops_search_placeholder: "Search for stop",
125
+ use_2_fingers: "Use 2 fingers to operate the map.",
124
126
  zoomin: "Zoom in",
125
127
  zoomout: "Zoom out",
126
128
  },
@@ -179,6 +181,7 @@ const translations: Translations = {
179
181
  share_image_save: "Enregistrer l'image",
180
182
  share_menu_title: "Partager",
181
183
  stops_search_placeholder: "Chercher un arrêt",
184
+ use_2_fingers: "Utilisez 2 doigts pour manipuler la carte.",
182
185
  zoomin: "Zoomer",
183
186
  zoomout: "Dézoomer",
184
187
  },
@@ -237,6 +240,7 @@ const translations: Translations = {
237
240
  share_image_save: "Salva immagine",
238
241
  share_menu_title: "Condividi",
239
242
  stops_search_placeholder: "Ricerca delle fermate",
243
+ use_2_fingers: "Usa 2 dita per operare la mappa.",
240
244
  zoomin: "Zoom avanti",
241
245
  zoomout: "Zoom indietro",
242
246
  },