react-spatial 1.5.3 → 1.5.4

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 (294) hide show
  1. package/components/BaseLayerSwitcher/BaseLayerSwitcher.js +231 -0
  2. package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +7 -0
  3. package/components/BaseLayerSwitcher/index.js +1 -0
  4. package/components/BaseLayerSwitcher/index.js.map +7 -0
  5. package/components/BasicMap/BasicMap.js +278 -0
  6. package/components/BasicMap/BasicMap.js.map +7 -0
  7. package/components/BasicMap/index.js +1 -0
  8. package/components/BasicMap/index.js.map +7 -0
  9. package/{src/components → components}/CanvasSaveButton/CanvasSaveButton.js +93 -320
  10. package/components/CanvasSaveButton/CanvasSaveButton.js.map +7 -0
  11. package/components/CanvasSaveButton/index.js +1 -0
  12. package/components/CanvasSaveButton/index.js.map +7 -0
  13. package/components/Copyright/Copyright.js +55 -0
  14. package/components/Copyright/Copyright.js.map +7 -0
  15. package/components/Copyright/index.js +1 -0
  16. package/components/Copyright/index.js.map +7 -0
  17. package/components/FeatureExportButton/FeatureExportButton.js +62 -0
  18. package/components/FeatureExportButton/FeatureExportButton.js.map +7 -0
  19. package/components/FeatureExportButton/index.js +1 -0
  20. package/components/FeatureExportButton/index.js.map +7 -0
  21. package/components/FitExtent/FitExtent.js +32 -0
  22. package/components/FitExtent/FitExtent.js.map +7 -0
  23. package/components/FitExtent/index.js +1 -0
  24. package/components/FitExtent/index.js.map +7 -0
  25. package/{src/components → components}/Geolocation/Geolocation.js +61 -144
  26. package/components/Geolocation/Geolocation.js.map +7 -0
  27. package/components/Geolocation/index.js +1 -0
  28. package/components/Geolocation/index.js.map +7 -0
  29. package/components/LayerTree/LayerTree.js +278 -0
  30. package/components/LayerTree/LayerTree.js.map +7 -0
  31. package/components/LayerTree/index.js +1 -0
  32. package/components/LayerTree/index.js.map +7 -0
  33. package/components/MousePosition/MousePosition.js +110 -0
  34. package/components/MousePosition/MousePosition.js.map +7 -0
  35. package/components/MousePosition/index.js +1 -0
  36. package/components/MousePosition/index.js.map +7 -0
  37. package/components/NorthArrow/NorthArrow.js +43 -0
  38. package/components/NorthArrow/NorthArrow.js.map +7 -0
  39. package/components/NorthArrow/index.js +1 -0
  40. package/components/NorthArrow/index.js.map +7 -0
  41. package/components/Overlay/Overlay.js +122 -0
  42. package/components/Overlay/Overlay.js.map +7 -0
  43. package/components/Overlay/index.js +1 -0
  44. package/components/Overlay/index.js.map +7 -0
  45. package/components/Permalink/Permalink.js +206 -0
  46. package/components/Permalink/Permalink.js.map +7 -0
  47. package/components/Permalink/index.js +1 -0
  48. package/components/Permalink/index.js.map +7 -0
  49. package/{src/components → components}/Popup/Popup.js +55 -165
  50. package/components/Popup/Popup.js.map +7 -0
  51. package/components/Popup/index.js +1 -0
  52. package/components/Popup/index.js.map +7 -0
  53. package/{src/components → components}/ResizeHandler/ResizeHandler.js +15 -50
  54. package/components/ResizeHandler/ResizeHandler.js.map +7 -0
  55. package/components/ResizeHandler/index.js +1 -0
  56. package/components/ResizeHandler/index.js.map +7 -0
  57. package/components/RouteSchedule/RouteSchedule.js +223 -0
  58. package/components/RouteSchedule/RouteSchedule.js.map +7 -0
  59. package/components/RouteSchedule/index.js +1 -0
  60. package/components/RouteSchedule/index.js.map +7 -0
  61. package/components/ScaleLine/ScaleLine.js +32 -0
  62. package/components/ScaleLine/ScaleLine.js.map +7 -0
  63. package/components/ScaleLine/index.js +1 -0
  64. package/components/ScaleLine/index.js.map +7 -0
  65. package/components/StopsFinder/StopsFinder.js +210 -0
  66. package/components/StopsFinder/StopsFinder.js.map +7 -0
  67. package/components/StopsFinder/StopsFinderOption.js +51 -0
  68. package/components/StopsFinder/StopsFinderOption.js.map +7 -0
  69. package/components/StopsFinder/index.js +1 -0
  70. package/components/StopsFinder/index.js.map +7 -0
  71. package/components/Zoom/Zoom.js +130 -0
  72. package/components/Zoom/Zoom.js.map +7 -0
  73. package/components/Zoom/index.js +1 -0
  74. package/components/Zoom/index.js.map +7 -0
  75. package/package.json +1 -1
  76. package/{src/propTypes.js → propTypes.js} +12 -16
  77. package/propTypes.js.map +7 -0
  78. package/{src/setupTests.js → setupTests.js} +1 -1
  79. package/setupTests.js.map +7 -0
  80. package/utils/GlobalsForOle.js +94 -0
  81. package/utils/GlobalsForOle.js.map +7 -0
  82. package/utils/KML.js +412 -0
  83. package/utils/KML.js.map +7 -0
  84. package/utils/KMLFormat.js +69 -0
  85. package/utils/KMLFormat.js.map +7 -0
  86. package/{src/utils → utils}/Styles.js +14 -20
  87. package/utils/Styles.js.map +7 -0
  88. package/{src/utils → utils}/getPolygonPattern.js +6 -34
  89. package/utils/getPolygonPattern.js.map +7 -0
  90. package/{src/utils → utils}/timeUtils.js +5 -22
  91. package/utils/timeUtils.js.map +7 -0
  92. package/.github/workflows/conventional-pr-title.yml +0 -21
  93. package/.github/workflows/main.yml +0 -28
  94. package/.husky/commit-msg +0 -4
  95. package/.husky/post-checkout +0 -4
  96. package/.husky/post-merge +0 -4
  97. package/.husky/post-rebase +0 -4
  98. package/.husky/pre-commit +0 -4
  99. package/.nvmrc +0 -1
  100. package/.whitesource +0 -8
  101. package/CHANGELOG.md +0 -65
  102. package/DEVELOP.md +0 -113
  103. package/__mocks__/mapbox-gl.js +0 -11
  104. package/__mocks__/resize-observer-polyfill.js +0 -9
  105. package/babel.config.js +0 -3
  106. package/commitlint.config.js +0 -1
  107. package/data/topic1.js +0 -119
  108. package/data/topic2.js +0 -28
  109. package/doc/README.md +0 -21
  110. package/doc/doc-config.json +0 -4
  111. package/pull_request_template.md +0 -16
  112. package/renovate.json +0 -4
  113. package/scripts/read-pkg-json.js +0 -17
  114. package/src/components/BaseLayerSwitcher/BaseLayerSwitcher.js +0 -322
  115. package/src/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js +0 -69
  116. package/src/components/BaseLayerSwitcher/README.md +0 -61
  117. package/src/components/BaseLayerSwitcher/__snapshots__/BaseLayerSwitcher.test.js.snap +0 -88
  118. package/src/components/BaseLayerSwitcher/index.js +0 -1
  119. package/src/components/BasicMap/BasicMap.js +0 -413
  120. package/src/components/BasicMap/BasicMap.test.js +0 -281
  121. package/src/components/BasicMap/README.md +0 -18
  122. package/src/components/BasicMap/index.js +0 -1
  123. package/src/components/CanvasSaveButton/CanvasSaveButton.test.js +0 -148
  124. package/src/components/CanvasSaveButton/README.md +0 -76
  125. package/src/components/CanvasSaveButton/__snapshots__/CanvasSaveButton.test.js.snap +0 -76
  126. package/src/components/CanvasSaveButton/index.js +0 -1
  127. package/src/components/Copyright/Copyright.js +0 -89
  128. package/src/components/Copyright/Copyright.test.js +0 -134
  129. package/src/components/Copyright/README.md +0 -36
  130. package/src/components/Copyright/index.js +0 -1
  131. package/src/components/FeatureExportButton/FeatureExportButton.js +0 -118
  132. package/src/components/FeatureExportButton/FeatureExportButton.test.js +0 -417
  133. package/src/components/FeatureExportButton/README.md +0 -76
  134. package/src/components/FeatureExportButton/__snapshots__/FeatureExportButton.test.js.snap +0 -67
  135. package/src/components/FeatureExportButton/index.js +0 -1
  136. package/src/components/FitExtent/FitExtent.js +0 -62
  137. package/src/components/FitExtent/FitExtent.test.js +0 -48
  138. package/src/components/FitExtent/README.md +0 -34
  139. package/src/components/FitExtent/__snapshots__/FitExtent.test.js.snap +0 -13
  140. package/src/components/FitExtent/index.js +0 -1
  141. package/src/components/Geolocation/Geolocation.test.js +0 -267
  142. package/src/components/Geolocation/README.md +0 -25
  143. package/src/components/Geolocation/__snapshots__/Geolocation.test.js.snap +0 -92
  144. package/src/components/Geolocation/index.js +0 -1
  145. package/src/components/LayerTree/LayerTree.js +0 -487
  146. package/src/components/LayerTree/LayerTree.test.js +0 -337
  147. package/src/components/LayerTree/README.md +0 -92
  148. package/src/components/LayerTree/__snapshots__/LayerTree.test.js.snap +0 -1746
  149. package/src/components/LayerTree/index.js +0 -1
  150. package/src/components/MousePosition/MousePosition.js +0 -175
  151. package/src/components/MousePosition/MousePosition.test.js +0 -132
  152. package/src/components/MousePosition/README.md +0 -50
  153. package/src/components/MousePosition/__snapshots__/MousePosition.test.js.snap +0 -76
  154. package/src/components/MousePosition/index.js +0 -1
  155. package/src/components/NorthArrow/NorthArrow.js +0 -75
  156. package/src/components/NorthArrow/NorthArrow.test.js +0 -104
  157. package/src/components/NorthArrow/README.md +0 -59
  158. package/src/components/NorthArrow/__snapshots__/NorthArrow.test.js.snap +0 -117
  159. package/src/components/NorthArrow/index.js +0 -1
  160. package/src/components/Overlay/Overlay.js +0 -176
  161. package/src/components/Overlay/Overlay.test.js +0 -149
  162. package/src/components/Overlay/README.md +0 -59
  163. package/src/components/Overlay/__snapshots__/Overlay.test.js.snap +0 -9
  164. package/src/components/Overlay/index.js +0 -1
  165. package/src/components/Permalink/Permalink.js +0 -326
  166. package/src/components/Permalink/Permalink.test.js +0 -285
  167. package/src/components/Permalink/README.md +0 -105
  168. package/src/components/Permalink/index.js +0 -1
  169. package/src/components/Popup/Popup.test.js +0 -307
  170. package/src/components/Popup/README.md +0 -93
  171. package/src/components/Popup/__snapshots__/Popup.test.js.snap +0 -180
  172. package/src/components/Popup/index.js +0 -1
  173. package/src/components/README.md +0 -41
  174. package/src/components/ResizeHandler/ResizeHandler.test.js +0 -344
  175. package/src/components/ResizeHandler/index.js +0 -1
  176. package/src/components/RouteSchedule/README.md +0 -118
  177. package/src/components/RouteSchedule/RouteSchedule.js +0 -370
  178. package/src/components/RouteSchedule/RouteSchedule.test.js +0 -113
  179. package/src/components/RouteSchedule/__snapshots__/RouteSchedule.test.js.snap +0 -248
  180. package/src/components/RouteSchedule/index.js +0 -1
  181. package/src/components/ScaleLine/README.md +0 -29
  182. package/src/components/ScaleLine/ScaleLine.js +0 -50
  183. package/src/components/ScaleLine/ScaleLine.test.js +0 -30
  184. package/src/components/ScaleLine/__snapshots__/ScaleLine.test.js.snap +0 -7
  185. package/src/components/ScaleLine/index.js +0 -1
  186. package/src/components/StopsFinder/README.md +0 -50
  187. package/src/components/StopsFinder/StopsFinder.js +0 -284
  188. package/src/components/StopsFinder/StopsFinder.test.js +0 -17
  189. package/src/components/StopsFinder/StopsFinderOption.js +0 -61
  190. package/src/components/StopsFinder/__snapshots__/StopsFinder.test.js.snap +0 -133
  191. package/src/components/StopsFinder/index.js +0 -1
  192. package/src/components/Zoom/README.md +0 -25
  193. package/src/components/Zoom/Zoom.js +0 -180
  194. package/src/components/Zoom/Zoom.test.js +0 -141
  195. package/src/components/Zoom/__snapshots__/Zoom.test.js.snap +0 -201
  196. package/src/components/Zoom/index.js +0 -1
  197. package/src/styleguidist/ComponentsList.js +0 -52
  198. package/src/styleguidist/StyleGuide.js +0 -277
  199. package/src/styleguidist/styleguidist.css +0 -38
  200. package/src/utils/GlobalsForOle.js +0 -99
  201. package/src/utils/KML.js +0 -594
  202. package/src/utils/KML.test.js +0 -337
  203. package/src/utils/KMLFormat.js +0 -100
  204. package/src/utils/KMLFormat.test.js +0 -50
  205. package/src/utils/__snapshots__/KML.test.js.snap.KML-readFeatures()-and-writeFeatures()-should-read-and-write-lineDash-and-fillPattern-style-for-polygon.canvas-image.png +0 -0
  206. package/src/utils/__snapshots__/getPolygonPattern.test.js.snap.getPolygonPattern()-render-pattern-2-(cross)-color-and-(light-blue)-opacity.canvas-image.png +0 -0
  207. package/src/utils/__snapshots__/getPolygonPattern.test.js.snap.getPolygonPattern()-render-pattern-3-(diagonal-line-from-bottom-left-tot-top-right)-with-color-(light-blue)-and-opacity.canvas-image.png +0 -0
  208. package/src/utils/__snapshots__/getPolygonPattern.test.js.snap.getPolygonPattern()-render-pattern-4-(diagonal-line-from-top-left-to-bottom-right)-with-color-(light-blue)-and-opacity.canvas-image.png +0 -0
  209. package/src/utils/getPolygonPattern.test.js +0 -61
  210. package/src/utils/timeUtils.test.js +0 -30
  211. package/styleguide.config.js +0 -251
  212. /package/{src/components → components}/BaseLayerSwitcher/BaseLayerSwitcher.md.scss +0 -0
  213. /package/{src/components → components}/BaseLayerSwitcher/BaseLayerSwitcher.scss +0 -0
  214. /package/{src/components → components}/BasicMap/BasicMap.md.scss +0 -0
  215. /package/{src/components → components}/CanvasSaveButton/CanvasSaveButton.md.scss +0 -0
  216. /package/{src/components → components}/Copyright/Copyright.md.scss +0 -0
  217. /package/{src/components → components}/FeatureExportButton/FeatureExportButton.md.scss +0 -0
  218. /package/{src/components → components}/FitExtent/FitExtent.md.scss +0 -0
  219. /package/{src/components → components}/Geolocation/Geolocation.md.scss +0 -0
  220. /package/{src/components → components}/Geolocation/Geolocation.scss +0 -0
  221. /package/{src/components → components}/LayerTree/LayerTree.md.scss +0 -0
  222. /package/{src/components → components}/LayerTree/LayerTree.scss +0 -0
  223. /package/{src/components → components}/MousePosition/MousePosition.md.scss +0 -0
  224. /package/{src/components → components}/NorthArrow/NorthArrow.scss +0 -0
  225. /package/{src/components → components}/Overlay/Overlay.md.scss +0 -0
  226. /package/{src/components → components}/Overlay/Overlay.scss +0 -0
  227. /package/{src/components → components}/Permalink/Permalink.md.scss +0 -0
  228. /package/{src/components → components}/Popup/Popup.md.scss +0 -0
  229. /package/{src/components → components}/Popup/Popup.scss +0 -0
  230. /package/{src/components → components}/RouteSchedule/RouteSchedule.md.scss +0 -0
  231. /package/{src/components → components}/RouteSchedule/RouteSchedule.scss +0 -0
  232. /package/{src/components → components}/ScaleLine/ScaleLine.scss +0 -0
  233. /package/{src/components → components}/Zoom/Zoom.md.scss +0 -0
  234. /package/{src/components → components}/Zoom/Zoom.scss +0 -0
  235. /package/{src/images → images}/RouteSchedule/firstStation.png +0 -0
  236. /package/{src/images → images}/RouteSchedule/lastStation.png +0 -0
  237. /package/{src/images → images}/RouteSchedule/line.png +0 -0
  238. /package/{src/images → images}/RouteSchedule/station.png +0 -0
  239. /package/{src/images → images}/baselayer/baselayer.basebright.png +0 -0
  240. /package/{src/images → images}/baselayer/baselayer.osm.png +0 -0
  241. /package/{src/images → images}/baselayer/baselayer.travic.png +0 -0
  242. /package/{src/images → images}/baselayer/open.topo.map.png +0 -0
  243. /package/{src/images → images}/baselayer/osm.baselayer.hot.png +0 -0
  244. /package/{src/images → images}/baselayer/osm.baselayer.png +0 -0
  245. /package/{src/images → images}/favicon.png +0 -0
  246. /package/{src/images → images}/geops_logo.png +0 -0
  247. /package/{src/images → images}/geops_logo.svg +0 -0
  248. /package/{src/images → images}/geops_qr.png +0 -0
  249. /package/{src/images → images}/mots/bus_poi-blue-01.svg +0 -0
  250. /package/{src/images → images}/mots/bus_poi-grey-01.svg +0 -0
  251. /package/{src/images → images}/mots/bus_round-blue-01.svg +0 -0
  252. /package/{src/images → images}/mots/bus_round-grey-01.svg +0 -0
  253. /package/{src/images → images}/mots/bus_square-blue-01.svg +0 -0
  254. /package/{src/images → images}/mots/bus_square-grey-01.svg +0 -0
  255. /package/{src/images → images}/mots/cable_car_poi-blue-01.svg +0 -0
  256. /package/{src/images → images}/mots/cable_car_poi-grey-01.svg +0 -0
  257. /package/{src/images → images}/mots/cable_car_round-blue-01.svg +0 -0
  258. /package/{src/images → images}/mots/cable_car_round-grey-01.svg +0 -0
  259. /package/{src/images → images}/mots/cable_car_square-blue-01.svg +0 -0
  260. /package/{src/images → images}/mots/cable_car_square-grey-01.svg +0 -0
  261. /package/{src/images → images}/mots/ferry_poi-blue-01.svg +0 -0
  262. /package/{src/images → images}/mots/ferry_poi-grey-01.svg +0 -0
  263. /package/{src/images → images}/mots/ferry_round-blue-01.svg +0 -0
  264. /package/{src/images → images}/mots/ferry_round-grey-01.svg +0 -0
  265. /package/{src/images → images}/mots/ferry_square-blue-01.svg +0 -0
  266. /package/{src/images → images}/mots/ferry_square-grey-01.svg +0 -0
  267. /package/{src/images → images}/mots/funicular_round-blue-01.svg +0 -0
  268. /package/{src/images → images}/mots/funicular_round-grey-01.svg +0 -0
  269. /package/{src/images → images}/mots/funicular_square-blue-01.svg +0 -0
  270. /package/{src/images → images}/mots/gondola_round-blue-01.svg +0 -0
  271. /package/{src/images → images}/mots/rail_poi-blue-01.svg +0 -0
  272. /package/{src/images → images}/mots/rail_poi-grey-01.svg +0 -0
  273. /package/{src/images → images}/mots/rail_round-blue-01.svg +0 -0
  274. /package/{src/images → images}/mots/rail_round-grey-01.svg +0 -0
  275. /package/{src/images → images}/mots/rail_square-blue-01.svg +0 -0
  276. /package/{src/images → images}/mots/rail_square-grey-01.svg +0 -0
  277. /package/{src/images → images}/mots/subway_round blue-01.svg +0 -0
  278. /package/{src/images → images}/mots/subway_round-blue-01.svg +0 -0
  279. /package/{src/images → images}/mots/tram_poi-blue-01.svg +0 -0
  280. /package/{src/images → images}/mots/tram_poi-grey-01.svg +0 -0
  281. /package/{src/images → images}/mots/tram_round-blue-01.svg +0 -0
  282. /package/{src/images → images}/mots/tram_round-grey-01.svg +0 -0
  283. /package/{src/images → images}/mots/tram_square-blue-01.svg +0 -0
  284. /package/{src/images → images}/mots/tram_square-grey-01.svg +0 -0
  285. /package/{src/images → images}/northArrow.svg +0 -0
  286. /package/{src/images → images}/northArrow.url.svg +0 -0
  287. /package/{src/images → images}/northArrowCircle.svg +0 -0
  288. /package/{src/images → images}/northArrowCircle.url.svg +0 -0
  289. /package/{src/themes → themes}/README.md +0 -0
  290. /package/{src/themes → themes}/default/components.scss +0 -0
  291. /package/{src/themes → themes}/default/examples.scss +0 -0
  292. /package/{src/themes → themes}/default/index.scss +0 -0
  293. /package/{src/themes → themes}/default/mixins.scss +0 -0
  294. /package/{src/themes → themes}/default/variables.scss +0 -0
