@geops/rvf-mobility-web-component 0.1.46 → 0.1.47

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.
Files changed (204) hide show
  1. package/.prettierrc.js +3 -1
  2. package/CHANGELOG.md +12 -0
  3. package/README.md +1 -1
  4. package/doc/package.json +4 -3
  5. package/doc/postcss.config.mjs +1 -1
  6. package/doc/src/app/components/GeopsMobilityDoc.tsx +13 -224
  7. package/doc/src/app/components/GeopsMobilitySearchDoc.tsx +11 -107
  8. package/doc/src/app/components/WebComponentDoc.tsx +45 -56
  9. package/doc/src/app/geops-mobility/page.tsx +7 -2
  10. package/doc/src/app/geops-mobility-search/page.tsx +6 -2
  11. package/doc/src/app/globals.css +47 -27
  12. package/doc/src/app/layout.tsx +4 -2
  13. package/docutils.js +33 -17
  14. package/eslint.config.mjs +28 -34
  15. package/iframe.html +181 -207
  16. package/index.html +108 -88
  17. package/index.js +2345 -1976
  18. package/input.css +21 -3
  19. package/package.json +39 -41
  20. package/scripts/build.mjs +2 -2
  21. package/scripts/dev.mjs +3 -3
  22. package/search.html +70 -23
  23. package/src/BaseLayer/BaseLayer.tsx +2 -1
  24. package/src/Copyright/Copyright.tsx +4 -2
  25. package/src/DebugDeparture/DebugDeparture.tsx +16 -12
  26. package/src/DebugStop/DebugStop.tsx +2 -2
  27. package/src/Departure/Departure.tsx +2 -3
  28. package/src/EmbedNavigation/DragPanWarning.ts +125 -0
  29. package/src/EmbedNavigation/EmbedNavigation.tsx +52 -0
  30. package/src/EmbedNavigation/index.js +1 -0
  31. package/src/EmbedNavigation/index.tsx +1 -0
  32. package/src/GeolocationButton/GeolocationButton.tsx +11 -35
  33. package/src/GeolocationButton/index.tsx +1 -1
  34. package/src/Map/Map.tsx +5 -3
  35. package/src/MapDispatchEvents/MapDispatchEvents.tsx +78 -0
  36. package/src/MapDispatchEvents/index.tsx +1 -0
  37. package/src/MobilityMap/MobilityMap.tsx +117 -162
  38. package/src/MobilityMap/MobilityMapAttributes.test.ts +21 -0
  39. package/src/MobilityMap/MobilityMapAttributes.ts +252 -0
  40. package/src/MobilityMap/index.tsx +1 -0
  41. package/src/MobilitySearch/MobilitySearch.tsx +35 -0
  42. package/src/MobilitySearch/MobilitySearchAttributes.test.ts +21 -0
  43. package/src/MobilitySearch/MobilitySearchAttributes.ts +68 -0
  44. package/src/MobilitySearch/index.ts +2 -0
  45. package/src/NotificationLayer/NotificationLayer.tsx +36 -5
  46. package/src/Overlay/Overlay.tsx +24 -11
  47. package/src/Permalink/Permalink.tsx +77 -0
  48. package/src/Permalink/index.tsx +1 -0
  49. package/src/RealtimeLayer/RealtimeLayer.tsx +72 -33
  50. package/src/RouteDestination/RouteDestination.tsx +3 -3
  51. package/src/RouteIcon/RouteIcon.tsx +33 -25
  52. package/src/RouteIcon/index.tsx +1 -1
  53. package/src/RouteIdentifier/RouteIdentifer.tsx +6 -5
  54. package/src/RouteInfos/RouteInfos.tsx +7 -3
  55. package/src/RouteSchedule/RouteSchedule.tsx +3 -3
  56. package/src/RouteScheduleFooter/RouteScheduleFooter.tsx +1 -1
  57. package/src/RouteScheduleHeader/RouteScheduleHeader.tsx +7 -29
  58. package/src/RouteStop/RouteStop.tsx +8 -11
  59. package/src/RouteStopDelay/RouteStopDelay.tsx +2 -1
  60. package/src/RouteStopName/RouteStopName.tsx +2 -2
  61. package/src/RouteStopPlatform/RouteStopPlatform.tsx +2 -2
  62. package/src/RouteStopProgress/RouteStopProgress.tsx +2 -1
  63. package/src/RouteStopServices/RouteStopServices.tsx +2 -2
  64. package/src/RouteStopStation/RouteStopStation.tsx +8 -2
  65. package/src/RouteStopTime/RouteStopTime.tsx +2 -1
  66. package/src/RvfButton/RvfButton.tsx +14 -5
  67. package/src/RvfCheckbox/RvfCheckbox.tsx +8 -8
  68. package/src/RvfEmbedNavigation/DragPanWarning.ts +5 -5
  69. package/src/RvfEmbedNavigation/RvfEmbedNavigation.tsx +1 -0
  70. package/src/RvfExportMenu/RvfExportMenu.tsx +14 -12
  71. package/src/RvfExportMenuButton/RvfExportMenuButton.tsx +6 -7
  72. package/src/RvfFeatureDetails/RvfFeatureDetails.tsx +25 -21
  73. package/src/RvfFeatureDetails/RvfLineNetworkDetails/RvfLineNetworkDetails.tsx +131 -127
  74. package/src/RvfFeatureDetails/RvfNotificationDetails/RvfNotificationDetails.tsx +309 -111
  75. package/src/RvfFeatureDetails/RvfSellingPointDetails/RvfSellingPointDetails.tsx +2 -2
  76. package/src/RvfFeatureDetails/RvfSharedMobilityDetail/FloatingVehiclesDetails/FloatingVehiclesDetails.tsx +3 -3
  77. package/src/RvfFeatureDetails/RvfSharedMobilityDetail/RvfSharedMobilityDetails.tsx +8 -6
  78. package/src/RvfFeatureDetails/RvfSharedMobilityDetail/StationDetails/StationDetails.tsx +5 -4
  79. package/src/RvfFeatureDetailsFooter/RvfFeatureDetailsFooter.tsx +43 -0
  80. package/src/RvfFeatureDetailsFooter/index.tsx +1 -0
  81. package/src/RvfFeatureDetailsTitle/RvfFeatureDetailsTitle.tsx +81 -0
  82. package/src/RvfFeatureDetailsTitle/index.tsx +1 -0
  83. package/src/RvfFloatingMenu/RvfFloatingMenu.tsx +4 -4
  84. package/src/RvfGeolocationButton/GeolocationButton.tsx +98 -0
  85. package/src/RvfGeolocationButton/index.tsx +1 -0
  86. package/src/RvfIconButton/RvfIconButton.tsx +20 -9
  87. package/src/RvfInputCopy/RvfInputCopy.tsx +8 -8
  88. package/src/RvfLayerTree/RvfLayerTree.tsx +5 -2
  89. package/src/RvfLayerTree/TreeItem/TreeItem.tsx +13 -16
  90. package/src/RvfLayerTree/layersTreeReducer.ts +23 -18
  91. package/src/RvfLayerTreeButton/RvfLayerTreeButton.tsx +6 -6
  92. package/src/RvfLineNetworkPlanLayer/RvfLineNetworkPlanLayer.tsx +2 -1
  93. package/src/RvfLink/RvfLink.tsx +4 -3
  94. package/src/RvfMobilityMap/RvfMobilityMap.tsx +324 -320
  95. package/src/RvfModal/RvfModal.tsx +4 -3
  96. package/src/RvfOverlayContent/RvfOverlayContent.tsx +128 -0
  97. package/src/RvfOverlayContent/index.ts +0 -0
  98. package/src/RvfOverlayHeader/RvfOverlayHeader.tsx +13 -10
  99. package/src/RvfPermalink/RvfPermalink.tsx +2 -2
  100. package/src/RvfPoisLayer/RvfPoisLayer.tsx +2 -1
  101. package/src/RvfRadioButton/RvfRadioButton.tsx +1 -1
  102. package/src/RvfRouteIcon/RvfRouteIcon.tsx +10 -0
  103. package/src/RvfRouteIcon/index.tsx +1 -0
  104. package/src/RvfSearch/RvfSearch.tsx +4 -1
  105. package/src/RvfSearchButton/RvfSearchButton.tsx +27 -0
  106. package/src/RvfSearchButton/index.tsx +1 -0
  107. package/src/RvfSelect/RvfSelect.tsx +7 -5
  108. package/src/RvfSelectedFeatureHighlightLayer/RvfSelectedFeatureHighlightLayer.tsx +1 -2
  109. package/src/RvfSellingPointsLayer/RvfSellingPointsLayer.tsx +2 -1
  110. package/src/RvfShare/RvfPermalinkButton/RvfPermalinkButton.tsx +13 -12
  111. package/src/RvfShare/RvfShare.tsx +11 -10
  112. package/src/RvfShareMenuButton/RvfShareMenuButton.tsx +5 -5
  113. package/src/RvfSharedMobilityLayerGroup/RvfSharedMobilityLayerGroup.tsx +25 -22
  114. package/src/RvfSingleClickListener/RvfSingleClickListener.tsx +102 -67
  115. package/src/RvfTarifZonenLayer/RvfTarifZonenLayer.tsx +2 -1
  116. package/src/RvfTopics/RvfTopics.tsx +6 -5
  117. package/src/RvfZoomButtons/RvfZoomButtons.tsx +3 -3
  118. package/src/ScaleLine/ScaleLine.tsx +5 -4
  119. package/src/ScrollableHandler/ScrollableHandler.tsx +2 -1
  120. package/src/ScrollableHandler/index.tsx +1 -1
  121. package/src/SingleClickListener/SingleClickListener.tsx +47 -4
  122. package/src/Station/Station.tsx +5 -5
  123. package/src/StationName/StationName.tsx +3 -3
  124. package/src/StationServices/StationServices.tsx +3 -3
  125. package/src/StationsLayer/StationsLayer.tsx +5 -4
  126. package/src/StopsSearch/StopsSearch.tsx +143 -88
  127. package/src/WindowMessageListener/WindowMessageListener.tsx +68 -0
  128. package/src/WindowMessageListener/index.tsx +1 -0
  129. package/src/icons/Airport/Airport.tsx +4 -4
  130. package/src/icons/ArrowDown/ArrowDown.tsx +1 -1
  131. package/src/icons/ArrowRight/ArrowRight.tsx +19 -0
  132. package/src/icons/ArrowRight/arrow-right.svg +16 -0
  133. package/src/icons/ArrowRight/index.tsx +1 -0
  134. package/src/icons/ArrowUp/ArrowUp.tsx +1 -1
  135. package/src/icons/ArrowUpRight/ArrowUpRight.tsx +1 -1
  136. package/src/icons/BarAndRestaurants/BarAndRestaurants.tsx +2 -2
  137. package/src/icons/Bathroom/Bathroom.tsx +1 -1
  138. package/src/icons/Copy/Copy.tsx +1 -1
  139. package/src/icons/Doc/Doc.tsx +1 -1
  140. package/src/icons/Email/Email.tsx +1 -1
  141. package/src/icons/FilePdf/FilePdf.tsx +1 -1
  142. package/src/icons/Geolocation/Geolocation.tsx +3 -5
  143. package/src/icons/Image/Image.tsx +1 -1
  144. package/src/icons/Menu/Menu.tsx +1 -1
  145. package/src/icons/Minus/Minus.tsx +1 -1
  146. package/src/icons/NoRealtime/NoRealtime.tsx +1 -1
  147. package/src/icons/Plus/Plus.tsx +1 -1
  148. package/src/icons/Police/Police.tsx +3 -3
  149. package/src/icons/Search/Search.tsx +0 -1
  150. package/src/icons/Share/Share.tsx +1 -1
  151. package/src/icons/Stack/Stack.tsx +1 -1
  152. package/src/icons/Tracking/Tracking.tsx +29 -0
  153. package/src/icons/Tracking/airport-14-svgrepo-com.svg +41 -0
  154. package/src/icons/Tracking/index.tsx +1 -0
  155. package/src/icons/WaitingAreas/WaitingAreas.tsx +1 -1
  156. package/src/icons/Warning/Warning.tsx +56 -0
  157. package/src/icons/Warning/index.tsx +1 -0
  158. package/src/icons/Warning/info-achtung-kreisrot-rot.svg +28 -0
  159. package/src/icons/WheelChair/WheelChair.tsx +1 -1
  160. package/src/index.tsx +8 -46
  161. package/src/indexDoc.ts +13 -0
  162. package/src/ui/Button/Button.tsx +57 -0
  163. package/src/ui/Button/index.tsx +1 -0
  164. package/src/ui/IconButton/IconButton.tsx +44 -0
  165. package/src/ui/IconButton/index.tsx +1 -0
  166. package/src/utils/MobilityEvent.ts +4 -3
  167. package/src/utils/applyInitialLayerVisibility.ts +3 -3
  168. package/src/utils/centerOnStation.ts +3 -2
  169. package/src/utils/centerOnVehicle.ts +5 -4
  170. package/src/utils/constants.ts +27 -3
  171. package/src/utils/exportPdf.ts +26 -20
  172. package/src/utils/fullTrajectoryStyle.ts +2 -2
  173. package/src/utils/getAllLayers.ts +4 -3
  174. package/src/utils/getDelayColor.test.ts +1 -0
  175. package/src/utils/getDelayColorForVehicle.test.ts +2 -0
  176. package/src/utils/getDelayString.test.ts +3 -0
  177. package/src/utils/getDelayTextForVehicle.test.ts +4 -0
  178. package/src/utils/getFullTrajectoryAndFit.ts +4 -3
  179. package/src/utils/getHoursAndMinutes.test.ts +1 -0
  180. package/src/utils/getLayersAsFlatArray.ts +2 -2
  181. package/src/utils/getLinkByDevice.ts +1 -1
  182. package/src/utils/getMainColorForVehicle.ts +3 -3
  183. package/src/utils/getPermalinkParameters.ts +2 -2
  184. package/src/utils/getStopStatus.test.ts +2 -1
  185. package/src/utils/getStopStatus.ts +1 -1
  186. package/src/utils/getTextForVehicle.ts +1 -1
  187. package/src/utils/hooks/useDeparture.tsx +6 -5
  188. package/src/utils/hooks/useI18n.tsx +6 -4
  189. package/src/utils/hooks/useInitialLayersVisiblity.tsx +2 -1
  190. package/src/utils/hooks/useLayerConfig.tsx +40 -0
  191. package/src/utils/hooks/useMapContext.tsx +30 -18
  192. package/src/utils/hooks/useRouteStop.tsx +3 -2
  193. package/src/utils/hooks/useRvfContext.tsx +11 -3
  194. package/src/utils/hooks/useStation.tsx +2 -1
  195. package/src/utils/hooks/useUpdatePermalink.tsx +25 -24
  196. package/src/utils/hooks/useZoom.tsx +4 -4
  197. package/src/utils/realtimeRVFStyle.ts +5 -4
  198. package/src/utils/sharingGraphqlUtils.ts +3 -2
  199. package/src/utils/sharingStylesUtils.ts +7 -7
  200. package/src/utils/sharingWFSUtils.ts +9 -15
  201. package/tailwind.config.mjs +1 -0
  202. package/tsconfig.json +1 -1
  203. package/doc/tailwind.config.ts +0 -20
  204. package/src/utils/getFeatureInformationTitle.tsx +0 -54
