react-spatial 1.4.0 → 1.5.2-beta.12

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
@@ -10,7 +10,7 @@ This library provides React components to build web applications and to visualiz
10
10
 
11
11
  This library uses the [mobility-toolbox-js](https://mobility-toolbox-js.geops.io/) library.
12
12
 
13
- Documentation and examples at https://react-spatial.geops.de.
13
+ Documentation and examples at https://react-spatial.geops.io.
14
14
 
15
15
  ## Getting Started
16
16
 
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from "react";
2
2
  import PropTypes from "prop-types";
3
3
  import OLMap from "ol/Map";
4
4
  import { unByKey } from "ol/Observable";
5
- import degrees from "radians-degrees";
5
+ import { toDegrees } from "ol/math";
6
6
  import NorthArrowSimple from "../../images/northArrow.svg";
7
7
  import NorthArrowCircle from "../../images/northArrowCircle.svg";
8
8
  const propTypes = {
@@ -17,7 +17,7 @@ const defaultProps = {
17
17
  children: null
18
18
  };
19
19
  const getRotation = (map, rotationOffset) => {
20
- return degrees(map.getView().getRotation()) + rotationOffset;
20
+ return toDegrees(map.getView().getRotation()) + rotationOffset;
21
21
  };
22
22
  function NorthArrow({ map, rotationOffset, circled, children, ...other }) {
23
23
  const [rotation, setRotation] = useState(rotationOffset);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/NorthArrow/NorthArrow.js"],
4
- "sourcesContent": ["import React, { useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport OLMap from 'ol/Map';\nimport { unByKey } from 'ol/Observable';\nimport degrees from 'radians-degrees';\nimport NorthArrowSimple from '../../images/northArrow.svg';\nimport NorthArrowCircle from '../../images/northArrowCircle.svg';\n\nconst propTypes = {\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * Rotation of the north arrow in degrees.\n */\n rotationOffset: PropTypes.number,\n\n /**\n * Display circle around the north arrow. Not used if pass children.\n */\n circled: PropTypes.bool,\n\n /**\n * Children content of the north arrow.\n */\n children: PropTypes.node,\n};\n\nconst defaultProps = {\n rotationOffset: 0,\n circled: false,\n children: null,\n};\n\nconst getRotation = (map, rotationOffset) => {\n return degrees(map.getView().getRotation()) + rotationOffset;\n};\n\n/**\n * This NorthArrow component inserts an arrow pointing north into an\n * [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nfunction NorthArrow({ map, rotationOffset, circled, children, ...other }) {\n const [rotation, setRotation] = useState(rotationOffset);\n\n useEffect(() => {\n if (!map) {\n return null;\n }\n const key = map.on('postrender', () => {\n setRotation(getRotation(map, rotationOffset));\n });\n return () => {\n unByKey(key);\n };\n }, [map, rotationOffset]);\n\n return (\n <div\n className=\"rs-north-arrow\"\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n style={{ transform: `rotate(${rotation}deg)` }}\n >\n {children || (circled ? <NorthArrowCircle /> : <NorthArrowSimple />)}\n </div>\n );\n}\n\nNorthArrow.propTypes = propTypes;\nNorthArrow.defaultProps = defaultProps;\n\nexport default React.memo(NorthArrow);\n"],
5
- "mappings": "AAAA,OAAO,SAAS,WAAW,gBAAgB;AAC3C,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,OAAO,aAAa;AACpB,OAAO,sBAAsB;AAC7B,OAAO,sBAAsB;AAE7B,MAAM,YAAY;AAAA,EAIhB,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA,EAKjC,gBAAgB,UAAU;AAAA,EAK1B,SAAS,UAAU;AAAA,EAKnB,UAAU,UAAU;AACtB;AAEA,MAAM,eAAe;AAAA,EACnB,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,UAAU;AACZ;AAEA,MAAM,cAAc,CAAC,KAAK,mBAAmB;AAC3C,SAAO,QAAQ,IAAI,QAAQ,EAAE,YAAY,CAAC,IAAI;AAChD;AAMA,SAAS,WAAW,EAAE,KAAK,gBAAgB,SAAS,aAAa,MAAM,GAAG;AACxE,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,cAAc;AAEvD,YAAU,MAAM;AACd,QAAI,CAAC,KAAK;AACR,aAAO;AAAA,IACT;AACA,UAAM,MAAM,IAAI,GAAG,cAAc,MAAM;AACrC,kBAAY,YAAY,KAAK,cAAc,CAAC;AAAA,IAC9C,CAAC;AACD,WAAO,MAAM;AACX,cAAQ,GAAG;AAAA,IACb;AAAA,EACF,GAAG,CAAC,KAAK,cAAc,CAAC;AAExB,SACE,oCAAC;AAAA,IACC,WAAU;AAAA,IAET,GAAG;AAAA,IACJ,OAAO,EAAE,WAAW,UAAU,eAAe;AAAA,KAE5C,aAAa,UAAU,oCAAC,sBAAiB,IAAK,oCAAC,sBAAiB,EACnE;AAEJ;AAEA,WAAW,YAAY;AACvB,WAAW,eAAe;AAE1B,eAAe,MAAM,KAAK,UAAU;",
4
+ "sourcesContent": ["import React, { useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport OLMap from 'ol/Map';\nimport { unByKey } from 'ol/Observable';\nimport { toDegrees } from 'ol/math';\nimport NorthArrowSimple from '../../images/northArrow.svg';\nimport NorthArrowCircle from '../../images/northArrowCircle.svg';\n\nconst propTypes = {\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * Rotation of the north arrow in degrees.\n */\n rotationOffset: PropTypes.number,\n\n /**\n * Display circle around the north arrow. Not used if pass children.\n */\n circled: PropTypes.bool,\n\n /**\n * Children content of the north arrow.\n */\n children: PropTypes.node,\n};\n\nconst defaultProps = {\n rotationOffset: 0,\n circled: false,\n children: null,\n};\n\nconst getRotation = (map, rotationOffset) => {\n return toDegrees(map.getView().getRotation()) + rotationOffset;\n};\n\n/**\n * This NorthArrow component inserts an arrow pointing north into an\n * [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nfunction NorthArrow({ map, rotationOffset, circled, children, ...other }) {\n const [rotation, setRotation] = useState(rotationOffset);\n\n useEffect(() => {\n if (!map) {\n return null;\n }\n const key = map.on('postrender', () => {\n setRotation(getRotation(map, rotationOffset));\n });\n return () => {\n unByKey(key);\n };\n }, [map, rotationOffset]);\n\n return (\n <div\n className=\"rs-north-arrow\"\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n style={{ transform: `rotate(${rotation}deg)` }}\n >\n {children || (circled ? <NorthArrowCircle /> : <NorthArrowSimple />)}\n </div>\n );\n}\n\nNorthArrow.propTypes = propTypes;\nNorthArrow.defaultProps = defaultProps;\n\nexport default React.memo(NorthArrow);\n"],
5
+ "mappings": "AAAA,OAAO,SAAS,WAAW,gBAAgB;AAC3C,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,OAAO,sBAAsB;AAC7B,OAAO,sBAAsB;AAE7B,MAAM,YAAY;AAAA,EAIhB,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA,EAKjC,gBAAgB,UAAU;AAAA,EAK1B,SAAS,UAAU;AAAA,EAKnB,UAAU,UAAU;AACtB;AAEA,MAAM,eAAe;AAAA,EACnB,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,UAAU;AACZ;AAEA,MAAM,cAAc,CAAC,KAAK,mBAAmB;AAC3C,SAAO,UAAU,IAAI,QAAQ,EAAE,YAAY,CAAC,IAAI;AAClD;AAMA,SAAS,WAAW,EAAE,KAAK,gBAAgB,SAAS,aAAa,MAAM,GAAG;AACxE,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,cAAc;AAEvD,YAAU,MAAM;AACd,QAAI,CAAC,KAAK;AACR,aAAO;AAAA,IACT;AACA,UAAM,MAAM,IAAI,GAAG,cAAc,MAAM;AACrC,kBAAY,YAAY,KAAK,cAAc,CAAC;AAAA,IAC9C,CAAC;AACD,WAAO,MAAM;AACX,cAAQ,GAAG;AAAA,IACb;AAAA,EACF,GAAG,CAAC,KAAK,cAAc,CAAC;AAExB,SACE,oCAAC;AAAA,IACC,WAAU;AAAA,IAET,GAAG;AAAA,IACJ,OAAO,EAAE,WAAW,UAAU,eAAe;AAAA,KAE5C,aAAa,UAAU,oCAAC,sBAAiB,IAAK,oCAAC,sBAAiB,EACnE;AAEJ;AAEA,WAAW,YAAY;AACvB,WAAW,eAAe;AAE1B,eAAe,MAAM,KAAK,UAAU;",
6
6
  "names": []
7
7
  }
@@ -38,7 +38,10 @@ const isPassed = (stop, time, stops, idx) => {
38
38
  return true;
39
39
  }
40
40
  const timeToCompare = stop.aimedDepartureTime || stop.aimedArrivalTime || 0;
41
- const delayToCompare = stop.departureDelay || stop.arrivalDelay || 0;
41
+ let delayToCompare = stop.departureDelay || stop.arrivalDelay || 0;
42
+ if (delayToCompare < 0) {
43
+ delayToCompare = 0;
44
+ }
42
45
  return timeToCompare + delayToCompare <= time;
43
46
  };
44
47
  const defaultRenderStationImg = (stations, index, isStationPassed, isNotStation) => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/RouteSchedule/RouteSchedule.js"],
4
- "sourcesContent": ["/* eslint-disable react/no-unused-prop-types */\n/* eslint-disable react/prop-types */\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport {\n RealtimeLayer as TrackerLayer,\n realtimeConfig,\n} from 'mobility-toolbox-js/ol';\nimport { getHoursAndMinutes, getDelayString } from '../../utils/timeUtils';\nimport ReactTransitPropTypes from '../../propTypes';\nimport firstStation from '../../images/RouteSchedule/firstStation.png';\nimport station from '../../images/RouteSchedule/station.png';\nimport lastStation from '../../images/RouteSchedule/lastStation.png';\nimport line from '../../images/RouteSchedule/line.png';\n\nconst { getBgColor } = realtimeConfig;\n\n/**\n * Returns a color class to display the delay.\n * @param {Number} time Delay time in milliseconds.\n */\nconst getDelayColor = (time) => {\n const secs = Math.round(((time / 1800 / 2) * 3600) / 1000);\n if (secs >= 3600) {\n return 'dark-red';\n }\n if (secs >= 500) {\n return 'middle-red';\n }\n if (secs >= 300) {\n return 'light-red';\n }\n if (secs >= 180) {\n return 'orange';\n }\n return 'green';\n};\n\n/**\n * Returns true if the train doesn't stop to the station.\n * @param {Object} stop Station information.\n */\nconst isNotStop = (stop) => {\n return !stop.arrivalTime && !stop.departureTime;\n};\n\n/**\n * Returns if the station has already been passed by the vehicule.\n * @param {Object} stop Station information.\n * @param {number} time The current time to test in ms.\n * @param {Array<Object>} stops the list of all stops of the train.\n * @param {idx} idx The index of the stop object in the stops array.\n */\nconst isPassed = (stop, time, stops, idx) => {\n // If the train doesn't stop to the stop object, we test if the stop just before has been passed or not.\n // if yes the current stop is considered as passed.\n if (isNotStop(stop)) {\n if (stops[idx - 1] && idx > 0) {\n return isPassed(stops[idx - 1], time, stops, idx);\n }\n return true;\n }\n\n // Sometimes stop.departureDelay is undefined.\n const timeToCompare = stop.aimedDepartureTime || stop.aimedArrivalTime || 0;\n const delayToCompare = stop.departureDelay || stop.arrivalDelay || 0;\n return timeToCompare + delayToCompare <= time;\n};\n\n/**\n * Returns an image for first, middle or last stations.\n * @param {Number} stations The stations list.\n * @param {Number} index Index of the station in the list.\n * @param {Boolean} isStationPassed If the train is already passed at this station.\n * @param {Boolean} isNotStation If the train doesn't stop to this station.\n */\nconst defaultRenderStationImg = (\n stations,\n index,\n isStationPassed,\n isNotStation,\n) => {\n const { length } = stations;\n let src = station.src || station;\n if (index === 0) {\n src = firstStation.src || firstStation;\n } else if (index === length - 1) {\n src = lastStation.src || lastStation;\n } else if (isNotStation) {\n src = line.src || line;\n }\n return <img src={src} alt=\"routeScheduleLine\" className=\"rt-route-icon\" />;\n};\n\nconst defaultRenderStation = ({\n lineInfos,\n onStationClick,\n trackerLayer,\n renderStationImg,\n stop,\n idx,\n}) => {\n const {\n stationId,\n arrivalDelay,\n departureDelay,\n arrivalTime,\n departureTime,\n state,\n stationName,\n aimedArrivalTime,\n aimedDepartureTime,\n } = stop;\n const cancelled = state === 'JOURNEY_CANCELLED' || state === 'STOP_CANCELLED';\n const { stations } = lineInfos;\n const isFirstStation = idx === 0;\n const isLastStation = idx === stations.length - 1;\n const isStationPassed = isPassed(stop, trackerLayer.time, stations, idx);\n const isNotStation = isNotStop(stop);\n return (\n <div\n // Train line can go in circle so begin and end have the same id,\n // using the time in the key should fix the issue.\n key={(stationId || stationName) + arrivalTime + departureTime}\n role=\"button\"\n className={[\n 'rt-route-station',\n isStationPassed ? ' rt-passed' : '',\n isNotStation ? ' rt-no-stop' : '',\n ].join('')}\n onClick={(e) => {\n return onStationClick(stop, e);\n }}\n tabIndex={0}\n onKeyPress={(e) => {\n return e.which === 13 && onStationClick(stop, e);\n }}\n >\n <div className=\"rt-route-delay\">\n {typeof arrivalDelay === 'undefined' || isFirstStation || cancelled ? (\n ''\n ) : (\n <span\n className={`rt-route-delay-arrival${` ${getDelayColor(\n arrivalDelay,\n )}`}`}\n >\n {`+${getDelayString(arrivalDelay)}`}\n </span>\n )}\n {typeof departureDelay === 'undefined' || isLastStation || cancelled ? (\n ''\n ) : (\n <span\n className={`rt-route-delay-departure${` ${getDelayColor(\n departureDelay,\n )}`}`}\n >\n {`+${getDelayString(departureDelay)}`}\n </span>\n )}\n </div>\n <div className=\"rt-route-times\">\n <span\n className={`rt-route-time-arrival ${\n cancelled ? 'rt-route-cancelled' : ''\n }`}\n >\n {getHoursAndMinutes(aimedArrivalTime)}\n </span>\n <span\n className={`rt-route-time-departure ${\n cancelled ? 'rt-route-cancelled' : ''\n }`}\n >\n {getHoursAndMinutes(aimedDepartureTime)}\n </span>\n </div>\n {renderStationImg(stations, idx, isStationPassed, isNotStation)}\n <div className={cancelled ? 'rt-route-cancelled' : ''}>{stationName}</div>\n </div>\n );\n};\n\nconst renderRouteIdentifier = ({ routeIdentifier, longName }) => {\n if (routeIdentifier) {\n // first part of the id, without leading zeros.\n const id = parseInt(routeIdentifier.split('.')[0], 10);\n if (!longName.includes(id)) {\n return ` (${id})`;\n }\n }\n return null;\n};\n\nconst defaultRenderHeader = ({ lineInfos, renderHeaderButtons }) => {\n const {\n type,\n vehicleType,\n shortName,\n longName,\n stroke,\n destination,\n routeIdentifier,\n text_color: textColor,\n } = lineInfos;\n return (\n <div className=\"rt-route-header\">\n <span\n className=\"rt-route-icon\"\n style={{\n /* stylelint-disable-next-line value-keyword-case */\n backgroundColor: stroke || getBgColor(type || vehicleType),\n color: textColor || 'black',\n }}\n >\n {shortName}\n </span>\n <div className=\"rt-route-title\">\n <span className=\"rt-route-name\">{destination}</span>\n <span>\n {longName}\n {renderRouteIdentifier(lineInfos)}\n </span>\n </div>\n <div className=\"rt-route-buttons\">\n {renderHeaderButtons(routeIdentifier)}\n </div>\n </div>\n );\n};\n\nconst defaultRenderFooter = (props) => {\n const { lineInfos, renderCopyright } = props;\n if (!lineInfos.operator && !lineInfos.publisher) {\n return null;\n }\n return <div className=\"rt-route-footer\">{renderCopyright({ ...props })}</div>;\n};\n\nconst defaultRenderLink = (text, url) => {\n return (\n <div className=\"rt-route-copyright-link\">\n {url ? (\n <a href={url} target=\"_blank\" rel=\"noreferrer\">\n {text}\n </a>\n ) : (\n <>{text}</>\n )}\n </div>\n );\n};\n\nconst defaultRenderCopyright = ({ lineInfos }) => {\n return (\n <span className=\"rt-route-copyright\">\n {lineInfos.operator &&\n defaultRenderLink(lineInfos.operator, lineInfos.operatorUrl)}\n {lineInfos.operator && lineInfos.publisher && <span>&nbsp;-&nbsp;</span>}\n {lineInfos.publisher &&\n defaultRenderLink(lineInfos.publisher, lineInfos.publisherUrl)}\n {lineInfos.license && <span>&nbsp;(</span>}\n {lineInfos.license &&\n defaultRenderLink(lineInfos.license, lineInfos.licenseUrl)}\n {lineInfos.license && ')'}\n </span>\n );\n};\n\nconst propTypes = {\n /**\n * CSS class of the route schedule wrapper.\n */\n className: PropTypes.string,\n\n /**\n * Trajectory stations informations.\n */\n lineInfos: ReactTransitPropTypes.lineInfos,\n\n /**\n * Trackerlayer.\n */\n trackerLayer: PropTypes.instanceOf(TrackerLayer).isRequired,\n\n /**\n * Render Header of the route scheduler.\n */\n renderHeader: PropTypes.func,\n\n /**\n * Render Footer of the route scheduler.\n */\n renderFooter: PropTypes.func,\n\n /**\n * Render Copyright of the route scheduler.\n */\n renderCopyright: PropTypes.func,\n\n /**\n * Render the status of the station image.\n */\n renderStationImg: PropTypes.func,\n\n /**\n * Render a station.\n */\n renderStation: PropTypes.func,\n\n /**\n * Function triggered on station's click event.\n */\n onStationClick: PropTypes.func,\n\n /**\n * Function to render header buttons.\n */\n renderHeaderButtons: PropTypes.func,\n};\n\nconst defaultProps = {\n className: 'rt-route-schedule',\n lineInfos: null,\n renderHeader: defaultRenderHeader,\n renderStation: defaultRenderStation,\n renderStationImg: defaultRenderStationImg,\n renderCopyright: defaultRenderCopyright,\n renderFooter: defaultRenderFooter,\n renderHeaderButtons: () => {\n return null;\n },\n onStationClick: () => {},\n};\n\n/**\n * RouteSchedule displays information, stops and punctuality about the clicked route.\n */\nfunction RouteSchedule(props) {\n const { lineInfos, className, renderStation, renderHeader, renderFooter } =\n props;\n\n if (!lineInfos) {\n return null;\n }\n\n return (\n <div className={className}>\n {renderHeader({ ...props })}\n <div className=\"rt-route-body\">\n {lineInfos.stations.map((stop, idx) => {\n return renderStation({ ...props, stop, idx });\n })}\n </div>\n {renderFooter({ ...props })}\n </div>\n );\n}\n\nRouteSchedule.propTypes = propTypes;\nRouteSchedule.defaultProps = defaultProps;\n\nexport default React.memo(RouteSchedule);\n"],
5
- "mappings": "AAEA,OAAO,WAAW;AAClB,OAAO,eAAe;AACtB;AAAA,EACE,iBAAiB;AAAA,EACjB;AAAA,OACK;AACP,SAAS,oBAAoB,sBAAsB;AACnD,OAAO,2BAA2B;AAClC,OAAO,kBAAkB;AACzB,OAAO,aAAa;AACpB,OAAO,iBAAiB;AACxB,OAAO,UAAU;AAEjB,MAAM,EAAE,WAAW,IAAI;AAMvB,MAAM,gBAAgB,CAAC,SAAS;AAC9B,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,SAAS,IAAI,CAAC,MAAM,QAAQ;AACrC,WAAO,cAAc,EAAE,GAAG,OAAO,MAAM,IAAI,CAAC;AAAA,EAC9C,CAAC,CACH,GACC,aAAa,EAAE,GAAG,MAAM,CAAC,CAC5B;AAEJ;AAEA,cAAc,YAAY;AAC1B,cAAc,eAAe;AAE7B,eAAe,MAAM,KAAK,aAAa;",
4
+ "sourcesContent": ["/* eslint-disable react/no-unused-prop-types */\n/* eslint-disable react/prop-types */\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport {\n RealtimeLayer as TrackerLayer,\n realtimeConfig,\n} from 'mobility-toolbox-js/ol';\nimport { getHoursAndMinutes, getDelayString } from '../../utils/timeUtils';\nimport ReactTransitPropTypes from '../../propTypes';\nimport firstStation from '../../images/RouteSchedule/firstStation.png';\nimport station from '../../images/RouteSchedule/station.png';\nimport lastStation from '../../images/RouteSchedule/lastStation.png';\nimport line from '../../images/RouteSchedule/line.png';\n\nconst { getBgColor } = realtimeConfig;\n\n/**\n * Returns a color class to display the delay.\n * @param {Number} time Delay time in milliseconds.\n */\nconst getDelayColor = (time) => {\n const secs = Math.round(((time / 1800 / 2) * 3600) / 1000);\n if (secs >= 3600) {\n return 'dark-red';\n }\n if (secs >= 500) {\n return 'middle-red';\n }\n if (secs >= 300) {\n return 'light-red';\n }\n if (secs >= 180) {\n return 'orange';\n }\n return 'green';\n};\n\n/**\n * Returns true if the train doesn't stop to the station.\n * @param {Object} stop Station information.\n */\nconst isNotStop = (stop) => {\n return !stop.arrivalTime && !stop.departureTime;\n};\n\n/**\n * Returns if the station has already been passed by the vehicule.\n * @param {Object} stop Station information.\n * @param {number} time The current time to test in ms.\n * @param {Array<Object>} stops the list of all stops of the train.\n * @param {idx} idx The index of the stop object in the stops array.\n */\nconst isPassed = (stop, time, stops, idx) => {\n // If the train doesn't stop to the stop object, we test if the stop just before has been passed or not.\n // if yes the current stop is considered as passed.\n if (isNotStop(stop)) {\n if (stops[idx - 1] && idx > 0) {\n return isPassed(stops[idx - 1], time, stops, idx);\n }\n return true;\n }\n\n // Sometimes stop.departureDelay is undefined.\n const timeToCompare = stop.aimedDepartureTime || stop.aimedArrivalTime || 0;\n let delayToCompare = stop.departureDelay || stop.arrivalDelay || 0;\n\n // It could happens that the delay is negative we simply ignores it.\n if (delayToCompare < 0) {\n delayToCompare = 0;\n }\n\n return timeToCompare + delayToCompare <= time;\n};\n\n/**\n * Returns an image for first, middle or last stations.\n * @param {Number} stations The stations list.\n * @param {Number} index Index of the station in the list.\n * @param {Boolean} isStationPassed If the train is already passed at this station.\n * @param {Boolean} isNotStation If the train doesn't stop to this station.\n */\nconst defaultRenderStationImg = (\n stations,\n index,\n isStationPassed,\n isNotStation,\n) => {\n const { length } = stations;\n let src = station.src || station;\n if (index === 0) {\n src = firstStation.src || firstStation;\n } else if (index === length - 1) {\n src = lastStation.src || lastStation;\n } else if (isNotStation) {\n src = line.src || line;\n }\n return <img src={src} alt=\"routeScheduleLine\" className=\"rt-route-icon\" />;\n};\n\nconst defaultRenderStation = ({\n lineInfos,\n onStationClick,\n trackerLayer,\n renderStationImg,\n stop,\n idx,\n}) => {\n const {\n stationId,\n arrivalDelay,\n departureDelay,\n arrivalTime,\n departureTime,\n state,\n stationName,\n aimedArrivalTime,\n aimedDepartureTime,\n } = stop;\n const cancelled = state === 'JOURNEY_CANCELLED' || state === 'STOP_CANCELLED';\n const { stations } = lineInfos;\n const isFirstStation = idx === 0;\n const isLastStation = idx === stations.length - 1;\n const isStationPassed = isPassed(stop, trackerLayer.time, stations, idx);\n const isNotStation = isNotStop(stop);\n return (\n <div\n // Train line can go in circle so begin and end have the same id,\n // using the time in the key should fix the issue.\n key={(stationId || stationName) + arrivalTime + departureTime}\n role=\"button\"\n className={[\n 'rt-route-station',\n isStationPassed ? ' rt-passed' : '',\n isNotStation ? ' rt-no-stop' : '',\n ].join('')}\n onClick={(e) => {\n return onStationClick(stop, e);\n }}\n tabIndex={0}\n onKeyPress={(e) => {\n return e.which === 13 && onStationClick(stop, e);\n }}\n >\n <div className=\"rt-route-delay\">\n {typeof arrivalDelay === 'undefined' || isFirstStation || cancelled ? (\n ''\n ) : (\n <span\n className={`rt-route-delay-arrival${` ${getDelayColor(\n arrivalDelay,\n )}`}`}\n >\n {`+${getDelayString(arrivalDelay)}`}\n </span>\n )}\n {typeof departureDelay === 'undefined' || isLastStation || cancelled ? (\n ''\n ) : (\n <span\n className={`rt-route-delay-departure${` ${getDelayColor(\n departureDelay,\n )}`}`}\n >\n {`+${getDelayString(departureDelay)}`}\n </span>\n )}\n </div>\n <div className=\"rt-route-times\">\n <span\n className={`rt-route-time-arrival ${\n cancelled ? 'rt-route-cancelled' : ''\n }`}\n >\n {getHoursAndMinutes(aimedArrivalTime)}\n </span>\n <span\n className={`rt-route-time-departure ${\n cancelled ? 'rt-route-cancelled' : ''\n }`}\n >\n {getHoursAndMinutes(aimedDepartureTime)}\n </span>\n </div>\n {renderStationImg(stations, idx, isStationPassed, isNotStation)}\n <div className={cancelled ? 'rt-route-cancelled' : ''}>{stationName}</div>\n </div>\n );\n};\n\nconst renderRouteIdentifier = ({ routeIdentifier, longName }) => {\n if (routeIdentifier) {\n // first part of the id, without leading zeros.\n const id = parseInt(routeIdentifier.split('.')[0], 10);\n if (!longName.includes(id)) {\n return ` (${id})`;\n }\n }\n return null;\n};\n\nconst defaultRenderHeader = ({ lineInfos, renderHeaderButtons }) => {\n const {\n type,\n vehicleType,\n shortName,\n longName,\n stroke,\n destination,\n routeIdentifier,\n text_color: textColor,\n } = lineInfos;\n return (\n <div className=\"rt-route-header\">\n <span\n className=\"rt-route-icon\"\n style={{\n /* stylelint-disable-next-line value-keyword-case */\n backgroundColor: stroke || getBgColor(type || vehicleType),\n color: textColor || 'black',\n }}\n >\n {shortName}\n </span>\n <div className=\"rt-route-title\">\n <span className=\"rt-route-name\">{destination}</span>\n <span>\n {longName}\n {renderRouteIdentifier(lineInfos)}\n </span>\n </div>\n <div className=\"rt-route-buttons\">\n {renderHeaderButtons(routeIdentifier)}\n </div>\n </div>\n );\n};\n\nconst defaultRenderFooter = (props) => {\n const { lineInfos, renderCopyright } = props;\n if (!lineInfos.operator && !lineInfos.publisher) {\n return null;\n }\n return <div className=\"rt-route-footer\">{renderCopyright({ ...props })}</div>;\n};\n\nconst defaultRenderLink = (text, url) => {\n return (\n <div className=\"rt-route-copyright-link\">\n {url ? (\n <a href={url} target=\"_blank\" rel=\"noreferrer\">\n {text}\n </a>\n ) : (\n <>{text}</>\n )}\n </div>\n );\n};\n\nconst defaultRenderCopyright = ({ lineInfos }) => {\n return (\n <span className=\"rt-route-copyright\">\n {lineInfos.operator &&\n defaultRenderLink(lineInfos.operator, lineInfos.operatorUrl)}\n {lineInfos.operator && lineInfos.publisher && <span>&nbsp;-&nbsp;</span>}\n {lineInfos.publisher &&\n defaultRenderLink(lineInfos.publisher, lineInfos.publisherUrl)}\n {lineInfos.license && <span>&nbsp;(</span>}\n {lineInfos.license &&\n defaultRenderLink(lineInfos.license, lineInfos.licenseUrl)}\n {lineInfos.license && ')'}\n </span>\n );\n};\n\nconst propTypes = {\n /**\n * CSS class of the route schedule wrapper.\n */\n className: PropTypes.string,\n\n /**\n * Trajectory stations informations.\n */\n lineInfos: ReactTransitPropTypes.lineInfos,\n\n /**\n * Trackerlayer.\n */\n trackerLayer: PropTypes.instanceOf(TrackerLayer).isRequired,\n\n /**\n * Render Header of the route scheduler.\n */\n renderHeader: PropTypes.func,\n\n /**\n * Render Footer of the route scheduler.\n */\n renderFooter: PropTypes.func,\n\n /**\n * Render Copyright of the route scheduler.\n */\n renderCopyright: PropTypes.func,\n\n /**\n * Render the status of the station image.\n */\n renderStationImg: PropTypes.func,\n\n /**\n * Render a station.\n */\n renderStation: PropTypes.func,\n\n /**\n * Function triggered on station's click event.\n */\n onStationClick: PropTypes.func,\n\n /**\n * Function to render header buttons.\n */\n renderHeaderButtons: PropTypes.func,\n};\n\nconst defaultProps = {\n className: 'rt-route-schedule',\n lineInfos: null,\n renderHeader: defaultRenderHeader,\n renderStation: defaultRenderStation,\n renderStationImg: defaultRenderStationImg,\n renderCopyright: defaultRenderCopyright,\n renderFooter: defaultRenderFooter,\n renderHeaderButtons: () => {\n return null;\n },\n onStationClick: () => {},\n};\n\n/**\n * RouteSchedule displays information, stops and punctuality about the clicked route.\n */\nfunction RouteSchedule(props) {\n const { lineInfos, className, renderStation, renderHeader, renderFooter } =\n props;\n\n if (!lineInfos) {\n return null;\n }\n\n return (\n <div className={className}>\n {renderHeader({ ...props })}\n <div className=\"rt-route-body\">\n {lineInfos.stations.map((stop, idx) => {\n return renderStation({ ...props, stop, idx });\n })}\n </div>\n {renderFooter({ ...props })}\n </div>\n );\n}\n\nRouteSchedule.propTypes = propTypes;\nRouteSchedule.defaultProps = defaultProps;\n\nexport default React.memo(RouteSchedule);\n"],
5
+ "mappings": "AAEA,OAAO,WAAW;AAClB,OAAO,eAAe;AACtB;AAAA,EACE,iBAAiB;AAAA,EACjB;AAAA,OACK;AACP,SAAS,oBAAoB,sBAAsB;AACnD,OAAO,2BAA2B;AAClC,OAAO,kBAAkB;AACzB,OAAO,aAAa;AACpB,OAAO,iBAAiB;AACxB,OAAO,UAAU;AAEjB,MAAM,EAAE,WAAW,IAAI;AAMvB,MAAM,gBAAgB,CAAC,SAAS;AAC9B,QAAM,OAAO,KAAK,MAAQ,OAAO,OAAO,IAAK,OAAQ,GAAI;AACzD,MAAI,QAAQ,MAAM;AAChB,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,KAAK;AACf,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,KAAK;AACf,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,KAAK;AACf,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAMA,MAAM,YAAY,CAAC,SAAS;AAC1B,SAAO,CAAC,KAAK,eAAe,CAAC,KAAK;AACpC;AASA,MAAM,WAAW,CAAC,MAAM,MAAM,OAAO,QAAQ;AAG3C,MAAI,UAAU,IAAI,GAAG;AACnB,QAAI,MAAM,MAA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kB,UAAU,SAAS,UAAU,UAAU,GAC1D,UAAU,WAAW,GACxB;AAEJ;AAEA,MAAM,YAAY;AAAA,EAIhB,WAAW,UAAU;AAAA,EAKrB,WAAW,sBAAsB;AAAA,EAKjC,cAAc,UAAU,WAAW,YAAY,EAAE;AAAA,EAKjD,cAAc,UAAU;AAAA,EAKxB,cAAc,UAAU;AAAA,EAKxB,iBAAiB,UAAU;AAAA,EAK3B,kBAAkB,UAAU;AAAA,EAK5B,eAAe,UAAU;AAAA,EAKzB,gBAAgB,UAAU;AAAA,EAK1B,qBAAqB,UAAU;AACjC;AAEA,MAAM,eAAe;AAAA,EACnB,WAAW;AAAA,EACX,WAAW;AAAA,EACX,cAAc;AAAA,EACd,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,qBAAqB,MAAM;AACzB,WAAO;AAAA,EACT;AAAA,EACA,gBAAgB,MAAM;AAAA,EAAC;AACzB;AAKA,SAAS,cAAc,OAAO;AAC5B,QAAM,EAAE,WAAW,WAAW,eAAe,cAAc,aAAa,IACtE;AAEF,MAAI,CAAC,WAAW;AACd,WAAO;AAAA,EACT;AAEA,SACE,oCAAC;AAAA,IAAI;AAAA,KACF,aAAa,EAAE,GAAG,MAAM,CAAC,GAC1B,oCAAC;AAAA,IAAI,WAAU;AAAA,KACZ,UAAU,SAAS,IAAI,CAAC,MAAM,QAAQ;AACrC,WAAO,cAAc,EAAE,GAAG,OAAO,MAAM,IAAI,CAAC;AAAA,EAC9C,CAAC,CACH,GACC,aAAa,EAAE,GAAG,MAAM,CAAC,CAC5B;AAEJ;AAEA,cAAc,YAAY;AAC1B,cAAc,eAAe;AAE7B,eAAe,MAAM,KAAK,aAAa;",
6
6
  "names": []
7
7
  }
