react-spatial 2.0.3 → 2.1.7-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +1 -1
  2. package/components/BaseLayerSwitcher/BaseLayerSwitcher.js +79 -70
  3. package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +2 -2
  4. package/components/BasicMap/BasicMap.js +2 -1
  5. package/components/BasicMap/BasicMap.js.map +1 -1
  6. package/components/CanvasSaveButton/CanvasSaveButton.js +10 -7
  7. package/components/CanvasSaveButton/CanvasSaveButton.js.map +2 -2
  8. package/components/Copyright/Copyright.js +5 -2
  9. package/components/Copyright/Copyright.js.map +2 -2
  10. package/components/FeatureExportButton/FeatureExportButton.js +5 -4
  11. package/components/FeatureExportButton/FeatureExportButton.js.map +2 -2
  12. package/components/FitExtent/FitExtent.js +5 -4
  13. package/components/FitExtent/FitExtent.js.map +2 -2
  14. package/components/Geolocation/Geolocation.js +6 -5
  15. package/components/Geolocation/Geolocation.js.map +2 -2
  16. package/components/LayerTree/LayerTree.js +68 -50
  17. package/components/LayerTree/LayerTree.js.map +2 -2
  18. package/components/MousePosition/MousePosition.js +12 -11
  19. package/components/MousePosition/MousePosition.js.map +2 -2
  20. package/components/NorthArrow/NorthArrow.js +5 -4
  21. package/components/NorthArrow/NorthArrow.js.map +2 -2
  22. package/components/Overlay/Overlay.js +43 -39
  23. package/components/Overlay/Overlay.js.map +1 -1
  24. package/components/Permalink/Permalink.js.map +2 -2
  25. package/components/Popup/Popup.js +28 -22
  26. package/components/Popup/Popup.js.map +2 -2
  27. package/components/ResizeHandler/ResizeHandler.js.map +1 -1
  28. package/components/RouteSchedule/RouteSchedule.js +82 -52
  29. package/components/RouteSchedule/RouteSchedule.js.map +2 -2
  30. package/components/ScaleLine/ScaleLine.js +2 -1
  31. package/components/ScaleLine/ScaleLine.js.map +2 -2
  32. package/components/StopsFinder/StopsFinder.js +23 -17
  33. package/components/StopsFinder/StopsFinder.js.map +2 -2
  34. package/components/StopsFinder/StopsFinderOption.js +18 -12
  35. package/components/StopsFinder/StopsFinderOption.js.map +2 -2
  36. package/components/Zoom/Zoom.js +16 -14
  37. package/components/Zoom/Zoom.js.map +2 -2
  38. package/package.json +59 -71
  39. package/setupTests.js +10 -1
  40. package/setupTests.js.map +2 -2
  41. package/utils/KML.js +3 -3
  42. package/utils/KML.js.map +2 -2
@@ -1,3 +1,4 @@
1
+ import { jsx } from "react/jsx-runtime";
1
2
  import KMLFormat from "ol/format/KML";
2
3
  import Layer from "ol/layer/Layer";
3
4
  import PropTypes from "prop-types";
@@ -57,7 +58,7 @@ class FeatureExportButton extends PureComponent {
57
58
  }
58
59
  render() {
59
60
  const { children, format, layer, projection, ...other } = this.props;
60
- return /* @__PURE__ */ React.createElement(
61
+ return /* @__PURE__ */ jsx(
61
62
  "div",
62
63
  {
63
64
  className: "rs-feature-export-button",
@@ -69,9 +70,9 @@ class FeatureExportButton extends PureComponent {
69
70
  },
70
71
  onKeyPress: (evt) => {
71
72
  return evt.which === 13 && FeatureExportButton.exportFeatures(layer, projection, format);
72
- }
73
- },
74
- children
73
+ },
74
+ children
75
+ }
75
76
  );
76
77
  }
77
78
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/FeatureExportButton/FeatureExportButton.js"],
4
- "sourcesContent": ["import KMLFormat from \"ol/format/KML\";\nimport Layer from \"ol/layer/Layer\";\nimport PropTypes from \"prop-types\";\nimport React, { PureComponent } from \"react\";\n\nimport KML from \"../../utils/KML\";\n\nconst propTypes = {\n /**\n * Children content of the Feature export button.\n */\n children: PropTypes.node,\n\n /**\n * Format to export features (function).\n * Supported formats: https://openlayers.org/en/latest/apidoc/module-ol_format_Feature-FeatureFormat.html\n */\n format: PropTypes.func,\n\n /**\n * A layer extending an [ol/layer/Layer](https://openlayers.org/en/latest/apidoc/module-ol_layer_Layer.html),\n * using a valid [ol/source/Vector](https://openlayers.org/en/latest/apidoc/module-ol_source_Vector.html)\n */\n layer: PropTypes.instanceOf(Layer).isRequired,\n\n /**\n * Map projection.\n */\n projection: PropTypes.string,\n};\n\nconst defaultProps = {\n children: null,\n format: KMLFormat,\n projection: \"EPSG:3857\",\n};\n\n/**\n * The FeatureExportButton component creates a button that exports feature geometries\n * from an [ol/layer/Vector](https://openlayers.org/en/latest/apidoc/module-ol_layer_Vector-VectorLayer.html)\n * with a [ol/source/Vector](https://openlayers.org/en/latest/apidoc/module-ol_source_Vector.html) on click.<br>\n * The default export format is KML, which supports the features' style export.<br>\n * Other formats do not always support style export (See specific format specs).\n */\nclass FeatureExportButton extends PureComponent {\n static createFeatureString(layer, projection, format) {\n if (format === KMLFormat) {\n return KML.writeFeatures(layer, projection);\n }\n\n // eslint-disable-next-line new-cap\n return new format().writeFeatures(layer.getSource().getFeatures(), {\n featureProjection: projection,\n });\n }\n\n static exportFeatures(layer, projection, format) {\n const now = new Date()\n .toJSON()\n .slice(0, 20)\n .replace(/[.:T-]+/g, \"\");\n const featString = this.createFeatureString(layer, projection, format);\n\n const formatString = featString\n ? featString.match(/<(\\w+)\\s+\\w+.*?>/)[1]\n : \"xml\";\n\n const fileName = `exported_features_${now}.${formatString}`;\n const charset = document.characterSet || \"UTF-8\";\n const type = `${\n formatString === \"kml\"\n ? \"data:application/vnd.google-earth.kml+xml\"\n : \"data:text/xml\"\n };charset=${charset}`;\n\n if (featString) {\n if (window.navigator.msSaveBlob) {\n // ie 11 and higher\n window.navigator.msSaveBlob(new Blob([featString], { type }), fileName);\n } else {\n const link = document.createElement(\"a\");\n link.download = fileName;\n link.href = `${type},${encodeURIComponent(featString)}`;\n link.click();\n }\n }\n }\n\n render() {\n const { children, format, layer, projection, ...other } = this.props;\n\n return (\n <div\n className=\"rs-feature-export-button\"\n role=\"button\"\n tabIndex={0}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n onClick={() => {\n return FeatureExportButton.exportFeatures(layer, projection, format);\n }}\n onKeyPress={(evt) => {\n return (\n evt.which === 13 &&\n FeatureExportButton.exportFeatures(layer, projection, format)\n );\n }}\n >\n {children}\n </div>\n );\n }\n}\n\nFeatureExportButton.propTypes = propTypes;\nFeatureExportButton.defaultProps = defaultProps;\n\nexport default FeatureExportButton;\n"],
5
- "mappings": "AAAA,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,OAAO,eAAe;AACtB,OAAO,SAAS,qBAAqB;AAErC,OAAO,SAAS;AAEhB,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,UAAU,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAMpB,QAAQ,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAMlB,OAAO,UAAU,WAAW,KAAK,EAAE;AAAA;AAAA;AAAA;AAAA,EAKnC,YAAY,UAAU;AACxB;AAEA,MAAM,eAAe;AAAA,EACnB,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,YAAY;AACd;AASA,MAAM,4BAA4B,cAAc;AAAA,EAC9C,OAAO,oBAAoB,OAAO,YAAY,QAAQ;AACpD,QAAI,WAAW,WAAW;AACxB,aAAO,IAAI,cAAc,OAAO,UAAU;AAAA,IAC5C;AAGA,WAAO,IAAI,OAAO,EAAE,cAAc,MAAM,UAAU,EAAE,YAAY,GAAG;AAAA,MACjE,mBAAmB;AAAA,IACrB,CAAC;AAAA,EACH;AAAA,EAEA,OAAO,eAAe,OAAO,YAAY,QAAQ;AAC/C,UAAM,OAAM,oBAAI,KAAK,GAClB,OAAO,EACP,MAAM,GAAG,EAAE,EACX,QAAQ,YAAY,EAAE;AACzB,UAAM,aAAa,KAAK,oBAAoB,OAAO,YAAY,MAAM;AAErE,UAAM,eAAe,aACjB,WAAW,MAAM,kBAAkB,EAAE,CAAC,IACtC;AAEJ,UAAM,WAAW,qBAAqB,GAAG,IAAI,YAAY;AACzD,UAAM,UAAU,SAAS,gBAAgB;AACzC,UAAM,OAAO,GACX,iBAAiB,QACb,8CACA,eACN,YAAY,OAAO;AAEnB,QAAI,YAAY;AACd,UAAI,OAAO,UAAU,YAAY;AAE/B,eAAO,UAAU,WAAW,IAAI,KAAK,CAAC,UAAU,GAAG,EAAE,KAAK,CAAC,GAAG,QAAQ;AAAA,MACxE,OAAO;AACL,cAAM,OAAO,SAAS,cAAc,GAAG;AACvC,aAAK,WAAW;AAChB,aAAK,OAAO,GAAG,IAAI,IAAI,mBAAmB,UAAU,CAAC;AACrD,aAAK,MAAM;AAAA,MACb;AAAA,IACF;AAAA,EACF;AAAA,EAEA,SAAS;AACP,UAAM,EAAE,UAAU,QAAQ,OAAO,YAAY,GAAG,MAAM,IAAI,KAAK;AAE/D,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV,MAAK;AAAA,QACL,UAAU;AAAA,QAET,GAAG;AAAA,QACJ,SAAS,MAAM;AACb,iBAAO,oBAAoB,eAAe,OAAO,YAAY,MAAM;AAAA,QACrE;AAAA,QACA,YAAY,CAAC,QAAQ;AACnB,iBACE,IAAI,UAAU,MACd,oBAAoB,eAAe,OAAO,YAAY,MAAM;AAAA,QAEhE;AAAA;AAAA,MAEC;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,oBAAoB,YAAY;AAChC,oBAAoB,eAAe;AAEnC,eAAe;",
4
+ "sourcesContent": ["import KMLFormat from \"ol/format/KML\";\nimport Layer from \"ol/layer/Layer\";\nimport PropTypes from \"prop-types\";\nimport React, { PureComponent } from \"react\";\n\nimport KML from \"../../utils/KML\";\n\nconst propTypes = {\n /**\n * Children content of the Feature export button.\n */\n children: PropTypes.node,\n\n /**\n * Format to export features (function).\n * Supported formats: https://openlayers.org/en/latest/apidoc/module-ol_format_Feature-FeatureFormat.html\n */\n format: PropTypes.func,\n\n /**\n * A layer extending an [ol/layer/Layer](https://openlayers.org/en/latest/apidoc/module-ol_layer_Layer.html),\n * using a valid [ol/source/Vector](https://openlayers.org/en/latest/apidoc/module-ol_source_Vector.html)\n */\n layer: PropTypes.instanceOf(Layer).isRequired,\n\n /**\n * Map projection.\n */\n projection: PropTypes.string,\n};\n\nconst defaultProps = {\n children: null,\n format: KMLFormat,\n projection: \"EPSG:3857\",\n};\n\n/**\n * The FeatureExportButton component creates a button that exports feature geometries\n * from an [ol/layer/Vector](https://openlayers.org/en/latest/apidoc/module-ol_layer_Vector-VectorLayer.html)\n * with a [ol/source/Vector](https://openlayers.org/en/latest/apidoc/module-ol_source_Vector.html) on click.<br>\n * The default export format is KML, which supports the features' style export.<br>\n * Other formats do not always support style export (See specific format specs).\n */\nclass FeatureExportButton extends PureComponent {\n static createFeatureString(layer, projection, format) {\n if (format === KMLFormat) {\n return KML.writeFeatures(layer, projection);\n }\n\n return new format().writeFeatures(layer.getSource().getFeatures(), {\n featureProjection: projection,\n });\n }\n\n static exportFeatures(layer, projection, format) {\n const now = new Date()\n .toJSON()\n .slice(0, 20)\n .replace(/[.:T-]+/g, \"\");\n const featString = this.createFeatureString(layer, projection, format);\n\n const formatString = featString\n ? featString.match(/<(\\w+)\\s+\\w+.*?>/)[1]\n : \"xml\";\n\n const fileName = `exported_features_${now}.${formatString}`;\n const charset = document.characterSet || \"UTF-8\";\n const type = `${\n formatString === \"kml\"\n ? \"data:application/vnd.google-earth.kml+xml\"\n : \"data:text/xml\"\n };charset=${charset}`;\n\n if (featString) {\n if (window.navigator.msSaveBlob) {\n // ie 11 and higher\n window.navigator.msSaveBlob(new Blob([featString], { type }), fileName);\n } else {\n const link = document.createElement(\"a\");\n link.download = fileName;\n link.href = `${type},${encodeURIComponent(featString)}`;\n link.click();\n }\n }\n }\n\n render() {\n const { children, format, layer, projection, ...other } = this.props;\n\n return (\n <div\n className=\"rs-feature-export-button\"\n role=\"button\"\n tabIndex={0}\n {...other}\n onClick={() => {\n return FeatureExportButton.exportFeatures(layer, projection, format);\n }}\n onKeyPress={(evt) => {\n return (\n evt.which === 13 &&\n FeatureExportButton.exportFeatures(layer, projection, format)\n );\n }}\n >\n {children}\n </div>\n );\n }\n}\n\nFeatureExport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AAU,GAAG,EAAE,KAAK,CAAC,GAAG,QAAQ;AAAA,MACxE,OAAO;AACL,cAAM,OAAO,SAAS,cAAc,GAAG;AACvC,aAAK,WAAW;AAChB,aAAK,OAAO,GAAG,IAAI,IAAI,mBAAmB,UAAU,CAAC;AACrD,aAAK,MAAM;AAAA,MACb;AAAA,IACF;AAAA,EACF;AAAA,EAEA,SAAS;AACP,UAAM,EAAE,UAAU,QAAQ,OAAO,YAAY,GAAG,MAAM,IAAI,KAAK;AAE/D,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV,MAAK;AAAA,QACL,UAAU;AAAA,QACT,GAAG;AAAA,QACJ,SAAS,MAAM;AACb,iBAAO,oBAAoB,eAAe,OAAO,YAAY,MAAM;AAAA,QACrE;AAAA,QACA,YAAY,CAAC,QAAQ;AACnB,iBACE,IAAI,UAAU,MACd,oBAAoB,eAAe,OAAO,YAAY,MAAM;AAAA,QAEhE;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,oBAAoB,YAAY;AAChC,oBAAoB,eAAe;AAEnC,eAAe;",
6
6
  "names": []
7
7
  }
