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

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.
@@ -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 = { className?: string } & InputHTMLAttributes &
6
+ export type InputProps = {
7
+ className?: string;
8
+ focusOnFirstRender?: boolean;
9
+ } & InputHTMLAttributes &
6
10
  PreactDOMAttributes;
7
11
 
8
- function Input({ className, ...props }: InputProps) {
9
- return (
10
- <input
11
- {...props}
12
- className={twMerge("p-2 text-sm read-only:text-gray-400", className)}
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-16 items-center gap-4 rounded-md bg-white p-4 pt-3.5 shadow",
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 size-4 items-center rounded-none border-none bg-transparent p-0 shadow-none",
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")}
@@ -1,9 +1,10 @@
1
1
  import { createContext } from "preact";
2
2
  import { useContext } from "preact/hooks";
3
3
 
4
- import type { Rosetta } from "rosetta";
5
-
6
- export type I18NContextType = Rosetta<Record<string, string>>;
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
  }
@@ -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 Mobility",
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: "Haltestellen suchen",
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]: "Shared Mobility",
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]: "Mobilité partagée",
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]: "Mobilità condivisa",
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",
package/src/utils/i18n.ts DELETED
@@ -1,7 +0,0 @@
1
- import rosetta from "rosetta";
2
-
3
- import translations from "./translations";
4
-
5
- const i18n = rosetta(translations);
6
-
7
- export default i18n;