@@ -38,7 +38,8 @@ function StopsFinderOption({ option }) {
38
38
  if (value) {
39
39
  const MotIcon = iconForMot[key];
40
40
  return /* @__PURE__ */ React.createElement("span", {
41
- className: classes.icon
41
+ className: classes.icon,
42
+ key
42
43
  }, /* @__PURE__ */ React.createElement(MotIcon, null));
43
44
  }
44
45
  return /* @__PURE__ */ React.createElement(React.Fragment, null);
@@ -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}>\n <MotIcon />\n </span>\n );\n }\n return <></>;\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,OAAO,KAAK,MAAM;AAC3B,WAAO,OAAO,qBAAqB,MAAM;AAAA,EAC3C,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;AAAA,IAAS,UAAU,oCAAC,WAAI;AAAA,KACvB,oCAAC;AAAA,IAAI,WAAW,QAAQ;AAAA,KACrB,OAAO,QAAQ,OAAO,WAAW,GAAG,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AAC3D,QAAI,OAAO;AACT,YAAM,UAAU,WAAW;AAC3B,aACE,oCAAC;AAAA,QAAK,WAAW,QAAQ;AAAA,SACvB,oCAAC,aAAQ,CACX;AAAA,IAEJ;AACA,WAAO,wDAAE;AAAA,EACX,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": ["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 <></>;\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,OAAO,KAAK,MAAM;AAC3B,WAAO,OAAO,qBAAqB,MAAM;AAAA,EAC3C,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;AAAA,IAAS,UAAU,oCAAC,WAAI;AAAA,KACvB,oCAAC;AAAA,IAAI,WAAW,QAAQ;AAAA,KACrB,OAAO,QAAQ,OAAO,WAAW,GAAG,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AAC3D,QAAI,OAAO;AACT,YAAM,UAAU,WAAW;AAC3B,aACE,oCAAC;AAAA,QAAK,WAAW,QAAQ;AAAA,QAAM;AAAA,SAC7B,oCAAC,aAAQ,CACX;AAAA,IAEJ;AACA,WAAO,wDAAE;AAAA,EACX,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
  }
