react-spatial 2.0.0-beta.1 → 2.0.0-beta.3

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 (213) hide show
  1. package/README.md +5 -10
  2. package/components/BaseLayerSwitcher/BaseLayerSwitcher.js +243 -220
  3. package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +7 -1
  4. package/components/BaseLayerSwitcher/BaseLayerSwitcher.scss +6 -5
  5. package/components/BaseLayerSwitcher/index.js +1 -3
  6. package/components/BaseLayerSwitcher/index.js.map +7 -1
  7. package/components/BasicMap/BasicMap.js +165 -285
  8. package/components/BasicMap/BasicMap.js.map +7 -1
  9. package/components/BasicMap/index.js +1 -3
  10. package/components/BasicMap/index.js.map +7 -1
  11. package/components/CanvasSaveButton/CanvasSaveButton.js +434 -556
  12. package/components/CanvasSaveButton/CanvasSaveButton.js.map +7 -1
  13. package/components/CanvasSaveButton/CanvasSaveButton.md.scss +1 -1
  14. package/components/CanvasSaveButton/index.js +1 -3
  15. package/components/CanvasSaveButton/index.js.map +7 -1
  16. package/components/Copyright/Copyright.js +44 -77
  17. package/components/Copyright/Copyright.js.map +7 -1
  18. package/components/Copyright/index.js +1 -3
  19. package/components/Copyright/index.js.map +7 -1
  20. package/components/FeatureExportButton/FeatureExportButton.js +44 -92
  21. package/components/FeatureExportButton/FeatureExportButton.js.map +7 -1
  22. package/components/FeatureExportButton/index.js +1 -3
  23. package/components/FeatureExportButton/index.js.map +7 -1
  24. package/components/FitExtent/FitExtent.js +31 -46
  25. package/components/FitExtent/FitExtent.js.map +7 -1
  26. package/components/FitExtent/index.js +1 -3
  27. package/components/FitExtent/index.js.map +7 -1
  28. package/components/Geolocation/Geolocation.js +158 -228
  29. package/components/Geolocation/Geolocation.js.map +7 -1
  30. package/components/Geolocation/Geolocation.scss +7 -5
  31. package/components/Geolocation/index.js +1 -3
  32. package/components/Geolocation/index.js.map +7 -1
  33. package/components/LayerTree/LayerTree.js +359 -357
  34. package/components/LayerTree/LayerTree.js.map +7 -1
  35. package/components/LayerTree/LayerTree.scss +4 -6
  36. package/components/LayerTree/index.js +1 -3
  37. package/components/LayerTree/index.js.map +7 -1
  38. package/components/MousePosition/MousePosition.js +71 -109
  39. package/components/MousePosition/MousePosition.js.map +7 -1
  40. package/components/MousePosition/index.js +1 -3
  41. package/components/MousePosition/index.js.map +7 -1
  42. package/components/NorthArrow/NorthArrow.js +37 -61
  43. package/components/NorthArrow/NorthArrow.js.map +7 -1
  44. package/components/NorthArrow/index.js +1 -3
  45. package/components/NorthArrow/index.js.map +7 -1
  46. package/components/Overlay/Overlay.js +93 -123
  47. package/components/Overlay/Overlay.js.map +7 -1
  48. package/components/Overlay/index.js +1 -3
  49. package/components/Overlay/index.js.map +7 -1
  50. package/components/Permalink/Permalink.js +194 -229
  51. package/components/Permalink/Permalink.js.map +7 -1
  52. package/components/Permalink/index.js +1 -3
  53. package/components/Permalink/index.js.map +7 -1
  54. package/components/Popup/Popup.js +139 -215
  55. package/components/Popup/Popup.js.map +7 -1
  56. package/components/Popup/Popup.md.scss +1 -0
  57. package/components/Popup/Popup.scss +3 -1
  58. package/components/Popup/index.js +1 -3
  59. package/components/Popup/index.js.map +7 -1
  60. package/components/ResizeHandler/ResizeHandler.js +88 -137
  61. package/components/ResizeHandler/ResizeHandler.js.map +7 -1
  62. package/components/ResizeHandler/index.js +1 -3
  63. package/components/ResizeHandler/index.js.map +7 -1
  64. package/components/RouteSchedule/RouteSchedule.js +227 -277
  65. package/components/RouteSchedule/RouteSchedule.js.map +7 -1
  66. package/components/RouteSchedule/RouteSchedule.md.scss +4 -2
  67. package/components/RouteSchedule/RouteSchedule.scss +12 -23
  68. package/components/RouteSchedule/index.js +1 -3
  69. package/components/RouteSchedule/index.js.map +7 -1
  70. package/components/ScaleLine/ScaleLine.js +17 -39
  71. package/components/ScaleLine/ScaleLine.js.map +7 -1
  72. package/components/ScaleLine/ScaleLine.scss +6 -4
  73. package/components/ScaleLine/index.js +1 -3
  74. package/components/ScaleLine/index.js.map +7 -1
  75. package/components/StopsFinder/StopsFinder.js +134 -162
  76. package/components/StopsFinder/StopsFinder.js.map +7 -1
  77. package/components/StopsFinder/StopsFinderOption.js +30 -60
  78. package/components/StopsFinder/StopsFinderOption.js.map +7 -1
  79. package/components/StopsFinder/index.js +1 -3
  80. package/components/StopsFinder/index.js.map +7 -1
  81. package/components/Zoom/Zoom.js +102 -106
  82. package/components/Zoom/Zoom.js.map +7 -1
  83. package/components/Zoom/Zoom.md.scss +3 -1
  84. package/components/Zoom/Zoom.scss +7 -5
  85. package/components/Zoom/index.js +1 -3
  86. package/components/Zoom/index.js.map +7 -1
  87. package/images/geops_qr.png +0 -0
  88. package/package.json +88 -182
  89. package/propTypes.js +36 -24
  90. package/propTypes.js.map +7 -1
  91. package/setupTests.js +21 -4
  92. package/setupTests.js.map +7 -1
  93. package/themes/README.md +26 -0
  94. package/themes/default/components.scss +9 -14
  95. package/themes/default/examples.scss +20 -20
  96. package/themes/default/index.scss +3 -3
  97. package/themes/default/mixins.scss +7 -5
  98. package/themes/default/variables.scss +27 -25
  99. package/utils/GlobalsForOle.js +72 -73
  100. package/utils/GlobalsForOle.js.map +7 -1
  101. package/utils/KML.js +320 -381
  102. package/utils/KML.js.map +7 -1
  103. package/utils/Styles.js +25 -33
  104. package/utils/Styles.js.map +7 -1
  105. package/utils/getLayersAsFlatArray.js +14 -0
  106. package/utils/getLayersAsFlatArray.js.map +7 -0
  107. package/utils/getPolygonPattern.js +11 -44
  108. package/utils/getPolygonPattern.js.map +7 -1
  109. package/utils/timeUtils.js +20 -35
  110. package/utils/timeUtils.js.map +7 -1
  111. package/LayerService.js +0 -193
  112. package/LayerService.js.map +0 -1
  113. package/LayerService.test.js +0 -160
  114. package/LayerService.test.js.map +0 -1
  115. package/Projections.js +0 -16
  116. package/Projections.js.map +0 -1
  117. package/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js +0 -88
  118. package/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js.map +0 -1
  119. package/components/BaseLayerToggler/BaseLayerToggler.js +0 -490
  120. package/components/BaseLayerToggler/BaseLayerToggler.js.map +0 -1
  121. package/components/BaseLayerToggler/BaseLayerToggler.md.scss +0 -9
  122. package/components/BaseLayerToggler/BaseLayerToggler.scss +0 -49
  123. package/components/BaseLayerToggler/BaseLayerToggler.test.js +0 -127
  124. package/components/BaseLayerToggler/BaseLayerToggler.test.js.map +0 -1
  125. package/components/BaseLayerToggler/index.js +0 -3
  126. package/components/BaseLayerToggler/index.js.map +0 -1
  127. package/components/BasicMap/BasicMap.test.js +0 -288
  128. package/components/BasicMap/BasicMap.test.js.map +0 -1
  129. package/components/CanvasSaveButton/CanvasSaveButton.test.js +0 -173
  130. package/components/CanvasSaveButton/CanvasSaveButton.test.js.map +0 -1
  131. package/components/Copyright/Copyright.test.js +0 -133
  132. package/components/Copyright/Copyright.test.js.map +0 -1
  133. package/components/FeatureExportButton/FeatureExportButton.test.js +0 -407
  134. package/components/FeatureExportButton/FeatureExportButton.test.js.map +0 -1
  135. package/components/FilterButton/FilterButton.js +0 -131
  136. package/components/FilterButton/FilterButton.js.map +0 -1
  137. package/components/FilterButton/FilterButton.scss +0 -36
  138. package/components/FilterButton/FilterButton.test.js +0 -48
  139. package/components/FilterButton/FilterButton.test.js.map +0 -1
  140. package/components/FilterButton/index.js +0 -3
  141. package/components/FilterButton/index.js.map +0 -1
  142. package/components/FitExtent/FitExtent.test.js +0 -44
  143. package/components/FitExtent/FitExtent.test.js.map +0 -1
  144. package/components/FollowButton/FollowButton.js +0 -143
  145. package/components/FollowButton/FollowButton.js.map +0 -1
  146. package/components/FollowButton/FollowButton.scss +0 -36
  147. package/components/FollowButton/FollowButton.test.js +0 -57
  148. package/components/FollowButton/FollowButton.test.js.map +0 -1
  149. package/components/FollowButton/index.js +0 -3
  150. package/components/FollowButton/index.js.map +0 -1
  151. package/components/Geolocation/Geolocation.test.js +0 -263
  152. package/components/Geolocation/Geolocation.test.js.map +0 -1
  153. package/components/LayerTree/LayerTree.test.js +0 -323
  154. package/components/LayerTree/LayerTree.test.js.map +0 -1
  155. package/components/MousePosition/MousePosition.test.js +0 -125
  156. package/components/MousePosition/MousePosition.test.js.map +0 -1
  157. package/components/NorthArrow/NorthArrow.test.js +0 -106
  158. package/components/NorthArrow/NorthArrow.test.js.map +0 -1
  159. package/components/Overlay/Overlay.test.js +0 -145
  160. package/components/Overlay/Overlay.test.js.map +0 -1
  161. package/components/Permalink/Permalink.test.js +0 -267
  162. package/components/Permalink/Permalink.test.js.map +0 -1
  163. package/components/Popup/Popup.test.js +0 -291
  164. package/components/Popup/Popup.test.js.map +0 -1
  165. package/components/ResizeHandler/ResizeHandler.test.js +0 -410
  166. package/components/ResizeHandler/ResizeHandler.test.js.map +0 -1
  167. package/components/RouteSchedule/RouteSchedule.test.js +0 -102
  168. package/components/RouteSchedule/RouteSchedule.test.js.map +0 -1
  169. package/components/ScaleLine/ScaleLine.test.js +0 -32
  170. package/components/ScaleLine/ScaleLine.test.js.map +0 -1
  171. package/components/Search/Search.js +0 -230
  172. package/components/Search/Search.js.map +0 -1
  173. package/components/Search/Search.md.scss +0 -4
  174. package/components/Search/Search.scss +0 -78
  175. package/components/Search/Search.test.js +0 -15
  176. package/components/Search/Search.test.js.map +0 -1
  177. package/components/Search/SearchService.js +0 -72
  178. package/components/Search/SearchService.js.map +0 -1
  179. package/components/Search/engines/Engine.js +0 -26
  180. package/components/Search/engines/Engine.js.map +0 -1
  181. package/components/Search/engines/StopFinder.js +0 -47
  182. package/components/Search/engines/StopFinder.js.map +0 -1
  183. package/components/Search/index.js +0 -6
  184. package/components/Search/index.js.map +0 -1
  185. package/components/StopsFinder/StopsFinder.test.js +0 -19
  186. package/components/StopsFinder/StopsFinder.test.js.map +0 -1
  187. package/components/TrackerControl/TrackerControl.js +0 -171
  188. package/components/TrackerControl/TrackerControl.js.map +0 -1
  189. package/components/TrackerControl/TrackerControl.scss +0 -30
  190. package/components/TrackerControl/TrackerControl.test.js +0 -17
  191. package/components/TrackerControl/TrackerControl.test.js.map +0 -1
  192. package/components/TrackerControl/index.js +0 -3
  193. package/components/TrackerControl/index.js.map +0 -1
  194. package/components/Zoom/Zoom.test.js +0 -150
  195. package/components/Zoom/Zoom.test.js.map +0 -1
  196. package/images/FilterButton/filter.svg +0 -1
  197. package/images/FollowButton/follow.svg +0 -1
  198. package/images/baselayer/osm.baselayer.hot.png +0 -0
  199. package/images/baselayer/osm.baselayer.png +0 -0
  200. package/styleguidist/ComponentsList.js +0 -52
  201. package/styleguidist/ComponentsList.js.map +0 -1
  202. package/styleguidist/StyleGuide.js +0 -253
  203. package/styleguidist/StyleGuide.js.map +0 -1
  204. package/utils/KML.test.js +0 -163
  205. package/utils/KML.test.js.map +0 -1
  206. package/utils/KMLFormat.js +0 -105
  207. package/utils/KMLFormat.js.map +0 -1
  208. package/utils/KMLFormat.test.js +0 -22
  209. package/utils/KMLFormat.test.js.map +0 -1
  210. package/utils/getPolygonPattern.test.js +0 -66
  211. package/utils/getPolygonPattern.test.js.map +0 -1
  212. package/utils/timeUtils.test.js +0 -32
  213. package/utils/timeUtils.test.js.map +0 -1