@@ -1,307 +0,0 @@
1
- import React from 'react';
2
- import renderer from 'react-test-renderer';
3
- import { configure, mount, shallow } from 'enzyme';
4
- import Adapter from '@cfaester/enzyme-adapter-react-18';
5
- import 'jest-canvas-mock';
6
-
7
- import OLMap from 'ol/Map';
8
- import View from 'ol/View';
9
- import Feature from 'ol/Feature';
10
- import Point from 'ol/geom/Point';
11
- import Line from 'ol/geom/LineString';
12
- import Popup from './Popup';
13
-
14
- let map;
15
-
16
- configure({ adapter: new Adapter() });
17
-
18
- const feat = new Feature({
19
- geometry: new Point([1000, 1000]),
20
- });
21
-
22
- const featLine = new Feature({
23
- geometry: new Line([
24
- [1000, 1000],
25
- [2000, 2000],
26
- ]),
27
- });
28
-
29
- describe('Popup', () => {
30
- beforeEach(() => {
31
- map = new OLMap({});
32
- });
33
-
34
- describe('should match snapshot', () => {
35
- test('without feature', () => {
36
- const component = renderer.create(
37
- <Popup map={map}>
38
- <div id="foo" />
39
- </Popup>,
40
- );
41
- const tree = component.toJSON();
42
- expect(tree).toMatchSnapshot();
43
- });
44
-
45
- test('with default values.', () => {
46
- const component = renderer.create(
47
- <Popup map={map} feature={feat}>
48
- <div id="foo" />
49
- </Popup>,
50
- );
51
- const tree = component.toJSON();
52
- expect(tree).toMatchSnapshot();
53
- });
54
-
55
- test('without close button.', () => {
56
- const component = renderer.create(
57
- <Popup
58
- map={map}
59
- feature={feat}
60
- renderCloseButton={() => {
61
- return null;
62
- }}
63
- >
64
- <div id="bar" />
65
- </Popup>,
66
- );
67
- const tree = component.toJSON();
68
- expect(tree).toMatchSnapshot();
69
- });
70
-
71
- test('without header.', () => {
72
- const component = renderer.create(
73
- <Popup
74
- map={map}
75
- feature={feat}
76
- renderHeader={() => {
77
- return null;
78
- }}
79
- >
80
- <div id="bar" />
81
- </Popup>,
82
- );
83
- const tree = component.toJSON();
84
- expect(tree).toMatchSnapshot();
85
- });
86
-
87
- test('with tabIndex defined.', () => {
88
- const component = renderer.create(
89
- <Popup map={map} feature={feat} tabIndex="0">
90
- <div id="bar" />
91
- </Popup>,
92
- );
93
- const tree = component.toJSON();
94
- expect(tree).toMatchSnapshot();
95
- });
96
- });
97
-
98
- [
99
- ['click', {}],
100
- ['keypress', { which: 13 }],
101
- ].forEach((evt) => {
102
- test(`should trigger onCloseClick function on ${evt[0]} event.`, () => {
103
- const spy = jest.fn(() => {});
104
-
105
- const component = mount(
106
- <Popup map={map} feature={feat} onCloseClick={spy}>
107
- <div id="gux" />
108
- </Popup>,
109
- );
110
-
111
- component
112
- .find('div')
113
- .at(3)
114
- .simulate(...evt);
115
- expect(spy).toHaveBeenCalled();
116
- });
117
-
118
- test(`should trigger default onCloseClick function on ${evt[0]} event without errors.`, () => {
119
- const component = mount(
120
- <Popup map={map} feature={feat}>
121
- <div id="gux" />
122
- </Popup>,
123
- );
124
- // test if no js error triggered by the default value
125
- try {
126
- component
127
- .find('div')
128
- .at(3)
129
- .simulate(...evt);
130
- expect(true).toBe(true);
131
- } catch (e) {
132
- expect(false).toBe(true);
133
- }
134
- });
135
- });
136
-
137
- describe(`init position`, () => {
138
- test(`using popupCoordinate.`, () => {
139
- map.getPixelFromCoordinate = jest.fn(() => {
140
- return [10010, 100200];
141
- });
142
- const component = mount(
143
- <Popup map={map} popupCoordinate={[1001, 1002]}>
144
- <div id="gux" />
145
- </Popup>,
146
- );
147
- expect(component.state().left).toBe(10010);
148
- expect(component.state().top).toBe(100200);
149
- component.setProps({ feature: featLine });
150
- map.getPixelFromCoordinate = jest.fn(() => {
151
- return [10011, 100100];
152
- });
153
- component.setProps({ popupCoordinate: [1009, 1009] });
154
- expect(component.state().left).toBe(10011);
155
- expect(component.state().top).toBe(100100);
156
- });
157
-
158
- test(`using feature.`, () => {
159
- map.getPixelFromCoordinate = jest.fn(() => {
160
- return [10010, 100200];
161
- });
162
- const component = mount(
163
- <Popup map={map} feature={feat}>
164
- <div id="gux" />
165
- </Popup>,
166
- );
167
- expect(component.state().left).toBe(10010);
168
- expect(component.state().top).toBe(100200);
169
- map.getPixelFromCoordinate = jest.fn(() => {
170
- return [10011, 100100];
171
- });
172
- component.setProps({ feature: featLine });
173
- expect(component.state().left).toBe(10011);
174
- expect(component.state().top).toBe(100100);
175
- });
176
- });
177
-
178
- describe(`updates position`, () => {
179
- test(`on map postrender event.`, () => {
180
- map.getPixelFromCoordinate = jest.fn(() => {
181
- return [10, 200];
182
- });
183
- const component = shallow(
184
- <Popup map={map} feature={feat}>
185
- <div id="gux" />
186
- </Popup>,
187
- );
188
- const spy = jest.spyOn(component.instance(), 'updatePixelPosition');
189
- map.dispatchEvent({ type: 'postrender' });
190
- expect(spy).toHaveBeenCalledTimes(1);
191
- });
192
- });
193
-
194
- describe(`#panIntoView`, () => {
195
- beforeEach(() => {
196
- const target = document.createElement('div');
197
- const { style } = target;
198
- style.position = 'absolute';
199
- style.left = '-1000px';
200
- style.top = '-1000px';
201
- style.width = '100px';
202
- style.height = '100px';
203
- document.body.appendChild(target);
204
-
205
- map = new OLMap({
206
- target,
207
- view: new View({
208
- center: [1000, 1000],
209
- resolutions: [1],
210
- zoom: 0,
211
- }),
212
- });
213
- map.renderSync();
214
- });
215
-
216
- afterEach(() => {
217
- const target = map.getTarget();
218
- map.setTarget(null);
219
- if (target && target.parentNode) {
220
- target.parentNode.removeChild(target);
221
- }
222
- map.dispose();
223
- });
224
-
225
- test(`animate the map.`, () => {
226
- map.getTarget().getBoundingClientRect = jest.fn(() => {
227
- return {
228
- bottom: -10,
229
- left: 5,
230
- right: -5,
231
- top: 5,
232
- };
233
- });
234
- map.getPixelFromCoordinate = jest.fn(() => {
235
- return [10, 20];
236
- });
237
- const spy = jest.spyOn(map.getView(), 'animate');
238
- mount(
239
- <Popup map={map} feature={feat} panIntoView>
240
- <div id="gux" />
241
- </Popup>,
242
- );
243
- expect(spy).toHaveBeenCalledTimes(1);
244
- expect(spy).toHaveBeenCalledWith({
245
- center: [1005, 990],
246
- duration: 500,
247
- });
248
- });
249
-
250
- test(`using panRect`, () => {
251
- map.getPixelFromCoordinate = jest.fn(() => {
252
- return [10, 200];
253
- });
254
- const spy = jest.spyOn(map.getView(), 'animate');
255
- mount(
256
- <Popup
257
- map={map}
258
- feature={feat}
259
- panIntoView
260
- panRect={{ top: 0, left: 0, bottom: -10, right: 0 }}
261
- >
262
- <div id="gux" />
263
- </Popup>,
264
- );
265
- expect(spy).toHaveBeenCalledTimes(1);
266
- expect(spy).toHaveBeenCalledWith({
267
- center: [1000, 990],
268
- duration: 500,
269
- });
270
- });
271
-
272
- test(`doesn't animate the map`, () => {
273
- map.getPixelFromCoordinate = jest.fn(() => {
274
- return [10, 200];
275
- });
276
- const spy = jest.spyOn(map.getView(), 'animate');
277
- mount(
278
- <Popup
279
- map={map}
280
- feature={feat}
281
- panIntoView
282
- panRect={{ top: 0, left: 0, bottom: 0, right: 0 }}
283
- >
284
- <div id="gux" />
285
- </Popup>,
286
- );
287
- expect(spy).toHaveBeenCalledTimes(0);
288
- });
289
- });
290
-
291
- test(`deregisters postrender on unmount.`, () => {
292
- map.getPixelFromCoordinate = jest.fn(() => {
293
- return [10, 200];
294
- });
295
- const component = shallow(
296
- <Popup map={map} feature={featLine}>
297
- <div id="gux" />
298
- </Popup>,
299
- );
300
- const spy = jest.spyOn(component.instance(), 'updatePixelPosition');
301
- map.dispatchEvent({ type: 'postrender' });
302
- expect(spy).toHaveBeenCalledTimes(1);
303
- component.unmount();
304
- map.dispatchEvent({ type: 'postrender' });
305
- expect(spy).toHaveBeenCalledTimes(1);
306
- });
307
- });
@@ -1,93 +0,0 @@
1
-
2
- The following example demonstrates the use of Popup.
3
-
4
- ```jsx
5
- import React, { useState, useMemo, useCallback } from 'react';
6
- import { Layer, MapboxLayer} from 'mobility-toolbox-js/ol';
7
- import VectorLayer from 'ol/layer/Vector';
8
- import { Map, Feature } from 'ol';
9
- import Point from 'ol/geom/Point';
10
- import OSM from 'ol/source/OSM';
11
- import VectorSource from 'ol/source/Vector';
12
- import TileGrid from 'ol/tilegrid/TileGrid';
13
- import { getCenter } from 'ol/extent';
14
- import { Style, Circle, Fill, Icon } from 'ol/style';
15
- import BasicMap from 'react-spatial/components/BasicMap';
16
- import Popup from 'react-spatial/components/Popup';
17
-
18
- const map = new Map({ controls: [] });
19
-
20
- const layers = [
21
- new MapboxLayer({
22
- url: `https://maps.geops.io/styles/base_dark_v2/style.json?key=${apiKey}`,
23
- }),
24
- new Layer({
25
- olLayer: new VectorLayer({
26
- source: new VectorSource({
27
- features: [
28
- new Feature({
29
- geometry: new Point([874105.13, 6106172.77]),
30
- }),
31
- new Feature({
32
- geometry: new Point([873105.13, 6106172.77]),
33
- }),
34
- ],
35
- }),
36
- style: new Style({
37
- image: new Icon({
38
- anchor: [0.5, 46],
39
- anchorXUnits: 'fraction',
40
- anchorYUnits: 'pixels',
41
- src: 'https://openlayers.org/en/latest/examples/data/icon.png',
42
- imgSize: [32, 48]
43
- }),
44
- }),
45
- }),
46
- }),
47
- ];
48
-
49
-
50
- function PopupExample() {
51
- const [featureClicked, setFeatureClicked] = useState();
52
-
53
- const content = useMemo(() => {
54
- return featureClicked &&
55
- featureClicked
56
- .getGeometry()
57
- .getCoordinates()
58
- .toString();
59
- }, [featureClicked]);
60
-
61
- const onFeaturesClick = useCallback((features) => {
62
- setFeatureClicked(features.length ? features[0] : null);
63
- }, []);
64
-
65
- const onCloseClick = useCallback(()=> {
66
- setFeatureClicked(null);
67
- }, []);
68
-
69
- return (
70
- <div className="rs-popup-example">
71
- <BasicMap
72
- map={map}
73
- center={[874105.13, 6106172.77]}
74
- zoom={17}
75
- layers={layers}
76
- onFeaturesClick={onFeaturesClick}
77
- tabIndex={0}
78
- />
79
- <Popup
80
- map={map}
81
- header="Geometry"
82
- feature={featureClicked}
83
- onCloseClick={onCloseClick}
84
- panIntoView
85
- >
86
- <div>{content}</div>
87
- </Popup>
88
- </div>
89
- );
90
- }
91
-
92
- <PopupExample />;
93
- ```
@@ -1,180 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`Popup should match snapshot with default values. 1`] = `
4
- <div
5
- className="rs-popup"
6
- style={
7
- {
8
- "left": 0,
9
- "top": 0,
10
- }
11
- }
12
- >
13
- <div
14
- className="rs-popup-container"
15
- tabIndex=""
16
- >
17
- <div
18
- className="rs-popup-header"
19
- >
20
- <div
21
- aria-label="Close"
22
- className="rs-popup-close-bt"
23
- onClick={[Function]}
24
- onKeyPress={[Function]}
25
- role="button"
26
- tabIndex={0}
27
- title="Close"
28
- >
29
- <svg
30
- fill="currentColor"
31
- focusable={false}
32
- height="1em"
33
- stroke="currentColor"
34
- strokeWidth="0"
35
- style={
36
- {
37
- "color": undefined,
38
- }
39
- }
40
- viewBox="0 0 24 24"
41
- width="1em"
42
- xmlns="http://www.w3.org/2000/svg"
43
- >
44
- <path
45
- d="M0 0h24v24H0z"
46
- fill="none"
47
- />
48
- <path
49
- d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
50
- />
51
- </svg>
52
- </div>
53
- </div>
54
- <div
55
- className="rs-popup-body"
56
- >
57
- <div
58
- id="foo"
59
- />
60
- </div>
61
- </div>
62
- </div>
63
- `;
64
-
65
- exports[`Popup should match snapshot with tabIndex defined. 1`] = `
66
- <div
67
- className="rs-popup"
68
- style={
69
- {
70
- "left": 0,
71
- "top": 0,
72
- }
73
- }
74
- >
75
- <div
76
- className="rs-popup-container"
77
- tabIndex="0"
78
- >
79
- <div
80
- className="rs-popup-header"
81
- >
82
- <div
83
- aria-label="Close"
84
- className="rs-popup-close-bt"
85
- onClick={[Function]}
86
- onKeyPress={[Function]}
87
- role="button"
88
- tabIndex={0}
89
- title="Close"
90
- >
91
- <svg
92
- fill="currentColor"
93
- focusable={false}
94
- height="1em"
95
- stroke="currentColor"
96
- strokeWidth="0"
97
- style={
98
- {
99
- "color": undefined,
100
- }
101
- }
102
- viewBox="0 0 24 24"
103
- width="1em"
104
- xmlns="http://www.w3.org/2000/svg"
105
- >
106
- <path
107
- d="M0 0h24v24H0z"
108
- fill="none"
109
- />
110
- <path
111
- d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
112
- />
113
- </svg>
114
- </div>
115
- </div>
116
- <div
117
- className="rs-popup-body"
118
- >
119
- <div
120
- id="bar"
121
- />
122
- </div>
123
- </div>
124
- </div>
125
- `;
126
-
127
- exports[`Popup should match snapshot without close button. 1`] = `
128
- <div
129
- className="rs-popup"
130
- style={
131
- {
132
- "left": 0,
133
- "top": 0,
134
- }
135
- }
136
- >
137
- <div
138
- className="rs-popup-container"
139
- tabIndex=""
140
- >
141
- <div
142
- className="rs-popup-header"
143
- />
144
- <div
145
- className="rs-popup-body"
146
- >
147
- <div
148
- id="bar"
149
- />
150
- </div>
151
- </div>
152
- </div>
153
- `;
154
-
155
- exports[`Popup should match snapshot without feature 1`] = `null`;
156
-
157
- exports[`Popup should match snapshot without header. 1`] = `
158
- <div
159
- className="rs-popup"
160
- style={
161
- {
162
- "left": 0,
163
- "top": 0,
164
- }
165
- }
166
- >
167
- <div
168
- className="rs-popup-container"
169
- tabIndex=""
170
- >
171
- <div
172
- className="rs-popup-body"
173
- >
174
- <div
175
- id="bar"
176
- />
177
- </div>
178
- </div>
179
- </div>
180
- `;
@@ -1 +0,0 @@
1
- export { default } from './Popup';
@@ -1,41 +0,0 @@
1
- # Components
2
-
3
- This folder contains all the components.
4
-
5
- ## Create a new component
6
-
7
- Each component must have this structure:
8
-
9
- ```bash
10
- src/
11
- components/
12
- MyCategory/
13
- MyComponent/
14
- index.js // ES module export.
15
- MyComponent.js // The JSX component WITHOUT hardcoded classNames !!!!
16
- MyComponent.test.js // The test file with at least snapshots tests.
17
- MyComponent.scss // A sass file with default CSS when the main html element of MyComponent uses rs-mycomponent CSS class.
18
- README.md // The MyComponentExample component of use to display in the doc.
19
- MyComponent.md.scss // A sass file for the MyComponentExample component used in README.md
20
- ```
21
-
22
- Some rules must be followed:
23
-
24
- - a component must allow to provide a className to the main html element of the component.
25
- - a component must be controlled by his parent via props.
26
- - a component must use `children` property instead of `renderXXX` functions when possible.
27
- - a component must propagate basic props `<NewComp {...this.props}>` when possible.
28
- - a component must have tests.
29
- - a component can provide a translation function using a `t` property.
30
- - default props must have a value or `undefined` (no `null` otherwise the attribute is created in the snapshot).
31
- - no redux stuff.
32
- - no hardcoded `className`, only in default props.
33
- - no translation library specific stuff.
34
-
35
- ## Create a new component from another
36
-
37
- ```bash
38
- yarn cp
39
- ```
40
-
41
- then follow the guide.