@@ -9,6 +9,8 @@ import PropTypes from "prop-types";
9
9
  import { FaPlus, FaMinus } from "react-icons/fa";
10
10
  import { ZoomSlider } from "ol/control";
11
11
  import OLMap from "ol/Map";
12
+ import { easeOut } from "ol/easing";
13
+ import { unByKey } from "ol/Observable";
12
14
  const propTypes = {
13
15
  map: PropTypes.instanceOf(OLMap).isRequired,
14
16
  delta: PropTypes.number,
@@ -34,10 +36,19 @@ const defaultProps = {
34
36
  zoomSlider: false,
35
37
  delta: 1
36
38
  };
37
- const updateZoom = (map, zoomAction) => {
38
- map.getView().cancelAnimations();
39
- const zoom = map.getView().getZoom();
40
- map.getView().animate({ zoom: zoom + zoomAction });
39
+ const updateZoom = (map, delta) => {
40
+ const view = map.getView();
41
+ const currentZoom = view.getZoom();
42
+ const newZoom = currentZoom + delta;
43
+ const constrainedZoom = view.getConstrainedZoom(newZoom);
44
+ if (view.getAnimating()) {
45
+ view.cancelAnimations();
46
+ }
47
+ view.animate({
48
+ zoom: constrainedZoom,
49
+ duration: 250,
50
+ easing: easeOut
51
+ });
41
52
  };
42
53
  function Zoom({
43
54
  map,
@@ -73,10 +84,9 @@ function Zoom({
73
84
  return currentZoom <= map.getView().getConstrainedZoom(map.getView().getMinZoom());
74
85
  }, [currentZoom, map]);
75
86
  useEffect(() => {
76
- const zoomListener = () => {
77
- return setZoom(map.getView().getZoom());
78
- };
79
- map.on("moveend", zoomListener);
87
+ const listenerKey = map.on("moveend", () => {
88
+ setZoom(map.getView().getZoom());
89
+ });
80
90
  let control;
81
91
  if (zoomSlider && ref.current) {
82
92
  control = new ZoomSlider();
@@ -85,7 +95,7 @@ function Zoom({
85
95
  map.addControl(control);
86
96
  }
87
97
  return () => {
88
- map.un("moveend", zoomListener);
98
+ unByKey(listenerKey);
89
99
  if (control) {
90
100
  map.removeControl(control);
91
101
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/Zoom/Zoom.js"],
4
- "sourcesContent": ["import React, {\n useEffect,\n useRef,\n useCallback,\n useState,\n useMemo,\n} from 'react';\nimport PropTypes from 'prop-types';\nimport { FaPlus, FaMinus } from 'react-icons/fa';\nimport { ZoomSlider } from 'ol/control';\nimport OLMap from 'ol/Map';\n\nconst propTypes = {\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * The zoom delta applied on each click.\n */\n delta: PropTypes.number,\n\n /**\n * Titles HTML attribtues for button.\n */\n titles: PropTypes.shape({\n zoomIn: PropTypes.string,\n zoomOut: PropTypes.string,\n }),\n\n /**\n * Children content of the zoom in button.\n */\n zoomInChildren: PropTypes.node,\n\n /**\n * Children content of the zoom out button.\n */\n zoomOutChildren: PropTypes.node,\n\n /**\n * Display a slider to zoom.\n */\n zoomSlider: PropTypes.bool,\n};\n\nconst defaultProps = {\n titles: {\n zoomIn: 'Zoom in',\n zoomOut: 'Zoom out',\n },\n zoomInChildren: <FaPlus focusable={false} />,\n zoomOutChildren: <FaMinus focusable={false} />,\n zoomSlider: false,\n delta: 1,\n};\n\nconst updateZoom = (map, zoomAction) => {\n map.getView().cancelAnimations();\n const zoom = map.getView().getZoom();\n\n map.getView().animate({ zoom: zoom + zoomAction });\n};\n\n/**\n * The Zoom component creates a zoom wrapper containing zoom-in and zoom-out buttons\n * and an optional [ol/ZoomSlider](https://openlayers.org/en/latest/apidoc/module-ol_control_ZoomSlider-ZoomSlider.html).\n */\nfunction Zoom({\n map,\n titles,\n zoomInChildren,\n zoomOutChildren,\n zoomSlider,\n delta,\n ...other\n}) {\n const ref = useRef();\n const [currentZoom, setZoom] = useState();\n\n const zoomIn = useCallback(\n (evt) => {\n if (!evt.which || evt.which === 13) {\n updateZoom(map, delta);\n }\n },\n [delta, map],\n );\n\n const zoomOut = useCallback(\n (evt) => {\n if (!evt.which || evt.which === 13) {\n updateZoom(map, -delta);\n }\n },\n [delta, map],\n );\n\n const zoomInDisabled = useMemo(() => {\n return (\n currentZoom >=\n map.getView().getConstrainedZoom(map.getView().getMaxZoom())\n );\n }, [currentZoom, map]);\n\n const zoomOutDisabled = useMemo(() => {\n return (\n currentZoom <=\n map.getView().getConstrainedZoom(map.getView().getMinZoom())\n );\n }, [currentZoom, map]);\n\n useEffect(() => {\n /* Trigger zoom update to disable zooms on max and min */\n const zoomListener = () => {\n return setZoom(map.getView().getZoom());\n };\n map.on('moveend', zoomListener);\n\n let control;\n if (zoomSlider && ref.current) {\n control = new ZoomSlider();\n // We don't want to navigate to the zoom slider using TAB navigation.\n control.element.firstElementChild.tabIndex = -1;\n // Set the zoom slider in the custom control wrapper.\n control.setTarget(ref.current);\n map.addControl(control);\n }\n return () => {\n map.un('moveend', zoomListener);\n if (control) {\n map.removeControl(control);\n }\n };\n }, [map, zoomSlider]);\n\n return (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div className=\"rs-zooms-bar\" {...other}>\n <button\n type=\"button\"\n tabIndex={0}\n className=\"rs-zoom-in\"\n title={titles.zoomIn}\n onClick={zoomIn}\n onKeyPress={zoomIn}\n disabled={zoomInDisabled}\n >\n {zoomInChildren}\n </button>\n {zoomSlider ? <div className=\"rs-zoomslider-wrapper\" ref={ref} /> : null}\n <button\n type=\"button\"\n tabIndex={0}\n className=\"rs-zoom-out\"\n title={titles.zoomOut}\n onClick={zoomOut}\n onKeyPress={zoomOut}\n disabled={zoomOutDisabled}\n >\n {zoomOutChildren}\n </button>\n </div>\n );\n}\n\nZoom.propTypes = propTypes;\nZoom.defaultProps = defaultProps;\n\nexport default React.memo(Zoom);\n"],
5
- "mappings": "AAAA,OAAO;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAO,eAAe;AACtB,SAAS,QAAQ,e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AAAA,KAET,eACH,CACF;AAEJ;AAEA,KAAK,YAAY;AACjB,KAAK,eAAe;AAEpB,eAAe,MAAM,KAAK,IAAI;",
4
+ "sourcesContent": ["import React, {\n useEffect,\n useRef,\n useCallback,\n useState,\n useMemo,\n} from 'react';\nimport PropTypes from 'prop-types';\nimport { FaPlus, FaMinus } from 'react-icons/fa';\nimport { ZoomSlider } from 'ol/control';\nimport OLMap from 'ol/Map';\nimport { easeOut } from 'ol/easing';\nimport { unByKey } from 'ol/Observable';\n\nconst propTypes = {\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * The zoom delta applied on each click.\n */\n delta: PropTypes.number,\n\n /**\n * Titles HTML attribtues for button.\n */\n titles: PropTypes.shape({\n zoomIn: PropTypes.string,\n zoomOut: PropTypes.string,\n }),\n\n /**\n * Children content of the zoom in button.\n */\n zoomInChildren: PropTypes.node,\n\n /**\n * Children content of the zoom out button.\n */\n zoomOutChildren: PropTypes.node,\n\n /**\n * Display a slider to zoom.\n */\n zoomSlider: PropTypes.bool,\n};\n\nconst defaultProps = {\n titles: {\n zoomIn: 'Zoom in',\n zoomOut: 'Zoom out',\n },\n zoomInChildren: <FaPlus focusable={false} />,\n zoomOutChildren: <FaMinus focusable={false} />,\n zoomSlider: false,\n delta: 1,\n};\n\nconst updateZoom = (map, delta) => {\n const view = map.getView();\n const currentZoom = view.getZoom();\n const newZoom = currentZoom + delta;\n const constrainedZoom = view.getConstrainedZoom(newZoom);\n if (view.getAnimating()) {\n view.cancelAnimations();\n }\n view.animate({\n zoom: constrainedZoom,\n duration: 250,\n easing: easeOut,\n });\n};\n\n/**\n * The Zoom component creates a zoom wrapper containing zoom-in and zoom-out buttons\n * and an optional [ol/ZoomSlider](https://openlayers.org/en/latest/apidoc/module-ol_control_ZoomSlider-ZoomSlider.html).\n */\nfunction Zoom({\n map,\n titles,\n zoomInChildren,\n zoomOutChildren,\n zoomSlider,\n delta,\n ...other\n}) {\n const ref = useRef();\n const [currentZoom, setZoom] = useState();\n\n const zoomIn = useCallback(\n (evt) => {\n if (!evt.which || evt.which === 13) {\n updateZoom(map, delta);\n }\n },\n [delta, map],\n );\n\n const zoomOut = useCallback(\n (evt) => {\n if (!evt.which || evt.which === 13) {\n updateZoom(map, -delta);\n }\n },\n [delta, map],\n );\n\n const zoomInDisabled = useMemo(() => {\n return (\n currentZoom >=\n map.getView().getConstrainedZoom(map.getView().getMaxZoom())\n );\n }, [currentZoom, map]);\n\n const zoomOutDisabled = useMemo(() => {\n return (\n currentZoom <=\n map.getView().getConstrainedZoom(map.getView().getMinZoom())\n );\n }, [currentZoom, map]);\n\n useEffect(() => {\n // Trigger zoom update to disable zooms on max and min\n const listenerKey = map.on('moveend', () => {\n setZoom(map.getView().getZoom());\n });\n\n let control;\n if (zoomSlider && ref.current) {\n control = new ZoomSlider();\n // We don't want to navigate to the zoom slider using TAB navigation.\n control.element.firstElementChild.tabIndex = -1;\n // Set the zoom slider in the custom control wrapper.\n control.setTarget(ref.current);\n map.addControl(control);\n }\n return () => {\n unByKey(listenerKey);\n if (control) {\n map.removeControl(control);\n }\n };\n }, [map, zoomSlider]);\n\n return (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div className=\"rs-zooms-bar\" {...other}>\n <button\n type=\"button\"\n tabIndex={0}\n className=\"rs-zoom-in\"\n title={titles.zoomIn}\n onClick={zoomIn}\n onKeyPress={zoomIn}\n disabled={zoomInDisabled}\n >\n {zoomInChildren}\n </button>\n {zoomSlider ? <div className=\"rs-zoomslider-wrapper\" ref={ref} /> : null}\n <button\n type=\"button\"\n tabIndex={0}\n className=\"rs-zoom-out\"\n title={titles.zoomOut}\n onClick={zoomOut}\n onKeyPress={zoomOut}\n disabled={zoomOutDisabled}\n >\n {zoomOutChildren}\n </button>\n </div>\n );\n}\n\nZoom.propTypes = propTypes;\nZoom.defaultProps = defaultProps;\n\nexport default React.memo(Zoom);\n"],
5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AA,IACd,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,UAAU;AAAA,KAET,cACH,GACC,aAAa,oCAAC;AAAA,IAAI,WAAU;AAAA,IAAwB;AAAA,GAAU,IAAK,MACpE,oCAAC;AAAA,IACC,MAAK;AAAA,IACL,UAAU;AAAA,IACV,WAAU;AAAA,IACV,OAAO,OAAO;AAAA,IACd,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,UAAU;AAAA,KAET,eACH,CACF;AAEJ;AAEA,KAAK,YAAY;AACjB,KAAK,eAAe;AAEpB,eAAe,MAAM,KAAK,IAAI;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,19 +1,15 @@
1
1
  {
2
2
  "name": "react-spatial",
3
3
  "description": "Components to build React map apps.",
4
- "version": "1.4.0",
4
+ "version": "1.5.2-beta.12",
5
5
  "license": "MIT",
6
6
  "dependencies": {
7
7
  "@geops/geops-ui": "0.1.13",
8
8
  "@material-ui/core": "4.12.3",
9
9
  "@material-ui/icons": "4.11.2",
10
10
  "@material-ui/lab": "4.0.0-alpha.60",
11
- "abortcontroller-polyfill": "1.7.3",
12
11
  "query-string": "7.0.1",
13
- "radians-degrees": "1.0.0",
14
12
  "re-resizable": "6.9.1",
15
- "react-autosuggest": "10.1.0",
16
- "react-draggable": "4.4.4",
17
13
  "react-icons": "4.4.0",
18
14
  "resize-observer-polyfill": "1.5.1"
19
15
  },
@@ -25,26 +21,22 @@
25
21
  "react-dom": "^16"
26
22
  },
27
23
  "devDependencies": {
28
- "@babel/core": "7.15.0",
29
- "@babel/eslint-parser": "7.15.0",
30
- "@babel/plugin-transform-runtime": "7.15.0",
31
24
  "@babel/preset-env": "7.15.0",
32
25
  "@babel/preset-react": "7.14.5",
26
+ "@cfaester/enzyme-adapter-react-18": "0.7.0",
33
27
  "@commitlint/cli": "17.0.2",
34
28
  "@commitlint/config-conventional": "17.0.2",
35
29
  "@svgr/webpack": "5.5.0",
36
- "@testing-library/jest-dom": "5.16.3",
37
- "@testing-library/react": "12.1.4",
38
- "@testing-library/user-event": "13.5.0",
39
- "@wojtekmaj/enzyme-adapter-react-17": "0.6.7",
40
- "babel-core": "7.0.0-bridge.0",
41
- "babel-jest": "27.2.4",
42
- "babel-loader": "8.2.2",
43
- "buble": "0.20.0",
44
- "canvas": "2.8.0",
30
+ "@testing-library/jest-dom": "5.16.5",
31
+ "@testing-library/react": "14.0.0",
32
+ "@testing-library/user-event": "14.4.3",
33
+ "babel-jest": "29.5.0",
34
+ "babel-loader": "9.1.2",
35
+ "canvas": "2.11.2",
45
36
  "css-loader": "5.2.6",
46
37
  "enzyme": "3.11.0",
47
38
  "esbuild": "^0.15.6",
39
+ "esbuild-loader": "^3.0.1",
48
40
  "eslint": "7.32.0",
49
41
  "eslint-config-airbnb": "18.2.1",
50
42
  "eslint-config-prettier": "8.3.0",
@@ -56,32 +48,31 @@
56
48
  "file-loader": "6.2.0",
57
49
  "fixpack": "3.0.6",
58
50
  "generact": "0.4.0",
59
- "husky": "8.0.1",
60
- "identity-obj-proxy": "3.0.0",
51
+ "husky": "^7.0.0",
52
+ "identity-obj-proxy": "^3.0.0",
61
53
  "is-ci": "3.0.1",
62
- "jest": "26.6.3",
63
- "jest-canvas-mock": "2.3.1",
64
- "jest-canvas-snapshot-serializer": "1.0.1",
54
+ "jest": "29.5.0",
55
+ "jest-canvas-mock": "2.5.0",
65
56
  "jest-date-mock": "1.0.8",
57
+ "jest-environment-jsdom": "^29.5.0",
66
58
  "jest-fetch-mock": "3.0.3",
67
59
  "jest-serializer-html": "7.1.0",
68
- "jest-svg-transformer": "1.0.0",
69
60
  "jest-transform-file": "1.1.1",
61
+ "jest-transformer-svg": "^2.0.1",
70
62
  "jsts": "2.7.3",
71
63
  "lint-staged": "11.2.0",
72
64
  "mapbox-gl": "1.13.1",
73
65
  "maplibre-gl": "2.4.0",
74
- "mobility-toolbox-js": "2.0.0-beta.54",
66
+ "mobility-toolbox-js": "2.0.0-beta.79",
75
67
  "ol": "6.14.1",
76
68
  "prettier": "2.4.1",
77
69
  "proj4": "2.7.5",
78
70
  "prop-types": "15.7.2",
79
- "react": "17.0.2",
80
- "react-app-polyfill": "2.0.0",
81
- "react-dom": "17.0.2",
82
- "react-styleguidist": "11.0.8",
71
+ "react": "18",
72
+ "react-dom": "18",
73
+ "react-styleguidist": "13.1.1",
83
74
  "react-svg-loader": "3.0.3",
84
- "react-test-renderer": "17.0.2",
75
+ "react-test-renderer": "18.2.0",
85
76
  "sass": "1.49.9",
86
77
  "sass-loader": "10.2.0",
87
78
  "standard-version": "9.5.0",
@@ -91,13 +82,13 @@
91
82
  "stylelint-config-recommended-scss": "4.3.0",
92
83
  "stylelint-config-standard": "22.0.0",
93
84
  "stylelint-scss": "3.21.0",
85
+ "terser-webpack-plugin": "^5.3.7",
94
86
  "url-loader": "4.1.1",
95
87
  "vinyl-fs": "3.0.3",
96
- "webpack": "4.46.0",
88
+ "webpack": "^5.81.0",
97
89
  "xml-beautifier": "0.5.0"
98
90
  },
99
91
  "scripts": {
100
- "buble": "buble --no modules,asyncAwait -i src -o build --objectAssign Object.assign --sourcemap",
101
92
  "build": "yarn esbuild && find build -type f -name '*.test.*' -delete && rm -rf build/styleguidist && cp package.json README.md LICENSE build && cp -rf src/images build && cp -rf src/themes build",
102
93
  "coverage": "yarn test --coverage --coverageDirectory=coverage",
103
94
  "cp": "generact --root src/components",
@@ -106,9 +97,10 @@
106
97
  "format": "prettier --write 'src/**/*.js' && eslint 'src/**/*.js' --fix && stylelint 'src/**/*.css' 'src/**/*.scss' --fix",
107
98
  "link2": "cmdToAdd=$(node ./scripts/read-pkg-json.js add) && $cmdToAdd && yarn build && cmdToRemove=$(node ./scripts/read-pkg-json.js remove) && $cmdToRemove && cd build && yarn link",
108
99
  "lint": "eslint 'src/**/*.js' && stylelint 'src/**/*.css' 'src/**/*.scss'",
109
- "postbuild": "cp package.json build/ && cd src && find . -name '*.scss' | cpio -pdm ../build",
100
+ "postbuild": "cp package.json build/ && cd src && find . -name '*.scss' | cpio -pdm ../build && cd ..",
110
101
  "prebuild": "rm -rf build/",
111
- "publish:beta": "yarn release -- --prerelease beta --skip.changelog && git push origin HEAD && yarn run build && git push --tags && yarn publish build/ --tag beta",
102
+ "prepare": "is-ci || husky install",
103
+ "publish:beta": "yarn release -- --prerelease beta --skip.changelog && git push origin HEAD && yarn run build && git push --tags && HUSKY=0 yarn publish build/ --tag beta && cd ..",
112
104
  "publish:beta:dryrun": "yarn release -- --prerelease beta --dry-run --skip.changelog",
113
105
  "publish:public": "yarn release && git push origin HEAD && yarn build && git push --tags && yarn publish build/",
114
106
  "publish:public:dryrun": "yarn release --dry-run",
@@ -130,20 +122,19 @@
130
122
  "es6": true,
131
123
  "jest": true
132
124
  },
133
- "parser": "@babel/eslint-parser",
134
125
  "extends": [
135
126
  "airbnb",
136
127
  "airbnb/hooks",
137
128
  "prettier"
138
129
  ],
130
+ "parserOptions": {
131
+ "ecmaVersion": "latest"
132
+ },
139
133
  "plugins": [
140
134
  "prettier"
141
135
  ],
142
136
  "rules": {
143
- "arrow-body-style": [
144
- "error",
145
- "always"
146
- ],
137
+ "arrow-body-style": "off",
147
138
  "import/no-extraneous-dependencies": [
148
139
  "error",
149
140
  {
@@ -165,11 +156,10 @@
165
156
  }
166
157
  },
167
158
  "jest": {
168
- "maxConcurrency": 10,
159
+ "testEnvironment": "jsdom",
169
160
  "transform": {
170
161
  ".+\\.js$": "babel-jest",
171
- ".+\\.svg$": "jest-svg-transformer",
172
- "\\.(jpg|jpeg|png|gif|webp)$": "jest-transform-file"
162
+ ".+\\.svg$": "jest-transformer-svg"
173
163
  },
174
164
  "transformIgnorePatterns": [
175
165
  "node_modules/(?!(jsts|ol|mobility-toolbox-js)|@geops|geotiff|quick-lru)"
@@ -178,11 +168,10 @@
178
168
  "<rootDir>/src/**/?(*.)+(spec|test).[jt]s?(x)"
179
169
  ],
180
170
  "moduleNameMapper": {
181
- ".+\\.scss$": "identity-obj-proxy"
171
+ "\\.(jpg|jpeg|png|gif|webp|scss)$": "identity-obj-proxy"
182
172
  },
183
173
  "snapshotSerializers": [
184
- "jest-serializer-html",
185
- "jest-canvas-snapshot-serializer"
174
+ "jest-serializer-html"
186
175
  ],
187
176
  "testPathIgnorePatterns": [
188
177
  "<rootDir>/(build|coverage|public|doc|packages)"
@@ -8,7 +8,11 @@ export const getHoursAndMinutes = (timeInMs) => {
8
8
  const date = new Date(timeInMs);
9
9
  return `${pad(date.getHours())}:${pad(date.getMinutes())}`;
10
10
  };
11
- export const getDelayString = (timeInMs) => {
11
+ export const getDelayString = (delayInMs) => {
12
+ let timeInMs = delayInMs;
13
+ if (timeInMs < 0) {
14
+ timeInMs = 0;
15
+ }
12
16
  const h = Math.floor(timeInMs / 36e5);
13
17
  const m = Math.floor(timeInMs % 36e5 / 6e4);
14
18
  const s = Math.floor(timeInMs % 36e5 % 6e4 / 1e3);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/timeUtils.js"],
4
- "sourcesContent": ["/**\n * Returns a string representation of a number, with a zero if the number is lower than 10.\n * @ignore\n */\nexport const pad = (integer) => {\n return integer < 10 ? `0${integer}` : integer;\n};\n\n/**\n * Returns a 'hh:mm' string from a time in ms.\n * @param {Number} timeInMs Time in milliseconds.\n * @ignore\n */\nexport const getHoursAndMinutes = (timeInMs) => {\n if (!timeInMs || timeInMs <= 0) {\n return '';\n }\n const date = new Date(timeInMs);\n return `${pad(date.getHours())}:${pad(date.getMinutes())}`;\n};\n\n/**\n * Returns a string representing a delay.\n * @param {Number} timeInMs Delay time in milliseconds.\n * @ignore\n */\nexport const getDelayString = (timeInMs) => {\n const h = Math.floor(timeInMs / 3600000);\n const m = Math.floor((timeInMs % 3600000) / 60000);\n const s = Math.floor(((timeInMs % 3600000) % 60000) / 1000);\n\n if (s === 0 && h === 0 && m === 0) {\n return '0';\n }\n if (s === 0 && h === 0) {\n return `${m}m`;\n }\n if (s === 0) {\n return `${h}h${m}m`;\n }\n if (m === 0 && h === 0) {\n return `${s}s`;\n }\n if (h === 0) {\n return `${m}m${s}s`;\n }\n return `${h}h${m}m${s}s`;\n};\n"],
5
- "mappings": "AAIO,aAAM,MAAM,CAAC,YAAY;AAC9B,SAAO,UAAU,KAAK,IAAI,YAAY;AACxC;AAOO,aAAM,qBAAqB,CAAC,aAAa;AAC9C,MAAI,CAAC,YAAY,YAAY,GAAG;AAC9B,WAAO;AAAA,EACT;AACA,QAAM,OAAO,IAAI,KAAK,QAAQ;AAC9B,SAAO,GAAG,IAAI,KAAK,SAAS,CAAC,KAAK,IAAI,KAAK,WAAW,CAAC;AACzD;AAOO,aAAM,iBAAiB,CAAC,aAAa;AAC1C,QAAM,IAAI,KAAK,MAAM,WAAW,IAAO;AACvC,QAAM,IAAI,KAAK,MAAO,WAAW,OAAW,GAAK;AACjD,QAAM,IAAI,KAAK,MAAQ,WAAW,OAAW,MAAS,GAAI;AAE1D,MAAI,MAAM,KAAK,MAAM,KAAK,MAAM,GAAG;AACjC,WAAO;AAAA,EACT;AACA,MAAI,MAAM,KAAK,MAAM,GAAG;AACtB,WAAO,GAAG;AAAA,EACZ;AACA,MAAI,MAAM,GAAG;AACX,WAAO,GAAG,KAAK;AAAA,EACjB;AACA,MAAI,MAAM,KAAK,MAAM,GAAG;AACtB,WAAO,GAAG;AAAA,EACZ;AACA,MAAI,MAAM,GAAG;AACX,WAAO,GAAG,KAAK;AAAA,EACjB;AACA,SAAO,GAAG,KAAK,KAAK;AACtB;",
4
+ "sourcesContent": ["/**\n * Returns a string representation of a number, with a zero if the number is lower than 10.\n * @ignore\n */\nexport const pad = (integer) => {\n return integer < 10 ? `0${integer}` : integer;\n};\n\n/**\n * Returns a 'hh:mm' string from a time in ms.\n * @param {Number} timeInMs Time in milliseconds.\n * @ignore\n */\nexport const getHoursAndMinutes = (timeInMs) => {\n if (!timeInMs || timeInMs <= 0) {\n return '';\n }\n const date = new Date(timeInMs);\n return `${pad(date.getHours())}:${pad(date.getMinutes())}`;\n};\n\n/**\n * Returns a string representing a delay.\n * @param {Number} timeInMs Delay time in milliseconds.\n * @ignore\n */\nexport const getDelayString = (delayInMs) => {\n let timeInMs = delayInMs;\n if (timeInMs < 0) {\n timeInMs = 0;\n }\n const h = Math.floor(timeInMs / 3600000);\n const m = Math.floor((timeInMs % 3600000) / 60000);\n const s = Math.floor(((timeInMs % 3600000) % 60000) / 1000);\n\n if (s === 0 && h === 0 && m === 0) {\n return '0';\n }\n if (s === 0 && h === 0) {\n return `${m}m`;\n }\n if (s === 0) {\n return `${h}h${m}m`;\n }\n if (m === 0 && h === 0) {\n return `${s}s`;\n }\n if (h === 0) {\n return `${m}m${s}s`;\n }\n return `${h}h${m}m${s}s`;\n};\n"],
5
+ "mappings": "AAIO,aAAM,MAAM,CAAC,YAAY;AAC9B,SAAO,UAAU,KAAK,IAAI,YAAY;AACxC;AAOO,aAAM,qBAAqB,CAAC,aAAa;AAC9C,MAAI,CAAC,YAAY,YAAY,GAAG;AAC9B,WAAO;AAAA,EACT;AACA,QAAM,OAAO,IAAI,KAAK,QAAQ;AAC9B,SAAO,GAAG,IAAI,KAAK,SAAS,CAAC,KAAK,IAAI,KAAK,WAAW,CAAC;AACzD;AAOO,aAAM,iBAAiB,CAAC,cAAc;AAC3C,MAAI,WAAW;AACf,MAAI,WAAW,GAAG;AAChB,eAAW;AAAA,EACb;AACA,QAAM,IAAI,KAAK,MAAM,WAAW,IAAO;AACvC,QAAM,IAAI,KAAK,MAAO,WAAW,OAAW,GAAK;AACjD,QAAM,IAAI,KAAK,MAAQ,WAAW,OAAW,MAAS,GAAI;AAE1D,MAAI,MAAM,KAAK,MAAM,KAAK,MAAM,GAAG;AACjC,WAAO;AAAA,EACT;AACA,MAAI,MAAM,KAAK,MAAM,GAAG;AACtB,WAAO,GAAG;AAAA,EACZ;AACA,MAAI,MAAM,GAAG;AACX,WAAO,GAAG,KAAK;AAAA,EACjB;AACA,MAAI,MAAM,KAAK,MAAM,GAAG;AACtB,WAAO,GAAG;AAAA,EACZ;AACA,MAAI,MAAM,GAAG;AACX,WAAO,GAAG,KAAK;AAAA,EACjB;AACA,SAAO,GAAG,KAAK,KAAK;AACtB;",
6
6
  "names": []
7
7
  }