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,15 +1,13 @@
|
|
|
1
|
-
import React, { useState, useRef, useEffect, useCallback } from
|
|
2
|
-
import PropTypes from
|
|
3
|
-
import OLMap from
|
|
4
|
-
import { createStringXY } from
|
|
5
|
-
import OLMousePosition from
|
|
6
|
-
|
|
1
|
+
import React, { useState, useRef, useEffect, useCallback } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import OLMap from "ol/Map";
|
|
4
|
+
import { createStringXY } from "ol/coordinate";
|
|
5
|
+
import OLMousePosition from "ol/control/MousePosition";
|
|
7
6
|
const propTypes = {
|
|
8
7
|
/**
|
|
9
8
|
* An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
|
|
10
9
|
*/
|
|
11
10
|
map: PropTypes.instanceOf(OLMap).isRequired,
|
|
12
|
-
|
|
13
11
|
/**
|
|
14
12
|
* List of projections to display.
|
|
15
13
|
*/
|
|
@@ -19,20 +17,17 @@ const propTypes = {
|
|
|
19
17
|
* The label to display in the select box.
|
|
20
18
|
*/
|
|
21
19
|
label: PropTypes.string.isRequired,
|
|
22
|
-
|
|
23
20
|
/**
|
|
24
21
|
* The value used to create the options´s projection of the MousePosition control.
|
|
25
22
|
* See [doc](https://openlayers.org/en/latest/apidoc/module-ol_control_MousePosition.html).
|
|
26
23
|
*/
|
|
27
24
|
value: PropTypes.string.isRequired,
|
|
28
|
-
|
|
29
25
|
/**
|
|
30
26
|
* A function following the [CoordinateFormat](https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html#~CoordinateFormat).
|
|
31
27
|
*/
|
|
32
|
-
format: PropTypes.func
|
|
33
|
-
})
|
|
28
|
+
format: PropTypes.func
|
|
29
|
+
})
|
|
34
30
|
),
|
|
35
|
-
|
|
36
31
|
/**
|
|
37
32
|
* The initially selected projection
|
|
38
33
|
*/
|
|
@@ -41,46 +36,38 @@ const propTypes = {
|
|
|
41
36
|
* The label to display in the select box.
|
|
42
37
|
*/
|
|
43
38
|
label: PropTypes.string.isRequired,
|
|
44
|
-
|
|
45
39
|
/**
|
|
46
40
|
* The value used to create the options´s projection of the MousePosition control.
|
|
47
41
|
* See [doc](https://openlayers.org/en/latest/apidoc/module-ol_control_MousePosition.html).
|
|
48
42
|
*/
|
|
49
43
|
value: PropTypes.string.isRequired,
|
|
50
|
-
|
|
51
44
|
/**
|
|
52
45
|
* A function following the [CoordinateFormat](https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html#~CoordinateFormat).
|
|
53
46
|
*/
|
|
54
|
-
format: PropTypes.func
|
|
47
|
+
format: PropTypes.func
|
|
55
48
|
}),
|
|
56
|
-
|
|
57
49
|
/**
|
|
58
50
|
* Function triggered on projection's change event.
|
|
59
51
|
* @param {Event} event The change event object.
|
|
60
52
|
* @param {Object} projection The selected projection object.
|
|
61
53
|
*/
|
|
62
|
-
onChange: PropTypes.func
|
|
54
|
+
onChange: PropTypes.func
|
|
63
55
|
};
|
|
64
|
-
|
|
65
56
|
const defaultProps = {
|
|
66
|
-
onChange: () => {
|
|
57
|
+
onChange: () => {
|
|
58
|
+
},
|
|
67
59
|
projections: [
|
|
68
60
|
{
|
|
69
|
-
label:
|
|
70
|
-
value:
|
|
61
|
+
label: "EPSG:4326",
|
|
62
|
+
value: "EPSG:4326"
|
|
71
63
|
},
|
|
72
64
|
{
|
|
73
|
-
label:
|
|
74
|
-
value:
|
|
75
|
-
}
|
|
65
|
+
label: "EPSG:3857",
|
|
66
|
+
value: "EPSG:3857"
|
|
67
|
+
}
|
|
76
68
|
],
|
|
77
|
-
projectionValue: null
|
|
69
|
+
projectionValue: null
|
|
78
70
|
};
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* The MousePosition component renders a select box with map projection options
|
|
82
|
-
* and the cursor position in coordinates using the selected projection.
|
|
83
|
-
*/
|
|
84
71
|
function MousePosition({
|
|
85
72
|
map,
|
|
86
73
|
projections,
|
|
@@ -89,30 +76,24 @@ function MousePosition({
|
|
|
89
76
|
...other
|
|
90
77
|
}) {
|
|
91
78
|
const [projection, setProjection] = useState(
|
|
92
|
-
projections &&
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return p.value === projectionValue.value;
|
|
96
|
-
})) ||
|
|
97
|
-
projections[0]),
|
|
79
|
+
projections && (projectionValue && projections.find((p) => {
|
|
80
|
+
return p.value === projectionValue.value;
|
|
81
|
+
}) || projections[0])
|
|
98
82
|
);
|
|
99
83
|
const [control, setControl] = useState();
|
|
100
84
|
const ref = useRef();
|
|
101
|
-
|
|
102
85
|
useEffect(() => {
|
|
103
86
|
const mousePosition = new OLMousePosition({
|
|
104
87
|
target: ref.current,
|
|
105
|
-
undefinedHTML:
|
|
106
|
-
className:
|
|
88
|
+
undefinedHTML: " ",
|
|
89
|
+
className: ""
|
|
107
90
|
});
|
|
108
91
|
map.addControl(mousePosition);
|
|
109
92
|
setControl(mousePosition);
|
|
110
|
-
|
|
111
93
|
return () => {
|
|
112
94
|
map.removeControl(mousePosition);
|
|
113
95
|
};
|
|
114
96
|
}, [map]);
|
|
115
|
-
|
|
116
97
|
useEffect(() => {
|
|
117
98
|
if (!projection || !control) {
|
|
118
99
|
return;
|
|
@@ -120,19 +101,14 @@ function MousePosition({
|
|
|
120
101
|
control.setProjection(projection.value);
|
|
121
102
|
control.setCoordinateFormat(projection.format || createStringXY(4));
|
|
122
103
|
}, [projection, control]);
|
|
123
|
-
|
|
124
104
|
useEffect(() => {
|
|
125
105
|
if (projections) {
|
|
126
|
-
const proj =
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return p.value === projectionValue.value;
|
|
130
|
-
})) ||
|
|
131
|
-
projections[0];
|
|
106
|
+
const proj = projectionValue && projections.find((p) => {
|
|
107
|
+
return p.value === projectionValue.value;
|
|
108
|
+
}) || projections[0];
|
|
132
109
|
setProjection(proj);
|
|
133
110
|
}
|
|
134
111
|
}, [projections, projectionValue]);
|
|
135
|
-
|
|
136
112
|
const onChangeCb = useCallback(
|
|
137
113
|
(evt) => {
|
|
138
114
|
const newProj = projections.find((opt) => {
|
|
@@ -141,35 +117,26 @@ function MousePosition({
|
|
|
141
117
|
setProjection(newProj);
|
|
142
118
|
onChange(evt, newProj);
|
|
143
119
|
},
|
|
144
|
-
[onChange, projections]
|
|
120
|
+
[onChange, projections]
|
|
145
121
|
);
|
|
146
|
-
|
|
147
122
|
if (!projection || !projections || !projections.length) {
|
|
148
123
|
return null;
|
|
149
124
|
}
|
|
150
|
-
|
|
151
125
|
return (
|
|
152
126
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
);
|
|
165
|
-
})}
|
|
166
|
-
</select>
|
|
167
|
-
<span ref={ref} className="rs-coordinates" />
|
|
168
|
-
</div>
|
|
127
|
+
/* @__PURE__ */ React.createElement("div", { className: "rs-mouse-position", ...other }, /* @__PURE__ */ React.createElement(
|
|
128
|
+
"select",
|
|
129
|
+
{
|
|
130
|
+
className: "rs-select",
|
|
131
|
+
value: projection.value,
|
|
132
|
+
onChange: onChangeCb
|
|
133
|
+
},
|
|
134
|
+
projections.map((option) => {
|
|
135
|
+
return /* @__PURE__ */ React.createElement("option", { key: option.value, value: option.value }, option.label);
|
|
136
|
+
})
|
|
137
|
+
), /* @__PURE__ */ React.createElement("span", { ref, className: "rs-coordinates" }))
|
|
169
138
|
);
|
|
170
139
|
}
|
|
171
|
-
|
|
172
140
|
MousePosition.propTypes = propTypes;
|
|
173
141
|
MousePosition.defaultProps = defaultProps;
|
|
174
|
-
|
|
175
142
|
export default React.memo(MousePosition);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/MousePosition/MousePosition.js"],
|
|
4
|
+
"sourcesContent": ["import React, { useState, useRef, useEffect, useCallback } from 'react';\nimport PropTypes from 'prop-types';\nimport OLMap from 'ol/Map';\nimport { createStringXY } from 'ol/coordinate';\nimport OLMousePosition from 'ol/control/MousePosition';\n\nconst propTypes = {\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 * List of projections to display.\n */\n projections: PropTypes.arrayOf(\n PropTypes.shape({\n /**\n * The label to display in the select box.\n */\n label: PropTypes.string.isRequired,\n\n /**\n * The value used to create the options\u00B4s projection of the MousePosition control.\n * See [doc](https://openlayers.org/en/latest/apidoc/module-ol_control_MousePosition.html).\n */\n value: PropTypes.string.isRequired,\n\n /**\n * A function following the [CoordinateFormat](https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html#~CoordinateFormat).\n */\n format: PropTypes.func,\n }),\n ),\n\n /**\n * The initially selected projection\n */\n projectionValue: PropTypes.shape({\n /**\n * The label to display in the select box.\n */\n label: PropTypes.string.isRequired,\n\n /**\n * The value used to create the options\u00B4s projection of the MousePosition control.\n * See [doc](https://openlayers.org/en/latest/apidoc/module-ol_control_MousePosition.html).\n */\n value: PropTypes.string.isRequired,\n\n /**\n * A function following the [CoordinateFormat](https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html#~CoordinateFormat).\n */\n format: PropTypes.func,\n }),\n\n /**\n * Function triggered on projection's change event.\n * @param {Event} event The change event object.\n * @param {Object} projection The selected projection object.\n */\n onChange: PropTypes.func,\n};\n\nconst defaultProps = {\n onChange: () => {},\n projections: [\n {\n label: 'EPSG:4326',\n value: 'EPSG:4326',\n },\n {\n label: 'EPSG:3857',\n value: 'EPSG:3857',\n },\n ],\n projectionValue: null,\n};\n\n/**\n * The MousePosition component renders a select box with map projection options\n * and the cursor position in coordinates using the selected projection.\n */\nfunction MousePosition({\n map,\n projections,\n projectionValue,\n onChange,\n ...other\n}) {\n const [projection, setProjection] = useState(\n projections &&\n ((projectionValue &&\n projections.find((p) => {\n return p.value === projectionValue.value;\n })) ||\n projections[0]),\n );\n const [control, setControl] = useState();\n const ref = useRef();\n\n useEffect(() => {\n const mousePosition = new OLMousePosition({\n target: ref.current,\n undefinedHTML: ' ',\n className: '',\n });\n map.addControl(mousePosition);\n setControl(mousePosition);\n\n return () => {\n map.removeControl(mousePosition);\n };\n }, [map]);\n\n useEffect(() => {\n if (!projection || !control) {\n return;\n }\n control.setProjection(projection.value);\n control.setCoordinateFormat(projection.format || createStringXY(4));\n }, [projection, control]);\n\n useEffect(() => {\n if (projections) {\n const proj =\n (projectionValue &&\n projections.find((p) => {\n return p.value === projectionValue.value;\n })) ||\n projections[0];\n setProjection(proj);\n }\n }, [projections, projectionValue]);\n\n const onChangeCb = useCallback(\n (evt) => {\n const newProj = projections.find((opt) => {\n return evt.target.value === opt.value;\n });\n setProjection(newProj);\n onChange(evt, newProj);\n },\n [onChange, projections],\n );\n\n if (!projection || !projections || !projections.length) {\n return null;\n }\n\n return (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div className=\"rs-mouse-position\" {...other}>\n <select\n className=\"rs-select\"\n value={projection.value}\n onChange={onChangeCb}\n >\n {projections.map((option) => {\n return (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n );\n })}\n </select>\n <span ref={ref} className=\"rs-coordinates\" />\n </div>\n );\n}\n\nMousePosition.propTypes = propTypes;\nMousePosition.defaultProps = defaultProps;\n\nexport default React.memo(MousePosition);\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./MousePosition";
|
|
@@ -1,75 +1,59 @@
|
|
|
1
|
-
import React, { useEffect, useState } from
|
|
2
|
-
import PropTypes from
|
|
3
|
-
import OLMap from
|
|
4
|
-
import { unByKey } from
|
|
5
|
-
import { toDegrees } from
|
|
6
|
-
import NorthArrowSimple from
|
|
7
|
-
import NorthArrowCircle from
|
|
8
|
-
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import OLMap from "ol/Map";
|
|
4
|
+
import { unByKey } from "ol/Observable";
|
|
5
|
+
import { toDegrees } from "ol/math";
|
|
6
|
+
import NorthArrowSimple from "../../images/northArrow.svg";
|
|
7
|
+
import NorthArrowCircle from "../../images/northArrowCircle.svg";
|
|
9
8
|
const propTypes = {
|
|
10
9
|
/**
|
|
11
10
|
* An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
|
|
12
11
|
*/
|
|
13
12
|
map: PropTypes.instanceOf(OLMap).isRequired,
|
|
14
|
-
|
|
15
13
|
/**
|
|
16
14
|
* Rotation of the north arrow in degrees.
|
|
17
15
|
*/
|
|
18
16
|
rotationOffset: PropTypes.number,
|
|
19
|
-
|
|
20
17
|
/**
|
|
21
18
|
* Display circle around the north arrow. Not used if pass children.
|
|
22
19
|
*/
|
|
23
20
|
circled: PropTypes.bool,
|
|
24
|
-
|
|
25
21
|
/**
|
|
26
22
|
* Children content of the north arrow.
|
|
27
23
|
*/
|
|
28
|
-
children: PropTypes.node
|
|
24
|
+
children: PropTypes.node
|
|
29
25
|
};
|
|
30
|
-
|
|
31
26
|
const defaultProps = {
|
|
32
27
|
rotationOffset: 0,
|
|
33
28
|
circled: false,
|
|
34
|
-
children: null
|
|
29
|
+
children: null
|
|
35
30
|
};
|
|
36
|
-
|
|
37
31
|
const getRotation = (map, rotationOffset) => {
|
|
38
32
|
return toDegrees(map.getView().getRotation()) + rotationOffset;
|
|
39
33
|
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* This NorthArrow component inserts an arrow pointing north into an
|
|
43
|
-
* [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
|
|
44
|
-
*/
|
|
45
34
|
function NorthArrow({ map, rotationOffset, circled, children, ...other }) {
|
|
46
35
|
const [rotation, setRotation] = useState(rotationOffset);
|
|
47
|
-
|
|
48
36
|
useEffect(() => {
|
|
49
37
|
if (!map) {
|
|
50
38
|
return null;
|
|
51
39
|
}
|
|
52
|
-
const key = map.on(
|
|
40
|
+
const key = map.on("postrender", () => {
|
|
53
41
|
setRotation(getRotation(map, rotationOffset));
|
|
54
42
|
});
|
|
55
43
|
return () => {
|
|
56
44
|
unByKey(key);
|
|
57
45
|
};
|
|
58
46
|
}, [map, rotationOffset]);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
className
|
|
63
|
-
|
|
64
|
-
{
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
{children || (circled ? <NorthArrowCircle /> : <NorthArrowSimple />)}
|
|
68
|
-
</div>
|
|
47
|
+
return /* @__PURE__ */ React.createElement(
|
|
48
|
+
"div",
|
|
49
|
+
{
|
|
50
|
+
className: "rs-north-arrow",
|
|
51
|
+
...other,
|
|
52
|
+
style: { transform: `rotate(${rotation}deg)` }
|
|
53
|
+
},
|
|
54
|
+
children || (circled ? /* @__PURE__ */ React.createElement(NorthArrowCircle, null) : /* @__PURE__ */ React.createElement(NorthArrowSimple, null))
|
|
69
55
|
);
|
|
70
56
|
}
|
|
71
|
-
|
|
72
57
|
NorthArrow.propTypes = propTypes;
|
|
73
58
|
NorthArrow.defaultProps = defaultProps;
|
|
74
|
-
|
|
75
59
|
export default React.memo(NorthArrow);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/NorthArrow/NorthArrow.js"],
|
|
4
|
+
"sourcesContent": ["import React, { useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport OLMap from 'ol/Map';\nimport { unByKey } from 'ol/Observable';\nimport { toDegrees } from 'ol/math';\nimport NorthArrowSimple from '../../images/northArrow.svg';\nimport NorthArrowCircle from '../../images/northArrowCircle.svg';\n\nconst propTypes = {\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 * Rotation of the north arrow in degrees.\n */\n rotationOffset: PropTypes.number,\n\n /**\n * Display circle around the north arrow. Not used if pass children.\n */\n circled: PropTypes.bool,\n\n /**\n * Children content of the north arrow.\n */\n children: PropTypes.node,\n};\n\nconst defaultProps = {\n rotationOffset: 0,\n circled: false,\n children: null,\n};\n\nconst getRotation = (map, rotationOffset) => {\n return toDegrees(map.getView().getRotation()) + rotationOffset;\n};\n\n/**\n * This NorthArrow component inserts an arrow pointing north into an\n * [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nfunction NorthArrow({ map, rotationOffset, circled, children, ...other }) {\n const [rotation, setRotation] = useState(rotationOffset);\n\n useEffect(() => {\n if (!map) {\n return null;\n }\n const key = map.on('postrender', () => {\n setRotation(getRotation(map, rotationOffset));\n });\n return () => {\n unByKey(key);\n };\n }, [map, rotationOffset]);\n\n return (\n <div\n className=\"rs-north-arrow\"\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n style={{ transform: `rotate(${rotation}deg)` }}\n >\n {children || (circled ? <NorthArrowCircle /> : <NorthArrowSimple />)}\n </div>\n );\n}\n\nNorthArrow.propTypes = propTypes;\nNorthArrow.defaultProps = defaultProps;\n\nexport default React.memo(NorthArrow);\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,WAAW,gBAAgB;AAC3C,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,OAAO,sBAAsB;AAC7B,OAAO,sBAAsB;AAE7B,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA;AAAA;AAAA;AAAA,EAKjC,gBAAgB,UAAU;AAAA;AAAA;AAAA;AAAA,EAK1B,SAAS,UAAU;AAAA;AAAA;AAAA;AAAA,EAKnB,UAAU,UAAU;AACtB;AAEA,MAAM,eAAe;AAAA,EACnB,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,UAAU;AACZ;AAEA,MAAM,cAAc,CAAC,KAAK,mBAAmB;AAC3C,SAAO,UAAU,IAAI,QAAQ,EAAE,YAAY,CAAC,IAAI;AAClD;AAMA,SAAS,WAAW,EAAE,KAAK,gBAAgB,SAAS,UAAU,GAAG,MAAM,GAAG;AACxE,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,cAAc;AAEvD,YAAU,MAAM;AACd,QAAI,CAAC,KAAK;AACR,aAAO;AAAA,IACT;AACA,UAAM,MAAM,IAAI,GAAG,cAAc,MAAM;AACrC,kBAAY,YAAY,KAAK,cAAc,CAAC;AAAA,IAC9C,CAAC;AACD,WAAO,MAAM;AACX,cAAQ,GAAG;AAAA,IACb;AAAA,EACF,GAAG,CAAC,KAAK,cAAc,CAAC;AAExB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MAET,GAAG;AAAA,MACJ,OAAO,EAAE,WAAW,UAAU,QAAQ,OAAO;AAAA;AAAA,IAE5C,aAAa,UAAU,oCAAC,sBAAiB,IAAK,oCAAC,sBAAiB;AAAA,EACnE;AAEJ;AAEA,WAAW,YAAY;AACvB,WAAW,eAAe;AAE1B,eAAe,MAAM,KAAK,UAAU;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./NorthArrow";
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import React, { Component, useState } from
|
|
2
|
-
import PropTypes from
|
|
3
|
-
import { Resizable } from
|
|
4
|
-
import ResizeHandler from
|
|
5
|
-
|
|
1
|
+
import React, { Component, useState } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { Resizable } from "re-resizable";
|
|
4
|
+
import ResizeHandler from "../ResizeHandler";
|
|
6
5
|
const propTypes = {
|
|
7
6
|
/**
|
|
8
7
|
* CSS class added to container.
|
|
9
8
|
*/
|
|
10
9
|
className: PropTypes.string,
|
|
11
|
-
|
|
12
10
|
/**
|
|
13
11
|
* Children content of the overlay.
|
|
14
12
|
*/
|
|
15
13
|
children: PropTypes.node,
|
|
16
|
-
|
|
17
14
|
/**
|
|
18
15
|
* Observed element to define screen size.
|
|
19
16
|
*/
|
|
@@ -22,15 +19,13 @@ const propTypes = {
|
|
|
22
19
|
PropTypes.node,
|
|
23
20
|
PropTypes.instanceOf(Component),
|
|
24
21
|
PropTypes.shape({ current: PropTypes.node }),
|
|
25
|
-
PropTypes.shape({ current: PropTypes.instanceOf(Component) })
|
|
22
|
+
PropTypes.shape({ current: PropTypes.instanceOf(Component) })
|
|
26
23
|
]),
|
|
27
|
-
|
|
28
24
|
/**
|
|
29
25
|
* Deactivate the ability to resize the overlay on mobile.
|
|
30
26
|
* /!\ This prop is only used if isMobile (observer width < 768px).
|
|
31
27
|
*/
|
|
32
28
|
isMobileResizable: PropTypes.bool,
|
|
33
|
-
|
|
34
29
|
/**
|
|
35
30
|
* Size parameters to the Resizable component on mobile.
|
|
36
31
|
* Pass following prop to re-resizable component: 'size', 'defaultSize', 'minHeight' & 'maxHeight'
|
|
@@ -42,45 +37,40 @@ const propTypes = {
|
|
|
42
37
|
maximalHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
43
38
|
defaultSize: PropTypes.shape({
|
|
44
39
|
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
45
|
-
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
40
|
+
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
46
41
|
}),
|
|
47
42
|
size: PropTypes.shape({
|
|
48
43
|
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
49
|
-
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
50
|
-
})
|
|
44
|
+
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
45
|
+
})
|
|
51
46
|
}),
|
|
52
|
-
|
|
53
47
|
/**
|
|
54
48
|
* Minimal width to consider the observed as mobile.
|
|
55
49
|
* Default is 768px.
|
|
56
50
|
*/
|
|
57
51
|
thresholdWidthForMobile: PropTypes.number,
|
|
58
|
-
|
|
59
52
|
/**
|
|
60
53
|
* Callback when stop resizing
|
|
61
54
|
* Pass following prop to re-resizable component
|
|
62
55
|
* (https://github.com/bokuweb/re-resizable)
|
|
63
56
|
*/
|
|
64
57
|
onResizeStop: PropTypes.func,
|
|
65
|
-
|
|
66
58
|
/**
|
|
67
59
|
* Callback when start resizing
|
|
68
60
|
* Pass following prop to re-resizable component
|
|
69
61
|
* (https://github.com/bokuweb/re-resizable)
|
|
70
62
|
*/
|
|
71
|
-
onResizeStart: PropTypes.func
|
|
63
|
+
onResizeStart: PropTypes.func
|
|
72
64
|
};
|
|
73
|
-
|
|
74
65
|
const defaultMobileSize = {
|
|
75
66
|
defaultSize: {
|
|
76
|
-
width:
|
|
77
|
-
height:
|
|
67
|
+
width: "100%",
|
|
68
|
+
height: "25%"
|
|
78
69
|
},
|
|
79
|
-
size:
|
|
80
|
-
maximalHeight:
|
|
81
|
-
minimalHeight:
|
|
70
|
+
size: void 0,
|
|
71
|
+
maximalHeight: "100%",
|
|
72
|
+
minimalHeight: "25%"
|
|
82
73
|
};
|
|
83
|
-
|
|
84
74
|
const defaultProps = {
|
|
85
75
|
className: null,
|
|
86
76
|
children: null,
|
|
@@ -88,13 +78,11 @@ const defaultProps = {
|
|
|
88
78
|
isMobileResizable: true,
|
|
89
79
|
mobileSize: defaultMobileSize,
|
|
90
80
|
thresholdWidthForMobile: 768,
|
|
91
|
-
onResizeStop: () => {
|
|
92
|
-
|
|
81
|
+
onResizeStop: () => {
|
|
82
|
+
},
|
|
83
|
+
onResizeStart: () => {
|
|
84
|
+
}
|
|
93
85
|
};
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* The Overlay component creates a resizable, swipable overlay <div\>
|
|
97
|
-
*/
|
|
98
86
|
const Overlay = ({
|
|
99
87
|
observe,
|
|
100
88
|
className,
|
|
@@ -103,74 +91,60 @@ const Overlay = ({
|
|
|
103
91
|
mobileSize,
|
|
104
92
|
onResizeStop,
|
|
105
93
|
onResizeStart,
|
|
106
|
-
thresholdWidthForMobile
|
|
94
|
+
thresholdWidthForMobile
|
|
107
95
|
}) => {
|
|
108
96
|
const [isMobile, setIsMobile] = useState();
|
|
109
|
-
|
|
110
97
|
const onResize = (entries) => {
|
|
111
98
|
for (let i = 0; i < entries.length; i += 1) {
|
|
112
99
|
const { width } = entries[i].contentRect;
|
|
113
100
|
setIsMobile(width <= thresholdWidthForMobile);
|
|
114
101
|
}
|
|
115
102
|
};
|
|
116
|
-
|
|
117
103
|
let resizableMobileSize;
|
|
118
104
|
if (mobileSize) {
|
|
119
105
|
resizableMobileSize = { ...defaultMobileSize, ...mobileSize };
|
|
120
106
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
>
|
|
162
|
-
<div className="tm-overlay-mobile-content">{children}</div>
|
|
163
|
-
</Resizable>
|
|
164
|
-
) : (
|
|
165
|
-
<div className={`tm-overlay${className ? ` ${className}` : ''}`}>
|
|
166
|
-
{children}
|
|
167
|
-
</div>
|
|
168
|
-
)}
|
|
169
|
-
</>
|
|
170
|
-
);
|
|
107
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, observe ? /* @__PURE__ */ React.createElement(ResizeHandler, { observe, onResize }) : null, isMobile ? /* @__PURE__ */ React.createElement(
|
|
108
|
+
Resizable,
|
|
109
|
+
{
|
|
110
|
+
style: {
|
|
111
|
+
position: "absolute"
|
|
112
|
+
},
|
|
113
|
+
enable: {
|
|
114
|
+
top: isMobileResizable,
|
|
115
|
+
right: false,
|
|
116
|
+
bottom: false,
|
|
117
|
+
left: false,
|
|
118
|
+
topRight: false,
|
|
119
|
+
bottomRight: false,
|
|
120
|
+
bottomLeft: false,
|
|
121
|
+
topLeft: false
|
|
122
|
+
},
|
|
123
|
+
maxHeight: mobileSize && resizableMobileSize.maximalHeight,
|
|
124
|
+
minHeight: mobileSize && resizableMobileSize.minimalHeight,
|
|
125
|
+
handleComponent: {
|
|
126
|
+
top: /* @__PURE__ */ React.createElement("div", { className: "tm-overlay-handler" }, "\u2014")
|
|
127
|
+
},
|
|
128
|
+
onResizeStart,
|
|
129
|
+
onResizeStop,
|
|
130
|
+
handleStyles: {
|
|
131
|
+
top: {
|
|
132
|
+
top: "-20px",
|
|
133
|
+
height: "20px",
|
|
134
|
+
padding: "20px 0",
|
|
135
|
+
width: "100%",
|
|
136
|
+
display: "flex",
|
|
137
|
+
alignItems: "center",
|
|
138
|
+
justifyContent: "center"
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
size: resizableMobileSize.size,
|
|
142
|
+
defaultSize: mobileSize && resizableMobileSize.defaultSize,
|
|
143
|
+
className: `tm-overlay-mobile${className ? ` ${className}` : ""}`
|
|
144
|
+
},
|
|
145
|
+
/* @__PURE__ */ React.createElement("div", { className: "tm-overlay-mobile-content" }, children)
|
|
146
|
+
) : /* @__PURE__ */ React.createElement("div", { className: `tm-overlay${className ? ` ${className}` : ""}` }, children));
|
|
171
147
|
};
|
|
172
|
-
|
|
173
148
|
Overlay.propTypes = propTypes;
|
|
174
149
|
Overlay.defaultProps = defaultProps;
|
|
175
|
-
|
|
176
150
|
export default Overlay;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/Overlay/Overlay.js"],
|
|
4
|
+
"sourcesContent": ["import React, { Component, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { Resizable } from 're-resizable';\nimport ResizeHandler from '../ResizeHandler';\n\nconst propTypes = {\n /**\n * CSS class added to container.\n */\n className: PropTypes.string,\n\n /**\n * Children content of the overlay.\n */\n children: PropTypes.node,\n\n /**\n * Observed element to define screen size.\n */\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\n /**\n * Deactivate the ability to resize the overlay on mobile.\n * /!\\ This prop is only used if isMobile (observer width < 768px).\n */\n isMobileResizable: PropTypes.bool,\n\n /**\n * Size parameters to the Resizable component on mobile.\n * Pass following prop to re-resizable component: 'size', 'defaultSize', 'minHeight' & 'maxHeight'\n * (https://github.com/bokuweb/re-resizable)\n * /!\\ This prop is only used if isMobile (observer width < 768px).\n */\n mobileSize: PropTypes.shape({\n minimalHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n maximalHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n defaultSize: PropTypes.shape({\n height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n }),\n size: PropTypes.shape({\n height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n }),\n }),\n\n /**\n * Minimal width to consider the observed as mobile.\n * Default is 768px.\n */\n thresholdWidthForMobile: PropTypes.number,\n\n /**\n * Callback when stop resizing\n * Pass following prop to re-resizable component\n * (https://github.com/bokuweb/re-resizable)\n */\n onResizeStop: PropTypes.func,\n\n /**\n * Callback when start resizing\n * Pass following prop to re-resizable component\n * (https://github.com/bokuweb/re-resizable)\n */\n onResizeStart: PropTypes.func,\n};\n\nconst defaultMobileSize = {\n defaultSize: {\n width: '100%',\n height: '25%',\n },\n size: undefined,\n maximalHeight: '100%',\n minimalHeight: '25%',\n};\n\nconst defaultProps = {\n className: null,\n children: null,\n observe: null,\n isMobileResizable: true,\n mobileSize: defaultMobileSize,\n thresholdWidthForMobile: 768,\n onResizeStop: () => {},\n onResizeStart: () => {},\n};\n\n/**\n * The Overlay component creates a resizable, swipable overlay <div\\>\n */\nconst Overlay = ({\n observe,\n className,\n children,\n isMobileResizable,\n mobileSize,\n onResizeStop,\n onResizeStart,\n thresholdWidthForMobile,\n}) => {\n const [isMobile, setIsMobile] = useState();\n\n const onResize = (entries) => {\n for (let i = 0; i < entries.length; i += 1) {\n const { width } = entries[i].contentRect;\n setIsMobile(width <= thresholdWidthForMobile);\n }\n };\n\n let resizableMobileSize;\n if (mobileSize) {\n resizableMobileSize = { ...defaultMobileSize, ...mobileSize };\n }\n\n return (\n <>\n {observe ? <ResizeHandler observe={observe} onResize={onResize} /> : null}\n {isMobile ? (\n <Resizable\n style={{\n position: 'absolute',\n }}\n enable={{\n top: isMobileResizable,\n right: false,\n bottom: false,\n left: false,\n topRight: false,\n bottomRight: false,\n bottomLeft: false,\n topLeft: false,\n }}\n maxHeight={mobileSize && resizableMobileSize.maximalHeight}\n minHeight={mobileSize && resizableMobileSize.minimalHeight}\n handleComponent={{\n top: <div className=\"tm-overlay-handler\">—</div>,\n }}\n onResizeStart={onResizeStart}\n onResizeStop={onResizeStop}\n handleStyles={{\n top: {\n top: '-20px',\n height: '20px',\n padding: '20px 0',\n width: '100%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n },\n }}\n size={resizableMobileSize.size}\n defaultSize={mobileSize && resizableMobileSize.defaultSize}\n className={`tm-overlay-mobile${className ? ` ${className}` : ''}`}\n >\n <div className=\"tm-overlay-mobile-content\">{children}</div>\n </Resizable>\n ) : (\n <div className={`tm-overlay${className ? ` ${className}` : ''}`}>\n {children}\n </div>\n )}\n </>\n );\n};\n\nOverlay.propTypes = propTypes;\nOverlay.defaultProps = defaultProps;\n\nexport default Overlay;\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./Overlay";
|