react-spatial 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/RouteSchedule/RouteSchedule.js +3 -2
- package/components/RouteSchedule/RouteSchedule.js.map +2 -2
- package/package.json +1 -1
- package/components/Control/Control.js +0 -43
- package/components/Control/Control.js.map +0 -7
- package/components/Control/index.js +0 -1
- package/components/Control/index.js.map +0 -7
|
@@ -96,11 +96,12 @@ function RouteStop({
|
|
|
96
96
|
const [isStationPassed, setIsStationPassed] = useState(false);
|
|
97
97
|
useEffect(() => {
|
|
98
98
|
let timeout = null;
|
|
99
|
-
const
|
|
99
|
+
const time = trackerLayer.time || trackerLayer.engine?.time || Date.now();
|
|
100
|
+
const isStopPassed = isPassed(stop, time, stations, idx);
|
|
100
101
|
setIsStationPassed(isStopPassed);
|
|
101
102
|
if (stop.state === "TIME_BASED" && !isStopPassed) {
|
|
102
103
|
timeout = setInterval(() => {
|
|
103
|
-
setIsStationPassed(isPassed(stop,
|
|
104
|
+
setIsStationPassed(isPassed(stop, time, stations, idx));
|
|
104
105
|
}, 2e4);
|
|
105
106
|
}
|
|
106
107
|
return () => {
|
|
@@ -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 */\nimport {\n realtimeConfig,\n RealtimeLayer as TrackerLayer,\n} from \"mobility-toolbox-js/ol\";\nimport PropTypes from \"prop-types\";\n/* eslint-disable react/prop-types */\nimport React, { useEffect, useState } from \"react\";\n\nimport firstStation from \"../../images/RouteSchedule/firstStation.png\";\nimport lastStation from \"../../images/RouteSchedule/lastStation.png\";\nimport line from \"../../images/RouteSchedule/line.png\";\nimport station from \"../../images/RouteSchedule/station.png\";\nimport ReactTransitPropTypes from \"../../propTypes\";\nimport {\n getDelayString as defaultGetDelayString,\n getHoursAndMinutes,\n} from \"../../utils/timeUtils\";\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 defaultGetDelayColor = (time) => {\n const secs = Math.round(((time / 1800 / 2) * 3600) / 1000);\n if (secs >= 3600) {\n return \"rgb(237 0 76)\";\n }\n if (secs >= 500) {\n return \"rgb(232 0 0)\";\n }\n if (secs >= 300) {\n return \"rgb(255 74 0)\";\n }\n if (secs >= 180) {\n return \"rgb(247 191 0)\";\n }\n return \"rgb(0 160 12)\";\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 alt=\"routeScheduleLine\" className=\"rt-route-icon\" src={src} />;\n};\n\n/**\n * Returns an text.\n * @param {Number} stations The stations list.\n * @param {Number} index Index of the station in the list.\n * @param {Boolean} cancelled If the station is cancelled\n */\nconst defaultRenderStationName = (stations, index, cancelled) => {\n const { stationName } = stations[index];\n return (\n <div className={cancelled ? \"rt-route-cancelled\" : \"\"}>{stationName}</div>\n );\n};\n\n/**\n * Render a delay string.\n * @param {Number} delay The delay in ms to display.\n * @param {Boolean} stop The current stop object.\n * @param {Function} getDelayString Function to get string to display.\n * @param {Function} getColor Define the css color to use.\n *\n */\nconst defaultRenderDelay = (delay, stop, getDelayString, getDelayColor) => {\n return (\n <span style={{ color: getDelayColor?.(delay, stop) || \"inherit\" }}>\n {`${getDelayString?.(delay, stop) || \"\"}`}\n </span>\n );\n};\n\nconst emptyFunc = () => {};\n\nfunction RouteStop({\n getDelayColor = defaultGetDelayColor,\n getDelayString = defaultGetDelayString,\n idx,\n lineInfos,\n onStationClick = emptyFunc,\n renderArrivalDelay = defaultRenderDelay,\n renderDepartureDelay = defaultRenderDelay,\n renderStationImg = defaultRenderStationImg,\n renderStationName = defaultRenderStationName,\n stop,\n trackerLayer,\n}) {\n const {\n aimedArrivalTime,\n aimedDepartureTime,\n arrivalDelay,\n departureDelay,\n state,\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 isNotStation = isNotStop(stop);\n const [isStationPassed, setIsStationPassed] = useState(false);\n\n useEffect(() => {\n let timeout = null;\n\n const isStopPassed = isPassed(stop, trackerLayer.time, stations, idx);\n setIsStationPassed(isStopPassed);\n\n // We have to refresh the stop when the state it's time_based\n if (stop.state === \"TIME_BASED\" && !isStopPassed) {\n timeout = setInterval(() => {\n setIsStationPassed(isPassed(stop, trackerLayer.time, stations, idx));\n }, 20000);\n }\n return () => {\n clearInterval(timeout);\n };\n }, [stop, trackerLayer, stations, idx]);\n\n return (\n <div\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 onKeyPress={(e) => {\n return e.which === 13 && onStationClick(stop, e);\n }}\n role=\"button\"\n tabIndex={0}\n >\n <div className=\"rt-route-delay\">\n {arrivalDelay === undefined ||\n arrivalDelay === null ||\n isFirstStation ||\n cancelled\n ? \"\"\n : renderArrivalDelay(\n arrivalDelay,\n stop,\n getDelayString,\n getDelayColor,\n )}\n {departureDelay === undefined ||\n departureDelay === null ||\n isLastStation ||\n cancelled\n ? \"\"\n : renderDepartureDelay(\n departureDelay,\n stop,\n getDelayString,\n getDelayColor,\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 {renderStationName(stations, idx, cancelled)}\n </div>\n );\n}\n\nconst defaultRenderStation = (props) => {\n const { arrivalTime, departureTime, stationId, stationName } = props.stop;\n // eslint-disable-next-line react/jsx-props-no-spreading\n return (\n <RouteStop\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 // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n />\n );\n};\n\nconst defaultRenderRouteIdentifier = ({ longName, routeIdentifier }) => {\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) && !Number.isNaN(id)) {\n return ` (${id})`;\n }\n }\n return null;\n};\nconst defaultRenderHeaderButtons = () => {\n return null;\n};\n\nconst defaultRenderHeader = ({\n lineInfos,\n renderHeaderButtons = defaultRenderHeaderButtons,\n renderRouteIdentifier = defaultRenderRouteIdentifier,\n}) => {\n const {\n destination,\n longName,\n routeIdentifier,\n shortName,\n stroke,\n text_color: textColor,\n type,\n vehicleType,\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 defaultRenderLink = (text, url) => {\n return (\n <div className=\"rt-route-copyright-link\">\n {url ? (\n <a href={url} rel=\"noreferrer\" target=\"_blank\">\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> - </span>}\n {lineInfos.publisher &&\n defaultRenderLink(lineInfos.publisher, lineInfos.publisherUrl)}\n {lineInfos.license && <span> (</span>}\n {lineInfos.license &&\n defaultRenderLink(lineInfos.license, lineInfos.licenseUrl)}\n {lineInfos.license && \")\"}\n </span>\n );\n};\n\nconst defaultRenderFooter = (props) => {\n const { lineInfos, renderCopyright = defaultRenderCopyright } = props;\n if (!lineInfos.operator && !lineInfos.publisher) {\n return null;\n }\n return <div className=\"rt-route-footer\">{renderCopyright({ ...props })}</div>;\n};\n\nconst propTypes = {\n /**\n * CSS class of the route schedule wrapper.\n */\n className: PropTypes.string,\n\n /**\n * Function to get the delay color.\n */\n getDelayColor: PropTypes.func,\n\n /**\n * Function to get the delay string for stations.\n */\n getDelayString: PropTypes.func,\n\n /**\n * Trajectory stations informations.\n */\n lineInfos: ReactTransitPropTypes.lineInfos,\n\n /**\n * Function triggered on station's click event.\n */\n onStationClick: PropTypes.func,\n\n /**\n * Render delay for arrival.\n */\n renderArrivalDelay: PropTypes.func,\n\n /**\n * Render Copyright of the route scheduler.\n */\n renderCopyright: PropTypes.func,\n\n /**\n * Render delay for departure.\n */\n renderDepartureDelay: PropTypes.func,\n\n /**\n * Render Footer of the route scheduler.\n */\n renderFooter: PropTypes.func,\n\n /**\n * Render Header of the route scheduler.\n */\n renderHeader: PropTypes.func,\n\n /**\n * Function to render header buttons.\n */\n renderHeaderButtons: PropTypes.func,\n\n /**\n * Render the route identifier in the header\n */\n renderRouteIdentifier: PropTypes.func,\n\n /**\n * Render a station.\n */\n renderStation: PropTypes.func,\n\n /**\n * Render the status of the station image.\n */\n renderStationImg: PropTypes.func,\n\n /**\n * Render a station name.\n */\n renderStationName: PropTypes.func,\n\n /**\n * Trackerlayer.\n */\n trackerLayer: PropTypes.instanceOf(TrackerLayer).isRequired,\n};\n\n/**\n * RouteSchedule displays information, stops and punctuality about the clicked route.\n */\nfunction RouteSchedule({\n className = \"rt-route-schedule\",\n renderFooter = defaultRenderFooter,\n renderHeader = defaultRenderHeader,\n renderStation = defaultRenderStation,\n ...props\n}) {\n const { lineInfos } = 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, idx, stop });\n })}\n </div>\n {renderFooter({ ...props })}\n </div>\n );\n}\n\nRouteSchedule.propTypes = propTypes;\n\nexport default React.memo(RouteSchedule);\n"],
|
|
5
|
-
"mappings": "AACA;AAAA,EACE;AAAA,EACA,iBAAiB;AA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YAAY,OAAO;AAAA,EAC3B,WAAW,cAAc;AACvB,UAAM,KAAK,OAAO;AAAA,EACpB;AACA,SAAO,oCAAC,SAAI,KAAI,qBAAoB,WAAU,iBAAgB,KAAU;AAC1E;AAQA,MAAM,2BAA2B,CAAC,UAAU,OAAO,cAAc;AAC/D,QAAM,EAAE,YAAY,IAAI,SAAS,KAAK;AACtC,SACE,oCAAC,SAAI,WAAW,YAAY,uBAAuB,MAAK,WAAY;AAExE;AAUA,MAAM,qBAAqB,CAAC,OAAO,MAAM,gBAAgB,kBAAkB;AACzE,SACE,oCAAC,UAAK,OAAO,EAAE,OAAO,gBAAgB,OAAO,IAAI,KAAK,UAAU,KAC7D,GAAG,iBAAiB,OAAO,IAAI,KAAK,EAAE,EACzC;AAEJ;AAEA,MAAM,YAAY,MAAM;AAAC;AAEzB,SAAS,UAAU;AAAA,EACjB,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,qBAAqB;AAAA,EACrB,uBAAuB;AAAA,EACvB,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB;AAAA,EACA;AACF,GAAG;AACD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,YAAY,UAAU,uBAAuB,UAAU;AAC7D,QAAM,EAAE,SAAS,IAAI;AACrB,QAAM,iBAAiB,QAAQ;AAC/B,QAAM,gBAAgB,QAAQ,SAAS,SAAS;AAChD,QAAM,eAAe,UAAU,IAAI;AACnC,QAAM,CAAC,iBAAiB,kBAAkB,IAAI,SAAS,KAAK;AAE5D,YAAU,MAAM;AACd,QAAI,UAAU;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable react/no-unused-prop-types */\nimport {\n realtimeConfig,\n RealtimeLayer as TrackerLayer,\n} from \"mobility-toolbox-js/ol\";\nimport PropTypes from \"prop-types\";\n/* eslint-disable react/prop-types */\nimport React, { useEffect, useState } from \"react\";\n\nimport firstStation from \"../../images/RouteSchedule/firstStation.png\";\nimport lastStation from \"../../images/RouteSchedule/lastStation.png\";\nimport line from \"../../images/RouteSchedule/line.png\";\nimport station from \"../../images/RouteSchedule/station.png\";\nimport ReactTransitPropTypes from \"../../propTypes\";\nimport {\n getDelayString as defaultGetDelayString,\n getHoursAndMinutes,\n} from \"../../utils/timeUtils\";\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 defaultGetDelayColor = (time) => {\n const secs = Math.round(((time / 1800 / 2) * 3600) / 1000);\n if (secs >= 3600) {\n return \"rgb(237 0 76)\";\n }\n if (secs >= 500) {\n return \"rgb(232 0 0)\";\n }\n if (secs >= 300) {\n return \"rgb(255 74 0)\";\n }\n if (secs >= 180) {\n return \"rgb(247 191 0)\";\n }\n return \"rgb(0 160 12)\";\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 alt=\"routeScheduleLine\" className=\"rt-route-icon\" src={src} />;\n};\n\n/**\n * Returns an text.\n * @param {Number} stations The stations list.\n * @param {Number} index Index of the station in the list.\n * @param {Boolean} cancelled If the station is cancelled\n */\nconst defaultRenderStationName = (stations, index, cancelled) => {\n const { stationName } = stations[index];\n return (\n <div className={cancelled ? \"rt-route-cancelled\" : \"\"}>{stationName}</div>\n );\n};\n\n/**\n * Render a delay string.\n * @param {Number} delay The delay in ms to display.\n * @param {Boolean} stop The current stop object.\n * @param {Function} getDelayString Function to get string to display.\n * @param {Function} getColor Define the css color to use.\n *\n */\nconst defaultRenderDelay = (delay, stop, getDelayString, getDelayColor) => {\n return (\n <span style={{ color: getDelayColor?.(delay, stop) || \"inherit\" }}>\n {`${getDelayString?.(delay, stop) || \"\"}`}\n </span>\n );\n};\n\nconst emptyFunc = () => {};\n\nfunction RouteStop({\n getDelayColor = defaultGetDelayColor,\n getDelayString = defaultGetDelayString,\n idx,\n lineInfos,\n onStationClick = emptyFunc,\n renderArrivalDelay = defaultRenderDelay,\n renderDepartureDelay = defaultRenderDelay,\n renderStationImg = defaultRenderStationImg,\n renderStationName = defaultRenderStationName,\n stop,\n trackerLayer,\n}) {\n const {\n aimedArrivalTime,\n aimedDepartureTime,\n arrivalDelay,\n departureDelay,\n state,\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 isNotStation = isNotStop(stop);\n const [isStationPassed, setIsStationPassed] = useState(false);\n\n useEffect(() => {\n let timeout = null;\n const time = trackerLayer.time || trackerLayer.engine?.time || Date.now();\n\n const isStopPassed = isPassed(stop, time, stations, idx);\n setIsStationPassed(isStopPassed);\n\n // We have to refresh the stop when the state it's time_based\n if (stop.state === \"TIME_BASED\" && !isStopPassed) {\n timeout = setInterval(() => {\n setIsStationPassed(isPassed(stop, time, stations, idx));\n }, 20000);\n }\n return () => {\n clearInterval(timeout);\n };\n }, [stop, trackerLayer, stations, idx]);\n\n return (\n <div\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 onKeyPress={(e) => {\n return e.which === 13 && onStationClick(stop, e);\n }}\n role=\"button\"\n tabIndex={0}\n >\n <div className=\"rt-route-delay\">\n {arrivalDelay === undefined ||\n arrivalDelay === null ||\n isFirstStation ||\n cancelled\n ? \"\"\n : renderArrivalDelay(\n arrivalDelay,\n stop,\n getDelayString,\n getDelayColor,\n )}\n {departureDelay === undefined ||\n departureDelay === null ||\n isLastStation ||\n cancelled\n ? \"\"\n : renderDepartureDelay(\n departureDelay,\n stop,\n getDelayString,\n getDelayColor,\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 {renderStationName(stations, idx, cancelled)}\n </div>\n );\n}\n\nconst defaultRenderStation = (props) => {\n const { arrivalTime, departureTime, stationId, stationName } = props.stop;\n // eslint-disable-next-line react/jsx-props-no-spreading\n return (\n <RouteStop\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 // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n />\n );\n};\n\nconst defaultRenderRouteIdentifier = ({ longName, routeIdentifier }) => {\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) && !Number.isNaN(id)) {\n return ` (${id})`;\n }\n }\n return null;\n};\nconst defaultRenderHeaderButtons = () => {\n return null;\n};\n\nconst defaultRenderHeader = ({\n lineInfos,\n renderHeaderButtons = defaultRenderHeaderButtons,\n renderRouteIdentifier = defaultRenderRouteIdentifier,\n}) => {\n const {\n destination,\n longName,\n routeIdentifier,\n shortName,\n stroke,\n text_color: textColor,\n type,\n vehicleType,\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 defaultRenderLink = (text, url) => {\n return (\n <div className=\"rt-route-copyright-link\">\n {url ? (\n <a href={url} rel=\"noreferrer\" target=\"_blank\">\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> - </span>}\n {lineInfos.publisher &&\n defaultRenderLink(lineInfos.publisher, lineInfos.publisherUrl)}\n {lineInfos.license && <span> (</span>}\n {lineInfos.license &&\n defaultRenderLink(lineInfos.license, lineInfos.licenseUrl)}\n {lineInfos.license && \")\"}\n </span>\n );\n};\n\nconst defaultRenderFooter = (props) => {\n const { lineInfos, renderCopyright = defaultRenderCopyright } = props;\n if (!lineInfos.operator && !lineInfos.publisher) {\n return null;\n }\n return <div className=\"rt-route-footer\">{renderCopyright({ ...props })}</div>;\n};\n\nconst propTypes = {\n /**\n * CSS class of the route schedule wrapper.\n */\n className: PropTypes.string,\n\n /**\n * Function to get the delay color.\n */\n getDelayColor: PropTypes.func,\n\n /**\n * Function to get the delay string for stations.\n */\n getDelayString: PropTypes.func,\n\n /**\n * Trajectory stations informations.\n */\n lineInfos: ReactTransitPropTypes.lineInfos,\n\n /**\n * Function triggered on station's click event.\n */\n onStationClick: PropTypes.func,\n\n /**\n * Render delay for arrival.\n */\n renderArrivalDelay: PropTypes.func,\n\n /**\n * Render Copyright of the route scheduler.\n */\n renderCopyright: PropTypes.func,\n\n /**\n * Render delay for departure.\n */\n renderDepartureDelay: PropTypes.func,\n\n /**\n * Render Footer of the route scheduler.\n */\n renderFooter: PropTypes.func,\n\n /**\n * Render Header of the route scheduler.\n */\n renderHeader: PropTypes.func,\n\n /**\n * Function to render header buttons.\n */\n renderHeaderButtons: PropTypes.func,\n\n /**\n * Render the route identifier in the header\n */\n renderRouteIdentifier: PropTypes.func,\n\n /**\n * Render a station.\n */\n renderStation: PropTypes.func,\n\n /**\n * Render the status of the station image.\n */\n renderStationImg: PropTypes.func,\n\n /**\n * Render a station name.\n */\n renderStationName: PropTypes.func,\n\n /**\n * Trackerlayer.\n */\n trackerLayer: PropTypes.instanceOf(TrackerLayer).isRequired,\n};\n\n/**\n * RouteSchedule displays information, stops and punctuality about the clicked route.\n */\nfunction RouteSchedule({\n className = \"rt-route-schedule\",\n renderFooter = defaultRenderFooter,\n renderHeader = defaultRenderHeader,\n renderStation = defaultRenderStation,\n ...props\n}) {\n const { lineInfos } = 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, idx, stop });\n })}\n </div>\n {renderFooter({ ...props })}\n </div>\n );\n}\n\nRouteSchedule.propTypes = propTypes;\n\nexport default React.memo(RouteSchedule);\n"],
|
|
5
|
+
"mappings": "AACA;AAAA,EACE;AAAA,EACA,iBAAiB;AAAA,OACZ;AACP,OAAO,eAAe;AAEtB,OAAO,SAAS,WAAW,gBAAgB;AAE3C,OAAO,kBAAkB;AACzB,OAAO,iBAAiB;AACxB,OAAO,UAAU;AACjB,OAAO,aAAa;AACpB,OAAO,2BAA2B;AAClC;AAAA,EACE,kBAAkB;AAAA,EAClB;AAAA,OACK;AAEP,MAAM,EAAE,WAAW,IAAI;AAMvB,MAAM,uBAAuB,CAAC,SAAS;AACrC,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,MAAM,CAAC,KAAK,MAAM,GAAG;AAC7B,aAAO,SAAS,MAAM,MAAM,CAAC,GAAG,MAAM,OAAO,GAAG;AAAA,IAClD;AACA,WAAO;AAAA,EACT;AAGA,QAAM,gBAAgB,KAAK,sBAAsB,KAAK,oBAAoB;AAC1E,MAAI,iBAAiB,KAAK,kBAAkB,KAAK,gBAAgB;AAGjE,MAAI,iBAAiB,GAAG;AACtB,qBAAiB;AAAA,EACnB;AAEA,S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AAA;AAAA,EAKxB,cAAc,UAAU;AAAA;AAAA;AAAA;AAAA,EAKxB,qBAAqB,UAAU;AAAA;AAAA;AAAA;AAAA,EAK/B,uBAAuB,UAAU;AAAA;AAAA;AAAA;AAAA,EAKjC,eAAe,UAAU;AAAA;AAAA;AAAA;AAAA,EAKzB,kBAAkB,UAAU;AAAA;AAAA;AAAA;AAAA,EAK5B,mBAAmB,UAAU;AAAA;AAAA;AAAA;AAAA,EAK7B,cAAc,UAAU,WAAW,YAAY,EAAE;AACnD;AAKA,SAAS,cAAc;AAAA,EACrB,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,GAAG;AACL,GAAG;AACD,QAAM,EAAE,UAAU,IAAI;AAEtB,MAAI,CAAC,WAAW;AACd,WAAO;AAAA,EACT;AAEA,SACE,oCAAC,SAAI,aACF,aAAa,EAAE,GAAG,MAAM,CAAC,GAC1B,oCAAC,SAAI,WAAU,mBACZ,UAAU,SAAS,IAAI,CAAC,MAAM,QAAQ;AACrC,WAAO,cAAc,EAAE,GAAG,OAAO,KAAK,KAAK,CAAC;AAAA,EAC9C,CAAC,CACH,GACC,aAAa,EAAE,GAAG,MAAM,CAAC,CAC5B;AAEJ;AAEA,cAAc,YAAY;AAE1B,eAAe,MAAM,KAAK,aAAa;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import OLControl from "ol/control/Control";
|
|
2
|
-
import OLMap from "ol/Map";
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
import React, { useEffect, useRef } from "react";
|
|
5
|
-
const propTypes = {
|
|
6
|
-
/**
|
|
7
|
-
* The class of the control to be created.
|
|
8
|
-
*/
|
|
9
|
-
ControlClass: PropTypes.instanceOf(OLControl),
|
|
10
|
-
/**
|
|
11
|
-
* ol/map.
|
|
12
|
-
*/
|
|
13
|
-
map: PropTypes.instanceOf(OLMap).isRequired,
|
|
14
|
-
/**
|
|
15
|
-
* Options for ol/control/Control.
|
|
16
|
-
* See https://openlayers.org/en/latest/apidoc/module-ol_control_ScaleLine-Control.html
|
|
17
|
-
*/
|
|
18
|
-
options: PropTypes.object
|
|
19
|
-
};
|
|
20
|
-
const defaultProps = {
|
|
21
|
-
options: {}
|
|
22
|
-
};
|
|
23
|
-
function Control({
|
|
24
|
-
ControlClass,
|
|
25
|
-
map,
|
|
26
|
-
options = defaultProps.options,
|
|
27
|
-
...other
|
|
28
|
-
}) {
|
|
29
|
-
const ref = useRef();
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
const control = new ControlClass({
|
|
32
|
-
...options,
|
|
33
|
-
...{ target: ref.current }
|
|
34
|
-
});
|
|
35
|
-
map.addControl(control);
|
|
36
|
-
return () => {
|
|
37
|
-
map.removeControl(control);
|
|
38
|
-
};
|
|
39
|
-
}, [ControlClass, map, options]);
|
|
40
|
-
return /* @__PURE__ */ React.createElement("div", { ref, ...other });
|
|
41
|
-
}
|
|
42
|
-
Control.propTypes = propTypes;
|
|
43
|
-
export default React.memo(Control);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/Control/Control.js"],
|
|
4
|
-
"sourcesContent": ["import OLControl from \"ol/control/Control\";\nimport OLMap from \"ol/Map\";\nimport PropTypes from \"prop-types\";\nimport React, { useEffect, useRef } from \"react\";\n\nconst propTypes = {\n /**\n * The class of the control to be created.\n */\n ControlClass: PropTypes.instanceOf(OLControl),\n\n /**\n * ol/map.\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * Options for ol/control/Control.\n * See https://openlayers.org/en/latest/apidoc/module-ol_control_ScaleLine-Control.html\n */\n options: PropTypes.object,\n};\n\nconst defaultProps = {\n options: {},\n};\n\n/**\n * The Control component creates an\n * [ol/control/Control](https://openlayers.org/en/latest/apidoc/module-ol_control_ScaleLine-Control.html)\n * for an [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nfunction Control({\n ControlClass,\n map,\n options = defaultProps.options,\n ...other\n}) {\n const ref = useRef();\n\n useEffect(() => {\n const control = new ControlClass({\n ...options,\n ...{ target: ref.current },\n });\n\n map.addControl(control);\n return () => {\n map.removeControl(control);\n };\n }, [ControlClass, map, options]);\n\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <div ref={ref} {...other} />;\n}\n\nControl.propTypes = propTypes;\n\nexport default React.memo(Control);\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,OAAO,eAAe;AACtB,OAAO,SAAS,WAAW,cAAc;AAEzC,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,cAAc,UAAU,WAAW,SAAS;AAAA;AAAA;AAAA;AAAA,EAK5C,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMjC,SAAS,UAAU;AACrB;AAEA,MAAM,eAAe;AAAA,EACnB,SAAS,CAAC;AACZ;AAOA,SAAS,QAAQ;AAAA,EACf;AAAA,EACA;AAAA,EACA,UAAU,aAAa;AAAA,EACvB,GAAG;AACL,GAAG;AACD,QAAM,MAAM,OAAO;AAEnB,YAAU,MAAM;AACd,UAAM,UAAU,IAAI,aAAa;AAAA,MAC/B,GAAG;AAAA,MACH,GAAG,EAAE,QAAQ,IAAI,QAAQ;AAAA,IAC3B,CAAC;AAED,QAAI,WAAW,OAAO;AACtB,WAAO,MAAM;AACX,UAAI,cAAc,OAAO;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,cAAc,KAAK,OAAO,CAAC;AAG/B,SAAO,oCAAC,SAAI,KAAW,GAAG,OAAO;AACnC;AAEA,QAAQ,YAAY;AAEpB,eAAe,MAAM,KAAK,OAAO;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./Control";
|