@@ -1,3 +1,4 @@
1
+ import { jsx } from "react/jsx-runtime";
1
2
  import OLMap from "ol/Map";
2
3
  import PropTypes from "prop-types";
3
4
  import React from "react";
@@ -33,7 +34,7 @@ function FitExtent({
33
34
  map.getView().cancelAnimations();
34
35
  map.getView().fit(extent, map.getSize());
35
36
  };
36
- return /* @__PURE__ */ React.createElement(
37
+ return /* @__PURE__ */ jsx(
37
38
  "div",
38
39
  {
39
40
  className,
@@ -41,9 +42,9 @@ function FitExtent({
41
42
  onKeyPress: fit,
42
43
  role: "button",
43
44
  tabIndex: "0",
44
- ...other
45
- },
46
- children
45
+ ...other,
46
+ children
47
+ }
47
48
  );
48
49
  }
49
50
  FitExtent.propTypes = propTypes;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/FitExtent/FitExtent.js"],
4
- "sourcesContent": ["import OLMap from \"ol/Map\";\nimport PropTypes from \"prop-types\";\nimport React from \"react\";\n\nconst propTypes = {\n /**\n * Button content.\n */\n children: PropTypes.node.isRequired,\n\n /**\n * CSS class for the fitExtent button.\n */\n className: PropTypes.string,\n\n /**\n * The extent to be zoomed.\n */\n extent: PropTypes.arrayOf(PropTypes.number).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/**\n * The FitExtent component creates a button that updates the current extent of\n * an [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nfunction FitExtent({\n children,\n className = \"rs-fit-extent\",\n extent,\n map,\n ...other\n}) {\n const fit = (evt) => {\n if (evt.which && evt.which !== 13) {\n return;\n }\n map.getView().cancelAnimations();\n map.getView().fit(extent, map.getSize());\n };\n\n return (\n <div\n className={className}\n onClick={fit}\n onKeyPress={fit}\n role=\"button\"\n tabIndex=\"0\"\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n >\n {children}\n </div>\n );\n}\n\nFitExtent.propTypes = propTypes;\n\nexport default FitExtent;\n"],
5
- "mappings": "AAAA,OAAO,WAAW;AAClB,OAAO,eAAe;AACtB,OAAO,WAAW;AAElB,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,UAAU,UAAU,KAAK;AAAA;AAAA;AAAA;AAAA,EAKzB,WAAW,UAAU;AAAA;AAAA;AAAA;AAAA,EAKrB,QAAQ,UAAU,QAAQ,UAAU,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA,EAK5C,KAAK,UAAU,WAAW,KAAK,EAAE;AACnC;AAMA,SAAS,UAAU;AAAA,EACjB;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG;AACD,QAAM,MAAM,CAAC,QAAQ;AACnB,QAAI,IAAI,SAAS,IAAI,UAAU,IAAI;AACjC;AAAA,IACF;AACA,QAAI,QAAQ,EAAE,iBAAiB;AAC/B,QAAI,QAAQ,EAAE,IAAI,QAAQ,IAAI,QAAQ,CAAC;AAAA,EACzC;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,MAAK;AAAA,MACL,UAAS;AAAA,MAER,GAAG;AAAA;AAAA,IAEH;AAAA,EACH;AAEJ;AAEA,UAAU,YAAY;AAEtB,eAAe;",
4
+ "sourcesContent": ["import OLMap from \"ol/Map\";\nimport PropTypes from \"prop-types\";\nimport React from \"react\";\n\nconst propTypes = {\n /**\n * Button content.\n */\n children: PropTypes.node.isRequired,\n\n /**\n * CSS class for the fitExtent button.\n */\n className: PropTypes.string,\n\n /**\n * The extent to be zoomed.\n */\n extent: PropTypes.arrayOf(PropTypes.number).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/**\n * The FitExtent component creates a button that updates the current extent of\n * an [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nfunction FitExtent({\n children,\n className = \"rs-fit-extent\",\n extent,\n map,\n ...other\n}) {\n const fit = (evt) => {\n if (evt.which && evt.which !== 13) {\n return;\n }\n map.getView().cancelAnimations();\n map.getView().fit(extent, map.getSize());\n };\n\n return (\n <div\n className={className}\n onClick={fit}\n onKeyPress={fit}\n role=\"button\"\n tabIndex=\"0\"\n {...other}\n >\n {children}\n </div>\n );\n}\n\nFitExtent.propTypes = propTypes;\n\nexport default FitExtent;\n"],
5
+ "mappings": "AA8CI;AA9CJ,OAAO,WAAW;AAClB,OAAO,eAAe;AACtB,OAAO,WAAW;AAElB,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,UAAU,UAAU,KAAK;AAAA;AAAA;AAAA;AAAA,EAKzB,WAAW,UAAU;AAAA;AAAA;AAAA;AAAA,EAKrB,QAAQ,UAAU,QAAQ,UAAU,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA,EAK5C,KAAK,UAAU,WAAW,KAAK,EAAE;AACnC;AAMA,SAAS,UAAU;AAAA,EACjB;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG;AACD,QAAM,MAAM,CAAC,QAAQ;AACnB,QAAI,IAAI,SAAS,IAAI,UAAU,IAAI;AACjC;AAAA,IACF;AACA,QAAI,QAAQ,EAAE,iBAAiB;AAC/B,QAAI,QAAQ,EAAE,IAAI,QAAQ,IAAI,QAAQ,CAAC;AAAA,EACzC;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,MAAK;AAAA,MACL,UAAS;AAAA,MACR,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ;AAEA,UAAU,YAAY;AAEtB,eAAe;",
6
6
  "names": []
7
7
  }
@@ -1,3 +1,4 @@
1
+ import { jsx } from "react/jsx-runtime";
1
2
  import Feature from "ol/Feature";
2
3
  import Point from "ol/geom/Point";
3
4
  import VectorLayer from "ol/layer/Vector";
@@ -65,7 +66,7 @@ const propTypes = {
65
66
  };
66
67
  const defaultProps = {
67
68
  alwaysRecenterToPosition: true,
68
- children: /* @__PURE__ */ React.createElement(FaRegDotCircle, { focusable: false }),
69
+ children: /* @__PURE__ */ jsx(FaRegDotCircle, { focusable: false }),
69
70
  className: "rs-geolocation",
70
71
  colorOrStyleFunc: [235, 0, 0],
71
72
  neverCenterToPosition: false,
@@ -193,7 +194,7 @@ class Geolocation extends PureComponent {
193
194
  return propTypes[key] ? props : { ...props, [key]: value };
194
195
  }, {});
195
196
  const { active } = this.state;
196
- return /* @__PURE__ */ React.createElement(
197
+ return /* @__PURE__ */ jsx(
197
198
  "div",
198
199
  {
199
200
  className: `${className} ${active ? "rs-active" : ""}`,
@@ -205,9 +206,9 @@ class Geolocation extends PureComponent {
205
206
  },
206
207
  role: "button",
207
208
  tabIndex: "0",
208
- ...other
209
- },
210
- children
209
+ ...other,
210
+ children
211
+ }
211
212
  );
212
213
  }