package/input.css CHANGED
@@ -1,6 +1,24 @@
1
- @tailwind base;
2
- @tailwind components;
3
- @tailwind utilities;
1
+ @import 'tailwindcss';
2
+
3
+ @config './tailwind.config.mjs';
4
+
5
+ /*
6
+ The default border color has changed to `currentColor` in Tailwind CSS v4,
7
+ so we've added these compatibility styles to make sure everything still
8
+ looks the same as it did with Tailwind CSS v3.
9
+
10
+ If we ever want to remove these styles, we need to add an explicit border
11
+ color utility to any element that depends on these defaults.
12
+ */
13
+ @layer base {
14
+ *,
15
+ ::after,
16
+ ::before,
17
+ ::backdrop,
18
+ ::file-selector-button {
19
+ border-color: var(--color-gray-200, currentColor);
20
+ }
21
+ }
4
22
 
5
23
  ::-webkit-scrollbar {
6
24
  width: 3px;
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.46",
5
+ "version": "0.1.47",
6
6
  "homepage": "https://rvf-mobility-web-component-geops.vercel.app/",
7
7
  "type": "module",
8
8
  "main": "index.js",
@@ -11,65 +11,63 @@
11
11
  "graphql-request": "^7.1.2",
12
12
  "jspdf": "^2.5.2",
13
13
  "lodash.debounce": "^4.0.8",
14
- "maplibre-gl": "^4.7.1",
15
- "mobility-toolbox-js": "3.3.1",
16
- "ol": "^10.3.1",
17
- "preact": "^10.25.4",
18
- "preact-custom-element": "^4.3.0",
14
+ "maplibre-gl": "^5.7.2",
15
+ "mobility-toolbox-js": "3.3.4-beta.31",
16
+ "ol": "^10.6.1",
17
+ "preact": "^10.27.2",
18
+ "preact-custom-element": "^4.5.1",
19
19
  "react": "npm:@preact/compat@^18.3.1",
20
20
  "react-dom": "npm:@preact/compat@^18.3.1",
21
- "react-icons": "^5.4.0",
22
- "react-spatial": "^1.12.2",
21
+ "react-icons": "^5.5.0",
22
+ "react-spatial": "^2.0.0",
23
23
  "rosetta": "^1.1.0",
24
- "showdown": "^2.1.0",
25
- "tailwind-merge": "^2.6.0"
24
+ "showdown": "^2.1.0"
26
25
  },
