react-spatial 1.5.3 → 1.5.5

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 (282) hide show
  1. package/components/BaseLayerSwitcher/BaseLayerSwitcher.js +262 -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/{src/components → components}/BasicMap/BasicMap.js +80 -170
  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 +133 -278
  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/{src/components → components}/Copyright/Copyright.js +21 -41
  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 +80 -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/{src/components → components}/FitExtent/FitExtent.js +16 -30
  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 +60 -110
  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/{src/components → components}/LayerTree/LayerTree.js +113 -213
  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/{src/components → components}/MousePosition/MousePosition.js +37 -70
  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/{src/components → components}/NorthArrow/NorthArrow.js +18 -34
  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/{src/components → components}/Overlay/Overlay.js +59 -85
  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/{src/components → components}/Permalink/Permalink.js +64 -147
  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 +57 -116
  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 -49
  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 +268 -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/{src/components → components}/ScaleLine/ScaleLine.js +8 -23
  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/{src/components → components}/StopsFinder/StopsFinder.js +74 -103
  66. package/components/StopsFinder/StopsFinder.js.map +7 -0
  67. package/components/StopsFinder/StopsFinderOption.js +44 -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/{src/components → components}/Zoom/Zoom.js +46 -77
  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 +32 -31
  76. package/{src/propTypes.js → propTypes.js} +30 -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 +420 -0
  83. package/utils/KML.js.map +7 -0
  84. package/{src/utils → utils}/KMLFormat.js +29 -32
  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.test.js +0 -281
  120. package/src/components/BasicMap/README.md +0 -18
  121. package/src/components/BasicMap/index.js +0 -1
  122. package/src/components/CanvasSaveButton/CanvasSaveButton.test.js +0 -148
  123. package/src/components/CanvasSaveButton/README.md +0 -76
  124. package/src/components/CanvasSaveButton/__snapshots__/CanvasSaveButton.test.js.snap +0 -76
  125. package/src/components/CanvasSaveButton/index.js +0 -1
  126. package/src/components/Copyright/Copyright.test.js +0 -134
  127. package/src/components/Copyright/README.md +0 -36
  128. package/src/components/Copyright/index.js +0 -1
  129. package/src/components/FeatureExportButton/FeatureExportButton.js +0 -118
  130. package/src/components/FeatureExportButton/FeatureExportButton.test.js +0 -417
  131. package/src/components/FeatureExportButton/README.md +0 -76
  132. package/src/components/FeatureExportButton/__snapshots__/FeatureExportButton.test.js.snap +0 -67
  133. package/src/components/FeatureExportButton/index.js +0 -1
  134. package/src/components/FitExtent/FitExtent.test.js +0 -48
  135. package/src/components/FitExtent/README.md +0 -34
  136. package/src/components/FitExtent/__snapshots__/FitExtent.test.js.snap +0 -13
  137. package/src/components/FitExtent/index.js +0 -1
  138. package/src/components/Geolocation/Geolocation.test.js +0 -267
  139. package/src/components/Geolocation/README.md +0 -25
  140. package/src/components/Geolocation/__snapshots__/Geolocation.test.js.snap +0 -92
  141. package/src/components/Geolocation/index.js +0 -1
  142. package/src/components/LayerTree/LayerTree.test.js +0 -337
  143. package/src/components/LayerTree/README.md +0 -92
  144. package/src/components/LayerTree/__snapshots__/LayerTree.test.js.snap +0 -1746
  145. package/src/components/LayerTree/index.js +0 -1
  146. package/src/components/MousePosition/MousePosition.test.js +0 -132
  147. package/src/components/MousePosition/README.md +0 -50
  148. package/src/components/MousePosition/__snapshots__/MousePosition.test.js.snap +0 -76
  149. package/src/components/MousePosition/index.js +0 -1
  150. package/src/components/NorthArrow/NorthArrow.test.js +0 -104
  151. package/src/components/NorthArrow/README.md +0 -59
  152. package/src/components/NorthArrow/__snapshots__/NorthArrow.test.js.snap +0 -117
  153. package/src/components/NorthArrow/index.js +0 -1
  154. package/src/components/Overlay/Overlay.test.js +0 -149
  155. package/src/components/Overlay/README.md +0 -59
  156. package/src/components/Overlay/__snapshots__/Overlay.test.js.snap +0 -9
  157. package/src/components/Overlay/index.js +0 -1
  158. package/src/components/Permalink/Permalink.test.js +0 -285
  159. package/src/components/Permalink/README.md +0 -105
  160. package/src/components/Permalink/index.js +0 -1
  161. package/src/components/Popup/Popup.test.js +0 -307
  162. package/src/components/Popup/README.md +0 -93
  163. package/src/components/Popup/__snapshots__/Popup.test.js.snap +0 -180
  164. package/src/components/Popup/index.js +0 -1
  165. package/src/components/README.md +0 -41
  166. package/src/components/ResizeHandler/ResizeHandler.test.js +0 -344
  167. package/src/components/ResizeHandler/index.js +0 -1
  168. package/src/components/RouteSchedule/README.md +0 -118
  169. package/src/components/RouteSchedule/RouteSchedule.js +0 -370
  170. package/src/components/RouteSchedule/RouteSchedule.test.js +0 -113
  171. package/src/components/RouteSchedule/__snapshots__/RouteSchedule.test.js.snap +0 -248
  172. package/src/components/RouteSchedule/index.js +0 -1
  173. package/src/components/ScaleLine/README.md +0 -29
  174. package/src/components/ScaleLine/ScaleLine.test.js +0 -30
  175. package/src/components/ScaleLine/__snapshots__/ScaleLine.test.js.snap +0 -7
  176. package/src/components/ScaleLine/index.js +0 -1
  177. package/src/components/StopsFinder/README.md +0 -50
  178. package/src/components/StopsFinder/StopsFinder.test.js +0 -17
  179. package/src/components/StopsFinder/StopsFinderOption.js +0 -61
  180. package/src/components/StopsFinder/__snapshots__/StopsFinder.test.js.snap +0 -133
  181. package/src/components/StopsFinder/index.js +0 -1
  182. package/src/components/Zoom/README.md +0 -25
  183. package/src/components/Zoom/Zoom.test.js +0 -141
  184. package/src/components/Zoom/__snapshots__/Zoom.test.js.snap +0 -201
  185. package/src/components/Zoom/index.js +0 -1
  186. package/src/styleguidist/ComponentsList.js +0 -52
  187. package/src/styleguidist/StyleGuide.js +0 -277
  188. package/src/styleguidist/styleguidist.css +0 -38
  189. package/src/utils/GlobalsForOle.js +0 -99
  190. package/src/utils/KML.js +0 -594
  191. package/src/utils/KML.test.js +0 -337
  192. package/src/utils/KMLFormat.test.js +0 -50
  193. 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
  194. package/src/utils/__snapshots__/getPolygonPattern.test.js.snap.getPolygonPattern()-render-pattern-2-(cross)-color-and-(light-blue)-opacity.canvas-image.png +0 -0
  195. 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
  196. 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
  197. package/src/utils/getPolygonPattern.test.js +0 -61
  198. package/src/utils/timeUtils.test.js +0 -30
  199. package/styleguide.config.js +0 -251
  200. /package/{src/components → components}/BaseLayerSwitcher/BaseLayerSwitcher.md.scss +0 -0
  201. /package/{src/components → components}/BaseLayerSwitcher/BaseLayerSwitcher.scss +0 -0
  202. /package/{src/components → components}/BasicMap/BasicMap.md.scss +0 -0
  203. /package/{src/components → components}/CanvasSaveButton/CanvasSaveButton.md.scss +0 -0
  204. /package/{src/components → components}/Copyright/Copyright.md.scss +0 -0
  205. /package/{src/components → components}/FeatureExportButton/FeatureExportButton.md.scss +0 -0
  206. /package/{src/components → components}/FitExtent/FitExtent.md.scss +0 -0
  207. /package/{src/components → components}/Geolocation/Geolocation.md.scss +0 -0
  208. /package/{src/components → components}/Geolocation/Geolocation.scss +0 -0
  209. /package/{src/components → components}/LayerTree/LayerTree.md.scss +0 -0
  210. /package/{src/components → components}/LayerTree/LayerTree.scss +0 -0
  211. /package/{src/components → components}/MousePosition/MousePosition.md.scss +0 -0
  212. /package/{src/components → components}/NorthArrow/NorthArrow.scss +0 -0
  213. /package/{src/components → components}/Overlay/Overlay.md.scss +0 -0
  214. /package/{src/components → components}/Overlay/Overlay.scss +0 -0
  215. /package/{src/components → components}/Permalink/Permalink.md.scss +0 -0
  216. /package/{src/components → components}/Popup/Popup.md.scss +0 -0
  217. /package/{src/components → components}/Popup/Popup.scss +0 -0
  218. /package/{src/components → components}/RouteSchedule/RouteSchedule.md.scss +0 -0
  219. /package/{src/components → components}/RouteSchedule/RouteSchedule.scss +0 -0
  220. /package/{src/components → components}/ScaleLine/ScaleLine.scss +0 -0
  221. /package/{src/components → components}/Zoom/Zoom.md.scss +0 -0
  222. /package/{src/components → components}/Zoom/Zoom.scss +0 -0
  223. /package/{src/images → images}/RouteSchedule/firstStation.png +0 -0
  224. /package/{src/images → images}/RouteSchedule/lastStation.png +0 -0
  225. /package/{src/images → images}/RouteSchedule/line.png +0 -0
  226. /package/{src/images → images}/RouteSchedule/station.png +0 -0
  227. /package/{src/images → images}/baselayer/baselayer.basebright.png +0 -0
  228. /package/{src/images → images}/baselayer/baselayer.osm.png +0 -0
  229. /package/{src/images → images}/baselayer/baselayer.travic.png +0 -0
  230. /package/{src/images → images}/baselayer/open.topo.map.png +0 -0
  231. /package/{src/images → images}/baselayer/osm.baselayer.hot.png +0 -0
  232. /package/{src/images → images}/baselayer/osm.baselayer.png +0 -0
  233. /package/{src/images → images}/favicon.png +0 -0
  234. /package/{src/images → images}/geops_logo.png +0 -0
  235. /package/{src/images → images}/geops_logo.svg +0 -0
  236. /package/{src/images → images}/geops_qr.png +0 -0
  237. /package/{src/images → images}/mots/bus_poi-blue-01.svg +0 -0
  238. /package/{src/images → images}/mots/bus_poi-grey-01.svg +0 -0
  239. /package/{src/images → images}/mots/bus_round-blue-01.svg +0 -0
  240. /package/{src/images → images}/mots/bus_round-grey-01.svg +0 -0
  241. /package/{src/images → images}/mots/bus_square-blue-01.svg +0 -0
  242. /package/{src/images → images}/mots/bus_square-grey-01.svg +0 -0
  243. /package/{src/images → images}/mots/cable_car_poi-blue-01.svg +0 -0
  244. /package/{src/images → images}/mots/cable_car_poi-grey-01.svg +0 -0
  245. /package/{src/images → images}/mots/cable_car_round-blue-01.svg +0 -0
  246. /package/{src/images → images}/mots/cable_car_round-grey-01.svg +0 -0
  247. /package/{src/images → images}/mots/cable_car_square-blue-01.svg +0 -0
  248. /package/{src/images → images}/mots/cable_car_square-grey-01.svg +0 -0
  249. /package/{src/images → images}/mots/ferry_poi-blue-01.svg +0 -0
  250. /package/{src/images → images}/mots/ferry_poi-grey-01.svg +0 -0
  251. /package/{src/images → images}/mots/ferry_round-blue-01.svg +0 -0
  252. /package/{src/images → images}/mots/ferry_round-grey-01.svg +0 -0
  253. /package/{src/images → images}/mots/ferry_square-blue-01.svg +0 -0
  254. /package/{src/images → images}/mots/ferry_square-grey-01.svg +0 -0
  255. /package/{src/images → images}/mots/funicular_round-blue-01.svg +0 -0
  256. /package/{src/images → images}/mots/funicular_round-grey-01.svg +0 -0
  257. /package/{src/images → images}/mots/funicular_square-blue-01.svg +0 -0
  258. /package/{src/images → images}/mots/gondola_round-blue-01.svg +0 -0
  259. /package/{src/images → images}/mots/rail_poi-blue-01.svg +0 -0
  260. /package/{src/images → images}/mots/rail_poi-grey-01.svg +0 -0
  261. /package/{src/images → images}/mots/rail_round-blue-01.svg +0 -0
  262. /package/{src/images → images}/mots/rail_round-grey-01.svg +0 -0
  263. /package/{src/images → images}/mots/rail_square-blue-01.svg +0 -0
  264. /package/{src/images → images}/mots/rail_square-grey-01.svg +0 -0
  265. /package/{src/images → images}/mots/subway_round blue-01.svg +0 -0
  266. /package/{src/images → images}/mots/subway_round-blue-01.svg +0 -0
  267. /package/{src/images → images}/mots/tram_poi-blue-01.svg +0 -0
  268. /package/{src/images → images}/mots/tram_poi-grey-01.svg +0 -0
  269. /package/{src/images → images}/mots/tram_round-blue-01.svg +0 -0
  270. /package/{src/images → images}/mots/tram_round-grey-01.svg +0 -0
  271. /package/{src/images → images}/mots/tram_square-blue-01.svg +0 -0
  272. /package/{src/images → images}/mots/tram_square-grey-01.svg +0 -0
  273. /package/{src/images → images}/northArrow.svg +0 -0
  274. /package/{src/images → images}/northArrow.url.svg +0 -0
  275. /package/{src/images → images}/northArrowCircle.svg +0 -0
  276. /package/{src/images → images}/northArrowCircle.url.svg +0 -0
  277. /package/{src/themes → themes}/README.md +0 -0
  278. /package/{src/themes → themes}/default/components.scss +0 -0
  279. /package/{src/themes → themes}/default/examples.scss +0 -0
  280. /package/{src/themes → themes}/default/index.scss +0 -0
  281. /package/{src/themes → themes}/default/mixins.scss +0 -0
  282. /package/{src/themes → themes}/default/variables.scss +0 -0