213
214
  toggle() {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/Geolocation/Geolocation.js"],
4
- "sourcesContent": ["import Feature from \"ol/Feature\";\nimport Point from \"ol/geom/Point\";\nimport VectorLayer from \"ol/layer/Vector\";\nimport OLMap from \"ol/Map\";\nimport { unByKey } from \"ol/Observable\";\nimport { transform } from \"ol/proj\";\nimport VectorSource from \"ol/source/Vector\";\nimport Circle from \"ol/style/Circle\";\nimport Fill from \"ol/style/Fill\";\nimport Stroke from \"ol/style/Stroke\";\nimport Style from \"ol/style/Style\";\nimport PropTypes from \"prop-types\";\nimport React, { PureComponent } from \"react\";\nimport { FaRegDotCircle } from \"react-icons/fa\";\n\nconst propTypes = {\n /**\n * If true, the map will center once on the position then will constantly recenter to the current Position.\n * If false, the map will center once on the position then will never recenter if the position changes.\n */\n alwaysRecenterToPosition: PropTypes.bool,\n\n /**\n * Children content of the Geolocation button.\n */\n children: PropTypes.node,\n\n /**\n * CSS class of the button.\n */\n className: PropTypes.string,\n\n /**\n * Color (Number array with rgb values) or style function.\n * If a color is given, the style is animated.\n */\n colorOrStyleFunc: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.number),\n PropTypes.func,\n ]),\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 * If true, the map will never center to the current position\n */\n neverCenterToPosition: PropTypes.bool,\n\n /**\n * If true, the map is not centered after it has been dragged once.\n */\n noCenterAfterDrag: PropTypes.bool,\n\n /**\n * Function triggered after the geolocation is activated. Takes the ol/map and the component instance as arguments.\n */\n onActivate: PropTypes.func,\n\n /**\n * Function triggered after the geolocation is deactivated. Takes the ol/map and the component instance as arguments..\n */\n onDeactivate: PropTypes.func,\n\n /**\n * Function triggered when geolocating is not successful.\n */\n onError: PropTypes.func,\n\n /**\n * Function triggered after successful geoLocation calls. Takes the ol/map, the current lat/lon coordinate and the component instance as arguments.\n */\n onSuccess: PropTypes.func,\n};\n\nconst defaultProps = {\n alwaysRecenterToPosition: true,\n children: <FaRegDotCircle focusable={false} />,\n className: \"rs-geolocation\",\n colorOrStyleFunc: [235, 0, 0],\n neverCenterToPosition: false,\n noCenterAfterDrag: false,\n onActivate: () => {},\n onDeactivate: () => {},\n onError: () => {},\n onSuccess: () => {},\n};\n\n/**\n * The GeoLocation component creates a button to display the current device's location on an\n * [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nclass Geolocation extends PureComponent {\n constructor(props) {\n super(props);\n\n this.layer = new VectorLayer({\n source: new VectorSource(),\n });\n\n this.isRecenteringToPosition = true;\n\n this.state = {\n active: false,\n };\n this.point = undefined;\n }\n\n activate() {\n const { map, noCenterAfterDrag, onActivate } = this.props;\n\n this.projection = map.getView().getProjection().getCode();\n this.point = new Point([0, 0]);\n this.highlight();\n this.layer.setMap(map);\n this.setState({ active: true });\n\n this.watch = navigator.geolocation.watchPosition(\n this.update.bind(this),\n this.error.bind(this),\n {\n enableHighAccuracy: true,\n },\n );\n\n if (noCenterAfterDrag) {\n this.dragListener = map.on(\"pointerdrag\", () => {\n this.isRecenteringToPosition = false;\n });\n }\n\n onActivate(map, this);\n }\n\n componentWillUnmount() {\n this.deactivate();\n }\n\n deactivate() {\n const { map, onDeactivate } = this.props;\n window.clearInterval(this.interval);\n this.layer.setMap(null);\n navigator.geolocation.clearWatch(this.watch);\n\n this.setState({\n active: false,\n });\n\n this.isRecenteringToPosition = true;\n this.point = undefined;\n onDeactivate(map, this);\n unByKey(this.dragListener);\n }\n\n error(error) {\n const { onError } = this.props;\n\n this.deactivate();\n onError(error);\n }\n\n highlight() {\n const { colorOrStyleFunc } = this.props;\n const feature = new Feature({\n geometry: this.point,\n });\n\n if (Array.isArray(colorOrStyleFunc)) {\n const color = colorOrStyleFunc;\n\n let decrease = true;\n let opacity = 0.5;\n let rotation = 0;\n\n window.clearInterval(this.interval);\n this.interval = window.setInterval(() => {\n rotation += 0.03;\n decrease = opacity < 0.1 ? false : decrease;\n decrease = opacity > 0.5 ? true : decrease;\n opacity += decrease ? -0.03 : 0.03;\n if (feature) {\n feature.changed();\n }\n }, 50);\n\n feature.setStyle(() => {\n const circleStyle = new Style({\n image: new Circle({\n fill: new Fill({\n color: \"rgba(255, 255, 255, 0.01)\",\n }),\n radius: 20,\n rotation,\n stroke: new Stroke({\n color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, ${opacity})`,\n lineDash: [30, 10],\n width: 6,\n }),\n }),\n });\n\n circleStyle.getImage().setRotation(rotation);\n\n return [\n new Style({\n image: new Circle({\n fill: new Fill({\n color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.5)`,\n }),\n radius: 10,\n }),\n }),\n circleStyle,\n ];\n });\n } else {\n feature.setStyle(colorOrStyleFunc);\n }\n\n this.layer.getSource().clear();\n this.layer.getSource().addFeature(feature);\n }\n\n render() {\n const { children, className } = this.props;\n // Remove component props from other HTML props.\n const other = Object.entries(this.props).reduce((props, [key, value]) => {\n return propTypes[key] ? props : { ...props, [key]: value };\n }, {});\n const { active } = this.state;\n\n return (\n <div\n className={`${className} ${active ? \"rs-active\" : \"\"}`}\n onClick={() => {\n return this.toggle();\n }}\n onKeyPress={(e) => {\n return e.which === 13 && this.toggle();\n }}\n role=\"button\"\n tabIndex=\"0\"\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n >\n {children}\n </div>\n );\n }\n\n toggle() {\n const { active } = this.state;\n const { onError } = this.props;\n const geolocation = \"geolocation\" in navigator;\n\n if (!geolocation) {\n onError(new Error(\"Geolocation not supported\"));\n } else if (!active) {\n this.activate();\n } else {\n this.deactivate();\n }\n }\n\n update({ coords: { latitude, longitude } }) {\n const { alwaysRecenterToPosition, map, neverCenterToPosition, onSuccess } =\n this.props;\n\n const position = transform(\n [longitude, latitude],\n \"EPSG:4326\",\n this.projection,\n );\n this.point.setCoordinates(position);\n\n if (!neverCenterToPosition && this.isRecenteringToPosition) {\n map.getView().setCenter(position);\n if (!alwaysRecenterToPosition) {\n this.isRecenteringToPosition = false;\n }\n }\n\n onSuccess(map, [latitude, longitude], this);\n }\n}\n\nGeolocation.propTypes = propTypes;\nGeolocation.defaultProps = defaultProps;\n\nexport default Geolocation;\n"],
5
- "mappings": "AAAA,OAAO,aAAa;AACpB,OAAO,WAAW;AAClB,OAAO,iBAAiB;AACxB,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,OAAO,kBAAkB;AACzB,OAAO,YAAY;AACnB,OAAO,UAAU;AACjB,OAAO,YAAY;AACnB,OAAO,WAAW;AAClB,OAAO,eAAe;AACtB,OAAO,SAAS,qBAAqB;AACrC,SAAS,sBAAsB;AAE/B,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA,EAKhB,0BAA0B,UAAU;AAAA;AAAA;AAAA;AAAA,EAKpC,UAAU,UAAU;AAAA;AAAA;AAAA;AAAA,EAKpB,WAAW,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAMrB,kBAAkB,UAAU,UAAU;AAAA,IACpC,UAAU,QAAQ,UAAU,MAAM;AAAA,IAClC,UAAU;AAAA,EACZ,CAAC;AAAA;AAAA;AAAA;AAAA,EAKD,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA;AAAA;AAAA;AAAA,EAKjC,uBAAuB,UAAU;AAAA;AAAA;AAAA;AAAA,EAKjC,mBAAmB,UAAU;AAAA;AAAA;AAAA;AAAA,EAK7B,YAAY,UAAU;AAAA;AAAA;AAAA;AAAA,EAKtB,cAAc,UAAU;AAAA;AAAA;AAAA;AAAA,EAKxB,SAAS,UAAU;AAAA;AAAA;AAAA;AAAA,EAKnB,WAAW,UAAU;AACvB;AAEA,MAAM,eAAe;AAAA,EACnB,0BAA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;AACzB,UAAM,cAAc,iBAAiB;AAErC,QAAI,CAAC,aAAa;AAChB,cAAQ,IAAI,MAAM,2BAA2B,CAAC;AAAA,IAChD,WAAW,CAAC,QAAQ;AAClB,WAAK,SAAS;AAAA,IAChB,OAAO;AACL,WAAK,WAAW;AAAA,IAClB;AAAA,EACF;AAAA,EAEA,OAAO,EAAE,QAAQ,EAAE,UAAU,UAAU,EAAE,GAAG;AAC1C,UAAM,EAAE,0BAA0B,KAAK,uBAAuB,UAAU,IACtE,KAAK;AAEP,UAAM,WAAW;AAAA,MACf,CAAC,WAAW,QAAQ;AAAA,MACpB;AAAA,MACA,KAAK;AAAA,IACP;AACA,SAAK,MAAM,eAAe,QAAQ;AAElC,QAAI,CAAC,yBAAyB,KAAK,yBAAyB;AAC1D,UAAI,QAAQ,EAAE,UAAU,QAAQ;AAChC,UAAI,CAAC,0BAA0B;AAC7B,aAAK,0BAA0B;AAAA,MACjC;AAAA,IACF;AAEA,cAAU,KAAK,CAAC,UAAU,SAAS,GAAG,IAAI;AAAA,EAC5C;AACF;AAEA,YAAY,YAAY;AACxB,YAAY,eAAe;AAE3B,eAAe;",
4
+ "sourcesContent": ["import Feature from \"ol/Feature\";\nimport Point from \"ol/geom/Point\";\nimport VectorLayer from \"ol/layer/Vector\";\nimport OLMap from \"ol/Map\";\nimport { unByKey } from \"ol/Observable\";\nimport { transform } from \"ol/proj\";\nimport VectorSource from \"ol/source/Vector\";\nimport Circle from \"ol/style/Circle\";\nimport Fill from \"ol/style/Fill\";\nimport Stroke from \"ol/style/Stroke\";\nimport Style from \"ol/style/Style\";\nimport PropTypes from \"prop-types\";\nimport React, { PureComponent } from \"react\";\nimport { FaRegDotCircle } from \"react-icons/fa\";\n\nconst propTypes = {\n /**\n * If true, the map will center once on the position then will constantly recenter to the current Position.\n * If false, the map will center once on the position then will never recenter if the position changes.\n */\n alwaysRecenterToPosition: PropTypes.bool,\n\n /**\n * Children content of the Geolocation button.\n */\n children: PropTypes.node,\n\n /**\n * CSS class of the button.\n */\n className: PropTypes.string,\n\n /**\n * Color (Number array with rgb values) or style function.\n * If a color is given, the style is animated.\n */\n colorOrStyleFunc: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.number),\n PropTypes.func,\n ]),\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 * If true, the map will never center to the current position\n */\n neverCenterToPosition: PropTypes.bool,\n\n /**\n * If true, the map is not centered after it has been dragged once.\n */\n noCenterAfterDrag: PropTypes.bool,\n\n /**\n * Function triggered after the geolocation is activated. Takes the ol/map and the component instance as arguments.\n */\n onActivate: PropTypes.func,\n\n /**\n * Function triggered after the geolocation is deactivated. Takes the ol/map and the component instance as arguments..\n */\n onDeactivate: PropTypes.func,\n\n /**\n * Function triggered when geolocating is not successful.\n */\n onError: PropTypes.func,\n\n /**\n * Function triggered after successful geoLocation calls. Takes the ol/map, the current lat/lon coordinate and the component instance as arguments.\n */\n onSuccess: PropTypes.func,\n};\n\nconst defaultProps = {\n alwaysRecenterToPosition: true,\n children: <FaRegDotCircle focusable={false} />,\n className: \"rs-geolocation\",\n colorOrStyleFunc: [235, 0, 0],\n neverCenterToPosition: false,\n noCenterAfterDrag: false,\n onActivate: () => {},\n onDeactivate: () => {},\n onError: () => {},\n onSuccess: () => {},\n};\n\n/**\n * The GeoLocation component creates a button to display the current device's location on an\n * [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nclass Geolocation extends PureComponent {\n constructor(props) {\n super(props);\n\n this.layer = new VectorLayer({\n source: new VectorSource(),\n });\n\n this.isRecenteringToPosition = true;\n\n this.state = {\n active: false,\n };\n this.point = undefined;\n }\n\n activate() {\n const { map, noCenterAfterDrag, onActivate } = this.props;\n\n this.projection = map.getView().getProjection().getCode();\n this.point = new Point([0, 0]);\n this.highlight();\n this.layer.setMap(map);\n this.setState({ active: true });\n\n this.watch = navigator.geolocation.watchPosition(\n this.update.bind(this),\n this.error.bind(this),\n {\n enableHighAccuracy: true,\n },\n );\n\n if (noCenterAfterDrag) {\n this.dragListener = map.on(\"pointerdrag\", () => {\n this.isRecenteringToPosition = false;\n });\n }\n\n onActivate(map, this);\n }\n\n componentWillUnmount() {\n this.deactivate();\n }\n\n deactivate() {\n const { map, onDeactivate } = this.props;\n window.clearInterval(this.interval);\n this.layer.setMap(null);\n navigator.geolocation.clearWatch(this.watch);\n\n this.setState({\n active: false,\n });\n\n this.isRecenteringToPosition = true;\n this.point = undefined;\n onDeactivate(map, this);\n unByKey(this.dragListener);\n }\n\n error(error) {\n const { onError } = this.props;\n\n this.deactivate();\n onError(error);\n }\n\n highlight() {\n const { colorOrStyleFunc } = this.props;\n const feature = new Feature({\n geometry: this.point,\n });\n\n if (Array.isArray(colorOrStyleFunc)) {\n const color = colorOrStyleFunc;\n\n let decrease = true;\n let opacity = 0.5;\n let rotation = 0;\n\n window.clearInterval(this.interval);\n this.interval = window.setInterval(() => {\n rotation += 0.03;\n decrease = opacity < 0.1 ? false : decrease;\n decrease = opacity > 0.5 ? true : decrease;\n opacity += decrease ? -0.03 : 0.03;\n if (feature) {\n feature.changed();\n }\n }, 50);\n\n feature.setStyle(() => {\n const circleStyle = new Style({\n image: new Circle({\n fill: new Fill({\n color: \"rgba(255, 255, 255, 0.01)\",\n }),\n radius: 20,\n rotation,\n stroke: new Stroke({\n color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, ${opacity})`,\n lineDash: [30, 10],\n width: 6,\n }),\n }),\n });\n\n circleStyle.getImage().setRotation(rotation);\n\n return [\n new Style({\n image: new Circle({\n fill: new Fill({\n color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.5)`,\n }),\n radius: 10,\n }),\n }),\n circleStyle,\n ];\n });\n } else {\n feature.setStyle(colorOrStyleFunc);\n }\n\n this.layer.getSource().clear();\n this.layer.getSource().addFeature(feature);\n }\n\n render() {\n const { children, className } = this.props;\n // Remove component props from other HTML props.\n const other = Object.entries(this.props).reduce((props, [key, value]) => {\n return propTypes[key] ? props : { ...props, [key]: value };\n }, {});\n const { active } = this.state;\n\n return (\n <div\n className={`${className} ${active ? \"rs-active\" : \"\"}`}\n onClick={() => {\n return this.toggle();\n }}\n onKeyPress={(e) => {\n return e.which === 13 && this.toggle();\n }}\n role=\"button\"\n tabIndex=\"0\"\n {...other}\n >\n {children}\n </div>\n );\n }\n\n toggle() {\n const { active } = this.state;\n const { onError } = this.props;\n const geolocation = \"geolocation\" in navigator;\n\n if (!geolocation) {\n onError(new Error(\"Geolocation not supported\"));\n } else if (!active) {\n this.activate();\n } else {\n this.deactivate();\n }\n }\n\n update({ coords: { latitude, longitude } }) {\n const { alwaysRecenterToPosition, map, neverCenterToPosition, onSuccess } =\n this.props;\n\n const position = transform(\n [longitude, latitude],\n \"EPSG:4326\",\n this.projection,\n );\n this.point.setCoordinates(position);\n\n if (!neverCenterToPosition && this.isRecenteringToPosition) {\n map.getView().setCenter(position);\n if (!alwaysRecenterToPosition) {\n this.isRecenteringToPosition = false;\n }\n }\n\n onSuccess(map, [latitude, longitude], this);\n }\n}\n\nGeolocation.propTypes = propTypes;\nGeolocation.defaultProps = defaultProps;\n\nexport default Geolocation;\n"],
5
+ "mappings": "AA+EY;AA/EZ,OAAO,aAAa;AACpB,OAAO,WAAW;AAClB,OAAO,iBAAiB;AACxB,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,OAAO,kBAAkB;AACzB,OAAO,YAAY;AACnB,OAAO,UAAU;AACjB,OAAO,YAAY;AACnB,OAAO,WAAW;AAClB,OAAO,eAAe;AACtB,OAAO,SAAS,qBAAqB;AACrC,SAAS,sBAAsB;AAE/B,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA,EAKhB,0BAA0B,UAAU;AAAA;AAAA;AAAA;AAAA,EAKpC,UAAU,UAAU;AAAA;AAAA;AAAA;AAAA,EAKpB,WAAW,UAAU;AAAA;AAAA;A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
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
1
2
  import Layer from "ol/layer/Layer";
2
3
  import { unByKey } from "ol/Observable";
3
4
  import { getUid } from "ol/util";
@@ -159,9 +160,13 @@ class LayerTree extends Component {
159
160
  };
160
161
  this.olKeys = [];
161
162
  }