@@ -1,307 +1,231 @@
1
- function objectWithoutProperties (obj, exclude) { var target = {}; for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k) && exclude.indexOf(k) === -1) target[k] = obj[k]; return target; }
2
- import React, { PureComponent } from 'react';
3
- import PropTypes from 'prop-types';
4
-
5
- import { MdClose } from 'react-icons/md';
6
- import OLMap from 'ol/Map';
7
- import Feature from 'ol/Feature';
8
- import { getCenter } from 'ol/extent';
9
- import { unByKey } from 'ol/Observable';
10
-
11
- var propTypes = {
1
+ import { getCenter } from "ol/extent";
2
+ import Feature from "ol/Feature";
3
+ import OLMap from "ol/Map";
4
+ import { unByKey } from "ol/Observable";
5
+ import PropTypes from "prop-types";
6
+ import React, { PureComponent } from "react";
7
+ import { MdClose } from "react-icons/md";
8
+ const propTypes = {
12
9
  /**
13
10
  * React Children.
14
11
  */
15
12
  children: PropTypes.node.isRequired,
16
-
17
13
  /**
18
- * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
14
+ * Class name of the popup.
19
15
  */
20
- map: PropTypes.instanceOf(OLMap).isRequired,
21
-
16
+ className: PropTypes.string,
22
17
  /**
23
18
  * An [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).
24
19
  */
25
20
  feature: PropTypes.instanceOf(Feature),
26
-
27
21
  /**
28
22
  * Popup title.
29
23
  */
30
24
  header: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
31
-
25
+ /**
26
+ * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
27
+ */
28
+ map: PropTypes.instanceOf(OLMap).isRequired,
29
+ /**
30
+ * Function triggered on close button click.
31
+ */
32
+ onCloseClick: PropTypes.func,
32
33
  /**
33
34
  * If true, the popup is panned in the map's viewport.
34
35
  */
35
36
  panIntoView: PropTypes.bool,
36
-
37
37
  /**
38
38
  * Custom BoundingClientRect to fit popup into.
39
39
  * Use if panIntoView is true. Default is the map's BoundingClientRect.
40
40
  */
41
41
  panRect: PropTypes.objectOf(PropTypes.number),
42
-
43
42
  /**
44
43
  * Coordinate position of the popup.
45
44
  */
46
45
  popupCoordinate: PropTypes.arrayOf(PropTypes.number),
47
-
48
- /**
49
- * Class name of the popup.
50
- */
51
- className: PropTypes.string,
52
-
53
- /**
54
- * Title HTML attributes.
55
- */
56
- titles: PropTypes.shape({
57
- closeButton: PropTypes.string,
58
- }),
59
-
60
46
  /**
61
- * Function triggered on close button click.
47
+ * Render the close button
62
48
  */
63
- onCloseClick: PropTypes.func,
64
-
49
+ renderCloseButton: PropTypes.func,
65
50
  /**
66
- * HTML tabIndex attribute.
51
+ * Render the footer
67
52
  */
68
- tabIndex: PropTypes.string,
69
-
53
+ renderFooter: PropTypes.func,
70
54
  /**
71
55
  * Render the header
72
56
  */
73
57
  renderHeader: PropTypes.func,
74
-
75
58
  /**
76
- * Render the close button
59
+ * HTML tabIndex attribute.
77
60
  */
78
- renderCloseButton: PropTypes.func,
79
-
61
+ tabIndex: PropTypes.string,
80
62
  /**
81
- * Render the footer
63
+ * Title HTML attributes.
82
64
  */
83
- renderFooter: PropTypes.func,
65
+ titles: PropTypes.shape({
66
+ closeButton: PropTypes.string
67
+ })
84
68
  };
85
-
86
- var defaultProps = {
87
- header: null,
69
+ const defaultProps = {
70
+ className: "rs-popup",
88
71
  feature: null,
72
+ header: null,
73
+ onCloseClick: () => {
74
+ },
89
75
  panIntoView: false,
90
76
  panRect: null,
91
77
  popupCoordinate: null,
92
- className: 'rs-popup',
93
- tabIndex: '',
94
- titles: { closeButton: 'Close' },
95
- onCloseClick: function () {},
96
- renderHeader: null,
97
78
  renderCloseButton: null,
98
- renderFooter: function () {
79
+ renderFooter: () => {
99
80
  return null;
100
81
  },
82
+ renderHeader: null,
83
+ tabIndex: "",
84
+ titles: { closeButton: "Close" }
101
85
  };
102
-
103
- /**
104
- * The Popup component renders a popup over an
105
- * [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html)
106
- * on click.
107
- */
108
- var Popup = /*@__PURE__*/(function (PureComponent) {
109
- function Popup(props) {
110
- PureComponent.call(this, props);
86
+ class Popup extends PureComponent {
87
+ constructor(props) {
88
+ super(props);
111
89
  this.state = {
112
- popupElement: null,
113
- top: 0,
114
90
  left: 0,
91
+ popupElement: null,
92
+ top: 0
115
93
  };
116
94
  this.postrenderKey = null;
117
95
  }
118
-
119
- if ( PureComponent ) Popup.__proto__ = PureComponent;
120
- Popup.prototype = Object.create( PureComponent && PureComponent.prototype );
121
- Popup.prototype.constructor = Popup;
122
-
123
- Popup.renderHeader = function renderHeader (props) {
124
- var header = props.header;
125
- var renderCloseButton = props.renderCloseButton;
126
- return (
127
- React.createElement( 'div', { className: "rs-popup-header" },
128
- header,
129
- (renderCloseButton || Popup.renderCloseButton)(props)
130
- )
131
- );
132
- };
133
-
134
- Popup.renderCloseButton = function renderCloseButton (ref) {
135
- var onCloseClick = ref.onCloseClick;
136
- var titles = ref.titles;
137
-
138
- return (
139
- React.createElement( 'div', {
140
- role: "button", tabIndex: 0, className: "rs-popup-close-bt", title: titles.closeButton, 'aria-label': titles.closeButton, onClick: function () {
96
+ static renderCloseButton({ onCloseClick, titles }) {
97
+ return /* @__PURE__ */ React.createElement(
98
+ "div",
99
+ {
100
+ "aria-label": titles.closeButton,
101
+ className: "rs-popup-close-bt",
102
+ onClick: () => {
141
103
  return onCloseClick();
142
- }, onKeyPress: function (evt) {
104
+ },
105
+ onKeyPress: (evt) => {
143
106
  return evt.which === 13 && onCloseClick();
144
- } },
145
- React.createElement( MdClose, { focusable: false })
146
- )
107
+ },
108
+ role: "button",
109
+ tabIndex: 0,
110
+ title: titles.closeButton
111
+ },
112
+ /* @__PURE__ */ React.createElement(MdClose, { focusable: false })
147
113
  );
148
- };
149
-
150
- Popup.prototype.componentDidMount = function componentDidMount () {
151
- var this$1 = this;
152
-
153
- var ref = this.props;
154
- var map = ref.map;
114
+ }
115
+ static renderHeader(props) {
116
+ const { header, renderCloseButton } = props;
117
+ return /* @__PURE__ */ React.createElement("div", { className: "rs-popup-header" }, header, (renderCloseButton || Popup.renderCloseButton)(props));
118
+ }
119
+ componentDidMount() {
120
+ const { map } = this.props;
155
121
  this.updatePixelPosition();
156
-
157
- this.postrenderKey = map.on('postrender', function () {
158
- this$1.updatePixelPosition();
122
+ this.postrenderKey = map.on("postrender", () => {
123
+ this.updatePixelPosition();
159
124
  });
160
- };
161
-
162
- Popup.prototype.componentDidUpdate = function componentDidUpdate (prevProps, prevState) {
163
- var ref = this.props;
164
- var feature = ref.feature;
165
- var panIntoView = ref.panIntoView;
166
- var popupCoordinate = ref.popupCoordinate;
167
- var ref$1 = this.state;
168
- var popupElement = ref$1.popupElement;
169
- if (
170
- feature !== prevProps.feature ||
171
- popupCoordinate !== prevProps.popupCoordinate
172
- ) {
125
+ }
126
+ componentDidUpdate(prevProps, prevState) {
127
+ const { feature, panIntoView, popupCoordinate } = this.props;
128
+ const { popupElement } = this.state;
129
+ if (feature !== prevProps.feature || popupCoordinate !== prevProps.popupCoordinate) {
173
130
  this.updatePixelPosition();
174
131
  }
175
-
176
- if (
177
- panIntoView &&
178
- popupElement &&
179
- popupElement !== prevState.popupElement
180
- ) {
132
+ if (panIntoView && popupElement && popupElement !== prevState.popupElement) {
181
133
  this.panIntoView();
182
134
  }
183
- };
184
-
185
- Popup.prototype.componentWillUnmount = function componentWillUnmount () {
135
+ }
136
+ componentWillUnmount() {
186
137
  unByKey(this.postrenderKey);
187
- };
188
-
189
- Popup.prototype.panIntoView = function panIntoView () {
190
- var ref = this.props;
191
- var map = ref.map;
192
- var panRect = ref.panRect;
193
- var ref$1 = this.state;
194
- var popupElement = ref$1.popupElement;
195
-
196
- var mapRect = panRect || map.getTarget().getBoundingClientRect();
197
- var popupRect = popupElement.getBoundingClientRect();
198
- var ref$2 = map.getView().getCenter();
199
- var x = ref$2[0];
200
- var y = ref$2[1];
201
- var res = map.getView().getResolution();
202
- var newCenter = [x, y];
203
-
138
+ }
139
+ panIntoView() {
140
+ const { map, panRect } = this.props;
141
+ const { popupElement } = this.state;
142
+ const mapRect = panRect || map.getTarget().getBoundingClientRect();
143
+ const popupRect = popupElement.getBoundingClientRect();
144
+ const [x, y] = map.getView().getCenter();
145
+ const res = map.getView().getResolution();
146
+ const newCenter = [x, y];
204
147
  if (mapRect.top > popupRect.top) {
205
148
  newCenter[1] = y + (mapRect.top - popupRect.top) * res;
206
149
  }
207
-
208
150
  if (mapRect.left > popupRect.left) {
209
151
  newCenter[0] = x - (mapRect.left - popupRect.left) * res;
210
152
  }
211
-
212
153
  if (mapRect.right < popupRect.right) {
213
154
  newCenter[0] = x + (popupRect.right - mapRect.right) * res;
214
155
  }
215
-
216
156
  if (mapRect.bottom < popupRect.bottom) {
217
157
  newCenter[1] = y - (popupRect.bottom - mapRect.bottom) * res;
218
158
  }
219
-
220
159
  if (newCenter[0] !== x || newCenter[1] !== y) {
221
160
  map.getView().animate({ center: newCenter, duration: 500 });
222
161
  }
223
- };
224
-
225
- Popup.prototype.updatePixelPosition = function updatePixelPosition () {
226
- var ref = this.props;
227
- var map = ref.map;
228
- var feature = ref.feature;
229
- var popupCoordinate = ref.popupCoordinate;
230
- var coord = popupCoordinate;
231
-
232
- if (feature && !coord) {
233
- coord = getCenter(feature.getGeometry().getExtent());
234
- }
235
-
236
- if (coord) {
237
- var pos = map.getPixelFromCoordinate(coord);
238
-
239
- if (pos && pos.length === 2) {
240
- this.setState({
241
- left: pos[0],
242
- top: pos[1],
243
- });
244
- }
245
- }
246
- };
247
-
248
- Popup.prototype.render = function render () {
249
- var this$1 = this;
250
-
251
- var ref = this.props;
252
- var feature = ref.feature;
253
- var popupCoordinate = ref.popupCoordinate;
254
- var children = ref.children;
255
- var header = ref.header;
256
- var titles = ref.titles;
257
- var tabIndex = ref.tabIndex;
258
- var renderHeader = ref.renderHeader;
259
- var renderFooter = ref.renderFooter;
260
- var rest = objectWithoutProperties( ref, ["feature", "popupCoordinate", "children", "header", "titles", "tabIndex", "renderHeader", "renderFooter"] );
261
- var other = rest;
262
-
162
+ }
163
+ render() {
164
+ const {
165
+ children,
166
+ feature,
167
+ header,
168
+ popupCoordinate,
169
+ renderFooter,
170
+ renderHeader,
171
+ tabIndex,
172
+ titles,
173
+ ...other
174
+ } = this.props;
263
175
  if (!feature && !popupCoordinate) {
264
176
  return null;
265
177
  }
266
-
267
178
  delete other.panIntoView;
268
179
  delete other.panRect;
269
180
  delete other.map;
270
181
  delete other.header;
271
182
  delete other.onCloseClick;
272
183
  delete other.renderCloseButton;
273
-
274
- var ref$1 = this.state;
275
- var top = ref$1.top;
276
- var left = ref$1.left;
277
-
278
- // force re-render if the feature or the coordinate changes.
279
- // this is needed to update the popupElement ref
280
- var key = feature ? feature.getId() : popupCoordinate.join();
281
- return (
282
- React.createElement( 'div', Object.assign({},
283
- { className: "rs-popup", style: {
284
- left: left,
285
- top: top,
286
- } }, other),
287
- React.createElement( 'div', {
288
- className: "rs-popup-container", tabIndex: tabIndex, key: key, ref: function (popupElement) {
289
- this$1.setState({ popupElement: popupElement });
290
- } },
291
- (renderHeader || Popup.renderHeader)(this.props),
292
- React.createElement( 'div', { className: "rs-popup-body" }, children),
293
- renderFooter(this.props)
294
- )
184
+ const { left, top } = this.state;
185
+ const key = feature ? feature.getId() : popupCoordinate.join();
186
+ return /* @__PURE__ */ React.createElement(
187
+ "div",
188
+ {
189
+ className: "rs-popup",
190
+ style: {
191
+ left,
192
+ top
193
+ },
194
+ ...other
195
+ },
196
+ /* @__PURE__ */ React.createElement(
197
+ "div",
198
+ {
199
+ className: "rs-popup-container",
200
+ key,
201
+ ref: (popupElement) => {
202
+ this.setState({ popupElement });
203
+ },
204
+ tabIndex
205
+ },
206
+ (renderHeader || Popup.renderHeader)(this.props),
207
+ /* @__PURE__ */ React.createElement("div", { className: "rs-popup-body" }, children),
208
+ renderFooter(this.props)
295
209
  )
296
210
  );
297
- };
298
-
299
- return Popup;
300
- }(PureComponent));
301
-
211
+ }
212
+ updatePixelPosition() {
213
+ const { feature, map, popupCoordinate } = this.props;
214
+ let coord = popupCoordinate;
215
+ if (feature && !coord) {
216
+ coord = getCenter(feature.getGeometry().getExtent());
217
+ }
218
+ if (coord) {
219
+ const pos = map.getPixelFromCoordinate(coord);
220
+ if (pos && pos.length === 2) {
221
+ this.setState({
222
+ left: pos[0],
223
+ top: pos[1]
224
+ });
225
+ }
226
+ }
227
+ }
228
+ }
302
229
  Popup.propTypes = propTypes;
303
230
  Popup.defaultProps = defaultProps;
304
-
305
231
  export default Popup;
306
-
307
- //# sourceMappingURL=Popup.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"Popup.js","sources":["../../../src/components/Popup/Popup.js"],"sourcesContent":["import React, { PureComponent } from 'react';\nimport PropTypes from 'prop-types';\n\nimport { MdClose } from 'react-icons/md';\nimport OLMap from 'ol/Map';\nimport Feature from 'ol/Feature';\nimport { getCenter } from 'ol/extent';\nimport { unByKey } from 'ol/Observable';\n\nconst propTypes = {\n /**\n * React Children.\n */\n children: PropTypes.node.isRequired,\n\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * An [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).\n */\n feature: PropTypes.instanceOf(Feature),\n\n /**\n * Popup title.\n */\n header: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n\n /**\n * If true, the popup is panned in the map's viewport.\n */\n panIntoView: PropTypes.bool,\n\n /**\n * Custom BoundingClientRect to fit popup into.\n * Use if panIntoView is true. Default is the map's BoundingClientRect.\n */\n panRect: PropTypes.objectOf(PropTypes.number),\n\n /**\n * Coordinate position of the popup.\n */\n popupCoordinate: PropTypes.arrayOf(PropTypes.number),\n\n /**\n * Class name of the popup.\n */\n className: PropTypes.string,\n\n /**\n * Title HTML attributes.\n */\n titles: PropTypes.shape({\n closeButton: PropTypes.string,\n }),\n\n /**\n * Function triggered on close button click.\n */\n onCloseClick: PropTypes.func,\n\n /**\n * HTML tabIndex attribute.\n */\n tabIndex: PropTypes.string,\n\n /**\n * Render the header\n */\n renderHeader: PropTypes.func,\n\n /**\n * Render the close button\n */\n renderCloseButton: PropTypes.func,\n\n /**\n * Render the footer\n */\n renderFooter: PropTypes.func,\n};\n\nconst defaultProps = {\n header: null,\n feature: null,\n panIntoView: false,\n panRect: null,\n popupCoordinate: null,\n className: 'rs-popup',\n tabIndex: '',\n titles: { closeButton: 'Close' },\n onCloseClick: () => {},\n renderHeader: null,\n renderCloseButton: null,\n renderFooter: () => {\n return null;\n },\n};\n\n/**\n * The Popup component renders a popup over an\n * [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html)\n * on click.\n */\nclass Popup extends PureComponent {\n static renderHeader(props) {\n const { header, renderCloseButton } = props;\n return (\n <div className=\"rs-popup-header\">\n {header}\n {(renderCloseButton || Popup.renderCloseButton)(props)}\n </div>\n );\n }\n\n static renderCloseButton({ onCloseClick, titles }) {\n return (\n <div\n role=\"button\"\n tabIndex={0}\n className=\"rs-popup-close-bt\"\n title={titles.closeButton}\n aria-label={titles.closeButton}\n onClick={() => {\n return onCloseClick();\n }}\n onKeyPress={(evt) => {\n return evt.which === 13 && onCloseClick();\n }}\n >\n <MdClose focusable={false} />\n </div>\n );\n }\n\n constructor(props) {\n super(props);\n this.state = {\n popupElement: null,\n top: 0,\n left: 0,\n };\n this.postrenderKey = null;\n }\n\n componentDidMount() {\n const { map } = this.props;\n this.updatePixelPosition();\n\n this.postrenderKey = map.on('postrender', () => {\n this.updatePixelPosition();\n });\n }\n\n componentDidUpdate(prevProps, prevState) {\n const { feature, panIntoView, popupCoordinate } = this.props;\n const { popupElement } = this.state;\n if (\n feature !== prevProps.feature ||\n popupCoordinate !== prevProps.popupCoordinate\n ) {\n this.updatePixelPosition();\n }\n\n if (\n panIntoView &&\n popupElement &&\n popupElement !== prevState.popupElement\n ) {\n this.panIntoView();\n }\n }\n\n componentWillUnmount() {\n unByKey(this.postrenderKey);\n }\n\n panIntoView() {\n const { map, panRect } = this.props;\n const { popupElement } = this.state;\n\n const mapRect = panRect || map.getTarget().getBoundingClientRect();\n const popupRect = popupElement.getBoundingClientRect();\n const [x, y] = map.getView().getCenter();\n const res = map.getView().getResolution();\n const newCenter = [x, y];\n\n if (mapRect.top > popupRect.top) {\n newCenter[1] = y + (mapRect.top - popupRect.top) * res;\n }\n\n if (mapRect.left > popupRect.left) {\n newCenter[0] = x - (mapRect.left - popupRect.left) * res;\n }\n\n if (mapRect.right < popupRect.right) {\n newCenter[0] = x + (popupRect.right - mapRect.right) * res;\n }\n\n if (mapRect.bottom < popupRect.bottom) {\n newCenter[1] = y - (popupRect.bottom - mapRect.bottom) * res;\n }\n\n if (newCenter[0] !== x || newCenter[1] !== y) {\n map.getView().animate({ center: newCenter, duration: 500 });\n }\n }\n\n updatePixelPosition() {\n const { map, feature, popupCoordinate } = this.props;\n let coord = popupCoordinate;\n\n if (feature && !coord) {\n coord = getCenter(feature.getGeometry().getExtent());\n }\n\n if (coord) {\n const pos = map.getPixelFromCoordinate(coord);\n\n if (pos && pos.length === 2) {\n this.setState({\n left: pos[0],\n top: pos[1],\n });\n }\n }\n }\n\n render() {\n const {\n feature,\n popupCoordinate,\n children,\n header,\n titles,\n tabIndex,\n renderHeader,\n renderFooter,\n ...other\n } = this.props;\n\n if (!feature && !popupCoordinate) {\n return null;\n }\n\n delete other.panIntoView;\n delete other.panRect;\n delete other.map;\n delete other.header;\n delete other.onCloseClick;\n delete other.renderCloseButton;\n\n const { top, left } = this.state;\n\n // force re-render if the feature or the coordinate changes.\n // this is needed to update the popupElement ref\n const key = feature ? feature.getId() : popupCoordinate.join();\n return (\n <div\n className=\"rs-popup\"\n style={{\n left,\n top,\n }}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n >\n <div\n className=\"rs-popup-container\"\n tabIndex={tabIndex}\n key={key}\n ref={(popupElement) => {\n this.setState({ popupElement });\n }}\n >\n {(renderHeader || Popup.renderHeader)(this.props)}\n <div className=\"rs-popup-body\">{children}</div>\n {renderFooter(this.props)}\n </div>\n </div>\n );\n }\n}\n\nPopup.propTypes = propTypes;\nPopup.defaultProps = defaultProps;\n\nexport default Popup;\n"],"names":["const","super","this","let"],"mappings":";AAAA,OAAO,KAAK,IAAI,aAAa,QAAQ,OAAO,CAAC;AAC7C,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC;AACA,SAAS,OAAO,QAAQ,gBAAgB,CAAC;AACzC,OAAO,KAAK,MAAM,QAAQ,CAAC;AAC3B,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,SAAS,SAAS,QAAQ,WAAW,CAAC;AACtC,SAAS,OAAO,QAAQ,eAAe,CAAC;AACxC;AACAA,GAAK,CAAC,SAAS,GAAG;AAClB;AACA;AACA;AACA,EAAE,QAAQ,EAAE,SAAS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ature from \"ol/Feature\";\nimport OLMap from \"ol/Map\";\nimport { unByKey } from \"ol/Observable\";\nimport PropTypes from \"prop-types\";\nimport React, { PureComponent } from \"react\";\nimport { MdClose } from \"react-icons/md\";\n\nconst propTypes = {\n /**\n * React Children.\n */\n children: PropTypes.node.isRequired,\n\n /**\n * Class name of the popup.\n */\n className: PropTypes.string,\n\n /**\n * An [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).\n */\n feature: PropTypes.instanceOf(Feature),\n\n /**\n * Popup title.\n */\n header: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * Function triggered on close button click.\n */\n onCloseClick: PropTypes.func,\n\n /**\n * If true, the popup is panned in the map's viewport.\n */\n panIntoView: PropTypes.bool,\n\n /**\n * Custom BoundingClientRect to fit popup into.\n * Use if panIntoView is true. Default is the map's BoundingClientRect.\n */\n panRect: PropTypes.objectOf(PropTypes.number),\n\n /**\n * Coordinate position of the popup.\n */\n popupCoordinate: PropTypes.arrayOf(PropTypes.number),\n\n /**\n * Render the close button\n */\n renderCloseButton: PropTypes.func,\n\n /**\n * Render the footer\n */\n renderFooter: PropTypes.func,\n\n /**\n * Render the header\n */\n renderHeader: PropTypes.func,\n\n /**\n * HTML tabIndex attribute.\n */\n tabIndex: PropTypes.string,\n\n /**\n * Title HTML attributes.\n */\n titles: PropTypes.shape({\n closeButton: PropTypes.string,\n }),\n};\n\nconst defaultProps = {\n className: \"rs-popup\",\n feature: null,\n header: null,\n onCloseClick: () => {},\n panIntoView: false,\n panRect: null,\n popupCoordinate: null,\n renderCloseButton: null,\n renderFooter: () => {\n return null;\n },\n renderHeader: null,\n tabIndex: \"\",\n titles: { closeButton: \"Close\" },\n};\n\n/**\n * The Popup component renders a popup over an\n * [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html)\n * on click.\n */\nclass Popup extends PureComponent {\n constructor(props) {\n super(props);\n this.state = {\n left: 0,\n popupElement: null,\n top: 0,\n };\n this.postrenderKey = null;\n }\n\n static renderCloseButton({ onCloseClick, titles }) {\n return (\n <div\n aria-label={titles.closeButton}\n className=\"rs-popup-close-bt\"\n onClick={() => {\n return onCloseClick();\n }}\n onKeyPress={(evt) => {\n return evt.which === 13 && onCloseClick();\n }}\n role=\"button\"\n tabIndex={0}\n title={titles.closeButton}\n >\n <MdClose focusable={false} />\n </div>\n );\n }\n\n static renderHeader(props) {\n const { header, renderCloseButton } = props;\n return (\n <div className=\"rs-popup-header\">\n {header}\n {(renderCloseButton || Popup.renderCloseButton)(props)}\n </div>\n );\n }\n\n componentDidMount() {\n const { map } = this.props;\n this.updatePixelPosition();\n\n this.postrenderKey = map.on(\"postrender\", () => {\n this.updatePixelPosition();\n });\n }\n\n componentDidUpdate(prevProps, prevState) {\n const { feature, panIntoView, popupCoordinate } = this.props;\n const { popupElement } = this.state;\n if (\n feature !== prevProps.feature ||\n popupCoordinate !== prevProps.popupCoordinate\n ) {\n this.updatePixelPosition();\n }\n\n if (\n panIntoView &&\n popupElement &&\n popupElement !== prevState.popupElement\n ) {\n this.panIntoView();\n }\n }\n\n componentWillUnmount() {\n unByKey(this.postrenderKey);\n }\n\n panIntoView() {\n const { map, panRect } = this.props;\n const { popupElement } = this.state;\n\n const mapRect = panRect || map.getTarget().getBoundingClientRect();\n const popupRect = popupElement.getBoundingClientRect();\n const [x, y] = map.getView().getCenter();\n const res = map.getView().getResolution();\n const newCenter = [x, y];\n\n if (mapRect.top > popupRect.top) {\n newCenter[1] = y + (mapRect.top - popupRect.top) * res;\n }\n\n if (mapRect.left > popupRect.left) {\n newCenter[0] = x - (mapRect.left - popupRect.left) * res;\n }\n\n if (mapRect.right < popupRect.right) {\n newCenter[0] = x + (popupRect.right - mapRect.right) * res;\n }\n\n if (mapRect.bottom < popupRect.bottom) {\n newCenter[1] = y - (popupRect.bottom - mapRect.bottom) * res;\n }\n\n if (newCenter[0] !== x || newCenter[1] !== y) {\n map.getView().animate({ center: newCenter, duration: 500 });\n }\n }\n\n render() {\n const {\n children,\n feature,\n header,\n popupCoordinate,\n renderFooter,\n renderHeader,\n tabIndex,\n titles,\n ...other\n } = this.props;\n\n if (!feature && !popupCoordinate) {\n return null;\n }\n\n delete other.panIntoView;\n delete other.panRect;\n delete other.map;\n delete other.header;\n delete other.onCloseClick;\n delete other.renderCloseButton;\n\n const { left, top } = this.state;\n\n // force re-render if the feature or the coordinate changes.\n // this is needed to update the popupElement ref\n const key = feature ? feature.getId() : popupCoordinate.join();\n return (\n <div\n className=\"rs-popup\"\n style={{\n left,\n top,\n }}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n >\n <div\n className=\"rs-popup-container\"\n key={key}\n ref={(popupElement) => {\n this.setState({ popupElement });\n }}\n tabIndex={tabIndex}\n >\n {(renderHeader || Popup.renderHeader)(this.props)}\n <div className=\"rs-popup-body\">{children}</div>\n {renderFooter(this.props)}\n </div>\n </div>\n );\n }\n\n updatePixelPosition() {\n const { feature, map, popupCoordinate } = this.props;\n let coord = popupCoordinate;\n\n if (feature && !coord) {\n coord = getCenter(feature.getGeometry().getExtent());\n }\n\n if (coord) {\n const pos = map.getPixelFromCoordinate(coord);\n\n if (pos && pos.length === 2) {\n this.setState({\n left: pos[0],\n top: pos[1],\n });\n }\n }\n }\n}\n\nPopup.propTypes = propTypes;\nPopup.defaultProps = defaultProps;\n\nexport default Popup;\n"],
5
+ "mappings": "AAAA,SAAS,iBAAiB;AAC1B,OAAO,aAAa;AACpB,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,OAAO,eAAe;AACtB,OAAO,SAAS,qBAAqB;AACrC,SAAS,eAAe;AAExB,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,UAAU,UAAU,KAAK;AAAA;AAAA;AAAA;AAAA,EAKzB,WAAW,UAAU;AAAA;AAAA;AAAA;AAAA,EA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AAAA,UACC,WAAU;AAAA,UACV;AAAA,UACA,KAAK,CAAC,iBAAiB;AACrB,iBAAK,SAAS,EAAE,aAAa,CAAC;AAAA,UAChC;AAAA,UACA;AAAA;AAAA,SAEE,gBAAgB,MAAM,cAAc,KAAK,KAAK;AAAA,QAChD,oCAAC,SAAI,WAAU,mBAAiB,QAAS;AAAA,QACxC,aAAa,KAAK,KAAK;AAAA,MAC1B;AAAA,IACF;AAAA,EAEJ;AAAA,EAEA,sBAAsB;AACpB,UAAM,EAAE,SAAS,KAAK,gBAAgB,IAAI,KAAK;AAC/C,QAAI,QAAQ;AAEZ,QAAI,WAAW,CAAC,OAAO;AACrB,cAAQ,UAAU,QAAQ,YAAY,EAAE,UAAU,CAAC;AAAA,IACrD;AAEA,QAAI,OAAO;AACT,YAAM,MAAM,IAAI,uBAAuB,KAAK;AAE5C,UAAI,OAAO,IAAI,WAAW,GAAG;AAC3B,aAAK,SAAS;AAAA,UACZ,MAAM,IAAI,CAAC;AAAA,UACX,KAAK,IAAI,CAAC;AAAA,QACZ,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;AAEA,MAAM,YAAY;AAClB,MAAM,eAAe;AAErB,eAAe;",
6
+ "names": []
7
+ }
@@ -7,6 +7,7 @@
7
7
  left: 0 !important;
8
8
  right: 0;
9
9
  bottom: 0;
10
+ // stylelint-disable
10
11
  top: auto !important;
11
12
  border: 1px solid #e8e8e8;
12
13
  }
@@ -1,10 +1,12 @@
1
+ @use "../../themes/default/variables";
2
+
1
3
  .rs-popup {
2
4
  position: absolute;
3
5
 
4
6
  .rs-popup-container {
5
7
  position: absolute;
6
8
  background-color: white;
7
- filter: drop-shadow($box-shadow);
9
+ filter: drop-shadow(variables.$box-shadow);
8
10
  bottom: 12px;
9
11
  left: -50px;
10
12
  min-width: 220px;
@@ -1,3 +1 @@
1
- export { default } from './Popup';
2
-
3
- //# sourceMappingURL=index.js.map
1
+ export { default } from "./Popup";
@@ -1 +1,7 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/Popup/index.js"],"sourcesContent":["export { default } from './Popup';\n"],"names":[],"mappings":"AAAA,SAAS,OAAO,QAAQ,SAAS,CAAC;"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/Popup/index.js"],
4
+ "sourcesContent": ["export { default } from \"./Popup\";\n"],
5
+ "mappings": "AAAA,SAAS,eAAe;",
6
+ "names": []
7
+ }