@@ -1 +0,0 @@
1
- export { default } from './LayerTree';
@@ -1,132 +0,0 @@
1
- /* eslint-disable react/jsx-props-no-spreading */
2
- import React from 'react';
3
- import renderer from 'react-test-renderer';
4
- import { configure, mount } from 'enzyme';
5
- import Adapter from '@cfaester/enzyme-adapter-react-18';
6
- import 'jest-canvas-mock';
7
- import OLMap from 'ol/Map';
8
- import OLMousePosition from 'ol/control/MousePosition';
9
- import MousePosition from './MousePosition';
10
-
11
- configure({ adapter: new Adapter() });
12
- const expectSnapshot = (props) => {
13
- const map = new OLMap({});
14
- const component = renderer.create(<MousePosition map={map} {...props} />);
15
- const tree = component.toJSON();
16
- expect(tree).toMatchSnapshot();
17
- };
18
-
19
- describe('MousePosition', () => {
20
- describe('matches snapshots', () => {
21
- test('using default values.', () => {
22
- expectSnapshot({});
23
- });
24
-
25
- test('using no projections.', () => {
26
- expectSnapshot({
27
- projections: [],
28
- });
29
- });
30
-
31
- test('using only one projection', () => {
32
- expectSnapshot({
33
- projections: [{ label: 'foo', value: 'foo' }],
34
- });
35
- });
36
-
37
- test('using multiple projections.', () => {
38
- expectSnapshot({
39
- projections: [
40
- { label: 'foo', value: 'foo' },
41
- { label: 'bar', value: 'bar' },
42
- ],
43
- });
44
- });
45
- });
46
-
47
- test('add MousePosition control to the map.', () => {
48
- const map = new OLMap({});
49
- const spy = jest.spyOn(map, 'removeControl');
50
- const spy2 = jest.spyOn(map, 'addControl');
51
- const fn = jest.fn();
52
- mount(
53
- <MousePosition
54
- map={map}
55
- projections={[
56
- {
57
- label: 'EPSG:4326',
58
- value: 'EPSG:4326',
59
- format: fn,
60
- },
61
- ]}
62
- />,
63
- );
64
- const ctrl = spy2.mock.calls[0][0];
65
- expect(spy).toHaveBeenCalledTimes(0);
66
- expect(spy2).toHaveBeenCalledTimes(1);
67
- expect(ctrl).toBeInstanceOf(OLMousePosition);
68
- expect(ctrl.getProjection().getCode()).toBe('EPSG:4326');
69
- expect(ctrl.getCoordinateFormat()).toBe(fn);
70
- });
71
-
72
- test('add/remove MousePosition control on mount/unmount.', () => {
73
- const map = new OLMap({});
74
- const spy = jest.spyOn(map, 'removeControl');
75
- const spy2 = jest.spyOn(map, 'addControl');
76
- const wrapper = mount(<MousePosition map={map} />);
77
- expect(spy).toHaveBeenCalledTimes(0);
78
- expect(spy2).toHaveBeenCalledTimes(1);
79
- wrapper.unmount();
80
- expect(spy).toHaveBeenCalledTimes(1);
81
- expect(spy.mock.calls[0][0]).toBe(spy2.mock.calls[0][0]);
82
- });
83
-
84
- test('triggers onChange when select projection.', () => {
85
- const map = new OLMap({});
86
- const onChange = jest.fn(() => {});
87
- const wrapper = mount(
88
- <MousePosition
89
- map={map}
90
- onChange={onChange}
91
- projections={[
92
- {
93
- label: 'EPSG:4326',
94
- value: 'EPSG:4326',
95
- format: jest.fn(),
96
- },
97
- ]}
98
- />,
99
- );
100
- // onChange triggered on instantiation.
101
- expect(onChange).toHaveBeenCalledTimes(0);
102
- wrapper.find('select').simulate('change', {});
103
- expect(onChange).toHaveBeenCalledTimes(1);
104
- });
105
-
106
- test('applies new format and value when we select a new projection.', () => {
107
- const map = new OLMap({});
108
- const spy = jest.spyOn(map, 'addControl');
109
- const projs = [
110
- {
111
- label: 'EPSG:4326',
112
- value: 'EPSG:4326',
113
- format: jest.fn(),
114
- },
115
- {
116
- label: 'EPSG:3857',
117
- value: 'EPSG:3857',
118
- format: jest.fn(),
119
- },
120
- ];
121
- const wrapper = mount(<MousePosition map={map} projections={projs} />);
122
-
123
- const ctrl = spy.mock.calls[0][0];
124
- expect(ctrl.getProjection().getCode()).toBe(projs[0].value);
125
- expect(ctrl.getCoordinateFormat()).toBe(projs[0].format);
126
- wrapper
127
- .find('select')
128
- .simulate('change', { target: { value: 'EPSG:3857' } });
129
- expect(ctrl.getProjection().getCode()).toBe(projs[1].value);
130
- expect(ctrl.getCoordinateFormat()).toBe(projs[1].format);
131
- });
132
- });
@@ -1,50 +0,0 @@
1
-
2
- The following example demonstrates the use of MousePosition.
3
-
4
- ```jsx
5
- import React from 'react';
6
- import { MapboxLayer } from 'mobility-toolbox-js/ol';
7
- import Tile from 'ol/layer/Tile';
8
- import OSM from 'ol/source/OSM';
9
- import Map from 'ol/Map';
10
- import BasicMap from 'react-spatial/components/BasicMap';
11
- import MousePosition from 'react-spatial/components/MousePosition';
12
-
13
- const map = new Map({ controls: [] });
14
-
15
- const layers = [
16
- new MapboxLayer({
17
- url: `https://maps.geops.io/styles/travic_v2/style.json?key=${apiKey}`,
18
- }),
19
- ];
20
-
21
- <div className="rs-mouse-position-example">
22
- <BasicMap map={map} center={[1149722.7037660484, 6618091.313553318]} zoom={6} layers={layers} tabIndex={0} />
23
- <MousePosition
24
- map={map}
25
- projections={[
26
- {
27
- label: 'World Geodetic System 1984',
28
- value: 'EPSG:4326',
29
- },
30
- {
31
- label: 'Web mercator with custom output',
32
- value: 'EPSG:3857',
33
- format: coordinates => {
34
- const decimals = 4;
35
- const text = [];
36
- coordinates.forEach(input => {
37
- const coord =
38
- Math.round(parseFloat(input) * 10 ** decimals) /
39
- 10 ** decimals;
40
- const parts = coord.toString().split('.');
41
- parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, "'");
42
- text.push(parts.join());
43
- });
44
- return `Coordinates: ${text.join(' ')}`;
45
- },
46
- },
47
- ]}
48
- />
49
- </div>
50
- ```
@@ -1,76 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`MousePosition matches snapshots using default values. 1`] = `
4
- <div
5
- className="rs-mouse-position"
6
- >
7
- <select
8
- className="rs-select"
9
- onChange={[Function]}
10
- value="EPSG:4326"
11
- >
12
- <option
13
- value="EPSG:4326"
14
- >
15
- EPSG:4326
16
- </option>
17
- <option
18
- value="EPSG:3857"
19
- >
20
- EPSG:3857
21
- </option>
22
- </select>
23
- <span
24
- className="rs-coordinates"
25
- />
26
- </div>
27
- `;
28
-
29
- exports[`MousePosition matches snapshots using multiple projections. 1`] = `
30
- <div
31
- className="rs-mouse-position"
32
- >
33
- <select
34
- className="rs-select"
35
- onChange={[Function]}
36
- value="foo"
37
- >
38
- <option
39
- value="foo"
40
- >
41
- foo
42
- </option>
43
- <option
44
- value="bar"
45
- >
46
- bar
47
- </option>
48
- </select>
49
- <span
50
- className="rs-coordinates"
51
- />
52
- </div>
53
- `;
54
-
55
- exports[`MousePosition matches snapshots using no projections. 1`] = `null`;
56
-
57
- exports[`MousePosition matches snapshots using only one projection 1`] = `
58
- <div
59
- className="rs-mouse-position"
60
- >
61
- <select
62
- className="rs-select"
63
- onChange={[Function]}
64
- value="foo"
65
- >
66
- <option
67
- value="foo"
68
- >
69
- foo
70
- </option>
71
- </select>
72
- <span
73
- className="rs-coordinates"
74
- />
75
- </div>
76
- `;
@@ -1 +0,0 @@
1
- export { default } from './MousePosition';
@@ -1,104 +0,0 @@
1
- import 'jest-canvas-mock';
2
- import React from 'react';
3
- import renderer from 'react-test-renderer';
4
- import { act } from 'react-dom/test-utils';
5
- import { configure, mount } from 'enzyme';
6
- import Adapter from '@cfaester/enzyme-adapter-react-18';
7
- import MapEvent from 'ol/MapEvent';
8
- import OLMap from 'ol/Map';
9
- import OLView from 'ol/View';
10
- import { TiImage } from 'react-icons/ti';
11
- import NorthArrow from './NorthArrow';
12
-
13
- configure({ adapter: new Adapter() });
14
- let olView;
15
- let olMap;
16
-
17
- describe('NorthArrow', () => {
18
- beforeEach(() => {
19
- olView = new OLView();
20
- olMap = new OLMap({ view: olView });
21
- });
22
-
23
- test('should match snapshot with default value.', () => {
24
- let component;
25
- renderer.act(() => {
26
- component = renderer.create(<NorthArrow map={olMap} />);
27
- });
28
- const tree = component.toJSON();
29
- expect(tree).toMatchSnapshot();
30
- });
31
-
32
- test('should match snapshot with custom attributes.', () => {
33
- let component;
34
- renderer.act(() => {
35
- component = renderer.create(
36
- <NorthArrow map={olMap} className="test-class" tabIndex={0} />,
37
- );
38
- });
39
- const tree = component.toJSON();
40
- expect(tree).toMatchSnapshot();
41
- });
42
-
43
- test('should match snapshot with children.', () => {
44
- let component;
45
- renderer.act(() => {
46
- component = renderer.create(
47
- <NorthArrow map={olMap}>
48
- <TiImage />
49
- </NorthArrow>,
50
- );
51
- });
52
- const tree = component.toJSON();
53
- expect(tree).toMatchSnapshot();
54
- });
55
-
56
- test('should match snapshot rotated.', () => {
57
- let component;
58
- renderer.act(() => {
59
- component = renderer.create(
60
- <NorthArrow map={olMap} rotationOffset={45} />,
61
- );
62
- });
63
- const tree = component.toJSON();
64
- expect(tree).toMatchSnapshot();
65
- });
66
-
67
- test('should match snapshot with circle.', () => {
68
- let component;
69
- renderer.act(() => {
70
- component = renderer.create(<NorthArrow circled map={olMap} />);
71
- });
72
- const tree = component.toJSON();
73
- expect(tree).toMatchSnapshot();
74
- });
75
-
76
- test('should react on view rotation (transform: `rotate(20deg)`)', () => {
77
- const wrapper = mount(<NorthArrow map={olMap} />);
78
- // Trigger view rotation
79
- olMap.getView().setRotation(0.3490658503988659);
80
- act(() => {
81
- olMap.dispatchEvent(new MapEvent('postrender', olMap));
82
- // 20 degrees = 0.3490658503988659 radians
83
- });
84
- expect(wrapper.html()).toMatchSnapshot();
85
- });
86
-
87
- test('should react on view rotation with offset (transform: `rotate(10deg)`)', () => {
88
- const wrapper = mount(<NorthArrow map={olMap} rotationOffset={-10} />);
89
- olMap.getView().setRotation(0.3490658503988659);
90
- act(() => {
91
- olMap.dispatchEvent(new MapEvent('postrender', olMap));
92
- });
93
- expect(wrapper.html()).toMatchSnapshot();
94
- });
95
-
96
- test('should remove post render event on unmount', () => {
97
- const wrapper = mount(<NorthArrow map={olMap} rotationOffset={-10} />);
98
- // eslint-disable-next-line no-underscore-dangle
99
- expect(olMap.listeners_.postrender.length).toBe(4);
100
- wrapper.unmount();
101
- // eslint-disable-next-line no-underscore-dangle
102
- expect(olMap.listeners_.postrender.length).toBe(3);
103
- });
104
- });
@@ -1,59 +0,0 @@
1
-
2
- The following example demonstrates the use of NorthArrowExample (Alt + Shift + click to rotate).
3
-
4
- ```jsx
5
- import React from 'react';
6
- import { Layer } from 'mobility-toolbox-js/ol';
7
- import Map from 'ol/Map';
8
- import { DragRotate, defaults } from 'ol/interaction';
9
- import Tile from 'ol/layer/Tile';
10
- import TileGrid from 'ol/tilegrid/TileGrid';
11
- import TileImageSource from 'ol/source/TileImage';
12
- import { getCenter} from 'ol/extent';
13
- import BasicMap from 'react-spatial/components/BasicMap';
14
- import NorthArrow from 'react-spatial/components/NorthArrow';
15
-
16
- const extent = [599500, 199309, 600714, 200002];
17
-
18
- const map = new Map({ controls: [] });
19
-
20
- const layers = [
21
- new Layer({
22
- olLayer: new Tile({
23
- extent,
24
- source: new TileImageSource({
25
- tileUrlFunction: c =>
26
- '//plans.trafimage.ch/static/tiles/' +
27
- `bern_aussenplan/${c[0]}/${c[1]}/${-c[2]-1}.png`,
28
- tileGrid: new TileGrid({
29
- origin: [extent[0], extent[1]],
30
- resolutions: [
31
- 6.927661,
32
- 3.4638305,
33
- 1.73191525,
34
- 0.865957625,
35
- 0.4329788125,
36
- 0.21648940625,
37
- 0.108244703125,
38
- ],
39
- }),
40
- }),
41
- }),
42
- }),
43
- ];
44
-
45
- <div style={{position:'relative'}}>
46
- <BasicMap
47
- map={map}
48
- center={getCenter(extent)}
49
- zoom={17}
50
- layers={layers}
51
- tabIndex={0}
52
- />
53
- <NorthArrow
54
- map={map}
55
- rotationOffset={20}
56
- circled
57
- />
58
- </div>;
59
- ```
@@ -1,117 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`NorthArrow should match snapshot rotated. 1`] = `
4
- <div
5
- className="rs-north-arrow"
6
- style={
7
- {
8
- "transform": "rotate(45deg)",
9
- }
10
- }
11
- >
12
- <svg
13
- data-file-name="SvgNorthArrow"
14
- />
15
- </div>
16
- `;
17
-
18
- exports[`NorthArrow should match snapshot with children. 1`] = `
19
- <div
20
- className="rs-north-arrow"
21
- style={
22
- {
23
- "transform": "rotate(0deg)",
24
- }
25
- }
26
- >
27
- <svg
28
- baseProfile="tiny"
29
- fill="currentColor"
30
- height="1em"
31
- stroke="currentColor"
32
- strokeWidth="0"
33
- style={
34
- {
35
- "color": undefined,
36
- }
37
- }
38
- version="1.2"
39
- viewBox="0 0 24 24"
40
- width="1em"
41
- xmlns="http://www.w3.org/2000/svg"
42
- >
43
- <circle
44
- cx="8.5"
45
- cy="8.5"
46
- r="2.5"
47
- />
48
- <path
49
- d="M16 10c-2 0-3 3-4.5 3s-1.499-1-3.5-1c-2 0-3.001 4-3.001 4h14.001s-1-6-3-6zM20 3h-16c-1.103 0-2 .897-2 2v12c0 1.103.897 2 2 2h16c1.103 0 2-.897 2-2v-12c0-1.103-.897-2-2-2zm0 14h-16v-12h16v12z"
50
- />
51
- </svg>
52
- </div>
53
- `;
54
-
55
- exports[`NorthArrow should match snapshot with circle. 1`] = `
56
- <div
57
- className="rs-north-arrow"
58
- style={
59
- {
60
- "transform": "rotate(0deg)",
61
- }
62
- }
63
- >
64
- <svg
65
- data-file-name="SvgNorthArrowCircle"
66
- />
67
- </div>
68
- `;
69
-
70
- exports[`NorthArrow should match snapshot with custom attributes. 1`] = `
71
- <div
72
- className="test-class"
73
- style={
74
- {
75
- "transform": "rotate(0deg)",
76
- }
77
- }
78
- tabIndex={0}
79
- >
80
- <svg
81
- data-file-name="SvgNorthArrow"
82
- />
83
- </div>
84
- `;
85
-
86
- exports[`NorthArrow should match snapshot with default value. 1`] = `
87
- <div
88
- className="rs-north-arrow"
89
- style={
90
- {
91
- "transform": "rotate(0deg)",
92
- }
93
- }
94
- >
95
- <svg
96
- data-file-name="SvgNorthArrow"
97
- />
98
- </div>
99
- `;
100
-
101
- exports[`NorthArrow should react on view rotation (transform: \`rotate(20deg)\`) 1`] = `
102
- <div class="rs-north-arrow"
103
- style="transform: rotate(20deg);"
104
- >
105
- <svg data-file-name="SvgNorthArrow">
106
- </svg>
107
- </div>
108
- `;
109
-
110
- exports[`NorthArrow should react on view rotation with offset (transform: \`rotate(10deg)\`) 1`] = `
111
- <div class="rs-north-arrow"
112
- style="transform: rotate(10deg);"
113
- >
114
- <svg data-file-name="SvgNorthArrow">
115
- </svg>
116
- </div>
117
- `;
@@ -1 +0,0 @@
1
- export { default } from './NorthArrow';
@@ -1,149 +0,0 @@
1
- import React, { useState } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { act } from 'react-dom/test-utils';
4
- import { configure, mount } from 'enzyme';
5
- import renderer from 'react-test-renderer';
6
- import Adapter from '@cfaester/enzyme-adapter-react-18';
7
- import ResizeObserver from 'resize-observer-polyfill';
8
- import { Resizable } from 're-resizable';
9
- import Overlay from './Overlay';
10
-
11
- jest.mock('resize-observer-polyfill');
12
-
13
- configure({ adapter: new Adapter() });
14
-
15
- const propTypes = {
16
- isMobileResizable: PropTypes.bool,
17
- thresholdWidthForMobile: PropTypes.number,
18
- };
19
-
20
- const defaultProps = {
21
- isMobileResizable: undefined,
22
- thresholdWidthForMobile: undefined,
23
- };
24
-
25
- const BasicComponent = ({ thresholdWidthForMobile, isMobileResizable }) => {
26
- const [ref, setRef] = useState(null);
27
-
28
- return (
29
- <>
30
- <div
31
- ref={(node) => {
32
- if (node !== ref) {
33
- setRef(node);
34
- }
35
- }}
36
- className="observer"
37
- />
38
- <Overlay
39
- observe={ref}
40
- thresholdWidthForMobile={thresholdWidthForMobile}
41
- isMobileResizable={isMobileResizable}
42
- >
43
- Test content
44
- </Overlay>
45
- </>
46
- );
47
- };
48
- BasicComponent.propTypes = propTypes;
49
- BasicComponent.defaultProps = defaultProps;
50
-
51
- describe('Overlay', () => {
52
- test('should match snapshot.', () => {
53
- const component = renderer.create(<Overlay>Test content</Overlay>);
54
- const tree = component.toJSON();
55
- expect(tree).toMatchSnapshot();
56
- });
57
-
58
- test('should react on observe resize.', () => {
59
- const wrapper = mount(<BasicComponent />);
60
- const target = wrapper.find('.observer').getDOMNode();
61
-
62
- act(() => {
63
- // The mock class set the onResize property, we just have to run it to
64
- // simulate a resize
65
- ResizeObserver.onResize([
66
- {
67
- target,
68
- contentRect: {
69
- width: 200,
70
- height: 200,
71
- },
72
- },
73
- ]);
74
- });
75
- wrapper.update();
76
-
77
- expect(wrapper.find('.tm-overlay').length > 0).toBe(false);
78
- expect(wrapper.find('.tm-overlay-mobile').length > 0).toBe(true);
79
- });
80
-
81
- test('should force mobile overlay display on big screen.', () => {
82
- const wrapper = mount(
83
- <BasicComponent thresholdWidthForMobile={Infinity} />,
84
- );
85
- const target = wrapper.find('.observer').getDOMNode();
86
-
87
- act(() => {
88
- ResizeObserver.onResize([
89
- {
90
- target,
91
- contentRect: {
92
- width: 1200,
93
- height: 200,
94
- },
95
- },
96
- ]);
97
- });
98
- wrapper.update();
99
-
100
- expect(wrapper.find('.tm-overlay').length > 0).toBe(false);
101
- expect(wrapper.find('.tm-overlay-mobile').length > 0).toBe(true);
102
- });
103
-
104
- test('should allow resizing with top handler on mobile.', () => {
105
- const wrapper = mount(<BasicComponent />);
106
- const target = wrapper.find('.observer').getDOMNode();
107
-
108
- // Force resize to make it mobile.
109
- act(() => {
110
- ResizeObserver.onResize([
111
- {
112
- target,
113
- contentRect: {
114
- width: 200,
115
- height: 200,
116
- },
117
- },
118
- ]);
119
- });
120
- wrapper.update();
121
-
122
- const resizableProps = wrapper.find(Resizable).props();
123
-
124
- expect(resizableProps.enable.top).toBe(true);
125
- });
126
-
127
- test('should not allow resizing with top handler on mobile.', () => {
128
- const wrapper = mount(<BasicComponent isMobileResizable={false} />);
129
- const target = wrapper.find('.observer').getDOMNode();
130
-
131
- // Force resize to make it mobile.
132
- act(() => {
133
- ResizeObserver.onResize([
134
- {
135
- target,
136
- contentRect: {
137
- width: 200,
138
- height: 200,
139
- },
140
- },
141
- ]);
142
- });
143
- wrapper.update();
144
-
145
- const resizableProps = wrapper.find(Resizable).props();
146
-
147
- expect(resizableProps.enable.top).toBe(false);
148
- });
149
- });