react-spatial 1.8.2 → 1.9.0

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/README.md CHANGED
@@ -2,11 +2,10 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/react-spatial.svg?style=flat-square)](https://www.npmjs.com/package/react-spatial)
4
4
  [![build](https://github.com/geops/react-spatial/workflows/main/badge.svg)](https://github.com/geops/react-spatial/actions?query=workflow%3Amain)
5
- [![Renovate](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com)
6
5
  [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
7
6
  ![Vercel](https://vercelbadge.vercel.app/api/geops/react-spatial)
8
7
 
9
- This library provides React components to build web applications and to visualize real-time geographical information based on [OpenLayers](https://openlayers.org/) and [Mapbox GL](https://docs.mapbox.com/mapbox-gl-js/api/).
8
+ This library provides React components to build web applications and to visualize real-time geographical information based on [OpenLayers](https://openlayers.org/) and [Malibre GL](https://maplibre.org/maplibre-gl-js/).
10
9
 
11
10
  This library uses the [mobility-toolbox-js](https://mobility-toolbox-js.geops.io/) library.
12
11
 
@@ -99,17 +99,17 @@ class Geolocation extends PureComponent {
99
99
  const { onError } = this.props;
100
100
  const geolocation = "geolocation" in navigator;
101
101
  if (!geolocation) {
102
- onError();
102
+ onError(new Error("Geolocation not supported"));
103
103
  } else if (!active) {
104
104
  this.activate();
105
105
  } else {
106
106
  this.deactivate();
107
107
  }
108
108
  }
109
- error() {
109
+ error(error) {
110
110
  const { onError } = this.props;
111
111
  this.deactivate();
112
- onError();
112
+ onError(error);
113
113
  }
114
114
  deactivate() {
115
115
  const { map, onDeactivate } = this.props;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/Geolocation/Geolocation.js"],
4
- "sourcesContent": ["import React, { PureComponent } from \"react\";\nimport PropTypes from \"prop-types\";\n\nimport OLMap from \"ol/Map\";\nimport { transform } from \"ol/proj\";\nimport Point from \"ol/geom/Point\";\nimport Feature from \"ol/Feature\";\nimport { unByKey } from \"ol/Observable\";\n\nimport Style from \"ol/style/Style\";\nimport Circle from \"ol/style/Circle\";\nimport Fill from \"ol/style/Fill\";\nimport Stroke from \"ol/style/Stroke\";\n\nimport VectorLayer from \"ol/layer/Vector\";\nimport VectorSource from \"ol/source/Vector\";\n\nimport { FaRegDotCircle } from \"react-icons/fa\";\n\nconst propTypes = {\n /**\n * CSS class of the button.\n */\n className: PropTypes.string,\n\n /**\n * Children content of the Geolocation button.\n */\n children: PropTypes.node,\n\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * Function triggered 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 /**\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 * If true, the map is not centered after it has been dragged once.\n */\n noCenterAfterDrag: PropTypes.bool,\n\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 * If true, the map will never center to the current position\n */\n neverCenterToPosition: PropTypes.bool,\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\nconst defaultProps = {\n className: \"rs-geolocation\",\n children: <FaRegDotCircle focusable={false} />,\n onError: () => {},\n onSuccess: () => {},\n onActivate: () => {},\n onDeactivate: () => {},\n noCenterAfterDrag: false,\n alwaysRecenterToPosition: true,\n neverCenterToPosition: false,\n colorOrStyleFunc: [235, 0, 0],\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 componentWillUnmount() {\n this.deactivate();\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();\n } else if (!active) {\n this.activate();\n } else {\n this.deactivate();\n }\n }\n\n error() {\n const { onError } = this.props;\n\n this.deactivate();\n onError();\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 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 update({ coords: { latitude, longitude } }) {\n const { map, alwaysRecenterToPosition, 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 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 radius: 20,\n rotation,\n fill: new Fill({\n color: \"rgba(255, 255, 255, 0.01)\",\n }),\n stroke: new Stroke({\n lineDash: [30, 10],\n width: 6,\n color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, ${opacity})`,\n }),\n }),\n });\n\n circleStyle.getImage().setRotation(rotation);\n\n return [\n new Style({\n image: new Circle({\n radius: 10,\n fill: new Fill({\n color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.5)`,\n }),\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 role=\"button\"\n tabIndex=\"0\"\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 // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n >\n {children}\n </div>\n );\n }\n}\n\nGeolocation.propTypes = propTypes;\nGeolocation.defaultProps = defaultProps;\n\nex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OAAO,IAAI,KAAK;AAExB,WACE;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,UAAS;AAAA,QACT,WAAW,GAAG,SAAS,IAAI,SAAS,cAAc,EAAE;AAAA,QACpD,SAAS,MAAM;AACb,iBAAO,KAAK,OAAO;AAAA,QACrB;AAAA,QACA,YAAY,CAAC,MAAM;AACjB,iBAAO,EAAE,UAAU,MAAM,KAAK,OAAO;AAAA,QACvC;AAAA,QAEC,GAAG;AAAA;AAAA,MAEH;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,YAAY,YAAY;AACxB,YAAY,eAAe;AAE3B,eAAe;",
4
+ "sourcesContent": ["import React, { PureComponent } from \"react\";\nimport PropTypes from \"prop-types\";\n\nimport OLMap from \"ol/Map\";\nimport { transform } from \"ol/proj\";\nimport Point from \"ol/geom/Point\";\nimport Feature from \"ol/Feature\";\nimport { unByKey } from \"ol/Observable\";\n\nimport Style from \"ol/style/Style\";\nimport Circle from \"ol/style/Circle\";\nimport Fill from \"ol/style/Fill\";\nimport Stroke from \"ol/style/Stroke\";\n\nimport VectorLayer from \"ol/layer/Vector\";\nimport VectorSource from \"ol/source/Vector\";\n\nimport { FaRegDotCircle } from \"react-icons/fa\";\n\nconst propTypes = {\n /**\n * CSS class of the button.\n */\n className: PropTypes.string,\n\n /**\n * Children content of the Geolocation button.\n */\n children: PropTypes.node,\n\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * Function triggered 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 /**\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 * If true, the map is not centered after it has been dragged once.\n */\n noCenterAfterDrag: PropTypes.bool,\n\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 * If true, the map will never center to the current position\n */\n neverCenterToPosition: PropTypes.bool,\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\nconst defaultProps = {\n className: \"rs-geolocation\",\n children: <FaRegDotCircle focusable={false} />,\n onError: () => {},\n onSuccess: () => {},\n onActivate: () => {},\n onDeactivate: () => {},\n noCenterAfterDrag: false,\n alwaysRecenterToPosition: true,\n neverCenterToPosition: false,\n colorOrStyleFunc: [235, 0, 0],\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 componentWillUnmount() {\n this.deactivate();\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 error(error) {\n const { onError } = this.props;\n\n this.deactivate();\n onError(error);\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 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 update({ coords: { latitude, longitude } }) {\n const { map, alwaysRecenterToPosition, 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 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 radius: 20,\n rotation,\n fill: new Fill({\n color: \"rgba(255, 255, 255, 0.01)\",\n }),\n stroke: new Stroke({\n lineDash: [30, 10],\n width: 6,\n color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, ${opacity})`,\n }),\n }),\n });\n\n circleStyle.getImage().setRotation(rotation);\n\n return [\n new Style({\n image: new Circle({\n radius: 10,\n fill: new Fill({\n color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.5)`,\n }),\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 role=\"button\"\n tabIndex=\"0\"\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 // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n >\n {children}\n </div>\n );\n }\n}\n\nGeolocation.propTypes = propTypes;\nGeolocation.defaultProps = defaultProps;\n\nexport default Geolocation;\n"],
5
+ "mappings": "AAAA,OAAO,SAAS,qBAAqB;AACrC,OAAO,eAAe;AAEtB,OAAO,WAAW;AAClB,SAAS,iBAAiB;AAC1B,OAAO,WAAW;AAClB,OAAO,aAAa;AACpB,SAAS,eAAe;AAExB,OAAO,WAAW;AAClB,OAAO,YAAY;AACnB,OAAO,UAAU;AACjB,OAAO,YAAY;AAEnB,OAAO,iBAAiB;AACxB,OAAO,kBAAkB;AAEzB,SAAS,sBAAsB;AAE/B,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,WAAW,UAAU;AAAA;AAAA;AAAA;AAAA,EAKrB,UAAU,UAAU;AAAA;AAAA;AAAA;AAAA,EAKpB,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA;AAAA;AAAA;AAAA,EAKjC,SAAS,UAAU;AAAA;AAAA;AAAA;AAAA,EAKnB,WAAW,UAAU;AAAA;AAAA;AAAA;AAAA,EAKrB,YAAY,UAAU;AAAA;AAAA;AAAA;AAAA,EAKtB,cAAc,UAAU;AAAA;AAAA;AAAA;AAAA,EAKxB,mBAAmB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAM7B,0BAA0B,UAAU;AAAA;AAAA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C;AAAA,cACnD,CAAC;AAAA,YACH,CAAC;AAAA,UACH,CAAC;AAAA,UACD;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH,OAAO;AACL,cAAQ,SAAS,gBAAgB;AAAA,IACnC;AAEA,SAAK,MAAM,UAAU,EAAE,MAAM;AAC7B,SAAK,MAAM,UAAU,EAAE,WAAW,OAAO;AAAA,EAC3C;AAAA,EAEA,SAAS;AACP,UAAM,EAAE,UAAU,UAAU,IAAI,KAAK;AAErC,UAAM,QAAQ,OAAO,QAAQ,KAAK,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,KAAK,MAAM;AACvE,aAAO,UAAU,GAAG,IAAI,QAAQ,EAAE,GAAG,OAAO,CAAC,GAAG,GAAG,MAAM;AAAA,IAC3D,GAAG,CAAC,CAAC;AACL,UAAM,EAAE,OAAO,IAAI,KAAK;AAExB,WACE;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,UAAS;AAAA,QACT,WAAW,GAAG,SAAS,IAAI,SAAS,cAAc,EAAE;AAAA,QACpD,SAAS,MAAM;AACb,iBAAO,KAAK,OAAO;AAAA,QACrB;AAAA,QACA,YAAY,CAAC,MAAM;AACjB,iBAAO,EAAE,UAAU,MAAM,KAAK,OAAO;AAAA,QACvC;AAAA,QAEC,GAAG;AAAA;AAAA,MAEH;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,YAAY,YAAY;AACxB,YAAY,eAAe;AAE3B,eAAe;",
6
6
  "names": []
7
7
  }
@@ -71,6 +71,10 @@ const propTypes = {
71
71
  * @return {node} A jsx node.
72
72
  */
73
73
  renderLabel: PropTypes.func,
74
+ /**
75
+ * Custom function to render the checkbox.
76
+ */
77
+ renderCheckbox: PropTypes.func,
74
78
  /**
75
79
  * Object holding title for the layer tree's buttons.
76
80
  */
@@ -118,6 +122,7 @@ const defaultProps = {
118
122
  renderItemContent: null,
119
123
  renderBeforeItem: null,
120
124
  renderAfterItem: null,
125
+ renderCheckbox: null,
121
126
  renderLabel: (layer, layerComp) => {
122
127
  const { t } = layerComp.props;
123
128
  return t(layer.name);
@@ -244,7 +249,7 @@ class LayerTree extends Component {
244
249
  return expLayers;
245
250
  }
246
251
  renderInput(layer, inputProps) {
247
- const { titles, isItemHidden } = this.props;
252
+ const { titles, isItemHidden, renderCheckbox } = this.props;
248
253
  let tabIndex = 0;
249
254
  if (!(layer.children || []).filter((c) => {
250
255
  return !isItemHidden(c);
@@ -252,7 +257,7 @@ class LayerTree extends Component {
252
257
  tabIndex = -1;
253
258
  }
254
259
  const inputType = layer.get("group") ? "radio" : "checkbox";
255
- return (
260
+ return renderCheckbox ? renderCheckbox(layer, this, inputProps) : (
256
261
  // eslint-disable-next-line jsx-a11y/label-has-associated-control,jsx-a11y/no-noninteractive-element-interactions
257
262
  /* @__PURE__ */ React.createElement(
258
263
  "label",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/LayerTree/LayerTree.js"],
4
- "sourcesContent": ["import React, { Component } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { Layer, getLayersAsFlatArray } from \"mobility-toolbox-js/ol\";\nimport { unByKey } from \"ol/Observable\";\n\nconst propTypes = {\n /**\n * Layers provider.\n */\n layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)),\n\n /**\n * CSS class to apply on the container.\n */\n className: PropTypes.string,\n\n /**\n * Padding left to apply on each level.\n */\n padding: PropTypes.number,\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 * Determine the className used by the div containing the parent and its children.\n */\n getParentClassName: 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 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 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 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 * Object holding title for the layer tree's buttons.\n */\n titles: PropTypes.shape({\n /**\n * aria-label on checkbox to show layer.\n */\n layerShow: PropTypes.string,\n /**\n * aria-label on checkbox to hide layer.\n */\n layerHide: PropTypes.string,\n /**\n * title on button to show sublayers.\n */\n subLayerShow: PropTypes.string,\n /**\n * title on button to show sublayers.\n */\n subLayerHide: PropTypes.string,\n }),\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 * Translation function.\n * @param {function} Translation function returning the translated string.\n */\n t: PropTypes.func,\n};\n\nconst defaultProps = {\n layers: [],\n className: \"rs-layer-tree\",\n padding: 30,\n isItemHidden: () => {\n return false;\n },\n getParentClassName: () => {\n return undefined;\n },\n renderItem: null,\n renderItemContent: null,\n renderBeforeItem: null,\n renderAfterItem: null,\n renderLabel: (layer, layerComp) => {\n const { t } = layerComp.props;\n return t(layer.name);\n },\n titles: {\n layerShow: \"Show layer\",\n layerHide: \"Hide layer\",\n subLayerShow: \"Show sublayer\",\n subLayerHide: \"Hide sublayer\",\n },\n t: (s) => {\n return s;\n },\n expandChildren: false,\n};\n\n/**\n * The LayerTree component renders an interface for toggling\n * [mobility-toolbox-js layers](https://mobility-toolbox-js.geops.io/api/identifiers%20html#ol-layers)\n * and their corresponding child layers.\n */\n\nclass LayerTree extends Component {\n constructor(props) {\n super(props);\n\n const { layers, isItemHidden } = this.props;\n const initialExpandedLayers = layers\n ? this.getExpandedLayers(\n layers.filter((l) => {\n return (\n !isItemHidden(l) &&\n (l.children || [])\n .filter((child) => {\n return child.visible;\n })\n .filter((c) => {\n return !isItemHidden(c);\n }).length\n );\n }),\n )\n : [];\n\n this.state = {\n rootLayer: new Layer(),\n expandedLayers: initialExpandedLayers,\n revision: 0,\n };\n // this.updateLayers = this.updateLayers.bind(this);\n this.olKeys = [];\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 onInputClick(layer, toggle = false) {\n if (toggle) {\n this.onToggle(layer);\n } else if (layer.setVisible) {\n layer.setVisible(!layer.visible);\n } else {\n // eslint-disable-next-line no-param-reassign\n layer.visible = !layer.visible;\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 /**\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 l.children.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 updateLayers() {\n const { layers, expandChildren } = 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 getLayersAsFlatArray(rootLayer).forEach((layer) => {\n this.olKeys.push(\n layer.on(\"propertychange\", () => {\n const { revision } = this.state;\n this.setState({ revision: revision + 1 });\n }),\n );\n });\n\n const state = { rootLayer };\n if (\n typeof expandChildren === \"function\"\n ? expandChildren(layers)\n : expandChildren\n ) {\n state.expandedLayers = rootLayer.children.flatMap((l) => {\n return this.expandLayer(l);\n });\n }\n\n this.setState(state);\n }\n\n expandLayer(layer, expLayers = []) {\n const { isItemHidden } = this.props;\n if (layer.visible && !isItemHidden(layer)) {\n const children = layer.children\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 renderInput(layer, inputProps) {\n const { titles, isItemHidden } = this.props;\n let tabIndex = 0;\n\n if (\n !(layer.children || []).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 (\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 tabIndex={tabIndex}\n title={layer.visible ? titles.layerHide : titles.layerShow}\n aria-label={layer.visible ? titles.layerHide : titles.layerShow}\n onKeyPress={(e) => {\n if (e.which === 13) {\n this.onInputClick(layer);\n }\n }}\n >\n <input\n type={inputType}\n tabIndex={-1}\n checked={layer.visible}\n readOnly\n onClick={() => {\n return this.onInputClick(layer);\n }}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...inputProps}\n />\n <span />\n </label>\n );\n }\n\n renderArrow(layer) {\n const { isItemHidden } = this.props;\n const { expandedLayers } = this.state;\n\n if (\n !(layer.children || []).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 // 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 { t, titles, isItemHidden, renderLabel } = this.props;\n const { expandedLayers } = this.state;\n\n const onInputClick = () => {\n this.onInputClick(\n layer,\n (layer.children || []).filter((c) => {\n return !isItemHidden(c);\n }).length && !layer.get(\"isAlwaysExpanded\"),\n );\n };\n const title = `${t(layer.name)} ${\n expandedLayers.includes(layer) ? titles.subLayerHide : titles.subLayerShow\n }`;\n\n return (\n <div\n role=\"button\"\n tabIndex={0}\n className=\"rs-layer-tree-toggle\"\n title={title}\n aria-expanded={expandedLayers.includes(layer)}\n aria-label={title}\n onClick={onInputClick}\n onKeyPress={onInputClick}\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 renderItemContent(layer, inputProps = {}, toggleProps = {}) {\n return (\n <>\n {this.renderInput(layer, inputProps)}\n {this.renderToggleButton(layer, toggleProps)}\n </>\n );\n }\n\n renderItem(layer, level) {\n const { isItemHidden } = this.props;\n const { expandedLayers } = this.state;\n const {\n renderItem,\n renderItemContent,\n renderBeforeItem,\n renderAfterItem,\n padding,\n getParentClassName,\n } = this.props;\n\n const children = expandedLayers.includes(layer)\n ? [\n ...(layer.children || []).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 className={getParentClassName()} key={layer.key}>\n <div\n className={`rs-layer-tree-item ${layer.visible ? \"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 renderTree() {\n const { isItemHidden } = this.props;\n const { rootLayer } = this.state;\n\n if (!rootLayer?.children?.length) {\n return null;\n }\n\n return (\n <>\n {rootLayer.children\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 render() {\n const { className } = this.props;\n return <div className={className}>{this.renderTree()}</div>;\n }\n}\n\nLayerTree.propTypes = propTypes;\nLayerTree.defaultProps = defaultProps;\n\nexport default LayerTree;\n"],
5
- "mappings": "AAAA,OAAO,SAAS,iBAAiB;AACjC,OAAO,eAAe;AACtB,SAAS,OAAO,4BAA4B;AAC5C,SAAS,eAAe;AAExB,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,QAAQ,UAAU,QAAQ,UAAU,WAAW,KAAK,CAAC;AAAA;AAAA;AAAA;AAAA,EAKrD,WAAW,UAAU;AAAA;AAAA;AAAA;AAAA,EAKrB,SAAS,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASnB,cAAc,UAAU;AAAA;AAAA;AAAA;AAAA,EAKxB,oBAAoB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS9B,YAAY,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYtB,mBAAmB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS7B,kBAAkB,UAAU;AAAA;AAAA;AAAA;AAAA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AC;AAAA,IAC7B,CAAC,CACL;AAAA,EAEJ;AAAA,EAEA,SAAS;AACP,UAAM,EAAE,UAAU,IAAI,KAAK;AAC3B,WAAO,oCAAC,SAAI,aAAuB,KAAK,WAAW,CAAE;AAAA,EACvD;AACF;AAEA,UAAU,YAAY;AACtB,UAAU,eAAe;AAEzB,eAAe;",
4
+ "sourcesContent": ["import React, { Component } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { Layer, getLayersAsFlatArray } from \"mobility-toolbox-js/ol\";\nimport { unByKey } from \"ol/Observable\";\n\nconst propTypes = {\n /**\n * Layers provider.\n */\n layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)),\n\n /**\n * CSS class to apply on the container.\n */\n className: PropTypes.string,\n\n /**\n * Padding left to apply on each level.\n */\n padding: PropTypes.number,\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 * Determine the className used by the div containing the parent and its children.\n */\n getParentClassName: 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 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 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 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 * Custom function to render the checkbox.\n */\n renderCheckbox: 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 show layer.\n */\n layerShow: PropTypes.string,\n /**\n * aria-label on checkbox to hide layer.\n */\n layerHide: PropTypes.string,\n /**\n * title on button to show sublayers.\n */\n subLayerShow: PropTypes.string,\n /**\n * title on button to show sublayers.\n */\n subLayerHide: PropTypes.string,\n }),\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 * Translation function.\n * @param {function} Translation function returning the translated string.\n */\n t: PropTypes.func,\n};\n\nconst defaultProps = {\n layers: [],\n className: \"rs-layer-tree\",\n padding: 30,\n isItemHidden: () => {\n return false;\n },\n getParentClassName: () => {\n return undefined;\n },\n renderItem: null,\n renderItemContent: null,\n renderBeforeItem: null,\n renderAfterItem: null,\n renderCheckbox: null,\n renderLabel: (layer, layerComp) => {\n const { t } = layerComp.props;\n return t(layer.name);\n },\n titles: {\n layerShow: \"Show layer\",\n layerHide: \"Hide layer\",\n subLayerShow: \"Show sublayer\",\n subLayerHide: \"Hide sublayer\",\n },\n t: (s) => {\n return s;\n },\n expandChildren: false,\n};\n\n/**\n * The LayerTree component renders an interface for toggling\n * [mobility-toolbox-js layers](https://mobility-toolbox-js.geops.io/api/identifiers%20html#ol-layers)\n * and their corresponding child layers.\n */\n\nclass LayerTree extends Component {\n constructor(props) {\n super(props);\n\n const { layers, isItemHidden } = this.props;\n const initialExpandedLayers = layers\n ? this.getExpandedLayers(\n layers.filter((l) => {\n return (\n !isItemHidden(l) &&\n (l.children || [])\n .filter((child) => {\n return child.visible;\n })\n .filter((c) => {\n return !isItemHidden(c);\n }).length\n );\n }),\n )\n : [];\n\n this.state = {\n rootLayer: new Layer(),\n expandedLayers: initialExpandedLayers,\n revision: 0,\n };\n // this.updateLayers = this.updateLayers.bind(this);\n this.olKeys = [];\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 onInputClick(layer, toggle = false) {\n if (toggle) {\n this.onToggle(layer);\n } else if (layer.setVisible) {\n layer.setVisible(!layer.visible);\n } else {\n // eslint-disable-next-line no-param-reassign\n layer.visible = !layer.visible;\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 /**\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 l.children.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 updateLayers() {\n const { layers, expandChildren } = 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 getLayersAsFlatArray(rootLayer).forEach((layer) => {\n this.olKeys.push(\n layer.on(\"propertychange\", () => {\n const { revision } = this.state;\n this.setState({ revision: revision + 1 });\n }),\n );\n });\n\n const state = { rootLayer };\n if (\n typeof expandChildren === \"function\"\n ? expandChildren(layers)\n : expandChildren\n ) {\n state.expandedLayers = rootLayer.children.flatMap((l) => {\n return this.expandLayer(l);\n });\n }\n\n this.setState(state);\n }\n\n expandLayer(layer, expLayers = []) {\n const { isItemHidden } = this.props;\n if (layer.visible && !isItemHidden(layer)) {\n const children = layer.children\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 renderInput(layer, inputProps) {\n const { titles, isItemHidden, renderCheckbox } = this.props;\n let tabIndex = 0;\n\n if (\n !(layer.children || []).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 tabIndex={tabIndex}\n title={layer.visible ? titles.layerHide : titles.layerShow}\n aria-label={layer.visible ? titles.layerHide : titles.layerShow}\n onKeyPress={(e) => {\n if (e.which === 13) {\n this.onInputClick(layer);\n }\n }}\n >\n <input\n type={inputType}\n tabIndex={-1}\n checked={layer.visible}\n readOnly\n onClick={() => {\n return this.onInputClick(layer);\n }}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...inputProps}\n />\n <span />\n </label>\n );\n }\n\n renderArrow(layer) {\n const { isItemHidden } = this.props;\n const { expandedLayers } = this.state;\n\n if (\n !(layer.children || []).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 // 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 { t, titles, isItemHidden, renderLabel } = this.props;\n const { expandedLayers } = this.state;\n\n const onInputClick = () => {\n this.onInputClick(\n layer,\n (layer.children || []).filter((c) => {\n return !isItemHidden(c);\n }).length && !layer.get(\"isAlwaysExpanded\"),\n );\n };\n const title = `${t(layer.name)} ${\n expandedLayers.includes(layer) ? titles.subLayerHide : titles.subLayerShow\n }`;\n\n return (\n <div\n role=\"button\"\n tabIndex={0}\n className=\"rs-layer-tree-toggle\"\n title={title}\n aria-expanded={expandedLayers.includes(layer)}\n aria-label={title}\n onClick={onInputClick}\n onKeyPress={onInputClick}\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 renderItemContent(layer, inputProps = {}, toggleProps = {}) {\n return (\n <>\n {this.renderInput(layer, inputProps)}\n {this.renderToggleButton(layer, toggleProps)}\n </>\n );\n }\n\n renderItem(layer, level) {\n const { isItemHidden } = this.props;\n const { expandedLayers } = this.state;\n const {\n renderItem,\n renderItemContent,\n renderBeforeItem,\n renderAfterItem,\n padding,\n getParentClassName,\n } = this.props;\n\n const children = expandedLayers.includes(layer)\n ? [\n ...(layer.children || []).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 className={getParentClassName()} key={layer.key}>\n <div\n className={`rs-layer-tree-item ${layer.visible ? \"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 renderTree() {\n const { isItemHidden } = this.props;\n const { rootLayer } = this.state;\n\n if (!rootLayer?.children?.length) {\n return null;\n }\n\n return (\n <>\n {rootLayer.children\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 render() {\n const { className } = this.props;\n return <div className={className}>{this.renderTree()}</div>;\n }\n}\n\nLayerTree.propTypes = propTypes;\nLayerTree.defaultProps = defaultProps;\n\nexport default LayerTree;\n"],
5
+ "mappings": "AAAA,OAAO,SAAS,iBAAiB;AACjC,OAAO,eAAe;AACtB,SAAS,OAAO,4BAA4B;AAC5C,SAAS,eAAe;AAExB,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,QAAQ,UAAU,QAAQ,UAAU,WAAW,KAAK,CAAC;AAAA;AAAA;AAAA;AAAA,EAKrD,WAAW,UAAU;AAAA;AAAA;AAAA;AAAA,EAKrB,SAAS,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASnB,cAAc,UAAU;AAAA;AAAA;AAAA;AAAA,EAKxB,oBAAoB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS9B,YAAY,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYtB,mBAAmB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS7B,kBAAkB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS5B,iBAAiB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAU3B,aAAa,UAAU;AAAA;AAAA;AAAA;AAAA,EAKvB,gBAAgB,UAAU;AAAA;AAAA;AAAA;AAAA,EAK1B,QAAQ,UAAU,MAAM;AAAA;AAAA;AAAA;AAAA,IAItB,WAAW,UAAU;AAAA;AAAA;AAAA;A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UAAU,YAAY;AACtB,UAAU,eAAe;AAEzB,eAAe;",
6
6
  "names": []
7
7
  }
@@ -1,24 +1,20 @@
1
1
  import React, { useMemo, useState, useEffect } from "react";
2
2
  import PropTypes from "prop-types";
3
- import { Autocomplete } from "@material-ui/lab";
3
+ import { Autocomplete, autocompleteClasses, styled } from "@mui/material";
4
4
  import { FaSearch } from "react-icons/fa";
5
- import TextField from "@material-ui/core/TextField";
6
- import CircularProgress from "@material-ui/core/CircularProgress";
5
+ import TextField from "@mui/material/TextField";
6
+ import CircularProgress from "@mui/material/CircularProgress";
7
7
  import { StopFinderControl } from "mobility-toolbox-js/ol";
8
8
  import { Map } from "ol";
9
- import { makeStyles } from "@material-ui/core";
10
- import StopsFinderOptions from "./StopsFinderOption";
11
- const useStyles = makeStyles(() => {
12
- return {
13
- popupIndicatorOpen: {
14
- transform: "rotate(0)"
15
- }
16
- };
17
- });
9
+ import StopsFinderOption from "./StopsFinderOption";
10
+ const StyledAutocomplete = styled(Autocomplete)(() => ({
11
+ [`&.${autocompleteClasses.popupIndicatorOpen}`]: {
12
+ transform: "rotate(0)"
13
+ }
14
+ }));
18
15
  function StopsFinder({
19
16
  agencies,
20
17
  apiKey,
21
- autocompleteProps,
22
18
  bbox,
23
19
  field,
24
20
  limit,
@@ -28,9 +24,10 @@ function StopsFinder({
28
24
  radius,
29
25
  refLocation,
30
26
  renderAutocomplete,
31
- url
27
+ url,
28
+ textFieldProps,
29
+ ...props
32
30
  }) {
33
- const classes = useStyles();
34
31
  const [inputValue, setInputValue] = useState("");
35
32
  const [suggestions, setSuggestions] = useState([]);
36
33
  const [isLoading, setLoading] = useState(false);
@@ -104,13 +101,8 @@ function StopsFinder({
104
101
  setLoading
105
102
  );
106
103
  }
107
- const textFieldProps = {
108
- ...(autocompleteProps || {}).textFieldProps || {}
109
- };
110
- const autocProps = { ...autocompleteProps };
111
- delete autocProps.textFieldProps;
112
104
  return /* @__PURE__ */ React.createElement(
113
- Autocomplete,
105
+ StyledAutocomplete,
114
106
  {
115
107
  fullWidth: true,
116
108
  autoComplete: true,
@@ -120,7 +112,7 @@ function StopsFinder({
120
112
  return option.properties.name;
121
113
  },
122
114
  onChange: (evt, value, reason) => {
123
- if (onSelect && reason === "select-option") {
115
+ if (onSelect && reason === "selectOption") {
124
116
  onSelect(value, evt);
125
117
  }
126
118
  },
@@ -130,10 +122,8 @@ function StopsFinder({
130
122
  TextField,
131
123
  {
132
124
  label: "Search stops",
133
- ...{
134
- ...params,
135
- ...textFieldProps
136
- },
125
+ ...params,
126
+ ...textFieldProps,
137
127
  InputProps: {
138
128
  ...params.InputProps,
139
129
  endAdornment: /* @__PURE__ */ React.createElement(React.Fragment, null, isLoading && /* @__PURE__ */ React.createElement(CircularProgress, { size: 20 }), params.InputProps.endAdornment)
@@ -141,11 +131,17 @@ function StopsFinder({
141
131
  }
142
132
  );
143
133
  },
144
- renderOption: (option) => {
145
- return /* @__PURE__ */ React.createElement(StopsFinderOptions, { option });
134
+ renderOption: (liProps, option) => {
135
+ return /* @__PURE__ */ React.createElement(
136
+ StopsFinderOption,
137
+ {
138
+ key: option.properties?.name,
139
+ option,
140
+ ...liProps
141
+ }
142
+ );
146
143
  },
147
- ...autocProps,
148
- classes: { ...classes, ...autocompleteProps.classes },
144
+ ...props,
149
145
  inputValue,
150
146
  open: isOpen,
151
147
  options: suggestions,
@@ -177,10 +173,9 @@ StopsFinder.propTypes = {
177
173
  */
178
174
  apiKey: PropTypes.string,
179
175
  /**
180
- * Properties apply to the default [MUI Autocomplete component](https://material-ui.com/api/autocomplete/).
181
- * We add a custom properties textFieldProps for the default [MUI TextField component](https://material-ui.com/api/text-field/) used by the Autocomplete.
176
+ * Properties apply to the default [MUI TextField component](https://material-ui.com/api/text-field/) used by the Autocomplete.
182
177
  */
183
- autocompleteProps: PropTypes.object,
178
+ textFieldProps: PropTypes.object,
184
179
  /**
185
180
  * minX,minY,maxX,maxY coordinates in WGS84 wherein the station should lie.
186
181
  */
@@ -241,7 +236,7 @@ StopsFinder.propTypes = {
241
236
  StopsFinder.defaultProps = {
242
237
  agencies: null,
243
238
  apiKey: null,
244
- autocompleteProps: {},
239
+ textFieldProps: {},
245
240
  bbox: null,
246
241
  field: null,
247
242
  limit: null,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/StopsFinder/StopsFinder.js"],
4
- "sourcesContent": ["import React, { useMemo, useState, useEffect } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { Autocomplete } from \"@material-ui/lab\";\nimport { FaSearch } from \"react-icons/fa\";\nimport TextField from \"@material-ui/core/TextField\";\nimport CircularProgress from \"@material-ui/core/CircularProgress\";\nimport { StopFinderControl } from \"mobility-toolbox-js/ol\";\nimport { Map } from \"ol\";\nimport { makeStyles } from \"@material-ui/core\";\nimport StopsFinderOptions from \"./StopsFinderOption\";\n\nconst useStyles = makeStyles(() => {\n return {\n popupIndicatorOpen: {\n transform: \"rotate(0)\",\n },\n };\n});\n\nfunction StopsFinder({\n agencies,\n apiKey,\n autocompleteProps,\n bbox,\n field,\n limit,\n map,\n mots,\n onSelect,\n radius,\n refLocation,\n renderAutocomplete,\n url,\n}) {\n const classes = useStyles();\n const [inputValue, setInputValue] = useState(\"\");\n const [suggestions, setSuggestions] = useState([]);\n const [isLoading, setLoading] = useState(false);\n const [isOpen, setOpen] = useState(false);\n\n const control = useMemo(() => {\n return new StopFinderControl({\n url,\n apiKey,\n target: document.createElement(\"div\"),\n element: document.createElement(\"div\"),\n render(newSuggestions = { features: [] }) {\n setSuggestions(newSuggestions.features);\n setLoading(false);\n },\n });\n }, [apiKey, url]);\n\n useEffect(() => {\n if (!inputValue) {\n setSuggestions([]);\n setLoading(false);\n return () => {};\n }\n const abortController = new AbortController();\n setLoading(true);\n control.apiParams = {\n prefAgencies: agencies && agencies.toString(),\n bbox: bbox && bbox.toString(),\n field: field && field.toString(),\n limit,\n mots: mots && mots.toString(),\n radius,\n ref_location: refLocation && refLocation.toString(),\n };\n control.search(inputValue, abortController);\n return () => {\n abortController.abort();\n };\n }, [\n agencies,\n bbox,\n control,\n field,\n inputValue,\n limit,\n mots,\n radius,\n refLocation,\n ]);\n\n // Ensure the control is not associated to the wrong map\n useEffect(() => {\n if (!control) {\n return () => {};\n }\n\n control.map = map;\n\n return () => {\n control.map = null;\n };\n }, [map, control]);\n\n if (!control) {\n return null;\n }\n\n if (renderAutocomplete) {\n return renderAutocomplete(\n suggestions,\n inputValue,\n setInputValue,\n isOpen,\n setOpen,\n isLoading,\n setLoading,\n );\n }\n const textFieldProps = {\n ...((autocompleteProps || {}).textFieldProps || {}),\n };\n const autocProps = { ...autocompleteProps };\n delete autocProps.textFieldProps;\n\n return (\n <Autocomplete\n fullWidth\n autoComplete\n autoHighlight\n selectOnFocus\n getOptionLabel={(option) => {\n return option.properties.name;\n }}\n onChange={(evt, value, reason) => {\n if (onSelect && reason === \"select-option\") {\n onSelect(value, evt);\n }\n }}\n popupIcon={<FaSearch focusable={false} size={15} />}\n renderInput={(params) => {\n return (\n <TextField\n label=\"Search stops\"\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...{\n ...params,\n ...textFieldProps,\n }}\n InputProps={{\n ...params.InputProps,\n endAdornment: (\n <>\n {isLoading && <CircularProgress size={20} />}\n {params.InputProps.endAdornment}\n </>\n ),\n }}\n />\n );\n }}\n renderOption={(option) => {\n return <StopsFinderOptions option={option} />;\n }}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...autocProps}\n classes={{ ...classes, ...autocompleteProps.classes }}\n inputValue={inputValue}\n open={isOpen}\n options={suggestions}\n loading={isLoading}\n onOpen={() => {\n setOpen(true);\n }}\n onClose={() => {\n setOpen(false);\n }}\n onInputChange={(evt, val) => {\n setInputValue(val);\n }}\n />\n );\n}\n\nStopsFinder.propTypes = {\n /**\n * Array or a comma separated list of agencies which should be available.\n * Order of these agencies chooses which agency will be preferred.\n * Available values : sbb, db\n */\n agencies: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.string),\n ]),\n\n /**\n * geOps api key to access the StopsFinder service.\n */\n apiKey: PropTypes.string,\n\n /**\n * Properties apply to the default [MUI Autocomplete component](https://material-ui.com/api/autocomplete/).\n * We add a custom properties textFieldProps for the default [MUI TextField component](https://material-ui.com/api/text-field/) used by the Autocomplete.\n */\n autocompleteProps: PropTypes.object,\n\n /**\n * minX,minY,maxX,maxY coordinates in WGS84 wherein the station should lie.\n */\n bbox: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.number),\n ]),\n\n /**\n * Array or a comma separated list of fields which should be used for look up.\n * Available values : id, name, coords\n */\n field: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.string),\n ]),\n\n /**\n * Control how many matches will be returned.\n */\n limit: PropTypes.number,\n\n /**\n * A map.\n */\n map: PropTypes.instanceOf(Map).isRequired,\n\n /**\n * Array or a comma separated list of mode of transpaorts which should be available.\n * Available values : bus, ferry, gondola, tram, rail, funicular, cable_car, subway\n */\n mots: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.string),\n ]),\n\n /**\n * Function called when a suggestion is selected.\n */\n onSelect: PropTypes.func,\n\n /**\n * Radius around refLocation in meters that is most relevant.\n * Used as granularity for location rank.\n */\n radius: PropTypes.number,\n\n /**\n * Coordinates in WGS84 (in lat,lon order) used to rank stops close to this position higher.\n * Available values : id, name, coords\n */\n refLocation: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.number),\n ]),\n\n /**\n * Function to render a different autocomplete input than the default one.\n */\n renderAutocomplete: PropTypes.func,\n\n /**\n * Url of the geOps StopsFinder service.\n */\n url: PropTypes.string,\n};\n\nStopsFinder.defaultProps = {\n agencies: null,\n apiKey: null,\n autocompleteProps: {},\n bbox: null,\n field: null,\n limit: null,\n mots: null,\n onSelect: null,\n radius: null,\n refLocation: null,\n url: null,\n renderAutocomplete: null,\n};\n\nexport default StopsFinder;\n"],
5
- "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ACzB,UAAU;AAAA,IACV,UAAU,QAAQ,UAAU,MAAM;AAAA,EACpC,CAAC;AAAA;AAAA;AAAA;AAAA,EAKD,OAAO,UAAU;AAAA;AAAA;AAAA;AAAA,EAKjB,KAAK,UAAU,WAAW,GAAG,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA,EAM/B,MAAM,UAAU,UAAU;AAAA,IACxB,UAAU;AAAA,IACV,UAAU,QAAQ,UAAU,MAAM;AAAA,EACpC,CAAC;AAAA;AAAA;AAAA;AAAA,EAKD,UAAU,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAMpB,QAAQ,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAMlB,aAAa,UAAU,UAAU;AAAA,IAC/B,UAAU;AAAA,IACV,UAAU,QAAQ,UAAU,MAAM;AAAA,EACpC,CAAC;AAAA;AAAA;AAAA;AAAA,EAKD,oBAAoB,UAAU;AAAA;AAAA;AAAA;AAAA,EAK9B,KAAK,UAAU;AACjB;AAEA,YAAY,eAAe;AAAA,EACzB,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,mBAAmB,CAAC;AAAA,EACpB,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AAAA,EACP,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,KAAK;AAAA,EACL,oBAAoB;AACtB;AAEA,eAAe;",
4
+ "sourcesContent": ["/* eslint-disable react/jsx-props-no-spreading */\nimport React, { useMemo, useState, useEffect } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { Autocomplete, autocompleteClasses, styled } from \"@mui/material\";\nimport { FaSearch } from \"react-icons/fa\";\nimport TextField from \"@mui/material/TextField\";\nimport CircularProgress from \"@mui/material/CircularProgress\";\nimport { StopFinderControl } from \"mobility-toolbox-js/ol\";\nimport { Map } from \"ol\";\nimport StopsFinderOption from \"./StopsFinderOption\";\n\nconst StyledAutocomplete = styled(Autocomplete)(() => ({\n [`&.${autocompleteClasses.popupIndicatorOpen}`]: {\n transform: \"rotate(0)\",\n },\n}));\n\nfunction StopsFinder({\n agencies,\n apiKey,\n bbox,\n field,\n limit,\n map,\n mots,\n onSelect,\n radius,\n refLocation,\n renderAutocomplete,\n url,\n textFieldProps,\n ...props\n}) {\n const [inputValue, setInputValue] = useState(\"\");\n const [suggestions, setSuggestions] = useState([]);\n const [isLoading, setLoading] = useState(false);\n const [isOpen, setOpen] = useState(false);\n\n const control = useMemo(() => {\n return new StopFinderControl({\n url,\n apiKey,\n target: document.createElement(\"div\"),\n element: document.createElement(\"div\"),\n render(newSuggestions = { features: [] }) {\n setSuggestions(newSuggestions.features);\n setLoading(false);\n },\n });\n }, [apiKey, url]);\n\n useEffect(() => {\n if (!inputValue) {\n setSuggestions([]);\n setLoading(false);\n return () => {};\n }\n const abortController = new AbortController();\n setLoading(true);\n control.apiParams = {\n prefAgencies: agencies && agencies.toString(),\n bbox: bbox && bbox.toString(),\n field: field && field.toString(),\n limit,\n mots: mots && mots.toString(),\n radius,\n ref_location: refLocation && refLocation.toString(),\n };\n control.search(inputValue, abortController);\n return () => {\n abortController.abort();\n };\n }, [\n agencies,\n bbox,\n control,\n field,\n inputValue,\n limit,\n mots,\n radius,\n refLocation,\n ]);\n\n // Ensure the control is not associated to the wrong map\n useEffect(() => {\n if (!control) {\n return () => {};\n }\n\n control.map = map;\n\n return () => {\n control.map = null;\n };\n }, [map, control]);\n\n if (!control) {\n return null;\n }\n\n if (renderAutocomplete) {\n return renderAutocomplete(\n suggestions,\n inputValue,\n setInputValue,\n isOpen,\n setOpen,\n isLoading,\n setLoading,\n );\n }\n return (\n <StyledAutocomplete\n fullWidth\n autoComplete\n autoHighlight\n selectOnFocus\n getOptionLabel={(option) => {\n return option.properties.name;\n }}\n onChange={(evt, value, reason) => {\n if (onSelect && reason === \"selectOption\") {\n onSelect(value, evt);\n }\n }}\n popupIcon={<FaSearch focusable={false} size={15} />}\n renderInput={(params) => {\n return (\n <TextField\n label=\"Search stops\"\n {...params}\n {...textFieldProps}\n InputProps={{\n ...params.InputProps,\n endAdornment: (\n <>\n {isLoading && <CircularProgress size={20} />}\n {params.InputProps.endAdornment}\n </>\n ),\n }}\n />\n );\n }}\n renderOption={(liProps, option) => {\n return (\n <StopsFinderOption\n key={option.properties?.name}\n option={option}\n {...liProps}\n />\n );\n }}\n {...props}\n inputValue={inputValue}\n open={isOpen}\n options={suggestions}\n loading={isLoading}\n onOpen={() => {\n setOpen(true);\n }}\n onClose={() => {\n setOpen(false);\n }}\n onInputChange={(evt, val) => {\n setInputValue(val);\n }}\n />\n );\n}\n\nStopsFinder.propTypes = {\n /**\n * Array or a comma separated list of agencies which should be available.\n * Order of these agencies chooses which agency will be preferred.\n * Available values : sbb, db\n */\n agencies: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.string),\n ]),\n\n /**\n * geOps api key to access the StopsFinder service.\n */\n apiKey: PropTypes.string,\n\n /**\n * Properties apply to the default [MUI TextField component](https://material-ui.com/api/text-field/) used by the Autocomplete.\n */\n textFieldProps: PropTypes.object,\n\n /**\n * minX,minY,maxX,maxY coordinates in WGS84 wherein the station should lie.\n */\n bbox: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.number),\n ]),\n\n /**\n * Array or a comma separated list of fields which should be used for look up.\n * Available values : id, name, coords\n */\n field: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.string),\n ]),\n\n /**\n * Control how many matches will be returned.\n */\n limit: PropTypes.number,\n\n /**\n * A map.\n */\n map: PropTypes.instanceOf(Map).isRequired,\n\n /**\n * Array or a comma separated list of mode of transpaorts which should be available.\n * Available values : bus, ferry, gondola, tram, rail, funicular, cable_car, subway\n */\n mots: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.string),\n ]),\n\n /**\n * Function called when a suggestion is selected.\n */\n onSelect: PropTypes.func,\n\n /**\n * Radius around refLocation in meters that is most relevant.\n * Used as granularity for location rank.\n */\n radius: PropTypes.number,\n\n /**\n * Coordinates in WGS84 (in lat,lon order) used to rank stops close to this position higher.\n * Available values : id, name, coords\n */\n refLocation: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.number),\n ]),\n\n /**\n * Function to render a different autocomplete input than the default one.\n */\n renderAutocomplete: PropTypes.func,\n\n /**\n * Url of the geOps StopsFinder service.\n */\n url: PropTypes.string,\n};\n\nStopsFinder.defaultProps = {\n agencies: null,\n apiKey: null,\n textFieldProps: {},\n bbox: null,\n field: null,\n limit: null,\n mots: null,\n onSelect: null,\n radius: null,\n refLocation: null,\n url: null,\n renderAutocomplete: null,\n};\n\nexport default StopsFinder;\n"],
5
+ "mappings": "AACA,OAAO,SAAS,SAAS,UAAU,iBAAiB;AACpD,OAAO,eAAe;AACtB,SAAS,cAAc,qBAAqB,cAAc;AAC1D,SAAS,gBAAgB;AACzB,OAAO,eAAe;AACtB,OAAO,sBAAsB;AAC7B,SAAS,yBAAyB;AAClC,SAAS,WAAW;AACpB,OAAO,uBAAuB;AAE9B,MAAM,qBAAqB,OAAO,YAAY,EAAE,OAAO;AAAA,EACrD,CAAC,KAAK,oBAAoB,kBAAkB,EAAE,GAAG;AAAA,IAC/C,WAAW;AAAA,EACb;AACF,EAAE;AAEF,SAAS,YAAY;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG;AACD,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,EAAE;AAC/C,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,CAAC,CAAC;AACjD,QAAM,CAAC,WAAW,UAAU,IAAI,SAAS,KAAK;AAC9C,QAAM,CAAC,QAAQ,OAAO,IAAI,SAAS,KAAK;AAExC,QAAM,UAAU,QAAQ,MAAM;AAC5B,WAAO,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, { Suspense, lazy } from "react";
2
2
  import PropTypes from "prop-types";
3
- import { makeStyles } from "@material-ui/core";
3
+ import { CircularProgress, styled } from "@mui/material";
4
4
  const ext = "_round-blue-01.svg";
5
5
  const iconForMot = {};
6
6
  [
@@ -17,23 +17,16 @@ const iconForMot = {};
17
17
  return import(`../../images/mots/${mot}${ext}`);
18
18
  });
19
19
  });
20
- const useStyles = makeStyles((theme) => {
21
- return {
22
- flex: {
23
- display: "flex",
24
- alignItems: "center"
25
- },
26
- icon: {
27
- marginRight: theme.spacing(2)
28
- }
29
- };
30
- });
31
- function StopsFinderOption({ option }) {
32
- const classes = useStyles();
33
- return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement("div", null) }, /* @__PURE__ */ React.createElement("div", { className: classes.flex }, Object.entries(option.properties.mot).map(([key, value]) => {
20
+ const StyledFlex = styled("div")(() => ({
21
+ display: "flex",
22
+ alignItems: "center",
23
+ gap: 5
24
+ }));
25
+ function StopsFinderOption({ option, ...props }) {
26
+ return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(CircularProgress, { size: 20 }) }, /* @__PURE__ */ React.createElement(StyledFlex, { ...props }, Object.entries(option.properties?.mot).map(([key, value]) => {
34
27
  if (value) {
35
28
  const MotIcon = iconForMot[key];
36
- return /* @__PURE__ */ React.createElement("span", { className: classes.icon, key }, /* @__PURE__ */ React.createElement(MotIcon, null));
29
+ return /* @__PURE__ */ React.createElement(StyledFlex, { key }, /* @__PURE__ */ React.createElement(MotIcon, null));
37
30
  }
38
31
  return null;
39
32
  }), /* @__PURE__ */ React.createElement("span", null, option.properties.name)));
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/StopsFinder/StopsFinderOption.js"],
4
- "sourcesContent": ["import React, { lazy, Suspense } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { makeStyles } from \"@material-ui/core\";\n\nconst ext = \"_round-blue-01.svg\";\nconst iconForMot = {};\n[\n \"bus\",\n \"ferry\",\n \"gondola\",\n \"tram\",\n \"rail\",\n \"funicular\",\n \"cable_car\",\n \"subway\",\n].forEach((mot) => {\n iconForMot[mot] = lazy(() => {\n return import(`../../images/mots/${mot}${ext}`);\n });\n});\n\nconst useStyles = makeStyles((theme) => {\n return {\n flex: {\n display: \"flex\",\n alignItems: \"center\",\n },\n icon: {\n marginRight: theme.spacing(2),\n },\n };\n});\n\nfunction StopsFinderOption({ option }) {\n const classes = useStyles();\n\n return (\n <Suspense fallback={<div />}>\n <div className={classes.flex}>\n {Object.entries(option.properties.mot).map(([key, value]) => {\n if (value) {\n const MotIcon = iconForMot[key];\n return (\n <span className={classes.icon} key={key}>\n <MotIcon />\n </span>\n );\n }\n return null;\n })}\n <span>{option.properties.name}</span>\n </div>\n </Suspense>\n );\n}\n\nStopsFinderOption.propTypes = {\n option: PropTypes.object.isRequired,\n};\n\nexport default React.memo(StopsFinderOption);\n"],
5
- "mappings": "AAAA,OAAO,SAAS,MAAM,gBAAgB;AACtC,OAAO,eAAe;AACtB,SAAS,kBAAkB;AAE3B,MAAM,MAAM;AACZ,MAAM,aAAa,CAAC;AACpB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,EAAE,QAAQ,CAAC,QAAQ;AACjB,aAAW,GAAG,IAAI,KAAK,MAAM;AAC3B,WAAO,OAAO,qBAAqB,GAAG,GAAG,GAAG;AAAA,EAC9C,CAAC;AACH,CAAC;AAED,MAAM,YAAY,WAAW,CAAC,UAAU;AACtC,SAAO;AAAA,IACL,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,YAAY;AAAA,IACd;AAAA,IACA,MAAM;AAAA,MACJ,aAAa,MAAM,QAAQ,CAAC;AAAA,IAC9B;AAAA,EACF;AACF,CAAC;AAED,SAAS,kBAAkB,EAAE,OAAO,GAAG;AACrC,QAAM,UAAU,UAAU;AAE1B,SACE,oCAAC,YAAS,UAAU,oCAAC,WAAI,KACvB,oCAAC,SAAI,WAAW,QAAQ,QACrB,OAAO,QAAQ,OAAO,WAAW,GAAG,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AAC3D,QAAI,OAAO;AACT,YAAM,UAAU,WAAW,GAAG;AAC9B,aACE,oCAAC,UAAK,WAAW,QAAQ,MAAM,OAC7B,oCAAC,aAAQ,CACX;AAAA,IAEJ;AACA,WAAO;AAAA,EACT,CAAC,GACD,oCAAC,cAAM,OAAO,WAAW,IAAK,CAChC,CACF;AAEJ;AAEA,kBAAkB,YAAY;AAAA,EAC5B,QAAQ,UAAU,OAAO;AAC3B;AAEA,eAAe,MAAM,KAAK,iBAAiB;",
4
+ "sourcesContent": ["/* eslint-disable react/jsx-props-no-spreading */\nimport React, { Suspense, lazy } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { CircularProgress, styled } from \"@mui/material\";\n\nconst ext = \"_round-blue-01.svg\";\nconst iconForMot = {};\n[\n \"bus\",\n \"ferry\",\n \"gondola\",\n \"tram\",\n \"rail\",\n \"funicular\",\n \"cable_car\",\n \"subway\",\n].forEach((mot) => {\n iconForMot[mot] = lazy(() => {\n return import(`../../images/mots/${mot}${ext}`);\n });\n});\n\nconst StyledFlex = styled(\"div\")(() => ({\n display: \"flex\",\n alignItems: \"center\",\n gap: 5,\n}));\n\nfunction StopsFinderOption({ option, ...props }) {\n return (\n <Suspense fallback={<CircularProgress size={20} />}>\n <StyledFlex {...props}>\n {Object.entries(option.properties?.mot).map(([key, value]) => {\n if (value) {\n const MotIcon = iconForMot[key];\n return (\n <StyledFlex key={key}>\n <MotIcon />\n </StyledFlex>\n );\n }\n return null;\n })}\n <span>{option.properties.name}</span>\n </StyledFlex>\n </Suspense>\n );\n}\n\nStopsFinderOption.propTypes = {\n option: PropTypes.object.isRequired,\n};\n\nexport default React.memo(StopsFinderOption);\n"],
5
+ "mappings": "AACA,OAAO,SAAS,UAAU,YAAY;AACtC,OAAO,eAAe;AACtB,SAAS,kBAAkB,cAAc;AAEzC,MAAM,MAAM;AACZ,MAAM,aAAa,CAAC;AACpB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,EAAE,QAAQ,CAAC,QAAQ;AACjB,aAAW,GAAG,IAAI,KAAK,MAAM;AAC3B,WAAO,OAAO,qBAAqB,GAAG,GAAG,GAAG;AAAA,EAC9C,CAAC;AACH,CAAC;AAED,MAAM,aAAa,OAAO,KAAK,EAAE,OAAO;AAAA,EACtC,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,KAAK;AACP,EAAE;AAEF,SAAS,kBAAkB,EAAE,QAAQ,GAAG,MAAM,GAAG;AAC/C,SACE,oCAAC,YAAS,UAAU,oCAAC,oBAAiB,MAAM,IAAI,KAC9C,oCAAC,cAAY,GAAG,SACb,OAAO,QAAQ,OAAO,YAAY,GAAG,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AAC5D,QAAI,OAAO;AACT,YAAM,UAAU,WAAW,GAAG;AAC9B,aACE,oCAAC,cAAW,OACV,oCAAC,aAAQ,CACX;AAAA,IAEJ;AACA,WAAO;AAAA,EACT,CAAC,GACD,oCAAC,cAAM,OAAO,WAAW,IAAK,CAChC,CACF;AAEJ;AAEA,kBAAkB,YAAY;AAAA,EAC5B,QAAQ,UAAU,OAAO;AAC3B;AAEA,eAAe,MAAM,KAAK,iBAAiB;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -2,12 +2,13 @@
2
2
  "name": "react-spatial",
3
3
  "license": "MIT",
4
4
  "description": "Components to build React map apps.",
5
- "version": "1.8.2",
5
+ "version": "1.9.0",
6
6
  "dependencies": {
7
- "@geops/geops-ui": "0.1.18",
8
- "@material-ui/core": "4.12.4",
9
- "@material-ui/icons": "4.11.3",
10
- "@material-ui/lab": "4.0.0-alpha.61",
7
+ "@emotion/react": "^11.11.3",
8
+ "@emotion/styled": "^11.11.0",
9
+ "@geops/geops-ui": "0.3.2",
10
+ "@mui/icons-material": "^5.15.9",
11
+ "@mui/material": "^5.15.9",
11
12
  "re-resizable": "6.9.11",
12
13
  "react-icons": "5.0.1",
13
14
  "resize-observer-polyfill": "1.5.1"
@@ -21,23 +22,23 @@
21
22
  "react-dom": "^18"
22
23
  },
23
24
  "devDependencies": {
24
- "@babel/preset-env": "7.23.8",
25
+ "@babel/preset-env": "7.23.9",
25
26
  "@babel/preset-react": "7.23.3",
26
27
  "@cfaester/enzyme-adapter-react-18": "0.7.1",
27
- "@commitlint/cli": "18.4.4",
28
- "@commitlint/config-conventional": "18.4.4",
28
+ "@commitlint/cli": "18.6.0",
29
+ "@commitlint/config-conventional": "18.6.0",
29
30
  "@svgr/plugin-jsx": "^8.1.0",
30
31
  "@svgr/webpack": "8.1.0",
31
- "@testing-library/jest-dom": "6.2.0",
32
- "@testing-library/react": "14.1.2",
32
+ "@testing-library/jest-dom": "6.4.2",
33
+ "@testing-library/react": "14.2.1",
33
34
  "@testing-library/user-event": "14.5.2",
34
35
  "babel-jest": "29.7.0",
35
36
  "babel-loader": "9.1.3",
36
37
  "canvas": "2.11.2",
37
- "css-loader": "6.9.0",
38
+ "css-loader": "6.10.0",
38
39
  "enzyme": "3.11.0",
39
- "esbuild": "^0.19.11",
40
- "esbuild-loader": "^4.0.2",
40
+ "esbuild": "^0.20.0",
41
+ "esbuild-loader": "^4.0.3",
41
42
  "eslint": "8.56.0",
42
43
  "eslint-config-airbnb": "19.0.4",
43
44
  "eslint-config-prettier": "9.1.0",
@@ -49,7 +50,7 @@
49
50
  "file-loader": "6.2.0",
50
51
  "fixpack": "4.0.0",
51
52
  "generact": "0.4.0",
52
- "husky": "8.0.3",
53
+ "husky": "9.0.10",
53
54
  "identity-obj-proxy": "^3.0.0",
54
55
  "is-ci": "3.0.1",
55
56
  "jest": "29.7.0",
@@ -61,33 +62,33 @@
61
62
  "jest-transform-file": "1.1.1",
62
63
  "jest-transformer-svg": "^2.0.2",
63
64
  "jsts": "2.11.0",
64
- "lint-staged": "15.2.0",
65
+ "lint-staged": "15.2.2",
65
66
  "mapbox-gl": "1.13.1",
66
- "maplibre-gl": "3.6.2",
67
- "mobility-toolbox-js": "2.3.7",
67
+ "maplibre-gl": "4.0.0",
68
+ "mobility-toolbox-js": "2.3.8",
68
69
  "ol": "8.2.0",
69
- "postcss": "^8.4.33",
70
- "prettier": "3.2.4",
70
+ "postcss": "^8.4.35",
71
+ "prettier": "3.2.5",
71
72
  "proj4": "2.10.0",
72
73
  "prop-types": "15.8.1",
73
74
  "react": "18",
74
75
  "react-dom": "18",
75
- "react-styleguidist": "13.1.1",
76
+ "react-styleguidist": "13.1.2",
76
77
  "react-svg-loader": "3.0.3",
77
78
  "react-test-renderer": "18.2.0",
78
79
  "sass": "1.70.0",
79
- "sass-loader": "14.0.0",
80
+ "sass-loader": "14.1.0",
80
81
  "standard-version": "9.5.0",
81
82
  "stream-array": "1.1.2",
82
83
  "style-loader": "3.3.4",
83
- "stylelint": "16.1.0",
84
+ "stylelint": "16.2.1",
84
85
  "stylelint-config-recommended-scss": "14.0.0",
85
86
  "stylelint-config-standard": "36.0.0",
86
- "stylelint-scss": "6.0.0",
87
+ "stylelint-scss": "6.1.0",
87
88
  "terser-webpack-plugin": "^5.3.10",
88
89
  "url-loader": "4.1.1",
89
90
  "vinyl-fs": "4.0.0",
90
- "webpack": "^5.89.0",
91
+ "webpack": "^5.90.1",
91
92
  "xml-beautifier": "0.5.0"
92
93
  },
93
94
  "scripts": {