27
26
  "devDependencies": {
28
- "@commitlint/cli": "^19.6.1",
29
- "@commitlint/config-conventional": "^19.6.0",
30
- "@eslint/js": "^9.17.0",
27
+ "@commitlint/cli": "^19.8.1",
28
+ "@commitlint/config-conventional": "^19.8.1",
29
+ "@eslint/js": "^9.35.0",
30
+ "@geops/eslint-config-react": "^1.5.0",
31
+ "@tailwindcss/cli": "^4.1.13",
31
32
  "@tailwindcss/container-queries": "^0.1.1",
32
33
  "@testing-library/preact": "^3.2.4",
33
- "@types/geojson": "^7946.0.15",
34
- "@types/jest": "^29.5.14",
34
+ "@types/geojson": "^7946.0.16",
35
+ "@types/jest": "^30.0.0",
35
36
  "@types/preact-custom-element": "^4.0.4",
36
- "concurrently": "^9.1.2",
37
- "esbuild": "^0.24.2",
37
+ "concurrently": "^9.2.1",
38
+ "esbuild": "^0.25.10",
38
39
  "esbuild-sass-plugin": "^3.3.1",
39
- "eslint": "^9.17.0",
40
- "eslint-config-prettier": "9.1.0",
41
- "eslint-plugin-jsx-a11y": "^6.10.2",
42
- "eslint-plugin-perfectionist": "^4.5.0",
43
- "eslint-plugin-prettier": "^5.2.1",
44
- "eslint-plugin-react": "^7.37.3",
45
- "eslint-plugin-react-hooks": "^5.1.0",
46
- "eslint-plugin-tailwindcss": "^3.17.5",
40
+ "eslint": "^9.35.0",
41
+ "eslint-plugin-tailwindcss": "^4.0.0-beta.0",
47
42
  "fixpack": "^4.0.0",
48
43
  "generact": "^0.4.0",
49
44
  "husky": "^9.1.7",
50
- "jest": "^29.7.0",
45
+ "jest": "^30.1.3",
51
46
  "jest-canvas-mock": "^2.5.2",
52
- "jest-environment-jsdom": "^29.7.0",
47
+ "jest-environment-jsdom": "^30.1.2",
53
48
  "jest-preset-preact": "^4.1.1",
54
- "next": "15.0.3",
55
- "preact-render-to-string": "^6.5.12",
56
- "prettier": "^3.4.2",
49
+ "lint-staged": "^16.2.0",
50
+ "next": "15.5.2",
51
+ "preact-render-to-string": "^6.6.1",
52
+ "prettier": "^3.6.2",
53
+ "prettier-plugin-tailwindcss": "^0.6.14",
57
54
  "standard-version": "^9.5.0",
58
- "tailwindcss": "^3.4.17",
59
- "ts-jest": "^29.2.5",
60
- "typescript": "^5.7.2",
61
- "typescript-eslint": "^8.19.0"
55
+ "tailwind-merge": "^3.3.1",
56
+ "tailwindcss": "^4.1.13",
57
+ "ts-jest": "^29.4.3",
58
+ "typescript": "^5.9.2",
59
+ "typescript-eslint": "^8.44.0"
62
60
  },
