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.
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js +262 -0
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +7 -0
- package/components/BaseLayerSwitcher/index.js +1 -0
- package/components/BaseLayerSwitcher/index.js.map +7 -0
- package/{src/components → components}/BasicMap/BasicMap.js +80 -170
- package/components/BasicMap/BasicMap.js.map +7 -0
- package/components/BasicMap/index.js +1 -0
- package/components/BasicMap/index.js.map +7 -0
- package/{src/components → components}/CanvasSaveButton/CanvasSaveButton.js +133 -278
- package/components/CanvasSaveButton/CanvasSaveButton.js.map +7 -0
- package/components/CanvasSaveButton/index.js +1 -0
- package/components/CanvasSaveButton/index.js.map +7 -0
- package/{src/components → components}/Copyright/Copyright.js +21 -41
- package/components/Copyright/Copyright.js.map +7 -0
- package/components/Copyright/index.js +1 -0
- package/components/Copyright/index.js.map +7 -0
- package/components/FeatureExportButton/FeatureExportButton.js +80 -0
- package/components/FeatureExportButton/FeatureExportButton.js.map +7 -0
- package/components/FeatureExportButton/index.js +1 -0
- package/components/FeatureExportButton/index.js.map +7 -0
- package/{src/components → components}/FitExtent/FitExtent.js +16 -30
- package/components/FitExtent/FitExtent.js.map +7 -0
- package/components/FitExtent/index.js +1 -0
- package/components/FitExtent/index.js.map +7 -0
- package/{src/components → components}/Geolocation/Geolocation.js +60 -110
- package/components/Geolocation/Geolocation.js.map +7 -0
- package/components/Geolocation/index.js +1 -0
- package/components/Geolocation/index.js.map +7 -0
- package/{src/components → components}/LayerTree/LayerTree.js +113 -213
- package/components/LayerTree/LayerTree.js.map +7 -0
- package/components/LayerTree/index.js +1 -0
- package/components/LayerTree/index.js.map +7 -0
- package/{src/components → components}/MousePosition/MousePosition.js +37 -70
- package/components/MousePosition/MousePosition.js.map +7 -0
- package/components/MousePosition/index.js +1 -0
- package/components/MousePosition/index.js.map +7 -0
- package/{src/components → components}/NorthArrow/NorthArrow.js +18 -34
- package/components/NorthArrow/NorthArrow.js.map +7 -0
- package/components/NorthArrow/index.js +1 -0
- package/components/NorthArrow/index.js.map +7 -0
- package/{src/components → components}/Overlay/Overlay.js +59 -85
- package/components/Overlay/Overlay.js.map +7 -0
- package/components/Overlay/index.js +1 -0
- package/components/Overlay/index.js.map +7 -0
- package/{src/components → components}/Permalink/Permalink.js +64 -147
- package/components/Permalink/Permalink.js.map +7 -0
- package/components/Permalink/index.js +1 -0
- package/components/Permalink/index.js.map +7 -0
- package/{src/components → components}/Popup/Popup.js +57 -116
- package/components/Popup/Popup.js.map +7 -0
- package/components/Popup/index.js +1 -0
- package/components/Popup/index.js.map +7 -0
- package/{src/components → components}/ResizeHandler/ResizeHandler.js +15 -49
- package/components/ResizeHandler/ResizeHandler.js.map +7 -0
- package/components/ResizeHandler/index.js +1 -0
- package/components/ResizeHandler/index.js.map +7 -0
- package/components/RouteSchedule/RouteSchedule.js +268 -0
- package/components/RouteSchedule/RouteSchedule.js.map +7 -0
- package/components/RouteSchedule/index.js +1 -0
- package/components/RouteSchedule/index.js.map +7 -0
- package/{src/components → components}/ScaleLine/ScaleLine.js +8 -23
- package/components/ScaleLine/ScaleLine.js.map +7 -0
- package/components/ScaleLine/index.js +1 -0
- package/components/ScaleLine/index.js.map +7 -0
- package/{src/components → components}/StopsFinder/StopsFinder.js +74 -103
- package/components/StopsFinder/StopsFinder.js.map +7 -0
- package/components/StopsFinder/StopsFinderOption.js +44 -0
- package/components/StopsFinder/StopsFinderOption.js.map +7 -0
- package/components/StopsFinder/index.js +1 -0
- package/components/StopsFinder/index.js.map +7 -0
- package/{src/components → components}/Zoom/Zoom.js +46 -77
- package/components/Zoom/Zoom.js.map +7 -0
- package/components/Zoom/index.js +1 -0
- package/components/Zoom/index.js.map +7 -0
- package/package.json +32 -31
- package/{src/propTypes.js → propTypes.js} +30 -16
- package/propTypes.js.map +7 -0
- package/{src/setupTests.js → setupTests.js} +1 -1
- package/setupTests.js.map +7 -0
- package/utils/GlobalsForOle.js +94 -0
- package/utils/GlobalsForOle.js.map +7 -0
- package/utils/KML.js +420 -0
- package/utils/KML.js.map +7 -0
- package/{src/utils → utils}/KMLFormat.js +29 -32
- package/utils/KMLFormat.js.map +7 -0
- package/{src/utils → utils}/Styles.js +14 -20
- package/utils/Styles.js.map +7 -0
- package/{src/utils → utils}/getPolygonPattern.js +6 -34
- package/utils/getPolygonPattern.js.map +7 -0
- package/{src/utils → utils}/timeUtils.js +5 -22
- package/utils/timeUtils.js.map +7 -0
- package/.github/workflows/conventional-pr-title.yml +0 -21
- package/.github/workflows/main.yml +0 -28
- package/.husky/commit-msg +0 -4
- package/.husky/post-checkout +0 -4
- package/.husky/post-merge +0 -4
- package/.husky/post-rebase +0 -4
- package/.husky/pre-commit +0 -4
- package/.nvmrc +0 -1
- package/.whitesource +0 -8
- package/CHANGELOG.md +0 -65
- package/DEVELOP.md +0 -113
- package/__mocks__/mapbox-gl.js +0 -11
- package/__mocks__/resize-observer-polyfill.js +0 -9
- package/babel.config.js +0 -3
- package/commitlint.config.js +0 -1
- package/data/topic1.js +0 -119
- package/data/topic2.js +0 -28
- package/doc/README.md +0 -21
- package/doc/doc-config.json +0 -4
- package/pull_request_template.md +0 -16
- package/renovate.json +0 -4
- package/scripts/read-pkg-json.js +0 -17
- package/src/components/BaseLayerSwitcher/BaseLayerSwitcher.js +0 -322
- package/src/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js +0 -69
- package/src/components/BaseLayerSwitcher/README.md +0 -61
- package/src/components/BaseLayerSwitcher/__snapshots__/BaseLayerSwitcher.test.js.snap +0 -88
- package/src/components/BaseLayerSwitcher/index.js +0 -1
- package/src/components/BasicMap/BasicMap.test.js +0 -281
- package/src/components/BasicMap/README.md +0 -18
- package/src/components/BasicMap/index.js +0 -1
- package/src/components/CanvasSaveButton/CanvasSaveButton.test.js +0 -148
- package/src/components/CanvasSaveButton/README.md +0 -76
- package/src/components/CanvasSaveButton/__snapshots__/CanvasSaveButton.test.js.snap +0 -76
- package/src/components/CanvasSaveButton/index.js +0 -1
- package/src/components/Copyright/Copyright.test.js +0 -134
- package/src/components/Copyright/README.md +0 -36
- package/src/components/Copyright/index.js +0 -1
- package/src/components/FeatureExportButton/FeatureExportButton.js +0 -118
- package/src/components/FeatureExportButton/FeatureExportButton.test.js +0 -417
- package/src/components/FeatureExportButton/README.md +0 -76
- package/src/components/FeatureExportButton/__snapshots__/FeatureExportButton.test.js.snap +0 -67
- package/src/components/FeatureExportButton/index.js +0 -1
- package/src/components/FitExtent/FitExtent.test.js +0 -48
- package/src/components/FitExtent/README.md +0 -34
- package/src/components/FitExtent/__snapshots__/FitExtent.test.js.snap +0 -13
- package/src/components/FitExtent/index.js +0 -1
- package/src/components/Geolocation/Geolocation.test.js +0 -267
- package/src/components/Geolocation/README.md +0 -25
- package/src/components/Geolocation/__snapshots__/Geolocation.test.js.snap +0 -92
- package/src/components/Geolocation/index.js +0 -1
- package/src/components/LayerTree/LayerTree.test.js +0 -337
- package/src/components/LayerTree/README.md +0 -92
- package/src/components/LayerTree/__snapshots__/LayerTree.test.js.snap +0 -1746
- package/src/components/LayerTree/index.js +0 -1
- package/src/components/MousePosition/MousePosition.test.js +0 -132
- package/src/components/MousePosition/README.md +0 -50
- package/src/components/MousePosition/__snapshots__/MousePosition.test.js.snap +0 -76
- package/src/components/MousePosition/index.js +0 -1
- package/src/components/NorthArrow/NorthArrow.test.js +0 -104
- package/src/components/NorthArrow/README.md +0 -59
- package/src/components/NorthArrow/__snapshots__/NorthArrow.test.js.snap +0 -117
- package/src/components/NorthArrow/index.js +0 -1
- package/src/components/Overlay/Overlay.test.js +0 -149
- package/src/components/Overlay/README.md +0 -59
- package/src/components/Overlay/__snapshots__/Overlay.test.js.snap +0 -9
- package/src/components/Overlay/index.js +0 -1
- package/src/components/Permalink/Permalink.test.js +0 -285
- package/src/components/Permalink/README.md +0 -105
- package/src/components/Permalink/index.js +0 -1
- package/src/components/Popup/Popup.test.js +0 -307
- package/src/components/Popup/README.md +0 -93
- package/src/components/Popup/__snapshots__/Popup.test.js.snap +0 -180
- package/src/components/Popup/index.js +0 -1
- package/src/components/README.md +0 -41
- package/src/components/ResizeHandler/ResizeHandler.test.js +0 -344
- package/src/components/ResizeHandler/index.js +0 -1
- package/src/components/RouteSchedule/README.md +0 -118
- package/src/components/RouteSchedule/RouteSchedule.js +0 -370
- package/src/components/RouteSchedule/RouteSchedule.test.js +0 -113
- package/src/components/RouteSchedule/__snapshots__/RouteSchedule.test.js.snap +0 -248
- package/src/components/RouteSchedule/index.js +0 -1
- package/src/components/ScaleLine/README.md +0 -29
- package/src/components/ScaleLine/ScaleLine.test.js +0 -30
- package/src/components/ScaleLine/__snapshots__/ScaleLine.test.js.snap +0 -7
- package/src/components/ScaleLine/index.js +0 -1
- package/src/components/StopsFinder/README.md +0 -50
- package/src/components/StopsFinder/StopsFinder.test.js +0 -17
- package/src/components/StopsFinder/StopsFinderOption.js +0 -61
- package/src/components/StopsFinder/__snapshots__/StopsFinder.test.js.snap +0 -133
- package/src/components/StopsFinder/index.js +0 -1
- package/src/components/Zoom/README.md +0 -25
- package/src/components/Zoom/Zoom.test.js +0 -141
- package/src/components/Zoom/__snapshots__/Zoom.test.js.snap +0 -201
- package/src/components/Zoom/index.js +0 -1
- package/src/styleguidist/ComponentsList.js +0 -52
- package/src/styleguidist/StyleGuide.js +0 -277
- package/src/styleguidist/styleguidist.css +0 -38
- package/src/utils/GlobalsForOle.js +0 -99
- package/src/utils/KML.js +0 -594
- package/src/utils/KML.test.js +0 -337
- package/src/utils/KMLFormat.test.js +0 -50
- 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
- package/src/utils/__snapshots__/getPolygonPattern.test.js.snap.getPolygonPattern()-render-pattern-2-(cross)-color-and-(light-blue)-opacity.canvas-image.png +0 -0
- 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
- 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
- package/src/utils/getPolygonPattern.test.js +0 -61
- package/src/utils/timeUtils.test.js +0 -30
- package/styleguide.config.js +0 -251
- /package/{src/components → components}/BaseLayerSwitcher/BaseLayerSwitcher.md.scss +0 -0
- /package/{src/components → components}/BaseLayerSwitcher/BaseLayerSwitcher.scss +0 -0
- /package/{src/components → components}/BasicMap/BasicMap.md.scss +0 -0
- /package/{src/components → components}/CanvasSaveButton/CanvasSaveButton.md.scss +0 -0
- /package/{src/components → components}/Copyright/Copyright.md.scss +0 -0
- /package/{src/components → components}/FeatureExportButton/FeatureExportButton.md.scss +0 -0
- /package/{src/components → components}/FitExtent/FitExtent.md.scss +0 -0
- /package/{src/components → components}/Geolocation/Geolocation.md.scss +0 -0
- /package/{src/components → components}/Geolocation/Geolocation.scss +0 -0
- /package/{src/components → components}/LayerTree/LayerTree.md.scss +0 -0
- /package/{src/components → components}/LayerTree/LayerTree.scss +0 -0
- /package/{src/components → components}/MousePosition/MousePosition.md.scss +0 -0
- /package/{src/components → components}/NorthArrow/NorthArrow.scss +0 -0
- /package/{src/components → components}/Overlay/Overlay.md.scss +0 -0
- /package/{src/components → components}/Overlay/Overlay.scss +0 -0
- /package/{src/components → components}/Permalink/Permalink.md.scss +0 -0
- /package/{src/components → components}/Popup/Popup.md.scss +0 -0
- /package/{src/components → components}/Popup/Popup.scss +0 -0
- /package/{src/components → components}/RouteSchedule/RouteSchedule.md.scss +0 -0
- /package/{src/components → components}/RouteSchedule/RouteSchedule.scss +0 -0
- /package/{src/components → components}/ScaleLine/ScaleLine.scss +0 -0
- /package/{src/components → components}/Zoom/Zoom.md.scss +0 -0
- /package/{src/components → components}/Zoom/Zoom.scss +0 -0
- /package/{src/images → images}/RouteSchedule/firstStation.png +0 -0
- /package/{src/images → images}/RouteSchedule/lastStation.png +0 -0
- /package/{src/images → images}/RouteSchedule/line.png +0 -0
- /package/{src/images → images}/RouteSchedule/station.png +0 -0
- /package/{src/images → images}/baselayer/baselayer.basebright.png +0 -0
- /package/{src/images → images}/baselayer/baselayer.osm.png +0 -0
- /package/{src/images → images}/baselayer/baselayer.travic.png +0 -0
- /package/{src/images → images}/baselayer/open.topo.map.png +0 -0
- /package/{src/images → images}/baselayer/osm.baselayer.hot.png +0 -0
- /package/{src/images → images}/baselayer/osm.baselayer.png +0 -0
- /package/{src/images → images}/favicon.png +0 -0
- /package/{src/images → images}/geops_logo.png +0 -0
- /package/{src/images → images}/geops_logo.svg +0 -0
- /package/{src/images → images}/geops_qr.png +0 -0
- /package/{src/images → images}/mots/bus_poi-blue-01.svg +0 -0
- /package/{src/images → images}/mots/bus_poi-grey-01.svg +0 -0
- /package/{src/images → images}/mots/bus_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/bus_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/bus_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/bus_square-grey-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_poi-blue-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_poi-grey-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_square-grey-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_poi-blue-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_poi-grey-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_square-grey-01.svg +0 -0
- /package/{src/images → images}/mots/funicular_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/funicular_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/funicular_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/gondola_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/rail_poi-blue-01.svg +0 -0
- /package/{src/images → images}/mots/rail_poi-grey-01.svg +0 -0
- /package/{src/images → images}/mots/rail_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/rail_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/rail_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/rail_square-grey-01.svg +0 -0
- /package/{src/images → images}/mots/subway_round blue-01.svg +0 -0
- /package/{src/images → images}/mots/subway_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/tram_poi-blue-01.svg +0 -0
- /package/{src/images → images}/mots/tram_poi-grey-01.svg +0 -0
- /package/{src/images → images}/mots/tram_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/tram_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/tram_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/tram_square-grey-01.svg +0 -0
- /package/{src/images → images}/northArrow.svg +0 -0
- /package/{src/images → images}/northArrow.url.svg +0 -0
- /package/{src/images → images}/northArrowCircle.svg +0 -0
- /package/{src/images → images}/northArrowCircle.url.svg +0 -0
- /package/{src/themes → themes}/README.md +0 -0
- /package/{src/themes → themes}/default/components.scss +0 -0
- /package/{src/themes → themes}/default/examples.scss +0 -0
- /package/{src/themes → themes}/default/index.scss +0 -0
- /package/{src/themes → themes}/default/mixins.scss +0 -0
- /package/{src/themes → themes}/default/variables.scss +0 -0
|
@@ -1,233 +1,181 @@
|
|
|
1
|
-
import React, { PureComponent } from
|
|
2
|
-
import PropTypes from
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import { unByKey } from 'ol/Observable';
|
|
9
|
-
|
|
1
|
+
import React, { PureComponent } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { MdClose } from "react-icons/md";
|
|
4
|
+
import OLMap from "ol/Map";
|
|
5
|
+
import Feature from "ol/Feature";
|
|
6
|
+
import { getCenter } from "ol/extent";
|
|
7
|
+
import { unByKey } from "ol/Observable";
|
|
10
8
|
const propTypes = {
|
|
11
9
|
/**
|
|
12
10
|
* React Children.
|
|
13
11
|
*/
|
|
14
12
|
children: PropTypes.node.isRequired,
|
|
15
|
-
|
|
16
13
|
/**
|
|
17
14
|
* An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
|
|
18
15
|
*/
|
|
19
16
|
map: PropTypes.instanceOf(OLMap).isRequired,
|
|
20
|
-
|
|
21
17
|
/**
|
|
22
18
|
* An [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).
|
|
23
19
|
*/
|
|
24
20
|
feature: PropTypes.instanceOf(Feature),
|
|
25
|
-
|
|
26
21
|
/**
|
|
27
22
|
* Popup title.
|
|
28
23
|
*/
|
|
29
24
|
header: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
30
|
-
|
|
31
25
|
/**
|
|
32
26
|
* If true, the popup is panned in the map's viewport.
|
|
33
27
|
*/
|
|
34
28
|
panIntoView: PropTypes.bool,
|
|
35
|
-
|
|
36
29
|
/**
|
|
37
30
|
* Custom BoundingClientRect to fit popup into.
|
|
38
31
|
* Use if panIntoView is true. Default is the map's BoundingClientRect.
|
|
39
32
|
*/
|
|
40
33
|
panRect: PropTypes.objectOf(PropTypes.number),
|
|
41
|
-
|
|
42
34
|
/**
|
|
43
35
|
* Coordinate position of the popup.
|
|
44
36
|
*/
|
|
45
37
|
popupCoordinate: PropTypes.arrayOf(PropTypes.number),
|
|
46
|
-
|
|
47
38
|
/**
|
|
48
39
|
* Class name of the popup.
|
|
49
40
|
*/
|
|
50
41
|
className: PropTypes.string,
|
|
51
|
-
|
|
52
42
|
/**
|
|
53
43
|
* Title HTML attributes.
|
|
54
44
|
*/
|
|
55
45
|
titles: PropTypes.shape({
|
|
56
|
-
closeButton: PropTypes.string
|
|
46
|
+
closeButton: PropTypes.string
|
|
57
47
|
}),
|
|
58
|
-
|
|
59
48
|
/**
|
|
60
49
|
* Function triggered on close button click.
|
|
61
50
|
*/
|
|
62
51
|
onCloseClick: PropTypes.func,
|
|
63
|
-
|
|
64
52
|
/**
|
|
65
53
|
* HTML tabIndex attribute.
|
|
66
54
|
*/
|
|
67
55
|
tabIndex: PropTypes.string,
|
|
68
|
-
|
|
69
56
|
/**
|
|
70
57
|
* Render the header
|
|
71
58
|
*/
|
|
72
59
|
renderHeader: PropTypes.func,
|
|
73
|
-
|
|
74
60
|
/**
|
|
75
61
|
* Render the close button
|
|
76
62
|
*/
|
|
77
63
|
renderCloseButton: PropTypes.func,
|
|
78
|
-
|
|
79
64
|
/**
|
|
80
65
|
* Render the footer
|
|
81
66
|
*/
|
|
82
|
-
renderFooter: PropTypes.func
|
|
67
|
+
renderFooter: PropTypes.func
|
|
83
68
|
};
|
|
84
|
-
|
|
85
69
|
const defaultProps = {
|
|
86
70
|
header: null,
|
|
87
71
|
feature: null,
|
|
88
72
|
panIntoView: false,
|
|
89
73
|
panRect: null,
|
|
90
74
|
popupCoordinate: null,
|
|
91
|
-
className:
|
|
92
|
-
tabIndex:
|
|
93
|
-
titles: { closeButton:
|
|
94
|
-
onCloseClick: () => {
|
|
75
|
+
className: "rs-popup",
|
|
76
|
+
tabIndex: "",
|
|
77
|
+
titles: { closeButton: "Close" },
|
|
78
|
+
onCloseClick: () => {
|
|
79
|
+
},
|
|
95
80
|
renderHeader: null,
|
|
96
81
|
renderCloseButton: null,
|
|
97
82
|
renderFooter: () => {
|
|
98
83
|
return null;
|
|
99
|
-
}
|
|
84
|
+
}
|
|
100
85
|
};
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* The Popup component renders a popup over an
|
|
104
|
-
* [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html)
|
|
105
|
-
* on click.
|
|
106
|
-
*/
|
|
107
86
|
class Popup extends PureComponent {
|
|
108
87
|
static renderHeader(props) {
|
|
109
88
|
const { header, renderCloseButton } = props;
|
|
110
|
-
return (
|
|
111
|
-
<div className="rs-popup-header">
|
|
112
|
-
{header}
|
|
113
|
-
{(renderCloseButton || Popup.renderCloseButton)(props)}
|
|
114
|
-
</div>
|
|
115
|
-
);
|
|
89
|
+
return /* @__PURE__ */ React.createElement("div", { className: "rs-popup-header" }, header, (renderCloseButton || Popup.renderCloseButton)(props));
|
|
116
90
|
}
|
|
117
|
-
|
|
118
91
|
static renderCloseButton({ onCloseClick, titles }) {
|
|
119
|
-
return (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
92
|
+
return /* @__PURE__ */ React.createElement(
|
|
93
|
+
"div",
|
|
94
|
+
{
|
|
95
|
+
role: "button",
|
|
96
|
+
tabIndex: 0,
|
|
97
|
+
className: "rs-popup-close-bt",
|
|
98
|
+
title: titles.closeButton,
|
|
99
|
+
"aria-label": titles.closeButton,
|
|
100
|
+
onClick: () => {
|
|
127
101
|
return onCloseClick();
|
|
128
|
-
}
|
|
129
|
-
onKeyPress
|
|
102
|
+
},
|
|
103
|
+
onKeyPress: (evt) => {
|
|
130
104
|
return evt.which === 13 && onCloseClick();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
</div>
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
/* @__PURE__ */ React.createElement(MdClose, { focusable: false })
|
|
135
108
|
);
|
|
136
109
|
}
|
|
137
|
-
|
|
138
110
|
constructor(props) {
|
|
139
111
|
super(props);
|
|
140
112
|
this.state = {
|
|
141
113
|
popupElement: null,
|
|
142
114
|
top: 0,
|
|
143
|
-
left: 0
|
|
115
|
+
left: 0
|
|
144
116
|
};
|
|
145
117
|
this.postrenderKey = null;
|
|
146
118
|
}
|
|
147
|
-
|
|
148
119
|
componentDidMount() {
|
|
149
120
|
const { map } = this.props;
|
|
150
121
|
this.updatePixelPosition();
|
|
151
|
-
|
|
152
|
-
this.postrenderKey = map.on('postrender', () => {
|
|
122
|
+
this.postrenderKey = map.on("postrender", () => {
|
|
153
123
|
this.updatePixelPosition();
|
|
154
124
|
});
|
|
155
125
|
}
|
|
156
|
-
|
|
157
126
|
componentDidUpdate(prevProps, prevState) {
|
|
158
127
|
const { feature, panIntoView, popupCoordinate } = this.props;
|
|
159
128
|
const { popupElement } = this.state;
|
|
160
|
-
if (
|
|
161
|
-
feature !== prevProps.feature ||
|
|
162
|
-
popupCoordinate !== prevProps.popupCoordinate
|
|
163
|
-
) {
|
|
129
|
+
if (feature !== prevProps.feature || popupCoordinate !== prevProps.popupCoordinate) {
|
|
164
130
|
this.updatePixelPosition();
|
|
165
131
|
}
|
|
166
|
-
|
|
167
|
-
if (
|
|
168
|
-
panIntoView &&
|
|
169
|
-
popupElement &&
|
|
170
|
-
popupElement !== prevState.popupElement
|
|
171
|
-
) {
|
|
132
|
+
if (panIntoView && popupElement && popupElement !== prevState.popupElement) {
|
|
172
133
|
this.panIntoView();
|
|
173
134
|
}
|
|
174
135
|
}
|
|
175
|
-
|
|
176
136
|
componentWillUnmount() {
|
|
177
137
|
unByKey(this.postrenderKey);
|
|
178
138
|
}
|
|
179
|
-
|
|
180
139
|
panIntoView() {
|
|
181
140
|
const { map, panRect } = this.props;
|
|
182
141
|
const { popupElement } = this.state;
|
|
183
|
-
|
|
184
142
|
const mapRect = panRect || map.getTarget().getBoundingClientRect();
|
|
185
143
|
const popupRect = popupElement.getBoundingClientRect();
|
|
186
144
|
const [x, y] = map.getView().getCenter();
|
|
187
145
|
const res = map.getView().getResolution();
|
|
188
146
|
const newCenter = [x, y];
|
|
189
|
-
|
|
190
147
|
if (mapRect.top > popupRect.top) {
|
|
191
148
|
newCenter[1] = y + (mapRect.top - popupRect.top) * res;
|
|
192
149
|
}
|
|
193
|
-
|
|
194
150
|
if (mapRect.left > popupRect.left) {
|
|
195
151
|
newCenter[0] = x - (mapRect.left - popupRect.left) * res;
|
|
196
152
|
}
|
|
197
|
-
|
|
198
153
|
if (mapRect.right < popupRect.right) {
|
|
199
154
|
newCenter[0] = x + (popupRect.right - mapRect.right) * res;
|
|
200
155
|
}
|
|
201
|
-
|
|
202
156
|
if (mapRect.bottom < popupRect.bottom) {
|
|
203
157
|
newCenter[1] = y - (popupRect.bottom - mapRect.bottom) * res;
|
|
204
158
|
}
|
|
205
|
-
|
|
206
159
|
if (newCenter[0] !== x || newCenter[1] !== y) {
|
|
207
160
|
map.getView().animate({ center: newCenter, duration: 500 });
|
|
208
161
|
}
|
|
209
162
|
}
|
|
210
|
-
|
|
211
163
|
updatePixelPosition() {
|
|
212
164
|
const { map, feature, popupCoordinate } = this.props;
|
|
213
165
|
let coord = popupCoordinate;
|
|
214
|
-
|
|
215
166
|
if (feature && !coord) {
|
|
216
167
|
coord = getCenter(feature.getGeometry().getExtent());
|
|
217
168
|
}
|
|
218
|
-
|
|
219
169
|
if (coord) {
|
|
220
170
|
const pos = map.getPixelFromCoordinate(coord);
|
|
221
|
-
|
|
222
171
|
if (pos && pos.length === 2) {
|
|
223
172
|
this.setState({
|
|
224
173
|
left: pos[0],
|
|
225
|
-
top: pos[1]
|
|
174
|
+
top: pos[1]
|
|
226
175
|
});
|
|
227
176
|
}
|
|
228
177
|
}
|
|
229
178
|
}
|
|
230
|
-
|
|
231
179
|
render() {
|
|
232
180
|
const {
|
|
233
181
|
feature,
|
|
@@ -240,51 +188,44 @@ class Popup extends PureComponent {
|
|
|
240
188
|
renderFooter,
|
|
241
189
|
...other
|
|
242
190
|
} = this.props;
|
|
243
|
-
|
|
244
191
|
if (!feature && !popupCoordinate) {
|
|
245
192
|
return null;
|
|
246
193
|
}
|
|
247
|
-
|
|
248
194
|
delete other.panIntoView;
|
|
249
195
|
delete other.panRect;
|
|
250
196
|
delete other.map;
|
|
251
197
|
delete other.header;
|
|
252
198
|
delete other.onCloseClick;
|
|
253
199
|
delete other.renderCloseButton;
|
|
254
|
-
|
|
255
200
|
const { top, left } = this.state;
|
|
256
|
-
|
|
257
|
-
// force re-render if the feature or the coordinate changes.
|
|
258
|
-
// this is needed to update the popupElement ref
|
|
259
201
|
const key = feature ? feature.getId() : popupCoordinate.join();
|
|
260
|
-
return (
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
202
|
+
return /* @__PURE__ */ React.createElement(
|
|
203
|
+
"div",
|
|
204
|
+
{
|
|
205
|
+
className: "rs-popup",
|
|
206
|
+
style: {
|
|
264
207
|
left,
|
|
265
|
-
top
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
208
|
+
top
|
|
209
|
+
},
|
|
210
|
+
...other
|
|
211
|
+
},
|
|
212
|
+
/* @__PURE__ */ React.createElement(
|
|
213
|
+
"div",
|
|
214
|
+
{
|
|
215
|
+
className: "rs-popup-container",
|
|
216
|
+
tabIndex,
|
|
217
|
+
key,
|
|
218
|
+
ref: (popupElement) => {
|
|
275
219
|
this.setState({ popupElement });
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
</div>
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
(renderHeader || Popup.renderHeader)(this.props),
|
|
223
|
+
/* @__PURE__ */ React.createElement("div", { className: "rs-popup-body" }, children),
|
|
224
|
+
renderFooter(this.props)
|
|
225
|
+
)
|
|
283
226
|
);
|
|
284
227
|
}
|
|
285
228
|
}
|
|
286
|
-
|
|
287
229
|
Popup.propTypes = propTypes;
|
|
288
230
|
Popup.defaultProps = defaultProps;
|
|
289
|
-
|
|
290
231
|
export default Popup;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/Popup/Popup.js"],
|
|
4
|
+
"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"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,qBAAqB;AACrC,OAAO,eAAe;AAEtB,SAAS,eAAe;AACxB,OAAO,WAAW;AAClB,OAAO,aAAa;AACpB,SAAS,iBAAiB;AAC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A,SAAS;AACP,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,IAAI,KAAK;AAET,QAAI,CAAC,WAAW,CAAC,iBAAiB;AAChC,aAAO;AAAA,IACT;AAEA,WAAO,MAAM;AACb,WAAO,MAAM;AACb,WAAO,MAAM;AACb,WAAO,MAAM;AACb,WAAO,MAAM;AACb,WAAO,MAAM;AAEb,UAAM,EAAE,KAAK,KAAK,IAAI,KAAK;AAI3B,UAAM,MAAM,UAAU,QAAQ,MAAM,IAAI,gBAAgB,KAAK;AAC7D,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV,OAAO;AAAA,UACL;AAAA,UACA;AAAA,QACF;AAAA,QAEC,GAAG;AAAA;AAAA,MAEJ;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV;AAAA,UACA;AAAA,UACA,KAAK,CAAC,iBAAiB;AACrB,iBAAK,SAAS,EAAE,aAAa,CAAC;AAAA,UAChC;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;AACF;AAEA,MAAM,YAAY;AAClB,MAAM,eAAe;AAErB,eAAe;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./Popup";
|
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
import ReactDOM from
|
|
2
|
-
import { PureComponent, Component } from
|
|
3
|
-
import PropTypes from
|
|
4
|
-
import ResizeObserver from
|
|
5
|
-
|
|
1
|
+
import ReactDOM from "react-dom";
|
|
2
|
+
import { PureComponent, Component } from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import ResizeObserver from "resize-observer-polyfill";
|
|
6
5
|
const propTypes = {
|
|
7
6
|
observe: PropTypes.oneOfType([
|
|
8
7
|
PropTypes.string,
|
|
9
8
|
PropTypes.node,
|
|
10
9
|
PropTypes.instanceOf(Component),
|
|
11
10
|
PropTypes.shape({ current: PropTypes.node }),
|
|
12
|
-
PropTypes.shape({ current: PropTypes.instanceOf(Component) })
|
|
11
|
+
PropTypes.shape({ current: PropTypes.instanceOf(Component) })
|
|
13
12
|
]),
|
|
14
13
|
maxHeightBrkpts: PropTypes.objectOf(PropTypes.number),
|
|
15
14
|
maxWidthBrkpts: PropTypes.objectOf(PropTypes.number),
|
|
16
15
|
stylePropHeight: PropTypes.string,
|
|
17
16
|
onResize: PropTypes.func,
|
|
18
|
-
|
|
19
17
|
// This property is used to re-apply the classes, for example when the className of the observed node changes.
|
|
20
18
|
forceUpdate: PropTypes.oneOfType([
|
|
21
19
|
PropTypes.string,
|
|
22
20
|
PropTypes.number,
|
|
23
|
-
PropTypes.bool
|
|
24
|
-
])
|
|
21
|
+
PropTypes.bool
|
|
22
|
+
])
|
|
25
23
|
};
|
|
26
|
-
|
|
27
|
-
// Same as bootstrap
|
|
28
24
|
const defaultProps = {
|
|
29
25
|
observe: null,
|
|
30
26
|
maxHeightBrkpts: {
|
|
@@ -32,22 +28,19 @@ const defaultProps = {
|
|
|
32
28
|
s: 768,
|
|
33
29
|
m: 992,
|
|
34
30
|
l: 1200,
|
|
35
|
-
xl: Infinity
|
|
31
|
+
xl: Infinity
|
|
36
32
|
},
|
|
37
33
|
maxWidthBrkpts: {
|
|
38
34
|
xs: 576,
|
|
39
35
|
s: 768,
|
|
40
36
|
m: 992,
|
|
41
37
|
l: 1200,
|
|
42
|
-
xl: Infinity
|
|
38
|
+
xl: Infinity
|
|
43
39
|
},
|
|
44
40
|
stylePropHeight: null,
|
|
45
41
|
onResize: null,
|
|
46
|
-
forceUpdate: null
|
|
42
|
+
forceUpdate: null
|
|
47
43
|
};
|
|
48
|
-
/**
|
|
49
|
-
* This component adds css class to an element depending on his size.
|
|
50
|
-
*/
|
|
51
44
|
class ResizeHandler extends PureComponent {
|
|
52
45
|
static applyBreakpoints(entry, breakpoints, size, direction) {
|
|
53
46
|
let found = false;
|
|
@@ -63,7 +56,6 @@ class ResizeHandler extends PureComponent {
|
|
|
63
56
|
});
|
|
64
57
|
return screenSize;
|
|
65
58
|
}
|
|
66
|
-
|
|
67
59
|
constructor(props) {
|
|
68
60
|
super(props);
|
|
69
61
|
this.observer = new ResizeObserver((entries) => {
|
|
@@ -71,54 +63,40 @@ class ResizeHandler extends PureComponent {
|
|
|
71
63
|
});
|
|
72
64
|
this.nodes = [];
|
|
73
65
|
}
|
|
74
|
-
|
|
75
66
|
componentDidMount() {
|
|
76
67
|
this.observe();
|
|
77
68
|
}
|
|
78
|
-
|
|
79
69
|
componentDidUpdate(prevProps) {
|
|
80
70
|
const { observe, forceUpdate } = this.props;
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
observe !== prevProps.observe ||
|
|
84
|
-
forceUpdate !== prevProps.forceUpdate
|
|
85
|
-
) {
|
|
71
|
+
if (observe !== prevProps.observe || forceUpdate !== prevProps.forceUpdate) {
|
|
86
72
|
this.observe();
|
|
87
73
|
}
|
|
88
74
|
}
|
|
89
|
-
|
|
90
75
|
componentWillUnmount() {
|
|
91
76
|
this.observer.disconnect();
|
|
92
77
|
}
|
|
93
|
-
|
|
94
78
|
onResize(entries) {
|
|
95
|
-
const { maxHeightBrkpts, maxWidthBrkpts, stylePropHeight, onResize } =
|
|
96
|
-
this.props;
|
|
97
|
-
|
|
79
|
+
const { maxHeightBrkpts, maxWidthBrkpts, stylePropHeight, onResize } = this.props;
|
|
98
80
|
if (stylePropHeight) {
|
|
99
81
|
const vh = window.innerHeight * 0.01;
|
|
100
82
|
document.documentElement.style.setProperty(stylePropHeight, `${vh}px`);
|
|
101
83
|
}
|
|
102
|
-
|
|
103
84
|
if (!maxWidthBrkpts && !maxHeightBrkpts) {
|
|
104
85
|
onResize(entries);
|
|
105
86
|
return;
|
|
106
87
|
}
|
|
107
|
-
|
|
108
88
|
let newScreenWidth;
|
|
109
89
|
let newScreenHeight;
|
|
110
|
-
|
|
111
90
|
for (let i = 0; i < entries.length; i += 1) {
|
|
112
91
|
const entry = entries[i];
|
|
113
92
|
const rect = entry.contentRect;
|
|
114
93
|
const { height, width } = rect;
|
|
115
|
-
|
|
116
94
|
if (maxWidthBrkpts) {
|
|
117
95
|
newScreenWidth = ResizeHandler.applyBreakpoints(
|
|
118
96
|
entry,
|
|
119
97
|
maxWidthBrkpts,
|
|
120
98
|
width,
|
|
121
|
-
|
|
99
|
+
"w"
|
|
122
100
|
);
|
|
123
101
|
}
|
|
124
102
|
if (maxHeightBrkpts) {
|
|
@@ -126,53 +104,41 @@ class ResizeHandler extends PureComponent {
|
|
|
126
104
|
entry,
|
|
127
105
|
maxHeightBrkpts,
|
|
128
106
|
height,
|
|
129
|
-
|
|
107
|
+
"h"
|
|
130
108
|
);
|
|
131
109
|
}
|
|
132
110
|
}
|
|
133
|
-
|
|
134
111
|
if (onResize) {
|
|
135
112
|
onResize(entries, newScreenWidth, newScreenHeight);
|
|
136
113
|
}
|
|
137
114
|
}
|
|
138
|
-
|
|
139
115
|
observe() {
|
|
140
116
|
this.observer.disconnect();
|
|
141
117
|
const { observe } = this.props;
|
|
142
|
-
|
|
143
118
|
if (!observe) {
|
|
144
119
|
return;
|
|
145
120
|
}
|
|
146
|
-
|
|
147
|
-
if (typeof observe === 'string' || observe instanceof String) {
|
|
121
|
+
if (typeof observe === "string" || observe instanceof String) {
|
|
148
122
|
this.nodes = document.querySelectorAll(observe);
|
|
149
123
|
} else if (observe instanceof Component) {
|
|
150
|
-
// eslint-disable-next-line react/no-find-dom-node
|
|
151
124
|
this.nodes.push(ReactDOM.findDOMNode(observe));
|
|
152
125
|
} else if (observe instanceof Element) {
|
|
153
126
|
this.nodes.push(observe);
|
|
154
127
|
} else if (observe.current instanceof Element) {
|
|
155
|
-
// observe value created with React.createRef() on a html node.
|
|
156
128
|
this.nodes.push(observe.current);
|
|
157
129
|
} else if (observe.current instanceof Component) {
|
|
158
|
-
// observe value created with React.createRef() on a React component.
|
|
159
|
-
// eslint-disable-next-line react/no-find-dom-node
|
|
160
130
|
this.nodes.push(ReactDOM.findDOMNode(observe.current));
|
|
161
131
|
}
|
|
162
|
-
|
|
163
132
|
if (this.nodes.length) {
|
|
164
133
|
this.nodes.forEach((node) => {
|
|
165
134
|
return this.observer.observe(node);
|
|
166
135
|
});
|
|
167
136
|
}
|
|
168
137
|
}
|
|
169
|
-
|
|
170
138
|
render() {
|
|
171
139
|
return null;
|
|
172
140
|
}
|
|
173
141
|
}
|
|
174
|
-
|
|
175
142
|
ResizeHandler.propTypes = propTypes;
|
|
176
143
|
ResizeHandler.defaultProps = defaultProps;
|
|
177
|
-
|
|
178
144
|
export default ResizeHandler;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/ResizeHandler/ResizeHandler.js"],
|
|
4
|
+
"sourcesContent": ["import ReactDOM from 'react-dom';\nimport { PureComponent, Component } from 'react';\nimport PropTypes from 'prop-types';\nimport ResizeObserver from 'resize-observer-polyfill';\n\nconst propTypes = {\n observe: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.node,\n PropTypes.instanceOf(Component),\n PropTypes.shape({ current: PropTypes.node }),\n PropTypes.shape({ current: PropTypes.instanceOf(Component) }),\n ]),\n maxHeightBrkpts: PropTypes.objectOf(PropTypes.number),\n maxWidthBrkpts: PropTypes.objectOf(PropTypes.number),\n stylePropHeight: PropTypes.string,\n onResize: PropTypes.func,\n\n // This property is used to re-apply the classes, for example when the className of the observed node changes.\n forceUpdate: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.number,\n PropTypes.bool,\n ]),\n};\n\n// Same as bootstrap\nconst defaultProps = {\n observe: null,\n maxHeightBrkpts: {\n xs: 576,\n s: 768,\n m: 992,\n l: 1200,\n xl: Infinity,\n },\n maxWidthBrkpts: {\n xs: 576,\n s: 768,\n m: 992,\n l: 1200,\n xl: Infinity,\n },\n stylePropHeight: null,\n onResize: null,\n forceUpdate: null,\n};\n/**\n * This component adds css class to an element depending on his size.\n */\nclass ResizeHandler extends PureComponent {\n static applyBreakpoints(entry, breakpoints, size, direction) {\n let found = false;\n let screenSize;\n Object.entries(breakpoints).forEach((brkpt) => {\n const cssClass = `rs-${direction}-${brkpt[0]}`;\n entry.target.classList.remove(cssClass);\n if (!found && size <= brkpt[1]) {\n found = true;\n [screenSize] = brkpt;\n entry.target.classList.add(cssClass);\n }\n });\n return screenSize;\n }\n\n constructor(props) {\n super(props);\n this.observer = new ResizeObserver((entries) => {\n return this.onResize(entries);\n });\n this.nodes = [];\n }\n\n componentDidMount() {\n this.observe();\n }\n\n componentDidUpdate(prevProps) {\n const { observe, forceUpdate } = this.props;\n\n if (\n observe !== prevProps.observe ||\n forceUpdate !== prevProps.forceUpdate\n ) {\n this.observe();\n }\n }\n\n componentWillUnmount() {\n this.observer.disconnect();\n }\n\n onResize(entries) {\n const { maxHeightBrkpts, maxWidthBrkpts, stylePropHeight, onResize } =\n this.props;\n\n if (stylePropHeight) {\n const vh = window.innerHeight * 0.01;\n document.documentElement.style.setProperty(stylePropHeight, `${vh}px`);\n }\n\n if (!maxWidthBrkpts && !maxHeightBrkpts) {\n onResize(entries);\n return;\n }\n\n let newScreenWidth;\n let newScreenHeight;\n\n for (let i = 0; i < entries.length; i += 1) {\n const entry = entries[i];\n const rect = entry.contentRect;\n const { height, width } = rect;\n\n if (maxWidthBrkpts) {\n newScreenWidth = ResizeHandler.applyBreakpoints(\n entry,\n maxWidthBrkpts,\n width,\n 'w',\n );\n }\n if (maxHeightBrkpts) {\n newScreenHeight = ResizeHandler.applyBreakpoints(\n entry,\n maxHeightBrkpts,\n height,\n 'h',\n );\n }\n }\n\n if (onResize) {\n onResize(entries, newScreenWidth, newScreenHeight);\n }\n }\n\n observe() {\n this.observer.disconnect();\n const { observe } = this.props;\n\n if (!observe) {\n return;\n }\n\n if (typeof observe === 'string' || observe instanceof String) {\n this.nodes = document.querySelectorAll(observe);\n } else if (observe instanceof Component) {\n // eslint-disable-next-line react/no-find-dom-node\n this.nodes.push(ReactDOM.findDOMNode(observe));\n } else if (observe instanceof Element) {\n this.nodes.push(observe);\n } else if (observe.current instanceof Element) {\n // observe value created with React.createRef() on a html node.\n this.nodes.push(observe.current);\n } else if (observe.current instanceof Component) {\n // observe value created with React.createRef() on a React component.\n // eslint-disable-next-line react/no-find-dom-node\n this.nodes.push(ReactDOM.findDOMNode(observe.current));\n }\n\n if (this.nodes.length) {\n this.nodes.forEach((node) => {\n return this.observer.observe(node);\n });\n }\n }\n\n render() {\n return null;\n }\n}\n\nResizeHandler.propTypes = propTypes;\nResizeHandler.defaultProps = defaultProps;\n\nexport default ResizeHandler;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,cAAc;AACrB,SAAS,eAAe,iBAAiB;AACzC,OAAO,eAAe;AACtB,OAAO,oBAAoB;AAE3B,MAAM,YAAY;AAAA,EAChB,SAAS,UAAU,UAAU;AAAA,IAC3B,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU,WAAW,SAAS;AAAA,IAC9B,UAAU,MAAM,EAAE,SAAS,UAAU,KAAK,CAAC;AAAA,IAC3C,UAAU,MAAM,EAAE,SAAS,UAAU,WAAW,SAAS,EAAE,CAAC;AAAA,EAC9D,CAAC;AAAA,EACD,iBAAiB,UAAU,SAAS,UAAU,MAAM;AAAA,EACpD,gBAAgB,UAAU,SAAS,UAAU,MAAM;AAAA,EACnD,iBAAiB,UAAU;AAAA,EAC3B,UAAU,UAAU;AAAA;AAAA,EAGpB,aAAa,UAAU,UAAU;AAAA,IAC/B,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,EACZ,CAAC;AACH;AAGA,MAAM,eAAe;AAAA,EACnB,SAAS;AAAA,EACT,iBAAiB;AAAA,IACf,IA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