162
- static getChildren = (layer) => layer?.get("children") || layer?.children || // ol.layer.group
163
- layer?.getLayers?.().getArray() || [];
164
- static getVisible = (layer) => layer.getVisible ? layer.getVisible() : layer.visible;
163
+ static getChildren = (layer) => {
164
+ return layer?.get("children") || layer?.children || // ol.layer.group
165
+ layer?.getLayers?.().getArray() || [];
166
+ };
167
+ static getVisible = (layer) => {
168
+ return layer.getVisible ? layer.getVisible() : layer.visible;
169
+ };
165
170
  static listenGroups = (layers) => {
166
171
  const flat = getLayersAsFlatArray(layers);
167
172
  const keys = flat.map((layer) => {
@@ -248,7 +253,7 @@ class LayerTree extends Component {
248
253
  }
249
254
  render() {
250
255
  const { className } = this.props;
251
- return /* @__PURE__ */ React.createElement("div", { className }, this.renderTree());
256
+ return /* @__PURE__ */ jsx("div", { className, children: this.renderTree() });
252
257
  }
253
258
  renderArrow(layer) {
254
259
  const { isItemHidden } = this.props;
@@ -258,7 +263,7 @@ class LayerTree extends Component {
258
263
  }).length || layer.get("isAlwaysExpanded")) {
259
264
  return null;
260
265
  }
261
- return /* @__PURE__ */ React.createElement(
266
+ return /* @__PURE__ */ jsx(
262
267
  "div",
263
268
  {
264
269
  className: `rs-layer-tree-arrow rs-layer-tree-arrow-${!expandedLayers.includes(layer) ? "collapsed" : "expanded"}`
@@ -275,8 +280,8 @@ class LayerTree extends Component {
275
280
  }
276
281
  const inputType = layer.get("group") ? "radio" : "checkbox";
277
282
  return renderCheckbox ? renderCheckbox(layer, this, inputProps) : (
278
- // eslint-disable-next-line jsx-a11y/label-has-associated-control,jsx-a11y/no-noninteractive-element-interactions
279
- /* @__PURE__ */ React.createElement(
283
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
284
+ /* @__PURE__ */ jsxs(
280
285
  "label",
281
286
  {
282
287
  className: `rs-layer-tree-input rs-layer-tree-input-${inputType} rs-${inputType}`,
@@ -286,22 +291,24 @@ class LayerTree extends Component {
286
291
  }
287
292
  },
288
293
  tabIndex,
289
- title: LayerTree.getVisible(layer) ? titles.layerHide : titles.layerShow
290
- },
291
- /* @__PURE__ */ React.createElement(
292
- "input",
293
- {
294
- checked: LayerTree.getVisible(layer),
295
- onClick: () => {
296
- return this.onInputClick(layer);
297
- },
298
- readOnly: true,
299
- tabIndex: -1,
300
- type: inputType,
301
- ...inputProps
302
- }
303
- ),
304
- /* @__PURE__ */ React.createElement("span", null)
294
+ title: LayerTree.getVisible(layer) ? titles.layerHide : titles.layerShow,
295
+ children: [
296
+ /* @__PURE__ */ jsx(
297
+ "input",
298
+ {
299
+ checked: LayerTree.getVisible(layer),
300
+ onClick: () => {
301
+ return this.onInputClick(layer);
302
+ },
303
+ readOnly: true,
304
+ tabIndex: -1,
305
+ type: inputType,
306
+ ...inputProps
307
+ }
308
+ ),
309
+ /* @__PURE__ */ jsx("span", {})
310
+ ]
311
+ }
305
312
  )
306
313
  );
307
314
  }
@@ -324,31 +331,36 @@ class LayerTree extends Component {
324
331
  if (renderItem) {
325
332
  return renderItem(layer, this.onInputClick, this.onToggle);
326
333
  }
327
- return /* @__PURE__ */ React.createElement(
334
+ return /* @__PURE__ */ jsxs(
328
335
  "div",
329
336
  {
330
337
  className: getParentClassName(),
331
- key: layer.key || layer.get("key") || layer.get("name") || getUid(layer)
338
+ children: [
339
+ /* @__PURE__ */ jsx(
340
+ "div",
341
+ {
342
+ className: `rs-layer-tree-item ${LayerTree.getVisible(layer) ? "rs-visible" : ""}`,
343
+ style: {
344
+ paddingLeft: `${padding * level}px`
345
+ },
346
+ children: renderItemContent ? renderItemContent(layer, this) : this.renderItemContent(layer)
347
+ }
348
+ ),
349
+ renderBeforeItem?.(layer, level, this),
350
+ [...children].reverse().map((child) => {
351
+ return this.renderItem(child, level + 1);
352
+ }),
353
+ renderAfterItem?.(layer, level, this)
354
+ ]
332
355
  },
333
- /* @__PURE__ */ React.createElement(
334
- "div",
335
- {
336
- className: `rs-layer-tree-item ${LayerTree.getVisible(layer) ? "rs-visible" : ""}`,
337
- style: {
338
- paddingLeft: `${padding * level}px`
339
- }
340
- },
341
- renderItemContent ? renderItemContent(layer, this) : this.renderItemContent(layer)
342
- ),
343
- renderBeforeItem && renderBeforeItem(layer, level, this),
344
- [...children].reverse().map((child) => {
345
- return this.renderItem(child, level + 1);
346
- }),
347
- renderAfterItem && renderAfterItem(layer, level, this)
356
+ layer.key || layer.get("key") || layer.get("name") || getUid(layer)
348
357
  );
349
358
  }
350
359
  renderItemContent(layer, inputProps = {}, toggleProps = {}) {
351
- return /* @__PURE__ */ React.createElement(React.Fragment, null, this.renderInput(layer, inputProps), this.renderToggleButton(layer, toggleProps));
360
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
361
+ this.renderInput(layer, inputProps),
362
+ this.renderToggleButton(layer, toggleProps)
363
+ ] });
352
364
  }
353
365
  // Render a button which expands/collapse the layer if there is children
354
366
  // or simulate a click on the input otherwise.
@@ -364,7 +376,7 @@ class LayerTree extends Component {
364
376
  );
365
377
  };