63
61
  "scripts": {
64
- "build": "yarn build:css && yarn build:js",
62
+ "build": "yarn build:css && yarn build:js && cp index*.js* doc/public/",
65
63
  "build:css": "yarn tailwind:component && yarn tailwind:website",
66
64
  "build:js": "node scripts/build.mjs",
67
65
  "cp": "generact --root src",
68
66
  "dev": "node scripts/dev.mjs",
69
- "doc": "yarn build && cp index.js doc/public/index.js && cd doc && yarn build",
70
- "doc:dev": "yarn build && cp index.js doc/public/index.js && cp index.js.map doc/public/index.js.map && cd doc && yarn dev",
71
- "format": "prettier --write 'src/**/*.(tsx|ts)' && eslint src/**/*.tsx src/**/*.ts --fix ",
72
- "lint": "eslint src/**/*.tsx",
67
+ "doc": "yarn build && cd doc && yarn build",
68
+ "doc:dev": "yarn build && cd doc && yarn dev",
69
+ "format": "prettier --write 'src/**/*.(tsx|ts)' && eslint 'src/**/*.tsx' 'src/**/*.ts' --fix ",
70
+ "lint": "eslint 'src/**/*.tsx' 'src/**/*.ts'",
73
71
  "prepare": "husky",
74
72
  "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 ",
75
73
  "publish:beta:dryrun": "yarn release -- --prerelease beta --dry-run --skip.changelog",
@@ -77,8 +75,8 @@
77
75
  "publish:public:dryrun": "yarn release --dry-run",
78
76
  "release": "standard-version",
79
77
  "start": "concurrently \"yarn tailwind:component --watch\" \"yarn tailwind:website --watch\" \"yarn dev\"",
80
- "tailwind:component": "tailwindcss --input=./input.css --output=src/style.css --content=src/**/*.tsx",
81
- "tailwind:website": "tailwindcss --input=./input.css --output=output.css --content=*.html --minify",
78
+ "tailwind:component": "npx @tailwindcss/cli --input=./input.css --output=src/style.css --content=src/**/*.tsx",
79
+ "tailwind:website": "npx @tailwindcss/cli --input=./input.css --output=output.css --content=*.html --minify",
82
80
  "test": "TZ=UTC jest",
83
81
  "up": "yarn upgrade-interactive --latest",
84
82
  "upstream": "git fetch upstream && git merge upstream/main"
package/scripts/build.mjs CHANGED
@@ -3,14 +3,14 @@ import { sassPlugin } from "esbuild-sass-plugin";
3
3
 
4
4
  await esbuild.build({
5
5
  bundle: true,
6
- entryPoints: ["./src/index.js"],
6
+ entryPoints: ["./src/index.js", "./src/indexDoc.js"],
7
7
  external: ["mapbox-gl"],
8
8
  loader: {
9
9
  ".png": "dataurl",
10
10
  ".svg": "dataurl",
11
11
  },
12
12
  minify: true,
13
- outfile: "index.js",
13
+ outdir: "./",
14
14
  plugins: [sassPlugin({ type: "css-text" })],
15
15
  sourcemap: false,
16
16
  });
package/scripts/dev.mjs CHANGED
@@ -3,13 +3,13 @@ import { sassPlugin } from "esbuild-sass-plugin";
3
3
 
4
4
  const ctx = await esbuild.context({
5
5
  bundle: true,
6
- entryPoints: ["./src/index.js"],
6
+ entryPoints: ["./src/index.js", "./src/indexDoc.js"],
7
7
  external: ["mapbox-gl"],
8
8
  loader: {
9
9
  ".png": "dataurl",
10
10
  ".svg": "dataurl",
11
11
  },
12
- outfile: "index.js",
12
+ outdir: "./",
13
13
  plugins: [sassPlugin({ type: "css-text" })],
14
14
  sourcemap: true,
15
15
  });
@@ -23,6 +23,6 @@ await ctx.watch();
23
23
  // eslint-disable-next-line no-undef
24
24
  console.log(
25
25
  `watching... and running at ${
26
- host === "0.0.0.0" ? "http://localhost" : host
26
+ !host || host === "0.0.0.0" ? "http://localhost" : host
27
27
  }:${port}`,
28
28
  );
package/search.html CHANGED
@@ -16,6 +16,7 @@
16
16
  }
17
17
  </script>
18
18
  <script type="module" src="./index.js"></script>
19
+ <script type="module" src="./indexDoc.js"></script>
19
20
  <script src="./docutils.js"></script>
20
21
  <link rel="stylesheet" type="text/css" href="./output.css" />
21
22
  <style>
@@ -82,32 +83,78 @@
82
83
  const pkgSrc = "https://www.unpkg.com/@geops/mobility-web-component";
83
84
  const wc = document.querySelector("geops-mobility-search");
84
85
 
85
- const attrs = [
86
- "apikey",
87
- "bbox",
88
- "countrycode",
89
- "event",
90
- "field",
91
- "limit",
92
- "mots",
93
- "onselect",
94
- "params",
95
- "prefagencies",
96
- "reflocation",
97
- "url",
98
- ];
86
+ window.addEventListener("load", () => {
99
87
 
100
- const events = [
101
- "mwc:stopssearchselect",
102
- ];
88
+ // Add special parameters
89
+ window.MobilityMapAttributes.fullscreen = {
90
+ type: "boolean",
91
+ defaultValue: "false",
92
+ description: `Load the page in fullscreen mode.`,
93
+ reload: true,
94
+ };
103
95
 
104
- document.querySelector('#attributes').innerHTML = generateAttributesTable(wc, attrs);
105
- document.querySelector('#events').innerHTML = generateEventsTable(wc, events);
106
- document.querySelector('#code').innerHTML = generateCodeText(wc, attrs, pkgSrc);
107
- wc.addEventListener('mwc:attribute', (event) => {
108
- document.querySelector('#code').innerHTML = generateCodeText(wc, attrs, pkgSrc);
96
+ /* Attributes */
97
+ const attrs = Object.keys(MobilitySearchAttributes);
98
+ const booleanAttrs = Object.entries(MobilitySearchAttributes)
99
+ .filter(([, attr]) => attr.type === "boolean")
100
+ .map(([key]) => key);
101
+ const booleanTrueByDefault = booleanAttrs.filter(
102
+ (key) => MobilitySearchAttributes[key].defaultValue === "true",
103
+ );
104
+ const reloadAttrs = Object.entries(MobilitySearchAttributes)
105
+ .filter(([key, attr]) => !!attr.reload)
106
+ .map(([key]) => key);
107
+
108
+ const descriptionByAttr = Object.entries(MobilitySearchAttributes).reduce((acc, [key, attr]) => {
109
+ acc[key] = attr.description;
110
+ return acc;
111
+ }, {});
112
+
113
+ /* Events */
114
+ const events = [
115
+ "mwc:stopssearchselect",
116
+ "mwc:attribute",
117
+ ];
118
+ const descriptionByEvent = {
119
+ "mwc:stopssearchselect":
120
+ "Only when search attribute is 'true'. Event fired when a stop is selected in the stops search results. The event data contains the selected stop.",
121
+ "mwc:attribute":
122
+ "Event fired when an web component's attribute is changed. The event data contains the list of all attributes and their values.",
123
+ };
124
+
125
+ document.querySelector("#attributes").innerHTML =
126
+ generateAttributesTable(
127
+ wc,
128
+ attrs,
129
+ booleanAttrs,
130
+ booleanTrueByDefault,
131
+ descriptionByAttr,
132
+ reloadAttrs,
133
+ );
134
+ document.querySelector("#events").innerHTML = generateEventsTable(
135
+ wc,
136
+ events,
137
+ descriptionByEvent,
138
+ );
139
+ document.querySelector("#code").innerHTML = generateCodeText(
140
+ wc,
141
+ attrs,
142
+ pkgSrc,
143
+ );
144
+ wc.addEventListener("mwc:attribute", (event) => {
145
+ document.querySelector("#code").innerHTML = generateCodeText(
146
+ wc,
147
+ attrs,
148
+ pkgSrc,
149
+ );
150
+ });
151
+ applyPermalinkParameters(wc);
152
+ events.forEach((eventName) => {
153
+ wc.addEventListener(eventName, (event) => {
154
+ console.log(`${eventName} event`, event);
155
+ });
156
+ });
109
157
  });
110
- applyPermalinkParameters(wc);
111
158
  </script>
112
159
  </body>
113
160
  </html>
@@ -1,10 +1,11 @@
1
1
  import { MaplibreLayer } from "mobility-toolbox-js/ol";
2
- import { MaplibreLayerOptions } from "mobility-toolbox-js/ol/layers/MaplibreLayer";
3
2
  import { memo } from "preact/compat";
4
3
  import { useEffect, useMemo } from "preact/hooks";
5
4
 
6
5
  import useMapContext from "../utils/hooks/useMapContext";
7
6
 
7
+ import type { MaplibreLayerOptions } from "mobility-toolbox-js/ol/layers/MaplibreLayer";
8
+
8
9
  export type BaseLayerProps = MaplibreLayerOptions;
9
10
 
10
11
  function BaseLayer(props: BaseLayerProps) {
@@ -1,12 +1,14 @@
1
1
  import { CopyrightControl } from "mobility-toolbox-js/ol";
2
- import { CopyrightControlOptions } from "mobility-toolbox-js/ol/controls/CopyrightControl";
3
- import { JSX, PreactDOMAttributes } from "preact";
4
2
  import { useEffect, useMemo, useState } from "preact/hooks";
5
3
 
6
4
  import useMapContext from "../utils/hooks/useMapContext";
5
+
7
6
  // @ts-expect-error bad type definition
8
7
  import style from "./index.css";
9
8
 
9
+ import type { CopyrightControlOptions } from "mobility-toolbox-js/ol/controls/CopyrightControl";
10
+ import type { JSX, PreactDOMAttributes } from "preact";
11
+
10
12
  export type CopyrightProps = {
11
13
  options?: CopyrightControlOptions;
12
14
  } & JSX.HTMLAttributes<HTMLDivElement> &
@@ -1,8 +1,11 @@
1
- import { JSX, PreactDOMAttributes } from "preact";
2
-
3
1
  import useDebug from "../utils/hooks/useDebug";
4
2
  import useDeparture from "../utils/hooks/useDeparture";
5
3
 
4
+ import type { RealtimeDeparture } from "mobility-toolbox-js/types";
5
+ import type { JSX, PreactDOMAttributes } from "preact";
6
+
7
+ import type { StationFeature } from "../StopsSearch";
8
+
6
9
  export type DebugDepartureProps = JSX.HTMLAttributes<HTMLDivElement> &
7
10
  PreactDOMAttributes;
8
11
 
@@ -13,7 +16,7 @@ const pad = (n: number) => {
13
16
  return `0${n}`.slice(-2);
14
17
  };
15
18
 
16
- const formatDebugTime = (time, excludeSeconds = false) => {
19
+ const formatDebugTime = (time: string, excludeSeconds = false) => {
17
20
  const d = new Date(time);
18
21
 
19
22
  return !time || Number.isNaN(d)
@@ -37,34 +40,35 @@ function DebugDeparture(props: DebugDepartureProps) {
37
40
  return null;
38
41
  }
39
42
  const {
40
- // @ts-expect-error bad type definition
41
43
  arrivalTime,
42
44
  at_station_ds100: atStationDs100,
43
- // @ts-expect-error bad type definition
44
45
  departureTime,
45
46
  fzo_estimated_time: fzoEstimatedTime,
46
47
  has_fzo: hasFzo,
47
- // @ts-expect-error bad type definition
48
48
  last_boarding_time: lastBoardingTime,
49
49
  min_arrival_time: minArrivalTime,
50
50
  ris_aimed_time: risAimedTime,
51
51
  ris_estimated_time: risEstimatedTime,
52
52
  state,
53
- // @ts-expect-error bad type definition
54
53
  station,
55
- // @ts-expect-error bad type definition
56
54
  stations_in_between: stationsInBetween,
57
55
  time,
58
56
  train_number: trainNumber,
59
- } = departure;
57
+ } = departure as {
58
+ arrivalTime: string;
59
+ departureTime: string;
60
+ last_boarding_time: string;
61
+ station: StationFeature;
62
+ stations_in_between: number;
63
+ } & RealtimeDeparture;
60
64
 
61
65
  const risTime = new Date(risAimedTime);
62
66
  const urlDate = Number.isNaN(risTime)
63
67
  ? ""
64
68
  : [
65
- (risTime as Date).getFullYear(),
66
- pad((risTime as Date).getMonth() + 1),
67
- pad((risTime as Date).getDate()),
69
+ risTime.getFullYear(),
70
+ pad(risTime.getMonth() + 1),
71
+ pad(risTime.getDate()),
68
72
  ].join("-");
69
73
 
70
74
  const risLink = [
@@ -1,8 +1,8 @@
1
- import { JSX, PreactDOMAttributes } from "preact";
2
-
3
1
  import useDebug from "../utils/hooks/useDebug";
4
2
  import useRouteStop from "../utils/hooks/useRouteStop";
5
3
 
4
+ import type { JSX, PreactDOMAttributes } from "preact";
5
+
6
6
  export type DebugStopProps = JSX.HTMLAttributes<HTMLDivElement> &
7
7
  PreactDOMAttributes;
8
8
 
@@ -1,5 +1,3 @@
1
- import type { RealtimeDeparture } from "mobility-toolbox-js/types";
2
-
3
1
  import { memo, useMemo } from "preact/compat";
4
2
 
5
3
  import DebugDeparture from "../DebugDeparture";
@@ -8,6 +6,8 @@ import getHoursAndMinutes from "../utils/getHoursAndMinutes";
8
6
  import { DepartureContext } from "../utils/hooks/useDeparture";
9
7
  import useMapContext from "../utils/hooks/useMapContext";
10
8
 
9
+ import type { RealtimeDeparture } from "mobility-toolbox-js/types";
10
+
11
11
  export interface DepartureProps {
12
12
  departure: RealtimeDeparture;
13
13
  index: number;
@@ -28,7 +28,6 @@ function Departure({ departure, index, ...props }: DepartureProps) {
28
28
  setTrainId(departure.train_id);
29
29
  setStationId();
30
30
  }}
31
- type="button"
32
31
  {...props}
33
32
  >
34
33
  <div
@@ -0,0 +1,125 @@
1
+ import { Control } from "ol/control";
2
+ import { DragPan } from "ol/interaction";
3
+ import { unByKey } from "ol/Observable";
4
+
5
+ import type { Map, MapBrowserEvent } from "ol";
6
+ import type { Options } from "ol/control/Control";
7
+ import type { EventsKey } from "ol/events";
8
+
9
+ type DragPanWarningOptions = {
10
+ className?: string;
11
+ } & Options;
12
+
13
+ class DragPanWarning extends Control {
14
+ dragPan?: DragPan;
15
+
16
+ icon: HTMLDivElement;
17
+
18
+ onPointerDragRef?: EventsKey;
19
+
20
+ text: HTMLParagraphElement;
21
+
22
+ constructor(options: DragPanWarningOptions = {}) {
23
+ const element = document.createElement("div");
24
+ element.className =
25
+ options.className !== undefined
26
+ ? options.className
27
+ : "ol-drag-pan-warning";
28
+ element.style.display = "none";
29
+ element.style.pointerEvents = "auto";
30
+
31
+ super({
32
+ element,
33
+ render: options.render,
34
+ target: options.target,
35
+ });
36
+
37
+ this.icon = document.createElement("div");
38
+ this.icon.className = `${element.className}-icon`;
39
+
40
+ // sbb icons: sbb/two-finger-tap-large.svg';
41
+ this.icon.innerHTML = `
42
+ <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48">
43
+ <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
+ </svg>
45
+ `;
46
+ this.element.appendChild(this.icon);
47
+
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);
52
+
53
+ this.dragPan = undefined;
54
+ this.onPointerDragRef = undefined;
55
+ this.onPointerDrag = this.onPointerDrag.bind(this);
56
+ this.onTouchEnd = this.onTouchEnd.bind(this);
57
+ }
58
+
59
+ onPointerDrag(event: MapBrowserEvent<PointerEvent>) {
60
+ // Show the warning on next pointerdrag events.
61
+ if (event.activePointers?.length !== 1) {
62
+ return true;
63
+ }
64
+ this.element.style.display = "flex";
65
+ document.addEventListener("touchend", this.onTouchEnd, { once: true });
66
+ return false;
67
+ }
68
+
69
+ onTouchEnd() {
70
+ unByKey(this.onPointerDragRef);
71
+ this.element.style.display = "none";
72
+ }
73
+
74
+ setMap(map: Map) {
75
+ super.setMap(map);
76
+ document.removeEventListener("touchend", this.onTouchEnd);
77
+ unByKey(this.onPointerDragRef);
78
+
79
+ if (map) {
80
+ const viewport = map.getViewport();
81
+
82
+ // We allow default scroll behavior for touch events.
83
+ viewport.style.touchAction = "pan-x pan-y";
84
+
85
+ // Deactivate drag pan only on touch events.
86
+ this.dragPan = map
87
+ .getInteractions()
88
+ .getArray()
89
+ .find((interaction) => {
90
+ return interaction instanceof DragPan;
91
+ });
92
+
93
+ if (!this.dragPan) {
94
+ // eslint-disable-next-line no-console
95
+ console.error(
96
+ "Impossible to find the DragPan interaction, DragPanWarning will not work as expected.",
97
+ );
98
+ return;
99
+ }
100
+
101
+ this.listenerKeys.push(
102
+ // @ts-expect-error - we need to listen to pointerdown events
103
+ map.on("pointerdown", (evt: MapBrowserEvent<PointerEvent>) => {
104
+ document.removeEventListener("touchend", this.onTouchEnd);
105
+
106
+ if (
107
+ evt.originalEvent.pointerType !== "touch" ||
108
+ // @ts-expect-error - condition_ is a private method
109
+ !this.dragPan?.condition_(evt)
110
+ ) {
111
+ this.element.style.display = "none";
112
+ return true;
113
+ }
114
+
115
+ this.onPointerDragRef = map.on("pointerdrag", this.onPointerDrag);
116
+
117
+ return true;
118
+ }),
119
+ );
120
+ this.element.addEventListener("click", this.onTouchEnd);
121
+ }
122
+ }
123
+ }
124
+
125
+ export default DragPanWarning;
@@ -0,0 +1,52 @@
1
+ import { MouseWheelZoom } from "ol/interaction";
2
+ import { useEffect, useState } from "preact/hooks";
3
+
4
+ import useMapContext from "../utils/hooks/useMapContext";
5
+
6
+ import DragPanWarning from "./DragPanWarning";
7
+
8
+ function EmbedNavigation() {
9
+ const { isEmbed, map } = useMapContext();
10
+ const [target, setTarget] = useState(null);
11
+
12
+ useEffect(() => {
13
+ let dragPanWarningControl = null;
14
+
15
+ if (!map || !target || !isEmbed) {
16
+ return;
17
+ }
18
+
19
+ // Deactivates mouse wheel zoom
20
+ map.getInteractions().forEach((interaction) => {
21
+ if (interaction instanceof MouseWheelZoom) {
22
+ interaction.setActive(false);
23
+ }
24
+ });
25
+
26
+ dragPanWarningControl = new DragPanWarning({ target: target });
27
+ map.addControl(dragPanWarningControl);
28
+
29
+ return () => {
30
+ if (dragPanWarningControl) {
31
+ map.removeControl(dragPanWarningControl);
32
+ }
33
+
34
+ // Deactivates mouse wheel zoom
35
+ map.getInteractions().forEach((interaction) => {
36
+ if (interaction instanceof MouseWheelZoom) {
37
+ interaction.setActive(true);
38
+ }
39
+ });
40
+ };
41
+ }, [map, target, isEmbed]);
42
+
43
+ return (
44
+ <div
45
+ ref={(node) => {
46
+ return setTarget(node);
47
+ }}
48
+ ></div>
49
+ );
50
+ }
51
+
52
+ export default EmbedNavigation;
@@ -0,0 +1 @@
1
+ export { default } from "./EmbedNavigation";
@@ -0,0 +1 @@
1
+ export { default } from "./EmbedNavigation";