366
378
  const title = `${renderLabel(layer, this)} ${expandedLayers.includes(layer) ? titles.subLayerHide : titles.subLayerShow}`;
367
- return /* @__PURE__ */ React.createElement(
379
+ return /* @__PURE__ */ jsxs(
368
380
  "div",
369
381
  {
370
382
  "aria-expanded": expandedLayers.includes(layer),
@@ -375,10 +387,12 @@ class LayerTree extends Component {
375
387
  role: "button",
376
388
  tabIndex: 0,
377
389
  title,
378
- ...toggleProps
379
- },
380
- /* @__PURE__ */ React.createElement("div", null, renderLabel(layer, this)),
381
- this.renderArrow(layer)
390
+ ...toggleProps,
391
+ children: [
392
+ /* @__PURE__ */ jsx("div", { children: renderLabel(layer, this) }),
393
+ this.renderArrow(layer)
394
+ ]
395
+ }
382
396
  );
383
397
  }
384
398
  renderTree() {
@@ -387,11 +401,11 @@ class LayerTree extends Component {
387
401
  if (!LayerTree.getChildren(rootLayer).length) {
388
402
  return null;
389
403
  }
390
- return /* @__PURE__ */ React.createElement(React.Fragment, null, LayerTree.getChildren(rootLayer).filter((l) => {
404
+ return /* @__PURE__ */ jsx(Fragment, { children: LayerTree.getChildren(rootLayer).filter((l) => {
391
405
  return !isItemHidden(l);
392
406
  }).reverse().map((l) => {
393
407
  return this.renderItem(l, 0);
394
- }));
408
+ }) });
395
409
  }
396
410
  updateLayers() {
397
411
  const { expandChildren, layers } = this.props;
@@ -431,7 +445,9 @@ class LayerTree extends Component {
431
445
  if (parent) {
432
446
  parent.setVisible(true);
433
447
  }
434
- if (children && !children.some((child) => child.getVisible())) {
448
+ if (children && !children.some((child) => {
449
+ return child.getVisible();
450
+ })) {
435
451
  children.forEach((child) => {
436
452
  child.setVisible(true);
437
453
  });
@@ -440,7 +456,9 @@ class LayerTree extends Component {
440
456
  children.forEach((child) => {
441
457
  child.setVisible(false);
442
458
  });
443
- if (parent?.getVisible() && !parent?.get("children").find((child) => child.getVisible())) {
459
+ if (parent?.getVisible() && !parent?.get("children").find((child) => {
460
+ return child.getVisible();
461
+ })) {
444
462
  parent.setVisible(false);
445
463
  }
446
464
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/LayerTree/LayerTree.js"],
4
- "sourcesContent": ["import Layer from \"ol/layer/Layer\";\nimport { unByKey } from \"ol/Observable\";\nimport { getUid } from \"ol/util\";\nimport PropTypes from \"prop-types\";\nimport React, { Component } from \"react\";\n\nimport getLayersAsFlatArray from \"../../utils/getLayersAsFlatArray\";\n\nconst propTypes = {\n /**\n * CSS class to apply on the container.\n */\n className: PropTypes.string,\n\n /**\n * Boolean determining whether children collapse/expand when their parent is toggled\n * @param {...(boolean|function)} expandChildren Boolean or function returning a boolean.\n * @return {boolean} True or false\n */\n expandChildren: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),\n\n /**\n * Determine the className used by the div containing the parent and its children.\n */\n getParentClassName: PropTypes.func,\n\n /**\n * Determine if the item is hidden in the tree or not.\n *\n * @param {object} item The item to hide or not.\n *\n * @return {bool} true if the item is not displayed in the tree\n */\n isItemHidden: PropTypes.func,\n\n /**\n * Layers provider.\n */\n layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)),\n\n /**\n * Padding left to apply on each level.\n */\n padding: PropTypes.number,\n\n /**\n * Custom function to render custom content after the list of children of an item.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderAfterItem: PropTypes.func,\n\n /**\n * Custom function to render custom content before the list of children of an item.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderBeforeItem: PropTypes.func,\n\n /**\n * Custom function to render the checkbox.\n */\n renderCheckbox: PropTypes.func,\n\n /**\n * Custom function to render an item in the tree.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderItem: PropTypes.func,\n\n /**\n * Custom function to render only the content of an item in the tree.\n * inputProps und toggleProps can be used when calling the default renderItemContent function\n * (comp.renderItemContent(layer, inputProps, toggleProps)) to overwrite the default input and label props\n *\n * @param {Layer} layer The layer the item content is created for\n * @param {LayerTree} comp The LayerTree component.\n *\n * @return {node} A jsx node.\n */\n renderItemContent: PropTypes.func,\n\n /**\n * Custom function to render the label.\n *\n * @param {string} item The label to render.\n * @param {LayerTree} comp The LayerTree component.\n *\n * @return {node} A jsx node.\n */\n renderLabel: PropTypes.func,\n\n /**\n * Translation function.\n * @param {function} Translation function returning the translated string.\n */\n t: PropTypes.func,\n\n /**\n * Object holding title for the layer tree's buttons.\n */\n titles: PropTypes.shape({\n /**\n * aria-label on checkbox to hide layer.\n */\n layerHide: PropTypes.string,\n /**\n * aria-label on checkbox to show layer.\n */\n layerShow: PropTypes.string,\n /**\n * title on button to show sublayers.\n */\n subLayerHide: PropTypes.string,\n /**\n * title on button to show sublayers.\n */\n subLayerShow: PropTypes.string,\n }),\n};\n\nconst defaultProps = {\n className: \"rs-layer-tree\",\n expandChildren: false,\n getParentClassName: () => {\n return undefined;\n },\n isItemHidden: () => {\n return false;\n },\n layers: [],\n padding: 30,\n renderAfterItem: null,\n renderBeforeItem: null,\n renderCheckbox: null,\n renderItem: null,\n renderItemContent: null,\n renderLabel: (layer) => {\n return layer?.get(\"name\") || \"\";\n },\n t: (s) => {\n return s;\n },\n titles: {\n layerHide: \"Hide layer\",\n layerShow: \"Show layer\",\n subLayerHide: \"Hide sublayer\",\n subLayerShow: \"Show sublayer\",\n },\n};\n\n/**\n * The LayerTree component renders an interface for toggling layers visibility.\n * and their corresponding child layers.\n */\n\nclass LayerTree extends Component {\n constructor(props) {\n super(props);\n\n const { isItemHidden, layers } = this.props;\n const initialExpandedLayers = layers\n ? this.getExpandedLayers(\n layers.filter((l) => {\n return (\n !isItemHidden(l) &&\n LayerTree.getChildren(l)\n .filter((child) => {\n return LayerTree.getVisible(child);\n })\n .filter((c) => {\n return !isItemHidden(c);\n }).length\n );\n }),\n )\n : [];\n\n this.state = {\n expandedLayers: initialExpandedLayers,\n revision: 0,\n rootLayer: new Layer({}),\n };\n // this.updateLayers = this.updateLayers.bind(this);\n this.olKeys = [];\n }\n\n static getChildren = (layer) =>\n layer?.get(\"children\") ||\n layer?.children ||\n // ol.layer.group\n layer?.getLayers?.().getArray() ||\n [];\n\n static getVisible = (layer) =>\n layer.getVisible ? layer.getVisible() : layer.visible;\n\n static listenGroups = (layers) => {\n const flat = getLayersAsFlatArray(layers);\n const keys = flat.map((layer) => {\n return layer.on(\"change:visible\", (e) => {\n const { target } = e;\n if (target.getVisible() && target.get(\"group\")) {\n flat.forEach((l) => {\n if (l.get(\"group\") === target.get(\"group\") && l !== target) {\n l.setVisible(false);\n }\n });\n }\n });\n });\n return keys;\n };\n\n static setVisible = (layer, visible) => {\n if (layer.setVisible) {\n layer.setVisible(visible);\n return;\n }\n // eslint-disable-next-line no-param-reassign\n layer.visible = visible;\n };\n\n componentDidMount() {\n this.updateLayers();\n }\n\n componentDidUpdate(prevProps) {\n const { layers } = this.props;\n\n if (layers !== prevProps.layers) {\n this.updateLayers();\n }\n }\n\n componentWillUnmount() {\n unByKey(this.olKeys);\n this.olKeys = [];\n }\n\n expandLayer(layer, expLayers = []) {\n const { isItemHidden } = this.props;\n if (LayerTree.getVisible(layer) && !isItemHidden(layer)) {\n const children = LayerTree.getChildren(layer)\n .filter((c) => {\n return !isItemHidden(c) && !c.get(\"isAlwaysExpanded\");\n })\n .flatMap((c) => {\n return this.expandLayer(c, expLayers);\n });\n return [...expLayers, ...children, layer];\n }\n return expLayers;\n }\n\n /**\n * Get the always expanded ancestors (isAlwaysExpanded=true) of the given layers\n * together with the (given) initially expanded layers\n *\n * @param {Layer} layers Initially expanded layers\n * @return {Array.<Layer>} Initially expanded layers and all its always expanded ancestors\n */\n getExpandedLayers(layers) {\n const { isItemHidden } = this.props;\n const children = layers.flatMap((l) => {\n return LayerTree.getChildren(l).filter((c) => {\n return !isItemHidden(c) && c.get(\"isAlwaysExpanded\");\n });\n });\n\n if (!children.length) {\n return layers;\n }\n return [...layers, this.getExpandedLayers(children)].flat();\n }\n\n onInputClick(layer, toggle = false) {\n if (toggle) {\n this.onToggle(layer);\n } else {\n LayerTree.setVisible(layer, !LayerTree.getVisible(layer));\n }\n }\n\n onToggle(layer) {\n const { expandedLayers } = this.state;\n const pos = expandedLayers.indexOf(layer);\n if (pos > -1) {\n expandedLayers.splice(pos, 1);\n } else {\n expandedLayers.push(...this.getExpandedLayers([layer]));\n }\n this.setState({ expandedLayers });\n }\n\n render() {\n const { className } = this.props;\n return <div className={className}>{this.renderTree()}</div>;\n }\n\n renderArrow(layer) {\n const { isItemHidden } = this.props;\n const { expandedLayers } = this.state;\n\n if (\n !LayerTree.getChildren(layer).filter((c) => {\n return !isItemHidden(c);\n }).length ||\n layer.get(\"isAlwaysExpanded\")\n ) {\n return null;\n }\n\n return (\n <div\n className={`rs-layer-tree-arrow rs-layer-tree-arrow-${\n !expandedLayers.includes(layer) ? \"collapsed\" : \"expanded\"\n }`}\n />\n );\n }\n\n renderInput(layer, inputProps) {\n const { isItemHidden, renderCheckbox, titles } = this.props;\n let tabIndex = 0;\n\n if (\n !LayerTree.getChildren(layer).filter((c) => {\n return !isItemHidden(c);\n }).length\n ) {\n // We forbid focus on keypress event for first level layers and layers without children.\n tabIndex = -1;\n }\n\n const inputType = layer.get(\"group\") ? \"radio\" : \"checkbox\";\n return renderCheckbox ? (\n renderCheckbox(layer, this, inputProps)\n ) : (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control,jsx-a11y/no-noninteractive-element-interactions\n <label\n className={`rs-layer-tree-input rs-layer-tree-input-${inputType} rs-${inputType}`}\n onKeyPress={(e) => {\n if (e.which === 13) {\n this.onInputClick(layer);\n }\n }}\n tabIndex={tabIndex}\n title={\n LayerTree.getVisible(layer) ? titles.layerHide : titles.layerShow\n }\n >\n <input\n checked={LayerTree.getVisible(layer)}\n onClick={() => {\n return this.onInputClick(layer);\n }}\n readOnly\n tabIndex={-1}\n type={inputType}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...inputProps}\n />\n <span />\n </label>\n );\n }\n\n renderItem(layer, level) {\n const { isItemHidden } = this.props;\n const { expandedLayers } = this.state;\n const {\n getParentClassName,\n padding,\n renderAfterItem,\n renderBeforeItem,\n renderItem,\n renderItemContent,\n } = this.props;\n\n const children = expandedLayers.includes(layer)\n ? [\n ...LayerTree.getChildren(layer).filter((c) => {\n return !isItemHidden(c);\n }),\n ]\n : [];\n\n if (renderItem) {\n return renderItem(layer, this.onInputClick, this.onToggle);\n }\n\n return (\n <div\n className={getParentClassName()}\n key={\n layer.key || layer.get(\"key\") || layer.get(\"name\") || getUid(layer)\n }\n >\n <div\n className={`rs-layer-tree-item ${LayerTree.getVisible(layer) ? \"rs-visible\" : \"\"}`}\n style={{\n paddingLeft: `${padding * level}px`,\n }}\n >\n {renderItemContent\n ? renderItemContent(layer, this)\n : this.renderItemContent(layer)}\n </div>\n {renderBeforeItem && renderBeforeItem(layer, level, this)}\n {[...children].reverse().map((child) => {\n return this.renderItem(child, level + 1);\n })}\n {renderAfterItem && renderAfterItem(layer, level, this)}\n </div>\n );\n }\n\n renderItemContent(layer, inputProps = {}, toggleProps = {}) {\n return (\n <>\n {this.renderInput(layer, inputProps)}\n {this.renderToggleButton(layer, toggleProps)}\n </>\n );\n }\n\n // Render a button which expands/collapse the layer if there is children\n // or simulate a click on the input otherwise.\n renderToggleButton(layer, toggleProps) {\n const { isItemHidden, renderLabel, titles } = this.props;\n const { expandedLayers } = this.state;\n\n const onInputClick = () => {\n this.onInputClick(\n layer,\n LayerTree.getChildren(layer).filter((c) => {\n return !isItemHidden(c);\n }).length && !layer.get(\"isAlwaysExpanded\"),\n );\n };\n const title = `${renderLabel(layer, this)} ${\n expandedLayers.includes(layer) ? titles.subLayerHide : titles.subLayerShow\n }`;\n\n return (\n <div\n aria-expanded={expandedLayers.includes(layer)}\n aria-label={title}\n className=\"rs-layer-tree-toggle\"\n onClick={onInputClick}\n onKeyPress={onInputClick}\n role=\"button\"\n tabIndex={0}\n title={title}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...toggleProps}\n >\n <div>{renderLabel(layer, this)}</div>\n {this.renderArrow(layer)}\n </div>\n );\n }\n\n renderTree() {\n const { isItemHidden } = this.props;\n const { rootLayer } = this.state;\n\n if (!LayerTree.getChildren(rootLayer).length) {\n return null;\n }\n\n return (\n <>\n {LayerTree.getChildren(rootLayer)\n .filter((l) => {\n return !isItemHidden(l);\n })\n .reverse()\n .map((l) => {\n return this.renderItem(l, 0);\n })}\n </>\n );\n }\n\n updateLayers() {\n const { expandChildren, layers } = this.props;\n\n // Update the root layer\n let rootLayer = new Layer({});\n if (Array.isArray(layers)) {\n if (layers.length === 1) {\n [rootLayer] = layers;\n }\n rootLayer = new Layer({ children: layers });\n } else {\n rootLayer = layers;\n }\n\n const flat = getLayersAsFlatArray(rootLayer);\n flat.forEach((layer) => {\n this.olKeys.push(\n layer.on(\"propertychange\", () => {\n const { revision } = this.state;\n this.setState({ revision: revision + 1 });\n }),\n\n // Manage group visibility\n layer.on(\"change:visible\", (evt) => {\n const { target } = evt;\n if (target.getVisible() && target.get(\"group\")) {\n flat.forEach((l) => {\n if (l.get(\"group\") === target.get(\"group\") && l !== target) {\n l.setVisible(false);\n }\n });\n }\n }),\n\n // Manage parent/children visibility\n layer.on(\"change:visible\", (evt) => {\n const { target } = evt;\n const parent = target.get(\"parent\");\n const children = LayerTree.getChildren(target);\n\n if (target.getVisible()) {\n // We make the parent visible\n if (parent) {\n parent.setVisible(true);\n }\n\n // If children doesn't contain any visible layers, we display all children.\n if (children && !children.some((child) => child.getVisible())) {\n children.forEach((child) => {\n child.setVisible(true);\n });\n }\n } else {\n // We hide all the children\n children.forEach((child) => {\n child.setVisible(false);\n });\n\n // If the parent has no more visible child we also hide it.\n if (\n parent?.getVisible() &&\n !parent?.get(\"children\").find((child) => child.getVisible())\n ) {\n parent.setVisible(false);\n }\n }\n }),\n );\n });\n\n // Set parent property.\n flat.forEach((layer) => {\n const children = LayerTree.getChildren(layer);\n children.forEach((child) => {\n child.set(\"parent\", layer);\n });\n });\n\n const state = { rootLayer };\n if (\n typeof expandChildren === \"function\"\n ? expandChildren(layers)\n : expandChildren\n ) {\n const children = LayerTree.getChildren(rootLayer);\n state.expandedLayers = children.flatMap((l) => {\n return this.expandLayer(l);\n });\n }\n\n this.setState(state);\n }\n}\n\nLayerTree.propTypes = propTypes;\nLayerTree.defaultProps = defaultProps;\n\nexport default LayerTree;\n"],
5
- "mappings": "AAAA,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,OAAO,eAAe;AACtB,OAAO,SAAS,iBAAiB;AAEjC,OAAO,0BAA0B;AAEjC,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,WAAW,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOrB,gBAAgB,UAAU,UAAU,CAAC,U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,eAAS,QAAQ,CAAC,UAAU;AAC1B,cAAM,IAAI,UAAU,KAAK;AAAA,MAC3B,CAAC;AAAA,IACH,CAAC;AAED,UAAM,QAAQ,EAAE,UAAU;AAC1B,QACE,OAAO,mBAAmB,aACtB,eAAe,MAAM,IACrB,gBACJ;AACA,YAAM,WAAW,UAAU,YAAY,SAAS;AAChD,YAAM,iBAAiB,SAAS,QAAQ,CAAC,MAAM;AAC7C,eAAO,KAAK,YAAY,CAAC;AAAA,MAC3B,CAAC;AAAA,IACH;AAEA,SAAK,SAAS,KAAK;AAAA,EACrB;AACF;AAEA,UAAU,YAAY;AACtB,UAAU,eAAe;AAEzB,eAAe;",
4
+ "sourcesContent": ["import Layer from \"ol/layer/Layer\";\nimport { unByKey } from \"ol/Observable\";\nimport { getUid } from \"ol/util\";\nimport PropTypes from \"prop-types\";\nimport React, { Component } from \"react\";\n\nimport getLayersAsFlatArray from \"../../utils/getLayersAsFlatArray\";\n\nconst propTypes = {\n /**\n * CSS class to apply on the container.\n */\n className: PropTypes.string,\n\n /**\n * Boolean determining whether children collapse/expand when their parent is toggled\n * @param {...(boolean|function)} expandChildren Boolean or function returning a boolean.\n * @return {boolean} True or false\n */\n expandChildren: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),\n\n /**\n * Determine the className used by the div containing the parent and its children.\n */\n getParentClassName: PropTypes.func,\n\n /**\n * Determine if the item is hidden in the tree or not.\n *\n * @param {object} item The item to hide or not.\n *\n * @return {bool} true if the item is not displayed in the tree\n */\n isItemHidden: PropTypes.func,\n\n /**\n * Layers provider.\n */\n layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)),\n\n /**\n * Padding left to apply on each level.\n */\n padding: PropTypes.number,\n\n /**\n * Custom function to render custom content after the list of children of an item.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderAfterItem: PropTypes.func,\n\n /**\n * Custom function to render custom content before the list of children of an item.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderBeforeItem: PropTypes.func,\n\n /**\n * Custom function to render the checkbox.\n */\n renderCheckbox: PropTypes.func,\n\n /**\n * Custom function to render an item in the tree.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderItem: PropTypes.func,\n\n /**\n * Custom function to render only the content of an item in the tree.\n * inputProps und toggleProps can be used when calling the default renderItemContent function\n * (comp.renderItemContent(layer, inputProps, toggleProps)) to overwrite the default input and label props\n *\n * @param {Layer} layer The layer the item content is created for\n * @param {LayerTree} comp The LayerTree component.\n *\n * @return {node} A jsx node.\n */\n renderItemContent: PropTypes.func,\n\n /**\n * Custom function to render the label.\n *\n * @param {string} item The label to render.\n * @param {LayerTree} comp The LayerTree component.\n *\n * @return {node} A jsx node.\n */\n renderLabel: PropTypes.func,\n\n /**\n * Translation function.\n * @param {function} Translation function returning the translated string.\n */\n t: PropTypes.func,\n\n /**\n * Object holding title for the layer tree's buttons.\n */\n titles: PropTypes.shape({\n /**\n * aria-label on checkbox to hide layer.\n */\n layerHide: PropTypes.string,\n /**\n * aria-label on checkbox to show layer.\n */\n layerShow: PropTypes.string,\n /**\n * title on button to show sublayers.\n */\n subLayerHide: PropTypes.string,\n /**\n * title on button to show sublayers.\n */\n subLayerShow: PropTypes.string,\n }),\n};\n\nconst defaultProps = {\n className: \"rs-layer-tree\",\n expandChildren: false,\n getParentClassName: () => {\n return undefined;\n },\n isItemHidden: () => {\n return false;\n },\n layers: [],\n padding: 30,\n renderAfterItem: null,\n renderBeforeItem: null,\n renderCheckbox: null,\n renderItem: null,\n renderItemContent: null,\n renderLabel: (layer) => {\n return layer?.get(\"name\") || \"\";\n },\n t: (s) => {\n return s;\n },\n titles: {\n layerHide: \"Hide layer\",\n layerShow: \"Show layer\",\n subLayerHide: \"Hide sublayer\",\n subLayerShow: \"Show sublayer\",\n },\n};\n\n/**\n * The LayerTree component renders an interface for toggling layers visibility.\n * and their corresponding child layers.\n */\n\nclass LayerTree extends Component {\n constructor(props) {\n super(props);\n\n const { isItemHidden, layers } = this.props;\n const initialExpandedLayers = layers\n ? this.getExpandedLayers(\n layers.filter((l) => {\n return (\n !isItemHidden(l) &&\n LayerTree.getChildren(l)\n .filter((child) => {\n return LayerTree.getVisible(child);\n })\n .filter((c) => {\n return !isItemHidden(c);\n }).length\n );\n }),\n )\n : [];\n\n this.state = {\n expandedLayers: initialExpandedLayers,\n revision: 0,\n rootLayer: new Layer({}),\n };\n // this.updateLayers = this.updateLayers.bind(this);\n this.olKeys = [];\n }\n\n static getChildren = (layer) => {\n return (\n layer?.get(\"children\") ||\n layer?.children ||\n // ol.layer.group\n layer?.getLayers?.().getArray() ||\n []\n );\n };\n\n static getVisible = (layer) => {\n return layer.getVisible ? layer.getVisible() : layer.visible;\n };\n\n static listenGroups = (layers) => {\n const flat = getLayersAsFlatArray(layers);\n const keys = flat.map((layer) => {\n return layer.on(\"change:visible\", (e) => {\n const { target } = e;\n if (target.getVisible() && target.get(\"group\")) {\n flat.forEach((l) => {\n if (l.get(\"group\") === target.get(\"group\") && l !== target) {\n l.setVisible(false);\n }\n });\n }\n });\n });\n return keys;\n };\n\n static setVisible = (layer, visible) => {\n if (layer.setVisible) {\n layer.setVisible(visible);\n return;\n }\n\n layer.visible = visible;\n };\n\n componentDidMount() {\n this.updateLayers();\n }\n\n componentDidUpdate(prevProps) {\n const { layers } = this.props;\n\n if (layers !== prevProps.layers) {\n this.updateLayers();\n }\n }\n\n componentWillUnmount() {\n unByKey(this.olKeys);\n this.olKeys = [];\n }\n\n expandLayer(layer, expLayers = []) {\n const { isItemHidden } = this.props;\n if (LayerTree.getVisible(layer) && !isItemHidden(layer)) {\n const children = LayerTree.getChildren(layer)\n .filter((c) => {\n return !isItemHidden(c) && !c.get(\"isAlwaysExpanded\");\n })\n .flatMap((c) => {\n return this.expandLayer(c, expLayers);\n });\n return [...expLayers, ...children, layer];\n }\n return expLayers;\n }\n\n /**\n * Get the always expanded ancestors (isAlwaysExpanded=true) of the given layers\n * together with the (given) initially expanded layers\n *\n * @param {Layer} layers Initially expanded layers\n * @return {Array.<Layer>} Initially expanded layers and all its always expanded ancestors\n */\n getExpandedLayers(layers) {\n const { isItemHidden } = this.props;\n const children = layers.flatMap((l) => {\n return LayerTree.getChildren(l).filter((c) => {\n return !isItemHidden(c) && c.get(\"isAlwaysExpanded\");\n });\n });\n\n if (!children.length) {\n return layers;\n }\n return [...layers, this.getExpandedLayers(children)].flat();\n }\n\n onInputClick(layer, toggle = false) {\n if (toggle) {\n this.onToggle(layer);\n } else {\n LayerTree.setVisible(layer, !LayerTree.getVisible(layer));\n }\n }\n\n onToggle(layer) {\n const { expandedLayers } = this.state;\n const pos = expandedLayers.indexOf(layer);\n if (pos > -1) {\n expandedLayers.splice(pos, 1);\n } else {\n expandedLayers.push(...this.getExpandedLayers([layer]));\n }\n this.setState({ expandedLayers });\n }\n\n render() {\n const { className } = this.props;\n return <div className={className}>{this.renderTree()}</div>;\n }\n\n renderArrow(layer) {\n const { isItemHidden } = this.props;\n const { expandedLayers } = this.state;\n\n if (\n !LayerTree.getChildren(layer).filter((c) => {\n return !isItemHidden(c);\n }).length ||\n layer.get(\"isAlwaysExpanded\")\n ) {\n return null;\n }\n\n return (\n <div\n className={`rs-layer-tree-arrow rs-layer-tree-arrow-${\n !expandedLayers.includes(layer) ? \"collapsed\" : \"expanded\"\n }`}\n />\n );\n }\n\n renderInput(layer, inputProps) {\n const { isItemHidden, renderCheckbox, titles } = this.props;\n let tabIndex = 0;\n\n if (\n !LayerTree.getChildren(layer).filter((c) => {\n return !isItemHidden(c);\n }).length\n ) {\n // We forbid focus on keypress event for first level layers and layers without children.\n tabIndex = -1;\n }\n\n const inputType = layer.get(\"group\") ? \"radio\" : \"checkbox\";\n return renderCheckbox ? (\n renderCheckbox(layer, this, inputProps)\n ) : (\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n <label\n className={`rs-layer-tree-input rs-layer-tree-input-${inputType} rs-${inputType}`}\n onKeyPress={(e) => {\n if (e.which === 13) {\n this.onInputClick(layer);\n }\n }}\n tabIndex={tabIndex}\n title={\n LayerTree.getVisible(layer) ? titles.layerHide : titles.layerShow\n }\n >\n <input\n checked={LayerTree.getVisible(layer)}\n onClick={() => {\n return this.onInputClick(layer);\n }}\n readOnly\n tabIndex={-1}\n type={inputType}\n {...inputProps}\n />\n <span />\n </label>\n );\n }\n\n renderItem(layer, level) {\n const { isItemHidden } = this.props;\n const { expandedLayers } = this.state;\n const {\n getParentClassName,\n padding,\n renderAfterItem,\n renderBeforeItem,\n renderItem,\n renderItemContent,\n } = this.props;\n\n const children = expandedLayers.includes(layer)\n ? [\n ...LayerTree.getChildren(layer).filter((c) => {\n return !isItemHidden(c);\n }),\n ]\n : [];\n\n if (renderItem) {\n return renderItem(layer, this.onInputClick, this.onToggle);\n }\n\n return (\n <div\n className={getParentClassName()}\n key={\n layer.key || layer.get(\"key\") || layer.get(\"name\") || getUid(layer)\n }\n >\n <div\n className={`rs-layer-tree-item ${LayerTree.getVisible(layer) ? \"rs-visible\" : \"\"}`}\n style={{\n paddingLeft: `${padding * level}px`,\n }}\n >\n {renderItemContent\n ? renderItemContent(layer, this)\n : this.renderItemContent(layer)}\n </div>\n {renderBeforeItem?.(layer, level, this)}\n {[...children].reverse().map((child) => {\n return this.renderItem(child, level + 1);\n })}\n {renderAfterItem?.(layer, level, this)}\n </div>\n );\n }\n\n renderItemContent(layer, inputProps = {}, toggleProps = {}) {\n return (\n <>\n {this.renderInput(layer, inputProps)}\n {this.renderToggleButton(layer, toggleProps)}\n </>\n );\n }\n\n // Render a button which expands/collapse the layer if there is children\n // or simulate a click on the input otherwise.\n renderToggleButton(layer, toggleProps) {\n const { isItemHidden, renderLabel, titles } = this.props;\n const { expandedLayers } = this.state;\n\n const onInputClick = () => {\n this.onInputClick(\n layer,\n LayerTree.getChildren(layer).filter((c) => {\n return !isItemHidden(c);\n }).length && !layer.get(\"isAlwaysExpanded\"),\n );\n };\n const title = `${renderLabel(layer, this)} ${\n expandedLayers.includes(layer) ? titles.subLayerHide : titles.subLayerShow\n }`;\n\n return (\n <div\n aria-expanded={expandedLayers.includes(layer)}\n aria-label={title}\n className=\"rs-layer-tree-toggle\"\n onClick={onInputClick}\n onKeyPress={onInputClick}\n role=\"button\"\n tabIndex={0}\n title={title}\n {...toggleProps}\n >\n <div>{renderLabel(layer, this)}</div>\n {this.renderArrow(layer)}\n </div>\n );\n }\n\n renderTree() {\n const { isItemHidden } = this.props;\n const { rootLayer } = this.state;\n\n if (!LayerTree.getChildren(rootLayer).length) {\n return null;\n }\n\n return (\n <>\n {LayerTree.getChildren(rootLayer)\n .filter((l) => {\n return !isItemHidden(l);\n })\n .reverse()\n .map((l) => {\n return this.renderItem(l, 0);\n })}\n </>\n );\n }\n\n updateLayers() {\n const { expandChildren, layers } = this.props;\n\n // Update the root layer\n let rootLayer = new Layer({});\n if (Array.isArray(layers)) {\n if (layers.length === 1) {\n [rootLayer] = layers;\n }\n rootLayer = new Layer({ children: layers });\n } else {\n rootLayer = layers;\n }\n\n const flat = getLayersAsFlatArray(rootLayer);\n flat.forEach((layer) => {\n this.olKeys.push(\n layer.on(\"propertychange\", () => {\n const { revision } = this.state;\n this.setState({ revision: revision + 1 });\n }),\n\n // Manage group visibility\n layer.on(\"change:visible\", (evt) => {\n const { target } = evt;\n if (target.getVisible() && target.get(\"group\")) {\n flat.forEach((l) => {\n if (l.get(\"group\") === target.get(\"group\") && l !== target) {\n l.setVisible(false);\n }\n });\n }\n }),\n\n // Manage parent/children visibility\n layer.on(\"change:visible\", (evt) => {\n const { target } = evt;\n const parent = target.get(\"parent\");\n const children = LayerTree.getChildren(target);\n\n if (target.getVisible()) {\n // We make the parent visible\n if (parent) {\n parent.setVisible(true);\n }\n\n // If children doesn't contain any visible layers, we display all children.\n if (\n children &&\n !children.some((child) => {\n return child.getVisible();\n })\n ) {\n children.forEach((child) => {\n child.setVisible(true);\n });\n }\n } else {\n // We hide all the children\n children.forEach((child) => {\n child.setVisible(false);\n });\n\n // If the parent has no more visible child we also hide it.\n if (\n parent?.getVisible() &&\n !parent?.get(\"children\").find((child) => {\n return child.getVisible();\n })\n ) {\n parent.setVisible(false);\n }\n }\n }),\n );\n });\n\n // Set parent property.\n flat.forEach((layer) => {\n const children = LayerTree.getChildren(layer);\n children.forEach((child) => {\n child.set(\"parent\", layer);\n });\n });\n\n const state = { rootLayer };\n if (\n typeof expandChildren === \"function\"\n ? expandChildren(layers)\n : expandChildren\n ) {\n const children = LayerTree.getChildren(rootLayer);\n state.expandedLayers = children.flatMap((l) => {\n return this.expandLayer(l);\n });\n }\n\n this.setState(state);\n }\n}\n\nLayerTree.propTypes = propTypes;\nLayerTree.defaultProps = defaultProps;\n\nexport default LayerTree;\n"],
5
+ "mappings": "AAoTW,SA0HL,UA1HK,KA2CL,YA3CK;AApTX,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,OAAO,eAAe;AACtB,OAAO,SAAS,iBAAiB;AAEjC,OAAO,0BAA0B;AAEjC,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,WAAW,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOrB,gBAAgB,UAAU,UAAU,CAAC,UAAU,MAAM,UAAU,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA,EAKpE,oBAAoB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS9B,cAAc,UAAU;AAAA;AAAA;AAAA;AAAA,EAKxB,QAAQ,UAAU,QAAQ,UAAU,WAAW,KAAK,CAAC;AAAA;AAAA;AAAA;AAAA,EAKrD,SAAS,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASnB,iBAAiB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS3B,kBAAkB,UAAU;AAAA;AAAA;AAAA;AAAA,EAK5B,gBAAgB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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;AAAA,EACrB;AACF;AAEA,UAAU,YAAY;AACtB,UAAU,eAAe;AAEzB,eAAe;",
6
6
  "names": []
7
7
  }
@@ -1,3 +1,4 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
1
2
  import OLMousePosition from "ol/control/MousePosition";
2
3
  import { createStringXY } from "ol/coordinate";
3
4
  import OLMap from "ol/Map";
@@ -119,23 +120,23 @@ function MousePosition({
119
120
  },
120
121
  [onChange, projections]
121
122
  );
122
- if (!projection || !projections || !projections.length) {
123
+ if (!projection || !projections?.length) {
123
124
  return null;
124
125
  }
125
- return (
126
- // eslint-disable-next-line react/jsx-props-no-spreading
127
- /* @__PURE__ */ React.createElement("div", { className: "rs-mouse-position", ...other }, /* @__PURE__ */ React.createElement(
126
+ return /* @__PURE__ */ jsxs("div", { className: "rs-mouse-position", ...other, children: [
127
+ /* @__PURE__ */ jsx(
128
128
  "select",
129
129
  {
130
130
  className: "rs-select",
131
131
  onChange: onChangeCb,
132
- value: projection.value
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", { className: "rs-coordinates", ref }))
138
- );
132
+ value: projection.value,
133
+ children: projections.map((option) => {
134
+ return /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value);
135
+ })
136
+ }
137
+ ),
138
+ /* @__PURE__ */ jsx("span", { className: "rs-coordinates", ref })
139
+ ] });
139
140
  }
140
141
  MousePosition.propTypes = propTypes;
141
142
  export default React.memo(MousePosition);